Skip to content

Instantly share code, notes, and snippets.

@bobrik

bobrik/main.go Secret

Created November 22, 2022 00:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bobrik/2c1a8a19b921fefe22caac21fda1be82 to your computer and use it in GitHub Desktop.
Save bobrik/2c1a8a19b921fefe22caac21fda1be82 to your computer and use it in GitHub Desktop.
package main
import (
"io"
"log"
"net/http"
"time"
)
func main() {
go massageBallast()
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
resp, err := http.Get("https://sim.cfperf.net/cached-assets/zero-5g.bin")
if err != nil {
log.Fatalf("Error sending a request: %v", err)
}
defer resp.Body.Close()
n, err := io.Copy(w, resp.Body)
if err != nil {
log.Fatalf("Error copying response body: %v", err)
}
log.Printf("Copied %d bytes", n)
})
err := http.ListenAndServe(":4444", nil)
if err != nil {
log.Fatalf("Error listening: %v", err)
}
}
func massageBallast() {
ballast := make([]uint8, 4*1024*1024*1024)
for i := range ballast {
ballast[i] = uint8(i % 8)
}
for {
sum := 0
for _, b := range ballast {
sum += int(b)
}
time.Sleep(1 * time.Second)
log.Printf("sum = %d", sum)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment