Skip to content

Instantly share code, notes, and snippets.

@alloy-d
alloy-d / logger.js
Created February 4, 2013 22:23
IE MAKES LOGGING IN JAVASCRIPT SO FUN.
define(function () {
var exports = {};
funcs = ["log", "warn", "error", "group", "groupEnd"];
for (var i in funcs) {
exports[funcs[i]] = (function (func) {
return function () {
if (typeof(console) !== "undefined" && funcs[i] in console) {
console[func].apply(console, arguments);
}
};
module Kernel
alias_method :_orig_raise, :raise
def raise(*args)
begin
_orig_raise(*args)
rescue Exception => e
Bugsnag.notify(e)
_orig_raise(e)
end
end
# It is acknowledged that all perl one-liners here are both inelegant
# and probably great targets for replacement with sed.
# Get a list of fully merged branches:
git branch --merged | perl -pe '$_ =~ s/..//' > branches
# edit branches to exclude branches that shouldn't be deleted (example: master)
@alloy-d
alloy-d / gitconfig
Last active December 21, 2015 12:59
Git configuration
[user]
name = Adam Lloyd
email = [email protected]
[alias]
ci = commit
co = checkout
d = difftool
st = status --short
current = rev-parse --abbrev-ref HEAD
autocommit = !"git commit -m \"$(curl -s 'http://whatthecommit.com' | grep -A1 'id=\"content\"' | tail -n 1 | tr -d '<p>')\""
@alloy-d
alloy-d / classify.rb
Created September 26, 2013 20:13
A hacky method for classifying things based on user input.
classify = ->(list, ider) do
groups = {}
list.each do |thing|
print "#{ider.call(thing)} "
(groups[gets.chomp.intern]||=[]) << thing
end
groups
end
@alloy-d
alloy-d / work-with-me.markdown
Last active December 24, 2015 15:09
Come work with me at Jibe!

Come work with me!

I'm looking for some Ruby/JS/web development people to come work with me at [Jibe][jibe]!

What do we do?

At Jibe, we provide tools and applications to help our clients distribute their message to more job seekers, and provide solutions to help their prospective employees navigate the application process with ease.

@alloy-d
alloy-d / hash-set-logic.rb
Created October 16, 2013 18:00
Set logic for Ruby hashes. Somehow nothing like this is built in.
require 'set'
class Hash
# Returns true if the set of this Hash's key/value pairs
# is a superset of the given hash's key/value pairs.
#
# See Set#superset?
def superhash?(hash)
self.to_set.superset?(hash.to_set)
end
@alloy-d
alloy-d / gist:7238534
Created October 30, 2013 19:21
git ls-files --recursive
git ls-files; git submodule foreach 'for file in $(git ls-files); do echo "$path/$file"; done' | grep -ve '^Entering '
@alloy-d
alloy-d / access-recorder.rb
Last active December 28, 2015 17:28
Record (basic) field accesses. Intended for use in Mustache templates.
require 'set'
class AccessRecorder
attr_reader :accessed
def initialize
@accessed = Set.new
end
def has_key?(*args) true end
def [](key)
@alloy-d
alloy-d / censored_exception.rb
Created February 11, 2014 20:29
Censoring wordy exceptions.
require 'active_support/backtrace_cleaner'
module CensoredException
def self.extended(base)
orig_backtrace = base.method(:backtrace)
base.define_singleton_method(:backtrace) do
BACKTRACE_CLEANER.clean(orig_backtrace.call)
end
end