Skip to content

Instantly share code, notes, and snippets.

@gnzsnz
gnzsnz / ib_async.py
Last active July 29, 2024 09:06 — 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 / 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 / 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):

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 / 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
@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 / coding_standard.py
Created September 17, 2024 20:00 — forked from nateGeorge/coding_standard.py
coding standards, originally from enthought
# taken from here: http://web.archive.org/web/20110527163743/https://svn.enthought.com/enthought/browser/sandbox/docs/coding_standard.py
""" This module is an example of the Enthought Python coding standards.
It was adapted from the Python Enhancement Proposal 8 (aka PEP 8) titled
'Style Guide for Python Code' (http://www.python.org/peps/pep-0008.html).
The first item in a module must be a documentation string (docstring). The
first line of the docstring should be a one line summary. If a more
detailed description is required, put an empty line before it.
@gnzsnz
gnzsnz / lz4_bench.ipynb
Created March 11, 2025 12:25
Xopen lz4 benchmark
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.