Skip to content

Instantly share code, notes, and snippets.

View davidhofmann's full-sized avatar

L&S David Hofmann davidhofmann

View GitHub Profile
@davidhofmann
davidhofmann / fp-array.js
Last active October 2, 2025 13:30
JS: Functional programming helpers
/*
Copyright (c) 2022 David Hofmann <the.urban.drone@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions
of the Software.
@davidhofmann
davidhofmann / chart-pie.slisp
Last active February 9, 2021 12:05
Using Chart.js with Sibilisp
(use-all "chart.js" chartjs)
(use "./chartbase"
(create-chart-base :as base)
(create-chart-colors :as colors))
(provide
(defun create-pie-chart (data labels)
(lambda (el)
(let* ((place-into (base))
(chart (new chartjs (place-into el)
@davidhofmann
davidhofmann / accordion.js
Last active March 3, 2021 10:14
Stateful value/observer – various PoC's
import { VCell } from './vcell.js';
const SELECTOR_WIDGET = '.accordion';
const SELECTOR_CLICKAREA = '.accordion_btn';
const SELECTOR_MASK = '.accordion_mask';
const SELECTOR_BODYAREA = '.accordion_body';
const CLASS_OPEN = 'is--open';
export function autoStart(selector = SELECTOR_WIDGET) {
@davidhofmann
davidhofmann / bgimage.css
Last active June 7, 2021 09:58
Responsive Background-Images via Sibilisp
.bgimage {
display: block;
background-color: hsl(0, 0%, 0%);
background-repeat: no-repeat;
background-size: cover;
background-position: 50% 50%;
}
.bgimage--16_9 {
width: 100%;
@davidhofmann
davidhofmann / filesys.slisp
Last active August 30, 2023 05:27
Sibilisp Node Packages
(use-all "fs-extra" fse)
(defconstant *DEFAULT_ENCODING* "utf8")
(defconstant *DEFAULT_FILEMODE* 0o775) ; this does not work right now, sibilant does not support octals
(provide
(defun make-dir! (dir-path)
(|> dir-path
@davidhofmann
davidhofmann / arrays.js
Last active October 7, 2024 15:02
Functional programming tools right on the prototypes!
(function (run) {
run(Array.prototype, Array);
})(function (P, C) {
C.empty = C.zero = function () {
return [];
};
C.isArrayOf = function (a, f) {
return Array.isArray(a) && a.every(x => f(x));