This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Write a program that asks for as many word as you want (one word per line) | |
## until you press enter on an empty line, and then repeats all the words back in alphabetical | |
## order | |
## Where to being with this one? I got to the words = [] portion but wasn't | |
## sure how to get multiple words, entered separately a.) into the array and b.) on a loop. | |
## After trying a variety of ways, I broke down and did some googling. | |
## I came up with this... Explanations to follow. | |
puts 'Please type one word on each line and hit enter...' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Array | |
def pad!(min_size, value = nil) | |
if self.length < min_size | |
self.fill(value, self.length...min_size) | |
else | |
return self | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def is_fibonacci?(i) | |
fib = [0,1] | |
while i > fib[-1] | |
fib << (fib[-1] + fib[-2]) | |
end | |
fib.include?(i) | |
end | |
############################## |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Before I started this exercise I read the wikipedia on reverse Polish notation. It made | |
# sense to me for the most part, but then I discovered their chart about stacks which is a | |
# total GEM! However, last night I read ericatdbc.tumblr.com 's blog about the importance of | |
# understanding the stack data structure by the end of week one. So I did some additional | |
# research but still didn't fully understand how it worked. At this point, I thought I | |
# should give it a try anyways. | |
# Step 1: After reading the wiki and the blog I knew I needed to get my input string into | |
# an array. Using one of the example strings on Socrates I defined the string as a variable and | |
# using the class String #split method I was able to achieve that. You will also see that |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Advice from Graduate # 1: ### | |
"You're going to want to save this email chain and refer to it during DBC: | |
.... You should get this book (Well Grounded Rubyist) and go through the entire thing, | |
making sure to do the coding exercises along with the book. Once you finish, do it again. | |
Then, if you have time, do it one more time. This is the best book on Ruby, IMHO. If you | |
do just this paragraph before rolling into DBC, you will dominate. | |
If at any point in time you feel like the book isn't doing a good job of explaining things, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The hardest part about this exercise for me was figuring out how to get the filenames | |
# from my music folder into an array that could be fed into this method. I had never used | |
# the Dir[] class before so it was a bit foreign to me to think that I could just give Dir | |
# a file path and a parameter to collect file extensions and they would all just be in an | |
# array. Good to know. | |
def shuffle array | |
array = array.shuffle! | |
filename = 'Erics_playlist.m3u' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# These are just to make the map easier to read | |
# "M" is visually more dense than "o" | |
M = 'land' | |
o = 'water' | |
world = [[o,o,o,o,o,M,o,o,o,o,o], | |
[o,o,o,o,M,M,o,o,o,o,o], | |
[o,o,o,o,o,M,o,o,M,M,o], | |
[o,o,o,M,o,M,o,o,o,M,o], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% if @roll %> | |
<img src="/<%= @roll.value %>.png" title="<%= @roll.value %>" alt="the roll"> | |
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var header = $('.span4 h1:first-child') | |
var headerText = header.html(); | |
$('.btn-group').hover(function() { | |
event.preventDefault; | |
header.html("Unicorn") | |
}, | |
function() { | |
header.html(headerText) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<link rel="stylesheet" href="http://cdn.jsdelivr.net/normalize/2.1.0/normalize.css"> | |
<link rel="stylesheet" href="main.css"> | |
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800"> | |
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Lato:100,900"> | |
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/3.0.2/css/font-awesome.min.css"> | |
</head> |
OlderNewer