Skip to content

Instantly share code, notes, and snippets.

View danmackinlay's full-sized avatar

dan mackinlay danmackinlay

View GitHub Profile
#!/bin/sh
# 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
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 *
np.random.randn(i))
@danmackinlay
danmackinlay / gist:1954656
Created March 2, 2012 01:36
gpu kernel panic report
Fri Mar 2 11:04:59 2012
panic(cpu 0 caller 0xffffff7f80a87907): NVRM[0/1:0:0]: Read Error 0x00000100: CFG 0xffffffff 0xffffffff 0xffffffff, BAR0 0xc0000000 0xffffff8115c2d000 0x0a5480a2, D0, P3/4
Backtrace (CPU 0), Frame : Return Address
0xffffff811560ae70 : 0xffffff8000220702
0xffffff811560aef0 : 0xffffff7f80a87907
0xffffff811560af80 : 0xffffff7f80b77a64
0xffffff811560afd0 : 0xffffff7f80b77b24
0xffffff811560b030 : 0xffffff7f80e24749
0xffffff811560b170 : 0xffffff7f80b96bad
0xffffff811560b1a0 : 0xffffff7f80a91282
/*
* file-based loggers, because logging to a GUI window is no good when SuperCollide does its segfault thing.
*/
NullLogger {
/* this parent class provdes a black hole logger so that you can stop
logging without changing code. */
formatMsg {|msgs|
var stampedMsgs = msgs;
//A nil in the first msg argument will be replaced by a datestamp
msgs[0].isNil.if({
information and Phase Transitions in Socio-Economic Systems
Terry Bossomaier, Dan Mackinlay, Lionel Barnett...
\section{Introduction}
\label{sec:intro}
Diamonds are not a good very long term investment! They are steadily turning into graphite. It will take millions of years, but the most stable form of carbon at room temperature and pressure is graphite. Thus diamonds will undergo a phase transition to graphite, albeit over a very long timescale.
When we normally think of phase transitions we think of the states of matter, ice melting to water or water turning to steam. They are order/disorder transitions. In graphite the carbon atoms are linked together in layers. The layers can slide over one another giving graphite its excellent lubricant properties. In diamond the carbon atoms are linked together in a three dimensional structure with each carbon at the centre of a tetrahedron linked to carbons at all four corners. Thus carbon has to go through a major structural reorganization to change from diamond t
information and Phase Transitions in Socio-Economic Systems
Terry Bossomaier, Dan Mackinlay, Lionel Barnett...
\section{Introduction}
\label{sec:intro}
Diamonds are not a good very long term investment! They are steadily turning into graphite. It will take millions of years, but the most stable form of carbon at room temperature and pressure is graphite. Thus diamonds will undergo a phase transition to graphite, albeit over a very long timescale.
When we normally think of phase transitions we think of the states of matter, ice melting to water or water turning to steam. They are order/disorder transitions. In graphite the carbon atoms are linked together in layers. The layers can slide over one another giving graphite its excellent lubricant properties. In diamond the carbon atoms are linked together in a three dimensional structure with each carbon at the centre of a tetrahedron linked to carbons at all four corners. Thus carbon has to go through a major structural reorganization to change from diamond t
@danmackinlay
danmackinlay / bezier_smooth_plot.py
Created January 16, 2012 08:02
pure python bezier smoothing for matplotlib
"""
For http://stackoverflow.com/q/5255932
"""
def tangent_interpolate(index, x_array, y_array, dist=0.5):
before_index = max(index - 1, 0)
after_index = min(index + 1, len(x_array))
chord_vector_x = x_array[after_index] - x_array[before_index]
chord_vector_y = y_array[after_index] - y_array[before_index]
if dist>0:
@danmackinlay
danmackinlay / shrinkpdf.sh
Created November 25, 2011 02:11
reduce PDF file size by optimising it for screen viewing
#!/bin/bash
# copied from http://www.tatome.de/bliki/doku.php?id=projects:shrinkpdf
if [ $# -lt 2 ] || [ $# -gt 3 ]; then
echo usage: shrinkpdf \<filename\> \<resolution\> \[\<output\>\]
exit
fi
if [ ! -e "$1" ]; then
echo "$1" does not exist. Exiting.
@danmackinlay
danmackinlay / run_script_with_args.sh
Created November 3, 2011 05:12
Submit jobs with arguments to openPBS
#!/bin/sh
# Because OpenPBS is fucked, it cannot pass arguments to scripts, but only set environment variables.
# So we build this sophisticated functionality for ourselves, using a tottering monolith of subtle and
# hairy code that shows how functionality such as this might be accomplished despite
# the fierce difficulty, and yet how it is clearly such a shambolic affair that it can not possibly have seemed
# reasonable to provide as a service to users
#
# Usage:
# qsub run_script_with_args.sh -v 'PBS_COMMAND=ls -l'
exec $PBS_COMMAND
@danmackinlay
danmackinlay / gdmp.py
Created October 18, 2011 10:24 — forked from tkf/gdmp.py
Command line tool for google-diff-match-patch
#!/usr/bin/env python
"""
Command line tool for google-diff-match-patch
"""
from diff_match_patch import diff_match_patch
HTMLTEMP = '''\
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"