Skip to content

Instantly share code, notes, and snippets.

package main
import (
"encoding/base64"
"encoding/json"
"fmt"
)
type X struct {
B []byte `json:"b"`
@nikolaydubina
nikolaydubina / git_commit_ollama.sh
Last active October 8, 2024 19:28 — forked from karpathy/add_to_zshrc.sh
Git Commit Message AI
# -----------------------------------------------------------------------------
# AI-powered Git Commit Function
# Copy paste this gist into your ~/.bashrc or ~/.zshrc to gain the `gcm` command. It:
# 1) gets the current staged changed diff
# 2) sends them to an LLM to write the git commit message
# 3) allows you to easily accept, edit, regenerate, cancel
# based on https://gist.github.com/karpathy/1dd0294ef9567971c1e4348a90d69285
gcm() {
# Function to generate commit message
// https://jameshfisher.com/2018/02/20/c-inline-assembly-hello-world/
int main(void) {
register int syscall_no asm("rax") = 1;
register int arg1 asm("rdi") = 1;
register char* arg2 asm("rsi") = "hello, world!\n";
register int arg3 asm("rdx") = 14;
asm("syscall");
return 0;
}
// https://go.dev/play/p/HTKZzENHPcG
package main
import (
"encoding/json"
"fmt"
)
type Color struct{ c uint }

Why browsers do not send If-None-Match for caching images? Why browser does not try to get 304 status code for caching?

This can be because there are video html that is trying to load at same time. This can break some browser behavior that will not even attempt to use cached images for some reason. Make preload="none" for videos to stop loading them, and then browser will attempt to use etags for images. Add Cache Control: public. This will make Safari to attempt If-None-Match and make 304 requetsts. private should also work.

2024-04-23

// https://go.dev/play/p/1nLXyCDe1_3
// because UNIX! 🐣
package main
import "fmt"
var (
Read = Permission{0x1}
Write = Permission{0x2}
Execute = Permission{0x4}
// 🍧
package main
import "fmt"
type LRUCache struct {
size int
vals map[string]string
order PtrList
}

Convert to CSV

jq -r '[.function_name, .call_count] | @csv'
// does go unpack multiple assignment with variable returns?
// no 🙅🏻‍♂️
// https://go.dev/play/p/8wKi-2J7aL7
package main
import "fmt"
func one(v int) int { return v }
func two() (int, int) { return 2, 3 }
// slice of strings as CLI argument 🐹
// https://pkg.go.dev/flag#Value
package main
import (
"flag"
"log"
)
type arrayFlags []string