Skip to content

Instantly share code, notes, and snippets.

View unwave's full-sized avatar

Roman Markov unwave

View GitHub Profile
@KaoruNishikawa
KaoruNishikawa / diff.py
Last active January 2, 2025 02:31
Print Git-like diff of arbitrary 2 strings in Python
import difflib
def diff(a: str, b: str) -> None:
line_color = {"+": 32, "-": 31}
diffs = difflib.ndiff(a.splitlines(keepends=True), b.splitlines(keepends=True))
diff_list = list(diffs)
styled: list[str] = []
for prev, next in zip(diff_list, diff_list[1:] + [""]):
@inaz2
inaz2 / enumwindows.py
Last active June 16, 2024 11:13
EnumWindows + GetWindowText by Python ctypes (Cygwin)
from ctypes import *
EnumWindows = cdll.user32.EnumWindows
EnumWindowsProc = CFUNCTYPE(c_bool, POINTER(c_int), POINTER(c_int))
GetWindowText = cdll.user32.GetWindowTextW
GetWindowTextLength = cdll.user32.GetWindowTextLengthW
IsWindowVisible = cdll.user32.IsWindowVisible
def enum_func(hwnd, lParam):
if IsWindowVisible(hwnd):