Skip to content

Instantly share code, notes, and snippets.

@ascarter
ascarter / reorg.sh
Created January 27, 2021 17:06
Photo re-organization script
#!/bin/sh
# Rearrange exported originals to a yyyy/mm camera roll for OneDrive
# Set options
while getopts "is" arg; do
case "${arg}" in
i) INFO=1 ;;
s) SUMMARIZE=1 ;;
esac
package handlers
import (
"bytes"
"fmt"
"log"
"net/http"
"net/http/httptest"
"regexp"
"strings"
@ascarter
ascarter / requestlog.go
Created July 30, 2020 14:34
Request logging middleware
package handlers
import (
"fmt"
"log"
"net/http"
"os"
"time"
)
@ascarter
ascarter / docker.bash
Created May 24, 2019 18:09
Convenience functions for running docker with ephemeral containers
# -*- mode: unix-shell-script; -*-
# Run command in container with local directory mounted
# Useful for scripting languages like Ruby, Python, and Node
# Usage: docker_cmd <image> <bin> <cmd> [args]
docker_cmd() {
local image=$1; shift
local bin=$1; shift
local cmd=$1; shift
local args=$*
@ascarter
ascarter / docker-compose.yml
Created May 23, 2019 21:18
Grafana/Prometheus/Loki stack
version: "3.7"
services:
prometheus:
image: prom/prometheus
ports:
- 9090:9090
volumes:
- prometheus-storage:/prometheus
loki:
@ascarter
ascarter / help.mk
Created May 22, 2019 23:56
Makefile help
HELP_FORMAT=" \033[36m%-25s\033[0m %s\n"
.PHONY: help
help: ## Display this usage information
@echo "Valid targets:"
@grep -E '^[^ ]+:.*?## .*$$' $(MAKEFILE_LIST) | \
sort | \
awk 'BEGIN {FS = ":.*?## "}; \
{printf $(HELP_FORMAT), $$1, $$2}'
@echo ""
@echo "This host will build the following targets if 'make release' is invoked:"
@ascarter
ascarter / darkmode.sh
Last active November 29, 2018 01:10
macOS AppleScript for dark mode
# macOS display mode
alias darkmode='osascript -e "tell application \"System Events\" to tell appearance preferences to set dark mode to true"'
alias lightmode='osascript -e "tell application \"System Events\" to tell appearance preferences to set dark mode to false"'
alias togglemode='osascript -e "tell application \"System Events\" to tell appearance preferences to set dark mode to not dark mode"'
@ascarter
ascarter / dk
Created December 1, 2017 19:53
Run app via docker
#!/bin/sh
# Run app via docker
dk() {
# Usage: dk <cmd> <app> [args]
local cmd=$1; shift
local app=$1; shift
local args=$*
local name_prefix="${USER}_"

Keybase proof

I hereby claim:

  • I am ascarter on github.
  • I am ascarter (https://keybase.io/ascarter) on keybase.
  • I have a public key ASD6MZm3JbqHYXOkhB-wr_5yya86iKzlgAH-OMez-Z3FAwo

To claim this, I am signing this object:

@ascarter
ascarter / logex.go
Last active September 1, 2017 01:39
Log wrapper for Go stdlib logger
package log
import (
"io"
"io/ioutil"
stdlog "log"
"os"
)
var (