Skip to content

Instantly share code, notes, and snippets.

View seanhagen's full-sized avatar
:shipit:
coding

Sean Hagen seanhagen

:shipit:
coding
  • Flight Center Travel Group
  • Vancouver, British Columbia
  • 16:42 (UTC -07:00)
View GitHub Profile

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 February 21, 2019 01:28
Example non-working pipeline
package main
import (
"context"
"flag"
"log"
"reflect"
"cloud.google.com/go/bigquery"
ps "cloud.google.com/go/pubsub"
@seanhagen
seanhagen / events.go
Created February 11, 2019 20:08
Cloud Dataflow -- trying to get GCS writes working
package main
import (
"bufio"
"context"
"flag"
"log"
"reflect"
ps "cloud.google.com/go/pubsub"
@seanhagen
seanhagen / anonymous-gist.go
Created October 24, 2018 23:48
Profiling code
// 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 October 24, 2018 23:46
Golang func to print memory usage
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 October 20, 2018 01:17
Example implementation of server for reproduction
// 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
#!/usr/bin/python
#import gtk
import gnomekeyring as gkey
import getpass
class Keyring(object):
def __init__(self, name, server, protocol):
self._name = name
self._server = server
@seanhagen
seanhagen / k8s.yml
Last active October 20, 2017 17:47
K8S Config
---
apiVersion: v1
kind: Service
metadata:
name: users
spec:
ports:
- port: 80
targetPort: 80
protocol: TCP
@seanhagen
seanhagen / site.pp
Created November 26, 2013 20:06
Simple PHP Puppet setup
group { 'puppet':
ensure => present,
}
class initial_setup {
exec { 'apt-get update':
command => '/usr/bin/apt-get update',
}
package { "essential-packages":
@seanhagen
seanhagen / battery-status
Created December 15, 2016 19:16
My version of @holman's battery status script
#!/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*//')