Skip to content

Instantly share code, notes, and snippets.

View schmichael's full-sized avatar

Michael Schurter schmichael

View GitHub Profile
@schmichael
schmichael / globalcontext.md
Last active June 21, 2018 18:39
Global Context Trees for Services

Global Context Trees for Services

aka Service Lifecycle Contexts

Request-scoped Contexts

Request-scoped contexts are unambigiously good. Other than a brief mention of main() they're the only use case covered by the official context announcement and documentation. Every single feature of contexts makes sense in a request/response scenario:

  • Cancelation provides a unified API for canceling work whose result is no longer needed
  • Deadlines and timeouts provide a unified API for preventing requests from blocking indefinitely.
@RadGH
RadGH / df-rooms.md
Last active December 10, 2017 16:04
Dwarf Fortress Rooms & Industries for 42.04

Dwarf Fortress Rooms & Industries

This is a list of rooms and industries that you will be building in Dwarf Fortress v42.xx. Use it to help plan your fortress, get some ideas, or figure out what should go in your stockpiles.

Primary Industries

Food

Indoor Storage: Raw plants, Prepared meals

@schmichael
schmichael / gist:9745170
Last active August 29, 2015 13:57
Thoughts on go-nsq
  • I don't understand why you'd want more than one type of Handler per Reader, so why not add Handler to Reader's constructor with an optional concurrency int on Reader?
  • A HandlerFunc function type would be a nice alternative interface for stateless handlers or closures.
  • Graceful shutdown is confusing and awkward. A (non-blocking) 30 second sleep in Stop must be followed by blocking on the ExitChan (which should be a struct{})? Why not simply make Stop block until handlers have exited gracefully?
  • Reader.Configure is awkward, but makes sense if you want to provide validation for Reader fields. However, it seems strange to make the fields public and provide a setter with no indication which is the proper mechanism to use.
  • Perhaps a separate ReaderConfig type (like tls.Config) which could be built as a struct literal and passed to Reader.Configure (or a constructor?) would allow for validation and public fields.
  • Proper Reader initialization is non-obvious. I *t
@jmelesky
jmelesky / runningavg.py
Created October 20, 2011 04:25 — forked from schmichael/runningavg.py
Handy script for calculating averages streamed via stdin
#!/usr/bin/env python
import sys
import math
CHUNK = 100
if len(sys.argv) > 1:
CHUNK = int(sys.argv[1])
s = 0
@schmichael
schmichael / runningavg.py
Created October 20, 2011 00:41
Handy script for calculating averages streamed via stdin
#!/usr/bin/env python
import sys
CHUNK = 100
if len(sys.argv) > 1:
CHUNK = int(sys.argv[1])
vals = []
i = 1