I am trying to make one Service (SecondService) a dependency of another (FirstService), where the result from one is going to joined with portions of another.
Disclaimer: I have about 8-10 hours of total AngularJS experience.
(function (doc) { | |
doc.body.style.fontSize = '115%'; | |
doc.body.style.margin = '0 auto'; | |
doc.body.style.maxWidth = '37em'; | |
var count, | |
rPage = /\[\s*?page\s*?(\d+?)\s*?\]/i, | |
TOP = 'top-of-document'; | |
function turn(delta) { |
{- | |
If we list all the natural numbers below 10 that are multiples of | |
3 or 5,we get 3, 5, 6 and 9. The sum of these multiples is 23. | |
Find the sum of all the multiples of 3 or 5 below 1000. | |
-} | |
main = | |
print (sum [x | x <- [1..999], mod x 5 == 0 || mod x 3 == 0]) |
--[[ | |
If we list all the natural numbers below 10 that are multiples of | |
3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. | |
Find the sum of all the multiples of 3 or 5 below 1000. | |
]] | |
local counter = 0 | |
local limit = 1000 | |
local sum = 0 |
/* | |
If we list all the natural numbers below 10 that are multiples of | |
3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. | |
Find the sum of all the multiples of 3 or 5 below 1000. | |
*/ | |
var result; | |
result = Array.apply(0, new Array(1000)) |
// Async Before App Init | |
angular.module('app', [/*...*/]) | |
.config(function () { | |
// register all routes and stuff | |
}) | |
.run(function ($rootScope) { | |
$rootScope.$on('$stateChangeStart', function (AsyncValue) { | |
if (!AsyncValue.pageAvailable) { | |
// send back to home | |
} |
angular.module('app') | |
.directive('dynamicFields', function () { | |
return { | |
link: function ($scope) { | |
// this hack brought to you by kalisjoshua; plenty of searching | |
// and one big guess that this might work, only time will tell | |
$scope.validation[$scope.name] = $scope.validation['{{name}}']; | |
}, | |
scope: { | |
name: '@', |
Evolving the shopping cart into a Command Pattern in JavaScript.
Writing a slide-deck presentation framework in the browser.
I have been wanting to gain some more Computer Science knowledge so I started reading more about Design Patterns. I have known about them for a long time and generally speaking my primary understanding ended at the Singleton pattern. I knew that there were other patterns defined but had no use for them since I didn't know them or how to use them.
Recently I have been building libraries of code more and have found that I like the Command Pattern a lot. Especially in JavaScript where some other language features are missing - or available depending on your point of view - which create problems for securing functionality from tampering.
You are a developer wanting to create a new library for a particular purpose. You know that you are not going to necessarily think of everything, needed for other developers to use up front, so you want to also provide a way for them to add in features as they need to. You want to do this but don't want to allow them to harm the functionalit
(function piratize () { | |
$('h1, h2, h3, h4, h5, h6') | |
.each(function (_, el) { | |
el.innerHTML = el.innerHTML | |
.split(' ') | |
.reduceRight(function (acc, word) { | |
if (!acc[1] && /r/.test(word)) { | |
word = word.replace(/(.*)(r+)/i, '$1$2rrrr');; | |
acc[1] = true; | |
} |