Skip to content

Instantly share code, notes, and snippets.

View lawrencejones's full-sized avatar

Lawrence Jones lawrencejones

View GitHub Profile
#!/bin/sh
# Add RVM to PATH for scripting
PATH=/usr/local/bin:$PATH
# Add brew sbin folder to path
export PATH="/usr/local/sbin:$PATH"
# Add npm locations to path
export NODE_PATH="/usr/local/lib/node_modules:/usr/local/lib/node:$NODE_PATH"
export PATH="/usr/local/share/npm/bin:$PATH"
function Point(x,y) {
return {x: x, y: y};
}
function Grid(initials, dimx, dimy) {
var points = [];
for (i = 0; i < dimx*dimy; i++) {
var enabled = true;
for (j = 0; j < initials.length; j++)
if (i == initials[j])
#!/usr/bin/env node
var http = require('http');
var argv = process.argv.splice(2),
truecount = argv.length,
pages = [];
function printUrls() {
if (--truecount > 0)
return;
@lawrencejones
lawrencejones / crossings.pro
Last active January 2, 2016 23:28
Imperial Prolog assessed Cwk
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% 276 Introduction to Prolog %
% %
% Coursework 2013-14 (crossings) %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% ------------ (utilities) DO NOT EDIT
@lawrencejones
lawrencejones / Make.config
Created February 3, 2014 17:44
Platform compatible
# -*- makefile -*-
SHELL = /bin/sh
VPATH = $(SRCDIR)
# Binary utilities.
# If the host appears to be x86, use the normal tools.
# If it's x86-64, use the compiler and linker in 32-bit mode.
# Otherwise assume cross-tools are installed as i386-elf-*.
@lawrencejones
lawrencejones / refresh.applescript
Created February 9, 2014 22:21
Applescript to refresh Google Chrome
tell application "Chrome" to tell the active tab of its first window
reload
end tell
################################################################################
# Seed data
################################################################################
CITIES = { # LAT, LONG
london: [51.5072, 0.1275]
manchester: [53.4667, 2.2333]
newcastle: [54.9740, 1.6132]
bristol: [51.4500, 2.5833]
southampton: [50.8970, 1.4042]
@lawrencejones
lawrencejones / c_prototype
Created February 16, 2014 22:37
Generates C function stubs
function! GenPrototypes(reg)
let fs=[]
let l:space = '\_s\{-}'
let l:keywd = '\(\(\w\+\s\+\)\+\)' . l:space ") #1
let l:rtype = '\(\w\+\)' . l:space ") #3
let l:fname = '\(\w\+\)' . l:space ") #4
let l:parms = '\((.*)\)' . l:space ") #5
let l:block = '\({\_.\{-}}\)'
let l:regex = l:keywd . l:rtype
\ . l:fname . l:parms
@lawrencejones
lawrencejones / Make.tests
Last active August 29, 2015 13:56
Makes test output colorful- yay\!
# -*- makefile -*-
include $(patsubst %,$(SRCDIR)/%/Make.tests,$(TEST_SUBDIRS))
# Colors!
GREEN =\e[01;38;5;82m
PINK =\e[01;38;5;197m
D =\e[01;37;40m
CLRCOL =\e[0m
@lawrencejones
lawrencejones / b2.coffee
Last active August 29, 2015 13:56
Implements priority donation according to the Imperial Pintos Specification (based on thread niceness and recent cpu time), using Round Robin ordering of threads
PRI_MAX = 63
RUN_TIME = 36/4
TIMER_INTERVAL = 4
TICKS_PER_SEC = 100
crrt = null
ticks = 0
create_thread = (name, nice, pri = PRI_MAX) ->
{ name: name, p: pri, n: nice, rcpu: 0 }