Fork me on GitHub

Drew's World

Rants, News, Etc on my Life and Projects

Western Digital MyPassport

by Andrew De Ponte (@cyphactor)

So, recently I bought a Western Digital (WD) MyPassport portable 500GB hard drive. I found when plugging it in that it had a very annoying Virtual CD built into its firmware called WD SmartWare which I was not the least bit interested in using. All, I wanted was an external USB hard drive that was portable and just worked. So, the first thing I tried was to reformat it to a Journaled Mac OS X file system. Once, I reformatted it, I was able to copy files too and from the external drive just like I wanted to be. However, every time I plugged the external drive in it would also mount this stupid Virtual CD which I didn’t want to deal with.

So, I googled around a bit for a way to stop this thing from mounting and coming up every time I plug the external drive in. I found a bunch of articles outlining how to update the firmware on the external hard drive and a bunch of very long step by step processes all just to get this stupid Virtual CD to go away. Soon, enough I found the answer I was looking for. It was simply to grab the UUID of the Volume by using the following command:

diskutil info /Volumes/WD\ SmartWare/

Once, I had the UUID of the Volume then I created the /etc/fstab file and added the following line to it.

UUID=84789472-2EB5-3C8E-BFC1-F554F91B026C none hfs rw,noauto 0 0

In my opinion this was a much better solution as it just disabled the auto mounting of that volume and didn’t require a firmware flash or anything crazy just to get rid of the stupid Virtual CD. Anyways, I probably made this post more for me than any of you. Though, hopefully someone else finds this tid bit useful as well.

Fat Fingered my MacBook Air

So I setup my MacBook Air right after I got it and was just using the basic functionality. I then realized that I needed root to do something. Yep, you guessed it, I some how managed to to fat finger my root password when I setup the initial Admin user in the setup process. This is normally not a big deal as you can always put the DVD back in and rerun the setup wizard to create a new user. However when you are a MacBook Air and have no DVD drive it gets to be a tad bit more complex.

The key is single user mode. After some googling I found that you can easily get into single user mode on Mac OS X simply by rebooting and right after the Chime noise holding Command-S and it will start you up into single user mode. For details on single user mode please go here.

When you see the prompt for single user mode it will tell you two commands to run to make it so that you can modify the file system. One is a fsck command and the other is a mount command. I simply ran the two commands as the info above the prompt instructed me to. Once it was done running those commands, I ran the following command and rebooted so that it would start the initial setup process over again. I did this because I knew that if I created a new Admin user and knew its password I could then sudo in and change the password of my existing Admin user that I previously fat fingered the password for.

rm /var/db/.AppleSetupDone

I know that there are command line tools that allow you to change passwords, etc. in Mac OS X, but for some reason I wasn’t feeling like looking up the directions on how to use them. Hence, I just did it this way. Figured I would share my find on Single User Mode, :-). I am sure someone has already found it, but it is new to me.

A Quick Multi-Source Ticket Dashboard

by Andrew De Ponte (@cyphactor)

Today was one of those days where I woke up and something was just off with respect to my workflow for some reason. I was frustrated with the fact that I had to load a browser and go to a website to see what my tickets were for the day. Instinctively I just wanted my tickets to magically be in my head so I didn’t have to go through all those steps. So, I started thinking about this problem more and more as the day went by and I came to the conclusion that I really have two problems.

  1. I have tickets dispersed through multiple ticketing system.
  2. I hate having to go through so many steps to see my tickets.

When I started thinking about my two problems I realized that I have my tickets in roughly four different applications/services. These applications/services are as follows:

  • Trac - Web based project management/task management tool
  • Lighthouse - Web based project management/task management tool
  • GitHub - Web based Git repository management system and issue tracking tool
  • Things - Desktop task management system

Beyond having multiple ticket sources, most of them have multiple accounts for various reasons (contract jobs I have done, etc.). Being in a specific environment while working within that scope/environment is fine. For example if I am working on Project X it makes sense that I be in project X’s environment. However, the situation that I am frustrated with is the initialization and transition periods which exist before you start working on a project and when you are switching from one project to the next project.

Based on my issues and the situation I am frustrated with I have come up with a small set of requirements for a solution. These requirements are listed below.

  1. Tickets from all ticket sources must exist in a dashboard
  2. This dashboard must require zero effort/steps to view it
  3. This dashboard must automatically update with zero effort/steps

