Skip to content

Instantly share code, notes, and snippets.

JavaScript Functions

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

  • function expressions are defined by var name = ... are invoked with name(...) but are not hoisted.
  • function declarations are defined by function name(...){...}, are invoked similarly, and are hoisted.

Rules for this:

    1. this is the global object (window, or global when in terminal)
    1. this is whatever object the function/method is being called from
    1. this is whatever you say this is.
@afg419
afg419 / package-management.markdown
Last active March 24, 2016 16:49 — forked from rrgayhart/package-management.markdown
The Dangers of Using Code You Don't Control

##Discuss Speaking JavaScript, especially following chapters here:

####Which sections were interesting? I literally love the .bind() method, because partial function application is super friggin cool. I also literally love what I understand of prototyping. So imagine I've got two instances of the same class/constructor, and they are each doing something but it depends on what the other has already done... or something like that. Prototypes allow the one instance to update the constructor prototype, say change some boolean to true, and thus immediately communicate that message to the other instance just by checking its prototype. It is cool. I like it.

####Which sections did you totally skim? None. I am a good person.

####Do you think the reading was valuable?
Yes. I felt like I learned a great deal.

I think far and away the most difficult rule to follow here would be the 4 parameters into a method rule. I think is because I've come across a variety of methods which just simply need that many parameters! The Highcharts gem had methods which could take an unlimited number of parameters (as hash options), and I often was feeding 10 - 20! A quick way around this rule is to make a simple class/struct which just has a bunch of attr_readers or methods which respond with the params you need to pass, and then pass instances of this class to the method... but that seems about the same as passing a hash with more than four key value pairs.

Another alternative might be two make a class which takes 3 parameters on initialization... and then your methods on that class could take another 3 to bring the total up to 6!

One way or another though, if you are ever going to do a sort of '

@afg419
afg419 / js_exercism_comps.md
Created March 19, 2016 23:16
Analysis of a JS exercism

##Leap My code: here

  • Responder #1 (here) - This responder is using Number.isInteger rather than modular arithmetic. Otherwise the if then logic is pretty much identical.

  • Responder #2 (here) - This user extracted the checking of divisibility to its own method. I think it's OK done this way, but I think x % 4 === 0 is pretty readable on it's own.

  • Responder #3 (here) - This user did pretty much exactly what I did. I will say, the alternate way of forming the conditional is a bit harder to read this way, especially because it relies on implicit use of associativity, and frankly, I don't know what that is.

  • Responder #4 (here) - This responder extracted the entire condit

What does it mean to concatenate files? Find an image of an example concatenated file. Why would we want to concatenate files?

Puts the files together. Single GET request to get both files.

What does it mean to precompile files? What does this have to do with coffeescript and sass files?

Compiling means convert to machine code. Precompiling is therefore compiling before the app runs. Coffeescript and sass files are not precompiled directly. Coffeescript and sass are higher languages than css and js, they compile first to css and js, then compiled to machine code.

What does it mean to minify files? Find an image of an example minified file. Why would we want to minify files?

Take outs unnecessary characters. Smaller file size when minified, so less to send.

Start up the server for Catch 'em All (rails s) and navigate to http://localhost:3000/assets/application.js. Then open up the code for application.js in your text editor. Why are these not the same?

(Quotes from http://chris.beams.io/posts/git-commit/ if not otherwise specified.)

Style: Messages should be consistent in their form... Similar length, similar spelling (full word or abbreviations), similar capitalization usage, similar punctuation, and similar tense of speech.

Separate subject from body with a blank line
Limit the subject line to 50 characters
Capitalize the subject line
Do not end the subject line with a period
Use the imperative mood in the subject line

@afg419
afg419 / setting_expectations.markdown
Last active December 8, 2015 01:01 — forked from rwarbelow/setting_expectations.markdown
Setting Expectations

Setting Group Expectations

Group Member Names: Skylark, Starlord, Shrieking Huntress

  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? Available to work before school, except wed fri, otherwise evenings are generally good.

  2. How will group members communicate? How often will communication happen, and how will open lines of communication be maintained? Slack(for communication), waffle(status)... Clear and explicit conversation everytime we split to individual tasks about expectations etc.

How does the Agile model compare to the waterfall model?

Agile insists on constant interaction with the client, unlike waterfall which insists on a single meeting. This allows for changing client specifications. This makes the developers more effective on behalf of the client.

The work flow for an agile developer is then focused around making working software -- even if it only satisfies some of the client's specifications -- as often as possible. Thus of specs change, the problems this cause are limited to just one more production cycle.

Why do you think Agile is so popular in software development?

An Agile developer will ask less of the client, and deliver something closer to what the client wants. Developers not offering Agile are simply worse suited to the task of development for a client.

Do you think Agile is applicable in all industries?

No. I think Agile is very specific to industries where a final goal can be segmented neatly into more or less independent parts. Tho

@afg419
afg419 / cfu_crud_in_sinatra.markdown
Created December 1, 2015 20:03 — forked from rwarbelow/cfu_crud_in_sinatra.markdown
CRUD in Sinatra -- Check for Understanding
  1. Define CRUD.
  2. There are seven verb + path combinations that are necessary in a basic Sinatra app in order to provide full CRUD functionality. List each of the seven combinations, and explain what each is for.
  3. Why do we use set method_override: true?
  4. Explain the difference between value and name in this line: <input type='text' name='task[title]' value="<%= @task.title %>"/>.
  5. What are params? Where do they come from?