Skip to content

Instantly share code, notes, and snippets.

View richievos's full-sized avatar

Richie Vos richievos

View GitHub Profile
Enumerable.class_eval do
def dump_spark_histogram
element_count_pairs = self.group_by { |x| x }.to_a.map { |el, els| [el, els.size] }
element_count_pairs = element_count_pairs.sort_by(&:first)
max_el_len = element_count_pairs.map(&:first).map(&:to_s).map(&:size).max
element_count_pairs.each do |el, count|
puts("%#{max_el_len}s: #{('=' * count)}" % el)
end
@richievos
richievos / gist:2134865
Created March 20, 2012 12:43
sublime-keymap
// see also https://gist.github.com/1988097
// and http://www.sublimetext.com/docs/commands
[
{ "keys": ["alt+command+ctrl+c"], "command": "copy_path"},
{ "keys": ["ctrl+command+v"], "command": "paste"},
{ "keys": ["command+v"], "command": "paste_and_indent"}
]
@richievos
richievos / another_before.rb
Created November 21, 2011 21:05 — forked from bjeanes/example_its_lets.rb
Spectastrophe #1
describe FashionSituation do
before { @situation = FashionSituation.new(:shirt => false, :shoes => false, :shorts => true) }
it "should be inappropriate at a restaurant" do
@situation.location = 'restaurant'
@situation.should_not be_appropriate
end
it "should be inappropriate at work" do
@situation.location = 'work'
@situation.should_not be_appropriate
end
@richievos
richievos / 1-before_spec.rb
Created November 21, 2011 05:33 — forked from ragaskar/1-before_spec.rb
Spectastrophe #1
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe "Something doppelganger" do
describe "RailCar" do
let(:gateway) { RailCar.new :login => "a", :password => "b" }
describe "#commit" do
let(:response) { railcar.send :commit, request, {} }
describe "response" do
require 'spec_helper'
require 'parslet/rig/rspec'
require 'tv_show_parslet'
describe TvShowParslet do
let(:parser) { described_class.new }
def p(string)
parse(string, :trace => true)
@richievos
richievos / 1-before_spec.rb
Created November 19, 2011 12:54
Spectastrophe #1
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe "Something doppelganger" do
describe "RailCar" do
let(:gateway) { RailCar.new :login => "a", :password => "b" }
describe "#commit" do
let(:response) { railcar.send :commit, request, {} }
describe "response" do
@richievos
richievos / html_formatter.rb.diff
Created August 29, 2011 03:11
Approximation of what adding times to the html formatter would look like -- Final version would be more DRY and what not
diff --git a/vendor/gems/rspec-1.2.9/lib/spec/runner/formatter/html_formatter.rb b/vendor/gems/rspec-1.2.9/lib/spec/runner/formatter/html_formatter.rb
index 2d0c65d..dd86a71 100644
--- a/vendor/gems/rspec-1.2.9/lib/spec/runner/formatter/html_formatter.rb
+++ b/vendor/gems/rspec-1.2.9/lib/spec/runner/formatter/html_formatter.rb
@@ -56,11 +56,12 @@ module Spec
def example_started(example)
@example_number += 1
+ @time = Time.now
end
require 'pp'
votes = {
"gus" => ["Colonel Panic", "Cigar Heroes"],
"shinji" => ["Bomb Squad","Taco Town"],
"nawara" => ["Colonel Panic", "Taco Town", "Danger!! Death Ray"],
"dodos" => [],
"richie" => ["Bomb Squad", "Death Ray", "Bomb Ray Death Squad"],
"colin" => ["Colonel Panic", "Taco Town"],
"joey" => ["Danger!! Death Ray", "Bomb Squad"]
AppTweeter = Struct.new(:status) do
class << self
def new_user(user)
update("#{user.name} just signed up!")
end
def update(status)
status = "[#{Rails.env}] #{status}" unless Rails.env.production?
Delayed::Job.enqueue AppTweeter.new(status)
end
class CreatedContext
def p
Proc.new { |x| puts "proc: #{self.inspect} on #{x.inspect}"}
end
def l
lambda { |x| puts "lambda: #{self.inspect} on #{x.inspect}"}
end
end