Skip to content

Instantly share code, notes, and snippets.

Avatar

matu3ba

  • Aachen
View GitHub Profile
@matu3ba
matu3ba / POSIXunsafe.txt
Created Sep 10, 2021
Incomplete list of safety shortcomings in POSIX shell
View POSIXunsafe.txt
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
View bash_advanced_backup.sh
#!/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
View bash_simple_backup.sh
#!/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 / cmpLangSema.md
Last active Sep 8, 2021
comparing language semantics of systems programming languages
View cmpLangSema.md

#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 / gen_ffs.zig
Last active Sep 3, 2021
helper program to cross check correctness of ffs with simpler algorithm
View gen_ffs.zig
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 / gen_ctz.zig
Created Sep 2, 2021
helper program to cross check correctness of ctz with simpler algorithm
View gen_ctz.zig
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 / red_ftstring.c
Created Aug 31, 2021
reduced red_ftstring.c from freetype-demo
View red_ftstring.c
/****************************************************************************/
/* */
/* 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 / gist:6381175f3ce79df4638f8614fbae2e8e
Last active Aug 25, 2021
quickly_made_zig_structure.md
View gist:6381175f3ce79df4638f8614fbae2e8e
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
View cli_args_handling.zig
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 / usage.md
Created Apr 3, 2020
RWTH oppenconnect in shell usage
View usage.md

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