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
page.click('#checkout',{ | |
button: 'left', //left, right, middle, | |
clickCount: 1, | |
delay: 200 //how long to hold down the mouse button | |
}) |
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
page.on('console', msg => {}); | |
page.on('dialog', msg => {}); | |
page.on('error', msg => {}); | |
page.on('frameattached', msg => {}); | |
page.on('framenavigated', msg => {}); | |
page.on('load', msg => {}); //javascript load events | |
page.on('request', msg => {}); | |
page.on('response', msg => {}); | |
page.on('workercreated', msg => {}); |
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
const page = await browser.newPage(); | |
page.reload(); | |
page.setExtraHTTPHeaders({}); | |
page.setRequestInterception(value) | |
page.setJavaScriptEnabled(enabled) | |
page.setOfflineMode(enabled) |
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
browser = await puppeteer.launch({ | |
headless: //Whether to run browser in headless mode | |
executablePath: //path to a specified version of chrome to run | |
slowMo: //slows down all actions | |
defaultViewport: { | |
width: | |
height: | |
deviceScaleFactor: | |
isMobile: | |
hasTouch: |
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
(async () => { | |
const browser = await puppeteer.launch(); | |
const page = await browser.newPage(); | |
await page.goto('https://example.com'); | |
await page.screenshot({path: 'example.png'}); | |
await browser.close(); | |
})(); |
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
exports.handler = function(context, event, callback) { | |
var SquareConnect = require('square-connect'); | |
var Twilio = require('twilio'); | |
var accessToken = context.accessToken; | |
var locationId = context.locationId; | |
var messageBody = event.message; | |
var number = event.number; | |
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
const fs = require('fs'); | |
/** | |
* Adapted from https://github.com/ApelSYN/mnist_dl/blob/master/lib/digitsLoader.js | |
* Reads a file and resolves an array of data | |
* @param {string} labelFileName | |
* @return {promise} | |
*/ | |
function digitsLoader(labelFileName) { | |
return new Promise(function(resolve, reject) { |
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
body = { | |
'limit': 1000, | |
'query': { | |
'filter': { | |
'updated_at': { | |
'start_at': yesterday.toISOString(), | |
'end_at': today.toISOString(), | |
}, | |
}, | |
}, |
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 SquareConnect = require('square-connect'); | |
SquareConnect.ApiClient.instance.authentications['oauth2'].accessToken = 'sq0atp-XXXX'; | |
var sqlite3 = require('sqlite3').verbose(); | |
var db = new sqlite3.Database('./database.db'); | |
var apiInstance = new SquareConnect.CustomersApi(); | |
var today = new Date(); |
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 apiInstance = new SquareConnect.CustomersApi(); | |
db.each("SELECT * FROM Customers WHERE ...", function (err, row) { | |
apiInstance.createCustomer({ | |
given_name:row.given_name, | |
family_name:row.family_name, | |
email_address:row.email_address | |
}).then(function (data) { | |
console.log('API called successfully. Returned data: ' + data); | |
}, function (error) { |