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/env perl | |
# export PAGER="ansi16_to_ansi256.pl | ${PAGER:-less -R}" | |
use strict; | |
use Color::ANSI::Util qw(ansi16_to_rgb rgb_to_ansi256); | |
my $esc = qr/\x1b\[/; | |
my $fg = qr/3\d/; | |
my $bg = qr/4\d/; | |
my $seq = qr/$esc((?:$fg|$bg)(?:;(?:$fg|$bg))*)m/o; |
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 "huffman.h" | |
int huff_decode(const dict_entry *dict, char *out, const huff_word **in, | |
size_t *len, size_t *bits, size_t *off) | |
{ | |
const dict_entry *n = dict; | |
int found = 0; | |
while (!found && *len && *off < *bits) { | |
unsigned char bit = (**in >> *off) & 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
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
package Env; | |
sub new { | |
my $class = shift; | |
my $names = shift; |
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
\ | |
\ Garbage.fs | |
\ | |
\ A compact, simple implementation of a garbage-collected | |
\ cons-pair heap utilizing Cheney's algorithm. | |
\ Pointers to pairs are identified by a pattern in the | |
\ high-order bits of a value, chosen not to collide | |
\ with the constants "true" or "false". | |
\ |
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
unsigned check_range(const char *bad, const char *good, size_t len, size_t bounds[2]) | |
{ | |
if (len < 2) { | |
if (len) | |
return *bad != *good; | |
return 0; | |
} else if (memcmp(bad, good, len)) { | |
size_t subbounds[2][2] = { { 0 } }; | |
int leftbad = check_range(&bad[0 ], &good[0 ], len / 2, subbounds[0]); | |
int rightbad = check_range(&bad[len / 2], &good[len / 2], len - len / 2, subbounds[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 <assert.h> | |
#include <errno.h> | |
#include <stddef.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <limits.h> | |
#include <stdint.h> | |
#define RANK_0_LOG 5 | |
#define RANK_0_SIZE (1ul << RANK_0_LOG) |
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
// "Poor man's valgrind" | |
#include "pmvg.h" | |
#include <stdlib.h> | |
#include <search.h> | |
static void *track_tree; | |
struct track_pair { | |
void *addr; size_t size; | |
}; | |
static long bytes_lost; |
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
/** | |
* @file | |
* Provides a lightweight integer-keyed key-value store. | |
* | |
* The key must be an integral type (default @c int), but can be any integral | |
* type if @c KV_KEY_TYPE is defined before @c #include'ing this file. | |
*/ | |
#ifndef KV_INT_H_ | |
#define KV_INT_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
// by alex evans, 2011. released into the public domain. | |
// based on a first ever reading of the png spec, it occurs to me that a minimal png encoder should be quite simple. | |
// this is a first stab - may be buggy! the only external dependency is zlib and some basic typedefs (u32, u8) | |
// | |
// VERSION 0.02! now using zlib's crc rather than my own, and avoiding a memcpy and memory scribbler in the old one | |
// by passing the zero byte at the start of the scanline to zlib first, then the original scanline in place. WIN! | |
// | |
// more context at http://altdevblogaday.org/2011/04/06/a-smaller-jpg-encoder/. | |
// | |
// follow me on twitter @mmalex http://twitter.com/mmalex |
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/env perl | |
use strict; | |
use List::Util qw(max); | |
my $name = "b"; | |
# for each significant bit position, where the sequence through the bit | |
# positions is chosen such that each bit chosen divides the remaining | |
# search space as nearly evenly as possible, construct an array that | |
# looks like this: |
NewerOlder