Skip to content

Instantly share code, notes, and snippets.

View ericlowry's full-sized avatar

Eric Lowry ericlowry

View GitHub Profile
@ericlowry
ericlowry / couchdb.sh
Last active August 11, 2023 05:41
Create a couchdb container for testing
#!/usr/bin/env bash
#
# couchdb.sh - manage the docker development environment for couchdb
#
COMMAND="$1"
CONTAINER="$2"
IMAGE="apache/couchdb:latest"
@ericlowry
ericlowry / commander-cli-example.js
Last active May 17, 2020 15:45
Simple commander CLI template
#!/usr/bin/env node
//
// exmaple commander cli
//
require('dotenv').config();
const cli = require('commander').version(require('../package.json').version);
const makeInt = v => parseInt(v);
@ericlowry
ericlowry / proxy.toml
Last active May 17, 2020 15:33
simple traefik example with proxy server
#
# mkdir ./proxy/certs/swat
# cd ./proxy/certs/swat
# mkcert -cert-file=./cert.pem -key-file=./key.pem swat.localhost "*.swat.localhost"
#
[[tls.certificates]]
certFile = "/opt/proxy/certs/swat/cert.pem"
keyFile = "/opt/proxy/certs/swat/key.pem"
stores = ["default"]
@ericlowry
ericlowry / upsert-presrerve-cdate
Created May 17, 2020 15:25
couchdb nano upsert that preserves mdate and muser (slower than upsert which uses HEAD for _rev)
//
// async upsert( db, doc[, id] )
//
// attempts to insert a document, on document conflict, attempt to create a new version
//
const upsert = (db, doc, id) =>
// attempt to insert the doucment "as is"
db.insert(doc, id).catch(err => {
// for anything other than a document conflict...
if (err.statusCode !== 409)
@ericlowry
ericlowry / upsert.js
Last active August 11, 2023 05:46
couchdb nano upsert - fast and simple
//
// async upsert( db, doc[, id] )
//
// attempts to insert a document, on document conflict, attempt to create a new version
//
const upsert = (db, doc, id) =>
// attempt to insert the doucment "as is"
db.insert(doc, id).catch(err => {
// for anything other than a document conflict...
if (err.statusCode !== 409)