Skip to content

Instantly share code, notes, and snippets.

View tristansokol's full-sized avatar

Tristan Sokol tristansokol

View GitHub Profile
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:
(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();
})();
@tristansokol
tristansokol / fashion-mnist-to-array.js
Created July 12, 2018 02:25
Created more easily accessible json objects from the fashion MINST data set.
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) {
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();
body = {
'limit': 1000,
'query': {
'filter': {
'updated_at': {
'start_at': yesterday.toISOString(),
'end_at': today.toISOString(),
},
},
},
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) {
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,
});
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)");
{
"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"
}
<?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}};