June 28th, 2009

Geektool Setup

After reading a Lifehacker article this last week, I discovered and dived into a Mac app called GeekTool. Similar to Rainmeter for the PC, “GeekTool is a PrefPane (System Preferences module) for Panther or Tiger to show system logs, unix commands output, or images (i.e. from the internet) on your desktop (or even in front of all windows).”

I got a few scripts from Nicinabox, a few from IamAwesome, and the rest were either grabbed from other sites or I wrote them myself.

NOTE: A few of these scripts require Lynx - a text-only web browser.

    Here’s the current setup:

    picture-1

    And here are the details:

    Background by tonyxprice

    Scripts:

    FullTime

    date “+%l:%M:%S %p”

    Day

    date “+%d”

    Month

    date +%B

    Day of Week

    date +%A

    CPU

    top -l 1| awk ‘/CPU usage/ {print $8, $9}’
    top -l 1| awk ‘/CPU usage/ {print $10, $11}’
    top -l 1| awk ‘/CPU usage/ {print $12, $13}’

    Memory

    top -l 1 | awk ‘/PhysMem/ {print “Used: ” $8 ” \nFree: ” $10}’

    Network

    myen0=`ifconfig en0 | grep “inet ” | grep -v 127.0.0.1 | awk ‘{print $2}’`

    if [ "$myen0" != "" ]
    then
    echo “Ethernet: $myen0″
    else
    echo “Ethernet: INACTIVE”
    fi

    myen1=`ifconfig en1 | grep “inet ” | grep -v 127.0.0.1 | awk ‘{print $2}’`

    if [ "$myen1" != "" ]
    then
    echo “Airport: $myen1″
    else
    echo “Airport: INACTIVE”
    fi

    wip=`curl –silent http://checkip.dyndns.org | awk ‘{print $6}’ | cut -f 1 -d “<”`
    echo “External: $wip”

    Weather Temp

    lynx -dump http://printer.wunderground.com/auto/printer/CA/YOURCITY.html |awk ‘/Temp/{printf $2, “: “; for (i=3; i<=3; i++) printf $i ” ” }’

    Weather Conditions

    lynx -dump http://printer.wunderground.com/auto/printer/CA/YOURCITY.html|awk ‘/Cond/ && !/Fore/ {for (i=2; i<=10; i++) printf $i ” ” }’

    Weather Sunrise

    curl http://m.wund.com/US/CA/YOURCITY.html | grep ‘Sunrise’ | sed -e :a -e ’s/<[^>]*>//g;/</N;//ba’ | sed -e ’s/Sunrise/Sunrise: /g’ | sed -e ’s/PST//g’

    Weather Sunset

    curl http://m.wund.com/US/CA/YOURCITY.html | grep ‘Sunset’ | sed -e :a -e ’s/<[^>]*>//g;/</N;//ba’ | sed -e ’s/Sunset/Sunset: /g’ | sed -e ’s/PST//g’

    Weather Forecast

    curl –silent “http://xml.weather.yahoo.com/forecastrss?p=YOURZIP&u=f” | grep -e “Forecast:” -A 2 | tail -n 2 | sed -e ’s/<br \/>//’ -e ’s/<BR \/>//’ | sed “s/\(.*\)\.\ \(.*\)/\1\?\2/” | tr “?” “\n” | sed “s/High\:\ \(.*\)\ Low\:\ \(.*\)/\?H\: \1\ L\:\ \2/” | sed “s/\?\(.*\)/\\1/”

    PHP Scripts (placed in ~/Sites/)

    Weather Image:

    <?php
    /* Be Sure to replace CITYDATA in $url with your own city from Yahoo */

    $url=”http://weather.yahoo.com/forecast/YOURCITYCODE.html”;

    $ch = curl_init();
    $timeout = 0; // set to zero for no timeout
    curl_setopt ($ch, CURLOPT_URL, $url);
    curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
    $file_contents = curl_exec($ch);
    curl_close($ch);

    $divStart = “<div class=\”forecast-icon\”";
    $strEnd = “‘); _background-image/* */: none;”;
    $start = strpos($file_contents, $divStart) + 50;
    $end = strpos($file_contents, $strEnd);
    $length = $end-$start;

    $imagepath=substr($file_contents, $start , $length);
    $image=imagecreatefrompng($imagepath);

    imagealphablending($image, true);
    imagesavealpha($image, true);
    header(’Content-Type: image/png’);
    imagepng($image);
    ?>

    Gmail

    <?php
    $url = ‘https://USERNAME:PASSWORD@mail.google.com/mail/feed/atom’;
    $buffer = file_get_contents($url);
    $xml = new SimpleXMLElement($buffer);
    //print_r($xml);
    echo $xml->fullcount . ” unread\n”;

    foreach($xml->entry as $entry){
    echo $entry->title . ” (from: ” . $entry->author->name . “)\n”;
    }
    ?>

    Tags: > >

    May 20th, 2009

    Military Service

    9130136I flew down to San Diego this week to attend the military funeral for my Grandpa who passed away recently.  My wife just recently lost her Grandpa (also military) and told me the service was not to be missed.

    Despite the fog, the view from Ft. Rosecrans (San Diego) was gorgeous.  The service was obviously small and included one soldier playing taps on a bugle, two soldiers unfolding then folding the flag, and finished by one of the soldiers presenting the flag to my Grandma.

    It was quiet, intimate, and respectful — perfectly suited for my pops.

    Tags: >

    March 16th, 2009

    Bishop - March 2009

    Just got back from a week climbing in Bishop.  It was by far the best climbing trip I’ve ever taken.  Aside from getting so much time on the rock (never done a climbing trip longer than 3 days before), I ticked some amazing problems that had been on my project list for a long time.

    First, some pictures…

    Finishing up “King Tut” (v3)
    489240215_qrupx-xl-1

    Ripped a flapper on “Seven Spanish Angels” (v6)
    489253104_ycsvc-xl

    Grabbing the pinch on “Seven Spanish Angels” (v6)
    489256569_5bllx-xl

    My kiddo kickin it in the Ice Caves
    img_5308

    Half way up “The Hunk” (v2R)
    img_5321

    Topping out “The Hunk” (v2R)
    img_5336

    Sitting atop my proudest send - High Plains Drifter (v7)
    img_5352

    And here are some videos of the climbs I did.  I didn’t manage to take any video on this trip — I wanted to focus on enjoying the climbs without the hassle of setting up a video camera.  But these videos of other climbers should suffice.

    Seven Spanish Angels
    YouTube Preview Image

    Green Wall Center
    http://www.vimeo.com/2757179

    Serengeti
    YouTube Preview Image

    High Plains Drifter
    http://www.vimeo.com/1313657

    Tags: > >

    February 27th, 2009

    Pure - a mini review

    I’m at work and need to catch up on email, so here’s my quick and dirty review of “Pure” — a climbing flick from Chuck Fryberger.  I’ve not yet read some other reviews I know are out there, so hopefully my opinions here are … pure.

    The Good

    • Great footage — the climbs were on stage and they performed well
    • Unique angles — obviously, lots of time spent getting everything framed well, and yes, I did notice a lot of depth to the shots (foreground and background blurred … very pretty)
    • Not afraid to experiment — lots of the action was placed in the upper thirds of the shot.  I haven’t seen a lot of this recently, and it’s nice to see someone thinking ahead.  It’s a risky thing to do, because you can sometimes lose your subject off the screen if they do something big and unexpected.
    • Despite the over-use of what I’m sure is a $200 Final Cut video filter, whatever the video filter was, it looked great.  Darkened corners with some de-saturated colors gave it a clean look overall.

    The Bad

    • As stated before in a tweet, the computerized Mac voice was annoying.
    • There was little to no story line
    • The Rocklands footage was very blown out
    • The title graphics for each climb were very hard to read.  The broken-up font made some of the grades completely illegible.
    • There was more footage of Fred Nicole walking around with his crash pad than there was of him actually climbing
    • The emotional arc of the film went flat.  It started out very high energy, came down in the middle, then…stayed at 50% until the end.  I actually started getting sleepy during the Switzerland segment.
    • The film was basically all about Nalle Hukkataival.
    • …and suddenly?  The film was over.  A very abrupt ending.

    The Bottom Line

    Overall, what the film lacked in content, it made up for in sheen.  It was one of the prettiest climbing films of late and I certainly respect the filmmaker’s eye for getting the good shot.  As stated previously, the film spent far too much time on a single climber and had a very abrupt ending.  I would have liked to see some other climbers, and I would have liked a “finale” of sorts.  If the film had really completed an arc and brought back the engergy level … or if there was a proper ending to the film — I’d be able to give it a better review.  Minus those two biggies?  I’ll give it a B-.

    …can’t wait for the next one.

    Tags: >

    February 11th, 2009

    PHP’s “strtotime” vs JAVA’s … nothing

    PHP’s “strtotime” function is one of the coolest core functions of the language.  I never really noticed how great it was until today.

    At my company, we import date formats from customers and need to store them in MySQL format. (’Y-m-d h:m:s’).  In PHP, you can pass strtotime just about anything and — with the help of the date function — convert that wiley timestamp to what you want.

    Consider the following time formats:

    • 2004-02-12T15:19:21+00:00 (ISO 8601)
    • Thu, 21 Dec 2000 16:01:07 +0200 (RFC 2822)
    • Monday, January 1st
    • tomorrow
    • -1 week 2 days 4 hours 2 seconds

    Let’s convert these to MySQL timestamps with PHP:

    echo date(’Y-m-d h:m:s’, strtotime(’2004-02-12T15:19:21+00:00′));
    echo date(’Y-m-d h:m:s’, strtotime(’Thu, 21 Dec 2000 16:01:07 +0200′));
    echo date(’Y-m-d h:m:s’, strtotime(’Monday, January 1st’));
    echo date(’Y-m-d h:m:s’, strtotime(’tomorrow’));
    echo date(’Y-m-d h:m:s’, strtotime(’-1 week 2 days 4 hours 2 seconds’));

    This automagically outputs:

    2004-02-12 07:02:21
    2000-12-21 06:12:07
    2009-01-01 12:01:00
    2009-02-12 12:02:00
    2009-02-06 09:02:41

    I remember the first time I can across strtotime and thought “wow - it will take in just about any format.”  Clearly, there are some limits (I can’t enter “orange” and get a date back) — but needless to say, the function is simple and powerful.

    Back to today at work.

    A developer (we’ve recently moved to being an all-Java shop) tells me he has to write a custom date parser for ingesting and converting partner’s date formats.  And every time we see a new date format, he has to add to his parser (then we have to build it, QA it, release it).

    Poppy cock, I say!  Isn’t there something in Java like strtotime?  Turns out?  No.

    I did my googling, nothing.  Then I turned to Twitter.  Watch as we go from “But you *can* do that in Java!” to “oh, well, you’d have to be expecting a certain date format” quicker than you can say “ISO 8601.”

    • Java Friend #1: “you can do that simply: String time = “12:31:24″; DateFormat sdf = new SimpleDateFormat(”hh:mm:ss”); String result = sdf.parse(time).toString();”
    • Java Friend #2: “Won’t SimpleDateFormat.parse do what you need?”
    • Me, to both: “Thanks for the suggestions. All the sample code I see is massive compared to the one-liner “strtotime.” Sigh. Ah well.”"
    • Java Friend #1 replies : “a one liner, but not as short as strtotime: System.out.println(new SimpleDateFormat(”EEE, dd MMM yyyy HH:mm:ss z”).parse(t));”"
    • I direct message #1: “Will SimpleDateFormat accept multiple input date formats: ISO 8601, RFC 2822, MySQL Timestamp/Datestamp, etc.?”
    • His reply:  “you need to know the date format coming into SimpleDateTime. What format is it?”
    • Me: “There’s the rub. Could be ISO 8601, RFC 2822, MySQL Timestamp/Datestamp, etc. Was hoping to not have to write for each possible…”
    • Him: “you’ll need to do something about the type of date strings you operating on to make an error free conversion”

    <slaps forehead>

    And there’s the problem — I don’t want to have to build in a switch for every known date format.  If partner XYZ wants to enter a non-standard format (”-1 week 2 days 4 hours 2 seconds”?), we shouldn’t need to refactor the code to parse this.

    Now.  A disclaimer.  I am not a JAVA programmer.  I consider myself an intermediate PHP programmer.  Programming is not my job nor is it my dream to become a full-time developer.

    However, I’ve done my google…and I’ve asked 4 different JAVA experts who all agree it can’t be done as cleanly as strototime.

    That being said?  Booooo to you Java.  Boooooo.

    Tags: > > > > >

    February 5th, 2009

    “Mirando” - climbing film from Bishop

    I wrapped up the editing of my new climbing film, Mirando.  Check it out:

    http://www.fractionfilm.com/2009/02/mirando/

    Tags: > >