Building Perl stand-alone applications with a GUI using Mojolicious and PAR-Packer

May 17th, 2013

You might have come across the same problem I have faced pretty often: You want to write a small snippet of code for a friend who's not into programming to solve some task. You want to use the scripting language of your choice (yeah, Perl). But for many people, especially Windows users, explaining them how to install perl, install some modules from CPAN, and finally how to use the script from the command line is tedious and often takes more time than writing it in the first place. And sometimes it even takes more time than solving the task by hand which is quite frustrating.

So I always wanted to build stand-alone applications with a GUI for those cases. But building GUIs is usually a huge pain in the ass, so I always avoided it; until I got the idea to build web applications with Mojolicious as GUI. Building stand alone executables without the need of installing perl, modules, or libraries can be solved with PAR-Packer. So far, that was just a thought.

A few days ago I got a small task: My brother wanted an application to automatically correct one kind of systemic error in large data sets. So I wanted to put that idea to the test. It worked out quite well!

The function field of a plane curve

May 13th, 2013

My colleague and me were confronted with a question concerning the introductory chapter of a text on algebraic geometry. The scenario of a plane curve $C=Z(f)\subseteq \mathbb A_{\Bbbk}^2$ over a field $\Bbbk$ is considered, for a nonconstant polynomial $f\in\Bbbk[x,y]$. It was stated that the function field $\mathbb K:=\mathrm{Quot}(\Bbbk[x,y]/\langle f\rangle)$ is obviously of transcendence degree $1$ over $\Bbbk$ because $f(x,y)=0$ is a new relation between $x$ and $y$. The prerequisites to this text are basic undergraduate knowledge of algebra and topology. The question was about the obviousness of the above statement. We came up with a proof that only really requires some linear algebra. I found it rather cute. Do you want to see it?

My Quest for (CPU) Power

May 11th, 2013

This glab post is essentially about running a certain shell command remotely on multiple systems within a network that has been set up for public-key authentication. It's a standard task for experienced system administrators I am sure, but for me it was a little adventure in bash scripting — and I wanted to share it with you.

Getting rid of superfluous entries in the TrueCrypt chain loader

May 8th, 2013

I'm using TrueCrypt system encryption for my Windows Partition and use its chain loader to boot Linux via GRUB, which is installed on my /boot partition. However, at some point I also had GRUB installed on my root partition. Because of that the TrueCrypt boot loader — after pressing ESC when I didn't want to boot Windows — showed a list of partitions to boot from instead of directly starting the only other boot loader. That's less convenient and a little bit annoying, so I wanted to get rid of the entry.

As the TrueCrypt boot loader seems to detect boot loaders on partitions automatically, I wanted to try deleting the redundant one. However, I didn't find anything on how to delete a boot loader from a partition; that's probably because it usually isn't necessary. A quick search on Wikipedia revealed that the boot loader on a partition is stored in the volume boot record (VBR) of the partition, which is just the first sector, similar to the MBR. So I first made a backup in case I got anything wrong[1]:

$dd if=/dev/sda5 of=sda5.vbr bs=512 count=1 and then wrote zeros to the VBR:$ dd if=/dev/zero of=/dev/sda5 bs=512 count=1

which did exactly what I wanted.

Be aware, however, that when you want to delete the boot loader from an extended partition, this would overwrite the partition table in the extended boot record (EBR), so you may only overwrite the first 446 bytes of the sector instead of all 512.

One last thing that cannot be stressed enough: Have a current and complete backup handy, and be prepared you might have to use it. I'm no expert on the subject. If the VBR is used for more purposes than just containing a boot loader as I expect, zeroing the whole sector may really go wrong.

1. make sure to backup to a different partition than the one you're going to write on :) []

Vector Bundles vs Locally Free Sheaves

April 30th, 2013

I wrote a little text that outlines why vector bundles and locally free sheaves are the same thing. This approach is very messy with a lot of gluing, mostly because I did not look at Exercise II.5.18 in Hartshorne right away. The construction given there is much more canonical and preferable over mine. However, I decided to put this online simply because it is different and personally, it gave me a better feeling for why the two notions coincide.

Why Sudoku is boring

April 17th, 2013

