Skip to content

Instantly share code, notes, and snippets.

View kpumuk's full-sized avatar

Dmytro Shteflyuk kpumuk

View GitHub Profile
Feature: User login
In order to use application
As a user
I want to be able to login and logout from the application
Scenario: Access restricted to an anonymous user
Given Anonymous user
When I go to the home page
Then I should be on the login page
class Module
def name_finder(*methods)
methods.each do |method|
raise TypeError.new("method name is not symbol") unless method.is_a?(Symbol)
metaclass = class << self; self; end
metaclass.send(:define_method, method) do
instance_variable_get(self.find_by_name(method.to_s))
end
end
end
# == Schema Information
# Schema version: 20090420101231
#
# Table name: loop_locks
#
# entity_id :integer(4) not null
# loop :string(255) not null
# created_at :datetime not null
# timeout_at :datetime not null
#
def from_russia?
if MAXMIND_GEOIP_DB
info = MAXMIND_GEOIP_DB.look_up(ip_address) || {}
info[:country_code].to_s.upcase == 'RU'
else
false
end
end
@kpumuk
kpumuk / Rakefile
Created March 16, 2010 14:11
Append some actions to an existing Rake task (something like "after" action)
task :hello do
puts 'hello'
end
task :hello do
puts 'world!'
end
@kpumuk
kpumuk / Rakefile
Created March 16, 2010 14:16
Perform some actions before the rake task execution (something like "before" action)
task :hello do
puts 'hello'
end
task :before do
puts 'before all'
end
task :hello => :before
@kpumuk
kpumuk / Rakefile
Created March 16, 2010 14:21
Completely override rake task (and dismiss it's actions and prerequisites)
task :hello do
puts 'hello'
end
Rake.application[:hello].clear
task :hello do
puts 'hello, world'
end
@kpumuk
kpumuk / mysql_xtradb.patch
Created April 20, 2010 08:02
Patch for the Homebrew's mysql formula to build it with Percona XtraDB plugin
diff --git a/Library/Formula/mysql.rb b/Library/Formula/mysql.rb
index 1f2ecdc..b6f3c01 100644
--- a/Library/Formula/mysql.rb
+++ b/Library/Formula/mysql.rb
@@ -1,5 +1,11 @@
require 'formula'
+class PerconaXtradb < Formula
+ url 'http://www.percona.com/percona-builds/Percona-Server/Percona-Server-5.1.45-10/source/percona-xtradb-1.0.6-10.tar.gz'
+ md5 'd20bc3befd6e732c40fd41a9adcec9d9'
begin
require 'capistrano/recipes/deploy/strategy/fast_remote_cache'
rescue LoadError
require 'capistrano/recipes/deploy/strategy/remote_cache'
end
module Capistrano
module Deploy
module Strategy
RsyncRemoteCache = Class.new(defined?(FastRemoteCache) ? FastRemoteCache : RemoteCache)
(n=(c=IRB.conf)[:PROMPT][:NULL]).map{|k,v|n[k]=v.to_s};c[:MAIN_CONTEXT].prompt_mode=c[:AUTO_INDENT]=:NULL;class IRB::InputMethod;def prompt=(p);@prompt=p.gsub(/^(\s*)/){'8=='+'='*$1.size}+'D ';end;end