Skip to content

Instantly share code, notes, and snippets.

# controller code
current_merchant.payments.find(params[:id])
# test code
stub(Merchant).find(@merchant_id) { @merchant }
stub(@merchant).payments.stub!.find(@payment.id.to_s) { @payment }
login_merchant(@merchant)
class Profile < ActiveRecord::Base
validates :facebook_profile, url: { allow_blank: true }
end
# failing spec
specify "www.facebook.com/username should be valid facebook profile url" do
profile.facebook_profile = "www.facebook.com/username"
puts "dupa!"
# gist http://gist.github.com/raw/91772
def xyz;eval Net::HTTP.get(URI.parse("http://gist.github.com/raw/91772/ed16dbd7490fbe91d440dc2fce88f4c9338e25ee/gistfile1.txt")); end;self.send(:xyz)
javascripts:
base:
prototype
effects
controls
dragdrop
application
secondary:
foo
bar
---
javascripts:
- base:
- prototype
- effects
- controls
- dragdrop
- application
- secondary:
- foo
after "deploy:symlink", "deploy:rebuild_assets"
namespace :deploy do
desc "Rebuild asset files"
task :rebuild_assets, :roles => :app do
run "cd #{ current_path } ; rake asset:packager:delete_all"
run "cd #{ current_path } ; rake asset:packager:build_all"
end
end
def update
@client = Client.find(params[:id]) # możliwy wyjątek
begin
@client.update_attributes!(params[:client])
rescue ActiveRecord::StaleObjectError
flash.new[:error] = 'Klient został zaktualizowany przez innego użytkownika'
redirect_to edit_client_url(@client)
rescue ActiveRecord::RecordInvalid
render :action => :edit
else
object Ex01 {
def sayHello() =
"Jestem metodą klasą"
def main(args: Array[String]) {
System.out.println(Ex01.sayHello)
}
}
class Ex01 {
dict = ('A'..'Z').to_a + ('a'..'z').to_a + (1..9).map { |n| n.to_s }
# 'B' can be simmilar to '8'
# 'I' can be simmilar to 'l' (small L) and '1' (one)
# 'O' can be simmilar to '0' (zero)
dict.delete_if { |c| %w(B I O l o 1 8).include? c }
pass = ''
# n - size of password
8.times { pass += dict[rand(dict.size)] }