Skip to content

Instantly share code, notes, and snippets.

View invidian's full-sized avatar
☁️
Finds bugs

Mateusz Gozdek invidian

☁️
Finds bugs
  • Microsoft
  • Berlin
  • 12:18 (UTC +02:00)
  • X @_invidian
View GitHub Profile
@invidian
invidian / terraform.patch
Created May 24, 2019 10:53
Quality formatting improvement with terraform 0.12upgrade
provisioner "file" {
@@ -115,96 +115,150 @@ Name = ${element(null_resource.server_names_tinc.*.triggers.name, count.index)}
Device = /dev/net/tun
AddressFamily = ipv4
BindToAddress = ${element(hcloud_server.servers.*.ipv4_address, count.index)}
-${replace(join("\n", formatlist("ConnectTo = %s", split(" ", replace(replace(replace(replace(replace(replace(join(",", null_resource.server_names.*.triggers.name), element(null_resource.server_names.*.triggers.name, count.index), ""), ",,", ","), ".${var.domain}", ""), "-", "_"), ",", " "), "/(^ | $)/", "")))), "/^ConnectTo = $/", "")}
+${replace(
+join(
+"\n",
+formatlist(
@invidian
invidian / main.go
Created October 2, 2019 10:19
Golang calculating max time
package main
import (
"fmt"
"time"
)
// hoursSince returns how many hours passed from given date.
// for Time 0 (time.Time{}), it returns 0.
func hoursSince(d time.Time) int {
@invidian
invidian / main.go
Created December 2, 2019 16:17
Golang reverse formatting with regex
package main
import (
"fmt"
"reflect"
"regexp"
"sort"
)
func main() {
@invidian
invidian / Vagrantfile
Created May 21, 2020 09:46
Vagrantfile for testing Tinkerbell
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/bionic64"
config.disksize.size = '30GB'
config.vm.provider :virtualbox do |v|
v.check_guest_additions = false
v.functional_vboxsf = false
v.cpus = 2
v.memory = 2048
@invidian
invidian / githubstatus
Created June 15, 2020 20:05
xfce4-genmon-plugin script for GitHub notifications
#!/bin/bash
NOTIFICATIONS_COUNT=0
NOTIFICATIONS_URL=https://github.com/notifications
ICONS_DIR=~/.cache/githubstatus-indicator
ICONS_SIZE=32
TEXT="No new notifications."
GITHUB_USERNAME=$(yq -r '.hosts["github.com"].user' ~/.config/gh/config.yml)
GITHUB_TOKEN=$(yq -r '.hosts["github.com"].oauth_token' ~/.config/gh/config.yml)
@invidian
invidian / main.c
Last active February 26, 2021 11:37
C unit tests time formatting
// Run using 'gcc main.c -g -O2 -pedantic -o main $(pkg-config gtk+-3.0 --cflags) && ./main'
#include <gdk/gdk.h>
#include <time.h>
#include <assert.h>
#include <limits.h>
static int hview_time_to_string(char *str, size_t maxsize, time_t time) {
struct tm *tm = gmtime(&time);
@invidian
invidian / delete-context-and-orphan-user-and-cluster-from-kubeconfig.sh
Created July 5, 2021 17:48
Script to delete context and orphan user and context from kubeconfig
#!/bin/bash
if [[ "$#" -ne 1 ]]; then
echo "Wrong number of arguments, expected 1, got $#."
exit 1
fi
CONTEXT_NAME=$1
KUBECONFIG="${KUBECONFIG:-~/.kube/config}"
@invidian
invidian / main.go
Created November 11, 2021 12:22
Golang stream gzip compression and decompression
package main
import (
"compress/gzip"
"io"
"log"
"os"
)
func main() {
@invidian
invidian / README.md
Created December 3, 2021 17:03
Golang hello world syscalls

Obtained using:

$ cat <<EOF > main.go
> package main

import "fmt"

func main() {
        fmt.Println("vim-go")
}
@invidian
invidian / seccomp.json5
Created December 3, 2021 17:08
Minimal seccomp profile for Docker container running Go binary
{
"defaultAction": "SCMP_ACT_ERRNO",
"syscalls": [
{
"names": [
// Used by Go binary.
"arch_prctl",
"clone",
"close",
"execve",