Skip to content

Instantly share code, notes, and snippets.

@thilo
thilo / .rvmrc
Last active August 29, 2015 14:03
GC Tweaks for faster tests for ruby 2.1.x
rvm --create use ruby-2.1.2
export RUBY_GC_HEAP_INIT_SLOTS=1000000
export RUBY_GC_HEAP_FREE_SLOTS=500000
export RUBY_GC_HEAP_GROWTH_FACTOR=1.1
export RUBY_GC_HEAP_GROWTH_MAX_SLOTS=10000000
export RUBY_GC_MALLOC_LIMIT_MAX=500000000
export RUBY_GC_MALLOC_LIMIT_GROWTH_FACTOR=1.1
<%= _("${TM_SELECTED_TEXT/"/\\"/g}") %> #rails gettext snippet for HTML text
_("${TM_SELECTED_TEXT/"/\\"/g}") #rails gettext snippet for ruby strings
To use same shortcut for both scope them a following
text.html.ruby #for html
string.quoted.single.ruby|string.quoted.double.ruby #for ruby strings
describe "store localized date strings" do
class User < ActiveRecord::Base
end
it "should store a german date string" do #failing
user = User.create! :date_of_birth => '20.12.1980'
user.date_of_birth.should == Date.parse('1980-12-20')
end
it "should store a international date string" do
framework 'Cocoa'
app = NSApplication.sharedApplication
window = NSWindow.alloc.initWithContentRect([0,0,200,60],
styleMask:NSTitledWindowMask | NSClosableWindowMask | NSResizableWindowMask ,
backing:NSBackingStoreBuffered,
defer:false)
class Salute
attr_writer :stalutation
def show_salutation(sender)
@stalutation.stringValue = "Hi MacRuby!"
end
end
require 'hotcocoa'
include HotCocoa
application do
window = window(title: 'Hello World', frame: [0,0,200,60])
label = label(text:'Hello World', layout: {align: :center})
window << label
end
# fixes deserialization from xml with nested associations
# based on http://www.xcombinator.com/2008/08/11/activerecord-from_xml-and-from_json-part-2/
module ActiveRecord #:nodoc:
module Serialization
def from_hash( hash )
h = hash.dup
h.each do |key,value|
case value.class.to_s
@thilo
thilo / prefix for gems
Created May 11, 2010 14:45
how to install gem executables with a prefix
gem install gem_with_executable --format-executable
@thilo
thilo / gist:414595
Created May 26, 2010 15:00
a rather minimal dmg script for xcode
set -ex
dir="$TEMP_FILES_DIR/disk"
dmg="$BUILT_PRODUCTS_DIR/$PROJECT_NAME.dmg"
dmg_options="-imagekey zlib-level=9 -format UDZO"
rm -rf "$dir"
mkdir "$dir"
cp -R "$BUILT_PRODUCTS_DIR/$PROJECT_NAME.app" "$dir"
chmod -Rf go-w "$dir"
@thilo
thilo / custom_steps.rb
Created June 4, 2010 09:33 — forked from terrainoob/custom_steps.rb
capybara with subdomains
Given /^I visit subdomain "(.+)"$/ do |sub|
#host! "#{sub}.example.com" #for webrat
Capybara.default_host = "#{sub}.example.com" #for Rack::Test
Capybara.app_host = "http://#{sub}.example.com:9887" if Capybara.current_driver == :culerity
################################################################################
# As far as I know, you have to put all the {sub}.example.com entries that you're
# using in your /etc/hosts file for the Culerity tests. This didn't seem to be
# required for Rack::Test
################################################################################