This file contains 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
module Foo | |
end |
This file contains 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
initializer "iqvoc.load_migrations" do |app| | |
app.class.configure do | |
config.paths['db/migrate'] += Iqvoc::Engine.paths['db/migrate'].existent | |
end | |
end |
This file contains 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
puts RUBY_VERSION | |
class Foo | |
def info(*args) | |
puts args.inspect | |
end | |
end |
This file contains 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
find -name "*.rb" | \ | |
while read filepath; do \ | |
{ echo -n "$filepath: "; head -n1 "$filepath"; } | \ | |
grep -v encoding | sed -e "s#.*#$filepath#"; \ | |
done | \ | |
while read filepath; do \ | |
{ echo "# encoding: UTF-8"; echo; } | \ | |
cat - "$filepath" > "$filepath.tmp"; \ | |
mv "$filepath.tmp" "$filepath"; \ | |
done |
This file contains 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
test "unicode decoding" do | |
encoded_val = "\u00C4ffle" | |
decoded_val = JSON.parse("{\"x\": \"#{encoded_val}\"}")['x'].gsub("\\n", "\n") | |
assert_equal decoded_val, "Äffle" | |
end | |
# 1.9.2 passes | |
# 1.8.7 | |
# <"u00C4ffle"> expected but was |
This file contains 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
e = Typhoeus::Easy.new | |
e.url = "http://example.com/" | |
e.method = :get | |
e.perform |
This file contains 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
module Foo | |
module Configuration | |
require 'ostruct' | |
extend ActiveSupport::Concern | |
included do | |
# | |
end | |
module ClassMethods |
This file contains 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
# dynamically determining the MySQL socket in use | |
<% socket = ["/tmp/mysql.sock", | |
"/opt/local/var/run/mysql5/mysqld.sock", | |
"/tmp/mysqld.sock", | |
"/var/run/mysqld.sock"].detect { |socket| File.exist?(socket) } %> | |
development: | |
encoding: utf8 | |
username: root |
This file contains 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
development: | |
encoding: utf8 | |
username: user | |
password: foobar | |
database: foo_development | |
<% if defined?(JRuby) %> | |
adapter: jdbcmysql | |
hostname: localhost | |
<% else %> | |
adapter: mysql |
This file contains 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
## n-level tree based hierarchical URLs with Rails and acts_as_tree | |
## be free to adopt this to acts_as_nested_set or whatever | |
# routes.rb | |
map.article_deeplink ':locale/*path/:slug', :controller => 'articles', :action => 'show' | |
# generate the url | |
# the array building function should be moved into an instance method | |
article_deeplink_path(:path => @article.ancestors.reverse.map(&:slug), :slug => @article.slug) |