Skip to content

Instantly share code, notes, and snippets.

View nitrix's full-sized avatar

Alex Belanger nitrix

View GitHub Profile
@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 October 1, 2024 05:42
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.
(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
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 8);
glEnable(GL_MULTISAMPLE);
/*
* ████████╗ ██████╗ ██████╗ ██╗ ██╗ ██╗██╗████████╗
* ╚══██╔══╝██╔═══██╗██╔═══██╗██║ ██║ ██╔╝██║╚══██╔══╝
* ██║ ██║ ██║██║ ██║██║ █████╔╝ ██║ ██║
* ██║ ██║ ██║██║ ██║██║ ██╔═██╗ ██║ ██║
* ██║ ╚██████╔╝╚██████╔╝███████╗██║ ██╗██║ ██║
* ╚═╝ ╚═════╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝
*
* Alex Belanger (nitrix)
* https://github.com/nitrix/toolkit
@nitrix
nitrix / gist:64e307cd448af069f80185df80c63182
Created December 16, 2019 05:25
Go image pkg overhead vs array
package main
import (
"fmt"
"image"
"image/color"
"time"
)
func main() {
func triangularNumberOf(n int) int {
return n * (n + 1) / 2
}
func reverseTriangularNumberOf(sum int) int {
n := (math.Sqrt(8 * float64(sum) + 1) - 1) / 2
return int(math.Ceil(n))
}
@nitrix
nitrix / gist:ff6cacbe5790605f4e61dbe9dda5e9e2
Created May 1, 2019 19:27
Bash profile useful aliases at work
# Docker Compose
# Runs a docker command of your choice from anywhere.
#
# Usage: dc <command>
dc() {
docker-compose --project-directory ~/Documents/Repos/workspace -f ~/Documents/Repos/workspace/docker-compose.yml $@
}
# Docker Compose Restart.
# Restart a container by name.
; Turn nasm into 16-bit mode
BITS 16
; Set origin address
ORG 0x7C00
; MEMORY LAYOUT
; 0x0000 - 0x0500 Interrupt Vector Table, BIOS Data Area
; 0x0500 - 0x7C00 Stack (growing down)
; 0x7C00 - 0x7E00 First stage bootloader
; 0x7E00 - 0xFFFF Free for use!
dc() {
docker-compose --project-directory ~/Documents/Repos/ws-development -f ~/Documents/Repos/ws-development/docker-compose.yml $@
}
# Docker compose restart
dcr() {
dc kill "$1"
dc up -d "$1"
}