Skip to content

Instantly share code, notes, and snippets.

View jwodder's full-sized avatar

John T. Wodder II jwodder

  • A well house for a large spring
  • 16:04 (UTC -04:00)
View GitHub Profile
@jwodder
jwodder / rsacrypt.c
Created May 8, 2014 21:46
a wrapper around OpenSSL for RSA file encryption
/* rsacrypt, v.1.1
* Written 3 Jan 2008 by John T. Wodder II
* Last edited 21 Jan 2008 by John Wodder
*
* This program uses the OpenSSL libcrypto cryptographic library to perform RSA
* encryption & decryption on files of arbitrary length. It was written mainly
* because I couldn't find a program that already did this.
*/
/* Things that need to be addressed:
@jwodder
jwodder / Ternary.hs
Created May 11, 2014 00:39
Ternary/conditional operator in Haskell
module Ternary where
data TernaryBranch a = a :? a deriving (Eq, Ord, Read, Show, Bounded)
instance Functor TernaryBranch where fmap f (x :? y) = f x :? f y
infixr 0 ?:, :?, ?~
(?:) :: Bool -> TernaryBranch a -> a
True ?: (y :? _) = y
False ?: (_ :? z) = z
@jwodder
jwodder / bench.sh
Created May 11, 2014 21:36
Run a command repeatedly and write the runtimes to a file
#!/bin/bash
n=1000
args=`getopt n:o: $*` || {
echo "Usage: bench [-n runs] [-o outfile] cmd args ..."
exit 2
}
set -- $args
for i
do case "$1" in
-n) n="$2"; shift; shift;;
@jwodder
jwodder / mkLatin1.ps
Created May 11, 2014 23:53
Make a font use ISOLatin1Encoding
% This procedure takes a Font resource and creates a new font from it that uses
% the ISOLatin1Encoding encoding vector. It is based on code given in the PLRM.
% Stack effect: font name-of-new-font -- new-font
% Example usage:
% /Helvetica findfont /Helvetica-Latin1 mkLatin1 12 scalefont setfont
/mkLatin1 {
exch dup length dict begin
@jwodder
jwodder / limits.c
Created May 17, 2014 00:28
Print various values from <limits.h> and <float.h>
#include <stdio.h>
#include <stdint.h>
#include <limits.h>
#include <float.h>
void showInt(const char* name, size_t bytes, intmax_t max, intmax_t min,
uintmax_t umax);
/* Converting between floating-point types undoubtedly won't preserve things
* appropriately, so showFloat is implemented as a macro: */
@jwodder
jwodder / deaths.pl
Created June 26, 2014 23:20
Unique NetHack deaths
#!/usr/bin/perl -wnl
# A Perl script for printing all unique NetHack deaths incurred and their
# frequencies, based on a shell script posted to RGRN by "Faux_Pseudo"
# Written 12 Nov 2008 by John T. Wodder II
# Last edited 14 Nov 2008 by John Wodder
# Usage: deaths.pl [-sw] [logfile ...]
# Options:
# -s - If no logfiles are given on the command line, read from stdin instead
# of /usr/games/lib/nethackdir/logfile
# -w - Strip off any "while helpless" messages & similar stuff that comes
@jwodder
jwodder / colors.c
Created June 26, 2014 23:25
curses color spectrum
#include <curses.h>
int main(void) {
initscr();
noecho();
cbreak();
start_color();
init_pair(1, COLOR_RED, COLOR_BLACK);
init_pair(2, COLOR_GREEN, COLOR_BLACK);
init_pair(3, COLOR_BLUE, COLOR_BLACK);
init_pair(4, COLOR_CYAN, COLOR_BLACK);
@jwodder
jwodder / finbin.pl
Created July 3, 2014 17:01
Find binaries in the user's PATH
#!/usr/bin/perl -wl
# finbin - find binaries in the user's PATH
# See the POD at the end of the file for documentation.
use strict;
use File::Glob 'bsd_glob', 'GLOB_NOCASE', 'GLOB_QUOTE', 'GLOB_BRACE';
use Getopt::Std;
my %opts;
our $VERSION = 1.3;
getopts('fFp:qx', \%opts) || exit 2;
@jwodder
jwodder / xattr-addblanks.diff
Created May 8, 2011 19:06
A patch to commit 9fcd797d of xattr for separating all attribute listings with blank lines
diff --git xattr.c xattr.c
index 41d2fbd..1f297e9 100644
--- xattr.c
+++ xattr.c
@@ -60,10 +60,10 @@ int main(int argc, char** argv) {
free(value);
}
putchar('\n');
+ putchar('\n');
}
@jwodder
jwodder / Dockerfile
Created March 14, 2017 22:55
A demonstration of setuptools issue 967
FROM ubuntu:16.04
RUN apt-get update && apt-get install -y python-virtualenv
WORKDIR /issue967
COPY run.sh setup.py /issue967/
CMD ["/bin/bash", "run.sh"]