Skip to content

Instantly share code, notes, and snippets.

View matu3ba's full-sized avatar

Jan Ph. H. matu3ba

View GitHub Profile
@matu3ba
matu3ba / usage.md
Created April 3, 2020 21:36
RWTH oppenconnect in shell usage

sudo openconnect -u timid --passwd-on-stdin --authgroup 'RWTH-VPN (Split Tunnel)' vpn.rwth-aachen.de

@matu3ba
matu3ba / cli_args_handling.zig
Created April 9, 2021 09:22
cli_args_handling
const std = @import("std");
const process = std.process;
const mem = std.mem;
const usage: []const u8 =
\\Usage: executable_name [options]
\\
\\ -h Print this help message and exit.
\\ -c <command> Run `sh -c <command>` on startup.
\\
@matu3ba
matu3ba / gist:6381175f3ce79df4638f8614fbae2e8e
Last active August 25, 2021 19:44
quickly_made_zig_structure.md
entry points: main.zig -> main() -> buildOutputType() -> Compilation.create()
Main steps how assembly is generated
1. lib/std/zig/tokenizer.zig -> Token (same file)
2. lib/std/zig/parse.zig -> AST (lib/std/zig/ast.zig)
3. src/AstGen.zig -> Zir (src/Zir.zig)
4. src/Sema.zig -> Air (src/Air.zig)
5. src/codegen.zig -> LLVM/C backend/etc
Future plan
@matu3ba
matu3ba / red_ftstring.c
Created August 31, 2021 12:41
reduced red_ftstring.c from freetype-demo
/****************************************************************************/
/* */
/* The FreeType project -- a free and portable quality TrueType renderer. */
/* */
/* Copyright (C) 1996-2021 by */
/* D. Turner, R.Wilhelm, and W. Lemberg */
/* */
/* */
/* ftstring.c - simple text string display */
/* */
@matu3ba
matu3ba / gen_ctz.zig
Created September 2, 2021 21:02
helper program to cross check correctness of ctz with simpler algorithm
const std = @import("std");
const maxInt = std.math.maxInt;
const print = std.debug.print;
test "custom number system print ctz" {
//var in: u64 = 0;
var in: u32 = 256;
//var in: u64 = 256;
//var in: u128 = 256;
var x: @TypeOf(in) = 0;
@matu3ba
matu3ba / gen_ffs.zig
Last active September 3, 2021 09:09
helper program to cross check correctness of ffs with simpler algorithm
const std = @import("std");
const maxInt = std.math.maxInt;
const print = std.debug.print;
test "print ffs" {
//var in: u64 = 0;
//var in: u32 = 256;
//var in: u64 = 256;
var in: u128 = 256;
var x: @TypeOf(in) = 0;
@matu3ba
matu3ba / cmpLangSema.md
Last active September 8, 2021 19:02
comparing language semantics of systems programming languages

#comparison

This in an article about what I think what different C-family languages can be semantically distinguished in how they approach programming and what the effects on the most important categories in system programming (highest performance and reliability demands) are.

Nongoal: Looking into language philosophies and origins for design decisions, because they are very deep rabbit holes (even for single languages).

@matu3ba
matu3ba / bash_simple_backup.sh
Created September 7, 2021 21:57
simple backup
#!/bin/bash
#quick backup script to mess with nvim config
## backup all files except those defined in ExcludeArray
## NOTE: files in list will not be touched
## other (newly created/renamed) files are deleted before restoring
#safer defaults https://bertvv.github.io/cheat-sheets/Bash.html
set -o errexit # abort on nonzero exitstatus
set -o nounset # abort on unbound variable
@matu3ba
matu3ba / bash_advanced_backup.sh
Created September 7, 2021 21:59
advanced backup
#!/usr/bin/env bash
#quick backup script to mess with nvim config
## backup all files except those defined in ExcludeArray
## files in ExcludeArray will not be touched
## all other files in nvim config are deleted before restoring
## USAGE: 1. in $NVIM_PATH: bash backup.sh
## 2. in $NVIM_PATH/$BACKUP_FOLDER: bash restore.sh
@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