Skip to content

Instantly share code, notes, and snippets.

@bhurlow
bhurlow / tunnel.js
Created May 7, 2013 19:56
proxy tunnel
View tunnel.js
var http = require('http');
var net = require('net');
var url = require('url');
var proxy = http.createServer();
// proxy an HTTP request
proxy.on('request', function(req, res){
var uri = url.parse(req.url);
@bhurlow
bhurlow / macros.clj
Created November 30, 2023 05:08
java.util.Function converion macros
View macros.clj
(defmacro as-function [f]
`(reify java.util.function.Function
(apply [this arg#]
(~f arg#))))
(defmacro as-consumer [f]
`(reify java.util.function.Consumer
(accept [this arg#]
(~f arg#))))
@bhurlow
bhurlow / gist:3043629
Created July 3, 2012 21:57
Linux Screen Cheat Sheets
View gist:3043629
–ctrl a c -> cre­ate new win­dow
–ctrl a A -> set win­dow name
–ctrl a w -> show all win­dow
–ctrl a 1|2|3|… -> switch to win­dow n
–ctrl a ” -> choose win­dow
–ctrl a ctrl a -> switch between win­dow
–ctrl a d -> detach win­dow
–ctrl a ? -> help
–ctrl a [ -> start copy, move cur­sor to the copy loca­tion, press ENTER, select the chars, press ENTER to copy the selected char­ac­ters to the buffer
–ctrl a ] -> paste from buffer
@bhurlow
bhurlow / malli.clj
Created March 2, 2022 19:30
schema generation
View malli.clj
(ns yd.seed.core
(:require [malli.core :as m]
[malli.error :as me]
[malli.generator :as mg]))
(def event-types
[:enum
:post
:comment
:reaction
@bhurlow
bhurlow / temp_sensor.txt
Created December 3, 2021 14:11
Temp Sensor Readouts
View temp_sensor.txt
383981
2021-12-03 03:02:44.754101; 40.00 %RH; -50.00 °C
383931
2021-12-03 03:02:46.927674; 40.00 %RH; -50.00 °C
383980
2021-12-03 03:02:49.106408; 40.00 %RH; -50.00 °C
383999
2021-12-03 03:02:51.284882; 40.00 %RH; -50.00 °C
384063
2021-12-03 03:02:53.463237; 41.00 %RH; -50.00 °C
@bhurlow
bhurlow / jpost
Last active October 30, 2021 19:05
alias so you can pipe into curl to post json
View jpost
#!/bin/bash
curl -X POST -d @- $1 --header "Content-Type:application/json"
@bhurlow
bhurlow / compose.js
Created November 18, 2019 20:12
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 September 13, 2019 15:25
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 / gist:3861616
Created October 9, 2012 21:36
Better XML to JSON parsing for cdata
View gist:3861616
// Changes XML to JSON
// fixed some bugs from http://davidwalsh.name/convert-xml-json
// October 9, 2012
// Brian Hurlow
function xmlToJson(xml) {
// Create the return object
var obj = {};
// console.log(xml.nodeType, xml.nodeName );
@bhurlow
bhurlow / install_docker.sh
Last active April 25, 2019 12:07
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]