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
begin | |
require "rubygems" | |
require "bundler" | |
rescue LoadError | |
raise "Could not load the bundler gem. Install it with `gem install bundler`." | |
end | |
if Gem::Version.new(Bundler::VERSION) <= Gem::Version.new("0.9.24") | |
raise RuntimeError, "Your bundler version is too old." + | |
"Run `gem install bundler` to upgrade." |
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
# Don't change this file! | |
# Configure your app in config/environment.rb and config/environments/*.rb | |
RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT) | |
module Rails | |
class << self | |
def boot! | |
unless booted? | |
preinitialize |
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 "bundler" | |
Bundler.require(:default, :development) | |
# ENV['RAILS_ENV'] ||= 'production' | |
# Specifies gem version of Rails to use when vendor/rails is not present | |
RAILS_GEM_VERSION = '2.3.5' unless defined? RAILS_GEM_VERSION | |
# Bootstrap the Rails environment, frameworks, and default configuration | |
require File.join(File.dirname(__FILE__), 'boot') |
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
source "http://rubygems.org" | |
gem 'rails', '2.3.5' | |
gem 'aasm', '2.1.5' | |
gem 'acts-as-taggable-on', '2.0.4' | |
gem 'activemerchant', '1.5.1' | |
gem 'authlogic', '2.1.5' | |
gem 'aws-s3', '0.6.2' | |
gem 'configatron', '2.6.0' |
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
#Percona-XtraDB obsoletes mysql-server packages, so upgrade is pretty straightforward. | |
#Instead of updating currently installed packages Percona-XtraDB should be installed. It will replace currently #installed mysql-server, mysql-client, etc. | |
# Dont's do it straight on production server, let's try on the staging one | |
#!/bin/bash -e | |
cat<<EOF> /etc/yum.repos.d/Percona.repo | |
[percona] | |
name=CentOS-$releasever - Percona | |
baseurl=http://repo.percona.com/centos/5Server/os/i386/ |
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 'cucumber/rake/task' | |
require 'spec/rake/spectask' | |
require 'database_cleaner' | |
namespace :rcov do | |
Cucumber::Rake::Task.new(:cucumber) do |t| | |
t.rcov = true | |
t.rcov_opts = %w{--rails --exclude osx\/objc,gems\/,spec\/,features\/ --aggregate coverage.data} | |
t.rcov_opts << %[-o "coverage"] | |
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
# app/controllers/posts_controller.rb | |
class PostsController < ApplicationController | |
def index | |
@posts.all_cached # Retrive only at once by every 5 minutes | |
expires_in 5.minutes, :private => false, :public => true | |
end | |
end | |
# app/models/post.rb | |
Class Post |
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/performance/benchmarker 50 "Banner.within_street('М').collect(&:street)" | |
user system total real | |
#1 20.300000 0.030000 20.330000 ( 25.248899) | |
script/performance/benchmarker 50 'Banner.search("^М*", :per_page => 10000).collect(&:street)' | |
user system total real | |
#1 107.010000 0.100000 107.110000 (109.985505) | |
script/performance/benchmarker 1000 'BannerFormat.all' |
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
Checking the memcached & sphinx running | |
if $0 == 'script/server' | |
# Check for memcached | |
begin | |
# check if memcached is running; if it is, use that instead of the default memory cache | |
Timeout.timeout(0.5) { TCPSocket.open("localhost", 11211) { } } | |
config.cache_store = :mem_cache_store, %w(localhost:11211), { :namespace => 'zimaletto', :timeout => 60 } | |
$stderr.puts "\033[0;32mUsing memcached on localhost:11211\033[0;34m" | |
rescue StandardError |
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
#!/usr/local/bin/ruby | |
d1=[83,51] | |
d2=[85,31] | |
d3=[18,137] | |
A = d2[0] - d1[0]; | |
B = d2[1] - d1[1]; | |
C = d3[0] - d1[0]; | |
D = d3[1] - d1[1]; |