Skip to main content

One social network to rule them all: identi.ca

Facebook, Twitter, LinkedIn, Netlog, Google Buzz,... er bestaan heel wat sociale netwerken op het internet, en meer dan waarschijnlijk heb je zelf wel een account bij een of meerdere van deze services.

En desondanks ga ik op deze pagina proberen om jou te overtuigen om je aan te sluiten bij nog een ander sociaal netwerk: identi.ca. Identi.ca is een platform voor microblogging. Zoals Twitter, maar dan beter. Lees dus vooral verder:

How to add flattr buttons to your Drupal site

Here is a quick and diry way for putting dynamic flattr buttons in articles on a Drupal site.

The difficult part is getting the javascript thing in the <head> section of your pages. I did it as follows:

I created a file 'flattr.js', with the following content:

(function() {
    var s = document.createElement('script'), t = document.getElementsByTagName('script')[0];
    s.type = 'text/javascript';
    s.async = true;
    s.src = 'http://api.flattr.com/js/0.6/load.js?mode=auto';
    t.parentNode.insertBefore(s, t);
})();

Then I added the following php code to a block that is visible on every page of the site:

<?php
drupal_add_js('sites/johanv.org/flattr.js');
?>

(You might use an existing block, or create a new block just for this purpose.) Make sure you choose 'php' as input format for the block.

Now you just have to paste the code for the button in the articles, on the place where it is needed. You need to specify full html as input format though.

I know there exists a Drupal module for Flattr, but I think it is not ready for easy usage yet.

Strange HTTP error 0 problem when updating Drupal 6

After moving my Drupal 6 websites to another hosting provider, I got an error message every time I have to update a module. It says:

An unrecoverable error has occurred. You can find the error message below. It is advised to copy it to the clipboard for reference.
Please continue to the error page
An HTTP error 0 occurred. http://johanv.org/update.php?id=18&op=do

The problem has probably to do with Drupal issue 1046682, but I don't understand how I can fix it.

But after a whole lot of Googling, I found a stupid workaround for this problem. You can run the update script using Internet Explorer. The problem only shows up with Firefox and Chromium. What a fail.

Fedora/NVidia font problem

A quick fedora/nvidia tip:

After installing the evil and freedom hating nvidia-drivers on my Fedora system, a lot of font sizes magically increased. It seems you can fix this (per user) by clicking ‘System’, ‘Preferences’, ‘Appearance’. Click the ‘fonts’ tab, then the ‘details’ button, and change the resolution back to 96 dpi.

You can probably change this in some configuration file as well. If you know how, please let me know.

Log on to Fedora 14 with your active directory credentials

You can use your active directory username and password to login to a PC running Fedora 14. This is how I did it:

Install pam_krb5 and samba-winbind:

yum install pam_krb5 samba-winbind

Click ‘System’, ‘Administration’, ‘Authentication’. Enter the root password.

Enter the following settings (adapt ‘MYDOMAIN’, ‘EXAMPLE.COM’, and ‘mydcn’ to your situation)

  • User Account Database: Winbind

  • Winbind Domain: MYDOMAIN

  • Security Model: ads

  • Winbind ADS Realm: EXAMPLE.COM

  • Winbind Domain Controllers: mydc1, mydc2

  • Template Shell: /bin/bash

  • Check ‘Allow offline login’

Click ‘Join Domain’, and enter username and password of a domain account.

Under ‘Advanced options’, Password Hashing Algorithm should be ‘MD5’, and ‘Create home directories on the first login’ should be checked.

Click Apply, and close the window.

Now you should be able to logon with username ‘MYDOMAIN\\myuser’, and your domain password. If you don't want the prefix ‘MYDOMAIN\\’, edit /etc/samba/smb.conf. In the section [global] change

winbind use default domain = false

to

winbind use default domain = true

and reboot (or restart winbind and/or samba).

References:

Booting an existing Windows 7 installation from Fedora using Virtualbox.

UPDATE 2014-11-14: Don't follow this howto. The tutorial of FTS-team describes a much better way to do this.

