Microblog : A very long article Wikipedia article on the orientation of toilet paper [7 jun à 22:52] [R]

Samedi, 19 février 2011

Arduino with Vim

Traduction: [ Google | Babelfish ]

Catégories : [ Bricolage/Arduino | Informatique ]

If you are used to Vim as a text editor, the Arduino IDE is terrible to use. After a little bit of fiddling, here are my tips to program an Arduino using Vim.

Makefile

To compile the Arduino software, I found the Makefile by Alan Burlison and I modified it to suit my needs. You can get the modified version and use it at your own risks.

It has been modified as follows:

  • Support for arduino 0022 only (but you can change the version number in the Makefile). Versions prior to 0018 are not supported.
  • Binaries are located in /usr/bin.
  • The board is by default atmega328.
  • The programming protocol is stk500v1 and the speed is 57600 bauds.
  • The terminal emulator is xterm and the serial communication software is picocom.
  • The serial port is /dev/ttyUSB0.

All these default values can be changed in the Makefile.master file. Moreover, the following changes have been made:

  • After killing the serial communication software, sleep for 1 second
  • Before starting the programmer, the DTR signal is triggered with stty to reset the board (programming would otherwise not be possible)
  • Warnings remain warnings (GCC's -Werror flag has been removed, because I had a weird warning that I don't know how to fix)
  • The sketch's .pde file is hardlinked into the build directory, and is #included in sketchname_pde.cpp instead of copied into it. This allows GCC to report the errors on the proper line of the .pde file as well as report the proper path for this file in its error messages (when compiling sketchname_pde.cpp, GCC is in the build directory; since it would include ../sketch.pde, the error messages relative to this file would point to a file name starting with ../, but since Vim is in the parent directory, the path to sketch.pde would be wrong and Vim's QuickFix fails to find the file).
  • Linking is made by gcc instead of g++ because of a bug in linking to libm (which is needed if you want to do floating point computations, so it links against it by default).
  • A vim: line has been appended to make Vim recognize the file as a Makefile

To use this Makefile, put Makefile.master into your sketchbook directory, and create in your sketch's directory a Makefile which contains include ../Makefile.master. If you want to add extra libraries (here RF12, GLCDlib and Ports), it looks like this:

LIBS = RF12 GLCDlib Ports
LIB_DIRS = $(addprefix ../libraries/,$(LIBS))
include ../Makefile.master

Typing make inside the directory where the Makefile resides builds the sketch. make upload uploads it, make monitor starts the serial communication software on the serial port and make upload_monitor does both sequentially. Finally, make clean cleans up the build directory created when buidling the sketch.

Arduino Syntax File for Vim

Get arduino.vim by Johannes Hoff and put it in your ˜/.vim/syntax/ directory. It will let Vim recognize .pde files are as arduino, turning on C++ syntax highlighting plus Arduino-specific keywords.

Tabs

Vim allows to open multiple tabs: run vim -p *.* in your sketch's directory, and it opens all the files (except the Makefile) in separate tabs. Use Ctrl-PgUp and Ctrl-PgDown to switch between tabs.

To close all tabs at once, you can use :tabd q, but this is tedious, so I made a shortcut: Add command Q tabd q to your .vimrc and you can close all the tabs at once using :Q. You can do the same with :w, :wq and :x if you want.

