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 | |
set -e | |
i=0 | |
while [ $i -lt 3 ]; do | |
r=$((RANDOM % 10)) | |
if [ $r -lt 3 ]; then | |
((i++)) |
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> | |
void standard(int A, int B, int C, int array[A][B][C]) { | |
for (int i = 0; i < A; i++) { | |
for (int j = 0; j < B; j++) { | |
for (int k = 0; k < C; k++) { | |
printf("%d\n", array[i][j][k]); | |
} | |
} | |
} |
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 STATIC_ASSERT(cond) ((void)sizeof(char[1 - 2 * !(cond)])) | |
struct S { | |
int x, y; | |
short z; | |
}; | |
int main(void) { | |
STATIC_ASSERT(1 + 2 == 3); | |
STATIC_ASSERT(sizeof(float) <= sizeof(double)); |
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
test1: CFLAGS ?= -Wall -Wextra | |
test2: CFLAGS += -Wall -Wextra | |
test3: override CFLAGS += -Wall -Wextra | |
test4: override CFLAGS := -Wall -Wextra $(CFLAGS) | |
test1 test2 test3 test4: | |
@echo "$@: $(CFLAGS)" |
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
diff --git a/DATS/Makefile b/DATS/Makefile | |
index ef0418e..6df16b0 100644 | |
--- a/DATS/Makefile | |
+++ b/DATS/Makefile | |
@@ -7,12 +7,9 @@ MAKEFLAGS += --silent | |
###### | |
-PATSCC=\ | |
-$(PATSHOME)/bin/patscc |
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
type stmts = stmt ref list | |
and stmt = Assign of var * expr | |
and expr = | |
| Int of int | |
| Val of var | |
| Binop of expr * expr (* e1 + e2 *) | |
and var = string |
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
// https://rain-1.github.io/why/why.html | |
// https://github.com/rain-1/makes/tree/master/previous-version/makes.c | |
// | |
// Example usage: | |
// makes foo foo.c foo.h && gcc -Wall -Wextra -o foo foo.c | |
#include <stdbool.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.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
function f() | |
return 1, 2, 3 | |
end | |
print(f()) -- 1 2 3 | |
print(f(), 4) -- 1 4 | |
print(4, f()) -- 4 1 2 3 |
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 | |
# ShellChecked with no issues detected | |
# | |
# Example usage for debugging a sporadically failing program: | |
# repeat.sh -- gdb --eval-command=run --eval-command=quit --args ./a.out | |
while [[ $1 != "--" ]]; do | |
n=$1 | |
shift | |
done |
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
// CFLAGS="-Wall -Wextra" | |
#include <assert.h> | |
#include <stdbool.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
typedef struct task { | |
void (*func)(void *); | |
void *args; | |
struct task *next; |
NewerOlder