Skip to content

Instantly share code, notes, and snippets.

View judesamp's full-sized avatar

Jeremy Samples judesamp

View GitHub Profile
@judesamp
judesamp / gist:fd4794b81aca61494543029ba6d41c9b
Created May 5, 2016 14:02 — forked from datwright/gist:1082717
Rails Migrations Cheat sheet
# Migration generator shortcuts.
# rails generate migration MyNewMigration
# rails generate migration add_fieldname_to_tablename fieldname:string
# rails generate model Product name:string description:text
# The set of available column types [:string, :text, :integer, :float, :decimal, :datetime, :timestamp, :time, :date, :binary, :boolean]
# A migration is a subclass of ActiveRecord::Migration. You must implement the "up" and "down" (revert) methods.
# These are the handy methods available to a Migration:
@judesamp
judesamp / a-love_letter_mashup_user_stories
Last active August 29, 2015 14:02
Love Letter Mashup User Stories
a collection of love letter mashup user stories
@judesamp
judesamp / erb_application_layout_stuff.erb
Created May 29, 2014 15:10
login/logout + flash message stuff for application.html.erb
<div class="nav navbar-nav navbar-right">
<% unless user_signed_in? %>
<p class="btn btn-default" id="modal_button">signup</p>
<p class="btn btn-default" id="login_button">login</p>
<% end %>
<% if user_signed_in? %>
<a class="btn btn-default" href="/dashboard">Your Dashboard</a>
<a class="btn btn-default" href="/users">All Users!</a>
<%= link_to('Logout', destroy_user_session_path, :method => :delete, class: "btn btn-default") %>
<span>logged in as <%= current_user.email %></span>
@judesamp
judesamp / horse_racing_with_tests.rb
Created April 9, 2014 12:41
A simplified horse racing game with a few rspec tests
require 'rspec'
class Game
def process_pregame
clear_screen
end
def retrieve_play_again_answer
user_answer = ''
# until user_play_again_answer_valid?(user_answer)
@judesamp
judesamp / game_of_life.rb
Created April 9, 2014 03:01
A simple Ruby version of Conway's game of life (with a few RSpec tests embedded)
class World
attr_reader :cells, :cells_with_neighbors
def initialize
# @cells = Array.new(10, Array.new(10, Cell.new))
@cells = Array.new(10) { Array.new(10) { Cell.new } }
system "clear"
puts "\n\n\n\n"
print_world
puts "\n\n\n\n"
@judesamp
judesamp / horse_racing_game_with_class_extras.rb
Created April 7, 2014 21:12
Horse racing game collaboration with Adam (with a little class inheritance and a class method or two)
class Game
def initialize
@winner = ''
end
def process_pregame
clear_screen
end
def retrieve_play_again_answer
@judesamp
judesamp / horse_racing_collaborate.rb
Last active August 29, 2015 13:58
horse racing game collaboration (without inheritance)
class RaceGame
QUESTIONS = [ {question: "\nWhich South Park character gets killed in almost every episode?", :answer_options => ["1. Cartman", "2. Stan", "3. Trey Parker", "4. Kenny"], answer: 4 },
{question: "\nWhich movie starred Johnny Depp as Willy Wonka?", answer_options: ["1. Charlie and the Chocolate Factor", "2. Pirates", "3. What's Eating Gilbert Grape?", "4. Edward Scissorhands"], answer: 1 },
{question: "\nWho is The Friendly Ghost?,", :answer_options => ["1. Flying Dutchman", "2. Casper", "3. That dude from Scooby Doo", "4. Slimer"], answer: 2 },
{question: "\nWhat was the mailman's name on the TV show 'Seinfeld'?", :answer_options => ["1. Mark", "2. Ted", "3. Newman", "4. Bob"], answer: 3 },
{question: "\nWhat movie starred Mel Gibson as William Wallace?", :answer_options => ["1. The Patriot", "2. Lethal Weapon", "3. Liam Neeson", "4. Braveheart"], answer: 4 },
{question: "\nHow does James Bond like his martini
@judesamp
judesamp / horse_racing.rb
Last active August 29, 2015 13:58
A horse racing game for the terminal
class Game
attr_accessor :user_horse, :opponent_horse_1, :opponent_horse_2
def initialize
@goad_count = 0
@song_count = 0
@whisper_count = 0
@corner_counter = 1
@race_distances = [100, 125, 150]
@printer = PrintTrack.new
@race_strategies = ["fast", "slow", "the middle way"]
@judesamp
judesamp / personality_quiz.rb
Last active August 29, 2015 13:57
A pet personality quiz
@questions = [ {question_id: 1, question: "Which of the following words best describes your personality",
answer_a: {answer_text: "tenacious", scoring: {goldfish: 1, ferret: 5, cat: 3, white_bengal_tiger: 4, dog: 2}},
answer_b: {answer_text: "loyal", scoring: {goldfish: 0, ferret: 3, cat: 2, white_bengal_tiger: 1, dog: 5}},
answer_c: {answer_text: "independent", scoring: {goldfish: 4, ferret: 4, cat: 5, white_bengal_tiger: 5, dog: 2}},
answer_d: {answer_text: "curious", scoring: {goldfish: 1, ferret: 5, cat: 4, white_bengal_tiger: 4, dog: 3}},
answer_e: {answer_text: "loud", scoring: {goldfish: 1, ferret: 2, cat: 3, white_bengal_tiger: 5, dog: 5}}
},
{question_id: 2, question: "Are you more likely to:",
answer_a: {answer_text: "make a list of pros and cons before making a decision", scoring: {goldfish: 4, ferret: 1, cat: 3, white_bengal_tiger: 3, dog: 1}},
@judesamp
judesamp / guessing_game.rb
Last active August 29, 2015 13:57
a simple text guessing game...
@array_of_secret_words = [
[{word: "call", hint_1: 'rhymes with small', hint_2: 'Who you gonna _____?'}, {word: "sham", hint_1: 'rhymes with wham', hint_2: '_____Wow'}, {word: "dogs", hint_1: 'rhymes with cogs', hint_2: 'The _____ are barking!'}, {word: "what", hint_1: 'rhymes with but', hint_2: 'rhymes with mutt'}],
[{word: "faces", hint_1: 'rhymes with laces', hint_2: 'Til we have ___.'}, {word: "blame", hint_1: 'rhymes with shame', hint_2: "Don\'t ______ me."}, {word: "shelf", hint_1: 'rhymes with elf', hint_2: 'book'}, {word: "metro", hint_1: 'goes with opolis', hint_2: 'area'}],
[{word: "actual", hint_1: 'in the real', hint_2: 'Morpheus says blue pill!'}, {word: "orange", hint_1: '____ you glad', hint_2: 'is the new black!'}, {word: "famous", hint_1: 'Almost _____', hint_2: '15 minutes and counting'}]
]
@player_misses = 0
word_length = 0