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.2-p180 :009 > driver.projects.first.tickets | |
| RuntimeError: can't typecast "252" | |
| from /Users/ecruz/.rvm/gems/ruby-1.9.2-p180@panorama/gems/activesupport-3.0.6/lib/active_support/core_ext/hash/conversions.rb:96:in `typecast_xml_value' | |
| from /Users/ecruz/.rvm/gems/ruby-1.9.2-p180@panorama/gems/activesupport-3.0.6/lib/active_support/core_ext/hash/conversions.rb:118:in `block in typecast_xml_value' | |
| from /Users/ecruz/.rvm/gems/ruby-1.9.2-p180@panorama/gems/activesupport-3.0.6/lib/active_support/core_ext/hash/conversions.rb:117:in `each' | |
| from /Users/ecruz/.rvm/gems/ruby-1.9.2-p180@panorama/gems/activesupport-3.0.6/lib/active_support/core_ext/hash/conversions.rb:117:in `inject' | |
| from /Users/ecruz/.rvm/gems/ruby-1.9.2-p180@panorama/gems/activesupport-3.0.6/lib/active_support/core_ext/hash/conversions.rb:117:in `typecast_xml_value' | |
| from /Users/ecruz/.rvm/gems/ruby-1.9.2-p180@panorama/gems/activesupport-3.0.6/lib/active_support/core_ext/hash/conversions.rb:78:in `from_xml' | |
| from /Users/ecruz/.rvm/gems/ruby-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
| class Una | |
| def get | |
| "Esta es una prueba" | |
| end | |
| end | |
| dos = Class.new(Una) do | |
| def get | |
| "desde aca" | |
| 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
| module MyApp | |
| # See ActiveSupport::Cache::Store for documentation. | |
| module Cache | |
| class << self | |
| def fetch(key, options = {}, &block) | |
| if block_given? | |
| if ActionController::Base.perform_caching && options && options[:expires_in].to_i > 0 | |
| Rails.cache.fetch(key, options, &block) | |
| else | |
| yield |
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
| # Como usarlo: | |
| # ruby sleep.rb "6:15 AM" | |
| # ruby sleep.rb | |
| require 'date' | |
| require 'time' | |
| desired_hour = ARGV.first || "7 AM" | |
| wakeup_at = Time.parse("#{Date.today} #{desired_hour}") |
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
| ./configure \ | |
| --pid-path=/var/run/nginx.pid \ | |
| --lock-path=/var/lock/nginx.lock \ | |
| --error-log-path=/var/log/nginx/error.log \ | |
| --user=www-data \ | |
| --group=www-data \ | |
| --without-mail_pop3_module \ | |
| --without-mail_imap_module \ | |
| --without-mail_smtp_module \ | |
| --without-http_fastcgi_module \ |
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 solution(roman) | |
| roman.scan(/IV|IX|CM|XC|I|V|L|X|C|M|D/).inject(0) do |final, current| | |
| final += case current | |
| when 'IV' then 4 | |
| when 'IX' then 9 | |
| when 'XC' then 90 | |
| when 'CM' then 900 | |
| when 'I' then 1 | |
| when 'V' then 5 | |
| when 'X' then 10 |
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 pascalsTriangle(n) | |
| (1..n).inject([]) do |final, level| | |
| final << (1..level).inject([]) do |horizontal, index| | |
| if index == 1 || index == level | |
| horizontal << 1 | |
| else | |
| horizontal << (final[level - 2][index - 2]) + (final[level - 2][index - 1]) | |
| end | |
| end | |
| final |
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
| class Hash | |
| def method_missing( symbol, *args ) | |
| a, method = symbol.to_s.split('_') | |
| if method | |
| if self.has_key?(method.to_sym) || self.has_key?(method) | |
| self[method.to_sym] || self[method] | |
| else | |
| if method.include?('=') | |
| key = method.split('=').first.strip | |
| if has_key?(key) |
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 faster_paginate collection | |
| output = '' | |
| if collection.num_pages > 1 | |
| output << "<nav class='pagination'>" | |
| page_base = collection.current_page | |
| if page_base > 4 | |
| output << content_tag(:span, class: 'first') do | |
| link_to raw(t 'views.pagination.first'), url_for(params.merge(page: 1)) | |
| end | |
| output << content_tag(:span, class: 'page gap') { '... '} |
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
| if ENV['DEBUG_GEMLOADING'] | |
| Bundler::Runtime.class_eval do | |
| def Kernel.require file | |
| puts Benchmark.measure("#{file}") { | |
| super | |
| }.format("%t - %n: %r") | |
| end | |
| end | |
| end |
OlderNewer