As many of you know despite the fact that I write software for various platforms and in various languages my platform for development is generally Mac OS X. Given that Mac OS X was my environment, I started thinking about this requirement set and thinking about how I could make something that required zero effort/steps to view it. The closest thing I could come up with was having my tickets displayed on my desktop. After a few minutes of googling based on that idea I found an awesome tool for Mac OS X called GeekTool. Among other things, GeekTool will run shell scripts/console applications for you on a set frequency and display their output to a defined section of your desktop. This was perfect in my opinion so I played with it for a few minutes and decide that I was going to use GeekTool.

Given the functionality of GeekTool all that was really left was to write shell scripts/console applications that output all of my tickets from the various ticket sources and I would have a very quick and functional solution to my issue. Hence, I got to writing and pumped out the following short little Ruby scripts, and one AppleScript script to provide output of all my tickets from the various sources.

The following is a ruby script that pulls all my tickets in from all of my various Lighthouse accounts and projects.

#!/usr/bin/env ruby
require 'rubygems'
require 'lighthouse-api'

include Lighthouse

accounts = ['domain one', 'domain two', 'domain three']
Lighthouse.token = 'your lighthouse All Accounts token'

accounts.each { |a|
  Lighthouse.account = a
  Project.find(:all).each { |p|
    if (!p.archived)
      ticks = p.tickets({:q => "responsible:me sort:priority state:open"})
      if (ticks.length > 0)
        puts p.name
        puts "-------------------------"
        puts "    id | pri | title"
        puts "-------------------------"
        ticks.each { |t|
          puts t.id.to_s.rjust(6) + " | " + t.priority.to_s.center(3) + " | " + t.title
        }
        puts "\n"
      end
    end
  }
}

The following is a ruby script that pulls all my tickets in from all of my various GitHub accounts and projects.

#!/usr/bin/env ruby

require 'rubygems'
require 'octopi'

include Octopi

creds = [
  { :login => "login one", :token => "API token tied to login one" },
  { :login => "login two", :token => "API token tied to login two" },
  { :login => "login three", :token => "API token tied to login three"}
]

creds.each { |cred|
  authenticated_with :login => cred[:login], :token => cred[:token] do
    user = User.find(cred[:login])
    repos = user.repositories
    repos.each { |r|
      ticks = Issue.find_all(:repository => r, :state => "open")
      if (ticks.length > 0)
        puts r.name
        puts "-------------------------"
        puts "    id | pri | title"
        puts "-------------------------"
        ticks.each { |t|
          puts "n/a".rjust(6) + " | " + t.votes.to_s.center(3) + " | " + t.title
        }
        puts "\n"
      end
    }
  end
}

The following is a AppleScript script that pulls all my tickets in from Things.

tell application "Things"
  set nl to "\n"
  set output to "Things Tasks in Today\n--------------------------\n"
  repeat with todayToDo in to dos of list "Today"
    set curTaskName to name of todayToDo
    set output to output & " - " & curTaskName & nl
  end repeat
end tell
output

The following is a Python script that pulls all my tickets in from Trac when your Trac environment has the Trac XML RPC plugin installed.

#!/usr/bin/env python

import xmlrpclib

username = "loginname"
password = "password"
port = None # if need to specify a port set this to the port number
host = "domain-name-where-trac-hosted" # trac.rippletv.com at my work
path = "/path-to-the-environment"

url = "https://%s:%s@%s" % (username, password, host) 
if (port):
    url += ":%s" % (str(port))
url += path + "/login/xmlrpc"

svr = xmlrpclib.ServerProxy(url)

print "-------------------------"
print "    id | pri | title"
print "-------------------------"

ticket_ids = svr.ticket.query("owner=" + username + "&status!=closed&order=priority")
for ti in ticket_ids:
  cur_tick = svr.ticket.get(ti)
  cur_tick_hash = cur_tick[3]
  cur_id = ti
  cur_summary = cur_tick_hash['summary']
  cur_priority = cur_tick_hash['priority']
  pri_num = 0
  if (cur_priority == "trivial"):
    pri_num = 0
  elif (cur_priority == "minor"):
    pri_num = 1
  elif (cur_priority == "major"):
    pri_num = 2
  elif (cur_priority == "critical"):
    pri_num = 3
  elif (cur_priority == "blocker"):
    pri_num = 4
  print str(cur_id).rjust(6) +  " | " + str(pri_num).center(3) + " | " + str(cur_summary)

After coding the above scripts I simply set them up through the GeekTool UI and like magic within 15 mins or so I had a working solution to my issue, thanks to the power of REST based Web Services, Ruby, the Ruby Community, and Things AppleScript integration. Checkout a screenshot here.