Compare commits

..

3 Commits

Author SHA1 Message Date
ike
e5a9fa5109 adjust the connector word percentage 2025-08-28 23:12:04 +00:00
ike
c09b66ea65 default to jagged little pill words 2025-08-28 22:59:52 +00:00
ike
2d60d26245 add readme; make links more frequent 2025-08-27 20:42:57 +00:00
7 changed files with 124 additions and 263 deletions

BIN
.DS_Store vendored

Binary file not shown.

25
README.md Normal file
View File

@ -0,0 +1,25 @@
![jaggedpill](jaggedpill.jpg)
# Jagged Pill
Jagged Pill is a webserver that responds to any request with a generated
HTML page containing random text and links. The generator is tuned to be very
nonsensical, but ends up creating some weirdly strange and poetic prose...
keep following links to find more!
I use this as an AI scraper labyrinth (or poison pill), with the following NGINX config:
```
# No AI Bots
if ($http_user_agent ~* '(AIBot|AnotherBot|YetAnotherBot)') {
rewrite ^(.*)$ /clank/$1;
}
location /clank/ {
rewrite ^/clank/(.*)$ $1 break;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://localhost:4791;
}
```

12
go.mod
View File

@ -2,14 +2,4 @@ module jaggedpill
go 1.22.1
require (
github.com/mroth/weightedrand/v2 v2.1.0
github.com/schollz/progressbar/v3 v3.18.0
)
require (
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db // indirect
github.com/rivo/uniseg v0.4.7 // indirect
golang.org/x/sys v0.29.0 // indirect
golang.org/x/term v0.28.0 // indirect
)
require github.com/mroth/weightedrand/v2 v2.1.0

22
go.sum
View File

@ -1,24 +1,2 @@
github.com/chengxilo/virtualterm v1.0.4 h1:Z6IpERbRVlfB8WkOmtbHiDbBANU7cimRIof7mk9/PwM=
github.com/chengxilo/virtualterm v1.0.4/go.mod h1:DyxxBZz/x1iqJjFxTFcr6/x+jSpqN0iwWCOK1q10rlY=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db h1:62I3jR2EmQ4l5rM/4FEfDWcRD+abF5XlKShorW5LRoQ=
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db/go.mod h1:l0dey0ia/Uv7NcFFVbCLtqEBQbrT4OCwCSKTEv6enCw=
github.com/mroth/weightedrand/v2 v2.1.0 h1:o1ascnB1CIVzsqlfArQQjeMy1U0NcIbBO5rfd5E/OeU=
github.com/mroth/weightedrand/v2 v2.1.0/go.mod h1:f2faGsfOGOwc1p94wzHKKZyTpcJUW7OJ/9U4yfiNAOU=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/schollz/progressbar/v3 v3.18.0 h1:uXdoHABRFmNIjUfte/Ex7WtuyVslrw2wVPQmCN62HpA=
github.com/schollz/progressbar/v3 v3.18.0/go.mod h1:IsO3lpbaGuzh8zIMzgY3+J8l4C8GjO0Y9S69eFvNsec=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU=
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.28.0 h1:/Ts8HFuMR2E6IP/jlo7QVLZHggjKQbhu/7H0LJFr3Gg=
golang.org/x/term v0.28.0/go.mod h1:Sw/lC2IAUZ92udQNf3WodGtn4k/XoLyZoh8v/8uiwek=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

BIN
jaggedpill.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

110
main.go
View File

