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
# | |
# = Capistrano database.yml task | |
# | |
# Provides a couple of tasks for creating the database.yml | |
# configuration file dynamically when deploy:setup is run. | |
# | |
# Category:: Capistrano | |
# Package:: Database | |
# Author:: Simone Carletti <[email protected]> | |
# Copyright:: 2007-2010 The Authors |
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
# | |
# = Capistrano Passenger deploy tasks | |
# | |
# Provides tasks for deploying a Rails application with Passenger (aka mod_rails). | |
# | |
# Category:: Capistrano | |
# Package:: Passenger | |
# Author:: Simone Carletti <[email protected]> | |
# Copyright:: 2007-2008 The Authors | |
# License:: MIT License |
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
# | |
# = Capistrano FastCGI deploy tasks | |
# | |
# Provides tasks for deploying a Rails application with FastCGI. | |
# | |
# Category:: Capistrano | |
# Package:: FastCGI | |
# Author:: Simone Carletti <[email protected]> | |
# Copyright:: 2007-2008 The Authors | |
# License:: MIT License |
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 Title Helper | |
# | |
# Provides helpers for managing page title. | |
# | |
# Category:: Rails | |
# Package:: Helpers | |
# Author:: Simone Carletti <[email protected]> | |
# Copyright:: 2007-2008 The Authors | |
# License:: MIT License |
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
RewriteEngine On | |
RewriteBase / | |
RewriteCond %{QUERY_STRING} !^id=([0-9]*)$ | |
RewriteRule .* - [env=send_x_robot:true] | |
Header set X-Robots-Tag "noindex" env=send_x_robot |
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
# | |
# = SuperStruct | |
# | |
# SuperStruct is an enhanced version of the Ruby Standard library <tt>Struct</tt>. | |
# | |
# Compared with the original version, it provides the following additional features: | |
# * ability to initialize an instance from Hash | |
# * ability to pass a block on creation | |
# | |
# You can read more at http://www.simonecarletti.com/blog/2010/01/ruby-superstruct/ |
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 'ipaddr' | |
require 'benchmark' | |
class IPAddr | |
def self.valid_ipv4?(addr) | |
if /\A(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\Z/ =~ addr | |
return $~.captures.all? {|i| i.to_i < 256} | |
end | |
false | |
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 'benchmark' | |
require 'nokogiri' | |
TIMES = 50_000 | |
doc = Nokogiri::XML(File.new("test.xml")) | |
node = doc.at_xpath("./strategies") | |
Benchmark.bmbm do |x| |
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 CacheKey | |
extend self | |
def expirable(range = :minute, time = ::Time.current) | |
key = case range | |
when :always | |
::Time.current | |
when :never | |
nil | |
when :second |
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
MongoDb vs PostgreSQL (single table with 777,229 records) | |
-------------------------------------------------------- | |
# Number of Records in the table | |
=> 777229 | |
# Size of the Table | |
# PostgreSQL (Data + Indexes) | |
+----------------+ |
OlderNewer