I commonly need to get a big list of all the stuff people think of when they think new and shiny these days. This list is for that.
I take a very inclusionist approach to it. 1
- Web Storage (localStorage, sessionStorage)
- Web SQL Database
I commonly need to get a big list of all the stuff people think of when they think new and shiny these days. This list is for that.
I take a very inclusionist approach to it. 1
# Rails developers have long had bad experiences with fixtures for | |
# several reasons, including misuse. | |
# | |
# Misuse of fixtures is characterized by having a huge number of them, | |
# requiring the developer to maintain a lot of data and creating dependencies | |
# between tests. In my experience working (and rescuing) many applications, 80% | |
# of fixtures are only used by 20% of tests. | |
# | |
# An example of such tests is one assuring that a given SQL query with | |
# GROUP BY and ORDER BY conditions returns the correct result set. As expected, |
# adapted from rspec-rails http://github.com/rspec/rspec-rails/blob/master/spec/rspec/rails/mocks/mock_model_spec.rb | |
shared_examples_for "ActiveModel" do | |
require 'test/unit/assertions' | |
require 'active_model/lint' | |
include Test::Unit::Assertions | |
include ActiveModel::Lint::Tests | |
# to_s is to support ruby-1.9 | |
ActiveModel::Lint::Tests.public_instance_methods.map{|m| m.to_s}.grep(/^test/).each do |m| |
RSpec.configure do |c| | |
c.around do |example| | |
Capybara.using_driver(example.metadata[:driver], &example) | |
end | |
end | |
module Capybara | |
def self.using_driver(driver) | |
Capybara.current_driver = driver | |
yield |
// Run the function as soon as it's called, but prevent further calls during `delay` ms | |
// Example: function.throttle(200) will only run function() once every 200 ms. | |
// Useful, for example, to avoid constant processing while typing in a live search box. | |
Function.prototype.throttle = function(delay) { | |
var fn = this | |
return function() { | |
var now = (new Date).getTime() | |
if (!fn.lastExecuted || fn.lastExecuted + delay < now) { | |
fn.lastExecuted = now | |
fn.apply(fn, arguments) |
RSpec.configure do |config| | |
# RSpec automatically cleans stuff out of backtraces; | |
# sometimes this is annoying when trying to debug something e.g. a gem | |
config.backtrace_clean_patterns = [ | |
/\/lib\d*\/ruby\//, | |
/bin\//, | |
/gems/, | |
/spec\/spec_helper\.rb/, | |
/lib\/rspec\/(core|expectations|matchers|mocks)/ | |
] |
#!/usr/bin/env ruby | |
require 'bundler' | |
Bundler.setup(:default, :test) if defined?(Bundler) | |
require "selenium-webdriver" | |
require 'capybara/dsl' | |
Capybara.default_driver = :selenium | |
Capybara.default_selector = :css | |
Capybara.default_wait_time = 5 |
def tip(msg); puts; puts msg; puts "-"*100; end | |
# | |
# 30 Ruby 1.9 Tips, Tricks & Features: | |
# http://www.igvita.com/2011/02/03/new-ruby-19-features-tips-tricks/ | |
# | |
tip "Upgrading to Ruby 1.9 is simple: rvm install 1.9.2 && rvm --default 1.9.2" | |
tip "Ruby 1.9 supports named captures in regular expressions!" |
#kaminari uses different method names than will:paginate, but with a small add-on | |
#we can use it for paginating thinking sphinx results | |
ThinkingSphinx::Search.class_eval do | |
def num_pages | |
total_pages | |
end | |
def limit_value | |
per_page | |
end |