Skip to content

Instantly share code, notes, and snippets.

View insolor's full-sized avatar

insolor insolor

View GitHub Profile
@insolor
insolor / test.md
Last active March 18, 2024 09:25
Note/Important/warning in github markdown

Note

Highlights information that users should take into account, even when skimming.

Important

Crucial information necessary for users to succeed.

Warning

Critical content demanding immediate user attention due to potential risks.

Doesn't work anymore:

@insolor
insolor / trogon_typer_example.py
Created June 29, 2023 18:08
Using trogon with typer
"""
A basic example on how to use trogon (https://github.com/Textualize/trogon) with typer (https://github.com/tiangolo/typer)
Running:
> python trogon_typer_example.py tui
"""
import click
from trogon import tui
import typer
@insolor
insolor / docker-compose.yml
Last active August 30, 2022 19:01
Custom docker-compose.yml for fastapi-admin demo, which runs mysql and redis along with the fastapi-admin
version: "3"
services:
db:
image: mysql:latest
environment:
MYSQL_DATABASE: 'fastapi-admin'
MYSQL_ROOT_PASSWORD: '123456'
ports:
- '3306:3306'
volumes:
@insolor
insolor / names_to_lower.py
Last active December 14, 2020 06:46
Rename files and directories to lower case recursively depht-first in python
from pathlib import Path
# WARNING: Renaming is an irreversible operation, so it is better to use an absolute path
for path in sorted(Path('~/some_directory').rglob('*'), key=lambda p: len(p.parts), reverse=True):
# Rename and print new name
print(path.rename(path.with_name(path.name.lower())))
@insolor
insolor / set_parent.py
Last active November 17, 2021 14:04
Specify parent of a tkinter widget with a context manager
"""Specify parent of a tkinter widget
with a context manager"""
import tkinter as tk
from contextlib import contextmanager
@contextmanager
def set_parent(new_parent):
old_root = tk._default_root
tk._default_root = new_parent
@insolor
insolor / tinype.asm
Created June 13, 2019 06:33
Tiny PE
format binary as 'exe'
IMAGE_DOS_SIGNATURE equ 5A4Dh
IMAGE_NT_SIGNATURE equ 00004550h
PROCESSOR_AMD_X8664 equ 8664h
IMAGE_SCN_CNT_CODE equ 00000020h
IMAGE_SCN_MEM_READ equ 40000000h
IMAGE_SCN_MEM_WRITE equ 80000000h
IMAGE_SCN_CNT_INITIALIZED_DATA equ 00000040h
IMAGE_SUBSYSTEM_WINDOWS_GUI equ 2
IMAGE_NT_OPTIONAL_HDR64_MAGIC equ 20Bh
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.