Skip to content

Instantly share code, notes, and snippets.

View rjcorwin's full-sized avatar

R.J. (Steinert) Corwin rjcorwin

View GitHub Profile
for f in *; do mv "$f" "$(echo "$f" | sed s/$1/$2/)"; done
#!/usr/bin/env node
const util = require('util');
const exec = util.promisify(require('child_process').exec)
const EventEmitter = require('events');
const sleep = (milliseconds) => new Promise((res) => setTimeout(() => res(true), milliseconds))
class PouchDbChangesFeedWorker extends EventEmitter {
// @TODO Instead of napTime, we could subscribe to the changes feed and wake on activity.
constructor (feeds = [], changeProcessor, PouchDB, batchSize = 5, sleepTimeAfterBatchProcessed = 0, sleepTimeAfterNoChanges = 3000, batchLimit = undefined) {
super()
this._feeds = feeds
this._changeProcessor = changeProcessor
const sleep = (milliseconds) => new Promise((res) => setTimeout(() => res(true), milliseconds))
#/bin/bash
# First param is the string to match, second is the destination directory.
ls -d -1 $PWD/* | sed 's/\ /\\\ /g' | sed 's/\*/\\\*/g' | sed 's/\#/\\\#/g' | sed "s/\'/\\\'/g" | grep $1 | xargs -I {} cp "{}" $2
wget --recursive --no-clobber --page-requisites --html-extension --convert-links --domains $1 http://$1
cd $1
dat share
dat://3c2f7c59b4bae4cb10d11effa65d3b144f1e0c06416406c0d39e9d1dabbbe76b/
/*
Create a folder called `folder-of-code` and then inside of that folder put
other folders like foo and bar with different assets in them. Then run this
server and notice how the static directory served will change depending on
wether you hit `http://foo.lvh.me` and `http://bar.lvh.me`.
Note you could rework this example to change the folder context depending on
something in `req.params.*` but for this example we are using the wildcard
const util = require('util')
const exec = util.promisify(require('child_process').exec)
async example() {
console.log(await exec('ls'))
console.log(await exec('ls'))
}
example()
<!DOCTYPE html>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at