Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am notbend on github.
  • I am ben_d (https://keybase.io/ben_d) on keybase.
  • I have a public key ASCv8HI6qP1QyHY11uw092Tx4rdMGx2AfJB9AmG9OWK17Qo

To claim this, I am signing this object:

@notbend
notbend / update_state.js
Last active December 21, 2015 03:58
could this be done without making a copy of the entire object in the update method?
var Stateful = function(states, init_state) {
if (typeof(states) === 'number') {
this.states = [];
for (var i = 0; i < states; i++) {
this.states[i] = "_" + i; //prefix with _ (_0,_1,_2...) so state labels are strings
}
} else {
this.states = states;
}
this.state = this.states[init_state];
@notbend
notbend / gist:6169102
Created August 6, 2013 21:55
node hello world
var http = require('http');
var s = http.createServer(function(req, res) {
res.writeHead(200, { 'content-type': 'text/plain'})
res.end("hello world");
});
var Terrain = function() {
//TODO windows, sun, building colors
this.sun_x = 0.00;
this.sun_y = 0.00;
this.holes = Array(); //x,y
this.p1_pos = 0; //index of building
this.p2_pos = 7;
var has_p1_pos = has_p2_pos = false;
for (var i=0; i < 15; i++) {
if (i < 5 && !has_p1_pos && Math.random() > 0.6) {
@notbend
notbend / gist:6017962
Last active December 19, 2015 21:08
flat file atomic read/write in progress
require 'thread'
require 'time'
require 'csv'
class FlatfileDb
attr_reader :active_data
def initialize()
@active_data = Array.new
@sem = Mutex.new
end
#!/bin/bash
dir=$1
if [ -n "${dir}" ]; then
echo "Creating new git instance in ${dir}"
mkdir "${dir}"
mkdir "${dir}/app"
mkdir "${dir}/config"
mkdir "${dir}/test"
@notbend
notbend / console output
Created June 5, 2013 03:54
mariaDB post install instructions
[ben@haro ~]$ sudo pacman -S mariadb
resolving dependencies...
looking for inter-conflicts...
Packages (3): libmariadbclient-5.5.31-1 mariadb-clients-5.5.31-1 mariadb-5.5.31-1
Total Download Size: 16.51 MiB
Total Installed Size: 153.10 MiB
:: Proceed with installation? [Y/n] Y
@notbend
notbend / fac.hs
Created May 11, 2013 08:04
factorial function in haskell
factorial :: (Integral a) => a -> a
factorial 0 = 1
factorial n = n * factorial (n - 1)