Uptonian Thoughts

The Illusion of Safety by Thrice

· ·

The first Thrice song I ever heard was on the Atticus: …dragging the lake, Vol. 2 compilation. When I first heard To Awake and Avenge the Dead, I was in my car alone and I must have listened to it five times on repeat. I had discovered Thrice, and I immediately knew that they were a band to watch.

Writing a review of an album over six years after its initial release allows a certain unique retrospective into the music, but it also presents some issues, especially when the group’s later material has evolved so greatly from their origins. However, this album is a classic, and every time I listen to it the music evokes the feelings of those high school years during which I first had the joy of hearing Thrice. The Illusion of Safety opens with a quiet but frantically discordant guitar. The song swells, and Dustin Kensrue ironically begs for his life to end in order to escape the violence of this world. The sad state of the world and its inhabitants is a theme that runs throughout this album, manifesting itself as commentary on friendship in Trust and The Beltsville Crucible, or a lament concerning the decay of morals in A Subtle Dagger. Sings Kensrue:

We extend our claws to grasp at shadows of the ideals we have, lost causalities of a subtle dagger

The songs never lose their intensity but the order in which they are presented to the listener shows their dynamic. The minor chord solos of A Subtle Dagger give way to almost poppy rhythms in See You In The Shallows. The 6/8 waltz feel of Trust gives way to brutal breakdowns in To Awake and Avenge the Dead. The songs can be brutal, but they all have an underlying passion that shines through the riffs and lyrics.

After hearing this album, I quickly sought out Thrice’s debut release, Identity Crisis, and found that the group was currently writing songs for their next release, The Artist in the Ambulance. Needless to say, I was very excited to find such a dynamic and colorful band that is still actively writing and creating music.

Rating: 4.5/5

Blog Comment Design

· ·

I updated my blog comments from the Hemingway default to a more iconic design.

A post about blog comments that I saw a few weeks ago inspired me to use the “big number” idea for my own comments.

I also enabled Gravatars and have highlighted my own comments when I make them. I have posted the comment loop and the relevant comment CSS in case anyone else wants to use this idea.

This is the comment loop in comments.php.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php if ($comments) : ?>

    <ol id="comments">

    <?php $i = 1 ?>

    <?php foreach ($comments as $comment) : ?>
        <li id="comment-<?php comment_ID() ?>" class="<?php echo get_comment_author_email() == get_the_author_email() ? ' blog-author' : $oddcomment ?>">
            <cite>
                <span class="author"><?php comment_author_link() ?></span>
                <span class="date"><a href="#comment-<?php comment_ID() ?>"><?php comment_date( $hemingway->date_format() . '.y' ) ?> / <?php comment_date('H.i') ?></a></span>
                <span class="gravatar"><?php echo get_avatar( $comment, $size = '80'); ?></span>
            </cite>
            <div class="content">
                <span class="number"><?php echo $i ?></span>
                <?php if ($comment->comment_approved == '0') : ?>
                <em>Your comment is awaiting moderation.</em>
                <?php endif; ?>
                <?php comment_text() ?>
            </div>
            <div class="clear"></div>
        </li>

        <?php $i++; ?>


    <?php /* Changes every other comment to a different class */
        if ('alt' == $oddcomment) $oddcomment = '';
        else $oddcomment = 'alt';
    ?>

    <?php endforeach; /* end for each comment */ ?>

    </ol>

 <?php else : // this is displayed if there are no comments so far ?>

  <?php if ('open' == $post->comment_status) : ?>
        <!-- If comments are open, but there are no comments. -->

     <?php else : // comments are closed ?>
        <!-- If comments are closed. -->
        <p class="nocomments">Comments are closed.</p>

    <?php endif; ?>
<?php endif; ?>

This is the CSS section for my comments.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/* Comments */
ol#comments li .content span.number {
    position: relative;
    top: 0px;
    left: 0px;
    font-size: 10em;
    color: #c7c7c7;
    float: right;
}

ol#comments li {
    padding: 10px 0;
}

ol#comments li.blog-author {
    background-color: #ddd;
}

ol#comments li.alt .content {
    background-color: #ddd;
}

ol#comments li cite span.date a {
    text-decoration: none;
}

ol#comments li cite span.gravatar {
    margin-top: 13px;
}

ol#comments li cite span.gravatar img {
    padding: 3px;
    border: 1px solid #ccc;
}

Yahoo! Weather Feeds With Python

· ·

Download the weather script from GitHub.

UPDATE: Chris Lasher updated my script. It now utilizes optparse and docstrings. Some of the options have been changed, too, and I have licensed the code under a by-nc-sa CC license. I have updated this post to reflect these changes. Thanks, Chris!

I believe that everyone likes to know what the weather is like outside. In the good ol’ days, people used to stick a hand out of the window and know everything they needed to know about the weather; now we have myriad options to check the weather.