WARNING: After a month, I ran into problems with the windows activation. I couldn't activate the virtual and the physical windows at the same time. I tried what's on http://forums.virtualbox.org/viewtopic.php?t=9697 under 2. Bios Settings, but it didn't work.

My laptop is a dual boot system with Windows 7 and Fedora. Now I want to create a virtual machine in Fedora, which boots the existing Windows 7 installation. It worked for me (TM) on a Dell Precision M4500, with the native Windows. This is how I did it, starting from a completely updated Fedora 14.

  • Surf to http://www.virtualbox.org/wiki/Linux_Downloads, and download the .repo file at the bottom of the page.

  • Put the .repo file in /etc/yum.repos.d and install VirtualBox-4.0.

  • Install the kernel source: yum install kernel-devel gcc

  • Install the vboxdrv kernel module issuing /etc/init.d/vboxdrv setup.This didn't seem to work the first time, so i issued the command again until I got Starting VirtualBox kernel modules [ OK ].

  • Create a directory to store the virtual disk file: mkdir ~/vm

  • A typical Windows Vista installation exists of 2 partitions: a small boot partition, and a big one for the rest. You need to identify them. In my case, the partitions are /dev/sda2 and /dev/sda3 respectively.

  • I want to run virtualbox under my normal user account. So I had to add myself to the group vboxusers: usermod -a -G vboxusers johanv. I will also need read/write access to /dev/sda2 and /dev/sda3. But every time I change something to the security settings of these block devices, some time later Fedora changes it back for me. I'm not sure how to handle this, so for the moment, I did usermod -a -G disk johanv to grant me r/w access to all raw disks and partitions. Which is very unsafe! Any suggestion of a better way to arrange this, is more than welcome.

  • We need to generate an mbr which our virtual machine will use.

    • Debian based distributions contain a package ‘mbr’, which can be used to create such a mbr. But it isn't availiable for Fedora. So let's build it from source.

    • We need to install dev86: yum install dev86.

    • The source for mbr is available at http://www.chiark.greenend.org.uk/~neilt/mbr/mbr.tar.gz. Unpack the archive, and compile and install mbr issuing these commands:

      ./configure
      make
      su -c "make install"
    • Create a mbr as follows: (change the 23 to the numbers of your Windows partitions. 23 is for /dev/sda2 and /dev/sda3.)

      /usr/local/sbin/install-mbr -e23 --force ~/vm/vm.mbr
    • This creates a file ~/vm/vm.mbr of 512 bytes, containing our mbr.

  • Now create the virtual disk for your virtual machine. I did this as root. Remember to adapt the partition numbers to your needs:

VBoxManage internalcommands createrawvmdk -filename /home/johanv/vm/win7.vmdk -rawdisk /dev/sda -partitions 3,2 -mbr /home/johanv/vm/vm.mbr -relative
  • I typed ‘-partitions 3,2’ instead of ‘-partitions 2,3’, because I think that otherwise the OS-partition will get the drive letter D instead of C. I'm not sure of this.

  • At last: create the virtual machine using VirtualBox Manager:

    • Click ‘New’.

    • Name your machine, and choose an OS (in my case Windows 7 64 bit)

    • Assign memory

    • Choose ‘Use existing hard disk’ and browse to the vmdk.

    • When the virtual machine is created, click ‘System’, ‘Motherbord’, and disable IO APIC

    • Read what's under ‘DMI BIOS settings’ on http://forums.virtualbox.org/viewtopic.php?f=28&p=149094. It seems that for OEM versions, you need to copy some of your real bios information to your virtual machine. I just did it as told on the page, although I'm not sure it is necessary for Windows 7.

  • The virtual machine doesn't boot right now. You need to insert a Windows 7 installation CD, choose 'Repair computer', and let it fix the Windows boot loader.

  • After this, my system booted, I got the Windows 7 splash screen, and then the computer crashed with the following BSOD:

A problem has been detected and windows has been shut down to prevent damage
to your computer.

If this is the first time you've seen this stop error screen,
restart your comptuer. If this screen appears again, follow
these steps:

Check for viruses on your computer. Remove any newly installed
hard drives or hard drive controllers. Check your hard drive
to make sure it is properly configured and terminated.
Run CHKDSK /F to check for hard drive corruption, and then
restart your computer.

Technical information:

*** STOP: 0x0000007B (0xFFFFF880009A9928, 0xFFFFFFFFC0000034, 0x0000000000000000, 0
x0000000000000000)
  • It seems Windows doesn't like it when the type of your hard drives changes. I managed to fix this problem as follows:

    • Boot in your original Windows 7

    • (Backup your registry)

    • Download MergeIDE.zip, unpack it, and import the .reg file

    • Reboot to Fedora

    • Open VirtualBox manager, Select your virtual machine, Click 'Settings'

    • Click 'Storage', remove your hard disk from the SATA controller, and add it to the IDE controller

    • (Not sure this is needed:) For the IDE controller, choose 'PIIX3' as type, and disable host I/O cache.

  • If you boot up your virtual machine now, it should just work (TM).

references:

UPDATE: Fixing the security

As mentioned, the security of the above implementation is very bad. I improved it a little, creating a dedicated user to run virtualbox. (uid 899 is arbitrary, but less than 1000, to prevent the user from showing up in gdm)

useradd -u 899 -m -g vboxusers -G disk vboxuser
passwd vboxuser
cd /home
#replace 'johanv' by your own login below
cp -rp johanv/VirtualBox\\ VMs/ vboxuser/
cp -rp johanv/.VirtualBox/ vboxuser/
cp -rp johanv/vm vboxuser/
chown -R vboxuser vboxuser
sed -i 's/johanv/vboxuser/' vboxuser/.VirtualBox/VirtualBox.xml
sed -i 's/johanv/vboxuser/' vboxuser/VirtualBox\\ VMs/win7/win7.vbox
# replace 'win7' by the name of your virtual machine above.

Enter visudo, and add the following line:

johanv ALL=(vboxuser) NOPASSWD: /usr/bin/virtualbox

(Change the account name as appropriate.)

If you want to enable sound for your virtual computer, download and install paprefs:

yum install paprefs

Run paprefs, click on the ‘Network Server’ tab and enable network access to local sound devices. (Again, probably not the most safe way to do this, but it works.)

Now you can run virtualbox as follows:

xhost +si:localuser:vboxuser
sudo -H -u vboxuser virtualbox

! Don't forget to remove your ‘normal user account’ from the ‘disk’ group !

Wild idee: bierherkenningssoftware

(Click here for info in English.)

Onlangs zat ik met een aantal collega’s op café (in de Kulminator nog wel), en daar kwam remembeer ter sprake. Remembeer is een toepassing op mijn telefoon, die ik kan gebruiken om de bieren te loggen die ik drink, en om ze een score te geven.

Maar remembeer heeft zijn beperkingen. De database is niet genormaliseerd, ik mis integratie met identi.ca, en vooral: het is een beetje een gedoe om alle gegevens van een bier in te geven.

En toen kwam iemand met dit idee op de proppen: Je zou een foto moeten kunnen nemen van het etiket, en dan zou het programma automatisch moeten kunnen bepalen over welk bier het gaat.

Wel, ik heb daar een nachtje over geslapen, en dat lijkt me een geweldig idee. Ik wil zoiets implementeren. Ik wil een soort van webservice maken die op basis van een foto van een etiket (of stopje bij gebrek aan etiket) de informatie over het bier en bijhorende brouwerij oplevert.

Dat gaat natuurlijk niet gemakkelijk zijn. Bovendien zal het in mijn vrije tijd moeten gebeuren. Dus een bruikbaar afgewerkt resultaat zal nog niet voor de eerste jaren zijn. Maar het lijkt me een geweldig ‘pet project’. Dus ik maak er meteen werk van.

En nu het goede nieuws: als je geïnteresseerd bent, mag je mij helpen met dit project :-)

Er is nog weinig van concrete planning. Maar het zal alleszins open source zijn. Dat houdt het leuk.

