diff --git a/Data/quotes.csv b/Data/quotes.csv new file mode 100644 index 00000000..ca136487 --- /dev/null +++ b/Data/quotes.csv @@ -0,0 +1,19 @@ +Genre,Author,Quote +IQ,Thomas Edison,"Genius is one percent inspiration and ninety-nine percent perspiration." +Misc,Johann Wolfgang von Goethe,"Difficulties increase the nearer we get to the goal." +Misc,William Shakespeare,"Having nothing, nothing can he lose." +Misc,Albert Einstein,"Learn from yesterday, live for today, hope for tomorrow." +Misc,Michelangelo,"Faith in oneself is the best and safest course." +Misc,Sophocles,"It takes both sunshine and rain to make a rainbow." +Misc,Mahatma Gandhi,"We must become the change we want to see." +Misc,Johann Wolfgang von Goethe,"Knowing is not enough; we must apply!" +Misc,Immanuel Kant,"Science is organized knowledge. Wisdom is organized life." +Misc,Indira Gandhi,"You can't shake hands with a clenched fist." +Misc,Albert Einstein,"Try not to become a man of success, but rather try to become a man of value." +Misc,Pierre Auguste Renoir,"The pain passes, but the beauty remains." +Misc,Heraclitus,"All is flux; nothing stays still." +Misc,Japanese proverb,"The day you decide to do it is your lucky day." +Misc,Abraham Lincoln,"The best thing about the future is that it only comes one day at a time." +Misc,Epictetus,"We have two ears and one mouth so that we can listen twice as much as we speak." +Misc,Cervantes,"Be slow of tongue and quick of eye." +Misc,Bruce Lee,"Mistakes are always forgivable, if one has the courage to admit them." diff --git a/Data/sayings.csv b/Data/sayings.csv deleted file mode 100644 index 6c1f0bab..00000000 --- a/Data/sayings.csv +++ /dev/null @@ -1,69 +0,0 @@ -Joke -"Chuck Norris doesnt read books. He stares them down until he gets the information he wants." -"Time waits for no man. Unless that man is Chuck Norris." -"If you spell Chuck Norris in Scrabble, you win. Forever." -"Chuck Norris breathes air five times a day." -"In the Beginning there was nothing then Chuck Norris roundhouse kicked nothing and told it to get a job." -"Chuck Norris has a mug of nails instead of coffee in the morning." -"If Chuck Norris were to travel to an alternate dimension in which there was another Chuck Norris and they both fought, they would both win." -"The dinosaurs looked at Chuck Norris the wrong way once. You know what happened to them." -"Chuck Norris tears cure cancer. Too bad he has never cried." -"Chuck Norris once roundhouse kicked someone so hard that his foot broke the speed of light" -"Since 1940, the year Chuck Norris was born, roundhouse kick related deaths have increased 13,000 percent." -"Chuck Norris does not own a stove, oven, or microwave , because revenge is a dish best served cold." -"Chuck Norris does not sleep. He waits." -"There is no chin behind Chuck Norris beard. There is only another fist." -"The chief export of Chuck Norris is pain." -"Chuck Norris recently had the idea to sell his pee as a canned beverage. Its now called Red Bull." -"If paper beats rock, rock beats scissors, and scissors beats paper, what beats all 3 at the same time? Chuck Norris." -"On the 7th day, God rested Chuck Norris took over." -"Chuck Norris can dribble a bowling ball." -"Chuck Norris drinks napalm to fight his heartburn." -"Chuck Norris roundhouse kick is so powerful, it can be seen from outer space by the naked eye." -"If you want a list of Chuck Norris enemies, just check the extinct species list." -"Chuck Norris has never blinked in his entire life. Never." -"Chuck Norris does not use spell check. If he happens to misspell a word, Oxford will change the spelling." -"Some kids pee their name in the snow. Chuck Norris can pee his name into concrete." -"Chuck Norris counted to infinity twice." -"Chuck Norris can speak Braille." -"Chuck Norris can have both feet on the ground and kick butt at the same time." -"Chuck Norris can do a wheelie on a unicycle." -"Chuck Norris stands faster than anyone can run." -"Once a cobra bit Chuck Norris leg. After five days of excruciating pain, the cobra died." -"Chuck Norris once won a game of Connect Four in three moves." -"Champions are the breakfast of Chuck Norris." -"When the Boogeyman goes to sleep every night he checks his closet for Chuck Norris." -"Chuck Norris can slam revolving doors." -"Chuck Norris does not hunt because the word hunting implies the possibility of failure. Chuck Norris goes killing." -"The dark is afraid of Chuck Norris." -"Chuck Norris makes onions cry." -"Death once had a near-Chuck-Norris experience." -"When Chuck Norris writes, he makes paper bleed." -"Chuck Norris can strangle you with a cordless phone." -"Chuck Norris never retreats; He just attacks in the opposite direction." -"Chuck Norris can build a snowman out of rain." -"Chuck Norris can drown a fish." -"When Chuck Norris enters a room, he doesnt turn the lights on, he turns the dark off." -"The only time Chuck Norris was ever wrong was when he thought he had made a mistake." -"Chuck Norris is the only person that can punch a cyclops between the eye." -"Chuck Norris used to beat up his shadow because it was following to close. It now stands 15 feet behind him." -"Outer space exists because its afraid to be on the same planet with Chuck Norris." -"When Chuck Norris does a pushup, he's pushing the Earth down." -"Chuck Norris doesnt wear a watch. He decides what time it is." -"Chuck Norris does not get frostbite. Chuck Norris bites frost." -"Chuck Norris spices up his steaks with pepper spray." -"The Great Wall of China was originally created to keep Chuck Norris out. It didn't work." -"Chuck Norris can get in a bucket and lift it up with himself in it." -"Chuck Norris doesn't shower, he only takes blood baths." -"Chuck Norris can divide by zero." -"Chuck Norris once kicked a horse in the chin. Its descendants are now known as giraffes." -"When Chuck Norris does division, there are no remainders." -"It takes Chuck Norris 20 minutes to watch '60 Minutes'." -"Chuck Norris once went skydiving, but promised never to do it again. One Grand Canyon is enough." -"We live in an expanding universe. All of it is trying to get away from Chuck Norris." -"Chuck Norris beat the sun in a staring contest." -"Chuck Norris can clap with one hand." -"Chuck Norris doesn't need to shave. His beard is scared to grow." -"Chuck Norris invented airplanes because he was tired of being the only person that could fly." -"Freddy Krueger has nightmares about Chuck Norris." -"Chuck Norris can start a fire with an ice cube." diff --git a/Data/scripts.csv b/Data/scripts.csv index d70403bd..7d69b143 100644 --- a/Data/scripts.csv +++ b/Data/scripts.csv @@ -186,7 +186,7 @@ speak-french.ps1, speaks the given text with a French text-to-speech (TTS) voice speak-german.ps1, speaks the given text with a German text-to-speech (TTS) voice speak-italian.ps1, speaks the given text with an Italian text-to-speech (TTS) voice speak-joke.ps1, speaks a random Chuck Norris joke by text-to-speech (TTS) -speak-saying.ps1, speaks a random saying by text-to-speech (TTS) +speak-quote.ps1, speaks a random quote by text-to-speech (TTS) speak-test.ps1, performs a speak test by text-to-speech (TTS) speak-text.ps1, speaks the given text by text-to-speech (TTS) speak-time.ps1, speaks the current time by text-to-speech (TTS) @@ -219,9 +219,9 @@ write-lowercase.ps1, writes the given text in lowercase letters write-marquee.ps1, writes the given text as marquee write-morse-code.ps1, writes the given text in Morse code write-motd.ps1, writes the message of the day (MOTD) +write-quote.ps1, writes a random quote write-red.ps1, writes the given text in a red foreground color write-rot13.ps1, encodes or decodes the given text with ROT13 -write-saying.ps1], writes a random saying write-typewriter.ps1, writes the given text with the typewriter effect write-uppercase.ps1, writes the given text in uppercase letters write-vertical.ps1, writes the given text in vertical direction diff --git a/README.md b/README.md index 52a71384..3f64de86 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ Mega Collection of PowerShell Scripts * [speak-german.ps1](Scripts/speak-german.ps1) - speaks the given text with a German text-to-speech (TTS) voice * [speak-italian.ps1](Scripts/speak-italian.ps1) - speaks the given text with an Italian text-to-speech (TTS) voice * [speak-joke.ps1](Scripts/speak-joke.ps1) - speaks a random Chuck Norris joke by text-to-speech (TTS) -* [speak-saying.ps1](Scripts/speak-saying.ps1) - speaks a random saying by text-to-speech (TTS) +* [speak-quote.ps1](Scripts/speak-quote.ps1) - speaks a random quote by text-to-speech (TTS) * [speak-test.ps1](Scripts/speak-test.ps1) - performs a speak test by text-to-speech (TTS) * [speak-text.ps1](Scripts/speak-text.ps1) - speaks the given text by text-to-speech (TTS) * [speak-time.ps1](Scripts/speak-time.ps1) - speaks the current time by text-to-speech (TTS) @@ -246,9 +246,9 @@ Mega Collection of PowerShell Scripts * [write-marquee.ps1](Scripts/write-marquee.ps1) - writes the given text as marquee * [write-morse-code.ps1](Scripts/write-morse-code.ps1) - writes the given text in Morse code * [write-motd.ps1](Scripts/write-motd.ps1) - writes the message of the day (MOTD) +* [write-quote.ps1](Scripts/write-quote.ps1) - writes a random quote * [write-red.ps1](Scripts/write-red.ps1) - writes the given text in a red foreground color * [write-rot13.ps1](Scripts/write-rot13.ps1) - encodes or decodes the given text with ROT13 -* [write-saying.ps1](Scripts/write-saying.ps1) - writes a random saying * [write-typewriter.ps1](Scripts/write-typewriter.ps1) - writes the given text with the typewriter effect * [write-uppercase.ps1](Scripts/write-uppercase.ps1) - writes the given text in uppercase letters * [write-vertical.ps1](Scripts/write-vertical.ps1) - writes the given text in vertical direction diff --git a/Scripts/speak-joke.ps1 b/Scripts/speak-joke.ps1 index 4a0295ef..ac43e3ec 100755 --- a/Scripts/speak-joke.ps1 +++ b/Scripts/speak-joke.ps1 @@ -14,10 +14,10 @@ try { $Table = import-csv "$PSScriptRoot/../Data/jokes.csv" + $NumRows = $Table.count $Generator = New-Object System.Random - $Index = [int]$Generator.next(0,66) - + $Index = [int]$Generator.next(0,$NumRows - 1) $Joke = $Table[$Index].Joke & "$PSScriptRoot/speak-english.ps1" "$Joke" diff --git a/Scripts/speak-quote.ps1 b/Scripts/speak-quote.ps1 new file mode 100755 index 00000000..87300811 --- /dev/null +++ b/Scripts/speak-quote.ps1 @@ -0,0 +1,29 @@ +<# +.SYNOPSIS + speak-quote.ps1 +.DESCRIPTION + Speaks a random quote by text-to-speech (TTS) +.EXAMPLE + PS> .\speak-quote.ps1 +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz + License: CC0 +#> + +try { + $Table = import-csv "$PSScriptRoot/../Data/quotes.csv" + $NumRows = $Table.count + + $Generator = New-Object System.Random + $Index = [int]$Generator.next(0,$NumRows - 1) + $Quote = $Table[$Index].Quote + $Author = $Table[$Index].Author + + & "$PSScriptRoot/speak-english.ps1" "$Quote (by $Author)" + exit 0 +} catch { + write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} diff --git a/Scripts/speak-saying.ps1 b/Scripts/speak-saying.ps1 deleted file mode 100755 index 5ee63000..00000000 --- a/Scripts/speak-saying.ps1 +++ /dev/null @@ -1,28 +0,0 @@ -<# -.SYNOPSIS - speak-saying.ps1 -.DESCRIPTION - Speaks a random saying by text-to-speech (TTS) -.EXAMPLE - PS> .\speak-saying.ps1 -.LINK - https://github.com/fleschutz/PowerShell -.NOTES - Author: Markus Fleschutz - License: CC0 -#> - -try { - $Table = import-csv "$PSScriptRoot/../Data/saying.csv" - - $Generator = New-Object System.Random - $Index = [int]$Generator.next(0,66) - - $Joke = $Table[$Index].Joke - - & "$PSScriptRoot/speak-english.ps1" "$Joke" - exit 0 -} catch { - write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" - exit 1 -} diff --git a/Scripts/write-joke.ps1 b/Scripts/write-joke.ps1 index 192e6de5..c3c87c00 100755 --- a/Scripts/write-joke.ps1 +++ b/Scripts/write-joke.ps1 @@ -14,11 +14,12 @@ try { $Table = import-csv "$PSScriptRoot/../Data/jokes.csv" + $NumRows = $Table.count $Generator = New-Object System.Random - $Index = [int]$Generator.next(0,66) - + $Index = [int]$Generator.next(0,$NumRows - 1) $Joke = $Table[$Index].Joke + "📣 $Joke" exit 0 } catch { diff --git a/Scripts/write-saying.ps1 b/Scripts/write-quote.ps1 similarity index 50% rename from Scripts/write-saying.ps1 rename to Scripts/write-quote.ps1 index ad8e60a6..1ac91848 100755 --- a/Scripts/write-saying.ps1 +++ b/Scripts/write-quote.ps1 @@ -1,10 +1,10 @@ <# .SYNOPSIS - write-saying.ps1 + write-quote.ps1 .DESCRIPTION - Writes a random saying to the console. + Writes a random quote to the console. .EXAMPLE - PS> .\write-saying.ps1 + PS> .\write-quote.ps1 .LINK https://github.com/fleschutz/PowerShell .NOTES @@ -13,13 +13,15 @@ #> try { - $Table = import-csv "$PSScriptRoot/../Data/sayings.csv" + $Table = import-csv "$PSScriptRoot/../Data/quotes.csv" + $NumRows = $Table.count $Generator = New-Object System.Random - $Index = [int]$Generator.next(0,66) + $Index = [int]$Generator.next(0,$NumRows - 1) + $Quote = $Table[$Index].Quote + $Author = $Table[$Index].Author - $Line = $Table[$Index].Saying - "📣 $Line" + "📣 $Quote <$Author>" exit 0 } catch { write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"