CREATE TABLE _test(id SERIAL PRIMARY KEY, item_id INT NOT NULL, parent_id INT);
INSERT INTO _test(item_id, parent_id) VALUES (1, null), (2, 1), (3, 1), (3, 5), (4, 3), (5, 5);
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"database/sql" | |
"log" | |
) | |
func main() { | |
db, err := sql.Open("VENDOR_HERE", "YOUR_DSN_HERE") | |
handleError(err) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"context" | |
"flag" | |
"fmt" | |
"log" | |
"net/http" | |
"os" | |
"os/signal" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"reflect" | |
) | |
// Name of the struct tag used in examples | |
const tagName = "validate" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# How to use "acme.sh" to set up Lets Encrypt without root permissions | |
# See https://github.com/Neilpang/acme.sh for more | |
# This assumes that your website has a webroot at "/var/www/<domain>" | |
# I'll use the domain "EXAMPLE.com" as an example | |
# When this is done, there will be an "acme" user that handles issuing, | |
# updating, and installing certificates. This account will have the following | |
# (fairly minimal) permissions: | |
# - Host files at http://EXAMPLE.com/.well-known/acme-challenge |
-
brew install gnupg, pinentry-mac
(this includes gpg-agent and pinentry) -
Generate a key:
$ gpg --gen-key
-
Take the defaults. Whatevs
-
Tell gpg-agent to use pinentry-mac:
$ vim ~/.gnupg/gpg-agent.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"flag" | |
"fmt" | |
"os" | |
) | |
func main() { | |
askCommand := flag.NewFlagSet("ask", flag.ExitOnError) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ($ssl_client_i_dn != "/C=US/O=CloudFlare, Inc./OU=Origin Pull/L=San Francisco/ST=California/CN=origin-pull.cloudflare.net") { | |
return 403; | |
} | |
ssl_verify_client on; | |
ssl_client_certificate /etc/nginx/ssl/origin-pull-ca.pem; | |
ssl_verify_depth 1; | |
if ($ssl_client_verify != "SUCCESS") { | |
return 403; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Source: http://nicolasmerouze.com/guide-routers-golang/ | |
// Package httprouterwrapper allows the use of http.HandlerFunc compatible funcs with julienschmidt/httprouter | |
package httprouterwrapper | |
import ( | |
"net/http" | |
"github.com/gorilla/context" | |
"github.com/julienschmidt/httprouter" |
NewerOlder