Skip to content

Instantly share code, notes, and snippets.

Riccardo Tacconi rtacconi

Block or report user

Report or block rtacconi

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:286083
# render a file (image, video) inside the browser
def inline
@video = Video.find(params[:id])
send_file @video.filepath.path, :type => @video.filepath_content_type
# force the browser to show the download modal box and send the file to the browser
# you can use the :xsendfile => true option
# send_file @video.filepath.path, :type => @video.filepath_content_type
def download
View pickaxe_book_googgle_search_test.rb
require File.dirname(__FILE__) + '/../test_helper'
class PickaxeBookGooggleSearchTest < ActiveSupport::TestCase
include WatirOnRails
# Uncomment the following lines to specify a test server.
# WatirOnRails defaults to http://localhost:3000
# server "localhost"
# port 3001
View gist:324409
#!/usr/local/bin/ruby -w
require "rubygems"
require "highline/import"
# The old way, using ask() and say()...
choices = %w{ruby python perl}
say("This is the old way using ask() and say()...")
say("Please choose your favorite programming language:")
say( { |c| " #{c}\n" }.join)
View gist:492436
context "should destroy participation" do
setup do
@configuration = Factory.create :configuration, :status => 'LIVE'
@p = Factory.create :participation, :configuration => @configuration
@admin = Factory.create :participant, :admin => true
login_as @admin
should "delete :destroy participations" do
assert_difference('Participation.count', -1) do
View gist:492457
<html><body>You are being <a href="">redirected</a>.</body></html>
View gist:523101
p = Participant.find params[:id]
render :nothing => true, :status => 200
render :nothing => true, :status => 404
View gist:569969
With this code:, "Move questions to...").click
browser.alert do
browser.button(:id => "alert").click
end #=> "the alert message"
I get this error:
View gist:584444
echo "recursively removing .svn folders from"
rm -rf `find . -type d -name .svn`
rtacconi / gist:708121
Created Nov 20, 2010
Test unique attributes with RSpec and accept_values_for, a custom matcher
View gist:708121
class CourseItem < ActiveRecord::Base
validates_presence_of :course_id, :day, :url
validates_uniqueness_of :course_id, :scope => :day, :message => "- this day has been already created."
describe CourseItem do
# check uniqueness using this matcher
context "should create one item per day and per course only" do
before do
CourseItem.create! :day => 1, :course_id => 1, :url => '/courses/index.html'
rtacconi / package-ubuntu-server-rvm.txt
Created Jun 20, 2011
Ubuntu server dependencies for Ruby 1.9.2 (rvm)
View package-ubuntu-server-rvm.txt
sudo aptitude install curl git-core ruby build-essential bison openssl libreadline5 libreadline-dev curl git-core zlib1g zlib1g-dev libssl-dev vim libsqlite3-0 libsqlite3-dev sqlite3 libreadline-dev libxml2-dev git-core subversion autoconf
You can’t perform that action at this time.