Skip to content

Instantly share code, notes, and snippets.

View p4tin's full-sized avatar
💭
GO GO GO!!!

Paul Fortin p4tin

💭
GO GO GO!!!
View GitHub Profile
@p4tin
p4tin / simple_dep_injection_test.go
Last active July 9, 2018 01:41
Simple dependancy Injection example
package main
import (
"fmt"
"testing"
)
var ScreenPrint = fmt.Printf
func Greet(name string) {
@p4tin
p4tin / Dockerfile
Created July 1, 2018 14:47
Capturing docker stop in a golang application (no need for S6!!)
from alpine:latest
COPY main /
CMD [ "./main" ]
@p4tin
p4tin / rotate_and_match.go
Created June 21, 2018 03:51
Find words that have the same letters in a list
package main
import (
"fmt"
"strings"
)
func rotate(a []byte, i int) {
for count := 1; count <= i; count++ {
tmp := a[0]
@p4tin
p4tin / README.md
Last active June 21, 2018 01:11
Calling GO from python

After compiling libadd.go (with the command: "go build -buildmode=c-shared -o libadd.so libadd.go", it will have created 2 files (a libadd.so and libadd.h), the libadd.so is the shared library to call from python as shown in call_lib.h

@p4tin
p4tin / proxy.go
Last active February 24, 2018 03:07
Proxying a request to a backend
package main
import (
"net/http"
"net/http/httputil"
"net/url"
"github.com/gorilla/mux"
)
@p4tin
p4tin / k8s-pi.md
Created February 11, 2018 13:28 — forked from alexellis/k8s-pi.md
K8s on Raspbian

K8s on (vanilla) Raspbian Lite

Yes - you can create a Kubernetes cluster with Raspberry Pis with the default operating system Raspbian. Carry on using all the tools and packages you're used to with the officially-supported OS.

Pre-reqs:

  • You must use an RPi2 or 3 for Kubernetes
  • I'm assuming you're using wired ethernet (Wi-Fi also works)

Master node setup

@p4tin
p4tin / gen_slug.go
Last active January 18, 2018 04:04
package main
import (
"math/rand"
"time"
)
func init() {
rand.Seed(time.Now().UnixNano())
}
@p4tin
p4tin / sentinel.go
Created January 17, 2018 03:50
Go Routine Health Status - Future Kill/ReSpawn/Auto-Scale
package main
import (
"fmt"
"math/rand"
"sync"
"time"
)
const WORKERS = 3
@p4tin
p4tin / poller-receiver.go
Last active October 21, 2017 00:03
golang message receive-process skeleton
package main
import (
"os"
"os/signal"
"sync"
"syscall"
"time"
log "github.com/sirupsen/logrus"
@p4tin
p4tin / caddy
Created February 25, 2017 03:33 — forked from slav123/caddy
caddy init.d script
#!/bin/bash
# Caddy daemon
# chkconfig: 345 20 80
# description: Caddy daemon
# processname: caddy
DAEMON_PATH="/usr/local/bin"
DAEMON='./caddy'
DAEMONOPTS="-conf=/etc/caddy/Caddyfile -log /var/log/caddy.log"