Skip to content

Instantly share code, notes, and snippets.

@linzj
linzj / serve.sh
Created January 22, 2025 23:45
create a https serve
#!/bin/bash
# Generate SSL certificates if they don't exist
if [ ! -f key.pem ] || [ ! -f cert.pem ]; then
openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodes -subj "/CN=localhost" >/dev/null 2>&1
fi
# Start HTTPS server
http-server -S -C cert.pem -K key.pem -p 8080
@linzj
linzj / expand.js
Created November 23, 2024 03:23
Expand the overflow-hidden content to allow the inspector to capture it as an image.
function expand(node) {
// Modify styles to ensure the content is fully visible
node.style.overflow = "visible"; // Remove any clipping
node.style.maxHeight = "none"; // Remove height constraints
node.style.height = "auto"; // Let it expand fully
node.style.maxWidth = "none"; // Remove width constraints
node.style.width = "auto"; // Adjust the width
// Optional: If the node has child elements with hidden content
node.querySelectorAll("*").forEach((child) => {
@linzj
linzj / flutterappgetnativewindow.cpp
Created August 16, 2024 01:12
flutter app get native window
flutter::PluginRegistrarWindows* registrar =
flutter::PluginRegistrarManager::GetInstance()
->GetRegistrar<flutter::PluginRegistrarWindows>(plugin_registrar_ref);
auto native_window = registrar->GetView()->GetNativeWindow();
@linzj
linzj / .bashrc
Created July 9, 2024 23:53
bashrc example
# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth
# append to the history file, don't overwrite it
shopt -s histappend
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=10000000
HISTFILESIZE=20000000
@linzj
linzj / llvm-objdump.patch
Created January 11, 2024 23:57
patch llvm objdump so that -D will emit full code not data
diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp
index 9979a26cf115..1b0fd9414088 100644
--- a/llvm/tools/llvm-objdump/llvm-objdump.cpp
+++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp
@@ -1754,7 +1754,7 @@ static void disassembleObject(const Target *TheTarget, ObjectFile &Obj,
// denoted as a word/short etc.
if (!MappingSymbols.empty()) {
char Kind = getMappingSymbolKind(MappingSymbols, Index);
- DumpARMELFData = Kind == 'd';
+ DumpARMELFData = !DisassembleAll && Kind == 'd';
@linzj
linzj / testindirectbranch.cc
Last active January 8, 2024 23:21
Test Indirect Branch performance
#include <time.h>
#include <ctime>
#include <iostream>
#include <vector>
#ifdef _WIN32
#include <Windows.h>
#endif
class HighResolutionTimer {
@linzj
linzj / pdburl.py
Created January 13, 2023 00:05 — forked from Barakat/pdburl.py
Locating PDB file URL in Microsoft Symbol Server
#!python3
import pefile
SYMBOLS_SERVER = 'https://msdl.microsoft.com/download/symbols'
def main():
pe = pefile.PE('C:/Windows/System32/kernel32.dll', fast_load=True)
pe.parse_data_directories()
for directory in pe.DIRECTORY_ENTRY_DEBUG:
@linzj
linzj / extract.js
Created June 12, 2021 00:00
Calculate the case: if you have m ball in the box, what is the probability that you fetch n times and all the balls are fetch at least once.
function extract(n, m) {
let results = [];
n = BigInt(n);
m = BigInt(m)
function factorial(n) {
let result = 1n;
for (let i = 2n; i <= n; ++i)
result *= i;
return result;
@linzj
linzj / test_bits.c
Created November 10, 2020 07:51
test non zero bits
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
int main(int argc, char** argv) {
unsigned long long n = strtoull(argv[1], NULL, 0);
while (n != 0) {
int where = __builtin_ctzll(n);
printf("%d bit set.\n", where);
n &= ~(1ULL << where);
@linzj
linzj / test-arm64-cache.cc
Created July 22, 2020 07:32
Test arm64's cache
#include <errno.h>
#include <fcntl.h>
#include <linux/fcntl.h>
#include <linux/ioctl.h>
#include <linux/types.h>
#include <linux/unistd.h>
#include <stdio.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/stat.h>