Skip to content

Instantly share code, notes, and snippets.

@marawannwh
marawannwh / quickgit.fish
Created December 4, 2024 02:58 — forked from Abushawish/quickgit.fish
Git add, commit, and push in one function for Fish Shell
# 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
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,
# 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.
buckets[3][5] = value
elem = add(
unsafe.Pointer(b),
dataOffset+bucketCnt*uintptr(t.keysize)+i*uintptr(t.elemsize)
)
// map bucket
type bmap struct {
tophash [8]uint8
keys [8]keyType
values [8]valueType
}
// map header
type hmap struct {
B uint8
<Key>: <value>
"name": "Marwan"
"age": 30
"gender": "Male"
// Assume the following hashing results
hash("name") = 3
hash("age") = 5
hash("gender") = 6
// The underlying array would be like
["", "", "", "Marwan", "", 30, "Male", ...]
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
type hmap struct {
count int
flags uint8
B uint8
noverflow uint16
hash0 uint32
buckets unsafe.Pointer
oldbuckets unsafe.Pointer
nevacuate uintptr
extra *mapextra