it’s not the first time i’m annoyed by php, and surely not the last one. i’ve often called php an ad-hoc language, which is changed a lot and contains many inconsistencies. and often tends to break backwards compatibility. for example, i recently upgraded to php 5.3 (while upgrading the server; before, it was running 5.2 if i recall correctly). this instantly broke the openid server i’m using to login to mathoverflow. this was easy to fix, apparently some behaviour changed and i had to replace two or three lines of codes by almost identical ones to make it work again. now i stumbled about something else, while posting something new on blackness. namely, the member function setdate of the datetime object changed a little bit: on success, it no longer returns null, but the object itself. (in case of an error, it still returns false.) well, the blackness editor was expecting null to indicate success, and complained that the data was invalid. great.
i mean, its nicer to return the object (to allow cascadation, at least if one is sure no error occurs – otherwise one is screwed), but why just change this between two versions?! such changes make upgrading php a russian roulette: it might break your programs. and in many cases (like this), it might take you a long time to find out that your program is broken. and when you found out it’s broken, you have to search for the problem, identify it, only to find out that php just changed the rules a little bit. this is just bad. and yet another reason not to use php for anything serious.
(and a programming language not useable for anything serious is, well, to be bluntly: a big pile of crap.)
posts about computer. (page 3.)
today i had to shuffle the lines of a text file. the last time i tried to do this in the bash i only found the hint to use sort -R
. this actually produced the somehow strange order of the music video series. today i found out that there’s another way to do this, namely by using the command shuf
. it works the same way as sort
. i just wanted to write this down so i won’t forget :-)
i stumbled over a wordpress bug making my xhtml invalid. in fact, i noticed i stumbled about it the second time. i think the first time was when i installed wordpress 3.0, and the second time after upgrading to 3.0.1. the problem is, that shortcodes which appear in single lines should not be enclosed with <p>…</p> according to the manual. but my wordpress installation is doing exactly that what is claimed to be fixed for some time.
i started digging a bit, and quickly noticed that i already fixed it. since it seems to be a persistent problem i want to document it, just in case i have it again. internally, wordpress first runs the function wpautop
on the content, which adds <p>…</p>, and then runs shortcode_unautop
to remove <p>…</p> around shortcodes standing in a single line. (in previous wordpress versions, both was done in wpautop
if i recall correctly.) now the problem is, that my wordpress installation calls these two functions in the wrong order. so shortcode_unautop
is called first, finds nothing to remove, and then wpautop
is called, which adds the faulty <p>…</p> code.
an easy fix is to change wp-include/default-filters.php
by changing all lines add_filter(‘whatever‘, ‘shortcode_unautop’);
to add_filter(‘whatever‘, ‘shortcode_unautop’, 11);
. after that, everything is fine. i wonder whether this happens on every installation or just on some.
now that i fixed this a second time, i wanted to find out in more detail what’s going on. after some digging, i found out that the cause is a plugin i use: wp_unformatted. it removes wpautop
from the filter list and adds it again later, hence moving it after shortcode_unautop
if both have the same default priority. well, so the right thing is to fix that plugin.
in case you want to know how to fix that plugin, proceed as follows:
- change the line in
wp_sponge
fromreturn wpautop($pee);
toreturn shortcode_unautop(wpautop($pee));
; - add
remove_filter(‘the_content’, ‘shortcode_unautop’);
afterremove_filter(‘the_content’, ‘wpautop’);
.
when installing a new ubuntu, i had essentially two programs which were replaced by alternatives i had trouble with – amarok1 was replaced by amarok2, and gqview was replaced by geeqie. compared to amarok2 pretty much not working at all, geeqie is working, though partially not as expected. the worst part of it is getting confused with directories. assume you store your photos in a more complex directory structure, say
photos/
photos/canada/
photos/finland/
photos/germany/
photos/germany/2010-04-23
photos/germany/2010-05-01
photos/germany/2010-06-02
photos/switzerland/
now you go into the photos/germany/2010-05-01/
directory, look at some pictures, and decide to go one directory up. as expected, the current marked directory is 2010-05-01
. so, when you go another directory up, you’d except the current marked directory to be germany
. but well, as opposed to any sane program (such as gqview), geeqie selects the first in the list. this is really, really annoying, and i have no idea who implemented something like this…
anyway, i just found a forum post describing how to install gqview and make sure ubuntu won’t automatically update to geeqie for you… in case this annoys you as well, follow the instructions :)
i upgraded to a new ubuntu a week ago, after buying a new harddisk. this resulted in getting amarok2 instead of amarok1, which i was used to. and it was a complete failure. it ignored my music, didn’t show anything in the collection, and some tries to change this didn’t do anything. well. so i decided to try out exaile. this worked well, until i noticed that changing to the desktop exaile was running on took up to five seconds. i don’t know why. but this is clearly inacceptable, this should take way less than one second. so i started looking around. i tried rhythmbox, the standard gnome player, but it didn’t really managed to read my music collection. then, i tried xmms2 and various frontends. so far, i didn’t really found a frontend which convinced me. but at least the backend is working fine. maybe i should start hacking my own frontend together, to do exactly what i want it to do.
it is not exactly satisfactory, but for the moment, i think i’ll stay with xmms2. at least it works fine so far, accepts my music collection, and has no strange hickups.
as once announced, i worked on spielwiese‘s gallery system. it is now featured by a c++ backend which generates the galleries as well as the thumbnails (if they aren’t already there), both in grayscale and color! so far, the galleries are shown as before (with some exceptions, mostly in the beginning of the blog though), but on every page you can find a clickable text in the footer, on the very bottom of the page, called “change colors!”: this toggles the thumbnails between grayscale and colors! unfortunately, this currently does not remembers the value (by setting a cookie), so if you reload the page everything will be grayscale again. but the most important part, namely the backend, is there! and maybe it will remember the state before the end of this day :)
since i’m always forgetting what to do to encrypt a harddisk, and have to rely on other sites (which might go offline once), i decided to sum everything up in a post. parts can already be found here in this blog.
note that the disk device name can differ from computer to computer, so i used /dev/sdx
in this description which you have to change to the right name.
creation.
first, connect the disk and unmount it. then, delete all existing partitions and create a linux primary partition (or do whatever else you want):
$ sudo fdisk /dev/sdx
then it is recommended to clear the partition with random data:
$ sudo dd if=/dev/urandom of=/dev/sdx1
note that this step takes a lot of time.
then, make luks aware of the drive, open it with luks and format it:
$ sudo cryptsetup –verbose –cipher aes-xts-plain64 –key-size 512 –verify-passphrase luksFormat /dev/sdx1
$ sudo cryptsetup luksOpen /dev/sdx1 encrdisk
$ sudo mke2fs -v /dev/mapper/encrdisk
$ sudo cryptsetup luksClose encrdisk
this creates an ext2 file system. now you should be able to unplug the drive and reconnect it, and ubuntu should ask you for a passphrase to unlock the disk. feel free to add -L “label”
(at most 16 characters; see the man page for more details); ubuntu will try to mount the disk as /media/label then.
(edit: since there is now a successful attack on the aes-cbc-essiv
encryption mentioned here earlier, i changed it to aes-xts-plain64
, using a different approach.)
mounting and unmounting.
to mount:
$ sudo cryptsetup luksOpen /dev/sdx1 encrdisk
$ sudo mount /dev/mapper/encrdisk /mnt
to unmount:
$ sudo unmount /mnt
$ sudo cryptsetup luksClose encrdisk
note that for example newer ubuntu versions automatically ask for a passphrase and performs luksOpen / mount / unmount / luksClose for you.
checking.
basically, you just have to open the partition, run the usual file system check, and close it:
$ sudo cryptsetup luksOpen /dev/sdx1 encrdisk
$ sudo fsck -v -C -n /dev/mapper/encrdisk
$ sudo cryptsetup luksClose encrdisk
passphrase management.
note that luks has a storage of several passphrases, which can all be used to open the partition. one can add and remove phrases to/from this list.
to add a passphrase:
$ cryptsetup luksAddKey /dev/sdx1
to remove a passphrase (you have to enter the passphrase to be removed):
$ cryptsetup luksRemoveKey /dev/sdx1
to remove the passphrase from a slot (useful if you forgot one of the passphrases and want to remove it):
$ cryptsetup luksKillSlot /dev/sdx1 0
while talking with a friend about learning programming, i searched for course material for the best programming course i ever had so far, namely dibo‘s “programmierkurs java” (which i praised so often when it comes to this topic). while looking, i found a new website by dibo, called programmierkurs java, which features the lectures (both slides and video recordings!) and exercises. in case you want to learn programming and understand german well enough, take a look there!
ok, so much for advertising. when taking to the friend, another topic was “what is the right programming language to begin with?” in this case, the canidates java and c++ were named. i would definitely go for java, even though i prefer to use c++ myself for most things i program, as java is more allergic to programming errors: if you try to access an array out of the boundaries, it will throw an exception and will not result in unexpected behaviour. moreover, it is widely available (for free!) and easy to set up, there is a huge amount of (good and bad) literature about it, it is not too far off from the real world programming languages which one might use later (in case one wants to learn more than one language, it might also be a good idea to start with something more esoteric, like functional programming). moreover, it can be used both imperatively (which is in particular useful in the beginning) and object oriented (which one shouldn’t touch too early, in my opinion).
i got another external hard drive today. the main reason is that i want to encrypt my (current) backup harddisk, which requires reformatting the disk. but if i do so, i’m left with nothing but the original data on the laptop, and no backup. in case something goes terribly wrong, i’m screwed. i just created an encrypted partition on the disk; this is really pretty easy and not much command line typing is required, in particular if everything is set up: then linux will ask me for the password as soon as i plug the usb cable in, and automatically mount it using that password. that’s how it should be. and so far, it works perfect.
currently, rsync is mirroring my home directory onto the disk. as soon as it is done, i will copy some stuff from the other backup disk over (like my server’s backups) which i don’t have on the laptop’s harddisk (which is 180 gb smaller than each of the backup disks), and after that, my old backup disk will be reformatted as well and also filled.
after that, i will deposit one of the backup drives somewhere outside my apartment: in case something goes wrong (like house burns down, someone decides to break in, …), i still have a backup somewhere. and, as it is encrypted, nobody but me can read it. (even if someone breaks in here, and steals both laptop and backup, they can’t access the data without my password. and yes, i am aware of xkcd.)
as you may have noticed, i use wikipedia a lot – both for linking to descriptions of terms i use in this blog, and for looking up stuff myself which i encounter somewhere, may it be offline or online. usually, chances are good that wikipedia offers at least some kind of description which answers my questions, or at least helps me getting an idea. but from time to time, it happens that you try to look something up on wikipedia, only to find out that such an article existed but was deleted – for example, because it was “not relevant”. i can understand that people do not want to see wikipedia flooded by biographies of john doe and jane roe – only a handful people are interested in these, probably most notably john doe and jane roe themselves.
but there are cases where i simply can’t understand the decision. for example, there is the chilenian doom metal band mar de grises, which i discovered by chance in zurich’s now deceased knochenhaus. according to the wikipedia deletion log, it is “not noteable” and failes some guidelines. so, who decides what is noteable and what is not? and, after all, the simplified ruleset explicitly mentiones
ignore all rules – rules on wikipedia are not fixed in stone. the spirit of the rule trumps the letter of the rule. the common purpose of building an encyclopedia trumps both.
i can pretty well understand that not every small band hobby band project should be mentioned – in particular the ones which sound bad and dissolve quickly with none or almost no productions. but that’s not the case for mar de grises. besides that, the deletion log also mentiones other problems with the article (namely, being badly written and failling to provide references for some claims), but why not throw these parts out or reduce the article to a stub?
two other examples, this time from the german wikipedia, are sinnlos im weltraum and lord of the weed, two fandubs. according to the english wikipedia, sinnlos im weltraum (a redub of a star trek series), dating back to 1994, is one of the first such projects, essentially starting the whole genre of fandubs. i don’t know how many people know it, probably a huge number. lord of the weed (a redub of the beginning of 2001′s lord of the rings) is also rather well-known; i don’t remember how often i saw it – at least ten times. well, it is obviously true that these movies haven’t been shown in movie theaters or on television – as they contain copyrighted material (i.e. the original movie), used without permission. for the same reason, they haven’t been shown on film festivals, you can’t buy them on dvd. they are also not listed on the imdb. but – so what? does that make them not noteable? irrelevant?
on the other hand, a lot of totally trashy movies – which, compared to sinnlos im weltraum and lord of the weed, are really crappy and lame – are featured on media, two good examples are a music video by grup tekkan and the infamous star wars kid, making a fool out of himself. these are pushed by media as “youtube movies you have to see” or are even shown on tv. and they can be found on wikipedia. even though they are real crap. in the case of star wars kid, the really embarrassing movie was uploaded by “friends” of its actor and will probably haunt him for a very long time. to make this even better, a lot of online versions of famous newspapers or magazines feature this video as well, showing it to an even wider audience. and i thought the use of a pillories are outlawed in modern countries.
anyway. i’m still using wikipedia, even though of these reasons. and i even created an account at the english wikipedia and started writing an article about infrastructures (number theory). as so far, nobody else dared to write something on this subject, and a google search only gives documents featuring other kinds of infrastructures, or scientific articles about this subject, i thought it would be time to add something to the web. i’ve started a series of posts on my math blog on infrastructures, but as google usually ranks wikipedia articles higher, i decided to also add something to wikipedia. so far, it is more a stub and far from being a complete article, but at least provides some information and several references to literature.