Dealing with spaces in filenames

As I always forgot how to properly deal with it when scripting things -.-, here is one solution on how to deal with spaces in file names and processing it properly in a loop.

find . -print0 | while read -d $'\0' i; do mv "$i" ./; done

Source: http://www.cyberciti.biz/tips/handling-filenames-with-spaces-in-bash.html


Fix/rescue broken video

To fix or at least do a partial rescue, one could try playing with this line:

mencoder -forceidx -oac copy -ovc copy /tmp/src.mp4 -o /tmp/dst.avi


Free music for commercial use

Moving data from an old google sheet to a new google sheet

My original intend to use a new functionality in google sheets on a sheet I already created with the old version. As I already had a lot of content I didnt want to rewrite everything. And I only wanted to add a few formulas using "COUNTIFS". And copy pasting from the old to the new didnt work.

Here is what did work for me to convert from old google sheet to a new google sheet:
In a spreadsheet created in the old version, click the down arrow next to a sheet tab and click Copy to…, and copy the sheet (and its contents) to a spreadsheet created in the new version.

You may find other solutions here:

Also google needs some versioning because "old" and "new" are not the best keywords to search for.

Kubuntu 13.10: Network not working after sleep

Here is the fix that worked for me:

Most awesome place to spend ones vacation

Is here


A hotel in Tenerife with its own weightlifting gym. So you have a weightlifting gym, Sun, pool, beach (I'm sure there is somewhere) and good weather. All you need.

Linux: ps to pdf lossless

I came to the requirement to convert pdf to ps. However I noticed ps2pdf without any options will do some compression which in my case largely reduced the quality. So I needed to find a way to do it lossless, here it is:

ps2pdf -dAutoFilterColorImages=false -dAutoFilterGrayImages=false -dColorImageFilter=/FlateEncode -dGrayImageFilter=/FlateEncode source.ps destination.pdf

Linux: merge two mp4 files

You may want to combine multiple mp4/m4v video files into one continuous video. In order to do this, you need to install the gpac library of programs onto Ubuntu. Open up Terminal and run:

sudo apt-get install gpac

This will install the gpac library. One of the programs included with it is MP4Box, which you can use to concatenate the video files. If you get an error like MP4Box: error while loading shared libraries: libgpac.so: cannot open shared object file: No such file or directory, then you need to link the shared library to /usr/lib:

sudo ln -s /usr/local/lib64/libgpac.so /usr/lib/libgpac.so

Now to convert your files, add -cat filename.mp4 for each of your files to this command, with -new combinedfile.mp4 as your output, combined file:

MP4Box -cat vid1.mp4 -cat vid2.mp4 -cat vid3.mp4 -new combinedfile.mp4

Resource: www.thetechrepo.com (almost a 100% copy from there - however I use my site as my personal lookup)

Linux: rotating a mp4 video

If you want to rotate a mp4 video file in any direction here is a simple one-liner:

mencoder input.mp4 -o output.mp4 -vf rotate=1 -oac mp3lame -ovc lavc

Where rotate could be:
              Rotates the image by 90 degrees and optionally flips it.  For values between 4-7 rotation is only done if the movie geometry is portrait and not landscape.

                 0    Rotate by 90 degrees clockwise and flip (default).

                 1    Rotate by 90 degrees clockwise.

                 2    Rotate by 90 degrees counterclockwise.

                 3    Rotate by 90 degrees counterclockwise and flip.

For more information use man mencoder.

Linux: convert flash video to mp4

Here is a simple one liner to convert flash videos (*.flv) to mp4:

ffmpeg -i input.flv -c copy -copyts output.mp4

kdenlive: cannot find mlt profiles

After doing a system update and starting kdenlive I got the a pop-up window with the message cannot find mlt profiles and a suggested path of /usr/share/mlt/profiles . After reinstalling melt and kdenlive and getting the latest versions etc I found out that I just should have looked for the correct path. On my system are two that I could use.  /usr/share/mlt-4/profiles and  /usr/share/mlt-5/profiles . Of course I chose the newer  /usr/share/mlt-5/profiles . It took awhile for me to figure that out.

If you have 2 mlt versions installed it is best to uninstall kdenlive and both mlt versions and then reinstall kdenlive and let the system solve its dependencies so it will install the correct mlt version (mlt-5 in my case).

Linux: Converting mkv to mp4

Converting mkv (Matroska) to mp4 (H.264) simply done on a command line using ffmpeg

ffmpeg -i source.mkv -vcodec copy -acodec libfaac -ac 2 -ab 128k output.mp4

You might want to adjust the bit rate.

VirtualBox: Resizing hard discs

First of all: dynamically allocated disk space does not mean that the disk will increase its size by itself beyond the maximum specified size.

I specified 20GB as max for one of my virtual boxes. This turned out to be too less for whatever reason. So I need to resize it. Here is how I did it:
Download SystemRescueCD from that link.
Create a new disk for that virtual machine with the new size. 80GB in my case (to be safe ;)). This can be done in VirtualBox by right clicking on the machine and select Settings. There you go to Storage->Sata-Controller and click on the add-disc-button.
After the disc is created add the SysteRescueCD ISO to the primary CD drive of the virtual machine.
Start the system and wait for the boot menu to appear. Select the first (default) boot option.
When it is booted type startx to get a graphical user interface. There you will presented a desktop with a terminal.
Start gparted from the terminal.
In gparted check whats the name of your old and your new hard disc. In my case the old was /dev/sda and new /dev/sdb.
Go to the terminal and execute dd if=/dev/sdOld of=/dev/sdNew. In my case dd if=/dev/sda of=/dev/sdb.
Wait till it is done (may take a while).
Exit the desktop and reboot.
Wait for the boot of SystemRescueCD and select default again.
Again: startx and then in the terminal start gparted.
Go to the new hard disc in gparted and resize it to your desired space (as it has the same size as the old disc now). After that logout and execute shutdown -h now.
In the VirtualBox main window remove the old hard disc and the SystemRescueCD. Set the new disc as primary hard disc.
Thats it.

