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
var page = require('webpage').create(); | |
page.open('http://edysegura.com', function () { | |
var title = page.evaluate(function () { | |
return document.title; | |
}); | |
page.clipRect = { top: 0, left: 0, width: 600, height: 700 }; | |
page.render(title + ".png"); | |
phantom.exit(); | |
}); |
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
// print process.argv | |
process.argv.forEach(function(val, index, array) { | |
console.log(index + ': ' + val); | |
}); | |
//$ node process.js one two=three four | |
//0: node | |
//1: /Users/mjr/work/node/process-2.js | |
//2: one | |
//3: two=three |
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
//convert a string to number | |
+'2' //2 | |
+'2a' //NaN | |
//convert anything to boolean | |
!!'it will be converted to true' //true | |
!!'' //false |
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
{ | |
"sass.options": { | |
"outputDir": "../styles" | |
}, | |
"linting.enabled": true, | |
"language": { | |
"javascript": { | |
"linting.prefer": "JSHint", | |
"linting.usePreferredOnly": true | |
} |
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
<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> |
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
//given | |
spyOn(YourService, 'yourMethod').and.callFake(function () { | |
var mockDeferred = $q.defer(); | |
mockDeferred.resolve(); | |
return mockDeferred.promise; | |
}); | |
//when | |
serviceOrScope.method(); |
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
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 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
it('should test many calls', function() { | |
// GIVEN | |
spyOn(YourObject, 'yourMethod'); | |
// WHEN | |
Something.happens(); | |
// THEN | |
[ | |
'HTML', |
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
var counter = (function(){ | |
var i = 0; | |
return { | |
get: function(){ | |
return i; | |
}, | |
set: function( val ){ | |
i = val; | |
}, |
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
/* | |
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'); |