Waarschijnlijk zullen afbeeldingen getest moeten worden op kenmerken, en zal het programma getraind moeten worden. Dus een eerste iets dat ik nodig heb, zijn afbeeldingen van etiketten. Dat is al een zaak waarbij je kunt helpen. Bij deze een oproep: als je nog eens een bier drinkt, neem een foto van het etiket. (Of van het stopke bij gebrek aan etiket.) Bij voorkeur upload je die foto's naar identi.ca met hashtag #beerlabel. Vermeld de naam van het bier, en de brouwerij. Heb je geen identi.ca-account, en wil je er geen aanmaken, mail ze me dan. (Mijn e-mailadres vind je elders op deze site.)

Wat moet er verder nog gebeuren:

Er moet een database opgesteld worden die bieren (met info over alcoholpercentage, soort bier, enz.) verbindt met brouwerijen en foto's. Ik speel met het idee om dat met Drupal te doen; uiteindelijk heb ik daar wat ervaring mee. Ik vermoed dat we wel node types ‘beer’ en ‘brewery’ of zoiets kunnen definiëren.

Dan moet er onderzocht worden welke tools er beschikbaar zijn om afbeeldingen te ‘bekijken’ en met elkaar te vergelijken. Een uitdaging, zeg maar. Ik heb al wat rondgekeken, en er zijn een aantal zaken die uitgeprobeerd kunnen worden. Misschien zitten er wel bruikbare algoritmes in OpenCV? (uiteraard heb ik dit nog niet bekeken :)). Misschien zijn er webservices in de stijl van TinEye die gebruikt kunnen worden? Ik weet het nog niet. Weet jij het wel? Of heb je suggesties? Laat het weten.

Verder is er nog een website nodig, om alle info over het project te verzamelen. Dat zal het minste werk zijn; hier mag je binnenkort een update over verwachten.

Nu er nog geen website is, is er al wel een ander communicatiekanaal: de identi.ca group !beerscan. Momenteel ben ik de enige niet-bot in die groep, dus als je geïnteresseerd bent, sluit je gerust aan. Zit je niet op identi.ca, kun je altijd de rss-feed van !beerscan volgen.

Automatic beer label recognition

Yesterday, the Antwerp pub ‘Kulminator’ was nominated by ratebeer.com as Best Beer Pub. I work in Antwerp, and yesterday after work, I went over there with a couple of collegues, to enjoy some beer.

We talked about beers, and I showed my collegues the remembeer app on my Android phone. This app allows you to log the beers you drink, and to rate them. But as it turns out, I don't log the beers I drink that often. When there is a beer in front of me, most of the time I don't have time to log it using the tiny buttons of the Android software keyboard. :)

So one of my collegues said: you should be able to take a picture of the label or cap of the bottle. The app should recognize this picture, and automatically fill out the information about the beer.

Now this sounded like an interesting project. I want to program such a thing. But I'm not sure how to start.

I guess I need to develop some kind of backend, to which you can upload pictures. Or maybe I can upload the picture to some existing image recognition backend, and then do something with the result.

I did a little Googling, and I found out about TinEye, an online reverse picture search. Maybe I can upload the pictures to TinEye (or something similar), and use the result for searching the beer info in a backend database.

If I ever succeed in programming such a service, I would be happy to implement this into remembeer (if the source code will be available again some time). I will any way contact the remembeer devs.

Now, what I want to know from you, dear reader :-)

  • Do you know any existing open source app that does something similar to beer label recognition? I think there are apps for wine, but I doubt they are open source.

  • How would you interpret images of beer labels? Do you know any existing open source projects for image matching?

  • Are you a beer lover, and do you want to help me generating a database with pictures of labels/caps and info about beers?

  • Are you a programmer, and do you want to help me with the implementation of this project?

If you answer ‘yes’ to one of the above questions, and you want to help me out, please contact me.

updated: Contact info

  • !beerscan identi.ca group

  • Please upload pictures of beer labels/caps, and tag them with #beerlabel.

  • I am still working on a web site for the project.

  • I am @johanv on identi.ca

  • You can e-mail me: my address is my first name, followed by @losderover.be

