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
@lzap
lzap / harmless-playbook.yaml
Created November 3, 2021 18:48
Example Ansible playbook
---
- name: Ensure vim on localhost1
hosts: localhost1
remote_user: root
tasks:
- name: Ensure vim-minimal is installed
ansible.builtin.yum:
name: vim-minimal
state: latest
@lzap
lzap / main.go
Created April 5, 2022 11:47
AWS SDK V2 test
package main
import (
"context"
"errors"
"fmt"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/credentials"
"github.com/aws/aws-sdk-go-v2/service/ec2"
@lzap
lzap / instance.go
Created April 6, 2022 10:53
Create an EC2 instance in Go SDK V2
func CreateInstance(client *ec2.Client) {
input := &ec2.RunInstancesInput{}
input.DryRun = aws.Bool(true)
input.ImageId = aws.String("ami-08c308b1bb265e927")
input.InstanceType = types.InstanceTypeT3Micro
input.MinCount = aws.Int32(1)
input.MaxCount = aws.Int32(1)
resp, err := client.RunInstances(context.TODO(), input)
if err != nil {
fmt.Println(err)
@lzap
lzap / azure-lighthouse-subscription-vm-management.json
Last active August 19, 2022 08:10
MS Azure Lighthouse Test: lzap's personal account
{
"$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"mspOfferName": {
"type": "string",
"metadata": {
"description": "Specify a unique name for your offer"
},
"defaultValue": "Red Hat Cloud Provisioning"
@lzap
lzap / otelpgx5.patch
Created September 23, 2022 10:13
OpenTelemetry provisioning patch for pgx/v5
Index: internal/db/connection.go
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/internal/db/connection.go b/internal/db/connection.go
--- a/internal/db/connection.go (revision c976e66ddccd4ba8ed8cb5e7e82686161aa305cb)
+++ b/internal/db/connection.go (date 1663920062746)
@@ -1,15 +1,20 @@
package db
@lzap
lzap / test-subscription.json
Last active November 16, 2022 12:08
Example Lighthouse subscription - redhat.com tenant
{
"$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"mspOfferName": {
"type": "string",
"metadata": {
"description": "Specify a unique name for your offer"
},
"defaultValue": "Red Hat Cloud Provisioning"
package main
import (
"fmt"
"time"
)
func main() {
start := time.Now()
_ = p0(200_000)
@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
@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 / 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"