Skip to content

Instantly share code, notes, and snippets.

View dzaporozhets's full-sized avatar

Dmitriy Zaporozhets dzaporozhets

View GitHub Profile
@dzaporozhets
dzaporozhets / gist:2803029
Created May 27, 2012 09:30
Clone all branches to local
`git branch -a`.split("\n")[2..-1].map { |name| name = name.gsub("remotes\/origin\/", "").strip; `git checkout -b #{name} origin/#{name}` }
@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 / 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 / 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"
#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 / 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
# 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
Started GET "/taurus" for 193.138.246.138 at 2011-12-09 16:36:50 +0000
Processing by ServiceProvidersController#show as HTML
Parameters: {"id"=>"taurus"}
Rendered shared/_social_bar.html.erb (0.1ms)
Rendered /home/styleup/StyleUp/shared/bundle/ruby/1.9.1/gems/gmaps4rails-1.3.2/app/views/gmaps4rails/_gmaps4rails.html.erb (0.8ms)
Rendered service_providers/_service_item.html.erb (0.2ms)
Rendered service_providers/_service_type_item.html.erb (2.7ms)
Rendered service_providers/_service_type_item.html.erb (0.4ms)
Rendered service_providers/show.html.erb within layouts/application (35.1ms)
Completed 500 Internal Server Error in 44ms
sudo -u USERNAME -H sh -c "string"
@dzaporozhets
dzaporozhets / gist:1432871
Created December 5, 2011 08:35
ruby native
sudo aptitude install git-core curl gcc checkinstall libxml2-dev libxslt-dev sqlite3 libsqlite3-dev libcurl4-openssl-dev libreadline5-dev libc6-dev libssl-dev libmysql++-dev make build-essential zlib1g-dev
wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2-p290.tar.gz
tar xfvz ruby-1.9.2-p290.tar.gz
cd ruby-1.9.2-p290
./configure
make
sudo checkinstall -D