Skip to content

Instantly share code, notes, and snippets.

View nitrix's full-sized avatar

Alex Belanger nitrix

View GitHub Profile
Setup:
1) Fresh new install of msys2-x86_64-20220503.exe.
2) Launch _specifically_ the "MSYS2 MinGW x64" terminal (not the one it suggests).
3) Run pacman -S mingw-w64-x86_64-{make,cmake,gcc,clang,gdb} and say yes at the prompt.
4) Add `C:\msys64\mingw64\bin` to windows's PATH.
*** If you intend to continue with the usage section, you have to restart the "MSYS2 MinGW x64" terminal
for your changes to the PATH environment variable to refresh.
@nitrix
nitrix / uncrustify.cfg
Last active April 11, 2022 21:14
Sharing the uncrustify configuration I often use to someone interested on IRC.
tok_split_gte=false
utf8_byte=false
utf8_force=false
indent_cmt_with_tabs=false
indent_align_string=false
indent_braces=false
indent_braces_no_func=false
indent_braces_no_class=false
indent_braces_no_struct=false
indent_brace_parent=false
-falign-functions -falign-jumps
-falign-labels -falign-loops
-fcaller-saves
-fcode-hoisting
-fcrossjumping
-fcse-follow-jumps -fcse-skip-blocks
-fdelete-null-pointer-checks
-fdevirtualize -fdevirtualize-speculatively
-fexpensive-optimizations
-ffinite-loops
@nitrix
nitrix / wsl-go-install.sh
Created November 15, 2021 14:55
Script to install Go 1.17 on Linux and WSL (Windows Subsystem for Linux)
#!/bin/bash
set -e
GVERSION="1.17"
GFILE="go$GVERSION.linux-amd64.tar.gz"
GOPATH="$HOME/projects/go"
GOROOT="/usr/local/go"
if [ -d $GOROOT ]; then
echo "Installation directories already exist $GOROOT"
main :-
natural(N),
N < 1000,
(multipleOf(3, N) ; multipleOf(5, N)),
converge(sum(N), Answer),
printLine(Answer).
------------------------- vs --------------------------
solution(N) :-
@nitrix
nitrix / main.go
Created January 27, 2021 23:36
Deleting registry keys recursively on windows.
package main
import (
"golang.org/x/sys/windows/registry"
"io"
"log"
)
func main() {
key, err := registry.OpenKey(registry.CURRENT_USER, "Test", registry.ALL_ACCESS)
@nitrix
nitrix / main.go
Created January 23, 2021 22:41
Shit code, months with more than 2 paydays
package main
import (
"fmt"
"github.com/jinzhu/now"
"log"
"os"
"strconv"
"time"
)
@nitrix
nitrix / defer.h
Created January 11, 2021 18:54
defer attempt
#ifndef DEFER_H
#define DEFER_H
struct guard_metadata {
int labels[32];
size_t label_count;
bool run_mode;
int at;
};
@nitrix
nitrix / clang-format-bug.md
Created January 10, 2021 22:17
LLVM's clang-format nondeterministic bug
---
IndentCaseLabels: 'true'
IndentWidth: '4'

...
void foo(void) {
@nitrix
nitrix / gist:19bab7c711d05811a4661a189d26bc19
Last active January 5, 2021 16:58
memory order atomics explanation
All atomic operations are guaranteed to be atomic within themselves (the
combination of two atomic operations is not atomic as a whole!) and to be
visible in the total order in which they appear on the timeline of the
execution stream. That means no atomic operation can, under any circumstances,
be reordered, but other memory operations might very well be. Compilers (and
CPUs) routinely do such reordering as an optimization.
It also means the compiler must use whatever instructions are necessary to
guarantee that an atomic operation executing at any time will see the results
of each and every other atomic operation, possibly on another processor core
(but not necessarily other operations), that were executed before.