Skip to content

Instantly share code, notes, and snippets.

@claudiob
claudiob / default.css
Created June 7, 2011 22:22
Three different CSS coding styles
/*
Theme Name: Stubbornella
Theme URI: http://www.stubbornella.org/@@@theme specific url@@@
Description: The stubbornella CMS theme based on the default WordPress theme.
Version: .1
Author: Nicole Sullivan
Author URI: http://www.stubbornella.org/
Stubbornella Beta .1
http://www.stubbornella.org/ @@@theme specific url@@@
@claudiob
claudiob / prepare-commit-msg
Created August 8, 2013 19:10
At Topspin, we use the Pivotal Tracker ticket number in the name of the git branch assigned to that feature, e.g. 12345-feature. However, this format does not work for Pivotal/Github hooks, which require this text in the commit message: [#12345] feature If you just add the following gist in .git/hooks/prepare-commit-msg then the integration betw…
#!/bin/sh
#
case "$2,$3" in
merge,)
original_message=$(<$1)
echo $original_message | sed -e "s/^Merge branch '\([[:digit:]]*\)-/[#\1] &/" > $1 ;;
*) ;;
esac
@claudiob
claudiob / test_order_is_affected_by_limit_in_the_argument.rb
Created October 3, 2013 04:49
The ActiveRecord `order` is subject to SQL injection (http://rails-sqli.org/#order) and, for instance, applies LIMIT to the query. Maybe we can improve this?
unless File.exists?('Gemfile')
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
gem 'rails', github: 'rails/rails'
gem 'sqlite3'
GEMFILE
system 'bundle'
end
@claudiob
claudiob / jeremy.rb
Last active August 29, 2015 14:00 — forked from jcohenho/gist:11065868
class User
attr_accessible :username
has_many :audio_items
end
class AudioItem
attr_accessible :position
belongs_to :user
@claudiob
claudiob / How to like a YouTube video in Ruby.md
Last active August 29, 2015 14:02
How to like a YouTube video in Ruby
@claudiob
claudiob / Bh · Bootstrap Helpers for Ruby.md
Last active August 29, 2015 14:06
Bh · Bootstrap Helpers for Ruby

Code snippets for the presentation about Bh · Bootstrap Helpers, comparing code to display:

  1. A horizontal form (HTML, without Bh)
  2. A horizontal form (ERB, without Bh)
  3. A horizontal form (ERB, with Bh)
  4. An inline form (ERB, with Bh)
  5. A simple modal (ERB, with Bh)
  6. A simple modal (ERB, without Bh)
@claudiob
claudiob / Analysis.md
Last active August 29, 2015 14:12
Benchmarking PR #17227 to Rails

Performance comparison: throw(:abort) vs. raise ActiveSuppot::CallbackAborted #################################################################################

In the current Rails stable (4.2) and master (5.0.0.alpha), callbacks can be halted with return false.

PR #17227 replaces this behavior with an explicit throw(:abort).

In a comment, @tenderlove asks whether this will have a significant impact on the performance, and whether it would be better (performance-wise) to use a raise/rescue construct instead.

The code below can be used to benchmark the impact of these different strategies on ActiveRecord callbacks.

@claudiob
claudiob / 5_0_release_notes.md
Created January 2, 2015 18:49
Proposed release notes for Rails 5, stems from PR #17227

Ruby on Rails 5.0 Release Notes

Highlights in Rails 5.0:

  • Explicitly halt callback chains

These release notes cover only the major changes. To learn about other features, bug fixes, and changes, please refer to the changelogs or check out the list of commits in the main Rails repository on GitHub.

@claudiob
claudiob / README.md
Last active August 29, 2015 14:15
I need feedback 😀

This stems from the open PR #15719 on Collection Routing.

That PR is very big and adds many new features to Rails, so I'd like to follow a conservative approach and add one feature at the time, making sure it's fully tested and backwards-compatible.


The first feature is to change the match of a path like GET /posts/1,3,4:

  • currently, Rails matches to posts#show with the params set to id: "1,3,4"
  • the idea is instead to match to posts#index with the params set to ids: ["1", "3", "4"].
begin
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
end
gemfile(true) do
source 'https://rubygems.org'
gem 'rails', github: 'rails/rails'