Skip to content

Instantly share code, notes, and snippets.

@ki4jnq
ki4jnq / style.md
Last active June 18, 2020 14:32
Pragmatic Code Guidelines

What's This?

While often "good style" and idioms are language specific, some principles transcend language choice or personal preference. This is an attempt collect some of those practices in one place.

Control Flow

Extensive branching structures quickly become difficult to maintain. When you find yourself creating deeply nested structures, start looking for ways to break it down.

@ki4jnq
ki4jnq / app.go
Last active November 9, 2018 20:19
package web
import (
"net/http"
"encoding/json"
)
func ServerStart() {
http.HandleFunc("/", func(res http.ResponseWriter, req *http.Request) {
buf, err := json.Marshal(map[string]string{"message": "Hello World!"})
@ki4jnq
ki4jnq / uri.js
Last active January 3, 2016 11:49 — forked from jlong/uri.js
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"