Skip to content

Instantly share code, notes, and snippets.

# This script compiles scramble.c and calculates the score.
# Before use, put scramble.c, $text, $pict in current directory.
text=pg100.txt
pict=filament.jpg
# Die if any command fails.
# Die if files are missing.
set -e
ls scramble.c $text $pict >/dev/null
@kernigh
kernigh / benchrand.rb
Created May 9, 2016 02:35
benchmark for different random number generators
# Run benchmarks:
# $ ruby benchrand.rb
# Run benchmarks in parallel with sh and xterm:
# $ for i in 1 2; do xterm -hold -e ruby benchrand.rb& done
#
# Outputs the time to generate SIZE random bytes with several
# different random number generators:
# - Random::DEFAULT from Ruby
# - /dev/urandom
# - arc4random_buf() from libc
@kernigh
kernigh / SetDemo.mod
Created December 10, 2016 17:25
test for Modula-2 set operations in Amsterdam Compiler Kit
MODULE SetDemo;
FROM InOut IMPORT WriteLn, WriteString;
PROCEDURE Puts(s: ARRAY OF CHAR);
BEGIN
WriteString(s);
WriteLn;
END Puts;
@kernigh
kernigh / ack-elf-fix.diff
Created January 17, 2017 02:01
ack: fix for ELF symbol table
diff --git a/util/amisc/aelflod.c b/util/amisc/aelflod.c
index d5a9c0d..dbaafc9 100644
--- a/util/amisc/aelflod.c
+++ b/util/amisc/aelflod.c
@@ -43,6 +43,7 @@ char* stringarea;
uint32_t ack_off_char;
int nstab = 0; /* S_STB symbol count */
int nsym = 0; /* other symbol count */
+int nlocal = 0; /* local symbols */
@kernigh
kernigh / ack-powerpc-ex.diff
Last active January 18, 2017 21:26
ack: PowerPC extended mnemonics, incomplete diff
diff --git a/mach/powerpc/as/mach2.c b/mach/powerpc/as/mach2.c
index 480c5fa..47ef18c 100644
--- a/mach/powerpc/as/mach2.c
+++ b/mach/powerpc/as/mach2.c
@@ -10,18 +10,32 @@
%token <y_word> C
%token <y_word> OP
+%token <y_word> OP_BDA
+%token <y_word> OP_BDL
@kernigh
kernigh / fifo-fail.diff
Last active October 11, 2017 21:37
prevent Ruby tests getting stuck in OpenBSD
Some of Ruby's tests get stuck in OpenBSD.
This is because of OpenBSD's bug. FIFO gets stuck.
This patch causes all FIFO tests to fail,
so I can run `make test-all` and `make test-spec` in OpenBSD.
Jeremy Evans (who knows OpenBSD better than me)
described the bug here: https://bugs.ruby-lang.org/issues/13875#note-7
diff --git a/spec/ruby/spec_helper.rb b/spec/ruby/spec_helper.rb
@kernigh
kernigh / disksize.c
Created June 8, 2018 17:22
size of OpenBSD disk partition
#include <sys/types.h>
#include <sys/disklabel.h>
#include <sys/dkio.h> /* DIOCGDINFO */
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
/*
* Shows the size in bytes of a disk partition in OpenBSD.
@kernigh
kernigh / Xorg.0.log
Created August 30, 2018 03:01
dmesg and Xorg.0.log of PowerBook5,4
[ 60.705] (--) no aperture driver access: only wsfb driver useable
[ 62.207] (--) Using wscons driver on /dev/ttyC4
[ 62.469]
X.Org X Server 1.19.6
Release Date: 2017-12-20
[ 62.469] X Protocol Version 11, Revision 0
[ 62.469] Build Operating System: OpenBSD 6.4 macppc
[ 62.469] Current Operating System: OpenBSD ghostborough.my.domain 6.4 GENERIC#188 macppc
[ 62.470] Build Date: 29 August 2018 03:36:30PM
[ 62.470]
@kernigh
kernigh / Xorg.0.log
Created October 21, 2019 03:40
OpenBSD 6.6 amd64 on desktop hardware from 2010
[ 10093.090] (WW) checkDevMem: failed to open /dev/xf86 and /dev/mem
(Operation not permitted)
Check that you have set 'machdep.allowaperture=1'
in /etc/sysctl.conf and reboot your machine
refer to xf86(4) for details
[ 10093.090] linear framebuffer access unavailable
[ 10093.099] (--) Using wscons driver on /dev/ttyC4
[ 10093.136]
X.Org X Server 1.20.5
X Protocol Version 11, Revision 0
@kernigh
kernigh / Xorg.0.log
Created December 17, 2019 03:17
macppc PowerBook5,4 OpenBSD 6.6-current 5 Dec
[ 51.654] (--) no aperture driver access: only wsfb driver useable
[ 53.028] (--) Using wscons driver on /dev/ttyC4
[ 53.426]
X.Org X Server 1.20.5
X Protocol Version 11, Revision 0
[ 53.426] Build Operating System: OpenBSD 6.6 macppc
[ 53.427] Current Operating System: OpenBSD ghostborough.my.domain 6.6 GENERIC#631 macppc
[ 53.428] Build Date: 04 December 2019 04:23:41PM
[ 53.428]
[ 53.428] Current version of pixman: 0.38.4