Skip to content

Instantly share code, notes, and snippets.

View kotatsuyaki's full-sized avatar

Ming-Long Huang kotatsuyaki

View GitHub Profile
@kotatsuyaki
kotatsuyaki / vlang.nix
Created November 7, 2021 06:13
Dirty nix derivation for vlang
{ pkgs, lib, stdenv, fetchFromGitHub, glfw, freetype, openssl, makeWrapper, upx, git, strace, binutils-unwrapped, libGL, boehmgc, sqlite, libexecinfo, xorg, valgrind }:
stdenv.mkDerivation rec {
pname = "vlangg";
version = "weekly.2021.44";
src = fetchFromGitHub {
owner = "vlang";
repo = "v";
rev = version;
@kotatsuyaki
kotatsuyaki / logcat.txt
Created November 28, 2021 07:35
waydroid logcat output
--------- beginning of main
11-28 07:27:10.056 16 16 I SELinux : SELinux: Loaded service_contexts from:
11-28 07:27:10.056 16 16 I SELinux : /vendor/etc/selinux/vndservice_contexts
11-28 07:27:10.056 14 14 I SELinux : SELinux: Loaded service_contexts from:
11-28 07:27:10.056 14 14 I SELinux : /system/etc/selinux/plat_service_contexts
11-28 07:27:10.059 15 15 I hwservicemanager: hwservicemanager is ready now.
11-28 07:25:25.181 13 13 W auditd : type=2000 audit(0.0:1): state=initialized audit_enabled=0 res=1
11-28 07:25:26.796 1 1 W systemd : type=1130 audit(0.0:2): uid=0 auid=4294967295 ses=4294967295 subj=kernel msg='unit=systemd-remount-fs exe="/nix/store/q0881awy50g4srnnwasci37y2jk5sf99-systemd-249.5/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
11-28 07:25:26.798 13 13 W auditd : type=1334 audit(0.0:3): prog-id=48 op=LOAD
11-28 07:25:26.798 13 13 W auditd : type=1334 audit(0.0:4): prog-id=49 op=LOAD
@kotatsuyaki
kotatsuyaki / flake.nix
Created March 27, 2022 06:42
Nix flake for devshell with chkservice (https://github.com/linuxenko/chkservice)
{
description = "chkservice devshell";
outputs = { self, nixpkgs }:
let
pkgs = nixpkgs.legacyPackages.x86_64-linux;
chkservice = pkgs.stdenv.mkDerivation {
name = "chkservice";
src = pkgs.fetchFromGitHub {
owner = "linuxenko";
@kotatsuyaki
kotatsuyaki / notes.md
Last active April 13, 2022 05:52
LXC environment setup for live migration assignment

Launching host containers

lxc launch image:alpine:3.15 host1
lxc launch image:alpine:3.15 host2

Essential packages in alpine

  • qemu-system-x86_64
@kotatsuyaki
kotatsuyaki / patchelf-package-use.nix
Created April 25, 2022 02:16
Package Ubuntu binary in Nix with autoPatchelfHook
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-21.11";
utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, utils }:
utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
@kotatsuyaki
kotatsuyaki / Makefile
Created May 26, 2022 02:55
Using C++ modules with GCC 12
.POSIX:
CXX = g++
CXXFLAGS = -std=c++20 -fmodules-ts
main: gcm.cache main.cpp
$(CXX) $(CXXFLAGS) main.cpp -o main
gcm.cache:
$(CXX) $(CXXFLAGS) -c -x c++-system-header iostream
@kotatsuyaki
kotatsuyaki / Cargo.toml
Last active May 30, 2022 13:10
Experiments for "How to wrap Sqlx data access types retaining transaction support?"
[package]
name = "sqlx-wrapper-question"
version = "0.1.0"
edition = "2021"
[dependencies]
sqlx = { version = "0.5", features = [ "runtime-tokio-rustls", "sqlite" ] }
async-trait = "0.1"
tokio = { version = "1", features = [ "rt", "macros" ] }
@kotatsuyaki
kotatsuyaki / silk.py
Created June 13, 2022 02:29
Plotting program for ICCAD 2022 problem E (TW)
import sys
from typing import Literal, Union
from matplotlib import axes, pyplot as plt
from matplotlib import collections as mc
import numpy as np
import math
infile = open(sys.argv[1])
outfile = open(sys.argv[2])
@kotatsuyaki
kotatsuyaki / main.rs
Created July 15, 2022 14:58
Use lopdf to add bookmarks to PDF file in Rust
use lopdf::{Bookmark, Document, Object};
fn main() {
let mut doc = Document::load("input.pdf").unwrap();
let pages = doc.get_pages();
let page_3_obj = pages.get(&3).unwrap().clone();
let _bm = doc.add_bookmark(
Bookmark::new("Test Bookmark Title".into(), [0., 0., 1.], 0, page_3_obj),
None,
@kotatsuyaki
kotatsuyaki / README.md
Created August 29, 2022 16:19
Mount VMware `vmdk` image on Linux

Tl;dr run this command to mount the second partition on fedora.vmdk to the mountpoint ./mnt.

guestmount -a fedora.vmdk -m /dev/sda2 --ro ./mnt

guestmount is part of libguestfs. In nixpkgs, use libguestfs-with-appliance instead of libguestfs, since the latter produces the following error. See NixOS/nixpkgs#37540 for details.