Skip to content

Instantly share code, notes, and snippets.

View FatihDurmus's full-sized avatar
🤡
Happy for now

Fatih Durmuş FatihDurmus

🤡
Happy for now
View GitHub Profile
string_1 = "Hello"
string_2 = "Hello"
puts "string_1's id is #{string_1.object_id}."
puts "string_2's id is #{string_2.object_id}."
2.4.3
Order of parameters and arguments
What output would you expect from this code snippet?
def mixed_args(a,b,*c,d)
puts "Arguments:"
puts a,b,c,d
end
mixed_args(1,2,3,4,5)
hatası da bu
@FatihDurmus
FatihDurmus / gist:676216
Created November 14, 2010 23:23
fiyat.rb
ef Ticket.most_expensive(*tickets)
tickets.max_by(&:price)
end
Now we can use the Ticket.most_expensive method to tell which of several tickets is
the most expensive. (We’ll avoid having two tickets with the same price, because our
method doesn’t deal gracefully with that situation.)
th = Ticket.new("Town Hall","11/12/13")
cc = Ticket.new("Convention Center","12/13/14/")
fg = Ticket.new("Fairgrounds", "13/14/15/")
th.price = 12.55
require "stacklike"
class Stack
include Stacklike
end
/home/fatih/Belgeler/RubyApplication1/lib/stack.rb:8: uninitialized constant Stack::Stacklike (NameError)
@FatihDurmus
FatihDurmus / gist:728221
Created December 4, 2010 14:35
stacklike.rb
#
# To change this template, choose Tools | Templates
# and open the template in the editor.
module StackLike
def stack
@stack ||= []
@FatihDurmus
FatihDurmus / gist:728337
Created December 4, 2010 17:23
suite.rb ama stacklike.rb ye ihtiyaç duyuyor
#
# To change this template, choose Tools | Templates
# and open the template in the editor.
require "stacklike"
class Suitcase
end
@FatihDurmus
FatihDurmus / gist:728341
Created December 4, 2010 17:27
ikiside burada,sorun firs_unload çalışmıyor
module Stacklike
def stack
@stack ||= []
end
B
def add_to_stack(obj)
stack.push(obj)
end
def take_from_stack
stack.pop
@FatihDurmus
FatihDurmus / gist:728342
Created December 4, 2010 17:29
netbeans'den
#
# To change this template, choose Tools | Templates
# and open the template in the editor.
module Stacklike
def stack
@stack ||= []
end
NetBeansProjects/simple_cms$ rails g migration myMigration --trace
/usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.5/lib/action_dispatch/routing/mapper.rb:171:in `default_controller_and_action': missing :action (ArgumentError)
from /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.5/lib/action_dispatch/routing/mapper.rb:72:in `normalize_options!'
from /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.5/lib/action_dispatch/routing/mapper.rb:55:in `initialize'
from /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.5/lib/action_dispatch/routing/mapper.rb:272:in `new'
from /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.5/lib/action_dispatch/routing/mapper.rb:272:in `match'
from /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.5/lib/action_dispatch/routing/mapper.rb:1173:in `match'
from /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.5/lib/action_dispatch/routing/mapper.rb:1360:in `match'
from /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.5/lib/action_dispatch/routing/mapper.rb:259:in `r
@FatihDurmus
FatihDurmus / gist:888235
Created March 26, 2011 12:26
routes.rb
SimpleCms::Application.routes.draw do
resources :posts
root :controller => "posts"
# The priority is based upon order of creation:
# first created -> highest priority.
# Sample of regular route:
# match 'products/:id' => 'catalog#view'
# Keep in mind you can assign values other than :controller and :action