Skip to content

Instantly share code, notes, and snippets.

View bpostlethwaite's full-sized avatar

Ben Postlethwaite bpostlethwaite

View GitHub Profile
@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)
@bpostlethwaite
bpostlethwaite / closure.js
Created December 18, 2012 21:06
Run this with a simple node.js http server + simple fileserver (just put the index.html in the public directory and fire it up --- should be similar to how we have it set up in hand-carved html... delete the requests for "filed" and "url" and delete the homespun routing logic.
/*
* To start I would make sure the JQuery func print outs the height
*/
var result = document.getElementById('result');
$("#a").click(function () {
var msg = $(this).height()
result.appendChild( document.createTextNode(msg) )
})
@bpostlethwaite
bpostlethwaite / ForwardMag.m
Created August 2, 2013 17:50
Attempt 1 at replicated Forward Mag Operator
%% Geometry
nx = 9;
ny = nx;
nz = nx-1;
% Set up graded mesh
curve = 0;
weight = 0.61; % Percent finer mesh at finest scale to coarsest.
gmesh = meshfunc(curve, weight);
import numpy as np
import plotly
py = plotly.plotly(username='bpostlethwaite', key='xxxxxxxxxx')
numletters = 5
letterblock = 100.
pad = 10.
{
"metadata": {
"language": "Julia",
"name": "Julia Benchmark Plotly Barchart"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
@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)

monitoring shit with monit

get monit

sudo apt-get install monit

monit configuration is in ~/.monitrc

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 () {