Weather Underground Script

Since is ending their free XOAP service conkyForecast will no longer work at the end of this month.

Therefore I wrote a small script to get the temperature and condition from Weather Underground

# Fetches Weather info from Weather Underground
# Usage: ./ zipcode
# International:
#  * Go to
#  * Find your city
#  * Click the RSS icon
#  * Station ID is the number that follows /stations/ in the url

# Values are either True or False

import sys
import feedparser

def usage():
    if international:
        print("  ./ StationID")
        print("  ./ zipcode")

if not len(sys.argv) == 2:


if international:


if not feed.feed:
    # Assume Error


if metric:


print('%s - %s' % (temp, condition))



$ ./wunderground 11201
69.6F - Clear

I’m using this script for my conky config:

${execi 600 /home/pyther/scripts/wunderground 11201}

Make Windows 7 USB installer in Linux

So for whatever reason you need to install Windows 7 from a flash drive that’s not a problem!

In Linux:

  1. Format flash drive: mkfs.vfat -F 32 /dev/sdx
  2. Set Label: mlabel -i /dev/sdd1 ::WIN7x64 (optional)
  3. Download Grub4Dos –
  4. unzip
  5. Run ./ /dev/sdx
  6. Copy grldr and menu.lst to the root of the flash drive
  7. Add to menu.lst
    title Install Windows 7
    root (hd0,0)
    chainloader (hd0,0)/bootmgr
  8. Copy Win 7 Install files to root of USB flash drive.
  9. Boot Flash Drive – Select Install Windows 7

TIP: To install any version of Windows 7 (Home Premium, Professional, Ultimate) remove ei.cfg from the sources directory. However, you still need a product key for the appropriate version.

In Windows:

  1. Format Drive as Fat32
  2. Copy Files from Install DVD to Flash drive

That’s it, boot from the flash drive you are all good.

Note: The windows disk formater writes code to the MBR and VBR. This obvisouly doesn’t happen in Linux therefore we need to use grub4dos as our bootloader.

Remote Assistance – Win XP/Vista/7

I was looking for a solution that would allow me to remotely connect to machines on the local network. We often get phone calls form users asking for help. It is way easier to provide help if we can see their screens and we usually end up having to visit their workstation. This can be time consuming, especially when we are in the middle of a project.

In my search, I came across a wonderful gem called Microsoft Remote Assistance which happens to be included in Windows XP/Vista/7.

How does it Work?

  1. Tech enters the Machine name of the client that he/she wants to provide Remote Assistance to.
  2. User is prompted to allow Tech to view their computer (Yes/No)
  3. Tech then can request to take control
  4. Again, the user is prompted to allow the tech to take control

Enabling Remote Assistance on the Domain (via Group Policy)

Computer Configuration -> Policies -> Admin Templates -> System -> Remote Assistance

  • Offer Remote Assistance -> Enable
  • Solicited Remote Assistance -> Disable (If you don’t want your users requesting others for Remote Assistance)

You then have two choices “Allow helpers to control the computer” or “Allow helpers to only view the computer”. In addition to selecting one of these choices, you have to add the users and groups that should be able to provide remote assistance.

Offering Remote Assistance

  • Start -> All Programs -> Maintenance -> Windows Remote Assistance or type in msra.exe
  • Click “Help Someone who has invited you”
  • Click “Advance connection option for the help desk”
  • Lastly, enter the machine name or ip address of the machine you want to provide Remote Assistance to


How can I possibly remember all the host names?

I’ve created a small C# application that you can have your users run. I would put it on a shared drive and push out a shortcut via group policy.


Bin: Included in source ./WhoAmI/bin/Release/WhoAmI.exe

Offering Remote Assistance – A nice GUI app

Although the method mentioned above works it is long and convoluted. I put together a small  C# app to easily offer Remote Assistance to a user.

The app simply calls msra.exe /offerra <hostname>

Bin: Included in souce ./RemoteAssistance/bin/Release/RemoteAssitance.exe

Ideas for the two Easy GUI apps came from SYNACK over at edugeek.

More Information:

DNS Conditional Forwarding – dnsmasq

Why would I want to use Conditional Forwarding?

In my case, my local dns server has entries for local hostnames such as m2n.ion.lan, mongo.ion.lan, and tux.ion.lan. If I am using the vpn dns, then these address lookups would fail. By using Conditional Forwarding I can do all lookups locally, except for ones that match the remote top level domain (example.local). Anything that matches example.local would be forwarded to the remote dns server.


  1. Connect to remote vpn server and use local DNS server
  2. Ping server.remote.local (remote FQDN) – fail
  3. Ping server.ion.lan (local FQDN) – success

Of course the remote ping fails because the local DNS server knows nothing about the remote domain. If I was to configure my machine to use the remote DNS server the opposite would happen. I would be able to ping server.remote.local, but a ping to server.ion.lan would fail.

Solution: Use dnsmasq with conditional forwarding to forward *.work.local requests to the remote dns server.

1. Install dnsmasq using your local package manager

2. Edit /etc/dnsmasq.conf

# Tells dnsmasq to forward anything with the domain of remote.local to dns server

# Listen to requests only coming from the local machine

# Do not cache anything
# A decent dns server will already cache for your local network

3. Edit /etc/resolv.conf

# Local LAN Domain
domain ion.lan

# local dnsmasq server

# Your main dns server (dnsmasq will forward all requests to this server)

4. Start dnsmasq

5. Test – ping a local server and remote server using the FQDN

All dns requests will be forwarded to except any matching *.remote.local. server.remote.local will be forwarded to

OpenVPN Client – DNS Script

The OpenVPN server can pass DNS servers and a domain name to the client. This gives the benefit of using the remote dns servers for local hostname lookups.

Finding a good script that worked to do this provide difficult…

In server.conf add:

push "dhcp-option DOMAIN ion.lan"
push "dhcp-option DNS"

Then save this script on the client in same location as the client config


case "$1" in
	    mv /etc/resolv.conf /etc/resolv.conf.bak

		echo "# Generated by OpenVPN Client UP Script" > /etc/resolv.conf
		for opt in ${!foreign_option_*};
	        echo ${!opt} | sed -e 's/dhcp-option DOMAIN/domain/g' -e 's/dhcp-option DNS/nameserver/g' >> /etc/resolv.conf
        mv /etc/resolv.conf.bak /etc/resolv.conf
        echo "Pass either UP or DOWN"

In the client.conf add

script-security 2

up "./ up"
down "./ down"

Now connect and check /etc/resolv.conf to see if the VPN nameserver and domain is listed.


Syslinux is a simple bootloader for fat, ext2/3/4, and brtfs.

Syslinux works in the following way (in a nutshell):

  1. MBR looks for the active partition (the one tagged as bootable)
  2. The MBR loads the code found on the partition’s boot sector and executes it
  3. This code then loads the rest of the boot loader code from /boot partition (file: ldlinux.sys)
  4. COM32 modules are loaded to provide extra functionality such as a graphical menu or chain loading

For a more detailed explanation:

Sample configuration:

UI vesamenu.c32


# Refer to

MENU COLOR border       30;44   #40ffffff #a0000000 std
MENU COLOR title        1;36;44 #9033ccff #a0000000 std
MENU COLOR sel          7;37;40 #e0ffffff #20ffffff all
MENU COLOR unsel        37;44   #50ffffff #a0000000 std
MENU COLOR help         37;40   #c0ffffff #a0000000 std
MENU COLOR timeout_msg  37;40   #80ffffff #00000000 std
MENU COLOR timeout      1;37;40 #c0ffffff #00000000 std
MENU COLOR msg07        37;40   #90ffffff #a0000000 std
MENU COLOR tabmsg       31;40   #30ffffff #00000000 std

LABEL arch
	MENU LABEL Arch Linux
	LINUX /vmlinuz26
	APPEND root=/dev/sda2 ro nomodeset
	INITRD /kernel26.img

LABEL archfallback
	MENU LABEL Arch Linux Fallback
	LINUX /vmlinuz26
	APPEND root=/dev/sda2 ro nomodeset
	INITRD /kernel26-fallback.img

As you can see, the majority of the config contains MENU statements declaring colors and positing for the menu. If you removed all the MENU statements, the config would be less than 20 lines.


Syslinux Graphical Boot Menu

I was lazy and took a screenshot of the Arch Linux installer menu. The configuration above generates the same menu, except there are only two boot choices, Arch Linux and Arch Linux Fallback.

The arch wiki has a whole lot of good information on configuring Syslinux.

iheartradio – command line (mplayer)

Well after some experimentation and playing around I have found some new information out regarding listening to iheartradio from the command line in Linux.

Newer versions of mplayer have support to play the rtmp:// protocol eliminating the need for rtmpdump.

Quick Recap on how to grab the rtmp:// url from an iheartradio stream

  • Go to; where station id is the call letters (ex: wtfx-fm)
  • The attribute primary_location in <stream> contains the rtmp url

NOTE: The RTMP URL changes every 5-10 minutes! You must fetch the new url everytime.

To play the stream with mplayer:

mplayer "rtmp://" -novideo

The -novideo option is very improtant otherwise mplayer will take 5+ minutes trying to find video for the stream (there is none).

