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
let https = require('https'); | |
function httpGetAsync(url,callback) { | |
return https.get(url, | |
function(response) { | |
var body = "; | |
response.on('data', function(d) { | |
body += d; }); | |
response.on('end', function() { | |
let parsed = JSON.parse(body) | |
callback(parsed) |
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
let getDataOne = (cb) => { | |
setTimeout(function(){ | |
//calling the callback | |
cb('dummy data one') | |
}, 1000); | |
} | |
let getDataTwo = (cb) => { | |
setTimeout(function(){ | |
//calling the callback | |
cb('dummy data two') |
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
//get generator instance variable | |
let generatorSequenceResult = | |
generatorSequence(); | |
console.log('done value for the first time', | |
generatorSequenceResult.next()) | |
console.log('done value for the second time', |
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
let getComments = (link) => { | |
let response | |
try { | |
response = JSON.parse(request('GET',"https://www. | |
reddit.com/" + link).getBody('utf8')) | |
} catch(err) { | |
response = { message: "Something went wrong" , | |
errorCode: err['statusCode'] } | |
} | |
return response |
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
function GetContent (){ | |
var elem = document.getElementById ("my div"); | |
var message = ""; | |
if (elem.outerHTML !== undefined) { | |
message +="outerHTML:" + elem.outerHTML |
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
/* | |
* Keymap.js: bind key events to handler functions. | |
* | |
* This module defines a Keymap class. An instance of this class represents a | |
* mapping of key identifiers (defined below) to handler functions. A Keymap | |
* can be installed on an HTML element to handle keydown events. When such an | |
* event occurs, the Keymap uses its mapping to invoke the appropriate handler. | |
* | |
* When you create a Keymap, you can pass a JavaScript object that represents | |
* the initial set of bindings for the Keymap. The property names of this object |
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
'use strict'; | |
var MongoClient = require('mongodb').MongoClient; | |
MongoClient.connect( 'mongodb://127.0.0.1:27017/accounting', function (err, connection) { | |
var collection = connection.collection('customers'); | |
var doFind = function (callback) { collection.find().toArray(function (err, documents) { | |
console.dir(documents); |
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
Imports System | |
Imports System.Windows.Forms | |
Namespace | |
Apress.VisualBasicRecipes.Chapter01 | |
Public Class Recipe01_02 Inherits Form | |
' Private members to hold references to the form's controls. |
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
Imports System | |
Namespace | |
Apress.VisualBasicRecipes.Chapter01 | |
Public Class ConsoleUtils | |
' This method will display a prompt and read a response from the console. | |
Public Shared Function ReadString(ByVal message As String) As String |