Skip to content

Instantly share code, notes, and snippets.

:shipit:
coding

Sean Hagen seanhagen

:shipit:
coding
Block or report user

Report or block seanhagen

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
@seanhagen
seanhagen / go-config.el
Created Jun 24, 2019
Emacs LSP & yasnippet config
View go-config.el
;;; go-config.el --- Summary
;;; Commentary:
;;; Code:
(setenv "GOPATH" "/home/sean/Code/Go")
(use-package go-mode
:ensure t
:defer t
:mode "\\.go\\'"
@seanhagen
seanhagen / grpc-middleware.go
Created Apr 4, 2019
Honeycomb Go GRPC Middleware
View grpc-middleware.go
// HoneycombUnary returns an interceptor that adds Honeycomb metrics to any incoming unary requests.
func HoneycombUnary() grpc.UnaryServerInterceptor {
return func(ctx context.Context, r interface{}, i *grpc.UnaryServerInfo, h grpc.UnaryHandler) (interface{}, error) {
ctx, t, s := setupTrace(ctx, r, i.FullMethod, "unary")
defer t.Send()
o, err := h(ctx, r)
result := "success"
if err != nil {
View resources.md

Community

There is a Vancovuer Developers Slack channel which is a great forum to ask for help on projects, checkout freelance opportunities, or get together and code with others!

Vancouver Developers

And if you join the channel #lhl-coffee-code you can come hang out with us on Wednesdays and work on coding projects!

If you are interested in ethics in tech, we also have an ethics in tech meetup group - we'll probably have a group for this in Vancouver Developers at some point but if you're interested, feel free to drop me an email (sadiefreeman@gmail.com) and I can put you in touch.

@seanhagen
seanhagen / example.go
Created Feb 21, 2019
Example non-working pipeline
View example.go
package main
import (
"context"
"flag"
"log"
"reflect"
"cloud.google.com/go/bigquery"
ps "cloud.google.com/go/pubsub"
@seanhagen
seanhagen / events.go
Created Feb 11, 2019
Cloud Dataflow -- trying to get GCS writes working
View events.go
package main
import (
"bufio"
"context"
"flag"
"log"
"reflect"
ps "cloud.google.com/go/pubsub"
View anonymous-gist.go
// p := profile.Start(profile.CPUProfile, profile.ProfilePath("/tmp/prof"), profile.NoShutdownHook)
p := profile.Start(profile.MemProfile, profile.ProfilePath("/tmp/prof"), profile.NoShutdownHook)
time.AfterFunc(time.Minute, func() {
fmt.Printf("1 minute until profiling stopped\n")
})
time.AfterFunc(time.Minute*2, func() {
fmt.Printf("stopping profiling\n")
p.Stop()
@seanhagen
seanhagen / anonymous-gist.go
Created Oct 24, 2018
Golang func to print memory usage
View anonymous-gist.go
func PrintMemUsage(id int, name string) {
var m runtime.MemStats
runtime.ReadMemStats(&m)
// For info on each, see: https://golang.org/pkg/runtime/#MemStats
fmt.Printf(
"Call %v from %v -- Alloc = %v MiB\tTotalAlloc = %v MiB\tSys = %v MiB\tNumGC = %v\n",
id,
name,
bToMb(m.Alloc),
bToMb(m.TotalAlloc),
@seanhagen
seanhagen / example-service.go
Created Oct 20, 2018
Example implementation of server for reproduction
View example-service.go
// PingMe ...
func (s *Service) PingMe(ctx context.Context, in *api.PingMessage) (*api.PongMessage, error) {
header := metadata.Pairs("header-key", "val")
err := grpc.SendHeader(ctx, header)
return &api.PongMessage{Response: fmt.Sprintf("pongback: %v", in.Greeting)}, err
}
// StreamIn ...
func (s *Service) StreamIn(stream api.Ping_StreamInServer) error {
count := 0
@seanhagen
seanhagen / k8s.yml
Last active Oct 20, 2017
K8S Config
View k8s.yml
---
apiVersion: v1
kind: Service
metadata:
name: users
spec:
ports:
- port: 80
targetPort: 80
protocol: TCP
@seanhagen
seanhagen / battery-status
Created Dec 15, 2016
My version of @holman's battery status script
View battery-status
#!/bin/bash
#
# battery-status
#
# A quick little indicator for battery status on your Mac laptop, suitable for
# display in your prompt.
battery=$(upower -e | grep BAT)
state=$(upower -i $battery | grep state | tail -1 |awk -F":" '{print $2}' |sed -e 's/\s*//')
time_left=$(upower -i $battery |grep "time to empty" |tail -1 |awk -F":" '{print $2}' | sed -e 's/\s*//')
You can’t perform that action at this time.