Jul072008

Wine rocks my world

Ubuntu is probably the best Linux distribution out there, but sometimes you need to use software that’s only available on Windows. What do you do? Give Wine a chance. As its website states, Wine is a free implementation of Windows on Unix. Installation on Ubuntu is pretty straight forward, so you should not have problems installing it.

The above screenshot shows Wincachegrind working through Wine. Eventhough there’s a KDE version (haven’t looked for GNOME, which I run), I really needed the Windows version as it offers far more information than its Linux counterparts. With Wine, I installed the package with no problems, and I’m now using it as if it was a native Linux application. Awesome!

Bookmark and Share


Jul012008

Transparent Pidgin chat windows

If you have Ubuntu with the Compiz effects enabled, it’s pretty easy to control which application windows you want with some transparency. On this post I’ll show you how to set your Pidgin windows with a 90% opacity. Go to the Compiz settings manager by clicking System -> Preferences -> Advanced Desktop Effects Settings. On the window that shows up, click on the General category at the left category list, and then click on the General Options button at the right. Select the Opacity Settings tab. A screen similar to the following will appear:

We will create an Opacity setting for windows that match a certain condition. Click on the button New shown right below the Window Opacities list, and enter the following details for each shown field, and then click the Close button:

  • Opacity windows: class=Pidgin & !title=Buddy List

  • Opacity window values: 90

We’ve just specified that we want 90% opacity for all windows that have “Pidgin” at its class, but do not have “Buddy List” as a title. As you see, this procedure is not limited to Pidgin windows, so you can learn from the windows matching rules to apply different settings to different windows.

Thanks to Ryan for this post.

Bookmark and Share


Jun302008

Show what music you are playing on Pidgin

So you want the world to know what cool tunes you are currently listening to on your Ubuntu? Well, perhaps not the whole world, but at least your IM contacts. First thing you need is to be using Pidgin, and your favorite music player (I use Rhythmbox), since we will install a plugin to link our music player to our messenger. Open the Synaptic Package Manager (System -> Administration -> Synaptic Package Manager), click the button Search, and enter “pidgin-musictracker”. Right click on the available package (it should be just one), and select “Mark for Installation”. Click Apply.

If you are already running Pidgin, restart it. Once it has started, click on the Tools menu, option Plugins. Look for “MusicTracker”. Enable it by clicking on the checkbox. You can optionally select it and click on Configure Plugin to have more fun. That’s it!

Bookmark and Share


Jun272008

My desktop: Windows XP on Ubuntu through VMWare

Since I normally need to test different applications (almost all of them built with CakePHP) to make sure they work on different browsers (including IE7), I’ve recently installed VMWare over my Ubuntu Hardy to use Windows XP. This is how my desktop looks like when running it (click on the image to get the larger version):

You can see the excellent htop command showing that for some reason at that precise moment my Processor #1 was at 100% while Processor #2 was resting at a 15% :)

Bookmark and Share


Jun272008

Simple backup script for Ubuntu

Trying to prevent myself from another home fiasco, I’ve decided to build a simple script to backup some of my directories. There are a lot of scripts / backup tools out there, but I just wanted to build my own for the fun of it, and since what I really wanted was to create a tar.gz of the contents of a specific directory (no root path), including hidden files, and without the need to support incremental backups. Take a look at the script:

#!/bin/bash

function showHelp() {
	if [ "$1" != "" ]; then
		echo "ERROR: $1"
		echo ""
	fi

	echo "Usage: $0 <folder> <file.tar.gz>"
	echo "where:"
	echo "	<folder>	folder to backup"
	echo "	<file.tar.gz>	where to save the backup (.tar.gz file)"
}

