Code Snippets

Termination status of last executed program

$ echo $?

What is the overhead of Rust’s Option type?

use std::mem::size_of;

macro_rules! show_size {
    (header) => (
        println!("{:<22} {:>4}    {}", "Type", "T", "Option<T>");
    );
    ($t:ty) => (
        println!("{:<22} {:4} {:4}", stringify!($t), size_of::<$t>(), size_of::<Option<$t>>())
    )
}

fn main() {
    show_size!(header);
    show_size!(i32);
    show_size!(&i32);
    show_size!(Box<i32>);
    show_size!(&[i32]);
    show_size!(Vec<i32>);
    show_size!(Result<(), Box<i32>>);
}

source:

Git

Rename a branch

$ git checkout old-name
$ git branch -m new-name

Git clone specific tag

$ git clone --depth 1 --branch <tag_name> <repo_url>

Git download a specific tag

$ git checkout tags/<tag_name>

Git log pretty branches

git log --all --decorate --oneline --graph

Creating packages in Dart/Flutter

$  dart create -t package <PACKAGE_NAME>

Adjust volume with amixer

$ amixer -D pulse sset Master 100%

AVI to MP4

#!/bin/bash

for i in *.avi;
    do ffmpeg -i "$i" -c:v libx264 -preset ultrafast "$(basename  "$i" .avi)".mp4;
done

Download website recursively

wget -r <web address>

⧉ kwatafana | email: kwatafana (at) protonmail (dot) com

updated: 2022-12-31 14:16:41.569476892 UTC