Skip to content

Instantly share code, notes, and snippets.

@chris-taylor
chris-taylor / salary.py
Created June 2, 2013 17:03
Quick script to pull out salary data from indeed.co.uk and compute averages
# -*- coding: utf-8 -*-
import re
import sys
import locale
from bs4 import BeautifulSoup
from urllib2 import urlopen
@chris-taylor
chris-taylor / homebrew-opencv.log
Last active December 16, 2015 23:50
OpenCV failed to build on 10.7.5
This file has been truncated, but you can view the full file.
## Output of brew --config
crntaylor:opencv crntaylor$ brew --config
HOMEBREW_VERSION: 0.9.4
ORIGIN: https://github.com/mxcl/homebrew
HEAD: 7be8b458f96da9d37d009c1a96888419f646c7cf
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CELLAR: /usr/local/Cellar
CPU: quad-core 64-bit sandybridge
OS X: 10.7.5-x86_64
@chris-taylor
chris-taylor / mcode.matlab
Created May 3, 2013 14:27
Writes code that evaluates to a given Matlab object.
function code = mcode(x)
% MCODE Returns a char array containing Matlab code that evaluates to the
% object x. That is, the two quantities
%
% >> x
% >> eval(mcode(x))
%
% should be identical.
%
@chris-taylor
chris-taylor / em.lhs
Last active December 14, 2015 05:48
eilenberg moore category (wip)
Given a class representing covariant functors between categories
> import Control.Category
> class (Category hom, Category hom') => Covariant f hom hom' where
> cmap :: hom a b -> hom' (f a) (f b)
and a class for adjunctions
> class (Covariant f hom hom', Covariant g hom' hom) => Adjunction f g hom hom' where
@chris-taylor
chris-taylor / adjunction.hs
Created February 18, 2013 14:22
Adjunctions in Haskell
{-# LANGUAGE NoImplicitPrelude
, MultiParamTypeClasses
, FlexibleInstances
, FunctionalDependencies
, UndecidableInstances #-}
import Prelude hiding (id, (.))
import qualified Prelude
@chris-taylor
chris-taylor / ADT.hs
Created February 10, 2013 23:01
Code to accompany my series on algebraic data types.
{-# LANGUAGE FlexibleContexts, UndecidableInstances, RankNTypes, ConstraintKinds #-}
module ADT where
------------
-- Part 1 --
------------
-- The unit type '1', equivalent to '()'
@chris-taylor
chris-taylor / common.txt
Last active December 11, 2015 09:08
Quick script for counting up most common words in a text, ignoring very common words
the
be
am
are
is
was
were
been
to
of
@chris-taylor
chris-taylor / jsmath.js
Created June 11, 2012 21:41
jsMath inclusion
/**********************************************************************
*
* Customize the values given below to suit your needs.
* You can make additional copies of this file with
* different customizated settings if you need to load
* jsMath with different parameters.
*
* Load this page via:
*
* <SCRIPT SRC="path-to-jsMath/easy/load.js"></SCRIPT>
@chris-taylor
chris-taylor / em.matlab
Created December 5, 2012 10:07
Expectation Maximization
function em(X,theta)
% Expectation maximization, P coins
%
% X is TxN matrix of coin flip results (1 = heads, 0 = tails)
% theta is 1xP vector of probabilities (0 < theta < 1)
% Convergence criterion (relative difference)
tol = 1e-6;
% Compute parameters of distribution assigning coins to outputs
@chris-taylor
chris-taylor / US2012ElectionPredictions.txt
Created November 4, 2012 18:00
US 2012 Election predictions
State Winner Confidence
California DEM 100%
Connecticut DEM 100%
District of Columbia DEM 100%
Massachusetts DEM 100%
New York DEM 100%
Vermont DEM 100%
Maryland DEM 100%
Washington DEM 100%
Hawaii DEM 100%