Skip to content

Instantly share code, notes, and snippets.

View npinto's full-sized avatar

Nicolas Pinto npinto

View GitHub Profile
--- configure 2011-03-23 18:17:28.000000000 -0700
+++ configure 2011-03-23 18:21:28.000000000 -0700
@@ -2864,7 +2864,7 @@
die "swig did not return version information"
fi
if [ `echo $_swig_version | cut -f 2 -d '.'` -ge 4 ] || \
- [ `echo $_swig_version | cut -f 3 -d '.'` -ge 29 ]
+ [ `echo $_swig_version | cut -f 3 -d '.'` -ge 29 ] || [ `echo $_swig_version | cut -f 1 -d '.'` -ge 2 ]
then
echores "`${SWIG} -version 2>&1 | grep Version | cut -f 3 -d ' '`"
@npinto
npinto / gist:1055274
Created June 29, 2011 23:32
Joblib Bug when using Parallel and Memory(...).cache'd functions
from math import sqrt
from joblib import Memory, Parallel, delayed
mem = Memory('tmp')
@mem.cache
def sqrt2(v):
return sqrt(v)
print Parallel(n_jobs=4, verbose=True)(delayed(sqrt2)(i**2) for i in range(10))
@npinto
npinto / gist:1081475
Created July 13, 2011 22:25
tmux burn script
#!/bin/bash
set -e
set -x
# -- if a session 'burn' already exists, re-attach
tmux ls | grep '^burn:' && tmux attach -d -t burn && exit 0
# -- otherwise create it
tmux new-session -d -s burn htop
@npinto
npinto / gist:1082998
Created July 14, 2011 18:00
nose_multiproces_patch
diff -r 274adce935a2 nose/plugins/multiprocess.py
--- a/nose/plugins/multiprocess.py Thu Jul 14 11:01:35 2011 -0500
+++ b/nose/plugins/multiprocess.py Thu Jul 14 21:21:21 2011 -0400
@@ -33,9 +33,13 @@
Controlling distribution
^^^^^^^^^^^^^^^^^^^^^^^^
-There are two context-level variables that you can use to control this default
+There are three context-level variables that you can use to control this default
behavior.
@npinto
npinto / rr64x-linux-src-v1.0__for_kernel_2.6.39+.patch
Created August 31, 2011 05:11
Patch for HighPoint rr64x (rr64x-linux-src-v1.0, tested on linux-2.6.39-gentoo-r3) | Fix "error: too many arguments to function ‘blkdev_get’" or "linux/config.h: No such file or directory" issues, among others...
diff --git a/osm/linux/os_linux.c b/osm/linux/os_linux.c
index cf30c4b..0c6fe51 100644
--- a/osm/linux/os_linux.c
+++ b/osm/linux/os_linux.c
@@ -260,7 +260,7 @@ void refresh_sd_flags(PVBUS_EXT vbus_ext)
struct block_device *bdev = bdget(MKDEV(major[i], minor));
if (bdev &&
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28)
- blkdev_get(bdev, FMODE_READ)
+ blkdev_get(bdev, FMODE_READ, NULL)
@npinto
npinto / theano_sgd.py
Created September 7, 2011 16:23
TheanoSGDClassifier
# Example of a BaseEstimator implemented with Theano.
# This could use the GPU, except that
# a) linear regression isn't really worth it, and
# b) the multi_hinge_margin Op is only implemented for the CPU.
#
import numpy as np
try:
import theano
from theano import tensor
except ImportError:
@npinto
npinto / cairo_test.py
Created September 30, 2011 06:32
cairo_test.py
import cairo as C
from math import pi
width, height = 400, 250
output = "circle.png"
surf = C.ImageSurface(C.FORMAT_RGB24,width,height)
ctx = C.Context(surf)
# fill everyting with white
#!/usr/bin/env python
import numpy as np
from scikits.learn import linear_model
from dldata import hongmajaj # Hong & Majaj Neuronal Datasets module
# -- random number generator
rng = np.random.RandomState(42)
# -- dataset object
@npinto
npinto / gist:1753068
Created February 6, 2012 16:19
CUDA 4.1 on Ubuntu
# -- Toolkit
(cd /tmp && wget http://developer.download.nvidia.com/compute/cuda/4_1/rel/toolkit/cudatoolkit_4.1.28_linux_64_ubuntu11.04.run)
(cd /tmp && sh cudatoolkit_4.1.28_linux_64_ubuntu11.04.run --noexec --target ./cudatoolkit)
(cd /tmp/cudatoolkit && ./install-linux.pl auto)
# -- SDK
(cd /tmp && wget http://developer.download.nvidia.com/compute/cuda/4_1/rel/sdk/gpucomputingsdk_4.1.28_linux.run)
(cd /tmp && sh gpucomputingsdk_4.1.28_linux.run --noexec --target ./cudasdk)
(cd /tmp/cudasdk && ./install-sdk-linux.pl --prefix=/usr/local/cuda/sdk --cudaprefix=/usr/local/cuda)
@npinto
npinto / gist:1818999
Created February 13, 2012 18:45
boots
#!/bin/bash
PJT=$HOME/venv/hongmajaj_ht_vs_neurons
set -e
set -x
test ! -d ${PJT}
mkdir -p ${PJT}
virtualenv ${PJT}