Skip to content

Instantly share code, notes, and snippets.

@tcannonfodder
tcannonfodder / gist:9939717
Last active August 29, 2015 13:58
Basic Controller
def new
@model = Model.new
@Title = "New Model"
end
def create
@model = Model.new(params[:model])
if @model.save
redirect_to model_path(@model), :flash => {:success => "Model Created"}
products GET /products(.:format) products#index
POST /products(.:format) products#create
new_product GET /products/new(.:format) products#new
edit_product GET /products/:id/edit(.:format) products#edit
product GET /products/:id(.:format) products#show
PUT /products/:id(.:format) products#update
DELETE /products/:id(.:format) products#destroy
@tcannonfodder
tcannonfodder / 1up_download.rb
Last active December 14, 2015 03:09
Download all the 1up shows, based on this pastebin: http://pastebin.com/Da1QMJUa . Heck, you could give it any text file of URLs and it would download them. Just did this for fun.
# require 'typhoeus'
episode_URLs = Array.new
URL_regex = /(?<url>http.*)\/(?<filename>.*)$/
URL_list = File.open("1upshow_urls.txt") # Read in the 1up show file
URL_list.each{
|line|
found_URL = URL_regex.match(line)
@tcannonfodder
tcannonfodder / spec_sheet_calculator.rb
Created February 21, 2013 14:59
Meant to be used with Markdown or other plaintext files. Looks for your estimated hours for a project, written in the syntax: [X hours]. Examples: [1 hour] , [10 hours], [10.5 hours], [.5 hours], [0.5 hours] Note that it doesn't work for estimations on the same line. I write my spec sheets where 1 bullet point has 1 estimation.
# Looks at the text file provided and uses my format of spec sheet hours to calculate the total hours of the project.
raise "Must provide Source File!" if ARGV.size < 1
total_hours = 0
spec_sheet = File.open(ARGV[0])
spec_sheet.each{ |line|
specced_hours = /\[[^0-9.]*(?<hours>\d*\.\d+|[^\.]\d*).*\]/.match(line)
@tcannonfodder
tcannonfodder / testem.json
Last active December 10, 2015 18:08
This is a bare-minimum testem configuration file that will allow you to use testem with a rails project. You save it in the root directory of the project (at the same level as the Gemfile), and then you can navigate to the project and run testem. How it works: What this configuration does is precompile the assets before the tests are run using t…
{
"framework": "jasmine",
"src_files": [
"app/assets/javascripts/*.js",
"spec/scripts/*.js"
],
"serve_files": [
"public/assets/*.js",
"spec/scripts/*.js"
],