Skip to content

Instantly share code, notes, and snippets.

@johntyree
johntyree / scree_plot.py
Created February 3, 2014 15:10
Create a scree plot showing eigval contribution
#!/usr/bin/env python
# coding: utf8
# GistID: 8785541
from __future__ import division
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
@johntyree
johntyree / big_O.py
Created February 10, 2014 03:57
Big Theta
#!/usr/bin/env python2
# GistID: 8910125
from numpy import array, log, linspace
from matplotlib import pyplot as plt
# http://en.wikipedia.org/wiki/Big_o_notation#Family_of_Bachmann.E2.80.93Landau_notations # noqa
n = linspace(1, 100)
fn = log(n) / log(5) # log_5(n)
gn = log(n) / log(3) # log_3(n)
@johntyree
johntyree / win_notify.py
Last active August 29, 2015 13:56
inotify substitute for Windows
#!/usr/bin/env python
# coding: utf8
# GistID: 8949940
from os.path import abspath, expanduser
def on_modify(path, callback):
""" Watch a path for changes by write time, recursively.
@johntyree
johntyree / optionModel.hs
Created February 13, 2014 05:40
Monte Carlo options pricing in Haskell
{-# OPTIONS_GHC -funbox-strict-fields #-}
{-# OPTIONS_GHC -fexcess-precision #-}
{-# OPTIONS_GHC -Odph #-}
{-# OPTIONS_GHC -O2 #-}
-- {-# LANGUAGE BangPatterns #-}
-- {-# LANGUAGE DoAndIfThenElse #-}
{-# LANGUAGE RankNTypes #-}
-- GistID: 8970316
@johntyree
johntyree / composable.py
Created April 18, 2014 20:16
Composable functions... kind of
#!/usr/bin/env python
# coding: utf8
# GistID: 11062517
from __future__ import division
import functools
import inspect
class composable(object):
#! /bin/bash
USER=tyree
FTPPASS=
HOST=john.bitsurge.net
SUBDIR="public"
if [[ "$1" == "-p" ]]; then
shift
SUBDIR="private"

chk

SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL';
CREATE SCHEMA IF NOT EXISTS `mydb` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci ;
USE `mydb`;
-- -----------------------------------------------------
-- Table `mydb`.`pubmed`
-- -----------------------------------------------------
another change
Section "Module"
Load "dbe" # Double buffer extension
SubSection "extmod"
Option "omit xfree86-dga" # don't initialise the DGA extension
EndSubSection
# Load "freetype" # This loads the font modules
Load "glx" # This loads the GLX module
EndSection