Skip to content

Instantly share code, notes, and snippets.

@gabehollombe
gabehollombe / gist:3c08b0b217b80c2c6467
Last active August 29, 2015 14:09
Spin up an in-memory Hadoop / HDFS instance
# Substitute path/version of hadoop files below
# Note: this will create a directory ./build/test/data/dfs/ to store your HDFS file system in. Clean this up when you're done.
HADOOP_CLASSPATH=/usr/local/Cellar/hadoop/2.4.0/libexec/share/hadoop/yarn/test/hadoop-yarn-server-tests-2.4.0-tests.jar hadoop jar /usr/local/Cellar/hadoop/2.4.0/libexec/share/hadoop/mapreduce/hadoop-mapreduce-client-jobclient-2.4.0-tests.jar minicluster --nnport=8020
require 'ostruct'
def thing
OpenStruct.new(foo: 'FOO')
end
context 'foo' do
it 'returns foo' do
expect(thing.foo).to eq('FOO')
end
@gabehollombe
gabehollombe / fizzbuzz_without_conditionals.clj
Created July 29, 2015 12:05
FizzBuzz without conditionals
(defn fizz-buzz-n
[n]
(or
(and (zero? (mod n 15)) "FizzBuzz")
(and (zero? (mod n 3)) "Fizz")
(and (zero? (mod n 5)) "Buzz")
n))
(println (clojure.string/join "\n"
(->> (take 25 (iterate inc 1))
#!/usr/bin/ruby
require 'rubygems'
require 'blather/client'
setup 'moderator@enterprise-g.local', 'moderator'
message :chat? do |m|
puts m.read_content(:meeting)
end
@gabehollombe
gabehollombe / gist:293193
Created February 3, 2010 00:11
ActiveRecord doesnt like foreign keys?
class Category < ActiveRecord::Base
has_many :assignments, :foreign_key => 'category_uuid', :primary_key => 'uuid'
end
class Post < ActiveRecord::Base
has_many :assignments, :foreign_key => 'post_uuid', :primary_key => 'uuid'
end
class Assignment < ActiveRecord::Base
belongs_to :post, :foreign_key => 'uuid', :primary_key => 'post_uuid'
@gabehollombe
gabehollombe / Better version
Created May 20, 2010 06:26
Capybara: a better way to check if text is visible
### IMPORTANT NOTE: See the comment thread below for a more concise way to determine this now, using has_css...
#A better 'I should not see' for Capybara that lets jQuery determine visibility of the text you're looking for.
Then /^"([^\"]*)" should not be visible$/ do |text|
finder_script = %{
function is_text_visible_on_page(text) {
var match = false;
$('*:visible')
LabelForNestedStories AnotherLabel
- Feature title (single line description in parens)
- Some other feature (you don't need blank lines seperating your stories but you can use them for extra readability in the file)
- Another feature
Multi-line description of this feature.
Use two tabs to indent for easy visual parsing.
[] Chores look like checkboxes (short description in parens)
grammar PivotalStories
rule stories
story*
end
rule story
feature*
end
rule feature
@gabehollombe
gabehollombe / Example txt to pivotal format
Created September 28, 2010 06:03 — forked from cjheath/Example Treetop grammar fragment
Parsing a text file for Pivotal Tracker stories with Treetop
LabelOne LabelTwo
- feature one (description one)
- feature two (description two)
- feature three with multiline desc following
desc line 1
desc line 2
desc line 3
@gabehollombe
gabehollombe / discover.rb
Created March 25, 2011 00:01
Get autotest to run on spec/integration changes and friends
Autotest.add_hook :initialize do |at|
at.add_mapping(%r%^spec/integration/.*_spec.rb$%, true) { |filename, _|
filename
}
at.add_mapping(%r%^app/(models|controllers|helpers|lib)/.*rb$%, true) {
at.files_matching %r%^spec/integration/.*_spec.rb$%
}
at.add_mapping(%r%^app/views/(.*)$%, true) {