Skip to content

Instantly share code, notes, and snippets.

View ticktricktrack's full-sized avatar

Rainer Kuhn ticktricktrack

  • Groundsure
  • Brighton, UK
View GitHub Profile
Page.delete_all
Node.delete_all
p = Page.new(:name => "testbild")
root = Box.new(:height => 400, :width => 600)
grid1 = Grid.new(:height => 400, :width => 300, :align => "left")
grid2 = Grid.new(:height => 400, :width => 300, :align => "right")
grid3 = Grid.new(:height => 200, :width => 300, :align => "top")
grid4 = Grid.new(:height => 200, :width => 300, :align => "bottom")
@ticktricktrack
ticktricktrack / exercise_1_by_Ray.rb
Created December 6, 2010 16:12
exercise 1 by Ray from Rubylearning Metaprogramming Batch 6
results = []
# 3
results << class A
def initialize
@a = 11
@@a = 22
a = 33
end
@a = 1
@ticktricktrack
ticktricktrack / exercise1_by_ray_attempt_2.rb
Created December 7, 2010 16:07
exercise1_by_ray_attempt_2.rb
class I
def like arg
puts "%s %s %s" % [self.class, self.class.instance_methods(false), arg]
end
end
c, m, arg = gets.split # input 'I like metaprogramming.'
puts
# If I can't modify the like method itself, let's modify what it calls
@ticktricktrack
ticktricktrack / exercise1_by_ray_attempt_2.rb
Created December 7, 2010 16:17
exercise1_by_ray_attempt_2.rb
class I
def like arg
puts "%s %s %s" % [self.class, self.class.instance_methods(false), arg]
end
end
c, m, arg = gets.split # input 'I like metaprogramming.'
puts
# If I can't modify the like method itself, let's modify what it calls
# MaskedString = Class.new(String)
Object.const_set("MaskedString", Class.new(String))
MaskedString.instance_eval do
define_method :tr_vowel do
tr 'aeiou', '*'
end
end
MaskedString.class_eval do
- wrap(true)
%p
Wrap Me!
module ActionView
module Template::Handlers
class ErSass < ERB
def compile(template, local_assigns = {})
erbsrc = "<% __in_erb_template=true %>#{template.source}"
erboutput = self.class.erb_implementation.new(erbsrc, :trim => (self.class.erb_trim_mode == "-")).src
erboutput + ";Sass::Engine.new(@output_buffer.to_s, {:load_paths => ['.', 'app/stylesheets']}).render"
end
end
end
@ticktricktrack
ticktricktrack / development.rb
Created February 10, 2012 15:21
development.rb
application.rb:
# Enable the asset pipeline
config.assets.enabled = true
# Version of your assets, change this if you want to expire all your assets
config.assets.version = '1.0'
development.rb
@ticktricktrack
ticktricktrack / rspec-syntax-cheat-sheet.rb
Created February 17, 2012 11:18 — forked from dnagir/rspec-syntax-cheat-sheet.rb
RSpec 2 syntax cheat sheet by example
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below)
module Player
describe MovieList, "with optional description" do
it "is pending example, so that you can write ones quickly"
it "is already working example that we want to suspend from failing temporarily" do
pending("working on another feature that temporarily breaks this one")
class MyJob
@queue = :my_queue
def self.perform(args)
puts 'Job starting'
puts 'whoohooo'
end
end