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 <errno.h> | |
#include <limits.h> | |
#include <stddef.h> | |
#include <stdint.h> | |
int | |
parse_signed(const char src[static 1], intmax_t min, intmax_t max, | |
intmax_t dest[static 1], char **endptr) { | |
int sign; | |
intmax_t value; |
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
# sample input: 10-1000,15-350,50-1500,2100,1700-1800,45,40,145,2-1300 | |
set -o pipefail | |
tr , '\n' | sort -n | awk ' | |
BEGIN { | |
FS = OFS = "-" | |
} | |
NF < 1 || NF > 2 || (NF == 2 && $1 > $2) { | |
print "bad input: " $0 | "cat >&2" | |
exit 1 | |
} |
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 <stdio.h> | |
#include <ctype.h> | |
#include <strings.h> | |
static int | |
is_palindromic(const char *str, size_t n) { | |
size_t i, j; | |
if (n == 0) | |
return 1; |
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
# Takes an IPv6 address as argument | |
# and encodes it as described in RFC1924. | |
export LC_ALL=C | |
export POSIXLY_CORRECT=1 | |
unset BC_ENV_ARGS | |
unset BC_LINE_LENGTH | |
d0='0' d10='A' d20='K' d30='U' d40='e' d50='o' d60='y' d70='+' d80='`' | |
d1='1' d11='B' d21='L' d31='V' d41='f' d51='p' d61='z' d71='-' d81='{' |
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 <stdio.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
#define WIDTH 64 | |
#define HEIGHT 64 | |
#define AREA (WIDTH * HEIGHT) | |
#define WHITE 255 | |
#define BLACK 0 |
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
wrapper= | |
status=0 | |
badsrc() { | |
printf 'skipping %s\n' "$src" >&2 | |
status=1 | |
} | |
randstr() { | |
tr -cd '[:alnum:]' </dev/urandom | head -c 10 |
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 <err.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
typedef struct node *node; | |
typedef struct node *leaf; | |
typedef struct { | |
int last; |
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
# nowebp - find and convert WEBP images | |
# | |
# Usage: nowebp [DIR] | |
# | |
# nowebp searches the directory hierarchy starting from DIR (current | |
# directory if absent) for images in WEBP format, and converts each | |
# image it finds to PNG or JPG, depending on whether it is compressed | |
# losslessly or contains transparent pixels, or neither, respectively. | |
export LC_ALL=C |
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 <locale.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <uniconv.h> | |
#include <unigbrk.h> | |
#include <unistr.h> | |
int | |
reverse(uint8_t *str) { | |
size_t len; |
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 <errno.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#ifndef STACK_SIZE_MAX | |
#define STACK_SIZE_MAX 1000 | |
#endif | |
double stack[STACK_SIZE_MAX]; |