Comparing different Ruby interfaces to like a video using YouTube API:
/* | |
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@@@ |
#!/bin/sh | |
# | |
case "$2,$3" in | |
merge,) | |
original_message=$(<$1) | |
echo $original_message | sed -e "s/^Merge branch '\([[:digit:]]*\)-/[#\1] &/" > $1 ;; | |
*) ;; | |
esac |
unless File.exists?('Gemfile') | |
File.write('Gemfile', <<-GEMFILE) | |
source 'https://rubygems.org' | |
gem 'rails', github: 'rails/rails' | |
gem 'sqlite3' | |
GEMFILE | |
system 'bundle' | |
end |
class User | |
attr_accessible :username | |
has_many :audio_items | |
end | |
class AudioItem | |
attr_accessible :position | |
belongs_to :user |
Code snippets for the presentation about Bh · Bootstrap Helpers, comparing code to display:
- A horizontal form (HTML, without Bh)
- A horizontal form (ERB, without Bh)
- A horizontal form (ERB, with Bh)
- An inline form (ERB, with Bh)
- A simple modal (ERB, with Bh)
- A simple modal (ERB, without Bh)
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.
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 toid: "1,3,4"
- the idea is instead to match to
posts#index
with the params set toids: ["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' |