ipython on windows

iPython is a very nice way to fiddle around with Python interactively. Most beginners just use IDLE for this, since it comes with Python. But as you get to plotting stuff, you’ll find that IDLE just doesn’t cut it (it freezes every time you plot anything). So you try the regular python command line (on the black screen) but get frustrated that you can’t change directories or use tabbed completion or anything. You hear about ipython and try to use it but it’s not very obvious. Well all you have to do is make a shortcut and you’ll be off and running.By the way, if you had started on Linux in the first place, you wouldn’t have to deal with all this! Anyway, on Windows,

0. Make sure you have Python installed with matplotlib and numpy modules.

1. Get ipython from http://ipython.scipy.org/ install it from the download page for your version of python

2. Make a shortcut to python.exe and then right click it and hit properties to change where it points to to:

3. Double click the shortcut.

Yay. Now you have ipython on windows with matplotlib interactive capabilities! I suggest having your text editor open in one window and this ipython window in the other. Edit your code, save it, and then type “run mycode.py” to run it in the interpreter.

A nice screenshot of an interactive matplotlib session on Windows

Anyway.

online happiness

I’ve found four excellent things online recently and think I should re-share them to all zero of my faithful blog readers. Hi friends! Anyway, I just posted a rant about Twitter, so no need to go there again. That’s the first one.

My friend Adam showed me this excellent free PDF book by David MacKay called Sustainable Energy – without the hot air. It is straight talk about all the crazy myths and misconceptions going around about renewables and other energy issues. The first few items on that link are raving review one-liners by high-profile peeps. Well written with much infused sarcasm.

And from Slashdot, I read a bit of this pdf (A Mathematician’s Lament) on the status of the USA mathematical education system. It’s twenty-five pages of welcome truth. Again sarcastic and wonderful.

Finally, there’s the DropBox. I’d heard about it earlier, but at work in Seattle where I’m actually using 2 computers, it’s become invaluable. It seamlessly integrates into my file managers (My Computer in windows, Nautilus in Ubuntu, and I think Finder in Mac). When I drag or change a file in my designated drop box folder on any computer, it automatically synchronizes across all computers. It’s superbly wonderful. As a bonus, it’s web interface keeps versions of every single update. So if you want to go back to the file you overwrote 2 days ago, no problem, there it is. Click this link to accept my referral and give me 250 extra MB! Or this one to sign up without giving me a bonus.

the value of twitter

OK, I used to think twitter was stupid. I imagined it as just a big collection of facebook status updates. Personally, I couldn’t care less about you going to the grocery store. But then I went to the ANS conference in Atlanta and realized what the big deal was. You can embed tags in your twitter posts, using the # symbol. For instance, at the ANS conference, if you say something and put #ans09 in it, everyone who searches #ans09 can see what everyone who said #ans09 has posted. So you go there and it’s like: “hey a group of us here at #ans09 are going to max’s down the street. come on by!” You try #fremontfair for the solstice parade happening in seattle tomorrow and it’s all “PCC RT @amyhale: Getting prepped to live-blog, tweet tomorrow’s #Fremontfair the “Center of the Universe”! Watch 4 updates + audio too!”

Another feature: you can do it all on SMS on your phone. So imagine a group of people going out. If they all set their phones to “follow” the same person, he or she can just say: “ok going to Brown Jug now.” Or “going to Bab’s now.”  and everyone will get texts with that info. That’s actually new and useful communication right there.

So sign up for it. Do some searches for stuff you’re interested in. Up-to-date collective knowledge is at hand.

Actually the real reason I checked it out was all the buzz about the Iranians using it to organize protests. Apprently the US state department asked twitter to delay a scheduled maintenance window so the Iranians wouldn’t be left in the dark. Cool.

BTW, if you’re all interested in whether or not I’m at the grocery store, I’m partofthething on twitter.

commands to do stuff in linux

Here are some nice commands.

Combine lots of pdf files:

gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=combinedpdf.pdf -dBATCH 1.pdf 2.pdf 3.pdf

Convert eps files to eps files with perfectly fitting bounding boxes:

epstool --copy -b file1.eps newfile.eps

Pull pages out of a pdf (more):

pdftk A=one.pdf B=two.pdf cat A1-7 B1-5 A8 output combined.pdf

Make a quicktime movie with ffmpeg:

ffmpeg -f mp4 -vcodec mpeg4 -i case3-flyby.avi case3-flyby.mov

Encode lots of jpgs to avi:
mencoder mf://hexes???.jpg -mf fps=10:type=jpg -ovc lavc -lavcopts vcodec=mpeg4 -oac copy -o output.avi

Convert pngs to jpg:
mogrify -format jpg -quality 90 hexes???.png

Shrink a bunch of jpgs:
convert -resize 20% IMG_2704.JPG sm_IMG_2704.JPG

Pull audio out of a video file:
ffmpeg -i was014.dv -ab 128 -ar 44100 was1.mp3

Play audio faster or slower without changing the pitch
mplayer -af scaletempo was1-fixed-up.mp3 . Use [ or ] to change speed.
(Note: you have to have a more modern version of mplayer to do this https://launchpad.net/~rvm/+archive/mplayer)

Run povray with 100 frames on the clock:
povray -W1200 -H1000 +kff100 hexes.pov