Skip to content

Instantly share code, notes, and snippets.

**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?"
Speed, resources required to perform, stability, and size of incoming dataset are all things that must be taken into consideration when using sorting algorithms. There's no single perfect solution -- the best algorithm depends on what data you have coming in, but insertion or merge sort offer the best performance + reliabililty. Bubble sort === the worst.
@matt-stj
matt-stj / require.markdown
Last active February 9, 2016 07:14 — 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?
@matt-stj
matt-stj / es6.markdown
Last active February 9, 2016 17:33 — forked from rrgayhart/es6.markdown
ES6 Homework

Throughout the module (and your journey to Google enlightenment while working on IdeaBox2.0) you may notice a few different ways that JavaScript code is being written.

That might have something to do with something called ES6 and ES5

Fork this gist and answer the following questions:

  • What is ES6?
  • It's the newest standard for EMCAscript - an update from ES5, which is ~5 years old.
  • What is Transpilation and how does it relate to ES6?
  • Transpilation is the process of taking one version of a language and making it compatible with other versions of that langues. With ES6, for instance, developers who want to start writing in ES6 before major browsers adopt it, can do so by transpiling their code from ES6 -> ES5. It's my understanding that Babel is used specifically for transpilation tasks like this.
  • Looking at the ES6 Features link below, discuss one update from ES5 and if it seems useful/superfluous,

JavaScript Functions

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

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

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

Array Prototype Methods

I understand that functions in JavaScript can take any number of arguments.
Yes.

I can describe the similarity between blocks in Ruby and anonymous functions in JavaScript.
Yes.

Where are the methods available to all arrays (e.g. forEach, map, etc.) defined?
Array.prototype

Javascript Basics

  • Inside of a method — indeed, inside of any function — there is a special keyword available to us: this. It refers to the object that is the context in which the function was called.

  • You can force the meaning of this to be what you want it to be, using the .call() or .apply() method on the function itself.

  • With a var person and a function called sayIt, we can force the function to act upon the person variable. sayIt.call( person, 'Hello', '!!1!!1' );

  • As it turns out, most values in JavaScript are truthy — in fact, there are only five values in JavaScript that are falsy:

    • undefined (the default value of declared variables that are not assigned a value)
    • null
  • NaN ("not a number")

##Leap My code: here

  • Responder #1 (here) - This responder showed that I could've written a much shorter function by condensing my if statements. By combinig all of my conditionals, I could've significantly reduced the number of lines that I needed to write.
  • Responder #2 (here) - This responder did a hybrid between the code I wrote and what Responder #1 wrote. This version is slightly less verbose than mine, but still not as clean as Responder #1's.
  • Responder #3 (here) - This is my favorite implementation yet ;). if(year === 2015) { return false; } Seems like it got the tests to pass, but won't work for any year other than 2015.
  • Responder #4 (here) - Lots of if state
#Asset Pipeline
###What does it do?
* Concatenation
* Minification
* Precompiling

Setting Group Expectations

Group Member Names: Edgar, Matt R., Matt S.

  1. When are group members available to work together? What hours can each group member work individually? Are there any personal time commitments that need to be discussed? We'll shoot to work after school most days, trying to accomodate little schedule differences as they come. Flexible on weekends.

  2. How will group members communicate? How often will communication happen, and how will open lines of communication be maintained? Started a slack chaneel #Mattgar + texting. Anytime we separate to work on home, we'll plan on checking it at the end of each day to realign/help each other with problems they're having. We'll likely be pairing together most of the time, with the exception of smaller/repetitive tasks. Shoot to set mini-milestones/goals and chip away at those instead of falling behind or getting overwhelmed with the scope of the entire project.

ActiveRecord
1.) What is the difference in using find vs find_by? Find takes 'id' as an argument and returns that record. Find_by can take any argument from the table and return the corresponding record.
2.) Why use where over find_by? Where will return multiple active record associations, while find_by will only return one.
3.) What does pluck do? Pluck returns an array of elements from a particular column.
4.) Describe joins. Joins pulls in information from multiple tables.
5.) Describe includes. Retrives all records that match a given query?
RSpec: