- @
- @
This file contains 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
var testModule = (function () { | |
var counter = 0; | |
return { | |
incrementCounter: function () { | |
return counter++; | |
}, | |
This file contains 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
App.Router.map(function() { | |
this.route("news", { | |
path: "/news" | |
}), this.route("entertainment", { | |
path: "/entertainment" | |
}), this.route("fashionBeauty", { | |
path: "/fashion-beauty" | |
}), this.route("lifestyle", { | |
path: "/lifestyle" | |
}), this.route("books", { |
This file contains 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
if (window.location.href.indexOf('://custom.me') === 0) { | |
window.location.replace('http://projectname.io' + window.location.pathname); | |
} |
This file contains 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 Promise() { | |
this.callbackQ = [], | |
this.errorQ = [], | |
this.then = function(callback, error){ | |
this.callbackQ.push(callback); | |
this.errorQ.push(error); | |
}, |
This file contains 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
$(window).scroll($.debounce(50), function() { | |
if ($(window).scrollTop() === $(document).height() - $(window).height()) { | |
var nextId = $('.article:last').data('next'); // gets the id of 'next' article from markup. | |
$.get('/ajax-article/' + nextId, function(content) { // gets the html | |
$($('.article', content)).insertAfter('.article:last'); //insert html after last article |
This file contains 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 debounce(func, wait, immediate) { | |
var timeout; | |
return function() { | |
var context = this, | |
args = arguments; | |
clearTimeout(timeout); | |
timeout = setTimeout(function() { | |
timeout = null; | |
if (!immediate) { | |
func.apply(context, args); |
This file contains 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 ack(m,n) { | |
return (m == 0) ? | |
n + 1 : | |
(m > 0 && n==0) ? | |
ack(m-1,1) : | |
(m > 0 && n > 0) ? | |
ack(m - 1, ack(m,n-1)) : | |
undefined; | |
} |
This file contains 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
package main | |
import ( | |
"fmt" | |
) | |
func main() { | |
fmt.Println("ack(3, 4):", ack(3, 4)) | |
} | |
This file contains 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 findIds(arr, filterFn) { | |
var results = arr.filter(filterFn); | |
results.timestamp = new Date(); | |
return result; | |
} | |
var ids = [0, 1, 2, 8, 4, 4, 5, 6, 7, 8, 9]; | |
var filtered = findIds(ids, function(x) { | |
return (x == 8); |