Other Resources: http://forums.virtualbox.org/viewtopic.php?t=10348

Pdf manipulation from the command line (rotation and merging)

This is how to rotate:

pdfjam --suffix rotated270 --angle '270' --fitpaper 'true' --rotateoversize 'true' --batch *.pdf

A shortcut to pdfjam and all that stuff is pdf90 - see man pdf90.

And this is how to merge using ghostscript.

gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -sOutputFile=out.pdf *.pdf

Searching in gzipped files

Can easily done with zgrep. Use it just like you are used to use grep. So zgrep wordToGrep file(s). Another variation would be zcat fileName | grep wordToLookFor.

Read ext4 from windows

The tool to read your ext4 discs is ext2read. You need to run the tool as administrator (right click on the executable and select "run as administrator"). Have fun.

Linux disc formatting

These two guides where helpful to me:
Step by step change linux partition system id on fedora system. In other words: How to set up a specific file-system for your disk.
Make a external usb hard disk portable on linux and windows using vfat filesystem.

Linux: how to create a bootable USB stick

This guide demonstrates a good way to create a bootable USB device. The only thing which was irritating to me was the last part where it was said "How to make a USB drive bootable".

The table in there should (in my opinion) look like this:

umount /dev/sdX1 #X needs to be replaced by e.g. a,b,c (or any other partition you have mounted automatically. Check it with the mount command)
fdisk /dev/sdX #X can be e.g. a,b,c
#now we are in an interactive fdisk session
p   #print partition table
a   #activate partition (bootable)
1   #partition 1 is bootable
w   #write changes to partition table


Linux wlan drivers

Today I stumbled an old problem with one of my laptops. It is necessary to load the windows-wlan-driver to make it work. The second thing is to use ndiswrapper to load it. I guess for the most wlan-card it is enough to install the kernel-firmware package. But in other cases these actions need to be taken:
  1. Determine your wlan-card (as root type lspci -v and look for something that looks like wireless).
  2. Research for the windows-wlan-driver based on that data. Download it and transfer it to the target system.
  3. Go to the drivers directory.
  4. ndiswrapper -i driver.inf #if there is no ndiswrapper, you need to install it too
  5. ndiswrapper -l #to check if it did work (driver present, device present, should be found there somewhere)
  6. modprobe ndiswrapper #load the ndiswrapper module
  7. ndiswrapper -ma #make it load at boot and automatically load the hardware
Other resources: http://wiki.ubuntuusers.de/wlan/ndiswrapper

Enable num-lock at KDE startup

This is a nice thing to have (at least for me). So you can do:

Menu -> Configure Desktop -> Hardware -> Input Devices -> Keyboard -> NumLock on KDE startup -> Turn on
Menu -> System Settings -> Hardware -> Keyboard -> NumLock on KDE startup -> Turn on


Google sites and paypal buttons

I just found myself puzzling the paypal button for donations. So I came across that which gives a perfect fitting solution.

A simple solution would be a simple copy paste of the paypal-button-source-code into the html source code of the google site.

Another hint is: The resolution of a paypal button usually is width=125 and height=48 pixels.

So buttons will look like this (EUR):

Or like that ;) (USD)

Python and Qt: Compiling a *.ui file

Simply do:

pyuic4 -o target.py source.ui

You don't have pyuic? Then do (depending on your OS):
sudo zypper install python-qt4-devel
sudo apt-get install python-qt4-devel

Why do I write it here? Because I forget that all the time.

Vim: Reloading a file

Reloading can be done with the ":edit" command, without specifying a file name. If you have made modifications to the file and you do not care about them (they will be lost), you can use
":edit!" to force the reload.

For further reading:

:help :edit
:help :edit!
:help 'confirm'

Linux touchpad configuration

Gsynatpics is the graphical tool to change the behavior of a touchpad under linux OS. Glad it exists ;). For non GNOME users, you have to add gsynaptics-init in .xinitrc or .xsession.

ICQ login issue

I just ran into an ICQ login error. The error message on my linux messanger said that the password was wrong. But it turns out that the default login server "login.oscar.aol.com" just needs to be replaced by "login.icq.com".

Thanks goes to this page.