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 / git-diff-branch-only.sh
Created September 21, 2019 00:24
Shell function to show git diff only for changes made to a branch
git-diff-branch-only () {
local branch=${1:-$(git branch --show-current)}
local base=${2:-master}
git diff $(git merge-base $branch $base) $branch
}
@ianfoo
ianfoo / now-configless-ianfoo-1zvz3xpyb.log
Created August 8, 2019 22:35
Error building Zeit project with two Go functions
TaskID 0999ab9e-b992-43a1-9690-fcda177f0243
TaskID 0999ab9e-b992-43a1-9690-fcda177f0243
yarn info @now/build-utils@latest...
yarn info @now/go...
yarn add @now/build-utils@0.9.11...
yarn add v1.16.0
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
@ianfoo
ianfoo / session.txt
Created July 16, 2019 02:45
What really happens when you run go run?
$ cat hello.go
package main
import "fmt"
func main() {
fmt.Println("Hello!")
}
$ go run -x hello.go
WORK=/var/folders/zh/tm1rghjn6hxdzbh5j8bnrmp80000gn/T/go-build036837237
@ianfoo
ianfoo / go-cross-compiling.md
Last active November 12, 2023 23:23
Cross compiling and dynamic linking in Go

I'm rough on the details but I think I can shed some light. When compiling for Linux, cgo is optional but desirable. So when you're building on Linux and have libc available, cgo will be enabled and the resulting binary will be dynamically linked to libc. When compiling for Darwin, linking to libSystem is mandatory -- there is no stable syscall interface, and so Go programs always have to link against libsystem or whatever it is. The runtime contains a copy of enough of the libsystem API that it can

@ianfoo
ianfoo / hello-server.go
Created July 9, 2019 23:34
Simple Hello server (need nontrivial functionality to ensure libc usage)
package main
import (
"log"
"net/http"
"os"
"time"
)
func main() {
@ianfoo
ianfoo / errtest.go
Created July 9, 2019 18:13
Testing errors.Unwrap in go1.13 beta
package main
import (
"errors"
"fmt"
)
func main() {
errs := []error{
errors.New("errors.New error"),
@ianfoo
ianfoo / output.txt
Created July 9, 2019 13:50
V2 packages in go
$ for f in main.go fooprinter.go foo/foo.go foo/v2/foo.go; do echo -e "\n======= $f ======="; cat $f; done
======= main.go =======
package main
import "./foo"
func main() {
foo.Print()
printFooV2()
@ianfoo
ianfoo / graphql.py
Created May 29, 2019 23:30
Simple Graphene-Python schema
"""
A simple exploration of implementing a GraphQL schema with
https://graphene-python.org.
"""
import datetime
import uuid
import pprint
import graphene
@ianfoo
ianfoo / gke-upgrade.md
Created May 21, 2019 20:32
Managing multiple gcloud configs, and upgrading GKE clusters

Manage multiple gcloud configurations

  • Makes it easy to bounce around different GCP projects
  • gcloud config configurations activate
  • `gcloud config set <[section/]property>
  • Configurations stored in $XDG_CONFIG_HOME/gcloud/configurations
    • No way to clone a configuration with gcloud, so you can copy files to start.

Upgrading a GKE cluster

@ianfoo
ianfoo / brew-install.txt
Last active May 13, 2019 01:00
Homebrew installed
adns
apr
apr-util
argon2
ark
aspell
autoconf
automake
awscli
brotli