Skip to content

Instantly share code, notes, and snippets.

alexbain /
Last active Dec 30, 2015
Extract all .7z files in a directory into subdirectories that match the file name
for i in *.7z; do
subdirectory_name=$(echo $i | sed 's/.7z//');
7z x "$i" -o"$subdirectory_name"
alexbain /
Last active Aug 29, 2015
iPhone inventory checker
# 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 "check availability" network requests to figure out what to look for.
import requests
import twilio
import sys
import time
View gist:18f83ac40a1369224173
"title": "btc-box",
"services": {
"query": {
"list": {
"0": {
"query": "plugin:\"load\"",
"alias": "Load",
"color": "#7EB26D",
"id": 0,
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;
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;;
alexbain /
Last active Dec 10, 2015
Upstart configuration template for a NodeJS app on Ubuntu 12.04LTS. Expected to live in ``/etc/init``
# /etc/init/
description ""
start on runlevel [2345]
stop on runlevel [016]
# Restart when job dies
#!/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 / gist:3152023
Created Jul 20, 2012
Guardfile (Rocco)
View gist:3152023
# Generate documentation whenever a file is changed
guard 'rocco', :dir => 'docs', :stylesheet => '' do
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);