This file contains hidden or 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
# Proposal of implementation Django-like generic views in rack and rango compatible way | |
# It must play well with: | |
# 1) Rack apps | |
# 2) Rango controllers | |
# NOTE: if you don't know what generic views are, take a look at | |
# http://docs.djangoproject.com/en/dev/ref/generic-views/ | |
# generic view | |
def render_template(env) |
This file contains hidden or 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
gem "hpricot", "0.8.1" | |
require "hpricot" | |
html = <<-HTML | |
<div class="info"> | |
<p><strong>Job description</strong></p> <!-- elements[0] --> | |
<p id="ctl00_MainContent_CD_CD_Drop_DescHTML"> <!-- elements[1] --> | |
<p></p> | |
<p></p> | |
<p>Location: Barrs Court Specialist (SEN) School, Barrs Court Road, Hereford, HR1 1EQ</p> |
This file contains hidden or 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
** has_many_polymorphs: autoload hook invoked | |
** has_many_polymorphs: preloading parent model Tag | |
** has_many_polymorphs: associating Tag.taggables | |
Tagging Columns (0.027593) SHOW FIELDS FROM `taggings` | |
Vacancy Columns (0.001997) SHOW FIELDS FROM `vacancies` | |
** has_many_polymorphs: preloading parent model Tagging | |
Cache hit: route_filters/all ({:expires_in=>300 seconds}) | |
RouteFilter Columns (0.001286) SHOW FIELDS FROM `route_filters` | |
Cache hit: route_filters/all ({:expires_in=>300 seconds}) | |
User Columns (0.001988) SHOW FIELDS FROM `users` |
This file contains hidden or 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 GetNestedItemMixin | |
# Simplier syntax for code such as params[:post] && params[:post][:title] | |
# | |
# @author Jakub Stastny aka Botanicus | |
# @param [Object] First argument is the key of the hash, the second one the key of the inner hash selected by the first key etc. | |
# @return [Object, nil] The value of the most inner hash if found or nil. | |
# @raise [ArgumentError] If you don't specify keys. | |
# | |
# @example | |
# {a: {b: 1}}.get(:a, :b) # => 1 |
This file contains hidden or 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
#!script/runner | |
# jsou to tři hlavní skupiny: | |
# | |
# 6.směrnice | |
# | |
# nové cases - ty je potřeba navázat přes smartlink na šestou směrnici - je tam sloupec s příslušným article | |
# staré cases - totéž | |
# | |
# u všech smartlinků bych dal implicitně 5 hvězdiček |
This file contains hidden or 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
# ruby 1.9.1p129 (2009-05-12 revision 23412) [i386-darwin9.6.0] | |
user system total real | |
by_define_method 0.680000 0.000000 0.680000 ( 0.700586) | |
by_explicit_definition 0.560000 0.010000 0.570000 ( 0.581977) | |
by_eval 0.550000 0.000000 0.550000 ( 0.553484) | |
by_class_eval 0.540000 0.010000 0.550000 ( 0.561800) | |
by_class_eval_block 0.540000 0.000000 0.540000 ( 0.548041) | |
by_module_eval 0.550000 0.010000 0.560000 ( 0.560635) | |
by_module_eval_block 0.520000 0.000000 0.520000 ( 0.539168) |
This file contains hidden or 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
require "rubygems" | |
require "rbench" | |
def omg_slow | |
return 1 | |
end | |
def omg_fast | |
1 | |
end |
This file contains hidden or 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
require "rbench" | |
RBench.run(1_000_000) do | |
column :one, :title => "String" | |
column :two, :title => "String using String.new" | |
column :three, :title => "Array" | |
column :four, :title => "Array using Array.new" | |
column :five, :title => "Hash" | |
column :six, :title => "Hash using Hash.new" | |
This file contains hidden or 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
namespace :sites do | |
# use for sites deployment | |
# Usage: | |
# cap sites:deploy | |
task :deploy do | |
run "cd #{shared_path}/sites" | |
run "(test -f sites.lock) && (echo 'Sites are locked:' && cat sites.lock) || git update" | |
end | |
# Run just on first deploy to given server |
This file contains hidden or 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
def my_method | |
puts whatever | |
rescue Exception => e | |
puts "Exception #{e.message} occured!" | |
end | |
my_method | |
def my_method2 | |
puts whatever |