Skip to content

Instantly share code, notes, and snippets.

View insolor's full-sized avatar

insolor insolor

View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@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
@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 / 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 / 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 / test.md
Last active January 20, 2025 07:49
Note/Important/warning in github markdown

Note

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

Tip

Optional information to help a user be more successful.

Important

Crucial information necessary for users to succeed.

[!WARNING]

@insolor
insolor / gettext_mo_little_endian.hexpat
Last active April 27, 2025 18:06
Gettext MO ImHex pattern (little endian)
import std.sys;
struct StringTableEntry {
u32 length;
char *offset[this.length] : u32;
str string = this.offset [[export]];
};
struct MOHeader {
char magic[4];