Skip to content

Instantly share code, notes, and snippets.

View wridgers's full-sized avatar

Will Ridgers wridgers

View GitHub Profile
@wridgers
wridgers / client.js
Created November 30, 2014 02:30
Possible faye bug?
var faye = require('faye');
var client = new faye.Client('http://localhost:8000/');
client.subscribe('/test', console.log);
client.publish('/test', 'Hello world.');
fact :: (Integral a) => a -> a
fact f
| f == 0 = 1
| otherwise = f*fact (f-1)
fac :: (Integral a) => a -> a
fac 0 = 1
fac n = n*fac(n-1)
det :: (Integral a) => [[a]] -> a
det matrix
| rows /= cols = -1
| rows == cols = 1
where rows = length (matrix)
cols = length (matrix !! 0)
removen :: Int -> [a] -> [a]
removen n arr =
let (x,y) = splitAt n arr
in x ++ tail y
@wridgers
wridgers / sql.php
Created August 14, 2011 10:54
Converting a CubeCart install to a PrestaShop install. Part 1.
<?php
function clean($in) {
// I used this function to rename things, since the conversation also required a name change.
$out = str_replace("Oldsite", "Newsite", $in);
return $out;
}
$source_database = 'dbname';
@wridgers
wridgers / bash.php
Created August 14, 2011 11:01
Converting a CubeCart install to a PrestaShop install. Part 2.
<?php
$source_database = 'dbname';
$source_server = 'dbserver';
$source_user = 'dbuser';
$source_pass = 'dbpass';
$source = mysql_connect( $source_server, $source_user, $source_pass );
mysql_select_db($source_database);
@wridgers
wridgers / go.sh
Created August 14, 2011 11:03
Converting a CubeCart install to a PrestaShop install. Part 3.
#!/bin/bash
file=$1
id=$2
echo Making 45x45
convert $1 -resize 45x45^ -gravity center -extent 45x45 ./out/$2-$2-small.jpg
echo Making 80x80
convert $1 -resize 80x80^ -gravity center -extent 80x80 ./out/$2-$2-medium.jpg
@wridgers
wridgers / rules.txt
Created December 10, 2011 18:18
Rules for C/C++ Turing Machine contest
-- RULES --
~ should be a single .c or .cpp file
~ must be written in C or C++ (C is a subset of C++)
~ entry must compile (of course)
~ must be a deterministic 1-tape TM as defined below
~ should accept the input string as a command-line argument (see Links for how to do this)
~ upon input, the program should output state:tape followed by a new line
~ the program should terminate once the state becomes H,Y, or N.
~ the delta function should be changeable (no hard coding the procedure!)
~ submissions should have a 'default' delta function that reverses the input string
@wridgers
wridgers / .tmux.conf
Created February 7, 2012 16:05
tmux config file
# Make it use C-a, similar to screen..
unbind C-b
unbind l
set -g prefix C-a
bind-key C-a last-window
# Reload key
bind r source-file ~/.tmux.conf
set -g history-limit 1000
@wridgers
wridgers / tlds.txt
Created March 3, 2012 23:14
A list of all internet top level domains, line by line.
.aero
.asia
.biz
.cat
.com
.coop
.info
.int
.jobs
.mobi