Skip to content

Instantly share code, notes, and snippets.

View andrewplummer's full-sized avatar
🙃

Andrew Plummer andrewplummer

🙃
View GitHub Profile
@andrewplummer
andrewplummer / Error.js
Created January 12, 2017 12:37
Python/Ruby style error handling
(function() {
// lib
// Private
function canHandleError(err, block) {
return !block.errorClasses || block.errorClasses.some(function(errorClass) {
return err instanceof errorClass;
});
}
// Requires bufferWithMap custom operator (below).
function KeyEventManager (delay) {
this.shortcutsBySeqId = {};
this.partialSequenceCounts = {};
this.delay = delay;
}
KeyEventManager.prototype.connectObservable = function(observable) {
this.setupObservable(observable);
// ----
// Sass (v3.4.21)
// Compass (v1.0.3)
// ----
.foo {
color: black;
}
.bar {
@andrewplummer
andrewplummer / Sass inheriting nested
Last active May 30, 2016 05:12
Sass inheriting nested.
// ----
// Sass (v3.4.21)
// Compass (v1.0.3)
// ----
body p .foo {
color: red;
}
.bar {
// ----
// Sass (v3.4.21)
// Compass (v1.0.3)
// ----
.example-block {
color: blue;
}
.example__actions {
@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); }',
'}',
@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 / 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 / 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 / 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;