A few years ago, I was running Konfabulator on Windows. The best widget for this application was the weather widget. I had a large weather widget that showed the current weather in the town in which I was currently residing, and some smaller weather widgets allowed me to keep tabs on the weather elsewhere.

When I got my Powerbook in 2004, I continued to use Konfabulator. With Tiger came Dashboard in 2005; I promptly started using the weather widgets provided by Dashboard. However, I realized that the requirement that I switch contexts to Dashboard just to quickly check small tidbits of information greatly distracted me from my workflow. Even the ability to display widgets directly on the desktop was no help; the pretty images take up too much screen real estate.

As I have written about in the past, I utilize Geek Tool on my desktop. One of the scripts I run scrapes the Weather Underground XML feed for Blacksburg, VA and displays the current conditions. This works fine, but it isn’t very extensible. Weather Underground does not appear to have a feed API, so each city’s XML feed must be found manually and utilized in the script. Last night I decided that this was unacceptable.

Yahoo offers a great RSS-based API for its weather services. Python has a built-in XML parser. It doesn’t take a rocket surgeon to put those two together. With a little help from Yahoo’s Developer Network, I was able to come up with a more robust script with which the weather can be displayed.

I learned a few things regarding Python while writing this script. The getopt() method is a very useful command-line options and arguments parser. It’s very simple to define options for your script using this method.

1
2
3
4
import getopt
import sys

opts, args = getopt(sys.argv[1:], "cflv")

Now the options that were passed on the command line and that are part of cflv are in the opts array; command line arguments are listed in args.

UPDATE: My script now uses optparse instead of getopt.

minidom is a simple but complete DOM implementation. Using the getElementsByTagName and the getAttribute methods makes for easy and stress-free XML parsing.

1
2
3
4
5
6
7
8
from xml.dom.minidom import parse

dom = parse("file.xml")

attrs = []

for node in dom.getElementsByTagName('tag'):
    attrs.append(node.getAttribute('text'))

attrs contains the text attribute of each tag node in the XML file file.xml.

I am currently looking into building this script on top of a Twitter model. Keep checking in for more information.

In order to run the script, pass it a zip code to find the weather.

1
$ weather.py 24060

Running the script without any arguments will show the usage and the available options.

  • -c Suppress the current weather output. Use this if you only want the forecast data.
  • -f DAYS Show the forecast for the next DAYS days.
  • -l Show the city and region name of the forecast that was retrieved. Use this to verify the zip code that you are using is in fact your area.
  • -v Print headers above all output.

Here is some example output from the script:

Default options:

1
2
$ weather.py 24060
55F | Drizzle

Forecast and location options:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
$ weather.py -lf2 24060
Blacksburg, VA

55F | Drizzle

22 Apr 2008
  Low: 50F
  High: 60F
  Condition: Few Showers

23 Apr 2008
  Low: 49F
  High: 71F
  Condition: AM Clouds/PM Sun

Blogwatch

· ·

A couple of my friends have blogs, too.

You should read them.

Geek Tool Redux

· ·

I last wrote about GeekTool when I had an iTunes script and some process management output on my desktop. I have a few new scripts that I’ll highlight here.

tail -25 /var/log/system.log

The first script displays the last 25 lines of the system log. In Mac OS X 10.5, the system log rolls over at midnight every day, and this for some reason causes the built-in file display to malfunction. I am using tail to display the last 25 lines of the system log.

ps -ecm -O %cpu,%mem

This script shows the output of all currently running processes, sorted by memory usage.

  • -e Displays processes from all users.
  • -c Only displays the executable name, not the entire path to the excutable.
  • -m Sorts the processes by memory usage.
  • -O Designates the start of a list of comma-delimited options. %cpu displays CPU usage as a percentage. %mem displays memory usage as a percentage.

    cal sed “s/^/ /;s/$/ /;s/ $(date +%e) / $(date +%e sed ‘s/./-/g’) /”

This command outputs a formatted display of the current month. The current date is replaced by the string “–” in order to visually differentiate it.

/path/to/script/iTunes-Now-Playing.pl | iconv -f utf-8 -t ucs-2-internal

This Perl script is something I wrote to display the currently playing track in iTunes. You can download the script here. The script contains a function that was derived from John Gruber’s article How to Determine if a Certain App Is Running Using AppleScript and Perl.

/usr/bin/curl -s http://rss.wunderground.com/auto/rss_full/VA/Blacksburg.xml?units=both | awk '/%3Ctitle%3ECurrent/ {printf "Temp: " $4 " | "; for (i = 8; i %3C 11; i++) if ($i != "-") printf $i " "; else break; printf "\n"}'

UPDATE: I now use a Python script that uses the Yahoo! Weather API to get weather data.

