Skip to content

Instantly share code, notes, and snippets.

View sinamics's full-sized avatar
🎯
Focusing

Bernt Christian Egeland sinamics

🎯
Focusing
View GitHub Profile
@sinamics
sinamics / format_usb_win10.txt
Last active June 29, 2023 17:22
Format USB Drive in Windows 10 with DiskPart
Open Command Prompt and run as Administrator.
2. Type: diskpart in the command prompt window
3. type: list disk
4. Now, select the correct disk by typing: select disk 2 (your drive number)
5. type: attributes disk clear readonly
@sinamics
sinamics / motd.sh
Created December 30, 2022 15:46
Motd welcome message
#!/bin/bash
# The [ -t 1 ] check only works when the function is not called from
# a subshell (like in `$(...)` or `(...)`, so this hack redefines the
# function at the top level to always return false when stdout is not
# a tty.
# THIS FIEL IS LOADED FROM /etc/zsh/zshrc
if [ -t 1 ]; then
@sinamics
sinamics / self_signed_ssl.sh
Created November 20, 2022 17:00
Generate self signed ssl certificates client/server
#!/bin/bash
IP="192.168.1.22"
SUBJECT_CA="/C=SE/ST=Stockholm/L=Stockholm/O=himinds/OU=CA/CN=$IP"
SUBJECT_SERVER="/C=SE/ST=Stockholm/L=Stockholm/O=himinds/OU=Server/CN=$IP"
SUBJECT_CLIENT="/C=SE/ST=Stockholm/L=Stockholm/O=himinds/OU=Client/CN=$IP"
function generate_CA () {
echo "$SUBJECT_CA"
openssl req -x509 -nodes -sha256 -newkey rsa:2048 -subj "$SUBJECT_CA" -days 365 -keyout ca.key -out ca.crt
@sinamics
sinamics / mqtt-tls.md
Last active November 17, 2022 12:10
mqtt tls config

MQTT TLS config

These are some rough notes for deploying a test/dev local CA, a server key/cert, and a client key/cert. The intention is to provide a quick and dirty (don't use in production) local CA with one server and one client.

Easy-rsa

Follow the install guide for easy-rsa (https://github.com/OpenVPN/easy-rsa)

Init PKI

./easyrsa init-pki

Build CA

#!/bin/bash
#
# This is a vzbackup hook script that backups up your proxmox vms, containers and pve configs to remote storage
# such as google drive using proxmox's native vzbackup tool and rclone.
# https://github.com/TheRealAlexV/proxmox-vzbackup-rclone
#
# ./vzbackup-rclone.sh rehydrate YYYY/MM/DD file_name_encrypted.bin
############ /START CONFIG
dumpdir="/var/lib/vz/dump" # Set this to where your vzdump files are stored
# Copy SSH Key to Remote Linux Device
# use the below PowerShell one-line command to copy the contents of the id_rsa.pub public key to a remote Linux device.
# Replace the {IP-ADDRESS-OR-FQDN} with the IP address or FQDN (Fully Qualified Domain Name) of the remote Linux device you would like to copy the public key to.
type $env:USERPROFILE\.ssh\id_rsa.pub | ssh {IP-ADDRESS-OR-FQDN} "cat >> .ssh/authorized_keys"
@sinamics
sinamics / .git-credentials
Created October 23, 2022 10:21
Set github accesstoken globally
# add new .git-credentials file in userhome folder
nano ~/.git-credentials
# paste in your username and token generated from github.
# example:
https://<USERNAME>:<TOKEN>@github.com
# Reload github config helper
git config --global credential.helper store
@sinamics
sinamics / starship.toml
Last active October 22, 2022 11:11
starship config
format = """
$time \
$status\
$username@$hostname\
$git_branch$git_status$nodejs \
$directory\
$fill\
$python \
$package \
@sinamics
sinamics / lord_shell.sh
Last active January 18, 2024 18:48
Install zsh and oh my zsh plugin with aliases ( optionally ).
#!/bin/bash
# To use this script copy&paste this in your terminal:
# bash <(curl -s https://gist.githubusercontent.com/sinamics/d009a27192aa2fd22ea97bca3c0a36fd/raw/lord_shell.sh)
#########################################
# This script will install the following packages:
# - zsh
# - oh my zsh
# - zsh-autosuggestions
#!/usr/bin/env bash
set -e
# install docker bash completion
curl -L https://raw.githubusercontent.com/docker/docker/v$(docker version --format '{{.Server.Version}}')/contrib/completion/bash/docker -o /etc/bash_completion.d/docker
# install docker-compose bash completion
curl -L https://raw.githubusercontent.com/docker/compose/$(docker-compose version --short)/contrib/completion/bash/docker-compose -o /etc/bash_completion.d/docker-compose