Skip to content

Instantly share code, notes, and snippets.

View ahx's full-sized avatar

Andreas Haller ahx

View GitHub Profile
@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'
# 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)
# 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!
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(-)
.bundle
db/*.sqlite3
log/*.log
tmp/**/*
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
From 3786858be2d9ea56444fc0554a289a558d8bede9 Mon Sep 17 00:00:00 2001
From: Andreas Haller <[email protected]>
Date: Fri, 8 Oct 2010 11:39:17 +0200
Subject: [PATCH] `test_timer=on rake test` to print how long each test takes to run
---
Rakefile | 7 +++++++
lib/test_timer.rb | 40 ++++++++++++++++++++++++++++++++++++++++
test/test_helper.rb | 7 +++++++
3 files changed, 54 insertions(+), 0 deletions(-)
@ahx
ahx / app.js
Created October 23, 2010 20:26
small demo for handlebars.js, jQuery 1.4.3 data events and require.js
/* small demo for handlebars.js, jQuery, require.js */
/*global Handlebars */
var cart = {
products: [
],
total: function() {
var sum = 0;
for(var i in this.products) {
sum += this.products[i].price;
@ahx
ahx / integration_test.rb
Created November 12, 2010 16:21
gaming_test.rb
# Example of how you can to use Capybara with plain Rails' integration tests and FactoryGirl (or plain MyModel.create…)
require 'test_helper'
require 'capybara'
require 'capybara/dsl'
require 'database_cleaner'
Capybara.app = Pardy::Application
Capybara.default_driver = :rack_test
DatabaseCleaner.strategy = :truncation
.bundle
db/*.sqlite3
log/*.log
tmp/**/*