Ubuntu and PCMCIA card



  3. Reboot



Herp Derp YouTube comments

Herp Derp now has a dedicated page!


MacBook Air 13″ vs Dell Inspiron 6000

Two MacBook Airs could live inside the lid of the Dell Inspiron 6000.


Cloning a drive the ‘dd’ way





Copying from the image file to the new drive:

  3. Type in a terminal:




Arduino Gadgets


Pretty stoked to finally get one! So far I’ve dissected an old RC car and turned its wireless receiver board / remote into a volume controller for my Mac. I foresee many cool projects…


Nagios alerts using sSMTP



1. Install sSMTP and mailx

sudo apt-get install ssmtp mailx

2. Configure sSMTP by editing /etc/ssmtp/ssmtp.conf

# Config file for sSMTP sendmail
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
root=[your user account]@[]

# MX records are consulted. Commonly mailhosts are named

# Where will the mail seem to come from?

# The full hostname
hostname=[some hostname here]
AuthUser=[your user account]@[your domain]
AuthPass=[your password]

# Are users allowed to set their own From: address?
# NO - Use the system generated From: address


sudo chown root:nagcmd /etc/ssmtp/ssmtp.conf
sudo chmod 640 /etc/ssmtp/ssmtp.conf





sudo -vvv ssmtp



jQuery Nivo Slider + WordPress JavaScript error

I don’t know if you can really call this a bug, but it’s certainly something that needs to be dealt with. After implementing the jQuery Nivo Slider plugin (which is great when it works), I was getting the following error in the JavaScript console in Chrome during every image transition:

Uncaught TypeError: Cannot call method 'substr' of undefined

The transitions were working, but the previous image wasn’t ‘overlayed’ by the next image – it would just disappear and the new one would appear. It was almost like something else was there. Looking back at my ‘raw’ HTML code in the WordPress post, I had all three images in sequential order, but neatly aligned by pressing enter after each. What I didn’t know was that WordPress, even in HTML mode, was adding <br /> tags after I pressed enter, causing this problem.

Solution: Make the <img> tags back to back on the same line, thus removing the automatically generated <br /> tags.


Going back to the black Twitter app icon


1. Download the original icon here
2. Open up Applications and find the Twitter app
4. Go to Contents, then Resources
6. Put in your password if prompted
8. Click ‘Replace’ when prompted
9. Put in your password if prompted




Changing an LCD string on a Dell server remotely with Python

Here’s a little Python script I cooked up for work. We often have to change the custom LCD string on boxes if the machine is given a new name. Before, we’d have to restart a machine to access the DRAC configuration to change the name. With this script, all you have to do is enable IPMI through the DRAC remotely (if it isn’t already enabled), and know the correct credentials.

If the LCD isn’t set to view the custom string, you should be able to change it from the front of the box. As you can see, the function that I have commented out at the bottom is supposed to do this for you, but I never got it to work.

You may have to change ‘/usr/sbin/ipmitool’ to your appropriate path.

import os

# Tanner Stokes - - 2-26-10
# This script changes the LCD user string on Dell machines that conform to IPMI 2.0

sp_hostname = raw_input ("\nEnter DNS or IP of SP: ");
user_string = raw_input("Enter LCD string: ")

hex_string = ""

for x in user_string:
 	hex_string += hex(ord(x))
	# add space between each hex output
	hex_string += " "

print '\nTrying to change LCD string on '+sp_hostname+'...'

return_val = os.system('/usr/sbin/ipmitool -H '+sp_hostname+' -I lan -U root raw 0x6 0x58 193 0 0 '+str(len(user_string))+' '+hex_string)

if (return_val == 0):
	print 'LCD string changed successfully.\n'
	print '\nNon-zero return value, something went wrong.'
	print 'Make sure IPMI is enabled on the remote host and the DNS or IP is correct.\n'

# this function supposedly sets the user string to show on the LCD, but never got it to work
# this can be changed from the front of the box anyway
# os.system('/usr/sbin/ipmitool -H '+sp_dns+' -I lan -U root raw 0x6 0x58 194 0')

Sending Growl messages over a network with Python

6-6-12 – This script is really old and may not work with current versions of Growl. There are some good libraries to choose from and I’d recommend looking at them instead.

Updated 12-4-10 – minor code updates
I have yet another script. This one is actually my first one in Python, which is kind of sad after all the good things I’ve heard about the language. This time I didn’t actually write the entire script – I simply added to one that had already been written to give it more functionality.

