Skip to content

Instantly share code, notes, and snippets.

🌟
Always be dreaming

Jeffrey Horn jrhorn424

🌟
Always be dreaming
Block or report user

Report or block jrhorn424

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jrhorn424
jrhorn424 / introrx.md
Created Oct 11, 2019 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
View introrx.md
@jrhorn424
jrhorn424 / Singleton.js
Created Oct 10, 2019 — 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.
View Singleton.js
/* **
*
* 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 Oct 10, 2019 — forked from hallettj/global-variables-are-bad.js
How and why to avoid global variables in JavaScript
View global-variables-are-bad.js
// 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 Oct 10, 2019 — forked from zcaceres/Revealing-Module-Pattern.md
Using the Revealing Module Pattern in Javascript
View Revealing-Module-Pattern.md

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 Oct 10, 2019 — forked from simonexmachina/post.md
JavaScript and Object Models
View post.md

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 Oct 10, 2019 — forked from romainl/javascript_deep_dive.md
JavaScript Deep Dive to Crack The JavaScript Interviews
View javascript_deep_dive.md
View js-objects.md

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 Feb 26, 2017 — forked from dergachev/GIF-Screencast-OSX.md
OS X Screencast to animated GIF
View GIF-Screencast-OSX.md

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 Nov 10, 2015 — forked from jcmeyer10/gist:ccddcc239676d58094dd
Commands and Error Messages When Trying to POST to my table through CURL
View attempting_to_curl.md

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"
  }
View counter.js
//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
You can’t perform that action at this time.