Skip to content

Instantly share code, notes, and snippets.

AutoHotkey v2: Flexible Collections
Go: Strong Typing for Collections
#Requires AutoHotkey v2.0.2+
#SingleInstance Force
DetectHiddenWindows true
; Hotkey: Ctrl+Alt+O to organize desktop files
^!o:: {
organizDesktopFiles()
}
; Hotkey: Ctrl+Alt+S to take a screenshot and save with timestamp
package main
import (
"encoding/json"
"fmt"
"net/http"
)
type User struct {
ID int `json:"id"`
#Requires AutoHotkey v2.0.2+
#SingleInstance Force
DetectHiddenWindows true
readConfigFile(fileName) {
try {
fileObj := FileOpen(fileName, "r")
if !fileObj {
throw Error("Could not open file")
}
package main
import (
"fmt"
"os"
)
func readConfigFile(fileName string) (string, error) {
data, err := os.ReadFile(fileName)
if err != nil {
#Requires AutoHotkey v2.0.2+
#SingleInstance Force
; Global counter for demonstration
downloadCount := 0
; Start three "concurrent" downloads
SetTimer(downloadImage, 2000) ; Run after 2 seconds
SetTimer(downloadVideo, 3000) ; Run after 3 seconds
SetTimer(downloadDoc, 1000) ; Run after 1 second
package main
import (
"fmt"
"time"
)
func downloadFile(fileName string, duration time.Duration) {
fmt.Printf("Starting download: %s\n", fileName)
time.Sleep(duration) // Simulate download time
package main
import (
"fmt"
"time"
)
func downloadFile(fileName string, duration time.Duration) {
fmt.Printf("Starting download: %s\n", fileName)
time.Sleep(duration) // Simulate download time
#Requires AutoHotkey v2.0.2+
#SingleInstance Force
; Regular function
greetUser(name) {
return "Hello, " . name
}
; Function that takes a function as parameter
applyOperation(x, y, operationFunc) {