Skip to content

Instantly share code, notes, and snippets.

View joshuakfarrar's full-sized avatar
💻
EitherT[IO, Throwable, Human]

Joshua K. Farrar joshuakfarrar

💻
EitherT[IO, Throwable, Human]
View GitHub Profile
[11] pry(main)> hash = Hash.new
=> {}
[12] pry(main)> hash.merge(:a => 1)
=> {:a=>1}
[13] pry(main)> hash.inspect
=> "{}"
[14] pry(main)> hash = hash.merge(:a => 1)
=> {:a=>1}
[15] pry(main)> hash
=> {:a=>1}
irb(main):061:0> @taxon.products.unscope(:order).ascend_by_master_price.each do |product|
irb(main):062:1* puts product.price
irb(main):063:1> end
...
15.99
...
15.99
...
22.99
...
[9] pry(main)> def returns_hash
[9] pry(main)* { :c => :d }
[9] pry(main)* end
=> nil
[10] pry(main)> a = { :a => :b }
=> {:a=>:b}
[11] pry(main)> a.merge! returns_hash
=> {:a=>:b, :c=>:d}
[12] pry(main)> a
=> {:a=>:b, :c=>:d}
@joshuakfarrar
joshuakfarrar / board.js
Last active August 29, 2015 14:12
simple shapes for tic-tac-toe
define(function() {
var Board = Class.extend({
paint: function(context) {
var width = context.canvas.width,
height = context.canvas.height;
var padding = 5;
for (var i = 0; i < 4; i++) {
var line;
***************************************************************************
[FATAL] Spree does not work with the protected_attributes gem installed!
You MUST remove this gem from your Gemfile. It is incompatible with Spree.
***************************************************************************
@joshuakfarrar
joshuakfarrar / quick-find.rb
Last active August 29, 2015 14:14
Princeton Algorithms - Week One - Quick Find
class QuickFind
attr_accessor :id
def initialize(n)
@id = Array.new(n) { |e| e = e }
end
def connect(a, b)
c = @id[a]
d = @id[b]
@joshuakfarrar
joshuakfarrar / quick-union.rb
Created January 25, 2015 05:41
Princeton Algorithms - Week One - Quick Union
class QuickUnion
attr_accessor :id
def initialize(n)
@id = Array.new(n) { |e| e = e }
end
def connect(a, b)
@id[b] = a
end
@joshuakfarrar
joshuakfarrar / weighted-quick-union.rb
Last active August 29, 2015 14:14
Princeton Algorithms - Week One - Weighted Quick Union
class WeightedQuickUnion
attr_accessor :id
def initialize(n)
@id = Array.new(n) { |e| e = e }
@size = Array.new(n) { |e| e = 1 }
end
def connect(a, b)
c = parent_of(a)
irb(main):010:0> true * true
NoMethodError: undefined method `*' for true:TrueClass
from (irb):10
from /Users/sent1nel/.rbenv/versions/2.0.0-p247/bin/irb:12:in `<main>'
irb(main):013:0> true - nil
NoMethodError: undefined method `-' for true:TrueClass
from (irb):13
from /Users/sent1nel/.rbenv/versions/2.0.0-p247/bin/irb:12:in `<main>'
irb(main):014:0> nil - true
NoMethodError: undefined method `-' for nil:NilClass
var gulp = require('gulp');
var bower = require('gulp-bower');
var del = require('del');
gulp.task('clean', function(cb) {
del([
'bower_components'
], cb);
});