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
# Author: Maksim Horbul | |
# | |
# This patch allows to use :expires_in option with the FileStore Cache | |
# | |
# Example: | |
# <% cache :expires_in => 10.minutes %> | |
# <div>Cool fragment which is going to be expired in 10 minutes.</div> | |
# <% 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
require 'rubygems' | |
require 'net/http' | |
require 'uri' | |
require 'hpricot' | |
require 'optparse' | |
require 'set' | |
def timed(&block) | |
s = Time.now | |
yield |
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
require 'time' | |
def deg2rad(d) | |
(d/180.0)*Math::PI | |
end | |
def rad2deg(r) | |
(r/Math::PI)*180 | |
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
# | |
# MemCacheStore extension which allows to find and delete the objects from cache by keys matched regexp. | |
# | |
# Idea was taken from http://github.com/martincik/memcache_store_with_delete_matched/ | |
module ActiveSupport | |
module Cache | |
class MemCacheStore < Store | |
cattr_accessor :keys_key_name |
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
namespace :benchmark do | |
namespace :find do | |
desc "Benchmarking find by id" | |
task :simple => :environment do | |
Benchmark.bm(20) do |bm| | |
bm.report 'find-by-id' do | |
5_000.times do | |
Person.find(100) | |
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
# .gitignore file for XCode projects | |
build/* | |
*.pbxuser | |
*.perspectivev3 | |
Database/*.sqlite3.db | |
# Mac OS X Finder and whatnot | |
.DS_Store | |
# XCode (and ancestors) per-user config (very noisy, and not relevant) |
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
# Rails | |
# Different interfaces for the similar methods | |
# Why ? | |
ruby-1.8.7-p299 > now = Time.now | |
=> Thu Aug 26 14:16:31 -0700 2010 | |
ruby-1.8.7-p299 > now.ago(10) | |
=> Thu Aug 26 14:16:21 -0700 2010 | |
ruby-1.8.7-p299 > now.advance(:seconds => 10) | |
=> Thu Aug 26 14:16:41 -0700 2010 |
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
# Maksim Horbul | |
# AWS Import API test | |
# | |
# Error response all the time | |
# | |
# <ErrorResponse xmlns="http://importexport.amazonaws.com/doc/2010-06-01/"> | |
# <Error> | |
# <Type>Sender</Type> | |
# <Code>SignatureDoesNotMatch</Code> | |
# <Message>The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.</Message> |
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
require 'yaml'; Dir.glob("app/jobs/*").map {|j| File.basename(j, ".rb")}.reduce({}) { |r,k| r[k] = {"cron" => "* * * * *", "custom_job_class" => k.gsub(/(_(.)|^(.))/) {|m| m.gsub(/_/,"").upcase}, "queue" => "resque", "description" => k.gsub(/(_(.)|^(.))/) {|m| "#{m.gsub(/_/," ").upcase}"} }; r }.to_yaml | |
__END__ | |
--- | |
awesome_worker_one: | |
cron: "* * * * *" | |
custom_job_class: AwesomeWorkerOne | |
queue: resque | |
description: Awesome Worker One |
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
ruby-1.9.1-p378 > class A | |
ruby-1.9.1-p378 ?> def foo | |
ruby-1.9.1-p378 ?> yield | |
ruby-1.9.1-p378 ?> end | |
ruby-1.9.1-p378 ?> def zoo | |
ruby-1.9.1-p378 ?> puts "zoo" | |
ruby-1.9.1-p378 ?> end | |
ruby-1.9.1-p378 ?> end | |
=> nil | |
ruby-1.9.1-p378 > a = A.new |