Skip to content

Instantly share code, notes, and snippets.

desc "Launch a Capybara session in a console"
task capyconsole: :environment do
require "capybara"
require "pry"
driver = case ENV.fetch('DRIVER', 'phantomjs')
when 'phantomjs'
require "capybara/poltergeist"
Capybara.register_driver :poltergeist_debug do |app|
@mileszs
mileszs / 0_reuse_code.js
Last active August 29, 2015 14:16
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
#!/bin/bash
VERSION="1.1"
REEV="http://rubyforge.org/frs/download.php/48623/ruby-enterprise-1.8.6-20081215.tar.gz"
REEF="ruby-enterprise-1.8.6-20081215.tar.gz"
REEFF=${REEF%".tar.gz"}
PASSENGER="2.0.6"
echo "#####################################"
echo "Welcome, let's get this party rollin'"
echo "#####################################"
@mileszs
mileszs / snippet.rb
Created February 26, 2009 20:07 — forked from jqr/snippet.rb
require 'rational'
class Numeric
def to_r(rounding = 10_000)
Rational((self * rounding).to_i, rounding)
end
end
class Rational
def to_proper
#!/bin/bash
# Unattended REE/Passenger installation
# Source: http://weblog.brightlight-ict.nl/2008/12/unattended-passenger-ruby-enterprise-installation-on-ubuntu-8/
# 15/03/09 Updated to use latest r.e.e. and passenger 2.1 and rewrote bits thanks to the comments left on my blog. Thanks guys
if [ "$(whoami)" != "root" ]; then
echo "You need to be root to run this!"
exit 2
fi
class LegislatorsController < ApplicationController
layout :choose_layout
def search
setup_search(legislators_path(:u => params[:u]))
end
def bm_search
setup_search(bm_legislators_path(:u => params[:u]))
end
<!DOCTYPE html>
<html lang='en'>
<head>
<title>LiftCalc</title>
<meta http-equiv='Content-type' content='text/html;charset=UTF-8'>
<meta name='viewport' content='width=device-width'>
<meta name='viewport' content='initial-scale=1.6'>
<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js'></script>
<script type='text/javascript'>
# Warning: Loses any scope it may have been called on!
def send_all_in_batches(batch_size, method, *args)
transaction do
start_id = first(:order => 'id ASC').id
end_id = first(:order => 'id DESC').id
current_id = start_id
while current_id <= end_id
if time = args.delete(:time)
send_at(time, :send_to_batch, current_id, current_id + batch_size, method, *args)
else
# Used to graph results from autobench
#
# Usage: ruby autobench_grapher.rb result_from_autobench.tsv
#
# This will generate three svg & png graphs
require "rubygems"
require "scruffy"
require 'csv'
require 'yaml'
ActionController::Integration::Session.class_eval do
def generic_url_rewriter
env = {
'REQUEST_METHOD' => "GET",
'QUERY_STRING' => "",
"REQUEST_URI" => "/",
"HTTP_HOST" => host,
"SERVER_PORT" => https? ? "443" : "80",
"HTTPS" => https? ? "on" : "off",
"rack.input" => "wtf"