Archive for the ‘Knowledge’ Category

SVN users, secure your web site!

Tuesday, September 29th, 2009

After reading this article I found I host one of the site affected by this security issue.

I.e. if your website has “.svn” folders (because you’ve forgot to exclude them from the zip or whatever) than your source code may be exposed to the anonymous users.

Two possible (and simple) solutions:

  1. Exclude “.svn” folders when publishing/deploying
  2. Add this to your Apache2 website configuration
    <Directory ~ ".*\.svn">
      Order allow,deny
      Deny from all
      Satisfy All
    </Directory>

Filling the MP3 player before going on vacation

Thursday, August 6th, 2009

Isn’t your MP3 player brand new? Would you like to go on vacation with a bunch of music but don’t have enough space?

It’s quite common to buy high definition MP3 today, but they take too much space especially if you don’t need such high quality while having your sun bath.

Lucky enough, you are a geek, so you know what’s a bash script.

So, create you collection, copying your MP3s in a dedicated folder, then run the following command

find -type f ! -name '*.low.mp3' -exec ffmpeg -i {} -ab 128K {}.low.mp3 \;

It will create 128k MP3 version of your collection (converting the format, if necessary)
When done, just delete the high quality version

find -type f ! -name '*.low.mp3' -exec rm {} \;

and copy the remaining on your MP3 player.

Wish you good vacation!

Setting up FoodMart on Mondrian

Monday, August 3rd, 2009

I don’t know either if I’m stupid or if the Pentaho developers are lacking of effort in helping poor conference speakers like me.

If you want to show someone the features of something, you have to set up a demo. And half the times these demos require data. And if you are setting up a demo for a business intelligence tool, data is essential!

Pentaho provides you with a dataset to use in demos and as a playground (thank you), but it’s quite difficult to set it up. An early adopter may judge this as project immatureness, while Mondrian is all but immature!

That’s what you need to set up the FoodMart database on PostgreSQL before demoing Mondrian (don’t try that with MySQL: it will take hours!)

First, locate a copy of these dependencies: log4j, eigenbase-xom, eigenbase-properties, eigenbase-resgen, commons-logging and postgresql-8.4-701.jdbc4.jar (or a suitable postgres jdbc driver): let’s say you have them in folder “mondrian/lib” and that you are in folder “mondrian”

Then write in a console:

java -cp .:lib/mondrian.jar:lib/log4j.jar:lib/eigenbase-xom.jar:lib/eigenbase-properties.jar:lib/eigenbase-resgen.jar:lib/commons-logging.jar:lib/postgresql-8.4-701.jdbc4.jar
mondrian.test.loader.MondrianFoodMartLoader
-verbose -tables -data
-jdbcDrivers=org.postgresql.Driver
-outputJdbcURL='jdbc:postgresql://localhost/mondrian?user=postgres&password=postgres'
-inputFile=demo/FoodMartCreateData.sql

Then wait for a minute.

Bah, maybe it’s just me, too comfy sat on ant and maven.

Speeding Firefox/Thunderbird start-up

Monday, July 13th, 2009

Having found and read this forum thread, I’ve modified the script to:

#!/bin/bash
username=$(whoami)

function check_app {
	proc="$(ps aux | grep $username | grep -v $0 | grep $1 | grep -v grep)"
	if [ "$proc" != "" ]
	then
		echo "!!! Shutdown $1 first!"
		exit 1
	fi
}

function vacuum_mozillas {
	echo "Vacuuming $1..."
	find $2 -type f -name '*.sqlite' -exec sqlite3 {} VACUUM \;
}

check_app firefox
check_app thunderbird
vacuum_mozillas firefox ~/.mozilla/firefox/
vacuum_mozillas thunderbird ~/.thunderbird

echo 'Done!'

While it sensibly improves start up times, don’t expect too much.

KVM: from disk image to LVM

Sunday, May 10th, 2009

In the beginning I was creating virtual machines out of physical ones, overbooking their size to make guests believe they had, say, 30G, while the hard drive just had 20.

With the passing of time, these disk images were growing and growing, and performances went lower and lower.

So I’ve followed this guide, and found a problem at paragraph 8: converting an image file into a raw LVM volume does NOT work, at least with the current version of KVM available on Debian Lenny.

The solution is quite simple, even if time and disk space consuming, and it came from this post.

First create a raw image file:

kvm-img convert disk0.qcow2 -O raw disk0.raw

Then DD it to the LVM volume

dd if=disk0.raw of=/dev/vg01/vm1 bs=1M

Voilą!

Fax through email, email through scanner, with Exim

Thursday, April 23rd, 2009

Just to share, and to write down a note for further reference.

The good:

  • I’ve a fax/scanner/printer that’s able to directly send via email what you scan
  • I’ve a email to fax service

