Skip to content

Instantly share code, notes, and snippets.

@gnzsnz
gnzsnz / Creating GPG keys and subkeys.md
Created April 26, 2024 07:34
Creating GPG keys and subkeys

Creating GPG keys and subkeys

There are the steps to create GPG key pair and the additional steps to create a subkey.

Create GPG keys

gpg --full-generate-key
Please select what kind of key you want:
@gnzsnz
gnzsnz / upgrade_postgres_cluster.md
Created March 17, 2024 15:54
Upgrade Postgres cluster

Install latest version

sudo apt install postgresql-16 postgresql-client-16

List clusters

sudo pg_lsclusters

Create postgres user and database

How to create a user, a database and grant all privileges on the new database?

sudo -u postgres psql
postgres=# CREATE DATABASE mydb;
postgres=# CREATE USER myuser WITH ENCRYPTED PASSWORD 'mypass';
postgres=# GRANT ALL PRIVILEGES ON DATABASE mydb TO myuser;
postgres=# GRANT ALL ON SCHEMA public TO myuser;
@gnzsnz
gnzsnz / How to use semaphores in asyncio.md
Last active February 16, 2024 12:08
Asyncio semaphores in python

How to use semaphores in asyncio

A short example showing asyncio semaphores

import asyncio
import time
from random import random

async def my_coroutine(sem,task_id):
@gnzsnz
gnzsnz / pca.py
Last active December 9, 2023 15:09
Principal Component Analysis in pure Numpy
# -*- coding: utf-8 -*-
"""
Created on Sun Jan 31 11:03:57 2013
@author: Sukhbinder
https://sukhbinder.wordpress.com/2022/08/21/principal-component-analysis-with-numpy/
"""
import numpy as np
@gnzsnz
gnzsnz / Main.py
Created December 8, 2023 21:32 — forked from Macfly/Main.py
Async server with socketio and Ib_insync
import math
import asyncio
import logging, sys
import sqlite3
from asyncio import sleep
from logging.handlers import TimedRotatingFileHandler
import aiohttp_cors
import aiosqlite
import socketio
@gnzsnz
gnzsnz / list.md
Created November 28, 2023 23:23 — forked from ih2502mk/list.md
Quantopian Lectures Saved
@gnzsnz
gnzsnz / SSH_Certificates.md
Last active August 21, 2023 12:36
SSH Certificates

SSH Certificates

Create CA

A certificate authority is a third party trusted by hosts and users to sign each other public certificates. So user would need it's pub key signed by the CA in order to access host. And host would need it's pub certificate signed by the CA for users to trust that it's the host they intend to connect.

Host CA

Generate a host certificate authority

@gnzsnz
gnzsnz / git_aliases.md
Created October 13, 2022 11:42
Git alias

List of git aliases

Simple log

git config --global alias.slog "log --graph --all --topo-order --pretty='format:%h %ai %s%d (%an)'"

List git aliases

@gnzsnz
gnzsnz / list_linux_users.md
Created September 15, 2022 07:57
List linux users

List linux users

this will list non system users only

getent passwd | awk -F: '$3 >= 1000 && $3 <=60000 { print $1}'