Skip to content

Instantly share code, notes, and snippets.

@mikattack
mikattack / logger_test.go
Created August 16, 2016 19:32
Example Go unit test for logging middleware
package middleware
import (
"bufio"
"bytes"
"fmt"
"net/http"
"net/http/httptest"
"os"
"strings"
@mikattack
mikattack / Dockerfile
Last active November 12, 2015 18:23
Docker-ized Webserver Example
FROM ubuntu:14.04
RUN apt-get -y update && apt-get -y install nginx
RUN mkdir -p /var/www/website
ADD nginx/global.conf /etc/nginx/conf.d/
ADD nginx/nginx.conf /etc/nginx/nginx.conf
EXPOSE 80
@mikattack
mikattack / client.go
Last active October 16, 2015 12:57
Basic chunked response server and client. There's a single, obvious error in here that poor error handling obscures. See if you can spot it.
package main
import (
"encoding/json"
"fmt"
"io"
"net/http"
)
@mikattack
mikattack / yosemite_nginx_dsnmasq.md
Last active July 28, 2019 14:47
[Yosemite/El Capitan] Nginx and DNSMasq

Under Yosemite (and El Capitan), the launch launchctl utility changed.

For dnsmasq:

  1. brew install dnsmasq or brew upgrade dnsmasq
  2. sudo cp -fv /usr/local/opt/dnsmasq/*.plist /Library/LaunchDaemons
  3. In /usr/local/etc/dnsmasq.conf add the line address=/devel/127.0.0.1 (do NOT add dev as this is now a top-level TLD)
  4. sudo launchctl bootstrap system /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
  5. sudo launchctl enable system/homebrew.mxcl.dnsmasq
  6. sudo launchctl kickstart -kp system/homebrew.mxcl.dnsmasq
@mikattack
mikattack / it.unbit.uwsgi.plist
Created March 5, 2013 13:35
Launchd plist file for "uwsgi" in Emperor mode.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Disabled</key>
<false/>
<key>KeepAlive</key>
<true/>
<key>RunAtLoad</key>
<true/>