This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override BIN := test | |
override SRC := test.c msg.c | |
override OBJ := $(SRC:%=%.o) | |
override DEP := $(SRC:%=%.d) | |
CFLAGS := -O2 -march=native -mtune=native -flto | |
$(BIN): $(OBJ) | |
$(CC) $(CFLAGS) -o $@ $^ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <errno.h> | |
#include <stdio.h> | |
// We want a function that creates a couple files. Here's the naive approach: | |
int hardcoded_cleanup(const char *path1, const char *path2) { | |
FILE *file1 = fopen(path1, "w"); | |
if (file1 == NULL) { | |
return errno; | |
} |
C++20 takes yet another swing at its infamous initialization rules. The players involved this time are Aggregate initialization (type a{1, 2, 3}
) and direct initialization (type a(1, 2, 3)
). A common pitfall with aggregate init is:
std::vector<int> vec0(5, 9); // 9, 9, 9, 9, 9
std::vector<int> vec1{5, 9}; // 5, 9
So if you don't know what you're doing, {}
is potentially dangerous to use with types that might have both "real" constructors and such with std::initializer_list
. If you had your head in the sand for 10 11 years and always used ()
then you never were in danger.
Daniel Lemire https://lemire.me/en/
Experimental vs asymptotic software engineering, Ullman's essay
Denis' Book
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Clear all Android packages and user data via ADB, by @noseratio | |
# Run: powershell -f adb-clear-packages.ps1 | |
# To get ADB: https://community.chocolatey.org/packages/adb | |
# | |
# Q: Why not a factory reset? | |
# A: https://www.reddit.com/r/Android/comments/naetg8/a_quick_powershell_script_for_clearing_user_data/gxtaswl?context=3 | |
$confirmation = Read-Host "This will clear all packages data and user files. Are you sure you want to proceed? (y|n)" | |
if ($confirmation -ne 'y') { | |
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <array> | |
#include <iostream> | |
template<typename ...Args> | |
constexpr std::size_t ARG_SIZE() { return sizeof...(Args) + 1; } | |
template<typename From, typename To> | |
concept SameAs = std::is_same_v<From, To>; | |
template<std::size_t N, typename T, SameAs<T>... Ts> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// x64 encoding | |
enum Reg { | |
RAX, RCX, RDX, RBX, RSP, RBP, RSI, RDI, | |
R8, R9, R10, R11, R12, R13, R14, R15, | |
}; | |
enum XmmReg { | |
XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7, | |
XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.Maybe | |
fizzBuzz n = | |
let | |
base divisor s = | |
if (n `mod` divisor) == 0 | |
then Just s | |
else Nothing | |
maybeFizz = base 3 "Fizz" | |
maybeBuzz = base 5 "Buzz" |
NewerOlder