Skip to content

Instantly share code, notes, and snippets.

View tylertreat's full-sized avatar

Tyler Treat tylertreat

View GitHub Profile
@tylertreat
tylertreat / GCPAuthenticationInterceptor.java
Created January 25, 2019 16:45
Spring RestTemplate interceptor which can make HTTP requests to Google OIDC-authenticated resources using a service account
package com.realkinetic.gcp.spring.oidc;
import com.auth0.jwt.JWT;
import com.auth0.jwt.algorithms.Algorithm;
import com.auth0.jwt.interfaces.DecodedJWT;
import com.google.api.client.http.*;
import com.google.api.client.http.javanet.NetHttpTransport;
import com.google.api.client.json.JsonObjectParser;
import com.google.api.client.json.jackson2.JacksonFactory;
import com.google.api.client.util.GenericData;
@tylertreat
tylertreat / prometheus.yml
Created November 22, 2018 05:58
Prometheus config for pushgateway
global:
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
# scrape_timeout is set to the global default (10s).
scrape_configs:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
- job_name: 'pushgateway'
# metrics_path defaults to '/metrics'
@tylertreat
tylertreat / graphson_to_dot.py
Created May 11, 2018 22:13
Super janky script to convert graphson to DOT format
import json
import sys
def main():
graphson_file = sys.argv[1]
_to_dot_graph(graphson_file)
def _to_dot_graph(graphson_file):

Keybase proof

I hereby claim:

  • I am tylertreat on github.
  • I am tylertreat (https://keybase.io/tylertreat) on keybase.
  • I have a public key whose fingerprint is FA5C 8B53 190C D672 5BDD EFA6 1484 FBC8 4FF0 4832

To claim this, I am signing this object:

@tylertreat
tylertreat / ring_buffer.go
Last active February 24, 2016 00:27
Ring buffer struct
type RingBuffer struct {
queue uint64
dequeue uint64
mask, disposed uint64
nodes nodes
}
@tylertreat
tylertreat / defer.go
Last active February 21, 2016 19:40
Closing file without defer
func findHelloWorld(filename string) error {
file, err := os.Open(filename)
if err != nil {
return err
}
defer file.Close()
scanner := bufio.NewScanner(file)
for scanner.Scan() {
if scanner.Text() == "hello, world!" {
package main
import (
"flag"
"fmt"
"os"
"time"
"github.com/tylertreat/bench"
"github.com/tylertreat/bench/requester"
@tylertreat
tylertreat / benchmark.go
Last active January 24, 2017 22:20
Redis and NATS Benchmark
package main
import (
"flag"
"fmt"
"os"
"time"
"github.com/gocql/gocql"
"github.com/nats-io/nats"
func isInt64InSlice(i int64, slice []int64) bool {
for _, j := range slice {
if j == i {
return true
}
}
return false
}
type IntContainer []int
func (i IntContainer) Iterator(cancel <-chan struct{}) <-chan int {
ch := make(chan int)
go func() {
for _, val := range i {
select {
case ch <- val:
case <-cancel:
close(ch)