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
//synchronous behaviour testing | |
var async = require('async'); | |
var request = require('request'); | |
function async_function(){ | |
} | |
function sync_function(){ | |
var result = "5"; |
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 processObjWithRef(obj, result){ | |
if(obj==null || typeof obj != 'object'){ | |
//nothing really to do here - you're going to lose the reference to result if you try an assignment | |
} | |
if(obj instanceof Array) { | |
for(var i=0; i<obj.length; i++){ | |
result.push(); | |
processObjWithRef(obj[i], result[i]); | |
} | |
} |
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 http = require('http'); | |
var request = require('request'); | |
var samplePayload = { | |
"key1":{ | |
"key1.1": { | |
"key1.1.1": ["val1.1.1.1", "val1.1.1.2", "val1.1.1.3", "val1.1.1.4"] | |
}, | |
"key1.2": ["val1.2.1" ,"val1.2.2"] | |
}, |
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 currentDoc = jsdom.jsdom('<html><head><title>href test</title></head><body><p><a href="test.html">Test</a></p></body></html>';, null, {}); | |
var window = currentDoc.createWindow(); | |
jsdom.jQueryify(window, 'jquery-1.4.2.min.js' , function() { | |
console.log(window.$('a')[0]['href']); | |
}); | |
/* | |
returns /Users/[path to the script]/test.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
//clothe a hub file that has 'naked' expressions | |
//e.g. turn {key:$('body p')} into {key:"$('body p')"} | |
function clothe(contents){ | |
closers = /[\}\]\)\/"']/ | |
openers = /[\{\[\(\/"']/ | |
closing = { | |
"{": "}", | |
"[": "]", | |
"(": ")", |
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 codeAddress(){ | |
var geocoder,latLng; | |
geocoder = new google.maps.Geocoder(); | |
var address = document.getElementById('address').value; | |
geocoder.geocode( { 'address': address}, function(results, status) { | |
if (status == google.maps.GeocoderStatus.OK) { | |
latLng=results[0].geometry.location; | |
document.getElementById("address").value = latLng; | |
} else { | |
alert('Geocode was not successful for the following reason: ' + status); |
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 jsdom = require('jsdom'); | |
var body1="<html><head>"+ | |
"<script type='text/javascript' src='https://maps.googleapis.com/maps/api/js?key=***key***&sensor=false'></script>"+ | |
"<script type='text/javascript' src='https://raw.github.com/gist/2878326/f2d5d46b07a9f425870fa025c2cfbeb379c41a67/gistfile1.js'></script></head>"+ | |
"<script>functions testMe(){ var a = 1;}</script>" | |
"<body>" | |
"<div><form id='addressform'>"+ | |
"<input id='address' class='address' type='textbox' value='1 Market St, San Francisco'>"+ | |
"<input id='test' class='test' type='textbox' value='not tested'></form></div></body>"+ |
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
/usr/local/bin/node src/testScripts/PeopleSearchTests/scratchpad/umbrella_test.js | |
Starting batch 0 | |
It's been 123 since you start this script | |
360 so far, got response from 1, and still waiting: 359 max ever: 360 | |
360 so far, got response from 2, and still waiting: 358 max ever: 360 | |
360 so far, got response from 3, and still waiting: 357 max ever: 360 | |
360 so far, got response from 4, and still waiting: 356 max ever: 360 | |
360 so far, got response from 5, and still waiting: 355 max ever: 360 | |
360 so far, got response from 6, and still waiting: 354 max ever: 360 | |
360 so far, got response from 7, and still waiting: 353 max ever: 360 |
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
/usr/local/bin/node src/testScripts/PeopleSearchTests/scratchpad/umbrella_test.js | |
Starting batch 0 | |
1000 so far, got response from 1, and still waiting: 999 max ever: 1000 | |
1000 so far, got response from 2, and still waiting: 998 max ever: 1000 | |
1000 so far, got response from 3, and still waiting: 997 max ever: 1000 | |
1000 so far, got response from 4, and still waiting: 996 max ever: 1000 | |
1000 so far, got response from 5, and still waiting: 995 max ever: 1000 | |
1000 so far, got response from 6, and still waiting: 994 max ever: 1000 | |
1000 so far, got response from 7, and still waiting: 993 max ever: 1000 | |
1000 so far, got response from 8, and still waiting: 992 max ever: 1000 |
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
/usr/local/bin/node src/testScripts/PeopleSearchTests/scratchpad/umbrella_test.js | |
Starting batch 0 | |
1000 so far, got response from 1, and still waiting: 999 max ever: 1000 | |
1000 so far, got response from 2, and still waiting: 998 max ever: 1000 | |
1000 so far, got response from 3, and still waiting: 997 max ever: 1000 | |
1000 so far, got response from 4, and still waiting: 996 max ever: 1000 | |
1000 so far, got response from 5, and still waiting: 995 max ever: 1000 | |
1000 so far, got response from 6, and still waiting: 994 max ever: 1000 | |
1000 so far, got response from 7, and still waiting: 993 max ever: 1000 | |
1000 so far, got response from 8, and still waiting: 992 max ever: 1000 |
OlderNewer