Skip to content

Instantly share code, notes, and snippets.

@yusufsyaifudin
yusufsyaifudin / parse_json.go
Created September 15, 2021 08:23 — forked from mjohnsullivan/parse_json.go
Parse JSON objects with arbitrary key names in Go using interfaces and type assertions
// Parsing arbitrary JSON using interfaces in Go
// Demonstrates how to parse JSON with abritrary key names
// See https://blog.golang.org/json-and-go for more info on generic JSON parsing
package main
import (
"encoding/json"
"fmt"
)
@yusufsyaifudin
yusufsyaifudin / useful_scripts.md
Last active July 23, 2021 02:29
Useful scripts

Useful script

Tunnel Private Network to Local using SSH Tunneling

ssh -L localhost:port:remote_ip:remote_port username@<IP that have access to remote_ip>
  • Ensure that you can SSH ssh username@<IP that have access to remote_ip> (public key already added in the instance)
  • Ensure that your SSH instance can access remote target, it can be db, http or etc
@yusufsyaifudin
yusufsyaifudin / main_test.go
Created March 23, 2021 11:22
Implement As method to convert interface type to the right data structure as it is first write. That means, if it use struct A, it only valid to output target as A. If we re-declare struct A, it will not match since it is not the real A in the first declaration.
package main_test
import (
"fmt"
"reflect"
"testing"
)
type AnimalName string

This is my learning towards how to generate Time Based OTP using SHA-512 algorithm.

@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
package store_handler
import (
"encoding/json"
"fmt"
"github.com/hashicorp/raft"
"github.com/labstack/echo/v4"
"net/http"
"strings"
"time"
package fsm
import (
"encoding/json"
"fmt"
"github.com/dgraph-io/badger/v2"
"github.com/hashicorp/raft"
"io"
"os"
"strings"
@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:
@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 / 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