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
| /* http://stackoverflow.com/a/1732454/417501 */ | |
| %{ | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <ctype.h> | |
| #include <string.h> | |
| #define MYEOF EOF | |
| #define TOKEN_URL 257 |
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
| #!/bin/sh | |
| PATH="$PATH:/usr/local/bin" | |
| export LC_CTYPE=C | |
| export LC_COLLATE=C | |
| # decode URL encoded $1 and print result to stdout | |
| urldecode() { | |
| gawk "BEGIN { print \"$(echo "$1" | sed -e 's/"/\\"/' -e 's/+/ /g' -e 's/%/\\x/g')\" }" </dev/null | |
| } |
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
| /* remove comments from C source files */ | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| /* | |
| * read ahead buffer | |
| */ | |
| static char rabuf[BUFSIZ], *readahead = rabuf; |
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
| section bss | |
| BUFSIZ equ 64 | |
| iobuf resb BUFSIZ ; where we put the number | |
| section text | |
| ; convert 32 bit number in argument to asciz in iobuf | |
| ; return pointer to number in ax | |
| global ltoa@4 |
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
| # binary gcd algorithm in amd64 assembly | |
| # gcd(u, v); | |
| .text | |
| .globl gcd | |
| .type gcd,@function | |
| gcd: | |
| # u is in edi | |
| # v is in esi | |
| # abs routines are not branch free because we need to test |
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
| static struct puzzle * | |
| read_puzzles(size_t *n_puzzle, FILE *puzzlefile) | |
| { | |
| struct puzzle *puzzles; | |
| size_t cap = 64, n_linebuf; | |
| char *linebuf = NULL; | |
| *n_puzzle = 0; | |
| puzzles = malloc(cap * sizeof *puzzles); | |
| if (puzzles == NULL) { |
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
| /*- | |
| * Copyright (c) 2014, 2016 Robert Clausecker | |
| */ | |
| /* | |
| * util.h - various utility functions | |
| */ | |
| #ifndef UTIL_H | |
| #define UTIL_H |
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
| .text | |
| .globl exp | |
| .type exp,@function | |
| .align 16 | |
| exp: | |
| fldt 4(%esp) # x | |
| fldl2e # log2(e) x | |
| fmulp # x' (= log2(e) * x) | |
| fld %st(0) # x' x' | |
| frndint # round(x') x' |
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
| /* https://www.reddit.com/r/abstractgames/comments/6dklih/ */ | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| /* | |
| * The game is played on a board like this, every player has three | |
| * pieces named a, b, and c. The player to play first (blue) has | |
| * uppercase pieces, the other player has lowercase pieces. This is | |
| * the initial setup: | |
| * |
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
| /*- | |
| * Copyright (c) 2014, 2016 Robert Clausecker | |
| */ | |
| /* | |
| * parse_mode() - parse an octal or symbolic mode string into a mode_t | |
| */ | |
| #define _XOPEN_SOURCE 700 | |
| #include <stdlib.h> |