Twitter Weather Forecasts Using Linux

March 11th, 2009 by MadHatter

twitter sh2

Twitter’s feature to allow updates from terminal allows for a lot of creative ways to use twitter. I used some already written scripts and commands and put it all together to receive weather forecasts for my area at 9am every day on my phone.  Example of SMS message sent to my phone “Forecast for: DES MOINES, IA    Today    Mainly clear and frigid – Low 10“  Here is how I did it:

First I used a written shell script and made output modifications so length would be under Twitter’s length limitations. The modified script is listed below:

Note: I take no credit for the original script. It was available online, and I modified it based on my needs. Dave Taylor is the original author, and offers a book full of shell scripts I recommend checking out! Page Here

#!/bin/sh
# weather – report weather forecast, including lat/long, for zip
# Dave Taylor – found at
http://www.intuitive.com/wicked/showscript.cgi?063-weather.sh
# Edited for twitter use by MadHatter (maddhat.com)

llurl=”http://www.census.gov/cgi-bin/gazetteer?city=&state=&zip=”
wxurl=”
http://wwwa.accuweather.com
wxurl=”$wxurl/adcbin/public/local_index_print.asp?zipcode=”

if [ "$1" = "-a" ] ; then
size=999; shift
else
size=5
fi

if [ $# -eq 0 ] ; then
echo “Usage: $0 [-a] zipcode” >&2
exit 1
fi

if [ $size -eq 5 ] ; then
echo “”

# get some information on the zipcode from the Census Bureau

lynx -source “${llurl}$1″ | \
sed -n ‘/^<li><strong>/,/^Location:/p’ | \
sed ’s/<[^>]*>//g;s/^ //g’
fi

# the weather forecast itself at accuweather.com

lynx -source “${wxurl}$1″ | \
sed -n ‘/Start – Forecast Cell/,/End – Forecast Cell/p’ | \
sed ’s/<[^>]*>//g;s/^ [ ]*//g’ | \
sed ’s/10-Day AccuWeather.com//’ | \
sed ’s/Today/Today:/’ | \
uniq | \
head -$size

exit 0

Save this as weather.sh in your home folder. Then open a text editor and create “tw.sh” saved to your home directory with the following contents:

Note: You need to replace the USER:PASSWORD with the username and password for the secondary twitter account.

#!/bin/sh
#tw.sh
curl -u USER:PASSWORD -d status=”$*”
http://twitter.com/statuses/update.xml

For this script to run correctly curl must be installed. For ubuntu the command is “sudo apt-get install curl

Now we have the necessary scripts created. To receive updates you will need to create a second twitter account of which to send updates. Make sure you follow this new account with your primary twitter account and turn on device updates if you are looking for update to your mobile device.

All that is left to get things up and running is to add the crontab entry. I added to my sudo crontab by the following “sudo crontab -e” and adding the following entry:

Note: This will run at 9am every day. You can edit yours however you’d like. For testing it may be a good idea to start with “* * * * *” to run every minute to ensure updates are working as planned. Replace “user” with your user name, as well as ZIPCODE with the zip code of the area you would like weather forecasts for.

0 9 * * * /home/user/tw.sh $(/home/user/weather.sh ZIPCODE)

Save the crontab entry. Check that it was added by typing “sudo crontab -l”. That’s all there is to it.
Some useful links for help and customization:
Twitter API, Cron.

Posted in Education, Technology | No Comments »

Testing Network Performance Using Iperf

March 10th, 2009 by MadHatter

Just a quick post on a great tool for testing network performance. Iperf is a very slim tool that will measure TCP/UDP bandwidth performance. It is an available ubuntu package “iperf ” and also has Windows/OSX binaries available. I found a working mirror here. What makes Iperf a good test versus a simple SMB/CIFS transfer for bandwidth performance is that it works in memory versus being limited by hard drive and CPU limitations.

Now a quick guide to get things up and running. The guide will be for two Ubuntu machines, testing network performance between the two.

1.Install – Type the following in terminal “sudo apt-get install iperf ” for both machines

2.Server Setup – Decide upon a server machine and a client. On the server type the following in terminal “iperf -s ”. This will place iperf in server mode, and it will listen for incoming connections.

iperf server

3.Client Setup - On the client machine you have a lot of options to play around with regarding how you want to connect to the server. You can explore what each of these are by typing “iperf –-help ”. The following is a simple test between the server (192.168.2.104), and the client (192.168.2.103).

4.Testing - Type “iperf 192.168.2.104 -i 2” (replacing the IP here with the test server IP and then enter key to start testing. This will connect to the server running on 192.168.2.104 and have an interval of 2 seconds. There will then be 6 tests completed. This should give you all of the information you need regarding your connection speed between the two machines.

iperf client

This should be enough to get you started using iperf. Check out the man page here if you have any usage questions.

Posted in Education, Technology | No Comments »

New WD Media Player Reviewed, Stripped Naked

November 3rd, 2008 by Brett Burns

wd a inhand

Over the weekend, Western Digital silently introduced their WD TV HD Media Player. It is an extremely small device (think two WD Passport drives stacked on top of each other) which packs an extreme amount of processing power. And best of all: I picked one up on sale at Best Buy for $99.99.

The unit’s design is nearly identical to WD’s MyBook series drives. features two USB ports (one on the back, one on the side), an HDMI output supporting up to 1080p60, and an optical SPDIF output. It supports drives formatted with FAT32, NTFS, and HFS+ file systems.

wd a back

Plugging it in to my current AV setup was very easy. This device not only boasts an optical SPDIF output, it also supports audio over HDMI, though no bitstreaming support for HD audio formats (more on that later).

At first, I did not really expect much. For a device with an MSRP of $129.99, what can one really expect? It seems Western Digital has decided to pack support for nearly everything into this tiny box at such a tiny price. From the manufacturer’s website:

Music - MP3, WMA, OGG, WAV/PCM/LPCM, AAC, FLAC, Dolby Digital, AIF/AIFF, MKA
Photo - JPEG, GIF, TIF/TIFF, BMP, PNG
Video -MPEG1/2/4, WMV9, AVI (MPEG4, Xvid, AVC), H.264, MKV, MOV (MPEG4, H.264)
Playlist - PLS, M3U, WPL
Subtitle -SRT (UTF-8)

Disclaimer: I did not test all of the formats listed above, as I’ve basically switched my entire media library to MKV containers with H.264 and AC3/DTS audio. I also did not bother testing analog outputs.

After getting it connected to my TV and receiver, I plugged in one of my drives. The first thing I noticed was how bad the “media library” function is. It might be a good thing for people with unorganized drives, but I already know my folder structures, so I’d prefer to just have a folder view. After turning the “media library” function off in the system settings, I had a normal folder view. I also switched the view to “list” instead of “thumbnail” since it is much faster. The other essential setting is to switch the audio output to “digital”, otherwise it’ll just play two channels even if you’re connected via SPDIF.

The first file I played was a recorded TV show with 720p resolution, encoded with x264 at around 5mbps, and containing AC3 (Dolby Digital 5.1) audio. So far, so good. My receiver showed Dolby Digital coming through, and the video playback was very smooth.

wd ua chip

The one thing I did notice is that the decoder chip inside (Sigma SMP8635LF) seems to be doing some type of video processing work, because the 720p files seemed to have added sharpening or “edge enhancement” which I was not able to turn off – somewhat annoying, since at times it would add unnecessary noise especially in dark scenes. This was not a problem when I switched the output resolution to 720p.

wd ua compareipod

Next, I tried a 1080p x264 file, also in an MKV container, this time with DTS audio. The video bitrate was around 15mbps, and I honestly expected many dropped frames. However, I was proven wrong, as the file played back with no issues at all. My receiver showed DTS audio coming through, and the video played back on my TV with no dropped frames.
Since I was playing back a 1080p file and the player was outputting 1080p60, I did not notice the sharpening effect mentioned above. I’m going to assume this is because there was no scaling going on, therefore no postprocessing of any kind.

With each file I tested, I increased the bitrate, so next I tested a 25mbps MPEG2 file (I had to change the extension from .TS to .MPG as the player won’t recognize .TS files). It was a 1080i movie captured from DTheater tape, and looked very nice. The player did a decent job with deinterlacing/IVTC, but when I switched the output resolution to 1080i and let my TV do the work, I did notice a slight increase in picture quality and motion was a bit smoother. This was mainly noticeable during slow camera pans.

Finally, I tested a couple of Blu-Ray backups. The player would recognize an .ISO file, however it didn’t understand the Blu-Ray structure, so it would not play that particular file. I decided to extract the .m2ts from the .ISO image and test that, and to my surprise, it worked! This particular movie was encoded with AVC at a bitrate of around 30mbps. The WD TV played it without breaking a sweat. Fast motion and lots of action, with bitrate peaks of over 45mbps, and playback was flawless. I’m sold.

wd a digg

A few miscellaneous issues:
Sometimes the video won’t completely fill the screen at first. It’s easily fixed by zooming in, then back out. But for some reason, the decoder just doesn’t scale the video properly. This doesn’t happen always. It seems to happen completely randomly. Once I zoomed in and out to fix it, it would play properly for the rest of the file. This issue is pretty annoying, and hopefully it can be fixed.

wd a picerr

I tried playing an MKV file containing MPEG2 video and AC3 audio, and it did not play. While that’s not a traditional container for those codecs, it still should have played.
The interface is a bit sluggish, although not the worst I’ve seen. It’s not unbearably slow, but there is definitely room for improvement.

1080p24 would be really nice. I shouldn’t necessarily expect that for $99.99, but I don’t think it would be very difficult to add that functionality via a firmware update.

I’m really upset that there is no network connectivity with this device. If I had to guess, I’d say WD did this because they want people to buy their drives as a complement to the media player.

Finally, I wish this device could switch the output resolution to the currently playing file’s native resolution. If I’m playing a 1080p file, output 1080p. If 1080i, output 1080i and let my TV do the deinterlacing (the chip inside of the player, while not terrible, does not do a great job). If 720p, output 720p, and so on… you get the point.

Conclusion:
The WD TV HD Media Player is worth every penny. Power consumption is much lower than using an HTPC. It’s completely silent. It plays back 1080p files like they’re no big deal. If you’re like me and have been waiting for a device like this, I can tell you with confidence that you won’t regret purchasing this. Though I had a few minor complaints, it’s a great deal for $129.99.

Full Gallery below:

Posted in Technology | 42 Comments »

« Previous Entries