Skip to content

Instantly share code, notes, and snippets.

View joyrexus's full-sized avatar

J. Voigt joyrexus

View GitHub Profile
@joyrexus
joyrexus / index.html
Created October 6, 2015 19:00
Sewanee Flyover III
<html>
<head>
<meta charset='utf-8' />
<title>Domain Flyover</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.8.0/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.8.0/mapbox-gl.css' rel='stylesheet' />
<link href='https://www.mapbox.com/base/latest/base.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
@joyrexus
joyrexus / index.html
Created October 6, 2015 18:50
Sewanee Flyover II
<html>
<head>
<meta charset='utf-8' />
<title>Domain Flyover</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.8.0/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.8.0/mapbox-gl.css' rel='stylesheet' />
<link href='https://www.mapbox.com/base/latest/base.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
@joyrexus
joyrexus / index.html
Last active October 6, 2015 18:47
Sewanee Flyover
<html>
<head>
<meta charset='utf-8' />
<title>Mapbox GL JS Easing</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.8.0/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.8.0/mapbox-gl.css' rel='stylesheet' />
<link href='https://www.mapbox.com/base/latest/base.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
@joyrexus
joyrexus / README.md
Last active August 29, 2015 14:18
stowing gobs

Looks like you have to use gob to register the types you want to stow when using stow.NewStore.

Compare original example using stow.NewJsonStore.

See this post for context.

@joyrexus
joyrexus / README.md
Last active August 29, 2015 14:18
posts on vim config
@joyrexus
joyrexus / README.md
Created April 2, 2015 20:29
query strings with curl

Note that you can do a GET request to construct query strings with curl.

# GET http://acme.org/tasks?status=overdue&since=today
curl --get http://acme.org/tasks -d status=overdue -d since=today

# GET http://httpbin.org/get?status=overdue&since=today&contains=bob%20jones
curl -d status=overdue                       \
     -d since=today                          \
     --data-urlencode "contains=bob jones"   \

-G http://acme.org/search

@joyrexus
joyrexus / README.md
Last active July 13, 2019 21:46
time in go

Working with time in Go is pretty straightforward.

Times

Get the current local time:

now := time.Now()                                   // 02 Apr 15 14:03

Construct a time with Date(y, m, d, h, m, s, ns, loc):

@joyrexus
joyrexus / README.md
Last active June 21, 2026 12:54
nested templates in go

Example of nested templates.

Given this file layout ...

.
├── server.go
└── templates
    ├── profiles.html
    └── layout.html
@joyrexus
joyrexus / README.md
Last active August 29, 2015 14:18
rest api demo w/ go

Quick demo showing how to to simulate a simple REST API.

Credit where due: this demo is based on this example from Ardan Studios' training materials. We're using httprouter for routing and added a retrieve handler for retrieving users by ID (/users/:id).

See also this example, reflecting basic practices for designing a REST API.

Usage

Start the server:

@joyrexus
joyrexus / README.md
Created March 30, 2015 16:31
parse JSON request

Simple demo of how to decode JSON data coming from an http POST request.

Run the server with go run server.go and then make a curl request:

. post.sh

... or ...

curl -d @- http://localhost:8080/user

{