Skip to content

Instantly share code, notes, and snippets.

View martinsirbe's full-sized avatar
🇱🇻
( ͡° ͜ʖ ͡°)_/¯ Labāk zīle rokā, nekā dzenis kokā.

Mārtiņš Irbe martinsirbe

🇱🇻
( ͡° ͜ʖ ͡°)_/¯ Labāk zīle rokā, nekā dzenis kokā.
View GitHub Profile
@martinsirbe
martinsirbe / funny-spec.yaml
Last active April 26, 2024 15:31
Just testing things... Move along...
openapi: 3.0.3
info:
title: Joke API
version: 1.0.0
paths:
/chuckle:
post:
summary: Send a chuckle-worthy number
description: >
Send a number that thinks it’s too cool. But remember, we’re too cool to keep it!
@martinsirbe
martinsirbe / gist:648dcb67e2f776f1f9ba1e8b5a69871f
Last active February 27, 2024 09:08
Use GPG key to sign git commits. (macOS)
brew install gpg pinentry-mac
# generate a new GPG key
gpg --full-generate-key
# list and copy pasta GPG key ID
gpg --list-secret-keys --keyid-format=long
# export it
gpg --armor --export <ID>
@martinsirbe
martinsirbe / O'Reilly Design Books (Free).md
Created November 19, 2023 19:09 — forked from udezekene/O'Reilly Design Books (Free).md
Download the just released O'Reilly Design Books for free without e-mail signup.

Free O'Reilly Design Books and convenient script to just download them.

HUGE thanks to O'Reilly for making this resource free. Visit the design page if you want to learn more about the design resources. Also, they do have FREE resources for other topics like: Data, IoT, Programming, Security, Web Development, and WebOps.

Thanks @augbog for the initial gist. If you are a developer or looking for software engineering books, headover to the source of this fork.

How to use:

  1. Take the download.sh file and put it into a directory where you want the files to be saved.
  2. cd into the directory and make sure that it has executable permissions (chmod +x download.sh should do it)
@martinsirbe
martinsirbe / tar_files_to_docker_container.md
Created February 17, 2023 09:59
Copy files to a Docker container without mounting a volume.

Create a tar archive of the files you want to add to the container using the following command:

tar -cz /path/to/files | docker run -i -t <image-name> tar -xz -C /data

This command will create a tar archive of the files you want to add to the container, and then pipe the output to the docker run command with the -it flags. The docker run command will then start a new container with the specified image and run the tar command inside the container to extract the files to the /data directory.

@martinsirbe
martinsirbe / main.go
Created July 9, 2020 16:08
An example of variadic function in Go.
package main
import "fmt"
const (
BaseURLType = "base_url"
HealthCheckURLType = "health_check"
)
type URLOption interface {
@martinsirbe
martinsirbe / Makefile
Created March 25, 2020 15:42
docker run postgres with health check to wait for postgres container to become healthy
.PHONY: postgres
postgres:
@docker run \
--rm \
--name postgres \
--health-cmd='pg_isready -U postgres || exit 1' \
--health-interval=2s \
--health-retries=10 \
-e POSTGRES_DB=db \
-e POSTGRES_USER=usr \
@martinsirbe
martinsirbe / main.go
Created May 10, 2019 08:40
An example of how to determine whether JSON element is null or is missing when decoding JSON to a Go struct. https://play.golang.org/p/cJCHJAbWhav
package main
import (
"encoding/json"
"fmt"
"log"
"strings"
)
type Test struct {
@martinsirbe
martinsirbe / main.go
Last active April 6, 2022 09:22
running limited amount of goroutines concurrently https://goplay.tools/snippet/sx0a_xBTqf3
package main
import (
"fmt"
"sync"
"time"
)
func processJob(i int) {
time.Sleep(time.Duration(5) * time.Second)
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
<Appenders>
<Console name="Console">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</Console>
</Appenders>
<Loggers>
<Root level="error">
<AppenderRef ref="Console"/>