Skip to content

Instantly share code, notes, and snippets.

View tbreuss's full-sized avatar
🚴‍♂️
Biking

tebe tbreuss

🚴‍♂️
Biking
View GitHub Profile
@tbreuss
tbreuss / split-xml.php
Created December 7, 2024 05:44
Splits a large XML file with many elements into individual XML files per element using PHP and DOMDocument
<?php
/**
* Splits a large XML file with many elements into individual XML files per element using PHP and DOMDocument
*
* The script does the following:
* - Load original XML
* - Create template XML and remove elements
* - For each element of the original XML
* - Create a clone of the template XML
* - Add element of the original XML to the clone
@bohwaz
bohwaz / dns_get_record_from.php
Last active January 22, 2025 22:18
PHP script to retrieve a DNS record from a custom nameserver
<?php
/**
* Make a DNS a request to a custom nameserver, this is similar to dns_get_record, but allows you to query any nameserver
* Usage: dns_get_record_from('ns.server.tld', 'A', 'mydomain.tld');
* => ['42.42.42.42']
* @author bohwaz
*/
function dns_get_record_from(string $server, string $type, string $record, string $protocol = 'udp'): array
{
@tbreuss
tbreuss / docker-enc2ly.md
Last active January 1, 2021 16:14
Converting Encore files to LilyPond using Docker

This is a solution to run the original enc2ly CLI program within a Docker container.

There are two CLI programs that convert Encore musical files to LilyPond.

Unfortunately I wasn't able to run these programs on my MacOS.

So, here are the instructions for using the original enc2ly CLI programm within a Docker container.

@brandonros
brandonros / preact-htm-example.html
Last active August 9, 2024 04:32
Preact + Hyperscript Tagged Markup (HTM) example
<!DOCTYPE html>
<html>
<head>
<title>Preact HTM Example</title>
</head>
<body>
<script type="module">
// 1. imports from unpkg.com
import * as Preact from 'https://unpkg.com/[email protected]/dist/preact.module.js'
import htm from 'https://unpkg.com/[email protected]/dist/htm.module.js'
@tiebingzhang
tiebingzhang / udptextd.php
Created July 2, 2020 18:06
An one-off PHP UDP server to listen on a UDP port and print the text received. Can be used as a very basic UDP log listener.
#!/usr/bin/php -f
<?php
error_reporting(~E_WARNING);
//Create a UDP socket
if(!($sock = socket_create(AF_INET, SOCK_DGRAM, 0))) {
$errorcode = socket_last_error();
$errormsg = socket_strerror($errorcode);
die("Couldn't create socket: [$errorcode] $errormsg \n");
}
echo "Socket created \n";
@Mrxchaoz
Mrxchaoz / Function.Array-Group-By.php
Created January 21, 2020 02:47 — forked from mcaskill/Function.Array-Group-By.php
PHP : Groups an array by a given key
<?php
if (!function_exists('array_group_by')) {
/**
* Groups an array by a given key.
*
* Groups an array into arrays by a given key, or set of keys, shared between all array members.
*
* Based on {@author Jake Zatecky}'s {@link https://github.com/jakezatecky/array_group_by array_group_by()} function.
* This variant allows $key to be closures.
@pyrou
pyrou / docker-compose.yml
Last active February 26, 2025 16:06
Use https://traefik.me SSL certificates for local HTTPS without having to touch your /etc/hosts or your certificate CA.
version: '3'
services:
traefik:
restart: unless-stopped
image: traefik:v2.0.2
ports:
- "80:80"
- "443:443"
labels:
- "traefik.http.services.traefik.loadbalancer.server.port=8080"
@odan
odan / splitting-pdf.md
Last active November 28, 2024 16:27
Spliting a PDF file into multiple PDF files

Spliting a PDF file into multiple PDF files

This function extracts all of the pages from a larger PDF file into single-page PDF files.

Installation

composer require setasign/fpdi-fpdf
@thephez
thephez / json-rpc-oas-example.json
Created December 4, 2018 17:33
Example of describing JSON-RPC 2.0 API with OpenAPI
{
"x-send-defaults": true,
"openapi": "3.0.0",
"x-api-id": "json-rpc-example",
"info": {
"title": "JSON-RPC OpenAPI",
"version": "1.0.0",
"description": "Example of how to describe a JSON-RPC 2 API in OpenAPI"
},
"servers": [

Fix for FOUC :

At the top of your HTML:

<!doctype html>
<html>
<head>
    <style>html{visibility: hidden;opacity:0;}</style>