Skip to content

Instantly share code, notes, and snippets.

Stephen Wood stephen-mw

Block or report user

Report or block stephen-mw

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
@stephen-mw
stephen-mw / go_null_json_example.go
Last active Dec 10, 2019
Golang http server with sql null values and json
View go_null_json_example.go
package main
import (
"database/sql"
"encoding/json"
"log"
"net/http"
"strconv"
_ "github.com/mattn/go-sqlite3"
View keybase.md

Keybase proof

I hereby claim:

  • I am stephen-mw on github.
  • I am stephenmw (https://keybase.io/stephenmw) on keybase.
  • I have a public key whose fingerprint is 02A1 A27C E45C 503C 84A9 E9AA 924B A05C D817 8DC7

To claim this, I am signing this object:

@stephen-mw
stephen-mw / linux_time_in_milliseconds.sh
Created Jun 15, 2016
Linux/Bash get the epoch linux time in milliseconds
View linux_time_in_milliseconds.sh
# If you don't care too much about the granularity, just multiply by 1000 :-)
echo $((`date +%s` * 1000))
1466013952000
@stephen-mw
stephen-mw / ec2list.go
Last active Dec 14, 2017
Ec2 list in go
View ec2list.go
package main
import (
"fmt"
"github.com/awslabs/aws-sdk-go/aws"
"github.com/awslabs/aws-sdk-go/service/ec2"
"github.com/vaughan0/go-ini"
"net/url"
"os"
"runtime"
View install_ixgbevf.bash
apt-get update -y
aptitude install -y build-essential
wget "http://downloads.sourceforge.net/project/e1000/ixgbevf%20stable/2.16.1/ixgbevf-2.16.1.tar.gz"
tar -zxf ./ixgbevf-*
cd ixgbevf*/src
make install
modprobe ixgbevf
sudo update-initramfs -c -k all
echo "options ixgbevf InterruptThrottleRate=1,1,1,1,1,1,1,1" > /etc/modprobe.d/ixgbevf.conf
@stephen-mw
stephen-mw / list_ec2_instances.md
Last active Jun 16, 2019
List running EC2 instances with golang and aws-sdk-go
View list_ec2_instances.md

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 / pre-push
Last active Aug 29, 2015 — forked from pixelhandler/pre-push.sh
pre-push hook to prevent pushing to dev, prod, release-*, patch-*
View pre-push
#!/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"
View The_Deployment_Manifesto
The 10 Tenets of Deployments
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL
NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and
"OPTIONAL" in this document are to be interpreted as described in
[RFC 2119](https://www.ietf.org/rfc/rfc2119.txt).
1. Configuration management MUST NOT be coupled to an external service, such as EC2, Openstack, Foreman, or anything else.
2. Devops SHOULD provide a self-service framework for the automatic creation and destruction of hosts from the ground up.
View easy_bash_colors
color() {
echo -e "\033[0;$1m$2\033[0m"
}
echo_red() {
color 31 "$1"
}
echo_green() {
color 32 "$1"
}
echo_yellow() {
@stephen-mw
stephen-mw / collectd_auto_install
Last active Dec 31, 2015
Debian/Ubuntu collectd compiling and installation script
View collectd_auto_install
#!/bin/bash
set -e
#
# Collectd automatic compile and installation script
# for debian systems
#
# Stephen Wood
# www.heystephenwood.com
#
You can’t perform that action at this time.