Skip to content

Instantly share code, notes, and snippets.

View mybuddymichael's full-sized avatar

Michael Hanson mybuddymichael

  • Formerly @hudl
  • California
View GitHub Profile
@mybuddymichael
mybuddymichael / airporttoggle.scpt
Created April 24, 2011 19:50
Quickly turn Airport off and on
do shell script "/usr/sbin/networksetup -setairportpower en1 off"
do shell script "/usr/sbin/networksetup -setairportpower en1 on"
@mybuddymichael
mybuddymichael / post-commit
Created September 3, 2011 21:44
Keep GitHub pages synced with 'master'
#!/usr/bin/env sh
if [ $(git symbolic-ref HEAD 2> /dev/null) = "refs/heads/master" ]
then
git checkout gh-pages
git merge master
git checkout master
fi
@mybuddymichael
mybuddymichael / _mixins.scss
Created January 22, 2012 00:33
My common SCSS mixins
@mixin link($px: 2, $style: solid, $color: white) {
text-decoration: none;
border-bottom: $px*1px $style $color;
}
@mixin font-size($font-size: 16) {
font-size: $font-size*1px;
font-size: $font-size/16*1rem;
}
require 'date'
class DataPoint
# Create a new data point.
#
# tag_name - A String containing a name or identifier for the
# data being measured.
# time_recorded - A DateTime object for the recording time.
# data - A String or Float which is the recorded data.
#
@mybuddymichael
mybuddymichael / .gitignore
Created March 10, 2012 23:11
Starter Stasis project
/.sass-cache
/public
@mybuddymichael
mybuddymichael / post-receive
Created May 6, 2012 03:00
My web server post-receive hook
#!/bin/sh
GIT_REPO="/home/private/mybuddymichael.git"
PUBLIC="/home/public/dev/"
cd $PUBLIC || exit
unset GIT_DIR
echo "*** Pulling changes into prime."
(ns pgbot/main)
(js/alert "Hi!")
__git_ps1() {
local b="$(git symbolic-ref HEAD 2>/dev/null)";
if [ -n "$b" ]; then
printf " (%s)" "${b##refs/heads/}";
fi
}
@mybuddymichael
mybuddymichael / ircbot.rb
Created October 11, 2012 20:36
A simple Ruby IRC bot
#!/usr/local/bin/ruby
require "socket"
# Don't allow use of "tainted" data by potentially dangerous operations
$SAFE = 1
class IRC
def initialize(server, port, nick, channel)
#!/bin/sh
ip_address="$1"
ping -c 1 "$ip_address" > /dev/null
if [ $? -gt 0 ]; then
log_line="`date` : Ping to $ip_address unsuccessful, REBOOTING."
echo "$log_line" >> /var/log/ping-or-reboot
/sbin/reboot