RackspaceCloud Command Line Tool

June 26th, 2009

My business partner Josh and I have started a new venture, Busted Loop. As part of that venture, we are making stuff and blogging about it. Today was my turn and I blogged about a tool I created, The RackspaceCloud Command Line Tool.

There will be more stuff in the coming weeks. I hope some of you will follow along… It won’t all be as geeky as this post… well.. pretty geeky, but not quite this geeky.

danb , ,

My Stand Up Workstation

April 20th, 2009

I work from home 4 out of 5 days. For the last few years I have spent the majority of my working hours on the couch in front of the TV. About 2 months ago I decided I was going to stand up to do my work. Here is how I was set up when I started standing:

old_full

And here is how I ended up:

new_full_cropped

To help with scale… the first picture is my old 15″ Mac Book Pro and a 19″ CRT. The second picture is my new 17″ Mac Book Pro and a 24″ LCD.

The entire setup is sitting on a standard cheapo corner desk from Staples.

The laptop is on a Plexiglas shelf. The LCD is mounted on the copper stand, not the wall. The keyboard and mouse stand is not attached to the laptop/monitor stand.

The laptop is very accessible so it’s quick and easy for me to yank it off the stand and go to the office or back to the couch for a movie.

The whiteboard I affixed to the tilted area in front of the keyboard has come in extremely handy a number of times.

I had planned on doing a detailed write up on how I built this thing…. but, it’s been a month now and the mojo is gone. I’ll just bust out some “highlights”… I’m happy to answer any questions you have.

I built the structure entirely out of copper pipe and rivets and I made the shelves from Plexiglas. It took me about 30ish hours to complete… Much of that time was spent experimenting and wasting materials.

The monitor is about 2-3 inches higher than my initial design (the top of the laptop and LCD should be flush) because I ordered the wrong mount and was too impatient to wait for a new one… so I “fabricated” an “adapter” out of some random junk… and two Isaac Asimov novels… really. I’ll get around to fixing that.

You may not have noticed the mood lighting… I added a small lamp behind the whiteboard which gives me decent light at night without having the overheads on.

Here’s a shot from during construction:

construction

I stuck with stock plumbing parts from Home Depot… Which means I basically have elbows, t-joints and straight bits to work with… this led to lots of joints and some interesting angles for stability.

The End.

danb , , ,

Moving Again

March 28th, 2009

I’m moving all my stuff from my godaddy dedicated server to a small group of slicehost slices. This is going to save me about 50% on my hosting bill, but still allow me some scalability when I need it. I really like what I’ve seen of slicehost so far… you can pick your flavor of linux, create new slices that look just like the ones you’ve already set up, or start completely fresh. You get full root access and it’s hard to beat the $20/month starting price. I’m going to start out with 3 slices.. Apache, Tomcat and DB. I’ve had this move on the back burner since mid February and I finally took the plunge over the last few days and finished it up. I’ve moved all my sites and apps and I think I’ve made all the old URLs line up with the new URLs… so it should be “seamless”.

I am also switching off roller, and on to wordpress for this blog… wordpress is much more feature rich than roller. Hopefully it will inspire me to blog more than once a quarter.

In other news… you should check out the clark island boat works blog, my friend Mac does the boat and blog building and it’s pretty interesting to see what goes into one of these boats…. even if you don’t really care about boats. At least give him a click or two.. he watches the damn traffic stats like some kind of junkie.

danb , , , ,

Greasemonkeying Around

November 26th, 2008

UPDATE 2: ok, this greasemonkey script is now outdated.. please use the firefox plugin instead. it has it's own url here. Everything below this point is just history now :)


