Skip to content

Instantly share code, notes, and snippets.

View chadjemmett's full-sized avatar

Chad Jemmett chadjemmett

View GitHub Profile
@chadjemmett
chadjemmett / stackflow experiment
Created October 22, 2011 00:35
a snippet of code. Trying to figure out why It doens't look the way I think it should.
#test of stacks and flows.
require "stack_flow_methods.rb"
Shoes.app do
#this flow shows up OK
flow :width => 300, :height => 100 do
background coral
#why don't these stacks show up in the flow I created.
stack :width => "50%" do background blueviolet
end
stack :width => "-50%" do background crimson
@chadjemmett
chadjemmett / loopy code
Created November 17, 2011 22:58
this code goes into a loop.
def age_method(age)
year = 314712000
puts "you are " + (age*year).to_s + " seconds old"
puts "you are " + (year/3600).to_s + " hours old"
end
puts "What is your age?"
age = gets.chomp
age_method(age)
@chadjemmett
chadjemmett / gist:3013877
Created June 28, 2012 21:02
A Dragon class.
class Dragon
def initialize name
@name = name
@asleep = false
@stuff_in_belly = 10
@stuff_in_guts = 0
puts @name + " is born!"
end
@chadjemmett
chadjemmett / gist:3055436
Created July 5, 2012 18:17
reverse a string without reverse method.
# the variables. a forward string
#the backward empty string.
#the holding array
forwards = "hello this is a string. In a moment it will be reversed without using the 'reverse' method."
backwards = ""
holding_array = []
@chadjemmett
chadjemmett / gist:3106378
Created July 13, 2012 18:08
Confused about how to organize variables.
class Todo
def initialize item
#what we need for a new item on the todo list.
#when the item was created.(optional)
@time_created = Time.now
#the string that is displayed that's identified.
@item = item
#whether it's done or not
@done = false
@chadjemmett
chadjemmett / gist:3201869
Created July 29, 2012 21:15
How to store objects with multiple variables.
class Todo
attr_accessor :item, :done, :time_created
def initialize item_name
#what we need for a new item on the todo list.
#when the item was created.(optional)
@time_created = Time.now
#the string that is displayed that's identified.
@item = item_name
#whether it's done or not
@chadjemmett
chadjemmett / gist:3493524
Created August 27, 2012 23:54
a ruby timer
timer = Proc.new do
|time, deadline|
time = Time.now
deadline = time + 5
while time != deadline
time = Time.now
end
@chadjemmett
chadjemmett / gist:3758321
Created September 20, 2012 20:58
Why isn't the 'combat' method working?
class Fight
def initialize
Player.new
Monster.new
end #end of the initialize method.
class Player
attr_accessor :ac, :attack, :hp
p {color: red;}
html { background: silver;}
.center {
width: 75%;
height: 100%;
float: center;
background-color: white;
margin-top: -20px;
<!DOCTYPE html>
<html>
<head lang="en">
<link text="css/text" rel="stylesheet" href="stylesheet.css"></link>
<meta charset="utf-8">
<title>Custom Plunker</title>
</head>
<div class="center">
<p>Here is a thing too</p>