Skip to content

Instantly share code, notes, and snippets.

Nick Glynn 17twenty

Block or report user

Report or block 17twenty

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
@17twenty
17twenty / readme.md
Created Jul 22, 2019
Using golang-migrate AKA mattes/migrate with Docker, Postgres and creating new schemas.
View readme.md

Using golang-migrate AKA mattes/migrate with Docker, Postgres and creating new schemas.

Prerequisites

We use the golang-migrate tool (formerly known as mattes/migrate) - build it with postgres support.

$ go get -v -u -tags 'postgres' github.com/golang-migrate/migrate/cli
$ migrate -h
Usage: migrate OPTIONS COMMAND [arg...]
@17twenty
17twenty / xForwardTest.go
Created Jan 18, 2017
Extracting X-Forwarded-For from connections in Golang
View xForwardTest.go
package main
import (
"fmt"
"log"
"net/http"
"strings"
)
func main() {
@17twenty
17twenty / .bash_profile
Last active May 20, 2019
Mac bash profile to add Git, nice prompt and ls colours, bash completion (requires brew install bash-completion)
View .bash_profile
if [ -f /usr/local/etc/bash_completion ]; then
. /usr/local/etc/bash_completion
fi
PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
unset color_prompt force_color_prompt
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
@17twenty
17twenty / gist:6925066
Last active Feb 2, 2019
Setting up your sdcard and u-boot's uEnv.txt for Beaglebone Black
View gist:6925066
# Find your micro SD card using lsblk - you're going to want to set your DISK parameter to it.
export DISK=/dev/mmcblk0
sudo dd if=/dev/zero of=${DISK} bs=1M count=16
sudo sfdisk --in-order --Linux --unit M ${DISK} <<-__EOF__
1,48,0xE,*
,,,-
__EOF__
@17twenty
17twenty / docker-compose.yml
Created Sep 14, 2017
As a way to get Zookeeper / Kafka AND Kafka Manager working together in docker compose...
View docker-compose.yml
version: '2'
services:
zookeeper:
hostname: zookeeper
image: wurstmeister/zookeeper
ports:
- "2181:2181"
kafka:
hostname: kafka
image: wurstmeister/kafka:0.9.0.0-1
@17twenty
17twenty / gist:2718613
Created May 17, 2012
Force Beaglebone to boot your settings on powerup from uEnv.txt
View gist:2718613
So the Beaglebone uses the file uEnv.txt to store settings as it doesn't have any NAND allocated to do it with, by
default the file is pretty empty save from the line:
optargs=run_hardware_tests quiet
You may have read a number of things about boot.scr etc - ignore it, it's not correct.
The bootcmd is hardwired in uboot to do the following (i've seperated it all out to make things clearer) - you can see it by
interrupting the bootsequence and performing a 'printenv'.
bootcmd=
@17twenty
17twenty / bash_profile
Last active Oct 3, 2018
My bash_profile for MacOS
View bash_profile
if [ -f /usr/local/etc/bash_completion ]; then
. /usr/local/etc/bash_completion
fi
PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
unset color_prompt force_color_prompt
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
@17twenty
17twenty / IntMe.py
Created Oct 1, 2014
Integer complement calculation in Python
View IntMe.py
#!/usr/bin/env python
# This would probably be the easiest way to do what you need
def getIntegerComplement (n):
# Setup mask of bits, can't use tilde as python uses signed :-/
mask = (1 << n.bit_length()) - 1
return n ^ mask
print getIntegerComplement(50)
@17twenty
17twenty / testing.go
Created Aug 15, 2018
Make your life easier by copying these into your Golang tests package
View testing.go
import (
"fmt"
"path/filepath"
"runtime"
"reflect"
"testing"
)
// assert fails the test if the condition is false.
func assert(tb testing.TB, condition bool, msg string, v ...interface{}) {
You can’t perform that action at this time.