Skip to content

Instantly share code, notes, and snippets.

View Saluev's full-sized avatar

Tigran Saluev Saluev

View GitHub Profile
@Saluev
Saluev / Dockerfile
Last active November 23, 2024 10:33
Dockerfile for Ubuntu-based Bioconda environment on Apple Silicon (M1/M2/M3/M4) architecture
FROM --platform=linux/amd64 ubuntu:24.10 AS bioinf
# --platform specification here is crucial because as of now,
# without specifying it Docker starts building for ARM
# by default, which leads to "rosetta: failed to open elf" errors.
RUN apt-get update && apt-get install -y less vim wget
# Install other utilities of your liking. Specifically, if git is needed:
# RUN apt-get install git && mkdir -p /root/.ssh && ssh-keyscan github.com >> /root/.ssh/known_hosts
# ssh-keyscan is invoked for git clone to work. Note that only GitHub will work now, change to required host.
@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 August 6, 2024 01:25
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)