Skip to content

Instantly share code, notes, and snippets.

@snim2
snim2 / interp.py
Last active August 29, 2015 14:07
Pylab interpolation example
{
"metadata": {
"name": "Heatmap example"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
### Keybase proof
I hereby claim:
* I am snim2 on github.
* I am snim2 (https://keybase.io/snim2) on keybase.
* I have a public key whose fingerprint is 194B B3F0 4F1A 6987 24D6 ACED 46D2 1328 8DF5 C798
To claim this, I am signing this object:
@snim2
snim2 / err.sh
Created June 18, 2015 09:48
py.test error
$ py.test --version
This is pytest version 2.6.3, imported from /usr/lib/python2.7/dist-packages/pytest.pyc
snim2:2073(0):pydgin$ pip install --user -r requirements.txt
Downloading/unpacking pytest-cov (from -r requirements.txt (line 1))
Downloading pytest-cov-1.8.1.tar.gz
Running setup.py (path:/tmp/pip-build-ND85Ym/pytest-cov/setup.py) egg_info for package pytest-cov
Downloading/unpacking pytest-xdist (from -r requirements.txt (line 2))
Downloading pytest-xdist-1.12.tar.gz
@snim2
snim2 / stat.md
Last active August 29, 2015 14:26

stat.h

Based on: sys/stat.h

Field Size Offset Note
ST_DEV 2 0 dev_t is a u short
ST_INO 2 2 ino_t is a u short
ST_MODE 4 4 mode_t is a u int
@snim2
snim2 / gist:192726
Created September 24, 2009 13:19
Generic Makefile for OCaml projects
#
# Generic Makefile for OCaml projects.
#
# Sarah Mount
# September 2009.
#
# Code should be structured roughly like this:
#
# project /
# Makefile
@snim2
snim2 / fig.tex
Created September 24, 2009 13:24
Placement and scaling of figures with LaTeX and the graphicx package
%%% Figure placement and scaling with LaTeX and graphicx.
%%%
%%% Sarah Mount.
%%%
%%% Replace all UPPERCASE text with your own.
%%% To change scaling, replace the "0.6\columnwidth" with your preferred size.
%%%
%%% "Hhtbp" is the preference of the author for figure placement:
%%% Place _H_ere > Place _h_ere if possible > place at _t_op of page >
%%% place at _b_ottom of page > place on a _p_age of figures.
@snim2
snim2 / dis-example.py
Created September 24, 2009 15:01
Using the Python disassembler to analyse uncaught exceptions
>>> import dis
>>> 1 / 0
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ZeroDivisionError: integer division or modulo by zero
>>> dis.dis()
1 0 LOAD_CONST 0 (1)
3 LOAD_CONST 1 (0)
--> 6 BINARY_DIVIDE
7 PRINT_EXPR
@snim2
snim2 / tab2space.el
Created November 1, 2009 11:44
Convert tabs to spaces in Emacs
;;; Turn tabs to spaces
(defun tabs-to-spaces (&optional begin end)
"Turn all tabs in a region into four spaces."
(interactive "r")
(save-excursion
(if mark-active
(replace-regexp "\t" " " nil (point) (mark))
(replace-regexp "\t" " " nil (point-min) (point-max))
)
)
@snim2
snim2 / csp-pygame.py
Created November 29, 2009 01:11
Use a python-csp process to render images to Pygame
@process
def Drawme(channel, _process=None):
import pygame
# Constants
WIDTH, HEIGHT = 512, 256
# Open window
pygame.init()
screen = pygame.display.set_mode((WIDTH, HEIGHT), 0)
QUIT = False
while not QUIT:
@snim2
snim2 / spaces2tabs4.el
Created December 12, 2009 21:37
Convert spaces to tabs in Emacs
(defun four-spaces-to-tab (&optional begin end)
"Replace four spaces with a tab in a region."
(interactive "r")
(save-excursion
(if mark-active
(replace-regexp " " "\t" nil (point) (mark))
(replace-regexp " " "\t" nil (point-min) (point-max))
)
)
)