Skip to content

Instantly share code, notes, and snippets.

View mnixry's full-sized avatar
😴
Sleeping

Mix mnixry

😴
Sleeping
View GitHub Profile
@mnixry
mnixry / printlog.c
Created November 4, 2025 04:32
Expose Wemeet Linux version internal logs
// Usage:
// gcc ./printlog.c -shared -o libwemeet_log_override.so -fPIC -Wall -Wextra
// export LD_PRELOAD=$(realpath ./libwemeet_log_override.so)
#include <execinfo.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
typedef struct {
const char *ptr;
@mnixry
mnixry / linux-cross-build-rust.nix
Created October 17, 2025 13:15
Nix snippet for cross build rust binaries to windows-gnu, linux-musl and apple-darwin.
{
lib,
pkgs,
crane,
zig_0_13,
cargo-zigbuild,
target,
rev,
}:
let
@mnixry
mnixry / replace_space_to_underscore.py
Created September 21, 2025 14:26
Replace space in string to underscore w/ x86_64 shellcode in Python.
import ctypes
import mmap
def replace_space_to_underscore(input_: str):
assert input_.isascii()
buf = ctypes.create_string_buffer(input_.encode())
shellcode = (
b"\x48\xbf"
+ ctypes.addressof(buf).to_bytes(8, "little")
@mnixry
mnixry / crontab-guru.ts
Created June 26, 2025 16:24
crontab.guru style cron syntax parser and generates explanation.
class CronTabParsingError extends Error {
static assert(condition: unknown, message: string): asserts condition {
if (!condition) {
throw new CronTabParsingError(message);
}
}
}
const ordinal = (n: number): string => {
if (n % 100 >= 11 && n % 100 <= 13) return `${n}th`;
import { cn } from "@/utils";
export const ProgressiveBlurBackground: React.FC<
React.ComponentProps<"div"> & {
orientation?: "top" | "bottom";
steps?: number;
blurTargetPx?: number;
}
> = ({
className,
@mnixry
mnixry / zon.py
Created May 24, 2025 17:45
A loose ZON (Zig Object Notation) parser in pure Python.
from typing import final
import parsy as p
whitespace = p.regex(r"\s*")
comment = p.regex(r"//.*")
def lexeme(parser: p.Parser):
return parser << (whitespace | comment)
@mnixry
mnixry / udpchk.py
Created May 23, 2025 14:14
Simple tool to test UDP support of SOCKS5 proxy.
# udpchk.py - simple tool to test UDP support of SOCKS5 proxy.
# Copyright (C) 2016-2017 Zhuofei Wang <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy
# of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
@mnixry
mnixry / loading-button.tsx
Last active April 28, 2025 00:33
Loading & Refresh Button component for Shadcn UI & Lucide Icons.
import { useCallback, useState } from 'react';
import { Loader2Icon } from 'lucide-react';
import { useInterval } from 'react-use';
import { cn } from '@/lib/utils';
import { Button } from '@/components/ui/button';
export const LoadingButtonPrimitive: React.FC<
React.ComponentPropsWithRef<typeof Button> & { loading?: boolean }
> = ({ loading, disabled, className, children, ...props }) => {
"""A module for serving static files with URL rewriting support.
Module Overview:
This module provides the RewrittenStaticFiles class, an extension of Starlette's StaticFiles that supports URL rewriting.
The class is designed to serve static files from a specified directory or packages and to apply rewrite rules in case a requested
file is not found (HTTP 404). Rewrite rules are defined as a dictionary where keys are patterns (either wildcard strings or compiled
regular expressions) and values are target paths. If a request initially results in a 404 error, the class will attempt to match
the path against the rewrite rules and serve the corresponding rewritten file if found.
Examples:
@mnixry
mnixry / unpack_ysm.py
Created October 13, 2024 04:00
Unpack YesSteveModel's proprietary format into zip format, for version < 1.2.0 only.
import hashlib
import zipfile
import zlib
from base64 import b64decode
from dataclasses import dataclass
from io import BytesIO
from pathlib import Path
from typing import IO, Literal, Optional
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes