brunotavares.net: ScrapBook

Notes. tech and a few thoughs

Google Analytics data from multiple profiles

If you ever need to get a integrated data report for multiple profiles you can get one here: http://gaevolution.appspot.com

Simple webinterface that aggregates multiple profiles from your GA account and produces a tabular report.

.. or you can always script arround the Data API

Tags:

Leave a Comment

Finding your Ubuntu version


$ cat /etc/lsb-release

Tags: , ,

Leave a Comment

Cloning VirtualBox disk images

If you hope that a simple copy will make it.. it doesn’t. Apparently the unique disk indentifier (UUID) is embbeded in the image file.


$ VBoxManage clonevdi sourceimage.vdi destimage.vdi

Leave a Comment

Visual Diffs

For some time now i started to notice the amount of time i wasted in solving version conflicts. The GNU diff works great with small change sets, but having a visual diff tool helps a lot when you’re dealing with long files with lots of diffs.

I used several visuall-diff-editors whit the several version-control software and i currently use Meld: it’s gtk, has in-line edition ( let’s you change the working copy with a real-time diff computing ) and its “command line diff” and diff3 compatible which makes it work smoothly with version-control software.

So, for the both version-control systems that i use currently here is my setup

SVN

For a quick diff using meld just run:

$ svn diff--diff-cmd meld

For a permanent setup edit ~/.subversion/config and set the diff-cmd to meld

GIT

Write a small wrapper:


#!/usr/bin/env sh
meld $2 $5

and the just configure svn to use the wrapper as diff tool

git config --global diff.external /path/to/wrapper

Tags: , ,

Leave a Comment

Pikeo::API 1.00

It’s now on CPAN: http://search.cpan.org/~bmavt/Pikeo-API-1.00/lib/Pikeo/API.pm

Project page still available: http://projects.brunotavares.net/projects/show/pikeoperlapi

Tags: ,

Leave a Comment

Maintaining your namespace clean in Perl

Some modules like XML::Simple export some functions by default into your namespace. Normally you don’t want this functions since the module has a OO interface; so, how to avoid the auto-export from taint your namespace ?

You can, at include time, be careful and explicitly tell the module not to export anything by doing this:


use XML::Simple qw();

But what if you are using a bunch of modules and you aren’t really sure of everything each one of them exports? You can either tell each one to export nothing ( qw() ) or you can use use namespace::clean.

namespace::clean defines a pragma that cleans up your namespace from exported functions. When you use the pragma all the exported functions to that point are cleaned-out from your namespace.

So if your using a lot of modules you can use it like this:


use strict;

use Foo;
use Bar;

use namespace::clean; #all Foo and Bar exported functions are cleaned out from your namespace

use Carp; #croak is available on your namespace

...

Tags:

Leave a Comment

If you use Live HTTP Headers for Firefox …

… you really should ckeck out HttpFox : https://addons.mozilla.org/en-US/firefox/addon/6647

It provides all the information that Live HTTP Headers do (and more, like request time tracking ) but with better organization.

Leave a Comment

Pikeo::API

At work we had the need to interact with Orange’s Pikeo service.

Pikeo is a Flickr like photo management/sharing service that has a REST API.

We ended up making a, object oriented, Perl wrapper for the API. The Perl API project is here, will be published to cpan as soon as we finish the documentation.

As always: comments , bugs and feature requests are welcome.

Tags: ,

Leave a Comment

svn and python

I still use svn for some projects, some of them are python.

Python pre-compiles the python files, so, the first time i run one of this projects i end up with a bunch of .pyc files that i don’t want to add to the repository.

Since svn doesn’t know this files the svn status generates a lot of garbage in the output.

svn has a property ( see svn properties ) called svn:ignore that tells svn to ignore certain files matching a pattern. The problem is that this property is directory/file based so you have to set it, at least, to every directory.

easy way to do this:

$ cd myproject
$ find . -type d | grep -v '.svn' | xargs svn propset svn:ignore "*.pyc"
$ svn commit

Tags:

Leave a Comment

Isolated Python environments.

I’ve a lot of code that depends on different versions of the same library, its quite hard to maintain the different versions installed in their specific dirs along with all their dependencies without tainting anything else.

To be able to run all of this code in one machine i’ve to make a lot of manipulation to the PYTHONPATH configuration. This is painfull and time-consuming. The plot thickens if i want to test some new version of the same library.

I found out virtualenv, this is a small python utility that bootstraps isolated python environments.

It allows you to maintain your application, libraries and all their dependencies in a isolated environment.

It also installs setup-tools in the virtual environment turning all your new libraries installations into painless tasks.

It comes with a set of handy scripts ( per-environment ) to activate and deactivate the environment so it’s quite simple to switch around environments.

Optionally you can make your environments inherit ( as a fallback ) the system site-packages and, with little effort, your enviromnents can be “relocatable” not being tied to any specific path which makes it possible to move them around your filesystem.

Tags:

Leave a Comment