Skip to content

Instantly share code, notes, and snippets.

View MikuAuahDark's full-sized avatar

Miku AuahDark MikuAuahDark

View GitHub Profile
@MikuAuahDark
MikuAuahDark / README.md
Last active March 10, 2024 17:59
1 Billion Row Challenge in Lua 5.1/LuaJIT

To run:

  1. Generate measurement.txt as per in the original repo instructions.
  2. Set the environment variable MEASUREMENT_FILE to the path of the measurement.txt.
  3. Run the script without arguments (luajit calculate_measurement.lua).

For Lua 5.1, you need to patch calls to ftell and fseek to use the 64-bit counterparts (e.g. _ftelli64 and _fseeki64 respectively for MSVC) as it can't handle file larger than 2GB. The exact modification for MSVC compiler are as follows:

diff --git a/src/liolib.c b/src/liolib.c
index 649f9a5..d1768cb 100644
--- a/src/liolib.c
@MikuAuahDark
MikuAuahDark / .lua
Created December 17, 2018 12:07
32-bit unsigned integer multiplication in Lua
function dwordMultiply(a, b)
a = a % 4294967296
b = b % 4294967296
local ah, al = math.floor(a / 65536), a % 65536
local bh, bl = math.floor(b / 65536), b % 65536
local high = ((ah * bl) + (al * bh)) % 65536
return ((high * 65536) + (al * bl)) % 4294967296
end
@MikuAuahDark
MikuAuahDark / README.md
Last active October 11, 2023 04:29
Python Script to Help Embedding Source Indexing Data to PDB

This is a simple Python script to help embedding source indexing information to PDBs using HTTP source server provider.

If you're looking to source-index your PDB and you're using GitHub, then this is perfect. If you need more information on how it works, take a look at Baldur Karlsson's writings for GitHub source indexing and Bruce Dawson's blogpost about source indexing in general.

To use this script, you need to specify a source-URL mapping which can be specified with --source. For example, if your project is hosted at https://github.com/love2d/love and you're building for commit 4b825dc642cb6eb9a060e54bf8d69288fbee4904, then the URL to access the source file can be re-constructed as https://raw.githubusercontent.com/love2d/love/4b825dc642cb6eb9a060e54bf8d69288fbee4904.

@MikuAuahDark
MikuAuahDark / STEPS.md
Last active July 30, 2023 13:09
Multiple Account Setup for Genshin Impact

Multi Account

Genshin Impact multi account in PC is bit annoying because you need to logout then login back. There are 2 ways to switch between account instantly and both requires the game not running.

Registry

Path: HKCU\SOFTWARE\miHoYo\Genshin Impact

@MikuAuahDark
MikuAuahDark / koikatu_check.cpp
Last active January 23, 2023 05:53
Rust code to check if PNG is KoiKatuChara or KoiKatuClothes
// Code to check whetever PNG image is normal PNG image or it also contain
// Koikatu data like character or clothes.
// Copyright (c) 2023 Miku AuahDark
// You can use portion of this code or as a whole without my permission.
// clang++ -std=c++17 -D_CRT_SECURE_NO_WARNINGS koikatu_check.cpp
#include <cerrno>
#include <cstdio>
@MikuAuahDark
MikuAuahDark / cp2seq.lua
Last active December 27, 2022 03:58
[Lua] Unicode code point to UTF-8 sequence
---@param code integer
function cp2seq(code)
if code <= 0x7F then
-- 0xxxxxxx
return string.char(code)
elseif code <= 0x7FF then
-- 110xxxxx 10xxxxxx
return string.char(
0xC0 + math.floor(code / 0x40),
0x80 + code % 0x40)
@MikuAuahDark
MikuAuahDark / main.lua
Created December 10, 2022 01:40
NAniTe Demo
local love = require("love")
local nanite = require("nanite")
local FOUR_DIAG_LEN = 96
local DIST_4_LETTER = FOUR_DIAG_LEN * 2 / math.sqrt(3)
local RAD = math.pi / 180
local NPadLogoData = {
timer = nil, ralewayBlack = nil, baked = nil, fontHeight = 0,
x1 = 0, x2 = 0, r = 0, fade = 1,
@MikuAuahDark
MikuAuahDark / inspect.cpp
Created November 18, 2022 12:58
Lua Stack Inspector with Relative Indices
extern "C"
{
#include <lua.h>
#include <lauxlib.h>
}
#include <cstdio>
#include <sstream>
static std::string luax_checkstring(lua_State *L, int i)
{
@MikuAuahDark
MikuAuahDark / runsilent.c
Last active November 16, 2022 16:45
Run Windows Console Program Without Console
/* clang -Wl,/subsystem:windows -Wl,/entry:mainCRTStartup -D_CRT_SECURE_NO_WARNINGS runsilent.c -luser32 -o runsilent.exe */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
/*
@MikuAuahDark
MikuAuahDark / README.md
Created November 16, 2022 16:35
How to Run WSL on Logon

Run WSL on Logon

  1. Compile runsilent.c in Windows
  2. Compile dummy.c in Linux
  3. Import the task with schtasks in Windows, modify the path as needed before importing.

Notes

  • When you shutdown the WSL (with wsl --shutdown), to start it again in background, run schtasks /run /tn:wslon. No administrator privileges is required.