Skip to content

Instantly share code, notes, and snippets.

Then /^I should( not)? see the following table rows( in any order)?:?$/ do |negate, unordered, expected_table|
extend TableStepsHelper
document = Nokogiri::HTML(page.body)
table = document.xpath('//table//tr').collect { |row| row.xpath('.//th|td') }
expected_table = parse_table(expected_table)
if negate
table.should not_contain_table(expected_table)
else
#!/bin/bash
wget http://download.jetbrains.com/ruby/RubyMine-5.4.3.tar.gz -O /tmp/rubymine
sudo tar -xzvf /tmp/rubymine -C /opt
sudo mv /opt/RubyMine-5.4.3.2.1 /opt/RubyMine
sudo cat >/usr/share/applications/jetbrains-rubymine.desktop <<EOF
[Desktop Entry]
Name=RubyMine
Comment=Integrated Development Environment
TryExec=/opt/RubyMine/bin/rubymine.sh
@bogdanRada
bogdanRada / Downgrading PHP 5.4 to 5.3 on Ubuntu 12.10 (Quantal)
Created July 12, 2013 12:11
Downgrading PHP 5.4 to 5.3 on Ubuntu 12.10 (Quantal)
First, I got a list of PHP-related install packages:
$ dpkg --get-selections | grep php
libapache2-mod-php5 install
php-apc install
php-pear install
php5 install
php5-cli install
if ENV['MY_RUBY_HOME'] && ENV['MY_RUBY_HOME'].include?('rvm')
begin
rvm_path = File.dirname(File.dirname(ENV['MY_RUBY_HOME']))
# rvm_lib_path = File.join(rvm_path, 'lib')
# $LOAD_PATH.unshift rvm_lib_path
require 'rvm'
RVM.use_from_path! File.dirname(File.dirname(__FILE__))
rescue LoadError
raise "RVM ruby lib is currently unavailable."
end
module ActiveSupport
module PagedScope
def self.extended(base)
base.scope :paginated, lambda { |page,per_page|
page ||= 0
per_page ||= 25
base.limit( per_page.to_i ).offset( per_page.to_i * page.to_i )
}
end
# Used to parse ActionScript style annotations
# [Annotation(key="value",foo="bar")]
# Where Annotation is the name and key and foo are attribute names.
# Quick string matching, does not create an "Annotation Object"
# for now, though that would be an improvement.
class AS3AnnotationParser
#Does the given annotation exist in the provided string?
def self.has_annotation (contents, name)
contents.match(/\[#{name}[^\]]?+\]/) != nil
end
@bogdanRada
bogdanRada / passenger apache setup
Last active December 26, 2015 20:39
Passenger Apache setup
After successful installation of the Apache 2 module, follow the next set of step to configure Apache.
Create the following two files in /etc/apache2/mods-available
sudo touch /etc/apache2/mods-available/passenger.load
paste following code in passenger.load file
LoadModule passenger_module /usr/lib/ruby/gems/1.9.2(your version)/gems
/passenger-3.0.2/ext/apache2/mod_passenger.so
@bogdanRada
bogdanRada / Git show deleted files from a directory
Last active December 27, 2015 03:59
Git show deleted files from a directory
$ git log --diff-filter=D --summary | sed -n '/^commit/h;/\/some_dir\//{G;s/\ncommit \(.*\)/ \1/gp}'
delete mode 100644 blah/some_dir/file1 d3bfbbeba5b5c1da73c432cb3fb61990bdcf6f64
delete mode 100644 blah/some_dir/file2 d3bfbbeba5b5c1da73c432cb3fb61990bdcf6f64
delete mode 100644 blah/some_dir/file3 9c89b91d8df7c95c6043184154c476623414fcb7
You'll get all files deleted from some_dir (see the sed command) together with the commit number in which it happen. Any sed regex will do (I use this to find deleted file types, etc)
@bogdanRada
bogdanRada / rails_routes_multiple_files.rb
Last active January 3, 2016 20:39 — forked from dhh/gist:2492118
rails_routes_multiple_files.rb
class ActionDispatch::Routing::Mapper
def draw(routes_name)
instance_eval(File.read(Rails.root.join("config/routes/#{routes_name}.rb")))
end
end
BCX::Application.routes.draw do
draw :api
draw :account
draw :session