Skip to content

Instantly share code, notes, and snippets.

View jrhorn424's full-sized avatar
🌟
Always be dreaming

Jeffrey Horn jrhorn424

🌟
Always be dreaming
View GitHub Profile
@jrhorn424
jrhorn424 / introrx.md
Created October 11, 2019 14:24 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@jrhorn424
jrhorn424 / Singleton.js
Created October 10, 2019 21:43 — forked from netpoetica/Singleton.js
A Singleton in JavaScript that truly ensures one instance, can be lazy-loaded (you can instantiate it whenever you need it), and has private and public scope.
/* **
*
* Singleton.js - a true Singleton in JavaScript
*
* A Singleton in JavaScript that truly ensures one instance, can be lazy loaded / you
* can instantiate it whenever you need it and has private and public scope.
*
* @author Keith Rosenberg, netPoetica
*
* */
@jrhorn424
jrhorn424 / global-variables-are-bad.js
Created October 10, 2019 21:42 — forked from hallettj/global-variables-are-bad.js
How and why to avoid global variables in JavaScript
// It is important to declare your variables.
(function() {
var foo = 'Hello, world!';
print(foo); //=> Hello, world!
})();
// Because if you don't, the become global variables.
(function() {
@jrhorn424
jrhorn424 / Revealing-Module-Pattern.md
Created October 10, 2019 21:42 — forked from zcaceres/Revealing-Module-Pattern.md
Using the Revealing Module Pattern in Javascript

The Revealing Module Pattern in Javascript

Zach Caceres

Javascript does not have the typical 'private' and 'public' specifiers of more traditional object oriented languages like C# or Java. However, you can achieve the same effect through the clever application of Javascript's function-level scoping. The Revealing Module pattern is a design pattern for Javascript applications that elegantly solves this problem.

The central principle of the Revealing Module pattern is that all functionality and variables should be hidden unless deliberately exposed.

Let's imagine we have a music application where a musicPlayer.js file handles much of our user's experience. We need to access some methods, but shouldn't be able to mess with other methods or variables.

Using Function Scope to Create Public and Private Methods

@jrhorn424
jrhorn424 / post.md
Created October 10, 2019 21:31 — forked from simonexmachina/post.md
JavaScript and Object Models

JavaScript and Object Models

A "choose your own adventure" story

JavaScript is has both object-oriented and functional heritage, thanks to its two parents: Scheme and Self.

It provides first class functions and makes it simple to compose these function objects into bundles of awesome. Even though I'm an OO "true believer" at heart, I find myself composing my code using functional concepts, and use the OO approach where there's a clear benefit or where I feel that it's the best way to communicate the interface.

Object-oriented software design is by no means the only way to do software design, but it's been an immensely successful model for a very long time now, and provides a clear and well-understood mental model for thinking and communicating about software. Lots of good ideas like encapsulation, delegation, traits and composition fit well into OO design.

@jrhorn424
jrhorn424 / javascript_deep_dive.md
Created October 10, 2019 21:11 — forked from romainl/javascript_deep_dive.md
JavaScript Deep Dive to Crack The JavaScript Interviews
@jrhorn424
jrhorn424 / js-objects.md
Created October 10, 2019 21:03 — forked from nifl/js-objects.md
JS Objects

Objects

Object properties can refer to numbers, strings, arrays, functions, and other objects. Properties will also accept variables.

Creating objects

Literal notation - "Object Literal"

Literal objects can have properties and methods added to them on the fly, which we cannot do with a constructor. To add a method to a constructor we must extend its prototype chain.

@jrhorn424
jrhorn424 / GIF-Screencast-OSX.md
Created February 26, 2017 12:32 — forked from dergachev/GIF-Screencast-OSX.md
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@jrhorn424
jrhorn424 / attempting_to_curl.md
Last active November 10, 2015 19:26 — forked from jcmeyer10/gist:ccddcc239676d58094dd
Commands and Error Messages When Trying to POST to my table through CURL

I am trying to run this. I am able to post to the table through Rails C, so I have access from there.

curl --request POST --header "Authorization: Token token="d168c8333a2b72bf7ad7bfe4bb9c669d" --header "Content-Type: application/json" -d '{
  "beer": {
    "name":"UFO"
    "brewery":"Harpoon"
    "style":"Hefe"
    "location_id":"11"
 }
//Verison 0
'use strict';
var counterFactory = function counterFactory() {
return function() {};
};
var firstCounter = counterFactory();
// firstCounter contains a reference to
// a new instance of the minimal function