Skip to content

Instantly share code, notes, and snippets.

View Groostav's full-sized avatar

Geoff Groostav

View GitHub Profile
@Groostav
Groostav / 1 SSCCE_1.f90
Last active April 17, 2025 05:18
intel ifx 2024 and 2025 compiler crash
module SSCCE_1
USE IFPORT
USE IFCORE
USE ISO_C_BINDING
USE, INTRINSIC :: IEEE_ARITHMETIC
IMPLICIT NONE
! Define interface of call-back routine.
ABSTRACT INTERFACE
TYPE(C_PTR) FUNCTION evaluatorCallback(inputMat,matM,matN,chosenFunctions,length)&
@Groostav
Groostav / Recovery.kt
Created January 22, 2025 22:21
code to manually recover a database file --requires OASIS classpath
package com.empowerops.front_end
import com.empowerops.common.Serializer.DataInputAdapter
import com.thoughtworks.xstream.XStream
import com.thoughtworks.xstream.io.HierarchicalStreamReader
import com.thoughtworks.xstream.io.HierarchicalStreamWriter
import com.thoughtworks.xstream.io.binary.BinaryStreamDriver
import com.thoughtworks.xstream.io.xml.PrettyPrintWriter
import com.thoughtworks.xstream.io.xml.XppDriver
import com.thoughtworks.xstream.security.WildcardTypePermission
@Groostav
Groostav / CommaSeparatedtextMatrixLexer.kt
Created January 19, 2025 07:36
non-functioning scanner impl
object CommaSeparatedTextMatrixLexer {
private val LINE_END = Pattern.compile(";?\r?\n")
private val COMMA = Pattern.compile(",\\s*")
private val NAME = Pattern.compile("[^;\r\n,]+")
private val NAME_AND_LINE_END = Pattern.compile("[^;\r\n,]+;?\r?\n")
fun tokenize(stream: InputStream): Sequence<MatrixToken> {
val chars = Scanner(stream)
@Groostav
Groostav / rant.md
Last active October 29, 2024 22:53
request for advice on migration from pub-sub to flows

This is a long one.

My problem: I'm having trouble backpressureing a function that is currently using an old pub/sub device on one of its events (that is to say: I have a producer that is running too fast for my consumer). I'm using guava's EventBus, which is old and very stateful. This works fine for many use cases, but in this particular backpressure case I've got deadlock for reasons I dont entirely understand if a subscriber calls runBlocking{} to attempt to block ImportantService when it fires a message.

EventBus is effectively depricated; it's really convienient for UI (read: giant stateful objects) but it's awful for any service trying to maintain referential transparency (read: using pure functions and composing message processing with things like flow.map)

At its core, I have this kind of object:

class ImportantService(..., private val eventPublisher: EventBus){

Getting element type from a Kotlin Array

Context: You are working on project that uses Java SDK version 16., Kotlin API version 1.9. Messages: 8


User: if I have a kotlin Array, how can i get the element type from it? That is, given vars: Array, how can I get a Class?

@Groostav
Groostav / rom-readme.md
Created April 26, 2024 03:47
rom description 2024-04-25

Reduced Order Modelling Toolkit

version 0.1. by Empower Operations. Copyright 2023.


This repository contains releases (sans source code) for the Reduced Order Modelling "ROM" toolkit by Empower Operations "empower-rom".

This is the culmination of work from research by Empower Operations under grant from the Government of Canada. We hope it helps you accelerate engineering!

@Groostav
Groostav / JavaSwitchExpressions.java
Created September 11, 2023 16:17
attempt 2 at benchmarking different switch types
package org.example;
public class JavaSwitchExpressions {
public static int intSwitchExpression(Node node) {
return switch(node.typeInt()){
case 0 -> ((Node.FirstNodeType) node).firstId();
case 1 -> ((Node.SecondNodeType) node).secondId();
case 2 -> ((Node.ThirdNodeType) node).thirdId();
case 3 -> ((Node.FourthNodeType) node).fourthId();
@Groostav
Groostav / SwitchBenchmarks.java
Created September 6, 2023 23:13
attempting to performance profile forms java switch expressions
package org.example;
import org.openjdk.jmh.annotations.*;
import java.util.concurrent.TimeUnit;
@BenchmarkMode(Mode.Throughput)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
@Warmup(iterations = 5, time = 5)
@Measurement(iterations = 5, time = 1)
parser = argparse.ArgumentParser()
parser.addArgument('--print-metadata')
subparsers = parser.add_subparsers(dest='command')
subparsers.add_parser(name='build')
subparsers.add_parser(name='predict')
parsed_args = parser.parse_args()
match vars(parsed_args):
@Groostav
Groostav / dumb-dsl.kt
Last active March 1, 2023 22:46
An attempt to create a statically-checked "domain-path" type
sealed interface PathTrace<out T> {
val elements: List<Nodable>
class Composite(override val elements: List<Nodable>): PathTrace<Nothing>
open class Empty: PathTrace<Nothing> {
override val elements: List<Nodable> get() = emptyList()
}
}