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 / package.json
Created January 22, 2016 17:40
Abusing tape reporting stream to provide post-test cleanup
{
"name": "test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "tape test*.js"
},
"author": "",
"license": "ISC"
@morganrallen
morganrallen / esp8266-function-pointer-failure.c
Created February 9, 2016 02:55
Minimal example showing the address of a function pointer being incorrect after a system callback
#include <c_types.h>
#include <osapi.h>
#include <user_interface.h>
#include <espconn.h>
#include <mem.h>
#include <gpio.h>
typedef int (* oGetValueCB)();
typedef void (* oSetValueCB)(int, int);
@morganrallen
morganrallen / esp-idf.md
Created September 27, 2016 18:31
ESP32 esp-idf

Component/Module Structure

By default the project.md file declares one SRCDIR as

SRCDIRS ?= main

Overriding this in local project Makefile didn't appear to change anything. This is because every src directory requires a component.mk

@morganrallen
morganrallen / config.xml
Last active November 15, 2016 00:52
This demonstrates my Cordova/Phonegap development flow using Chrome Inspector to minimize app rebuilds when only application code changes.
<?xml version='1.0' encoding='utf-8'?>
<widget id="io.cordova.hellocordova" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>HelloCordova</name>
<description>
A sample Apache Cordova application that responds to the deviceready event.
</description>
<author email="dev@cordova.apache.org" href="http://cordova.io">
Apache Cordova Team
</author>
<content src="http://192.168.1.100:8000/index.html" />
@morganrallen
morganrallen / history.md
Last active March 13, 2017 23:47
Macchina M2-B Hacking Notes

cli history

miniterm.py `udevserial -v ID_MODEL=Arduino_Due -v SUBSYSTEM=tty` 115200 --raw
esptool32 --port `udevserial -v ID_MODEL=Arduino_Due -v SUBSYSTEM=tty` --before no_reset --after no_reset --baud 115200 write_flash 0x10000 ./build/gatt_server_demos.bin