Skip to content

Instantly share code, notes, and snippets.

View syntaqx's full-sized avatar
🤷
¯\_(ツ)_/¯

Chase Pierce syntaqx

🤷
¯\_(ツ)_/¯
View GitHub Profile
@syntaqx
syntaqx / enum.go
Created August 6, 2019 22:07
Enum flag type for urfave/cli
package flagtype
// github.com/urfave/cli
import (
"fmt"
"strings"
)
type EnumValue struct {
Enum []string
@syntaqx
syntaqx / logger.go
Created August 6, 2019 22:05
Wraps zap.Logger with some level configuration
package log
import (
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)
// NewNop returns a no-op Logger. It never writes out logs or internal errors,
// andf it never runs user-defined hooks.
//
@syntaqx
syntaqx / docker_gc.sh
Created August 6, 2019 13:15
Garbage collection for Docker, try using it in /etc/cron.hourly/docker_gc.sh
#!/usr/bin/env bash
set -eo pipefail
[[ $TRACE ]] && set -x
# docker_gc.cron - Prunes all unused docker objects
# https://docs.docker.com/config/pruning/
#
# By default, Docker takes a conservative approach to cleaning up unused objects
# (often referred to as "garbage collection"), such as images, containers,
# volumes, and networks. This can cause Docker to use extra disk space,
@syntaqx
syntaqx / isdockerlive.sh
Created July 4, 2019 04:52
A simple shell script that leverages cURL to see if docker is up and running
#!/bin/bash
rep=$(curl -s --unix-socket /var/run/docker.sock http://ping > /dev/null)
status=$?
if [ "$status" == "7" ]; then
echo 'not connected'
exit 1
fi
version: 2.1
executors:
golang:
docker:
- image: syntaqx/ci-golang
docker-publisher:
docker:
- image: circleci/buildpack-deps:19.04
environment:
DOCKER_BUILDKIT: "1"
#cloud-config
users:
- default
- name: bastion
groups: sudo
shell: /bin/bash
sudo: ['ALL=(ALL) NOPASSWD:ALL']
hostname: ${fqdn}
package_update: true
@syntaqx
syntaqx / cloud-config.tls.yml
Created June 6, 2019 14:03
Hang onto these for me GitHub
#cloud-config
package_update: true
package_upgrade: true
packages:
- apt-transport-https
- ca-certificates
- curl
- gnupg2
- software-properties-common
@syntaqx
syntaqx / cloud-config.tlsyml
Created June 6, 2019 14:03
Hang onto these for me GitHub
#cloud-config
package_update: true
package_upgrade: true
packages:
- apt-transport-https
- ca-certificates
- curl
- gnupg2
- software-properties-common
@syntaqx
syntaqx / main.go
Created June 1, 2019 05:01
Golang SSH connection with hostkey verification
package main
import (
"bytes"
"fmt"
"io/ioutil"
"log"
"golang.org/x/crypto/ssh"
kh "golang.org/x/crypto/ssh/knownhosts"
@syntaqx
syntaqx / clone.sh
Created May 27, 2019 18:27
Clone all of the projects for a given user or organization.
#!/bin/bash
# Simple helper script that iterates over available repositories and clones them down.
# I know it could use some work.
export USER=syntaqx
curl -u $GITHUB_TOKEN:x-oauth-basic 'https://api.github.com/orgs/$USER/repos?per_page=100' | jq '.[].ssh_url' -r | while read url; do git clone "$url"; done