mirror of
https://github.com/idanoo/GoCatFacts
synced 2025-07-01 14:52:15 +00:00
Working proof of concept
This commit is contained in:
parent
c51b6236f0
commit
d39591b3c0
3 changed files with 309 additions and 4 deletions
|
@ -1,7 +1,10 @@
|
|||
# GoCatFacts
|
||||
|
||||
Beautiful program. HTTP server. You hit? You get fact. Boom. Default port 80.
|
||||
Quick and dirty proof of concept.
|
||||
|
||||
```shell
|
||||
go run main.go
|
||||
```
|
||||
|
||||
Initial fact list copied from https://github.com/0x27/catfacts/blob/master/catfacts.txt
|
||||
|
|
256
facts.txt
Normal file
256
facts.txt
Normal file
|
@ -0,0 +1,256 @@
|
|||
The penalty for killing a cat, 4,000 years ago in Egypt, was death.
|
||||
95% of all cat owners admit they talk to their cats.
|
||||
More cats are left-pawed than right-pawed. Out of 100 cats approximately 40 are left-pawed, 20 are right-pawed, and 40 are ambidextrous.
|
||||
A cat can jump as much as seven times its height.
|
||||
A cat cannot see directly under its nose. This is why the cat cannot seem to find tidbits on the floor.
|
||||
A cat has 230 bones in its body. A human only has 206 bones.
|
||||
A cat has four rows of whiskers.
|
||||
A frightened cat can run at speeds of up to 31 mph (50 km/h), slightly faster than a human sprinter.
|
||||
A cat sees about six times better than a human at night because of the tapetum lucidum, a layer of extra reflecting cells which absorb light.
|
||||
A cat's whiskers, called vibrissae, grow on the cat's face and on the back of its forelegs.
|
||||
Cat whiskers act as feelers or antennae, helping the animal to judge the precise width of any passage.
|
||||
A cat will almost never meow at another cat. Cats use this sound for humans.
|
||||
A cat will clean itself with paw and tongue after a dangerous experience or when it has fought with another cat.
|
||||
A cat will spend nearly 30% of its life grooming itself.
|
||||
A cat's brain is more similar to a human's brain than that of a dog.
|
||||
Cats have 32 muscles that control the outer ear (compared to human's 6 muscles each). A cat can rotate its ears independently 180 degrees.
|
||||
Cats can hear sounds as high-pitched as 65 kHz; a human's hearing stops at just 20 kHz.
|
||||
A cat's normal pulse is 140-240 beats per minute, with an average of 195.
|
||||
A cat's jaws cannot move sideways.
|
||||
A cat's normal body temperature is 101.5 degrees F (38.6 C).
|
||||
A cat's sense of taste is keener than a dog's sense of taste.
|
||||
A cat's tail held high means happiness. A twitching tail is a warning sign, and a tail tucked in close to the body is a sure sign of insecurity.
|
||||
A cat's tail plays a vital part in the cat's balance and in the "righting reflex" that allows it to land on its feet after falling from a height.
|
||||
A cat's tongue is scratchy because it's lined with papillae-tiny elevated backwards hooks that help to hold prey in place.
|
||||
A female cat can begin mating when she is between 5 and 9 months old.
|
||||
A male cat can begin mating when he is between 7 and 10 months old.
|
||||
A group of kittens is called a kindle; a group of adult cats form a clowder.
|
||||
A large majority of white cats with blue eyes are deaf. White cats with only one blue eye are deaf only in the ear closest to the blue eye.
|
||||
Adult cats with no health problems are in deep sleep 15 percent of their lives. They are in light sleep 50 percent of the time.
|
||||
Cats are only awake 6-8 hours a day.
|
||||
After being handled, cats lick themselves to smooth their fur and get rid of the "human" smell.
|
||||
Cats have 30 teeth (12 incisors, 10 premolars, 4 canines, and 4 molars).
|
||||
Kittens have baby teeth, which are replaced by permanent teeth around the age of 7 months.
|
||||
Both humans and cats have identical regions in the brain responsible for emotion.
|
||||
Multi-colored male cats are very rare. For every 3,000 tortoiseshell or calico cats born, only one will be male.
|
||||
Cat families usually play best in even numbers. Cats and kittens should be acquired in pairs whenever possible.
|
||||
Cat urine glows under a black light.
|
||||
Cats are attracted to automobile antifreeze because of its sweet taste.
|
||||
Cats are sometimes born with extra toes. This is called polydactyl.
|
||||
The cat's front paw has 5 toes, but the back paws have 4.
|
||||
Cats are the only domestic animals that walk directly on their claws, not on their paws.
|
||||
Cats bury their feces to cover their trails from predators.
|
||||
Cats have AB blood groups just like people.
|
||||
Cats can get bored. They show their boredom by excessive licking, chewing, or biting.
|
||||
Cats can have freckles. They can appear anywhere on a cat's skin and even in its mouth.
|
||||
Cats can learn tricks. They just sometimes choose not to.
|
||||
Cats can see color. Studies have shown that cats can distinguish between red, green, blue, yellow, and gray.
|
||||
Cats can see up to 120 feet away. Their peripheral vision is about 285 degrees.
|
||||
Cats have 13 ribs.
|
||||
Like birds, cats have a homing ability that uses it's biological clock, the angle of the sun, and the Earth's magnetic field.
|
||||
Cats have a third eyelid, called a haw, that is rarely visible. If it can be seen, it could be an indication of ill health.
|
||||
Cats have about 100 different vocalization sounds. In comparison, dogs have about 10.
|
||||
Cats have better memories than dogs.
|
||||
Cats have carpal pads on their front paws that help to prevent them from sliding on a slippery surface when jumping.
|
||||
Cats have true fur, meaning that they have both an undercoat and an outer coat.
|
||||
Cats lack a true collarbone and can generally squeeze their bodies through any space they can get their heads through.
|
||||
Cats love to hear the sound of their own name and your voice, so talk to them often.
|
||||
Cats must have fat in their diet, because they can't produce it on their own.
|
||||
Cats only need a sixth the amount of light that humans do to see. However, their daytime vision is only fair compared to that of humans.
|
||||
Cats purr at about 26 cycles per second, the same frequency as an idling diesel engine.
|
||||
Cats scratch to shed the sheaths of their old claws.
|
||||
Cat have 500 skeletal muscles (humans have 650).
|
||||
Cats with white fur and skin on their ears are very prone to sunburn.
|
||||
Cats, not dogs, are the most common pets in America . There are approximately 66 million cats to 58 million dogs.
|
||||
The average cat consumes about 127,750 calories a year, nearly 28 times its own weight in food and the same amount again in liquids.
|
||||
Each day in the US, animal shelters are forced to destroy 30,000 dogs and cats.
|
||||
Ear furnishings are the hairs that grow inside a cat's ears.
|
||||
Human painkillers such acetaminophen (Tylenol) are toxic to cats. Chocolate is also poisonous to cats.
|
||||
A female cat may have three to seven kittens every four months. This is why population control using spaying and neutering is so important.
|
||||
If your cat is in the habit of rolling over and exposing his stomach, you can be sure he feels perfectly safe with you.
|
||||
In addition to using their noses, cats can smell with the Jacobson's organ which is located in the upper surface of the mouth.
|
||||
In ancient Egypt, the entire family would shave their eyebrows off as a sign of mourning when the family cat died.
|
||||
In general, cats live longer than most dogs. An average life span might be 12 to 14 years. Some cats are reaching 20 or more.
|
||||
In relation to their body size, cats have the largest eyes of any mammal.
|
||||
Stroking a cat can help to relieve stress, and the feel of a purring cat on your lap conveys a strong sense of security and comfort.
|
||||
Owning a cat can increase your overall health and decrease the occurrence of high blood pressure and other illnesses.
|
||||
Many cats are unable to properly digest cow's milk. Milk and milk products give them diarrhea.
|
||||
Almost 10% of a cat's bones are in its tail.
|
||||
More than 30 percent of American households have a cat as part of the family.
|
||||
Neutering a cat extends its life span by two or three years.
|
||||
Never pick a kitten up by the neck. Only a mother cat may do this safely.
|
||||
Newborn kittens have closed ear canals that don't begin to open for nine days.
|
||||
One litter box per cat, plus an extra box, is the best formula for a multi-cat household.
|
||||
Mother cats teach their kittens to use the litter box.
|
||||
The ancestor of all domestic cats is the African Wild Cat, which still exists today.
|
||||
The average canned or dry cat meal is the nutritional equivalent of eating five mice.
|
||||
The cat family split from the other mammals at least 40 million years ago, making them one of the oldest mammalian families.
|
||||
The cat lover is an ailurophile, while a cat hater is an ailurophobe.
|
||||
The cat was domesticated over 4,000 years ago. Today's house cats are descended from wildcats in Africa and Europe .
|
||||
The catgut formerly used as strings in tennis rackets and musical instruments does not come from cats.
|
||||
The color of the points in Siamese cats is heat related. Cool areas are darker.
|
||||
Siamese kittens are born white because of the heat inside the mother's uterus before birth.
|
||||
The declawing of a pet cat involves surgery called an onychectomy, which is the equivalent of cutting a human's fingers off at the knuckle.
|
||||
The different types of tabby patterns that are seen in domestic cats also occur in wild cats.
|
||||
The giraffe, camel, and cat are the only animals that walk by both their left feet, then both their right feet when walking.
|
||||
The heaviest cat ever recorded weighed 46 lbs.
|
||||
The only domestic animal not mentioned in the Bible is the cat.
|
||||
The ancient Egyptians were the first civilisation to realise the cat's potential as a vermin hunter and tamed cats to protect the corn supplies.
|
||||
Sir Isaac Newton is not only credited with the laws of gravity but is also credited with inventing the cat flap.
|
||||
Cats can't taste sweets.
|
||||
Americans spend more annually on cat food than on baby food.
|
||||
In 1987 cats overtook dogs as the number one pet in America.
|
||||
In Asia and England, black cats are considered lucky.
|
||||
When a domestic cat goes after mice, about one pounce in three results in a catch.
|
||||
Studies show that if a cat falls off the seventh floor of a building it is 30% less likely to survive than a cat that falls off the twentieth floor.
|
||||
Most cats have no eyelashes.
|
||||
The way you treat kittens in the early stages of it's life will render it's personality traits later in life.
|
||||
A form of AIDS exists in cats.
|
||||
People who are allergic to cats are actually allergic to cat saliva or to cat dander.
|
||||
In ancient Egypt, mummies were made of cats, and embalmed mice were placed with them in their tombs.
|
||||
In the Middle Ages, during the Festival of Saint John, cats were burned alive in town squares.
|
||||
Today there are about 100 distinct breeds of the domestic cat.
|
||||
When cats are asleep, they are still alert to incoming stimuli. If you poke the tail of a sleeping cat, it will respond accordingly.
|
||||
The chlorine in fresh tap water irritates sensitive parts of the cat's nose. Let tap water sit for 24 hours before giving it to a cat.
|
||||
Cats purr to communicate. Purring does not always mean happiness.
|
||||
A cat is pregnant for about 58-65 days.
|
||||
A cat's hearing is much more sensitive than humans and dogs.
|
||||
Cats sleep 16 to 18 hours per day.
|
||||
A kittens eyes are always blue at first.
|
||||
If a male cat is both orange and black it is most likely sterile.
|
||||
There are tiny, parasitic worms that can live in a cat's stomach. These worms cause frequent vomiting.
|
||||
Cats have 30 vertebrae - 5 more than humans have.
|
||||
A cat's field of vision is about 185 degrees.
|
||||
A cat has a total of 24 whiskers, 4 rows of whiskers on each side. The upper two rows can move independently of the bottom two rows.
|
||||
A kitten will typically weigh about 3 ounces at birth. The typical male housecat will weigh between 7-9 pounds, slightly less for female housecats.
|
||||
Cats take between 20-40 breaths per minute.
|
||||
Cats lose almost as much fluid in the saliva while grooming themselves as they do through urination.
|
||||
The domestic cat is the only species able to hold its tail vertically while walking.
|
||||
Female felines are "superfecund," which means that each of the kittens in her litter can have a different father.
|
||||
Cat saliva contains a detergent that keeps their fur clean.
|
||||
Cats eyes don't glow in the dark; they only reflect light.
|
||||
Cats born without tails genetically have a shorter spine and longer rear legs than other cats.
|
||||
Cats eat grass to keep their digestive systems clean. The regurgitation brings up hair and other irritants.
|
||||
Cats are able to hear sounds that move faster than 45,000 hertz. They could hear the sound of a bat.
|
||||
There are approximately 60,000 hairs per square inch on the back of a cat and about 120,000 per square inch on its underside.
|
||||
The largest cat breed is the Ragdoll. Males weigh 12-20 pounds, with females weighing 10-15 pounds.
|
||||
The smallest cat breed is the Singapura. Males weigh about 6 pounds while females weigh about 4 pounds.
|
||||
Cats don't see "detail" very well. To them, their person may appear hazy when standing in front of them.
|
||||
Kittens begin dreaming at just over one week old.
|
||||
If an overweight cat's "sides" stick out further than her whiskers, she will lose her sense of perception and stability.
|
||||
Every cat's nose pad is unique, and no two nose prints are the same.
|
||||
About 37% of American homes today have at least 1 cat.
|
||||
The catnip plant contains an oil called hepetalactone which does for cats what marijuana does to some people. Catnip is non-addictive.
|
||||
Not every cat gets "high" from catnip. If the cat doesn't have a specific gene, it won't react (about 20% do not have the gene).
|
||||
When well treated, a cat can live twenty or more years.
|
||||
Cats are subject to gum disease and to dental caries. They should have their teeth cleaned by the vet or the cat dentist once a year.
|
||||
Cats can get tapeworms from eating mice. If your cat catches a mouse it is best to take the prize away from it.
|
||||
If a cat is frightened, the hair stands up fairly evenly all over the body.
|
||||
Cats respond most readily to names that end in an "ee" sound.
|
||||
A female cat reaches sexual maturity within 6 to 10 months.
|
||||
A male cat usually reaches sexual maturity between 9 and 12 months.
|
||||
A cat will tremble or shiver when it is in extreme pain.
|
||||
The average lifespan of an outdoor-only (feral and non-feral) is about 3 years; an indoor-only cat can live 16 years and longer.
|
||||
Cats with long, lean bodies are more likely to be outgoing, and more protective and vocal than those with a stocky build.
|
||||
A steady diet of dog food may cause blindness in your cat - it lacks taurine.
|
||||
An estimated 50% of today's cat owners never take their cats to a veterinarian for health care.
|
||||
Most cats adore sardines.
|
||||
Cats respond better to women than to men, probably due to the fact that women's voices have a higher pitch.
|
||||
When your cats rubs up against you, she is marking you as "hers" with her scent.
|
||||
Cat bites are more likely to become infected than dog bites - but human bites are the most dangerous of all.
|
||||
Don't be alarmed when your cats bring you gifts of birds, mice or other wild critters. This is a gift, and they do it to please you.
|
||||
A smooth, shiny coat is the sign of a healthy cat.
|
||||
A healthy kitten has clear, bright eyes and clean ears.
|
||||
If your cat hides and then runs out and pounces on you, she is acting out her instinctive hunting ritual.
|
||||
Cats lick people as a sign of affection.
|
||||
Most lively, active kittens grow up to be friendly, outgoing cats.
|
||||
A healthy cat's nose is cool.
|
||||
When a cat swishes its tail back and forth, she's concentrating on somthing; if her tail starts moving faster, she has become annoyed.
|
||||
Brushing your cat daily will cut down on hairballs.
|
||||
If you do not respond when your cat talks to you, it will soon lose the urge to communicate with you.
|
||||
Some cats, males in particular, develop health problems if fed dry food exclusively.
|
||||
A little vegetable oil daily will help to prevent fur-balls and bring a shine to your cat's coat.
|
||||
In multi-cat households, cats of the opposite sex usually get along better.
|
||||
25% of cat owners blow dry their cats hair after a bath.
|
||||
If your cat is near you, and her tail is quivering, this is the greatest expression of love your cat can give you.
|
||||
"Sociable" cats will follow you from room to room to monitor your activities throughout the day.
|
||||
The more cats are spoken to, the more they will speak to you.
|
||||
Most cats prefer their food at room temperature.
|
||||
A cat that bites you after you have rubbed his stomach, is probably biting out of pleasure, not anger.
|
||||
It costs $7000 to care for one household cat over its lifetime. This covers only the necessities; the pampered pet will carry a higher price.
|
||||
Cats lived with soldiers in trenches, where they killed mice during World War I.
|
||||
Napoleon was terrified of cats.
|
||||
Abraham Lincoln loved cats. He had four of them while he lived in the White House.
|
||||
The cat family split from the other mammals at least 40,000,000 years ago, making them one of the oldest mammalian families.
|
||||
Phoenician cargo ships are thought to have brought the first domesticated cats to Europe in about 900 BC.
|
||||
Cats have been domesticated for half as long as dogs have been.
|
||||
The Pilgrims were the first to introduce cats to North America.
|
||||
The first breeding pair of Siamese cats arrived in England in 1884.
|
||||
The first formal cat show was held in England in 1871; in America, in 1895.
|
||||
The Maine Coon cat is America's only natural breed of domestic feline.
|
||||
The life expectancy of cats has nearly doubled since 1930 - from 8 to 16 years.
|
||||
Cat litter was "invented" in 1947 when Edward Lowe asked his neighbor to try a dried, granulated clay used to sop up grease spills in factories.
|
||||
Genetic mutation created the domestic cat which is tame from birth.
|
||||
Cats can be taught to use a toilet, come, sit, beg, heel, jump through a hoop, play dead, roll over, open a door, shake, fetch and more.
|
||||
A cat will not eat its food if is unable to smell it.
|
||||
34% of cat-owning households have incomes of $60,000 or more.
|
||||
32% of those who own their own home, also own at least one cat.
|
||||
If your cat rolls over on his back to expose his belly, it means he trusts you.
|
||||
Contrary to popular belief, the cat is a social animal. A pet cat will respond and answer to speech, and seems to enjoy human companionship.
|
||||
Some cats will actually knead and drool when they are petted. The kneading or marching means that the cat is happy.
|
||||
Unlike humans and dogs, cats do not suffer a lot from loneliness. They are far more concerned with territorial issues.
|
||||
Hunting is not instinctive for cats. Kittens born to non-hunting mothers may never learn to hunt.
|
||||
Cats are attracted to the cave-like appeal of a clothes dryer.
|
||||
A cat will kill it's prey based on movement, but may not necessarily recognize prey as food. Realizing that prey is food is a learned behavior.
|
||||
Most deaf cats do not meow.
|
||||
In England, the government owns thousands of cats. Their job is to help keep the buildings free of rodents.
|
||||
The word cat refers to a family of meat-eating animals that include tigers, lions, leopards, and panthers.
|
||||
You can tell a cat's mood by looking into its eyes. A frightened or excited cat will have large, round pupils.
|
||||
The cat's footpads absorb the shocks of the landing when the cat jumps.
|
||||
Cats don't kill their prey with their claws, the claws are used to hold onto the prey, the teeth are used to kill the prey.
|
||||
The claws on the cat's back feet aren't as sharp as the claws on the front feet because they can't retract into the toe.
|
||||
Cats perspire through their paws.
|
||||
Cats, especially older cats, do get cancer. Many times this disease can be treated successfully.
|
||||
Some common houseplants are poisonous to cats, such as: English Ivy, iris, mistletoe, philodendron, and yew.
|
||||
Though rare, cats can contract canine heart worms.
|
||||
Cats think that humans are big cats. This influences their behavior in many ways.
|
||||
Cats can be taught to walk on a leash, but a lot of time and patience is required to teach them.
|
||||
A happy cat holds her tail high and steady.
|
||||
Cats have individual preferences for scratching surfaces and angles. Some are horizontal scratchers while others exercise their claws vertically.
|
||||
All cats have three sets of long hairs that are sensitive to pressure - whiskers, eyebrows,and the hairs between their paw pads.
|
||||
When a cat drinks, its tongue - which has tiny barbs on it - scoops the liquid up backwards.
|
||||
Florence Nightingale owned more than 60 cats in her lifetime.
|
||||
If your cat pushes his face against your head, it is a sign of acceptance and affection.
|
||||
Tomcats can mate at anytime, while quenns can only mate during a period of time called heat or estrus.
|
||||
At 4 weeks, it is important to play with kittens so that they do not develope a fear of people.
|
||||
Kittens remain with their mother till the age of 9 weeks.
|
||||
It is estimated that cats can make over 60 different sounds.
|
||||
Cats often overract to unexpected stimuli because of their extremely sensitive nervous system.
|
||||
Kittens who are taken along on short, trouble-free car trips to town tend to make good passengers when they get older.
|
||||
Cats, just like people, are subject to asthma.
|
||||
Did you know murf sometimes pretends he is a cat and walks around on all-fours?
|
||||
Since cats are so good at hiding illness, even a single instance of a symptom should be taken very seriously.
|
||||
There is a species of cat smaller than the average housecat. Its top weight is 5.5 pounds.
|
||||
A tortoiseshell is black with red or orange markings and a calico is white with patches of red, orange and black.
|
||||
The Ancient Egyptian word for cat was mau, which means "to see".
|
||||
Cats that live together sometimes rub each others heads to show that they have no intention of fighting.
|
||||
Australia and Antarctica are the only continents which have no native cat species.
|
||||
A falling cat will always right itself in a precise order.
|
||||
It is believed that a white cat sitting on your doorstep just before your wedding is a sign of lasting happiness.
|
||||
Cats are more active during the evening hours.
|
||||
According to myth, a cat sleeping with all four paws tucked under means cold weather is coming.
|
||||
The average litter of kittens is between 2 - 6 kittens.
|
||||
All cats need taurine in their diet to avoid blindness. Cats must also have fat in their diet as they are unable to produce it on their own.
|
||||
Unlike humans, cats do not need to blink their eyes on a regular basis to keep their eyes lubricated.
|
||||
It may take as long as 2 weeks for a kitten to be able to hear well.
|
||||
Cats can judge within 3 inches the precise location of a sound being made 1 yard away.
|
||||
A cat has approximately 60 to 80 million olfactory cells (a human has between 5 and 20 million).
|
||||
Cats dislike citrus scent.
|
||||
Cats lap liquid from the underside of their tongue, not from the top.
|
||||
Domestic cats purr both when inhaling and when exhaling.
|
||||
The ancient Egyptians were the first to tame the cat (in about 3000 BC), and used them to control pests.
|
||||
In Siam, the cat was so revered that one rode in a chariot at the head of a parade celebrating the new king.
|
||||
Female cats are "polyestrous," which means they may have many heat periods over the course of a year.
|
||||
Many cats love having their forehead gently stroked.
|
||||
Cats come back to full alertness from the sleep state faster than any other creature.
|
||||
In an average year, cat owners in the United States spend over $2 billion on cat food.
|
52
main.go
52
main.go
|
@ -1,9 +1,17 @@
|
|||
package gocatfacts
|
||||
package main
|
||||
|
||||
import "os"
|
||||
import (
|
||||
"bufio"
|
||||
"io"
|
||||
"log"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
"os"
|
||||
)
|
||||
|
||||
var (
|
||||
port = "8080"
|
||||
port = "8080"
|
||||
facts = []string{}
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
@ -13,4 +21,42 @@ func main() {
|
|||
port = portOverride
|
||||
}
|
||||
|
||||
// Load it up
|
||||
err := loadFacts()
|
||||
if err != nil {
|
||||
log.Fatalf("Error loading facts: %v", err)
|
||||
}
|
||||
|
||||
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||
io.WriteString(w, getRandomFact())
|
||||
})
|
||||
err = http.ListenAndServe(":"+port, nil)
|
||||
if err != nil {
|
||||
log.Fatalf("Error loading facts: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// loadFacts loads cat facts from a file named "facts.txt"
|
||||
func loadFacts() error {
|
||||
file, err := os.Open("facts.txt")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
scanner := bufio.NewScanner(file)
|
||||
for scanner.Scan() {
|
||||
facts = append(facts, scanner.Text())
|
||||
}
|
||||
|
||||
return scanner.Err()
|
||||
}
|
||||
|
||||
// getRandomFact returns a random cat fact from the loaded facts
|
||||
func getRandomFact() string {
|
||||
if len(facts) == 0 {
|
||||
return "No facts available."
|
||||
}
|
||||
|
||||
return facts[rand.Intn(len(facts))]
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue