Skip to content

Instantly share code, notes, and snippets.

View dzaporozhets's full-sized avatar

Dmitriy Zaporozhets dzaporozhets

View GitHub Profile
@dzaporozhets
dzaporozhets / rbenv-install-system-wide.sh
Created October 1, 2011 15:30
rbenv install and system wide install on Ubuntu 10.04 LTS.
# Update, upgrade and install development tools:
apt-get update
apt-get -y upgrade
apt-get -y install build-essential
apt-get -y install git-core
# Install rbenv
git clone git://github.com/sstephenson/rbenv.git /usr/local/rbenv
# Add rbenv to the path:
# MySQL. Versions 4.1 and 5.0 are recommended.
#
# Install the MySQL driver:
# gem install mysql2
#
# And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
development:
adapter: mysql2
encoding: utf8
@dzaporozhets
dzaporozhets / etc_init.d_unicorn_example.co.uk
Created March 7, 2012 13:29 — forked from vsizov/etc_init.d_unicorn_example.co.uk
Ruby on Rails server setup on Ubuntu 11.04 with Nginx, Unicorn, Rbenv
#! /bin/bash
### BEGIN INIT INFO
# Provides: unicorn
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the unicorn web server
# Description: starts unicorn
#Newbie programmer
def factorial(x):
if x == 0:
return 1
else:
return x * factorial(x - 1)
print factorial(6)
#First year programmer, studied Pascal
@dzaporozhets
dzaporozhets / teste_merge.rb
Created March 13, 2012 10:49 — forked from danielweinmann/teste_merge.rb
Testing Git merges using Grit
require 'grit'
require 'fileutils'
# Define our paths.
# We're gonna have 3 paths: one original, one for the fork, and yet another one for the merge
root_path = "#{File.dirname(__FILE__)}/documents"
original_path = "#{root_path}/original_repo.git"
fork_path = "#{root_path}/fork_repo.git"
merge_path = "#{root_path}/merge_repo"
@dzaporozhets
dzaporozhets / Gemfile
Created April 19, 2012 11:53 — forked from fxposter/Gemfile
Test environment for rails apps
group :development, :test do
gem 'rspec-rails', '~> 2.9' # rails generate rspec:install
gem 'factory_girl_rails'
end
group :test do
gem 'spork-rails' # spork rspec --bootstrap
gem 'capybara'
gem 'launchy'
gem 'timecop'
@dzaporozhets
dzaporozhets / gist:2770405
Created May 22, 2012 17:25 — forked from PotHix/gist:640517
remarkable -> shoulda sed helpers :P
grep "should_have_many" spec/* -Ril | xargs sed -i "s/should_have_many\(.*\)/it { should have_many\1 }/g"
grep "should_have_one" spec/* -Ril | xargs sed -i "s/should_have_one\(.*\)/it { should have_one\1 }/g"
grep "should_belong_to" spec/* -Ril | xargs sed -i "s/should_belong_to\(.*\)/it { should belong_to\1 }/g"
grep "should_validate_presence_of.*" spec/* -Ril | xargs sed -i "s/should_validate_presence_of\(.*\)/it { should validate_presence_of\1 }/g"
grep "should_validate_uniqueness_of.*" spec/* -Ril | xargs sed -i "s/should_validate_uniqueness_of\(.*\)/it { should validate_uniqueness_of\1 }/g"
grep "should_validate_numericality_of.*" spec/* -Ril | xargs sed -i "s/should_validate_numericality_of\(.*\)/it { should validate_numericality_of\1 }/g"
grep "should_validate_acceptance_of.*" spec/* -Ril | xargs sed -i "s/should_validate_acceptance_of\(.*\)/it { should validate_acceptance_of\1 }/g"
grep "should have_many :.*through.*" spec/* -Ril | xargs sed -i 's/should have_many :\([a-z_=>]*\),.*:through => :\(.*\)
@dzaporozhets
dzaporozhets / whitespace.rake
Created June 5, 2012 08:06 — forked from NARKOZ/whitespace.rake
Whitespaaaaaaaace! WHITESPAAAAAAAACE!
namespace :whitespace do
desc 'Removes trailing whitespace'
task :cleanup do
sh %{for f in `find . -type f | grep -v .git | grep -v ./vendor | grep -v ./tmp | egrep ".(rb|js|haml|html|css|sass)"`;
do sed -i '' 's/ *$//g' "$f";
done}, {:verbose => false}
puts "done"
end
desc 'Converts hard-tabs into two-space soft-tabs'
@dzaporozhets
dzaporozhets / gist:3065552
Created July 7, 2012 08:59 — forked from justincjahn/gist:3062860
Gitlab init.d for RedHat based distributions.
#!/bin/bash
#
# GitLab Runs unicorn and resque for nginx integration.
###
# chkconfig: 35 98 55
# processname: unicorn
# processname: resque
# description: Runs unicorn and resque for nginx integration.
###
#Newbie programmer
def factorial(x):
if x == 0:
return 1
else:
return x * factorial(x - 1)
print factorial(6)
#First year programmer, studied Pascal