Saturday, October 17, 2009

Disabled for your protection

My Firefox, on Windows, just reported that it had disabled the Microsoft .NET Framework Assistant 1.1 extension and the Windows Presentation Foundation plugin. Supposedly, these were security issues. If I'd be so kind as to restart the browser for the changes to take effect.

Well, whatever, go ahead. After the restart, the Extensions window pops up, showing .NET Framework Assistant as “Disabled for your protection.” Phew, thank you.

But now I'm curious. What's so evil about these Microsoft plugins that Mozilla feels the need to block them automatically? Luckily, there is a “More Information” link right there in the dialogue! So I click it:

It's great to see that Mozilla really cares about my security.

Friday, September 25, 2009

Digital signatures made easy

Some time ago, a friend of mine discovered that somebody was plagiarizing the content of this blog. I'm not going to provide this guy with link juice, but you can find it through Google easily. The post is an exact duplicate of my Visual C++/Studio: Application configuration incorrect?, except for the title. Even my remark at the end, which clearly suggests that the author of the post is also a developer on Taekwindow, has been copied with the link intact.

Now imitation is the sincerest form of flattery and all that, but stealing my content without even mentioning my name goes too far. I posted as much on this guy's blog, but have received no response. So in the end I overcame my aversion and filed a DMCA infringement notification to Blogger.

Have a look at that form. Scroll all the way down. What will you see? Look at that! Isn't it beautiful? I'm supposed to sign a digital form… by typing my “signature” in a text box! Also, this is legally binding!

That cracked me up. It cracked me up so completely that I typed a beautiful capital X in that box and hit Submit.

Today, I received an e-mail from Blogger. It said:

We have received your DMCA complaint regarding no-link-juice-for-you.blogspot.com dated 09/20/09. Our policy requires that DMCA complaints be signed by the copyright owner or an agent of such. As your DMCA complaint was unsigned, we cordially request that you re-send us a signed copy of your notice by fax to (650) 618-2680. Once we receive your complaint, we will investigate the issue and process your request accordingly.

I still wonder what would have happened if I'd just typed my name into that box.

Hilarious.

Monday, September 14, 2009

Centering a figure on the page in LaTeX

With those wide margins of LaTeX, it sometimes happens that you have a figure or table that is too wide, and just sticks out to the right. Chances are that you want it centered, sticking out equally to the right and to the left, but tough luck: the standard center environment still aligns it with the left margin, and so does the \centering command.

I was about to write a package to provide an environment that centers its content on the page instead of inside the text. This is not too difficult, but preventing the overfull \hbox errors is tricky (they are so bad that even \hbadness=10000 has no effect). But then I stumbled into a standard LaTeX command that does exactly what I want.

So here's how to center your figure whilst ignoring the text margins:
\centerline{\includegraphics{...}}
It also works inside float environments such as figure. That was easy!

Friday, July 3, 2009

Speeding up Kile

Even though I'm mostly a Gnome user, my LaTeX editor of choice is Kile. Unfortunately, it can become a bit sluggish, especially when dealing with long lines. (I hate artificial line breaks, so I just type one line per paragraph and turn on dynamic word wrapping.)

This seems to have something to do with rendering. To make Kile considerably faster, start it like this:
kile --graphicssystem raster
Instead of raster, you can also try opengl, which is supposed to be even faster, but not considered stable yet. YMMV.

Monday, June 15, 2009

Creating a multi-page PDF from images

It is often convenient to pour a series of JPEG (or PNG, or GIF) files into a PDF, for example for printing or for e-mailing. Given the power of the Linux command line, this is surprisingly difficult, but I found a fairly straightforward way to do it. Skip to the bottom if you just want the oneliner.

Many websites will tell you the following:
convert *.jpg output.pdf
Easy, no? Don't do this. Why? Look at this:

-rw-r--r--  1 thomas thomas 129826204 2009-06-15 15:29 output.pdf
-rw-r--r--  1 thomas thomas    947022 2009-06-15 15:04 page1.jpg
-rw-r--r--  1 thomas thomas    962956 2009-06-15 15:05 page2.jpg
-rw-r--r--  1 thomas thomas    925291 2009-06-15 12:54 page3.jpg
-rw-r--r--  1 thomas thomas    952717 2009-06-15 12:54 page4.jpg
-rw-r--r--  1 thomas thomas    642471 2009-06-15 15:08 page5.jpg

The original JPG files are less than 5 MB altogether, but the resulting PDF is a whopping 124 MB! Clearly, convert (from the otherwise excellent ImageMagick bundle) re-encodes the images somehow, instead of embedding them straight into the PDF file.

Enter the little-known utility sam2p. It comes in an Ubuntu package of the same name. In its simplest form, it converts a single image file into a PDF by embedding the image file into the PDF file. For example:
sam2p page1.jpg page1.pdf
One of the shortcomings of sam2p is that it does not allow you to set the page size directly, so you'll end up with PDFs that exactly fit the original images.

Now we can generate all the pages as separate PDFs, but sam2p cannot create a PDF with multiple pages. Enter pdfjoin from the pdfjam package (available in Ubuntu under that name). It is simple to use:
pdfjoin page*.pdf --outfile output.pdf
This will use a consistent page size, so it is no problem that sam2p spit out pages of arbitrary size. It defaults to A4 paper; specify --paper letterpaper to use the Letter format.

Because I'm lazy, I wrote a little bash oneliner to do the trick, then let my readers improve upon it (thanks Mark, thanks Eamon!). It is now a twoliner, but who cares:
find . -maxdepth 1 -iname 'page*.jpg' -exec sam2p '{}' '{}'.pdf \;
pdfjoin page*.pdf --outfile output.pdf
This assumes that your input images are named page1.jpg, page2.jpg etcetera, and that there are no files named like page*.pdf in the current directory. If you have more than 9 pages, remember to prefix a zero to keep them in order. If you want to do this for PNG or other images, remember to change the extension in both places.

Tuesday, May 19, 2009

Windows Genuine "Advantage"

My Windows is genuine. I fail to see the advantage.

Wednesday, May 13, 2009

Accepted for Google Summer of Code!

I have been accepted for Google Summer of Code 2009! The title of my project is “Extend EclipseFP functionality for Haskell.” I have just set up a blog where I can keep all posts together that are related to this project. (This blog will also allow me to test-drive Wordpress, because as we all know Blogger sucks.) You can find more information at my new blog: EclipseFP GSoC '09.