Skip to content

Instantly share code, notes, and snippets.

@trim21
trim21 / matlab_fread_in_python.py
Created September 18, 2023 12:02
matlab `fread` in python with numpy
from typing import Union, BinaryIO
import numpy as np
from binary_reader import BinaryReader
def f_read(reader: Union[BinaryIO, BinaryReader], shape, dtype):
"""
``fread`` method in matlab
@trim21
trim21 / callback.ts
Created April 12, 2023 07:39
typescript callback/promise style async function
type Callback<T = any> = (err?: unknown, result?: T) => void
export async function returnSomething(): Promise<number>;
export function returnSomething(callback: Callback<number>): void;
export function returnSomething(callback?: Callback<number>): void | Promise<number> {
return asCallback<number>(asyncCall(), callback)
}
@trim21
trim21 / var_dump_parser.py
Last active June 15, 2022 22:43
python parse php var_dump
"""
parse a PHP `var_dump` string to a python dict
Copy Right 2021 Trim21<[email protected]>
Licensed under MIT License
https://spdx.org/licenses/MIT.html
"""
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
SetTitleMatchMode, 2
SetTitleMatchMode, Fast ;可以使用正则表达式对标题进行匹配
GroupAdd, NonMDApp, ahk_exe pycharm64.exe
GroupAdd, NonMDApp, ahk_exe Code.exe