Skip to content

Instantly share code, notes, and snippets.

View tillsc's full-sized avatar

Till Schulte-Coerne tillsc

View GitHub Profile
@tillsc
tillsc / gist:1898836
Created February 24, 2012 07:50
My ~/.irbrc
#libaries
require 'rubygems' rescue nil
require 'irb/completion'
begin
# load hirb
$: << '/Library/Ruby/Gems/1.8/gems/hirb-0.5.0/lib'
require "hirb"
# start hirb
@tillsc
tillsc / gist:1284040
Created October 13, 2011 11:46
dm-oracle-adapter patch for indices with long table names
def create_index_statement(model, index_name, fields)
table_name = model.storage_name(name)
table_name_short = table_name.split("_").map{|s|s[0..3]}.join("_")
DataMapper::Ext::String.compress_lines(<<-SQL)
CREATE INDEX #{quote_name("i_#{table_name_short}_#{index_name}")} ON
#{quote_name(table_name)} (#{fields.map { |field| quote_name(field) }.join(', ')})
SQL
end
@tillsc
tillsc / gist:1250864
Created September 29, 2011 14:39
dm-oracle-adapter 1.2.0.rc2 -> rake spec
1)
'DataMapper::Adapters::OracleAdapter#create serial properties should not send NULL values' FAILED
expected: /\AINSERT INTO "ARTICLES" \("ID"\) VALUES \(DEFAULT\) RETURNING "ID"/,
got: " ~ (0,033) INSERT INTO \"ARTICLES\" (\"ID\") VALUES (DEFAULT) RETURNING \"ID\" INTO ?" (using =~)
2)
'DataMapper::Adapters::OracleAdapter#create properties without a default should not send NULL values' FAILED
expected: /^INSERT INTO "articles" \("id"\) VALUES \(('.{1,2}'|.{1,2})\)$/i,
got: " ~ (0,005) INSERT INTO \"ARTICLES\" (\"ID\") VALUES (?)" (using =~)
<!DOCTYPE html>
<html lang="de">
<head>
<title>HTML5 Dokument</title>
<meta charset="utf-8">
</head>
<body>
<header>
<h1>Der Header</h1>
</header>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="de">
<head>
<title>HTML4 Dokument</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<div id="branding">
<h1>Der Header</h1>
</div>
@tillsc
tillsc / Linking Data style Rails applications
Created November 10, 2010 08:43
Add this to your ApplicationController to get a linking data style url handling (force usage of 'format' in URLs)
before_filter :ensure_extension
# Force an extension to every url. (LD)
def ensure_extension
redirect_to url_for(:format => (request.format && request.format.symbol) || :html) unless params[:format]
end
# Set a default value for the :format parameter in url_for and *_url/*_path methods.
def default_url_options(options = nil)
{:format => params[:format]}.merge(options || {})