Search This Blog

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.
From:
http://stackoverflow.com/questions/485409/generating-a-histogram-from-column-values-in-a-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 http://pytables.org/svn/pytables/branches/std-2.2


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

python setup.py 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
MacText:






Result:







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: Imguru.com

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

A Google Chrome Extension:

https://chrome.google.com/extensions/detail/ehoopddfhgaehhmphfcooacjdpmbjlao

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

http://cocoastep.github.com/uploadur/#9-about.png

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
matplotlib.use("TKAGG")
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()
axes.legend((x,y,z),("XXXXXX","YYYYY","ZZZZZZ"),'best')


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


pyplot.show()

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);
}

1
2
4
4
0x7fff5fc01084
0x7fff5fc010b6
0x7fff5fc0111a
0x7fff5fc0111a"

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: 
    pass
cdef vector[Node] list2node():
    pass
cdef vector[int] test_int():
    pass
cdef vector[int*] test_intp(): 
    pass
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);