Skip to content

Instantly share code, notes, and snippets.

For the lack of a nail,
throw new HorseshoeNailNotFoundException("no nails!");
For the lack of a horseshoe,
EquestrianDoctor.getLocalInstance().getHorseDispatcher().shoot();
For the lack of a horse,
RidersGuild.getRiderNotificationSubscriberList().getBroadcaster().run(
new BroadcastMessage(StableFactory.getNullHorseInstance()));
For the lack of a nail,
throw new HorseshoeNailNotFoundException("no nails!");
For the lack of a horseshoe,
EquestrianDoctor.getLocalInstance().getHorseDispatcher().shoot();
For the lack of a horse,
RidersGuild.getRiderNotificationSubscriberList().getBroadcaster().run(
new BroadcastMessage(StableFactory.getNullHorseInstance()));
[color]
diff = auto
status = auto
branch = auto
[github]
user = mattvanhorn
token = b83e22fee5f0c4a3074e92b9cd8adb01
[git-tmbundle]
gitx-path = /Applications/GitX.app/
gitnub-path = "/Applications/GitNub.app/ "
@mattvanhorn
mattvanhorn / rubylike.elm
Created November 19, 2017 23:55
Trying to make ruby-like elm helpers
listCount : (a -> Bool) -> List a -> Int
listCount test list =
list
|> List.filter test
|> List.length
listAll : (a -> Bool) -> List a -> Bool
listAll test list =
let
@mattvanhorn
mattvanhorn / email_regex.rb
Created April 21, 2015 16:00
Regex for RFC2822 validation
EmailAddress = begin
qtext = '[^\\x0d\\x22\\x5c\\x80-\\xff]'
dtext = '[^\\x0d\\x5b-\\x5d\\x80-\\xff]'
atom = '[^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-' +
'\\x3c\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+'
quoted_pair = '\\x5c[\\x00-\\x7f]'
domain_literal = "\\x5b(?:#{dtext}|#{quoted_pair})*\\x5d"
quoted_string = "\\x22(?:#{qtext}|#{quoted_pair})*\\x22"
domain_ref = atom
sub_domain = "(?:#{domain_ref}|#{domain_literal})"
@mattvanhorn
mattvanhorn / fizzbuzz.rb
Created September 5, 2014 13:52
FizzBuzz without modulo or division
class FizzBuzz
def run
(1..100).each do |number|
result = ''
if divisible_by_3?(number)
result << "Fizz"
end
if divisible_by_5?(number)
result << "Buzz"
@mattvanhorn
mattvanhorn / erb_rendering.rb
Created May 7, 2014 23:45
Demo of two ways to pass locals to an ERB template.
require 'erb'
require 'ostruct'
class TemplateContext
def initialize(locals_hash)
locals_hash.each do |key, value|
singleton_class.send(:define_method, key) { value }
end
end
@mattvanhorn
mattvanhorn / gitconfig-aliases
Created April 28, 2014 19:13
My Git Aliases
[alias]
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
st = status
co = checkout
cob = checkout -b
a = add
aa= !git add -u && git add . && git status
commit = commit -v
c = commit -m

A lot of these are outright stolen from Edward O'Campo-Gooding's list of questions. I really like his list.

I'm having some trouble paring this down to a manageable list of questions -- I realistically want to know all of these things before starting to work at a company, but it's a lot to ask all at once. My current game plan is to pick 6 before an interview and ask those.

I'd love comments and suggestions about any of these.

I've found questions like "do you have smart people? Can I learn a lot at your company?" to be basically totally useless -- everybody will say "yeah, definitely!" and it's hard to learn anything from them. So I'm trying to make all of these questions pretty concrete -- if a team doesn't have an issue tracker, they don't have an issue tracker.

I'm also mostly not asking about principles, but the way things are -- not "do you think code review is important?", but "Does all code get reviewed?".

@mattvanhorn
mattvanhorn / gist:5359374
Last active December 16, 2015 01:59
Fast tests for your mailers in Rails
# test/unit/mailers/my_mailer_test.rb
require 'minitest/spec'
require 'minitest/autorun'
require "minitest-matchers"
require 'action_mailer'
require "email_spec"
# IF WE'VE ALREADY LOADED RAILS,
# WE DON'T HAVE TO WORRY ABOUT HAML OR MAILER CONFIG