Skip to content

Instantly share code, notes, and snippets.

View johnelliott's full-sized avatar
🕳️
tunneling

John Elliott johnelliott

🕳️
tunneling
View GitHub Profile
@johnelliott
johnelliott / uuidv4test.js
Last active April 10, 2024 07:31
uuid v4 regex
import { v4 as uuid } from 'uuid';
export function generateId() {
return uuid();
}
const v4 = new RegExp(/^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i);
console.log(generateId().match(v4));
//console.log(generateId().length)
@johnelliott
johnelliott / README.md
Last active September 19, 2023 13:53
http speed test with curl

cUrl speed test

Use

load up some urls into urls.txt

http://google.com/api/endpoint/1
http://google.com/api/other-endpoint/2

Run shell command:

@johnelliott
johnelliott / pokey-graceful-express.js
Last active January 24, 2023 19:19
Node.js Express Graceful shutdown Kubernetes
require('dotenv').config()
const http = require('http')
const express = require('express')
const app = express()
// Routes
app.get('/', function (req, res, next) {
console.log('got request')
setTimeout(function timeoutDone () {
@johnelliott
johnelliott / index.js
Last active October 11, 2022 18:04
Streaming HTML standard input demo
#! /usr/bin/env node
const http = require('http')
process.stdin.setRawMode(true)
process.stdin.resume()
process.stdin.setEncoding('utf8')
const server = http.createServer((req, res) => {
res.statusCode = 200
res.setHeader('Content-Type', 'text/html')
res.write('<html>')
@johnelliott
johnelliott / tailscale-hosts.sh
Created February 3, 2022 04:11
tailscale hosts
tailscale status --self=false | tr -s ' ' '\t' | cut -f1-2
@johnelliott
johnelliott / opentx-model-image-convert.sh
Created April 20, 2020 03:18
Convert OpenTX model images with ImageMagick
#!/usr/local/bin/bash
# convert should be from ImageMagick 7+
# e.g. $ cat input.jpg | ./opentx-model-image-convert.sh > output.bmp
convert - \
-resize 64x32 \
-gravity center \
-extent 64x32 \
-colorspace gray \

Tips for using PCD: https://github.com/kvannotten/pcd

... I also wanted [range downloads], but then I first used the seq and parallel programs. It's a very unix-y solution, but it turns out ids being integers is great. You may need to install and play with seq and parallel a bit, but this works for me:

episode downloads (echo must be removed for real downloading):

$ seq 4 10 |parallel echo pcd download mypodcast {}
pcd download mypodcast 4
pcd download mypodcast 5
pcd download mypodcast 6
@johnelliott
johnelliott / .vimrc.coworker.vim
Last active December 19, 2019 16:05
.vimrc.coworker.vim
unlet! skip_defaults_vim
if (filereadable($VIMRUNTIME .'/defaults.vim'))
source $VIMRUNTIME/defaults.vim
elseif (filereadable($VIMRUNTIME .'/vimrc_example.vim'))
source $VIMRUNTIME/vimrc_example.vim
endif
set noswapfile nobackup nojoinspaces gdefault ignorecase wildignorecase showcmd
set tabstop=4 expandtab softtabstop=2 shiftwidth=2
set undodir=~/.vim/undo clipboard=unnamed
#
# dump
# version
# Betaflight / STM32F7X2 (S7X2) 4.1.0 Aug 9 2019 / 11:41:22 (41a0b5938) MSP API: 1.42
# start the command batch
batch start