Sunday, 1 November 2009

Invoices in LaTeX Part One

If you're like me and enjoy a beautifully typeset document, you may be a user of LaTeX. I also dabble in web development and like to invoice clients occasionally -- and for this I found the invoice package by Oliver Corff. Titus Barik has a nice brief example though no PDF of the LaTeX example. So building on Titus's example, here is the rendered PDF from that example (using Koma Script's `scrlttr2' which typesets letters "better" than LaTeX `letter'). I wasn't that happy about the way the invoice table is rendered using the usual LaTeX tabular environment with \hline's, and set about making use of booktabs instead. By replacing \hline's with \toprule, \midrule and \bottomrule we get a slightly better looking invoice (download the PDF to see the difference). Part two we'll look at how to improve on the invoice package further.

Thursday, 22 October 2009

Asus EEE 1000H Hotkeys in Karmic

So after installing Ubuntu Karmic today, I was hoping the volume up/down keys would work, alas not. A little relevant reading brought this gem:
What does all that gibberish mean? It means the three keys that generate XF86Launch# (where # is 1-3) are user-defined hotkeys that you will be able to set in the gnome-control-center when that's functional again.
What does all that mean? It means running ``Gnome Control Center->Keyboard Shortcuts'' and vioala set those volume up/down (and mute) shortcuts. Now how they got disabled I dunno.

Thursday, 16 July 2009

Java 1.5 and Emacs

While trying out the Restlet tutorial, I thought it time to fix Emacs Java mode to correctly indent annotations. Found a post from Ben Tomasini which fixes it: (add-hook 'java-mode-hook '(lambda () "Treat Java 1.5 @-style annotations as comments." (setq c-comment-start-regexp "(@|/(/|[*][*]?))") (modify-syntax-entry ?@ "< b" java-mode-syntax-table))) Adding that to your .emacs file.

Restlet 2.0 First Steps

Trying out the Restlet 2.0 first steps tutorial I soon realized it hasn't been updated for the 2.0 API. Changes I had to make for it to compile were the following: FirstStepsApplication.java < import org.restlet.Router; --- > import org.restlet.routing.Router; HelloWorldResource.java < import org.restlet.resource.Representation; --- > import org.restlet.representation.Representation; 10,11c10,11 < import org.restlet.resource.StringRepresentation; < import org.restlet.resource.Variant; --- > import org.restlet.representation.StringRepresentation; > import org.restlet.representation.Variant; Another Ubuntu/Debian-specific problem was security... this error appeared: ... java.security.AccessControlException: access denied (java.lang.RuntimePermission createClassLoader) ... I recalled this was Tomcat permissions, found this and copied this: permission java.util.logging.LoggingPermission "control", ""; permission java.io.FilePermission "./*", "read,write,execute,delete"; permission java.util.PropertyPermission "user.dir", "read"; permission java.util.PropertyPermission "disableLuceneLocks", "read"; permission java.util.PropertyPermission "java.io.tmpdir", "read"; permission java.util.PropertyPermission "org.apache.*", "read"; permission java.io.FilePermission "/-", "read,write,execute,delete"; permission java.lang.RuntimePermission "createClassLoader", ""; into /etc/tomcat6/policy.d/04webapps.policy and restarted Tomcat and it works finally.

Friday, 12 June 2009

Git Commit Squashing

I've thought about this for a while -- How does one merge a series of Git commits into one commit for publishing? Luckily it's easy by squashing commits with rebase.

Sunday, 8 March 2009

Visualizing Data from Wikipedia's Settlement Infobox?

Wikipedia is a great way to get information on cities - the Settlement Infobox template that most city articles use encapsulates some really useful information like area (land/water/urban), population and densities. With all that information in a semi-structured format I would love to be able to extract it and visualize them like the amazing ones Jer Thorp has done using the New York Times API and Processing. Wikipedia also has an API - I just haven't been able to figure out whether Infobox data can be extracted using it!

Thursday, 5 March 2009

Twittering from the terminal

Update: Found out twitter ``tinifies'' your URLs for you...

I've been twittering for 2 hours now, and thought it would be nice to detail how one can update their status from the command-line without displaying their password. A few pages helped me along:

  • Dave Taylor wrote a fine article on how to tweet using the command line,
  • Duane Odom writes about his solution to encrypting passwords, which got me on the right track for that,
  • User Heller_Barde wrote a script, tinify which is excellent for shrinking the links you'll want to add to your tweet.
  • defcon posted a guide to getting started with GPG in Ubuntu, which I mostly followed line by line.

So now to my solution, a mashing of all the bits from the articles above:

  1. Create GPG key, remember what you put for your full name as you'll need it for the next step gpg --gen-key
  2. Create encrypted twitter `username:password' string. echo "<user>:<pass>" | gpg -e -r "Your Full Name" >~/.twitter.gpg
  3. Download the tinify script (and xclip and curl, if you don't have them already)
  4. Tweet away! (Don't forget to copy the link you want tinified before running) TWITTERPASSWD=`gpg -d -r "Your Full Name" ~/.twitter.gpg` \ curl --basic --user "$TWITTERPASSWD" --data-ascii \ "status=I think #TED is pretty, pretty good: `tinify`" \ http://twitter.com/statuses/update.json

Disclaimer: I've played around with GPG and Twitter for two hours or so, and haven't yet fully thought out the security consequence of storing the plaintext username:password string as an environment variable. A shell script to encapsulate the command above would be nice too! Next post perhaps?

Peace /nzroller