the further adventures of

Mike Pirnat

a leaf on the wind

Next Page »

Unhijacking Alfred's Google Searches

My ISP hijacking a Google search

I'm pretty much in love with Alfred; it's usually the first thing I install on a Mac. For whatever reason, though, I rarely use it to fire off Google searches, usually going straight to my browser. But today I fired off a search from Alfred and was aghast to see a crappy hijacked results page from my ISP, who I'd previously praised for having a fairly mature attitude toward all things internet and not requiring me to have TV service with them. I think I invented at least three new, wildly-offensive swear words when I realized what was happening.

Now, my ISP hides a tiny little opt-out link in an area of the page that, is virtually invisible due to its proximity to what my brain perceives as pure garbage. (In fact I'd written most of this before I even noticed it was there at all!) But you might not be so lucky, or, depending on the way the opt-out is implemented, you might not stay opted-out, and anyway, isn't a clever DIY solution more fun?

Since Alfred just makes a URL and hands off to the OS's preferred browser, I fired up Charles to see what was going on. Sure enough, they're intercepting GETs to http://www.google.com/search?q=whatever and throwing back a 302 to their own, crappy search, and I was able to quickly duplicate the behavior in my browser by cooking up the same form of URLs.

But why hadn't I noticed this before, using the search box in Safari, or by going straight to Google first? The reason is that my ISP's pattern-matching is delightfully naïve, so it doesn't catch the richer URLs that Google or Safari construct. This gives us the key we need to craft a workaround for Alfred: a custom search!

Custom searches are the cat's pajamas--I've rigged up a bunch for work to quickly drop me into our wiki, issue tracker, and so forth. Rather than waiting for the Alfred developers to provide a fix for the search hijacking, we can make our own custom search quickly and easily.

First, start by disabling the default Google search in Alfred. Open up its preferences, navigate into "Features", then "Web Searches", and then uncheck the Google checkbox:

Turning off Google search in Alfred preferences

Next, select "Custom Searches" and click the "+" to create a new one. You can then monkey with the URL to slip past The Man--for example, a simple alteration to the query string like http://www.google.com/search?&q={query} can do it. In my case, I chose to make the simple switch from HTTP to HTTPS, as it's likely to be more robust and gives me a nice, encrypted channel.

Creating a custom Google search for Alfred

To get the same nice logo that Alfred's default has, we can go get the icon out of the app itself. Right-click (or control-click) Alfred.app in your Applications folder and select "Show Package Contents". Then open the "Contents" and "Resources" folders and you'll find all of the icons. Find the "google.png" image and drag it over into the icon drop zone in your custom search.

Finally, we need to wire our new search into Alfred's "Fallback Searches". Pop open the one that's currently set to "Search Google for '...'" and scroll down to the bottom, where you'll find the custom search below a separator:

Replacing Alfred's fallback Google search

And that's all there is! Alfred is restored to full Google-searching glory. I'd like to say a huge thank you to the developers of Alfred for providing the flexibility that made this not only doable but easy. Huzzah!

Alfred searches Google, as it should be

Read and Post Comments

121/365: Mulligan

121/365: Mulligan

Monday was made even more special by learning a hard, hard lesson as I experienced my first serious betrayal by an Apple product.

When I started up my shiny new Air to prepare for a presentation the next day, I I found myself caught in a reboot loop. I'd get the grey screen and spinner for a few seconds, then it would stop, go dark again, then back to the grey screen and spinner again. I booted into the recovery mode (hold down Command-R while booting) and to my horror discovered that the FileVault-encrypted filesystem was unrecoverably corrupt.

Attempts to reinstall efficiently while in the office failed, as my bootable Lion install stick apparently doesn't have some driver kung-fu that the Air demands, and my friend Cory's Lion stick wasn't even bootable. I next gave up on the network reinstall when it estimated that it would need over 667 hours to download what it needed. Fortunately, the bandwidth at home is mine (all mine, muahahahaha!!) so it didn't take too long to restore once I got home. I'm also lucky that, as new as it was, it really didn't have anything critical on it; I'd mostly been storing documents out on Dropbox, so getting it back in shape was mostly just a matter of downloading and reinstalling things.

I think what killed it was leaving it asleep for several weeks, until the battery was completely flat, and that the filesystem never got put away cleanly when the charge completely expired.

So--don't do that.

Read and Post Comments

Building Pycrypto on Snow Leopard and Non-Apple Python

I wanted to use PyCrypto on a personal project, which means that even though I will eventually deploy to Linux (where PyCrypto is super-easy to come by), I first needed to get it set up on my development machines, which are all currently Macs running Snow Leopard. This takes a bit of finagling--including some steps that I didn't see listed in (m)any other guides--so I figured it would be worth sharing (or at least memorializing here so I can find it again).

You may be tempted to just easy_install PyCrypto, or manually grab the source and try building from that. That's likely to get you a giant wall of compiler output that includes this lovely gem:

Compiling with an SDK that doesn't seem to exist: /Developer/SDKs/MacOSX10.4u.sdk
Please check your Xcode installation

But I already installed Xcode! you cry. What gives?!

Here's Trick Number One: install Mac OS X 10.4 support when installing Xcode. I hadn't, so I got to reinstall Xcode. Naturally, Apple knows better than you do, and won't let you install without the "Essentials" package, so go find something else to do while 8+ GB of stuff you already installed gets done all over again.

Okay, you think, now I'm set. This is going to be great! You pop back into the terminal and retry the build:

$ python setup.py build
running build
running build_py
running build_ext
warning: GMP library not found; Not building Crypto.PublicKey._fastmath.
building 'Crypto.Hash.MD2' extension
gcc -arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -fno-strict-aliasing -fno-common -dynamic -std=c99 -O3 -fomit-frame-pointer -Isrc/ -I/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -c src/MD2.c -o build/temp.macosx-10.3-fat-2.6/src/MD2.o
In file included from /Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/unicodeobject.h:4,
                 from /Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/Python.h:85,
                 from src/MD2.c:31:
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/stdarg.h:4:25: error: stdarg.h: No such file or directory
In file included from /Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/unicodeobject.h:4,
                 from /Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/Python.h:85,
                 from src/MD2.c:31:
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/stdarg.h:4:25: error: stdarg.h: No such file or directory
lipo: can't figure out the architecture type of: /var/folders/FI/FIs1Mi6LFUeDQ-LNLRg+JE+++TI/-Tmp-//ccVhrG5I.out
error: command 'gcc' failed with exit status 1

Now you're confused. None of the existing "how to install PyCrypto" cheat sheets that you found had anything to say about this flavor of failure.

Upon reflection--and much Googling--you realize that this is your punishment for thinking you know better than Apple. You thought you were so clever when you installed a more current Python than what Apple ships, and you thought you were doing the right thing by going to Python.org to get the latest, greatest stuff. (Well, for some value of "latest, greatest", because like me you probably did this ages ago and never changed it once it was working.)

The problem is that Snow Leopard wants to use gcc-4.2 by default, but your Python.org-built Python wants gcc-4.0 instead.

Trick Number Two is that you need to tell it to do the right damn thing:

export CC=/usr/bin/gcc-4.0 
export CXX=/usr/bin/g++-4.0 

You can then python setup.py build and python setup.py install to your heart's content.

This second trick may be moot if your Python.org Mac Python binary is new enough--it looks like it got addressed in late 2009. Laziness, however, is one of the Three Virtues, and I find myself possessed of an abundance of it, so I have pretty much forgotten about keeping my Python current once I had something 2.6ish that was "good enough for now."

Now you know. And knowing is half the battle.

Read and Post Comments

Reconciling Leopard and the Brother 5070N Laser Printer

Once upon a time, I upgraded to Leopard on my Mac Pro, and, though I did not mention it at the time, something in upgrade land totally pissed off my Brother 5070N laser printer.

I'd bought the printer in the first place because it was one of the first to support Bonjour (née Rendezvous, née Zeroconf) networking. With good ol' Tiger, it Just WorkedTM, and all was milk and honey as far as printing went in my home. But noooo, it didn't like the hoity-toity, super-duper-greatest-thing-since-sliced-bread Leopard attitude, and just spat out endless reams of cryptic stack dumps instead of, say, directions to wherever I was in a hurry to leave for. I poked around a little, checking for new drivers and all that sort of common sense stuff, and found that even Brother's website claimed that the drivers were bundled with Leopard and that there was nothing for me to download.

I never did get around to figuring out the problem at the time, and being a sleep-deprived and very busy new dad it unfortunately hasn't been much of a priority. Somehow I've learned to live with six months (!!!) of not being able to print a damn thing. And worse, I've had to hold off on upgrading my wife's machine, which has kept her from being able to enjoy the goodness of automated Time Machine backups.

I finally got fed up with it today and decided to finally sort things out once and for all. I even indulged my inner noob and followed Brother's directions, even though it meant assigning a static IP to my printer and dropping it back from the awesomeness of Bonjour to the semi-awesomeness of old-school IP printing. It turns out that, even though no one says it anywhere, that was the key. So, here's a bit of advice for future Googlers: the 5070N will not print correctly using Bonjour under 10.5. You want the CUPS driver and the "HP Jetdirect - Socket" protocol. Then poof! It's all happy again.

Now to go about breaking upgrading Liz's laptop...

Read and Post Comments

Trading Stripes for Spots

So now that things have calmed down a little bit, I finally had time to install Leopard on the Mac Pro this weekend. I know I'm a bit late to the party, but here are a few quick thoughts so far...

The Good:

  • Time Machine -- syncs happily to the 500GB internal drive I installed last weekend (amusingly, with the words "honk if you love internal hard drives" printed on the inside of the box). Finally, something is doing at least some level of backup in our house!
  • Safari -- holy crap, fast fast fast! Feels like driving a zippy little sports car compared to the increasingly SUV-like Firefox (which has similar problems on tight corners).
  • Searching for text -- I love the visual emphasis on the search hits that "pops" the search result. It's subtle, but really helps quickly identify where the result is, which is not always easy when looking at a wall of text.
  • Searchable Help highlights menu options -- freaking brilliant. No more wondering where your favorite menu options got moved to (*cough* Adobe *cough*).
  • The Downloads folder. Yes, I already had my own that worked fine, but it's nice that it's earned an official special place, and it works well with the new Stacks feature for getting quickly to whatever I've just downloaded.
  • Hot diggety, Python's really nice out of the box!
  • Quick Look is pretty nice; got a feeling I'll be using it a lot soon.
  • Grammar checker is now just as widely available as the spell-checker. Nice touch.
  • Okay, the eye candy factor is nice too. I do like me some shiny things. :-)

