Skip to content

Instantly share code, notes, and snippets.

View nickdesaulniers's full-sized avatar

Nick Desaulniers (paternity leave) nickdesaulniers

View GitHub Profile
# C code
#include <stdio.h>
#include <inttypes.h>
#int main () {
# int64_t nums [3000] = {0};
# printf("%lld\n", nums[0]);
#}
@nickdesaulniers
nickdesaulniers / list_homescreen_icons.js
Last active August 29, 2015 14:03
List Firefox OS Homescreen Icons
// This is useful if you want to do something with the icons
// AFTER they've ALL been loaded. Some apps don't have
// icons listed in their manifests, and some have icons
// listed without actually having the actual asset or
// result in 404's. Here I just skip them by decrementing
// numToLoad, but if you still want to be able to launch the
// app, then you'd want to push a default icon into icons.
function loadIcons (cb) {
navigator.mozApps.mgmt.getAll().onsuccess = function (e) {
@nickdesaulniers
nickdesaulniers / async.js
Last active August 29, 2015 14:05
First trial of generators
// Run with `node.js v0.11.13: node --harmony file.js`
// Comment out/in fs.stat & setTimeout blocks. Based on:
// http://strongloop.com/strongblog/how-to-generators-node-js-yield-use-cases/
function thunkify (fn) { // fn === fs.stat xor setTimeout
return function b () {
// args === [__filename] xor [after, 1000]
var args = Array.prototype.slice.call(arguments);
return function c (cb) { // cb === pump
args.push(cb);
// args === [__filename, pump] xor [after, 1000, pump]
@nickdesaulniers
nickdesaulniers / control_flow_x64.txt
Last active August 29, 2015 14:06
Assembly control flow
// clang -S source.c
// Single if
if (x > 0) {
...
}
becomes:
### Keybase proof
I hereby claim:
* I am nickdesaulniers on github.
* I am nickd (https://keybase.io/nickd) on keybase.
* I have a public key whose fingerprint is 90C1 6D8E E59C B152 9D99 F861 027B 59AE 4389 4A07
To claim this, I am signing this object:
// Takeaways:
// 1. always return a promise, so you can chain .then calls
// 2. arrays of Promises can be passed to Promise.all or Promise.race
var parse = require('csv-parse');
var XMLHttpRequestPromise = require('xhr-promise');
var prefix = '../gtfs_caltrain_devs/';
// An array of strings
var csvs = [
mat4.multiply = function (out, a, b) {
if (SIMD) {
mat4.multiply = function (out, a, b) {
// https://www.youtube.com/watch?v=DXPfE2jGqg0
// http://drrobsjournal.blogspot.com/2012/10/fast-simd-4x4-matrix-multiplication.html
var _a = SIMD.Float32x4(b[0], b[1], b[2], b[3]);
var _b = SIMD.Float32x4(b[4], b[5], b[6], b[7]);
var _c = SIMD.Float32x4(b[8], b[9], b[10], b[11]);
var _d = SIMD.Float32x4(b[12], b[13], b[14], b[15]);
@nickdesaulniers
nickdesaulniers / oscillate.js
Created July 29, 2015 21:51
harmonic oscillation
var period = 2; // seconds
var amplitude = 0.5;
var verticalOffset = 0;
function nowSeconds () {
return performance.now() * 0.001;
}
function makeOscillate (amplitude, period, verticalOffset) {
return function (nowSeconds) {
@nickdesaulniers
nickdesaulniers / nick.xml
Created August 16, 2015 01:56 — forked from anonymous/nick.txt
test
<scene>
<group translateY="1.0" rotateY="0.78">
<cube scaleX="2.75" translateY="1.0"/>
<sphere translateX="1.0"/>
<sphere translateX="-1.0"/>
</group>
</scene>
@nickdesaulniers
nickdesaulniers / joshVR.xml
Created August 25, 2015 17:15 — forked from anonymous/joshVR.xml
joshVR snapshot
<!-- Giraffe by Nick Desaulniers BrazilJS 8/22/15 -->
<scene>
<group id="tree" translateX="-0.98">
<cube id="trunk" scaleY="3.26" scaleX="0.47"/>
<cube id="rightBranch" translateY="1.87" rotateZ="-0.36" scaleY="1.28" scaleX="0.23" translateX="0.19"/>
<cube id="middleBranch" translateY="2.15" rotateZ="0.00" scaleY="1.28" scaleX="0.23" translateX="-0.09"/>
<cube id="leftBranch" translateY="1.87" rotateZ="0.51" scaleY="1.28" scaleX="0.23" translateX="-0.46"/>
<group id="leaves" translateZ="0.28" translateY="-0.09">
<sphere translateY="2.98" scaleX="0.23" scaleY="0.23" translateX="0.00"/>
<sphere translateY="2.70" scaleX="0.23" scaleY="0.23" translateX="0.38"/>