Miklb's Mindless Ramblings

chronicling life in a digital world

URL Shorteners, HTTP Referers and 301 Redirects

I’ll start by saying I don’t know much about the subject, but am posting this in the hopes that someone who does can elucidate the issue. My basic dilemma is that I have a short bit of code on my single page templates that checks to see if a visitor is from Twitter, and if so, show a little message. (Not an original idea, I think I saw it on a post at Smashing Magazine). The code they used didn’t work, but with the help of BigJibby in the Habari IRC channel, I was able to get it working with Habari.

I more or less forgot about it, until a few people noticed it and asked if it was a plugin. When I replied it wasn’t, they asked if I could make it into one. So it went into a to-do list I keep of Habari related ideas. This evening I began working on it, and while troubleshooting how to actually output something to the entry single template (that’s a whole other can of worms), I discovered the code snippet wasn’t working. With the help of Michael, we discovered the problem wasn’t with the code snippet, rather it was with the URL shorteners. Twitter recently started defaulting to Bit.ly, and I recently began experimenting with Tr.im, both of which weren’t sending twitter.com as the referrer. Rather, due to their 301 redirect they return NULL. Which in a nut shell sucks.

Somehow Google Analytics is able to track referrals from Twitter, as last week when I had a huge upsurge in traffic from the popularity of the Infinite Summer Bookmarks, I’m seeing 50 visitors from Twitter the first day (of the 785, by far a record for this little weblog).

At this point, finishing the plugin seems moot, as the only way to be sure that visitors will actually see the message would be to use a URL shortener that doesn’t return NULL, of which, the only one we found that to not be the case was Owen’s Pastoid. I didn’t test Tinyurl, nor was I interested in looking for others. The disappointment had already set in. Besides that, if you are auto posting to Twitter with a plugin, you wouldn’t have the option to use a different shortener.

So kind readers/stumble-uponers, if anyone has a solution to this problem, please enlighten me. Meanwhile, I’ll work out the issue with Habari and my desire to output content on a single entry template within the content output, not above the body tag.

For anyone interested in the snippet of code I am using:

if ( parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST) == 'twitter.com' ) { echo "<h2 class='twittervisit'>Welcome, Twitter visitor! If this post is useful, don't hesitate to retweet!</h2>";

Alternative Icon for Shredder

FIXED Thanks to Michael for pointing out the broken link on the download. Now fixed.

Mail_TB_web.pngYesterday over at Hawk Wings they posted an entry on how to roll your own custom Mail.app icon, with a link to a .psd template. I personally don’t use Mail.app, rather I’ve been running the nightly build of Thunderbird 3 for quite some time. The nightly is actually called Shredder and is, quite possibly, the worst icon in the world, so when I saw the Hawk Wings post, I jumped at the chance to customize my icon.

I’m not sure anyone else would care to change their icon up, but you can download my alternate Thunderbird icon. Hawk Wings has a link in that post on how to change icons in Mac OS X for those new to Mac.

Infinite Summer Bookmarks

I’m horrible when it comes to reading books and novels. I think it stems from when I began cooking professionally and worked a crazy amount of hours, leaving me with very little free time. What free time I did have was either spent in a bar, or reading cookbooks and trade publications to further my knowledge base. However, it also meant I got away from reading fiction in any form. Today, my reading is solely relegated to reading online, and non-fiction for the most part.

This summer however, that changes. I’m not even sure how I came across it, but a few people put together the idea of collectively reading ( a book club if you will) Infinite Jest, by David Foster Wallace. Infite Summer is really a brilliant idea, and just another example of some of the great things about the internet and “social media”.

I’ll be reading along with everyone else, as well as with my fiancée. We ordered our copies a few weeks ago, and it’s been tough to not get started, but one of the premises of Infinite Summer is 75 pages a week, with discussion along the way (the book is 1000 pages, which is how the 75 pages a week idea came about—breaking the book into digestible chunks). The site will have guest writers as well as a forum, so I really wanted to follow the guide. The reading is to start Sunday, which brings me to the whole point of this post.

The “official” schedule was posted on Monday, that is, what page number corresponded with each ending week. It also will mark the cut off for “spoilers”. Nothing beyond that page will be discussed in the posts or in the general discussion area. They followed up with a post How to Read Infinite Jest, which recommends using bookmarks, several of them.

So I got the idea to make bookmarks. My fianceé was looking for a way to save the schedule without having to check back to the website, so I figured putting it on the bookmark would be convenient. A quick Google search turned up Stephen LeQuier’s 2009 Photoshop calendar template. A few modifications later, along with some simple graphics to match the Infinite Summer logo (which itself is a play on one of the edition’s cover), and I had myself a handy bookmark.

I’ll be the first to say I’m not a print designer (some would argue I’m not a designer at all), so apologies in advance if the quality isn’t the finest. My printer is in need of ink, so I’ve only done some tests to make sure the size would be OK. But I’m thinking that printed on some heavy paper or card stock would be sufficient to allow them to last the 3 months they’ll be in use.

I’m offering 2 downloads, both in .pdf format. A single version that might be able to be opened in PS with the layers intact, and a version with 5 on it. Why 5? Well, the guide to reading suggests multiple bookmarks, and well, I was able to fit 5 on a page.

Anyway, perhaps others will find them useful.

Download the single bookmark file..

Download the multiple bookmark file.

If you have any problems with the download, or the .pdf, leave a comment and I can see about offering other formats like .jpg.

Oh, and if you haven’t already planned to join the Infinite Summer, it’s not too late to get to the book store and read along with the rest of us.

UPDATE Matthew contacted me and reminded me that in the reading guide, there’s a pivotal point in the book on page 223. (No, I followed the guide and didn’t turn to the page to read it!) What ever is contained within that page is apparently something that the reader will need to refer back to often and he asked if I could update the bookmark once we reach that point in the schedule, which is July 13th. So on July 13th, check back for an updated copy of the bookmark for your main page that will contain that information. I’ll remove the June calendar to make room, Matthew says the information is quite brief.

Thank you for all who’ve commented so far, I’m quite happy to see so many people interested in the bookmarks and participating in Infinite Summer.

Also, I’ll be writing up a post on how I’m using Evernote to organize my thoughts and keep notes as I read.

Troubleshooting MAMP and Time Machine

Time MachineWell, it’s taken me what seems like forever, but I finally determined that MAMP has been the cause of all of my Time Machine woes. Basically Time Machine would get to a certain point, in my case it was around 29 GB, and simply stall, not allowing me to stop the backup process. I would basically have to restart the machine to get it to stop. I originally thought it was a problem with the formatting of the external drive, however I’d done all of the troubleshoot tips I’ve found on the web, to no avail. Finally let me say, I’m not a Unix expert, nor am I that well versed in file permissions. I know just enough to get myself in trouble, but I believe I understand this problem well enough at this point that I thought sharing my discoveries might help someone else avoid a similar headache.

In a nut shell, it seems that by default MAMP’s Apache instance doesn’t set a group owner for files created by the Apache server. Time Machine chokes on these files, which results in a stalled backup. After much Googling, I came across this blog post about MAMP Pro and Time Machine. I then used the Time Machine options to exclude the directory that I created for my document root (I believe MAMP defaults to /Users/foo/Sites/). Excluding my MAMP directory allowed Time Machine to completely backup my system. In the aforementioned blog post about MAMP Pro, it appears there is a preference pane in the pro version to choose your user/group for the Apache server. The free version of MAMP doesn’t offer this same preference, so I had to do a bit more digging.

What I found was that in the Apache httpd.conf file, around line 327, the group was indeed not set, rather it read “Group #-1”. From what I understand of the Apache .conf file, using the # comments out what ever follows, which is why the cache files were being created as an unknown group, or “nogroup” as the post calls them.

I solved my issue by:

  • changing “Group #-1” to “Group _www” on line 327 of the Apache httpd.conf found in Applications/MAMP/conf/apache
  • moving all the cache files that the Apache server had created in my MAMP document root to the trash
  • restarting Apache in MAMP (there’s actually no “restart”, you have to stop, then start the servers)
  • removing the MAMP directory exclusion from the Time Machine options

By all means, if there is any misinformation in this post, or you can shed further light on the subject, please leave a comment, as I would like to fully understand the issue, and as I said, the information might be helpful to others, as I haven’t found much on the subject in my searches.

Dark Nova: Space Trader for the iPhone

I spent countless hours playing Space Trader on my Handspring Visor, and don’t ask me why, but it was one of the first games I looked for when I visited the App Store. At the time, there wasn’t a single option, though I had run across a blog post somewhere saying that a port was coming. For one reason or another, I started poking around the App Store last night, and did a “power search” for Space Trader. Lo and behold, there it was. However, after a glance at the reviews, the $1.99 app got nothing but panned for not being a true port of the original. (The original game is licensed GPL, source code available on Pieter’s site.)

However, in the search results, Dark Nova showed up. Currently a free download, I grabbed a copy and damned if it isn’t exactly what an iPhone port of Space Trader should be. Even the author of the original Palm version was “truly impressed”.

For those not familiar with Space Trader, it’s quite a complex game with the goal of amassing enough money to buy a moon and retire. In addition to trading commodities (including running guns and drugs), players have the option of going rogue and playing the role of space pirate. However, running illegal cargo and pirating will bring about the wrath of the space police.

Now excuse me, I’ve got some trading to do…

Oh, and I’d love to see a screenshot of a Palm Pre running the original with the PalmOS emulator! That would be a hoot.