qtsone/learning / skills/tutor
tutor
FlaggedTurn this agent into a personal programming tutor with a versioned 0-to-expert curriculum (Go available; more languages coming). Use when the user wants to learn a programming language, start or resume lessons, get their exercise code graded, check learning progress, or contribute curriculum fixes — e.g. "/tutor go", "/tutor resume", "teach me Go", "continue my lessons", "grade my exercise".
curriculum/content/focus/containers/compose/exercise/app/main.go
View on GitHub// Command app is the tiny HTTP service you wire up with Compose in this
// lesson. It is provided for you — the lesson is about compose.yaml, not about
// server design, which a later stage covers properly.
//
// It reads two environment variables:
//
// PORT the port to listen on (default 8080)
// DATABASE_URL postgres://user:password@host:port/dbname
//
// It never speaks SQL: /dbping opens a TCP connection to the host and port in
// DATABASE_URL and reports whether it answered. That is enough to prove two
// things you are about to learn — that a service name resolves to the right
// container, and that your startup ordering works.
package main
import (
"fmt"
"log/slog"
"net"
"net/http"
"net/url"
"os"
"time"
)
func main() {
log := slog.New(slog.NewTextHandler(os.Stdout, nil))
dbAddr, err := databaseAddr(os.Getenv("DATABASE_URL"))
if err != nil {
log.Error("bad DATABASE_URL", "err", err)
os.Exit(1)
}
addr := ":" + env("PORT", "8080")
log.Info("starting", "listen", addr, "database", dbAddr)
mux := http.NewServeMux()
mux.HandleFunc("GET /healthz", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "ok")
})
mux.HandleFunc("GET /dbping", func(w http.ResponseWriter, r *http.Request) {
conn, err := net.DialTimeout("tcp", dbAddr, 2*time.Second)
if err != nil {
log.Error("database unreachable", "database", dbAddr, "err", err)
http.Error(w, "database unreachable: "+err.Error(), http.StatusServiceUnavailable)
return
}
defer conn.Close()
fmt.Fprintf(w, "reached %s\n", dbAddr)
})
if err := http.ListenAndServe(addr, mux); err != nil {
log.Error("server stopped", "err", err)
os.Exit(1)
}
}
func env(key, fallback string) string {
if v := os.Getenv(key); v != "" {
return v
}
return fallback
}
// databaseAddr reduces a postgres:// URL to the host:port the app dials.
func databaseAddr(raw string) (string, error) {
if raw == "" {
return "", fmt.Errorf("DATABASE_URL is empty")
}
u, err := url.Parse(raw)
if err != nil {
return "", fmt.Errorf("parse %q: %w", raw, err)
}
host := u.Hostname()
if host == "" {
return "", fmt.Errorf("no host in %q", raw)
}
port := u.Port()
if port == "" {
port = "5432"
}
return net.JoinHostPort(host, port), nil
}
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness. | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |