Skip to content

Instantly share code, notes, and snippets.

Avatar

Alex Belanger nitrix

View GitHub Profile
@nitrix
nitrix / wsl-go-install.sh
Created Nov 15, 2021
Script to install Go 1.17 on Linux and WSL (Windows Subsystem for Linux)
View wsl-go-install.sh
#!/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"
View gist:a3fac5788d273f17a9e1a998052bf711
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 Jan 27, 2021
Deleting registry keys recursively on windows.
View main.go
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 Jan 23, 2021
Shit code, months with more than 2 paydays
View main.go
package main
import (
"fmt"
"github.com/jinzhu/now"
"log"
"os"
"strconv"
"time"
)
@nitrix
nitrix / defer.h
Created Jan 11, 2021
defer attempt
View defer.h
#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 Jan 10, 2021
LLVM's clang-format nondeterministic bug
View clang-format-bug.md
---
IndentCaseLabels: 'true'
IndentWidth: '4'

...
void foo(void) {
@nitrix
nitrix / gist:19bab7c711d05811a4661a189d26bc19
Last active Jan 5, 2021
memory order atomics explanation
View gist:19bab7c711d05811a4661a189d26bc19
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.
View gist:e92b68c529f384609fcdcfcb2334e374
(interpreter) Running memcheck: underscore
==26617== Memcheck, a memory error detector
==26617== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==26617== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==26617== Command: chaos /root/chaos/tests/underscore.kaos
==26617==
1
2
3
View gist:5a5b6ed2d0ca8e9a37a3dbce5fb082e3
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 8);
glEnable(GL_MULTISAMPLE);
View gist:3f1a77c183b0d10d01f04cef93091163
/*
* ████████╗ ██████╗ ██████╗ ██╗ ██╗ ██╗██╗████████╗
* ╚══██╔══╝██╔═══██╗██╔═══██╗██║ ██║ ██╔╝██║╚══██╔══╝
* ██║ ██║ ██║██║ ██║██║ █████╔╝ ██║ ██║
* ██║ ██║ ██║██║ ██║██║ ██╔═██╗ ██║ ██║
* ██║ ╚██████╔╝╚██████╔╝███████╗██║ ██╗██║ ██║
* ╚═╝ ╚═════╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝
*
* Alex Belanger (nitrix)
* https://github.com/nitrix/toolkit