<3 LaTeX <3

A fair portion of my supposedly study-oriented weekend was spent in the recovery of ebooks deleted in an iOS update gone wrong, and the ongoing hunt for a worthy ePub reader for my iPad.

Besides my iPad, I have spent most of today (Sunday) in the company of an old friend, that most excellent of typesetting solutions, LaTeX. Microsoft Word is a fantastic tool for quick documents, but its very nature as a WYSIWYG editor makes it leaves much to be desired as a tool for quality typeset documents. There is no separation of style and content (like HTML and CSS for instance).

Because of this unholy marriage of elements, I can spend as much time in the play of dials and sliders as I do writing. LaTeX strictly separates content and style-I define spaces, typefaces, indentations, fonts, and other styles at the start of the document, and then as I write I simply insert the tags as ncesessary. Example “hello world” .tex file:

\\title{Cartesian closed categories and the price of eggs}
\\author{Jane Doe}
\\date{September 1994}
   Hello world!

Prep version 1

For reasons-reasons other than convenience-that I would not be able to fully articulate should you choose to put a gun to my head, I store my website’s files (WordPress), database and content images separately. I guess if one’s data centre is bombed then the other two will be okay? Well, back to the convenience. I post a great many images to this blog; for the aforementioned convenience, I store my images in Dropbox. I can quickly and easily move, rename or alter images on my blog without having to piss about with FTP. Now, beyond handling the core image processing I don’t want to get bogged down in resizing, foldering, renaming and uploading all of those files. Because of this I script the action, but my current script only creates preview and thumbnail sizes:


mkdir -p $MED $SML 

for file in $(find . -iname "*.jpg"); do 
    cp $file $MED 
    cp $file $SML 

mogrify -quality 90 -resize 540x540+0+0 $MED*.jpg 
mogrify -quality 90 -gravity center -crop 256x256+0+0 $SML*.jpg 

exit 0

Today I want to add three two new features to it:

  1. Move the given folder into my Dropbox folder.
  2. Construct the URL code I use and ready it for pasting. Typical code is:
<a title="Click to view larger size" href="https://ix.bhalash.com/1466601748/1.jpg">
    <img src="https://ix.bhalash.com/1466601748/1.jpg" alt="" />

For both steps, I need the ability to output

only the name of the current directory I am working in, since this directory will be named according the number to the post. In the case of this blog post the folder name will be 1466601748. I spent about three hours fucking about with awk, sed, Google and pipes before I discovered a very simple one-liner that delivers the folder name unto me:

[mark][1466601748] # pwd 
[mark][1466601748] # basename $(pwd) 

Call me stupid. So, #1 is the easiest to achieve:

[mark][1466601748] # 
mv $(pwd) ~/Dropbox/Public/content

Step 2, generating the URL code, will be interesting, although trivial too. It seems like the easiest way is to echo the URL while I insert the post number and then stick the hot, steaming result into my clipboard. This works fine…but my sense of neatness is screaming at me that there is probably a more elegant way to achieve my goal:


POSTID=$(basename $(pwd))

echo \<a title=\"Click to view larger size\" href=\"http\:\/\/ix.bhalash.com\/u\/$USERID\/content\/$POSTID\/1.jpg\"\>   \\
\<img src=\"http\:\/\/ix.bhalash.com\/u\/$USERID\/content\/$POSTID\/m\/1.jpg\" alt=\"\" \/\/>\< \/a\> | xclip -sel clip</a> 

exit 0

Short version: Escape the shit out of everything and let God judge the survivors. Using $USERID instead of a hard-set user number gives me a little bit of portability for you, the consumer.

Enjoy. /smrt

HOWTO: Time-lapse capture your Linux desktop

OR: Playing with my scrot


I’ve been playing with my scrot relentlessly for the past two or three days. Literally non-stop for hours a time. I’ve even been making videos and then putting those videos on YouTube.


Scrot – SCReen shOT – is a FOSS screen capture utility that cleaves to the old Unix philosophy: It does one thing and does it very well indeed. And that is take screenshots. So get your freaking mind out of the gutter, dear reader(s).

It’s cool, I can wait.

Done? Great.

Scrot is something I’ve used for my screen capturing since 2003 or so, and while I’ve previously bowed to scrot’s scripting prowess, it has only been in the last four days that I’ve discovered another fun use for scrot: Simple, lite (resource-wise) time-lapse capture of my desktop. You can do it at home with just scrot and mplayer.


  1. Get scrot and mplayer on your system if you don’t already have them. Under Ubuntu, conveniently, it is:

    apt-get install scrot mplayer

  2. Type or copy and paste this command into the terminal while in the folder where you would like to capture the images

    while [ 1 ]; do scrot -q 100 $(date +%Y%m%d%H%M%S).jpg; sleep 1; done

    gives you an unending loop. Scrot will literally loop taking screensots until you finally decide to kill the program. As a quick rule of thumb, you need between 900 and 1,200 still images per minute of footage (60 seconds@15 FPS=900; 60 seconds@20 FPS=1,200). This does seem like a whole lot of still images, but at ~300 stills per 10 minutes, you’ll generate (300x6) 1,800 per hour.
    So about two hours of recording will net you a video that will go along very nicely to your average song track.

  3. Make a list for mencoder to read:

    ls -1tr *.jpg > files.txt

    Simple, eh?

  4. Stitch together your still images with mencoder. While I noted my own preferences aloud yesterday, you really are free to look at mencoder’s options – and I freely encourage you to do this. So far as I can gather, mencoder can do anything you ask of it…if you know the correct account.

    Encoding your video as-is (video raw, like still raw) is great for quality, but takes up a respectable chunk of hard-disk space. I settled on encoding with h.264 because it gave me a great balance of file-size and quality. Your frames per second in the video matter for two reasons: 1. Controlling video length (for fitting it to a soundtrack), and 2. controlling playback speed. Do you want events to whizz past, or be slower and more followable?

    mencoder -ovc x264 -oac mp3lame -audiofile basket_case.mp3 -mf w=1400:h=900:fps=20:type=jpg 'mf://@files.txt' -o screenlapse.avi

    I strongly encourage you to look up documentation on mencoder (such as here) so you can experiment and determine a solution that best fits your own needs.

And that’s it. For your pleasure, here’s one I made earlier:

I have remarkably photosensitive eyes

Shop Street, Galway
St. Nicolas' Church, Galway

I got my eyes tested today at Specsavers, and became intimately reacquainted with the searing agony that comes of having strobes flashed in my eyes.

Wile I have yesterday’s and today’s images ready to upload, I am not in the least bit inclined to sit in front of a bright monitor for several hours while my eyes send fiery hot bolts of pain into my brain. Instead I am asking you, the Twitterati and Facebookers who read my site. Process my images for me.

If you win, I will use your version here on my site. I will totally and completely pimp you and your site in the post and pimp you wherever this photograph may be used. To the victor, glory.

The rules:

  1. The results must be posted on this Boards.ie forum post.
  2. While you are permitted to crop the image’s aspect ratio and create a smaller copy for sharing on the internet, you must not in any way shrink the master image. This is for archival purposes.
  3. Winner is by acclamation of the Boards.ie forum poster. Simply put, the most “likes” wins.