Skip to content

Instantly share code, notes, and snippets.

@rduque1
rduque1 / gist:e693c248b230b831f03a5f5a45119cee
Last active December 21, 2023 12:38
ssh tunnel to DB when software does not support different cipher

ssh tunnel to a remote DB when software does not support different cipher

1. create ssh tunnel

ssh -p <ssh-port> -c <cipher_aes256-cb> -L 8888:<db-host>:<db-port_3306> <user>@<remote-host>

2. Open the application to connect to a DB

# extract a circle from the image: translate to the middle of the image and define the radius to cut
convert IMG-TRM-1916-1038.jpg -alpha on -background none \( +clone -channel a -evaluate multiply 0 +channel -fill white -draw "translate 1500,1000 circle 0,0 0,150" \) -compose DstIn -composite -trim out.png
# convert a svg to png with resize the SVG to desired size
convert -background none -density 1536 -resize 4092x4092 roodwit.svg roodwitx4092_1536.png
# rounded rectangle crop
convert <image>.webp +repage -alpha on -background none \( +clone -channel a -evaluate multiply 0 +channel -fill white -draw "translate 225,225 roundrectangle 0,0 571,555 115,115" \) -compose DstIn -composite -trim out.webp
@rduque1
rduque1 / next.md
Created February 9, 2023 08:34 — forked from timruffles/next.md
Next.js page request handling

How Next.js responds to a page request with HTML

We create the next request handler function via app.getRequestHandler(). This returns a standard express handler, so we use it like expressApp.get('*', middlewareA(), middlewareB(), nextApp.getRequestHandler()).

When the handler is invoked:

  • Server#handleRequest (next-server/server/lib/next-server.js)
    • Parses URL + query string if not already done
  • Server#run
  • Searches for matching route
@rduque1
rduque1 / rest-api-response-format.md
Created November 30, 2022 13:08 — forked from igorjs/rest-api-response-format.md
REST API response format based on some of the best practices
@rduque1
rduque1 / README.md
Created September 30, 2022 13:15 — forked from gjreasoner/README.md
Expand Ubuntu 20 Proxmox Disk
# Resize the file system in UI, under VM -> Hardware -> Click on the disk to resize, click "Resize disk" button

# Confirm increase in disk space (1TB in my case)
$ lsblk
NAME                      MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda                         8:0    0    1T  0 disk
├─sda1                      8:1    0    1M  0 part
├─sda2                      8:2    0    1G  0 part /boot
└─sda3                      8:3    0    1T  0 part
@rduque1
rduque1 / kubernetes_cheat_sheet.sh
Last active September 23, 2022 13:53
Kubernetes
# get number of running pods
kubectl get -A pods --field-selector=status.phase=Running --output json | jq -j '.items | length'
# get number of NOT running pods
kubectl get -A pods --field-selector=status.phase!=Running --output json | jq -j '.items | length'
# find out why a pod is in pending
describe pod -n <namespace> <pod-name>
# get a node max number of pods
@rduque1
rduque1 / replace_comma_by_tab.sh
Created September 10, 2022 11:01
replace comma by tab
sed 's/,/\t/g' test.txt > output.txt
@rduque1
rduque1 / parallel
Created June 29, 2022 13:46 — forked from mjambon/parallel
bash: Run parallel commands and fail if any of them fails
#! /usr/bin/env bash
#
# Run parallel commands and fail if any of them fails.
#
set -eu
pids=()
for x in 1 2 3; do
@rduque1
rduque1 / nodejs-tcp-example.js
Created February 22, 2022 12:08 — forked from tedmiston/nodejs-tcp-example.js
Node.js TCP client and server example
/*
In the node.js intro tutorial (http://nodejs.org/), they show a basic tcp
server, but for some reason omit a client connecting to it. I added an
example at the bottom.
Save the following server in example.js:
*/
var net = require('net');
@rduque1
rduque1 / connect-docker-socket.sh
Created February 22, 2022 10:17
connect to docker socket api over tcp
# https://serverfault.com/questions/843296/how-to-expose-the-docker-api-over-tcp
ncat -lknvp 2375 -c "ncat -U /var/run/docker.sock"