Skip to content

Instantly share code, notes, and snippets.

View hearnadam's full-sized avatar

Adam Hearn hearnadam

View GitHub Profile
@hearnadam
hearnadam / Derive.scala
Created March 29, 2025 03:15
Scala 3 Type Masking
object Derive:
import scala.quoted.*
inline def derive[Contents, Mask]: NotIn[Contents, Mask] =
${ deriveImpl[Contents, Mask] }
private def deriveImpl[Contents: Type, Mask: Type](using q: Quotes): Expr[NotIn[Contents, Mask]] = {
import quotes.reflect.*
if (inMask[Contents, Mask]) {
report.errorAndAbort(s"Type ${Type.show[Contents]} is in Mask: ${Type.show[Mask]}")
} else {
@hearnadam
hearnadam / after.json
Created January 26, 2025 03:48
Ref.Atomic: after.json
[
{
"jmhVersion" : "1.37",
"benchmark" : "zio.stm.SingleRefBenchmark.refContention",
"mode" : "thrpt",
"threads" : 1,
"forks" : 4,
"jvm" : "/opt/homebrew/Cellar/openjdk/23.0.1/libexec/openjdk.jdk/Contents/Home/bin/java",
"jvmArgs" : [
],
@hearnadam
hearnadam / before.json
Created January 26, 2025 03:47
Ref.Atomic: before.json
[
{
"jmhVersion" : "1.37",
"benchmark" : "zio.stm.SingleRefBenchmark.refContention",
"mode" : "thrpt",
"threads" : 1,
"forks" : 4,
"jvm" : "/opt/homebrew/Cellar/openjdk/23.0.1/libexec/openjdk.jdk/Contents/Home/bin/java",
"jvmArgs" : [
],
[info] Benchmark Mode Cnt Score Error Units
[info] TypeMapBench.accessKyo thrpt 5 18473921.121 ± 291669.914 ops/s
[info] TypeMapBench.accessKyo:gc.alloc.rate thrpt 5 0.010 ± 0.028 MB/sec
[info] TypeMapBench.accessKyo:gc.alloc.rate.norm thrpt 5 0.001 ± 0.002 B/op
[info] TypeMapBench.accessKyo:gc.count thrpt 5 ≈ 0 counts
[info] TypeMapBench.accessZIO thrpt 5 6195532.475 ± 255445.260 ops/s
[info] TypeMapBench.accessZIO:gc.alloc.rate thrpt 5 8977.581 ± 386.679 MB/sec
[info] TypeMapBench.accessZIO:gc.alloc.rate.norm thrpt 5 1520.002 ± 0.004 B/op
[info] TypeMapBench.accessZIO:gc.count thrpt 5 139.000 counts
[info] TypeMapBench.accessZIO:gc.t
@hearnadam
hearnadam / canvas-tour.user.js
Created February 7, 2022 17:46
Userscript to block Canvas (Instructure) Student Tour
// ==UserScript==
// @name Canvas Student Tour Blocker
// @namespace https://github.com/hearnadam
// @author https://github.com/hearnadam
// @description Block canvas from showing student tour every time you clear your cookies.
// @version 1.0
// @match https://*canvas.*.edu/*
// @match https://canvas.com/*
// @match https://*.instructure.com/*
// @icon https://www.google.com/s2/favicons?domain=instructure.com
@hearnadam
hearnadam / prepareChess
Created May 4, 2021 20:24
A script to prepare a submission of the chess program written for CSIS370 @ George Fox University
#!/bin/bash
rm .gitignore;
mkdir obj bin;
chmod 644 Makefile;
chmod 644 include/*.h;
chmod 644 src/*.cpp;