Skip to main content

Posts

Showing posts from December, 2011

View markdown on Mac OS X

Use the Quicklook plugin from here . Simpy drop the QLMarkdown.qlgenerator to ~/Library/QuickLook or /Library/QuickLook Now whenever you select a markdown file (.md) it will format the file and show the formatted version to you through quicklook.

The "page flash" on the kindle

The "page flash" on the Kindle 4 - the sudden turning of all the pixels black and then white, before the page is displayed - occurs every 6 page turns. It seems to be necessary because a certain amount of 'dirt' accumulates inbetween - bold letters (and also normal text) seem to leave traces pixels around the edges of the letters after they have been wiped after a page turn. The 'flash' wipes these pixels out and makes the page look crisp again. I don't know if this is a flaw in the driver software, or a shortcoming in the e-ink display itself (that leaves the traces).

Quick state machine in Python

SM = { 'INTERTRIAL': {'TRIALSTART': 'TSTART0'}, 'TSTART0': {'TRIALSTART': 'TSTART1'}, 'TSTART1': {'TRIALSTART': 'INTRIAL'}, 'INTRIAL': {'TRIALEND': 'TEND0'}, 'TEND0': {'TRIALEND': 'TEND1'}, 'TEND1': {'TRIALEND': 'INTERTRIAL'} } nextstate = SM[currentstate].get(input,currentstate)

matplotlib installation

freetype2 http://download.savannah.gnu.org/releases-redirect/freetype/freetype-2.4.8.tar.gz ./configure make sudo make install libpng (http://www.libpng.org/pub/png/libpng.html) ./configure make sudo make install sudo easy_install matplotlib

Changing how numpy arrays are printed

Use numpy.set_printoptions . One of the things I like most about pylab (and numpy) is this flexibility, especially the summarization feature, which, when the array is very large, prints ellipses (...) instead of clobbering you with lines and lines of output. I like to set the threshold low (default is 1000) and I do this with pylab.set_printoptions(threshold=10)

Mac OS X install pytables and h5py

Install tables - need NumPy version 1.6 Get NumPy from sourceforge and install - need Python 2.7 Install python 2.7 on Lion, open new terminal (or refresh path) curl http://python-distribute.org/distribute_setup.py | python curl https://raw.github.com/pypa/pip/master/contrib/get-pip.py | python sudo pip install ipython sudo pip install tables need numexpr > 1.4.1,  Download anc ompile numexpr -> wants to compile using gcc-4.2 sudo ln -s gcc gcc-4.2 sudo pip install cython Get HDf5 from http://www.hdfgroup.org/ftp/HDF5/current/bin/mac-intel-x86_64/hdf5-1.8.8-mac-intel-x86_64-shared.tar.gz /configure and compile Copy the hdf5 folder whereever you want python setup.py build --hdf5=/path/to/hdf5 (from the unzipped source of h5py) sudo python setup.py install --hdf5=/usr/local/hdf5/ (in the unzipped dir of pytables) In contrast, to get h5py working on Ubuntu: sudo apt-get install libhdf5-serial-dev   sudo easy_install h5py

Dealing with strict key checking for SSH

Problem: While using sftp (or some other ssh related service) the following warning shows up and we can't use the service: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY! Someone could be eavesdropping on you right now (man-in-the-middle attack)! It is also possible that the RSA host key has just been changed. The fingerprint for the RSA key sent by the remote host is b0:a8:eb:30:ce:1a:0e:6a:4d:7a:6b:3a:0a:c6:27:60. Please contact your system administrator. Add correct host key in /Users/xxx/.ssh/known_hosts to get rid of this message. Offending key in /Users/xxx/.ssh/known_hosts: 28 RSA host key for web.sourceforge.net has changed and you have requested strict checking. Host key verification failed. Connection closed Solution: Remove the key by doing sed -i "28 d" ~/.ssh/known_

Mac OS Lion

Things I like New tab in terminal opens in same folder Preview can make pdfs by stringing msic documents together I don't like Preview is sooo sluggish Preview messes up some transparency in pdfs No save as (gotta duplicate etc etc)

Reading Plexon files into Python

Sample C code is at plx2csv , rather striaghtofrward reading of the plexon binary file Needed to load the data into Python, so looked at Boost.Python and pybindgen , but then decided that pickling the data from the c code and loading it into python scripts would be fine and so used The PicklingTools library.

++i OR i++ ?

From discussions on stack overflow we have: ++i does not expect to return a value while i++ might need to return a value. A modern compiler, for simple data types (i.e. integer) will treat the two the same if the context is right e.g. in a for loop For an object (e.g. an interator), however, ++i will be faster than i++ because a compiler cannot optimize away the creation of a temporary object for i++