Skip to content

Instantly share code, notes, and snippets.

View dcorking's full-sized avatar

David Corking dcorking

View GitHub Profile
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
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')
@isaacs
isaacs / node-and-npm-in-30-seconds.sh
Last active November 2, 2024 12:56
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh
// =========================
// Example 1: using a @mixin
// =========================
// SCSS:
@mixin a_pink_box() {
float: left;
display: block;
color: pink;
@jcasimir
jcasimir / render_and_redirect.markdown
Created September 11, 2011 21:29
Render and Redirect in Rails 3

Render and Redirect

The normal controller/view flow is to display a view template corresponding to the current controller action, but sometimes we want to change that. We use render in a controller when we want to respond within the current request, and redirect_to when we want to spawn a new request.

Render

The render method is very overloaded in Rails. Most developers encounter it within the view template, using render :partial => 'form' or render @post.comments, but here we'll focus on usage within the controller.

:action

@wdiechmann
wdiechmann / gist:1892556
Created February 23, 2012 12:03
Rendering a string of Erb/HAML back to a string (render :partial from everything else but filesystem)
# My intention is to be able to do this:
#
# from within some view, render a partial
# with the added flavour that the partial is not a file
# but rather a table model instance - like say a Customer,
# a PurchaseOrder, or in this case - a Template
# the partial rendering "should" adhere to all the standard Rails
# magic, ie nested rendering of partials, builders with Erb/HAML,
# I18n translation support to label the most important.
class PostsController < ActionController::Base
def create
Post.create(post_params)
end
def update
Post.find(params[:id]).update_attributes!(post_params)
end
private
@jrochkind
jrochkind / gist:2161449
Created March 22, 2012 18:40
A Capistrano Rails Guide

A Capistrano Rails Guide

by Jonathan Rochkind, http://bibwild.wordpress.com

why cap?

Capistrano automates pushing out a new version of your application to a deployment location.

I've been writing and deploying Rails apps for a while, but I avoided using Capistrano until recently. I've got a pretty simple one-host deployment, and even though everyone said Capistrano was great, every time I tried to get started I just got snowed under not being able to figure out exactly what I wanted to do, and figured I wasn't having that much trouble doing it "manually".

@soderlind
soderlind / config.ru
Created December 4, 2012 20:54 — forked from paulcook/config.ru
config.ru for Pow + Wordpress - based on http://stuff-things.net/2011/05/16/legacy-development-with-pow/. Added rewrite rule for WordPress Multi Site. More at http://soderlind.no/archives/2012/12/02/wordpress-and-pow/
# config.ru for Pow + Wordpress, based on http://stuff-things.net/2011/05/16/legacy-development-with-pow/
# added hackery to work around wordpress issues - Patrick Anderson ([email protected])
# added rubygems, replaced script_path with script from path_parts, added to_return to fix return error - Paul Cook
# clearly this could be cleaner, but it does work
# added rewrite rule for WordPress Multi Site - Per Soderlind (see also http://soderlind.no/archives/2012/12/02/wordpress-and-pow/)
require 'rubygems'
require 'rack'
require 'rack-legacy'
require 'rack-rewrite'
@mislav
mislav / rbenv-doctor.sh
Created February 7, 2013 03:50
A debugging script to analyze rbenv-specific setups
rbenv --version || rbenv 2>&1 | head -1
rbenv versions
rbenv global
env | grep -E 'PATH|RUBY|BUNDLE|RBENV'
which gem
rbenv which gem
@joshski
joshski / flame.lua
Created April 21, 2013 10:52
Generates a little flame. Works in Codea.
-- a little flame in a functional style
function particle(step, style, t)
local newStyle = step(style, t)
return {
style = newStyle,
next = function()
return particle(step, newStyle, t + 1)
end
}