Skip to content

Instantly share code, notes, and snippets.

View shama's full-sized avatar
✍️
writing a status message

Kyle Robinson Young shama

✍️
writing a status message
View GitHub Profile
@shama
shama / surfacenormal.js
Last active December 21, 2015 01:29
calc surface normal
function crossprod(a, b) {
return [
(a[1] * b[2]) - (a[2] * b[1]),
(a[2] * b[0]) - (a[0] * b[2]),
(a[0] * b[1]) - (a[1] * b[0])
]
}
function subvec(a, b) {
return [
@shama
shama / switchtask.js
Created August 1, 2013 05:55
Grunt task to run multiple watch targets
// Run with: grunt switchwatch:target1:target2 to only watch those targets
grunt.registerTask('switchwatch', function() {
var targets = Array.prototype.slice.call(arguments, 0);
Object.keys(grunt.config('watch')).filter(function(target) {
return !(grunt.util._.indexOf(targets, target) !== -1);
}).forEach(function(target) {
grunt.log.writeln('Ignoring ' + target + '...');
grunt.config(['watch', target], {files: []});
});
grunt.task.run('watch');
@shama
shama / index.js
Created July 29, 2013 00:06
requirebin sketch
var master = new (webkitAudioContext || AudioContext)
var jsynth = require('jsynth')
var tune = require('tune')
var ff = [];
[
'C D E G',
'A B C E',
'C D E G',
'A B C E',
@shama
shama / index.js
Created July 29, 2013 00:04
requirebin sketch
var context = webkitAudioContext || AudioContext
var master = new context()
var jsynth = require('jsynth')
var tune = require('tune')
var ff = [];
[
'C D E G',
'A B C E',
'C D E G',
@shama
shama / inde.js
Last active December 20, 2015 02:29
through stream
var through = require('through');
var split = require('split');
var a = through(function write(data) {
// We handle the data internally here
this.queue('line: ' + data + '\n');
});
a.pipe(process.stdout);
var exposed = through();
@shama
shama / screen_2013-03-20.png
Last active December 15, 2015 05:39
IMAGES!
Placeholder for images.
@shama
shama / teststars.csv
Created February 5, 2013 20:41
99 Test Stars From the HYG Star Database
We can make this file beautiful and searchable if this error is corrected: It looks like row 8 should actually have 23 columns, instead of 10. in line 7.
StarID,HIP,HD,HR,Gliese,BayerFlamsteed,ProperName,RA,Dec,Distance,PMRA,PMDec,RV,Mag,AbsMag,Spectrum,ColorIndex,X,Y,Z,VX,VY,VZ
0,,,,,,Sol,0,0,0.000004848,0,0,0,-26.73,4.85,G2V,0.656,0,0,0,0,0,0
1,1,224700,,,,,6.079e-05,01.08901332,282.485875706215,-5.20,-1.88,,9.10,1.84501631012894,F5,0.482,282.43485,0.00449,5.36884,4.9e-08,-7.12e-06,-2.574e-06
2,2,224690,,,,,0.00025315,-19.49883745,45.662100456621,181.21,-0.93,,9.27,5.97222057420059,K3V,0.999,43.04329,0.00285,-15.24144,-7.1e-08,4.0112e-05,-1.94e-07
3,3,224699,,,,,0.00033386,38.85928608,355.871886120996,5.24,-2.91,,6.61,-1.1464684004746,B9,-0.019,277.11358,0.02422,223.27753,3.148e-06,9.04e-06,-3.909e-06
4,4,224707,,,,,0.00055878,-51.89354612,129.032258064516,62.85,0.16,,8.06,2.50650851253155,F0V,0.370,79.62896,0.01164,-101.53103,7.2e-08,3.9313e-05,6.1e-08
5,5,224705,,,,,0.00066435,-40.59122440,348.432055749129,2.53,9.07,,8.55,0.839409483669963,G8III,0.902,264.58918,0.04601,-226.71007,9.967e-06,4.275e-06,1.1633e-05
6,6,,,,,,0.00120942,03.94648893,53.19148936170
@shama
shama / voxel-mesh.js
Created January 30, 2013 23:02
rotate uv 90 degs for front and left
Mesh.prototype.faceVertexUv = function(i) {
var vs = [
this.meshed.vertices[i*4+0],
this.meshed.vertices[i*4+1],
this.meshed.vertices[i*4+2],
this.meshed.vertices[i*4+3]
]
var spans = {
x0: vs[0][0] - vs[1][0],
x1: vs[1][0] - vs[2][0],
@shama
shama / grunt-compat.md
Last active December 10, 2015 23:08
Compatible Grunt v0.4.0rc5 Plugins

Each of the plugins below have been updated and tested for compatibility with Grunt 0.4.0rc5. Each also has been normalized towards the style of grunt-contrib-concat.

Updated to this.files

  • coffee - 0.4.0rc5
  • concat - 0.1.2rc5
  • handlebars - 0.4.0rc5
  • htmlmin - 0.1.1rc5
@shama
shama / hud-battery.js
Last active December 10, 2015 17:08
Canvas battery animation for a drone HUD: http://imgur.com/4stMG
var cv = document.getElementById('cv');
var ctx = cv.getContext('2d');
// HUD object
function HUD(ctx, opts) {
this.ctx = ctx;
this.options = options;
}
// clear for redraw