Skip to content

Instantly share code, notes, and snippets.

View brablc's full-sized avatar

Ondrej Brablc brablc

View GitHub Profile
@brablc
brablc / ncbackup.lua
Last active October 26, 2024 15:38
Neovim ncbackup
--[[
WORKED with NVchad, not with LazyVim, however - neovim's undo is making this obsolete
Description: Numbered Central Backup
Created by: Martin Krischik (2006)
Adapted by: Ondrej Brablc (2011 for vim, 2024 for neovim)
Customize:
vim.g.ncbackup_directory name of backup directory central to edited file by default ~/.local/state/nvim/ncbackups
vim.g.ncbackup_purge count of backups to hold - purge older once. 0 switches the feature off
@brablc
brablc / __init__.py
Created October 26, 2024 12:15
Pure Halloween 2024
# Stingy Jack Refactoring
# Good code doesn't need comments ...
# ... this dress code does
from matrix import BusinessSmart
from halloween import Lantern, PumpkinLantern
from typing import Protocol
__author__ = "Ondrej"
__version__ = "Halloween 2024"
@brablc
brablc / celery_monitor.py
Last active July 9, 2024 15:50
Django management command for Celery monitoring
# See https://github.com/brablc/swarm-health-alerter/edit/main/README.md#alerting-for-any-service
# Place to adm/management/commands/celery_monitor.py (change adm to your main application in the code too)
import os
import logging
import json
from celery import Celery
from celery.events import EventReceiver
from django.core.management.base import BaseCommand
@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 September 8, 2024 15:40
Browser performance benchmark for htmx compatible JS libraries (alpine, surreal, hyperscript, htmx)
import argparse
import os
import requests
from abc import ABC, abstractmethod
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,