Skip to content

Instantly share code, notes, and snippets.

Avatar

Morgan 'ARR!' Allen morganrallen

  • Allen Industries
  • Oakland
View GitHub Profile
View stpl.js
(function(glob) {
/*
stpl
Morgan "ARR!" Allen
morganrallen@gmail.com
supports simple replacements
<li>${var}</li> + { var: "val" } = <li>val</li>
simple replacement with default value
View core.js
(function(global) {
var config = false,
modules = [];
// setup single public namespace
var skel = global.skel = {
init: function(c) {
// put initial config in the public scope
config = c;
View xchng.node.js
/*
XChng v0.1
Morgan "ARR!" Allen <morganrallen@gmail.com>
</morganrallen@gmail.com>
MIT License
usage: node xchng.node.js [ value || 1 ]
*/
var http = require("http"),
View test-gist.js
var gist = "just a test, update";
View test.html
<html>
<head>
<script type="text/javascript" src="zeroth.js"></script>
</head>
<body>
<script>
console.log("First script");
</script>
<script>
var s = document.createElement("script");
View createElement.bug.js
var jsdom = require("jsdom"),
fs = require("fs");
fs.readFile("test.html", function(err, content) {
if(err) throw err;
var doc = jsdom.jsdom(content, jsdom.defaultLevel);
doc.addEventListener("load", function() {
console.log(arguments);
View relative-color.js
function RGB2HEX(s) {
return [ parseInt(s.substr(0,2), 16), parseInt(s.substr(2,2), 16), parseInt(s.substr(4,2), 16) ];
}
function ItoS(i) {
return i === 0 ? "00" : i.toString(16);
}
function HEX2RGB(s) {
return ItoS(s[0]) + ItoS(s[1]) + ItoS(s[2]);
@morganrallen
morganrallen / package.json
Created Nov 10, 2012
Nodejitsu deploy errors
View package.json
info: Welcome to Nodejitsu nko3-derpatron
info: jitsu v0.10.5, node v0.8.2
info: It worked if it ends with Nodejitsu ok
info: Executing command deploy
info: Analyzing application dependencies in node server/server.js
warn: Local package version appears to be old
warn: The package.json version will be incremented automatically
warn: About to write /Users/morganallen/devel/NKO3/derpatron/package.json
warn: Using '*' as a version for dependencies may eventually cause issues
warn: Use specific versions for dependencies to avoid future problems
@morganrallen
morganrallen / garmin.js
Created May 15, 2013
Open Stava upload new content page when Garmin Edge 305 is plugged in. NodeJS, node-udev
View garmin.js
#!/usr/bin/env node
var udev = require("udev");
var monitor = udev.monitor();
monitor.on("add", function(device) {
// change vendor and model IDs to match your device if not Garmin Edge 305
if(device.ID_VENDOR_ID === "091e" && device.ID_MODEL_ID === "0003") {
require("child_process").spawn("xdg-open", ["http://app.strava.com/upload/garmin_new"], {
env: process.env