Skip to content

Instantly share code, notes, and snippets.

View anxiousmodernman's full-sized avatar
🎺
ready for a ska revival

Coleman McFarland anxiousmodernman

🎺
ready for a ska revival
View GitHub Profile
@anxiousmodernman
anxiousmodernman / config.toml
Last active October 21, 2017 22:15
Host provisioning tool config
# Outline of a TOML-based DSL for configuring hosts. For now, we assume we execute these "on the box".
# Imports are processed first, and given the correct precedence as if they were passed on the command
# line. If an import uses a resolver
imports = [
"/path/to/local/something.toml",
"bucket1://some/remote.toml"
]
# Bucket is a resolver type. Configure a bucket called bucket1.
{% if ports is undefined %} {% set ports=[] %} {% endif %}
{% if env_vars is undefined %} {% set env_vars=[] %} {% endif %}
{% if volume_mounts is undefined %} {% set volume_mounts=[] %} {% endif %}
{% if hostname is undefined %} {% set host_arg='--net=host' %} {% else %} {% set host_arg='--hostname=%s' % hostname %} {% endif %}
{% if image_cmd is undefined %} {% set image_cmd='' %} {% endif %}
[Unit]
Description={{ description }}
Requires=network-online.target docker.service
@anxiousmodernman
anxiousmodernman / backtrace.txt
Last active August 19, 2017 21:05
backtrace
Using device: GTX 1060 (type: DiscreteGpu)
thread 'main' panicked at 'unexpected error: DeviceLost', /home/coleman/.cargo/registry/src/github.com-1ecc6299db9ec823/vulkano-0.6.0/src/lib.rs:161
stack backtrace:
0: std::sys::imp::backtrace::tracing::imp::unwind_backtrace
at /checkout/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
1: std::sys_common::backtrace::_print
at /checkout/src/libstd/sys_common/backtrace.rs:71
2: std::panicking::default_hook::{{closure}}
at /checkout/src/libstd/sys_common/backtrace.rs:60
@anxiousmodernman
anxiousmodernman / adapter.go
Created July 30, 2017 19:36
Adapting grpc streaming endpoint to io.Reader
// PutStreamAdapter turns our GMData_PutStreamServer into an io.Reader
type PutStreamAdapter struct {
stream GMData_PutStreamServer
buf *bytes.Buffer
eof bool
}
// NewPutStreamAdapter initializes our io.Reader wrapper type for the PutStream endpoint.
func NewPutStreamAdapter(s GMData_PutStreamServer) *PutStreamAdapter {
@anxiousmodernman
anxiousmodernman / Dockerfile
Last active July 26, 2017 19:11
Dockerized protoc compiler example
FROM golang:1.8.3-jessie
RUN apt-get update -qq
RUN apt-get install -y zip git
RUN mkdir -p $GOPATH/src/github.com/AsynkronIT/
RUN cd $GOPATH/src/github.com/AsynkronIT/ && git clone https://github.com/AsynkronIT/protoactor-go.git
RUN curl -L 'https://github.com/google/protobuf/releases/download/v3.2.0/protoc-3.2.0-linux-x86_64.zip' > proto.zip
[Unit]
Description="My Website"
[Service]
Slice=machine.slice
Environment="CERTS=/etc/letsencrypt/live/stage.coleman.codes/"
ExecStart=/usr/bin/rkt run --net=host --debug /opt/site/caddy-local-linux-amd64.aci --insecure-options=all --volume certs,kind=host,source=${CERTS},readOnly=true
KillMode=mixed
Restart=always
@anxiousmodernman
anxiousmodernman / roll_call.md
Last active July 8, 2017 02:13
DSA (Democratic Socialists of America) GitHub orgs
@anxiousmodernman
anxiousmodernman / config_mgmt.md
Created April 18, 2017 19:39
What does config management do?

Jobs for Config Management

  • determine if a service is running (ask systemd)
  • install a service (drop .service files; tell systemd)
  • identify hosts (ask consul)
  • identify hosts by attribute (ask consul... is this an ubuntu host?)
  • deliver files to hosts; config or packages or binaries
    • scp-ish way (local to remote)
  • wget-ish way (download from known place)
@anxiousmodernman
anxiousmodernman / domainsocket.rs
Last active March 12, 2017 22:25
Reading JSON from Unix domain socket
extern crate unix_socket;
extern crate serde_json;
use serde_json::Value;
use std::thread;
use std::io::{Cursor, BufRead, BufReader};
use unix_socket::{UnixStream, UnixListener};
fn handle_client(mut stream: UnixStream) {
@anxiousmodernman
anxiousmodernman / golang.md
Last active March 5, 2017 18:12
Write Golang!

Write Golang!

Go makes writing robust, powerful software easy. Write it!

Prerequesites

  • set a GOPATH and all your code lives there (echo $GOPATH)
  • make sure Go is installed with go version
  • set an alias in your shell to make it easy to hack: alias golang="cd $GOPATH/src/github.com"