Skip to content

Instantly share code, notes, and snippets.

def hills(terrain)
return 0 if terrain.empty?
forward_pool_depths = find_pools(terrain, "forward")
reverse_pool_depths = find_pools(terrain.reverse, "reverse")
return (forward_pool_depths + reverse_pool_depths)
end
def find_pools(terrain, direction)
highest_point = 0
potential_pools = []

Step One: Watch Mary Rose Cook Live Codes Space Invaders from Front-Trends. (The second worst conference name ever?)

Step Two: Fork this gist.

Step Three: Respond to this question in your fork: What is one approach you can take from this Mary's code and implement in your project?

  • Mary's approach really helped me to understand that I can view a project like this in an object-oriented way. At first, this felt very awkward in JavaScript just because it's new, and different from Ruby. Once I started to understand how modules/functions can often be treated much like Ruby classes and methods (with semantic and syntactic differences), it really helped me to better understand how to improve the structure of our GameTime project.

Step Four: Totally Optional: take a look at some of the other forks and comment if the spirit moves you.

@jwperry
jwperry / require.markdown
Last active April 4, 2016 15:50 — forked from rrgayhart/require.markdown
The Concept of Require

When you start working with WebPack for GameTime, you'll notice that you can't just define a variable in one file and find it in another as easily as you can in Rails.

Read Node.js, Require and Exports and Organize Your Code with RequireJS

Fork this gist and answer the following questions:

  • In the context of Node, what is a module?
  • A module is the "fundamental building block of Node" containing encapsuled, private code. Modules must be exported and then required within the files that you want to access them. Modules in this context seem very similar conceptually to separate class files in Ruby.

JavaScript Functions

I can explain the difference between function declarations and function expressions.

  • Function expressions store them in variables. Function declarations start with "function [name]" and are hoisted.

I can explain what the value of this is in a normal function.

  • Should refer to the function in the context it's being run in. This is the window "normally".

I can explain what the value of this is when called from the context of an object.

  • It should refer to the object based on the context it was called from.