Skip to content

Instantly share code, notes, and snippets.

@gary1410
gary1410 / gist:5865129
Created June 26, 2013 06:19
Hi, this is my first gist.
asdfsadfasdfsadfasdfsdfasd
@gary1410
gary1410 / Defining a Method
Created June 30, 2013 02:08
Hey guys, I'm doing this exercise "Exercise: Define a method that returns a formatted address" and for the life of me I can't and figure out what I"m doing wrong Here were the direction. Create a method called make_address that accepts parameters for the street, city , state, and zip and returns a single address string. For example if we call th…
def make_address(street, city, state, zip)
return "You live at #{street} in the beautiful city of #{city}, #{state}. Your zip is #{zip}."
end
@gary1410
gary1410 / gist:5930501
Last active December 19, 2015 09:09
Exercise: Calculate a letter grade
def get_grade(average)
case average
when 90..100
return 'A'
when 80..90
return 'B'
when 70..80
return 'C'
when 60..70
return 'D'
@gary1410
gary1410 / gist:6005238
Created July 16, 2013 02:10
Good guess exercise.
def good_guess?(int)
case int
when int == 42
return "true"
else
return "false"
end
end
@gary1410
gary1410 / gist:6091194
Last active December 20, 2015 07:09
Confused about while statements and line 6. I'm not sure I understand when to use a while state and "while true" means. Also, I'm confused about lines 6 and 7 concurrently. Why do you line 6 and then come back to say "if reply == 'yes.' Can anyone give an explanation here?
def ask(question)
while true
puts question
reply = gets.chomp.downcase
if (reply == 'yes' || reply == 'no')
if reply == 'yes'
answer = true
else
@gary1410
gary1410 / reverse_words
Last active December 20, 2015 09:58
Exercise: Reverse words Write a method reverse_words which takes a sentence as a string and reverse each word in it. I believe the logic is correct?
def reverse_words(str)
array = [ ]
array = str.split.each do |x|
end
str.reverse
end
https://www.dropbox.com/s/oz32yo4yl8lewvo/Screen%20Shot%202013-08-17%20at%202.57.15%20PM.png
<?xml version="1.0" encoding="utf-8" ?>
<!-- SQL XML created by WWW SQL Designer, http://code.google.com/p/wwwsqldesigner/ -->
<!-- Active URL: http://socrates.devbootcamp.com/sql.html -->
<sql>
<datatypes db="mysql">
<group label="Numeric" color="rgb(238,238,170)">
<type label="Integer" length="0" sql="INTEGER" re="INT" quote=""/>
<type label="Decimal" length="1" sql="DECIMAL" re="DEC" quote=""/>
class Cookie
def initialize(name,diameter)
@type = name
@size = diameter
end
def what_type_are_you?
@type
class Vehical
attr_accessor :drive, :brake
def initialize(args)
@color = args[:color]
@wheels = args[:wheels]
@status = :stopped
# @driving = false
end
def drive
@gary1410
gary1410 / app.rb
Created October 12, 2013 22:06
Using routes and sessions without a database
require 'sinatra'
require 'erb'
require_relative 'models/coach'
enable :sessions
get '/' do
p session
@current_user = session[:user]
@fname = @current_user[:fname]