Skip to content

Instantly share code, notes, and snippets.

View tudormunteanu's full-sized avatar
👨‍💻
Crafting and leading. Mostly Web3 these days. 🛠️🚀 #TechLeader

Tudor Munteanu tudormunteanu

👨‍💻
Crafting and leading. Mostly Web3 these days. 🛠️🚀 #TechLeader
View GitHub Profile
@m-radzikowski
m-radzikowski / script-template.sh
Last active May 4, 2024 04:13
Minimal safe Bash script template - see the article with full description: https://betterdev.blog/minimal-safe-bash-script-template/
#!/usr/bin/env bash
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
@nileshtrivedi
nileshtrivedi / home-server.md
Last active January 10, 2024 06:30
Home Server setup: Raspberry PI on Internet via reverse SSH tunnel

Raspberry Pi on Internet via reverse SSH tunnel

HackerNews discussed this with many alternative solutions: https://news.ycombinator.com/item?id=24893615

I already have my own domain name: mydomain.com. I wanted to be able to run some webapps on my Raspberry Pi 4B running perpetually at home in headless mode (just needs 5W power and wireless internet). I wanted to be able to access these apps from public Internet. Dynamic DNS wasn't an option because my ISP blocks all incoming traffic. ngrok would work but the free plan is too restrictive.

I bought a cheap 2GB RAM, 20GB disk VM + a 25GB volume on Hetzner for about 4 EUR/month. Hetzner gave me a static IP for it. I haven't purchased a floating IP yet.

@smiller171
smiller171 / database.tf
Last active October 3, 2023 16:49
Manage RDS password in Terraform in a sane way
resource "random_password" "db_master_pass" {
length = 40
special = true
min_special = 5
override_special = "!#$%^&*()-_=+[]{}<>:?"
keepers = {
pass_version = 1
}
}
registry:
restart: always
image: registry:latest
ports:
- 443:5000
environment:
REGISTRY_HTTP_TLS_CERTIFICATE: /certs/domain.crt
REGISTRY_HTTP_TLS_KEY: /certs/domain.key
REGISTRY_AUTH: htpasswd
REGISTRY_AUTH_HTPASSWD_PATH: /var/lib/registry/passfile
@fralau
fralau / key-pairs-cmdline.md
Last active December 6, 2023 15:10
Command line: create dictionary from key-value pairs

Converting an arbitrary list of key-value pairs from the command-line into a Python dictionary

Problem

You want to create a series of key-value pairs from the command line, using the argparse library, e.g.:

command par1 par2 --set foo=hello bar="hello world" baz=5

This is typically useful when you want to clearly distinguish":

  1. Ordinary arguments for the command-line utility itself (output, input, format, etc.) from
  2. A set of key-value pairs you want to pass to the python application. This is especially valid when you do not want that set of values to be predetermined, as this can save a lot of code.
@swalkinshaw
swalkinshaw / tutorial.md
Last active November 13, 2023 08:40
Designing a GraphQL API
@ipepe
ipepe / install-chrome-headless.sh
Last active April 19, 2024 07:15
Installing headless chrome on Ubuntu.
#!/bin/bash
# from https://chromium.woolyss.com/
# and https://gist.github.com/addyosmani/5336747
# and https://chromium.googlesource.com/chromium/src/+/lkgr/headless/README.md
sudo apt-get update
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:canonical-chromium-builds/stage
sudo apt-get update
sudo apt-get install chromium-browser
chromium-browser --headless --no-sandbox http://example.org/
@khornberg
khornberg / encode_decode_dictionary.py
Created August 25, 2017 12:39
python 3 base64 encode dict
"""
Given a dictionary, transform it to a string. Then byte encode that string. Then base64 encode it and since this will go
on a url, use the urlsafe version. Then decode the byte string so that it can be else where.
"""
data = base64.urlsafe_b64encode(json.dumps({'a': 123}).encode()).decode()
# And the decode is just as simple...
data = json.loads(base64.urlsafe_b64decode(query_param.encode()).decode())
# Byte encode the string, base64 decode that, then byte decode, finally transform it to a dictionary
@blainerothrock
blainerothrock / gen.swift
Last active July 12, 2018 15:56
A Very Simple Genetic Algorithm Written in Swift 3
#!/usr/bin/env xcrun swift -O
/*
gen.swift is a direct port of cfdrake's helloevolve.py from Python 2.7 to Swift 3
-------------------- https://gist.github.com/cfdrake/973505 ---------------------
gen.swift implements a genetic algorithm that starts with a base
population of randomly generated strings, iterates over a certain number of
generations while implementing 'natural selection', and prints out the most fit
string.
The parameters of the simulation can be changed by modifying one of the many
@kevin-smets
kevin-smets / 1_kubernetes_on_macOS.md
Last active May 5, 2024 10:12
Local Kubernetes setup on macOS with minikube on VirtualBox and local Docker registry

Requirements

Minikube requires that VT-x/AMD-v virtualization is enabled in BIOS. To check that this is enabled on OSX / macOS run:

sysctl -a | grep machdep.cpu.features | grep VMX

If there's output, you're good!

Prerequisites