Skip to content

Instantly share code, notes, and snippets.


dan mackinlay danmackinlay

View GitHub Profile
import numpy as np
from math import pi, log
import pylab
from scipy import fft, ifft
from scipy.optimize import curve_fit
i = 10000
x = np.linspace(0, 3.5 * pi, i)
y = (0.3*np.sin(x) + np.sin(1.3 * x) + 0.9 * np.sin(4.2 * x) + 0.06 *
# Converts a mysqldump file into a Sqlite 3 compatible file. It also extracts the MySQL `KEY xxxxx` from the
# CREATE block and create them in separate commands _after_ all the INSERTs.
# Awk is choosen because it's fast and portable. You can use gawk, original awk or even the lightning fast mawk.
# The mysqldump file is traversed only once.
# Usage: $ ./mysql2sqlite mysqldump-opts db-name | sqlite3 database.sqlite
# Example: $ ./mysql2sqlite --no-data -u root -pMySecretPassWord myDbase | sqlite3 database.sqlite
danmackinlay /
Last active August 29, 2015 14:12
Dirty hack to fake long exposure from a quicktime movie
import os
import tempfile
import subprocess
import skimage
from skimage import exposure
import as io
import argparse
import shutil
import numpy as np
danmackinlay / serialization.R
Created February 1, 2015 01:12
pas ssparse matrices between R and Python
View serialization.R
load.sparse.hdf = function (filename, path) {
idx = as.vector(h5read(filename, paste(path, "v_indices", sep="/")))
idxptr = as.vector(h5read(filename, paste(path, "v_indptr", sep="/")))
vals = as.vector(h5read(filename, paste(path, "v_data", sep="/")))
dims = as.vector(h5read(filename, paste(path, "v_datadims", sep="/")))
col.names = h5read(filename, paste(path, "v_col_names", sep="/"))
data = sparseMatrix(
danmackinlay /
Created August 26, 2009 04:05
load-monitoring script that pushes notifications to prowl when something goes wrong
#!/usr/bin/env python
load-monitoring script that pushes notifications to growl when something goes wrong
requires jacobb's prowlpy - and a prowl
account (
this version, with a "panic" function, is untested.
danmackinlay /
Created August 27, 2009 02:04
django- or FS-based contextmanager-friendly locks for python
various ways of acquiring cross-process locks on a string including a django one
needs test coverage, but won't get it here since I've just removed it from the project.
`with` statement requires python 2.5 or later; these may work as non-with statement doohickeys
django locks require version 1.0 or later to get the "force_insert" argument
danmackinlay / mysql_logger.lua
Created August 27, 2009 09:17
quick little script for mysql_proxy's lua interpreter to show you when queies start and end so you can see if some are timing out. helps if you don't have control of the server
View mysql_logger.lua
local log_file = 'mysql.log'
local fh =, "a+")
function read_query( packet )
if string.byte(packet) == proxy.COM_QUERY then
local query = string.sub(packet, 2)
local q = query
local cutoff = 160
if cutoff < #query then
q = query:sub(1, cutoff) .. "..."
danmackinlay / supervisord.ini
Created August 27, 2009 07:10
a supervisord minimal config for running e.g. a persistent process queue.
View supervisord.ini
command = /project_path/ process_queue
redirect_stderr = true
logfile = /var/log/supervisord.log
logfile_maxbytes = 50MB
danmackinlay /
Created September 3, 2009 05:37
syndicates private friend-feed groups with read-only public feeds
# −*− coding: UTF−8 −*−
quick/dirty private feed exposer
import settings
View index.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
<title>NetCultures blog test</title>
<style type="text/css" media="screen">
#header h1 {
color: pink;
#header {