Skip to content

Instantly share code, notes, and snippets.

View TomWright's full-sized avatar

Tom Wright TomWright

View GitHub Profile
@TomWright
TomWright / path.go
Last active November 26, 2020 17:47
Find relative path between 2 directories in Go.
package main
import (
"fmt"
"strings"
)
func main() {
fmt.Println(FindRelativePath("/some/source/path", "/some/destination/path")) // ../../destination/path
fmt.Println(FindRelativePath("/some/source/path", "/some/source")) // ..
### Keybase proof
I hereby claim:
* I am tomwright on github.
* I am tomwright93 (https://keybase.io/tomwright93) on keybase.
* I have a public key ASAQMdS32fzeB_VbL9Omv1dl2BmOGPnleuqIQVMDoIcFigo
To claim this, I am signing this object:
@TomWright
TomWright / Api.js
Last active January 9, 2017 16:43
Middleware implementation in Javascript.
// Example usage
function ApiCall() {
this.middleware = new TomWright.Middleware();
this.initMiddleware();
};
ApiCall.prototype.initMiddleware = function () {
this.middleware.use(this.ensureApiKeyExists);
this.middleware.use(this.checkForNotification);