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 git add, commit, and push using one function in friendly interactive shell (Fish Shell). | |
# Save this file within '~/.config/fish/functions' as 'quickgit.fish'. Create the directory if it does not exist. | |
# '--git-dir=$PWD/.git' Ensures that we run the git commands against the git project where we called the function | |
function quickgit # This is the function name and command we call | |
git --git-dir=$PWD/.git add . # Stage all unstaged files | |
git --git-dir=$PWD/.git commit -a -m $argv # Commit files with the given argument as the commit message | |
git --git-dir=$PWD/.git push # Push to remote | |
end |
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
func fetchInstances() (map[string]interface{}, error) { | |
jsonStr := []byte(`{ | |
"older_than": ` + olderThan + `, | |
"limit": ` + instancesToFetch + `, | |
}`) | |
req, err := http.NewRequest("GET", fetchInstancesURL, bytes.NewBuffer(jsonStr)) | |
req.Header.Set("Authorization", apiSecret) | |
req.Header.Set("Content-Type", "application/json") | |
client := &http.Client{ | |
Timeout: 30 * time.Second, |
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
# Use the offical golang image to create a binary. | |
# This is based on Debian and sets the GOPATH to /go. | |
# https://hub.docker.com/_/golang | |
FROM golang:1.16-buster as builder | |
# Create and change to the app directory. | |
WORKDIR /app | |
# Retrieve application dependencies. | |
# This allows the container build to reuse cached dependencies. |
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
buckets[3][5] = value |
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
elem = add( | |
unsafe.Pointer(b), | |
dataOffset+bucketCnt*uintptr(t.keysize)+i*uintptr(t.elemsize) | |
) |
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
// map bucket | |
type bmap struct { | |
tophash [8]uint8 | |
keys [8]keyType | |
values [8]valueType | |
} | |
// map header | |
type hmap struct { | |
B uint8 |
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
<Key>: <value> | |
"name": "Marwan" | |
"age": 30 | |
"gender": "Male" |
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
// Assume the following hashing results | |
hash("name") = 3 | |
hash("age") = 5 | |
hash("gender") = 6 | |
// The underlying array would be like | |
["", "", "", "Marwan", "", 30, "Male", ...] |
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
v = m[k] | |
// compiles to something similiar to the following | |
v = runtime.mapaccess(mt, m, k) | |
// which has the following signature | |
func mapaccess(t *maptype, m *hmap, k unsafe.Pointer) unsafe.Pointer |
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
type hmap struct { | |
count int | |
flags uint8 | |
B uint8 | |
noverflow uint16 | |
hash0 uint32 | |
buckets unsafe.Pointer | |
oldbuckets unsafe.Pointer | |
nevacuate uintptr | |
extra *mapextra |
NewerOlder