Skip to content

Instantly share code, notes, and snippets.

Alex Bain alexbain

Block or report user

Report or block alexbain

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@alexbain
alexbain / agent.nut
Last active Feb 15, 2016
Electric Imp code (agent & device) for a laundry monitoring device. Read more at $BLOG_POST (tbd)
View agent.nut
// Run on Agent
// Thresholds to adjust for better accuracy
dataThreshold <- 300; // Minimum accelerometer value to count as ON
onThreshold <- 24; // Number of ON samples before machine enters RUNNING state
offThreshold <- 60; // Number of OFF samples before machine enters OFF state
// State variable
running <- false;
@alexbain
alexbain / extract.sh
Last active Dec 30, 2015
Extract all .7z files in a directory into subdirectories that match the file name
View extract.sh
#!/bin/bash
for i in *.7z; do
subdirectory_name=$(echo $i | sed 's/.7z//');
7z x "$i" -o"$subdirectory_name"
done
View partial.bash_rc
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/-(git\/ \1 )/'
}
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color) color_prompt=yes;;
esac
force_color_prompt=yes
@alexbain
alexbain / app.com.conf
Last active Dec 10, 2015
Upstart configuration template for a NodeJS app on Ubuntu 12.04LTS. Expected to live in ``/etc/init``
View app.com.conf
# /etc/init/APP.com.conf
description "APP.com"
start on runlevel [2345]
stop on runlevel [016]
# Restart when job dies
respawn
View chef_solo_bootstrap.sh
#!/usr/bin/env bash
# Ensure things are up to date
apt-get -y update
apt-get -y upgrade
# Setup a build environment
apt-get install build-essential
apt-get install -y zlib1g-dev libssl-dev lib64readline-gplv2-dev libyaml-dev
@alexbain
alexbain / gist:3152023
Created Jul 20, 2012
Guardfile (Rocco)
View gist:3152023
# Generate documentation whenever a file is changed
guard 'rocco', :dir => 'docs', :stylesheet => 'http://jashkenas.github.com/docco/resources/docco.css' do
watch(%r{^app/.*\.(js)$})
end
@alexbain
alexbain / BB-FB-example.js
Created Apr 5, 2012
BackboneFirebase example
View BB-FB-example.js
// Create a new instance of the Rooms collections
FireDrop.Rooms = new FireDrop.collections.Rooms();
// Fetch the initial data from Firebase
FireDrop.Rooms.fetch({ success: function (response) {
// Keep this collection in sync with Firebase.
// You could save this as a property on the collection for later access.
new BackboneFirebase(FireDrop.Rooms);
@alexbain
alexbain / iphone-checker.py
Last active Aug 29, 2015
iPhone inventory checker
View iphone-checker.py
# Couple notes here:
# 0) Apple might change their APIs. If they do, this won't work any more.
# 1) If you want a different model iPhone, you'll have to do some sleuthing on apple.com "check availability" network requests to figure out what to look for.
import requests
import twilio
import sys
import time
import twilio.rest
View gist:18f83ac40a1369224173
{
"title": "btc-box",
"services": {
"query": {
"list": {
"0": {
"query": "plugin:\"load\"",
"alias": "Load",
"color": "#7EB26D",
"id": 0,
You can’t perform that action at this time.