Insights on Ruby, Git, jQuery, Cappuccino, WordPress, Debian and OS X. Please subscribe if you find something useful!

Run OS X System Profiler From Terminal

Posted: September 9th, 2009 | Author: Jerod | Filed under: OS X | Comments

OS X’s built-in System Profiler provides a great graphical display of pretty much anything you’ll want to know about your Mac.

profiler

That’s cool and all, but what if you want to access that information programmatically? Turns out you can also run the System Profiler from the terminal by executing this command:

jerod@mbp:~$ /usr/sbin/system_profiler

What’s great about this access method is that it allows you to slurp that data into any other program and have your way with it! For instance, I wanted to track my new battery’s cycle count and charge capacity over time. Why? I dunno, because I’m a geek, okay, get off my back!… Anyways, with the system_profiler command I simply run this little Ruby script every day:

1
2
3
4
5
6
7
8
9
10
require 'date'
 
data      = `/usr/sbin/system_profiler SPPowerDataType`
cycles    = data[/Cycle count: (\d+)/, 1]
condition = data[/Condition: (\w+)/, 1]
capacity  = data[/Full charge capacity \(mAh\): (\d+)/, 1]
 
File.open('/Users/jerod/Documents/battery_history.csv', "a") do |file|
  file.puts "#{Date.today},#{cycles},#{capacity},#{condition}"
end

Ruby uses the (possibly familiar) backticks (line 3) to capture output from a shell command. All that was left for me to do was to parse the raw data and save it to a CSV file.

Finally, note that the my script is passing SPPowerDataType as an argument which narrows down the returned results. You can learn more about how to use the system_profiler command by readings its manual. Just:

jerod@mbp:~$ man system_profiler

Kill Snow Leopard’s Blue Ring of Exposé

Posted: September 1st, 2009 | Author: Jerod | Filed under: OS X | Tags: , | Comments

Looks like I’m not the only one who hates Snow Leopard’s blue ring around selected windows in Exposé.

Thankfully, we don’t have to live with such monstrosities. Here’s a quick fix to free yourself from the blue haze. Fire up Terminal.app, then:

1
2
3
4
cd /System/Library/CoreServices/Dock.app/Contents/Resources/
sudo mv expose-window-selection-big.png expose-window-selection-big.ugly
sudo mv expose-window-selection-small.png expose-window-selection-small.ugly
sudo killall Dock

This will disable the blue rings altogether, but you may want to replace these two images with some custom ones that look a little cooler instead.

Let me know via the comments or on Twitter if you find some replacement images!

***UPDATE***

My friend Doug provided some drop-in replacement images that are a huge improvement. Just drop them into the directory after renaming the default images. So after step #3 above, do:

4
open .

This will open Finder in the current directory. Now drag the replacement images into this directory, provide your password, and kill the Dock.

5
sudo killall Dock

VoilĂ !

DOWNLOAD HERE


PHP5 with readline support on OS X

Posted: June 6th, 2009 | Author: Jerod | Filed under: OS X | Tags: , , | Comments

OS X ships with PHP5 installed but it does not have readline() support compiled in. Anybody using PHP from the command-line will want this, as it allows handy things such as tab completion and scrolling through command history using the up arrow.

Thankfully, MacPorts has a readline variant that can be easily installed:

sudo port install php5 +readline

If you execute the command above, apache2 will come along for the ride because it’s a default variant for the PHP5 port. If you don’t want apache2 (OS X ships with apache2 anyways), modify the command to look like this:

sudo port install php5 -apache2 +readline

Not sure if your PHP install has readline support? Execute this one-liner to find out:

<? echo function_exists('readline') ? "yes\n" : "no\n"; ?>

Tweetie Has Arrived

Posted: April 21st, 2009 | Author: Jerod | Filed under: OS X | Tags: | Comments

The anointing of an OS X application:
dockit


My Perfect OS X FTP Server

Posted: July 17th, 2008 | Author: Jerod | Filed under: OS X | Tags: | Comments

I don’t like FTP. Reasons abound, but to list a couple:

  1. Too complex to configure
  2. Insecure by default

But lets face it, sometimes you need to set up a quick and dirty FTP server for one-time use. Sure, OS X supports FTP file sharing natively but its a bit clunky because you have to either A) allow Anonymous access, or B) create a user account on your system and set up sharing on it. Lame.

There are many freeware,and shareware FTP clients but not too many servers. After a cursory review of all the offerings on IUseThis, I settled on PureFTPd Manager which is a free and open-source front-end for PureFTPd…and what a great choice I made.

Why does this app rock my socks off?

  1. Dead simple configuration – nice GUI walks you through everything
  2. Virtual users – one new system account and endless virtual users it can represent
  3. Logs and live status updates from GUI
  4. Uninstalls in a few clicks
  5. SSL/TLS support