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
# run - replace the current terminal with a graphical program | |
# To install, source this file from your shell rc (or copy-paste it). | |
run() { | |
if ! command -v "$1" >> /dev/null; then | |
echo "run: error: command not found" 1>&2 | |
return 1 | |
fi | |
("$@" &) | |
exit |
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
struct Cons<HEAD, TAIL>(HEAD, TAIL); | |
struct Nil; | |
struct Z; | |
struct S<N>(N); | |
struct True; | |
struct False; | |
struct Fizz; | |
struct Buzz; | |
struct FizzBuzz; |
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
#define _SPIM_NR_PRINT_INT 1 | |
#define _SPIM_NR_PRINT_FLOAT 2 | |
#define _SPIM_NR_PRINT_DOUBLE 3 | |
#define _SPIM_NR_PRINT_STRING 4 | |
#define _SPIM_NR_READ_INT 5 | |
#define _SPIM_NR_READ_FLOAT 6 | |
#define _SPIM_NR_READ_DOUBLE 7 | |
#define _SPIM_NR_READ_STRING 8 | |
#define _SPIM_NR_SBRK 9 | |
#define _SPIM_NR_EXIT 10 |
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 <values.h> | |
#include <features.h> | |
#include <gnu-versions.h> | |
#include <stdc-predef.h> | |
#include <gnu/stubs.h> | |
#include <gnu/stubs-64.h> | |
#include <gnu/libc-version.h> | |
#include <gnu/lib-names.h> | |
#include <gnu/lib-names-64.h> | |
#include <iconv.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
#!/bin/sh | |
# Adapted from <https://superuser.com/a/611582> | |
date1=$(date +%s) | |
while true; do | |
s="$(date -u --date @$(($(date +%s) - date1)) +%H:%M:%S)" | |
printf "%s\r" "$s" | |
sleep 0.1 |
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 <stdbool.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
typedef void *(ThunkFunc)(void *); | |
typedef struct thunk Thunk; | |
struct thunk { | |
void *result; | |
ThunkFunc *func; |
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> | |
#include <stdlib.h> | |
#include <string.h> | |
int main(int argc, const char *argv[]) | |
{ | |
FILE *fp; | |
int c; | |
unsigned int lineno = 1, colno = 1; |
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
// Prints a 4GB 'L' | |
#include <limits.h> | |
#include <stdio.h> | |
int main(void) | |
{ | |
int i; | |
putchar('L'); |
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
/* | |
$----------------$ | |
| Example usage: | | |
$----------------$------------------------------------------------------$ | |
| #include <stdbool.h> | | |
| #include <stdio.h> | | |
| | | |
| #include "func.h" | | |
| | | |
| LIST_TYPE(int) | |
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 <stdio.h> | |
#include <stdlib.h> | |
#define LEN(x) (sizeof(x) / sizeof(x[0])) | |
/* | |
* Declare `arr`, an array of four pointers to arrays of two function pointers | |
* to a function that accepts a pointer to a two by two two dimensional array | |
* of ints as a parameter and returns an int. | |
*/ |
NewerOlder