The Indifferent:

  • The new 3D-ified Dock -- not as horrible as all that. I'm slightly amused by how it picks up reflections from the windows above it. I could use nicer "here's what's running" indicators, but I'm just not seeing a justification for all the controversy.
  • The new menu bar -- square corners and semi-transparent... It'll take a little getting used to, but it's not going to upset me.
  • Stacks -- I kind of like these, but I'm not 100% in love with them yet.
  • The new folder icons. Not doing it for me.
  • I wonder how long I'll want to live in the "deep space" look.

The Really Annoying:

  • I have to upgrade Photoshop and friends. Granted, I was still running Photoshop 7, so I'm a bit behind the times on that, but it still sucks that what was working like a champ for me under Tiger completely craps out in Leopard. Boo, hiss.
  • XJournal, my LiveJournal client of choice on the Mac, crashes upon log-in to LJ. No Leopard-friendly upgrade is available yet. Again, boo, hiss.
  • Startup disk? What startup disk? Immediately after my first boot into Leopard, there was a software update that wanted to be dealt with promptly. So I took care of that, rebooted, and was greeted with the blinking file folder of doom, signifying that no startup disk could be found. Not the most rewarding experience after all of the anticipation and the lengthy upgrade.

And now back to actually doing stuff with the computer instead of poking it to see what it does...

