A tiny, dependency-free Python script to merge a Tencent Working (腾讯工蜂) merge request from the command line, since the web UI's "Merge" button has no first-class CLI counterpart.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| # -*- coding: utf-8 -*- | |
| """Replace full-width (CJK) punctuation with ASCII equivalents in Markdown. | |
| Intended for English Markdown documents that accidentally contain stray | |
| full-width punctuation copy-pasted from a Chinese source, without | |
| disturbing code blocks or inline code spans. | |
| Features | |
| -------- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import ( | |
| "reflect" | |
| "strings" | |
| "gopkg.in/yaml.v3" | |
| ) | |
| // StructToMap converts a struct to a map[string]any recursively. | |
| func StructToMap(s any, tagKey string) map[string]any { | |
| out := make(map[string]any) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import ctypes | |
| import struct | |
| import sys | |
| from ctypes import wintypes | |
| def cpuid(leaf: int, subleaf: int = 0) -> tuple[int, int, int, int]: | |
| # Define VirtualAlloc and VirtualFree | |
| kernel32 = ctypes.WinDLL('kernel32', use_last_error=True) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import glob | |
| import platform | |
| import subprocess | |
| def get_physical_cpu_cores(): | |
| plat = platform.system() | |
| if plat == 'Linux': | |
| return get_physical_cpu_cores_linux() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| sed -E -e "s/^(=>)?\s+0x[a-z0-9]+\s+//g" -e "s/(<\+[0-9]+>:\s+)(\w+\s+)0x[0-9a-f]+ </\1\2</g" "$@" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| extern const char * pWeakValue; | |
| static const char * pDefaultWeakValue = "nullptr"; | |
| // #pragma comment(linker, "/alternatename:_pWeakValue=_pDefaultWeakValue") | |
| #define DEFINE_WEAK(Type, Name) \ | |
| extern Type Name; \ | |
| static Type Name##Default; \ | |
| __pragma(warning(push)) \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #define DEFINE_WEAK_VARIABLE(Type, Name) \ | |
| extern "C" Type Name; \ | |
| extern "C" Type Name##Default; \ | |
| __pragma(comment(linker, "/alternatename:" #Name "=" #Name "Default")) \ | |
| extern "C" Type Name##Default \ | |
| #define DEFINE_WEAK_FUNCTION(Type, Name, Params) \ | |
| extern "C" Type Name Params; \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <string> | |
| #include <type_traits> | |
| // Primary template with a static assertion | |
| // for a meaningful error message | |
| // if it ever gets instantiated. | |
| // We could leave it undefined if we didn't care. | |
| #define DEFINE_HAS_METHOD(TraitsName, MethodName) \ |
NewerOlder