Use xip.io with a home-grown Apache VirtualHost setup
- Start here.
- Add a
ServerAlias
line to your VirtualHost definitions.
<VirtualHost *:80>
DocumentRoot "/Users/you/Sites/sitename"
ServerAlias sitename.*.xip.io
ServerName sitename.dev
type Post struct { | |
// db tag lets you specify the column name if it differs from the struct field | |
Id int64 `db:"post_id"` | |
Created int64 | |
Title string `form:"Title" binding:"required"` | |
Body string `form:"Body"` | |
UserId int64 `form:"UserId"` | |
Url string | |
} |
// An intersting pattern for testing, but you can use the check anywhere | |
import "testing" | |
func TestCheckingChannel(t *testing.T) { | |
stop := make(chan bool) | |
// Testing some fucntion that SHOULD close the channel | |
func (stop chan bool) { | |
close(chan) | |
}(stop) |
ServerAlias
line to your VirtualHost definitions.<VirtualHost *:80>
DocumentRoot "/Users/you/Sites/sitename"
ServerAlias sitename.*.xip.io
ServerName sitename.dev
databaseadmin: | |
image: phpmyadmin/phpmyadmin | |
environment: | |
PMA_HOST: some-mysql | |
links: | |
- mysqlserver | |
ports: | |
- "8080:80" | |
mysqlserver: | |
image: mysql |
require('font-awesome/css/font-awesome.css'); | |
document.body.innerHTML = '<i class="fa fa-fw fa-question"></i>'; |
<html lang="en-us"></html> | |
<head> | |
<meta charset="utf-8"/> | |
<meta http-equiv="X-UA-Compatible" cntnt="IE=edge"/> | |
<title></title> | |
<meta name="viewport" cntnt="width=device-width, initial-scale=1, user-scalable=0, maximum-scale=1.0"/> | |
<meta name="description"/> | |
<link rel="stylesheet" href="css/.min.css"/> | |
<link rel="stylesheet" href="css/theme.min.css"/> |
file, err := os.Open(path) | |
if err != nil { | |
return err | |
} | |
defer file.Close() | |
// Only the first 512 bytes are used to sniff the content type. | |
buffer := make([]byte, 512) | |
_, err = file.Read(buffer) | |
if err != nil { |
By default when Nginx starts receiving a response from a FastCGI backend (such as PHP-FPM) it will buffer the response in memory before delivering it to the client. Any response larger than the set buffer size is saved to a temporary file on disk. This process is outlined at the Nginx ngx_http_fastcgi_module page document page.
Since disk is slow and memory is fast the aim is to get as many FastCGI responses passing through memory only. On the flip side we don't want to set an excessively large buffer as they are created and sized on a per request basis (i.e. it's not shared memory).
// Generate unique IDs for use as pseudo-private/protected names. | |
// Similar in concept to | |
// <http://wiki.ecmascript.org/doku.php?id=strawman:names>. | |
// | |
// The goals of this function are twofold: | |
// | |
// * Provide a way to generate a string guaranteed to be unique when compared | |
// to other strings generated by this function. | |
// * Make the string complex enough that it is highly unlikely to be | |
// accidentally duplicated by hand (this is key if you're using `ID` |