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> | |
#define countof(X) (sizeof (X) / sizeof (X)[0]) | |
int display7(FILE *stream, unsigned char digit) | |
{ | |
const char digits[][7] = { | |
['-'] = " -", | |
['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
#include "critbit.h" | |
const node nodes[] = { | |
// read indices inside out | |
// for example, L(R(L(L(ROOT)))) is the root's left child's left child's | |
// right child's left child. | |
[ ROOT ] = { 6, 0 }, | |
[ R(ROOT) ] = { 64, 1 }, | |
[ L(ROOT) ] = { 5, 0 }, | |
[ R(L(ROOT)) ] = { 32, 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; | |
use Device::USB; | |
my ($vendorid, $productid) = (0x041e, 0x30df); | |
my $usb = Device::USB->new; | |
my $dev = $usb->find_device($vendorid, $productid) |
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
sauf is a lightweight exception handling system for C. | |
The original implementation idea came from an article in Dr. | |
Dobb's Journal : http://www.on-time.com/ddj0011.htm | |
Some implementation details were taken from the excc project : | |
http://adomas.org/excc/ . This project was almost sufficient to my | |
requirements, but it requires GCC (sauf aims to work with any C99- | |
compliant compiler) and does not support 'finally' blocks. |
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
/* | |
reg2nsh.c : Converts .REG (exported registry files) into .NSH-style | |
registry commands, for use with the NSIS ( http://nsis.sf.net/ ). | |
$Rev$ | |
$Date$ | |
Copyright (c) 2005 Darren Kulp under the terms of the MIT License | |
Permission is hereby granted, free of charge, to any person obtaining a | |
copy of this software and associated documentation files (the "Software"), |
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 | |
* @brief Moves the mouse pointer between screens on an X11 display. | |
* | |
* This program might be useful to you if you wish to switch between two X11 | |
* screens without moving your hands from the keyboard. I configure bbkeys to | |
* map the otherwise-unused windows keys and right-click key to move to the left | |
* screen, move to the right screen, and toggle between screens, respectively. | |
* | |
* Run with zero to three arguments (additional arguments are ignored). The |
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 warnings; | |
use strict; | |
use Net::WolframAlpha; | |
my $key = $ENV{WOLFRAM_ALPHA_API_KEY} | |
or die "set \$WOLFRAM_ALPHA_API_KEY in environment"; |
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
// positive shifts are left shifts | |
// left shifts are shifts higher into the word, which in a little-endian system | |
// is higher in memory | |
// XXX make endian-agnostic | |
void *memshift(void *dest, const void *src, size_t size, signed shift) | |
{ | |
int shiftleft = shift > 0; | |
int shiftright = shift < 0; | |
int destbyteshift = (shiftleft * (+shift / CHAR_BIT)); | |
int srcbyteshift = (shiftright * (-shift / CHAR_BIT)); |
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
CPPFLAGS += $(INCLUDE:%=-I%) $(DEFINES:%=-D%) | |
CXXFLAGS += -Wall -Wextra -Wno-unused | |
CC = gcc | |
LD = gcc | |
CFILES += $(wildcard *.c) | |
CXXFILES += $(wildcard *.cc) | |
CPP = g++ -x c++ -E -P | |
#DEFINES += CXX_VISIBLE=1 |