Skip to content

Instantly share code, notes, and snippets.

View ahx's full-sized avatar

Andreas Haller ahx

View GitHub Profile
From 086d026ea6f8da725e2f9cc254f0c069504e4510 Mon Sep 17 00:00:00 2001
From: Andreas Haller <[email protected]>
Date: Thu, 1 Apr 2010 16:09:35 +0200
Subject: [PATCH] show to_json issue
---
spec/orm/activerecord_spec.rb | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/spec/orm/activerecord_spec.rb b/spec/orm/activerecord_spec.rb
.bundle
db/*.sqlite3
log/*.log
tmp/**/*
From 935d1fe1a01f6b48f84cd1c6dbbe6bbd1318767a Mon Sep 17 00:00:00 2001
From: Andreas Haller <[email protected]>
Date: Tue, 16 Mar 2010 00:04:36 +0100
Subject: [PATCH] dont use Test::Unit::AssertionFailError (its gone in 1.9)
---
koans/edgecase.rb | 2 +-
src/edgecase.rb | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
# encoding: UTF-8
# Ein Zwölftonspielgenerator (nach Joseph Matthias Hauer)
# Language: German
# So läufts:
# Wenn Ruby 1.9: http://github.com/jvoorhis/midiator installieren, sonst
# sudo gem install midiator
# ruby zwölftonspiel.rb
# enjoy!
# remove content of script tags using Sanitize
require 'sanitize'
html = '<p>Do not<script>fail();</script> kill the <a href="/cats/42">cat</a>.</p>'
Sanitize.clean(html, Sanitize::Config::BASIC.merge(
:transformers => lambda { |env|
node = env[:node]
return unless node.name.downcase == 'script'
node.children.each(&:remove)
@ahx
ahx / csv2vcf
Created November 22, 2009 13:46
Einfache Umwandlung von aus Outlook exportiertem CSV (Win XP, Deutsch) in Apple Adressbook VCF
#!/usr/bin/env ruby
# encoding: UTF-8
# Umwandlung von Outlook exportiertes CSV (Win XP, Deutsch) in Apple Adressbook VCF
# Usage:
# csv2vcf adressen.csv > adressen.vcf
# requires Ruby 1.9
require 'csv'
# geme (aka mategem, vigem..) - open gem source in $EDITOR
geme() {
_geme_init_gemdir
$EDITOR $GEMDIR/gems/`$(which ls) $GEMDIR/gems | grep -x $1.* | sort | tail -1`/
}
_geme() {
_geme_init_gemdir
COMPREPLY=()
local curw=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=($(compgen -W '$(ls $GEMDIR/gems)' -- $curw));
From d22977fdec95113a937f557fdc07b7fe3c6c77c4 Mon Sep 17 00:00:00 2001
From: Andreas Haller <[email protected]>
Date: Tue, 22 Sep 2009 15:43:05 +0200
Subject: [PATCH] fixes checking for block parameter on Ruby 1.9
I replaced
rb_block_given_p() != Qtrue
with
!rb_block_given_p()
# my stupid way to switch between ruby versions for one terminal session
# (ruby 1.9 is in /usr/local/bin. 1.8 is in /usr/bin)
export ORIGPATH=$PATH
alias r19='export PATH=$ORIGPATH' # currently ruby 1.9 is the default on this installation
alias r18='export PATH=/usr/bin:$ORIGPATH'
//######### How to send authenticity_token automatically with every Ajax.Request.
//######### This will be obsolete in Rails 3 (as Yehuda mentiones here : https://rails.lighthouseapp.com/projects/8994/tickets/2696-prototypehelper-no-auth-token-param-for-get-requests#ticket-2696-2)
//######### Put this in your application.js
// Monkeypatches Ajax.Base to include authenticity_token parameter unless its already there
(function() {
function insert_auth_token (options) {
var o = options || {};
if (typeof(o.parameters) == "String" && !o.parameters.include("authenticity_token")) {
o.parameters = o.parameters + "&authenticity_token="+AUTH_TOKEN;