Skip to content

Instantly share code, notes, and snippets.

View jboelter's full-sized avatar

Joshua Boelter jboelter

  • Portland, OR, United States
View GitHub Profile
@jboelter
jboelter / clone
Last active December 12, 2020 19:49
Clone a git repo with the same path structure on disk
#! /usr/bin/python3
# Usage:
# clone repo_url [path] [clone args]
#
# Examples
# clone https://github.com/username/reponame.git
# git clone https://github.com/username/reponame.git /home/user/src/github.com/username/reponame
#
# clone https://github.com/username/reponame.git /src
# git clone https://github.com/username/reponame.git /src/github.com/username/reponame
@jboelter
jboelter / example.go
Last active August 4, 2019 14:26
golang template token patch (go version devel +a2f5d644d3 Sat Aug 3 08:47:32 2019 +0000 linux/amd64)
package main
import (
"fmt"
)
contract stringer@<type T> {
T String() string
}
@jboelter
jboelter / Dockerfile
Created July 7, 2018 16:37
Dockerfile w/ volume and correct permissions
# docker build . -t your:tag
# run the container and mount some directory into /data
# the startup script will create a user and launch CMD w/ the matching the UID:GID
# docker run --rm -it `pwd`:/data your:tag
FROM mhart/alpine-node
ENV GOSU_VERSION 1.10
RUN set -ex; \
\
@jboelter
jboelter / test.sql
Created November 22, 2017 07:15
select for update 1 or N as json
DROP TABLE test;
CREATE TABLE test (
id SERIAL NOT NULL PRIMARY KEY,
a TEXT DEFAULT 'A',
b TEXT DEFAULT 'B',
i INTEGER DEFAULT 0
);
INSERT INTO test DEFAULT VALUES ;
INSERT INTO test DEFAULT VALUES ;
INSERT INTO test DEFAULT VALUES ;
@jboelter
jboelter / gosetup.sh
Created August 3, 2017 23:36
Setup go 1.8.3 + gvt + tools for Visual Code
#!/bin/bash
set -x -e
# This script will attempt to fetch the go version specified below
# and install the tools required by vs-code + the metalinter.
# The binaries will be copied to $HOME/bin
# You might be prompted. Linux only for now.
GO_VERSION_WANT='1.8.3'
// Uses the default AWS SDK Credentials; e.g. via the environment
// AWS_REGION=region AWS_ACCESS_KEY_ID=key AWS_SECRET_ACCESS_KEY=secret
package main
import (
"bytes"
"flag"
"fmt"
"io"
"log"
// Uses the default AWS SDK Credentials; e.g. via the environment
// AWS_REGION=region AWS_ACCESS_KEY_ID=key AWS_SECRET_ACCESS_KEY=secret
package main
import (
"flag"
"fmt"
"io"
"log"
"os"
@jboelter
jboelter / pushself.go
Created August 26, 2015 18:13
client_golang prometheus extension to push metrics to self
package prometheus
import (
"fmt"
"sort"
"sync"
"github.com/golang/protobuf/proto"
dto "github.com/prometheus/client_model/go"
)