Skip to content

Instantly share code, notes, and snippets.

View bpostlethwaite's full-sized avatar

Ben Postlethwaite bpostlethwaite

View GitHub Profile
@bpostlethwaite
bpostlethwaite / sinbox.js
Created April 7, 2014 19:03
emitter that emits modified sine waves
var EventEmitter = require('events').EventEmitter
var sinner = SinBox()
setInterval( function () {
sinner.setAmplitude(12)
}, 500)
setInterval( function () {
sinner.setFrequency(40)
}, 500)
function randIntGenerator(min, max) {
if (!min) min = 50
if (!max) max = 250
return function () {
return Math.floor(Math.random() * (max - min + 1)) + min
}
}
// this creates a function that outputs a random integer in the specified range
randGrid = randIntGenerator(0,22)
// for units that are owned by a particular player
function clientEmitter (game, unitId, clientId) {
var ev = new EventEmitter()
var cachedEmit = ev.emit
// we need to override the event emitters emit function to put our own juice in there
ev.emit = function (msg, data) {
thingy = function () {
this.model = new Float32Array([
1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1
]);
}
proto.onRender = function () {
@bpostlethwaite
bpostlethwaite / extract8TracksGIFs
Created July 25, 2014 15:27
extract all the gif img tags from 8tracks
var tmp = $('<div></div>')
$('body').prepend(tmp)
tmp.css('height', 400)
tmp.css('width', 900)
tmp.css('overflow', 'scroll')
a = $('#feed-container').find('li')
for (var i = 0; i < a.length; i++) {
InfiniteCheeseburger Spiral
http://8tracks.imgix.net/i/002/376/836/I-love-weed-infinite-cheeseburgers-8011.gif
Olive sleep walking
http://8tracks.imgix.net/i/002/376/853/I-love-weed-never-ending-sleep-walking-9251.gif
cellular bio-thing
http://8tracks.imgix.net/i/002/347/582/giphy-1174.gif
awesome pyramid brain rail
http://8tracks.imgix.net/i/001/999/892/tumblr_n3jzcmLUuD1tn7hmso1_500-1226.gif
Infinite Oceans
http://8tracks.imgix.net/i/002/376/856/I-love-weed-symmetrical-oceans-1551.gif
Section "ServerLayout"
Identifier "layout"
Screen 0 "nvidia"
Inactive "intel"
EndSection
Section "Device"
Identifier "nvidia"
Driver "nvidia"
BusID "PCI:PCI address determined earlier"
@bpostlethwaite
bpostlethwaite / post.js
Last active August 29, 2015 14:05
post to plotly /datacache endpoint
$(function(){
var payload;
function getPlotlyGraphData() {
return [{x:[1,2,3],y:[2,4,3]},{x:[1,2,3],y:[9,7,8]}];
}
function getPlotlyGraphLayout() {
return {};
}
$(function(){
'use strict';
var payload;
function getPlotlyGraphData() {
return [{x:[1,2,3],y:[2,4,3]},{x:[1,2,3],y:[9,7,8]}];
}
function getPlotlyGraphLayout() {
return {};
@bpostlethwaite
bpostlethwaite / VectvsLoop.m
Created October 25, 2012 19:52
Vectorized Forward Operator Test
% Test between loop based and vectorized
% Forward Operators.
% Note that dimensions are in G(z,x,y) form as
% per UBC inversion group spec.
% Set up dimensions
N = 6:2:30;
% Outer Test loop
for tt = 1:length(N)