Archive

Archive for March, 2013

cpq and mvq: extensions of the Unix commands cp and mv to use a queue

March 28, 2013 Leave a comment

Problem
You browse your hard drive(s) and you want to copy/move several files to somewhere else. If the files are big (e.g. movies), then you need to wait minutes until a copy/move operation finishes. If the files are in different folders, you cannot select them all. If you try to launch each operation in the background, your machine will get very slow since all these operations will run concurrently.

Clearly, copy/move operations should be put in a queue and the next operation should start when the previous one terminates.

Solution
Under Windows you have Total Commander (F5/F6, then F2), but how to do it under Linux? Should I use Total Commander with wine? :) Under Linux I use Midnight Commander but in MC I didn’t find this feature. There is another Norton Commander clone called Krusader that has this feature but I didn’t like it much. I prefer MC :)

So, I came up with the following solution: create two command-line scripts called “cpq” and “mvq” that work like cp and mv (actually they call cp and mv) but they put tasks in a queue. These scripts launch a daemon process if necessary that executes each copy/move operation one after the other.

The project can be found here (https://github.com/jabbalaci/Copy-Queue) where you can also find a description about its installation.

Update (20130403)
Pierre (alias Deimos) wrote about “cpq” and “mvq” in his blog in French: Copy-Queue : un manager de copie de fichiers en ligne de commande.

Categories: bash Tags: , , , , ,

number

March 27, 2013 Leave a comment

Today I found an interesting Unix command by accident. It converts numbers to English:

$ number 961428808
nine hundred sixty-one million.
four hundred twenty-eight thousand.
eight hundred eight.

It works with much bigger numbers too.

Categories: bash Tags:

Targus laser presentation remote works on Linux

March 21, 2013 1 comment

targusA few weeks ago I bought a Targus laser presentation remote, model AMP13EU. I can report that it works perfectly on my Ubuntu box. I tested it under Ubuntu 12.10 and 12.04.

The user manual doesn’t mention Linux :( It says it works with Windows and Mac OS so when I bought it, I was just hoping that it would work with Linux too. Thank God it works like a charm.

Technical details
After connecting its USB receiver, “dmesg” produces the following output:

[ 3150.204455] usb 1-1.6: new full-speed USB device number 4 using ehci_hcd
[ 3150.300357] usb 1-1.6: New USB device found, idVendor=1048, idProduct=07d3
[ 3150.300361] usb 1-1.6: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 3150.300364] usb 1-1.6: Product: Laser Presentation Remote
[ 3150.300367] usb 1-1.6: Manufacturer: Targus
[ 3150.302437] input: Targus Laser Presentation Remote as /devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.6/1-1.6:1.0/input/input19
[ 3150.302631] hid-generic 0003:1048:07D3.0005: input,hidraw4: USB HID v1.11 Keyboard [Targus Laser Presentation Remote] on usb-0000:00:1a.0-1.6/input0
[ 3150.305049] input: Targus Laser Presentation Remote as /devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.6/1-1.6:1.1/input/input20
[ 3150.305304] hid-generic 0003:1048:07D3.0006: input,hidraw5: USB HID v1.11 Mouse [Targus Laser Presentation Remote] on usb-0000:00:1a.0-1.6/input1
[ 3150.308158] input: Targus Laser Presentation Remote as /devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.6/1-1.6:1.2/input/input21
[ 3150.308331] hid-generic 0003:1048:07D3.0007: input,hiddev0,hidraw6: USB HID v1.11 Keyboard [Targus Laser Presentation Remote] on usb-0000:00:1a.0-1.6/input2

marker.to: annotate a webpage and share it

March 21, 2013 Leave a comment

Problem
There is a webpage with lots of useful information and you want to highlight/annotate some parts of it for future references.

In my current case, I want to watch the videos of PyCon US 2013 but I don’t have much time so it will take some weeks till I finish them. In the meantime, I don’t want to forget which ones I had already seen. It would be nice if I could add some custom notes to the webpage that lists the videos. In addition, I want to see/edit my annotations at home and at my workplace too, i.e. it should be web-based.

Solution
Marker.to is a browser extension that does exactly this.

Have you ever used a marker pen for highlighting your paper documents?

Marker.to will do the same for webpages! After you install a browser extension or bookmarklet and run Marker simply by clicking on the icon, you can highlight text on a website with your mouse.

Annotating helps to point out important information in long articles. Our annotator creates a special link for the highlighted version of the page (like http://marker.to/XYZ123). You can share it through Twitter, Facebook, e-mail, IM etc. Or just bookmark it with your favorite bookmarking tool, i.e. Delicious.

You can view highlighted page with any browser! No bookmarklet or browser extension is necessary for viewing.” (source)

Related Work

Symbolic links are not treated properly on Dropbox

March 12, 2013 Leave a comment

If you try to use symbolic links in your Dropbox folder, you’ll end up with a mess :( Here is a nice summary of the problems. It turns out that it’s because of a stupid decision that was made by Dropbox a long time ago.

If you want them to implement symlinks properly, please vote here.

Set difference between two files

March 8, 2013 Leave a comment

Problem
You have two text files, short.txt and long.txt, and long.txt contains some extra lines. Which are these lines? That is, you want to perform a set difference: L \ S.

Solution
You can do this with the “comm” command:

First, make sure that the two files are sorted. Then:

comm -23 long_sorted.txt short_sorted.txt

Example

$ cat as.txt 
sl-1215
sl-2112
sl-9023
sl-9029
$ 
$ cat bs.txt 
sl-1215
sl-2112
sl-9012
sl-9016
sl-9023
sl-9029
$ 
$ comm -23 bs.txt as.txt 
sl-9012
sl-9016
$

Find more examples on “commhere (like union, etc.)

Compile your own FFmpeg

March 5, 2013 Leave a comment

Problem
There are some great audio codecs for FFmpeg which are open source but not completely compatible with GPL, thus they are not included in the FFmpeg package that you can install from the official repositories.

Solution
If you want these codecs, you must compile your own FFmpeg.

Here you can find a nice description of the available audio codecs. Which one should you use? In short, they come in this order: libfdk_aac > libfaac > Native FFmpeg AAC ≥ libvo_aacenc, i.e. libfdk_aac provides the best quality.

You can download static builds from here but they don’t include libfdk_aac and libfaac either :(

Compiling FFmpeg
Fortunately, compiling FFmpeg under Ubuntu is quite easy. You just need to follow this guide.

I have an installer script for Ubuntu called jabbatron. The new version of this script includes (1) compiling FFmpeg, and (2) updating FFmpeg. They are available under the menu point “(170) install from source (mc, tesseract3, ffmpeg)…”. This script automates all the steps that are described in the aforementioned guide.

Categories: ubuntu Tags: , ,
Follow

Get every new post delivered to your Inbox.

Join 72 other followers