This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Fun with sequential differences | |
# @author [email protected] | |
# Recursion (hideous...or maybe I'm just bad at it) | |
function seqdiff!(x; top=NaN, differences=[]) | |
if isempty(x) | |
return [0, differences], sum(differences) | |
end | |
if isnan(top) | |
top = pop!(x) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
simple mssql -> csv file example using pymssql | |
@author [email protected] | |
""" | |
import csv | |
import datetime | |
import pymssql | |
from decimal import Decimal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% Resourceful.m | |
% A 'game of life' where aging is an emergent property of resource limits. | |
% (c) Jack Peterson ([email protected]), 4/21/2012 | |
% Setup: | |
% A single type of organism with a single resource type. | |
% Things live on an env_size x env_size grid. | |
% env is the environmental grid. | |
% haz is the hazards grid. Each time step, there is a probability haz(i,j) | |
% that an organism living at tile (i,j) will be killed. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% AutoFilter.m | |
% Estimates the autoregression kernel of a noisy input signal | |
% using a simple low-pass filter. | |
% (c) Jack Peterson ([email protected]), 2011 | |
% Variable definitions: | |
% tests: number of different corrupted signals to analyze | |
% its: maximum filter power to test on each signal | |
% noisemax: number of different noise levels to test | |
% nstd: standard deviation of white noise |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
A simple agent-based model of a financial market. | |
(c) Jack Peterson ([email protected]), 2012 | |
""" | |
from __future__ import division | |
from random import random, shuffle | |
import pylab as p | |
from collections import Counter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% AFTree.m | |
% "Anti-ferromagnetic" model for tree growth | |
% (c) Jack Peterson ([email protected]), 2011 | |
% Define an NxN grid (T), with each grid point big enough to hold one tree. | |
% Each element T(i,j) = 1 if there a tree has randomly started to grow | |
% there, and T(i,j) = 0 otherwise. | |
N = 100; | |
T = round(rand(N)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function licor = licorify(filename) | |
%% licorify.m converts .81x Licor files into a Matlab structure (licor), | |
% which is organized as follows: | |
% | |
% - licor.headers: Structure containing the 31-row header block from the .81x | |
% file; i.e., the 'TSource' data is stored in licor.headers.TSource | |
% | |
% - licor.footers: Structure containing the 23-row footer block, organized in | |
% the same way as licor.headers | |
% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function f = randarbmulti(x,y,N) | |
% RANDARBMULTI generates N random numbers from an arbitrary PDF, defined by | |
% vectors x and y. Modified from randarb.m (Dave Dykes) at: | |
% http://www.mathworks.com/matlabcentral/fileexchange/6506-obs-from-arbitrary-pdf | |
% | |
% (c) Jack Peterson ([email protected]), 4/21/2013 | |
cdf_y = cumsum(y); | |
sum_y = sum(y); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Example Authorize.Net transaction postback handler. | |
* Writes transaction records to a MySQL database. | |
* | |
* Uses the Authorize.Net PHP SDK, which can be found at: | |
* https://github.com/AuthorizeNet/sdk-php | |
* | |
* Example HTML form: | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
parse a text file and count the occurrences of words in the file | |
@author Jack Peterson ([email protected]) | |
""" | |
import sys | |
import math | |
import sqlite3 | |
def wordcount(data): |
OlderNewer