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 / docker.alpine.install.awscliv2.sh
Last active March 26, 2024 14:50
Install AWSCLIv2 in `docker:latest` alpine image for running docker-dn-docker depoyments in Gitlab
# `docker:latest` image uses base alpine linux
# This script allows installing awscliv2 which requires
# gcc buildtools (instead of default `musl` in alpine)
# https://stackoverflow.com/questions/60298619/awscli-version-2-on-alpine-linux
GLIBC_VER=2.31-r0
# install glibc compatibility for alpine
apk --no-cache add \
binutils \
jq \
@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 / Async.gs
Last active March 14, 2024 19:11
Asynchronous execution for Google App Scripts (gas)
/*
* Async.gs
*
* Manages asyncronous execution via time-based triggers.
*
* Note that execution normally takes 30-60s due to scheduling of the trigger.
*
* @see https://developers.google.com/apps-script/reference/script/clock-trigger-builder.html
*/
@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 / docker-cockpit-portainer.sh
Last active February 12, 2024 20:15
Docker + Portainer + Cockpit
#1 Openssh server
sudo apt install -y openssh-server
sudo systemctl enable ssh
sudo systemctl start ssh
sudo ufw enable
sudo ufw allow ssh
#2 Docker (https://docs.docker.com/engine/install/ubuntu/)
sudo apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
@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 / jwt.server.js
Created March 9, 2017 03:59
Node JSON Web Token API authentication
// @see https://scotch.io/tutorials/authenticate-a-node-js-api-with-json-web-tokens
// =======================
// get the packages we need ============
// =======================
var express = require('express');
var app = express();
var bodyParser = require('body-parser');
var morgan = require('morgan');
var mongoose = require('mongoose');