Skip to content

Instantly share code, notes, and snippets.

View blockloop's full-sized avatar

Brett Jones blockloop

  • Lithic (privacy.com)
View GitHub Profile
@blockloop
blockloop / interface.go
Last active August 26, 2023 15:47
sql/db interfaces that I use in golang
package data
import (
"context"
"database/sql"
"time"
)
// DB is an interface to a sql database. It is a wrapper for the golang sql/db builtin
type DB interface {
@blockloop
blockloop / gpt-playground.yaml
Created March 24, 2023 16:17
gpt playground
---
- name: Install Gostatsd and Carbon Relay NG
hosts: all
become: true
handlers:
- name: Restart Carbon Relay NG
ansible.builtin.systemd:
name: carbon-relay-ng
tasks:
- name: Install dependencies
@blockloop
blockloop / hn
Last active November 25, 2022 03:27
browse top hacker news articles from the command line
#!/usr/bin/env bash
#
# Author: blockloop
#
# Purpose: browse top hacker news articles from the command line
#
# Requirements:
# jq fzf curl
set -ueo pipefail
@blockloop
blockloop / main.js
Created November 3, 2022 19:46
Tampermonkey Grafana Preview Alerts Table Size
// ==UserScript==
// @name Grafana Preview Alerts Table
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Grow the size of the Grafana Alerts Preview table so that it is legible.
// @author blockloop
// @match https://*.grafana.net/alerting/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=grafana.net
// @grant none
// ==/UserScript==
@blockloop
blockloop / docker-compose.yaml
Last active April 23, 2022 02:41
Thanos Receive example with docker-compose
version: "3"
networks:
default:
driver: bridge
ipam:
config:
- subnet: 172.16.57.0/24
services:
@blockloop
blockloop / .envrc
Last active October 13, 2021 15:36
Automatically use the correct go version for your project with direnv + goenv
#!/bin/bash
#
# see: https://direnv.net/
# see: https://github.com/syndbg/goenv
#
# Place this in your go project root as .envrc
GOMOD_VERSION=$(grep 'go 1\.' go.mod | cut -d' ' -f2)
if [[ $GOMOD_VERSION =~ ^1\.[0-9]+$ ]]; then
@blockloop
blockloop / Program.cs
Last active March 10, 2020 10:56
Ruby-ish *rescue* for C#. Swallowing exceptions in C# is almost always imprudent, but sometimes it's just necessary.
public T Rescue<T>(T defValue, Func<T> fn)
{
try
{
return fn();
}
catch
{
return defValue;
}

Raspberry Pi VPN Router

This is a quick-and-dirty guide to setting up a Raspberry Pi as a "router on a stick" to PrivateInternetAccess VPN.

Requirements

Install Raspbian Jessie (2016-05-27-raspbian-jessie.img) to your Pi's sdcard.

Use the Raspberry Pi Configuration tool or sudo raspi-config to:

@blockloop
blockloop / makephase1.sh
Created May 14, 2019 19:42
debug Makefiles
#!/bin/sh
unset TERMCAP
re_env=$(env | cut -d= -f1 | tr \\n '|')
re_dot_smthg='\.[^ ]+'
re_autovars='[%*+<?^@][^ ]'
re_misc='GNUMAKEFLAGS|MAKE([^ ]+)?|MFLAGS|SUFFIXES|-\*-command-variables-\*-'
make -rR -pk -q "$@" \
| grep -Ev "^(${re_env}#|$re_dot_smthg|$re_autovars|$re_misc) " \
@blockloop
blockloop / nginx.conf
Created April 1, 2019 02:24
NGINX static hosting
user nginx;
worker_processes 1;
error_log /dev/stderr warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}