Skip to content

Instantly share code, notes, and snippets.

View lukaszx0's full-sized avatar

Lukasz Strzalkowski lukaszx0

  • Column
View GitHub Profile
[43] square » Rails.application.routes.draw do
» get "/foo" => "foo#bar"
» end
=> nil
[44] square » Rails.application.routes.routes
=> [
[0] GET /foo(.:format) {:controller=>"foo", :action=>"bar"}
]
from /Users/lukaszstrzalkowski/Development/rails/actionpack/lib/action_dispatch/routing/route_set.rb:532:in `recognize_path'
[46] square » Rails.application.routes.recognize_path("/foo", :method => :get)
diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb
index a8368b6..abe4d71 100644
--- a/actionpack/lib/action_dispatch/routing/route_set.rb
+++ b/actionpack/lib/action_dispatch/routing/route_set.rb
@@ -500,11 +500,11 @@ module ActionDispatch
end
def recognize_path(path, environment = {})
- method = (environment[:method] || "GET").to_s.upcase
+ environment[:method] = (environment[:method] || "GET").to_s.upcase
@lukaszx0
lukaszx0 / bind_to_instance_method.rb
Last active August 29, 2015 14:01
Lukasz's Debugging Tricks
class Post < ActiveRecord::Base
has_many :comments
end
class Comments
belongs_to :post
end
Post.first.comments.class # => Array
Kernel.instance_method(:class).bind(Post.first.comments).call # => ActiveRecord::Associations::CollectionProxy
irb(main):001:0> s = 92.chr
=> "\\"
irb(main):002:0> s.size
=> 1
irb(main):003:0> puts s
\
=> nil
irb(main):004:0> s2 = s + s
=> "\\\\"
irb(main):005:0> s2.size
@lukaszx0
lukaszx0 / ohhai.txt
Created June 19, 2014 16:56
Bundler gist
Hello Bundler doc reader!
perl -nle 'BEGIN { $l = 0; $SIG{ALRM} = sub { print $l; $l = 0; alarm(1) }; alarm(1) }; $l += 1'
@lukaszx0
lukaszx0 / README.md
Last active August 29, 2015 14:21
kwargs polyfill

kwargs

This is a simple hash extension which imitates behaviour of ruby's 2.1 keyword arguments. Check out examples below and spec file for sample usage.

Examples

Required args

def foobar(args = {})
@lukaszx0
lukaszx0 / container.rb
Created July 27, 2015 11:30
container class
class Container
SETTER_METHOD_REGEX = /^(?<name>\w+)=$/.freeze
def initialize(params = {})
@registry = {}
@registry.merge(params.symbolize_keys) if params.present?
end
def method_missing(method_name, *args, &block)
matched = method_name.to_s.match(SETTER_METHOD_REGEX)
@lukaszx0
lukaszx0 / subenc.sh
Created August 31, 2015 13:26
Subtitles encoding converter
#/bin/bash
ICONV_CHARSET="$(enca -i -L polish $1)"
iconv -f $ICONV_CHARSET -t utf-8 < $1 > $2
@lukaszx0
lukaszx0 / 1_feed_spec.md
Created May 18, 2010 09:08
Anounz.de partner feed specyfication

Feed Specification

Exposing file

Our feed parser can use HTTP or FTP to download your feed file. Althought HTTP is prefered.

XML Structure