if [ $# -ne 2 ]; then
	showHelp
elif [ ! -d "$1" ]; then
	showHelp "Directory $1 does not exist"
	exit 1
else
	echo -n "Creating $2 from $1: "

	if [ -f "$2" ]; then
		mv "$2" "$2.previous"
	fi

	tar -cpzf "$2" --exclude="$2" --ignore-failed-read --transform="s/"`echo "$1" | sed -e 's/^\\///g' | sed -e 's/\\/$//g' | sed s/\\\//'\\\\'\\\//g`"//" "$1" &>/dev/null

	if [ $? -ne 0 ]; then
		echo "ERROR"
		exit 1
	else
		echo "DONE"

		if [ -f "$2.previous" ]; then
			rm -f "$2.previous"
		fi
	fi
fi

The line that probably looks scary is:

tar -cpzf "$2" --exclude="$2" --ignore-failed-read --transform="s/"`echo "$1" | sed -e 's/^\\///g' | sed -e 's/\\/$//g' | sed s/\\\//'\\\\'\\\//g`"//" "$1" &>/dev/null

The complicated part comes from the transform expression, which is used to get rid of the absolute path to the directory we are backing up. The tar –directory option here is not useful since it adds the “.” special path to the packaged file, so let’s break it down:

  • echo "$1": the folder to backup
  • sed -e 's/^\\///g': remove starting slash, if any
  • sed -e 's/\\/$//g': remove trailing slash, if any
  • sed s/\\\//'\\\\'\\\//g`: convert forward slash to escaped slashes (so every / is replaced by \/)
Bookmark and Share


Jun172008

Delete files from command line to Trash in Ubuntu 8.04

I should’ve probably entitled this post “Learn from your mistakes”. Yesterday I was getting rid of the Windows partition in favor of a VMWare installation of Windows XP on my Ubuntu Hardy Heron (8.04) so I decided it was time to reclaim the space used by Windows and use it for my home partition. No biggie, I did everything right, and fast. Wait, so fast that I didn’t notice a big boo-boo:

$ rm -fR /var/backups/home/mariano; rm -fR /home/mariano.old; rm -fR /home/mariano

“You did what??” You ask.. Yup, that’s right, I wiped not only my Home directory, but every single backup copy I had of it. Granted, I didn’t have *much* on my home folder (except my evolution mail folders and some other documents), but I still wanted to shoot my hands for insisting in adding -fR to my rm commands (-fR means: delete recursively, and no, do not ask me for confirmation.)

So after trying without any luck to recover the deleted inodes, I’ve successfully re-setup my home folder starting fresh, which wasn’t so bad. In order not to mess up again, I’ve decided to add this little alias to my ~/.bashrc file:

# alias to make del send files to trash

alias del='mv -t ~/.local/share/Trash/files --backup=t'

So from now on, I just need to remember to use “del” instead of “rm”, like so:

$ del example.txt

The above command would send example.txt to the trash, instead of wiping it out from the file system. You can later on decide to Empty the trash in your Desktop, or undelete your files. The del alias also works for folders.

Bookmark and Share


Jun092008

Apache2 + PHP5 + MySQL + xDebug + SSL + SVN + Python + Trac on Ubuntu Hardy (8.04) 64 bits

After setting up Ubuntu Hardy 64 bits (also known as AMD64) on my PC I had to do what every developer needs to do every now and then: set up my working environment. This is not a hard thing to do on Ubuntu, particularly if you choose to go with precompiled packages, installing them through the friendly Synaptic Package Manager. However, I do like to keep a tight control on what is the base of my day to day work, so instead of using the built-in packages, I chose to build them from source. Once again, this is not hard, but it can bring some complications for 64 bits environments. As I may probably need to do this once again in the future, I’ve decided to blog this guide on how to install the following packages on Ubuntu 8.04 64 bits: Apache 2 (with SSL support), PHP5 with xDebug, MySQL 5, Python through mod_python, SVN (client and server), and Trac integrated with SVN.

Continue Reading »

Bookmark and Share


May282008

SVN rename all your CakePHP views from thtml to ctp

As I recently moved to Ubuntu 8.04 (plus CompizFusion + AWN which is rocking my world), I am now back to the good old days where bash was there to save my life. So basically I needed to SVN rename (also known as move) all my thtml views to ctp, recursively. Since this is a short tip, I’ll get down to the details. Just cd to your /views path in CakePHP, and issue:

for file in `find . -name "*.thtml"` ; do svn mv $file `echo $file | sed s/\.thtml/\.ctp/` ; done

After that you can safely commit. Enjoy!

Bookmark and Share


May072008

CakeFest #2 coming up

Mark your calendars: first week of December, 2008 is the time for CakeFest #2, the second official gathering organized by the Cake Software Foundation to cover your favorite topic: CakePHP. This time, instead of sunny California, we are gathering on an exciting (also sunny) location: Buenos Aires, Argentina.

CakeFest Argentina 2008 will offer lectures in English and Spanish, so everyone is welcome! We expect a high turnaround so if you have a company, sign up for a sponsorship spot to get the prospectus, and then select your sponsorship level. If you have an IT topic that you master and would like to share with other bakers, then submit your lecture proposal.

If you are not interested in speaking nor sponsoring CakeFest, then signup as a visitor to attend. CakeFest #2 is shaping to be an exciting PHP / CakePHP event, so you better be there!

Bookmark and Share


May062008

How a one week getaway turns into a month vacation

So there we were, planning a one week getaway to Munich for Oktoberfest. Drinking all that fine beer and coming back to wonderful Germany sounded like a great idea. So great, that we’ve been extending our plan by days at a time.

If we can change our return flight, we are now looking at a one month stay. The idea is to set initial camp in Bad Wiesseen, then Munich, Esslingen, and then even visit Prague and other locations. Are you in the area? We’d love to share a beer!

Bookmark and Share


 
Powered by Wordpress and MySQL. Clauz's design for by Cricava