Skip to content

Instantly share code, notes, and snippets.

@cbhl
cbhl / bad12-2.js
Created April 8, 2014 21:41
bad12-2.js
// move randomly
// var moves = map.getAdjacentEmptyCells(me.getX(), me.getY());
// getAdjacentEmptyCells gives array of ((x, y), direction) pairs
// me.move(moves[map.getRandomInt(0, moves.length - 1)][1]);
var idx = function(x, y) {
return (y * map.getWidth())+x;
};
var d = function dfs(x, y, visited, path) {
if (( x == (map.getWidth() - 2) ) && (y == 10)) {
return true;
@cbhl
cbhl / bad12-1.js
Created April 8, 2014 21:40
bad12-1.js
// move randomly
// var moves = map.getAdjacentEmptyCells(me.getX(), me.getY());
// getAdjacentEmptyCells gives array of ((x, y), direction) pairs
// me.move(moves[map.getRandomInt(0, moves.length - 1)][1]);
var Q = [];
var n0 = {
'c': [me.getX(), me.getY()],
'p': []
};
@cbhl
cbhl / keybase.md
Last active August 29, 2015 13:57
keybase.md

Keybase proof

I hereby claim:

  • I am cbhl on github.
  • I am cbhl (https://keybase.io/cbhl) on keybase.
  • I have a public key whose fingerprint is 2C2F A6FA B21D 9CFB 3C6B FAE7 E5C7 1B66 D926 4E76

To claim this, I am signing this object:

@cbhl
cbhl / dt.py
Created February 27, 2014 15:55
dt.py
import re
import sys
p = re.compile("([0-9]{1,2}/[0-9]{1,2}/[0-9]{2,4} [0-9]{1,2}:[0-9]{2}:[0-9]{2}( (AM|PM|am|pm))?)")
for x in p.findall(sys.stdin.read()):
print x[0]
@cbhl
cbhl / gist:7594398
Last active December 29, 2015 01:39
nomic-20131121-1.md

Nomic

Rules

Instance started 2013-11-21

Immutable Rules

  1. All players must always abide by all the rules then in effect, in the form in which they are then in effect. The rules in the Initial Set are in effect whenever a game begins. The Initial Set consists of Rules 101-116 (immutable) and 201-213 (mutable).
@cbhl
cbhl / gist:5944647
Created July 7, 2013 19:42
Sanity-checking CLOCK_MONOTONIC (v1).
#include <time.h>
#include <stdio.h>
// compile with:
// $ gcc -Wall -o time_loop time_loop.c -lrt
// make sure -lrt comes after specifying the .c file or it won't link
int rv;
struct timespec current;
struct timespec last;
@cbhl
cbhl / video_trimmer.py
Created October 13, 2012 21:50
Trimming a video in Python
from subprocess import Popen, PIPE, STDOUT
import subprocess
import math, sys
from time import sleep
from os import path, access, W_OK, R_OK, F_OK
def cut(movie, start, clip):
subprocess.Popen(["ffmpeg", #Calls ffmpeg program
"-ss",str(start), #Begining of recording, must be string
"-t", '30', #How long to record clip for, must be a string
@cbhl
cbhl / progtest.sh
Created October 8, 2012 23:29 — forked from jlfwong/progdiff.sh
Diff the stdout, stderr and return code of a program with known stdout, stderr, and return code
#!/bin/bash
# CS 343 - A#Q# Test Script
# by m9chang
# based on progtest.sh by m9chang
# based on progdiff.sh by jlfwong (available at https://gist.github.com/3829517)
retval1=0 retval2=0 retcode=0
# Method: run