uploads redirect csv
/api/redirects-csv/upload.json
fetches latest session csv upload from db
| import pgEsacpe from 'pg-escape' | |
| console.log(pgEsacpe('Hello World, this is %s', 'Thomas')) | |
| console.log(pgEsacpe('Hello World, this is %Q', 'Thomas')) | |
| console.log(pgEsacpe('Hello World, this is %I', 'Thomas')) | |
| console.log(pgEsacpe('Hello World, this is %L', 'Thomas')) | |
| console.log(pgEsacpe('Hello World, this is %%', 'Thomas')) | |
| console.log(pgEsacpe('Hello World, this is %s', '"Thomas"')) | |
| console.log(pgEsacpe('Hello World, this is %Q', '"Thomas"')) | |
| console.log(pgEsacpe('Hello World, this is %I', '"Thomas"')) |
| knex.prototype.upsert = function(tableName, conflictTarget, itemData) { | |
| console.log(this) | |
| let exclusions = Object.keys(itemData) | |
| .filter(c => c !== conflictTarget) | |
| .map(c => exports.knex.raw('?? = EXCLUDED.??', [c, c]).toString()) | |
| .join(",\n"); | |
| let insertString = exports.knex(tableName).insert(itemData).toString(); | |
| let conflictString = exports.knex.raw(` ON CONFLICT (??) DO UPDATE SET ${exclusions} RETURNING *;`, conflictTarget).toString(); | |
| let query = (insertString + conflictString).replace(/\?/g, '\\?'); |
| import test from 'ava' | |
| import Promise from 'bluebird' | |
| export default function promiseRateLimit (fn, delay, count) { | |
| let working = 0 | |
| let queue = [] | |
| function work () { | |
| if ((queue.length === 0) || (working === count)) return | |
| working++ | |
| Promise.delay(delay).tap(function () { working-- }).then(work) |
| v7.2.1 | |
| 3.10.10 | |
| wonder@1.0.0 /Users/thomas/Desktop/wonder | |
| ├── archy@1.0.0 extraneous | |
| ├─┬ ava@0.17.0 | |
| │ ├── arr-flatten@1.0.1 | |
| │ ├── array-union@1.0.2 | |
| │ ├── array-uniq@1.0.3 | |
| │ ├── arrify@1.0.1 | |
| │ ├── auto-bind@0.1.0 |
| import pgEscape from 'pg-escape' | |
| class PGEscapeType { | |
| constructor(val) { | |
| this.val = val | |
| } | |
| } | |
| class PGSimpleString extends PGEscapeType {} | |
| class PGDollarQuotedString extends PGEscapeType {} |
| let subscriptionId = "IG5ryoQQ1ViS8v1TRO" | |
| let address = { first_name: 'Will', last_name: 'Ku', company: '', phone: '6312762113', line1: '8 Success Drivers, Copthall Bridge House, Station Bridge', line2: '', city: 'Harrogate', state: '', country: 'GB', zip: 'HG1 1SP' } | |
| chargebee.subscription.update(subscriptionId, {'shipping_address': address}).request() |
| var bool = Math.random() >= 0.5 | |
| function solidOperation () { | |
| // some pretend external function that fails sometimes | |
| var jankyOperation = function (value) { | |
| if (bool) throw new Error('operation failed') | |
| return value | |
| } | |
| let name = jankyOperation('thomas') | |
| let age = jankyOperation('27') |
| fetch('https://pasdev.estoreapi.com/graphql', { | |
| method: 'POST', | |
| mode: 'cors', | |
| headers: { | |
| 'Accept': 'application/json', | |
| 'Content-Type': 'application/json' | |
| }, | |
| body: JSON.stringify({ | |
| "query": "{\n author\n}", | |
| "variables": null, |