Skip to content

Instantly share code, notes, and snippets.

View amcrawford's full-sized avatar

Amber (Crawford) Hershman amcrawford

  • Software Engineer at Stitch Fix
  • Denver, CO
View GitHub Profile
def schedule_next_action(truancy_status)
completed_truancy_actions = TruancyEvent.where(shipment_id: truancy_status.shipment_id)
TRUANCY_ACTION_SCHEDULE.each do |action, details|
action_occurred = completed_truancy_actions.detect { |event| event.event == action }
# unless action_occurred
# last_action_occurred_at = nil
# if details.last_truancy_action
# last_action_occurred_at = completed_truancy_actions.detect { |event| event.event == details.last_truancy_action }.occurred_at
# end
@amcrawford
amcrawford / recursion.markdown
Last active February 26, 2016 21:44 — forked from rrgayhart/recursion.markdown
Recursion and Generators Homework

Recursion Discussion

  • Do you pronounce 'babel' in the same way? No

    • Follow Up Question: Will you now? Yaaas!
  • What is an example of why/where you might use recursion? You can use it in most cases where you would otherwise nest for/ while loops. In this video, the author uses it to create a search tree from an array of objects with like attributes.

What is one approach you can take from this Mary's code and implement in your project?

  • I really like Mary's use of filter to check for the presence of fellow invaders within a firing path and block the action if the result was greater than 0. I think that we could use a similar approach to track our snake's body and prevent backward movement over itself.
  • I also like how object oriented everything was; right now our game is a long method that is called at page-load but, we should abstract it out into instances of a "Game" module which might also help with some reset issues we are hitting now.

Consider the four responsibilities that Rebecca lists for client side code (hint: they're color coded).

According to this talk, client side code is responsible for: Presentation & Interaction; Data/ Server Communication; Application State and Setup

  • Did any of the responsibilities that she lists surprise you?

    Not necessarily; coming out of Rails, getting used to putting all of those responsibilities like setup, in particular, feels a bit strange but, working with and having seen some of the projects that we will do and that will force us to manage all of these things in our client-side code it makes sense.

@amcrawford
amcrawford / require.markdown
Last active February 14, 2016 03:27 — forked from rrgayhart/require.markdown
The Concept of Require

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?

"Modules are small chunks of your application that serve a specific purpose"... In the context of Node, a module is a set of objects with a given purpose in the program that are stored together and accessible within a one file. These act similarly to a module or class in Ruby in that they serve to group data and functions which are callable from other files through importing and exporting.

  • "Modules are small chunks of your application that serve a specific purpose"... In the context of Node, a module is a set of objects with a given purpose in the program that are stored together and accessible within a one file. These act similarly to a module or class in Ruby in that they serve to group data and functions which are callable from other files through importing and exporting.

  • The code examples in the second article look different than the first because the second article is describing the use of RequireJS to organize code and create module dependencies which uses define() and only calls require() in the main file.

**Step One**: Watch [Sorting Algorithms in JavaScript](https://www.youtube.com/watch?v=uRyqlhjXYQI)
**Step Two**: Fork this gist.
**Step Three**: Respond to this question in your fork: "What are some of the balances and trade offs between different sorting algoritms?"
**Step Four**: _Totally Optional_: take a look at some of the other forks and comment if the spirit moves you.
@amcrawford
amcrawford / es6.markdown
Last active February 6, 2016 17:30 — forked from rrgayhart/es6.markdown
ES6 Homework

What is ES6?

  • ES6 is the newest update to the Javascript and is currently being incorporated into most major JavaScript engines.

What is Transpilation and how does it relate to ES6?

  • Transpilation is the process of converting code to an updated/ similar language. Because ES6 is not fully supported yet, it must be converted on the client-side.

Looking at the ES6 Features link below, discuss one update from ES5 and if it seems useful/superfluous.

  • String interpolation seems pretty exciting! While not necessarily a needed feature, coming form Ruby, it would be really great to have.

JavaScript Functions

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

8/10

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

7/10