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
const pubsub = require('@google-cloud/pubsub'); | |
var client = new pubsub.v1.SubscriberClient({ | |
// optional auth parameters. | |
}); | |
var formattedSubscription = client.subscriptionPath('[PROJECT]', '[SUBSCRIPTION]'); | |
var ackIds = []; | |
var ackDeadlineSeconds = 0; | |
var request = { |
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
const pubsub = require('@google-cloud/pubsub') | |
const client = new pubsub.v1.SubscriberClient({ | |
// optional auth parameters. | |
}); | |
const formattedSubscription = client.subscriptionPath('[PROJECT]', '[SUBSCRIPTION]') | |
const maxMessages = 10 | |
const requestPull = { | |
subscription: formattedSubscription, |
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 the Google Cloud client library | |
const PubSub = require(`@google-cloud/pubsub`); | |
// Creates a client | |
const pubsub = new PubSub(); | |
const subscriptionName = 'your-subscription'; | |
const timeout = 60; | |
// References an existing subscription |
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 chai = require('chai'); | |
var expect = chai.expect; | |
describe('Test House Robber', function() { | |
it('Test nums = []', function() { | |
var nums = []; | |
var result = rob(nums); | |
expect(result).to.equal(0); | |
}); |
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
/** | |
* @param {number[]} nums | |
* @return {number} | |
*/ | |
var rob = function(nums) { | |
if (nums.length === 0) return 0; | |
var a = 0; | |
var b = 0; |
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 chai = require('chai'); | |
var expect = chai.expect; | |
describe('Test Is Same Tree', function() { | |
it('Test1', function() { | |
var tree1 = new TreeNode(1); | |
var tree2 = new TreeNode(1); | |
var result = isSameTree(tree1, tree2); | |
expect(result).to.be.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
/** | |
* Definition for a binary tree node. | |
* function TreeNode(val) { | |
* this.val = val; | |
* this.left = this.right = null; | |
* } | |
*/ | |
/** | |
* @param {TreeNode} p | |
* @param {TreeNode} q |
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 Greet() { | |
this.greeting = "Hello World"; | |
this.greet = function() { | |
console.log(this.greeting); | |
} | |
} | |
module.exports = new Greet(); |
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 Greet() { | |
this.greeting = "Hello World"; | |
this.greet = function() { | |
console.log(this.greeting); | |
} | |
} | |
module.exports = new Greet(); |
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
const Promise = require('bluebird'); | |
const readFile = Promise.promisify(require('fs').readFile); | |
const fileList = ['file1.txt', 'file2.txt', 'file3.txt']; | |
const promises = fileList.map((filename) => { | |
return readFile(filename) | |
.then((content) => { | |
return { | |
error: false, | |
data: content.toString() |