Skip to content

Instantly share code, notes, and snippets.

View paul-english's full-sized avatar

Paul English paul-english

View GitHub Profile
@paul-english
paul-english / decision-tables.clj
Last active August 29, 2015 14:02
decision-tables.clj
;; http://en.wikipedia.org/wiki/Decision_tables
;; http://rosettacode.org/wiki/Decision_tables
;; this example is ported from the pico lisp example
(defn yes? [condition]
(print (str (first condition) "? "))
(flush)
(loop [reply (read-line)]
(cond
(contains? #{"T" "Y" "YES" "Yes" "y" "yes" "true" "1"} reply) true
@paul-english
paul-english / euclid.py
Created May 28, 2014 19:42
Intro to python
# A quick introduction to python for math students (Paul English <[email protected]>)
################################################################################
# Python Setup
################################################################################
# 1. Install python 2.7 (or 3.0, both should work well)
# 2. Install pip
# 3. Install numpy using the command line tool pip
# pip intall numpy
@paul-english
paul-english / fools-constant.clj
Last active December 31, 2015 05:19
Calculating for fools gold
(defn argmax [f coll] (reduce (fn [a b] (if (> (f a) (f b)) a b)) coll))
(defn fools-constant [C N]
(let [n (argmax #(mod % 1)
(for [n (range 1 N)] (* C n)))]
[n (/ n C)]))
(fools-constant Math/PI 100)
(fools-constant Math/E 100)
@paul-english
paul-english / gist:7029656
Created October 17, 2013 18:16
Angular resource doesn't bind urlParameters for
api = $resource('http://127.0.0.1/api/v1/:type/:id',
{
type: '@type'
id: '@id'
},
{
get: {method: 'GET'}
post: {method: 'POST', headers: {'Content-Type': 'application/json'}}
del: {method: 'DELETE', headers: {'Content-Type': 'application/json'}}
create: {method: 'POST', headers: {'Content-Type': 'application/json'}}
> summary(factor.train)
ACTION RESOURCE MGR_ID ROLE_ROLLUP_1 ROLE_ROLLUP_2
0: 1897 4675 : 839 770 : 152 117961 :21407 118300 : 4424
1:30872 79092 : 484 2270 : 99 117902 : 742 118343 : 3945
25993 : 409 2594 : 82 91261 : 721 118327 : 2641
75078 : 409 1350 : 71 118315 : 498 118225 : 2547
3853 : 404 2014 : 67 118212 : 400 118386 : 1796
6977 : 299 16850 : 66 118290 : 398 118052 : 1665
(Other):29925 (Other):32232 (Other): 8603 (Other):15751
ROLE_DEPTNAME ROLE_TITLE ROLE_FAMILY_DESC ROLE_FAMILY
@paul-english
paul-english / Gruntfile.js
Created July 1, 2013 17:11
Gruntfile that makes use of assemble
// Generated on 2013-04-18 using generator-webapp 0.1.7
'use strict';
var lrSnippet = require('grunt-contrib-livereload/lib/utils').livereloadSnippet;
var mountFolder = function (connect, dir) {
return connect.static(require('path').resolve(dir));
};
// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
@paul-english
paul-english / hack.coffee
Created June 5, 2013 21:16
Hubot hacker plugin
# Description:
# None
#
# Dependencies:
# None
#
# Configuration:
# None
#
# Commands:
@paul-english
paul-english / gist:4752760
Created February 11, 2013 04:58
Some work graphing a few probability distributions using d3.js
var probability = {
normal: function(x, mean, stddev) {
var y = (1 / (stddev * Math.sqrt(2 * Math.PI))) * Math.pow(Math.E, - (Math.pow(x - mean, 2) / (2 * Math.pow(stddev, 2))));
//console.log('normal', x, mean, stddev, y);
return y;
},
logNormal: function(x, mean, stddev) {
var y = (1 / (x * Math.sqrt(2 * Math.PI * Math.pow(stddev, 2)))) * Math.pow(Math.E, - (Math.pow(Math.log(x) - mean, 2) / (2 * Math.pow(stddev, 2))));
//console.log('logNormal', x, mean, stddev, y);
y = isFinite(y) ? y : 0;
@paul-english
paul-english / neural-life.coffee
Created January 31, 2013 01:43
Neural network based implementation of Conway's game of life
brain = require('brain')
life = new brain.NeuralNetwork()
assert = require('assert')
_ = require('underscore')
THRESHOLD = 0.35
SIZE = 10
class Matrix
state: []
@paul-english
paul-english / GenericTestPlan.tex
Created January 30, 2013 04:07
A build file that places any static files in the `files` directory into your jar file, and a latex template for writing tabled test plans.
\documentclass[12pt]{article}
\usepackage{graphicx}
\pagestyle{empty}
\setcounter{secnumdepth}{2}
\topmargin=0cm
\oddsidemargin=0cm
\textheight=22.0cm