Skip to content

Instantly share code, notes, and snippets.

View dgoldie's full-sized avatar

Doug Goldie dgoldie

  • Mountain View, CA
View GitHub Profile
@dgoldie
dgoldie / match.exs
Created July 23, 2014 07:33 — forked from alco/match.exs
import M
File.read("match.exs") |> match({:ok, bin}, bin) |> String.length
#=> 156
s = """
id;name;value
1;foo;hi
2;bar;bye
"""
@dgoldie
dgoldie / Guardfile
Last active December 25, 2015 08:29 — forked from Emerson/Guardfile
guard 'minitest' do
# with Minitest::Unit
watch(%r|^test/(.*)\/?test_(.*)\.rb|)
watch(%r|^lib/(.*)([^/]+)\.rb|) { |m| "test/#{m[1]}test_#{m[2]}.rb" }
watch(%r|^test/test_helper\.rb|) { "test" }
# Rails 4 - App Files
watch(%r|^app/controllers/(.*)\.rb|) { |m| "test/controllers/#{m[1]}_test.rb" }
watch(%r|^app/helpers/(.*)\.rb|) { |m| "test/helpers/#{m[1]}_test.rb" }
@dgoldie
dgoldie / Guardfile
Created April 6, 2012 08:50 — forked from drnic/Guardfile
An example Guardfile with the works for a Rails app
guard 'rspec', :version => 2 do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" }
# Rails example
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
@dgoldie
dgoldie / hack.sh
Created April 1, 2012 09:07 — 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
#
@dgoldie
dgoldie / bootstrap_form_builder.rb
Created January 2, 2012 18:14 — forked from jamiepenney/bootstrap_form_builder.rb
Form builder for Twitter Bootstrap form elements.
class BootstrapFormBuilder < ActionView::Helpers::FormBuilder
def get_error_text(object, field, options)
if object.nil? || options[:hide_errors]
""
else
errors = object.errors[field.to_sym]
if errors.empty? then "" else errors.first end
end
end
Then /^(?:|I )should see "([^\"]*)"(?: within "([^\"]*)")?$/ do |text, selector|
with_scope(selector) do
if defined?(Spec::Rails::Matchers)
page.should have_xpath("//*[text()='#{text}']", :visible => true)
else
assert page.has_xpath("//*[text()='#{text}']", :visible => true)
end
end
end
@dgoldie
dgoldie / rcov.rake
Created June 7, 2011 20:35 — forked from jstirk/rcov.rake
rcov rake task for Rails 3, cucumber, rspec
# Forked to get it working with Rails 3 and RSpec 2
# Updated to aggregate Cucumber and rspec correctly
# Updated to not fail in production when Cucumber, rspec aren't available
#
# From http://github.com/jaymcgavren
#
# Save this as rcov.rake in lib/tasks and use rcov:all =>
# to get accurate spec/feature coverage data
#
# Use rcov:rspec or rcov:cucumber
//
// Backbone.Rails.js
//
// Makes Backbone.js play nicely with the default Rails setup, i.e.,
// no need to set
// ActiveRecord::Base.include_root_in_json = false
// and build all of your models directly from `params` rather than
// `params[:model]`.
//
// Load this file after backbone.js and before your application JS.
@dgoldie
dgoldie / mice.css
Created December 6, 2010 12:36 — forked from jeffkreeftmeijer/mice.css
spike of node.js and web sockets
.mouse, #preview{
position: absolute;
background-repeat: no-repeat;
height: 22px;
min-width: 15px;
z-index: 100;
}
.mouse{
background-image: url('../images/cursor.png');