Skip to content

Instantly share code, notes, and snippets.

View Egor3f's full-sized avatar

Egor Egor3f

View GitHub Profile
@Egor3f
Egor3f / makecert.sh
Last active November 18, 2024 09:52
Create custom root CA and certificates for your local services. Easy to use interactive wrapper over openssl. Works in all modern browsers, supports domains and IP's. Usage: bash <(curl -s makecert.sh)
#!/usr/bin/env bash
ROOTCERT=root.crt
ROOTKEY=root.key
ROOTDAYS=2000
CERTDAYS=500
if [[ ! -f $ROOTKEY ]]; then
read -e -p "Root CA Organization name: " -i "PersonalRootCA" rootorgname
openssl genrsa -out $ROOTKEY 4096 &&
@Egor3f
Egor3f / mysql_split.py
Created December 15, 2019 07:15
Split mysql dump to multiple files by database (python3)
import sys, re
fileName = sys.argv[1]
with open(fileName, 'r', encoding='utf-8') as f:
firstSection = ''
currentFile = None
for line in f:
if line.startswith('CREATE DATABASE'):
if currentFile:
currentFile.close()
@twolfson
twolfson / README.md
Created February 5, 2015 21:22
Toggling between `alembic` databases

alembic is great but lacks an out of the box way to set up running migrations against a specific database (e.g. development, test, production). The following adjustments to its env.py and alembic.ini allow us to target a specific database:

Example:

alembic -x db=development upgrade head

env.py:

@jboner
jboner / latency.txt
Last active March 12, 2025 11:18
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@schlamar
schlamar / processify.py
Last active March 12, 2025 19:37
processify
import os
import sys
import traceback
from functools import wraps
from multiprocessing import Process, Queue
def processify(func):
'''Decorator to run a function as a process.
Be sure that every argument and the return value