Skip to content

Instantly share code, notes, and snippets.

View oleksiilevzhynskyi's full-sized avatar

Oleksii Levzhynskyi oleksiilevzhynskyi

View GitHub Profile
@oleksiilevzhynskyi
oleksiilevzhynskyi / gist:1349543
Created November 8, 2011 22:43
Date Time Format in RUBY
Format meaning:
%a - The abbreviated weekday name (``Sun'')
%A - The full weekday name (``Sunday'')
%b - The abbreviated month name (``Jan'')
%B - The full month name (``January'')
%c - The preferred local date and time representation
%d - Day of the month (01..31)
%H - Hour of the day, 24-hour clock (00..23)
%I - Hour of the day, 12-hour clock (01..12)
@oleksiilevzhynskyi
oleksiilevzhynskyi / gist:1451122
Created December 9, 2011 11:05
Type Less With SSH Aliases

ssh [email protected] -p port

vi ~/.ssh/config

Host aliasname
HostName yourdomain.com
Port port
User yourusername
(function($) {
$.cookieEnabled = function () {
var key = 'testCookieEnabled';
var value = '1';
$.cookie(key, value, { path: '/' });
return $.cookie(key) == value;
};
$(document).ready(function(){
if( !$.cookieEnabled() ) {
@oleksiilevzhynskyi
oleksiilevzhynskyi / rails31init.md
Created February 9, 2012 09:29
Rails 3.1 with Rspec, Capybara, Factory Girl, Haml

Set up Gemfile

# in Gemfile

gem 'rails', '3.1.1'

gem 'haml'
gem 'haml-rails', :group => :development
<%
rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
std_opts = "--strict --tags ~@wip --tags ~@pending"
std_format = "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'}"
%>
default: <%= std_opts %> <%= std_format %> features
wip: --tags @wip --tags ~@pending --wip features
rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip
detail: --tags ~@pending --wip features
@oleksiilevzhynskyi
oleksiilevzhynskyi / gist:1978491
Created March 5, 2012 14:16
LC_CTYPE: cannot change locale (UTF-8)
export LC_ALL='en_GB.UTF-8'
@oleksiilevzhynskyi
oleksiilevzhynskyi / gist:2282518
Created April 2, 2012 10:47
installing the oniguruma gem on debian/ubuntu
sudo apt-get install libonig-dev
gem install oniguruma
@oleksiilevzhynskyi
oleksiilevzhynskyi / capybara_webkit_screenshot_env.rb
Created April 6, 2012 11:46 — forked from mattheworiordan/capybara_webkit_screenshot_env.rb
Cucumber and Capybara-Webkit automatic screenshots on failure
def screen_shot_and_save_page
require 'capybara/util/save_and_open_page'
path = "/#{Time.now.strftime('%Y-%m-%d-%H-%M-%S')}"
Capybara.save_page body, "#{path}.html"
page.driver.render Rails.root.join "#{Capybara.save_and_open_page_path}" "#{path}.png"
end
begin
After do |scenario|
screen_shot_and_save_page if scenario.failed?
@oleksiilevzhynskyi
oleksiilevzhynskyi / 0-readme.md
Created April 17, 2012 08:29 — forked from burke/0-readme.md
ruby-1.9.3-p125 cumulative performance patch.

Patched ruby 1.9.3-p125 for 30% faster rails boot

What is?

This script installs a patched version of ruby 1.9.3-p125 with patches to make ruby-debug work again (#47) and boot-time performance improvements (#66 and #68), and runtime performance improvements (#83 and #84). It also includes the new backported GC from ruby-trunk.

Huge thanks to funny-falcon for the performance patches.

@oleksiilevzhynskyi
oleksiilevzhynskyi / gist:2557639
Created April 30, 2012 11:57
Parallel tests

Parallel tests

test:
  database: yourproject_test<%= ENV['TEST_ENV_NUMBER'] %>
  • Parallel tests with Cucumber: