Skip to content

Instantly share code, notes, and snippets.

View amb26's full-sized avatar

Antranig Basman amb26

View GitHub Profile
<!DOCTYPE html>
<html>
<head>
<title>Infusion Todo List With Assignees</title>
<script src="../../dist/FluidInfusion.js"></script>
<fluid-url-base id="todoUrlBase" src="./"></fluid-url-base>
<!-- definitions for base app -->
/**
* Creates a single source effect that listens to changes in a computed signal and invokes a callback
* with the old and new values whenever the computed signal changes.
*
* @param {Computed} aComputed - The computed signal to observe.
* @param {Function} fn - A callback function with the signature (oldValue, newValue).
* @return {Effect} The created effect.
*/
fluid.singleSourceEffect = function (aComputed, fn) {
let oldValue = aComputed.value; // Initialize with the current value of the computed signal.
// Many thanks to Hugo Daniel https://hugodaniel.com/pages/boredom/ for inspiration for this concept
fluid.selfBootQuery = fluid.liveQuery("*[fl-layers]");
fluid.selfBootEffect = effect( () => {
const elements = fluid.selfBootQuery.value;
elements.forEach(element => {
const existing = fluid.viewContainerRegistry.get(element);
if (!existing) {
const layers = element.getAttribute("fl-layers");
const instance = fluid.viewComponent({
library(stringr)
library(dplyr)
library(HDInterval)
library(brms)
source("scripts/utils.R")
recordfiles <- c("A_formosa_detections_distances_to_first_records.csv",
"C_attenuata_detections_distances_to_first_records.csv",
@amb26
amb26 / fluid-signals.js
Created March 11, 2024 13:41
Spitball implementation of fluid.effect which delays notification until all referenced signals have moved away from undefined
fluid.effect = function (func, ...args) {
return effect( () => {
let undefinedSignals = false;
const designalArgs = [];
for (const arg of args) {
if (arg instanceof preactSignalsCore.Signal) {
const value = arg.value;
designalArgs.push(arg.value);
if (value === undefined) {
undefinedSignals = true;
@amb26
amb26 / imerss-new.js
Created March 2, 2024 23:44
Extremal version of imerss-new.js before destroying models
/*
Copyright 2017-2023 Antranig Basman
Licensed under the Educational Community License (ECL), Version 2.0 or the New
BSD license. You may not use this file except in compliance with one these
Licenses.
You may obtain a copy of the ECL 2.0 License and BSD License at
https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
*/
/* global Papa, maplibregl, HashTable, preactSignalsCore */
/* eslint-env node */
"use strict";
const linkedom = require("linkedom");
const arrow = `
<div class="long-down-arrow">
<svg width="16" height="111">
<use href="#downarrow" />
@amb26
amb26 / AllSpp.svg
Created December 15, 2023 20:03
Rowan's AllSpp.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@amb26
amb26 / testspeed2.txt
Created September 20, 2023 10:01
Testing time and space consumption of allocating JSON and DOM nodes - with 0 properties each
"use strict";
const testDOMSpeed = function (its) {
const array = [];
for (let i = 0; i < its; ++i) {
const element = document.createElement("div");
array.push(element);
}
return array;
};
@amb26
amb26 / testSpeed.txt
Created September 20, 2023 09:57
Testing time and space consumption of allocating JSON and DOM nodes - with 2 properties each
Program:
"use strict";
const testDOMSpeed = function (its) {
const array = [];
for (let i = 0; i < its; ++i) {
const element = document.createElement("div");
element.setAttribute("t1", "" + i);
element.setAttribute("t2", "" + i);