Sunday, December 30, 2007

Madison on War


Of all the enemies to the public liberty war is, perhaps, the most me be dreaded, because it comprises and develops the germ of every other. War is the parent of armies; from these proceed debts and taxes. And armies, and debt, and taxes are known instruments for bringing the many under the domination of the few.
~ James Madison 1795-04-20

Democracy....

... is the best revenge - Benazir Bhutto

Friday, December 28, 2007

For the Space Geek



NASA's Planet Quest web site has a Widget for your Yahoo Widget desktop to keep count to the extrasolar planet discoveries.

Its on my desktop. Is it on yours?

Saturday, May 05, 2007

Project Steve

(Project Steve): "Evolution is a vital, well-supported, unifying principle of the biological sciences, and the scientific evidence is overwhelmingly in favor of the idea that all living things share a common ancestry. Although there are legitimate debates about the patterns and processes of evolution, there is no serious scientific doubt that evolution occurred or that natural selection is a major mechanism in its occurrence. It is scientifically inappropriate and pedagogically irresponsible for creationist pseudoscience, including but not limited to "intelligent design," to be introduced into the science curricula of our nation's public schools."

Wednesday, May 02, 2007

Saturday, March 31, 2007

Old Media Company Steps Up

News.com is reporting that Sony BMG is asking muscicans to blog about their demos rather than sending in hard copy. Sounds like the fore shocks of a media company trying to re-invent itself.

Hope it works out for them. Might be a way to avoid extinction.... Nah... Not Sony.

Technorati Tags: , , ,

XML and Twitter and Weather, Oh My!

So with the advent of Twitter-mania I've been playing with it. However Twitter has become a victim of its own success, with the site being slow at the best of times and unresponsive at worst. So I've found a couple of alternatives to using the Twitter web site to post my status/thoughts. Since I'm a Widget fan I've discovered the Twidget which allows you to post text to Twitter with just a couple of clicks.

I wanted to post my local weather conditions to Twitter just to see if I could get a Linux command line poster working. Turns out you can! Although I first looked at the Twitter API it needed/used some stuff I'm not familiar with. So I asked the great and all-knowing Google and found a post over at Tech@Sakana which gives a script-based solution to push text onto your Twitter page using cURL.

The command line built using cURL looks like this:
curl --basic --user username:password --data status="Having fun with cURL" http://twitter.com/statuses/update.xml

Not to bad. Works great even when the twitter site is unresponsive.

Now for the Weather. Turns out that the National Weather Service (NWS) offers an XML-formatted file of the current weather conditions updated hourly. But... Having tried to use the native Linux tools to extract data from XML files I know how kludgy or even impossible it can be. I once again petitioned Google and found Xmlstarlet. Xmlstarlet is a command line utility from Sourceforge that can read and write XML files. In my case, I can use Xmlstarlet to extract the weather conditions I want from the XML file I download from the NWS.

Now I could build a script that collects the current observation file from the NWS, parses out the weather conditions I want to report. Builds a string of those conditions and sends them off to Twitter. Here's what it looks like:
#!/bin/bash

cd ~/weather

mv -f KLOU.xml KLOU.XML

wget -q http://www.weather.gov/data/current_obs/KLOU.xml

# At $now it is $temperature in $location with winds $wind

#Now
now=`xml select -T -t -v //observation_time KLOU.xml|cut -d" " -f6-8;echo ""`
#location
location=`xml select -T -t -v //location KLOU.xml|cut -d" " -f1,5;echo ""`
#Temperature
temperature=`xml select -T -t -v //temperature_string KLOU.xml;echo ""`
# Winds
## wind=`xml select -T -t -v //wind_string KLOU.xml|cut -d" " -f2-10;echo ""`
wind=`xml select -T -t -v //wind_string KLOU.xml;echo ""`

conditions=`echo At $now it is $temperature in $location. Winds: $wind.`

echo $conditions

curl --connect-timeout 5 --user johniac:******* --data status="$conditions" http://twitter.com/statuses/update.xml

If I'm going stick this into cron and have it run regularly, I need to add some locking code so that it won't run over the top of itself if Twitter or the NWS starts hanging connections. And of course that leads to the obligatory SMS messaging if a second instance trys to run. Maybe in version 2 ;-)


Technorati Tags: , , , ,