Skip to content

Instantly share code, notes, and snippets.

View dmitshur's full-sized avatar

Dmitri Shuralyov dmitshur

View GitHub Profile
@dmitshur
dmitshur / gist:6927554
Last active September 17, 2023 07:35
[Legacy GOPATH mode] How to `go get` private repos using SSH key auth instead of password auth.

WARNING: This gist was created in 2013 and targets the legacy GOPATH mode. If you're reading this in 2021 or later, you're likely better served by reading https://tip.golang.org/cmd/go/#hdr-Configuration_for_downloading_non_public_code and https://golang.org/ref/mod#private-modules.

$ ssh -A vm
$ git config --global url."git@github.com:".insteadOf "https://github.com/"
$ cat ~/.gitconfig
[url "git@github.com:"]
	insteadOf = https://github.com/
$ go get github.com/private/repo && echo Success!
Success!
@dmitshur
dmitshur / non-zero-synopsis-diff.txt
Created October 20, 2020 15:09
Raw data for golang.org/issue/31947.
total module versions considered: 1779
unique modules processed: 1061
github.com/elastic/beats/v7@v7.9.3-0.20201016221757-731564783976/filebeat/input/redis/doc.go:
"Package redis package contains input and harvester to read the redis slow log The redis slow log is stored in memory."
"Package redis package contains input and harvester to read the redis slow log"
github.com/elastic/beats/v7@v7.9.3-0.20201016221757-731564783976/libbeat/common/cleanup/cleanup.go:
"Package cleanup provides common helpers for common cleanup patterns on defer Use the helpers with `defer`."
@dmitshur
dmitshur / Default (OSX).sublime-keymap
Last active October 18, 2020 21:57
Sublime Text on OS X, make Cmd+F do the equivalent of Cmd+E followed by Cmd+F. Works for all selections, not just single line like "find_selected_text" setting.
[
// ... (existing content)
// Find selected text, even if it spans multiple lines (unlike "find_selected_text").
{ "keys": ["super+f"], "command": "run_multiple_commands", "args":
{ "commands":
[
// Only execute slurp if there's selected text.
{"command": "slurp_find_string", "context": "window", "condition": "selected_text"},
{"command": "show_panel", "args": {"panel": "find", "reverse": false}, "context": "window"}
@dmitshur
dmitshur / main.go
Last active March 16, 2020 10:59
A simple server for HTTPS and HTTP protocols.
// A simple server for HTTPS and HTTP protocols. It implements these behaviors:
//
// • uses Let's Encrypt to acquire and automatically refresh HTTPS certificates
//
// • redirects HTTPS requests to canonical hosts, reverse proxies requests to internal backing servers
//
// • redirects all HTTP requests to HTTPS
//
// • gates certain endpoints with basic auth, using bcrypt-hashed passwords
//
@dmitshur
dmitshur / gist:77cc54e53bbc0bf9a9a6
Last active February 19, 2020 10:01
How I use GOPATH with multiple workspaces.
@dmitshur
dmitshur / main.go
Last active January 28, 2018 08:48
Server for HTTPS protocol. Redirects to canonical hosts, reverse proxies requests to internal backing servers.
// Server for HTTPS protocol. Redirects to canonical hosts, reverse proxies requests to internal backing servers.
package main
import (
"crypto/tls"
"flag"
"log"
"net/http"
"net/http/httputil"
"time"
@dmitshur
dmitshur / main.go
Last active September 6, 2017 08:32
Server for HTTP protocol. Redirects all requests to HTTPS.
// Server for HTTP protocol. Redirects all requests to HTTPS.
package main
import (
"flag"
"log"
"net/http"
)
var (
@dmitshur
dmitshur / gist:5f9e93c38f6b75421060
Last active August 28, 2017 19:23
Trying to do reverse range in html/template... Is there a better way?
<ul>
{{/* So simple... */}}
{{range .Commits}}<li>{{.Commit.Message}}</li>
{{end}}
{{/* Is this really the shortest/best way to to do reverse range? */}}
{{range $i, $v := .Commits}}<li>{{(index $.Commits (revIndex $i (len $.Commits))).Commit.Message}}</li>
{{end}}
</ul>
@dmitshur
dmitshur / gist:7346402
Last active July 13, 2017 18:44
GoSublime setup steps.
package main
import (
_ "fmt"
_ "net"
_ "github.com/samuel/go-zookeeper"
_ "github.com/mocktesting/nolongerexists"
)