Skip to content

Instantly share code, notes, and snippets.

@brablc
brablc / diogenesjs.html
Last active March 16, 2024 02:05
Diogenes JS
<script>
function $debug(...args) {
console.log('debug', ...args);
}
function $on(eventName, callback) {
document.currentScript.parentElement.addEventListener(eventName, callback);
}
function $send(element, name, detail) {
let event = new CustomEvent(name, { detail: detail, bubbles: true });
element?.dispatchEvent(event);
@brablc
brablc / benchmark-htmx-js-libraries.py
Last active March 5, 2024 18:07
Browser performance benchmark for htmx compatible JS libraries (alpine, surreal, hyperscript, htmx)
import argparse
import os
import requests
parser = argparse.ArgumentParser(
description="""
Generates testing files for JS libraries that are popular with htmx.
Run --setup first to download libraries for local use.
A separate file for each library will be generated - timing is done with console.time and console.timeEnd.
"""
@brablc
brablc / fixutf.sh
Created February 16, 2022 10:33
Fix broken UTF-8 when copying text from PDF to Word on Mac
pbpaste | iconv -f utf8-mac -t utf-8//TRANSLIT | pbcopy
#!/usr/bin/php
<?php
if (!array_key_exists(1, $argv)) {
exit("Missing first param - path to parsed XML file! \nUse as {$argv[0]} </path/to/file.xml>\n");
}
if (!file_exists($argv[1])) {
exit("File {$argv[1]} not found!\n");
}
@brablc
brablc / le-check-affected-domains.sh
Last active March 4, 2020 10:22
Let's Encrypt Serial Check
wget https://d4twhgtvn0ff5.cloudfront.net/caa-rechecking-incident-affected-serials.txt.gz
zcat caa-rechecking-incident-affected-serials.txt.gz | awk '{print $2}' | sort > serials_only.txt
find /etc/letsencrypt/live -name 'cert.pem' -printf "%h\n" | cut -f5 -d/ | xargs -I% echo "echo \$(openssl x509 -text -noout </etc/letsencrypt/live/%/cert.pem | grep -A1 Serial\ Number | sed -e 1d -e's/://g' ) %" | sh > serials_hosted_with_domain.txt
cut -f1 -d\ serials_hosted_with_domain.txt | sort >serials_hosted.txt
comm -12 serials_only.txt serials_hosted.txt > affected_domains.txt
@brablc
brablc / shoptet-dataLayer-new.js
Last active October 31, 2018 15:40
Shoptet dataLayer - new
dataLayer = [];
dataLayer.push({'shoptet' : {
"pageType": "productDetail",
"product": {
"id": 47844,
"guid": "00d1a8e3-51be-11e7-819d-002590dc5efc",
"hasVariants": true,
"codes": [
{
"code": "47844\/38",
@brablc
brablc / shoptet-dataLayer-old.js
Last active October 31, 2018 15:40
Shoptet dataLayer - old
dataLayer = [];
dataLayer.push({'shoptet' : {
"pageType": "productDetail",
"product": {
"id": 47844,
"guid": "00d1a8e3-51be-11e7-819d-002590dc5efc",
"hasVariants": true,
"codes": {
"47844\/38": {
"amount": -5,
@brablc
brablc / shoptet-addon-html-codes-example.html
Last active July 7, 2019 18:20
Shoptet add-on HTML codes example
<script type="text/javascript">
var demoPartner = { 'host': '#HOST#', 'projectId': #PROJECT_ID#, 'template': '#TEMPLATE#' };
</script>
<script src="https://cdn.myshoptet.com/usr/demo-partner.myshoptet.com/user/documents/addon_1/common.js" type="text/javascript"></script>
<link href="https://cdn.myshoptet.com/usr/demo-partner.myshoptet.com/user/documents/addon_1/#TEMPLATE#.css" rel="stylesheet" />
<link href="https://cdn.myshoptet.com/usr/demo-partner.myshoptet.com/user/documents/addon_1/#HOST#/style.css?v=1" rel="stylesheet" />
@brablc
brablc / dnsmasq macOS.md
Last active September 24, 2021 10:24 — forked from ogrrd/dnsmasq OS X.md
Setup dnsmasq on OS X

Never touch your local /etc/hosts file in OS X again

To setup your computer to work with *.test domains, e.g. project.test, awesome.test and so on, without having to add to your hosts file each time.

Requirements

Install

@brablc
brablc / katalog.xsl
Created December 10, 2016 13:29
Shoptet Katalog XML Stylesheet
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output
method="html"
version="4.01"
encoding="utf-8"
indent="yes"
omit-xml-declaration="yes"
doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN" />
<xsl:template match="/">