Skip to content

Instantly share code, notes, and snippets.

View bep's full-sized avatar

Bjørn Erik Pedersen bep

View GitHub Profile
@bep
bep / go-test-all.sh
Created December 20, 2023 09:19
A zsh/bash function to test big Go projects in silent mode
function gota() {
set -o pipefail
go test -failfast ./... | { grep -Ev "^(\?|ok)\s+" || :; }
if [ $? -eq 0 ]
then
echo "Test OK."
else
echo "Test failed." >&2
fi
}
{{ $id := .Get 0 }}
<blockquote
class="instagram-media"
data-instgrm-permalink="https://www.instagram.com/p/{{ $id }}/?utm_source=ig_embed&amp;utm_campaign=loading"
data-instgrm-version="14"
style=" background:#FFF; border:0; border-radius:3px; box-shadow:0 0 1px 0 rgba(0,0,0,0.5),0 1px 10px 0 rgba(0,0,0,0.15); margin: 1px; max-width:540px; min-width:326px; padding:0; width:99.375%; width:-webkit-calc(100% - 2px); width:calc(100% - 2px);">
<div style="padding:16px;">
<a
href="https://www.instagram.com/p/{{ $id }}/?utm_source=ig_embed&amp;utm_campaign=loading"
style=" background:#FFFFFF; line-height:0; padding:0 0; text-align:center; text-decoration:none; width:100%;"
export function bridgeTurboAndAlpine(Alpine) {
document.addEventListener('turbo:before-render', (event) => {
Alpine.deferMutations();
});
document.addEventListener('turbo:render', () => {
if (document.documentElement.hasAttribute('data-turbo-preview')) {
return;
}

benchstat from two runs of Hugo 0.32 on a MacBook before and after the Meltdown update on macOS High Sierra:

name                                                                                                             old time/op    new time/op    delta
pkg:github.com/gohugoio/hugo/helpers goos:darwin goarch:amd64
StripHTML-4                                                                                                        3.56µs ± 0%    3.46µs ± 0%   ~     (p=0.100 n=3+3)
TestTruncateWordsToWholeSentence-4                                                                                  124ns ± 1%     126ns ± 1%   ~     (p=0.100 n=3+3)
TestTruncateWordsToWholeSentenceOld-4                                                                              6.55µs ± 0%    6.45µs ± 1%   ~     (p=0.100 n=3+3)
TotalWords-4                                                                                                       10.9µs ± 0%    10.9µs ± 1%   ~     (p=1.000 n=3+3)
TotalWordsOld-4                
go test -run="NONE" -bench="Benchmark.*" -test.benchmem=true -count=3 ./...

Hugo v0.31.1 vs v0.32:

benchmark                                                                                                                    old ns/op     new ns/op     delta
BenchmarkStripHTML-4                                                                                                         3557          3547          -0.28%
BenchmarkTestTruncateWordsToWholeSentence-4                                                                                  124           123           -0.81%
BenchmarkTestTruncateWordsToWholeSentenceOld-4                                                                               6402          6535          +2.08%
BenchmarkTotalWords-4                                                                                                        10852         10870         +0.17%
@bep
bep / keybase.md
Created September 25, 2017 23:41

Keybase proof

I hereby claim:

  • I am bep on github.
  • I am bep (https://keybase.io/bep) on keybase.
  • I have a public key whose fingerprint is 15BA B543 3F2B 427A C8DF 3773 8265 2D8B 4A9D 587A

To claim this, I am signing this object:

Developer Certificate of Origin Version 1.1
Copyright (C) 2004, 2006 The Linux Foundation and its contributors. 660 York Street, Suite 102, San Francisco, CA 94110 USA
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
Developer's Certificate of Origin 1.1
By making a contribution to this project, I certify that:
@bep
bep / hugo-on-android.md
Last active April 28, 2023 10:26
Run Hugo on an Android phone

First install Termux

Then there are two options:

Build from source

Open the Termux terminal on your Android device and copy-and-paste the commands listed below and hit ENTER:

Keybase proof

I hereby claim:

  • I am bep on github.
  • I am bep (https://keybase.io/bep) on keybase.
  • I have a public key whose fingerprint is AF2E 1F2C F3B5 A38D CC80 73E4 C640 08BC 136A 1391

To claim this, I am signing this object: