Skip to content

Instantly share code, notes, and snippets.

@robworley
robworley / pdf2eps.sh
Created March 13, 2014 12:13
Convert PDF to EPS
gs -dNOPAUSE -dNOCACHE -dBATCH -sDEVICE=epswrite -sOutputFile=output.eps input.pdf
@robworley
robworley / parallel.rake
Created December 20, 2012 16:49
Decrease setup time when using parallel_tests with rails, postgres and rspec. Significant perf gains when using the SQL schema format or heavyweight custom prepare steps.
namespace :parallel do
task(:prepare_pg, [:count] => "db:test:prepare") do |t, args|
num_processes = ParallelTests.determine_number_of_processes(args[:count])
original_test_env_number = ENV['TEST_ENV_NUMBER']
test_db_name = ActiveRecord::Base.configurations['test']['database']
Postgresql.drop_connections(test_db_name)
db = ActiveRecord::Base.connection
@robworley
robworley / export_pt_label
Last active October 10, 2015 19:17
export_pt_label
#!/usr/bin/env ruby
gem 'activesupport'
gem 'pivotal-tracker'
require 'active_support/core_ext/string'
require 'pivotal_tracker'
API_TOKEN = "YOUR_API_TOKEN"
PROJECT_ID = "YOUR_PROJECT_ID"
@robworley
robworley / clone_data.rb
Created May 20, 2011 20:24
Stream rows from one PostgreSQL database to another, eliminating the majority of ActiveRecord and SQL overhead
def clone_data(src_conn, dest_conn, table_name, options = {})
puts "Cloning #{table_name} data"
copyable = if options[:conditions]
"(SELECT * FROM #{table_name} WHERE #{options[:conditions]})"
else
table_name
end
copy_command = "COPY #{copyable} TO STDOUT"
(function($) {
// Monkey patch jQuery-UI 1.8.1 so IE retains scroll position when opening a dialog.
var oldDialogOpen = $.ui.dialog.prototype.open;
$.ui.dialog.prototype.open = function() {
var originalScrollTop = $(window).scrollTop(),
result = oldDialogOpen.apply(this, arguments);
$(window).scrollTop(originalScrollTop);
};
})(jQuery);