Skip to content

Instantly share code, notes, and snippets.

View ianfoo's full-sized avatar
💭
staring into the sun ☀️

Ian Molee ianfoo

💭
staring into the sun ☀️
  • Seattle WA
View GitHub Profile
@ianfoo
ianfoo / keybase.md
Created August 17, 2016 22:56
Keybase GitHub Verification

Keybase proof

I hereby claim:

  • I am ianfoo on github.
  • I am ianfoo (https://keybase.io/ianfoo) on keybase.
  • I have a public key whose fingerprint is 9605 BB8A DC1C F60F 48E5 B894 3F50 C56B 291E 447F

To claim this, I am signing this object:

@ianfoo
ianfoo / output.txt
Created July 19, 2018 03:48
Comparison of linear slice search vs hash-based search
n= 5 target= 0 slice-search-time: 169ns set-search-time: 309ns
n= 5 target= 2 slice-search-time: 82ns set-search-time: 163ns
n= 5 target= 5 slice-search-time: 68ns set-search-time: 150ns
n= 10 target= 0 slice-search-time: 30ns set-search-time: 145ns
n= 10 target= 5 slice-search-time: 60ns set-search-time: 131ns
n= 10 target= 10 slice-search-time: 55ns set-search-time: 118ns
n= 50 target= 0 slice-search-time: 33ns set-search-time: 67ns
n= 50 target= 25 slice-search-time: 55ns set-search-time: 127ns
n= 50 target= 50 slice-search-time: 70ns set-search-time: 120ns
n= 100 target= 0 slice-search-time: 47ns set-search-time: 76ns
@ianfoo
ianfoo / _.md
Last active August 10, 2018 20:41
golang: Separating Integration Tests and Unit Tests

Separating Integration Tests and Unit Tests

We can use build tags to run only certain types of tests. In this case, we want integration tests to run by default, so we tag the integration tests with a negated unit test tag, which indicates that the test should not be run if the unit build flag is set.

Alternatively, the integration tests could be tagged with integration or some other tag, and they'd only be run if the integration tag is set on test invocation.

How to run go test with tags

@ianfoo
ianfoo / go-missing-examples.md
Created September 4, 2018 18:03 — forked from andrestc/go-missing-examples.md
Go std lib funcs/methods missing examples

About this

This list has the goal of helping developers interested in contributing to the Go language but are unsure of where to start. This was not generated manually so some functions and methods here may not require examples (maybe because they are too simple, e.g .String()) and some of these may only make sense in a package level example (which are not considered for this list yet). Use your best judgment and check the documentation before you open up a CL to add an example.

You should also search in gerrit for open CLs that are already adding examples.

I will try to keep this list as up to date as possible. If you find any mistakes, please comment below and I will try to fix it.

@ianfoo
ianfoo / godoc-server.bash
Created September 26, 2018 23:42
A function to start, stop, or restart a local godoc server in the background
godoc-server () {
declare -lr funcname=$0
declare -lr godoc=$(which godoc)
start_server () {
declare -lr nohup=$(which gnohup || which nohup)
declare -lr logfile="/tmp/godoc-server.log"
$nohup $godoc $@ >$logfile 2>&1 &
}
stop_server() {
pkill -fn 'godoc -http'
// This illustrates how you can call a method on a nil pointer type
// if it doesn't dereference the nil value.
package main
import "fmt"
type T int
func (t *T) hello() string {
@ianfoo
ianfoo / bar.py
Created September 30, 2018 17:59
Simple example of defining and using Python modules
def dishroom():
return "Dishroom has 24 hour beans."
def huh():
return "You cooked beans for 24 hours? What's the matter with you?"
def sports():
return "¯\_(ツ)_/¯ Let's go watch sports."
@ianfoo
ianfoo / errorlist.go
Created October 4, 2018 00:07
Example of an error list in Go. https://play.golang.org/p/MLWS5UhxI11
package main
import (
"fmt"
"math/rand"
"strings"
)
type ErrorList []error
http://i.imgur.com/FApqk3D.jpg
http://i.imgur.com/TKLs9lo.jpg
https://i.redd.it/d8021b5i2moy.jpg
https://i.redd.it/4m5yk8gjrtzy.jpg
https://i.redd.it/xae65ypfqycy.jpg
http://i.imgur.com/lcEUZHv.jpg
https://i.redd.it/1nlgrn49x7ry.jpg
http://i.imgur.com/M3NOzLC.jpg
https://i.redd.it/w5q6gldnvcuy.jpg
https://i.redd.it/s5viyluv421z.jpg
@ianfoo
ianfoo / fetchurl.go
Created October 4, 2018 08:01
Fetch a URL and output to stdout
package main
import (
"fmt"
"io"
"net/http"
"os"
"path"
)