This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tree = new TreeModel(); | |
root = tree.parse({ | |
children: [ | |
{ | |
mobileTitle : 'Dashboard', | |
desktopTitle : 'My Sessions' | |
stateName : 'app.dashboard' | |
children: [ | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// how to reduce a list of tags using a filter command | |
['mice','hats','coats','hats'].reduce((curr,prev) => { if(curr.indexOf(prev) < 0){curr.push(prev)};return curr; },[]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1) nu-disco in the last day | |
https://soundcloud.com/search/sounds?q=nu%20disco&filter.created_at=last_day | |
2) auto-like everything | |
var list= document.getElementsByClassName("sc-button-like"); | |
for (var i = 0; i < list.length; i++) { | |
if(!list[i].classList.contains('sc-button-selected')){ | |
list[i].click(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// I think Ben's solution looks good although I probably wouldn't have used promises because | |
// I sometimes think the interface to them is confusing and you are locked into their interpretation not your own, | |
// If I did use them I would try and bury them behind my own interface. There are always going to be million | |
// different ways to do the same thing in angular so I try and model the problem in terms of OO design as opposed to | |
// language specific or angular specific, and of course making something easy to test is always my highest priorities. | |
// Coupling tests to promises is hard and they are difficult to read. So I would use promises in the background not in | |
// the foreground design. | |
// I have identified that we have 3 entities in this solution. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html ng-app="Demo"> | |
<head> | |
<meta charset="utf-8" /> | |
<title> | |
Creating A Simple Modal System In AngularJS | |
</title> | |
<link rel="stylesheet" type="text/css" href="./demo.css"></link> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Person(){ | |
var car = new Car(); | |
} | |
function Car(){ | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//coupled | |
function main(userInputtedString, userInputtedBoolean, userInputtedInt){ | |
var car = new Vehicle(); | |
var bus = new Vehicle(); | |
var plane = new Vehicle(); | |
var vehicles = [car,bus,plane]; | |
forEach(vehicle in vehicles){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//the real world implementation | |
function Alerter(){ | |
this.alert = (msg){ | |
window.alert(msg); | |
}; | |
} | |
var Alerter = new Alerter(); | |
//the Alerter is injected into here |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//original Code | |
function HttpAuthenticator($http){ | |
this.load = (){ | |
return $http.get('/api/login') | |
}; | |
} | |
var Authenticator = new HttpAuthenticator(); | |
//the controller which will attempt to log in when it is loaded |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//this type of coupling happens when you expose the internals object A to object B | |
//in this example we are accessing a method and assigning a property. | |
//this type of coupling happens when one module asks a question of another module | |
//if Person changes how it represents 'hasHobby' it breaks the coupled version in | |
//2 places | |
//by using a 3rd object to hold that information we only break the code in 1 | |
//place if we ever change how the Person represents hwo they have a hobby | |
//coupled | |
function main(){ |