Skip to content

Instantly share code, notes, and snippets.

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

Eugene Shershen h0rn3t

🏠
Working from home
View GitHub Profile
@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.
import asyncpg
import ujson
class Transaction:
def __init__(self, pool):
self.pool = pool
async def __aenter__(self):
self.acquire_context = self.pool.acquire()
@h0rn3t
h0rn3t / app.py
Created July 19, 2021 21:11 — forked from tombulled/app.py
Stream a file, in this case an mp4 video, supporting range-requests using starlette
from starlette.applications import Starlette
from starlette.responses import StreamingResponse
from starlette.requests import Request
from starlette.routing import Route
from pathlib import Path
from typing import IO, Generator
"""
Stream a file, in this case an mp4 video, supporting range-requests using starlette
@h0rn3t
h0rn3t / del_key.py
Created April 8, 2021 12:58 — forked from velykanov/del_key.py
Delete key from nested dictionary
def delete(key, dict_obj):
"""Deletes element from dict_obj accessing by complex key
Args:
key (str): Complex key to your value (separated by dots)
dict_obj (dict): Your dictionary
Raises:
KeyError: if object doesn't contain key

async in Python3

History

  1. generators found in Python 3.3
  2. event loop in the form of asyncio: In Python 3.4, the asyncio.coroutine decorator was used to label a function as acting as a coroutine that was meant for use with asyncio and its event loop.
  3. yield from to await in Python 3.5

Event loop and task

@h0rn3t
h0rn3t / audit_mixin.py
Created March 19, 2021 13:41 — forked from techniq/audit_mixin.py
Useful SQLAlchemy Mixins
from datetime import datetime
from sqlalchemy import Column, Integer, DateTime, ForeignKey
from sqlalchemy.orm import relationship
from sqlalchemy.ext.declarative import declared_attr
from flask_security import current_user
class AuditMixin(object):
created_at = Column(DateTime, default=datetime.now)
updated_at = Column(DateTime, default=datetime.now, onupdate=datetime.now)
@h0rn3t
h0rn3t / asyncio_plus_greenlet.py
Created March 14, 2021 17:56 — forked from zzzeek/asyncio_plus_greenlet.py
An asyncio program that runs rows into a Postgresql database, using blocking style code to actually run the database commands
"""This program is exactly the same as that of
https://gist.github.com/zzzeek/33943060f7a08cf9e82bf8df1f0f75de ,
with the exception that the add_and_select_data function is written in
synchronous style.
UPDATED!! now includes refinements by @snaury and @Caselit . SIMPLER
AND FASTER!!
@h0rn3t
h0rn3t / annotators.csv
Created March 1, 2021 11:04 — forked from vkocaman/annotators.csv
list of annotators offered by Spark NLP
We can make this file beautiful and searchable if this error is corrected: It looks like row 10 should actually have 5 columns, instead of 3 in line 9.
Annotator,Description,Version,Annotator Approach,Annotator Model
Tokenizer*,Identifies tokens with tokenization open standards,Opensource,-,+
Normalizer*,Removes all dirty characters from text,Opensource,-,+
Stemmer*,Returns hard'-stems out of words with the objective of retrieving the meaningful part of the word,Opensource,+,-
Lemmatizer*,Retrieves lemmas out of words with the objective of returning a base dictionary word,Opensource,-,+
RegexMatcher*,Uses a reference file to match a set of regular expressions and put them inside a provided key.,Opensource,+,+
TextMatcher*,Annotator to match entire phrases (by token) provided in a file against a Document,Opensource,+,+
Chunker*,Matches a pattern of part'-of'-speech tags in order to return meaningful phrases from document,Opensource,+,-
DateMatcher*,Reads from different forms of date and time expressions and converts them to a provided date format,Opensource,+,-
SentenceDetector*,Finds sentence bounds in raw text. Applies rules from Pragmatic Segmenter,Opensou
@h0rn3t
h0rn3t / install-kubernetes-flannel-centos7.md
Created January 10, 2021 14:55 — forked from rkaramandi/install-kubernetes-flannel-centos7.md
Installing Kubernetes with the Flannel Network Plugin on CentOS 7

Install Prerequisites on ALL (Worker and Master) Nodes

Let's remove any old versions of Docker if they exist:

sudo yum remove docker \
                  docker-common \
                  docker-selinux \
                  docker-engine
@h0rn3t
h0rn3t / test.service
Created December 23, 2020 12:19 — forked from circa10a/test.service
A Simple Systemd Service
#/etc/systemd/system/test.service
[Unit]
Description=Test Systemd Service
[Service]
ExecStartPre=/usr/bin/echo -e "\033[0;33m Pre start \033[0m"
ExecStart=/usr/bin/sleep 10
ExecStartPost=/usr/bin/echo -e "\033[0;33m Post start \033[0m"