Skip to content

Instantly share code, notes, and snippets.

@timoyuen
timoyuen / README.md
Created Mar 4, 2019 — forked from jirikuncar/README.md
Traefik - header matching
View README.md

Traefik routing

Proxy to services based on Accept header.

Run

docker-compose up -d

Test

View docker-compose.yml
version: '3'
services:
frontproxy:
image: traefik
command: --api --docker
ports:
- "80:80"
- "443:443"
volumes:
@timoyuen
timoyuen / cookie_jar_golang.go
Created Feb 1, 2019 — forked from varver/cookie_jar_golang.go
Login to a website with this golang code using persistent cookies or cookie jar .
View cookie_jar_golang.go
View gist:2861ca2d9dd05d3836b25f46e6a36fed

Here's the canonical TOML example from the TOML README, and a YAML version of the same. Which looks nicer?

title = "TOML Example"

[owner] name = "Tom Preston-Werner"

@timoyuen
timoyuen / 1_kubernetes_on_macOS.md
Created Jan 11, 2019 — forked from kevin-smets/1_kubernetes_on_macOS.md
Local Kubernetes setup on macOS with minikube on VirtualBox and local Docker registry
View 1_kubernetes_on_macOS.md

Requirements

Minikube requires that VT-x/AMD-v virtualization is enabled in BIOS. To check that this is enabled on OSX / macOS run:

sysctl -a | grep machdep.cpu.features | grep VMX

If there's output, you're good!

Prerequisites

@timoyuen
timoyuen / graphql-example.js
Created Jan 2, 2019 — forked from everdimension/graphql-example.js
simplified graphql explanation
View graphql-example.js
// Say we need to display list of posts showing *only* their titles
// and name of the post author
// without graphql
const data = {
posts: null,
usersById: {},
};
get('/api/posts')
@timoyuen
timoyuen / .dockerignore
Created Dec 6, 2018 — forked from remarkablemark/.dockerignore
Docker Node.js Example
View .dockerignore
node_modules/
*.log
@timoyuen
timoyuen / middleware.go
Created Oct 31, 2018 — forked from stefanwuthrich/middleware.go
Casbin Authorization for qiangxue/golang-restful-starter-kit
View middleware.go
package util
import (
"net/http"
"github.com/casbin/casbin"
"github.com/qiangxue/golang-restful-starter-kit/app"
"github.com/go-ozzo/ozzo-routing"
)
// Authorizer is a middleware that controls the access to the HTTP service, it is based
@timoyuen
timoyuen / .drone.yml
Created Oct 30, 2018 — forked from d0x2f/.drone.yml
.drone.yml example
View .drone.yml
workspace:
base: /build
pipeline:
dbnode1:
detach: true
image: mysql/mysql-cluster:7.5
commands:
- sleep 5
@timoyuen
timoyuen / dump-restore
Created Jul 25, 2018 — forked from ricjcosme/dump-restore
DUMP / RESTORE PostgreSQL Kubernetes
View dump-restore
DUMP
// pod-name name of the postgres pod
// postgres-user database user that is able to access the database
// database-name name of the database
kubectl exec [pod-name] -- bash -c "pg_dump -U [postgres-user] [database-name]" > database.sql
RESTORE
// pod-name name of the postgres pod
// postgres-user database user that is able to access the database
// database-name name of the database
You can’t perform that action at this time.