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 / irb.rb
Created March 16, 2012 08:54
render erb template
1.9.2p290 :013 > render_erb("Hey, <%= first_name %> <%= last_name %>", :first_name => "James", :last_name => "Moriarty")
=> "Hey, James Moriarty"
@jamesmoriarty
jamesmoriarty / irb.rb
Created March 27, 2012 02:31
Ruby Object Configuration Block
1.9.2p290 :083 > MyObject.configure do |config|
1.9.2p290 :084 > config.logger = STDOUT
1.9.2p290 :085?> end
=> MyObject
1.9.2p290 :190 > MyObject.new
=> #<MyObject:0x000001009ae268 @logger=#<IO:<STDOUT>>>
1.9.2p290 :191 > MyObject.new(:logger => nil)
=> #<MyObject:0x000001009a6928 @logger=nil>
@jamesmoriarty
jamesmoriarty / hack.sh
Created April 1, 2012 02:05 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
class Vector2
# A 2 coordinate vector.
# http://en.wikipedia.org/wiki/Coordinate_vector
# @param x The x coordinate of the vector
# @param y The y coordinate of the vector
constructor:(@x = 0, @y = 0) ->
# Add 2 vectors.
# @param vector A vector
# @return vector
javascript:document.body.contentEditable='true'; document.designMode='on'; void 0
@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)