Search This Blog

Saturday, April 2, 2011

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

Thursday, March 31, 2011

Useful gstreamer global variables directives

GST_DEBUG
python:5
GST_MEMDUMP:3
GST_PERFORMANCE:0
GST_DATAFLOW:*


Global variables

GST_PLUGIN_PATH
GST_PLUGIN_SYSTEM_PATH
GST_DEBUG_DUMP_DOT_DIR
GST_DEBUG_NO_COLOR

Wednesday, March 30, 2011

Some useful tips about gstreamer


self.player.get_state(timeout=3*gst.SECOND)

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.

http://www.google.com/support/blogger/bin/answer.py?hl=en&answer=41452

Here is the link:

http://www.google.com/support/chrome/bin/static.py?page=guide.cs&guide=27542&topic=27543&answer=173$

Just Found out this cool Blogging dashboard from Google: http://www.google.com/macwidgets/

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
<i>italic</i>.

How to Create SSH Tunnels

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

Wednesday, September 1, 2010

Synergy-Plus configuration

I often use my laptop together with a main desktop.
To save time i share the keyboard and the mouse utilizing a small utility called Synergy
that was introduced to me by my colleague Miki Tebeka

Assuming two computers: one MacOS - macbook pro and one PC Windows 7 and
I want to use the mouse and keyboard of the Windows machine:

The configuration on windows to be a server is quite tricky:
Options t; Add the network name of both the computer:
FMILO-DESKTOP
FMILO-MACOS
and then add
 0-100 % of left of FMILO-DESKTOP to 0-100% of FMILO-MACOS
 0-100 % of right of FMILO-MACOS to 0-100% of FMILO-DESKTOP

Here 0 - 100 % means how much of the side as a line should be sensitive to the mouse crossing.

To debug the session is quite useful to look at the log console while in Test Mode: Just right click (on Windows) in the dock icon and set show log Messages.

Hope this is helpful to someone else.

Friday, March 19, 2010

Prefix Sum on CUDA

Is not as trivial as it seems. I just finished to implement one and I can tell what you need
read the scan Gpu Gems 3 Article in particular chapter **39.3.1 Stream Compaction**.

To implement your own start from the LargeArrayScan example in the SDK, that will give you just the prescan. Assuming you have the selection array in device memory (an array of 1 and 0 meaning 1- select 0 - discard), dev_selection_array a dev_elements_array elements to be selected a dev_prescan_array and a dev_result_array all of size N then you do


prescan(dev_prescan_array,dev_selection_array, N);
scatter(dev_result_array, dev_prescan_array,
dev_selection_array, dev_elements_array, N);

where the scatter is


__global__ void scatter_kernel( T*dev_result_array,
const T* dev_prescan_array,
const T* dev_selection_array,
const T* dev_elements_array, std::size_t size){

unsigned int idx = blockIdx.x * blockDim.x + threadIdx.x;
if (idx >= size) return;
if (dev_selection_array[idx] == 1){
dev_result_array[dev_prescan_array[idx]] = dev_elements_array[idx];
}
}

for other nice application of the prescan see the paper Ble93

Otherwise you can use the CUDPP library where such primitives exists and are highly optimized even more that the sdk one.

Tuesday, March 16, 2010

New Blog Visual scheme

Reading the latimes today I found this new cool feature for customizing blogger appearance.
This is a fist update version, when I have more time I will play more with. Well done google!

Saturday, March 13, 2010

C++ Tricky

Nothing better than a bit of C++ for breakfast:
Reading A StackOverflow post I hacked a bit with an Object called SaveRestore.
The trick is to know that when the object gets out of scope { }, is destroyed.
You need to maintain a reference to the object and its value.

Thursday, March 11, 2010

Many Core and Reconfigurable SuperComputing Conference

I will speak at the Many Core and Reconfigurable SuperComputing Conference in Rome the 22-24 March 2010
with a talk entitled
A GPU Based Architecture for Distributing Dictionary Attacks to OpenPGP Secret Keyrings
To see all the other exciting talks: http://www.mrsc2010.eu/Programme