Skip to content

Instantly share code, notes, and snippets.

View randompast's full-sized avatar

randompast

View GitHub Profile
var keyboardJS = require("keyboardjs")
var keysDown = {}
var controls = require("./controls.js")
var controlsinit = require("./controlsinit.js")(keyboardJS, keysDown)
controlsinit(controls)
//controls.js
module.exports = [
//controls, name, source
[ ['up', 'w'], "forward", require("./movement/forward.js") ],
//inside a level
var inputHandler = require("../inputHandler.js")
module.exports = function() {
this.bot = new Nbot(200, 100, 50)
input = new inputHandler(this.bot)
this.render = function(ctx) {
input.keys(this.bot)
this.bot.update(ctx, this.speed)
@randompast
randompast / demo.js
Last active October 24, 2016 22:29
Basic game example
//Run with:
//nvm use 5
//npm install canvas-fit
//bude --live --open demo.js
var fit = require('canvas-fit')
var canvas = document.body.appendChild(document.createElement('canvas'))
window.addEventListener('resize', fit(canvas), false)
var ctx = canvas.getContext('2d')
@randompast
randompast / USDA_food_comparison
Last active January 31, 2016 23:58
Meeting DRI, 51 is a perfect score, top 10 items in each food category.
**********************************************************************
26.754754078155145 "Egg, yolk, dried"
24.046201202309142 "Egg, whole, dried"
23.39524529685794 "Milk, dry, nonfat, instant, with added vitamin A and vitamin D"
23.250817147598017 "Milk, dry, nonfat, regular, with added vitamin A and vitamin D"
22.215527934694343 "Egg, whole, dried, stabilized, glucose reduced"
22.098509368553476 "Egg Mix, USDA Commodity"
21.316484893459748 "Milk, dry, whole, with added vitamin D"
19.67519907319607 "Milk, buttermilk, dried"
19.65965565780853 "Protein supplement, milk based, Muscle Milk Light, powder"

The coherence of machine thought is a creative discovery with an unlimited potential to alleviate suffering and manifest joy. Clever usage enables an amplification of our cognitive faculties and creative versatility. -Me

#Educational Games:

@randompast
randompast / soundspike.m
Created December 9, 2015 02:22
Using glpk to reconstruct a convolved and thresholded signal.
x = k = r = z = A = c = b = s = y = xmin = lb = ub = ctype = vartype = yzero = 0;
#You can use audacity to record some sound.
#Watch out for size, 1s at 8000Hz is big.
x = wavread("data/test.wav")(:,1)';
x = x - mean(x);
x = x/max(abs(x));
length(x)
A = [];
@randompast
randompast / youtubefast.js
Created September 29, 2015 21:52
Faster youtube
var vid = document.getElementsByClassName("video-stream html5-main-video")[0]; vid.playbackRate = 3.0
@randompast
randompast / speedDate.js
Created September 24, 2015 07:56
Speed of Date.now(), a little test.
//Written as a 1-liner in console.
//I wanted to see how many times Date.now() could be called per millisecond.
//Interesting variability.
n = 0;
time = Date.now();
for(var i = 0; i < 1000; i++){
if(Date.now() === time){
n++
}else{
console.log(n);
@randompast
randompast / lettersort.js
Created September 23, 2015 20:58
sort string
"really simple letter sort".split("").sort()
.filter( //Optional if you don't mind duplicates.
function(v,i,arr){
return arr.indexOf(v) === i
})
@randompast
randompast / bizcard.tex
Last active September 22, 2015 06:23
Latex Business Card
%adapted from a friend's version of one of the card templates here:
%https://schneider.ncifcrf.gov/latex.html
%via help from kaste in #latex on freenode
%compile with (used texmaker)
%xelatex -synctex=1 -interaction=nonstopmode %.tex|evince %.pdf
\documentclass[11pt]{article}
\usepackage{graphicx}
\usepackage[mmddyy]{datetime}
\usepackage[top=0.0in, bottom=0.0in, left=0.0in, right=0.0in]{geometry}
\usepackage{fontspec}