initrd.img opnieuw genereren (Debian)

Debian tip van de dag:

Als je je bootpartitie read-only maakt, en je vergeet ze writable te remounten voor een ‘apt-get upgrade’, dan wordt het ‘initramfs’ niet opnieuw gegenereerd. Soms wordt de upgrade hierdoor niet afgebroken, en dan zit je daar met een systeem met een ‘verkeerd’ initramfs.

Een manier om initramfs opnieuw te laten genereren, is de volgende:

mount -o rw,remount /boot       #niet vergeten deze keer
dpkg-reconfigure linux-image-`uname -r`

Linux print- en scanserver

Een vijftal jaar geleden kochten we een nieuwe printer/scanner: een Brother DCP-115c.

Eerst en vooral: ik zou het niet opnieuw doen. Een nieuwe inktcassette kost bijna even veel als de printer zelf, en bovendien heeft het meer dan 3 jaar geduurd vooraleer de printer min of meer ‘out of the box’ werkte met een recente Linuxdistributie; de eerste waarmee het lukte was Ubuntu 10.04. (Is het nu echt zó moeilijk om postscript-ondersteuning in een printer in te bouwen? Maar dit ter zijde.)

Tegenwoordig staat onze printer op zolder, want als we thuis een computer gebruiken, dan is het een laptop. Die printer hangt aan een Linuxserver, en je kunt dus via het draadloze netwerk je printeropdrachten naar boven sturen. Je moet dan wel trappen doen om de prints te gaan halen, maar dat beperkt het aantal printopdrachten, en is goed voor de conditie ;-)

De printserversoftware is gewoon CUPS, en die draait op mijn ‘thuisserver’, een oude PC waar ik in het voorjaar van 2008 Ubuntu server edition op installeerde. Ik zou nu misschien niet meer voor Ubuntu kiezen, maar mijn server van toen draait nu nog steeds met weinig problemen, dus waarom zou ik hem vervangen?

De installatie van CUPS was niet moeilijk:

sudo apt-get install brother-cups-wrapper-common brother-cups-wrapper-extra cups

Als jouw printer standaardvriendelijker is dan de mijne, dan zijn die Brotherpakketten uiteraard niet nodig.

De configuratie was al iets moeilijker. Op mijn Ubuntu server staat geen grafische schil, en de webinterface voor de cups-configuratie werkt standaard enkel vanaf localhost. Ik had cups toch graag geconfigureerd vanop een andere PC, maar ik vond niet direct hoe ik dat moest ‘enablen’, dus loste ik het op via een ssh-tunnel. (Vermoedelijk gaat dat allemaal veel gemakkelijker door rechtstreeks de configuratiefiles aan te passen, maar ik had geen zin om dat uit te zoeken.) Ssh-tunnel dus. Voor linux/cygwin:

ssh -L 8080:127.0.0.1:631 username@servername

waarbij je het stuk ‘username@servername’ aanpast alnaargelang de naam van je ‘server’ en een user die kan ssh'en.

Als je nu surft naar http://localhost:8080 surft, kom je terecht op de administratie-interface van cups op je printserver. Eventueel kun je daar onder het flapje ‘Administration’ ‘Allow remote administration’ aanvinken, zodat je in de toekomst de omweg via de ssh-tunnel niet meer nodig hebt. Je kan je printserver dan beheren via http://servername:631.

Ook onder het flapje ‘Administration’ klik je op ‘Add printer’ om je printer te configureren. Dit komt neer op het doorlopen van een aantal eenvoudige stappen. (Ik koos de driver voor Brother DCP-110c, en die werkte.)

Je geconfigureerde printer aanspreken vanop een andere Linuxcomputer is vrij gemakkelijk. De meeste distributies voorzien wel een tooltje waarmee je een printer kan ‘toevoegen’. Deze tooltjes zijn in het algemeen ook in staat om een cups-printerserver te herkennen. Moest dat toch niet het geval zijn, dan kan je allicht ergens de URI van je printer opgeven, en die is ‘ipp://servername/printers/printername’ waar ‘printername’ de naam is die je je printer gegeven hebt op de server. (Let op: ik moest op de client, in dit geval Linux Mint, ook wel de Brotherdingen installeren: brother-cups-wrapper-common en brother-cups-wrapper-extra).

Je kan je cups-printserver overigens ook gebruiken onder Windows, op voorwaarde dat de juiste printerdriver op je Windowsclient geïnstalleerd is. Je voegt daarvoor een netwerkprinter toe, en als URL gebruik je gewoon de URI van je printer, maar je tikt ‘http:’ in plaats van ‘ipp:’, dus: ‘http://servername/printers/printername’. Geen gedoe meer dus met installatie van samba; had ik dat maar eerder geweten ;-)

Maar nu probleem 2: de scanner. Er bestaan command-line tools om de scanner aan te sturen:

apt-get install sane-utils

Je hebt ook nog software van Brother zelf nodig; download en installeer het pakket brscan2 van de website van Brother.

Update: If you have a 64-bit system, the driver provided by Brother won't work on a recent Ubuntu distribution. Shame on you, Brother. A solution can be found (as always :)) in the forums: http://ubuntuforums.org/showpost.php?p=11578647&postcount=8

Scannen kan nu als volgt:

sudo scanimage --format=tiff > outputfile.tiff

Nu graag nog wat gebruikersgemak. Je zou een webapplicatietje op de server kunnen maken, dat scant en het gescande document aanbiedt als download. Maar in mijn situatie is dat niet ideaal. Er staat geen grafische omgeving op mijn server, en bovendien hangt er ook geen scherm aan. En telkens een laptop mee naar boven nemen om de scan te kunnen starten, is een beetje vervelend. (En naar beneden lopen nadat het document op de scanner ligt, om het na de scan terug te gaan halen, is nog vervelender.)

Ik pakte het anders aan. Er hangt nu een toetsenbord aan mijn server, en telkens je op ENTER duwt, wordt een scan gemaakt, die wordt dan weggeschreven, en kan dan opgepikt worden via ftp of (toch) samba.

Om dit te bewerkstelligen maakte ik een nieuwe user aan:

sudo useradd -g scanner scanner

Deze user moet kunnen scannen met sudo, zonder dat daarvoor een wachtwoord ingegeven moet worden. Bewerk de configuratie van sudo met visudo, en voeg deze lijn toe:

scanner ALL = NOPASSWD : /usr/bin/scanimage

Maak een bestand ‘/usr/local/bin/scanloop.sh’ aan, met deze inhoud:

#!/bin/bash

outputdir=/mnt/bigdata/documenten/scans

while true; do
      echo Druk ENTER om te scannen.
      read a
      outputfile=`tempfile --suffix=.tiff -d $outputdir`
      chmod 666 $outputfile
      sudo scanimage --format=tiff > "$outputfile"
      echo Scan bewaard als "$outputfile"
done

En maak het executable:

sudo chmod +x /usr/local/bin/scanloop.sh

Als we het nu voor elkaar krijgen dat na het booten van de server de user scanner automatisch aanlogt, en bovenstaand script uitvoert, dan zijn we gesteld. En dat kan met ‘mingetty’.

sudo apt-get install mingetty

In het bestand ‘/etc/init/tty1.conf’ vervang je de lijn

exec /sbin/getty -8 38400 tty1

door

exec /sbin/mingetty --autologin scanner tty1

Op die manier wordt na het opstarten van de server, de user ‘scanner’ automatisch aangemeld op tty1. Als je dan nog het volgende commando ingeeft:

usermod -s /usr/local/bin/scanloop.sh scanner

dan maak je het nifty scanscriptje de shell voor diezelfde gebruiker.

Als je nu je server herstart, dan zal op tty1 automatisch het scanscriptje gestart worden. Iedere keer je op ENTER drukt, wordt een scan gemaakt, en weggeschreven in de directory bepaald in ‘scanloop.sh’. Die directory maak je dan beschikbaar via ftp, samba, webinterface, of nog een andere creatieve oplossing, zodat je vanop elke client in huis de documenten gemakkelijk kan downloaden.