Skip to content

Instantly share code, notes, and snippets.

View browny's full-sized avatar
👨‍💻

Browny Lin browny

👨‍💻
View GitHub Profile
@browny
browny / web-server.py
Created December 9, 2019 03:35
web-server.py
import tornado.ioloop
import tornado.web
import socket
class MainHandler(tornado.web.RequestHandler):
def get(self):
self.write("Hostname: " + socket.gethostname())
def make_app():
return tornado.web.Application([
@browny
browny / GKE101-Lab.md
Last active August 12, 2019 06:40
Labs of GKE101

Lab1

Introduction to Containers and Docker

Run the web server manually

# Provision a ubuntu VM
gcloud compute --project=infra101 instances create vm-based \
# Configuration for Alacritty, the GPU enhanced terminal emulator.
# Any items in the `env` entry below will be added as
# environment variables. Some entries may override variables
# set by alacritty itself.
#env:
# TERM variable
#
# This value is used to set the `$TERM` environment variable for
# each instance of Alacritty. If it is not present, alacritty will
#!/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