Skip to content

Instantly share code, notes, and snippets.

@smoothdvd
smoothdvd / application_helper.rb
Created February 7, 2012 05:27 — forked from purcell/application_helper.rb
Make will_paginate generate HTML that bootstrap.less will render nicely
# Based on https://gist.github.com/1182136
class BootstrapLinkRenderer < ::WillPaginate::ActionView::LinkRenderer
protected
def html_container(html)
tag :div, tag(:ul, html), container_attributes
end
def page_number(page)
tag :li, link(page, page, :rel => rel_value(page)), :class => ('active' if page == current_page)
@josevalim
josevalim / 1_README.md
Created December 13, 2011 09:30
FSSM based FileWatcher for Rails

Rails 3.2 ships with a simple FileWatcher that only reloads your app if any of the files changed.

Besides, it also provides a mechanism to hook up your own file watcher mechanism, so we can use tools like FSSM that hooks into Mac OS X fsevents. This is an example on how to hook your own mechanism (you need Rails master, soon to be Rails 3.2):

  1. Copy the 2_file_watcher.rb file below to lib/file_watcher.rb

  2. Add the following inside your Application in config/application.rb

if Rails.env.development?

@carlhoerberg
carlhoerberg / urlrewriter.rb
Created August 30, 2011 21:30
A sprockets processor which rewrites the relative urls in a css when concatenating css files
require 'sprockets'
require 'pathname'
require 'uri'
module Sprockets
class UrlRewriter < Processor
def evaluate(context, locals)
rel = Pathname.new(context.logical_path).parent
data.gsub /url\(['"]?([^\s)]+\.[a-z]+)(\?\d+)?['"]?\)/ do |url|
return url if URI.parse($1).absolute?
@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
@botanicus
botanicus / svg_processing.rb
Created August 9, 2010 14:57
Change colours of a SVG image with Nokogiri.
#!/usr/bin/env ruby
# encoding: utf-8
require "nokogiri"
require "fileutils"
# setup
required_colors = ["ff000", "006600", "003399"]
# main