Monday, October 15, 2007

What is Goonmill?

I have written up a definition of Goonmill, so that application actually has a scope and we know when it's done. See the DefiningGoonmill page in the wiki.

It breaks the application into the user tasks you should be able to perform with a completed Goonmill.

Sunday, October 14, 2007

Vim: Run the current buffer as Python code

This uses the handy preview window feature of Vim. Flagging a window as a preview window is useful because you can use pclose! to get rid of it, meaning you can reuse that vim real estate over and over for commands that produce output, and the output has to go somewhere.

fu! DoRunPyBuffer2()
pclose! " force preview window closed
setlocal ft=python

" copy the buffer into a new window, then run that buffer through python
sil %y a | below new | sil put a | sil %!python -
" indicate the output window as the current previewwindow
setlocal previewwindow ro nomodifiable nomodified

" back into the original window
winc p
endfu

command! RunPyBuffer call DoRunPyBuffer2()
map <Leader>p :RunPyBuffer<CR>


<Backslash>+p is mapped to run the current buffer through a Python interpreter. The output appears in a new window below the current one.

The code to do this with another interpreted language, such as bash, is almost identical and left as an exercise for the reader.

Saturday, October 13, 2007

Thumbnails from SWF video

I don't know if this'll ever be useful to anyone, but it was information I needed, and it was extremely hard to come by.

Here's how you extract a thumbnail from an video stored in an swf file. I'll leave the apt-get install dependencies as an exercise to the reader.

#!/bin/bash
SWF="$1"
AVI="${SWF/swf/avi}"
JPG="${SWF/.swf/%d.jpg}"
flasm -x "${SWF}"
mencoder -endpos 5 "${SWF}" -o /dev/null -nosound -ovc xvid -xvidencopts pass=1:turbo

mencoder -endpos 5 "${SWF}" -o "${AVI}" -nosound -ovc xvid -xvidencopts pass=2:bitrate=1600

ffmpeg -i "${AVI}" -an -ss 00:00:03 -t 00:00:01 -r 1 -y -s 120x90 "${JPG}"


BTW, this also converts the SWF to an AVI along the way, so if that's useful to you, great. (Modify the endpos and get rid of -nosound if you really wanted the AVI.)