init
This commit is contained in:
commit
9cd3f40ead
33
.gitignore
vendored
Normal file
33
.gitignore
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
.DS_Store
|
||||
# If you prefer the allow list template instead of the deny list, see community template:
|
||||
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
|
||||
#
|
||||
# Binaries for programs and plugins
|
||||
*.exe
|
||||
*.exe~
|
||||
*.dll
|
||||
*.so
|
||||
*.dylib
|
||||
|
||||
# Test binary, built with `go test -c`
|
||||
*.test
|
||||
|
||||
# Code coverage profiles and other test artifacts
|
||||
*.out
|
||||
coverage.*
|
||||
*.coverprofile
|
||||
profile.cov
|
||||
|
||||
# Dependency directories (remove the comment below to include it)
|
||||
# vendor/
|
||||
|
||||
# Go workspace file
|
||||
go.work
|
||||
go.work.sum
|
||||
|
||||
# env file
|
||||
.env
|
||||
|
||||
# Editor/IDE
|
||||
# .idea/
|
||||
# .vscode/
|
||||
25
index.html
Normal file
25
index.html
Normal file
@ -0,0 +1,25 @@
|
||||
<!DOCTYPE html><html><head><title>poem, rotting</title><meta name='viewport' content='width=device-width, initial-scale=1' /><link rel='stylesheet' href='style.css' /></head><body><h1>rotting</h1><small>This poem rots over time, eventually disappearing. New words are added to the top of the heap periodically. It offgasses into the internet via random UDP <a href='https://www.rfc-editor.org/rfc/rfc862'>echo packets</a>. Few hosts respond.</small><hr/><p id='poem'>ᵘͥnot ዲo g⋍ᦎtl ino hୂ gᜬݰnh,
|
||||
Olጮge shoul brnan a tᗹcose ⢄fay
|
||||
Rag※,rg᮱⟛᭸aᪿtᖤ dyg Џ᧣lߗght
|
||||
|
||||
Thेughwའs n ¨ thir˘Ὄd knw daks rght,
|
||||
Bcauọher៤ͳors⏢hͫd fkeె᪸o lgtnin⮌ᥬey
|
||||
D noഁ o ent notat godnȸt.
|
||||
|
||||
ᖜईo enѵth lᴛᬛ ླav by, cringނo brght
|
||||
Theiཐ٠rai d ௲igtaveuneૺiೡ a gඎnἻòa,
|
||||
aeઉ ݛag agaist the⎌dyng ofteht.
|
||||
|
||||
Wild⪴men ho⌆cҬuᖆt ansng the un i࿂ fligᛳ,
|
||||
n lern, tᲦ lࠋt,ႋׄhᲁल ivedtᖱsӰway╝
|
||||
Doᾬnt go၍get ቻntot gȔ nigη॒ᣯ
|
||||
|
||||
Gᨠve mஸn۳ nar deth, ଛhɇse wit😡သblin᪾inght
|
||||
BliЏ᬴es could aরeࡴlik mtᴷ⮆s a© gy
|
||||
RageraᔚagɡstheĄܔi⫝ of tlight
|
||||
|
||||
dyoᜇmyfathr, hereo te៎ݽadheit
|
||||
Curseࠓl൛ᜈ ٧e nwit ouẳe teaႳs, ௪ Ỹr⒱
|
||||
DoҾ ogetleീ᠖ntht ࠺ᮙoࢡnihϯ
|
||||
RaⰄ, ᕅagegੵst ᬁe yin᧒ of ۭhe Ỻƛht.
|
||||
</p></body></html>
|
||||
108
main.go
Normal file
108
main.go
Normal file
@ -0,0 +1,108 @@
|
||||
// You can edit this code!
|
||||
// Click here and start typing.
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"net"
|
||||
"os"
|
||||
"time"
|
||||
)
|
||||
|
||||
func getRandomAddress() string {
|
||||
ip1 := rand.Intn(256)
|
||||
ip2 := rand.Intn(256)
|
||||
ip3 := rand.Intn(256)
|
||||
ip4 := rand.Intn(256)
|
||||
return fmt.Sprintf("%d.%d.%d.%d", ip1, ip2, ip3, ip4)
|
||||
}
|
||||
|
||||
func offgas(r rune) {
|
||||
address := getRandomAddress()
|
||||
conn, err := net.Dial("udp", address+":7")
|
||||
if err != nil {
|
||||
fmt.Println("Error connecting to:", address, err)
|
||||
}
|
||||
defer conn.Close()
|
||||
|
||||
// Set write timeout
|
||||
conn.SetWriteDeadline(time.Now().Add(3 * time.Second))
|
||||
|
||||
// Send the character
|
||||
_, err = conn.Write([]byte(string(r)))
|
||||
if err != nil {
|
||||
fmt.Println("Error sending data to:", address, err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
// get poem.txt and index.html locations from args, if possible
|
||||
poemFile := "poem.txt"
|
||||
indexFile := "index.html"
|
||||
if len(os.Args) == 3 {
|
||||
poemFile = os.Args[1]
|
||||
indexFile = os.Args[2]
|
||||
}
|
||||
|
||||
// get string from poem.txt
|
||||
str, err := os.ReadFile(poemFile)
|
||||
if err != nil {
|
||||
fmt.Println("Error reading file:", err)
|
||||
return
|
||||
}
|
||||
|
||||
bstr := []byte(str)
|
||||
lastRune := rune(0)
|
||||
|
||||
randomByteSwitch := func(r rune) rune {
|
||||
dec := rand.Float64()
|
||||
if dec < 0.003 {
|
||||
lastRune = r
|
||||
if r == 10 || r == 13 {
|
||||
return r
|
||||
}
|
||||
|
||||
char := rand.Float64()
|
||||
if char > 0.3 {
|
||||
return rune(rand.Int31n(8191) + 97) // a-z
|
||||
}
|
||||
if char < 0.01 {
|
||||
return rand.Int31n(128591-128513) + 128513
|
||||
}
|
||||
|
||||
return rand.Int31n(11359)
|
||||
}
|
||||
if dec < 0.007 {
|
||||
if dec > 0.001 && r == 10 || r == 13 {
|
||||
if lastRune == 10 || lastRune == 13 {
|
||||
offgas(r)
|
||||
lastRune = r
|
||||
return -1
|
||||
}
|
||||
lastRune = r
|
||||
return r
|
||||
}
|
||||
|
||||
offgas(r)
|
||||
lastRune = r
|
||||
return -1
|
||||
}
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
bstr = bytes.Map(randomByteSwitch, bstr)
|
||||
|
||||
outstr := "<!DOCTYPE html><html><head><title>poem, rotting</title><meta name='viewport' content='width=device-width, initial-scale=1' /><link rel='stylesheet' href='style.css' /></head><body><h1>rotting</h1><small>This poem rots over time, eventually disappearing. New words are added to the top of the heap periodically. It offgasses into the internet via random UDP <a href='https://www.rfc-editor.org/rfc/rfc862'>echo packets</a>. Few hosts respond.</small><hr/><p id='poem'>" + string(bstr) + "</p></body></html>"
|
||||
|
||||
// write to index.html
|
||||
err = os.WriteFile(indexFile, []byte(outstr), 0644)
|
||||
err = os.WriteFile(poemFile, bstr, 0644)
|
||||
if err != nil {
|
||||
fmt.Println("Error writing file:", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
24
poem.txt
Normal file
24
poem.txt
Normal file
@ -0,0 +1,24 @@
|
||||
ᵘͥnot ዲo g⋍ᦎtl ino hୂ gᜬݰnh,
|
||||
Olጮge shoul brnan a tᗹcose ⢄fay
|
||||
Rag※,rg᮱⟛᭸aᪿtᖤ dyg Џ᧣lߗght
|
||||
|
||||
Thेughwའs n ¨ thir˘Ὄd knw daks rght,
|
||||
Bcauọher៤ͳors⏢hͫd fkeె᪸o lgtnin⮌ᥬey
|
||||
D noഁ o ent notat godnȸt.
|
||||
|
||||
ᖜईo enѵth lᴛᬛ ླav by, cringނo brght
|
||||
Theiཐ٠rai d ௲igtaveuneૺiೡ a gඎnἻòa,
|
||||
aeઉ ݛag agaist the⎌dyng ofteht.
|
||||
|
||||
Wild⪴men ho⌆cҬuᖆt ansng the un i࿂ fligᛳ,
|
||||
n lern, tᲦ lࠋt,ႋׄhᲁल ivedtᖱsӰway╝
|
||||
Doᾬnt go၍get ቻntot gȔ nigη॒ᣯ
|
||||
|
||||
Gᨠve mஸn۳ nar deth, ଛhɇse wit😡သblin᪾inght
|
||||
BliЏ᬴es could aরeࡴlik mtᴷ⮆s a© gy
|
||||
RageraᔚagɡstheĄܔi⫝ of tlight
|
||||
|
||||
dyoᜇmyfathr, hereo te៎ݽadheit
|
||||
Curseࠓl൛ᜈ ٧e nwit ouẳe teaႳs, ௪ Ỹr⒱
|
||||
DoҾ ogetleീ᠖ntht ࠺ᮙoࢡnihϯ
|
||||
RaⰄ, ᕅagegੵst ᬁe yin᧒ of ۭhe Ỻƛht.
|
||||
Loading…
x
Reference in New Issue
Block a user