The original script was found here: and almost all credit goes to it’s author, as I only added a little bit more to it.

What this version does is send a Growl message over UDP to a Mac (running Growl and configured to listen for incoming notifications) using Python. I thought this was really cool – I could script my remote Linux machines (or whatever OS) to send messages to my main Mac.

What I added was the ability to have command line arguments so that it would be easier to change options on the fly and also easier to script.

Running ./ -h will give you the following:

#!/usr/bin/env python

# Updated 12-4-2010
# Altered 1-17-2010 - Tanner Stokes -
# Added support for command line arguments

# """Growl 0.6 Network Protocol Client for Python"""
# __version__ = "0.6.3"
# __author__ = "Rui Carmo ("
# __copyright__ = "(C) 2004 Rui Carmo. Code under BSD License."
# __contributors__ = "Ingmar J Stein (Growl Team), John Morrissey (hashlib patch)"

  import hashlib
  md5_constructor = hashlib.md5
except ImportError:
  import md5
  md5_constructor =

import struct
# needed for command line arguments
import sys
import getopt

from socket import AF_INET, SOCK_DGRAM, socket


def main(argv):

    # default to sending to localhost
    host = "localhost"
    # default title
    title = "Title"
    # default description
    description = "Description"
    # default priority
    priority = 0
    # default stickiness
    sticky = False

    # if no arguments are given, show usage
    if(len(argv) < 1):

        opts, args = getopt.getopt(argv, "hH:t:d:p:s")
    except getopt.GetoptError:
    for opt, arg in opts:
        if opt in ("-h"):
        elif opt in ("-H"):
            host = arg
        elif opt in ("-t"):
            title = arg
        elif opt in ("-d"):
            description = arg
        elif opt in ("-p"):
            # acceptable values: -2 to 2
            priority = int(arg)
        elif opt in ("-s"):
            sticky = True

    # connect up to Growl server machine
    addr = (host, GROWL_UDP_PORT)

    s = socket(AF_INET,SOCK_DGRAM)
    # register application with remote Growl
    p = GrowlRegistrationPacket()
    # send registration packet
    s.sendto(p.payload(), addr)

    # assemble notification packet
    p = GrowlNotificationPacket(title=title, description=description, priority=priority, sticky=sticky)

    # send notification packet
    s.sendto(p.payload(), addr)

def usage():
    print """Usage: ./ [-hs] [-H hostname] [-t title] [-d description] [-p priority]
Send Growl messages over UDP
  -h help
  -H specify host
  -t title
  -d description
  -p priority [-2 to 2]
  -s make sticky"""

class GrowlRegistrationPacket:
  """Builds a Growl Network Registration packet.
     Defaults to emulating the command-line growlnotify utility."""

  def __init__(self, application="NetGrowl", password = None ):
    self.notifications = []
    self.defaults = [] # array of indexes into notifications
    self.application = application.encode("utf-8")
    self.password = password
  # end def

  def addNotification(self, notification="Command-Line Growl Notification", enabled=True):
    """Adds a notification type and sets whether it is enabled on the GUI"""
    if enabled:
  # end def

  def payload(self):
    """Returns the packet payload.""" = struct.pack( "!BBH",
                             len(self.application) ) += struct.pack( "BB",
                              len(self.defaults) ) += self.application
    for notification in self.notifications:
      encoded = notification.encode("utf-8") += struct.pack("!H", len(encoded)) += encoded
    for default in self.defaults: += struct.pack("B", default)
    self.checksum = md5_constructor()
    if self.password:
       self.checksum.update(self.password) += self.checksum.digest()
  # end def
# end class

class GrowlNotificationPacket:
  """Builds a Growl Network Notification packet.

  def __init__(self, application="NetGrowl",
               notification="Command-Line Growl Notification", title="Title",
               description="Description", priority = 0, sticky = False, password = None ):

    self.application  = application.encode("utf-8")
    self.notification = notification.encode("utf-8")
    self.title        = title.encode("utf-8")
    self.description  = description.encode("utf-8")
    flags = (priority & 0x07) * 2
    if priority < 0:
      flags |= 0x08
    if sticky:
      flags = flags | 0x0100 = struct.pack( "!BBHHHHH",
                             len(self.application) ) += self.notification += self.title += self.description += self.application
    self.checksum = md5_constructor()
    if password:
       self.checksum.update(password) += self.checksum.digest()
  # end def

  def payload(self):
    """Returns the packet payload."""
  # end def
# end class

if __name__ == '__main__':

    # send command line arguments to main() function