Skip to content

Instantly share code, notes, and snippets.

class Dir
def Dir.glob_in(path, *args)
original_dir = Dir.pwd
begin
Dir.chdir(path)
return Dir.glob(*args)
ensure
Dir.chdir(original_dir)
end
@boblail
boblail / Sample use of Pericope
Created October 11, 2010 20:10
Sample use of Pericope
@query = params[:query]
pretty_keywords = []
index_keywords = []
Pericope.split(@query, /[\r\n,;]/).each do |keyword|
if keyword.is_a?(Pericope)
pretty_keywords << keyword.to_s
index_keywords << "(#{keyword.to_a.join(" | ")})"
else
keyword = keyword.strip
@boblail
boblail / Capybara Zombie
Created January 20, 2011 02:08
Notes about capybara's examples which are failing for capyabara-zombie
1) Capybara::Driver::Zombie it should behave like driver with javascript support#drag_to should drag and drop an object
Failure/Error: @driver.find('//div[contains(., "Dropped!")]').should_not be_empty
expected empty? to return false, got true
# /opt/local/lib/ruby/gems/1.8/gems/rspec-expectations-2.4.0/lib/rspec/expectations/fail_with.rb:29:in `fail_with'
# /opt/local/lib/ruby/gems/1.8/gems/rspec-expectations-2.4.0/lib/rspec/expectations/handler.rb:44:in `handle_matcher'
# /opt/local/lib/ruby/gems/1.8/gems/rspec-expectations-2.4.0/lib/rspec/expectations/extensions/kernel.rb:50:in `should_not'
# /opt/local/lib/ruby/gems/1.8/gems/capybara-0.4.0/lib/capybara/spec/driver.rb:93
jQuery draggable.start and draggable.stop events are fired.
@boblail
boblail / test.rb
Created February 26, 2011 03:37
Isolates Google Analytics for Zombie to test
require 'rubygems'
require 'sinatra'
get '/ga' do
<<-HTML
<html>
<head>
<title>Google Analytics Test</title>
</head>
<body>
@boblail
boblail / test.rb
Created February 26, 2011 13:37
Test Google Analytics, new Image, and Zombie
require 'rubygems'
require 'sinatra'
get '/image' do
<<-HTML
<html>
<head>
<title>new Image Test</title>
</head>
<body>
@boblail
boblail / find_easter.cs
Created April 25, 2011 20:44
Calculate the date of Easter given the year
public static DateTime FindEaster( int year ) {
int month, day, century, n, m, i, j, k, z, a, l;
century = year / 100;
n = year % 19;
m = (century - 17) / 25;
i = century - (century >> 2) - (int)((century - m) / 3) + 19 * n + 15;
j = i % 30;
z = (int)(j / 28);
k = j - z * (1 - z * (int)(29 / (j + 1)) * (int)((21 - n) / 11));
@boblail
boblail / gist:2731915
Created May 19, 2012 18:45
A/B Testing; DDD
@boblail
boblail / pdftk.rb
Last active December 16, 2015 00:39 — forked from Echos/pdftk.rb
require 'formula'
class Pdftk < Formula
url 'http://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/pdftk-1.44-src.zip'
homepage 'http://www.pdflabs.com/'
md5 '9eb50fffcd621a627d387750c60982b4'
# depends_on 'gcc' # with "--enable-java" option , required "Homebrew-alt" .
# via : https://github.com/adamv/homebrew-alt/
def install
@boblail
boblail / sql_rocket
Last active December 17, 2015 09:29
Exports a MySQL database as XML, walks the XML stream with nokogiri, and outputs well-formed Postgres SQL
#!/usr/bin/env ruby
# encoding: utf-8
# https://gist.github.com/boblail/5587579
require 'benchmark'
require 'nokogiri'
require 'progressbar'
require 'tempfile'
class SqlRocket < Nokogiri::XML::SAX::Document
@boblail
boblail / ledger.md
Last active January 2, 2016 12:39
Refactor List

Ledger Refactors

  • Stop passing so many arguments to the TransactionEntry directive:
    • accounts and fiscalYears, at least, can be derived from root scope
  • Global months
  • Don't use expand and collapse methods
  • Nodes have both isAccount and resourceType