Skip to content

Instantly share code, notes, and snippets.

@io12
io12 / run.sh
Created November 11, 2020 04:14
# 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
struct Cons<HEAD, TAIL>(HEAD, TAIL);
struct Nil;
struct Z;
struct S<N>(N);
struct True;
struct False;
struct Fizz;
struct Buzz;
struct FizzBuzz;
#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
#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>
#!/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
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
typedef void *(ThunkFunc)(void *);
typedef struct thunk Thunk;
struct thunk {
void *result;
ThunkFunc *func;
#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;
// Prints a 4GB 'L'
#include <limits.h>
#include <stdio.h>
int main(void)
{
int i;
putchar('L');
/*
$----------------$
| Example usage: |
$----------------$------------------------------------------------------$
| #include <stdbool.h> |
| #include <stdio.h> |
| |
| #include "func.h" |
| |
| LIST_TYPE(int) |
@io12
io12 / type.c
Last active August 23, 2017 19:41
#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.
*/