Skip to content

Instantly share code, notes, and snippets.

@jamesarosen
jamesarosen / towards_a_better_rails_navigation_plugin.md
Created February 12, 2010 17:55
README for a proposed Rails navigation helper

Tired of building custom navigation code for each site?

Have you seen Ryan Heath's Navigation Helper? It's very usable, but it only does one nav-bar. I often have sites where there are many, e.g.

+-----------------------------------------------------------+
| MyApp                           | Home | Sign Out | FAQ | | # "site" nav bar
|===========================================================|
| | *Projects* | Friends |                                  | # "area" nav bar
|===========================================================|

| | Project Overview | Budget | History | | # "tabs" nav bar

@cavalle
cavalle / warden.rb
Created August 25, 2010 10:46
Testing Warden/Devise with Steak
# Create a file `spec/acceptance/support/warden.rb' with the following
# contents:
Spec::Runner.configure do |config|
config.include Warden::Test::Helpers, :type => :acceptance
config.after(:each, :type => :acceptance) { Warden.test_reset! }
end
# Or, if you're using RSpec 2 / Rails 3, the contents should be the following
# instead:

Sass/Less Comparison

In this document I am using Sass's SCSS syntax. You can choose to use the indented syntax in sass, if you prefer it, it has no functional differences from the SCSS syntax.

For Less, I'm using the JavaScript version because this is what they suggest on the website. The ruby version may be different.

Variables

@bryanl
bryanl / campfire-emoji.txt
Created January 27, 2011 16:34
campfire emoji
Surround these with : e.g. :calling:
+1
-1
bulb
calling
clap
cop
email
feet
describe "GET current" do
before do
@request.cookies['hidden_notices'] = "1,#{notices(:permanent).id}"
get :current, :format => 'js'
end
it { should respond_with(:success) }
it { should set_cookie(:hidden_notices).to("#{notices(:permanent).id}") }
it { should render_template('notices/current') }
end
@robb
robb / NSColor+Hex.h
Created April 1, 2011 14:57
NSColor+Hex
//
// NSColor+Hex.h
// SoundCloud
//
// Created by Robert Böhnke on 4/1/11.
// Copyright 2011 Soundcloud Ltd. All rights reserved.
//
#import <Foundation/Foundation.h>
@jraines
jraines / rails31init.md
Created May 24, 2011 17:03
Rails 3.1 with Rspec, Cucumber, Factory Girl, Haml, and Simple Form

Install Rails 3.1 RC

gem install rails --pre

generate new app, skipping Test::Unit file generation

rails new my_app -T

Set up Gemfile

@pat
pat / gist:1096339
Created July 21, 2011 01:43
Check definition pair in a definition list
Then /^"([^"]*)" should be set as "([^"]*)"$/ do |term, definition|
first(:xpath, "//dd[preceding-sibling::dt[.='#{term}']]").text.
should == definition
end
@steipete
steipete / UIImage+PSPDFKitAdditions.m
Created August 13, 2011 20:52
Preload UIImage for super-smooth interaction. especially great if you use JPGs, which otherwise produce a noticeable lag on the main thread.
- (UIImage *)pspdf_preloadedImage {
CGImageRef image = self.CGImage;
// make a bitmap context of a suitable size to draw to, forcing decode
size_t width = CGImageGetWidth(image);
size_t height = CGImageGetHeight(image);
CGColorSpaceRef colourSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef imageContext = CGBitmapContextCreate(NULL, width, height, 8, width*4, colourSpace,
kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Little);
@richardlawrence
richardlawrence / gist:1299371
Created October 19, 2011 19:17
Convert a Capybara table to something you can diff with a Cucumber table
# change 'table' to a more specific selector when the page will have more than one table
find('table').all('tr').map { |row| row.all('th, td').map { |cell| cell.text.strip } }