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 numberOfDocs = 1000 | |
var userName = 'RJ' | |
var templateDoc = { | |
yourDocHere: true | |
} | |
var fillUp = async (numberOfDocs, templateDoc, dbName) => { | |
let initialEstimate = await navigator.storage.estimate() | |
let db = new PouchDB(dbName) | |
delete templateDoc._rev |
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 fillUp = async (numberOfDocs, templateDoc, destroy = true) => { | |
let initialEstimate = await navigator.storage.estimate() | |
let dbName = `test-${new Date().getTime()}` | |
let db = new PouchDB(dbName) | |
delete templateDoc._rev | |
let i = 0 | |
while (numberOfDocs > i) { | |
let doc = Object.assign({}, templateDoc, { _id: `${i}` }) | |
await db.put(doc) | |
i++ |
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
if (inputs.location.value[3]) { | |
let selectedLocationNode = Loc | |
.flatten(inputs.location.locationList) | |
.find(node => node.id === inputs.location.value[3]) | |
if (selectedLocationNode.label === 'Other') { | |
// Do something. | |
} | |
} |
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 items = [ | |
{ name: 'Edward', value: 21 }, | |
{ name: 'Sharpe', value: 37 }, | |
{ name: 'And', value: 45 }, | |
{ name: 'The', value: -12 }, | |
{ name: 'Magnetic', value: 13 }, | |
{ name: 'Zeros', value: 37 } | |
] | |
// sort by value |
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
import { createStore } from 'redux-dat' | |
import reducer from './reducer.js' | |
const myActions = new DatArchive() | |
const store = createStore(myActions, reducer) | |
store.addPeer('...') |
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
function a() { | |
return new Promise((resolve, reject) => { | |
setTimeout(() => { | |
console.log('a') | |
resolve() | |
}, 1000) | |
}) | |
} |
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
[...document.querySelectorAll('div')].map(el => console.log(el)) |
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 util = require('util'); | |
const exec = util.promisify(require('child_process').exec) | |
const go = async () => { | |
try { | |
const output1 = await exec('echo 1') | |
console.log(output1.stdout) | |
const output2 = await exec('echo 2') | |
console.log(output2.stdout) | |
const output3 = await exec('echo 3') |
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
let username = ''; | |
let password = ''; | |
let dbName = ''; | |
const PouchDB = require('pouchdb') | |
const DB = PouchDB.defaults({ | |
prefix: '/tangerine/db/' | |
}); | |
try { |
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
ls -l | awk '{print $9}' | xargs -I {} sh -c 'echo {} && find ./{} -print | wc -l' |