Skip to content

Instantly share code, notes, and snippets.

View bbonamin's full-sized avatar
🕶️

Bruno Bonamin bbonamin

🕶️
View GitHub Profile
@bbonamin
bbonamin / pr.md
Created August 7, 2013 14:05 — forked from piscisaureus/pr.md

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = [email protected]:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@bbonamin
bbonamin / spec_helper.rb
Created August 6, 2013 15:11
spec_helper
require 'rubygems'
require 'spork'
#uncomment the following line to use spork with the debugger
#require 'spork/ext/ruby-debug'
Spork.prefork do
# Loading more in this block will cause your tests to run faster. However,
# if you change any configuration or code from libraries loaded here, you'll
# need to restart spork for it take effect.
# This file is copied to spec/ when you run 'rails generate rspec:install'
class FooController < ApplicationController
before_filter :user_required!
before_filter :admin_required!, :only => [:secret]
def not_secret
end
def secret
end
end
@bbonamin
bbonamin / Gemfile
Created January 7, 2013 11:40 — forked from soffes/Gemfile
source 'https://rubygems.org'
# The latest version of Ruby
ruby '1.9.3'
# The lastest version of Rails
gem 'rails', '3.2.10'
# Postgres
gem 'pg'
@bbonamin
bbonamin / quiet_assets.rb
Created December 26, 2012 22:57
Hide Rails Asset Pipeline noisy logging
if Rails.env.development?
Rails.application.assets.logger = Logger.new('/dev/null')
Rails::Rack::Logger.class_eval do
def call_with_quiet_assets(env)
previous_level = Rails.logger.level
Rails.logger.level = Logger::ERROR if env['PATH_INFO'] =~ %r{^/assets/}
call_without_quiet_assets(env)
ensure
Rails.logger.level = previous_level
end
@bbonamin
bbonamin / elasticsearch.rake
Created August 14, 2012 18:20 — forked from jarosan/elasticsearch.rake
Elasticsearch reindex task
# Run with: rake environment elasticsearch:reindex
namespace :elasticsearch do
desc "re-index elasticsearch"
task :reindex => :environment do
klass = Place
ENV['CLASS'] = klass.name
ENV['INDEX'] = new_index = klass.tire.index.name << '_' << Time.now.strftime('%Y%m%d%H%M%S')
class Model
default_scope where(deleted_at: nil)
def destroy_without_callbacks
self.deleted_at = Time.now.utc
update_without_callbacks
end
def destroy
run_callbacks :destroy do
@bbonamin
bbonamin / test.java
Created July 25, 2012 14:51
Java selenium drag and drop
bootons = driver.findElements(By.cssSelector("(removed)"));
for (int i = 0; i < bootons.size(); i++) {
WebElement booton = bootons.get(i);
List < WebElement > targets = driver.findElements("(removed)"));
for (int j = 0; j < targets.size(); j++) {
WebElement target = targets.get(j);
Actions builder = new Actions(driver);
Action dragAndDrop = builder.clickAndHold(booton).moveToElement(target).release().build();
dragAndDrop.perform();
}
@bbonamin
bbonamin / drag_drop.rb
Created July 17, 2012 14:18
Capybara drag and drop
shared_examples_for "driver with javascript support" do
before { @driver.visit('/with_js') }
describe '#find' do
it "should find dynamically changed nodes" do
@driver.find('//p').first.text.should == 'I changed it'
end
end
describe '#drag_to' do
@bbonamin
bbonamin / will_paginate.rb
Created June 27, 2012 22:08 — forked from isaacbowen/will_paginate.rb
extends will_paginate to play well with Twitter's Bootstrap
# config/initializers/will_paginate.rb
module WillPaginate
module ActionView
def will_paginate(collection = nil, options = {})
options[:renderer] ||= BootstrapLinkRenderer
super.try :html_safe
end
class BootstrapLinkRenderer < LinkRenderer