Skip to content

Instantly share code, notes, and snippets.

package main
import (
"fmt"
"time"
)
func intervalMessage(msg string, dur time.Duration) chan string {
outc := make(chan string)
go func() {
Do What You Want
Those are the most frightening four words brought to us by the connection revolution.
If you want to sing, sing.
If you want to lead, lead.
If you want to touch, connect, describe, disrupt, give, support, build, question... do it.
You will not be picked.
But if you want to pick yourself, go for it.
The cost is that you own the results
@blakesmith
blakesmith / pgmigrations.erb.sh
Created January 25, 2013 01:01
Create numbered migration files, 1-create_users.sql, 2-create_accounts.sql, put them in the MIGRATIONS_LOCATION directory.
#!/bin/bash
export PGPASSWORD=<%= password %>
USER=<%= user %>
DATABASE=<%= database %>
HOST=<%= host %>
MIGRATIONS_TABLE=<%= migrations_table %>
MIGRATIONS_LOCATION=<%= migrations_location %>
@blakesmith
blakesmith / gist:5234714
Created March 25, 2013 03:21
After a fresh install of Haskell Platform, there's a bunch of broken packages. Normal?
blake@Blake-Smiths-MacBook-Pro:~ » ghc-pkg check
Warning: haddock-interfaces: /usr/local/Cellar/haskell-platform/2012.2.0.0/share/doc/haskell-platform-2012.2.0.0/html/haskell-platform.haddock doesn't exist or isn't a file
Warning: haddock-html: /usr/local/Cellar/haskell-platform/2012.2.0.0/share/doc/haskell-platform-2012.2.0.0/html doesn't exist or isn't a directory
There are problems in package zlib-0.5.3.3:
Warning: library-dirs: /usr/local/Cellar/haskell-platform/2012.2.0.0/lib/ghc/zlib-0.5.3.3/ghc-7.4.2 doesn't exist or isn't a directory
Warning: haddock-interfaces: /usr/local/Cellar/haskell-platform/2012.2.0.0/share/doc/zlib-0.5.3.3/html/zlib.haddock doesn't exist or isn't a file
Warning: haddock-html: /usr/local/Cellar/haskell-platform/2012.2.0.0/share/doc/zlib-0.5.3.3/html doesn't exist or isn't a directory
import-dirs: /usr/local/Cellar/haskell-platform/2012.2.0.0/lib/ghc/zlib-0.5.3.3/ghc-7.4.2 doesn't exist or isn't a directory
file Codec/Compression/GZip.hi is missing
file Codec/Compress
blake@Blake-Smiths-MacBook-Pro:~/src/ghc » ./configure --target=arm-linux-gnueabihf --enable-unregisterised
checking for gfind... no
checking for find... /usr/bin/find
checking for sort... /usr/bin/sort
checking for GHC version date... inferred 7.7.20131029
checking for ghc... /usr/bin/ghc
checking version of ghc... 7.4.2
checking build system type... x86_64-apple-darwin12.5.0
checking host system type... x86_64-apple-darwin12.5.0
checking target system type... arm-unknown-linux-gnueabihf
property("meld two heaps with mins") = forAll { (h1: H, h2: H) =>
def getSeq(l: List[A], heap: H): List[A] = isEmpty(heap) match {
case true => l.reverse
case false => getSeq(findMin(heap) :: l, deleteMin(heap))
}
if (isEmpty(h1) || isEmpty(h2)) true
else {
val melded = getSeq(List(), meld(h1, h2))
val melded2 = getSeq(List(), meld(deleteMin(h1), insert(findMin(h1), h2)))
property("sorted delete") = forAll { (h: H) =>
def getSeq(l: List[A], heap: H): List[A] = isEmpty(heap) match {
case true => l.reverse
case false => getSeq(findMin(heap) :: l, deleteMin(heap))
}
val deleted = getSeq(List(), h)
deleted == deleted.sorted
}
def getMediaURI(userId: String, id: String): Future[MediaURI] =
for {
authed <- authorizedClient(userId, client)
track <- authed.getTrack(id)
url <- authed.resolveStreamLocation(track.streamUrl)
} yield MediaURI(url, Map())
@blakesmith
blakesmith / Makefile
Last active January 3, 2016 03:49
nginx log merger. Useful if you have logs distributed on many app nodes that you'd like unified into one big log file.
CC=gcc
CFLAGS=-Wall -pendatic -03 -std=c99
PROG=nginx_log_merger
all: nginx_log_merger.o
nginx_log_merger.o:
$(CC) $(CFLAGS) nginx_log_merger.c -o $(PROG)
clean:
@blakesmith
blakesmith / code_review_essentials.md
Last active January 8, 2026 13:18
Code Review Essentials for Software Teams

Code Review Essentials for Software Teams

Code Review is an essential part of any collaborative software project. Large software systems are usually written by more than one person, and so a highly functioning software team needs a robust process to keep its members, as well as the code base itself moving in the right direction.

Code Review is a powerful tool that: