Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
NAMESPACE=usecaseapp
SERVICE=usecaseapp
cat <<EOF | cfssl genkey - | cfssljson -bare server
{
"hosts": [
"${SERVICE}.${NAMESPACE}.svc.cluster.local"
],
@timoyuen
timoyuen / handler.go
Created February 22, 2020 04:05 — forked from trusch/handler.go
package events
import (
"encoding/json"
"io"
"net/http"
"github.com/joomcode/errorx"
"github.com/nats-io/go-nats-streaming"
uuid "github.com/satori/go.uuid"
@timoyuen
timoyuen / gist:993fc8cedda074bbef186192b18ca6b1
Created February 14, 2020 08:59 — forked from aodin/gist:9493190
Parsing JSON in a request body with Go
package main
import (
"encoding/json"
"io/ioutil"
"log"
"net/http"
)
type Message struct {
@timoyuen
timoyuen / api.go
Created February 14, 2020 08:59 — forked from bitristan/api.go
Send get and post request by golang
//发送get请求
func get(url string) string {
response, err := http.Get(url)
if err != nil {
fmt.Printf("%s", err)
os.Exit(1)
} else {
defer response.Body.Close()
contents, err := ioutil.ReadAll(response.Body)
if err != nil {
@timoyuen
timoyuen / install-make-coreos.sh
Created February 13, 2020 03:14
compile make for coreos
#!/bin/bash
docker run -ti --rm -v /opt/bin:/out ubuntu:14.04 \
/bin/bash -c "apt-get update && apt-get -y install make && cp /usr/bin/make /out/make"
apiVersion: v1
kind: Pod
metadata:
name: cockroachdb-client-secure
namespace: crdb
labels:
app: cockroachdb-client
spec:
serviceAccountName: cockroachdb
initContainers:
# Based on a modified script from here: http://tmont.com/blargh/2014/1/uploading-to-s3-in-bash
S3KEY="YOUR-ACCESSKEY"
S3SECRET="YOUR-SECRETKEY"
function putS3
{
path=$1
file=$2
aws_path=$3
@timoyuen
timoyuen / redis-cluster-backup.sh
Created June 2, 2019 13:30 — forked from juris/redis-cluster-backup.sh
Redis Cluster backup script
#!/bin/sh
readonly cluster_topology=$(redis-cli -h redis-cluster cluster nodes)
readonly slaves=$(echo "${cluster_topology}" | grep slave | cut -d' ' -f2,4 | tr ' ' ',')
mkdir -p /opt/redis-backup
for slave in ${slaves}
do
master_id=$(echo "${slave}" | cut -d',' -f2)
@timoyuen
timoyuen / gist:7c3f60e8b5ae335c87ddcab12ebcd999
Created May 10, 2019 04:51 — forked from rkuzsma/gist:b9a0e342c56479f5e58d654b1341f01e
Example Kubernetes yaml to pull a private DockerHub image
Step by step how to pull a private DockerHub hosted image in a Kubernetes YML.
export DOCKER_REGISTRY_SERVER=https://index.docker.io/v1/
export DOCKER_USER=Type your dockerhub username, same as when you `docker login`
export DOCKER_EMAIL=Type your dockerhub email, same as when you `docker login`
export DOCKER_PASSWORD=Type your dockerhub pw, same as when you `docker login`
kubectl create secret docker-registry myregistrykey \
--docker-server=$DOCKER_REGISTRY_SERVER \
--docker-username=$DOCKER_USER \
@timoyuen
timoyuen / postgres-cheatsheet.md
Created April 18, 2019 07:39 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)