Skip to content

Instantly share code, notes, and snippets.

View mikesmullin's full-sized avatar
🛴
woot!

Mike Smullin mikesmullin

🛴
woot!
View GitHub Profile
@mikesmullin
mikesmullin / cmavg.coffee
Last active July 15, 2018 16:00
Cumulative Moving Average (lets you calculate average in the middle of a stream of numbers)
avg = (a) ->
sum = 0
for v in a
sum += v
sum / a.length
cavg = (v, av, c) ->
av + ((v - av) / c)
console.log '---'
@mikesmullin
mikesmullin / recipe.rb
Created May 28, 2013 04:07
I found a situation when chef had generated Chef::Exceptions::CommandTimeout exception in git clone command if time of git clone is more than 600 seconds (10 minutes). Here's how to set the timeout value for such situations in chef recipe.
# monkey-patch Chef Git Provider
# to raise the default ShellOut timeout setting
# because this repo can take over 10min
# to clone from github.com
class ::Chef::Provider::Git
def clone # based on opscode/chef commit b86c5b06
converge_by("clone from #{@new_resource.repository} into #{@new_resource.destination}") do
remote = @new_resource.remote
args = []
@mikesmullin
mikesmullin / vm.rb
Created May 12, 2013 22:48
VirtualBox VBoxManage CLI helper
#!/usr/bin/env ruby
# vim: set ft=ruby :
verb = ARGV[0]
who = ARGV[1..-1]
workers = %w{Zero Nasir Harsh Nino Victor Andy Abbas Atef}
group = who.first.downcase == 'all'? workers : who
group.each do |worker|
next if %w{Zero}.include? worker # skip
@mikesmullin
mikesmullin / timer.rb
Created May 12, 2013 22:48
Pomodoro Timer
#!/usr/bin/env ruby
# vim: set ft=ruby :
class Sax
attr :b
attr :s1
attr :s2
def initialize
require 'bloops'
# the bloops o' phone
@mikesmullin
mikesmullin / megaphone.sh
Last active July 15, 2018 16:03
open loopback between microphone and speakers for Ubuntu Linux. written in Bash
#!/bin/sh
echo to unload, combine on same line:
echo pactl unload-module # to unload
pactl load-module module-loopback; #latency_msec=1000
@mikesmullin
mikesmullin / fixing-a-software-bug.md
Last active July 15, 2018 16:38
Process of fixing a software bug

Process of fixing a software bug:

A Guide for the Impatient Line Manager

(and how its interesting that only half of the time is estimatable

in a poorly run / bottom-dollar organization)

  1. Reproduce; verify problem
    (not estimatable; can only set a maximum cut-off time based on pain/worth)

    in other words, if you could capture errors at the moment they happen (client-side error reporting),
    as well as the steps that led up to them (user behavior analytics, determinism, demo recording),

@mikesmullin
mikesmullin / install-ejabberd.sh
Created July 10, 2012 02:07
install ejabberd server on Ubuntu
sudo apt-get install ejabberd
sudo vim /etc/ejabberd/ejabberd.cfg
# may optionally want to set the hostname and acl admin user, otherwise not required
sudo /etc/init.d/ejabberd start
ejabberdctl register mikesmullin localhost PaSsWoRD
tail -f /var/log/ejabberd/*.log
@mikesmullin
mikesmullin / toggle-pulseaudio.sh
Last active September 23, 2020 10:51
linux pulseaudio headphone speaker toggle switch
#!/bin/bash
# see original thread discussion:
# http://ubuntuforums.org/showthread.php?t=1370383
declare -i sinks=(`pacmd list-sinks | sed -n -e 's/\**[[:space:]]index:[[:space:]]\([[:digit:]]\)/\1/p'`)
declare -i sinks_count=${#sinks[*]}
declare -i active_sink_index=`pacmd list-sinks | sed -n -e 's/\*[[:space:]]index:[[:space:]]\([[:digit:]]\)/\1/p'`
declare -i next_sink_index=${sinks[0]}
@mikesmullin
mikesmullin / chromedriver.sh
Created May 8, 2012 16:08
easily install chromedriver on linux/osx
sudo apt-get install unzip;
wget -O /tmp/chromedriver.zip http://chromedriver.googlecode.com/files/chromedriver_linux64_19.0.1068.0.zip && sudo unzip /tmp/chromedriver.zip chromedriver -d /usr/local/bin/;
@mikesmullin
mikesmullin / stream-mysqldump-import-over-ssh.sh
Last active July 15, 2018 16:48
Import remote MySQL database by streaming a compressed dump over SSH
ssh REMOTE-SERVER.COM "mysqldump -uroot -p REMOTE_DB | gzip -c" | gunzip | mysql -uroot LOCAL_DB