Skip to content

Instantly share code, notes, and snippets.

@ckib16
ckib16 / gist:845e89017c0151b724b8
Created July 20, 2014 18:34
Git version still shows old 1.8.5.2 after installing git 2.0.1
christophersair:~ Chris$ git --version
git version 1.8.5.2 (Apple Git-48)
christophersair:~ Chris$ which git
/usr/bin/git
christophersair:~ Chris$
@ckib16
ckib16 / gist:b4296a7954604ced6368
Created August 3, 2014 02:44
TicTacToe errors
#Psuedo code
#Draw a playing field
# Get input from the player for an X to go in spaces #1-9
# Store input in a Hash with spaces #1-9 and either X or O???
# Map puts lines to each section of chart?
# Place X in space input by player
# Place O in a space not yet used by player
# Keep past choices displayed and ask user for another input (????)
# Keep going until player or computer has 3 marks in a row (Payer/Computer wins)
# OR board is filled (Tie)
@ckib16
ckib16 / gist:d4bd44c56b9e8d1f8384
Created September 1, 2014 20:41
Problems with .pop method
# blackjack_oop.rb
# Requirements
# - Dealer has a deck of cards. The cards are shuffled and dealt to the Dealer and Player. The player and dealer calculate their hands. If dealer has 21, game is over. If player has 21, player wins. If both have 21, they tie (push). If neither, play continues
# If play continues, player is asked to hit or stay. If player hits, new card is dealt and new caluclation made for <21, ==21 or >21. If <21, player can hit or stay. If ==21, player wins or ties is dealer aslo has 21. If >21 player loses.
# If player stays, dealer takes turn. Dealer must hit if <=16, and wil stay at >=17. If dealer, busts, palyer wins. If dealer stays at >= 17 and does not bust, compare score to player. Player with higher score wins. Game resets.
# Major nouns:
@ckib16
ckib16 / gist:4fcfb18e8a831644a846
Created September 1, 2014 21:50
Still have .pop method undefined?!
# blackjack_oop.rb
# Requirements
# - Dealer has a deck of cards. The cards are shuffled and dealt to the Dealer and Player. The player and dealer calculate their hands. If dealer has 21, game is over. If player has 21, player wins. If both have 21, they tie (push). If neither, play continues
# If play continues, player is asked to hit or stay. If player hits, new card is dealt and new caluclation made for <21, ==21 or >21. If <21, player can hit or stay. If ==21, player wins or ties is dealer aslo has 21. If >21 player loses.
# If player stays, dealer takes turn. Dealer must hit if <=16, and wil stay at >=17. If dealer, busts, palyer wins. If dealer stays at >= 17 and does not bust, compare score to player. Player with higher score wins. Game resets.
# Major nouns:
@ckib16
ckib16 / gist:8be71677026ed8c4a7d5
Created November 3, 2014 00:38
Toaster description
In just a few sentences, the message should describe a toaster (the kitchen appliance) in the terminology of a programming method.
What is/are its expected argument(s)?
- The toaster method should accept any toastable food as arguments (bread, bagle, pop-tarts)
What does it return?
- The Toaster method should return it's arguments that have been toasted, or heated until crispy but not burnt.
What are its side effects?
- Side effects include electricity used, heat produced, and time taken
@ckib16
ckib16 / gist:95a1280b6afa40128cb3
Last active August 29, 2015 14:09
Loop Checkpoint - "Title Case" exercise: Conditional logic not working; elsif condition was never met
# Downcase everything to normalize
#
require 'pry'
class Title
attr_accessor :string
def initialize(string)
@ckib16
ckib16 / topics_controller.rb
Created December 21, 2014 20:23
refactored controller with topics_params method
def create
@topic = Topic.new(topics_params)
authorize @topic
if @topic.save
redirect_to @topic, notice: "Topic was saved successfully."
else
flash[:error] = "Error creating topic. Please try again."
render :new
end
end
@ckib16
ckib16 / gist:11987af8e74cf74cd494
Created December 27, 2014 05:38
Need to delete 'image' string from users db table
create_table "users", force: true do |t|
t.string "name"
t.string "email", default: "", null: false
t.string "encrypted_password", default: "", null: false
t.string "reset_password_token"
t.datetime "reset_password_sent_at"
t.datetime "remember_created_at"
t.integer "sign_in_count", default: 0, null: false
t.datetime "current_sign_in_at"
t.datetime "last_sign_in_at"
# This interceptor just makes sure that local mail
# only emails you.
# http://edgeguides.rubyonrails.org/action_mailer_basics.html#intercepting-emails
class DevelopmentMailInterceptor
def self.delivering_email(message)
message.to = '[email protected]'
message.cc = nil
message.bcc = nil
end
end
@ckib16
ckib16 / Papertrail error log from Heroku and Mailgun (Blocmarks US #3)
Created February 1, 2015 20:40
Papertrail error log from Heroku and Mailgun (Blocmarks US #3)
Feb 01 12:21:35 blocmarks-ckib16 app/web.1: => Booting WEBrick
Feb 01 12:21:35 blocmarks-ckib16 app/web.1: => Rails 4.2.0 application starting in production on http://0.0.0.0:59955
Feb 01 12:21:35 blocmarks-ckib16 app/web.1: => Run `rails server -h` for more startup options
Feb 01 12:21:35 blocmarks-ckib16 app/web.1: => Ctrl-C to shutdown server
Feb 01 12:21:35 blocmarks-ckib16 app/web.1: Started POST "/incoming" for 173.203.37.137 at 2015-02-01 20:21:34 +0000
Feb 01 12:21:35 blocmarks-ckib16 app/web.1: User Load (15.6ms) SELECT "users".* FROM "users" WHERE ([email protected]) LIMIT 1
Feb 01 12:21:35 blocmarks-ckib16 app/web.1: Processing by IncomingController#create as */*
Feb 01 12:21:35 blocmarks-ckib16 app/web.1: PG::UndefinedTable: ERROR: relation "users" does not exist
Feb 01 12:21:35 blocmarks-ckib16 app/web.1: LINE 1: SELECT "users".* FROM "users" WHERE ([email protected]) LIMI...
Feb 01 12:21:35 blocmarks-ckib16 app/web.1: ^