Skip to content

Instantly share code, notes, and snippets.

@jakzal
jakzal / crawler-edit.php
Last active January 22, 2024 13:18
Removing nodes with DomCrawler
<?php
<<<CONFIG
packages:
- "symfony/dom-crawler: ~2.3"
- "symfony/css-selector: ~2.3"
CONFIG;
use Symfony\Component\DomCrawler\Crawler;
$html = <<<HTML
@jakzal
jakzal / MyThing.php
Last active December 19, 2023 11:08
Mocking ArrayAccess with prophecy in phpspec
<?php
class MyThing
{
private $myArray = null;
public function __construct($myArray)
{
$this->myArray = $myArray;
}
@jakzal
jakzal / 1 Readme.md
Last active December 13, 2023 21:18
Nextcloud behind Cloudflare on a Raspberry PI
@jakzal
jakzal / 00 - Object-oriented event sourcing.adoc
Last active November 30, 2023 14:17
Object-oriented event sourcing
@jakzal
jakzal / 00 - Deriving state from events.adoc
Last active November 30, 2023 14:17
Deriving state from events
@jakzal
jakzal / 1-HOWTO.md
Last active November 22, 2023 11:47
Raspberry PI 4 / RaspBee II / Docker / Home Assistant

Raspberry Pi OS installation

Install Raspberry Pi OS Lite 64bit with the Raspberry Pi Imager.

Enable ssh with key authentication, change the host name, set the user password, the WiFi password. etc.

Configuration

  1. Boot the Pi.
@jakzal
jakzal / TestDataBuilder.php
Last active April 26, 2023 20:37
Test data builder
<?php
namespace Acme\Builder;
class TestDataBuilder
{
/**
* @var array
*/
protected $defauts = [];
@jakzal
jakzal / tunnel.sh
Last active April 2, 2023 23:15
Run an http/https tunnel with ngrok
#!/usr/bin/env bash
COMMAND=${1:-"help"}
PROJECT_DIR=$(dirname $(readlink -f $0))"/.."
BIN_DIR=$PROJECT_DIR"/bin"
LOG_PATH=$PROJECT_DIR"/app/logs/ngrok.log"
NGROK_PATH=$BIN_DIR"/ngrok"
PARAMETERS_PATH=$PROJECT_DIR"/app/config/parameters.yml"
@jakzal
jakzal / Singleton.java
Created March 23, 2023 10:32
Singleton Supplier
package com.kaffeinelabs.function;
import java.util.function.Supplier;
public class Singleton<T> implements Supplier<T> {
private final Supplier<? extends T> factory;
private T instance = null;
private Singleton(final Supplier<? extends T> factory) {
this.factory = factory;