Archive for the ‘Linux’ Category

July 30th, 2010 @ 05:51

While sorting my pictures this evening, I was wondering how much pictures I captured with my EOS 450D camera since I got it. I knew (thanks to a doc about flashes I read a few days ago) that was I was looking for was the shutter actuation count of the camera.
Googling pointed me to a bunch of Windows or OSX related links, such as the nontheless nice 40D Shutter Count software, or pointers to exiftool, which did not work with the pictures taken on my 450D.
I then remembered the greatness of gphoto2 and gave it a shot.

  • Plugged the camera through USB, restarted it
  • Checked that it was detected with gphoto2 --auto-detect
  • Checked the capabilities with gphoto2 -a
  • Looked at the config options with gphoto2 --list-options
  • Found the /main/status/shuttercounter option
  • Ran gphoto2 --get-config=/main/status/shuttercounter
  • And here it is : 27781 shutter actuations

That number seems quite reliable, since I can have about 15000 of those pictures on my hard drive disks and I used to drop about 2 pics on 3 in my early days (I’m a lot softer on the shutter now, after experiencing the joys of picture sorting :p).

Good to know I’m still far from the 100.000 actuations expected shutter life for 450D’s.

Well, thanks gphoto2 for your simplicity !

July 22nd, 2010 @ 01:18

A school friend, namely p4bl0, mentioned the idea of maintaining blog posts with git and a set of hooks which would produce the blog html from the contents of the repo. I loved the idea, but thought I could push it a little further : a blog engine which would use no other storage than git, with the post subject and contents being the commit message subject and contents. A post-commit or post-receive hook then produces the html. As simple as that !

You can find the source in BloGit git repo, and see an example at BloGit example. To use the source, you first have to pack it (using the pack script), which will merge the raw_post and raw_produce, producing a single post script (which I also included at the end of this post), which you can simply put in an empty directory and run it. It will unpack the other script (produce), initialize the git repo, and set the hooks. It’ll then prompt you for your post title and then open an editor for you to set your post contents. Save the file, and you’re done with your first post : check the index.html file which has been produced in the same directory. You can write your own stylesheet in the blogit-style.css file. Further posts can be done with the same post script.

Yet, the best way is probably just to use the usual git workflow. To initialize the repo and all, run post --unpack, and to post post --raw or git commit --allow-empty (when using git commit, leave a blank line between the subject line and the rest of the post). You can also amend existing commits (using git commit --amend), use the GIT_AUTHOR_* environment variables to change the author, and so on. Since merge commits are skipped by the html generator, it should work just great for multi author blogging !

PS : I know this is JUST a git log pretty printer, and that the whole thing is pretty much trivial. I also know that using versionned files to store the posts would allow a lot of extra bonuses (such as automatically adding “Updated on …” mentions based on the commit log of each single file). I just thought the idea was fun :p There are probably a lot of things to improve, or a lot of smart git features to use there that I overlooked. Feel free to leave a line :)


July 16th, 2010 @ 05:46

Since Thunderbird 3 (or maybe before that), when you encounter an invalid SSL certificate, the GUI doesn’t even offer you to add an exception as in Firefox. Counter-intuitively, the same GUI than in Firefox is actually, available you just have to dig it through the menus. Here is a step-by-step tutorial with screenshots (had to do them for a doc, thought I’d share).

Go to Account Settings

In Security menu select View Certificates (alternatively, you can get there through Edit, Preferences, Advanced, Certificates, View Certificates if you have no Security menu here)

In Servers tab, hit Add Exception

