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 arr = []; | |
for (var i = 0; i < 100000; i++) arr[i] = i; | |
var numberOfRuns = 100; | |
function runTest(name, f) { | |
var totalTime = 0; | |
console.time(name); | |
for (var r = 0; r < numberOfRuns; r++) { |
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 stringFunctor(value, fn) { | |
var chars = value.split("") | |
return chars.map(function(char) { | |
return String.fromCharCode(fn(char.charCodeAt(0))) | |
}).join("") | |
} | |
function plus1(value) { | |
return value + 1 | |
} |
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
try { | |
anyFunction1(); | |
anyFunction2(); | |
anyFunction3(); | |
console.log('Success!'); | |
} | |
catch(e) { | |
console.log('Failed! Error: ' + e.message); | |
} |
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
RewriteEngine On | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteRule ^ index.php [QSA,L] |
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
/* | |
In the node.js intro tutorial (http://nodejs.org/), they show a basic tcp | |
server, but for some reason omit a client connecting to it. I added an | |
example at the bottom. | |
Save the following server in example.js: | |
*/ | |
var net = require('net'); |
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 counter = (function(){ | |
var i = 0; | |
return { | |
get: function(){ | |
return i; | |
}, | |
set: function( val ){ | |
i = val; | |
}, |
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
it('should test many calls', function() { | |
// GIVEN | |
spyOn(YourObject, 'yourMethod'); | |
// WHEN | |
Something.happens(); | |
// THEN | |
[ | |
'HTML', |
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 | |
anyString = "[{name=setPriority, action=Priority Toggle, property=priority, placeholder=system.userActivities.priorityToggle, states=[{name=true, briefDetails=Priority Toggle ON, details=Config$_run_closure8_closure29@45fb3b72}, {name=false, briefDetails=Priority Toggle OFF, details=Config$_run_closure8_closure30@70fbdd42}]}, {name=updateMetadata, action=Metadata Update, briefDetails=Metadata Update, placeholder=system.userActivities.metadataUpdate, details=Config$_run_closure8_closure31@277b5201}, {name=exportTitles, action=Download, briefDetails=Export Titles, placeholder=system.userActivities.download}, {name=login, action=Logged In, briefDetails=Logged In, placeholder=system.userActivities.login}, {name=logout, action=Logged Out, briefDetails=Logged Out, placeholder=system.userActivities.logout}, {name=sendEmail, action=Sent Email, briefDetails=Sent Email, placeholder=system.userActivities.sendMail, details=Config$_run_closure8_closure32@1144d3e7}]", | |
regex = /action=([\w\s]+),/g, | |
matched; | |
whil |
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
//given | |
spyOn(YourService, 'yourMethod').and.callFake(function () { | |
var mockDeferred = $q.defer(); | |
mockDeferred.resolve(); | |
return mockDeferred.promise; | |
}); | |
//when | |
serviceOrScope.method(); |
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
<filter> | |
<filter-name>CorsFilter</filter-name> | |
<filter-class>org.apache.catalina.filters.CorsFilter</filter-class> | |
<init-param> | |
<param-name>cors.allowed.origins</param-name> | |
<param-value>*</param-value> | |
</init-param> | |
<init-param> | |
<param-name>cors.allowed.methods</param-name> | |
<param-value>GET,POST,HEAD,OPTIONS,PUT</param-value> |