Skip to content

Instantly share code, notes, and snippets.

View Sammons's full-sized avatar

Ben Sammons Sammons

View GitHub Profile
@Sammons
Sammons / init
Last active December 28, 2015 18:09
All the commands I ran when re-setting up Ubuntu
#swap cap+control http://askubuntu.com/questions/412576/swap-caps-lock-and-ctrl-in-ubuntu-13-10
#GIT
sudo apt-get install git
git config --global user.name "Dopaskulous magic"
git config --global user.email [email protected]
#RUBY
sudo apt-get update
curl -L get.rvm.io | bash -s stable --auto
@Sammons
Sammons / heap.js
Last active August 29, 2015 14:00
Javascript Heap
//takes an array, and a comparator for its elements
// e.g. function(a,b) {return a > b}
var heap = function(ary, comp) {
this.array = [];
this.comparator = comp;
this._swap = function(a,b) {
var tmp = this.array[a];
this.array[a] = this.array[b];
this.array[b] = tmp
@Sammons
Sammons / silly mips
Last active August 29, 2015 14:00
learning liger mips
.data
spec: .byte 'a','b','\0'
.text
main:
li $v0, 1 # Load 1 to $v0 so we tell the OS to print
li $t1, 5 # $t1 = 5
move $a0, $t1 # $a0 = $t1, because $a0 is value printed
@Sammons
Sammons / crude quicksort
Created August 5, 2014 02:53
quicksort.js
function quicksort( array, comparator ) {
var recur = function(left, right) {
if (left < right) {
var par = partition( left, right )
recur( left, par - 1 )
recur( par + 1, right )
}
}
var choose_pivot = function( left, right ) {
@Sammons
Sammons / monitor.js
Created September 25, 2014 05:41
Crude file monitor example
var express = require('express');
var clc = require('cli-color');
var fs = require('fs');
var EventEmitter = require('events').EventEmitter;
var util = require('util')
var http = require('http').Server(app);
var io = require('socket.io')(http);
var app = express();
@Sammons
Sammons / Makefile
Created November 30, 2014 23:41
junky gist to make two binaries
# compiler
# clang rocks, try it sometime
# clang, gcc, cc, etc.
CC = gcc
# these are C++ flags
# -std=c++11 -ggdb `pkg-config --cflags opencv`
CFLAGS =
# other includes you want in the command to compile

Keybase proof

I hereby claim:

  • I am Sammons on github.
  • I am sammons (https://keybase.io/sammons) on keybase.
  • I have a public key whose fingerprint is ECD9 204D 43AC 7442 E91F E701 ACCE B0D6 9D3F 775F

To claim this, I am signing this object:

@Sammons
Sammons / index-text-file.c
Created January 3, 2016 08:42
toy hash table of lines of text in a file
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct offset_node_s {
struct offset_node_s * next;
unsigned long offset;
};
typedef struct offset_node_s offset_node;
@Sammons
Sammons / SetGame.js
Last active October 13, 2022 01:20
set card game
"use strict"
var properties = {
'color' : [ 'red', 'green', 'purple' ],
'count' : [ 1, 2, 3 ],
'shading' : [ 'solid', 'striped', 'open' ],
'symbol' : [ 'diamond', 'squiggle', 'oval']
};
function Card(characteristics) {
@Sammons
Sammons / fuzzy_thinking.js
Created January 10, 2016 00:51
thinking about heuristic scoring for words against strings
var pretend_db = [
'hello guys lets hang out soon',
'hello ben',
'what is up?',
'hey when are you coming to the bay?',
'yo',
'when are we getting together?',
'hig',