Skip to content

Instantly share code, notes, and snippets.

lestrrat lestrrat

Block or report user

Report or block lestrrat

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
lestrrat /
Created Dec 20, 2019
use strict;
use lib "local/lib/perl5";
use Data::Dumper;
use Image::ExifTool qw(:Public);
use Time::Piece;
my $name = "___CHILD'S_NAME___";
my @files;
for my $file (glob("*.jpg")) {
# Installs mariadb in Debian 9 GCP VM, creates self-signed certificates,
# sets up the server config, and restarts the mysql server
set -e
set -x
apt-get update
apt-get install -y mysql-server
View gist:db1e1310efc0d52cae563d2e9130fd91
# App Engine Standard Go 1.9 migration to Go 1.11
tag:["google-app-engine", "Go"]
Migrating from Go 1.9 to 1.11 in App Engine Standard isn't just a matter of updating Go itself -
it introduces a major update in the runtime itelf. Because of this, you can't just change your
code to work on Go 1.11 and expect it to be deployed properly. You will need to work on a few
more issues.
This article describes the new runtime known as the Google App Engine Standard 2nd Gen,
lestrrat /
Created Oct 30, 2018
Ever wanted to make health checks for GCP LBs (created from GKE ingress objects) to look at Cloud Endpoint's ESP server's alternate health check port? Well you're in luck, my friend.
set -e
# Script to configure the healthcheck for ESP
# (ESP listens on a separate port from the main port for healthchecks)
SERVICE_NAME="This the name of your service that you proxy your requests to"
ESP_HEALTH_CHECK_PORT_NAME="This is the name of the port that ESP listens for health checks."
ESP_MAIN_PORT_NAME="This is the name of the port that ESP listens for the actual service."
lestrrat /
Last active Dec 12, 2017
Delete dangling TCP Load Balancers on GCP Created By Kubernetes Services
use strict;
use JSON ();
my $src = qx(gcloud compute forwarding-rules list --format json);
my $json = JSON->new;
my $rules = $json->decode( $src );
for my $rule (@$rules) {
print "forwarding-rule $rule->{name}:\n";
if ($rule->{description} =~ m{kubernetes\.io/service-name}) { # TCP (k8s Service with external address)
my ($target_pool) = ($rule->{target} =~ m{/([^/]+)$});
View handler.go
// Wrap the handler with a context that holds the transaction
func withTx(h http.Handler) http.Handler {
return http.HandleFunc(func(w http.ResponseWriter, r *http.Request) {
tx, err := globalDB.BeginTx(r.Context())
if err != nil {
r = r.WithContext(context.WithTx(r.Context(), tx))
h.ServeHTTP(w, r)
lestrrat /
Last active Jun 1, 2019
Seven Stages of Becoming a Go Programmer
  • stage 1: You believe you can make Go do object oriented programming. You want to do this by using clever struct embedding.
  • stage 2: You believe goroutines will solve all of your problems. You want to use goroutines for anything and everything that you can, who cares if the code becomes a bit more complicated
  • stage 3: You believe that instead of object oriented programming, interfaces will solve all of your problems. You want to define everything in terms of interfaces
  • stage 4: You believe channels will solve all of your problems. You want to do everything from synchronization, returning values, and flow control using channels.
  • stage 5: You now believe Go is not as powerful as people claim it to be. You feel like you're stripped of all of the nice tools and constructs that other languages provide.
  • stage 6: You realize that stages 1~5 were all just your imagination. You just didn't want to accept the Go way. Everything starts to make sense.
  • stage 7: You are now at peace
use strict;
use feature 'say';
sub is_anagram {
my ($s1, $s2) = @_;
my %chars1;
my %chars2;
for my $c (split //, $s1) {
lestrrat / wc.go
Last active Sep 25, 2016
View wc.go
package main
import (
You can’t perform that action at this time.