Skip to content

Instantly share code, notes, and snippets.

@esommer
esommer / jquery_game.md
Last active April 20, 2016 13:48
starter instructions for making a game board and moving a character around

Use javascript & jquery to make a video game

We'll have a "gameboard" div, a character div, and use buttons as our "controllers" to start with:

<div id="gameboard">
    <div id="character"></div>
</div>
<ul id="controls">
    <li id="left"><</li>
    <li id="up">^</li>
Array [250/1862]
(
[0] => Array
(
[name] => user_id
[type] => terms
[style] => bucket
[nested] => Array
(
[0] => Array
<?php
$tree = [
["field" => "A", "nested" => [
["field" => "B", "nested" => []]
]],
["field" => "C", "nested" => [
["field" => "D", "nested" => [
["field" => "E", "nested" => []]
]],
["field" => "F", "nested" => []]
@esommer
esommer / gist:7668128
Created November 26, 2013 23:24
Solution to exercise from Mary's seminar: (we didn't need to be "return"ing all our outputs, just executing them is enough.
var http = require('http');
var fs = require('fs');
var DAY = "day";
var NIGHT = "night";
var server = {
getFile : function (path, filetype, res) {
fs.readFile(__dirname + path, 'utf8', function (err, data) {
res.writeHead(200, { 'Content-Type': filetype });
@esommer
esommer / js_stack.js
Created October 11, 2013 22:39
Implementation of a stack and cheaty stack in JavaScript. (NOTE: I stupidly deleted my testing code... I need to rewrite it (better) and put it back in. Apologies!)
var assert = require("assert"); // node needs this module
// CHEATING STACK (using built-in functions):
function CheatingStack () {
this.contents = [];
}
CheatingStack.prototype.push = function (item) {
this.contents.push(item);
};
@esommer
esommer / first_attempt
Last active December 21, 2015 22:09
Small, messy start to a Markov Chain problem that I tackled to play with and begin learning Python. Goal: Script reads text file and outputs sentences using vocabulary of that text and probabilistic determination of next words. Notes: (Ideas for where to improve / what I want to tackle next) - BUG: Sometimes it can't find a word in the dictionar…
import random
def text_to_paragraphs(file_name):
try:
file_data = open(file_name)
data = file_data.readlines()
data = [line.strip() for line in data]
data = filter(None, data)
return data
except IOError as err: