Skip to content

Instantly share code, notes, and snippets.

View tonini's full-sized avatar
💭
I may be slow to respond.

Samuel Tonini tonini

💭
I may be slow to respond.
View GitHub Profile
james = "say it loud!"
#1
def james.more
puts "#{self} I'm black and proud!"
end
#2
class << james
def power
# chop.rb
# zastav [@samueltonini]
#1
def chop(v, arr)
return false if arr.empty?
min = 0
max = arr.length - 1
# singleton_class.rb
# zastav [@samueltonini]
obj = Object.new
def obj.who_i_am?
puts "I'm a singleton method"
end
singleton_class = class << obj
# encoding: utf-8
require "yaml"
require "yaml/encoding"
input_for_yaml = {
:phonetic_notation => "[ə’kɒmplɪʃ]",
:words => ["schaffen", "vollbringen", "vollenden", "leisten", "durchführen"]
}
recipe = <<END
Für 4 Personen
Metall- oder Holzspiesse
Backpapier für das Blech
Chutney:
500 g säuerliche Äpfel, z. B. Cox Orange, geschält, in kleine Stücke geschnitten
2-3 EL Korinthen
225 g Zucker
require 'uri'
require 'open-uri'
require 'nokogiri'
@from = "en"
@to = "de"
@word_to_translate = "accomplish"
@url = "http://www.google.ch/dictionary?source=translation&hl=en&q=##{@word_to_translate}&langpair=#{@from}|#{@to}"
lambda {
hash = {}
Kernel.send :define_method, :say do |sentence, &block|
hash[sentence] = block
end
Kernel.send :define_method, :hello do |&block|
hash.each_pair do |sentence, say|
##
# :attr_reader: dependencies
#
# A list of Gem::Dependency objects this gem depends on.
#
# Use #add_dependency or #add_development_dependency to add dependencies to
# a gem.
array_attribute :dependencies
qwandry-0.0.1/lib/qwandry/launcher.rb:67:in `system': can't convert nil into String (TypeError)
@tonini
tonini / gist:798253
Created January 27, 2011 08:48
cucumber backdoor login
# Create backdoor method in session controller
# Backdoor login for feature testing
def backdoor_login
# be sure to be logged out
logout!
# Kill / reset the current session
reset_session