fake's blog

everything fake

PS3Eye GUID support for sysfs/udev

You've got a twin- or quad-PS3 Eye setup for a multitouch solution? On linux? Then you probably noticed there is no way to uniquely identify the cameras for persistant device names, if you change usb ports you're out of luck.

On windows, the CL-Eye SDK from codelaboratories has GUID support, which makes assigning the cameras in your code very reliable. On linux, the way to implement this would be udev rules.

I wrote a patch to expose the GUID and hardware version attributes of the cameras in sysfs. This required adding 2 hooks to the gspca framework, and implementing them in the ov534 driver file - i have no idea about the side effects this causes for the other gspca drivers, i don't have any other device to test this with. Also, i have never used sysfs before, and i didn't really test the usb sound stuff after my modifications, but for my use case it works perfectly. Be warned: use at your own risk.

Get the patch for kernel 2.6.35 - i use Ubuntu 10.10. Rough usage instructions, assuming you have your kernel source ready in /usr/src/linux

# patch -p1 < ~/ps3eye-guid-support_linux-2.6.35.patch
# make M=drivers/media/video/gspca
# cp drivers/media/video/gspca/*.ko /lib/modules/`uname -r`/kernel/drivers/media/video/gspca
# depmod -a

Then plug in the cam. The hardware version should be printed in the dmesg output, and /sys/classes/video4linux/video0/guid should show you the GUID of the cam. This can be used in ATTR{guid} - udev rules like this:

SUBSYSTEM=="video4linux", ACTION=="add", DRIVERS=="?*", ATTR{guid}=="123456-ABCD-DCBA-AAAA-BBCCDDEEFFAA", NAME="cam1"

This should create a device called cam1 for this (and only this!) camera.

Have fun!

OS X Snow Leopard, Bootcamp 3.0 and mounted Mac partitions

In case you - like me - are unhappy about bootcamp 3.0, shipped with mac os x 10.6 "snow leopard", mounting your mac partitions read only in windows and assignig them drive letters, here's a heads up:

DO NOT TRY TO REMOVE THESE DRIVE LETTERS using the "Computer Management -> Disk Management -> Remove drive letter" way.

Windows re-sets the partition's type if you choose this option, and the EFI Bios of your mac will no longer regard the partitions as bootable. Even if you re-add drive letters, the partition type will still be MSDATA. Yes, windows really sucks big time.

having tried quite a few tricks, i have to say: it's not easy to get out of this trap. Simply changing back the partition type is not the way to go, as the GUID partition table is way more complex than i thought.

You will have to dump the partition contents using dd into partitions with a correct GPT, while being extremely careful about the /dev/disk assignments - these change from boot to boot! Another tip: The "dd" shipped on the OS X boot cd is horribly slow (and the dvd drive keeps spinning all the time), it ran at about 17MB/s for me. Take the time to install rEFIt using the rescue system, and boot an ubuntu livecd. The dd in ubuntu ran at 95MB/s. Saves you a few hours.

If you need assistance, please comment on this entry, i will try to help you - but be warned: this procedure requires console-fu.

openfire 3.6 and lotus domino/notes ldap

i just found the time to finally get the 3.6.4 openfire working with my company's notes ldap server again. here is the new patch to the sources, it's a -p1 (when in the untared openfire_src dir) unified diff.

one hunk of my old patch was merged it seems (though no one even commented on that post, hence the blog post this time), but additional fixing was necessary so the setup tool does disable DN enclosing by default, which breaks authentication in the case of lotus notes. the no-base-dn fix (which is in fact a workaround for the broken notes ldap, but i stopped argueing a while ago) is also updated.

after installation and setup, if your admin users were found and added but you're still unable to log in, you will need to set the following properties, either in your sql database or in the embedded database script file while openfire is stopped:

ldap.encloseDNs = false
ldap.encloseGroupDN = false
ldap.encloseUserDN = false

That way, the DN enclosing will also be switched off after installation. Start up openfire and you're good to go.

Another property of interest for lotus domino ldap users is "ldap.override.avatar", it will enable the display and transmission of user icons. yay... technology just can't be stopped ;-)

multitouch table first test run

yesterday we did a first test run of the bytewerk.org ftir multitouch table, see for yourself:

Server-side caching php twitter widget

i was looking for a server-side twitter widget displaying a few tweets for the nachtwerk-online.de page, and i did not find an out-of-the-box solution. the twitter widget on my blog is a javascript client-side thingy. having some php experience i hacked this up (note you need the code below too, for the "niceTimeDiff"-method):

// load the tweets
// uses a cache to easen on the twitter server.
$mtime= null;
if($mtime== null ||(time()-$mtime)>(9*60)){// 9 minutes or older?
    $url=sprintf("http://twitter.com/statuses/user_timeline/%s.xml?count=%d","Nachtwerk_IN",5);// load 5 tweets
    $parsed=new SimpleXMLElement($tcontent);
        $message=ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]","<a href=\"\\0\" rel=\"nofollow\">\\0</a>",$message);
        $tweet['timeDiff']= niceTimeDiff($status->created_at);

Of course you will want to replace "Nachtwerk_IN" by your twitter id, and the 5 after it by the nr. of tweets you want to load. The file pointed to by $twitter_cache_file needs to be writable.

urls will be links. the method "niceTimeDiff" is written like this:

function niceTimeDiff($ref_date){
    if($days>1)$ret.=round($days)." days";
    elseif($hours>1)$ret.=round($hours)." hours";
    elseif($minutes>1)$ret.=round($minutes)." minutes";
    elseif($secs>1)$ret.=round($secs)." seconds";
    return$ret." ago";

Using this code, you will end up with an array called $all_tweets, containing assoziative arrays with 'message' and 'timeDiff' keys. Twitter will be checked every 9 minutes tops.

- page 1 of 9