Skip to content

Instantly share code, notes, and snippets.

import { Option, none, some } from 'fp-ts/lib/Option'
import { TaskEither, fromLeft, taskEither } from 'fp-ts/lib/TaskEither'
const a = (): Option<number> => {
if (Math.random() > 0.5) {
return none
}
return some(1)
}
interface ILocation {
cc: string
admin1: string
admin2: string
}
const location: Option<Partial<ILocation>> = some({cc: 'BR', admin1: 'SC'})
const first = 100
const offset = 10
const compose = (...fn) => x =>
fn.reduceRight((prevResult, func) => func(prevResult), x)
/*
const randomFloat = n => Math.random() * n
const nToStr = n => String(n)
const pad4 = str => str.padStart(4, '0')
const randomInt = compose(pad4, nToStr, Math.floor, randomFloat)
-='cd -'
...=../..
....=../../..
.....=../../../..
......=../../../../..
1='cd -'
2='cd -2'
3='cd -3'
4='cd -4'
5='cd -5'

Roteiro MongoDB

  1. $ mkdir -p /data/configdb

  2. $ mongod --configsvr --port 27010 starta mongod

  3. $ mongos --configdb localhost:27010 --port 27011 cria router

  4. $ mkdir /data/shard1 && mkdir /data/shard2 && mkdir /data/shard3 cria pasta pros shards

  5. Start shards

    $ mongod --port 27012 --dbpath /data/shard1 # shard1
#!/usr/bin/env node
var readline = require('readline'),
unflatten = require('flat').unflatten,
logfmt = require('logfmt');
var rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});