Skip to content

Instantly share code, notes, and snippets.


Jesper Rønn-Jensen jesperronn

View GitHub Profile
tobiashm / capistrano-database.rb
Last active Aug 29, 2015
Capistrano recipe for creating PostgreSQL database user
View capistrano-database.rb
Capistrano::Configuration.instance(true).load do
namespace :db do
desc "Create database user for current site"
task :create_user, roles: :db do
config ="..", "database.yml")
config =
config = YAML.load(config)
fail "No database config for #{stage}" unless config[stage.to_s]
username, password = config[stage.to_s].values_at("username", "password")
run "#{sudo as: 'postgres'} psql -d postgres" do |channel, _, _|
View convert_encoding.rb
#!/usr/bin/env ruby -KU
require 'optparse'
require 'ostruct'
require 'iconv'
SCRIPT_NAME = "File Character Encoding Converter"
class FileEncodingConverterOptionParser
View screenshots.rb
# This is an example of how you can set up screenshots for your
# browser testing. Just run cucumber with --format html --out report.html
module Screenshots
def embed_screenshot(id)
%x(scrot #{$ROOT_PATH}/images/#{id}.png)
jpmckinney / twitter-bootstrap-ie6.scss
Created Nov 14, 2011
SCSS additions to make Twitter Bootstrap work in IE6
View twitter-bootstrap-ie6.scss
// Assumes you are using <html> conditional classes as described here:
.lt-ie7 {
// blockquote small:before{content:'\2014 \00A0';}
blockquote small:before{content:"";}
// [class*="span"]{display:inline;float:left;margin-left:20px;}
pcreux / helper_steps.rb
Created Jan 23, 2012
Cucumber step to match tables
View helper_steps.rb
module TableMatchHelper
# @param table [Array[Array]]
# @param expected_table [Array[Array[String]]]
# The expected_table values are String. They are converted to
# Regexp when they start and end with a '/'
# Example:
# assert_table_match(
# [["Name", "Date"], ["Philippe", "Feb 08"]],
# [["Name", "Date"], ["Philippe", "/\w{3} \d{2}/"]]
mlangenberg / deploy.rb
Created Jun 25, 2012
Capistrano task to download all application log files (including logrotated)
View deploy.rb
namespace :log do
desc "Downloads application logs to ./log/deploy/<RAILS_ENV>/<TIMESTAMP>/"
task :fetch, :roles => :app do
source = "#{shared_path}/log/#{rails_env}.log*"
files_per_host = {}
run "ls #{source}" do |channel, stream, data|
files_per_host[channel[:host]] = data.split("\n")
destination = File.join('log', 'deploy')
mguymon / factory_girl_helper.rb
Last active Jan 27, 2016
RSpec helper for adding find_or_create to FactoryGirl for Rails
View factory_girl_helper.rb
module FactoryGirlHelper
def find_or_create(*args)
name = args.shift
clazz = nil
# convert from underscores String to camelcase Class
if name.is_a? Hash
name = name.first[0]
clazz = name.first[1].to_s.camelize.constantize
rwjblue /
Last active May 13, 2016
Guide to using drip with JRuby

#Overview drip is an awesome command line tool that can be used to dramatically lower perceived JVM startup time. It does this by preloading an entirely new JVM process\instance and allowing you to simply use the preloaded environment. This has extraordinary results with jruby.

We reduced time to run rake environment from 13 seconds to a mere 3.5 seconds. This is actually at or near MRI 1.9.3p327 (with falcon patch) speeds!

Adding a few addition jruby options will reduce startup time even further (down to 1.69 seconds).

#Install Drip Install drip if you haven't already (see

drewsberry /
Created Mar 30, 2015
ublock Analytics Filter

ublock Allow Google Analytics

  • Go to ublock settings and select the "Filters" tab

  • In the box, copy the following filter rule in:


  • Click "Apply changes"

  • You're done

# Before we start we'll make sure that we have a scaffolded app just to make sure we can test everything is working.
docker-compose up
docker-compose run app bundle exec rails generate scaffold post title body:text published:boolean RAILS_ENV=development
You can’t perform that action at this time.