The bad:

  • the only way you can write the email address on the printer is with an alphanumeric keyboard, like the one of a mobile phone
  • the destination address is in the form of
    NUMBER@my.verylongdomain.com
    so sending faxes is very slow

I needed to make that address shorter.

Thanks to Exim (the internal smtp server we use), I was able to map a shorter form of the previous address with the original.

On Debian lenny, I’ve added the file /etc/exim4/conf.d/router/050_exim4-config_forward_domain

forwarddomain:
driver = redirect
domains = f
data = $local_part@my.verylongdomain.com

Now my co workers can send emails to NUMBER@f and Exim will remap them to NUMBER@my.verylongdomain.com

HTH

Physical 2 Virtual: burying old Windows boxes

Saturday, November 29th, 2008

These are sad times, times I have to use and rely on Windows. Times my smiling co-workers say “Dunno!” every time their work suddenly stops working…
Anyway it’s good to see how linux is getting his way through.

In this period, we are getting greener by burying old windows boxes into KVM managed virtual ones. VMWare converter comes in handy for such tasks: just install the starter edition and follow this how to. Have it save the virtual machine on an external hard drive.

Once done, you’ll find as many .vmdk files as the hard drives you chose to convert. As the vmdk format is a public specification, KVM (son of qemu) supports it. Throw away the .vmx file, and run KVM with the VMDKs but be patient! Windows is a little more sensible than linux about hardware changes, so give your soon-to-be-virtual a run on your pc, just to be sure everything goes. Then copy the virtual images into your linux host, and schedule them to start right after boot (I’ve edited rc.local)

A couple of notes
Why Linux as a host? Because Windows runs faster when inside linux then when on it’s own hardware, and hard drives last longer.
Why not converting the services offered by those windows boxes to natively run on linux? That’s the second step: first I need to accumulate proofs of the quality of a linux environment. My smiling coworkers are sceptical.
Your host has no graphical environment: how do you manage the virtual boxes? Linux virtual boxes just need SSH: easy and fast. For the Windows ones, KVM can redirect the graphical output to an internal VNC server. So you can have a virtual machine bound to an IP address, delivering its services, while having a remote access by connecting a VNC Viewer directly to the host.

Still getting client-error-document-format-not-supported ?

Sunday, October 5th, 2008

I’ve wanted to set up a shared printer in my office where I run mixed boxes (both windows and linux), in particular I wanted to allow a windows box to print to a printer attached to a linux box.

Guess what? Error! Error! The document was in the queue but the printer kept idling.

CUPS “error_log” showed

Print-Job client-error-document-format-not-supported: Unsupported format ‘application/octet-stream’!

If you search that message you’ll find thousands of people telling you to uncomment two lines in CUPS configuration (even thou with recent Ubuntu it shouldn’t be necessary).
Problem is: that’s not enough!

The solution came reading this post in the ubuntuforums.

It seems that having the right driver on both boxes fools CUPS.
As I wanted the right driver on the linux box (it is its only local printer), I told windows to use a rawer one, “MS Publisher Imagesetter”, and that did the job.

printer_small.png

UPDATE
I’ve found that even the contrary solves the problem. Indeed it’s even better.

Set up the printer on linux as a raw queue and then use the right driver on windows.

Gentoo: bad for the environmentalist, good for the developer

Sunday, June 15th, 2008

Gentoo is a source based distro: usually, every software you need will be downloaded in source code form and compiled right on your box.
This opens up a whole set of optimizations, making Gentoo usually a bit faster than other distros, as it is more specialized and can take advantage of your own CPU instruction sets (think about MMX, SSE and 3DNow!).

These optimizations make some guy see Gentoo as an environment friendly distro: software is optimized, therefore less energy is required to accomplish the same task.

But even the less intuitive can understand that having a computer stuck at 100%, compiling for hours, it’s not really good for the environment.

Nonetheless, I still use Gentoo and I suggest using it to my coworkers. To me Gentoo is the perfect distro for every developer as it helps you understanding your box (and even the differences with other’s boxes, if you start contributing your ebuilds)
Understanding the main tool you (as a developer) use, will make you more efficient: you’ll start having answers to others questions, because you have seen your installation growing up, step by step.

That’s my point in using Gentoo: my box is in the palm of my hand. I know almost anything of it. I usually know why things happen, on the contrary of my coworkers, that waste time and productivity finding workarounds to things they don’t know.

Something that reflects the quality of their job, as they produce software that sometimes misbehaves.

If you want to be a good developer, start understanding your box now. Whatever operating system you use, shit is unlikely to happen: everything happens for a reason. If you think your OS makes it hard to understand, try another.

Juggling rhythm and motion

Wednesday, June 4th, 2008

I’ve just watched this beautiful video on TED.
If your eyes will closely follow the things he uses, you’ll be amazed by the 3D shapes he’s drawing in the air.
And you’ll learn something about learning, maybe recalling some old feeling.
Don’t want to anticipate, just sit and watch it