Skip to content

Instantly share code, notes, and snippets.

# 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 / 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 / pearson-correlation.js
Created June 9, 2021 16:06 — forked from matt-west/pearson-correlation.js
Pearson Correlation (JavaScript)
/**
* @fileoverview Pearson correlation score algorithm.
* @author matt.west@kojilabs.com (Matt West)
* @license Copyright 2013 Matt West.
* Licensed under MIT (http://opensource.org/licenses/MIT).
*/
/**
* Calculate the person correlation score between two items in a dataset.
@rduque1
rduque1 / docker-healthcheck.md
Created March 16, 2021 13:27 — forked from shotgunner/docker-healthcheck.md
How to view docker healthcheck logs?

How to see healthcheck Logs ?

Use docker inspect is different in swarm mode and normal mode if you wnat to use it in swarm mode:

  • Manager nodes: use this command for services. (but if you want to see healthceck logs of specific container see worker nodes section):

    • docker inspect --format "{{json .Spec.TaskTemplate.ContainerSpec.Healthcheck }}" hinava_dashboard |jq
  • Worker nodes: you should use complete name of the container that completed with <tab> key

  • docker inspect hinava_filebeat.1.umvobmm9wrjdz1b08y5jibvl2 | grep -B 10 -A 10 "health"
@rduque1
rduque1 / iptables.sh
Created February 23, 2021 12:50 — forked from Tristor/iptables.sh
Simple IPtables script for an OpenVPN server
#!/bin/bash
# Flushing all rules
iptables -F FORWARD
iptables -F INPUT
iptables -F OUTPUT
iptables -X
# Setting default filter policy
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP
@rduque1
rduque1 / create_loop_delete.sh
Last active October 4, 2020 15:19 — forked from nashjain/delete_all_aws_s3_object_versions.sh
Let's assume you backup a file every hour on AWS S3 and you want to clean up versions that are older than a week. However for the older versions, you want to leave one version per day just in case if you need them. Following script does that for you.
for id in `(cat toDel.txt)`; do echo "aws --profile wasabi s3 --endpoint-url=<endpoint> rm --recursive s3://<bucket>/id_$id/"; done