Skip to content

Instantly share code, notes, and snippets.

View browny's full-sized avatar
👨‍💻

Browny Lin browny

👨‍💻
View GitHub Profile
#!/bin/bash
# Usage:
# sh etcd-cluster.sh <instance_name>
INSTANCE_NAME=$1
REGISTRY=quay.io/coreos/etcd
# available from v3.2.5
REGISTRY=gcr.io/etcd-development/etcd
@browny
browny / main.go
Created October 28, 2018 11:25
Dialogflow webhook sample code
package main
import (
"encoding/json"
"fmt"
"log"
"net/http"
"strconv"
owm "github.com/briandowns/openweathermap"
@browny
browny / vegeta.sh
Last active October 3, 2021 16:29
Run distributed load testing based on GCP and vegeta
#!/bin/bash
# Usage: bash vegeta.sh <rate> <duration>
ACTION="GET http://google.com"
DURATION=${2:-5s}
RATE=${1:-10}
SLAVE_INSTANCES=$(gcloud compute instances list | grep vegeta- | awk '{print $1}')
SSH_ARGS="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
# --- run cmd on all slave instances in parallel ---
type MyLogger struct{}
func (m *MyLogger) Log(format string, v ...interface{}) {
log.Printf(format, v...)
}
type Master struct {
Logger `inject:"logger"`
Food `inject:"example.Master.Food"`
Transport `inject:"example.Master.Transport"`
func (s *InjectTestSuite) TestWeave() {
driver := example.Driver{}
farmer := example.Farmer{}
master := example.Master{}
myLogger := example.MyLogger{}
tillageMachine := example.TillageMachine{}
depMap := map[interface{}][]string{
&myLogger: []string{
"logger",

Keybase proof

I hereby claim:

  • I am browny on github.
  • I am browny (https://keybase.io/browny) on keybase.
  • I have a public key whose fingerprint is AEC5 6DF6 1F27 9E26 E27D 836F C0B3 8FD2 BC2F C101

To claim this, I am signing this object:

type fileReader struct {
src string
}
func (f *fileReader) Read() ([]byte, error) {
return ioutil.ReadFile(f.src)
}
type dbReader struct {
host string
type IReader interface {
Read() ([]byte, error)
}
type IWriter interface {
Write(dat []byte) error
}
func (e *Encryptor) Run(r IReader, w IWriter) error {
// read file
func (e *Encryptor) Run(
srcType, dstType, x, y, z, i, j string,
) error {
var src []byte
switch srcType {
case "file":
src = e.readFromFile(x, y, z)
case "database":
src = e.readFromDatabase(i, j)
}
func (e *Encryptor) Run(srcType, dstType string) error {
var src []byte
switch srcType {
case "file":
src = e.readFromFile(x, y, z)
case "database":
src = e.readFromDatabase(i, j)
}
// encrypt