Skip to content

Instantly share code, notes, and snippets.

View jamesmoriarty's full-sized avatar
🔮
0xc0000005

James Moriarty jamesmoriarty

🔮
0xc0000005
View GitHub Profile
@jamesmoriarty
jamesmoriarty / gemfile.rb
Created April 17, 2012 22:42
SimpleCov and Spork
gem 'spork', '1.0.0rc'
gem 'simplecov', :require => false
@jamesmoriarty
jamesmoriarty / map.rb
Created April 29, 2012 08:51
map exercise
class Map
attr_accessor :tiles, :start, :finish
WATER_VALUE = 10_000
FLATLAND_VALUE = 1
FOREST_VALUE = 2
MOUNTAIN_VALUE = 3
START_KEY = "@"
FINISH_KEY = "x"
group :development, :test do
gem 'ruby-debug19', :require => 'ruby-debug'
gem 'rspec-rails', '2.8.0'
gem 'factory_girl_rails', '1.1.rc1'
gem 'database_cleaner', '0.7.1'
gem 'spork', '0.9.0'
gem 'launchy'
gem 'capybara'
gem 'capybara-webkit'
gem 'paperclip', '2.7.0'
gem 'aws-sdk', '~> 1.3.4'
james ~ $ netx
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
postgres 60855 james 5u IPv6 0xffffff800afe09c0 0t0 TCP [::1]:postgresql (LISTEN)
postgres 60855 james 6u IPv4 0xffffff800ff86160 0t0 TCP 127.0.0.1:postgresql (LISTEN)
postgres 60855 james 7u IPv6 0xffffff800afdf700 0t0 TCP [fe80:1::1]:postgresql (LISTEN)
CREATE OR REPLACE FUNCTION calculate_dialup(
hours real,
service_dialup_id int
) RETURNS real as $$
DECLARE
dialup service_dialups%ROWTYPE;
excess_usage_charge real := 0;
BEGIN
SELECT * INTO dialup FROM service_dialups WHERE id = service_dialup_id;
-- ...
class Trie
def initialize
@root = {}
end
def build(string)
node = @root
string.chars.each do |char|
node[char] ||= {}
require "benchmark"
trie = Trie.new
dictionary = IO.read("/usr/share/dict/words").split("\n")
puts "/usr/share/dict/words has #{dictionary.size} words."
Benchmark.bm(15) do |benchmark|
benchmark.report("build (iterative)") do
trie = Trie.new
PATH=/usr/local/bin:$PATH
@jamesmoriarty
jamesmoriarty / git_bash_editor.sh
Created July 3, 2012 00:08
There was a problem with the editor 'vi'.
$ git commit
error: There was a problem with the editor 'vi'.
Please supply the message using either -m or -F option.
$ echo $?
1
$ git config --global core.editor /usr/bin/vim
$ git commit
[feature/tag-search 0167ee2] Merge branch 'master' of github.com:jamesmoriarty/project-x into feature/tag-search
$ echo $?
0