Skip to content

Instantly share code, notes, and snippets.

View andrewplummer's full-sized avatar
🙃

Andrew Plummer andrewplummer

🙃
View GitHub Profile
@andrewplummer
andrewplummer / gist:1868213
Created February 20, 2012 07:07
Git bash aliases with tab completion
#!/bin/sh
# Git related aliases
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
__define_git_completion () {
eval "
var sound = 'woof';
function bark(s) {
if(!s) {
return sound;
} else {
var sound = 'ruff';
return sound + s;
}
}
@andrewplummer
andrewplummer / gist:3087484
Created July 11, 2012 02:03
Dragonfly bug?
// Coming in:
//
// weekday = 40;
// d = new Date(2012, 1, 1);
// utc = false;
// prefer = 1;
// callDateMethod with those arguments is equivalent to "d.getDay()" and will return 3;
// When the bug occurs, weekday will become 47, where in every other browser it should remain 40 as:
// callDateMethod(...) IS 3 AND 40 % 7 IS 5
@andrewplummer
andrewplummer / github_show.sh
Last active October 10, 2015 19:38
Open a link to a file in Github from the command line.
#!/usr/bin/env ruby
require 'open-uri'
if ARGV.length == 0
puts <<-MESSAGE
GitHub Show Script
------------------
@andrewplummer
andrewplummer / gist:3837643
Created October 5, 2012 01:59
jQuery Bookmarklet
javascript:var%20i,s,ss=['https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js'];for(i=0;i!=ss.length;i++){s=document.createElement('script');s.src=ss[i];document.body.appendChild(s);}void(0);
@andrewplummer
andrewplummer / Class.js
Created November 22, 2012 03:21
Dead simple class inheritance
(function() {
var defineProperty = Object.defineProperty || function(obj, name, desc) {
obj[name] = desc.value;
};
var getOwnPropertyNames = Object.getOwnPropertyNames || function(obj) {
var names = [];
for(var key in obj) {
if(!obj.hasOwnProperty(key)) continue;
@andrewplummer
andrewplummer / notify.sh
Created November 27, 2012 04:56
Notify anything Ubuntu
#!/bin/sh
T="$(date +%s)"
"$@"
T="$(($(date +%s)-T))"
#TIME=$(printf "Pretty format: %02d:%02d:%02d:%02d\n" "$((T/86400))" "$((T/3600%24))" "$((T/60%60))" "$((T%60))")
TIME=$(printf "%02dh%02dm%02ds\n" "$((T/3600%24))" "$((T/60%60))" "$((T%60))")
notify-send "Process Finished" "\"$1\" completed in $TIME." -i $HOME/Dropbox/Icons/emblem-important.svg
@andrewplummer
andrewplummer / dump_icomoon_zip.rb
Created February 6, 2013 02:59
Dump an icomoon zip file into a given directory and rearrange the files a bit.
#!/usr/bin/env ruby
abort "Need path to .zip!" if ARGV[0].nil?
abort "Need path to font directory!" if ARGV[1].nil?
full_path = ARGV[0]
target_path = ARGV[1]
filename = full_path.split('/').last.split('.').first
filename_no_num = filename.gsub(/\d+$/, '')
tmp_dir = File.directory?('tmp') ? 'tmp/' : '/tmp/'
@andrewplummer
andrewplummer / error.js
Last active August 29, 2015 14:00
IE7 odd try/catch behavior
throwAnError = function () {
throw new Error('Erroring!');
}
window.windowMappedError = throwAnError;
try {
throwAnError();
} catch(e) {
alert('Caught the global error');
@andrewplummer
andrewplummer / spin.js
Last active August 29, 2015 14:21
Spin all da things
var style = document.createElement('style');
style.innerHTML = [
'@-moz-keyframes spin {',
'from { -moz-transform: rotate(0deg); }',
'to { -moz-transform: rotate(360deg); }',
'}',
'@-webkit-keyframes spin {',
'from { -webkit-transform: rotate(0deg); }',
'to { -webkit-transform: rotate(360deg); }',
'}',