Wednesday, February 18, 2009

How to Get to Germany

One of my office mates and I just got a papper accepted in a conference in Germany. We are quite happy about the accept, but making the travel arrangements have been ... well non direct. I tried all sorts of ideas on what would be the cheapest way to get to Germany (turns out going south to go north is cheapest), for the both of us. According to my travel partner, below is my intended route. [This a whiteboard in my office. I messed with the contrast using GIMP to make it more legible.]

Tuesday, February 17, 2009

Griffey's a Brave ~ not really

I said I want him. Now I got him. I hope I was right.

[Turns out I was a little premature. I wasn't the only one. The AJC jumped the gun a little.]

The 9 o'clock Block o'Fun

At 9 on Tuesdays, two shows play against each other. One on NBC and one on FOX. One about hunting terrorists, and the other portraying the same techniques as the villain. It's Heroes vs. 24.

On one side you have 24 on FOX where terrorists are on the loose. Jack Bauer is the only man who can stop them, and he will do everything necessary, including torture.

At the same time over on NBC, heroes (and heroines) are treated like terrorist and the villains are the tortures government tracking them down.

Why does this not surprise me?

Monday, February 16, 2009

Best Teaching Advice Yet

Some of my lonely readers may know that I am in the throws of teaching this semester. I read a lot of blogs, and I ran across this post from Luis Von Ahn's blog, "Luis Von Blog." A professor at CMU, Professor Von Ahn provides detailed advice on teaching. I repost the advice below

1. Crush them on the first 2 homework assignments -- those who remain will be good students.

2. When you don't know the answer to a question say it's outside the scope of the class.

3. Teaching evaluations are highly correlated with the grade the students think they will get at the time of filling out the surveys. Make your course easy, then crush them on the final (but see #1).

4. Never admit you're wrong. "I have a PhD, trust me."

5. Schedule office hours at 8am.

6. If you can't learn their names, call them all "dude."

7. Never, under any circumstances, disclose the exact grade cutoffs at the end of the semester. Somebody has to get the highest B, and they won't be happy. "You're lucky you got a B, dude."

8. Finish lecture 10 minutes early every time –- they love this (and they'll never know you love it even more).

9. Easiest way to get rid of whiners without yielding: "I'll take that into account when calculating your final grade."

10. Get good teaching assistants.
Some of this advice doesn't apply to my class (I have 35 students and no TA's), but I see exactly where he is coming from. Unfortunitly, I can not pull the "I have a Ph.D., trust me" trick, yet. But, I could have used it a couple of times.

One thing that I would add to this list is this word of advice: "Teaching is hard, get over it."

It's one thing to give advice on dealing with students, but he never address another fundamentle problem, laxidasical teachers. It takes an emmence effort on my part to prepare lecture, demos, and home works, and I have no one to complain to but myself. Teaching is one of the hardest endeavours I have ver undertaken, and the sooner you realize that it is not going to be a cake walk, the sooner you get to work and start preparing. Teaching is hard, very hard.

Anyway, I can't wait to start calling all my students "dude" because I am always forgetting their names. Thanks for the advice Luis, and word to all my dudes and dudettes.

Monday, February 9, 2009

GUIDE: follow up "YouTube Music Video (mp4) to mp3 audio"

I decided to take my posting about getting mp3's off you tube an additional step. If you meet the requirements listed in the post, I have written a quick python script that will download the video and convert it into an mp3 automatically. I am not saying that it is the best script, but it works. You should also change the access to os.system() calls, i.e., the calls to wget, to use direct paths, i.e., /usr/bin/wget, for security reasons.

Go ahead and give it a go, and let me know how it works. There are likely bugs. I just hacked it up before I left work today.


#!/usr/bin/env python
# pwn_music.py

#****************************************************
#Download Music from YouTube
#
# Usage:
#
# python pwn_music.py <YouTube URL> [<audio file name>]
#
# if no audio file name is provided, defaults to audio.mp3
#
# Sample Execution:
# python pwn_music.py http://www.youtube.com/watch?v=Gp7f4l myaudio.mp3
#
#
#
# (c) Adam Aviv, ALL RIGHTS RESERVED
# Released under the Creative Commons Licence
#
# Legal Note:
#
# The legality of certain audio downloads from YouTube is unclear. Use
# this program at your own risk. The author takes no responsibility
# for the way in which his code is used.
#
# Required Packages:
# (1) wget
# (2) faad
# (3) lame
#
# This program is designed to run on Linux Operating Systems
#
#****************************************************

import os,re,sys

def get_pwn_url(youtube_addr):

l = youtube_addr.split("www.")
if len(l) != 2:return None
l[1] = "pwn"+l[1]
url = "www.".join(l)


cmd = "wget -O - %s"%(url)
fd = os.popen(cmd)
data = fd.read()
fd.close()

if data:
start = 'href=\"'
end = '\">Download High Quality Video'
regex = r'%s.*%s'%(start,end)
match = re.compile(regex).search(data)
if not match:return None
return data[match.start()+len(start):match.end()-len(end)]

def pwn(pwn_url,out_name):

cmd = "wget -O video.mp4 %s" % (pwn_url)
os.system(cmd)

cmd = "faad video.mp4 -w | lame -r - %s"%(out_name)
os.system(cmd)
os.system("rm video.mp4")



def main(youtube_addr,out_name="audio.mp3"):
pwn_url = get_pwn_url(youtube_addr)

if not pwn_url:
print >>sys.stderr, "Invalid initial URL or No High Quality Download"

print pwn_url
pwn(pwn_url,out_name)
print "audio done, in file %s" %(out_name)

if __name__ == "__main__":

argc = len(sys.argv)
if argc < 2:
print >>sys.stderr, "ERROR \nUSAGE:pwn_music.py youtube_url audio_out"
elif argc >4:
print >>sys.stderr, "ERROR: \nUSAGE:pwn_music.py youtube_url audio_out"
else:
if argc == 2:
main(sys.argv[1])
elif argc == 3:
main(sys.argv[1],sys.argv[2])

Friday, February 6, 2009

Posting about Bonds over at DSS

I have sports in the title of this blog for a reason. I just put up a new post over at DirtySouthSports (DSS) about Bonds and the perjury case. Really it is a plea for finality for the whole steroid issue.

Go ahead and give it a read:

http://www.dirtysouthsports.com/2009/02/perjury-bonds-law-and-court-of-public.html

Thursday, February 5, 2009

GUIDE: YouTube Music Video (mp4) to mp3 audio

I learned a new trick today. I was listening to the radio when I heard a new song I liked. I normally don't purchase music nor [air quote] steal [air quote] music, but I was interested in how hard it would be to get an mp3 of a song I just heard on the radio without resorting to torrents or other file sharing services.

Turns out it is pretty damn easy, so I wrote up a quick guide to share with the (only 2) people who read my blog.

This guide is written for Linux system with these prerequisites:
1. faad : audio extractor
This can be easily installed through any major package manager. In fedora type
~>su -
~>yum install faad
2. lame : mp3 encoder
This can be installed the same way as above replace faad with lame
3. mplayer : video, audio player for linux
You can install mplayer though a repo or you can download from here
4. mplayer codecs: the codecs that make mplayer work
You will likely want this tar ball of the codec otherwise go to the link above

Step 1: Go To YouTube
Chances are that if you hear a song on the radio, there is a music video. If there is a music video, then somebody has uploaded it onto YouTube. A lot of the time, the band itself does this since it gives them some added publicity and exposure. Most of the time howerver, it is a pirated, illegal copy. Hopefully you can get your hands on a clean copy which may avoid my next point.

THE LEGALITY OF THIS PROCEDURE IS NOT CLEAR. If you have a guilty concious, then don't continue.

Still with me? Ok.

There will likely be more then one version of the music video posted. You should care most about the audio quality, not the video quality, when choosing which posting to work with. Once you have chosen the best sounding music video, it is time download the video.

2. PWNYouTube
PWNYouTube (Pown YouTube) is a web site that specializes in downloading video from YouTube. It is really easy to use.

You have two options: (1) copy the URL for the YouTube clip to the PWN YouTube site, or (2) simply change the YouTube URL in your browser by adding 'pwn' before youtube.

For example:

Just change this
www.youtube.com/watch?12340-ad...
to this
www.pwnyoutube.com/watch?12340-ad...

Then download the highest quality option provided to you. The resulting file will be name video.mp4. Go ahead and play the video with mplayer to check the sound quality. Don't worry about the picture, you will likely have some missing frames, but you don't care about that. If it's all good, move on to the next step.

3. Convert the mp4 to an mp3
There may be other ways to do this conversion, but I found this way the simplest. It proceeds in two steps really, but we are going to combine it into one command line statement. The first step is to extract the audio from the mp4 file to create a raw pcm output. The second step will convert the raw pcm into an mp3 encoding.

To do it all at once using the command line, first cd into the directory where the video.mp4 file was saved from step 2. Now type this command:

faad video.mp4 -w | lame -r - audio.mp3
You should see some feedback on the screen, like how much of the file has been converted and etc. Once all of that is done, your done. Really? Yeah really, that's it.

The audio.mp3 file is a mp3 comprehension of just the audio content of video.mp4. You can check the quality of the mp3 by playing it in mplayer. It will report all sorts of info on it when it loads.

Now, you have successfully, in a matter of 5 minutes, produced an mp3 of a song you just heard on the radio. How easy was that? Share and be merry.