Archive for October, 2007

Oct 16 2007

Changing Meta Types in iTunes Files

Published by Jonathan Wise under Hacks, Links

So I’m off on a road trip next week, and I’ve downloaded a number of “spoken word” MP3s to listen to while I drive (it’s an 8 hour trip). The only problem is that now they’re mixed into my iTunes library, and when I hit shuffle on my iPod, every 3rd or 4th song will be a chapter of a book. It would be useful if iTunes would let you identify any MP3 as an “Audiobook” but they’d rather you buy your books through them, so they don’t expose that functionality directly. Here’s instructions on how to re-type your MP3s as Audiobooks for iTunes…

Also, if you want to re-type video, or other MP4 files — say to turn a downloaded video into a “TV Show” check out Lostify for Mac. It won’t work with AVIs though.

3 responses so far

Oct 16 2007

Musings on a Jailbroken 1.1.1 iPhone

Published by Jonathan Wise under Hacks

So today a pretty stable-looking version iNdependance was released and it was finally time for me to get some 1.1.1 action going. I couldn’t live without my hacks (NES on the run is just too much fun, and VNSea lets me hack at my server without getting off the couch) but there are a few 1.1.1 features that I was interested in… just not enough to make me give up my 3rd party apps.

The instructions that came with iNdependance were quite good, but here’s a few things I would have like to have been told before hand:

  • If you’re already running a hacked 1.0.2 and its not unlocked and you’ve got SSH installed, you’re ready to go for the customized upgrade to 1.1.1. I had assumed that I’d have to let iTunes upgrade and then perform the hack — this is not true. The hack requires a hacked 1.0.2 to modify the 1.1.1 install process. Stay where you are and skip ahead to the “special” 1.1.1 install.
  • I had bad luck doing the steps through a USB hub. Nothing seemed to be working right until I disconnected the hub (and dock, just to be safe) and connected directly to a USB port on my Mac Mini.
  • Summerboard and Customize do not work on 1.1.1. There are a lot of apps that do, but I assume that tools that make assumptions about the file system or Springboard configuration aren’t ready for 1.1.1. This is sad because Summerboard was very pretty. Hopefully Erica gets a new version out soon.

Aside from these caveats, and a much longer jailbreak process, things are essentially like they were for the 1.0.2 hack. I don’t think I’ll use the iTunes WiFi Store, but I’m glad to have quick access to my iPod controls now!

Update: This might just be a fluke, but I found I’ve been unable to create mail accounts on the iPhone. No matter how accurately I know I type my password, it refuses to accept it — for both GMail and a regular POP account. Syncing the mail accounts on from my desktop computer, however, added the accounts to the iPhone, and we’re back to the races…

Update to Update: I found out that this was related to a bug in 1.1.1 — not unique to hacked iPhones. Make sure you turn off caps lock after using it, while entering passwords.

5 responses so far

Oct 15 2007

Webpages for the iPhone

Published by Jonathan Wise under Code Snippets

Having to scale and scroll on webpages on your iPhone is annoying. Sometimes its necessary, but very often just a little bit of effort could be put in to make the page iPhone friendly — or to make an iPhone specific version of the page. I’ve previously discussed the WordPress theme, but I have another page that I built that I use frequently, and I wanted to make an iPhone version.

So I spent some time Viewing Source on iPhone web apps that I use, and stole/extracted a few little snippets that can be applied to easily make iPhone pages. For an example of the transformation applied…

You’re welcome to View Source yourself and steal to your heart’s content. A few things that are non-obvious:

  • Note the meta tag for viewport where you can control how the iPhone scrolls and scales the page:
    • This particular combination prevents all scaling, but gracefully handles a rotate.
  • <meta name="viewport" content="user-scalable=false; initial-scale=1.0; maximum-scale=1.0; minimum-scale=1.0" />

  • The PHP I use in the main index to detect an iPhone and redirect looks like this:
  • <?
    if (stristr($_SERVER['HTTP_USER_AGENT'], ‘iPhone’)) {
       header(”Location: index-iphone.php”);
    }
    ?>

  • There’s plenty of great iPhone-like CSS definitions here

3 responses so far

Oct 15 2007

iPhone Theme for WordPress

Published by Jonathan Wise under Code Snippets, Hacks

Here’s a hack for ContentRobot’s excellent iPhone Plugin + Theme additions for WordPress that allows the user to decide which version to view. When deploying this theme, I had originally chosen two different roll-out strategies — both modifications of what’s provided by the original code.

For jonandnic.com I made two versions of the website. This seemed like a worthwhile idea at the time, but now that I’ve further hacked the plug-in, I think the approach I used on this site is better.

In short, what I wanted to do was allow the user to choose which version of the site they want to view. The iPhone theme obviously has less features than a full widget/side-bar ready theme, and despite the small screen size, there are times that I want that functionality on my iPhone.
Initially I had a hack in that would ask the users with each page visit. This got annoying, so I improved my hack to include a cookie that saves the preference for an hour. This way they can decide on each visit which version they want to see.

This is a derivative work from the original plug-in, which is provided here, under the GPL.

Update: Here’s another note. Once the user’s made their selection, you can allow them to change their preference by adding the following code somewhere in your iPhone theme code. I added it to the Footer…

  • <p>View <a href="<?php bloginfo('siteurl'); ?>?iphone=no">Full Version</a> of this site</p>

2 responses so far

Oct 14 2007

Enabling WebDAV on OS X

Published by Jonathan Wise under Links

I won’t re-write the article, but this weekend I wanted to turn on WebDAV on my Mac mini, and this article pretty much covered it for me. The article talks about using iCal, but do the steps and see the FAQ for additional tips on regular file sharing.
The only note I’d add is that Digest authentication didn’t work for me in OS X 10.4.10 — I had to use Basic authentication.

No responses yet

Oct 10 2007

Kicking off Code Poetry

Published by Jonathan Wise under Articles

Ever come up with a clever solution to a networking issue? Spent hours searching the Internet for info about a problem only to finally piece together a solution from 18 different sources, and wished someone would just write down a coherent walk-through? Written a particularly elite piece of script or useful app that you know you just have to share? Found a link or a bit of news that you want to capture before it scrolls off the Digg home page?

Well this is my home for all those things. For now I’m spinning this site off our personal blog, www.jonandnic.com, to free that site from my techno-ramblings. But I’d loved it if this site grew into a repository of useful info for geeks and by geeks.

Unless you decide to submit some content, this site won’t be updated as frequently as the main site — I’ll post when I have something worth writing. But if you want to help this site grow, go ahead and put in your own two cents. If it becomes worth it, I’ll register a domain name and make this its own entity. Until that happens, however, I hope my own hacks and code snippets are interesting enough to make this site worthwhile!

No responses yet

Oct 09 2007

WordPress Hacking: Multiple Blogs On One Set of Tables

Published by Jonathan Wise under Hacks

Note: This post was written for WordPress 2.1. Please see the comments for discussion on how to apply to newer versions!

I recently rolled out a new theme for my personal website. Normally when I do this, I do it against the live site, so there’s about an hour where the site is either broken, or looks really weird while I’m working on it. This time I wanted to be a little smarter.

The goal was to build another blog — a “test” blog where I can try out new themes and other experiments — that pointed to the same data as the main site. This way I could get a realistic picture of what the site would actually look like before I publish an updated theme.

The more I thought about that, the more useful the concept seemed. What if I wanted an iPhone-friendly version of the site? I wouldn’t want to write the same post in two places. Now eXpression could do this very easily — since every “page” was actually a query, you could just specify a different theme file (XSL) in the query. WordPress, not so much.

What WordPress can do is allow you to specify a table prefix for each installation on a given server. That means you can have 3 blogs, each with their own set of tables. When you build your wp-config file, you tell it what prefix to use. Since this is the case, it should be fairly easy to install another instance of WordPress and point it back to the original blog tables, right? Here’s how you do it…

Step 1 - Install a new instance of WordPress

  • Make sure it has a unique folder name so it doesn’t over-write your original blog
  • Run the install pages, and give the new blog a unique table prefix
    • IE: If your original blog got the default prefix: wp_ then give the new blog newwp_
  • Get the blog up and running with an admin account, but don’t bother posting anything

Step 2 - Point the new blog to the original blog’s tables

  • Modify wp-settings.php as per the instructions found here
    • Modify all the table pointers EXCEPT for Options
  • This means that only the Options (including Theme and Plugins) will be specific to your new site. Everything else (including Posts and Comments) will come from the original site
  • So anywhere you see: $wpdb->users = $wpdb->prefix .
    Change it to: $wpdb->users = ‘wp_’ . ‘users’;

    • where ‘wp_’ is the table prefix for your original blog

Step 3 - Grant the admin user from your original blog the same permissions on your new blog, by inserting two records into your wp_usermeta table:

  • Where wp_ is the table prefix of your original blog and newwp_ is the table prefix of your new blog…
    • INSERT INTO wp_usermeta (user_id, meta_key, meta_value) VALUES (1, 'newwp_user_level, 10')
    • INSERT INTO wp_usermeta (user_id, meta_key, meta_value) VALUES (1, 'newwp_capabilities', 'a:1:{s:13:"administrator";b:1;}')

That’s it! You now have two uniquely styled blogs with the same data in them! The only thing that sucks is if you have Sidebar widgets configured, you’ll need to re-configure them in your new blog as well and manually keep them in sync. That’s the case for all options, and that’s why this is useful. To see it at work, check out:

A couple other notes:

If you want, you can delete the superfluous “new blog” tables — just make sure you leave the Options table intact.

I have no idea how this will work during a WordPress upgrade. My current plan is to run the upgrade on the original, or base, blog, then manually change the Options table structure, if necessary, for the secondary, or derived, blogs.

9 responses so far