Skip to content

Instantly share code, notes, and snippets.

View ice1x's full-sized avatar

ice1x ice1x

  • Estonia
View GitHub Profile
@nekufa
nekufa / env.py
Created September 4, 2023 12:15
import re
from inspect import getmembers, isclass
from os import path
from posixpath import abspath
from schemas import settings
base = settings.BaseSettings.schema()
info = ''
toc = ''
@hellovertex
hellovertex / consumer_db.py
Created April 26, 2021 15:00
Faust App that redirects websocket traffic via Kafka topic
"""
1. Launch Kafka:
- $KAFKA_HOME/bin/zookeeper-server-start.sh $KAFKA_HOME/config/zookeeper.properties
- $KAFKA_HOME/bin/kafka-server-start.sh $KAFKA_HOME/config/server.properties
run via faust -A <filename> worker -l info
2. Faust library:
faust.App.agent: - main processing actor in Faust App
"""
@dmmeteo
dmmeteo / 1.srp.py
Last active May 24, 2024 07:29
SOLID Principles explained in Python with examples.
"""
Single Responsibility Principle
“…You had one job” — Loki to Skurge in Thor: Ragnarok
A class should have only one job.
If a class has more than one responsibility, it becomes coupled.
A change to one responsibility results to modification of the other responsibility.
"""
class Animal:
def __init__(self, name: str):
@claymcleod
claymcleod / pycurses.py
Last active May 18, 2024 09:55
Python curses example
import sys,os
import curses
def draw_menu(stdscr):
k = 0
cursor_x = 0
cursor_y = 0
# Clear and refresh the screen for a blank canvas
stdscr.clear()
@ygotthilf
ygotthilf / jwtRS256.sh
Last active May 23, 2024 07:42
How to generate JWT RS256 key
ssh-keygen -t rsa -b 4096 -m PEM -f jwtRS256.key
# Don't add passphrase
openssl rsa -in jwtRS256.key -pubout -outform PEM -out jwtRS256.key.pub
cat jwtRS256.key
cat jwtRS256.key.pub
@jefftriplett
jefftriplett / tor.py
Last active May 22, 2023 09:10
Python Requests + Tor (Socks5)
"""
setup:
pip install requests
pip install requests[socks]
super helpful:
- http://packetforger.wordpress.com/2013/08/27/pythons-requests-module-with-socks-support-requesocks/
- http://docs.python-requests.org/en/master/user/advanced/#proxies
"""