Skip to content

Instantly share code, notes, and snippets.

@kernigh
kernigh / crab.pl
Last active January 10, 2024 21:33
draw a crab in Perl/Tk with mega-widget
# Draw a crab in Perl/Tk. Public domain, see
# https://creativecommons.org/publicdomain/zero/1.0/
use strict;
use warnings;
# ColorChoice is a composite widget (a kind of mega-widget) with
# buttons to choose red, green, or blue. It always starts on red.
# When the user changes the color, this widget calls its -command.
package ColorChoice;
@kernigh
kernigh / deli.c
Created December 18, 2022 03:49
#eql? and #hash delegation for CRuby
#include <ruby.h>
static void
deli_mark(void *ptr)
{
rb_gc_mark((VALUE)ptr);
}
static const rb_data_type_t deli_type = {
"Type",
@kernigh
kernigh / hupme.c
Created January 12, 2022 20:02
hupme.c: look at siginfo_t from SIGHUP
#include <err.h>
#include <signal.h>
#include <stdio.h>
#include <unistd.h>
int signo;
int code;
int sigerrno;
pid_t pid;
uid_t uid;
@kernigh
kernigh / bm-ftoi.rb
Created October 12, 2021 01:49
Ruby benchmark: 10 million Float to Integer
require 'benchmark'
require 'carray'
require 'etc'
Ractor.new {} # show "warning: Ractor is experimental..."
puts "Making an Array of Floats..."
array = 10_000_000.times.map{500 * rand}
array1, array2, array3 = nil
nproc = Etc.nprocessors
Benchmark.bmbm do |x|
x.report("Float#to_i") {array1 = array.map &:to_i}
@kernigh
kernigh / primes2.pl
Created July 13, 2021 02:47
primes2.pl, a slower primes sieve
# primes2.pl by kernigh
#
# This solves https://github.com/PlummersSoftwareLLC/Primes in Perl
# using a vec string. It is slower than solution_1/primes.pl which
# uses an array: 7 iterations for primes2.pl versus 13 iterations for
# solution_1 on the same cpu.
#
# This primes2.pl is a translation from PrimeCPP.cpp, but without the
# count_primes method, and is "under BSD-new/BSD-3 or a more
# permissive license" (quoting CONTRIBUTING.md).
@kernigh
kernigh / dmesg
Created June 1, 2020 23:25
dmesg of PowerBook5,4
[ using 1143760 bytes of bsd ELF symbol table ]
console out [ATY,Jasper_A] console in [keyboard]USB and ADB found, using ADB
using parent ATY,JasperParent:: memaddr b8000000, size 8000000 : consaddr b8008000 : ioaddr b0020000, size 20000: width 1280 linebytes 1280 height 854 depth 8
Copyright (c) 1982, 1986, 1989, 1991, 1993
The Regents of the University of California. All rights reserved.
Copyright (c) 1995-2020 OpenBSD. All rights reserved. https://www.OpenBSD.org
OpenBSD 6.7-current (GENERIC) #9: Sat May 30 23:07:42 EDT 2020
kernigh@wisconsin.my.domain:/sys/arch/macppc/compile/GENERIC
real mem = 1073741824 (1024MB)
/*
* $ cc -O2 -o timefill timefill.c
* Add -DUSE_ASM for PowerPC asm.
*
* George Koehler modified this file on 2020-05-02. License is at
* https://github.com/milkytracker/MilkyTracker/blob/v1.02.00/COPYING
*
* This is a benchmark of PowerPC asm versus C for OpenBSD. It
* assumes clang or gcc. It might work on other BSDs and Linux, but
* you might need to provide timespecsub(3) if it is missing.
@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
@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 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]