Archive for the ‘uncategorized’ Category

Smoke-Free Banner

Friday, May 23rd, 2008
I just came up with a small PHP script that generates a simple "smoke free" banner that you can freely use in your website, or signature, or whatever.

Based on the information that you provide, the banner displays the number of days you have been smoke-free, the number of cigarettes you avoided and the amount of money you saved. For example, this is my smoke-free banner:




You can create your personal smoke-free banner here.

The idea is actually stolen from the "Smoke-Free QuitMeter Banner" originally created by "Josh Houghtelin of burnmytime.com & Erin S. Leadbetter", and you can find it here. The main difference is that QuitMeter generates a static image of your smoke-quitting statistics, while mine is generated on the fly (thus, the numbers will automatically be updated every time someone sees your banner).

what to do if Kino fails to import video files

Tuesday, May 13th, 2008
If you are trying to import non-DV files (such as AVI or OGG) into Kino, but you are only getting an error message, probably that's becuase you're missing ffmpeg, a program that is used by Kino to convert video file from non-DV formats to DV.

To fix this you only have to type:

# sudo apt-get install ffmpeg

The most likely is that you don't even have to restart Kino, just go ahead and just load the file, it should be working by now.

ubuntu: arrow keys make mouse pointer to move around

Saturday, May 10th, 2008
Today I discovered a nice feature in Ubuntu which allows you to move the mouse pointer using your numpad's arrow keys. You can even click using the middle '5' button.

However, this can be very annoying if you want to play a game or something, not only because you will have a mouse pointer running around the screen, but also because this feature actually steals the keyboard events, and possibly will cause your program to work improperly.

You can easily disable this feature by going to System → Preferences → Keyboard. Then go to the Mouse Keys tab. You will see a checkbox labeled as Allow to control the pointer using the keyboard. All you have to do is to make sure that you have this box unchecked. It should look like this:

disable-keyboard-mouse.png

GNOME Terminal ignores font rendering settings

Monday, May 5th, 2008
In the latest Ubuntu release, Hardy Heron, a bug in the GNOME Terminal causes the program to ignore the system's font rendering settings and instead uses its own.

I don't really know how to fix this in a proper manner, but I found something which is rather a work around on this problem, than a real solution.

You should try the following:

# cd /etc/fonts/conf.d
# sudo mv 10-no-sub-pixel.conf 10-no-sub-pixel.conf.1


The above command takes the 10-no-sub-pixel.conf out of the game. I prefer to rename the file than completely remove it, in case I want to get it back when the bug is fixed.

Restart your X Windows and try to open GNOME Terminal, which should be using your system-wide settings this time.

ubuntu: HP LaserJet 1018 is found but does not print

Monday, May 5th, 2008
Symptom:
You plugged in your printer. Ubuntu recognized it and displayed a message that your printer is ready for use. Then you send something for printing. Cups says that the job is being processed and eventually removed from the printing queue. However, you never see your printout coming. Your printer stays silent and idle all the time.

Diagnosis:
Some printers (including LaserJet 1018) are shipped with an incomplete firmware. These printers expect a working firmware to be sent from the operating system. However, due to licensing issues and restrictions the driver that comes with Ubuntu for this printer (foo2zjs) does not contain a firmware. Thus, the printer is essentially unusable.

Cure:
You will have to download the foo2zjs source code and build it yourself. You will also have to get yourself an appropriate firmware file. And that will fix it.

Here is the exact commands you have to type to get everything done:

wget -O foo2zjs.tar.gz http://foo2zjs.rkkda.com/foo2zjs.tar.gz
tar zxf foo2zjs.tar.gz
cd foo2zjs
sudo make uninstall
make
./getweb 1018
sudo make install
sudo make install-hotplug


The same procedure can be followed for all printers that are supported by the foo2zjs driver. The models currently supported are:

  • Minolta/QMS magicolor 2300 DL

  • Minolta/QMS magicolor 2200 DL

  • Konica Minolta magicolor 2430 DL

  • Minolta Color PageWorks/Pro L

  • HP LaserJet 1022

  • HP LaserJet 1020

  • HP LaserJet 1018

  • HP LaserJet 1005

  • HP LaserJet 1000

ubuntu: how to disable window snapping

Sunday, May 4th, 2008
The wobbling window effect is by far my favorite one from the plethora of compiz-fusion plugins. However, the window snap effect can be a bit of annoying sometimes and personally I prefer to disable it.

You may have tried to disable this feature by disabling the "Snapping Windows" plugin, but without the desired effect. Well, this is what you have to do: Start CompizConfig Settings Manager, go to System → Preferences → Advanced Desktop Effects Settings. The find the Wobbly Windows plugin (which should be enabled) and click on it to go to the plugin's setting screen. From the General tab, make sure you disable Snap windows and uncheck Snap Inverted. You should disable them both. It should look something like this:

disable-window-snap.png


And now you will be able to enjoy your wobbly windows without the annoying snapping.

compiz-fusion: switch from Metacity to Emerald

Thursday, May 1st, 2008
You can easily change your window manager from Metacity, compiz's default window manager, to the much more promising Emerald.

First you have to install Emerald:

sudo apt-get install emerald

Then you will have to tell compiz to load Emerald instead of Metacity. Edit your ~/.config/compiz/compiz-manager configuration file (create it if necessary):

gedit ~/.config/compiz/compiz-manager

Add the following line into the file:

USE_EMERALD="yes"

and save it. The next time your restart X you will have Emerald loaded instead of Metacity.

aftetris 1.11 (tetris clone for X11)

Thursday, May 1st, 2008
Since there is no "official" place for aftetris, my tetris clone for the X Window System, I'm posting a copy right here for whoever might be interested.

This is the download link: aftetris-1.11.tar.gz

Here you can watch a short video demonstration of the game:




To build the program simply type:

tar xvzf aftetris-1.11.tar.gz
cd aftetris-1.11
make


To install it in your system type:

sudo cp aftetris /usr/local/bin

To run the program type:

aftetris

The first time you run the program you will be asked to configure your keyboard settings. If you ever want to reconfigure the keyboard settings, type:

aftetris -customize

The game is good (I think) but the code sucks. However, I'm freely unfolding it in front of your eyes for you to revolt at the sight of it. Have tons of fun!

gcc: error: stray ‘\342’ in program

Thursday, April 17th, 2008
Lately I have been worried about a strange error message I have been getting from gcc, while trying to compile small C programs for my school's assignment.

The errors were of this form:

giannis@giannis-vbox:~$ gcc program.c
program.c: In function ‘main’:
program.c:57: error: stray ‘\342’ in program
program.c:57: error: stray ‘\200’ in program
program.c:57: error: stray ‘\234’ in program
program.c:57: error: stray ‘\’ in program
...


I couldn't see any obvious syntactical error in the mentioned line. This is how line #57 looks like:

printf(“\nThe linked list representation is...\n”);

At first sight, it looks pretty fine, but if you look closely you will see that the double quotation marks that surround the string literal are not the neutral (vertical) ones (like this: "). They are left and right double quotation marks respectively.

If I replace the quotation marks with the neutral ones, like this:

printf("\nThe linked list representation is...\n");

the problem is solved. So, if you are getting this kind of error maybe you should look closely to any double (or single) quotation marks in the erroneous line.

It is worth to say that I only had this problem when copying and pasting from the PDF files of my school, which were mostly likely exported by Micro$oft Word, which in turn had probably screwed the double quotation lines.

VirtualBox: access Windows-host shared folders from Ubuntu-guest

Wednesday, April 9th, 2008
This is the scenario that you run Windows as your host operating system and Ubuntu in a VirtualBox, and that you want to access a specific Windows folder from Ubuntu.

First you have to make sure that have install Guest Additions. From the VirtualBox's menu go to Devices → Install Guest Additions... This will mount a virtual CD on your /media/cdrom. Normally this folder's window will show up. As root run the program VBoxLinuxAdditions.run. When the program completes reboot your VirtualBox.

With Guest Additions installed you may now go ahead and define the shared folder(s). From the VirtualBox's menu go to Devices → Shared Folders. A dialog will show up. In this dialog you can specify which folder from your Windows system you want to share with your Ubuntu. Press the button with the + symbol to add a new shared folder in the list. You will have to specify a Folder Name for each folder you add. Make sure you memorize that name because you will need it very soon.

When done with you shared folder(s) specification, you may now go ahead and actually mount these folders from Ubuntu. First you have to create a mounpoint, that is, a directory in your Ubuntu which will reflect the shared folder from Windows:

# sudo mkdir /media/windows-share

Of course you may choose an alternative path for your mountpoint. With your mountpoint created you can now mount the shared folder, like this:

# sudo mount -t vboxsf folder-name /media/windows-share

Where folder-name will be the name you assigned for this folder when you were adding it in the shared folders list.

You could use the /etc/init.d/rc.local script to execute these commands on startup to have the shared folders automatically mounted every time you start your Ubuntu VirtualBox.