Skip to content

Instantly share code, notes, and snippets.

View dragonfax's full-sized avatar

Jason Stillwell dragonfax

View GitHub Profile
@dragonfax
dragonfax / asdf
Created October 11, 2019 20:30
asdfas
asf
@dragonfax
dragonfax / Contexts.md
Last active August 31, 2018 18:14
Blog post on contexts in go.

Whats a Context?

You can find this in a lot of frameworks for web dev nowdays and even a few UI frameworks. I feel its replacing something that some old languages had but modern ones don't. Dynamic scoping.

Think of it as a scope of data. Data that's scoped to the request. Every request might need a timeout, but it might not be a global hard-coded timeout. Different requests might require different timeouts. The headers are also request scoped data.

Dynamic Scope

We had this as a language feature back in perl. It was called "dynamic scoping" vs the "lexical scoping" we're all used to. Where you had global variables. But you could scope the value of a variable to a particular function call and its nested call tree.

@dragonfax
dragonfax / log.txt
Created May 2, 2018 01:29
travis api examples
Here is an example query and output. The `jq` command is just to format the JSON so its readable.
17245-jstillwell:~ jstillwell$ curl -s https://api.travis-ci.com/repos?limit=100 -H "Authorization: token XXXXXXXXX" | jq '.' | head -30
[
{
"id": 302275,
"slug": "zendesk/embeddable_framework",
"description": "Home of the Embeddable Web Widget",
"last_build_id": 72266014,
"last_build_number": "9681",
@dragonfax
dragonfax / main.go
Created November 15, 2016 05:56
Example QListView with custom Delegate
package main
import (
"fmt"
"os"
"github.com/therecipe/qt/core"
"github.com/therecipe/qt/gui"
"github.com/therecipe/qt/widgets"
)
@dragonfax
dragonfax / keybase.md
Created January 28, 2016 20:02
keybase.md

Keybase proof

I hereby claim:

  • I am dragonfax on github.
  • I am dragonfax (https://keybase.io/dragonfax) on keybase.
  • I have a public key whose fingerprint is E71B 4011 61B8 FDF2 7CA5 3828 F4C9 E0B5 00B1 1C51

To claim this, I am signing this object:

@dragonfax
dragonfax / README.md
Created September 10, 2015 23:11
test reading concurrently from the same io.Reader
  1. dd if=/dev/urandom of=test.file bs=1m count=100
  2. go build
  3. ./ test.file

This will have several goroutines try to read the file from the same file descriptor. And show that they all get only a random subset of the file.

@dragonfax
dragonfax / README.md
Last active August 30, 2015 06:54
golang oddity, XML encode encodes double quote wrong.

The standard is for double quote (") to be encoded into " But golang seems to encode as the literal entity "

@dragonfax
dragonfax / main.go
Created August 28, 2015 01:24
simple client to access Riak CS using aws-sdk-go
package main
import (
"bytes"
"fmt"
"io/ioutil"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/service/s3"
@dragonfax
dragonfax / main.go
Created August 28, 2015 01:23
using go-aws-auth to access Riak CS
package main
import (
"io/ioutil"
"log"
"net/http"
"time"
"github.com/smartystreets/go-aws-auth"
)
@dragonfax
dragonfax / main.go
Created August 28, 2015 01:22
Using goamz to access Riak CS
package main
import (
"fmt"
"log"
"github.com/mitchellh/goamz/aws"
"github.com/mitchellh/goamz/s3"
)