I was riding the backseat of a car, a pal of mine with a large Sudoku book on the seat beside me. I glared over at him and remarked that I find Sudokus utterly boring and would feel that my time is wasted on any of them. He looked up at me, clearly demanding an explanation for that statement. I continued to explain that a computer program could solve a Sudoku with such ease that there is no need for humans to do it. He replied that something similar could be said about chess, but still it's an interesting game. And it was then, that I realized why Sudoku is so horribly boring, and chess is not.

It was the fact that I could code a Sudoku solver and solve the Sudoku he was puzzling about, and I would be able to do it faster than it would take him to solve the entire thing by hand. This does not apply to chess, evidently. Of course, I confidently explained this to him. »Prove it.«, he said. So I did.

Groupon sold my e-Mail address

April 5th, 2013

The idea behind groupon is to make it easy (and cheaper) for new customers to try out a service or product. The whole site really looks like racket but I used it some time ago. I have the common practice that I create an e-mail address for every single service I register to. So I used an e-mail address of the style "mymail-groupon@mydomain.tld" for it. Today I got an e-mail with the subject "Abmahnung Ihrer aussehender Rechnung über 262,00 Euro" (impolite german for "Reminder for a payment about 262 euros") from an debt collecting agency.

The Rainich Trick

April 3rd, 2013

Zariski's proof[1] of the Hilbert Nullstellensatz makes use of the ineffable Rabinowitch Trick[2] (check it out, that has got to be the shortest paper ever). But who is that awesome guy Rabinowitsch? I found out today, and the answer is basically in in this MO post:

Rainich was giving a lecture in which he made use of a clever trick which he had discovered. Someone in the audience indignantly interrupted him pointing out that this was the famous Rabinowitsch trick and berating Rainich for claiming to have discovered it. Without a word Rainich turned to the blackboard, picked up the chalk, and wrote RABINOWITSCH. He then put down the chalk, picked up an eraser and began erasing letters. When he was done what remained was RABINOWITSCH. He then went on with his lecture.

Apparently, George Yuri Rainich is the mysterious stranger that went by the name of Rabinowitsch, which was his birthname[3][4]. I even updated the wikipedia page. Oh right, the reason this even caught my attention: Daniel R. Grayson has a really sweet, short proof of the Nullstellensatz, also using the Rainich Trick.

1. Oscar Zariski. A new proof of Hilbert's Nullstellensatz, Bulletin of the Ameican Mathematical Society Volume 53, Number 4 (1947), 362-368. []
2. J. L. Rabinowitsch, Zum Hilbertschen Nullstellensatz, Mathematische Annalen Volume 102, Number 1 (1929), 520. []
3. Bruce P. Palka, Editor's Endnotes (May 2004), The American Mathematical Monthly 111 (5): 456–460 []
4. Bruce P. Palka, Editor's Endnotes (December 2004). The American Mathematical Monthly 111 (10): 927–929 []

Recursively set ownership in Windows

April 2nd, 2013

I have a folder data with stuff in it. I am not using an Administrator account on my Windows machine, and that folder is supposed to be owned by my user. When you search for how to take ownership of all files and folders in a certain directory recursively, you get told to use TAKEOWN, a lot. Well, it has a little catch: You can only really use it to take ownership. Not to give it. A much more giving command is

ICACLS C:\data /setowner rattle /T

Oh yea, it's the /T switch that makes it recursive.

Affine Algebraic Groups

March 26th, 2013

I have written a short little thing about affine algebraic groups, mostly for myself, partially by request from a source that shall remain anonymous. I might talk about it in a secret seminar, known only by the mysterious letter $\eta$, in the proverbial مكة المكرمة of mathematics. Stay tuned.

Lenovo System Update somewhat demystified

March 9th, 2013

Suppose you have a Laptop, which therefore must be a ThinkPad™. Let's also assume that you use Windows 2008 as a workstation, just like I do. Then, you might run into some issues with Lenovo System Update. To be precise, it tells you:

An error occurred while gathering user information.

Then it stops. I will provide a solution to this problem which is not specific to Windows 2008 R2, and therefore, I hope that my solution will also work for future versions of Windows that are not out-of-the-box supported by SystemUpdate.

