Archive for uncategorized

PHP command line mode detection

23 August 2007

Use a block like this in PHP code to detect whether or not it's running in command line mode as opposed to web server script mode.

// if $_ENV['SHELL'] exists, we're probably in command line mode
if (array_key_exists('SHELL', $_ENV)) {
$this->setOutputMode(MYSQLICIOUS_OUTPUT_CMD);
} else {
$this->setOutputMode(MYSQLICIOUS_OUTPUT_HTML);
}

iPhone, Apple Store thoughts

6 August 2007

I spent some time in the Apple Store at the Pentagon City mall in Virginia yesterday, and I played with the iPhone for about 20 minutes before I became absolutely sick of it. So it didn't surprise me to read iPhone sucks buy Blackberry stock (via Scoble). I found the touch screen keyboard on the iPhone unusable. And I play piano and guitar -- I know how to control my fingers! Ironically, I think the touchscreen on my old Palm Zire was more accurate. I use my Blackberry way too often to even consider the productivity crippling interface of the iPhone. So, after having tried the iPhone, I'm amazed at the mostly rave reviews it's gotten.

But what really shocked me was that this particular Apple Store has no checkout registers.

I originally went into the store to buy a new protective sleeve for my iPod. It took me about five minutes to look through the different sleeves and choose one that looked about right. But then I wandered the small store for a few minutes before I assured myself that I was not daft, there really were no registers.

So, I flagged down the only employee in the store who was not attending to a customer, and he told me any employee in a green shirt could ring up my purchase -- except, apparently him, because he immediately turned his back on me and took off in the opposite direction.

After about five minutes of trying to get a Green Shirt's attention, I was ready to walk out. But finally, one Green Shirt (who evidently was too busy shooting this shit with his friend) directed another Green Shirt to ring me up. Here's what that consisted of:

  1. Green shirt scans my item with a Symbol handheld register
  2. Register crashes because it can't get a wireless signal
  3. Green shirt disappears to get another register
  4. Green shirt reappears, rescans my item
  5. Green shirt swipes my credit card
  6. Green shirt swipes my credit card
  7. Green shirt swipes my credit card
  8. Green shirt rescans my item (I swear I am not making this up)
  9. Green shirt disappears to get a bag for my item
  10. Green shirt reappears with a bag
  11. Green shirt walks to the completely opposite side of the store to pick up my receipt
  12. Green shirt returns and finally I am free to go

Wow....

I'm #1 (too)

4 August 2007

Wow!
Yabfog #1
[via Dave]

My Link Blogs

25 July 2007

Finally have a bunch of my link blogs posted. A little explanation, though.

First, this is an OPML file, generated by NewsGator, filtered through sed, and displayed by Optimal.

Second, I maintain these link blogs in FeedDemon and my own aggregator built on the NewsGator API.

As of the latest version (ver. 2.5), FeedDemon automatically syncs your "News Bins" with your NewsGator "Clippings Folders" -- two terminologies for the same thing. They really ought to pick a name. In any event, now that I've set it up, these should self-maintain without any additional work on my part. That's what programming is all about!

Juice-y Python

21 June 2007

I use Juice to manage my podcasts. But it doesn't do everything I need, and it's a little buggy, and I want to learn Python anyway. So I decided to download the latest source code and see if I could fix some of the bugs I've noticed and figure out how to extend it to do everything I need.

So step one was just getting to a point where I could compile it. The source code documentation is incomplete, so here's what I did, starting from scratch.

  1. Install Python 2.5.1
  2. Install pywin32 (I'm on Windows)
  3. Install mfc71.dll (needed by pywin32)
  4. Install py2exe (needed to compile Python source code to executable bytecode)
  5. Install wxPython (for the gui)
  6. Install pysqlite (may not be necessary, but I knew I'd need it eventually)
  7. Install NSIS (Nullsoft Scriptable Install System)
  8. Install NSIS FindProcDLL plug-in

PHEW!

Juice v.2.2.3.djm After all of that, it was actually fairly easy to build and install. However, I made the mistake of trying to upgrade the Universal Feed Parser, only to find that although Juice would still compile, install and run, it was silently crapping out while trying to read feeds so it would not actually update my podcasts. I reverted back to the version of UFP bundled with Juice and everything was fine (except for the UFP bugs I was hoping to have solved by using a later version, of course).

I should update this as things progress.

Quick WordPress Upgrading

21 June 2007

Note to self:

Grab a unified diff of the new version versus the old version:
svn diff -r HEAD --old http://svn.automattic.com/wordpress/tags/<old_version> \
--new http://svn.automattic.com/wordpress/tags/<new_version>

Apply the changes to the current installation:
patch -d <path_to_wp_install> -u -i <patchfile>

Leash and Feedparser

3 June 2007

Maybe I'll write up something a little more formal in the future. For now, I just want to publish this in case it's useful to someone.

Les Orchard posted a blurb that indicated that he was looking for a PHP class to perform HTTP requests with conditional GET support. Well, a while ago I was looking for that, too. Because I was working on a replacement for Magpie RSS (see below), I decided to use Snoopy as my HTTP client. I then wrote a brief extension, Leash, to provide a cache-enabled front end to Snoopy. Leash automatically caches the HTTP results, the time of the request, and the Last Modified and Etag HTTP headers. When you request a page you've previously requested, Leash first checks to see if the cached copy is older than the maximum cache age you've specified (or the default of 1 hour), and if the cache is too old, Leash performs a conditional GET. The latest version of Leash (which I bundle with Snoopy) is in my Subversion repository.

Also in that repository is my replacement for Magpie RSS. I always liked Magpie, but it didn't quite work for me and I also wanted an OPML parser. So I wrote one. Actually, first I wrote a generic PHP XML parser. Then I wrote the OPML parser and Feed parser.

Sorry, but I currently don't have time for documentation. Or support. That probably makes this of very limited utility to all but the most daring. If you're a PHP junkie, you'll probably be able to peruse the code and get the gist. And here's an example of how I'm using it to help manage my podcasts.

WordPress and JavaScript Hijacking

13 April 2007

I read this paper that Bruce Schneier linked to regarding JavaScript hijacking. Seems to me that WordPress plugin developers who piggyback on WordPress's builtin security features shouldn't have anything to worry about.

Judging from what little buzz there was, I think that's probably true, but I'm interested in others' thoughts.

Yikes! WordPress Hacked!

2 March 2007

The WordPress crew have announced that the WordPress 2.1.1 download got cracked by an unnamed attacker who injected some code that would allow remote code execution. I'm glad I haven't upgraded!

Done

28 February 2007

I'm remapped. That was like a flashback to elementary school, getting called out by the teacher in front of the whole class! :oops:

Thanks, Dave.