Skip to content

Instantly share code, notes, and snippets.

View pwmcintyre's full-sized avatar
🥑
golang fever

Peter McIntyre pwmcintyre

🥑
golang fever
View GitHub Profile
@pwmcintyre
pwmcintyre / tmux.conf
Created February 28, 2017 22:14 — forked from spicycode/tmux.conf
The best and greatest tmux.conf ever
# 0 is too far from ` ;)
set -g base-index 1
# Automatically set window title
set-window-option -g automatic-rename on
set-option -g set-titles on
#set -g default-terminal screen-256color
set -g status-keys vi
set -g history-limit 10000
@pwmcintyre
pwmcintyre / GNUPG Cheatsheet.md
Created February 28, 2017 23:36 — forked from turingbirds/GNUPG Cheatsheet.md
GPG (GNUPG) Cheatsheet

GNUPG CHEATSHEET

Setting up: key generation

This generates a public/private keypair.

$ gpg --gen-key

$ gpg --list-secret-keys

@pwmcintyre
pwmcintyre / benchmark-disk.ps1
Last active March 20, 2018 02:51
PowerShell - Continuously write random data to a disk
# running this will consume 10GB of data in the target path
# use SIGINT to stop (Ctrl + C)
function Run {
Param(
[ValidateNotNullOrEmpty()]
[string]$Target
)
#!/usr/bin/env bash
# message to en/decrypt
ORIGINAL_DATA="hello-world"
KEY_ALIAS="alias/example"
# AWS CLI bits
PROFILE_ENCRYPT=saml
PROFILE_DECRYPT=ASIAZF3IWVKQWIYJWJW7
REGION=us-east-1
package main
import (
"fmt"
"net/url"
"github.com/pkg/errors"
)
func main() {
{
"$id": "https://example.com/arrays.schema.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "A representation of a person, company, organization, or place",
"type": "object",
"properties": {
"fruits": {
"type": "array",
"items": {
"type": "string"

Golang doesn't have try/catch blocks, so you can't simply "throw" an error and hope something will catch it and give you a stack-trace showing you where it came from. Instead we return errors and check them ... but it's important to introduce context before returning ... here's why

Here a simple go program I wrote which doesn't appear to work 🤔

$ go run main.go 
access denied

... it attempts to "process" and "save", but since the "process" function adds no context to the error (it just bubbles it up), the final error is very confusing!

@pwmcintyre
pwmcintyre / makefile
Created January 1, 2020 22:32
nodejs makefile
SHELL := node
.SHELLFLAGS = -e
.ONESHELL: example
.SILENT: example
example:
const foo = "bar"
console.log( "success", { foo } )
@pwmcintyre
pwmcintyre / 1-README.md
Last active January 22, 2020 09:22
sample lambda cloudformation

Sample Lambda

Example IAM Role + Lambda

This will fail, you'll need to fix it somehow!

Commands

setup

#!/usr/bin/env python3
import boto3
# constants
role_name = 'OrganizationAccountAccessRole'
regions_in_scope = [
'us-east-2',
'us-east-1',
'us-west-1',
'us-west-2',