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.
Thursday, December 22, 2011
Monday, December 19, 2011
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).
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).
Labels:
electronics
Thursday, December 15, 2011
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)
Labels:
python
Wednesday, December 14, 2011
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
Labels:
mac,
matplotlib,
python
Monday, December 12, 2011
Bye bye eclipse, hello PyCharm and QT creator
I ditched eclipse for C when I found QT Creator. But I still kept it around for my python code, but it got annoying. Then I found PyCharm. I like it. Bye bye eclipse.
Labels:
ide,
python ide,
qt,
software
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)
Labels:
Ipython,
matplotlib,
numerical methods,
python
Friday, December 9, 2011
Wednesday, December 7, 2011
Mac OS Lion : install matplotlib
- Download source
- "Building mpl on Mac OS X is a nightmare" - John Hunter
- Use his very effective make.osx:
- sudo make -f make.osx PREFIX=/temp/build/dir PYVERSION=2.7 fetch deps mpl_install_std
- Remove old ~/.matplotlib directory (some weird warnings)
Labels:
mac,
matplotlib,
python
Tuesday, December 6, 2011
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)
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:
Solution:
Remove the key by doing
We know it is line 28, because that came up in the warning message.
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_hostsWe know it is line 28, because that came up in the warning message.
Labels:
commandline
Mac OS Lion
Things I like
- New tab in terminal opens in same folder
- Preview can make pdfs by stringing msic documents together
- Preview is sooo sluggish
- Preview messes up some transparency in pdfs
- No save as (gotta duplicate etc etc)
Saturday, December 3, 2011
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.
Thursday, December 1, 2011
++i OR i++ ?
From discussions on stack overflow we have:
++idoes not expect to return a value whilei++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
forloop - For an object (e.g. an interator), however,
++iwill be faster thani++because a compiler cannot optimize away the creation of a temporary object fori++
Subscribe to:
Posts (Atom)