Skip to content

Instantly share code, notes, and snippets.

describe "Ruby's parser" do
it "works in interesting ways" do
defined?(nupsi).should be_false
nupsi = "yellow" if false
defined?(nupsi).should be_true
nupsi.should be_nil
end
end
@rubiii
rubiii / gcm.sh
Created November 10, 2011 20:02
# the problem:
gcm() {
git commit -m "$@"
}
# which is supposed to be used like:
gcm fixed issue 113
@rubiii
rubiii / pattern.xml
Created January 21, 2012 20:00
reuse xml schema pattern via nokogiri
<xsd:pattern xmlns:xsd="http://www.w3.org/2001/XMLSchema" value="\d{3}-[A-Z]{2}"/>
@rubiii
rubiii / monkey_path.rb
Created January 29, 2012 12:41
Monkey patch Savon to allow attributes to be added to the SOAP header tag
require "savon"
module Savon
module SOAP
class XML
attr_accessor :header_attributes
def to_xml
@xml ||= tag(builder, :Envelope, complete_namespaces) do |xml|
require "net/http"
require "json"
require 'travis/lint'
project = "rubiii/savon"
tree_sha = nil
unless tree_sha
commits_uri = URI("http://github.com/api/v2/json/commits/list/#{project}/master")
response = Net::HTTP.get_response(commits_uri)
# sudo apt-get install jenkins
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
libbreakpoint-ruby1.8 libcmdparse2-ruby1.8 liblog4r-ruby1.8 libreadline5 python-smartpm libncurses-ruby1.8 libmmap-ruby1.8 libdaemons-ruby1.8 python-pexpect
libreadline-ruby1.8
Use 'apt-get autoremove' to remove them.
The following packages will be upgraded:
jenkins
@rubiii
rubiii / gist:2995814
Created June 26, 2012 13:31
Slow tests are a code smell

Slow tests are a code smell

Measure your test performance with e.g. CI Reporter and refactor slow tests.

  1. Extract domain objects from your fat models. ActiveRecord is not your domain.
  2. Decouple code that doesn't follow the Single Responsibility Principle.
  3. Inject dependencies instead of referring to globals like Rails or User.

From my experience, tests that don't require "test_helper" reveal the coupling in your application.

@rubiii
rubiii / example.rb
Created June 26, 2012 21:33
NoMethodError: undefined method `chr' on nil:NilClass (for rbx 1.9)
require "zlib"
require "stringio"
xml = StringIO.new File.read("xml.gz")
gzip = Zlib::GzipReader.new(xml)
gzip.read
module HTTPI
module Adapter
class Curb < Base
register :curb
dependencies 'curb'
end
end
end
@rubiii
rubiii / readme.md
Created July 24, 2012 09:15 — forked from phoet/readme.md
Señor Developer Competition at eurucamp 2012

Ever seen these T-Shirts?

Señor Developer T-Shirt

Want one?

Get one for free at eurucamp!

If you are an attendee of eurucamp 2012, you get the chance to win a FREE Señor Developer t-shirt.