Skip to content

Instantly share code, notes, and snippets.

@theterg
theterg / ma.l
Created December 27, 2011 20:00
MA translator plugin for chef
static int i_seen = 0;
%}
WC [A-Za-z']
NW [^A-Za-z']
%start INW NIW
%%
./produce.py produce 32c570d1d07756d92eb1a0e1cb3afbc60bfd5a94 ea8da467c44d4e3f2327b9346f0869787aa8342a
{"message":"derp"}
./consume.py consume 32c570d1d07756d92eb1a0e1cb3afbc60bfd5a94 489a92e768b4904fcf62b866017990d6f3af96d9
{"presence":{"from":{"resource":"489a92e768b4904fcf62b866017990d6f3af96d9"},"type":"available"}}
{"presence":{"from":{"resource":"ea8da467c44d4e3f2327b9346f0869787aa8342a"},"type":"available"}}
{"presence":{"from":{"swarm":"32c570d1d07756d92eb1a0e1cb3afbc60bfd5a94","resource":"ea8da467c44d4e3f2327b9346f0869787aa8342a"}}}
@theterg
theterg / 00-bug20.rules
Created February 10, 2012 17:31
UDEV rules for arduino and Sierra Wireless 888 on BUG Base
# Internal Ethernet lacks EEPROM for MAC address so each reboot it gets
# random one. In effect it appears as usb0 but we prefer to have it as eth0
ACTION=="add", KERNEL=="omap-backlight", SUBSYSTEM=="platform", RUN+="/sbin/modprobe bug_backlight"
KERNEL=="ttyS1", SUBSYSTEMS=="tty", RUN+="/etc/udev/scripts/bt_init.sh"
ACTION=="add", SUBSYSTEM=="bmi", RUN+="/bin/sh /etc/udev/scripts/bmi_eventpipe.sh"
ACTION=="remove", SUBSYSTEM=="bmi", RUN+="/bin/sh /etc/udev/scripts/bmi_eventpipe.sh"
KERNEL=="ttyS0", SUBSYSTEMS=="platform", SYMLINK+="ttyBMI2"
KERNEL=="ttySC0", SUBSYSTEMS=="platform", SYMLINK+="ttyBMI0"
KERNEL=="ttySC1", SUBSYSTEMS=="platform", SYMLINK+="ttyBMI3"
@theterg
theterg / etc_init.d_ppp
Created February 15, 2012 18:00
Accenture GSM configurations
#!/bin/sh
#
# /etc/init.d/ppp: start or stop PPP link.
#
# If you want PPP started on boot time (most dialup systems won't need it)
# rename the /etc/ppp/no_ppp_on_boot file to /etc/ppp/ppp_on_boot, and
# follow the instructions in the comments in that file.
#test -x /usr/sbin/pppd -a -f /etc/ppp/ppp_on_boot || exit 0
if [ -x /etc/ppp/ppp_on_boot ]; then RUNFILE=1; fi
#!/bin/bash
export ARCH=arm
#export CROSS_COMPILE=arm-angstrom-linux-gnueabi-
export CROSS_COMPILE=arm-linux-gnueabi-
unset CPATH
echo "Nuking output directory"
rm -rf install/lib
rm install/boot/*
set -e
@theterg
theterg / 00-bug20.rules
Created May 21, 2012 21:13
RM Kit XBee udev rule Located in /etc/udev/rules.d/00-bug20.rules
# Located in /etc/udev/rules.d/00-bug20.rules
# Internal Ethernet lacks EEPROM for MAC address so each reboot it gets
# random one. In effect it appears as usb0 but we prefer to have it as eth0
ACTION=="add", KERNEL=="omap-backlight", SUBSYSTEM=="platform", RUN+="/sbin/modprobe bug_backlight"
KERNEL=="ttyS1", SUBSYSTEMS=="tty", RUN+="/etc/udev/scripts/bt_init.sh"
ACTION=="add", SUBSYSTEM=="bmi", RUN+="/bin/sh /etc/udev/scripts/bmi_eventpipe.sh"
ACTION=="remove", SUBSYSTEM=="bmi", RUN+="/bin/sh /etc/udev/scripts/bmi_eventpipe.sh"
KERNEL=="ttyS0", SUBSYSTEMS=="platform", SYMLINK+="ttyBMI2"
KERNEL=="ttySC0", SUBSYSTEMS=="platform", SYMLINK+="ttyBMI0"
root@chipkit:/etc# cd /etc
root@chipkit:/etc# rm timezone
root@chipkit:/etc# rm localtime
root@chipkit:/etc# ln -s /usr/share/zoneinfo/America/New_York /etc/localtime
root@chipkit:/etc# ln -s /usr/share/zoneinfo/America/New_York /etc/timezone
root@chipkit:/etc# date
Fri Jul 13 15:15:07 EDT 2012
@theterg
theterg / LED_VU_BT_firmware.pde
Created September 29, 2012 07:42
LED VU BT firmware with animation upgrades
#define BUFFLEN 200
#define NUMLEDS 5
#define MAXVALUES 3
#define ACT_FADEUP 1
#define ACT_FADEDOWN 2
#define ACT_BLINK 3
int leds[] = {3, 5, 6, 9, 10};
int act[NUMLEDS];
var WebSocket = require('ws')
, ws = new WebSocket('ws://api.cosm.com:8080/');
var API_KEY = "" //ENTER API KEY HERE.
ws.on('open', function() {
ws.send('{"headers":{"X-ApiKey":"'+API_KEY+'"}, "method":"subscribe", "resource":"/feeds/61916/datastreams/sine60"}');
});
ws.on('message', function(message) {
console.log('received: %s', message);
});
@theterg
theterg / gist:5016797
Created February 22, 2013 21:48
Autoreconnect + keepalive TCP dump
POST /stream?resource_id=c7cf00fc21622a15f15bd390a698af3f34efd9bc&swarm_id=0d86ad8e7f33d4c9bb33d38ef9295f897a636523 HTTP/1.1
Host: api.bugswarm.net
Accept: application/json
X-BugSwarmApiKey: 7a849e6548dbd6f8034bb7cc1a37caa0b1a2654b
Connection: close
User-Agent: SwarmSessionImp
Transfer-Encoding: chunked
Content-Type: application/json ;charset=UTF-8
X-Forwarded-For: 69.195.32.42