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 / typora
Last active February 26, 2018 23:30
Open Typora.app from command line in OSX/macOS
#!/bin/bash
set -e
if [ -n "$1" ]; then
FILE="$(greadlink -f "$1")"
[ -f "$FILE" ] || [ -d "$FILE" ] || touch "$FILE"
osascript -e "tell application \"Typora\" to open \"$FILE\""
fi
osascript -e 'tell application "Typora" to activate'
@blockloop
blockloop / update_doctl.sh
Last active February 16, 2018 22:27
update digitalocean ssh firewall to local IP
#!/bin/bash
set -o pipefail
doctl="/usr/local/bin/doctl"
# name of your tag
TAG_NAME=""
# the DO token from https://cloud.digitalocean.com/settings/api/tokens
TOKEN=""
# the firewall ID found by running "doctl compute firewall list"
@blockloop
blockloop / smart_docker-compose.sh
Created January 16, 2018 17:28
bash function I use in place of docker-compose that finds the nearest sibling/child docker-compose.yml
function dc() {
closest=$(find . -maxdepth 4 -type f -name docker-compose.yml -printf '%P\n' | tail -n1)
if [ $# -eq 0 ] || [ -z "$closest" ]; then
docker-compose "$@"
else
docker-compose -f "$closest" "$@"
fi
}
@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 / main.go
Created November 6, 2017 20:08
Humanize a netmask
package main
import (
"fmt"
)
func main() {
for _, nm := range []uint64{24, 8} {
fmt.Printf("%d => %v\n", nm, humanizeNetmask(nm))
}
@blockloop
blockloop / howto.md
Created May 1, 2017 03:30
Enable Night Shift on older (pre 2012) Macs

** Credit to ryanmvc at https://pikeralpha.wordpress.com/2017/01/30/4398/#comment-9146

Here are step-by-step instructions that I created. You will need Xcode or any basic hex editor.

  1. Disable System Integrity Protection by booting into Recovery mode (hold down Command + R during boot-up), opening Terminal, and typing: csrutil disable
  2. Restart your Mac and open Finder. Navigate to System/Library/PrivateFrameworks/
  3. Make a copy of the entire CoreBrightness.framework folder (save it to your desktop or a similar place).
  4. In Xcode, open the copy of CoreBrightness.framework that you just created. File > Open; Browse to where you just saved CoreBrightness.framework; from within that .framework folder, choose the CoreBrightness icon at the top that looks like a shortcut.
  5. In Xcode, press Shift + Command + J on your keyboard. A navigation column will appear on the left-hand side. Secondary/right-click CoreBrightness at the top of that column and choose Open As > Hex.
  6. Once the hex code appears, press C
#!/usr/bin/env bash
# This script is taken from https://dev.to/thiht/shell-scripts-matter
set -euo pipefail
IFS=$'\n\t'
#/ Usage:
#/ Description:
#/ Examples:
#/ Options:
#/ --help: Display this help message
@blockloop
blockloop / keybase.md
Created February 10, 2017 19:46
keybase.md

Keybase proof

I hereby claim:

  • I am blockloop on github.
  • I am blockloop (https://keybase.io/blockloop) on keybase.
  • I have a public key ASDZ77BAmvKbMKD0d0cKTgYpuyJAcbPCgAWcGAj3vIeFCQo

To claim this, I am signing this object:

@blockloop
blockloop / AWS Swarm cluster.md
Created November 5, 2016 04:53 — forked from ghoranyi/AWS Swarm cluster.md
Create a Docker 1.12 Swarm cluster on AWS

This gist will drive you through creating a Docker 1.12 Swarm cluster (with Swarm mode) on AWS infrastructure.

Prerequisites

You need a few things already prepared in order to get started. You need at least Docker 1.12 set up. I was using the stable version of Docker for mac for preparing this guide.

$ docker --version
Docker version 1.12.0, build 8eab29e

You also need Docker machine installed.

My sync settings. Managed by atom-sync-settings package.