Skip to content

Instantly share code, notes, and snippets.

@yusufsyaifudin
yusufsyaifudin / cleanup.sh
Last active May 15, 2019 04:32
Cleaning up docker to reclaim disk space
#!/bin/bash
# based on https://lebkowski.name/docker-volumes/
# remove exited containers:
docker ps --filter status=dead --filter status=exited -aq | xargs -r docker rm -v
docker volume ls -qf dangling=true | xargs -r docker volume rm
# remove unused images:
docker images --no-trunc | grep '<none>' | awk '{ print $3 }' | xargs -r docker rmi
@yusufsyaifudin
yusufsyaifudin / docker-compose.yml
Created October 15, 2019 04:33 — forked from everpeace/docker-compose.yml
kafka cluster in docker-compose.
# WARNING: This docker-compose.yml is only for testing purpose.
# Parameters:
# - name: CONFLUENT_PLATFORM_VERSION
# default: 3.0.0
# reference: https://hub.docker.com/u/confluentinc/
# Ports:
# - description: Major ports are exposed to host computer
# - zookeeper: 2181
# kafka1: 9091
# kafka2: 9092
parameter from request = page and limit
so,
offset = (page - 1) * limit
but you need to check if page <= 0 then page = 1
if limit <= 0 then set it to default minimum limit
@yusufsyaifudin
yusufsyaifudin / .gitlab-ci.yml
Last active February 27, 2024 14:01
Docker Compose: Redis, Consul, Mongo, Jaeger with Health check. Sample of gitlab-ci.yml for running Go test (integration test or unit test)
# Inspiration: https://b.agilob.net/test-coverage-in-gitlab-ci-in-a-golang-project
# Navigate to: "Settings" -> "CI/CD" -> "Expand" next to "General pipeline settings"
# 1. Add ^coverage:\s(\d+(?:\.\d+)?%) tas your regex in "Test coverage parsing"
# 2. Go to "Pipeline status" to get the badges code
# This file is a template, and might need editing before it works on your project.
image: golang:1.13.4-alpine
services:
- docker:stable-dind # only docker daemon, so we need to install docker cli and docker compose in separate script
@yusufsyaifudin
yusufsyaifudin / web-servers.md
Created November 30, 2019 02:10 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@yusufsyaifudin
yusufsyaifudin / ca_and_cert_golang_demo.go
Created February 25, 2020 08:54 — forked from shaneutt/LICENSE
Golang: Demonstrate creating a CA Certificate, and Creating and Signing Certs with the CA
package main
import (
"bytes"
"crypto/rand"
"crypto/rsa"
"crypto/tls"
"crypto/x509"
"crypto/x509/pkix"
"encoding/pem"
@yusufsyaifudin
yusufsyaifudin / postgres.yml
Last active May 6, 2020 08:18
docker compose for postgresql 12
# run with: docker-compose -f postgres.yml up
# psql "postgres://postgres:postgres@localhost:5433"
version: '3.1'
services:
db:
image: postgres:12-alpine
restart: always
environment:
package fsm
import (
"encoding/json"
"fmt"
"github.com/dgraph-io/badger/v2"
"github.com/hashicorp/raft"
"io"
"os"
"strings"
package store_handler
import (
"encoding/json"
"fmt"
"github.com/hashicorp/raft"
"github.com/labstack/echo/v4"
"net/http"
"strings"
"time"
@yusufsyaifudin
yusufsyaifudin / jaeger-component-kafka.yaml
Created November 19, 2020 09:33
Proof Of Concept: Deploying Scalable Jaeger Components
# MY_IP=$(ifconfig | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p') docker-compose up
# reference:
# https://github.com/jaegertracing/jaeger/blob/v1.21.0/docker-compose/jaeger-docker-compose.yml
# https://gist.github.com/bocharovf/e19fa80f7b5f6b65db17249c91e79416
version: "3.5"
services:
agent1:
image: jaegertracing/jaeger-agent:1.21
command: [
# see https://www.jaegertracing.io/docs/1.21/deployment/#discovery-system-integration