Paste not working the way it should?

Many (if not most) websites are broken in various ways these days. One of the favorite bugs of web developers is breaking copy&paste. For whatever reason pasting text into form fields is not working at all on many websites.

Today gvim was annoying me with a different misfeature: Pasting text with more than one line is always inserted on a new line above the cursor. I want the text pasted where the cursor is, not where vim’s developers think they would like it. That’s the last straw.

To solve this problem for all times I wrote a small script which converts the paste buffer into keystrokes. For all applications it will look as if that text has been entered with the keyboard. Here is the code of my Download it and bind it to a key, for example Tux+V (Windows+V) or any other key you like.

Now always when I press Tux+V I get the contents of the copy buffer pasted exactly how I want it.

UDEV rule for USBASP

Again I got permission denied to access USBASP using avrdude. To fix this an UDEV rule has to be created.

A long time ago I created the file /etc/udev/rules.d/99-USB-AVR-PRG.rules with the following content:
# see:
# udevadm info -a -p /sys/bus/usb/devices/3-1
# After a change restart udev:
# systemctl restart udev.service

# borked rule
# Atmel AVR ISP mkII
#SUBSYSTEM=="usb", SYSFS{idVendor}=="03eb", SYSFS{idProduct}=="2104", GROUP="users", MODE="0660"

# usbprog bootloader
#ATTRS{idVendor}=="1781", ATTRS{idProduct}=="0c62", GROUP="users", MODE="0660"

# USBasp programmer
ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="05dc", GROUP="users", MODE="0666"

# USBtiny programmer
#ATTRS{idVendor}=="1781", ATTRS{idProduct}=="0c9f", GROUP="users", MODE="0660"

Most of the content is shamelessly copied and then commented out, then for me the only interesting line is the one for USBASP.

After copying the file I restarted UDEV with the following command:
systemctl restart udev.service

Now after plugging in USBASP the device should get the appropriate permissions.

How to Create a Verified E-Aadhaar Card PDF on Linux

The E-Aadhaar Card PDF which can be downloaded from the UID Authority of India contains a signature and some brain damaged verification code. In the middle of the page on the right side it shows “Not verified”, a yellow question mark and some more text about the digital signature. This question mark has to be clicked which then verification process. When this process is finished the question mark is replaced by a green tick and the text reads “Signature valid”. Since everybody just prints the page and deletes the file this verification process is completely superfluous. Since a smart ass wanted to save some money these documents are not signed by a proper key which makes the whole process a bit cumbersome.

The following steps show how to download the Aadhaar Card and convert it to a nice PDF:

Continue reading

LZWDecode a PDF File

Today I wanted to dissect a PDF file. Running pdf2ps quickly showed some big lumps of binary data. Looking a bit closer I found out that it is run through the filters ASCII85Decode and LZWDecode. After failing to decode this myself I searched again on the net and found the following blog entry:

Converting a PDF to PS without the LZWDecode filter

So just run the following commands:

qpdf --stream-data=uncompress original.pdf decoded.pdf
pdftops decoded.pdf

Avrdude Prints Part ID

Yesterday I saw the following error message of avrdude a bit too often:

avrdude: Device signature = 0x1e930f
avrdude: Expected signature for ATmega168 is 1E 94 06
Double check chip, or use -F to override this check.

Since I have a random mix of atmega 48, 88 and 168 and even some ‘p’ and ‘pa’ versions I often just try and get the error message. Then I try avrdude with some other part ID and often get more errors.

That’s why I wrote a patch (and log message) for avrdude (trunk @r1298). It just adds the device id to the output after the signature which has been found:

avrdude: Device signature = 0x1e930f (probably m88p)
avrdude: Expected signature for ATmega168 is 1E 94 06
Double check chip, or use -F to override this check.

This looks much better :)

Yes, I could use a microscope to read the part number from the chip but that’s too cumbersome. I prefer a solution where the software is telling me which part it is.

Reset Resolution of X Server after Program Crash

Today I played Warzone 2100. In the second mission in the beta camp I gave orders to build defenses, factories and other things. Then I loaded the transporter and started it to get to the missions map. But then the program crashed and left the X server in a pretty low resolution.

Now how do I reset the resolution?

Easy, the following line does the trick:

xrandr -s 1920x1080

You may have to choose the proper resolution for your monitor. Just entering xrandr without any options shows the available resolutions.

Running Python Application from Zip File

In the last few days I wrote a python application. It contains some GUI code using pygtk, some communication code, and some files containing register definitions. All in all it’s about 20 files.

Since most users will use it on windows it would be nice to have an executable or a package containing all code. I tried py2exe, but the resulting executable didn’t work. So I was searching for a different solution.

The solution should be:

  • Easy to distribute (one or two files).
  • Easy to create.
  • Work everywhere.

Continue reading

Manipulate PDF Files

A while ago I wanted to remove some pages from a PDF file. I was searching for tools to do that, but I didn’t find a solution. A few weeks ago I stumbled upon this blog post: Merge multiple PDF files into one file. There G33kgrrl describes a few of pdftk‘s functions. But it has quite a lot more functions. Read the manual to see what else it can do.

I hope I will remember this blog entry the next time I have to manipulate a PDF file ;)

Webserver gives a few kB and stalls

Today I wanted to download a few standards documents, about 15 PDF and ZIP files. But this stupid webserver always just sent between 100kB and 700kB, then it completely stopped sending data. This was annoying me. I wanted to look into these documents.

Don’t panic!

wget has a nice --continue option. This way I can hit CTRL+C and continue. repeating this until I have the whole file. But this is too cumbersome when downloading many and/or big files. I wanted a completely automated way to do that. And there is one, wget has many more options. Keep retrying forever and set the read timeout to 3 seconds:

wget --continue --tries=0 --read-timeout=3 URLS...

Tadaa! It downloads everything, problem solved :)