Skip to content

Instantly share code, notes, and snippets.

View lzap's full-sized avatar
🇪🇺
I break software for living.

Lukáš Zapletal lzap

🇪🇺
I break software for living.
View GitHub Profile
Starting: /home/lzap/go/bin/dlv dap --listen=127.0.0.1:39597 --log-dest=3 from /home/lzap/work/edge-api/cmd/migrate
DAP server listening at: 127.0.0.1:39597
Configuration Values:
Migration started ...
Opening database host=localhost user=postgres dbname=edge port=5432
SELECT version()
Postgres information: 'PostgreSQL 15.6 on x86_64-redhat-linux-gnu, compiled by gcc (GCC) 13.2.1 20231205 (Red Hat 13.2.1-6), 64-bit'
SELECT count(*) FROM pg_indexes WHERE tablename = 'third_party_repos' AND indexname = 'idx_third_party_repos_name' AND schemaname = CURRENT_SCHEMA()
Model index ThirdPartyRepo "idx_third_party_repos_name" exists deleting ...
DROP INDEX "idx_third_party_repos_name"
@lzap
lzap / example.json
Created February 28, 2024 15:32
Netboot OCI example
{
"schemaVersion": 2,
"mediaType": "application/vnd.oci.image.manifest.v1+json",
"artifactType": "application/vnd.unknown.artifact.v1",
"config": {
"mediaType": "application/vnd.oci.empty.v1+json",
"digest": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"size": 0
},
"layers": [
@lzap
lzap / foreman.ks
Created January 22, 2024 09:56
Foreman bootable container test
%pre
skopeo login foreman-nuc2.example.com -u lzap -p changeme --tls-verify=false
skopeo copy docker://foreman-nuc2.example.com/demo-lzap-fedora-bootc:eln oci:/var/tmp/container --tls-verify=false
%end
text
ostreecontainer --url=/var/tmp/container --transport=oci --no-signature-verification
user --name lzap --password $6$ptTfOsCpq5XA2qs6$FXMtwoMCQ4EJ698PXqJHuu/LS34WsomG2v1Cy5SzDtges40IaL4N.K2/7We6ertVDlA5tYhYofhNLAbfArGdH1 --iscrypted --groups wheel
sshkey --username lzap "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEhnn80ZywmjeBFFOGm+cm+5HUwm62qTVnjKlOdYFLHN lzap+ssh_redhat.com"
@lzap
lzap / hwaddr.go
Created July 26, 2023 14:56
Sortable HardwareAddr Golang
type HwAddrSlice []net.HardwareAddr
func (s HwAddrSlice) Len() int {
return len(s)
}
func (s HwAddrSlice) Swap(i, j int) {
s[i], s[j] = s[j], s[i]
}
@lzap
lzap / sources.diff
Created May 22, 2023 13:46
Working example for getting sources in one request
Index: internal/clients/http/sources/sources_client.go
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/internal/clients/http/sources/sources_client.go b/internal/clients/http/sources/sources_client.go
--- a/internal/clients/http/sources/sources_client.go (revision 5dc168130a2751cfead58bf47576a79c0b5f4218)
+++ b/internal/clients/http/sources/sources_client.go (date 1684762681785)
@@ -5,6 +5,8 @@
"encoding/json"
@lzap
lzap / gist:a87a4a7fb71df4a9ddd017d4bd4c788c
Created May 15, 2023 18:13
Computer latency at human scale
System event Actual latency Scaled latency
------------ -------------- --------------
One CPU cycle 0.4 ns 1 frame (1/60 s)
Level 1 cache access 0.9 ns 2 frames
Level 2 cache access 2.8 ns 7 frames
Level 3 cache access 28 ns 1 s
Main memory access (DDR) ~100 ns 4 s
Intel Optane memory access <10 μs 7 min
NVMe SSD I/O ~25 μs 17 min
SSD I/O 50–150 μs 0.5—2 hrs
@lzap
lzap / benchmark.go
Created April 29, 2023 11:18
Fixed benchmark and results from the https://blog.jetbrains.com/go/2023/04/27/comparing-db-packages/ blog post
package main
import (
"context"
"database/sql"
"fmt"
"log"
"time"
"gorm.io/gorm"
@lzap
lzap / bench.diff
Created April 27, 2023 17:10
Updated benchmark results for sqlite3 for article https://blog.jetbrains.com/go/2023/04/27/comparing-db-packages/
diff --git a/go-db-comparison/benchmarks/benchmark.go b/go-db-comparison/benchmarks/benchmark.go
index b6dc9f9..17e4955 100644
--- a/go-db-comparison/benchmarks/benchmark.go
+++ b/go-db-comparison/benchmarks/benchmark.go
@@ -6,30 +6,34 @@ import (
"log"
"time"
- "gorm.io/driver/mysql"
"gorm.io/gorm"
@lzap
lzap / gf.sh
Last active April 13, 2023 07:48
Script to fetch all branches and fast forward merge master/main/develop without checkout
#!/bin/bash
#UPSTREAM=origin
UPSTREAM=upstream
function bexists() {
local branch=${1}
local existed_in_local=$(git branch --list ${branch})
if [[ -z ${existed_in_local} ]]; then
package main
import (
"fmt"
"time"
)
func main() {
start := time.Now()
_ = p0(200_000)