Skip to content

Instantly share code, notes, and snippets.

View anicholson's full-sized avatar

Andy Nicholson anicholson

View GitHub Profile
@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

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;
}
}
@anicholson
anicholson / gist:5864974
Created June 26, 2013 05:25
Output of `rake` for json_schema_tools v0.8.8 when Rails 4 is installed.
{15:23}[2.0.0]~/repos/json_schema_tools:c1819d7 ✓ ➭ bundle install
The source :rubygems is deprecated because HTTP requests are insecure.
Please change your source to 'https://rubygems.org' if possible, or 'http://rubygems.org' if not.
Resolving dependencies...
Using rake (10.1.0)
Using i18n (0.6.4)
Using minitest (4.7.5)
Using multi_json (1.7.7)
Using atomic (1.1.9)
Using thread_safe (0.1.0)
Function IsPasswordValid(ByVal Password As String, ByRef Failures As ArrayList)
Dim Criteria() As InvalidationCriterion = {
new ShorterThanLength(8),
new ConsecutiveChars,
new NoSpecialChars,
new NoNumbers,
new NoMixedCase
}
@anicholson
anicholson / ohai_output
Created July 24, 2013 04:54
output of chef-solo run on server
Using apt (1.1.2)
Using build-essential (1.4.0)
Installing chef-solo-search (0.4.0) from git: 'git://github.com/edelight/chef-solo-search.git' with branch: 'master' at ref: '1f79c1d86e85aa3a2b01e15f90755cf60eb66a4f'
Installing user (0.3.1) from git: 'git://github.com/fnichol/chef-user.git' with branch: 'master' at ref: 'ce45d05e13491a82cbb5a2c36292391f3a1aaa36'
Using ruby_build (0.8.0)
Installing rbenv (0.7.3) from git: 'git://github.com/fnichol/chef-rbenv.git' with branch: 'master' at ref: '9afb4e5da2e6212504a12de3bbbd410cd96100f6'
Installing postgresql (0.11.1) from git: 'git://github.com/phlipper/chef-postgresql.git' with branch: 'master' at ref: 'e910a99bad3af54e6a34184ebcce52d6e63ba92f'
Using mongodb (0.11.0)
Installing mxc-chef-redmine (0.1.3) from git: 'ssh://[email protected]/messagexchange/mxc-chef-redmine.git' with branch: 'master' at ref: 'd11c57f9de81c6378e33888892a0159295e3e77c'
Installing mxc-chef-deployment (0.1.3) from git: 'ssh://[email protected]/messagexchange/mxc-deployment.git' with branc
@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;