Skip to content

Instantly share code, notes, and snippets.

View lbadura's full-sized avatar

Lukasz Badura lbadura

View GitHub Profile
@wheeyls
wheeyls / application_controller.rb
Last active May 15, 2022 07:04
A cached key-value store backend for Rails I18n. Designed to speed up translations when using a database like Redis or Mongo.
class ApplicationController < ActionController::Base
before_filter :ensure_fresh_i18n
private
def ensure_fresh_i18n
I18n.backend.ensure_freshness! I18n.locale
end
end
@devsigner
devsigner / rbenv-install-system-wide.sh
Created March 28, 2012 09:52 — forked from v1nc3ntlaw/rbenv-install-system-wide.sh
rbenv install ruby 1.9.3-p125 on Debian 6 Squeeze
# Update, upgrade and install development tools:
apt-get update
apt-get -y upgrade
apt-get -y install build-essential git-core curl libssl-dev \
libreadline5 libreadline5-dev \
zlib1g zlib1g-dev \
libmysqlclient-dev \
libcurl4-openssl-dev \
libxslt-dev libxml2-dev
@jc00ke
jc00ke / capybara-helpers.rb
Created January 28, 2012 07:47
Capybara helpers
def screenshot
require 'capybara/util/save_and_open_page'
now = Time.now
p = "/#{now.strftime('%Y-%m-%d-%H-%M-%S')}-#{rand}"
Capybara.save_page body, "#{p}.html"
path = Rails.root.join("#{Capybara.save_and_open_page_path}" "#{p}.png").to_s
page.driver.render path
Launchy.open path
end
@asux
asux / deploy.rb
Last active September 27, 2015 04:38
My typical multistaging deploy.rb for Vlad
require 'bundler/vlad'
require 'vlad/rvm'
set :default_stage, 'production'
set :shared_paths, {
'log' => 'log',
'system' => 'public/system',
'pids' => 'tmp/pids',
'sockets' => 'tmp/sockets',
@metaskills
metaskills / wait_until.rb
Last active May 2, 2024 01:51
Never sleep() using Capybara!
# WAIT! Do consider that `wait` may not be needed. This article describes
# that reasoning. Please read it and make informed decisions.
# https://www.varvet.com/blog/why-wait_until-was-removed-from-capybara/
# Have you ever had to sleep() in Capybara-WebKit to wait for AJAX and/or CSS animations?
describe 'Modal' do
should 'display login errors' do
visit root_path
@mudge
mudge / application_helper.rb
Created September 14, 2010 18:50
JRuby class for using pegdown as the Rails Markdown processor.
require 'markdown'
module ApplicationHelper
def markdown(text)
if text.present?
Markdown.new(text).to_html
else
text
end
end