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
  • 21:53 (UTC -04:00)
View GitHub Profile
@jwodder
jwodder / apt-check.py
Last active January 24, 2023 04:16
Display a table of available APT package updates
#!/usr/bin/python3
"""
This script lists all APT package updates currently available for your system
along with the version numbers of the old & new packages. It is derived from
``/usr/lib/update-notifier/apt-check`` in the ``update-notifier-common``
package on Ubuntu 14.04 (Trusty Tahr) and is made available under the same
license (the GNU GPL v2).
This script is know to work on Ubuntu Trusty and Xenial, and it should work on
any recent version of Ubuntu with the ``python3-apt`` package installed.
@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 / 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 / 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 / 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 / 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 / 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 / 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 / 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 / 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');
}