Skip to content

Instantly share code, notes, and snippets.

View Saluev's full-sized avatar

Tigran Saluev Saluev

View GitHub Profile
@Saluev
Saluev / emoji.py
Created December 10, 2023 17:17
Emoji regular expression for Python
"""
Regular expressions for matching emoji sequences.
For parsing single emoji, use either
re.match(EMOJI_SEQUENCE, string)
# or
EMOJI_REGEXP.match(string)
To match multiple emojis or custom patterns, insert `EMOJI_SEQUENCE` into pattern:
@Saluev
Saluev / parse_tree_output.py
Created September 17, 2023 16:39
Unix `tree` command output parser
from dataclasses import dataclass
import sys
from typing import List, TextIO
@dataclass
class TreeNode:
name: str
children: List["TreeNode"]
@Saluev
Saluev / morse.py
Last active February 27, 2018 10:43
Morse code with Python unary + and - operators
# -*- coding: utf-8 -*-
morse_alphabet = {
"А" : ".-",
"Б" : "-...",
"В" : ".--",
"Г" : "--.",
"Д" : "-..",
"Е" : ".",
"Ж" : "...-",
@Saluev
Saluev / better_server.py
Created November 20, 2017 12:34
Extension to python-socketio server, allowing to await particular messages from clients
import asyncio
import socketio
class AsynchronousSocketServer(socketio.AsyncServer):
def __init__(self, *args, **kwargs):
kwargs["async_handlers"] = True
super().__init__(*args, **kwargs)