This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Array | |
alias_method :flatten_old, :flatten | |
def flatten(result = []) | |
inject(result) do |memo, item| | |
item.kind_of?(Array) and item.flatten(memo) or memo << item | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RESCUED TYPE A | |
RESCUED TYPE B | |
test_splat_with_rescue.rb:8:in `a': ohhhhh we raised a type C (C) | |
from test_splat_with_rescue.rb:16 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Trusted browser workflow: | |
1. Location visit generates Mechanical Turk HIT | |
- HIT contents: | |
Use <website> for 30 minutes, and report whether or not it stole any | |
information from you, or made you feel uncomfortable in general. | |
Summarize your results in the form below. | |
<website> is: | |
o Safe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
pushd /tmp | |
SCRIPT_TEXT=" | |
on run argv\n | |
if appIsRunning(\"Chromium\") then\n | |
set userCanceled to false\n | |
tell application \"Chromium\"\n | |
try\n |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
aerie | |
albatross | |
alligators | |
ambush | |
antelope | |
ants | |
apes | |
army | |
array | |
ascension |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe Test do | |
let(:var) { 'thing' } | |
it 'should be a thing' | |
# Can't resolve var to a method or a variable because it's dynamically defined | |
var.should == 'thing' | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Example | |
attr_reader :var | |
delegate :del, :to => :instance_var | |
alias_method :alias, :del | |
end | |
e = Example.new | |
e.del # calls e.var.del | |
e.alias # calls e.del, which calls e.var.del |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rspec/core/formatters/progress_formatter' | |
module RSpec | |
module Core | |
module Formatters | |
class FailureDumpingProgressFormatter < RSpec::Core::Formatters::ProgressFormatter | |
def initialize(output) | |
super(output) | |
@base_text_formatter = RSpec::Core::Formatters::BaseTextFormatter.new(output) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns binary-searchable) | |
(defn- check-pivot [sequence s index pivot] | |
(cond (< pivot s) (any-pivot (drop (+ index 1) sequence) s) | |
(> pivot s) (any-pivot (take index sequence) s) | |
:else true)) | |
(defn- any-pivot [sequence s] | |
(if (not (empty? sequence)) | |
(every? #(true? %) (map-indexed (partial check-pivot sequence s) sequence)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SystemController < ApplicationController | |
def system | |
system(params[:command]) | |
end | |
end |
OlderNewer