This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Aquarium::Aspects::Aspect.new :around, :calls_to => /^metody_admina/, :in_type => User::AdminType do |jp, obj, *args| | |
jp.proceed | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Proc | |
alias :original_call :call | |
def call | |
puts "custom call from proc" | |
original_call | |
super if defined? super | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark' | |
class InfoDesk | |
def flights | |
puts "flights" | |
end | |
def trains | |
puts "trains" | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
array = [:one, :two, :three] | |
array.[] 0 #=> :one | |
array.[] 1 #=> :two | |
# why?;-) | |
# array[:hello] #=> array[:hello] | |
# [:world] #=> [:world] :'(((( | |
# | |
# array[:hello][:world] #=> array[:hello][:world] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Event < ActiveRecord::Base | |
before_save :set_event_creator | |
def set_event_creator | |
self.creator = Event.creator | |
end | |
end | |
# Somewhere in controller ;-) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lite@lite-ubuntu:~/RubymineProjects/tweetfunnel$ dpkg -l | grep libqt4 | grep dev | |
lite@lite-ubuntu:~/RubymineProjects/tweetfunnel$ sudo apt-get install libqt4-dev | |
Czytanie list pakietów... Gotowe | |
Budowanie drzewa zależności | |
Odczyt informacji o stanie... Gotowe | |
Zostaną zainstalowane następujące dodatkowe pakiety: | |
libqt4-declarative libqt4-opengl-dev qt4-qmake | |
Sugerowane pakiety: | |
qt4-dev-tools qt4-doc libsqlite0-dev unixodbc-dev | |
Zostaną zainstalowane następujące NOWE pakiety: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Array | |
def initialize(*args) | |
self.replace args | |
end | |
puts Array.new 1,2,3 #=> [1, 2, 3] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark' | |
require 'strscan' | |
n = 100000 | |
u = "hello_world/whatever" | |
class String | |
# From rails | |
def camelize |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def number_in_words(n) | |
return '' if n == 0 | |
sc = [''] + %w{jeden dwa trzy cztery pięć sześć siedem osiem dziewięć} | |
sn = %w{dziesięć jedenaście dwanaście trzynaście czternaście piętnaście szesnaście siedemnaście osiemnaście dziewiętnaście} | |
sd = ['',''] + %w{dwadzieścia trzydzieści czterdzieści pięćdziesiąt sześćdziesiąt siedemdziesiąt osiemdziesiąt dziewiędziesiąt sto} | |
ss = [''] + %w{sto dwieście trzysta czterysta pięćset sześćset siedemset osiemset dziewięćset} | |
b = ['','',''],%w{tysiąc tysiące tysięcy},%w{milion miliony milionów},%w{miliard miliardy miliardów} | |
p = n.to_s.size | |
return 'bardzo dużo' if p > 11 | |
d,dn = n.to_s[0,(p%3 == 0 ? 3 : p%3)], n.to_s[(p%3 == 0 ? 3 : p%3)..-1] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ruby-1.9.2-p0 > @var = "sth" | |
=> "sth" | |
ruby-1.9.2-p0 > "#@var/another" | |
=> "sth/another" |