Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Open to possibilities. Enquire within.

Jeff Dickey jdickey

💭
Open to possibilities. Enquire within.
View GitHub Profile
View redis_pubsub_demo.rb
# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Update 7 Oct 2010:
# - This example does *not* appear to work with Chrome >=6.0. Apparently,
# the WebSocket protocol implementation in the cramp gem does not work
# well with Chrome's (newer) WebSocket implementation.
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby
View capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@kennym
kennym / blogspot_to_jekyll.rb
Created Jul 30, 2011
Migrate your blogger blog posts to jekyll.
View blogspot_to_jekyll.rb
#!/usr/bin/env ruby
#
# Convert blogger (blogspot) posts to jekyll posts
#
# Basic Usage
# -----------
#
# ./blogger_to_jekyll.rb feed_url
#
# where `feed_url` can have the following format:
@bgentry
bgentry / sequel_paranoia.rb
Created Nov 30, 2011
Sequel Paranoia plugin (i.e. acts_as_paranoid)
View sequel_paranoia.rb
module Sequel
module Plugins
# The paranoia plugin creates hooks that automatically set deleted
# timestamp fields. The field name used is configurable, and you
# can also set whether to overwrite existing deleted timestamps (false
# by default). Adapted from Timestamps plugin.
#
# Usage:
#
# # Soft deletion for all model instances using +deleted_at+
@jumski
jumski / enumerize_matcher.rb
Created Apr 6, 2012
Rspec matcher for enumerize gem
View enumerize_matcher.rb
# RSpec matcher to spec enumerize settings
# usage:
#
# it { should enumerize(:sex).in(:male, :female).with_default(:male) }
RSpec::Matchers.define :enumerize do |attribute|
match do |model|
@attribute = attribute
@klass = model.class
@ream88
ream88 / response_matchers.rb
Created Jul 21, 2012
minitest-matchers for controller/functional specs
View response_matchers.rb
# Simple minitest matchers which will make your controller/functional specs less pain in the ass.
#
# ==== Dependencies
#
# gem 'minitest'
# gem 'minitest-matchers'
#
# ==== Matchers
#
# +must_have_status+ and its opposite +wont_have_status+ take both one argument which must be one of the following:
@josevalim
josevalim / 0_README.md
Created Sep 13, 2012
Sinatra like routes in Rails controllers
View 0_README.md

Sinatra like routes in Rails controllers

A proof of concept of having Sinatra like routes inside your controllers.

How to use

Since the router is gone, feel free to remove config/routes.rb. Then add the file below to lib/action_controller/inline_routes.rb inside your app.

@spilth
spilth / ruby-rails-resources.md
Last active Dec 1, 2016
A collection of useful reference and learning resources for Ruby and Rails.
View load_resources.rb
module LoadResources
module ClassMethods
def load_resource(resource_class, options = {})
filter_options = options.slice :only, :except, :if, :unless
resource_options = options.except :only, :except, :if, :unless
send(:before_filter, filter_options) do |controller|
ResourceBuilder.new(controller, resource_class, resource_options)
.send(:load_resource)
end
@jacrook
jacrook / font_variables.scss
Last active Sep 23, 2021
Sass Css Font Stack Variables
View font_variables.scss
//////////////////////////////////////////////////////////////
// Font Variables (http://cssfontstack.com/)
//////////////////////////////////////////////////////////////
//
// Serif font-stacks
//
$baskerville-font-stack: "Big Caslon", "Book Antiqua", "Palatino Linotype", Georgia, serif !default;