Skip to content

Instantly share code, notes, and snippets.

@paulirish
paulirish / gist:603681
Created September 29, 2010 22:25
html5 and friends - a bigass bulleted list of features

HTML5 and friends.

A bigass bulleted list of features.

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

javascript APIs

  • Web Storage (localStorage, sessionStorage)
  • Web SQL Database
# 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,
@pairing
pairing / active_model_lint.rb
Created October 21, 2010 19:03
RSpec ActiveModel Lint shared example
# 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|
@dchelimsky
dchelimsky / gist:669112
Created November 9, 2010 14:07
swinger_without_rspec_monkey_patch.rb
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
@micho
micho / gist:728639
Created December 5, 2010 00:40
Throttle and debounce examples
// 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)
@fguillen
fguillen / git_tips.md
Created December 19, 2010 20:53
Git Tips

(Several of these git examples have been extracted from the book 'Pragmatic guide to GIT' of Travis Swicegood )

Git tips

Global git user

git config --global user.name "Fernando Guillen"
git config --global user.email "fguillen.mail+spam@gmail.com"

Repository git user

cd /develop/myrepo

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)/
]
@paneq
paneq / capc.rb
Created January 27, 2011 18:50
Creating an object with Capybara api and jumping into it.
#!/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
@igrigorik
igrigorik / ruby-1.9-tips.rb
Created February 3, 2011 17:19
Ruby 1.9 features, tips & tricks you may not know about...
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!"
@javier
javier / gist:827358
Created February 15, 2011 10:21
kaminari ultrasphinx
#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