Skip to content

Instantly share code, notes, and snippets.

View deanmarano's full-sized avatar
🦏

Dean Marano deanmarano

🦏
View GitHub Profile
@deanmarano
deanmarano / gist:a597eec343facb565bc4
Created December 17, 2015 22:20
Private Method Testing
https://lostechies.com/chadmyers/2008/11/21/do-not-test-private-methods/
http://peterprovost.org/blog/2012/05/31/my-take-on-unit-testing-private-methods/
https://dzone.com/articles/why-shouldnt-i-test-private
http://programmers.stackexchange.com/questions/135047/new-to-tdd-should-i-avoid-private-methods-now
@deanmarano
deanmarano / readme.md
Created October 2, 2015 01:25
Scopes vs. Closures

Scopes vs. Closures

Scopes and closures are often confused since they are so closely related. In your day to day life, it's somewhat rare that you'll need to know the difference. However, if you enjoy using the debugger, this may have bit you without you even knowing it.

Scope

https://developer.mozilla.org/en-US/docs/Glossary/Scope In Javascript, creating a new function creates a new scope. These are the variables that are defined in the current frame of the stack.

@deanmarano
deanmarano / readme.md
Created October 2, 2015 01:25
Scopes vs. Closures

Scopes vs. Closures

Scopes and closures are often confused since they are so closely related. In your day to day life, it's somewhat rare that you'll need to know the difference. However, if you enjoy using the debugger, this may have bit you without you even knowing it.

Scope

https://developer.mozilla.org/en-US/docs/Glossary/Scope In Javascript, creating a new function creates a new scope. These are the variables that are defined in the current frame of the stack.

@deanmarano
deanmarano / after.js
Created February 12, 2015 22:09
After Ember setter
locations: function(key, value, oldValue) {
if(value) {
this.removeOldMarkers(oldValue);
this.addMarkers(value);
}
return value;
}.property(),
removeOldMarkers: function(markers) {
markers.forEach(function(marker) {
@deanmarano
deanmarano / before.js
Last active August 29, 2015 14:15
Before Ember setter
handleLocationChange: function() {
this.removeOldMarkers(this.get(‘currentLocations’));
this.set(‘currentLocations’, this.get(‘locations’);
this.addMarkers(this.get(‘locations’));
}.observes(‘locations’),
removeOldMarkers: function(markers) {
markers.forEach(function(marker) {
// remove markers from Google map
});
@deanmarano
deanmarano / gist:8dffa1f19469693faf0a
Created October 12, 2014 03:15
Additional weights.
[
{
"w0": -0.7201748196966946,
"w1": 0.5520502417348325,
"w2": -0.6326597002334893
},
{
"w0": -0.3573158294893801,
"w1": 0.8063981863670051,
"w2": -0.53787044249475
@deanmarano
deanmarano / answer.js
Last active August 29, 2015 14:07
Machine Learning 4.2
"// noprotect";
var a = function() {
'use strict';
var examples = [
{inputs: {a: -1, b: -1}, output: -1},
{inputs: {a: -1, b: 1}, output: -1},
{inputs: {a: 1, b: -1}, output: 1},
{inputs: {a: 1, b: 1}, output: -1},
];
@deanmarano
deanmarano / select2component.js
Last active August 29, 2015 14:06
Globals Version of Select2Component
var get = Ember.get;
var run = Ember.run;
/**
* Ember select-2 component wrapping the jQuery select2 plugin while
* respecting Ember data bindings and getter/setter methods on the content.
*
* Terminology:
* - Value: The currently selected value(s). Propagated to controllers etc.
* through the "value=..."" binding. Types:
@deanmarano
deanmarano / file-input.js
Created September 8, 2014 20:50
File Input Ember Component
import Ember from 'ember';
export default Ember.Component.extend({
tagName: 'input',
attributeBindings: ['type', 'accept', 'multiple'],
type: 'file',
multiple: false,
initialize: function() {
this.$().on('change', function(e) {
this.sendAction('on-change', e.currentTarget.files);
@deanmarano
deanmarano / gist:58d65bbef6c1cc475dc6
Last active August 29, 2015 14:04
Authorized Routes
AuthRoute = Ember.Route.extend
authorize: (->
@transitionTo 'login' unless @modelFor('application')
).on('willTransition')
## Which is the same as....
AuthRoute = Ember.Route.extend
willTransition: ->