This is all great, but this is a lot of work everytime you want to listen to a iheartradio stream. Therefore I have coded up a script.

The Script:

  • Asks you for the station id (ex: wtfx-fm)
  • Asks how long the stream should play for
  • Check for song information every 10 seconds
  • Not Perfect (Alpha Quality)
#!/usr/bin/env python

import subprocess
import time
import urllib2
import xml.etree.ElementTree as ET
import os
import datetime

#Location of Stream to be SAVED

def getXML():
    return xml

def getSongInfo():
    return artist,title

while True:
    station=raw_input("Enter Station ID [" + DefaultStation + "]: ")

    if not station:
    except urllib2.URLError:
        print "Error - Invalid Station ID or Web Server Problem - Try Again"

while True:
        TIME=int(raw_input("Time Stream will Play (in minutes): "))
    except ValueError:
        print "Error - Invalid Time - Try Again"


mp=subprocess.Popen(['/usr/bin/mplayer', rtmpurl, '-novideo', '-ao', 'alsa', '-quiet'], stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE)

endTime = + datetime.timedelta(minutes=TIME)


while < endTime:
    if not SongInfo == OldSongInfo:
        OldSongInfo = SongInfo
        print SongInfo[0] + " - " + SongInfo[1]

print("Stopping MPlayer...")
os.kill(mpPID, 2)

print "Done"


I got this script working on the N900 by downloading the Maemo 5 SDK and compiling the mplayer binary from a recent svn snapshot. Luckily, I didn't run into any problems. Although mplayer works with the N900, without any patches, it is not flawless. For example, video  gets jittery and skips when the backlight switches off. I would recommend leaving mplayer form extra installed and storing the mplayer you compiled in /opt. With audio playback I  do not have any issues, especially with the iheartradio rtmp stream!

Listen to iheartradio without Flash


If you have ever listened to any Clear Channel FM radio station then I am sure you have heard the ads to listen to the station online through iheartradio. The only problem is that iheartradio is a bulky and slow flash application. On a powerful desktop that isn’t a huge issue, but with my N900 (600mhz cpu, 256MB Ram) it takes over 5 minutes to start streaming the radio station. Of course, iheartradio has an application for the iPod and Blackberry, but no app for the N900.

I went on a quest to figure out how to listen to iheartradio without the bulky flash application and this is what I found.

Step 1:

The url of the a stations stream is can be found in a XML file, at URL “”

If I want to listen to The Fox (call letters: WTFX-FM), the URL of the XML would be “”

Open up the url in a web browser and grab the rtmp url which is between the <stream> tags. rtmp://

Step 2:

Download and Install rtmpdump and mplayer

  • Use your distro’s repositories
  • rtmpdump is in AUR (archlinux)

Step 3:

Lastly open up the terminal and enter the following command: rtmpdump -r $RTMPURL -v | mplayer -

-r tells rtmpdump the url of the stream

-v tells rtmpdump that the stream is a live stream

The | (pipe) directs stdin to mplayer and the – after mplayer tells mplayer to read data from stdin

Example: rtmpdump -r "rtmp://" -v | mplayer -

Things to watch out for:

  • The RTMP url may change/expire. I have not been able to confirm this yet, but if the RTMP url changes you will simply need to open the url of the xml file (step 1) and copy the new rtmp url


Maybe when I get some more time and become more ambitious I will write a small python wrapper that will extract the url from the xml file and start the stream.

HDTV Recording (MPEG2) to DVD

I record an episode of Dateline NBC because one of my family members wanted to see it, but she wasn’t going to be home to catch the episode. After much fooling around I finally got something that worked well.

So I’m tossing this here in hopes I will remember it and that someone else will find it useful.

The recording was in HD at a resolution of 1920×1280.

mencoder -oac lavc -ovc lavc -of mpeg -mpegopts format=dvd -vf scale=720:480,harddup -srate 48000 -af lavcresample=48000 -lavcopts vcodec=mpeg2video:vrc_buf_size=1835:vrc_maxrate=9800:vbitrate=6000:keyint=18:trell:aspect=16/9:acodec=ac3:abitrate=224:threads=4 -ofps 30000/1001 -o output.mpg input.mpg

And as another note: When you have a 16/9 video and you scale it to 720×480 (4/3) it will show the full frame to the wide screen tv (making the video look correct) or it will be stretched on a fullscreen television if the dvd player is outputting 4/3 letterbox. If the dvd player is outputting in cropped mode it will cut the extra width of and just show you the 4/3 portion.

^^ – This is how I understand the processes. It may be extremely wrong. If it is and you have a better understanding please let me know!