Skip to content

Instantly share code, notes, and snippets.

View shanemhansen's full-sized avatar

Shane Hansen shanemhansen

View GitHub Profile
package ai.shane;
import com.google.api.core.ApiFunction;
import com.google.api.core.ApiFuture;
import com.google.api.core.ApiFutureCallback;
import com.google.api.core.ApiFutures;
import com.google.api.gax.core.ExecutorProvider;
import com.google.api.gax.core.FixedExecutorProvider;
import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider;
import com.google.cloud.pubsub.v1.Publisher;
@shanemhansen
shanemhansen / covid19-wfh.md
Last active March 13, 2020 10:18
Tips on WFH during COVID-19

On WFH

Author: shanemhansen Date: 2020-03-03

Due to recent events, many people who aren’t used to working from home might be working from home. Given that I spent the previous 5 years prior to Google managing a fully remote group of people WFH now seems like a good time to share some observations of what works and typical pitfalls.

Communications

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
javascript:!function(){var e,t,n;try{var o=document.querySelectorAll("div[data-name='Active Items'] div[data-asin]"),r=[["ProductID","Price","Quantity","Description","Link"].join(",")];o.forEach(function(e){var t=e.getAttribute("data-price"),n=e.getAttribute("data-quantity"),o=e.getAttribute("data-asin"),c=e.querySelector(".sc-product-link").href,a='"'+e.querySelector(".sc-product-title").textContent.replace(/"/g,'""').trim()+'"';r.push([o,t,n,a,c].join(","))}),e=r.join("\n"),t=document.createElement("textarea"),n=document.getSelection(),t.textContent=e,document.body.appendChild(t),n.removeAllRanges(),t.select(),document.execCommand("copy"),n.removeAllRanges(),document.body.removeChild(t)}catch(e){return void alert("Copy failed: "+e)}alert("Copy Successful, csv in in your clipboard")}();

Load balancing

A survey of techniques for scaling busyish websites for non-experts.

Who Am I?

  • Shane Hansen (@shanemhansen)
  • Walmartlabs Edge Engineering
  • Performance connoisseur
@shanemhansen
shanemhansen / gist:cb9cbf657499e351615cb22a30765112
Created December 14, 2017 16:50
Comparisong of string=="" vs len(string) == 0
"".TestEmpty STEXT nosplit size=22 args=0x18 locals=0x0
0x0000 00000 (/home/shansen/foo.go:14) TEXT "".TestEmpty(SB), NOSPLIT, $0-24
0x0000 00000 (/home/shansen/foo.go:14) FUNCDATA $0, gclocals·d4dc2f11db048877dbc0f60a22b4adb3(SB)
0x0000 00000 (/home/shansen/foo.go:14) FUNCDATA $1, gclocals·33cdeccccebe80329f1fdbee7f5874cb(SB)
0x0000 00000 (/home/shansen/foo.go:14) MOVQ "".val+16(SP), AX
0x0005 00005 (/home/shansen/foo.go:15) TESTQ AX, AX
0x0008 00008 (/home/shansen/foo.go:15) JNE 16
#!/usr/bin/env python
rate=0.07 # some interest rate 1==100% .07==7%
frequency=1/12.0 # yearly frequency
deposit_amount=200.0 # dollars
target=1000000 # dollars
current=100000 # dollars
@shanemhansen
shanemhansen / mymod.c
Last active May 2, 2017 21:26
Using go to write emacs plugins
#include <emacs-module.h>
// this is all boilerplate to deal with the fact that C function pointers aren't callable in go
typedef emacs_value (*internFunc) (emacs_env *env, const char *symbol_name);
typedef emacs_env *(*getEnvFunc) (struct emacs_runtime *ert);
typedef emacs_value (*makeFuncFunc) (emacs_env *env,
ptrdiff_t min_arity,
ptrdiff_t max_arity,
emacs_value (*function) (emacs_env *env,
ptrdiff_t nargs,
#include <iostream>
#include <fstream>
#include "concurrentqueue/blockingconcurrentqueue.h"
#include "glob.h"
#include <boost/iostreams/filtering_stream.hpp>
#include <boost/iostreams/copy.hpp>
#include <boost/iostreams/filter/zlib.hpp>
using namespace std;
void runQuery1(const string&);
#!/bin/bash
PKG="$1"
BIN="$2"
shift;shift
go install "$BIN"
$GOPATH/bin/$(basename $BIN) $@ &
while true; do