Skip to content

Instantly share code, notes, and snippets.

Avatar

Morgan 'ARR!' Allen morganrallen

  • Allen Industries
  • Oakland
View GitHub Profile
@morganrallen
morganrallen / gist:5623956
Last active Dec 17, 2015
Auto compile LESS to CSS on write. Also will allow you to compile a parent script by putting /* lessc-parent: "main" */ on the top line
View gist:5623956
function LessToCss()
let match = matchstr(getline(1), '...lessc-parent: "\zs.\{-}\ze"')
if strlen(match) > 0
let current_file = match . ".less"
let filename = match
el
let current_file = shellescape(expand('%:p'))
let filename = shellescape(expand('%:r'))
endif
View gist:5760979
Project.Collections.MappedAreas = Backbone.Collection.extend({
model: {
"Model[LatLng, Geopoints[LatLng]]": {
Model: Backbone.Model,
Geopoints: Project.Collections.Geopoints,
LatLng: Project.Models.LatLng
}
}
});
@morganrallen
morganrallen / gist:6274144
Created Aug 19, 2013
Create repeating function. Takes arguments from first call and repeat on each call there after.
View gist:6274144
function repeater(fn) {
var args = false;
return function() {
if(args === false) args = arguments;
return fn.apply(this, args);
}
};
function add(a, b) {
@morganrallen
morganrallen / README.md
Last active Dec 28, 2015
Demonstrates possible bug in child_process
View README.md

Demonstrates possible bug in child_process

running node main.js will result in process.stdin.setRawMode being undefined and tty.setRawMode barfing 'Error: can't set raw mode on non-tty'

running node child-using-stdin.js will give the function as expected and give deprecation message rather than barf.

View sphero-bridge.js
Math.TAU = Math.PI + Math.PI;
const TO_DEGREES = 180 / Math.PI;
const TO_RADIANS = Math.PI / 180;
function headingFromDelta(x, y) {
var a = Math.atan2(y, x);
if(a < 0) a = (a + Math.PI) + Math.PI;
// janky rotation by 90deg
a = Math.round(a * TO_DEGREES);
@morganrallen
morganrallen / dev.js
Last active Aug 29, 2015
NPM script runner.
View dev.js
var path = require("path");
var spawn = require("child_process").spawn;
var scripts = process.argv.slice(2);
console.log("Running from %s", process.cwd());
scripts.forEach(function(script) {
console.log("[executing] npm run %s", script);
View sphero_control.js
var ds = require("dualshock-controller");
var sphero = require("spheron").sphero();
var spheroReady = false;
sphero.on("open", function() {
console.log("sphero ready");
spheroReady = true;
sphero.setBackLED(0xff);
View gist:f955cc0312ae2cdbe9a5
D/CordovaActivity(18223): onMessage(onPageStarted,file:///#!/sites)
D/CordovaLog(18223): file:///#!/sites: Line 1 : Uncaught ReferenceError: start is not defined
D/CordovaLog(18223): file:///#!/sites: Line 2 : Uncaught ReferenceError: addRow is not defined
D/CordovaLog(18223): file:///#!/sites: Line 3 : Uncaught ReferenceError: addRow is not defined
D/CordovaLog(18223): file:///#!/sites: Line 4 : Uncaught ReferenceError: addRow is not defined
D/CordovaLog(18223): file:///#!/sites: Line 5 : Uncaught ReferenceError: addRow is not defined
D/CordovaLog(18223): file:///#!/sites: Line 6 : Uncaught ReferenceError: addRow is not defined
D/CordovaLog(18223): file:///#!/sites: Line 7 : Uncaught ReferenceError: addRow is not defined
D/CordovaLog(18223): file:///#!/sites: Line 8 : Uncaught ReferenceError: addRow is not defined
D/CordovaLog(18223): file:///#!/sites: Line 9 : Uncaught ReferenceError: addRow is not defined
@morganrallen
morganrallen / crash.html
Created Nov 7, 2014
Thrust window destruction on display change
View crash.html
<html>
<head>
<style>
webview {
height: 100%;
width: 100%;
}
webview.nofx {
View _README.md

JankyBrowser

The only cross-platform browser that fits in a Gist!

One line install. Works on Linux, MacOSX and Windows.

Local Install

$> npm install http://gist.github.com/morganrallen/f07f59802884bcdcad4a/download