### Archive

Archive for April, 2011

## knotify4 is eating up the CPU

Problem

Sometimes the process knotify4 eats up the CPU cycles. I don’t know exactly what it is good for and why it is launched when I use Gnome, but it’s there. How to get rid of it?

Solution

When I see this process running, I always kill it (killall knotify4). As a more permanent solution, I made it unexecutable:

sudo chmod 644 /usr/bin/knotify4
sudo mv /usr/bin/knotify4 /usr/bin/knotify4.bak   # update, the previous step was not enough


I hope that’s the end of the story :)

Update (20111013)

Just a few minutes ago my CPU was under heavy load again. I checked “top“, and guess who was the guilty one again? Right, knotify4. I had already renamed it to knotify4.bak but something (maybe an update) restored the /usr/bin/knotify4 file :) Damn… Maybe we should write a crontab job that checks once a day if this f* is there.

I found some info about knotify4 here. Apparently, “knotify4 is required for delivering all notifications in KDE, including sound, text to speech, visual, command execution and taskbar flashing…” But why does it want to burn the CPU? No idea…

Categories: ubuntu Tags: ,

## Ubuntu 11.04 Natty Narwhal

If you want to upgrade several machines, read this post. With this “trick” you can reuse the downloaded packages on other machines too.

Unity redefines F10. As I use Midnight Commander a lot, it’s quite annoying as F10 means “quit” in MC. A workaround is to use ESC + 0 in MC, but that’s a PITA. Also, I assigned something to F10 in vim… Here is how to disable F10 in Unity: (1) install compizconfig-settings-manager and start it, (2) filter “unity” and start the Ubuntu Unity Plugin, (3) edit “Key to open the first panel menu” and disable it. Now everything is back to normal.

With CTRL + ALT + T you can start a new instance of your default terminal emulator. I use terminator, so here is how to make it the default: click on the power button in the top right corner and choose “System Settings”. On the left side at the bottom you will see “Set Preferred Applications”. Start it, and under the System tab specify your favorite terminal emulator.

Want to monitor the RAM / CPU usage? Execute the following commands:

sudo add-apt-repository ppa:alexeftimie/ppa
sudo apt-get update
sudo apt-get install indicator-sysmonitor
indicator-sysmonitor &


I use this customized output: “| CPU: {cpu} | RAM: {mem} |”. To edit it, right click on the applet and choose Preferences.

Is the Dropbox indicator applet gone? Here you will find a fix.

Missing the weather indicator? Execute “sudo apt-get install indicator-weather“. (via webupd8)

Unity wallpapers with shortcuts: here.

After playing one day with Unity, I found one thing very frustrating: there is no bottom panel for the applications, so I never know what programs are running. I noticed that I was pressing ALT + TAB a lot… I was already thinking of switching back to Ubuntu Classic when I could figure out how to get the bottom panel back. You just need to launch “gnome-panel” and customize the new panel. Add it to your startup applications, this way it will be launched each time you log in. It also added a top panel that I removed (right click, delete). Customization: right click and add “Window List” and “Workspace Switcher”. Since this is a classic panel, you can add all those applets that are missing in Unity, for instance the “System Monitor”.

If you find the global menu (File, Edit, etc. are on the top panel like in MacOS) annoying, here is how to get rid of it (via webupd8):

sudo apt-get remove appmenu-gtk indicator-applet-appmenu indicator-appmenu


Log out and log back in to take it into account. (edit: same thing in 11.10)

Under Eclipse I had a strange problem. Sometimes it crashed with the error message “The program ‘Eclipse’ received an X Window System error.” I found the solution here. In short, I had two xulrunner instances on my system, versions 1.9.1 and 1.9.2. Fire up Synaptic and remove 1.9.1.

With Firefox, I also had some strange problems. I couldn’t drag and drop an URL from the location bar to the Bookmarks. Or, sometimes the popup menu activated with the right mouse button disappeared when I moved the mouse pointer above it. The following command solved these problems:

sudo apt-get remove firefox-globalmenu

If you don’t like the new overlay scrollbars, here is how to get rid of them:

sudo apt-get remove overlay-scrollbar liboverlay-scrollbar-0.1-0


This tip is from here.

Categories: ubuntu Tags: , , , , ,

## Daleya: search files on file sharing sites

Daleya is a meta search engine that searches on popular file sharing sites like Megaupload, Rapidshare, etc.

