Skip to content

Instantly share code, notes, and snippets.

View hbd's full-sized avatar
💭
:)

Zak hbd

💭
:)
View GitHub Profile
package location
type Client struct {
clients []locationiface.Client
}
func NewClient(clients ...locationiface.Client) *Client {
return &Client{clients: clients}
}
package locationiface
type Client interface {
DriveTime(context.Context, ...Location) (float64, error)
}
@hbd
hbd / bing.go
Created January 22, 2020 06:34
Writing Clients in Go: Redundancy and the `*iface` Package
package bing
func (c *Client) DriveTime(ctx context.Context, locations ...Location) (float64, error) {
// Call external API.
driveTime, err := c.httpclient.Post(ctx, c.config.Endpoint+"/routing/time", ...)
...
return driveTime, nil
}
@hbd
hbd / main.go
Created January 11, 2020 03:52
h3ll0, w0rld!
package main
import (
"fmt"
)
func main() {
fmt.Println("h3ll0, w0rld!")
}
/*
Instructions:
To enable dark mode in Slack, add this to bottom of /Applications/Slack.app/Contents/Resources/app.asar.unpacked/src/static/ssb-interop.js
document.addEventListener('DOMContentLoaded', function() {
$.ajax({
url: 'https://gist.githubusercontent.com/hbd/04bdcb1af1658230374279c9013b91f0/raw/acbca2a4b40d892f44b65d62ce49626848351b15/slack-dark-mode.css',
success: function(css) {
let overrides = `
code { background-color: #535353; color: #85c5ff; } // Change color: to whatever font color you want
@hbd
hbd / pr-template.md
Created October 24, 2018 14:27
[WIP] PR Template

What's this PR do?

Where should the reviewer start?

Test output?

# taken from discussion -- not original code
n = int(input().strip())
bucket = defaultdict(list) # bucket, actually a list with 1 key/n values
# store each input in the appropriate sub-bucket location
# use the string's length as the index (key), and appends it at that sub-bucket location
# this collects all string of the same length in the same sub-bucket location
for _ in range(n):
number = input().strip()
bucket[len(number)].append(number)
@hbd
hbd / xss alert test
Last active November 25, 2016 16:22
alert();
I hereby claim: [15/76896]
* I am hbd on github.
* I am mister (https://keybase.io/mister) on keybase.
* I have a public key ASBD9YjzUdtA_MMMkI4GUJ45IDk7FMMbYsWNpzX3geOHdAo
To claim this, I am signing this object:
```json
{
for (i = r; i < r+8; i++) {
for (j = c; j < c+8; j++) {
...
tmp = A[i][j];
B[j][i] = tmp;
...
}
}