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 <limits.h> | |
#include <stddef.h> | |
#include <stdint.h> | |
#define popcnt(x) (size_t)({\ | |
typeof (_Generic(x, \ | |
int32_t: (uint32_t)1, \ | |
int64_t: (uint64_t)1, \ | |
uint32_t: (uint32_t)1, \ | |
uint64_t: (uint64_t)1))y=x; \ |
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
/* Compile with "gcc -std=c23 -mbmi2 -mlzcnt" (gcc-14) | |
* or "gcc -std=c2x -mbmi2 -mlzcnt" (gcc-13) | |
*/ | |
#include <errno.h> | |
#include <stdint.h> | |
#include <stdio.h> | |
#include <immintrin.h> | |
static void | |
bitpr (uint64_t n) |
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
// Behavior of gcc-14 and clang-19 diverge on this. | |
// Compile with -std=gnu23. | |
#include <stdio.h> | |
int main(void) { | |
printf("%s\n", _Generic( | |
(struct{_BitInt(8) x : 2;}){}.x, | |
_BitInt(2): "gcc", _BitInt(8): "clang")); | |
} |
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 <stddef.h> | |
#include <stdio.h> | |
#define options(X) \ | |
X('h', "help", "", "print this help") \ | |
X('s', "segfault", "", "commit sudoku") \ | |
X('d', "directory", "DIR", "touch a directory") \ | |
X('u', "uid-of", "NAME", "print a user ID") | |
#ifdef __clang__ |
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
/* SPDX-License-Identifier: GPL-2.0-or-later */ | |
/** | |
* @file stringy_check.c | |
* @author Juuso Alasuutari | |
* | |
* @brief Parse the raw content bytes of text strings as if the strings were | |
* arbitrarily large integers, and check if the result is a different | |
* prime number in both the big- and little-endian byte orders. | |
* | |
* I call the group of primes generated by this method "stringy primes"; run |
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
/* SPDX-License-Identifier: GPL-2.0-or-later */ | |
/** @file dstr.c | |
* | |
* @author Juuso Alasuutari | |
*/ | |
#include <errno.h> | |
#include "dstr.h" | |
/** |
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
#!/usr/bin/env bash | |
# | |
# IMPORTANT: The HTTP authorization header must be found | |
# in ~/.openai in full, not just the API key. | |
# | |
# Usage: ./bashplainer.sh /path/to/file.sh | |
# | |
# Requirements: dos2unix, jq, curl | |
# |
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
#!/usr/bin/env bash | |
# | |
# IMPORTANT: The HTTP authorization header must be found | |
# in ~/.openai in full, not just the API key. | |
# | |
# Usage: ./documentarist.sh [options] /path/to/file.c | |
# | |
# Requirements: dos2unix, cpp, clang-format, jq, curl | |
# |
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
#!/usr/bin/env bash | |
# | |
# Usage (_only_ if you really know what you're doing): | |
# etc_hosts_dig.sh >> /etc/hosts | |
# expand this list as needed | |
declare -a hosts_list=( | |
api.openai.com | |
auth0.openai.com | |
cdn.openai.com |
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
# /etc/udev/rules.d/99-xdm.rules | |
# Create a dev-dri-card0.device unit for xdm.service to wait on. | |
SUBSYSTEM=="drm", KERNEL=="card0", TAG+="systemd" |
NewerOlder