Skip to content

Instantly share code, notes, and snippets.

View sdesalas's full-sized avatar
🕹️

Steven de Salas sdesalas

🕹️
View GitHub Profile
version: '3'
services:
influxdb:
image: influxdb:latest
ports:
- '8086:8086'
volumes:
- ./data/influxdb:/var/lib/influxdb2
environment:
@sdesalas
sdesalas / cb.sh
Last active March 22, 2024 12:16
Poor mans apache bench
#! /bin/bash
#
# CurlBench. Dont want to install apache bench?
#
# Runs "curl" concurrently using arguments.
#
# Example: Make 100 requests to some domain (concurrency = 10)
# $ curl.sh http://some.domain.com 100 10
#
set -B
@sdesalas
sdesalas / gist:5c9db8f60e1ff5081a6ea7fd693676a8
Last active March 15, 2024 10:08
Bug report use type `nullable` and `anyOf` in express-openapi-validator
**Describe the bug**
A clear and concise description of what happens.
Hiya. Thanks for putting together this awesome library.
We're trying to validate a response schema as follows:
@sdesalas
sdesalas / check-redis.connect.sh
Created December 19, 2023 11:49
Check Redis connectivity
#! /bin/bash
# @see https://stackoverflow.com/questions/33243121/abuse-curl-to-communicate-with-redis
# Without any tools
exec 3<>/dev/tcp/$REDIS_HOST/6379 && echo -e "PING\r\n" >&3 && head -c 7 <&3
# With netcat (apt install netcat-traditional)
(printf "PING\r\n";) | nc $REDIS_HOST 6379
# With telnet
@sdesalas
sdesalas / jwt.es256.web.crypto.api.html
Last active December 5, 2023 13:03
JWT ES256 (ECDSA) Encoding and decoding in plain JavaScript (Web Crypto API)
<html>
<body>
<h1>JWT ES256 Encoding and decoding in plain JavaScript (Web Crypto API)</h1>
<textarea id="log" style="width: 100%; height: 400px;"></textarea>
</body>
<script>
///
/// PLEASE BE AWARE
/// IT IS GENERALLY A BAD IDEA TO GENERATE JWT TOKENS IN THE BROWSER
/// THIS SHOULD ONLY BE USED FOR TESTING PURPOSES
@sdesalas
sdesalas / generate.jwt.sh
Last active March 5, 2024 11:54
JWT ES256 and ECDS Key generation
# Generate JWT public/private key pair for use in JWT (ES256 algorithm)
openssl ecparam -name secp256r1 -genkey -out jwt.es256.priv
openssl ec -in jwt.es256.priv -pubout -outform PEM -out jwt.es256.pub
# Create PKCS8 format
openssl pkcs8 -topk8 -inform PEM -outform DER -in jwt.es256.priv -out jwt.es256.pkcs8 -nocrypt
base64 -i jwt.es256.pkcs8 > jwt.es256.pkcs8.base64
@sdesalas
sdesalas / scar_tissue.md
Created May 28, 2023 16:30 — forked from gtallen1187/scar_tissue.md
talk given by John Ousterhout about sustaining relationships

"Scar Tissues Make Relationships Wear Out"

04/26/2103. From a lecture by Professor John Ousterhout at Stanford, class CS142.

This is my most touchy-feely thought for the weekend. Here’s the basic idea: It’s really hard to build relationships that last for a long time. If you haven’t discovered this, you will discover this sooner or later. And it's hard both for personal relationships and for business relationships. And to me, it's pretty amazing that two people can stay married for 25 years without killing each other.

[Laughter]

> But honestly, most professional relationships don't last anywhere near that long. The best bands always seem to break up after 2 or 3 years. And business partnerships fall apart, and there's all these problems in these relationships that just don't last. So, why is that? Well, in my view, it’s relationships don't fail because there some single catastrophic event to destroy them, although often there is a single catastrophic event around the the end of the relation

@sdesalas
sdesalas / check.sh
Created April 8, 2023 21:49
Self CICD using Cron + Git
#!/bin/bash
#
# Helps redeploy services when there are git remote changes
#
# @usage: sudo ./check.sh [branch] [--force]
# @example: sudo ./check.sh origin/master --force
PATH=$PATH:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
FETCH=$(git fetch)
UPSTREAM=${1:-'origin/master'}
@sdesalas
sdesalas / oneline.ratelimit.test.sh
Last active April 8, 2023 13:13
Bash oneline http rate limit test
!# /bin/bash
time for i in `seq 1 50`; do curl -s -o /dev/null -H "Authorization: $AUTH" -w "$i %{http_code}\n" http://localhost:8080/api/endpoint; done;
@sdesalas
sdesalas / simple.launch.json
Created March 27, 2023 09:55
VS Code debugging
{
"version": "0.2.0",
"configurations": [
{
"name": "Inspect",
"request": "launch",
"type": "node-terminal",
"command": "node --inspect index.js"
}
]