Skip to content

Instantly share code, notes, and snippets.

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.

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 (
"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"))
}
package main
import (
"fmt"
"time"
"sync"
)
func main() {
wg := &sync.WaitGroup{}
package rand
import (
"crypto/rand"
"encoding/base64"
)
const (
byteLength = 6
)
@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 {
@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 / 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 / Brewfile
Created October 20, 2019 04:36 — forked from cliss/Brewfile
Casey Liss's Brewfile, as of 8 October 2019
cask_args appdir: "/Applications"
tap "homebrew/cask-fonts"
brew "mas"
mas "1Blocker", id: 1107421413
mas "Day One", id: 1055511498
mas "Deliveries", id: 924726344
mas "Due", id: 524373870
mas "Fantastical", id: 435003921
@countingtoten
countingtoten / How I saved a year of our family pictures from a dead hard drive.
Created September 18, 2019 18:22 — forked from chitchcock/How I saved a year of our family pictures from a dead hard drive.
"How I saved a year of our family pictures from a dead hard drive." saved ars forum
Copied from http://arstechnica.com/civis/viewtopic.php?f=19&t=1197911 (via http://www.libertypages.com/clarktech/?p=349)
-----------------------------------------------
MarkLT1
Ars Scholae Palatinae
et Subscriptor
Tribus: Where the women are strong, the men are good looking, and all the children are above average.
Registered: Nov 11, 2002
Posts: 924
-----------------------------------------------