Skip to content

Instantly share code, notes, and snippets.

View SteveOscar's full-sized avatar

Steven Olson SteveOscar

View GitHub Profile
@SteveOscar
SteveOscar / js_exercisms.md
Created March 15, 2016 20:51
JavaScript Exercisms

Leap

My Code

Other Solutions

  1. Solution 1 - This solution is similar to mine in how the person used the logic without an if/else statement, but the groupings of the && and || statements is different. But it produces the same results.
  2. Solution 2 - This person used a baseline false return, which seems unnecessary as long as the code covers and required possibilities. This person also used if/else statements, which is not needed.
  3. Solution 3 - This person did not complete the exercise, as they have only checked for divisibility by 4, and have not create an isLeap function.
  4. Solution 4 - This person used the same basic logic that I used, also choosing to not use an i
@SteveOscar
SteveOscar / sandi.md
Created March 16, 2016 14:55
Sandi Metz' 5 rules

#####Only instantiate one object in the controller.

This rule was the most interesting to me, and the one I initially mentally rejected, as it seems like it would often be impractical. But after looking further at how the implemented it, by creating a dashboard PORO with different methods to access multiple types of information, it is an interesting setup.

#####Each method should only have 5 lines.
About the 5-line methods rule - ff course in general it's good to keep methods as short and simple as possible, but I think that trying to squeeze every method into this rule will result in a lot of unreadable code using dense ternary statements, etc.

@SteveOscar
SteveOscar / speaking_js.md
Created March 18, 2016 20:37
Speaking Javascript

####Which sections were interesting?
I was interested by the idea of using IIFE's to avoid creating variables in the global scope, as variable scope was something I struggled with on my personal project. I was also interested by the idea of binding an extracted method to its original object.

####Which sections did you totally skim?
Chapter 17 was a burnout. I started reading it, but it's just too dense and long to retain much information. I think it might be valuable to go back to and refer to later once we have a better JS foundation, but right now, it's a bit overwhelming.

####Do you think the reading was valuable?
Yes, except for the last chapter. But I also think that reading without exercising the new concepts is fairly useless, so it's kind of on us to make the most of the reading by trying out examples in the console.

####Which topics were notably confusing?

@SteveOscar
SteveOscar / package-management.markdown
Last active March 24, 2016 17:57 — forked from rrgayhart/package-management.markdown
Code You Don't Control (WITH A GEM, UGHHHH!) - SteveO Responses

Checks for Understanding

Fork this Gist and Respond to the Following Questions

  • In broad strokes, summarize the event
    • A developer had released serveral packages on NPM that many programs used as a dependency, including major stuff like Babel. One of these packages was basically a simply formatting function called Kik. A large messaging comapny has that same name, and wanted to release a package called 'Kik'. They contacted the developer and offered compensation if he changed the name, lawyers at his door if he didn't. He refused, and pulled all of his packages from NPM, breaking many dependent programs in the process. NPM decided for the first time to un-unpublish a module.
@SteveOscar
SteveOscar / blog_topic.md
Created March 28, 2016 17:16
SteveO's blog topic

Creating Animations on HTML canvas

Background

  • Mod 4 is starting gametime, so this week I'm learning about this topic, and figure that writing a blog on it will help me/others in the processs.

Setting Up the canvas

  • How to setup HTML/JS/CSS
  • Create a blank canvas

JavaScript Functions

I can explain the difference between function declarations and function expressions.
-Yes. Declarations are hoisted and available right away, while expression values are undefined until they are declared.

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

  • The global ojbect.

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

  • The object in which it was called.
@SteveOscar
SteveOscar / HTML_canvas.md
Created April 1, 2016 18:19
Creating Basic HTML Canvas Animations

Creating Basic Animations With HTML Canvas

Using the HTML <canvas> element, it's possible to create custom animations and interactive games that run in the browser. It's a powerful tool, but also is literally a blank canvas that requires each frame of animation to be rendered by the code. Each frame is drawn, then the canvas is cleared, and the next frame is drawn, much like in traditional hand-drawn animation. This post will discuss how to create a very basic animation.

Canvas Setup

For this example we'll throw all of our code into one file. Create a new HTML document. In the <style> tags some CSS for basic styling of the canvas border (while we don't modify the contents of the canvas itself with CSS, we can style the display of the canvas element):

canvas {
    border: 3px #CCC solid;
}
@SteveOscar
SteveOscar / sOlson_Require.md
Created April 3, 2016 22:02
The Concept of Require

#####In the context of Node, what is a module?

  • Modules are groupings of code that serve similar purposes.
  • They are more or less the JS version of a Ruby class, a way to break up and group up sections of code.

#####The code examples from the second blog post look very different from the first. Why?

  • While the first blog post described how to use module.exports, which is the technique we've already been exposed to, the second article was talking about using RequireJS, a JavaScript file and module loader. RequireJS can be used to create modular chunks of code using a define function. Mutliple dependencies can be declared in another file through a define call.
@SteveOscar
SteveOscar / testable-js.markdown
Last active April 3, 2016 22:15 — forked from rrgayhart/testable-js.markdown
Writing Testable JavaScript

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

Did any of the responsibilities that she lists surprise you?

None of them really surprised me, as they all seem necessary for client-side code, but I found it helpful to have these ideas explicitly stated.

Do you feel like you mentally split your client side code in IdeaBox and other past projects into these responsibilities?

I definitely didn't consciously break apart responsibilities in my mind, but I think it will help in the future to keep a clearer mental picture of what's happening in my programs. It seems like in JavaScript it's a lot easier to get lost in your own code.

@SteveOscar
SteveOscar / gametime_3_steve_brenna.md
Created April 5, 2016 19:21
GameTime 3rd check in Steve and Brenna

Game Time Check In # 3

Instructor Goal Completion

GOALS

gif

  • We needed to complete basic gameplay mechanics, allowing the ball to go under building walls, end the game if the ball hits a building wall, allow walls to detect other walls, and be able to increase the velocity of the ball.
  • We didn't test and refactor as much yet, as the gameplay mechanics were more difficult than we assumed, but they are done now.
  • Refactoring some large functions.