@ -3,13 +3,11 @@ package main
import (
"fmt"
"github.com/mroth/weightedrand/v2"
"github.com/schollz/progressbar/v3"
"io"
"math/rand"
"net/http"
"os"
"path/filepath"
"slices"
"strings"
"text/template"
"time"
@ -69,7 +67,6 @@ func main() {
var fileFolder = "html_pages"
var wordTree PocketGraph = isShePervertedLikeMe()
var distances DelusionGraph = weAllHadDelusions(wordTree)
// youOughtaKnow returns an HTTP handler that processes requests.
func youOughtaKnow() http.Handler {
@ -345,7 +342,7 @@ func iDontWannaBeTheFiller() string {
paragraph := strings.Join(sentences, " ")
// Should paragraph contain link?
if rand.Float64() < 0.5 {
if rand.Float64() < 0.7 {
// Pick two or three words out of the paragraph
words := strings.Fields(paragraph)
if len(words) < 2 {
@ -384,7 +381,7 @@ func thanksForYourPatience() (string, error) {
return fmt.Sprintf("Error calculating size of file folder %s: %v\n", fileFolder, err), err
}
if size > 10*1024*1024 { // If the size of the folder is greater than 10 MB
if size > 10*1024*1024 { // If the size of the folder is greater than 100 MB
// If the file is older than the average file age, delete it
err = filepath.Walk(fileFolder, func(_ string, info os.FileInfo, err error) error {
if err != nil {
@ -427,11 +424,7 @@ func isShePervertedLikeMe() PocketGraph {
}
// read words.txt into a list
longmanBytes, err := os.ReadFile("word_lists/longman9000.txt")
jaggedLittlePillBytes, err := os.ReadFile("word_lists/jaggedlittlepill.txt")
wordsBytes := append(longmanBytes, jaggedLittlePillBytes...)
wordsBytes, err := os.ReadFile("word_lists/jaggedpill.txt")
if err != nil {
fmt.Println("Error reading words.txt:", err)
}
@ -440,7 +433,7 @@ func isShePervertedLikeMe() PocketGraph {
tree := make(PocketGraph)
for _, word := range ConnectionWords {
var percentageOfWords float64 = 0.02
var percentageOfWords float64 = 0.005
var numberOfConnections = float64(len(words)) * percentageOfWords
for j := 0; j < int(numberOfConnections); j++ {
randomWord := words[rand.Intn(len(words))]
@ -465,7 +458,7 @@ func isShePervertedLikeMe() PocketGraph {
// connect word to connector words?
shouldConnect := rand.Intn(2) == 0
if shouldConnect {
numConnectionWords := rand.Intn(2) + 1
numConnectionWords := rand.Intn(len(ConnectionWords)) + 1 // Random number of connection words between 1 and 3
for j := 0; j < numConnectionWords; j++ {
connectionWord := ConnectionWords[rand.Intn(len(ConnectionWords))]
tree[word] = append(tree[word], connectionWord)
@ -475,50 +468,6 @@ func isShePervertedLikeMe() PocketGraph {
return tree
}
type DelusionGraph map[string]map[string]int
func weAllHadDelusions(m PocketGraph) DelusionGraph {
distances := make(DelusionGraph)
bar := progressbar.Default(int64(len(m)*len(m)), "Calculating distances...")
// Initialize distances for each word
for word := range m {
distances[word] = make(map[string]int)
for otherWord := range m {
if word == otherWord {
distances[word][otherWord] = 0 // Distance to itself is 0
} else if slices.Contains(m[word], otherWord) {
distances[word][otherWord] = 1 // Direct connection
}
bar.Add(1)
}
}
for word, linkedWords := range m {
for _, linkedWord := range linkedWords {
if _, exists := distances[word][linkedWord]; !exists {
distances[word][linkedWord] = 1 // Direct connection
}
for otherWord, distance := range distances[linkedWord] {
if otherWord == word {
continue // Skip self-distance
}
if _, exists := distances[word][otherWord]; !exists {
distances[word][otherWord] = distance + 1 // Update distance
} else {
// If the distance is shorter, update it
if distance+1 < distances[word][otherWord] {
distances[word][otherWord] = distance + 1
}
}
}
}
}
return distances
}
// forgiveMeLove generates N random words from the tree
func (m PocketGraph) forgiveMeLove(n int) Words {
if n <= 0 {
@ -528,49 +477,18 @@ func (m PocketGraph) forgiveMeLove(n int) Words {
// Create a slice to hold the random words
randomWords := make(Words, 0, n)
// Pick 30% of N words out of the tree at random
numWords := int(float64(n) * 0.3)
for i := 0; i < numWords; i++ {
randomWord := iWentToYourHouse(m)
if randomWord == "" {
continue // Skip if the word is empty
}
randomWords = append(randomWords, randomWord)
}
// Connect the randomWords together using words that are linked to them, refering to distance
for i := 0; i < len(randomWords) && len(randomWords) <= n; i++ {
if len(randomWords) >= n {
// Generate N random words from the tree
word := m[iWentToYourHouse(m)] // Start with a random word from the tree
for i := 0; i < n-1; i++ {
if len(word) == 0 {
break
}
if len(randomWords[i]) == 0 {
continue // Skip empty words
}
// Get the linked words for the random word
wordDistances := distances[randomWords[i]]
if len(wordDistances) == 0 {
continue // Skip if there are no linked words
}
// do any of the random words link to each other?
for j := 0; j < len(randomWords); j++ {
if i == j || len(randomWords[j]) == 0 {
continue // Skip self or empty words
}
// Check if the random word links to the other random word
if distance, exists := wordDistances[randomWords[j]]; exists && distance > 0 {
// If they are linked, connect them by adding the other random word to the slice
if !slices.Contains(randomWords, randomWords[j]) {
randomWords = append(randomWords, randomWords[j])
}
}
for linkedWord, dist := range distances[randomWords[j]] {
if dist > 0 && !slices.Contains(randomWords, linkedWord) {
randomWords = append(randomWords, linkedWord)
}
}
}
random := rand.Intn(len(word))
nextWord := word[random] // Randomly select a word from the current word's linked words
randomWords = append(randomWords, nextWord)
word = m[nextWord] // Update the word to the next linked word
}
return randomWords
}

View File

@ -1,22 +1,24 @@
a
able
about
abvious
adored
advice
afraid
afternoon
again
ah
air
alarmed
alive
all
alleluia
All
Alleluia
along
already
alright
am
ammunition
amount
an
An
and
angry
any
@ -44,21 +46,17 @@ back
back-loaded
backwards
bandage
bath
be
bear
bearer
beat
beautiful
bed
been
before
believe
bell
bend
benefits
best
better
big
bills
biting
@ -81,8 +79,7 @@ broke
brothers
bruises
bug
burned
but
But
by
cab
calm
@ -93,14 +90,13 @@ carry
cars
case
catch
catholic
cause
Catholic
Cause
caution
cds
censor
certainly
chance
chardonnay
Chardonnay
chew
chicken
child
@ -110,18 +106,16 @@ choir
choke
choose
cigarette
ck
clears
cling
close
clothes
coaster
cologne
come
comes
comfort
coming
common
compared
Compared
concept
confessed
conflicts
@ -142,7 +136,6 @@ cry
crying
damn
dance
danced
darkest
day
deadlines
@ -152,10 +145,8 @@ deeds
deeper
deliverance
delusions
den
deny
desk
did
Did
didn't
die
died
@ -166,33 +157,31 @@ direction
dissect
distraction
disturb
do
doctor
does
Do
Doctor
Does
doesn't
doing
don't
door
down
drawer
drawers
dream
dreams
drift
drunk
dry
duplicity
Duplicity
dust
easier
easy
egg
eloquently
else
else's
empty
enough
Enough
envious
estella
Estella
eventually
ever
every
@ -201,21 +190,19 @@ everything's
ex
excellent
excuse
eyes
face
fade
fair
fall
falling
farther
fascinated
fast
father
Father
fault
feel
feelings
feels
feet
Feet
fell
felt
few
@ -239,10 +226,8 @@ food
foot
for
forget
forgive
forgiven
Forgiven
forgot
found
fountain
fractured
free
@ -255,7 +240,6 @@ friends
frightened
from
frustrated
fuck
full
fun
fundamental
@ -290,8 +274,7 @@ gunshot
had
hailing
half
hall
hand
Hand
handle
hands
happy
@ -301,22 +284,21 @@ has
hate
have
haven't
he
He
head
heading
heads
healthy
hear
heart
heights
held
hello
Hello
help
helping
her
here
hey
hidden
Here
Hey
Hidden
high
him
his
@ -324,12 +306,9 @@ hold
holds
hole
holes
home
honest
hope
hopeful
hours
house
how
humble
humbled
@ -338,37 +317,33 @@ hunt
hunter
hurry
hurt
i
i'd
i'll
i'm
i've
I
I'd
I'll
I'm
I've
idol
if
impatient
in
incense
information
inhaling
innocent
inquisition
inside
insist
insistence
insistance
intellectual
intercourse
into
ironic
Ironic
is
isn't
it
it's
its
It's
jagged
jam
jane
Jane
joke
joni
jump
jumping
just
@ -382,8 +357,7 @@ kindred
kissed
knife
knock
know
laid
Know
land
last
late
@ -393,9 +367,8 @@ learn
learned
least
left
lend
Lend
let's
letter
life
light
like
@ -421,7 +394,8 @@ maker
malt
man
many
mary
Mary
mate
matter
matters
may
@ -432,20 +406,19 @@ mean
measure
meet
meeting
melt
Melt
merely
mess
met
middle
midnight
might
mind
Mind
minds
mine
minute
minutes
mispronounced
miss
Miss
moment
money
months
@ -453,11 +426,10 @@ more
mother
motto
mouth
mr
Mr
much
must
my
nails
My
naked
name
nature
@ -471,13 +443,12 @@ ninety-eight
no
not
nothing
noticed
now
obvious
occasion
of
off
oh
Oh
okay
old
older
@ -486,13 +457,13 @@ one
one's
only
open
opened
or
Or
other
oughta
Oughta
our
out
over
outta
Over
overwhelmed
own
packed
@ -506,8 +477,7 @@ patience
peace
peaceful
pedestal
perfect
permission
Perfect
perverted
petrified
piano
@ -517,11 +487,11 @@ pill
pity
place
plane
play-it-safe
Play
played
playing
please
pocket
Please
Pocket
point
poor
pray
@ -533,18 +503,16 @@ problem
proud
prouder
puppet
push
put
Push
question
quickly
quiet
quite
rain
raising
ran
Raising
rational
rays
really
Really
reasons
receive
recommend
@ -558,24 +526,20 @@ resistance
responsible
restless
ride
right
ringing
robe
Right
roller
room
rose
row
ruler
sad
Safe
said
salt
sane
sang
sat
saviors
say
scan
scratch
scream
screw
see
@ -592,9 +556,7 @@ shells
shit
short
should
shouldn't
show
shower
sick
sign
silence
@ -603,10 +565,8 @@ single
sinners
sir
sit
six
skeptic
slap
smell
Skeptic
Slap
smile
smoke
smoking
@ -619,14 +579,12 @@ solely
solitary
some
someday
someone
Someone
something
sometimes
son
soon
Sometimes
Son
sorry
soul
soulmate
sound
speak
speed
@ -635,9 +593,7 @@ spit
spite
splintered
spoons
stairs
stated
stay
sticking
still
stomach
@ -648,10 +604,10 @@ stupid
substitute
suffer
suitcase
sunday
Sunday
sure
surprised
swallow
Swallow
swallowed
sweater
sweeper
@ -667,29 +623,29 @@ tell
ten
than
thank
thanks
Thanks
that
that's
That's
the
theatre
then
there
there's
There's
they
thick
thing
Thing
things
think
thinking
thinkin'
this
thought
thousand
three-year-old
thrill
through
throw
Throw
ticket
til
Til
time
times
tired
@ -706,7 +662,7 @@ trampled
treat
trembling
trucks
try
Try
trying
turned
two
@ -723,17 +679,15 @@ value
version
very
vicarious
visiting
Visiting
voice
void
wait
Wait
waited
wake
Wake
walk
walked
walking
wanna
want
Want
wanted
warm
was
@ -742,7 +696,7 @@ wavelength
way
ways
we
we'll
We'll
wear
wedding
week
@ -750,9 +704,8 @@ weight
well
went
what
what's
What's
when
where
while
whiskey
who
@ -768,28 +721,25 @@ wine
wise
wish
with
without
womb
won
wonder
woo
word
working
worry
Worry
would
would've
wouldn't
wound
wounded
writing
wrong
yeah
yet
you
you'd
You'd
you'll
you're
you've
You've
young
your
yours