CSS3 with Firebug and Opera Dragonfly

Vom 22. Juli 2010

I was playing around with some CSS3 stuff lately and while doing so I noticed that Firebug seems to be buggy as soon as you use some CSS3 rules:

These funny blocks that look like parts of a picture are indeed parts of the header image. Looks like the margin and padding highlight somehow displays the wrong stuff. Just as a reference, the above usually looks like this:

I’m sure this Firebug bug :) gets fixed pretty fast but it made me remember that Opera contains a similar development tool: Dragonfly. It’s not as hot and pretty as Firebug but the basic functionality looks pretty solid.

After this experience I will fire up Opera a bit more often when doing design stuff (right now I use Opera only for browsing). For the usual grunt work Firebug is absolute invaluable (alone the JS debugging …) but it’s good to know that there is an alternative at least for some situations. I like variety.

Abgelegt in: Programmieren | Kommentare ansehen und hinterlassen

Can’t set locale error on Linux

Vom 5. Juli 2010

Some time ago I’ve written about the virtual machine I got for my video streaming and archiving project events.mi. While the VM(Virtual Machine) did really well during the last month´s some command displayed some strange error messages.

man for example:

man: can't set the locale; make sure $LC_* and $LANG are correct

Special characters like German umlauts were also not correctly displayed on the console. This didn’t really was a problem until Subversion refused to operate because of a directory containing a special character.

The quick answer

The locale data is installed but the needed locale is not compiled into the locale archive. You can do this for the “de_DE.utf8” locale with the following command:

localedef -i de_DE -f UTF-8 de_DE

The long story

After a quick search I tried to reinstall or reconfigure the locales package but either helped to solve the issue. Since it’s obvious that the error is related to locales I did some digging in the POSIX Locale spec. The LANG environment variable was set to “de_DE.utf8” so there was no problem with the settings. However listing the locales showed something strange:

$ locale -a
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_COLLATE to default locale: No such file or directory
C
POSIX

The POSIX spec states that the C and POSIX locales are just placeholders for the default locale. However there is not a single “real” locale (e.g. “de_DE.utf8”) in the list and therefore the default locales point nowhere. A quick test of the setlocale() function in a small C program also showed that it always returns NULL and therefore fails.

Now the question is, why are there no real locales installed? I stumbled across a forum post mentioning localedef as a solution to the problem and the man page of localedef shows the directories where the character maps (/usr/share/i18n/charmaps) and “raw” locales (/usr/share/i18n/locales) are stored in a Linux system. These directories contained many character maps and locales but the “compiled” locales in the locale archive (/usr/lib/locale/locale-archive) where simply missing. Therefore locale -a returned only the placeholder locales and setting the “de_DE.utf8” locale failed.

Now localedef is the utility that compiles the raw locales and character maps into the locale archive. So the only thing we have to do is compile the wanted locale:

localedef -i de_DE -f UTF-8 de_DE

Now the list of available locales looks like it is supposed to do:

$ locale -a
C
de_DE
de_DE.utf8
POSIX

Now the necessary locales are in the locale archive and therefore all programs can use the setlocale() function again to set the locale to “de_DE.utf8”. Directory and file names are also displayed properly and Subversion can handle special characters again.

I hope this detailed description of the error helps a few people solving similar problems. :)

Abgelegt in: | Kommentare ansehen und hinterlassen

7. GamesDay abgeschlossen

Vom 30. April 2010

Der 7. GamesDay ist nun endlich abgeschlossen. Alle Aufzeichnungen sind online und es gibt nichts großes mehr zu tun. Endlich Zeit um stehen zu bleiben und etwas zurück zu blicken.

Im Gegensatz zu dem 6. GamesDay hatten wir dieses mal deutlich mehr Zeit für die Organisation (2 Monate statt 2 Wochen). Wir haben sie zwar nicht so gut ausgenutzt wie beim letzten mal, aber dafür hatten wir alle noch etwas Leben neben den GamesDay. Ich bin echt froh, dass dieses mal so viele bei der Organisation mit geholfen haben, besonders zum Schluss hin währe es sonst nicht machbar gewesen. Viele haben wirklich sehr gute Arbeit geleistet.

Alles in allem hat der GamesDay bei mir mit ca. 42 Std. produktiver Arbeitszeit zu buche geschlagen (ohne Besprechungen und Zeit an der HdM) und damit das Asteroids-Projekt (ca. 40 Std.) überholt. An für sich sind 42 Std. jetzt nicht so viel (knapp eine Woche normale Arbeit), aber 42 Std. produktive Arbeit sind eine ganze Menge. Einige haben vielleicht schon die Erfahrung gemacht, dass man an einem 8 Std. Tag nicht unbedingt 8 Std. produktiv arbeiten kann…

Von den Vorträgen haben mich mal wieder die technischen Themen begeistert. Allen voran “Game Engine Architecture” von Andreas Stiegler. Einfach genial, Punkt. Ich werde mir seinen Vortrag noch einige male anschauen, sobald mein nächstes Spiele-Projekt anläuft. Persönlich mag ich relativ realistisches bzw. physikalisches Gameplay sehr gern und Andreas hat bei seinem Vortrag witzig und anschaulich erklärt, wie man genau sowas angehen kann.

Ebenfalls sehr gut fand ich den Vortrag “Einführung in die Computer-Echtzeit-Grafik” von Benjamin Thaut. Ein schöner Vortrag darüber wie man in der 3D-Grafik die Dinge auf den Bildschirm bekommt, so dass sie schön aussehen und sich auch noch schnell genug bewegen können. Dieses Partikelsystem vergesse ich nie wieder…

Alles in allem bin ich momentan sehr froh, dass der GamesDay vorbei ist. Auch wenn es Spaß macht, ist es doch ein riesen Aufwand und als Organisator bekommt man beim GamesDay selbst leider immer nur die Sachen mit, die eben gerade nicht funktionieren.

ps.: Wer nicht beim GamesDay war kann sich übrigens die Aufzeichnungen anschauen.

Abgelegt in: Projekte | Kommentare ansehen und hinterlassen

First encounter with Python

Vom 21. April 2010

Today I gave a talk about Non-negative matrix factorization, an algorithm used e.g. in dataming to find similarities in a large number of documents. In this course (Dataming and pattern recognition) we use Python to implement some nice exercises (spam filters, document clustering, face recognition, etc.) and as a preparation for the talk I implemented some stuff in Python.

There were several aspects of Python I was looking forward to:

  • Program structure defined by indention
  • Operation or function syntax on variables
  • Speed (well, for an interpreted language…)

The first hours were quite funny (our professor gave a brief introduction). The documentation was a bit troublesome but I guess I just didn’t found the right one. The docs on the Python website are nice if you have enough time to actually read it but I really miss a reference like the Ruby core documentation. There you have everything in one place and can find almost anything with a simple browser search.

Program structure defined by indention

To use indentions to define the program structure also was nice at first. I really like the “executable pseudo code” thing because I usually use indentions in my notes to structure algorithms. However when writing larger functions or classes I had a hard time “scanning” the source code. The start of a specific code structure can be seen immediately but the end? Maybe I’m a bit to much used to languages like C, Java or Ruby which have very clear end markers, but I spend much more time in Python code actually searching the end of code block (function, method, …) than in other languages. It feels like my eyes are hanging somewhere in between the lines, not really sure where to go next. Again, it’s probably just a matter of getting used to. Maybe a light background color for whitespace in gedit will help.

Operation or function syntax on variables

When doing some “theoretical” stuff with algorithms we often defined abstract data types. These are basically a list of types involved, the operations that can be used on the data type and the behavior of the operations (usually expressed in form of axioms). The operations of an array data type might look like this:

insert(Array, Number, Value) → Array
get(Array, Number) → Value
slice(Array, Number, Number) → Array
delete(Array, Number) → Array
len(Array) → Number
join(Array, String) → String
…

In the pseudo code of algorithms I use this “operation” syntax because I usually think first about what to do and second about the data that gets manipulated.

a = ["hello", "world"]
len(a) → 2
slice(a, 0, 1) → ["hello"]
join(a, ", ") → "hello, world"

I was looking forward to Python supporting this style of programming. However it looks like this operation or function style of programming is currently replaced by object orientation. While this is not a bad idea the results look somewhat strange. For example joining an array of words:

a = ["hello", "world"]
", ".join(a)

Why is the string ", " responsible for joining the array a?!

The second point is that join is a method. Or to say exactly, that you first have to think about the data that gets manipulates (here the ", ", then a) and somewhere in between about what is actually done (join). To stay in a world of operations you could write

join(a, ", ")

where the interpreter could look if the first parameter a defines a join method and calls it. This way you could stay in the mental model of operations and it would also be consistent with the way you define methods in Python with the first parameter self.

On the downside you would lose the ability to do neat method chaining. However in many languages with the ability it isn’t used anyway (e.g. Java). The syntax for creating a new instance of a class would also look somewhat strange:

new(Post)

given that new is an operation of the Post class (like in Ruby).

Does Python really need another unremarkable form of object orientation (OO with a dot)? Why not spice up OO a bit to amplify some unique ideas and mental models behind Python?

Speed

In this case Python really showed of. To be more exact, numpy.matrix. I did some rather extensive matrix multiplications with relatively large matrices (e.g. 2000×500) and the performance was quite impressive. It calculated the results in seconds where the Ruby matrix class took minutes to do the work (and is not really made for this kind ob job).

Anyway, these are just my thoughts about Python after playing with it for some days. It just feels like there are two directions within the current Python language (operations and OO) and this looks a bit inconsistent from my point of view. But again, maybe I just don’t know the right Python features at the moment.

Abgelegt in: Programmieren | Kommentare ansehen und hinterlassen (5)

My new favorit virtual machine

Vom 1. April 2010

Yesterday I got access to a newly created virtual machine I can use for my streaming project. Initially I had doubts about the performance of the VM because ffmpeg2theora is encoding a DV stream there.

However after a look at htop these doubts vanished instantly:

This is simply the best VM I ever had. I have never seen a CPU load of “nan” before… :)

Abgelegt in: Projekte | Kommentare ansehen und hinterlassen (2)

Projekte

Simple Localization
Ein einfaches, aber macht- volles Übersetzungsplugin für Ruby on Rails.
Table Navigation
Ein jQuery Plugin um per Tastatur schnell durch Tabellen zu navigieren.

Über was ich schreibe…

Newsfeeds

Kommentare