Skip to content

Instantly share code, notes, and snippets.

@mattcodez
mattcodez / mrdbg-es5.js
Created February 3, 2016 19:13
Mapreduce Debug (ES6 & ES5)
//Transpiled from Babel
"use strict";
function MRDbg() {
for (var _len = arguments.length, txt = Array(_len), _key = 0; _key < _len; _key++) {
txt[_key] = arguments[_key];
}
return function (prev, cur, i, arr) {
if (i === 1) {
//Use ES6 modules for your controllers in SailsJS
//requires https://github.com/artificialio/sails-hook-babel
export default {
controllerAction1(req, res) {
//...
},
controllerAction2(req, res) {
//...
@mattcodez
mattcodez / pixel.js
Created November 26, 2014 06:51
Simple function to write a single pixel to a canvas element
//Copied from http://stackoverflow.com/q/4899799/119909
function pixel(x,y){
d[0] = 255;//r
d[1] = 0;//g
d[2] = 0;//b
d[3] = 255;//a
ctx.putImageData( id, x, y );
}
var ctx = document.getElementById('c').getContext('2d');
var id = ctx.createImageData(1,1);