Skip to content

Instantly share code, notes, and snippets.

View shimamura-sakura's full-sized avatar
🖥️
Coding…

lipsum shimamura-sakura

🖥️
Coding…
View GitHub Profile
@shimamura-sakura
shimamura-sakura / asar.py
Created April 8, 2026 03:15
simple electron/asar in python
#!/bin/env python3
from sys import argv
from typing import cast
from json import loads, dumps
from struct import unpack, pack
from os import makedirs, scandir
from os.path import join, split, sep
def efasar(inFile: str, filename: str):
@shimamura-sakura
shimamura-sakura / flate.zig
Created January 20, 2026 11:14
FLATE decompression in Zig
const std = @import("std");
const hclen_idxs = [_]u8{ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 };
const H30 = Huff(u8, 30);
const H288 = Huff(u16, 288);
const fixed = fixed: {
var hdist: H30 = undefined;
var hlitlen: H288 = undefined;
hdist.init(&(.{5} ** 30));
hlitlen.init(&(.{8} ** 144 ++ .{9} ** 112 ++ .{7} ** 24 ++ .{8} ** 8));
break :fixed .{ .hdist = hdist, .hlitlen = hlitlen };
@shimamura-sakura
shimamura-sakura / 0_reader.ts
Created August 30, 2025 14:44
an attempt to read unity's serialized files (CAB-xxx), for manosaba game. mainly a translation from python (UnityPy) to javascript.
type Endian = '<' | '>';
function safeNumber(v: bigint) {
const min = Number.MIN_SAFE_INTEGER;
const max = Number.MAX_SAFE_INTEGER;
if (v < min || v > max) throw new Error(`Number(${v})`); else return Number(v);
}
function many<T>(count: number, func: () => T) {
const a: T[] = [];
@shimamura-sakura
shimamura-sakura / README.txt
Last active April 15, 2025 13:31
jsflowers 2025 attempt 1 (save load)
1. 需要字体: Ume P Gothic, IPAmjMincho
2. 文件结构
game_ete/
bgimage/
bgm/ (所有BGM文件名改为全小写)
... 除script.iga外其他iga文件解压,每个一个文件夹
scripts.js 使用我的 flowerscript-js 反编译的脚本,组合成一个js: const game_script = { "脚本文件名.s": { 反编译结果 }, ... };
index_hiver.html
index.js (ts编译后)
3. 运行方法
@shimamura-sakura
shimamura-sakura / kaku.js
Last active June 25, 2024 03:00
Ohjelma romaaneiden lataamiseen kakuyomu:sta
'use strict';
module.exports = {
workNextData,
parseWorkHTML,
parseEpisodeHTML,
};
let lazy_JSDOM = null;
@shimamura-sakura
shimamura-sakura / box.zig
Created May 14, 2024 14:50
boxing a value in Zig
const std = @import("std");
const Allocator = std.mem.Allocator;
pub fn box(allocator: Allocator, value: anytype) !*@TypeOf(value) {
const ptr = try allocator.create(@TypeOf(value));
ptr.* = value;
return ptr;
}
test {
@shimamura-sakura
shimamura-sakura / struct-tuple-init.zig
Created April 20, 2024 16:17
Zig init struct with a tuple (so you can init it without writing field name)
const std = @import("std");
pub fn StructFieldsTuple(comptime T: type) type {
var info = switch (@typeInfo(T)) {
.Struct => |st| st,
else => @compileError("T must be a struct"),
};
var newFields = info.fields[0..info.fields.len].*;
inline for (&newFields, 0..) |*f, i| f.name = std.fmt.comptimePrint("{}", .{i});
info.decls = &.{};
@shimamura-sakura
shimamura-sakura / slice.zig
Last active February 6, 2024 08:52
A helper type for reading from memory files as a stream, referencing original memory.
fn Slice(comptime T: anytype) type {
return struct {
const Self = @This();
const Error = error{EOF};
left: T,
pub fn take(self: *Self, n: anytype) Error!@TypeOf(self.left[0..n]) {
if (self.left.len < n) return Error.EOF;
defer self.left = self.left[n..];
return self.left[0..n];
}
@shimamura-sakura
shimamura-sakura / goo-blog-copy.js
Created June 9, 2023 14:16
A javascript bookmark written for blog.goo.ne.jp blog articles
document.body.onclick = () => {
document.body.onclick = null;
navigator.clipboard.writeText(location.href + '\n\n' +
document.querySelector('article .mod-entry-set').innerText);
al = document.querySelectorAll('div.entry-bottom-pn>a');
if (al.length < 3) return alert('no next link');
window.location = al[2].href;
};
// bookmark this:
@shimamura-sakura
shimamura-sakura / libdeflate.zig
Created January 11, 2023 14:06
Read SMX file of SourceMod (SourcePawn) in Zig language. Decompress using libdeflate.
const c = @cImport(@cInclude("libdeflate.h"));
pub const Error = error{
LibDeflateAlloc,
LibDeflateBadData,
LibDeflateShortOutput,
LibDeflateInsufficientSpace,
LibDeflateOther,
};