Skip to content

Instantly share code, notes, and snippets.

View mrcrilly's full-sized avatar

Michael Crilly mrcrilly

View GitHub Profile
package main
import (
"flag"
"fmt"
"html/template"
"io/ioutil"
"os"
"strconv"
"strings"
@mrcrilly
mrcrilly / 1_kubernetes_on_macOS.md
Created September 20, 2018 23:40 — forked from kevin-smets/1_kubernetes_on_macOS.md
Local Kubernetes setup on macOS with minikube on VirtualBox and local Docker registry

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

@mrcrilly
mrcrilly / a.go
Created June 27, 2018 01:42
A versus B; as little abstraction as possible versus more abstraction
package main
import (
"fmt"
)
type person struct {
name string
age int
}
@mrcrilly
mrcrilly / gin_jwt_middleware.go
Last active February 23, 2024 01:13
Gin JWT Middleware (Example)
package main
import (
"errors"
"net/http"
"strconv"
"strings"
"time"
"github.com/dgrijalva/jwt-go"
@mrcrilly
mrcrilly / main.go
Last active February 27, 2018 04:13
This is why I think an FSM is a good idea on APIs
package main
import (
"fmt"
"log"
"net/http"
"github.com/julienschmidt/httprouter"
"github.com/looplab/fsm"
)
dataChannel := make(<-chan uint)
go iCanRead(dataChannel)
iCanWrite(dataChannel) // cannot use dataChannel (type <-chan uint) as type chan uint in argument to iCanWrite
func iCanRead(inbound chan uint) {
for {
message, _ := <-inbound
time.Sleep(time.Second)
// We don't like five, so we put it back in the channel
if message == 5 {
inbound <- message
continue
}
func iCanRead(inbound <-chan uint) {
for {
message, _ := <-inbound
fmt.Println(message)
time.Sleep(time.Second)
if message == uint(10) {
return
}
}
@mrcrilly
mrcrilly / main.go
Last active February 23, 2018 05:56
func main() {
dataChannel := make(chan uint)
go iCanRead(dataChannel)
iCanWrite(dataChannel)
}
func iCanRead(inbound chan uint) {
for {
message, _ := <-inbound
fmt.Println(message)
time.Sleep(time.Second)
if message == uint(10) {
return
}
}