Skip to content

Instantly share code, notes, and snippets.

@fgrehm
fgrehm / gist:186797
Created September 14, 2009 17:48 — forked from wiecklabs/gist:186777
class Address # Our custom, embedded-value type
accessor :address => String
accessor :address_2 => String
accessor :city => String
accessor :state => String
accessor :zip_code => String
orm.map_type do |signature, types|
signature.from [self]
signature.typecast_left method(:__load__)
@fgrehm
fgrehm / Results JRuby
Created March 9, 2012 00:51 — forked from sam/gist:2002262
Router Benchmark
Rehearsal -------------------------------------------------------------
INSERTION STATIC : Tree 0.334000 0.000000 0.334000 ( 0.334000)
INSERTION STATIC : Regexp 0.244000 0.000000 0.244000 ( 0.244000)
MATCHING STATIC : Tree 1.297000 0.000000 1.297000 ( 1.297000)
MATCHING STATIC : Regexp 13.382000 0.000000 13.382000 ( 13.382000)
--------------------------------------------------- total: 15.257000sec
user system total real
INSERTION STATIC : Tree 0.045000 0.000000 0.045000 ( 0.045000)
INSERTION STATIC : Regexp 0.106000 0.000000 0.106000 ( 0.106000)
@fgrehm
fgrehm / ClientSideValidations_TwitterBoostrap_SimpleForm.coffee
Created September 18, 2012 14:10 — forked from ddarren/ClientSideValidations_TwitterBoostrap_SimpleForm.js
Script to Make Client Side Validations Work w/ Twitter Bootstrap & Simple Form
jQuery ($) ->
$("div.control-group").focusout ->
$this = $(this)
if !$this.hasClass("error")
$this.addClass("success")
ClientSideValidations.formBuilders['SimpleForm::FormBuilder'].wrappers.bootstrap =
add: (element, settings, message) ->
wrapper = element.closest(".#{settings.wrapper_class}")
if element.data('valid') != false
@fgrehm
fgrehm / deploy.rake
Last active July 27, 2018 23:31 — forked from njvitto/deploy.rake
Rakefile to deploy and rollback to Heroku in two different environments (staging and production) for the same app
# Deploy and rollback on Heroku in staging and production
namespace :deploy do
PRODUCTION_APP = 'YOUR_PRODUCTION_APP'
STAGING_APP = 'YOUR_STAGING_APP'
REMOTE = ENV["REMOTE_HOST"] || "git@heroku.com"
def heroku_cmd(cmd)
Bundler.with_clean_env do
sh "heroku #{cmd}"
@fgrehm
fgrehm / en.yml
Last active December 16, 2015 10:49 — forked from leemeichin/url_validator.rb
en:
activemodel:
errors:
messages:
invalid_url: "must be a valid URL"
if ! $(psql template1 -c 'SHOW SERVER_ENCODING' | grep -q UTF8); then
psql postgres -c "update pg_database set datallowconn = TRUE where datname = 'template0';"
psql template0 -c "update pg_database set datistemplate = FALSE where datname = 'template1';"
psql template0 -c "drop database template1;"
psql template0 -c "create database template1 with template = template0 encoding = 'UTF8';"
psql template0 -c "update pg_database set datistemplate = TRUE where datname = 'template1';"
psql template1 -c "update pg_database set datallowconn = FALSE where datname = 'template0';"
fi