Skip to content

Instantly share code, notes, and snippets.

View mikhailov's full-sized avatar

Anatoly Mikhaylov mikhailov

View GitHub Profile
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
#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/
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'
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')
# 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
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."
@mikhailov
mikhailov / ajax_defaults.js
Created August 25, 2010 05:40
automatically show/hide ajax-spinner + disable/enable submit buttons
var spinner = $('#ajax-spinner');
$(document).ajaxSend(function() {
$('input[type=submit]').attr('disabled', 'disabled');
$('#warningBox').hide();
spinner.show()
}).ajaxStop(function() {
$('input[type=submit]').removeAttr('disabled');
spinner.hide()
});
@mikhailov
mikhailov / gist:706275
Created November 19, 2010 09:09
nginx native ssl redirection without ssl_requirement
server {
listen 80;
server_name *.domain.com;
rewrite ^(.*) https://$host$1 permanent;
}
@mikhailov
mikhailov / installation.sh
Created November 23, 2010 15:18
nginx+passenger (real production config)
# NOTICE: to get Nginx+Unicorn best-practices configuration see the gist https://gist.github.com/3052776
$ cd /usr/src
$ wget http://nginx.org/download/nginx-1.2.1.tar.gz
$ tar xzvf ./nginx-1.2.1.tar.gz && rm -f ./nginx-1.2.1.tar.gz
$ wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.30.tar.gz
$ tar xzvf pcre-8.30.tar.gz && rm -f ./pcre-8.30.tar.gz
$ wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz
@mikhailov
mikhailov / ruby_gc.sh
Created March 11, 2011 10:33
Ruby’s GC Configuration
- http://www.coffeepowered.net/2009/06/13/fine-tuning-your-garbage-collector/
- http://snaprails.tumblr.com/post/241746095/rubys-gc-configuration
article’s settings: ("spec spec" took 17-23!sec)
export RUBY_HEAP_MIN_SLOTS=1250000
export RUBY_HEAP_SLOTS_INCREMENT=100000
export RUBY_HEAP_SLOTS_GROWTH_FACTOR=1
export RUBY_GC_MALLOC_LIMIT=30000000
export RUBY_HEAP_FREE_MIN=12500