Skip to content

Instantly share code, notes, and snippets.

/*
* $ 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 / 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)
@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 / 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 / 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 / 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 / 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;