Skip to content

Instantly share code, notes, and snippets.

@bhurlow
bhurlow / compose.js
Created Nov 18, 2019
Async Composition
View compose.js
const R = require('ramda')
const maybeFoo = next => async item => {
console.log('maybeFoo', item)
item.data++
return next(item)
}
const maybeBar = next => async item => {
console.log('maybeBar', item)
@bhurlow
bhurlow / async.sh
Created Sep 13, 2019
async bash example
View async.sh
#! /bin/bash
cust_func(){
echo "Do something $1 times..."
sleep 1
}
# For loop 5 times
for i in {1..5}
do
@bhurlow
bhurlow / chan.js
Created May 30, 2018
async iteratros with buffer limit
View chan.js
function chan(n) {
let internalQueue = []
let drain = null
async function* wrappedIterator() {
while (true) {
if (internalQueue.length) {
if (drain) drain()
yield internalQueue.shift()
}
View gist:2c2f4ab232a29e5f4041a688d618c110
### Keybase proof
I hereby claim:
* I am bhurlow on github.
* I am bhurlow (https://keybase.io/bhurlow) on keybase.
* I have a public key ASCpmfCmKZXpos21zxXdNiafraKs12mdiVC-PZEAJDWUnQo
To claim this, I am signing this object:
View gist:b9e82506efdf8597bdb6243e517a7d29
alias ga 'git add'
alias gaa 'git add .'
alias gaaa 'git add -A'
alias gb 'git branch'
alias gbd 'git branch -d '
alias gc 'git commit'
alias gcm 'git commit -m'
alias gco 'git checkout'
alias gcob 'git checkout -b'
alias gcom 'git checkout master'
View bash
#! /bin/bash
filename=$(basename "$1")
extension="${filename##*.}"
filename="${filename%.*}"
ffmpeg -i $filename.$extension -codec:a libmp3lame $filename.mp3
View concurrent.clj
(ns scraper.concurrent
(:import [java.util.concurrent
ExecutorService
ExecutorCompletionService
Executors
CompletionService Future]))
(defn prln [& more]
(.write
*out*
@bhurlow
bhurlow / gist:7f4d87b272a04c282da8
Created Feb 28, 2016
grok pattern for nginx default
View gist:7f4d87b272a04c282da8
%{IP:client} - - \[%{HTTPDATE:time_local}\] %{QUOTEDSTRING:request} %{NUMBER:status} %{NUMBER:bytes} "-" %{QS:agent}
@bhurlow
bhurlow / install_docker.sh
Last active Apr 25, 2019
setup docker on ubuntu vivid 15.04
View install_docker.sh
#! /bin/bash
SERVICE="
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network.target docker.socket
Requires=docker.socket
[Service]
View repl_talk.js
var bencode = require('bencode')
var net = require('net')
var conn = net.connect(57720)
// var msg = {op: "eval", code: '(println 1000000)'}
// var msg = {op: "eval", code: '(println process.env.HOME)'}
// var msg = {op: "eval", code: '(cemerick.piggieback/cljs-repl (cljs.repl.node/repl-env))'}
// var msg = {op: "eval", code: "(+ 1 2 3)"}