Archive for August, 2010

Build your own URL shortener

Monday, August 30th, 2010
There are a lot of URL shorteners out there such as bit.ly, tinyurl.com, is.gd, tiny.cc. The list of services is large. For those of you that don’t know what a URL shortener is, it’s a piece of software that converts very long URLs such as:

http://www.blyon.com/blog/index.php/2010/08/28/build-your-own-url-shortener

Into: http://blyon.com/?efa

This make the URL easy to cut and paste and reduces the characters you use for things such as Twitter.

I’ve been using TinyURL.com for ages. This morning I wondered to myself, “why not just use blyon.com?” After all, the domain is shorter than TinyURL by 3 characters and if it’s just me using my service the hash only needs to be about 3 characters long because I am not storing millions of URLs. Other services use a long hash (7+ characters) because they need more unique ways to identify URLs.

It took all of 30 minutes to write the code, and maybe another 30 to debug it.

Here’s how it works and how to setup your own!

Go to http://www.blyon.com/t to input the URL and get the short URL which uses http://blyon.com/? as the base. There’s a simple PHP script inside /t/ which creates the hash and puts it into a two table MySQL database. I used /t/ just because I already had something at the root of blyon.com.

I added another snippet of code on blyon.com’s index.php page which figures out if someone is trying to lookup a hash or not. If it finds a hash that’s valid, it does a 302 redirect to the right location. The 302 redirect is an easy location director built right into HTTP, so basically you’re telling a browser that goes to the short URL to go somewhere else.

Now, why do this? For starters I was trying to wake up and wanted to have something to do while drinking coffee (the NPR stream was down). However, there may be a lot of SEO reasons to do this. For one, all my links I post are linked back to blyon.com, which means if something I tweet goes around the block a few times, it will all point back at blyon.com. Taking this one step further might mean that I should also allow for special keywords to be created, thus helping google learn indexicals that I want valued for my web site. The third great reason to do this (besides keeping oneself busy while drinking coffee) is to maintain your own links. If TinyURL goes down someday, everything you have ever linked to will stop working as well. However, who’s to say your (or my) admin skills are better than theirs.

Anyway, here’s the code!

The entire package as a tar: redir.tar.gz

To create the TinyURL you need this PHP code (my /t/ index page): index.php

The database include code: dbconfig.php

To figure out if a request is for your main index page or a shortened URL: mainindex.php

The MySQL database you’ll need: redir.mysql

PS: Thanks to Nathan Hickson for helping me debug this.

Get the iPhone4 on to T-Mobile

Wednesday, August 4th, 2010
Finally! The iPhone4 can be carrier unlocked, which means you can put the phone on any GSM network you would like! It feels great to enjoy freedom from the clutches of AT&T — their data services are over priced, their customer service is awful, their contracts and plans are nearly fraudulent, they opt-in to governmental monitoring, and to top it off their network barely works in most major markets. The alternative I prefer is T-Mobile. T-Mobile’s Edge service is not the fastest in the world but at least it works and is more reliable in the markets I use it in.

Here is a step-by-step instruction set to migrate your iPhone4 from AT&T to T-Mobile.

Step 1: The Micro SIM

Engadget published an article on how to create your own Micro SIM from your old SIM, however, it is missing a bunch of details:

First, there are several types of SIM cards that are out there in the wild. T-Mobile has two which are interchangeable. One of them will not work as a Micro SIM because it has connectors which are too wide. If you try to modify one of the older types you’ll end up destroying the SIM card and be left with nothing.

You can go to a T-Mobile store and buy a new SIM for $20. What you need is a 39.01a type SIM (shown in the picture) which is thinner and has smaller electrical contacts than the older types. [If anyone has more detail on the differences between the different SIM cards, please let me know and I will update the article to make this more clear.]

The SIM itself is the metal contact portion of the card, so what you’ll need to do is cut the plastic of the SIM to fit inside the iPhone SIM cradle.

Removing the actual sim is very easy, just get a staple and fold it out a bit and push it solidly into the center hole located on the side of the phone. The SIM cradle will pop free. Pull out the old ugly nasty AT&T SIM and use it as a template for the new T-Mobile SIM card.
Do your best to align the metal contact area on the T-Mobile SIM with the existing AT&T Micro SIM, pay close attention to orientation of the notch cut into the SIM cards, keep those in the same direction. If you have the right SIM style, it’s pretty easy, you really just need to align the SIM as closely as possible.

When cutting out the SIM, do not initially use scissors — doing so will put a lot of stress on the SIM itself and if you hear a “crunch” noise you’re destroying the SIM. I used a knife to cut out the SIM and a very sharp set of scissors to trim it in order to get it to fit into the iPhone4 SIM cradle.

Make sure that there’s no protruding shards of plastic, if there are, you may have a very hard time removing your SIM card.

Step 2: Jailbreak

This step is pretty simple. Using your iPhone4 (connected to wifi or some network) browse to www.jailbreakme.com and follow their really simple instructions to jailbreak the phone. Once the phone is jailbroken, you can move on to further steps.

If you find you can’t “slide to jailbreak” you may need to factory reset your phone using iTunes. I had to factory reset because apparently the www.jailbreakme.com site needs a fresh install.

If you run into problems or want to know more about this process, follow the direction on http://blog.iphone-dev.org/

Step 3: Carrier Unlock

There will be a new application on your iPhone desktop called Cydia, just open Cydia, allow it to upgrade itself (upgrading the packages ensure you get the most current packages). Search for the application ultrasn0w and install ultrasn0w. Once it is installed, you will be prompted to reboot the phone.

Before you do this, please take the time to visit the Dev-Team Blog to read more about their work and possibly give them a donation to help them with further efforts.

They also have much better and in-depth tutorials on Unlocking and Jailbreaking phones.

Step 4: Swap the SIM

After the phone has rebooted, make sure the phone activates and is functioning before you swap the old AT&T sim out with the new T-Mobile SIM.

Step 5: MMS and Internet setup

Make sure you have a data plan with T-Mobile, they have an unlimited service available which can be ordered by asking for the Blackberry data service. That will come with SMS and MMS services as well.

First you need to re-enable your data plan and MMS, you can do that by going to Settings -> General -> Network -> Cellular Data Network and enter the following:

Cellular Data:

APN: wap.voicestream.com
Username: [do not put anything]
Password: [do not put anything]
MMS

APN: wap.voicestream.com
Username: [do not put anything]
Password: [do not put anything]
MMSC: 216.155.174.84/servlets/mms
MMS Proxy 216.155.165.50:8080
MMS Max Size: [do not put anything]
MMS UA URL: [do not put anything]
Internet Tethering

APN wap.voicestream.net
Username: [do not put anything]
Password: [do not put anything]

Step 6: Canceling your AT&T contract

Dial customer support at 1-800-331-0500, enter your old phone number that was on the old AT&T SIM. Wait to get a customer service person on the phone and tell them you are moving to Spain or somewhere like Brazil and ask to cancel the service. By telling them you’re leaving the country they’ll give you 60 days to re-activate service.

If you have the time, throw a fit and tell them you never signed a physical contract. Just sit back and demand they find your signature and the AT&T cancellation person will actually call the Apple store where you bought the phone. It will at least cost AT&T some money for the hour they will spend digging around for your information.

**Tip For Jailbreakers: Buy the phone under contract and sign “Apple Store Sales Person” when you agree to the contract. Then sing your real name on the bill itself. That will result in no termination fees because you can contest you never signed the contract! (I know it’s evil but so is AT&T)

Problems: Facetime

T-Mobile apparently does not have support for Facetime. I’ve tried a few different methods to get it to register while on T-Mobile but no luck yet. This is all so fresh that I am sure there will be a patch to re-enable it soon. I will update this post when there is a method to update the phone to enable Facetime.