Jan/120
iOS Icon Template for Illustrator
I’ve had the need to calculate iOS icon corner radiuses and insets on several occasions, so I thought I’d create an Illustrator template for them. The template includes icons for iTunes, iPhone (Standard and Retina Display), and iPad, based on the dimensions I found in this stackoverflow question. Each icon has guides representing the corner rounding mask that Apple automatically applies, as well as 15%, 20% and 25% artwork insets within that boundary.
Here’s the template.
Jan/120
iPad Video Playlist Alternative
I recently bought my son the Audio + Video version of They Might Be Giants “Here Comes Science” on iTunes. It includes a video for each song, about 40 minutes in total. When played from iTunes it’s a continuous stream; as one clip finishes the next starts automatically. I was hoping it would work the same way on the iPad, but unfortunately it doesn’t. There it stops after each clip and returns you to the main screen where you have to manually start the next. Not great for a 1 year old.
I found this blog post, which suggests that you workaround this by converting the videos into episodes of a TV season. That seems like it would work, but it’s kind of a pain since it requires you to make the change in iTunes on a computer, then sync the videos back to the iPad.
After a little more searching, I found an iPad app called Video Playlist. It’s not ideal since you have to play the videos from within it rather than the built in Videos app, but it does work. Hopefully Apple will provide native support for this at some point, but in the mean time Video Playlist does the trick.
Jan/121
FMDB like condition with bind parameters
I’m working on an iOS project that uses the FMDB SQLite wrapper. I was trying to write a query with like condition and bind parameter, and it wasn’t returning any results. For example:
SELECT * FROM stuff WHERE name LIKE '%?%'
It turns out that this is because %?% is being treated as a string literal since it’s inside single quotes. To workaround this, you just need to build the condition using the ANSI SQL concatenation operator (||), just like if you were concatenating a String. For example:
SELECT * FROM stuff WHERE name LIKE '%' || ? || '%'
Jan/120
Switching Xbox 360 from 480p to HD mode
I bought an Xbox 360 for Christmas, and while setting it up I was kind of disappointed to find that my only display option was 480p. As it turns out, you can switch to HD mode, but it requires that you replace the included Composite cable with a Component or HDMI cable.
Microsoft offers a Component cable, which has an Xbox 360 AV connector on one end, and Component (Red, Green, Blue, Yellow, Red, White) connectors for audio and video on the other end. Newer Xbox 360 models also include an HDMI port, and you can connect them directly to your TV with a standard HDMI cable. The HDMI cable will send both video and audio to your TV, but you can also send audio through to your stereo or home theatre with a separate AV audio cable.
Once you have your cable connected, go to Settings > System > Console Settings > Display > HDTV Settings from the home screen. You should now see options for 720p, 1080i and 1080p (some may be disabled depending on your TV capabilities). If you went with the Component option, and you still don’t see anything but 480p, make sure that the TV / HDTV switch on the cable is set to HDTV.
Jan/122
Otterbox Defender for iPhone 4 Review
I’ve never been easy on my iPhones, and now that I have a 15 month old son whose favorite toys are iDevices, things have just gotten worse. Even still, my iPhones have always remained relatively unscathed, until now.
I bought my iPhone 4 back on release day in June 2010. For my previous iPhones, I’ve always gone case-free, but I decided to try one when Apple gave them away for free after antenna gate. I selected the Incase Snap Case, which I really liked based on its slim profile, and because it actually made the phone more comfortable to hold. I really liked the Snap Case, and have used it for a year and a half, but the downside is that it really doesn’t provide much protection for the front glass.
Even still, my iPhone had survived hundreds of drops on all kinds of surfaces until about 3 months ago when I got a tiny crack in the bottom corner of the screen. The crack was hardly visible, but it did make the lower area of the screen less touch sensitive, which was a bit of an annoyance. I had planned to live with this until my AT&T contract expires in 2012, but last week I dropped the phone face down on the sidewalk, which took care of the glass for good.
Fortunately, Apple was willing replace it for $150, even though I hadn’t purchased the extended AppleCare coverage (very cool of them). Now I’m hoping to keep the new phone in good condition so that I can resell it when the 2012 iPhone comes out.
In discussing more protective cases, a co-worker suggested the Otterbox Defender. My initial impression was that it was too bulky, but it did seem very protective, so I thought I’d give it a try. Amazon offers several different color options which range from $20-$25, and I decided to go with the Black and White one.
I received the Otterbox today, and it definitely is much more bulky than my old case. The additional thickness doesn’t cause the phone to feel much different in my pocket, which was my primary concern. With the case on, the iPhone sits within a hard plastic shell, which is then wrapped in an outer rubber covering. Both the front and back glass are inset well inside the plastic case, very well protected from impact. The rubber covering is texturized, and gives the iPhone a ruggedized look and feel. The plastic case has a screen cover built in, which I also didn’t think I’d like. After using it for the day, I’ve almost completely forgotten that it’s there, so I don’t think it will be a problem going forward. The case also comes with a substantial belt clip, which when fully assembled is about the size of the case itself.
The only thing that I really dislike about the Otterbox is that you have to lift a small rubber flap to plug in headphones. I use my headphones all the time, so it seems like this will be kind of annoying. The flap has a hole, which appears to be intended for the headphone jack, but it does not properly align. At first this seemed like a defect, but the Otterbox FAQ says that the hole is actually intended for the microphone instead of the headphone jack.
The only other possible area of concern is docking. The case has a rubber flap that exposes the connector on the bottom of the iPhone, but it’s likely that the size of the case will prevent it from fitting properly into some docks. I use a third party dock that’s similar to the Apple iPhone dock, and after completely removing the custom molding for various iPhone models, my phone fits in the dock nicely with the Otterbox cover on.
Bottom line is that the Otterbox Defender is good choice if you’re looking for a highly durable case and you don’t mind putting up with a little bulk to get it.
Dec/110
Hosting an svn server on Mac OS X
Over the past few years I’ve tried Beanstalk, Assembla and several other svn hosts for some of my projects. They all worked great, and none of them gave me reason for concern, but in the end I’m just more comfortable hosting my source internally.
I have a Mac Mini that serves as a Media Center in my living room. I also use it for some home server tasks since it’s always on and well backed up. I’ve setup svn + apache servers on Linux before, and I figured it should be easy to do the same thing on OS X since it ships with all of the necessary components. Apple makes it easy to configure OS X Server for svn hosting, but it can also be configured on standard OS X with a little command line work.
To get started, open Terminal and execute the following commands. Note that you’ll need to execute all of the commands as sudo since they’re operating on protected directories.
1: Create a repository
First you’ll need to create a repository. I created the repository in /usr/local, but the location doesn’t matter (just make sure you edit the location in Step 2 if you choose something else).
sudo mkdir /usr/local/svn; sudo svnadmin create /usr/local/svn/repo
After you’ve created the repository, you’ll need to change the owner to www so that Apache has permission to access it.
sudo chown -R www /usr/local/svn
2: Configure Apache for SVN Access
Next you’ll need to define the configuration that tells Apache that it should provide WebDAV access to your repository. This can be done by adding a new configuration file in /etc/apache2/other. The default Apache configuration automatically includes any supplemental configuration files from this location.
echo "LoadModule dav_svn_module /usr/libexec/apache2/mod_dav_svn.so <Location /svn> DAV svn SVNParentPath /usr/local/svn AuthType Basic AuthName \"Subversion repository\" AuthUserFile /etc/apache2/svn-auth Require valid-user </Location>" | sudo tee -a /etc/apache2/other/svn.conf
3: Create a User Account
Next you’ll need to define a user account for accessing Subversion via Apache. This can be done by running the following command (replace YOUR_USERNAME with your chosen username).
sudo htpasswd -c /etc/apache2/svn-auth YOUR_USERNAME
You may be asked for several passwords here:
- If prompted for Password: then enter your Mac OS X password. This is being requested because you’re running the command with sudo. You may not be prompted if you’ve run another sudo command in the last few minutes.
- When prompted for New Password: it’s asking for a new svn password for the account you’re creating
- When prompted for Re-type Password: it’s asking for you to confirm your new svn password
4: Restart Apache
Once this is done, the only remaining step is to restart Apache. You can do this by restarting the Web Sharing service in System Preferences (or starting it if it’s not running). To do this, go to System Preferences > Sharing > Web Sharing and deselect / re-select the checkbox to restart.
Once this is done, you should be able to access your svn repository at: http://localhost/svn/repo. You will be prompted to enter a username and password. Use whatever you provided in step 3. Enjoy your new repository!
Dec/110
App Engine + JSP + Jersey Viewable Example
I’m putting together a simple App Engine webapp that’s using Jersey as the controller and JSP for the view. Wrapping a Jersey Viewable in a Response, provides a clean way to do this, but I had a bit of trouble getting everything wired up properly. After a little googling I found a post over at Don Park’s Daily Habit that helped me get things right. Here’s a full working example for anyone who’s trying to do the same thing:
Required JARs
I’m using Jersey 1.11
- asm-3.1.jar
- jersey-core-1.11.jar
- jersey-server-1.11.jar
- jersey-servlet-1.11.jar
web.xml
<!--?xml version="1.0" encoding="utf-8"?--> JaxRsApplication com.sun.jersey.spi.container.servlet.ServletContainer javax.ws.rs.Application example.JaxRsApplication com.sun.jersey.config.property.JSPTemplatesBasePath /WEB-INF/jsp com.sun.jersey.config.property.WebPageContentRegex /(images|js|styles|(WEB-INF/jsp))/.* JaxRsApplication /*
JAX-RS Application
package example; import java.util.HashSet; import java.util.Set; import javax.ws.rs.core.Application; public class JaxRsApplication extends Application { @Override public Set> getClasses() { Set> classes = new HashSet>(); classes.add(HomeResource.class); return classes; } }
Root Resource
package example; import java.util.HashMap; import java.util.Map; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.core.Response; import com.sun.jersey.api.view.Viewable; @Path("/") public class HomeResource { @GET public Response get() { Map model = new HashMap(); model.put("word", "World"); return Response.ok(new Viewable("/home", model)).build(); } }
/WEB-INF/jsp/home.jsp
<!--?xml version="1.0" encoding="UTF-8"?-->
Hello ${it.word}Jan/090
Security Now
This week’s episode of the Security Now podcast was one of my favorites… it includes an explanation of how security researchers successfully forged a root certificate authority by brute forcing md5 with Playstations, a great story about an early PC called the PDP-8, and some information on a new small(er) form factor, instant charging, and non-toxic battery technology that was recently patented. Not all security stuff, but definitely interesting. All episodes can be downloaded here.
Jan/090
Pulsar
Pulsar: Absolutely loving Pulsar, the new XM/Sirius player for the Mac by Rogue Amoeba. I use it to listen to XM while at work, and also through my Apple TV at home (via Airfoil, another Rogue Amoeba product). Best of all I got Pulsar for free as an existing Rouge Amoeba product owner. See this page for details on that offer.
Oct/083
iPhone Tip: Enabling WiFi in Airplane Mode
I’ve decided to leave my laptop at home for an upcoming trip to Europe, so I’ll be using my iPhone for Internet acesss. I looked at AT&T’s international data plans, but none of them look apealling, so I’ll be sticking with WiFi.
To make sure I’m not charged roaming fees I’m going to keep my phone in airplane mode, but the problem is that automatically disables WiFi.
Well, as it turns out, the workaround is painfully simple… just turn it back on (duh). The WiFi slider automatically toggles to off when you enable airplane mode, but you can turn it back on without disabling it.
On a side note, I wrote this entire post on the subway using WordPress for iPhone in offline mode. Pretty cool, huh?



