Search This Blog

Loading...

Thursday, January 21, 2016

Logging in Python

All you need to know about logging in Python: HERE!

Wednesday, December 16, 2015

OS X service for sublime text

Want to open a file/folder in Sublime Text from finder (or some other app)? OS X services to the rescue. I followed the instruction in this forum post and now I can open any file/folder in Sublime with a single button click. Ok, that's cool. But you know what's cooler? Keyboard shortcuts! You can add shortcuts to any service (e.g. the one you just created) in System Preferences -> Keyboard -> Shortcuts. Look inside the Services -> Files and Folder. Just click on it and add your preferred shortcut. Neat, right?

Tuesday, April 28, 2015

iPython notebook server via SSH tunnel

On the host:
$ screen
$ cd vEnv3/
$ source bin/activate
[eEnv3]$ ipython notebook --no-browser --port=8000 --ip=0.0.0.0
(detach screen: ctrl-A ctrl-D)
on the local machine
$ autossh -M 20000 -N -L 9000:host:8000 [username@]host

Learning by playing

I randomly came across this awesome website. It looks really interesting, but I don't have the bandwidth right now to spend time plying with those ideas. In particular, this article looks pretty interesting for my super-secret font project ...

Wednesday, April 22, 2015

Python Package Development

Context

I'm developing a few Python packages, which are obviously under version control (personally hosted GIT repo in this case, but that's not relevant). Now, the package is in active development, but I usually work in different machines: my personal laptop and workstations at the lab. In the lab machines I don't have root access, so I work on a virtualenv, where I can install python packages using pip install.

How?

To facilitate the development in every machine I work on, this is the basic setup:
  1. Create a setup.py file in the repo, to use setuptools to install the package (this will also help you if you want to use PyPI later on to distribute your package)
  2. Clone the repo in every machine you will develop/use your package
  3. For every machine:
    1. activate the virtualenv
    2. cd into the cloned repo
    3. Type python setup.py develop

Wednesday, March 11, 2015

Sunday, January 18, 2015

Rendering large datasets with matplotlib

This post provides a great solution for a common problem. Like the author, I always go for vector graphics for publications and posters. The problem is that some times these images are build using large datasets, which means large number of vector elements in the final image. This, in turn, makes browsing such document slow and painful (I've sure have stopped reading some articles due to unresponisveness). To overcome such problem, matplotlib offers a neat trick. Is possible to rasterize only selected elements in your figure, while keeping the rest vectorized. Read the post for more info.