Skip to content

Instantly share code, notes, and snippets.

@tinyrobot
tinyrobot / underscore_games.js
Created January 27, 2012 15:03
Partial Application / javascript games with underscore.js
//our simple data structure
function Spatial(x,y,vx,vy){
this.x = x;
this.y = y;
this.vx = vx || Math.random();
this.vy = vy || Math.random();
}
//use partial application here so that we can compose this in our main update
function processEvents(keys){
@tinyrobot
tinyrobot / gamefuncs.clj
Created May 4, 2012 13:46
Playing with game related functions in clojure
;; Testing some potential basic game functions
;; moved-by : list list -> list
;; computes a new position by adding an x,y pair to an x,y pair
;; example: (moved-by '(1,1) '(0,1)) -> '(1,2)
(defn moved-by [position amount]
(map + position amount))
;; test moved-by: (moved-by '(1,1) '(0,1)) -> '(1,2)
(println (= '(1 2) (moved-by '(1,1) '(0,1))))
/** Simple touch input helper class that provides similar data to HaxePunk's mouse.
takes arguments defining a box within which to register touches. Only registers first touch.
*/
class TouchInput{
public var pressed:Bool = false;
public var released:Bool = false;
public var down:Bool = false;
public var touchX:Float = 0;
public var touchY:Float = 0;
@tinyrobot
tinyrobot / gist:5515012
Created May 3, 2013 23:16
Ideas for selector based server side templating with node
//data
var person = {name: "Dave", exampleattr: "true", friends: ["one","two","three"]};
//map data to selectors
var mapping = {
name: "#people .person",
exampleattr: {"#people .person" : "someattr"},
friends: "#people .friends"
};
//input
restore_pane_process() {
local pane_full_command="$1"
local session_name="$2"
local window_number="$3"
local pane_index="$4"
local dir="$5"
if _process_should_be_restored "$pane_full_command" "$session_name" "$window_number" "$pane_index"; then
# These two commands don't seem to be needed if addressing session:window.pane absolutely (see below)
tmux switch-client -t "${session_name}:${window_number}"
tmux select-pane -t "$pane_index"