Software Defined Radio

The owner of this blog is currently working on an cheap, open and powerful software defined radio solution called HackRF. This seems to be very exciting.

http://ossmann.blogspot.de/

Merge multiple pdfs into a single file

Ubuntu brings a nice package called “pdftk” for editing pdfs using the command line. This command joins multiple pdfs into a single pdf:

pdftk 1.pdf 2.pdf 3.pdf cat output 123.pdf

Here is another way to join pdf files, that only requires ghostscript:

gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=123.pdf 1.pdf 2.pdf 3.pdf

Using the commandline editor “sed” for batch renaming of files

Given a set of files, that all end with “.png.jpg”. We want to remove the “.png” from the filename. This can be done using the linux shell pipes and the commandline editor “sed”.

Examine this command: ls * | sed ‘s/\(.*\)png\.\(.*jpg\)/mv & \1\2/’ | sh

The interesting part here is of course sed ‘s/\(.*\)png\.\(.*jpg\)/mv & \1\2/’. The general syntax is “sed ‘s/patternToSubstitue/SubstituteBy/'”.

  • s means “substitute”
  • \(.*\)png\.\(.*jpg\) This splits the given string into a segment of arbitrary content \(.*\), another segment containing the fixed string “png.” and a third segment \(.*jpg\) consisting of a string with arbitrary content ending with “jpg”. The first and third part are dynamically created, so sed allows to reference them using \1 and \2
  • mv & \1\2 This part constructs a command that can be executed by the shell. The “&” references the original string passed into sed, the parts \1 and \2 are generated above and concatenated.

The result of this command is, that the substring “png.” is removed from all filenames in the current directory. Files that don’t match this pattern are not changed, because the mv command gets the same name as source and target file.

Imagemagick for batch processing of images

Imagemagick can apply a number of different filters at a time. In combination with the linux pipes it is possible to batch process a huge number of images.

The command below takes all images in the “data” directory and does the following steps:

  • Resize to 400×300 pixels
  • Transform to gray color
  • Apply a sepia effect to give the image an “old” style
  • Change (brightness,saturation,hue) from (100,100,100) to (100.35,100)

ls data/ | xargs -I {} convert data/{} -resize 400×300 -colorspace gray -sepia-tone 81% -modulate 100,35,100 -quality 60 {}.jpg

Show progress of “dd” process

The “dd” tool is very useful for cloning/backing up/erasing partitions and harddrives. However all these tasks take a long time and the “dd” command does not output status messages on the screen. You never know how much time the process will need to complete or how much data has already been processed.

Luckily there is a hidden way to get this information. Get a command prompt and enter the command below. Replace “Process-Id” by the id of the “dd” process, which can be obtained by “ps -A”.

kill -SIGUSR1 Process-Id

libusb couldn’t open USB device /dev/bus/usb/002/003: Permission denied.

The problem is, that libusb requires write access to USB device nodes. Check the entry

SUBSYSTEM==”usb”, ENV{DEVTYPE}==”usb_device”, MODE=”0664″

in the configuration file /etc/udev/rules.d/libusb.rules. If the file does not exist, create it. Adjust the entry to fit your needs. Maybe it is an alternative to add the current user to the group that has full usb access.

Using phplists with german special characters (Umlaute äöüß)

PHPList (http.www.phplist.com) cannot handle german special characters (Umlaute äöüß) in a standard installation. I followed some hints to fix that problem, and at some point it worked. I’m not quite sure which step really fixed the issue. The things I tried are:

  1. Include the german language file in the config.php.
  2. Make sure that the charsets in the phplists configuration is set to UTF-8.
  3. Edit the texts/german.inc translation file and change strCharSet to UTF-8
  4. Edit the admin/lan/de/language_info and set UTF-8 for charset.
  5. Open the database in phpMyAdmin and edit the phplist_message table. Set collation to utf8_general_ci.

EDIT: The PHPList version I used here is 2.10.17