Instantly share code, notes, and snippets.

View monitor.sh
#!/bin/bash
pid=$1
echo "Watching for spot instance termination; will SIGHUP $pid if so."
while kill -0 $pid >/dev/null 2>/dev/null; do
if curl -s http://169.254.169.254/latest/meta-data/spot/termination-time | grep -q .*T.*Z; then
echo 'oh noes! telling caffe to snapshot.'
kill -SIGHUP $pid
fi
View fastfood.py
'''
Implementation of Fastfood (Le, Sarlos, and Smola, ICML 2013).
Primarily by @esc (Valentin Haenel) and felixmaximilian
from https://github.com/scikit-learn/scikit-learn/pull/3665.
Modified by @dougalsutherland.
FHT implementation was "inspired by" https://github.com/nbarbey/fht.
'''
View chi2 histogram SVM example.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View keybase.md

I hereby claim:

  • I am dougalsutherland on github.
  • I am dougalsutherland (https://keybase.io/dougalsutherland) on keybase.
  • I have a public key whose fingerprint is 8900 ABA1 C715 5902 C7E0 7DD3 D429 4787 32BA 67CC

To claim this, I am signing this object:

{
View scikit-learn rbf sampler.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View set_wallpaper.py
#!/usr/bin/python
'''
Script to set the OSX or Unity desktop background to the top picture from a
given subreddit.
NOTE: on OSX, sets it for the current space (on all monitors), but not other
spaces. There doesn't seem to be an AppKit API to change it for all spaces.
'''
from __future__ import division, print_function, unicode_literals
View check_repodata.py
#!/usr/bin/env python
from __future__ import print_function
import json
import os
import sys
def check(path, checksum=False):
if checksum:
from conda.utils import md5_file
missing = set()
View set_wallpaper.py
#!/usr/bin/python
'''
Script to set the OSX desktop background to the top picture from a given
subreddit.
NOTE: sets it for the current space (on all monitors), but not other spaces.
There doesn't seem to be an AppKit API to change it for all spaces.
TODO: set it in the sqlite db instead:
http://1klb.com/blog/desktop-background-on-os-x-109-mavericks.html/
View connect-keyboard.scpt
#!/usr/bin/env osascript
-- based on http://stackoverflow.com/a/23018886/344821
tell application "System Events" to tell process "SystemUIServer"
set bt to (first menu bar item whose description is "bluetooth") of menu bar 1
click bt
tell (first menu item whose title is "CMU keyboard") of menu of bt
click
tell menu 1
if exists menu item "Connect"
click menu item "Connect"
View fourier_coefs_mex.c
#include <mex.h>
#include <math.h>
#define INDEX_TYPE_ID mxUINT8_CLASS
#define INDEX_TYPE uint8_T
void get_fourier_coefs(const double * X, const INDEX_TYPE * inds,
const double * mins, const double * ptps,
int num_pts, int dim, int num_bases, int M,