Skip to content

Instantly share code, notes, and snippets.

View paul-bjorkstrand's full-sized avatar

paul-bjorkstrand

View GitHub Profile
module = module ? {}
module.exports = (robot) ->
class Factoid
constructor: (@x, @v, @y) ->
robot.logger.info("making factoid [#{@x}, #{@v}, #{@y}]")
@y = if Array.isArray(@y) then @y else [@y]
respond: (robot, message) ->
robot.logger.info("responding to [#{@x}, #{@v}, #{@y}]")
switch @v
(async () => {
let response = await fetch('/system/console/status-pattern-detector.json');
let text = await response.text();
let json = text.replaceAll(/\n/g, ',')
.slice(0, -1);
let items = JSON.parse(`[${json}]`);
function getComponentName(item) {
//get the component name from the item
return "";
@paul-bjorkstrand
paul-bjorkstrand / cleanExample.java
Last active November 22, 2021 20:48
Loom snippets
// Roguh translation for my first approach, that had no way to an
// underlying error that occurred during execution of the tasks
class test {
public <V> List<V> test(List<Callable<V>> someTasks) {
try (var se = StructuredExecutor.open()) {
var futures = someTasks.stream()
.map(se::fork);
se.join();
@paul-bjorkstrand
paul-bjorkstrand / Main.java
Last active November 28, 2021 00:17
Loom simple actor pattern
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.FutureTask;
import java.util.concurrent.LinkedBlockingQueue;
public class Main {
public static void main(String[] args) {
var a1 = proxy(new TestActor("ta1"), Actor.class);
/*
* This is free and unencumbered software released into the public domain.
*
* Anyone is free to copy, modify, publish, use, compile, sell, or
* distribute this software, either in source code form or as a compiled
* binary, for any purpose, commercial or non-commercial, and by any
* means.
*
* In jurisdictions that recognize copyright laws, the author or authors
* of this software dedicate any and all copyright interest in the