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 inline char _hexify(const char c) | |
{ | |
return (((c | ('A' ^ 'a')) - '0') % 39); | |
} | |
/// Converts a len-digit hex number into its unsigned native representation. | |
unsigned int dehex_to_int(int ilen, const char ibuf[ilen]) | |
{ | |
unsigned int result = 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
/// Convert N-byte string into hex | |
char* tohex(int len, const char input[len]) | |
{ | |
char *buf = malloc(2 * len + 1); | |
int pos = 0; | |
for (const char *i = input; i < input + len; i++) | |
pos += sprintf(&buf[pos], "%02x", *i); | |
return buf; | |
} |
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/bash | |
# Back up Subversion repositories. Run from cron. | |
# Somewhat ironic that I post this to github ... | |
svndir=$HOME/svn | |
destdir=$HOME/svnbackups | |
dumpcmd="svnadmin dump --quiet --incremental" | |
repos=`find "$svndir" -maxdepth 1 -mindepth 1 -type d -exec basename {} \;` | |
for repo in $repos; do | |
oldend=`ls -1t $destdir/$repo.*.*.* 2>/dev/null | head -n1 | cut -d. -f 3` |
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
/* Find set bits by value. process_faster() is between 40% and 200% faster than process_naive(), depending on optimizations and environment. */ | |
void process_naive(long long x) | |
{ | |
long long val = 1; | |
while (x) { | |
if (x & 1) | |
record(val); | |
x >>= 1; | |
val <<= 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
--- cyclo-2.0/lib.C 1994-07-03 13:12:34.000000000 -0500 | |
+++ cyclo-2.0-kulp/lib.C 2009-05-28 10:08:23.000000000 -0500 | |
@@ -23,35 +23,16 @@ | |
extern "C" // called from 'C' scan.c | |
{ | |
-char *strndup(char *str, int n) | |
-{ | |
- char *t, *t2; | |
- t2=t=(char *)malloc(n+1*sizeof(char)); |
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
function cyc() | |
{ | |
mcstrip $1 | cyclo -c -n 0 | perl -le 'print for map "@$_", sort { $b->[1] <=> $a->[1] } map [ split ], <>' | column -t | |
} |
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
undefsym = (nm -pAP $(2); nm -puAP $(1)) | cut -d' ' -f1-2 | sort -k2 | uniq -u -f1 | grep '^$(1)' | cut -d: -f2 | cut -b2- | |
OBJECTS = work.o | |
SUPPORT_OBJECTS = support.o | |
.PHONY: need | |
need: ; @$(call undefsym,$(OBJECTS),$(SUPPORT_OBJECTS)) |
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
/** | |
* Copies a string from 'in' to 'out', replacing unprintable and some | |
* punctuation characters with their escaped versions. | |
* | |
* To be safe, the output buffer should be allocated with (4 * ilen) characters | |
* of space, for the worst case scenario, where all characters are unprintable. | |
* | |
* @param ilen the length of the input string | |
* @param in the input string | |
* @param olen the length of the output buffer |
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
#define NEW_OF_TYPE(T,...) \ | |
(memcpy(malloc(sizeof(T)), &(T){ __VA_ARGS__ }, sizeof (T))) |
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
main(int c,char**v){c<2||(setuid(0),execvp(v[1],&v[1]));} |
OlderNewer