Enter the address:port of the service you are using (without any protocol://) and hit Get Certificate

Hit Confirm Security Exception, and you're done !

July 9th, 2010 @ 20:14

For months I have been having (temporary) freezes upon X/gdm login, sometimes even before that, lasting anywhere between 1 and 5 minutes (that’s on my Dell Latitude E4200). Actually, I could still move the cursor, and at times a panel widget would refresh, but nothing else. Logging on a tty and running top would show eating 100% CPU (pretty much expected actually). Investigations of /var/log/Xorg.0.log revealed that X was continuously doing EDID probing because of an unknown TV1 monitor, while dmesg confirmed that something was going on with that mysterious TV1 output :
[ 12.924] (II) intel(0): Printing probed modes for output TV1
[ 15.065] (II) intel(0): Printing probed modes for output TV1
[ 15.477] (II) intel(0): Printing probed modes for output TV1
[ 15.892] (II) intel(0): Printing probed modes for output TV1

[drm] TV-1: set mode NTSC 480i 0
[drm] TV-1: set mode NTSC 480i 0
[drm] TV-1: set mode NTSC 480i 0

After spending quite a bunch of time trying to tell X to just ignore, I took the easy way and… switched to Ubuntu. But yesterday, I asked drago01 (maintainer of Compiz packages in Fedora) about the issue, and he immediately recognised the problem, calling it the “Ghost TV problem”. According to him and Adam Jackson (ajax), this is a screw up from hardware vendors. The graphics chipset thinks there is that TV plugged while there is definitely none.

Anyway, he also pointed me to the fix. 4 lines in xorg.conf and you’re done (this is actually my whole xorg.conf :p)

Section "Monitor"
Identifier "TV1"
Option "Ignore" "1"

March 31st, 2010 @ 20:01

Keyboard shortcuts are always a great matter of debate, and the whole problem is that most often they are chosen based on assumptions of the end user layout.

For instance, take this metacity commit : Change default cycle_group keybinding to Alt-grave. This change looks perfectly harmless, right ? Well not quite. It’s most likely based on the assumption that the end users has a qwerty keyboard layout (and it makes perfectly sense there). But let’s take an azerty layout. Grave is on the é/7 key, which is even farther from alt or tab than F6 is (well, not much I agree, but it might be even worse on other layouts). Is it really worth doing such a change then ?

Let’s also note that this also triggers a bad bug which gets alt+7 and alt+shift+7 to trigger the binding as well, while alt+grave is actually alt+altgr+7. This has been keeping me from nicely switching to my window n°7 in irssi for months (great thing that this window holds a really low traffic channel…).

All in all, I guess that the real problem is not that this change was made, but rather than we might need a system to have layout-dependant keybindings, or maybe hardware-location-based keybindings (i.e. that the key above the Tab key would trigger this keybinding independently of the layout).

Initially published on Mar 24, 2010 @ 8:22

Update : this change has been reverted for the GNOME 2.30 release. Even though I’m happy that the problem is “fixed”, it’s sad that the underlying problem (Alt+Shift+7 triggering Alt+`) is still there.

March 22nd, 2010 @ 01:56

For a project midterm presentation, we were asked to produce a bunch of slides explaining our project architecture and implementation choices. Apart of the obvious things (libraries in use, network protocol…), I had no real clue on what I could put in, so I thought I’d just throw some UML-like diagrams and that it would be fine. The only detail was : how to produce these diagrams ?

Since the project code was written in Python, all the inheritance relations were already held by the code and could be introspected, so that it was theoretically possible to automatically produce the inheritance diagram. And it actually is, and is implemented by things like the Epydoc (a documentation generator for Python code) parser, as well as the diagram generation, which Epydoc also implements. The only thing is that I wasn’t satisfied by the Epydoc diagrams since they were limited to the inheritance relationships, while I was also willing to include usage relationships and display only the main methods and variables of my objects.

I thus wrote Umlpy, a UML-like class diagram generator for Python code, which depends on Epydoc (for the parser) and python-graphviz (for the graph generation, it produces nicely spaced graphs and can output jpg, png or pdf files, and probably more). It handles the aforementioned requirements through docstrings parsing and introspection. Check the Umlpy README file for more documentation on how to use it. It took me about 10 minutes to get to the result I was expecting (it’s basically about adding a little docstring for usage relationship, and copy-pasting a docstring on methods or variables you want to see on the diagram.

This wouldn’t be complete without the mandatory screenshot, and this example code results into this diagram :
Umlpy result example

March 22nd, 2010 @ 00:13

A few days ago, I discovered I had a miniUSB-A (or something along the line) plug on my beloved EOS 450D camera. Fun stuff, I could read pictures directly from the camera without having to swapping my SDHC card back and forth, at a pretty decent transfer rate (yet quite slower than through the cardreaded of my laptop).

I then discovered libghoto2, which is the library behind the Linux support of this feature. After a little bit of googling, I stumbled upon the gphoto2 website, where they mentionned that it was possible to command shooting from the computer and directly get the resulting image on the computer. Immediately tried and… it works great ! (though I haven’t figured yet how to get the picture on the sdcard instead of directly on the computer).

Not sure what I’m going to do with this, but I’m confident there is a bunch of hacking possibilities here. Maybe should I write a simple GUI on top of it someday to begin with. Or I could try building a motorized base and remote control the whole thing from my n900 (and attempt to do things like Paris 26 Gigapixels). Hmmmmm…

April 11th, 2008 @ 18:07

Have you ever mistakenly shut down or rebooted your operation-critical server while you were willing to halt your desktop computer through ssh before going to bed, or anything like this? If so, and if you are on Debian/Ubuntu, molly-guard is designed for you: this nifty bash script gets between you and the shutdown/reboot/halt tools, checking if you are connecting through ssh and if so asking for the hostname of the machine before proceeding.

Wondering how it looks? Here is the output of a little test:

ixce@timmy:~$ sudo shutdown -r
W: molly-guard: SSH session detected!
Please type in hostname of the machine to shutdown: 
Good thing I asked; I won't shutdown timmy ...

Since it doesn’t correctly handle sudo yet (actually sudo is at fault here, since it drops SSH_CONNECTION environment variable when doing its stuff), you might want to add PRETEND_SSH around the beginning of /usr/sbin/shutdown as specified on Nico “nion” Golde’s blog.

You might also want to grab the molly-guard 0.3.2 etch package I backported from sid (all I changed is downgrade debhelper build-dep version and debhelper compatibility level in debian/compat since etch only has debhelper 5 and the sid package required debhelper 6 ; this shouldn’t break anything since the newer debhelper just seems to be needed to recognize a few fields in debian/control about where the package is maintained). Sources are also available, anyway.

Thanks hr for the tip :)

March 5th, 2008 @ 20:11

Huge thanks to Novell, OpenSuse and jpr for this awesome T-Shirt :) I love it!
OpenSuse T-Shirt

Sorry, I look completely tired and I’ve got too much hair these days :p

January 5th, 2008 @ 10:40

I discovered pamusb a few days ago (actually, I had already heard about it, but never puzzled to try it), and WOW it’s great! In case you wouldn’t have guessed it yet, it lets you use an USB drive or a removable media (SD cars or so), as a mean of authentication for any pam-based application (su/sudo, keyrings, screensaver…). The setup is damn easy (it’s all about adding one line to a file in /etc/pam.d, typing two commands and adding an agent run on every session), and the whole thing works damn well.
It’s just really cool to just have to unplug an usb key to lock my laptop and replug it to unlock it, or to insert it upon login or… It’s just greatly useful. I’m still a bit reluctant to make it “required” and not just “sufficient”. It’d just be awful to be unable to login because I lose it or so…

Oh, just a little tip, to avoid “Unsafe disk removal”, just add the drive to /etc/fstab (you can reference it by label) and make it readonly and mountable by user.
LABEL=MY-KEY /media/auth vfat ro,defaults,user,noauto 0 0If you want to rename *your key, just head to the RenameUSBDrive article in Ubuntu Documentation

Here are 0.4.2 debs for hardy (which currently only has 0.4.0):

And a few handy links: