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
| FIELDS = [:about_url, :feedback_url, :terms_of_service_url, :privacy_policy_url, :support_url, :contact_url] | |
| self.with_options(:with => /^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?$/ix ) do |url| | |
| FIELDS.each do |field| | |
| url.validates_format_of field, :if => lambda{ |val| !val.send(field).blank? } | |
| 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
| dd780fc2 (johan pretorius 2010-10-04 12:13:12 +0200 148) if (admin? or current_user.tf_admin?) and @channel_user | |
| 4315fa78 (johan pretorius 2010-01-24 20:00:54 +0200 149) redirect_to :controller => :channel_users, :action => 'index' | |
| dd780fc2 (johan pretorius 2010-10-04 12:13:12 +0200 150) elsif (admin? or current_user.tf_admin?) | |
| dd780fc2 (johan pretorius 2010-10-04 12:13:12 +0200 151) redirect_to :controller => :accounts, :action => 'show' | |
| bea746b9 (Johannes Fahrenkrug 2009-03-27 16:39:08 +0100 152) else | |
| bea746b9 (Johannes Fahrenkrug 2009-03-27 16:39:08 +0100 153) redirect_to :action => 'edit', :id => @user.id | |
| bea746b9 (Johannes Fahrenkrug 2009-03-27 16:39:08 +0100 154) end | |
| bea746b9 (Johannes Fahrenkrug 2009-03-27 16:39:08 +0100 155) else | |
| bea746b9 (Johannes Fahrenkrug 2009-03-27 16:39:08 +0100 156) render :action => 'edit' |
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
| # File net/pop.rb, line 410 | |
| def initialize(addr, port = nil, isapop = false) | |
| @address = addr | |
| @ssl_params = POP3.ssl_params | |
| @port = port | |
| @apop = isapop | |
| @command = nil | |
| @socket = nil | |
| @started = false |
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
| # ActiveRecord::ConnectionAdapters::Mysql2IndexDefinition | |
| module ActiveRecord | |
| module ConnectionAdapters | |
| class Mysql2IndexDefinition | |
| def case_sensitive? | |
| false | |
| end | |
| 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
| lite@lite-debian:~$ irb | |
| ruby-1.9.2-p0 > class C; end | |
| => nil | |
| ruby-1.9.2-p0 > c = C.new | |
| => #<C:0x00000000becdf0> | |
| ruby-1.9.2-p0 > c.method | |
| ArgumentError: wrong number of arguments(0 for 1) | |
| from (irb):3:in `method' | |
| from (irb):3 | |
| from /home/lite/.rvm/rubies/ruby-1.9.2-p0/bin/irb:16:in `<main>' |
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" |
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
| 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
| 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
| 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: |