Skip to content

Instantly share code, notes, and snippets.

View h0rn3t's full-sized avatar
🏠
Working from home

Eugene h0rn3t

🏠
Working from home
  • Ukraine
View GitHub Profile
@h0rn3t
h0rn3t / uuid6.sql
Created August 21, 2023 13:35 — forked from fabiolimace/UUIDv6.sql
Functions for generating UUIDv6 and UUIDv7 on PostgreSQL
/*
* MIT License
*
* Copyright (c) 2023 Fabio Lima
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@h0rn3t
h0rn3t / 8710.py
Last active October 11, 2023 17:42 — forked from artemholovnia/8710.py
SYNC OPENSEARCH
python manage.py shell -c '
from django_redis import get_redis_connection
from datahub_core.datetime_utils import datetime_utcnow
from ms_tko.models import AccountingPoint
client = get_redis_connection("default")
counter = 0
chunk_size = 50000
import asyncio
import dataclasses
from asyncio import iscoroutine
from datetime import datetime
from typing import Union, Optional
from pydantic import BaseModel, Field, validator, validate_arguments, UUID4
import uuid
@h0rn3t
h0rn3t / bench_excel_writers.py
Created August 15, 2022 21:06 — forked from lbolla/bench_excel_writers.py
Benchmark of several Python Excel writing modules
##############################################################################
#
# Simple Python program to benchmark several Python Excel writing modules.
#
# python bench_excel_writers.py [num_rows] [num_cols]
#
#
import sys
import resource
@h0rn3t
h0rn3t / metrials-go.md
Created August 13, 2022 08:46 — forked from egorsmkv/metrials-go.md
Материалы по Go (golang): мануалы, статьи, книги и ссылки на сообщества

Материалы по Go (golang)

На русском языке

Мануалы и туториалы

  • [Введение в программирование на Go][1]
  • [Маленькая книга о Go][3]
  • [Эффективный Go][2]
  • Есть еще [Краткий пересказ Effective Go на русском языке][4], но 2009 года
@h0rn3t
h0rn3t / simple_tasks_queue.py
Created August 1, 2022 10:03 — forked from horodchukanton/simple_tasks_queue.py
FastAPI Background tasks queue
import logging
from concurrent.futures import ThreadPoolExecutor
from datetime import timedelta, datetime
from typing import Any, Dict
class SimpleStorageEntry:
_counter: int = 0
id: int
@h0rn3t
h0rn3t / get_event_loop vs get_running_loop.py
Created July 22, 2022 13:11 — forked from kaelzhang/get_event_loop vs get_running_loop.py
Show a demo the differences between Python `asyncio.get_event_loop()` and (vs) `asyncio.get_running_loop()`. And also explain the differences between `asyncio.run()` and `loop.run_until_complete()`
import asyncio
# Ref: https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.get_event_loop
# > If there is no current event loop set in the current OS thread,
# > the OS thread is main, and set_event_loop() has not yet been called,
# > asyncio will create a new event loop and set it as the current one
loop = asyncio.get_event_loop()
# So, loop2 is loop
loop2 = asyncio.get_event_loop()
@h0rn3t
h0rn3t / README.md
Created September 30, 2021 10:05 — forked from florimondmanca/README.md
HTTPX vs aiohttp (over HTTPS)

Usage

  • Generate TLS certificates for localhost:
pip install trustme-cli
trustme-cli
  • Run wrk on each endpoint, eg:
@h0rn3t
h0rn3t / async.py
Created September 18, 2021 20:46 — forked from phizaz/async.py
Python turn sync functions to async (and async to sync)
import functools
def force_async(fn):
'''
turns a sync function to async function using threads
'''
from concurrent.futures import ThreadPoolExecutor
import asyncio
pool = ThreadPoolExecutor()
@h0rn3t
h0rn3t / README.md
Created August 23, 2021 11:52 — forked from ascendbruce/README.md
Use mac style keyboard shortcuts on Windows with AutoHotkey (ahk) script

Use (most) macOS style keyboard shortcuts on Windows

Make Windows PC's shortcut act like macOS (Mac OS X)

With this AutoHotKey script, you can use most macOS style shortcuts (eg, cmd+c, cmd+v, ...) on Windows with a standard PC keyboard.

Note that:

  1. you shouldn't change the modifier keys mapping with keyboard DIP. This script assumes you use a standard PC keyboard layout, and wish to use shortcuts as if it was a mac keyboard layout.
  2. To use cmd + shift + ↑ / ↓ / ← / → (select text between cursor and top / bottom / beginning of line / end of line), You should disable the Between input languages shotcut from Control Panel\Clock, Language, and Region\Language\Advanced settings > Change lanugage bar hot keys due to conflicting.