Skip to content

Instantly share code, notes, and snippets.

View jwgoedert's full-sized avatar

James Wesley Goedert jwgoedert

View GitHub Profile
@jwgoedert
jwgoedert / .block
Created May 17, 2017 03:03 — forked from arpitnarechania/.block
Condegram Spiral Plot
license: MIT
@jwgoedert
jwgoedert / instantiationPatternsPseudoclassical.js
Created March 20, 2017 13:16
Pseudoclassical Style Instantiation Pattern
//Pseudoclassical Instantiation Pattern
//only properties are needed inside function body
var Box = function(){
this.width = w;
this.depth = d;
this.height = h;
this.state = 'open';
//'generator' automatically returns this.
}
//attach methods to prototype
@jwgoedert
jwgoedert / instantiationPatternsPrototypal.js
Created March 20, 2017 12:29
Prototypal Insantiation
//Prototypal Instantiation Pattern Version one-using 'prototype'
var Box = function(w, d, h){
//uses Object.create to create attach to the object's prototype
let boxObj = Object.create(Box.prototype);
//**one could also link a seperate object containing methods like such
//let boxObj = Object.create(Box.containerMethods);
//create all properties associated with object
boxObj.width = w;
boxObj.depth = d;
boxObj.height = h;
@jwgoedert
jwgoedert / instantiationPatternsFunctionalShared.js
Created March 20, 2017 12:15
Functional Shared Instantiation Pattern
//Functional Shared Instantiation, create methods outside function body and link them inside
var Box = function(w, d, h){
let boxObj = {};
//properties are assigned within function body
boxObj.width = w;
boxObj.depth = d;
boxObj.height = h;
boxObj.state = 'open';
//Box methods are 'borrowed' from boxMethods
@jwgoedert
jwgoedert / instantiationPatternsFunctional.js
Last active March 20, 2017 12:15
Functional Instantiation Pattern
//Functional instantiation method, clear and easy to follow but calls new functions each time it is invoked
var Box = function(w, d, h){
let boxObj = {};
boxObj.width = w;
boxObj.depth = d;
boxObj.height = h;
boxObj.open = 'open'
//methods associated with new Object and created(defined) inside the function body
//they refer directly to the properties created above.
boxObj.openBox = function(){
@jwgoedert
jwgoedert / instatiationPattensGeneral.js
Created March 20, 2017 11:40
Instantiation Patterns
/*
Instantiation Patterns are a manner in which to organize methods and properties associated with an object and create
repeatable versions of this object, or object class. There are four methods to instatiate a constructor object:
Functional, Functional Shared, Prototypal and Pseudoclassical.
*/
@jwgoedert
jwgoedert / index.js
Created February 8, 2017 22:41
old version of billypedia
/* global $ _ opspark */
$(document).ready(function() {
$.getJSON('data.json', function (data) {
// YOUR CODE BELOW HERE //
// uncomment this to inspect all available data; delete when done //
// console.log(data);
// EXAMPLE: Looping over top rated recordings; replace with your code //
// let topRated = data.discography.topRated;
@jwgoedert
jwgoedert / jsbin.dipume.js
Last active January 30, 2017 21:16 — forked from anonymous/index.html
Last!
var myArr = [1,2,3,4,5,6,7,8,6,7,8,6];
//last with all the safeties using a for loop
last = function last(arr, number){
var newArr = [];
if(!Array.isArray(arr)){
return [];
}else if(isNaN(number) || number === undefined ){
return arr[arr.length - 1];
}else if(number < 0){
return newArr;
@jwgoedert
jwgoedert / jsbin.waporu.js
Created January 30, 2017 21:03 — forked from anonymous/index.html
Extend!
//takes any number of objects and creates one unified object.
_.extend1 = (...objects) =>{
const target = objects[0];
_.each(objects, (obj, i, objects) =>{
if(i === 0)return;
_.each(obj,( val, key, obj)=>{
target[key] = val;
});
});
@jwgoedert
jwgoedert / jsbin.meqobig.js
Created January 30, 2017 21:02 — forked from anonymous/index.html
Reduce!
/*literally does everything... takes a collection, a call-back
function and a starting state(this could be a number, )
*/
_.reduce = function(collection, fn, seed){
var prevResult = seed;
if(seed === undefined) seed = collection[0], prevResult = 1;
_.each(collection, function(el, i, collection){
prevResult = fn(prevResult, el, i);
});
return prevResult;