Nested case distinctions in LaTeX

March 7th, 2013

Trust me, I am not one to enjoy deeply nested case distinctions in a mathematical proof. In fact, I'd rather there were no case distinctions necessary at all. However, to quote the famous mathematician Nikolai Nowaczyk:

» Some theorems have beautiful proof - and some theorems are worth fighting for. «

Anyway. If you have to do it, you should do it in beautiful $\LaTeX$.

Convert WAV to MP3 with VLC

March 5th, 2013

If you like electronic music, you obviously lurk getworkdonemusic.com all the time with jDownloader running, so you can copy the link to any nice track on the air and download it, slowly aquiring a groovy selection of electronic music for the lonely train hours where you have to get work done, offline style. Sometimes, however, these tracks are in wave format, for reasons that are completely beyond me. A quick google search for »convert WAV to MP3« points you towards a huge selection of shitware, when it could be so much easier: Fire up VLC, the best media player in the world[1] and go

• Media, Convert/Save (Ctrl+R)
• Add your file to the list.
• Click the button that says Convert/Save.
• Select a destination file.
• Set the profile to Audio - MP3 and hit Start.

Also, make sure you don't have VLC set to loop, because otherwise it'll spend the next few hours overwriting that file with the same converted MP3 again and again. True story.

1. This post refers to VLC media player 2.0.5 Twoflower. []

Thunderbird: Mark all drafts as read

March 4th, 2013

I wasted like 60 seconds a day marking drafts in Thunderbird as read after I use the SendLater-Plugin. The following AutoIt-Scripts that runs in background now saves this precious amount of time!

$x_offset = 80$y_offset = 140

TraySetIcon('C:\Program Files (x86)\Mozilla Thunderbird\thunderbird.exe', 1)

While 1
WinWait('[TITLE:Send this email later; CLASS:MozillaDialogClass]')
WinWaitActive('[REGEXPTITLE:Mozilla Thunderbird]')
Sleep(1000)
$tb_pos = WinGetPos('[REGEXPTITLE:Mozilla Thunderbird]')$mouse_pos = MouseGetPos()
MouseClick('right', $tb_pos[0]+$x_offset, $tb_pos[1]+$y_offset, 1, 0)
Send('{UP 4}{ENTER}')
MouseMove($mouse_pos[0],$mouse_pos[1], 0)
WEnd

Animated LaTeX

March 1st, 2013

After discovering the toggle command available in MathJax, I immediately went to asked the capable people of tex.stackexchange whether this could be done inside a PDF file. And indeed: It can be done!

\documentclass{article}
\usepackage{animate}

\begin{document}
\begin{animateinline}[step]{1}
\strut$x=1$
\newframe
\strut$x=2$
\newframe
\strut$x=3$
\end{animateinline}
\end{document}

This would correspond to the slideshow: $\toggle{x=1}{x=2}{x=3}\endtoggle$. Now, what do I want with this package? I want to do abstract nonsense. A diagram-based proof should, in my opinion, be a slideshow. You start with the diagram that is your assumption and by simply interacting with the diagram (clicking it), in each step, a new arrow is constructed from some universal property. A very tiny example in MathJax:

The above example only has one step, because it's just the universal property of the kernel. For a proof of statements such as the Five Lemma, several steps would be involved.

I wanted to write a neat animated PDF with an abstract nonsense proof of the famous Snake Lemma, and there is a great book by Francis Borceux containing a proof, but unfortunately, I was unable to overcome a difficulty with the proof, so that will have to wait until someone answers my question.

Blog Size

March 1st, 2013

Looking at Roman's beautiful blog, I really couldn't take it no more. I finally removed that scourge of a tiny font size from the blag, now it is actually possible to read everything on a commonly shaped screen. At this point I wished this had been done in LESS, because then I would probably only have to change two variables in order to achieve, what now took me, approximately one hour.

Extension by Scalars and Dimension

February 26th, 2013

Let $K\subseteq L$ be a field extension, and let $V$ be a $K$-vector space. The extension of $V$ by scalars in $L$ is the tensor product $E=V\otimes_KL$. I will prove that every $L$-vector spaced is obtained as some extension in this way and that $\dim_L(E)=\dim_K(V)$.