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
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 January 20, 2024 22:01
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

{

@joyrexus
joyrexus / README.md
Last active January 21, 2024 21:51 — forked from btoone/curl.md
curl tutorial

An introduction to curl using GitHub's API.

Basics

Makes a basic GET request to the specifed URI

curl https://api.github.com/users/caspyin

Includes HTTP-Header information in the output

@joyrexus
joyrexus / README.md
Last active January 24, 2023 19:15
POST with curl

Below are a few examples of POSTing form data and file-uploads with curl.

For guidance on when to use which method, see form-data vs -urlencoded.

For details and more examples, see the POST section of the official tutorial.


In the examples below, suppose we need to POST data to https://foo.io/users/joyrexus/shoes, the canonical address for the shoes resource (a "collection" resource, in REST-speak) of a particular user (joyrexus):