Skip to content

Instantly share code, notes, and snippets.

View montanaflynn's full-sized avatar

Montana Flynn montanaflynn

View GitHub Profile
@montanaflynn
montanaflynn / kong-dns.md
Last active March 2, 2022 12:46
Example of using Kong with DNS

Kong

Kong is a powerful proxy built on nginx. By taking a request and passing it to an upstream server and then returning the result to the client Kong can perform his magic. To know which requests go to which service Kong looks for a Host header to match against. There's a few other ways Kong can match requests to services but for now that's the most basic route. Pun intended.

Start

Assuming everything has been installed and setup, such as dependencies and config files which can be found in the docs, it's time to turn Kong on. The first time Kong runs you'll see some Kong config values and initial migrations to the datastore.

kong start
@montanaflynn
montanaflynn / logf.go
Last active August 29, 2015 14:22
Siege log formatter
package main
import (
"regexp"
"io/ioutil"
"os"
)
func replace(reg, repl, text string) string {
regex, _ := regexp.Compile(reg)
@montanaflynn
montanaflynn / .zshrc
Last active August 29, 2015 14:22
Docker aliases
# Stats for all running containers
alias docker-stats-all='docker ps -q | xargs docker stats'
# Remove all stopped containers
alias docker-rm-containers='docker ps -a -q | xargs docker rm'
# Remove all unused unnamed images
alias docker-rmi-junk='docker images | grep \<none\> | awk '{print $3}' | xargs docker rmi'
@montanaflynn
montanaflynn / goxy.go
Last active May 29, 2018 12:33
Golang HTTP Proxy
package main
import (
"log"
"flag"
"net"
"net/http"
"net/http/httputil"
"time"
"strconv"
@montanaflynn
montanaflynn / api.js
Last active October 19, 2021 00:35
Simple express api to get website meta data
// API stuff like routing, etc...
var express = require('express')
// To get the meta data, custom
var getMetaData = require("./meta.js")
// Create express api and route
express().get('/', function(req, res) {
// Get the query parameter url
@montanaflynn
montanaflynn / autotest.go
Created October 6, 2015 21:15
Automatically test go projects on change
package main
import (
"fmt"
"github.com/go-fsnotify/fsnotify"
"log"
"os"
"os/exec"
)
package main
import (
"fmt"
"strconv"
"testing"
)
var (
host string
@montanaflynn
montanaflynn / benchmark_string_helpers_test.go
Created October 7, 2015 18:09
Benchmarks for different ways of concatenating strings and turning an int into a string
package main
import (
"bytes"
"fmt"
"strconv"
"testing"
)
var (
@montanaflynn
montanaflynn / main.go
Created October 8, 2015 20:12
Listen for SIGINFO to report progress
package main
import (
"fmt"
"os"
"os/signal"
"syscall"
"time"
)
@montanaflynn
montanaflynn / main.go
Last active October 25, 2015 21:52
Statistics with channels and first-class functions
package main
import (
"log"
)
type fchan chan float64
type ichan chan int
type datafun func(Data, ichan, fchan)