Skip to content

Instantly share code, notes, and snippets.

@stephen-mw
stephen-mw / sources.list
Created May 20, 2013 21:39
Ubuntu 10.04 apt sources.list Pop it into /etc/apt/sources.list && apt-get update
#############################################################
################### OFFICIAL UBUNTU REPOS ###################
#############################################################
###### Ubuntu Main Repos
deb http://us.archive.ubuntu.com/ubuntu/ lucid main restricted universe multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ lucid main restricted universe multiverse
###### Ubuntu Update Repos
deb http://us.archive.ubuntu.com/ubuntu/ lucid-security main restricted universe multiverse
@stephen-mw
stephen-mw / pre-push
Last active September 9, 2021 01:35 — forked from pixelhandler/pre-push.sh
pre-push hook to prevent pushing to dev, prod, release-*, patch-*
#!/bin/bash
# Prevents force-pushing to master
BRANCH=`git rev-parse --abbrev-ref HEAD`
PUSH_COMMAND=`ps -ocommand= -p $PPID`
PROTECTED_BRANCHES="^(master|dev|release-*|patch-*)"
FORCE_PUSH="force|delete|-f"
if [[ "$BRANCH" =~ $PROTECTED_BRANCHES && "$PUSH_COMMAND" =~ $FORCE_PUSH ]]; then
echo "Prevented force-push to protected branch \"$BRANCH\" by pre-push hook"
@stephen-mw
stephen-mw / list_ec2_instances.md
Last active April 18, 2022 16:07
List running EC2 instances with golang and aws-sdk-go

This is the beginning of hopefully many new posts with golang snippets from my blog. List all of your running (or pending) EC2 instances with Amazon's golang sdk.

For a list of filters or instance attributes consult the official documentation.

package main

import (
	"fmt"
	"github.com/awslabs/aws-sdk-go/aws"
@stephen-mw
stephen-mw / go_null_json_example.go
Last active November 22, 2022 13:28
Golang http server with sql null values and json
package main
import (
"database/sql"
"encoding/json"
"log"
"net/http"
"strconv"
_ "github.com/mattn/go-sqlite3"
@stephen-mw
stephen-mw / install_python38_on_pi.sh
Last active August 22, 2023 03:55
Install python3.8 and make the system default on Raspberry Pi
#!/usr/bin/env bash
set -euo pipefail
# This script downloads, compiles, and installs python3.8 as the system default
export VERSION=3.8.5
apt install -y \
build-essential \
libbz2-dev \