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
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 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
(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 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 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 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 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 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
body = { | |
'limit': 1000, | |
'query': { | |
'filter': { | |
'updated_at': { | |
'start_at': yesterday.toISOString(), | |
'end_at': today.toISOString(), | |
}, | |
}, | |
}, |
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 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) { |
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 apiInstance = new SquareConnect.CustomersApi(); | |
var opts = {}; | |
apiInstance.listCustomers(opts).then(function(data) { | |
var now = new Date(); | |
data.customers.forEach(function(element) { | |
db.run('INSERT into Customers (id , created_at , updated_at , synced_at ,given_name , family_name , email_address , creation_source ) VALUES( $id, $created_at, $updated_at, $synced_at, $given_name, $family_name , $email_address , $creation_source )', { | |
$id: element.id, $created_at: element.created_at, $updated_at: element.updated_at, $synced_at: now.toISOString(), $given_name: element.given_name, $family_name: element.family_name, $email_address: element.email_address, $creation_source: 'Square:'+element.creation_source, | |
}); |
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 sqlite3 = require('sqlite3').verbose(); | |
var db = new sqlite3.Database('./database.db'); | |
db.run("CREATE TABLE customers (id TEXT, created_at TEXT, updated_at TEXT, synced_at TEXT,given_name TEXT, family_name TEXT, email_address TEXT, creation_source TEXT)"); |
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
{ | |
"projectName": "square-connect", | |
"projectVersion": "2.8.0", | |
"projectDescription": "JavaScript client library for the Square Connect v2 API", | |
"projectLicenseName": "Apache-2.0", | |
"moduleName": "SquareConnect", | |
"usePromises": true, | |
"licenseName": "Apache 2.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
<?php | |
{{#models}} | |
{{#model}} | |
/** | |
* NOTE: This class is auto generated by the swagger code generator program. | |
* https://github.com/swagger-api/swagger-codegen | |
* Do not edit the class manually. | |
*/ | |
namespace {{modelPackage}}; |