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) \ |
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 | |
| import glob | |
| import os | |
| import shutil | |
| import subprocess | |
| import sys | |
| import rarfile |
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
| """ | |
| NamedStruct, a combinationof struct and namedtuple in python, make code more readable. | |
| You can access the fields by name rather than index. | |
| """ | |
| from __future__ import print_function | |
| import struct | |
| from collections import namedtuple |
NewerOlder