This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
runtime: go111 | |
service: myservice | |
env_variables: | |
HOST: "0.0.0.0" | |
instance_class: B1 | |
basic_scaling: | |
max_instances: 2 | |
idle_timeout: 15m |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM golang:1.11.1 AS builder | |
WORKDIR /src | |
#avoid downloading the dependencies on succesive builds | |
COPY go.mod go.sum ./ | |
RUN go mod download | |
RUN go mod verify | |
COPY . . | |
RUN mkdir -p ./build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
c := make(chan os.Signal, 1) | |
signal.Notify(c, os.Interrupt) | |
// Block until we receive our signal. | |
<-c | |
log.Println("shutting down signal received, waiting ...") | |
ctx, cancel := context.WithTimeout(context.Background(), time.Second*15) | |
defer cancel() | |
srv.Shutdown(ctx) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if you use gcloud but the app requires | |
gcloud auth application-default login | |
export GOOGLE_APPLICATION_CREDENTIALS="/home/$USER/.config/gcloud/application_default_credentials.json" | |
#https://docs.docker.com/machine/drivers/gce/#example | |
docker-machine create --driver google --google-project YOURPORJECTID --google-machine-type f1-micro VMNAME |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#install FlameGraph library | |
cd /opt/ | |
sudo git clone https://github.com/brendangregg/FlameGraph.git | |
#make it accesible from any folder | |
vim ~/.bashrc | |
##add these lines anywhere and exit vim (if you can) | |
export FLAMEPATH=/opt/FlameGraph | |
PATH=$PATH:$FLAMEPATH | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Set struct { | |
list map[int]struct{} //empty structs occupy 0 memory | |
} | |
func (s *Set) Has(v int) bool { | |
_, ok := s.list[v] | |
return ok | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#chrome | |
cd /tmp | |
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb | |
sudo dpkg -i google-chrome-stable_current_amd64.deb | |
sudo apt-get -f install | |
#docker | |
sudo apt-get update | |
sudo apt-get install -y \ | |
apt-transport-https \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func TestFibonacci(t *testing.T) { | |
f := func(n int) (r int) { | |
a, b := 0, 1 | |
for i := 2; i <= n; i++ { | |
b, a = a+b, b | |
} | |
return b | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/etc/systemd/system/ folder | |
[Unit] | |
Description=Start TightVNC server at startup | |
After=syslog.target network.target | |
[Service] | |
Type=forking | |
User=YOURUSER | |
PAMName=login | |
PIDFile=/home/YOURUSER/.vnc/%H:%i.pid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gcloud init | |
gcloud auth login | |
gcloud config set project newID | |
#create the app from the UI or ... gcloud app create --region="us-central" | |
gcloud app deploy --verbosity="info" | |