Skip to content

Instantly share code, notes, and snippets.

const testInput = ['w','h','a','t',' ','o','n',' ','e','a','r','t','h',' ','a','r','e',' ','y','o','u',' ','t','a','l','k','i','n','g',' ','a','b','o','u','t','?'];
const testOutput = ['w','h','a','a','t',' ','o','o','n',' ','e','e','a','a','r','t','h',' ','a','a','r','e','e',' ','y','o','o','u','u',' ','t','a','a','l','k','i','i','n','g',' ','a','a','b','o','o','u','u','t','?'];
function equalStringArr(as1, as2){
var equal = true;
for (let i = 0; i < as1.length; i++){
equal = equal && (as1[i] === as2[i]);
}
await client.query('BEGIN');
// await client.query(prep);
var ops = _.range(0, 10000).map((id) => {
return { insertOne: { "document": {...obj, test4: Math.random(), test5: Math.random(), test6: Math.random(), test7: Math.random(), test8: Math.random(), rid: id*Math.random() } }};
});
/*
var ins = `INSERT INTO test_tb VALUES ('${testarr[0]}', '${testarr[1]}', '${testarr[2]}', ${Math.random()}, ${Math.random()}, ${Math.random()}, ${Math.random()}, ${Math.random()}, ${Math.random()})`;
_.range(1, 10000).forEach(() => {
@josh-southern
josh-southern / seed.js
Created March 15, 2018 22:22
Concurrent Database Seeding with MongoDB
const MongoClient = require('mongodb').MongoClient;
const _ = require('ramda');
const cluster = require('cluster');
const numCPUs = require('os').cpus().length; // 8
var time = new Date().getTime();
var obj = {
test1: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Voluptatibus molestias vel, nesciunt, esse, magni optio officiis minima necessitatibus magnam ratione eveniet. Reprehenderit, dolor labore. Omnis excepturi magni, explicabo ad iste?',
test2: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Possimus ipsam mollitia sit animi quam, amet, incidunt magnam, ut asperiores, minima similique expedita quaerat tempore consequatur quo aperiam ducimus ipsum sequi?',
class Tree {
constructor(value = 0){
this.value = value;
this.visited = false;
this.left = null;
this.right = null;
this.parent = null;
}
}
@josh-southern
josh-southern / Rake Database.md
Created September 28, 2017 18:40 — forked from stevenyap/Rake Database.md
List of rake commands to manage database

Create database

rake db:create

Create database table

This will creates a migration file in /db/migrate without table definition.

rails g migration create_<TABLE>