Skip to content

Instantly share code, notes, and snippets.

View cpetschnig's full-sized avatar

Christoph Petschnig cpetschnig

  • SINC GmbH
  • Leipzig, Germany
  • 20:23 (UTC +02:00)
View GitHub Profile
@cpetschnig
cpetschnig / .irbrc
Created July 18, 2010 19:30
My .irbrc file: IRB customization
require 'rubygems'
irb_extensions = []
begin
# load wirble
require 'wirble'
# start wirble (with color)
Wirble.init
@cpetschnig
cpetschnig / .irbrc
Created April 28, 2010 08:09
My irb customization file
require 'rubygems'
irb_extensions = []
begin
# load wirble
require 'wirble'
# start wirble (with color)
Wirble.init
@cpetschnig
cpetschnig / create_user_mysql.sql
Created April 14, 2010 07:50
MySQL: Create DB user and set permissions
-- create new user and give permissions to all databases of names starting with "USERNAME_"
CREATE USER 'my_new_user'@'localhost' IDENTIFIED BY '9ixv[jX6g33yD#lZl#T5dV5l882_Y';
GRANT ALL ON `my_new_user\_%`.* TO 'my_new_user'@'localhost';
@cpetschnig
cpetschnig / validate_ipv6.rb
Created February 4, 2010 09:19
Regular Expression Validation for IPv6 Addresses in Ruby
# Regular Expression Validation for IPv6 addresses in Ruby
#
# Inspired by (if not to say copied from): http://forums.dartware.com/viewtopic.php?t=452
# Thanks, Dartware!
IPV6_REGEX = /^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f
# in file helper_test.rb:
def haml_tag_helper_method
haml_buffer.options[:escape_html] = true
haml_tag :div do
haml_tag :span, 'foo'
end
end
def test_haml_tag_with_block
def my_haml_helper
haml_tag :div do
haml_tag :span, 'foo'
end
end
would produce:
<div>
<span>foo</span>