Skip to content

Instantly share code, notes, and snippets.

@leonstafford
leonstafford / gist:3559d9f180a17c3863b47f5621a39788
Created September 5, 2021 04:16
install-go-inside-lokl-alpine
# combination of a cpl of SO answers
apk add --no-cache --virtual .build-deps bash gcc musl-dev openssl go
wget -O go.tgz https://dl.google.com/go/go1.10.3.src.tar.gz
tar -C /usr/local -xzf go.tgz
cd /usr/local/go/src/
go env -w GO111MODULE=auto
./make.bash
export PATH="/usr/local/go/bin:$PATH"
export GOPATH=/opt/go/
export PATH=$PATH:$GOPATH/bin
@leonstafford
leonstafford / cf_worker_simple_kv_read_static_site.js
Created March 21, 2020 14:19
CF Worker simple KV read for static site
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
/**
* Respond to the request
* @param {Request} request
*/
async function handleRequest(request) {
const url = new URL(request.url);
@leonstafford
leonstafford / openbsd_anycast_stream_ffmpeg.md
Last active June 12, 2019 04:33
Stream with ffmpeg to AnyCast M4 Plus

scan ports with

nc -z IPADDRESS 1-1000 #extend port range

  • use -u for UDP instead of CTP

Discovered open ports (TCP)

80 2425

@leonstafford
leonstafford / openbsd_xdebug_segfault.md
Last active June 3, 2019 15:33
OpenBSD + PHP + Xdebug segfaults

Needs inivestigation: Assumed due to OpenBSD's memory address security through randomization

Xdebug (when doing code coverage, especially?) performs a 2-pass of the code, more info here https://derickrethans.nl/phps-twopass-compiler.html)

Can re-run Xdebug multiple times and sometimes get lucky without segfault...

Reproducible with WP2Static's composer coverage

Running phpunit tests/unit does not segfault

@leonstafford
leonstafford / install.sh
Created June 3, 2019 14:24 — forked from tvlooy/install.sh
Use OpenBSD's pledge and unveil syscalls in PHP
# Note that this is for people that want to build it from source, using pecl
# This code is in official OpenBSD ports now https://marc.info/?l=openbsd-ports-cvs&m=154270973708561
pkg_add php-7.2.10
ln -s /usr/local/bin/php-7.2 /usr/local/bin/php
ln -s /usr/local/bin/phpize-7.2 /usr/local/bin/phpize
ln -s /usr/local/bin/php-config-7.2 /usr/local/bin/php-config
pkg_add autoconf-2.69p2
export AUTOCONF_VERSION=2.69
@leonstafford
leonstafford / kdenlive_crash_openbsd.txt
Last active May 28, 2019 06:40
KDEnlive crash OpenBSD
Occurs when trying to drag any videos to timeline. Also occurs within program Lives
Videos play fine from ffmpeg/melt.
sample small video to reproduce: http://mirrors.standaloneinstaller.com/video-sample/video-sample.avi
ktrace:
```
1737 kdenlive CALL mmap(0,0x81000,0x3<PROT_READ|PROT_WRITE>,0x5002<MAP_PRIVATE|MAP_ANON|MAP_STACK>,-1,0)
@leonstafford
leonstafford / elementor_custom_attributes.php
Last active December 21, 2018 10:12
elementor add custom attributes to pricing table buttons
<?php
function wp2static_snipcart_callback($buffer) {
$html_output = $buffer;
$dom = new DOMDocument();
$dom->loadHTML($html_output);
$finder = new DomXPath($dom);
$classname="elementor-price-table__button";
@leonstafford
leonstafford / linux_tile_business_cards.md
Created October 24, 2018 05:56
how to tile an image for business card printing in CLI

using pdfjam

pdfjam --nup 2x5 --papersize '{8.27in,11.69in}' --noautoscale true business-card-wp2static-1-up.pdf '1,1,1,1,1,1,1,1,1,1' -o 10upcard.pdf

@leonstafford
leonstafford / tmux resize editor pane to 80 chars width
Last active October 23, 2018 03:08
width restrict tmux to same as editor
# allow for 3 cols of line numbers and red line limiter
`resize-pane -t 0 -x 84`
# moving between panes
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# large history limit
set -g history-limit 999999999