DaleYa.com tool is powered by Google Co-op ‘Google custom search’ (http://www.google.com/cse/?hl=es) to refine the results of a search performed by the user. The sole purpose of this website is to facilitate and refine Internet searches to users…

Categories: Uncategorized

Problem

Solution

1. “If you like flowers, you can’t be a bad person.” (idiom)
2. Darth Vader likes flowers. (see the images below [click for larger images])

Using deductive inference, the conclusion follows from the first two premises.

Categories: fun

android map exposes the data that Google has been collecting from virtually all Android devices and street view cars, using them essentially as global wardriving machines.

When the phone detects any wireless network, encrypted or otherwise, it sends the BSSID (MAC address) of the router along with signal strength, and most importantly, GPS coordinates up to the mothership. This page allows you to ping that database and find exactly where any wi-fi router in the world is located.” (source)

Based on Mato’s post on Facebook.

## LaTeX formula to image (PNG)

Problem

With LaTeX you produce a nice formula that you would like to crop and convert to an image.

Solution

Let’s see the following simple LaTeX source:

\documentclass{article}
\pagestyle{empty}

\begin{document}
$a^2+b^2=c^2$
\end{document}


Save it as file.tex and execute “latex file.tex“, which will produce a DVI output (file.dvi). The image conversion is done the following way:

dvipng -T tight -x 1200 -z 9 file.dvi -o file.png


Result:

Ref.: I saw this conversion technique in justinvh’s Markdown-LaTeX project. If your goal is to include LaTeX formulae in HTML, try his script.

Categories: latex Tags: , ,

## Glider Rider

Glider Rider is one of my favorite tunes on SLAY Radio. Among the several remixes, I prefer the Makke version the most. This song is like a time machine, brings me back to the ’90s when we were listening to Marusha, Dune, Scooter, Prodigy, etc. Today it’s “old school rave”. Damn, time is passing…

Lyrics: (from here)

As we sail across the sky
No longer visible to the eye
We are free from reality
We are the ones you cannot see

Keep on gaining altitude
Higher and higher, me and you
Until the Earth is a bright blue dot
Until each other is all we’ve got

Glider rider in the sky
Take me with you for a while
Life is so hard to live down here
Take me with you way up there

Glider rider in the sky
Take me with you for a while
Life is so hard to live down here
Take me with you way up there

Keep on gaining altitude
Higher and higher, me and you
Until the Earth is a bright blue dot
Until each other is all we’ve got

Glider rider in the sky
Take me with you for a while
Life is so hard to live down here
Take me with you way up there

Glider rider in the sky
Take me with you for a while
Life is so hard to live down here
Take me with you way up there

## Embed images in HTML pages

If you have a web page with some images, usually the images are stored in separate files. Would it be possible to include all the images in the HTML file, making a self-contained file?

Well, yes, with the help of the data URI scheme. “The data URI scheme is a URI scheme that provides a way to include data in-line in web pages as if they were external resources.

Example: (borrowed from here)

<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA
AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
9TXL0Y4OHwAAAABJRU5ErkJggg==" alt="Red dot" />


As you can see, the data can contain newline characters. If you put it an HTML file and open it with your browser, you’ll see a small red dot.

General format:

 data:<MIME-type>;base64,<data>


Script to produce it

I made a little script that can do this BASE64 encoding of image files. You can download it from here (img_to_base64.py).

Usage:
------

./img_to_base64.py <image_file>
By default, the data is nested in an HTML tag and the output
is wrapped. These settings can be customized.
The output is printed to the standard output.

Sample output:
--------------

<img class='inline-image' src='data:image/gif;base64,R0lGODlhIgAbAPMPAGxsbNbW1v
/rhf/ge//3kf/Ub9/f3/b29oeHh/7LZv/0juazTktLS8WSLf//mf///yH5BAAAAAAALAAAAAAiABsAA
ASA8MlJq7046827/2AojiTVnI1xlFZjBisruU7tPCiqjg2h/L9KA2HgCQS5pE7UGLgwAhyCWWjYrrWE
owFgJqyEsDi82HZDja/jyGaXuV7rYE6fv8+gtLXA7/OtcCEGSoQMUyEHAQgAjI2OAAgBIwcGAZaXmAE
7Mpydnp+goaKjFBEAOw==' />


Project idea

It could be interesting to write a script that transforms an HTML file into a self-contained file, i.e. replace all occurrences of ‘<img src="some_image" />‘ with an embedded base64 encoded data.

Ref.: I met this image inlining technique in justinvh’s Markdown-LaTeX project.

Categories: html, python

## Alarm script

Problem

I managed to reach a state that I don’t hear my alarm clock any more in the morning. Somehow I’ve become immune against it. So the problem is: how to get up in the morning? Well, the best way would be to go to bed early but it’s not that easy… So I made a simple alarm script that starts playing a list of MP3s at a given time.

You can get the script (alarm.py) from here.

Usage

./alarm.py -p
Play music. First do this to adjust volume! If the volume
is low, you won't hear it in the morning.

./alarm.py -t 7h15
Set alarm time. The format is HhM, where H is the hour
(24-hour system), M is the minute, 'h' is the separator.

./alarm.py
Set alarm with the default time. In my case it's 6h55.

Tip
If you want to jump out of your bed as if you had been shot out of a cannon, use the song Green Hornet. For me this is one of the most annoying songs ever. This song could simply kill me :)

Update (20110601)

Here are some tips How to Get Up Right Away When Your Alarm Goes Off.

Update (20110701)
The script was updated a bit. Now it can collect songs recursively too. When the alarm is activated, only the first 60 seconds of a song is played. Collected songs are played in a random order. If you use the -p option, songs are played from beginning to end (not just the first 60 seconds).

Tip: if you use it with “./alarm.py -p“, it works like a media player. It collects recursively all your MP3s from the specified folder and plays them in a random order.

Categories: bash, python Tags: ,