Skip to content

Instantly share code, notes, and snippets.

View stefanwuthrich's full-sized avatar
😁

Stefan Wüthrich stefanwuthrich

😁
View GitHub Profile
package main
import (
"fmt"
"math/big"
"runtime"
"sync"
"time"
)
@stefanwuthrich
stefanwuthrich / util.co
Created March 26, 2019 03:54
Replace first match of a Sstring item in a String Slice
func ReplaceStringInSlice(slice []string, replace string, with string) []string {
for i, v := range slice {
if v == replace {
slice = append(slice[:i], slice[i+1:]...)
slice = append(slice, with)
return slice
}
}
return slice
}
@stefanwuthrich
stefanwuthrich / middleware.go
Created November 21, 2017 06:01
Casbin Authorization for qiangxue/golang-restful-starter-kit
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
@stefanwuthrich
stefanwuthrich / start.sh
Last active April 22, 2019 19:55
run docker tools on windows with hyper-v installed, but disabled (http://www.hanselman.com/blog/SwitchEasilyBetweenVirtualBoxAndHyperVWithABCDEditBootEntryInWindows81.aspx) (File start.sh is here C:\Program Files\Docker Toolbox)
#!/bin/bash
trap '[ "$?" -eq 0 ] || read -p "Looks like something went wrong... Press any key to continue..."' EXIT
VM=default
DOCKER_MACHINE=./docker-machine.exe
if [ ! -z "$VBOX_MSI_INSTALL_PATH" ]; then
VBOXMANAGE="${VBOX_MSI_INSTALL_PATH}VBoxManage.exe"