Skip to content

Instantly share code, notes, and snippets.

View anicholson's full-sized avatar

Andy Nicholson anicholson

View GitHub Profile
@anicholson
anicholson / understanding_refinements.rb
Last active August 29, 2015 14:13
Do refinements apply only to instance methods?
class Traveller
def what_are_you
puts "I'm a Backpacker"
end
def self.preferred_accommodation
puts "Hostels"
end
end
@anicholson
anicholson / bowling.rb
Created January 19, 2015 06:50
Bowling Kata
class Bowling
class EmptyFrame
def pin_total
0
end
def scores
[0,0]
end
@anicholson
anicholson / SassMeister-input.scss
Created March 24, 2015 02:46
Generated by SassMeister.com.
// ----
// Sass (v3.4.12)
// Compass (v1.0.3)
// ----
$foo: blue;
#one {
color: $foo;
@anicholson
anicholson / RSpec 3.2.3 output
Created May 13, 2015 03:14
Why don't RSpec instance_doubles honour the entire object API?
$ rspec sorting_spec.rb
F
Failures:
1) SortableThing can be sorted
Failure/Error: sorted = [thing1, thing2].sort
ArgumentError:
comparison of RSpec::Mocks::InstanceVerifyingDouble with RSpec::Mocks::InstanceVerifyingDouble failed
# ./sorting_spec.rb:20:in `sort'
module Hangman (Model, Letter, initialModel, Action, update, view, main) where
{-| A hangman game in Elm.
@docs Model
@docs Letter
@docs Action
@docs initialModel
@docs update
@docs view
@anicholson
anicholson / Brew config
Created May 31, 2012 03:00
Brew install imagemagick error
tusk:Library andy$ brew --config
HOMEBREW_VERSION: 0.9
HEAD: 7f24e45aceeb40cc77bdd5a9ff00dd606f1709e6
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CELLAR: /usr/local/Cellar
CPU: dual-core 64-bit core2
OS X: 10.6.8
Kernel Architecture: i386
Xcode: 4.0
GCC-4.0: N/A
@anicholson
anicholson / processor.rb
Created July 20, 2012 04:56
Gotcha: DOS maintains CWD for each drive

Given this scenario:

K:\>dir
...
some_dir
job_1
...
K:\>cd some_dir
K:\some_dir> C:

C:> cd script

@anicholson
anicholson / keybase.md
Created December 9, 2015 00:20
keybase.md

Keybase proof

I hereby claim:

  • I am anicholson on github.
  • I am andrewdotnich (https://keybase.io/andrewdotnich) on keybase.
  • I have a public key ASD9uQS7he9dDqhPl638kbWfHGifEyTiqlDvbNh1UGpA9Qo

To claim this, I am signing this object:

require 'rubygems'
require 'nokogiri'
require 'fileutils'
require 'date'
require 'uri'
# usage: ruby import.rb my-blog.xml
# my-blog.xml is a file from Settings -> Basic -> Export in blogger.
data = File.read ARGV[0]
<?php
function newBenefit($oldBenefit, $quality, $squares_eaten) {
if($squares_eaten > 5) {
return -1.1 * abs($oldBenefit);
} else if($quality == 'cadbury') {
return $oldBenefit * 0.8;
} else {
return $oldBenefit * 0.95;
}
}