Skip to content

Instantly share code, notes, and snippets.

View montanaflynn's full-sized avatar

Montana Flynn montanaflynn

View GitHub Profile
@montanaflynn
montanaflynn / chan.go
Created October 26, 2015 21:05
Waiting for multiple channels to close in Golang
package main
import (
"fmt"
"time"
)
func waitForChannelsToClose(chans ...chan struct{}) {
t := time.Now()
for _, v := range chans {
@montanaflynn
montanaflynn / docker-compose.yml
Created December 11, 2015 07:03
GitLab docker compose
postgresql:
image: sameersbn/postgresql:9.4-7
environment:
- DB_USER=gitlab
- DB_PASS=password
- DB_NAME=gitlabhq_production
gitlab:
image: sameersbn/gitlab:8.1.3
links:
- redis:redisio
@montanaflynn
montanaflynn / setup.sh
Last active December 22, 2015 02:35
OSX El Capitan Development Setup Script
#!/usr/bin/env bash
OSX=$(test "`uname`" == "Darwin" && echo "x")
if [[ OSX ]]; then
# Ask for the administrator password upfront
sudo -v
# Keep-alive: update existing `sudo` time stamp until `.osx` has finished
@montanaflynn
montanaflynn / port.go
Created January 7, 2016 08:21
Port package which finds available ports or checks if a port is available
package port
import (
"net"
"strconv"
)
// New gets an available port
func New() (port int, err error) {
@montanaflynn
montanaflynn / Makefile
Created January 7, 2016 08:53
Golang live reload code on change
PID = /tmp/awesome-golang-project.pid
GO_FILES = $(wildcard *.go)
serve:
@make restart
@fswatch -o . | xargs -n1 -I{} make restart || make kill
kill:
@kill `cat $(PID)` || true
@montanaflynn
montanaflynn / rickroll.go
Created January 14, 2016 06:46
rick rolling middleware
func rickRoll(res *http.Response) *http.Response {
if ct, ok := res.Header["Content-Type"]; !ok || len(ct) == 0{
return res
}
if res.Header["Content-Type"][0] == "video/x-flv" {
res.Header.Del("Content-Length")
if file, err := os.Open(*filename); err == nil {
res.Body = file
@montanaflynn
montanaflynn / rewind.go
Created January 17, 2016 08:02
Play and then rewind a gif, useful for making perfect loops
package main
import (
"image/gif"
"os"
)
func main() {
in, err := os.Open(os.Args[1])
@montanaflynn
montanaflynn / Makefile
Created January 22, 2016 09:24 — forked from isaacs/Makefile
# Hello, and welcome to makefile basics.
#
# You will learn why `make` is so great, and why, despite its "weird" syntax,
# it is actually a highly expressive, efficient, and powerful way to build
# programs.
#
# Once you're done here, go to
# http://www.gnu.org/software/make/manual/make.html
# to learn SOOOO much more.
@montanaflynn
montanaflynn / crop.go
Last active February 5, 2016 00:27
Example of cropping an image using a cli tool built in Golang
package main
import (
"fmt"
"image"
_ "image/jpeg"
"image/png"
"log"
"os"
"strconv"
@montanaflynn
montanaflynn / hiring-quotes.md
Last active January 15, 2019 13:33
Quotes on hiring for startups

"If you pick the right people and give them the opportunity to spread their wings and put compensation as a carrier behind it, you almost don't have to manage them." Jack Welch

"I hire people brighter than me and I get out of their way." Lee Iacocca

"The competition to hire the best will increase in the years ahead. Companies that give extra flexibility to their employees will have the edge in this area." Bill Gates

"The secret of my success is that we have gone to exceptional lengths to hire the best people in the world."