Skip to content

Instantly share code, notes, and snippets.

View mauriciomassaia's full-sized avatar

Mauricio Massaia mauriciomassaia

View GitHub Profile
@mauriciomassaia
mauriciomassaia / Map for LED strips with RGB
Created December 20, 2016 00:00
Map index for normal arrays and pixel arrays (RGB) which runs cols by col in inverted order. top to bottom then bottom to top and so on
function ledStripMap(cols, rows) {
var total = cols * rows;
// var map
var map = new Uint8Array(total);
var index = 0;
var count = 0
for(var i = 0; i < cols; i++) {
for (var j = 0; j < rows; j++) {
if (i % 2 === 0) {
@mauriciomassaia
mauriciomassaia / raycaster-line.js
Created August 9, 2016 02:58
Draw a line from the Raycaster origin and dest Vectors. Threejs
drawRaycastLine(raycaster) {
let material = new THREE.LineBasicMaterial({
color: 0xff0000,
linewidth: 10
});
let geometry = new THREE.Geometry();
let startVec = new THREE.Vector3(
raycaster.ray.origin.x,
raycaster.ray.origin.y,
raycaster.ray.origin.z);
@mauriciomassaia
mauriciomassaia / force-json.js
Created January 19, 2016 05:52
Replace single quotes with double quotes and add double quotes to a property
function addQuotes(match) {
return '"' + match.substr(0, match.length-1) + '":';
}
var t = "{tags:['000000000000000000000004', '000000000000000000000003', '300833B2DDD9014000000024', '300833B2DDD9014000000045', '300833B2DDD9014000000021', '000000000000000000000005', '000000000000000000000001', '300833B2DDD9014000000022', '000000000000000000000002']}";
var k = t.replace(/\'/g, '"');
k.replace(/[a-z]*\:/g, addQuotes);
/*
output:
@mauriciomassaia
mauriciomassaia / server.js
Created January 11, 2016 22:54
Open the default browser via node.js
const spawn = require('child_process').spawn;
// open default browser
spawn('open', ['http://localhost:9000']);
console.log('running on http://localhost:9000');
@mauriciomassaia
mauriciomassaia / .jshintrc
Created January 4, 2016 03:36
jshintrc template with THREE and TweenMax
{
"browser": true,
"node": true,
"esnext": true,
"bitwise": true,
"camelcase": true,
"curly": false,
"eqeqeq": true,
"immed": true,
"indent": 2,