Skip to content

Instantly share code, notes, and snippets.

@venning
venning / ebiten-drawing-bench.go
Last active November 27, 2023 11:45
Ebiten drawing benchmark
package main
import (
"errors"
"fmt"
"image/color"
"log"
"math/rand"
"runtime/debug"
"time"
package main
import (
"image"
"image/color"
"log"
"github.com/hajimehoshi/ebiten/v2"
"github.com/hajimehoshi/ebiten/v2/vector"
)
@venning
venning / gulp-handlebars-template.js
Created October 25, 2015 20:40
Handlebars-based version of gulp-template
'use strict';
var through = require('through2');
var PluginError = require('gulp-util').PluginError;
var Handlebars = require('handlebars');
var PLUGIN_NAME = 'gulp-handlebars-template';
// partly taken from: https://github.com/gulpjs/gulp/blob/master/docs/writing-a-plugin/guidelines.md
@venning
venning / standard_deviation.js
Created October 17, 2015 09:10
Standard Deviation with lodash
// NOTE requires lodash v3.4.0+ (for _.sum) and Node 4.0+ (for arrow function)
var _ = require('lodash');
function σ (array) {
var avg = _.sum(array) / array.length;
return Math.sqrt(_.sum(_.map(array, (i) => Math.pow((i - avg), 2))) / array.length);
};
@venning
venning / check_iteratee.js
Created March 23, 2015 20:09
lodash: automated test for iteratee/predicate in documentation
#!/usr/bin/env node
/*
* much of this was taken from:
* https://bitbucket.org/ariya/missing-doc/src/master/missing-doc.js
*/
'use strict';
var _ = require('lodash'),
@venning
venning / README
Created March 23, 2015 17:20
lodash: automated tester for documentation examples
This is intended to be run in Node. Provided a path to the lodash source file as a command-line argument.
There were a few edge case handlers that I removed; they only helped in a few places while severely reducing code clarity. There's also some weirdness with how it interprets literals that cause them to not match (see _.escapeRegExp), but it's not worth the time to fix.
Let me know.