Type :help tab to learn more about tabs (especially, :tabe xyz opens file xyz in a new tab. I thought you'd be glad to know).

QuickFix

You can call make from within Vim by typing :make but that's tedious also. I added the following mappings to my .vimrc:
imap <F9> <ESC>:make<CR>
map <F9> :make<CR>

This lets F9 calls :make (whether you're in command mode or in insert mode). You may want to add set autowrite in your .vimrc so that your files are automatically written when you call make.

Now, at least in Debian, after the call to :make has completed, when you return to your file's screen Vim redirects you to the file that contains the first error in make's output. In my setup, this is a warning in a file belonging to Arduino's core, which I don't want to modify. I could of course press Ctrl-O to return to the file I was editing just before running :make, but that's too much work. What I wanted is to be able to let Vim jump to the files containing warnings and errors, but to force it to ignore system files. The solution is then to add to your ˜/.vimrc the following (all in one line, without spaces after the equal sign):

autocmd Filetype arduino set errorformatˆ=\%-G../libraries\%.\%#,\%-G../../libraries\%.\%#,%-G/space/mweber/tmp/arduino-0022\%.\%#

It requires some tuning, because your Arduino directory is probably not in /space/mweber/tmp/arduino-0022, but since you're smart, you have already understood how to adapt it to your setup.

Please note that to get this setup to work properly, you need to append // vim:ft=arduino to all of the .pde, .cpp and .h files belonging to your sketches, otherwise the Vim will not do the ignoring above. And for this to work, modelines must be enabled by adding set modeline to your ˜/.vimrc.

Finally, since you opened all your files in tabs already, tell Vim not to open the file containing a warning/error in the current tab, but rather in the tab that already contains the file. You do this by adding set switchbuf=usetab in your ˜/.vimrc.

In short, your ˜/.vimrc has now these extra lines:

command Q tabd q
command W tabd w
set modeline
set autowrite
set switchbuf=usetab
imap <F9> <ESC>:make<CR>
map <F9> :make<CR>
autocmd Filetype arduino set errorformatˆ=\%-G../libraries\%.\%#,\%-G../../libraries\%.\%#,%-G/space/mweber/tmp/arduino-0022\%.\%#

[ Posté le 19 février 2011 à 19:22 | 2 commentaires | ]

Jeudi, 2 décembre 2010

Linux Tablet Comparison

Traduction: [ Google | Babelfish ]

Catégories : [ Informatique ]

I currently found 3 tablet computers running Linux (all have Bluetooth and WiFi, options are between parentheses):

First line reads: screen size, resolution, weight, autonomy, OS, price.

Shogo

10.6", 1024x600, 800g, 3 – 5 hours, Ångström, 500 EUR

ARM FreeScale i.MX-37, 256 MB RAM, 4 GB Flash, Ethernet, (3G), SDHC reader, 1 USB host, 2MPx camera

Hacking: root access with ssh by default

WeTab

11.6", 1366x768, 1000g, 6 hours, Meego, 450(570) EUR

Intel Atom N450, 1 GB RAM, 16(32) GB Flash, (3G+GPS), SDHC reader, 2 USB host, 1.3 MPx camera

Hacking: ?

Archos

10.1", 1024x600, 480g, 10 hours, Android+Ångström, 300(350) EUR

ARM Cortex A8, 256 MB RAM, 8(16) GB Flash, Micro SDHC reader, 1 USB host + 1 slave, 0.3 MPx camera

Hacking: replace Android with Ångström

[ Posté le 2 décembre 2010 à 11:12 | pas de commentaire | ]

Adresse de trackback

https://weber.fi.eu.org/blog/Informatique/linux_tablets_comparison.trackback

Commentaires

Aucun commentaire

Vendredi, 10 septembre 2010

My Own Maemo Repository

Traduction: [ Google | Babelfish ]

Catégories : [ Informatique ]

I built my own maemo repository to distribute my small and insignificant applications. The APT source is deb http://users.jyu.fi/~mweber/maemo/ fremantle main and the two currently available apps have their own .install files: pointscounter.install and maemo-dict.install.

[ Posté le 10 septembre 2010 à 10:49 | pas de commentaire | ]

Adresse de trackback

https://weber.fi.eu.org/blog/Informatique/my_own_maemo_repository.trackback

Commentaires

Aucun commentaire

Mercredi, 25 août 2010

QR Code Generator for WiFi Configuration

Traduction: [ Google | Babelfish ]

Catégories : [ Informatique ]

http://zxing.appspot.com/generator/ generates a QR Code that contains SSID, key and encryption type of a WiFi access point. This can be displayed on screen or printed on paper and used for automatically configuring a mobile device for connecting to the wireless network (provided the phone has a camera and can read the barcode).

[ Posté le 25 août 2010 à 21:59 | 2 commentaires | ]

Adresse de trackback

https://weber.fi.eu.org/blog/Informatique/qr-code_generator_for_wifi_configuration.trackback

Commentaires

Samedi, 3 juillet 2010

Obese Debian Kernel

Traduction: [ Google | Babelfish ]

Catégories : [ Informatique ]

To run the Maemo SDK on a 64-bit computer, you need to enable VDSO compat in the kernel. To do so on Debian Lenny, you need to recompile the kernel. The problem is that when you follow the instructions, you get a 400+ MB package, because the binaries contain all the debugging symbols. After some time spent in search for the solution, I found it: export INSTALL_MOD_STRIP=1 before running make-kpkg. This calls strip on the modules when creating the .deb package.

Here's the procedure:

apt-get install kernel-package ncurses-dev bzip2 module-init-tools initramfs-tools procps fakeroot

apt-get install linux-source-2.6.xx

cp /usr/src/linux-source-2.6.xx.tar.bz2 /some/path/

cd /some/path/

tar jxf linux-source-2.6.xx.tar.bz2

cd linux-source-2.6.xx

cp /boot/config-2.6.xx ./.config

make menuconfig

make-kpkg clean

export CONCURRENCY_LEVEL=2

export INSTALL_MOD_STRIP=1

make-kpkg --rootcmd fakeroot --initrd --revision=custom.001 kernel_image kernel_headers

[ Posté le 3 juillet 2010 à 15:49 | pas de commentaire | ]

Adresse de trackback

https://weber.fi.eu.org/blog/Informatique/obese_debian_kernel.trackback

Commentaires

Aucun commentaire

Mardi, 29 juin 2010

DICT-NetMOT Gateway Updated

Traduction: [ Google | Babelfish ]

Catégories : [ Informatique ]

The DICT-NetMOT Gateway I wrote some time ago suffered from an annoying bug: when the list of dictionaries at the source website is updated, the gateways uses the wrong dictionary (not-so-long story short: dictionaries are identified by index, and when the indexes change, it looks up in the wrong one). This has happened one time too many it seems, because I decided to fix this and get the gateway to download the list of dictionaries instead of using a hard-coded list. Currently the list is downloaded only on startup, so if it changes, the gateway needs to be restarted. If I am motivated, I may get it to reload automatically after a given timeout. EDIT: I was motivated, I just changed it; it now reloads after 1 day. (2010-06-29).

Short names for dictionaries, used as DICT identifiers, are generated automatically, so this may not work properly for dictionary names I haven't seen yet (there is a risk of short name collision, there is not checking against it).

Dictionaries which should be looked up by default can be specified with a (hard-coded) list of regexps against which the dictionary's long name is matched.

Also, some unidentified time ago, I updated the gateway to use the new NetMOT interface. I noticed that it started to use AJAX to provide the user with a list of suggestions while typing in the query box. I then used this feature to add support for ‘prefix’ and ‘glob’ matching strategies (‘prefix’ is mandatory in the DICT protocol, so before that the implementation was incomplete, but who cares?).

[ Posté le 29 juin 2010 à 08:08 | pas de commentaire | ]

Adresse de trackback

https://weber.fi.eu.org/blog/Informatique/dict_netmot_gateway_updated.trackback

Commentaires

Aucun commentaire

Jeudi, 27 mai 2010

Xorg intel Driver and Refreshing Graphics

Traduction: [ Google | Babelfish ]

Catégories : [ Informatique ]

The not-so-new-anymore computer at work has an intel graphics card, I therefore use the intel Xorg driver. Since Day One, bitmaps (background images) in Firefox got scrambled when they were being repainted. For example, when the top of the page has a background image, after scrolling down and up again, the image is redisplayed by slices, and each slice was repainted upside down.

I finally found the culprit today, after trillions of CPU cycles used for recompiling various versions of Firefox: if I set the AccelMethod option in xorg.conf to XAA (the default value being EXA), it works properly.

Now I just have to find out why the computer crashes (and shuts down) when I restart xdm.

[ Posté le 27 mai 2010 à 20:02 | pas de commentaire | ]

Adresse de trackback

https://weber.fi.eu.org/blog/Informatique/xorg_intel_driver_and_refreshing_bitmaps.trackback

Commentaires

Aucun commentaire

Samedi, 8 mai 2010

N900, xterm, screen and ViM

Traduction: [ Google | Babelfish ]

Catégories : [ Informatique ]

For some reason, the xterm on the Nokia N900 sends KP_Enter instead of simply Enter when pressing the Enter key. The result is that ViM inserts an “M” in addition to starting a new line. Maemo bug #6009 discusses the problem, and thankfully there's a fix (because the problem was identified in December 2009 and nobody is actually taking care of it, so it probably won't be corrected any time soon).

In the .screenrc file, add the line bindkey -a -k fe stuff ˆM. You can also fix a currently running screen by pressing C-a : and typing the same bindkey command.

[ Posté le 8 mai 2010 à 23:47 | 1 commentaire | ]

Mardi, 4 mai 2010

Shell Scripts and Large Files

Traduction: [ Google | Babelfish ]

Catégories : [ Informatique | TV/Leffakone ]

I use a shell script wrapper around MPlayer for recording TV programs in my Leffakone, the problem being that when TV reception is too bad, MPlayer crashes or freezes, so the wrapper restarts it when needed. Since MPlayer doesn't output anything while recording, I use a loop that checks every second that the recorded file is actually growing. Whem it stops growing (and there is still some recording time left), it means that MPlayer stopped working and that it needs to be restarted. Until now, I did this in a loop like this:
while [ $(stat -c %s $filename) -gt $last_size ]
do
  last_size=$(stat -c %s $filename)
  sleep 1
done

I then noticed that all recordings exceeding one hour (there aren't that many, that's why it took so long to notice it) where cut in two even though the picture doesn't show hints of bad reception. More peculiar, the size of the first part is slightly over 2 GB in size (therefore the problem is not related to a 2 GB size limit, right?). An experiment conducted yesterday show that it actually is: the test program (used here in its |[| form) handling the -gt comparison actually doesn't like values greater that 2ˆ31, which caused the loop to be interrupted and the recording to be split into two parts.

The solution is then (for Bash at least) to use the following syntax:

while [[ `stat -c %s $filename` -gt $last_size ]]
which seems to be working with values greater than 2ˆ31 (and than 2ˆ32, I just checked).

[ Posté le 4 mai 2010 à 08:53 | 1 commentaire | ]

Jeudi, 22 avril 2010

Amazon Images

Traduction: [ Google | Babelfish ]

Catégories : [ Informatique ]

In Abusing Amazon images you learn how to abuse Amazon images, creating images of an Amazon product with whatever tag overlaid on it (such as a “99% off” bullet).

But the interesting part is that you can get images in any format with the following syntax: http://ecw.images-amazon.com/images/P/ASIN.01.size_info.jpg .

Useful values for size info are:

  • THUMBZZZ for thumbnail
  • TZZZZZZZ for medium-size
  • nothing for default size
  • L, LZ or LZZ for large
  • AAxx, xx is the size of the largest dimension
  • SXxx, xx is the width
  • XYxx, xx is the height
  • SSxx, xx is the size of width and height (image is padded with white)

Plenty of other features are available, I now use SSxx for the blog so that I can add size/height attributes to the IMG elements in the HTML and WAP 2.0 versions.

[ Posté le 22 avril 2010 à 13:14 | pas de commentaire | ]

Adresse de trackback

https://weber.fi.eu.org/blog/Informatique/amazon_images.trackback

Commentaires

Aucun commentaire

Mardi, 9 février 2010

User Identification through Web Browser User-Agent

Traduction: [ Google | Babelfish ]

Catégories : [ Informatique ]

I found las year that 33 bits are enough to uniquely identify someone.

Now I just read that the browser's User-Agent field provides 5 to 15 bits of identification (10.5 bits on average). If you add zip code, geolocation, it becomes nearly enough to track people perfectly.

With EFF's Panopticlick, I know that my browser provides at least 16.12 bits of identification. The identifying criteria are the User-Agent and HTTP_Accept fields, available plugins, time zone, screen size, system fonts, cookies enabled/disabled and so-called super-cookies. The most scary part of the report is the statement that “Your browser fingerprint appears to be unique among the 71,157 tested so far.”

Without Javascript, my browser still provides 16.13 bits, due to the HTTP_Accept header and User-Agent.

[ Posté le 9 février 2010 à 12:56 | 1 commentaire | ]

Adresse de trackback

https://weber.fi.eu.org/blog/Informatique/user_identification_through_web_browser_user_agent.trackback

Commentaires

Lundi, 8 février 2010

The Definite New ADSL Modem

Traduction: [ Google | Babelfish ]

Catégories : [ Informatique ]

End of the new ADSL modem story. I sat on my principles and bought last Saturday an A-Link RR24AP(d) at Gigantti, even though it runs Linux (yes!) without publishing the source code (boo!). It cost me 20 EUR more than what it would have cost at Multitronic.fi, but I guess that's what it cost to get it immediately.

The RR24AP(d) is not perfect either: its DynDNS client is updating its DNS record even though the IP address doesn't change (I got banned temporarily by DynDNS for that; I restarted the DynDNS daemon running on minikone and disabled the one in the router).

Moreover, I wanted to use its telnet/ssh menu-based interface for enabling/disabling the WLAN from the desktop (I wrote a docklet for that with a wrapper script for hiding the protocol stuff), but although enabling works, disabling doesn't work. I had to use the Web interface instead. An additional nice discovery is that although the main menu offers choices numbered 1 to 10, when you choose 0, you get a root shell. I haven't found a way to enable/disable the WLAN from the shell, hence the wrapper script for the Web interface.

[ Posté le 8 février 2010 à 22:23 | pas de commentaire | ]

Adresse de trackback

https://weber.fi.eu.org/blog/Informatique/definite_new_ADSL_modem.trackback

Commentaires

Aucun commentaire

Vendredi, 5 février 2010

More ZyXEL Troubles

Traduction: [ Google | Babelfish ]

Catégories : [ Informatique ]

Part 2 of the new ADSL modem story.

This is how it goes: reboot the modem, connect to its telnet server. The TCP window is 2048 bytes long. Everything works fine. Telnet again: the TCP window is now 1024. Actually, it shrunk to 1024 already on the FIN/ACK packet sent by the router when closing this first telnet session and stays like this for all the subsequent connections. During those connection, each ACK packet it sends is followed by a second ACK where it resets the window size to 1024 bytes. After some time (this is the tricky part, I have no idea how time or idleness affects it), when telneting again, some TCP packets are lost, the client side has to retransmit them. Insist a bit more, and there are more and more packets which don't get acknowledged. Eventually, the telnet server may become non-responsive and the whole device stops responding to pings. Reboot the modem.

Whether using the forwarded port from the WAN to the client machine on the LAN is involved or not in prooking this behaviour is not known, more investigation needs to be done.

I contacted ZyXEL, they asked me to return the device. Let's see if they are able to reproduce the problem.

[ Posté le 5 février 2010 à 17:31 | 1 commentaire | ]

Jeudi, 4 février 2010

New ADSL Modem

Traduction: [ Google | Babelfish ]

Catégories : [ Informatique ]

The old A-Link RR64, Linux 2.4-based ADSL modem and router has been dying slowly for the past eight months or so, and when the “alarm” LED went suddenly on, I decided it was time to get a new piece of hardware before that one broke down completely. Since it had a hard time booting up after the power had been down, it was a good idea anyway.

After long discussions with my colleagues, I decided to buy a ZyXEL Prestige 660WP-D1, with an integrated WLAN base station. It's not based on free software, but the equivalent linux-based model by A-Link doesn't respect the GPL regarding the distributon of the source code (it actually doesn't even mention it's based on Linux), so I wasn't going to give my money to those people anymore.

I spent the whole evening and half the night yesterday trying to set it up so that it replaces the old device in the network. First thing, the ZyXEL does't have a DNS server for the local network, so I had to setup one on the server there using dnsmasq (merci tontonth :) ). This means I cannot get the outside DNS server's address from the ISP anymore (the router is unwilling to serve as a DNS proxy while at the same time propagating the dnsmasq's address through the DHCP configuration) but I have to set it up statically in dnsmasq. I hope it doesn't change its address every two weeks…

The second problem was that the NAS I use for backups is unable to get its IP address from the ZyXEL, so I had to set a static one.

But the weirdest of the weirdest, is that the machines connected through the WLAN were not able to connect to the ones on the LAN, which is a bit of a problem since the dnsmasq is on the LAN. After a long time reading the docs, I found in the latest firmware's changelog that the following bug had been fixed: 22. WLAN and LAN can not communicate with each other when the admin password is changed in the GUI. The new firmware indeed fixed the problem, but what screwy software design makes the bridging between two networks dependent on the admin's password and the GUI? This is bound to be a problem for any user who knows that default passwords must be changed, since the first time you connect to the Web interface as admin, it forces you to change the password.

Well, it seems to be working now. Let's cross fingers.

[ Posté le 4 février 2010 à 12:21 | 1 commentaire | ]

Mercredi, 27 janvier 2010

LPRng and Windows LPD Server

Traduction: [ Google | Babelfish ]

Catégories : [ Informatique ]

We have two kinds of printers at work: old HP LaserJets and newer Ricoh multifunction photocopiers connected to the same Windows-based print server (accepting the LPD protocol).

While no particular option in /etc/printcap is required to print with LPRng on the HP printers, the bq_format=l option is needed for printing to the Ricoh ones. This tells Windows that the data must be printed as is, as explained on the LPRng mailing list. But why does it work without this option on the HP printers then?

[ Posté le 27 janvier 2010 à 14:36 | pas de commentaire | ]

Adresse de trackback

https://weber.fi.eu.org/blog/Informatique/lprng_and_windows_lpd_server.trackback

Commentaires

Aucun commentaire

Mardi, 27 octobre 2009

Transcend 1 – Kingston 0

Catégories : [ Informatique ]

J'ai acheté il y a un an et demin un lecteur de cartes mémoires SD Kingston MobileLite. Il fonctionnait correctement sur ma vieille Debian Etch (avec un noyau 2.6.18), mais après l'avoir mise à jour en Lenny (noyau 2.6.26), le lecteur à cessé de fonctionner. Je l'ai renvoyé en garantie, on me l'a échangé contre un neuf, qui ne fonctionne pas mieux. Après un certain temps passer à fouiner sur le web, j'ai appris que quelque part entre le 2.6.18 et le 2.6.26 un certain nombre de contournements de bugs on été ajoutés au noyau afin de faire fonctionner des lecteurs de cartes SD plus ou moins mal foutus. Le résultat, c'est que le Kingston, qui est lui aussi mal foutu, mais différemment, ne fonctionne plus. La raison profonde, c'est que Linux tente de lire le dernier secteur de la carte (pour en déterminer la taille ?) et que lors d'une lecture par blocs, si le bloc contient le dernier secteur, le firmware du lecteur plante. Et s'il contient l'avant dernier secteur, il plante aussi. Le noyau 2.6.30 souffre également de ce bug, donc le problème n'a pas été corrigé depuis le 2.6.26. Et comme le lecteur ne fonctionne qu'une fois sur deux avec Leffakone (noyau 2.4.22), j'ai donc décidé de changer de crèmerie : j'ai acheté un lecteur Transcend P5, au nom nettement moins marketing, mais qui au moins fonctionne du premier coup. Transcend roulaize (pour le moment), Kingston pas.

[ Posté le 27 octobre 2009 à 20:55 | 2 commentaires | ]

Mardi, 20 octobre 2009

Reverse Engineering the param.cfg file of Cowon's iAudio 7 player

Traduction: [ Google | Babelfish ]

Catégories : [ Informatique ]

While I'm eating at work, I like to listen to the same podcast I was listening while commuting. But I don't want to search manually which file I was listening to, and at what point in the podcast I shut the player down. Since this information is probably in the player's system files somewhere, I just had to hack a bit and see if I could extract it.

The relevant file is system/param.cfg. At offset 0x0F, one can read a big-endian 16-bit number which is the offset in seconds from the beginning of the file where playing was stopped. That part was easy.

Now for the actual file. At offset 0x879, one can read a big-endian 32-bit number which is the first File Allocation Table entry of the file. And somehow, this wasn't difficult to guess, I probably would have designed it that way myself… Thankfully, the Mtools package in GNU offers a tool called mshowfat which takes a DOS path as an argument and returns the FAT range occupied by that file.

And Bob's your uncle.

[ Posté le 20 octobre 2009 à 12:23 | pas de commentaire | ]

Adresse de trackback

https://weber.fi.eu.org/blog/Informatique/iaudio_param_cfg.trackback

Commentaires

Aucun commentaire

Vendredi, 24 juillet 2009

Typematrix

Traduction: [ Google | Babelfish ]

Catégories : [ Informatique ]

In linux/Xorg, use inet(dtk2000) in xorg.conf's XkbLayout option (in addition to whatever basic layout you are already using) to be able to use the navigation and multimedia keys in the Typematrix EZReach 2030 USB keyboard. Only the eject key is not working. After that, it's up to the applications or window manager to make use of them, this config option only associates X11 symbols to the keys. I hadn't found this information anywhere on the web, I hope it will be useful to someone.

[ Posté le 24 juillet 2009 à 11:40 | pas de commentaire | ]

Adresse de trackback

https://weber.fi.eu.org/blog/Informatique/typematrix.trackback

Commentaires

Aucun commentaire

Mardi, 7 juillet 2009

Printing with LPR in Firefox

Traduction: [ Google | Babelfish ]

Catégories : [ Informatique ]

Firefox didn't allow me to print by default. Printing to a file was the only proposed option. The culprit here is not even Firefox but GTK, which needs to be told that there is life beyond printing to a file. I put to my $HOME/.gtkrc-2.0 file the following line: gtk-print-backends="pdf,cups,lpr,file", and I could finally print to lpr.

[ Posté le 7 juillet 2009 à 18:38 | pas de commentaire | ]

Adresse de trackback

https://weber.fi.eu.org/blog/Informatique/printing_with_lpr_in_firefox.trackback

Commentaires

Aucun commentaire

nohz=off is the Way to Go

Traduction: [ Google | Babelfish ]

Catégories : [ Informatique ]

Debian Lenny's default kernel is tickless, meaning that there is no periodic tick anymore. As a result, it seems that some applications that use periodically short sleeps (as in while(1) { // do possibly something; usleep(250); }) are scheduled far too often and the CPU is running more than in should while the system is seemingly idle. Passing the option nohz=off to the kernel seems to have fixed that problem.

[ Posté le 7 juillet 2009 à 18:34 | pas de commentaire | ]

Adresse de trackback

https://weber.fi.eu.org/blog/Informatique/nohz.trackback

Commentaires

Aucun commentaire

Hello, Helvetica!

Catégories : [ Informatique ]

I didn't need to say bye bye to Helvetica after all. The least bad compromise seems to be using the bitmap Helvetica font for GUI anyway, and set Firefox to use DejaVu fonts without allowing web sites to decide what font to use (I don't have anything besides DejaVu anyway, so I won't miss anything by doing so).

[ Posté le 7 juillet 2009 à 18:29 | pas de commentaire | ]

Adresse de trackback

https://weber.fi.eu.org/blog/Informatique/hello_helvetica.trackback

Commentaires

Aucun commentaire

Bye bye, Helvetica

Traduction: [ Google | Babelfish ]

Catégories : [ Informatique ]

I have used Helvetica as the sole font in WindowMaker for the past 12 years (AFAICR). I recently upgraded to Debian Lenny and switched from Mozilla 1.7 to Firefox 3.5 (at last!) I managed to setup my system to use the Helvetica bitmap font, which looks much nicer than Nimbus Sans (the Type 1 equivalent) in WindoMaker, and I was happy. But I discovered that Firefox now (AFAICT) prints Helvetica text using the Helvetica bitmap font, which produces very ugly documents. Mozilla was somehow smart enough to use vector fonts for that, but not Firefox. Helvetica seems to be something of the past :(

So I switched to DejaVu fonts for WindowMaker and Nimbus for GTK applications and Firefox. It's so sad.

[ Posté le 7 juillet 2009 à 12:00 | 1 commentaire | ]

Lundi, 15 juin 2009

Free est plus fort que moi

Catégories : [ Informatique ]

Il y a exactement 7 jours, la freeboite de mes parents est tombée en rade. Un coup de voltmètre sur l'alim montre qu'elle délivre toujours 12 volts, j'en conclue que la boite est morte. Après un certain temps passé à configurer XP pour qu'il utilise le modem 56k et connection au chat de la hotline de Free, je finis par obtenir un contact. Il me dit que le coup du voltmètre ne suffit pas pour conclure au mauvais fonctionnement de la boite, il va donc envoyer une nouvelle alim. Elle est arrivée cet après-midi. N'y croyant pas du tout, je la branche, et… Ô miracle, ça marche. Free a mauvaise réputation concernant le service client, mais là, ils ont été plus forts que moi.

[ Posté le 15 juin 2009 à 20:48 | pas de commentaire | ]

Adresse de trackback

https://weber.fi.eu.org/blog/Informatique/free_est_plus_fort_que_moi.trackback

Commentaires

Aucun commentaire

Samedi, 21 mars 2009

No for, no if

Traduction: [ Google | Babelfish ]

Catégories : [ Informatique ]

The mission: write a program that iterates over a list and asks the user, on every item, if he wants to change the current number, or quit (and keep the rest of the list unchanged).

Here's a possible python implementation.

def loop(data, index):
  return decide(index == len(data) - 1, 
                lambda: quit(data), 
                lambda: run(data, index+1)
               )
 
def decide(condition, iftrue, iffalse):
  return (iffalse, iftrue)[condition]()
 
def choose(selector, choices, default):
  return choices.get(selector, default)()
 
def change(data, index, new_value):
  data[index] = new_value
  return loop(data, index)
 
def run(data, index):
  print data[index]," Change? [n/q/]",
  reply = raw_input()
  return choose(reply.lower(),
                { 
                  "n": lambda: loop(data, index),
                  "q": lambda: quit(data)
                },
                lambda: decide(reply.isdigit(),
                               lambda: change(data, index, int(reply)),
                               lambda: run(data, index)
                              )
               )
 
def quit(data):
  return data
 
data = range(10)
print run(data, 0)

[ Posté le 21 mars 2009 à 18:09 | 2 commentaires | ]

Adresse de trackback

https://weber.fi.eu.org/blog/Informatique/no_for_no_if.trackback

Commentaires

Mercredi, 4 mars 2009

Last.fm Datamining

Traduction: [ Google | Babelfish ]

Catégories : [ Informatique ]

Interesting article about how personal profiles on different systems can be linked together by datamining:

“If your username isn't your real name, your Last.fm account may seem to be anonymous, but the facts it contains probably tell the world who you are.”

“even a small amount of information about other pseudonyms you've friended on Last.fm has a high probability of allowing a data miner to match you based on the friendship graphs from other sites”

“There are only 7 billion people on the planet, and only about a billion on the Internet. Every fact about a person (are they male or female? Where they live? Do they listen to Brian Eno?) slices that number down by a significant fraction. If you have enough facts about a person, (33 bits of independent facts, it turns out, because log2 7,000,000,000 = 32.7) you can determine who they are.”

[ Posté le 4 mars 2009 à 14:05 | 2 commentaires | ]

Vendredi, 20 février 2009

Ricoh Aficio MP 4500: Taming the Beast

Traduction: [ Google | Babelfish ]

Catégories : [ Informatique ]

I tried to use one of these wild devices to print a Letter landscape document on microperforated Letter sheets… in an A4 world.

When the printer is set to use A4 paper, it won't pay attention to the PostScript file telling it that the paper format is Letter. The result is that the print would be correctly positioned on an A4 sheet, but is shifted up the actual Letter sheet, because the letter sheet is aligned with the bottom of the would-be A4 sheet.

The solution is to feed the beast only portrait documents, centered on an A4 page, then shift the document 2.5mm to the left to compensate for the fact that it aligns the page's right border with the sheet's right border. This gets it really centered on the Letter sheet (it should be 3mm to account for the width difference between Letter and A4, but even A4 pages are shifted by 0.5mm; it would be too easy otherwise).

Finally, the bottom edge of the printed document is on the side of the back of the beast (the one that is against the wall, opposite of the control panel). This is important for the microperforated paper which has a smaller bottom margin than the top margin.

[ Posté le 20 février 2009 à 17:04 | 4 commentaires | ]

Mardi, 11 novembre 2008

Automatic X Screen Saver -based Autoaway for Irssi

Traduction: [ Google | Babelfish ]

Catégories : [ Informatique ]

I fixed a bug in xautoaway (actually, in X11::Protocol). The new version is available.

[ Posté le 11 novembre 2008 à 23:46 | pas de commentaire | ]

Adresse de trackback

https://weber.fi.eu.org/blog/Informatique/irssi_xautoaway_bugfix.trackback

Commentaires

Aucun commentaire

Mercredi, 5 novembre 2008

Automatic X Screen Saver -based Autoaway for Irssi

Traduction: [ Google | Babelfish ]

Catégories : [ Informatique ]

xautoaway.pl is an autoaway script for Irssi that allows Irssi to go away automatically when your X Window session has been idle for some time. Additionaly, it supports Irssi running in a GNU screen, being detached from an xterm in one display and reattached to another xterm on another display. Distributed as-is, under “it-works-for-me” pseudo-license (and under GNU GPLv3 real license).

It requires the X11::Protocol module and some additional setup (the provided, incomplete extension to X11::Protocol to support MIT-SCREEN-SAVER and the screen wrapper to be run instead of GNU screen).

[ Posté le 5 novembre 2008 à 23:40 | pas de commentaire | ]

Adresse de trackback

https://weber.fi.eu.org/blog/Informatique/irssi_xautoaway.trackback

Commentaires

Aucun commentaire

Mardi, 4 novembre 2008

DICT-NetMOT Gateway

Traduction: [ Google | Babelfish ]

Catégories : [ Informatique ]

I just finished motdictd.pl a gateway between the DICT protocol and the MOT online (not free at all) dictionary collection accessible to the University of Jyväskylä. It runs as a local DICT server, started from the command line by any user (preferably not root) and listens to 127.0.0.1 on port 2628. DICT queries are turned into HTTP requests to NetMOT, the resulting HTML code is cleaned up and returned as pure text to the DICT client. The CLI DICT client doesn't support multiple servers, so it accessing the gateway requires to call dict -h localhost if the default server is dict.org.

[ Posté le 4 novembre 2008 à 11:09 | 1 commentaire | ]

Lundi, 27 octobre 2008

Synergy

Traduction: [ Google | Babelfish ]

Catégories : [ Informatique ]

I just tested Synergy. This little tool allows to share one keyboard and mouse between several computers sitting next to each other (that is, each computer needs to have its own display) over the network. When the mouse cursor reaches the edge of the screen, it moves to the screen of the computer next to that edge (and the keyboard's focus too, of course). The great thing is that it works in Linux (and other Unices), in MacOS X and in Windows. So it's perfectly possible to have a mix of all these types of systems, and it woks seamlessly, without any extra hardware.

[ Posté le 27 octobre 2008 à 22:47 | pas de commentaire | ]

Adresse de trackback

https://weber.fi.eu.org/blog/Informatique/synergy.trackback

Commentaires

Aucun commentaire

Mercredi, 22 octobre 2008

Just for Fun

Traduction: [ Google | Babelfish ]

Catégories : [ Informatique ]

This is the follow-up to the previous episode.

Today's discussion with Ville was concluded more or less like that: he claimed that having access to the source code is of no use for him although he can code, because he has never been able to gather the necessary energy to start hacking an existing software. Well, that's his problem, isn't it? I devote some of my free time to hack software (in a very insignificant way, I'm sure) to adapt it to my needs, he devotes his to something else. And I enjoy my small software hacks. I'm proud of myself when I manage to understand MPlayer's subtitles code and add support for DVB subtitles, or when I add support for X11's screensaver protocol to perl's X11::Protocol module. And let's be honest: LATEX is ridiculously complicated, but I enjoy fighting the beast and bending it to my will.

I have loads of fun doing things myself. I make my own pizzas from scratch (dough and tomato sauce, altough I don't grow the tomatoes, olives and wheat, nor do I breed pigs or milk cows), I make my own ice-cream, my own Home Theater PC, my own blog engine, my own Carcassonne meeples. Buying something ready-made feels like a waste of money if I can do it myself for a reasonnable cost in time. I'm not going to devote large amounts of time on large projects such as writing my own operating sytem, word processor or image manipulation software, mainly because the time it would cost me compared to the benefit I would get out of it compared to using the existing tools is not worth it. Hacking oversized projects don't really interest me, even if they have bugs and I'd like to fix them. But I very much appreciate that small, one-person -sized softwares are free for me to hack when I set my mind to it.

The ones who consider the freedom given by free software to be useless are the ones who are too busy/lazy to take advantage of it and have more money at hand than time.

[ Posté le 22 octobre 2008 à 23:41 | 9 commentaires | ]

Adresse de trackback

https://weber.fi.eu.org/blog/Informatique/just_for_fun.trackback

Commentaires

Is Free Software Always Better?

Traduction: [ Google | Babelfish ]

Catégories : [ Informatique ]

This is the follow-up to the previous episode.

So, is free software always better than the other kind? Jonne claimed that the “freedom” aspect of free software isn't an advantage for him, because free software is hard to change, and it takes a long time to implement the new feature you would like to add to it. The alternative would be to send a bug report or feature request to the developers. But both in free project and proprietary ones you may reach grumpy developers, who will consider your request as low priority.

Now the real difference between free and proprietary is that in the case of free software, you have the right to do it yourself. It may be difficult and take an enourmous amount of time (such as integrating CMYK in GIMP, which was not designed orginally to handle anything else than RGB), but it is possible if you are willing to devote resources (time and/or money) to it. With a proprietary software, if the developers don't want to implement your feature, there is no appeal. Jonne's argument was that you can always find a software (free or not) that does what you want. I claim that this is not always true.

The first example is that when I built my leffakone five years ago, there was no software running on Linux that supported DVB subtitles and automatic TV commercial removal. Actually, there was no software that was supporting these two features at all. So I took the time to implement them myself (and yes, MPlayer's subtitle code is an horrible mess). The second example is a recent problem with Python's X11::Protocol module. It had a bug that I managed to identify thanks to the source code, and I found a way to go around it. I submitted a bug report, but to this day (over a month later) it has still not been answered. X11::Protocol was exactly what I needed, but had it been proprietary, I wouldn't have been able to find a workaround, and would have needed to settle with a sub-optimal solution, which would not have been doing exactly what I want.

Jonne also claimed that developers don't need the source code of a software, but the software should be designed so that it can be extended. Firefox is a good example: a lot of features can be added as “extensions” and the developers don't need to access Firefox's source code. But not all software is designed to be extensible, especially if it is in the (financial) interest of the publisher to prevent anyone to develop an extension without its blessing. This means that if the extension you want to develop doesn't follow the publisher's commercial strategy, you won't be allowed to do it. And again there will be no appeal. An no, you don't always find another software that does the same thing and would allow you to develop your extension.

And guess what? Most of the software available nowadays is not extensible. That is, it's not meant to be easy to extend. If you want to change its behavior or fix a bug, you have no choice but to dig into the source code. And even if the software has been designed with extensibility in mind, it doesn't mean that the data it exports through its extension API contains all the information you need for your purposes. A good example of this if my blog engine, Bloxsom. It was designed to be extensible, most of the work is done by extensions rather than by the software's core. But for implementing features such as multiple languages and multiple categories, I had to change the core, because the extension API was not enough. And I don't know any other blog engine that fits my requirements. But hey, I don't know all the blog engines in the world, so I may be wrong.

To be continued.

[ Posté le 22 octobre 2008 à 23:14 | pas de commentaire | ]

Adresse de trackback

https://weber.fi.eu.org/blog/Informatique/is_free_software_always_better.trackback

Commentaires

Aucun commentaire

Free Software is a Fad

Traduction: [ Google | Babelfish ]

Catégories : [ Informatique ]

I started to use free software in 1996 (or was it 97?), with Slackware 3.0. The first reason why I decided to learn Linux is because Unix systems were the ones used by real coders. Windows already looked too much like a toy, had the bad reputation of a shaky house built over the sand of MS-DOS. And also because it was cool (from a geek's perspective, of course). The reason why I continued to use free software was that even though free software is free as in “free speech”, it is also free as in “free beer”. There were software filling my needs, and I adapted the topic of my free-time projects to what was available on Linux. For example, I could have continued to play aimlessly with SoundForge in Windows, but coding an IRC bot in Perl on Linux was more appealing. It was a creative process, the creation of somethat that acts (if only by reflex), on the contrary of something you contemplate with more or less awe (like music or a painting). And also, the IRC bot was working on my behalf, providing a service.

I had a long discussion with two colleagues the other morning, who claimed that Free Software is a fad. I didn't agree with them at first, thinking about the origins of the free software movement, but after reflection I have to admit that in the last five years it actually has turned into a fad. Not a passing fad like clothing fashion (although the pointy shoe fashion could have changed more quickly for my taste), but in the sense of something that a lot of people use, and who use it because everybody else is also using it. The reason for this is that free software is free (as in “free beer”) and people are more often than not choosing something free over something they have to pay for. The average software user doesn't care whether he has the right to modify software or not. He's a user, not a developer, and he doesn't know how to use this right. I guess plenty of users still use warez software or free (as in “beer”) proprietary software instead of free software, because warez doesn't cost more than free software (at lease from the point of view of money). In some cases, one free (as in “speech”) software can drive the fad. This is the case of Firefox I guess, which was in its time technically superior to Internet Explorer (it respected the standards of the Web and had popup and ad blockers). And I wouldn't be surprised that Firefox has been the main driving force behind the free software fad.

To be continued.

[ Posté le 22 octobre 2008 à 22:32 | pas de commentaire | ]

Adresse de trackback

https://weber.fi.eu.org/blog/Informatique/free_software_is_a_fad.trackback

Commentaires

Aucun commentaire

Mercredi, 15 octobre 2008

FOAF

Traduction: [ Google | Babelfish ]

Catégories : [ Informatique ]

FOAF means Friend of a Friend. It's an RDF vocabulary that allows to describe oneself and link to people one knows. In other words, it forms a distributed social network, independant from any service provider such as Facebook, LinkedIn, Orkut and so on. It doesn't allow you to send messages to other people in your network, or any of the activities that are often associated with social networks, it only describes you and your relations to the people you know.

Here's my FOAF descriptor, that you can also view through FOAFer. There's also FOAF-a-Matic, a simple web tool that creates a basic FOAF descriptor for you (a more advanced descriptor will required to write RDF by hand, though). Finally, there is also a FOAF Generator that creates a FOAF descriptor based on your Facebook profile.

So if you feel geeky enough to get your own FOAF descriptor and if you know me, let me know about it :)

[ Posté le 15 octobre 2008 à 15:43 | pas de commentaire | ]

Adresse de trackback

https://weber.fi.eu.org/blog/Informatique/foaf.trackback

Commentaires

Aucun commentaire

Jeudi, 28 août 2008

Patches for Snownews

Traduction: [ Google | Babelfish ]

Catégories : [ Informatique ]

I wrote yesterday two small patches for Snownews 1.5.7. The first one adds support for the <content:encoded> tag (if such an element is present in the feed, it supersedes the <description> element). The second one fixes a bug that replaces <br> and <p> in the wrong place. Additionaly, it also inserts a newline when a <div> is found.

[ Posté le 28 août 2008 à 00:05 | pas de commentaire | ]

Adresse de trackback

https://weber.fi.eu.org/blog/Informatique/patches_for_Snownews.trackback

Commentaires

Aucun commentaire

Word Scrambler, Write-Only Version

Traduction: [ Google | Babelfish ]

Catégories : [ Informatique ]

Here's a more compact, less readable version of the scramble function:

sub scramble {
  return $_[0] if $_[0] =˜ /ˆ[A-Z]/;
  my @l = split //,$_[0];
  @l[1..$#l-1] =
     sort { rand(1) < 0.5 ? -1 : 1 } @l[1..$#l-1];
  return join("", @l);
}

[ Posté le 28 août 2008 à 00:05 | pas de commentaire | ]

Adresse de trackback

https://weber.fi.eu.org/blog/Informatique/word_scrambler_write-only_version.trackback

Commentaires

Aucun commentaire

« Vers le haut de votre âne » ou « les acronymes sont frais »

Catégories : [ Informatique ]

J'ai ajouté aujourd'hui des liens automatiques vers Google Translation afin que les lecteurs qui ne maîtrisent pas la langue de Shakesière (ou Molipeare, c'est selon) puissent avoir une idée de quoi je parle. J'en suis très fier, car chacun de ces liens offre une source quasi-inépuisable de fou-rire. Voici en particulier celui qui vient de me faire hurler de rire.

La traduction automatique est vraiment un outil formidable, on ne s'en lasse jamais.

[ Posté le 28 août 2008 à 00:05 | pas de commentaire | ]

Adresse de trackback

https://weber.fi.eu.org/blog/Informatique/vers_le_haut_de_votre_ane.trackback

Commentaires

Aucun commentaire

Editing MPEG TS Streams

Traduction: [ Google | Babelfish ]

Catégories : [ Informatique ]

When I record a TV show on Finnish DigiTV, I get an MPEG TS file containing interleaved audio and video streams (as well as a subtitle stream if the TV channel uses them). Removing the commercials or even simply the five minutes padding at the beginning and the end is not completely straightforward, but can be done quickly with some simple tools.

editmpegts is a command line tool I wrote that takes an MPEG TS stream and an edit list (in MPlayer's EDL format), specifying the time positions of commercial breaks and cuts the MPEG TS into slices to keep only the interesting part of the recording. I then transcode the slices individually, and contatenate them with avimerge.

There are however a couple of pitfalls if you want to use mencoder to transcode the slices into e.g., XviD+MP3, since the MPEG 2 video decoder resets every time the aspect ratio of the video changes. When doing 2-pass encoding, this means that the stats gathered before the change of aspect ratio will be lost, resulting in miscalculated bitrate and far too big output files (at least in the old, overpatched version of MPlayer I'm using).

mencoder reacts on two things: the change of the value in the aspect ratio field in the MPEG sequence header, and the presence of an “End of Sequence Marker”. editmpegts forces all the aspect ratio flags to the same value, and simply suppresses the marker by overwriting it with the data that precedes in within one TS packet. It is all done in one pass, no need to demultiplex and remultiplex the stream (but it does copy the data into a new output file, it doesn't therefore modify the input file).

The MPEG TS streams broadcast by SubTV contain loads of sequence headers but very few end of sequence markers. My understanding is that every sequence (starting with a sequence header) should end with an end of sequence marker, so SubTV's streams are illegal. But I may be wrong. Anyway, it works fine with MPlayer (and now with mencoder too), so who cares?

[ Posté le 28 août 2008 à 00:05 | pas de commentaire | ]

Adresse de trackback

https://weber.fi.eu.org/blog/Informatique/editing_mpeg_ts_streams.trackback

Commentaires

Aucun commentaire

Lundi, 1er octobre 2007

More Dirty Things to do in Perl: Unsorting

Traduction: [ Google | Babelfish ]

Catégories : [ Informatique ]

I discussed today with Matthieu Fritz about how the act of reading was processed in the brain, and he reminded me of a chain e-mail containing text where the letters of the words were scrambled, except the first one and the last one, and which was still surprisingly readable. He wondered if it worked with any text, or if the text in the e-mail was carefully composed. I quickly hacked a Perl script doing the job, and in the middle of writing it, I was wondering how I could scramble the letters of a word without writing too much code. The the solution popped into my mind: use sort, unsing rand instead of a comparison function. Here's the resulting script:

sub scramble {
  my $s = shift @_;
  my @letters = split //,$s;
  my $first = shift @letters;
  # Do not scramble words starting with an uppercase letter
  return $s if $first =˜ /[A-Z]/;
  my $last = pop @letters;
  my $rand = int(rand(2));
  # $rand == 0 means that the letters won't be exchanged, but we want as much
  # scrambling as possible, therefore we discard the use of 0
  $rand = -1 if $rand == 0;
  my @l = sort { $rand } @letters;
  return "$first".join("", @l)."$last";
}
 
while (<>) {
  # Scramble the words composed of lowercase letters and accentuated
  # characters
  s/([a-z\xa0-\xff]+)/&scramble($1)/ge;
  print;
}

Verdict: it works with short and common words, but not with longer or rarers ones.

[ Posté le 1er octobre 2007 à 20:39 | pas de commentaire | ]

Adresse de trackback

https://weber.fi.eu.org/blog/Informatique/more_dirty_things_to_do_in_perl.trackback

Commentaires

Aucun commentaire

Samedi, 30 juin 2007

Elisa/Kolumbus webmail virhekorjaus

Traduction: [ Google ]

Catégories : [ Informatique ]

Mozillalla (ja ehkä myös Firefoxilla) Elisan/Kolumbuksen webmail ei toimi hyvin, koska viestin otsake ei näy. Tässä on helppo korjaus:

userContent.css-tiedostoon, lisätään

div#mail-header, .content-functions, div#mail-steps, div#contact-cards, div#contacts-header, div#view, form.search, div#mail-header p, .splitted, form.search p, .action-info, p.go-oma-elisa, .prompt-controls, form#login p, .new-features { height:auto ! important; }

userContent.css:n paikka rippuu siitä, mitä käyttöjärjestelmä on käytössä. Tämä sivu selittää mistä se löytyy Firefoxilla (englanniksi).

[ Posté le 30 juin 2007 à 19:22 | pas de commentaire | ]

Adresse de trackback

https://weber.fi.eu.org/blog/Informatique/elisa_webmail_virhekorjaus.trackback

Commentaires

Aucun commentaire