Skip to content

Instantly share code, notes, and snippets.

View rwoeber's full-sized avatar

Richard Wöber rwoeber

  • Würzburg, Germany
View GitHub Profile
@rwoeber
rwoeber / rails_1.2_ruby_1.8.7.rb
Created January 11, 2010 10:08
make rails 1.2.x work with Ruby >= 1.8.7
# make rails 1.2.x work with Ruby >= 1.8.7
unless '1.9'.respond_to?(:force_encoding)
String.class_eval do
begin
remove_method :chars
rescue NameError
# OK
end
end
end
@rwoeber
rwoeber / rot13.rb
Created January 11, 2010 10:09
Ruby rot13
# or simply:
'foobar'.tr 'A-Za-z','N-ZA-Mn-za-m'
# rot(x)
class String
def rot(num = 13)
return self.split("").collect { |ch|
if /^[a-z]$/ === ch
((ch[0] + num - 'a'[0]) % 26 + 'a'[0]).chr
@rwoeber
rwoeber / sanitize_html.rb
Created January 12, 2010 13:03
remove unwanted markup in HTML string
# via http://www.viget.com/extend/html-sanitization-in-rails-that-actually-works
#
# $Id: sanitize.rb 3 2005-04-05 12:51:14Z dwight $
#
# Copyright (c) 2005 Dwight Shih
# A derived work of the Perl version:
# Copyright (c) 2002 Brad Choate, bradchoate.com
#
# Permission is hereby granted, free of charge, to
# any person obtaining a copy of this software and
@rwoeber
rwoeber / ansicolors.sh
Created January 12, 2010 13:24
show ANSI color code table
#!/bin/sh
#
# This file echoes a bunch of color codes to the
# terminal to demonstrate what's available. Each
# line is the color code of one forground color,
# out of 17 (default + 16 escapes), followed by a
# test use of that color on all nine background
# colors (default + 8 escapes).
#
@rwoeber
rwoeber / create_self_signed_certificate.sh
Created January 12, 2010 13:49
Creates a self-signed certificate and configuration files for Rails-SSL-development (with Apache/Passenger)
#!/bin/sh
# Creates a self-signed certificate and configuration files for
# rails-SSL-development (with Apache/Passenger)
# !!! Important !!!
# Some files will be created and deleted in the current working directory
# perhaps it is a good idea to execute this in a dedicated tmp-dir.
# see the instructions this scripts echos on howto integrate into your system
@rwoeber
rwoeber / post-commit
Created January 14, 2010 09:20
svn post-commit incremental backup to Amazon S3
#!/usr/bin/env ruby
# File : s3-post-commit.rb
# Description : A program to create svn backups using the
# Amazons S3 storage service
# Copyright : (c) 2007 Maximilian Schoefmann
# License : MIT, see the file MIT-LICENSE
# Modified : Richard Woeber
#
# Usage
# copty to svnserver:/path/to/svnrepo/hooks/post-commit and change the following constants
@rwoeber
rwoeber / rails1to2.rake
Created January 26, 2010 09:42
rake tasks to help migrating from rails 1.x
# by courtesy of
# - http://www.slashdotdash.net/2007/12/03/rails-2-upgrade-notes/
# - http://marklunds.com/articles/one/409
MOVE_COMMAND = "git mv"
desc "Checks your app and gently warns you if you are using deprecated code."
task :deprecated => :environment do
deprecated = {
'@params' => 'Use params[] instead',
@rwoeber
rwoeber / org.mongodb.mongod.plist
Created January 29, 2010 10:10
launchd configuration file for mongoDB
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.mongodb.mongod</string>
<key>UserName</key>
<string>mongod</string>
<key>GroupName</key>
<string>mongod</string>
@rwoeber
rwoeber / org.pgsql.pgsqld.plist
Created January 29, 2010 10:13
launchd configuration file for PostgreSQL
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.postgresql.dbms</string>
<key>UserName</key>
<string>postgres</string>
<key>GroupName</key>
<string>postgres</string>
# Solution to PragProg Magazine 8 Quiz
# (added Comment into the first line)
quiz8 = %q{
-- Vqnbg nm qhg
qstgq xhmtunsm Vqneg(uvlu)
qstgq wvojsmov = ""
qstgq hovw = ouwnmc.hjjvw(uvlu)
qstgq hovwSwnc = hovw
-- wgmrsfqk ovqvtuvr wvjqnvo nx ms avkiswro