Skip to content

Instantly share code, notes, and snippets.

@countingtoten
countingtoten / nginx.conf
Created February 19, 2020 17:11
Nginx Proxy Log Line
log_format json escape=json '${LOG_PREFIX} {"source": ["nginx","/var/log/nginx/access.log"], '
'"time": "$time_iso8601", '
'"level": "info", '
'"nginx_remote_addr": "$remote_addr", '
'"nginx_remote_port": "$remote_port", '
'"nginx_realip_remote_addr": "$realip_remote_addr", '
'"nginx_realip_remote_port": "$realip_remote_port", '
'"nginx_server_addr": "$server_addr", '
'"nginx_server_port": "$server_port", '
'"nginx_host": "$host", '
@countingtoten
countingtoten / 001_onboot
Created August 5, 2020 17:56
/var/lib/cloud/scripts/per-instance/001_onboot
#!/bin/bash
export DEBIAN_FRONTEND=noninteractive
export LC_ALL=C
export LANG=en_US.UTF-8
export LC_CTYPE=en_US.UTF-8
# Protect the droplet
ufw limit ssh
ufw allow https
@countingtoten
countingtoten / move_zeroes.go
Last active August 18, 2020 03:52
Given an array of random integers, move all the zeros in the array to the end of the array. Try to keep this in O(n) time (or better)! From @cassidoo's newsletter https://cassidoo.co/newsletter/
package main
import (
"fmt"
)
func moveZeros(nums []int) {
freeSpot := 0
for i, n := range nums {
package rand
import (
"crypto/rand"
"encoding/base64"
)
const (
byteLength = 6
)
package main
import (
"fmt"
"time"
"sync"
)
func main() {
wg := &sync.WaitGroup{}
package main
import (
"net"
)
func handleConnection(c net.Conn) {
c.Write([]byte("HTTP/1.1 200 OK\nContent-Type: text/html\nContent-Length: 27\n\n<html>Hello, world!</html>\n"))
}

Developing on the our Team

This document is a collection of team preferences and agreements. It can be updated at any time (PRs welcome) when opinions change. The advice below will not apply to all situations. Please use your best judgement and ignore these preferences when it makes sense.

1. Creating a Pull Request (PR)

1.1 MUST ensure ownership of the feature

Each developer is responsible for their feature, from the first commit to testing it in production. The developer is responsible for adding tests, reaching out for PR reviews in Slack, testing in staging, and testing in production after it is released.

package main
import (
"fmt"
)
/*
A trie (pronounced try) is a tree datastructure that links nodes by a common character.
It is also known as a prefix tree because all children of a node will have a common prefix.
It is like an efficient set of strings.