Skip to content

Instantly share code, notes, and snippets.

View trengrj's full-sized avatar

John Trengrove trengrj

  • Brisbane, Australia
  • 21:48 (UTC +10:00)
View GitHub Profile
@trengrj
trengrj / turing.io
Created March 25, 2014 13:04
a turing machine simulator in the io language
// Simple representation of a turing machine
Machine := Object clone
Machine tape := list()
Machine rule := Map clone
Machine pos := 0
Machine state := nil
Machine moveLeft := method (
@trengrj
trengrj / autofocus.js
Created March 25, 2014 13:16
really simple task manager internals
var autofocus = autofocus || {};
autofocus.tasks = [];
autofocus.colours = {};
autofocus.save = function() {
localStorage.tasks = JSON.stringify(autofocus.tasks);
}
autofocus.load = function() {
@trengrj
trengrj / hamming.c
Created March 25, 2014 13:23
compute first 1000 hamming numbers
/*
* Program to compute the first 1000 Hamming numbers.
* i.e. numbers of the form 3**i4**j5**k.
* Challenge from programming Praxis:
* http://programmingpraxis.com/2011/08/30/hamming-numbers/
*/
#include <stdio.h>
#include <stdlib.h>
@trengrj
trengrj / DrawPane.m
Created March 25, 2014 13:55
objective-c example of detecting way points
//
// A sample from DrawPane.m/h
// Created by John Trengrove
//
#import <UIKit/UIKit.h>
@class Letter;
@class Dot;
@class AppDelegate;

Roads, Nodes and Automobiles

or 'How a sat-nav could use a graph database'


@trengrj
trengrj / notes.rb
Created January 18, 2015 09:44
smarter ls for a directory of text files
#!/usr/bin/ruby
require 'smart_colored/extend'
filter = nil
def usage
puts "usage: 'notes [filter]'"
end
# add some more command line options like -d for different directory
library("ggplot2");
library("grid");
theme_ice <- function ()
{
theme(
text = element_text(size=16, family="Ubuntu Condensed"),
plot.title = element_text(size=16, family="Ubuntu Condensed"),
legend.title = element_text(size=14, family="Ubuntu Condensed", face = "italic"),
legend.position = c(.9, .5),
ggplot(mpg, aes(x = cty, y = hwy, color = factor(cyl))) +
geom_jitter() +
labs(x = "City mileage/gallon",
y = "Highway mileage/gallon",
color = "Cylinders") + theme_ice()
cat stores.txt | jq '.[] | .store_state+","+.title' | tr -d '"' | header -a "State,Store" | csvsql --query 'SELECT State,count(*) AS Count FROM stdin group by State order by Count desc' | csvlook
var w = 500,
var h = 300,
var svg = d3.select("svg")
.attr("width", w)
.attr("height", h)
.style("background-color", "#fefefe")
.style("display", "block");
var circle = svg.selectAll("circle")
.data([19,30,18,20,22,29]);