This file contains hidden or 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
| local function escape(code) | |
| return string.char(27) .. string.format("[%dm", code) | |
| end | |
| local function brightred(str) | |
| return escape(1) .. escape(31) .. str .. escape(0) | |
| end | |
| local function write(...) | |
| for _, str in ipairs({...}) do |
This file contains hidden or 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
| A B C | |
| 1 2 3 | |
| 4 5 6 | |
| 7 8 9 |
This file contains hidden or 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
| .ONESHELL: | |
| foo: | |
| @foo=defined | |
| echo $${foo:-undefined} | |
| .PHONY: foo |
This file contains hidden or 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
| all: foo.sh | |
| check: foo.sh | |
| @set -eu; \ | |
| echo "Running $<"; \ | |
| output=$$(sh $<); \ | |
| expect=42; \ | |
| if [ "$$output" != "$$expect" ]; then \ | |
| echo "*** CHECK FAILED: expected $$expect, got $$output"; \ | |
| fi |
This file contains hidden or 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 <cassert> | |
| #include <forward_list> | |
| #include <functional> | |
| #include <iostream> | |
| struct Task { | |
| using thunk = std::function<void()>; | |
| Task(thunk f) : f(f) {} | |
| void operator()() const { f(); } |
This file contains hidden or 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 <alloca.h> | |
| #include <assert.h> | |
| #include <stdio.h> | |
| struct task { | |
| void (*fn)(struct task *); | |
| void *arg, *ret; | |
| }; | |
| struct task_node { |
This file contains hidden or 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
| #ifndef BENCH_H | |
| #define BENCH_H | |
| #include <stdio.h> | |
| #include "wtime.h" | |
| #define BENCH_LOG \ | |
| "Benchmark Time Iterations\n" \ | |
| "--------------------------------------------------------------\n" \ | |
| "%-22s %9.3lf %5s %23ld\n" |
This file contains hidden or 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 <assert.h> | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| int int_of_string(const char *s) | |
| { | |
| return atoi(s); | |
| } | |
| int main(int argc, char *argv[]) |
This file contains hidden or 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
| open Unix | |
| let lsh_builtins = ["cd"; "help"; "exit"] | |
| let print_error msg = | |
| prerr_string "lsh: "; | |
| prerr_endline msg | |
| let lsh_cd args = | |
| assert (args.(0) = "cd"); |
This file contains hidden or 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/awk -f | |
| function join(arr, sep, i) { | |
| joined = arr[1] | |
| for (i = 2; i <= length(arr); i++) { | |
| joined = joined sep arr[i] | |
| } | |
| return joined | |
| } |