Skip to content

Instantly share code, notes, and snippets.

View sdesalas's full-sized avatar
💻

Steven de Salas sdesalas

💻
View GitHub Profile
@sdesalas
sdesalas / docker-compose.loki.yaml
Created September 12, 2024 21:48
Docker compose grafana loki
version: "3"
networks:
loki:
services:
loki:
image: grafana/loki:2.9.2
ports:
- "3100:3100"
@sdesalas
sdesalas / Caddyfile
Last active September 10, 2024 17:57
Launch script, upgrade, add docker and caddy
my.domain.com {
reverse_proxy localhost:40001
header -Server
header -X-Powered-By
log {
output file /var/log/caddy/my.domain.com-access.log
}
@ws {
header Connection *Upgrade*
header Upgrade websocket
version: '3.7'
services:
app:
image: coturn/coturn
#ports:
# - 3478:3478/tcp
# - 3478:3478/udp
# - 5349:5349/tcp # TLS
# - 5349:5349/udp # TLS
#! /bin/sh
# 1. Install Docker CE
curl -fsSL https://raw.githubusercontent.com/sdesalas/docker-install/master/install.sh -o ~/install-docker.sh
chmod + x ~/install-docker.sh
./install-docker.sh
# 2. Install Caddy
apt install -y debian-keyring debian-archive-keyring apt-transport-https curl
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/testing/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-testing-archive-keyring.gpg
@sdesalas
sdesalas / timeago.js
Last active July 10, 2024 23:10
Minimal KISS implementation of TimeAgo.
const SECOND = 1000;
const MINUTE = 60*SECOND;
const HOUR = 60*MINUTE;
const DAY = 24*HOUR;
const WEEK = 7*DAY;
const MONTH = 30*DAY;
const YEAR = 52*WEEK;
function timeAgo(date) {
const diff = Date.now() - new Date(date).getTime();
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 May 22, 2024 11:28
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