RSSAmplifier

Blog

Development blog

Doodlings and stuff.

olleharstedt.github.ioRSS feed ↗10 posts

Latest posts

Declarative domain-specific language for receipt printer

What? Write a declerative domain-specific langugae (DSL) that works as a template engine for a receipt printer. Why? An old printer class is decaying beyond any recognition. What used to be pure layout code is now littered with conditionals to decide padding and formatting, even when the injected printer driver class is used to distinguish between different printers. Just clean up the printer…

How to evaluate an applicants attitude

In nurse education they sometimes talk about the triplet “skill, knowledge, attitude” towards patient safety [1]. In the development world, we can be quite good with evaluating skills and knowledge, but how about evaluating and talking about constructive attitudes? Been part of setting up a hiring pipeline before, with some exercises in OOP design given to the participants, which should be…

Web development is a solved problem

DRAFT Maybe I’ve stagnated. Maybe I’m not being challenged. Stagnated on a handful of design patterns than can solve 99% of problems thrown at it. Pipeline Command object for steps in pipeline Data transfer object and intermediate representations for communication between pipeline steps Events for extensibility Message queue for async processing Abstract base-class for code reuse, with shallow…

Replace dependency injection and mocking with algebraic effects

The main idea is, instead of injecting what you need, you ask for it using an effect . If you don’t know what an algeabraic effect is, you can read about it on StackOverflow or Wikipedia . To quote the Stackoverflow answer: In short, algebraic effects are an exception mechanism which lets the throwing function continue its operation. Since PHP does not support effects, I’m using fibers to simulate…

Associative personal knowledge base

DRAFT A concept so simple I wondered why I haven’t thought of it before. And why it isn’t already built-in in bash. This is a command-line interface to a knowledge base, using association and ownership. The interface consists of five basic commands: put to put a new entity in the database desc to describe an entity (either add new description or fetch one) is-a to add a is-a relation has-a to add…

Wrap a DSL around PHPUnit to reduce boilerplate

DRAFT Use strategy pattern to inject new keywords into the DSL parser class. Each keyword is responsible for its own evaluation. Load new keywords this way using a (load lib.php) statement. Basic syntax and semantics: Losely inspired by Emacs Lisp. First item in list is function, rest is arguments Application is using space, as in (+ 1 2) , or (f x y) Strings use quotation " Numbers are integers…

We need to learn how to talk to radicalized people

DRAFT We need to learn how to talk to radicalized people. Not because they deserve it, but because it’s beneficial for us , long-term. How do you know if someone close to you has been radicalized? There’s a lot of talk of social media algorithms reducing trust and increasing radicalization. What’s the definition of being radicalized? Cult? Anti-rationalism? Anti-science, anti-argumentation. How…

Wrap a DSL around PHPUnit

DRAFT ; PHP Unit test ( test-class remotecontrol_handle ( test-method add_participants ( set ( participant ( list ( map ( "firstname" "John" ))))) ( set ( surveyId 1 )) ( set ( sessionKey "abc123" )) ( arguments sessionKey surveyId participant 'false ) ( result ( list ( map ( "firstname" "John" ))))) )

Report generating domain-specific language

Why can’t the customers write their own damn reports? Or the sales people. Or the technical support. They already know some basic SQL, right? How hard could it be to create a safe subset of SQL, that also includes some HTML formatting capability? But the parser would have to be dirt simple. I don’t want to end up with a big pile of code only I can maintain. What kind of language would work best?…

How do I write a map function in Forth?

TODO: DRAFT Introduction Short example of how to create an FP-like map word in Forth. Acknowledgments GeDaMo and others on Libera IRC ##forth channel. Code \ Create an array of size 4 and store four numbers on it create arr 4 , 10 , 20 , 30 , 40 , : count ( A -- A+cell N ) dup \ Duplicate address of array cell+ \ Move forward one cell swap \ ? @ ; : map ( A N xt -- ) >r \ Put xt on return stack?…