This bash script scrapes the Weather Underground feed for Blacksburg and displays the temperature and current conditions. It’s not as pretty as a Dashboard weather widget, but it takes up much less screen real estate. I have another instance of this command set up to scrape the Oak Ridge XML feed for when I’m back in Greensboro.

Each one of these scripts is set up to display for both my 20” Cinema Display and my MacBook screen; I have Home and Portable groups of commands set up in GeekTool. You can download GeekTool from Tynsoe’s website.

Wordpress 403 Forbidden Posting Error

· ·

In trying to post about my modified Twitter stats script, I ran into a 403 Forbidden error every time I tried to publish. I could write and publish test posts with minimal text, but I could not post what I had written about my scripts.

At first I thought it was an outdated version of Wordpress that was responsible for the error. However, upgrading to 2.3 did not fix anything. I simply ignored the error and conceded that I would not be able to post anything for now.

Wordpress 2.5 was released today, and I decided to try posting once more. I still got the same error. This time, I decided to Google the issue.

The results are not suprising.

It seems that Wordpress has some parsing issues when posts contain certain PHP commands. Apparently, modifying the mod_security rules in .htaccess helps to resolve this issue.

Adding the following code to the .htaccess file in wp-admin/ does the trick.

<IfModule mod_security.c>
    SecFilterEngine Off
</IfModule>

Twitter Stats

· ·

Update: TweetStats webifies a version of these Twitter statistics.

Twitter stats, by hour.

Damon Cortesi wrote a pretty nifty script to grab some Twitter statistics. A bunch of people modified his script in order to webify it, plot the results using gnuplot, and plot the results with the Google Charts API.

This last modification really intrigued me, as I know there are a few wrappers for the Google Charts API available, including one for Python. I decided to modify Colin Barrett’s Python script that uses the Google Charts API to use the pygooglechart module.

So now instead of:

if f[0] == "\n":
    s = "http://chart.apis.google.com/chart?cht=bvg&chbh;=15&chs;=600x300&chd;=t:%s&chxt;=y,x&
    chxr=0,0,%d&chtt;=%s"
    s = s % ( str(map(lambda x: x*100/max(v), v)).replace(" ", "")[1:-1], max(v), t )

we have:

# If we are at a newline, we have just finished gathering data for a single chart
if fields[0] == "\n":
    # Most of the time we are generating a vertical bar chart
    chart = GroupedVerticalBarChart(600, 300)
    # Set the y-axis range according to the current data
    chart.set_axis_range(Axis.LEFT, 0, max(chartData))

I also commented my modifications because I’m still on winter break and I felt like it.

You can download my modified script here. Make sure you have the pygooglechart module and read the included README.txt file.

PandoraJam

· ·

PandoraJam

PandoraJam is, at first glance, an application that allows a user to listen to her Pandora radio stations without using a browser window. Delve a little deeper, however, and one will find a well designed, impeccably implemented, and easy to use application chock full of useful features.

Interface

PandoraJam provides a wrapper to the Pandora.com Flash radio player. The main window displays the Pandora interface, complete with controls and the station picker. Below the radio are a master volume slider, a drop down menu for streaming audio to an Airport Express, a pause button, a skip button, and a record button. Next to the record button is a magnifying glass that locates the currently recording track in Finder, a nice little touch that helps avoid digging through directories to find your audio files. The application exudes Mac-ness, if only because of the juicy play control buttons.

Recording + iTunes Integration

PandoraJam really shines when it comes to grabbing Pandora’s stream. Recording can be set to begin on launch of the application, or a user can manually begin recording at any time. After a recording has completed, PandoraJam can automatically add the files to iTunes. PandoraJam creates its own playlist folder group, and adds each song to a separate playlist according to the Pandora station from which the song was recorded. This is a nice touch, especially when one wants to listen to a time-shifted Pandora station on his iPod.

Third-party Support

It seems as if every audio-related application has Last.fm support these days, and I love it. Last.fm keeps tracks of your music-listening habits and makes recommendations based upon your most-listened-to artists. Simply enter your Last.fm username and password and start scrobbling!

Growl support for almost every conceivable action (do I need an alert to let me know I just thumbed-up a song?!) can come in useful if PandoraJam is in the background. I personally love Growl’s music video style to let me know the title and artist of a song as it starts playing.

PandoraJam can also update the status of chat clients Adium, iChat, and Skype. This cross-application status update is a neat feature that all the kids seem to be playing with.

One of the most surprising features of PandoraJam is its ability to transmit audio to an Airport Express. I am not sure why, but there seem to be very few applications that have Airport Express support built in. This is really the feature that sold me on PandoraJam; listening to Pandora radio anywhere in the house is something for which I have longed for quite some time.

PandoraJam is $15 and is available from BitCartel. It is a great utility for music listeners and lovers, with that Mac OS X design ethos that we all love and desire in all our apps.