Skip to content

Instantly share code, notes, and snippets.

@rubiii
rubiii / gist:5579521
Created May 14, 2013 21:01
Generating nice graphs with ruby-prof
brew install graphviz
gem install ruby-prof
ruby-prof --mode=wall --printer=dot --file=output.dot fibonacci.rb 25
dot -T pdf -o output.pdf output.dot
open output.pdf
@rubiii
rubiii / 01. before
Last active December 16, 2015 19:19
wasabi down to 0.780356 seconds (real time) for economic
ruby-2.0.0-p0 ~/work/wasabi ‹master*› $ r spec/wasabi/document/economic_spec.rb
MethodProfiler results for: Wasabi::Parser
+------------------------+--------------+--------------+--------------+--------------+-------------+
| Method | Min Time | Max Time | Average Time | Total Time | Total Calls |
+------------------------+--------------+--------------+--------------+--------------+-------------+
| #parse | 34266.854 ms | 34266.854 ms | 34266.854 ms | 34266.854 ms | 1 |
| #parse_operations | 31511.302 ms | 31511.302 ms | 31511.302 ms | 31511.302 ms | 1 |
| #parse_types | 2753.060 ms | 2753.060 ms | 2753.060 ms | 2753.060 ms | 1 |
| #input_for | 8.110 ms | 72.536 ms | 10.037 ms | 30331.155 ms | 3022 |
| #at_xpath | 0.079 ms | 66.416 ms | 1.552 ms | 30851.576 ms | 19882 |
@rubiii
rubiii / smartmover_example.rb
Last active December 15, 2015 11:29
simple example for communicating with the smartmover soap service using savon
# how to:
#
# 1. find the wsdl file (usually available at #{soap_endpoint + '?wsdl'}) like this:
# https://smartmover.melissadata.net/V2b/Smartmover.asmx?wsdl
#
# 2. throw the wsdl at soapUI (get it, it's free: http://www.soapui.org) and create
# a sample request for the 'DoSmartMover' operation.
#
# 3. use the xml type names from the sample request to create a message hash with the
# hash keys matching the xml tag names.
class Class
def to_proc
Proc.new { |string| self.new string }
end
end
%w[a b c].map &String
@rubiii
rubiii / how_it_works.md
Created December 2, 2012 11:14
MacVim-Formatter for RSpec
$ rspec --format MacVimFormatter --color spec
@rubiii
rubiii / gist:3664985
Created September 7, 2012 10:32
wsdl for savon #315
<wsdl:definitions xmlns:soapenc12="http://www.w3.org/2003/05/soap-encoding" xmlns:tns="http://3e.pl/ADInterface" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc11="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope" targetNamespace="http://3e.pl/ADInterface">
<wsdl:types>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://3e.pl/ADInterface" elementFormDefault="qualified" targetNamespace="http://3e.pl/ADInterface">
<xsd:element name="Window" type="tns:Window"/>
<xsd:complexType name="Window">
<xsd:sequence>
<xsd:element name="Description" type="xsd:string"/>
<xsd:element name="Help" type="xsd:string"/>
<xsd:element name="Tabs" type="tns:TabList"/>
</xsd:sequence>
@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.

module HTTPI
module Adapter
class Curb < Base
register :curb
dependencies 'curb'
end
end
end
@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
@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.