Skip to content

Instantly share code, notes, and snippets.

View morganrallen's full-sized avatar

Morgan 'ARR!' Allen morganrallen

  • Allen Industries
  • Oakland
View GitHub Profile
@morganrallen
morganrallen / gist:5623956
Last active December 17, 2015 14:19
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
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
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 August 19, 2013 21:00
Create repeating function. Takes arguments from first call and repeat on each call there after.
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 December 28, 2015 17:59
Demonstrates possible bug in child_process

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.

@morganrallen
morganrallen / sphero-bridge.js
Created November 21, 2013 03:01
left overs from NKO4
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 August 29, 2015 13:56
NPM script runner.
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);
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);
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 November 7, 2014 19:36
Thrust window destruction on display change
<html>
<head>
<style>
webview {
height: 100%;
width: 100%;
}
webview.nofx {
@morganrallen
morganrallen / _README.md
Last active January 15, 2023 19:41
Janky Browser

JankyBrowser

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

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

Local Install

$&gt; npm install http://gist.github.com/morganrallen/f07f59802884bcdcad4a/download