I have recently started using sparkpeople to track my diet and exercise (we'll see how long that lasts). It's a nice site for the most part, but there are a few features I'd like to see… so instead of just begging for them through official channels, I've started to create them on my own.



The nutrition tracking page shows you your target calories, carbs, fat and protein and the number you have used for the day, but it doesn't show how many you have left of each.



Greasemonkey is a firefox add-on that allows you to install scripts that can interact with web pages as you surf them. You can use this to add additional functionality to web sites you use regularly or combine functionality from multiple websites together.



I have created a greasemonkey script that adds a “remaining” stat to the nutrition page, it looks like this:





If you have the greasemonkey add-on installed, you can click here and install the script. It should do its thing any time you are on your nutrition page.



UPDATE: I am just going to update this post as I add things to this script… I have now added some summary stuff in the side bar, it looks like this:


admin , , , ,

One Small Step For A Politician, One Giant Leap For Mediocrity

November 5th, 2008

History has been made it's very exciting…. Now that that's out of the way… New boss, same as the old boss… From “hope and change” to “more of the same”…



Four years from now things will be the same or worse. The trajectory is pretty much set. Obama will have a mediocre approval rating, so will congress, we will still be at war in the middle east, millions of Americans will not have health-care, the country will still run on coal, oil and gas, unemployment will be between 6 and 10%, lobbyists will still rule Washington… there will be no changes of substance (at least none that originate in Washington DC).



Millions who just had the most exciting political moment in their lives will have their faith in the system torn down anew. Their dreams of telling the grand kids how they played a part in the coming of the new dawn in American history will turn to ash before their very eyes.



The 2010 election will re-balance congress a bit (that season should be starting any day now). That tighter congress combined with mild resistance from the left to Obama's centrist nature, the economy and TWOT will keep meaningful change from happening and the machine will continue to slowly consolidate power while maintaining the status quo. Drastic change is dangerous to both parties in that it could open the door for people with actual ideas and jeopardize political careers that span decades if not generations.



The problems run much deeper than the president; they're pervasive and systemic. Here's an example:







My ballot… all filled out (mostly blank)… (I wrote in Bob Barr, just because I feel the Libertarian party should be on the ballot in every state, not because I like him). Note the complete lack of actual contests, all races are either Republican vs. Democrat or an uncontested Republican or Democrat. How is this a choice? I don't even think I know a single person who's views are represented by the platform of either party. These people represent the political establishment, therefor the establishment always wins. The politicians always win, the political machine always wins.



Congratulations to our new president, I look forward to some more refreshing mediocrity.

admin , , , ,

Calculating Inflated Prices with CPI and Groovy

September 21st, 2008

There have been a few occasions where I have wanted to express historic prices in terms of their inflated value or vice-versa.. e.g. $100 dollars in 2007 was worth about $63 in 1990.



This is actually a very simple thing to calculate… we take the CPI from 2007 (207.34) and the CPI from 1990 (130.65) and do the computation thusly:



$100.0 * (1.0 + ((130.65833333333333 - 207.3424166666667) / 207.3424166666667))



I have written a grails service that grabs the latest CPI data and does this for me… it's just groovy, so it should be easy to use outside of a grails app.


class InflationService {
    boolean transactional = true

    // this is where the live CPI data lives
    String cpiURL = 'ftp://ftp.bls.gov/pub/special.requests/cpi/cpiai.txt'

    // map of year to CPI average String -> double
    def cpiMap = [:]

    // track the last time we updated from the source data,
    // for long lived apps we don't want to get stale.
    long lastLoadTime = 0;

    // always use the current year as the target year
    double calculateCurrentDollars(String fromYear, double value) {
        refreshCPIData(false)

        GregorianCalendar date = new GregorianCalendar()
        def year = date.get(Calendar.YEAR)

        // not sure what the CPI table looks like in january...
        // this should account for no record for the current year...
        // more that 1 missing year is a serious problem
        def toYear = String.valueOf((cpiMap[String.valueOf(year)] != null) ? year : year-1)

        return calculateYearDollars(fromYear, toYear, value)
    }

    double calculateYearDollars(String fromYear, String toYear, double value) {
        refreshCPIData(false)

        def toCPI = cpiMap[toYear]
        def fromCPI = cpiMap[fromYear]
        // here's the actual math...
        // pretty simple when you final get down to it :)         // TODO - check for nulls or zeros and throw exception.
        return value * (1.0 + ((toCPI - fromCPI) / fromCPI))
    }

    // refresh cpiMap if last update was more than 1 day ago
    // OR forceUpdateNow param is true.
    public void refreshCPIData(boolean forceUpdateNow) {
        long oneDay = (1000 * 60 * 60 * 24)
        // update once per day. (or if forced)
        if (forceUpdateNow || (lastLoadTime + oneDay) < System.currentTimeMillis()) {
            lastLoadTime = System.currentTimeMillis()

            // grab the "tabular" data right from The Man
            cpiURL.toURL().text.eachLine {yearLine ->
                // find all the lines that start with a year..
                // these are the useful bits of the doc
                if (yearLine.matches(/^\s+\d\d\d\d\s.*/)) {
                    // split the line up into individual values
                    def yearList = yearLine.split(/\s+/).findAll {it.size() > 0}
                    // the first item is the year.. hang onto that
                    def year = yearList[0]
                    // the rest of the values are CPI values for each month
                    // (some averages at the end that we ignore)
                    yearList = yearList.tail().collect {Double.valueOf(it)}
                    // average all 12 months for every year...
                    // except the current year could have less than 12 months
                    int idx = yearList.size() < 12 ? yearList.size() - 1 : 11;
                    cpiMap[year] = yearList[0..idx].sum() / (idx + 1)
                }
            }
        }
    }
}

here is a simple test.

class InflationServiceTests extends GroovyTestCase {
    InflationService inflationService;

    void test2007to1990Dollars() {
        assertEquals('got wrong answer', 63.01572800870056,inflationService.calculateYearDollars('2007', '1990', 100.0));
    }
}



It shouldn't matter which direction you want to do the conversion in.. 1990 dollars to 2007 dollars or 2007 dollars to 1990 dollars. The data starts in 1913 (the year the federal reserve was created) and runs about a month behind.. so I write this in September 2008 and the CPI is available through August 2008.

admin , , ,

1 out of 4 ain't bad

September 12th, 2008

I saw this on weather.com and laughed out loud… saved here for posterity.. I'm posting before I actually read the story and ruin the joke…





admin ,

A Spam A Day

August 12th, 2008

The aspamaday blog is a fun blog.. The author turns spam subjects into little works of art. Today I sent in a spam subject I received (Who Needs Sex When You Can Steal DNA)… less than two hours later, he made this.

admin , ,

xkcd++

June 11th, 2008

xkcd is a great web comic… nerdy, smart, creative, and fun… It's one of my favorite RSS feeds. Today's comic is brilliant as always… but I felt like I had a slight improvement to make :)

nothing to say.

admin , , ,

Slicing Up Cory Doctorow's Little Brother

May 12th, 2008

I bought the audio book (and hard cover) version of Cory Doctorow's new book Little Brother. It's delivered as a 163 megabyte MP3 file, over 11 hours of spoken word… I have listened to dozens of audio books delivered as podcasts, but I only have one “normal” audio book (The Areas Of My Expertise by John Hodgman… hilarious) which I bought through iTunes, it is broken into 3 (2.5 hour) parts, which is still a bit long for an “episode”. I really prefer the podcast episode per chapter form factor because it caters to my various neurosises and gives me a feeling of progress and accomplishment even when I don't really deserve said feeling.



I listen to my podcasts in three places, my iPhone, my Apple TV, and through iTunes on my MacBook Pro (Holy fanboy, Batman). While the synchronization between the three is pretty good, it can mess up and lose my place in an audio file. This usually isn't an issue because I rarely need more than a sitting to complete any particular file. I suspect that I'm not going to finish an 11+ hour audio book in a sitting… or even 11… so there is bound to be frustration and cursing as I lose my place repeatedly somewhere in the syncing madness.



After some Googling, I found AudioSlicer. In under 30 minutes I had the book split into 26 named sections, intro, chapters 1-21, epilogue, afterword, bibliography, and credits and copyrights. Here is my .split file (unzip it) which you can use with AudioSlicer to split the MP3 you purchase into the same chapters (if you have a mac). When you “Export Splitted” make sure “Filename Format” is “[trackNumber]_[title]_[album]_[artist]“.



Now I could just import these files as a playlist in iTunes, but that's not how I roll… I want everything to be a podcast. Here is the iTunes friendly RSS based podcast feed i created (you'll need to follow the rest of the steps to make that useful, you can't just click that link and subscribe).



Now, take the mp3 files you created, and the podcast feed, and put them in a directory named “lb”… now put that lb directory in “/Library/WebServer/Documents/”. If you have web sharing enabled (System Preferences -> Sharing -> Web Sharing) you should now go to iTunes (or whatever) and go to Advanced -> Subscribe to podcast and paste in “http://localhost/lb/little_brother.xml”



Once the downloads are complete you should have something that looks like this:





All the files are served up locally and should not be available on the network at-large. Once all the chapters are downloaded into iTunes (or whatever) you can delete the lb directory and disable your web sharing (if you don't need it for other stuff, obviously).



I hope this is helpful to someone besides me… if anyone finds an easy way to split the file up on Linux or Windows, let me know.

admin , , , , , , ,