Search This Blog

Tuesday, December 13, 2011

I really like the interface to git provided by the GitHub guys: GitHubMac Home Page

Friday, August 26, 2011

Removing PackageKit

Finally I found how to remove the annoying "Command not found" message from the command line on fedora :
yum erase PackageKit

Sunday, August 21, 2011

Comparing E-mail Address Validating Regular Expressions

It seems there is NOT a unique way of validating an email address by a simple regexp;" From stackoverflow you arrive at different websites, among which there is that provides a php,java and C# package to check the email. Is neat also the trick of adding a + sign to the end of your email to a website, to track if they gave the email to someone else. Nice also the quote: be conservative in what you do, be liberal in what you accept from others. So do you still think parsing an email is easy ?

Saturday, August 20, 2011

Tuesday, August 9, 2011

Finding synonyms from the command line in linux

Just found Wordnet

A Dictionary-Thesaurus for Linux

To find a synonyms (useful when trying to find a meaningful name for an object ) just type

wn -simsv

Wednesday, July 27, 2011

Nice trick to get the memory usage of a python process

From: StackOverflow Question:

import os

def memory_usage():
    return next(line for line in open('/proc/%s/status'%pid).read().splitlines()
            if line.startswith('VmSize')).split()[-2]"

Thursday, July 14, 2011

How to decode Vorbis from a Webm audio stream

I had to decode audio in vorbis format from a webm file, here are some notes on what is involved in the process.

First of all you need to extract the AudioTrack from the WebM file.

Then from an AudioTrack Extract the privateData from it getPrivateData(size);

This PrivateData is the Header that libvorbis needs to initialize the internals of the VorbisDecoder

The VorbisDecoder needs 3 Ogg packets. This ogg packets have to be extracted from the PrivateData.

You have to unpack them as described in
Vorbis 3 Packets Specification (Xiph Laced format)

Then you are ready to follow the process described in :

Vorbis Decoding worflow

Pay attention that the internal buffer is limited so you have to call vorbis_synthesis_pcmout
after vorbis_synthesis_blockin. Always check for the return values of this functions.

The buffer returned by vorbis_synthesis_pcmout is in FLOAT32. To covert them to int16 you have to
multiply by 2 ** 15 - 1 and then clip them between - 2 ** 15 and 2 ** 15.

Pay attention to the number of channels as the data is stored as sample_ch1, sample_ch2, sample_ch1, sample_ch2.

Have fun !

Wednesday, July 13, 2011

Git Command

# How to list git untracked files
git ls-files --other --exclude-standard >> .gitignore

Tuesday, April 12, 2011

Logitech Control Center for Macintosh® OS X

Bought a new mouse, but the provided drivers does not work,
I had to download and install from:

Logitech Control Center for Macintosh® OS X

SELECT COUNT(grade) FROM table GROUP BY grade ORDER BY grade

How to create an histogram from a SQL database.

Wednesday, April 6, 2011

Installing PyTables On Fedora

Steps that I am doing to install PyTables on Fedora 10.
sudo yum install hdf5-devel
sudo yum install bz2-devel
sudo yum install lzo-devel
# optional : create and activate a python virtualenv
pip install -U numexpr

pip install

now the trick is to go inside the build directory (/build/tables if you are using a virtual environment)
and execute:

python build_ext -i
the you can simply do from the tables directory:
pip install -U .

Simulated Annealing

This morning I spent one hour refreshing the method of simulated annealing. I find very interesting how the association and explanation using thermodynamics terms makes the problem very easy to understand

Tuesday, April 5, 2011

Interesting approach to metadata in a file format

Reading Stackoverflow:

"tend to store metadata in a structure at the END of the file, not the beginning. This has two advantages:

Truncated/unterminated files are easily detected.
Metadata footers can often be appended to existing files without impacting their reading code."

To read the file simply seek to the end - sizeof(Metadata) and search for the magicString

Sunday, April 3, 2011

Cool tricks With Automator

After discovering the cool trick with latex on my previous post I played around a bit more with services.
And I discovered a new world.

Following the instruction from MidWinter :

I managed to create my own Convert Image service:

Here is how it looks like on my Automator:

A part from

OmniGraffle and Latex

Today I discovered something really really nice and useful.
Being a mix between an artist and a scientist, I use daily both OmniGraffle and Latex.

You can create latex images directly from OmniGraffle using the Latex services provided by


Saturday, April 2, 2011

How to upload images from your Computer to the Web

Well I was dealing with a lot of small images that you need to share around the internet in a quick and fast way, but also that are not really important to you like common life-picture.

Is there any good tool to upload quickly an image to some sort of pastebin for images website ?
Are there any good paste-image services on the web?

I liked the stackoverflow way of uploading pictures, and then I noticed the small link to their provider:

I registered in a breeze and ... surprise ! they have already tools to do what I need:
From the Tools Page:

A Google Chrome Extension:

I did not tried each plugin but I am very happy with this simple Macos Uploader :

Python PostgresSQL and puntuaction

I am experimenting some Database processing and as a simple test I want to query all the entries of a database that contains a given text.

What if the text contains quotes ?
Using psycopg2 the solution si to use adapt

Reading Stackoverflow answer and testing them myself the solution is to use the adapt function

from psycopg2.extensions import adapt

Wolfram at TED 2010

Good quotes from the Video of Wolfram at TED 2010

I really liked the phrase:

We're used to having science let us predict things.
But something like this is fundamentally irreducible. The only way to find its outcome is effectively just 
to watch it evolve.

The video that he shows contains pretty much mind blowing examples 

Video About Wolfram Alpha

I just finished to watch the introductory video about Wolfram Alpha
It mainly explained the main feature of the website and their main challenges in how to implement it.

I also liked the break down of their challenge:
  1. Data Acquisition
  2. Data Curation
  3. Linguistic Curation
  4. Dynamic Visualization
or as I translate;
  1. Get the information
  2. Extract the Good Information
  3. Make it understandable
  4. Make it attractive

Interesting sales data

While playing with WolframAlpha

I came up to this interesting data of retail sale per item, provided by the US govern census

Monthly & Annual Retail Trade

Nice shortcut to convert from PDF to EPS

From The continuing story of Mac OS X:

To convert pdf → eps (Mac OS X will only do (e)ps → pdf & pdf → ps),
- open the pdf in TeXShop, choose the 'Selection' tool in the Preview window toolbar
- select the desired rectangle (or all, either with ⌘-A or manually),
- choose 'Preview>Save Selection to File...', & save as eps."

Matplotlib: How to insert colored rectangle inside a label

Matplotlib: How to insert colored rectangle inside a label

import matplotlib
import matplotlib.pyplot as pyplot
import mpl_toolkits.mplot3d

figure = pyplot.figure()
figure.subplots_adjust(bottom=0.25, top=0.75)
axes = figure.gca(projection='3d')
xLabel = axes.set_xlabel('X', fontsize=14, fontweight='bold', color='b')
yLabel = axes.set_ylabel('Y',fontsize=14, fontweight='bold', color='r')
zLabel = axes.set_zlabel('Z',fontsize=14, fontweight='bold', color='g')

x = pyplot.Rectangle((0, 0), 0.1, 0.1,fc='b')
y = pyplot.Rectangle((0, 0), 0.1, 0.1,fc='r')
z = pyplot.Rectangle((0, 0), 0.1, 0.1,fc='g')

handles, labels = axes.get_legend_handles_labels()

plot = axes.plot([1,2,3],[1,2,3])

Friday, April 1, 2011

Accessing IplImage element of type IPL_DEPTH_16S in OpenCV - Stack Overflow

I wrote a little program in C to explain how pointers work:

Accessing IplImage element of type IPL_DEPTH_16S in OpenCV - Stack Overflow:

int main(){
char * pointer;

printf('%zu \n', sizeof(char));
printf('%zu \n', sizeof(signed short));
printf('%zu \n', sizeof(signed int));
printf('%zu \n', sizeof(float));

printf('%p \n',((char*)(pointer) + 10 * 5));
printf('%p \n',((signed short*)(pointer)) + 10 * 5);
printf('%p\n',(((signed int*)(pointer)) + 10 * 5));
printf('%p\n',((float*)(pointer)) + 10 * 5);


How to create a cython cpdef function with optional arguments
cdef class A:
    cpdef foo(self, int i=*, x=*)
And Cython now supports vector declarations
cdef class Node: 
cdef vector[Node] list2node():
cdef vector[int] test_int():
cdef vector[int*] test_intp(): 
static PyTypeObject *__pyx_ptype_3foo_Node = 0;
static std::vector<struct __pyx_obj_3foo_Node *> __pyx_f_3foo_list2node(void);
static std::vector __pyx_f_3foo_test_int(void);
static std::vector<int *> __pyx_f_3foo_test_intp(void);

Thursday, March 31, 2011

Useful gstreamer global variables directives


Global variables


Wednesday, March 30, 2011

Some useful tips about gstreamer


Saturday, March 26, 2011

Google Chrome Extension for Blogger

I just came across to this cool extension for chrome that allows me to directly post to blogspot.

Here is the link:$

Just Found out this cool Blogging dashboard from Google:

This widget has successfully logged in! Replace this text with your
first post.
<br class="khtml-block-placeholder">
<br class="khtml-block-placeholder">
You can use ⌘-B and ⌘-I to make text <b>bold</b> and

How to Create SSH Tunnels

Here is an example that works with synergy:
ssh -f -N -L localhost:24800:synergy-server:24800 synergy-server