Archive for the 'how-to' Category

20th Jan 2008

How-To: Make Your Own CD/DVD Lens Cleaner and Fix Your CD/DVD Drive Yourself

I ran into a problem this weekend. I upgraded my MacBook Pro’s hard drive to a 320GB Western Digital drive (win) and decided to create a boot camp partition with all my new free space I had, so I could play TF2 with friends. Upon trying to do this, however. I discovered my superdrive has decided to stop reading CDs. DVDs worked fine, but CDs? Nope. How could I install Windows then?

I tried several ways. I tried copying the CD to a DVD and using that, but it caused the Windows installer to crash. I also tried using VMWare Fusion, which just didn’t recognize the Boot Camp partition (probably because there was nothing on it). I tried copying a boot camp partition from another mac, as well as using Parallels to install it, both unsuccessful.

I was starting to think that I would have to replace the drive, when it dawned on me that I might be able to fix it using one of the CD Lens cleaner things. I’ve never used one before, so I was skeptical, but more than that, I was lazy. I didn’t want to drive to the store in -13 C weather and pay $10 for some special “cleaning CD”. What was so special about these CDs anyways? I decided to find out.

Seconds of googling turned up this image:
Lens Cleaner

It was painfully obvious. It’s just a piece of friggen felt glued on to a CD! I can do that! So I did. Behold:
MY Lens Cleaner

What is it? Simple really, a piece of a Swiffer brush I had laying around my room scotch tapped to a CD. I put it in, listened to it spin up a few times, then popped it out. Sure enough, CDs now read fine.

DISCLAIMER: It’s not my fault if you break your drive my trying this. It worked for me, but if you’re stupid (or more likely, unlucky) bad things might happen like the felt coming off inside your drive, then you’ll be screwed. So pray that doesn’t happen.

Posted by Posted by patrick under Filed under diy, how-to Comments 3 Comments »

18th Jul 2007

How-to: Pop-up Menu Selection AJAX in Rails

The problem: In Rails, how do you create a popup menu that calls a given action (to replace a div or whatever else) and passes the selected option as an argument when a new selection is made?

This took me way longer than I thought it would to figure out how to do, so I’m posting the answer here as well for anyone trying to do the same thing.


< %= select_tag :person_choice, options_for_select(@persons),
:onchange => remote_function(:update => “divToBeUpdated”, :with => ‘Form.Element.serialize(this)’, :url => { :action => ‘update_person’}) %>

The key here is the :with => ‘Form.Element.serialize(this)’ option. It’s a bit of magic javascript that passes the selected object along with AJAX call, but I actually don’t really understand it much beyond that. If anyone wants to give me a more thorough explanation, it would be highly appreciated.

Huzzah!
Update: Props to OnRails.org.

Posted by Posted by patrick under Filed under ajax, code, how-to, rails, ruby Comments 1 Comment »

01st Jul 2007

Using Google Apps for Your Domain email on the iPhone

I crumbled and bought an iPhone. Thus far, I love it. It’s the first ’smartphone’ (although the iPhone is more like a ‘geniusphone’) I’ve ever owned, meaning it’s the first that can do email and has unlimited data usage - something we don’t see in Canada.

On first sync, I noticed none of my 3 email accounts worked. I realized right away that it was obvious that both my school and photography emails wouldn’t work, since they were set up to use localhost as the mailserver (since I tunnel them through SSH). My SSL-enabled Google Apps for Your Domain email, however, was not working without reason.

I tapped my way to the settings to discover that the iPhone saw the ‘pop.gmail.com’ server address and assumed I was using a gmail account, so it appended a non-optional ‘@gmail.com’ string to my existing email address, making it look like ‘foo@bar.com@gmail.com’, which was obviously causing the problem.

A couple of other people have run into this problem on the Apple Discussions board as well as the Google Group for the Apps for Your Domain stuff. Thus, I offer a very simple solution:

In Mail.app, change the POP mail server from ‘pop.gmail.com’ to 209.85.199.109, the IP address of the same server. The iPhone won’t recognize it, so it won’t attempt to change it, and everything will work fine.

In addition, I highly recommend changing your username on the iPhone to ‘recent:food@bar.com’, so that Google’s email server knows to send you the most recently received/sent emails, even if they have already been POP’ed off the server by your home machine.

Enjoy your iPhone!

Posted by Posted by patrick under Filed under googleapps, how-to, iPhone Comments 1 Comment »

01st Mar 2007

How-to: Create an Adium Plugin

Creating a Plugin for Adium is actually really easy. Here’s a quick guide through the proper set up to help get you started. There is even a skeleton project at the end.

  1. Create a new Xcode project, choose Bundle -> Cocoa Bundle.
  2. Add the following frameworks to your project:
    • Adium.framework
    • AIUtilities.framework
    • FriBidi.framework

    These are necessary if you plan on using or changing any part of Adium, which you will likely be doing.

  3. Create your main class. It should be named something like ABMyTestPlugin. Your class should inherit from AIPlugin, found in Adium/AIPlugin. So you will need to import that.
  4. Override the -installPlugin and (if necessary) -uninstallPlugin methods. The meat of your code goes there.
  5. Override -pluginAuthor, -pluginVersion, -pluginDescription, and -pluginURL as well, to all return appropriate NSStrings. This isn’t required, but is good practice, so do it anyways.
  6. Get info on the build target (your bundle). Change the build settings to add the following:
    • Other Linker Flags: -undefined dynamic_lookup
    • Wrapper Extension: AdiumPlugin

    Also, under the Properties tab change the Creator to “AdiM” and the set the Principal class to the name of your main class (ABMyTestPlugin).

  7. Build your bundle, drag and drop it onto the Adium icon and test it out.

That’s pretty much all there is to it. More information on what you can do once you hook into adium can be found at the Map of Adium. It’s not really complete, but if you poke around inside the Adium.framework headers you will find that most of the methods are “self-documenting” and not to difficult to figure out. I’d also suggest looking at some existing plugins, like my Time Zone Plugin and the ones included within Adium itself.

If you’d like a skeleton of the Xcode project, grab it right here: AdiumTestPlugin.zip

You might want to also grab the Adium Source and compile your own frameworks since the ones included may be out of date.

Update: luapffuh pointed me to Toby’s guide to creating an Adium Plugin. Although mostly the same, his has bit more detail and is definitely worth checking out.

Posted by Posted by patrick under Filed under adium, cocoa, code, how-to, open-source Comments 3 Comments »

26th Feb 2007

Fun things to do with your old PPC iBook or PowerBook

Apple’s transition from the PowerPC architecture to the x86 architecture is going rather well. All their machines are now intel-based, and have been for about half a year. Lots of people have already made the switch: 3/5ths of my family, myself, my dad and now my brother, are such people. This is in line with Adium’s usage metrics, which show that a bit over half of it’s users are now running Intel machines. My brother recently decided to pack up and move to China (WTF?) and in doing so bought an Intel Mac Mini to replace his not-too-old, 1.33Ghz 12-inch iBook G4. He was nice enough to let me, um, hold on to it, while he is off in the land of the rising sun far east.

With my recent purchase of a Core 2 Duo Macbook Pro (Thanks, ADC Student Discount!), I didn’t really have a huge need for it, but being a geek I of course jumped at the chance of picking up another computer. But, what to do with it?

At first I thought I’d install FreeBSD. A lot of my friends use some linux variant, but I recently read a cool essay on FreeBSD vs. Linux and decided I wanted to try out FreeBSD. Unfortunately, driver support for Apple machines isn’t exactly stellar in FreeBSD 6.2, and is missing a few little things, like you know, keyboard, trackpad, and wireless drivers. Next Idea.

Okay, fine, I’ll install Kubuntu. I’m kinda familiar with Ubuntu, and I’ve been wanting to play with it and KDE. Driver support was much better, but Linux on Apple laptops is still pretty rough around the edges. No advanced power management (no sleep), and graphical glitches in X/KDE really turned me off. I was going to install XGL/Compiz and play around, but rather than fight with it all night I just decided to do a fresh OS X install. I still wasn’t sure what I was going to use the machine for, but running Linux was never a necessity anyways.

So with a fresh OS X install, I christened the machine Spartacus. What now? Hmmm…

I’d always wanted a MythTV box, but I don’t really watch that much television, and it’d be annoying to have to set up a cable hook-up in my room and tether it to a laptop. But then I had a sweet idea: What about that Democracy TV app?

1. Democracy

I had never noticed before, but Democracy is a sweet app. I had tried it out briefly once before, but it was too heavy on ram usage and somewhat unnecessary to be have running all the time for someone like me, who then had no interest in net TV. Now that I’ve seen that there’s some good stuff out there and I have a machine I can leave running all day downloading stuff, I can tell it is going to be getting a lot of use.

If I’m going to be watching videos I’m going to need codecs, which reminded me of something else: Perian.

2. Perian

Perian is pretty much exactly what it says it is, the swiss army knife of video codecs for the mac. I don’t need to talk a lot about this, it’s just really simple and really useful. Hooray!

But now that we are talking media apps, what else is there out there? Ah yes, what about that songbird app?

3. Songbird

When I first tried Songbird when it was announced some months ago, I was totally nonplussed. “It’s just a black iTunes”. I was wrong. I’ve been using it more now, and it’s a pretty powerful app. The ability to automagically list, download, and create a playlist for all the mp3s linked to by a particular site while browsing around is awesome. It makes reading MP3 blogs so much more enjoyable. The tight integration of other features like lyric searching, wikipedia band info, and tour info make listening to music much more of an experience than a secondary, background activity. I love it, and while there are some annoyances (no minimize on command-m?!) I can’t wait for it to go 1.0. I still keep iTunes around to stream music from my main machine, but I don’t plan on using it heavily.

Was there anything else? Ah, yes.

4. Games

Wesnoth. Quinn. X-Moto. Just a few free, light games that I love to play when killing time or just to relax a bit.

That’s essentially it so far. I’ve now got a sweet little media machine that can sit beside my bed downloading music and videos (totally legally) all day that I can peruse at my leisure. It’s got some games as well to keep me amused. It’s light, it’s fast, it’s Mac OS X, it’s great.

Thanks James. ;)

Posted by Posted by patrick under Filed under *nix, apple, how-to, ibook, legacy, me, open-source, ppc Comments 1 Comment »