Skip to content

Instantly share code, notes, and snippets.

Andrew Carter ascarter

Block or report user

Report or block ascarter

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ascarter
ascarter / docker.bash
Created May 24, 2019
Convenience functions for running docker with ephemeral containers
View docker.bash
# -*- 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
Grafana/Prometheus/Loki stack
View docker-compose.yml
version: "3.7"
services:
prometheus:
image: prom/prometheus
ports:
- 9090:9090
volumes:
- prometheus-storage:/prometheus
loki:
@ascarter
ascarter / help.mk
Created May 22, 2019
Makefile help
View help.mk
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 Nov 29, 2018
macOS AppleScript for dark mode
View darkmode.sh
# 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 Dec 1, 2017
Run app via docker
View dk
#!/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}_"
View keybase.md

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 Sep 1, 2017
Log wrapper for Go stdlib logger
View logex.go
package log
import (
"io"
"io/ioutil"
stdlog "log"
"os"
)
var (
@ascarter
ascarter / log.go
Created Dec 31, 2014
HTTP request logger in Go
View log.go
package __package__
import (
"net/http"
"time"
)
type responseLogger struct {
w http.ResponseWriter
status int
View batterycharge.py
#!/usr/bin/env python
# coding=UTF-8
import argparse
import math
import subprocess
import sys
def main(argv):
parser = argparse.ArgumentParser(description='Display current battery capacity')
@ascarter
ascarter / bbcurl.sh
Created Aug 19, 2011 — forked from alexkingorg/bbcurl.sh
View source from a URL in BBEdit
View bbcurl.sh
function bbcurl () {
curl $1 | bbedit --new-window +1 -t $1
}
You can’t perform that action at this time.