Pure git/github version of my scrapbook on Ruby on Rails, web-development, linux system configuration.
##########################################################################
## ##
## Check individual .md files above for more information on topics ##
## ##
##########################################################################
Archive:
- Blogs are published on http://www.eq8.eu/blogs
- Micro Blogs ar published on http://ruby-on-rails-eq8.blogspot.com/
rvm docs generate
to lunch ri Array
require 'net/http'
require 'cgi'
class Cowsays
def say(message)
message = CGI.escape(message)
Net::HTTP.get_print(URI.parse(http://www.cowsays.com/cowsay?message=#{message}))
end
end
source: ruby tapas 30
class Foo
include Rails.application.routes.url_helpers
# ... or you can Delegate methods it
def home_macro
h.link_to 'Home', root_path
end
private
def h
ActionController::Base.helpers
end
end
note you can do include UrlHelper
which includes link_to
but this will work only for String based urls as this module was changed in Rails 4 ( check source code )
if you keep getting error arguments passed to url_for can't be handled ...
your only chance is to use my former code
ActiveRecord::ConnectionAdapters::Column.value_to_boolean 'f' # => false
ActiveRecord::ConnectionAdapters::Column.value_to_boolean 't' # => true
ActiveRecord::ConnectionAdapters::Column.value_to_boolean '0' # => false
ActiveRecord::ConnectionAdapters::Column.value_to_boolean '1' # => true
ActiveRecord::ConnectionAdapters::Column.value_to_boolean nil # => false
- http://tindeck.com/robots.txt
- http://www.ben-norman.co.uk/blog/seo/ten-examples-of-creative-robots-txt-files/
Tell browser not to cache content that hold harmfull data (e.g.: user settings, card details..>)
<meta http-equiv="Cache-control" content="no-cache no-store">
def memstats
`ps -o size= #{$$}`.strip.to_i
end
source: ruby tapas 42
tail -f log/production.log | grep "NoMethodError"
"2010-10-25 23:48:46 UTC".to_time.iso8601
- Moneta key store (good for caching) https://github.com/minad/moneta