Skip to content

Instantly share code, notes, and snippets.

@DanH42
Last active August 29, 2015 14:17
Show Gist options
  • Save DanH42/59afcb9ac3b75e3cbe14 to your computer and use it in GitHub Desktop.
Save DanH42/59afcb9ac3b75e3cbe14 to your computer and use it in GitHub Desktop.
Markov Science!
<?php
/*
PHP Markov Chain text generator 1.0
Copyright (c) 2008-2010, Hay Kranen <http://www.haykranen.nl/projects/markov/>
Fork on Github: < http://github.com/hay/markov >
License (MIT / X11 license)
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
*/
function generate_markov_table($text, $look_forward) {
$table = array();
// now walk through the text and make the index table
for ($i = 0; $i < strlen($text); $i++) {
$char = substr($text, $i, $look_forward);
if (!isset($table[$char])) $table[$char] = array();
}
// walk the array again and count the numbers
for ($i = 0; $i < (strlen($text) - $look_forward); $i++) {
$char_index = substr($text, $i, $look_forward);
$char_count = substr($text, $i+$look_forward, $look_forward);
if (isset($table[$char_index][$char_count])) {
$table[$char_index][$char_count]++;
} else {
$table[$char_index][$char_count] = 1;
}
}
return $table;
}
function generate_markov_text($length, $table, $look_forward) {
// get first character
$char = array_rand($table);
$o = $char;
for ($i = 0; $i < ($length / $look_forward); $i++) {
$newchar = return_weighted_char($table[$char]);
if ($newchar) {
$char = $newchar;
$o .= $newchar;
} else {
$char = array_rand($table);
}
}
return $o;
}
function return_weighted_char($array) {
if (!$array) return false;
$total = array_sum($array);
$rand = mt_rand(1, $total);
foreach ($array as $item => $weight) {
if ($rand <= $weight) return $item;
$rand -= $weight;
}
}
?>
<?php
require 'markov.php';
$order = 4;
$length = 250;
$text = file_get_contents("science.txt");
$markov_table = generate_markov_table($text, $order);
$markov = generate_markov_text($length, $markov_table, $order);
$lines = explode("\n", $markov);
$line = $lines[1];
if(strlen($line) > 100){
$line = substr($line, 0, 100);
$words = explode(" ", $line);
array_pop($words);
$line = implode(" ", $words);
}
?>
<html>
<head>
<title> TOTALLY LEGITIMATE SCIENCE </title>
</head>
<body background="http://totally-legitimate.science/img/bg.jpg">
<h1 style="color:white;font-size:150px;text-align:center;height:150px;line-height:200px;font-family:Helvetica Neue,Helvetica,Arial,sans-serif"><i>
<?= $line ?>
</i></h1>
</body>
</html>
There are 206 bones in the adult human body and there are 300 in children as they grow some of the bones fuse together
Fleas can jump 130 times higher than their own height
The most dangerous animal in the world is the common housefly
Because of their habits of visiting animal waste, they transmit more diseases than any other animal
Snakes are true carnivorous because they eat nothing but other animals
They do not eat any type of plant material
The world's largest amphibian is the giant salamander
It can grow up to 5 feet in length
The smallest bone in the human body is the stapes or stirrup bone located in the middle ear. It is approximately .11 inches long
The longest cells in the human body are the motor neurons
They can be up to 4.5 feet long and run from the lower spinal cord to the big toe
There are no poisonous snakes in Maine
The blue whale can produce sounds up to 188 decibels
This is the loudest sound produced by a living animal and has been detected as far away as 530 miles
The largest man made lake in the US is Lake Mead, created by Hoover Dam
The poison arrow frogs of South and Central America are the most poisonous animals in the world
A new born blue whale measures 20 to 26 feet long and weighs up to 6,614 pounds
The first coast to coast telephone line was established in 1914
The Virginia opossum has a gestation period of only 12 days
The Stegosaurus dinosaur measured up to 30 feet long but had a brain the size of a walnut
The largest meteorite crater in the world is in Winslow, Arizona
It is 4,150 feet across and 150 feet deep
The human eye blinks an average of 4,200,000 times a year
Skylab, the first American space station, fell to the earth in thousands of pieces in 1979
It takes approximately 12 hours for food to entirely digest
Human jaw muscles can generate a force of 200 pounds on the molars
The Skylab astronauts grew 2 inches due to spinal lengthening and straightening as a result of zero gravity
An inch of rain water is equivalent to 15 inches of dry, powdery snow
Tremendous erosion at the base of Niagara Falls undermines the shale cliffs and as a result the falls have receded approximately 7 miles over the last 10,000 years
40 to 50 percent of body heat can be lost through the head as a result of its extensive circulatory network
A large swarm of desert locusts can consume 20,000 tons of vegetation a day
The largest telescope in the world is currently being constructed in northern Chile
The telescope will utilize 4 mirrors which will gather as much light as a single 52 foot mirror
The Hubble Space Telescope weighs 12 tons and cost $2.1 billion to originally build
The longest living cells in the body are brain cells which can live an entire lifetime
The largest flying animal was the pterosaur which lived 70 million years ago
This reptile had a wing span of 37 feet and weighed 200 pounds
The Atlantic Giant Squid's eye can be as large as 16 inches wide
Armadillos, opossums, and sloth's spend about 80% of their lives sleeping
The starfish species, Porcellanaster ivanovi, has been found to live in water as deep as 24,881 feet
The tentacles of the giant Arctic jellyfish can reach 120 feet in length
The greatest tide change on earth occurs in the Bay of Fundy
The difference between low tide and high tide can be as great as 55 feet
The highest temperature produced in a laboratory was 920,000,000 F at the Tokamak Fusion Test Reactor in Princeton, New Jersey
The most powerful laser in the world, the Nova laser at Lawrence Livermore National Laboratory, CA, USA, generates a pulse of energy equal to 100,000,000,000,000 watts of power for .000000001 second to a target the size of a grain of sand
The fastest computer in the world is the CRAY Y-MP C90 supercomputer
It has two gigabytes of central memory and 16 parallel central processor units
The heaviest human brain ever recorded weighed 5 pounds
The deepest part of the ocean is 35,813 feet deep and occurs in the Mariana Trench in the Pacific Ocean
At that depth the pressure is 18,000 pounds per square inch
The largest cave in the world, the Sarawak Chamber in Malaysia, is 2,300 feet long, 980 feet wide, and more than 230 feet high
The hottest planet in the solar system is Venus, with an estimated surface temperature of 864 degrees
The ears of a cricket are located on the front legs, just below the knee
The first electronic digital computer was developed in 1946 and contained over 18,000 vacuum tubes
The leg muscles of a locust are about 1000 times more powerful than an equal weight of human muscle
The cosmos contains approximately 50,000,000,000 galaxies
There are between 100,000,000,000 and 1,000,000,000,000 stars in a normal galaxy
Sound travels about 4 times faster in water than in air
Scientists have discovered that copper pollution of the atmosphere occurred about 2500 years ago
The pollution was attributed to the Romans who used copper for military purposes and to produce coins
Hydrofluoric acid will dissolve glass
In a full grown rye plant, the total length of roots may reach 380 miles
In a full grown rye plant, the total length of fine root hairs may reach 6600 miles
A large sunspot can last for about a week
If you could throw a snowball fast enough, it would totally vaporize when it hit a brick wall
Boron nitride is the second hardest substance known to man
The female Tarantula Hawk wasp paralyzes a large spider with her sting
She then lays her eggs on the motionless body so that her developing young have a fresh supply of spider meat to feed on
The seeds of an Indian Lotus tree remain viable for 300 to 400 years
The only letter not appearing on the Periodic Table is the letter "J"
Velcro was invented by a Swiss guy who was inspired by the way burrs attached to clothing
October 10 is National Metric Day
If you stretch a standard Slinky out flat it measures 87 feet long
The microwave was invented after a researcher walked by a radar tube and a chocolate bar melted in his pocket
Super Glue was invented by accident
No matter its size or thickness, no piece of paper can be folded in half more than 7 times
A car uses half its fuel to overcome wind resistance
Knowledge is growing so fast that ninety per cent of what we will know in fifty years time, will be discovered in those fifty years
According to an old English system of time units, a moment is one and a half minutes
The typewriter was invented in 1829, and the automatic dishwasher in 1889
The wristwatch was invented in 1904 by Louis Cartier
When glass breaks, the cracks move at speeds of up to 3,000 miles per hour
By raising your legs slowly and laying on your back, you can't sink in quicksand
Ten minutes of one hurricane contains enough energy to match the nuclear stockpiles of the world
Most gemstones contain several elements
Diamonds are the hardest substance known to man
Which of the 50 states has never had an earthquake? North Dakota
When hydrogen burns in the air, water is formed
Sterling silver contains 7.5% copper
Cars were first made with ignition keys in 1949
JB Dunlop was first to put air into tires
Alexander Graham Bell, who invented the telephone, also set a world water speed record of over seventy miles an hour at the age of seventy two
It is energy efficient to turn off a fluorescent light only if it will not be used again within an hour or more
This is because of the high voltage needed to turn it on, and the shortened life this high voltage causes
The Earth's equatorial circumference is greater than its polar circumference
Lake Baikal is the deepest lake in the world
Due to gravitational effects, you weigh slightly less when the moon is directly overhead
The Earth's average velocity orbiting the sun is 107,220 km per hour
There is a high and low tide because of our moon and the Sun
The United States consumes 25% of all the world's energy
Flying from London to New York by Concord, due to the time zones crossed, you can arrive 2 hours before you leave
There is enough fuel in a full tank of a Jumbo Jet to drive an average car four times around the world
The surface speed record on the moon is 10.56 miles per hour
If you could drive to the sun at 55 miles per hour it would take about 193 years
The moon is one million times drier than the Gobi Desert
Just twenty seconds worth of fuel remained when the Apollo 11 lunar module landed on the moon
A Boeing 707 uses four thousand gallons of fuel in its takeoff climb
The planet Saturn has a density lower than water
Since 1959, more than 6,000 pieces of space junk have fallen out of orbit
It takes 70% less energy to produce a ton of paper from recycled paper than from trees
Every year in the US, 625 people are struck by lightning
Hawaii is moving toward Japan 4 inches every year
The rocket engine has to supply its own oxygen so it can burn its fuel in outer space
The North Atlantic gets 1 inch wider every year
Oxygen is the most abundant element in the Earth's crust, waters, and atmosphere
A stroke of lightning discharges from 10 to 100 million volts & 30,000 amperes of electricity
Hydrogen is the most abundant element in the Universe
The average distance between the Earth & the Moon is 238,857 miles
The moon is 27% the size of the Earth
The center of the Sun is about 27 million degrees Fahrenheit
Sunlight takes about 8 minutes & 20 seconds to reach the Earth at 186,282 miles per second
The highest temperature on Earth was 136°F in Libya in 1922
The lowest temperature on Earth was -128.6°F in Antarctica in 1983
Sunlight can penetrate clean ocean water to a depth of 240 feet
The average ocean floor is 12,000 feet
The temperature can be determined by counting the number of cricket chirps in fourteen seconds and adding 40
House flies have a lifespan of two weeks
Chimps are the only animals that can recognize themselves in a mirror
Starfish don't have brains
The average person falls asleep in seven minutes
Shrimp hearts are in their heads
Every time you lick a stamp, you're consuming one tenth of a calorie
The longest recorded flight of a chicken is thirteen seconds
Emus and kangaroos cannot walk backwards
Cats have over one hundred vocal sounds, while dogs only have about ten
Porcupines float in water
An ostrich's eye is bigger that its brain
An iguana can stay under water for 28 minutes
The common goldfish is the only animal that can see both infrared and ultraviolet light
It is impossible to sneeze with your eyes open
The pupil of an octopus eye is rectangular
Our eyes are always the same size from birth, but our nose and ears never stop growing
The leg bones of a bat are so thin that no bat can walk
Ants cannot chew their food, they move their jaws sideways, like scissors, to extract the juices from the food
Hummingbirds are the only animals able to fly backwards
A cat has 32 muscles in each ear
Tigers have striped skin, not just striped fur
Armadillos get an average of 18.5 hours of sleep per day
Armadillos can walk underwater
There are more beetles than any other kind of creature in the world
Certain frogs that can survive the experience of being frozen
Only humans sleep on their backs
The human brain is 80% water
As an adult, you have more than 20 square feet of skin on your body
15 million blood cells are produced and destroyed in the human body every second
Every minute, 40,000 dead skin cells fall from your body
The brain uses more than 25% of the oxygen used by the human body
If your mouth was completely dry, you would not be able to distinguish the taste of anything
There are more living organisms on the skin of a single human being than there are human beings on the surface of the earth
Muscles are made up of bundles from about 5 in the eyelid to about 200 in the buttock muscle
Muscles in the human body make up about half of the body weight
The human body has enough fat to produce 7 bars of soap
The human head is a quarter of our total length at birth, but only an eighth of our total length by the time we reach adulthood
Most people blink about 17,000 times a day
Moths have no stomach
Hummingbirds can't walk
Sea otters have 2 coats of fur
A starfish can turn its stomach inside out
A zebra is white with black stripes
The animal with the largest brain in relation to its body is the ant
The largest eggs in the world are laid by a shark
A crocodile's tongue is attached to the roof of its mouth
Crocodiles swallow stones to help them dive deeper
Giraffes are unable to cough
Sharks are immune to cancer
Despite the hump, a camel's spine is straight
A giraffe's neck contains the same number of vertebrae as a human
The heart of giraffe is two feet long, and can weigh as much as twenty four pounds
On average, Elephants sleep for about 2 hours per day
Lobsters have blue blood
Shark teeth are literally as hard as steel
A mosquito has 47 teeth
Oxygen, carbon, hydrogen and nitrogen make up 90% of the human body
Seventy percent of the dust in your home consists of shed human skin
Fish are the only vertebrates that outnumber birds
A cockroach can live for several weeks without its head
The average human produces a quart of saliva a day
Elephants have been known to remain standing after they die
The embryos of tiger sharks fight each other while in their mother's womb, the survivor being the baby shark that is born
Ants do not sleep
Nearly a third of all bottled drinking water purchased in the US is contaminated with bacteria
Rats multiply so quickly that in 18 months, two rats could have over 1 million descendents
An Astronaut can be up to 2 inches taller returning from space
The cartilage disks in the spine expand in the absence of gravity
The oldest known fossil is of a single celled organism found in 3.2 billion year old stones in South Africa
The oldest multicellular fossils date from about 700 million years ago
The earliest cockroach fossils are about 280 million years old
Healthy nails grow about 2 cm each year
Fingernails grow four times as fast as toenails
The eye can see at 20 feet what another eye sees at 15 feet
The average person has 100,000 hairs on their head
Each hair grows about 5 inches every year
There are 60,000 miles in blood vessels in every human
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment