Skip to content

Instantly share code, notes, and snippets.

View krasio's full-sized avatar
🎣
Gone fishing

Krasimir Angelov krasio

🎣
Gone fishing
View GitHub Profile
module Inspector
def self.analyze(data)
registered_plugins.each do |name, block|
puts "Report: #{name}"
block.call(data)
end
end
def self.registered_plugins
@registered_plugins ||= {}
module Resque
class Job
alias_method :original_perform, :perform
def perform
original_perform
rescue ActiveRecord::StatementInvalid => e
if e.message =~ /server has gone away/i
ActiveRecord::Base.verify_active_connections!
retry
# features/support/configuration.rb
Before do
Neo4j::Transaction.run do
Neo4j._all_nodes.each { |n| n.del unless n.neo_id == 0 }
end
end
# spec/support/configuration.rb
def delete_all
Neo4j::Transaction.run do
# app/models/user.rb
class User
include Mongoid::Document
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable, :lockable and :timeoutable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
end
# config/environment.rb
# setting default timezone for your app when firing up Rails
config.time_zone = 'UTC'
# app/controllers/application_controller.rb
# changing timezone to one selected by user if logged in
before_filter :set_time_zone
def set_time_zone
Time.zone = current_user.time_zone if logged_in?
end
[alias]
c = commit -m
a = add
di = diff
dic = diff --cached
pl = pull
ps = push
plre = pull --rebase
st = status
out = log origin..HEAD
if [ "\$(type -t __git_ps1)" ]; then
PS1="\$(__git_ps1 '[%s]')$PS1"
fi