Skip to content

Instantly share code, notes, and snippets.

View joshcrews's full-sized avatar

Josh Crews joshcrews

View GitHub Profile
@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>
@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: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]
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: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
@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: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 / gist:9667107
Created March 20, 2014 15:58
Full Reftagger / Biblia.com translation options available
[
["English Standard Version", "esv"],
["New Living Translation", "nlt"],
["The New King James Version", "nkjv"],
["The Holman Christian Standard Bible", "hcsb"],
["King James Version", "kjv1900"],
["The Lexham English Bible", "leb"],
["The New International Version", "niv2011"],
["The NET Bible", "gs-netbible"],
["GOD’S WORD Translation", "godsword"],
require 'rubygems'
require 'mechanize'
require 'csv'
charities = []
('A'..'Z').each do |letter|
puts "\nstarting #{letter}"
url = "http://www.ecfa.org/MemberSearch.aspx?FirstLetter=#{letter}"
Josh,
Rand asked me to email you.
Is everything ok?
He announced his candidacy for President of the United States, and I know he is counting on your support for the campaign's "Stand with Rand" Money Bomb.
The entire political world is watching this Money Bomb and it's vital this effort be as successful as possible.