Skip to content

Instantly share code, notes, and snippets.

View matu3ba's full-sized avatar

Jan Ph. H. matu3ba

View GitHub Profile
@matu3ba
matu3ba / acl_min.zig
Created January 24, 2024 22:18
Minimal ACL. but ugly.
// zig run acl_min.zig
pub const DWORD = c_ulong;
pub const HANDLE = ?*anyopaque;
pub const PVOID = ?*anyopaque;
pub const PSID = PVOID;
pub const PSECURITY_DESCRIPTOR = PVOID;
pub const enum__SE_OBJECT_TYPE = c_uint;
pub const SE_OBJECT_TYPE = enum__SE_OBJECT_TYPE;
pub const wchar_t = c_ushort;
pub const SE_FILE_OBJECT: c_int = 1;
@matu3ba
matu3ba / plan.txt
Last active December 17, 2023 20:13
plan to end distro hopping
1. nix + arcan
2. QubesOS for VMs.
3. EndeavourOS
4. Windows with minimal installer
5. MacOS no idea.
@matu3ba
matu3ba / question
Last active October 17, 2023 08:19
LLVM planned pointer semantics questions
Dear llvm folks, I have some questions on the status or plan for the LLVM memory model semantics regarding pointers and it would be nice, if you can give me pointers where to look for answers.
Context: "PNVI-ae-udi tracks (1) ambiguities in provenance and (2) provenance exposure whereas VIP
does not. On the other hand, (3) VIP tracks provenance in integers (in a limited way, for round-trip
casts) whereas PNVI-ae-udi does not, and (4) VIP relies on the copy_alloc_id primitive, which is
not available in PNVI-ae-udi.". https://iris-project.org/pdfs/2022-popl-vip.pdf
1. As far as understand, temporal (undereferenced) out of bounds pointers are also not forced to be UB in contrast to C. Is that correct and would the llvm model them to allow this use case?
2. From what I understand, the one past the end ambiguous provenance of pointers originates from pointer that were casted to integers losing their provenance. Is there some decision or discussion what llvm is doing or will do and/or if user annotation is planne
@matu3ba
matu3ba / .envrc
Last active October 15, 2023 23:19
arcan DRI driver not from this Mesa build: dont mix old + new drivers! TODO best solution
use_nix
@matu3ba
matu3ba / ANSI.md
Created September 1, 2023 22:06 — forked from fnky/ANSI.md
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27
@matu3ba
matu3ba / cloneall.sh
Created August 1, 2023 23:48
Download various non-mainstream Kernels for (rip)grepping.
#!/usr/bin/env sh
git clone --depth=1 https://github.com/DragonFlyBSD/DragonFlyBSD
git clone --depth=1 https://github.com/freebsd/freebsd-src
git clone --depth=1 https://fuchsia.googlesource.com/fuchsia
git clone --depth=1 https://github.com/haiku/haiku
git clone --depth=1 https://github.com/hermitcore/rusty-hermit
git clone --depth=1 https://github.com/Stichting-MINIX-Research-Foundation/minix/
git clone --depth=1 https://github.com/NetBSD/src
git clone --depth=1 https://github.com/openbsd/src
@matu3ba
matu3ba / POSIXunsafe.txt
Created September 10, 2021 09:14
Incomplete list of safety shortcomings in POSIX shell
Incomplete list of safety shortcomings in POSIX shell
NEVER leave your variables unquoted.
https://unix.stackexchange.com/questions/171346/security-implications-of-forgetting-to-quote-a-variable-in-bash-posix-shells
And variables with common prefixes without braces.
https://stackoverflow.com/questions/8748831/when-do-we-need-curly-braces-around-shell-variables
Always clean up your environment to prevent stack smashing.
https://github.com/netblue30/firejail/issues/3678
Better use `test [expression]` and dont dare to ask why
@matu3ba
matu3ba / readfile.zig
Created April 27, 2023 20:07
read file
fn openAndRead(alloc: std.mem.Allocator, in_file: []const u8) !void {
var f = std.fs.cwd().openFile(in_file, .{}) catch |err| {
fatal("unable to open file '{s}': {s}\n", .{ in_file, @errorName(err) });
};
defer f.close();
const stat = try f.stat();
if (stat.size > std.math.maxInt(u32))
return error.FileTooBig;
const source = try alloc.allocSentinel(u8, @intCast(usize, stat.size), 0);
errdefer alloc.free(source);
@matu3ba
matu3ba / gist:39d3624de1779584b5cfb2cbe0853513
Last active April 15, 2023 19:46
backtracking attempt for window view creation. Code would be ugly, so dont implement.
-- Simplified version only taking into account idenically sized splits
-- along a full rectangle:
-- Windows can be grouped by following the direction of window numbers.
-- 1. 2. 3.
-- 1 | 2 | | |1 |2 | | | 6 | 1 | 2 | 3 | 4|
-- ---|---| 5 | |-----| 4 | 5 |---- |--------------|
-- 3 | 4 | | | 3 | | | 7 | 5 |
-- 1. allowed, because even though 5 has no split, it has full height
-- 2. not allowed, because 3 has no vsplit
-- 4. not allowed, because splits in 1,2 are not identical in 3.
@matu3ba
matu3ba / thead_status.diff
Created April 13, 2023 22:46
Idea for zig thread status (macos implementation idea missing and other portable questions on freebsd etc)
diff --git a/lib/std/Thread.zig b/lib/std/Thread.zig
index 8004f94d7f..22996939a3 100644
--- a/lib/std/Thread.zig
+++ b/lib/std/Thread.zig
@@ -275,6 +275,14 @@ pub fn getCurrentId() Id {
return Impl.getCurrentId();
}
+pub fn getStatus() c_int {
+ // https://stackoverflow.com/questions/9577231/how-to-check-the-state-of-linux-threads