Skip to content

Instantly share code, notes, and snippets.

View OhMeadhbh's full-sized avatar

Meadhbh Hamrick OhMeadhbh

View GitHub Profile
@OhMeadhbh
OhMeadhbh / ledtest.js
Last active August 29, 2015 14:00
send a morse code signal by way of the OK LED on a raspberry pi
// Copyright (c) 2014, Meadhbh S. Hamrick
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
@OhMeadhbh
OhMeadhbh / dysfunction.dys
Last active August 29, 2015 14:03
Dysfunction : a transfer syntax indented to irritate everyone
; dysfunction.dys
;
; Dysfunction is a new specification for communicating typed, structured,
; dynamic data between computing systems (or processes on the same system.)
; It defines a transfer syntax and processing expectations for systems which
; produce and consume formated data. This file is a brief introduction to
; Dysfunction, along with a few examples.
;
; Dysfunction is used in the same way JSON or XML might be used to store or
; communicate human readable representations of structured data. It is designed
@OhMeadhbh
OhMeadhbh / gist:21508f6fe4210b9f0877
Created July 14, 2014 19:22
javascript utility functions
// function _pad()
//
// pads the input with count numbers of char characters. Examples:
// _pad( "7" ) => "7"
// _pad( "A", 4 ) => " A"
// _pad( "7", 4, "*" ) => "***7"
function _pad( input, count, char ) {
count = count ? count : 0;
return String( Array( count ).join( ( char ? char : ' ' ) ) + input ).slice( - count );
@OhMeadhbh
OhMeadhbh / SonOfDysfunction.sod
Last active August 29, 2015 14:06
About SON of Dysfunction
; SonOfDysfunction.sod
;
; "SON of Dysfunction" is a serializable object notation (SON) built
; after the experimental "Dysfunction" transfer syntax. "SON of Dysfunction"
; (aka SOD) defines a transfer syntax, a type system, a set of XPath-ish macros
; to identify a nodes in transferred data structures and several recommended
; utility macros.
;
; The primary objective of SOD mostly to have a flexible object notation which
; worked like JSON but allowed comments. Like JSON, SOD targets systems with
@OhMeadhbh
OhMeadhbh / Raspbian Image Munging Utilities
Last active August 29, 2015 14:07
Shell scripts to modify a Raspbian image
Copyright (c) 2014, Smithee, Spelvin, Agnew & Plinge, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
@OhMeadhbh
OhMeadhbh / ddn.ddn
Created December 22, 2014 11:34
DDN: Son of Son of Dysfunction
; ddn.ddn
;
; This document describes the Dynamic Data Notation (DDN). DDN is a superset
; of JavaScript Object Notation and fills a similar role. It differs from JSON
; in a few important ways:
;
; * DDN supports comments. Semi-colons (;), hash markes (#) and C++ style
; "slash slash" di-graphs (//) all begin a "to the end of the line" style
; comment. C-style "slash splat" (/*) and "splat slash" (*/) digraphs
; enclose bounded comments.
@OhMeadhbh
OhMeadhbh / cropify.sh
Created December 24, 2014 00:20
chop the top & bottom from a noisy screenshot
# Figure out how big the input image is
GEO_INPUT=`identify $1 | cut -f 3 -d ' '`
X_INPUT=`echo $GEO_INPUT | cut -f 1 -d x`
Y_INPUT=`echo $GEO_INPUT | cut -f 2 -d x`
# Slice off a 2 pixel wide strip from the left side of the image
# Store as temp.jpg
convert $1 -crop 2x${Y_INPUT}+0+0 temp.jpg
# Now trim off the top of the temp.jpg. But we have to create a new image
@OhMeadhbh
OhMeadhbh / raspiuser
Last active August 29, 2015 14:12
Unhorking Raspbian
# raspiuser
#
# Having a fixed username / password combination is generally considered
# insecure. This script renames the default 'pi' user to one of your own
# choosing (please choose a name other than 'pi'.) Run it as root, passing
# the new username as the first parameter:
#
# sudo ./raspihork testuser
#
@OhMeadhbh
OhMeadhbh / lifecycle.js
Created February 12, 2015 19:32
node.js http.server object lifecycle
// lifecycle.js
//
// This example demonstrates how to start, use and eventually shut down a node.js server. Many
// node tutorials will tell you to completely restart a node process when changing a http
// server's behavior. This is good advice, since it can limit the effect of memory leaks and
// you don't have to worry about cross-version side effects on your business logic. But
// every now and again you'll run across a situation where it's impractical to restart a
// node process to upgrade server behaviour. For instance, we once made an "intelligent"
// proxy that would change it's logging and routing behaviour based on whether it (or we)
// thought an attack was happening.
@OhMeadhbh
OhMeadhbh / proxyroutes.json
Last active August 29, 2015 14:16
sn-proxy v1 config file
{
"production": {
"port": 80,
"httpsify": true
},
"staging": {
"port": 8080,
"default": "http://127.0.0.1:19000",
"hosts": [
{ "host": "#lo", "target": "http://127.0.0.1:19002" },