Skip to content

Instantly share code, notes, and snippets.

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

Mateusz Gozdek invidian

☁️
Finds bugs
  • Microsoft
  • Berlin
  • 20:26 (UTC +02:00)
  • X @_invidian
View GitHub Profile
@invidian
invidian / README.md
Last active November 10, 2022 13:08
Running "go test" command on a remote host using SSH

To use this snippet:

  1. Add the following to the package you would like to be able to test remotely:
    func TestMain(m *testing.M) {
      testutil.MainWithRemoteExecutionSupport(m)
    }
  2. Run your tests as GO_TEST_REMOTE_EXECUTION_SSH_HOST=<SSH host> go test ./<path to your package>.

In case your hosts use different glibc versions and you get an error executing a binary, add CGO_ENABLED=0 to the command above.

@invidian
invidian / Tiltfile
Created May 12, 2022 21:35
Tiltfile for local Go development with Docker compose
# -*- mode: Python -*-
local_resource('local-api-server',
cmd='make build-bin',
serve_env={
'S3_SECRET_ACCESS_KEY': 'minioadmin',
},
serve_cmd='./bin/server',
deps=[
'api',
@invidian
invidian / .semgrep.yml
Created May 4, 2022 12:27
Semgrep file whitespace rules
rules:
- id: files-must-not-have-trailing-whitespace
patterns:
- pattern-regex: '[[:blank:]]$'
message: Files must not have any trailing whitespace.
languages: [generic]
severity: ERROR
- id: files-must-not-have-trailing-newlines
patterns:
- pattern-regex: '\n\n\Z'
@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",
@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 / 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 / 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.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 / 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 / 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