Thursday, October 30, 2014

thread safe generator.

Generators are not thread safe, this example triggers the error:


You can fix it with a lock, which is considered cheaper than using a queue.

Wednesday, October 29, 2014

Decoration, Pickle, Closure.

What is closure? What it has to do with pickle-able ? 

A closure occurs when a function has access to a local variable from an enclosing scope that has finished its execution.
Here is an example, test2 doesn't work because pickle works with name. test3 doesn't work because it conflicts with top-level function 'foo'



Pickle, Decorator. 

The decorated function has the same name as the original function, makes it un-pickle-able.

the right way to write a decorator function is to always use 'wraps'. Be able to pickled is crucial when you programming multiprocess.


Sunday, October 26, 2014

Solution of over sensitive touch pad, Linux

Install ubuntu on VAIO ultrabook. The large touchpad is too sensitive that it often register my palm.

The palm detection can be fine-tuned, but here is a solution if you don't need that large a touchpad, and you want to 'tap-to-click'

open a terminal, use the 'synclient' command to find the current setting of your touchpad. The LeftEdge, RightEdge, TopEdge, and BottomEdge tells you roughly the dimension of your touchpad.

then you can use 'synclient AreaRightEdge=5000' to reduce the dimension of your touch pad. You may want to finetune it yourself. If the number is too small, that might deactivate your touchpad, don't worry, just set it to a larger number.