Skip to content

Instantly share code, notes, and snippets.

View ejallday's full-sized avatar

Eric Allen ejallday

  • Forj.ai
  • Minneapolis, MN
View GitHub Profile
@ejallday
ejallday / arraywords.rb
Last active December 14, 2015 23:39
Chirs Pine 8.3 Excercise
## 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...'
@ejallday
ejallday / self implicitly?
Last active December 15, 2015 13:48
I'm new at this, but it's my understanding that with classes: the 'name of the class' (Name), 'self' and simply typing 'new' garner the same result. Name and 'self' are receivers and they invoke #new. In the absence of a receiver and simply typing 'new', the method calls whatever the current object is, which happens to be 'self' and or Name. Why…
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
@ejallday
ejallday / Scamming the system!!
Last active December 15, 2015 15:29
UPDATED: After realizing that very large Fibonacci numbers would not work with my formula, I went about it a bit differently. This time I created a while loop tied to the input being smaller than the last element in my fib array, creating a Fibonacci sequence where fib[-1] should == i if i is in fact fibonacci. This seemed like a more roundabout…
def is_fibonacci?(i)
fib = [0,1]
while i > fib[-1]
fib << (fib[-1] + fib[-2])
end
fib.include?(i)
end
##############################
@ejallday
ejallday / RPN_Steps
Created April 3, 2013 02:24
This is my version of the RPN Calculator after lots of googling. This is the full annotated version with my final at the bottom. I'm going to go through my entire thought process and things I struggled with. I was only able to come up with my final solution after seeing someone else's that was similar... But I learned a new trick in the process:…
# 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
@ejallday
ejallday / How to prep for Dev Bootcamp... According to 2 Dev Bootcamp Graduates.
Last active December 15, 2015 18:58
How to prep for Dev Bootcamp... According to 2 Dev Bootcamp Graduates.
### 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,
@ejallday
ejallday / Building an Mp3 Playlist.
Last active December 15, 2015 18:59
Building an Mp3 Playlist.
# 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'
@ejallday
ejallday / civ.rb
Last active December 17, 2015 03:38
Chris Pine's Civilization problem
# 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],
<% if @roll %>
<img src="/<%= @roll.value %>.png" title="<%= @roll.value %>" alt="the roll">
<% end %>
var header = $('.span4 h1:first-child')
var headerText = header.html();
$('.btn-group').hover(function() {
event.preventDefault;
header.html("Unicorn")
},
function() {
header.html(headerText)
@ejallday
ejallday / index.html
Last active December 19, 2015 07:19 — forked from dbc-challenges/index.html
DBC Phase 2 Practice Assessment Part 3
<!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>