Skip to content

Instantly share code, notes, and snippets.

View just1689's full-sized avatar
☁️
In the cloud

Justin Tamblyn just1689

☁️
In the cloud
  • South Africa
View GitHub Profile
@just1689
just1689 / Dockerfile
Created May 7, 2019 08:12
Golang 1.12.4 Dockerfile with multistage build
FROM golang:1.12.4-alpine3.9 as builder
RUN mkdir /user && \
echo 'nobody:x:65534:65534:nobody:/:' > /user/passwd && \
echo 'nobody:x:65534:' > /user/group
RUN apk add --no-cache ca-certificates git
WORKDIR /src
# Use postgres/example user/password credentials
version: '3.1'
services:
db:
image: postgres
restart: always
environment:
POSTGRES_PASSWORD: toor
@just1689
just1689 / embedded.go
Created February 20, 2019 14:22 — forked from joshrotenberg/embedded.go
embedded nsqd
package main
// This is a basic example of running an nsqd instance embedded. It creates
// and runs an nsqd with all of the default options, and then produces
// and consumes a single message. You are probably better off running a
// standalone instance, but embedding it can simplify deployment and is
// useful in testing.
// See https://github.com/nsqio/nsq/blob/master/nsqd/options.go and
// https://github.com/nsqio/nsq/blob/master/apps/nsqd/nsqd.go for
version: "3"
services:
scylla-node1:
build: ./scylla
restart: always
networks:
web:
environment:
@just1689
just1689 / accounts.sql
Created October 9, 2018 05:38
Create trx db
-- postgres@11e07910117d:/$ pg_dump trx -t accounts -U trx
--
-- PostgreSQL database dump
--
-- Dumped from database version 10.5 (Debian 10.5-1.pgdg90+1)
-- Dumped by pg_dump version 10.5 (Debian 10.5-1.pgdg90+1)
SET statement_timeout = 0;
SET lock_timeout = 0;
regis
-----
```
$ openssl pkcs12 -nokeys -in regis-ctr.pfx -out regis-ctr.pem
$ openssl pkcs12 -nocerts -nodes -in regis-ctr.pfx -out regis-ctr.key
```
@just1689
just1689 / default.conf
Created September 19, 2018 14:17
Nginx reverse proxy config
server {
listen 80;
server_name konga.colaboratory.co.za;
sendfile on;
location / {
proxy_buffer_size 64k;
proxy_buffers 16 32k;
@just1689
just1689 / deployment.yaml
Created September 11, 2018 22:57
Creating something and exposing it in K8s
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-nginx
spec:
selector:
matchLabels:
run: my-nginx
replicas: 2
template:
@just1689
just1689 / main.go
Last active April 8, 2018 11:20
Go routines communicating back and forth
package main
import "fmt"
func main() {
channel := make(chan int)
done := make(chan bool)
start := 0
go playerOne(channel, done)
@just1689
just1689 / main.go
Last active April 8, 2018 11:20
Query multiple sources at once - return first
func Query(conns []Conn, query string) Result {
ch := make(chan Result)
for _, conn := range conns {
go func(c Conn) {
select {
case ch <- c.DoQuery(query):
default:
}
}(conn)
}