April 1st, 2007
I’ve been using Autotest (part of the ZenTest package) while testing my Rails applications and never thought of asking for more. After all, getting my tests (well, specs actually) run automatically whenever I make a relevant change and having diff-level granularity on which tests Autotest re-runs is pretty damn useful enough. That is, until I came across this RSpec and Autotest with Growl notifications blog entry (on JavaBlogs, no less!)
How’re these for red/green test results?
Tests (specs) passing!
Tests (specs) failing :(
Much better! Now I don’t have to glance at my terminal window (I recently realized how painful it is while coding with a single monitor) and get unobtrusive notifications.
Unfortunately, this is Mac-only (or wherever Growl is supported). I had to follow links to several blog entries to get it setup nicely (see Growl + Autotest Rails with Zentest 3.4.0 and Green goodness with autotest + growl - those are my references).
Basically you need Growl installed, and the growlnotify tool in your path. growlnotify can be found in the Extras/growlnotify directory in the Growl dmg (for example, after you’ve mounted the Growl-0.x.x.dmg, you can find it here: /Volumes/Growl/Extras/growlnotify). Just copy the growlnotify executable into your path (I copied it into /opt/local/bin since I’m using Darwin Ports and don’t have a /usr/local/bin directory). Verify it’s running by entering:
growlnotify -m "Testing growlnotify" Boo Ya!
into a terminal window. You should see a Growl notification.
Now, you need to create an Autotest hook by creating an autotest init file in your home directory named .autotest, and copy this chunk of text in:
module Autotest::Growl
def self.growl title, msg, img, pri=0, sticky=""
system "growlnotify -n autotest --image #{img} -p #{pri} -m #{msg.inspect} #{title} #{sticky}"
end
Autotest.add_hook :ran_command do |at|
output = at.results.last.slice(/(\d+)\s.*specifications?,\s(\d+)\s.*failures?/)
if output =~ /[1-9]\sfailures?/
growl "Test Results", "#{output}", "/Data/Pictures/Icons/rails_fail.png", 2, "-s"
else
growl "Test Results", "#{output}", "/Data/Pictures/Icons/rails_ok.png"
end
end
end
Replace the paths to the pass/fail icons (as you can see, mine are in /Data/Pictures/Icons/) with the correct paths to any images you want to display (grab them from Green goodness with autotest + growl or roll your own). You can change the parameters passed to growlnotify however you want (use growlnotify -h to see what parameters it acccepts). The pri parameter sets the priority level of the message (test failures come up with a priority of 2, hence the red background of the Growl notification). Passing -s to sticky tells Growl to keep the notification sticky. If you’re running your (auto)tests on a remote server (e.g. in a Continuous Integration system), you can even use growlnotify to send remote notifications (see the -H switch) to your development workstations!
Lovely! I love you, MacBook Pro serial no. W86280NAVWW (despite your broken DVD drive and you randomly freezing up on me when you get too hot).
February 25th, 2007
Yup I switched to Apple Mail from Thunderbird a few months back, primary reason being back then I was barely able to run my developer applications on 512MB of RAM (Apple Mail runs lighter than Thunderbird, unfortunately). It’s comforting to find that there is an IMAP-IDLE plugin for Apple Mail (Thunderbird got its IDLE support way back in 2004.)
What’s IDLE? Well, quoting myself:
Simply put, IDLE is a command that allows IMAP email servers to transmit updates to the client in real time. This saves the client from having to continuously poll the server to achieve the effect of new mail appearing immediately. All in all, an exceptionally useful command that saves Thunderbird the work of polling IMAP servers continuously.
So anyway, it’s really simple to install and use (just simple checkboxes for enabling IDLE for your IMAP accounts).
Remember to configure Mail to stop polling these mail accounts every X minutes or so now. Enjoy the geeky feeling of knowing you’ve just saved several CPU cycles and a few kilobytes of bandwidth.
February 5th, 2007
Not too long ago I was asked to use hook up the Mac Mini that was collecting dust in our office to our HP Deskjet printer (HP Deskjet 1280 to be exact) and have it function as a “print server” of sorts (we have since replaced it with a NAS with print server functionality, which subsequently broke - that’s how long this post has been sitting in my drafts folder). While setting it up to be shared with Mac machines was a cinch (we have a grand total of 3 Mac machines in the office, including the Mac Mini and my treasured MacBook Pro), sharing the printer from the Mac (Mini) to Windows machines was significantly more difficult. After some trial and error, first with what made the most sense, and then with stuff I could glean off the Internet, I finally arrived at something that works. Maybe this would be useful for the next unfortunate bloke that needs to do this sharing of printers from Mac to Windows machines without a print server.
First point of reference: Print from Windows XP to a shared Mac printer tip on Mac OS X Hints. The tip suggests you select a PostScript driver in Windows after finding it on the network (which requires you to do several things first, but we will come to that later). This worked, but it was sub-optimal because you couldn’t use the printer driver software to do stuff like 2-up printing (i.e. print 2 pages per side per sheet). This post will show you how to share a USB printer from Mac OS X to Windows PCs with full driver capability.
- On the Mac (the one that the USB printer that you want to share is connected to), go to the Sharing preferences pane and ensure Printer Sharing and Windows Sharing are both turned on.
- Fire up your browser and go to http://127.0.0.1:631 - this is the web interface to CUPS. When asked to enter a password, login with your Mac OS X user account (it has to be an administrator account).
- Go to the Printers tab and add a new printer (yes, in addition to any existing printer configuration that already exist for the same printer). Choose a name that’s short and descriptive (no spaces). For the purposes of this guide, let’s call it ‘uberprinter’. Best to keep it under 12 characters since Windows is finicky.
- When asked to select a device, select USB printer.
- You’ll be asked for a Device URI. To find out, open up a terminal and type
lpinfo -v. You should see your USB printer coming up. Mine came up as ‘direct usb://HP/Deskjet%201280?serial=CN516851RPUN’. Copy and paste this (without the ‘direct’ part - i.e., I’d have copied ‘usb://HP/Deskjet%201280?serial=CN516851RPUN’) into the ‘Device URI’ field.
- Select a ‘Make’ of ‘Raw‘. Keep going until the printer is added.
- You’re done configuring from the Mac. But before you go, determine your Mac’s IP address (do a ‘ifconfig’ in a shell or fire up System Profiler and check out the ‘Network’ item) - note it down somewhere. Now it’s time to hook up your Windows machine to use the shared printer.
- OK now go to your Windows machine and add a new printer (Control Panel -> Printers and Faxes). Select ‘A network printer… blah blah’. Don’t browse for the printer, you will enter its IP address directly in the ‘URL’ field. Enter ‘http://your.macs.ip.address:631/printers/uberprinter’ (replacing ‘your.macs.ip.address’ with your Mac’s IP address and ‘uberprinter’ with the short name you gave your printer). If you can’t remember your printer’s name, just scurry back to the Mac and browse to http://127.0.0.1:631/printers/. You should be able to see the printer you added listed there - its name is linked there.
- Now, all that’s left is to install the correct Windows printer driver on the Windows machine. If you’re lucky Windows already has your driver, if not do whatever you need to get the proper driver - after all, the purpose of jumping through all these hoops is to get full printer driver functionality off the shared Mac printer.
That’s it. That’ll teach you for not getting a print server or one of those new printers with network functionality.
Problems?
Some readers wrote in with their own difficulties and have kindly allowed me to share their solutions. First off, Patrick McKrell who had a solution for cases where you still are just not able to print from the Windows machine (it involves killing a daemon so it’s pretty sweet).
Thank you for making available your instructions for sharing a USB printer connected to a Mac using OS X with a Windows PC. All of your points worked flawlessly on the Mac. My Mac is a B&W G3 running OS X 10.2.8. The printer is an HP PSC 1510.
…
Back to Windows Add Printer. Is my driver there? No. I browsed the Windows file system to Program Files/HP/. No luck. Couldn’t find or add my driver. Next I unplugged the printer’s USB cable from the Mac and into the PC. Windows detected the new hardware, created whatever files it needed, and automatically created the USB-connected PSC 1500 series printer in Printers and Faxes. Well, that’s pretty darn close. I opened the printer’s properties, changed the port from USB to Internet Port (as per your configuration guidance), sent a print job….and nothing. Hmmm.
Finally, I recalled seeing someone’s web post –thanks to your point of reference. I followed the poster’s instructions, and, yeah, it prints, and in color. Thanks again, Chu, for your post. It was easy to follow, and importantly, it worked with my setup (despite the color issue).
Patrick McKrell
The solution? Change your CUPS configuration to allow raw printing:
Basically, I saw that every job on the windows side had “error”.
After looking at the error logs for cups on the mac box (/var/log/cups/), I noticed this line repeatedly:
print_job: Unsupported format ‘application/octet-stream’!
Did some googling, and found a post with the answer:
>
> You probably need to uncomment the following lines in
> /etc/cups/mime.types and /etc/cups/mime.convs:
>
>
> /etc/cups/mime.types:
> #application/octet-stream
>
>
> /etc/cups/mime.convs:
> #application/octet-stream application/vnd.cups-raw 0
> -
>
>
> That will allow raw printing.
Then, kill -HUP the cups daemon, and you’re good to go.
December 26th, 2006
VLC media player 0.8.6 (changelog) was released a few weeks ago so this may be old news, but I am clearing my backlog of drafts.
Mac OS X users, if you watch videos in full screen mode (like I do most of the time), you’d be delighted to know that they added a full screen controller à la the video player in iTunes:
That was one of my pet peeves with VLC when I was still using Windows as my main desktop OS, and I’d stayed true to Media Player Classic right to the point where I switched to OS X. Media Player Classic is Windows-only, so I had to switch to VLC as well (QuickTime player never impressed me and I wasn’t willing to pay for the Pro version). The lack of a full controller in full screen mode and the inability to move to specific spots in the video timeline with sufficient granularity seems to have been fixed with this new full screen controller panel.
And while they still haven’t made it possible to pause a video by clicking on the video output (which was the case in Media Player Classic), I’ve mostly compensated for it by hitting the space bar. Now that they’ve added a right-click context menu to the video output screen, the same can be done but in 2 clicks with just the mouse - not optimal but it does feel better to see a context menu pop up when right-clicking. I guess that’s the Windows user in me talking - I still feel that almost everything I see should have a context menu or it just feels wrong.
Oh and they added support for the Apple Remote Control. Works great, I just have to remember to take out my remote control and use it next time I’m sitting back watching a movie or anime.
December 14th, 2006
Saw this in a MacDonald’s at a local shopping mall:
If you can look past the fuzziness of the photo, it’s actually someone using a HP laptop with an Apple sticker. Now, if only I can get a HP sticker for my MacBook Pro…