Skip to content

Instantly share code, notes, and snippets.

View joshcrews's full-sized avatar

Josh Crews joshcrews

View GitHub Profile
@joshcrews
joshcrews / gist:5010140
Created February 22, 2013 01:48
Rails commands used at Feb 2013 Nashville Ruby on Rails beginner meetup
rails new flickr
rails server
rails generate scaffold Photo name:string
rake db:migrate
rails generate controller welcome index
@joshcrews
joshcrews / nss_talk_notes.md
Last active October 13, 2015 06:57
Josh Crews, Nashville Software School talks, November 27, 2012

The mythical man month

Project estimate: 2 developers * 12 months = 24 man-months != 4 devlopers * 6 months

@joshcrews
joshcrews / gist:3939763
Created October 23, 2012 16:12
Example Cucumber feature
Feature: Admin can hide events
In order to get bad stuff off the site without deleting it from the database
As a admin
I want to hide events
Scenario: normal
Given a user "tim@gmail.com" exists
Given he has an event named "Monster Truck Rally"
When I go to the events page
def find_shoes(temp, precipitation)
shoe_combos = [
{:temp => 90, :precipitation => false, :shoes => 'Sandals'},
{:temp => 90, :precipitation => true, :shoes => 'Flip-Flops'}
]
right_answers = shoe_combos.select do |combo|
combo[:temp] == temp && combo[:precipitation] = precipitation)
end
@joshcrews
joshcrews / gist:3901213
Created October 16, 2012 18:54
shoe_combos
shoe_combos = [
{:temp => 90, :precipitation => false, :shoes => 'Sandals'},
{:temp => 90, :precipitation => true, :shoes => 'Flip-Flops'}
]
def find_shoes(temp, precipation)
shoe_combos.each do |combo|
if (combo[:temp] == temp && combo[:precipitation] = precipitation)
return combo[:shoes]
@joshcrews
joshcrews / canonical_host.rb
Created July 12, 2012 02:32
Canonical Host middleware
class CanonicalHost
def initialize(app, host=nil, &block)
@app = app
@host = (block_given? && block.call) || host
end
def call(env)
if url = url(env)
[301, { 'Location' => url }, ['Redirecting...']]
else
@joshcrews
joshcrews / gist:1259380
Created October 3, 2011 15:31
app/views/admin/_text_with_ckeditor.html.erb
<% content_for :javascripts do %>
<%= javascript_include_tag "/javascripts/ckeditor/ckeditor.js" %>
<%= stylesheet_link_tag "/javascripts/ckeditor/contents.css" %>
<% end %>
<li id="<%= attribute_id %>">
<%= form.label attribute, label_text %>
<%= form.cktext_area attribute, :toolbar => 'Easy', :width => 800, :height => 400 %>
</li>