Read and Post Comments

Heck Yeah

Dang, it's suddenly turning out to be a great week! In brief:

  • After a couple miserable days of near-100-degree temperatures, the weather has cooled off and is now downright awesome.
  • Got my monitor back from Apple (no thanks to DHL, who apparently don't even believe in leaving slips at the door when they ignore the "no one will be home between X and Y, please deliver when it will actually make sense to do so" instructions). It's all fixed and happy, and now the cats have a new box to play with. It really is amazing how much better the ACD is than the old 19" monitor I'd been using in its stead...
  • I totally aced the infant CPR course we did last night. Plus, since everyone else was either too timid or too cool to do the "say stuff out loud along with the script" part of the training, my long-dormant inner theater geek had an excellent opportunity to ham it up loudly, to the amusement of all. Thought for today: "The scene is safe!"
  • This is the week that I finally have cleared enough off of my plate at work to dig into fixing the crapton of problems on our new site that are Safari-specific. It was an uphill battle for a few days, but this afternoon I finally had the "eureka!" moment of complete enlightenment and discovered the one bug in the JavaScript framework we're using that seems to be the lynchpin holding everything up. With what's literally a one-line change, close to twenty really horribly broken things on our site suddenly and miraculously work. Huzzah! I'll probably have something more on this once I get the legal OK from work to the disclose details of that portion of my brain...
  • We had a major project launch and data conversion that started last night at midnight... and for the first time in forever, I didn't have to do anything to support it. No being online from home, no camping out in the office, no having to monkey with it in the morning, nothing. After seven years of driving in at two or three in the morning, I can't describe how great that feels to just not have to worry about it. :-)
  • Liz kicked ass on her most recent papers! You go, girl!
  • The window's open, the sunset was lovely, the breeze is delightful, good music on the ol' MP3 player, and a cold beer. Ahhh, bliss.

I'm not entirely sure whether recent events are karma's equivalent of the cash-back bonus, or if I've just taken out a karma-equity loan that'll eventually catch up to me, but for now I'm just going to enjoy feeling happy.

Read and Post Comments

Fantastic Timing

Naturally, right at the height of the iPhone hooplah, the USB ports on the back of my 23" Apple Cinema Display would decide to die a sad and lonely death.

I woke up this morning to find that neither my keyboard nor mouse (the USB devices attached to the back of the ACD) would wake Serenity from its slumber. I gently caressed the power button on the front to trigger it to wake, and found that mouse and keyboard had left the building; it was totally unresponsive. I tried both ports on the back of the ACD and had the same result. So, like a good little geek trained in the scientific method, I started isolating variables, testing each of the USB ports on the Mac Pro itself (all good), testing other USB gizmos in the display (no joy), testing the display against each USB port on the Mac Pro (also no joy), testing a different keyboard and mouse against the display (nothing) and each of the ports on the box itself (all fine), and finally testing the display plugged into an entirely different Mac (still no luck).

My super-awesome wife has volunteered to call Apple tomorrow since I missed the cut-off time for the Apple Care hotline. I strongly suspect that Saturday or Sunday will involve another trip out to the Genius Bar, which I'm sure will be a delightful place to visit among the throngs of prospective iPhone buyers... Snarf. Hopefully they can just swap it out with a new display since it's still under warranty (just barely six months old!); I'd really hate to be without a display for days or weeks.

Meanwhile, I've discovered that there is great wisdom in never throwing out extra cables. (Hooray for USB extenders!)

Read and Post Comments

Awesomeness in the Absence of Awesomeness

Three cheers for my amazing wife, who this morning kicked my ass, made me go work out, and called Apple while I was taking out my frustration on the elliptical machine. She is a saint for putting up with me when I'm being a whiny little bitch (fairly infrequent these days, but still happens now and then).

After going through all of the standard stuff with Liz (to no avail), Apple scheduled an appointment for us, so this afternoon gets a surprise road trip with the MacPro. Let's just hope my precious doesn't have to be at the shop for too long... Either way, my computer-related plans for the weekend are pretty much shot.

Read and Post Comments

The Opposite of Awesome

This evening, my MacPro decided that "restart" was an important and necessary part of "wake from sleep." It starts to wake normally, but hiccups and suddenly it's booting again. I've done just about everything I can do to it over the past three hours, including a complete restore from the install media, and it still persists in its little delusion. I may try shifting it to another circuit or swap in different UPSes or surge protectors or something (maybe my UPS got pissed and can't cope with the power dip needed to wake the machine?).

It's safe to say that I am not very happy about this turn of events.

Read and Post Comments

Comic Life

So I discovered the other day that my new Mac came bundled with Plasq's nifty Comic Life, a program that lets you easily drop your photos and other images into comic book layouts, add effects and word balloons, and generally cause you to lose track of time.

I started putting together a simple page last night to see what it could do, and show Liz how cool it was, and it kind of got out of hand after that--becoming a three-page mini story of going to our friends' wedding in October:

It has a few little quirks that annoy (trying to get the right thing selected can be tricky once it's been dropped into place, and the fancy lettering really doesn't like to export to PDF without a fight), but it's probably one of the most fun and imaginative apps I've played with in a long, long time.

Read and Post Comments

Next Page »