Skip to content

Instantly share code, notes, and snippets.

@tonyblundell
tonyblundell / docker-compose.yml
Created October 5, 2018 14:03
Golang docker-compose.yml
version: "3"
services:
app:
image: golang:alpine
working_dir: /app
volumes:
- .:/app
command: sh -c "go fmt && go run main.go"
@tonyblundell
tonyblundell / distance.sql
Created September 29, 2014 14:48
SQL lat/long distance(mi) calc
3959 * ACOS(COS(RADIANS(lat1)) * COS(RADIANS(lat2)) *
COS(RADIANS(long2) - RADIANS(long1)) +
SIN(RADIANS(lat1)) * SIN(RADIANS(lat2)))
@tonyblundell
tonyblundell / ago.py
Created May 10, 2012 10:43
ago: Calculate a '3 hours ago' type string from a python datetime.
import datetime
def ago(t):
"""
Calculate a '3 hours ago' type string from a python datetime.
"""
units = {
'days': lambda diff: diff.days,
'hours': lambda diff: diff.seconds / 3600,
'minutes': lambda diff: diff.seconds % 3600 / 60,