r/PowerShell • u/[deleted] • Aug 07 '20
Script Sharing Get-WhatToEat
Because sometime i don't know what i'm going to order...
(With Windows Terminal) :
function Get-WhatToEat {
$list = @(
'๐'
'๐'
'๐'
'๐ญ'
'๐ฏ'
'๐ฃ'
)
Clear-Host
Get-Random $list
}
Get-WhatToEat50
u/ihaxr Aug 07 '20 edited Aug 07 '20
I mean if we're going to be ridiculous, let's be ridiculous :)
function ๐ด {
@('๐','๐','๐','๐ญ','๐ฏ','๐ฃ')
}
function ๐ฝ {
Clear-Host ; ๐ด | Get-Random
}
๐ฝ12
Aug 07 '20 edited Aug 07 '20
Don't know why but it doesn't work :(
Maybe the copy paste, replace the emoji with some "??"
Edit : Ok, it work with Pwsh 7.0.3
3
u/rlj551 Aug 07 '20
Sorry, couldn't run for me either. Looks like it will only run on specific versions or higher.
My version: PSVersion: 5.0.10586.117
The token '&&' is not a valid statement separator in this version.
7
u/ihaxr Aug 07 '20
Ah, just replace that with a
;then. I've been writing bash scripts all week so&&is stuck in my head.2
u/rlj551 Aug 07 '20
That did the trick.
haha, no worries man. BugiBugi said it works on POSH 7, so will try that way at home. Stuck on ver 5 here at work.
5
u/ihaxr Aug 07 '20
There are so many weird/random fixes and quality of life improvements in v7 that I don't even realize until I accidentally post something that uses them.
1
u/4thehalibit Aug 08 '20
Don't feel like opening laptop so I used Try it online it worked like a charm
20
u/empty_other Aug 07 '20
Nice, now I can blame the computer for making me fat.
> Get-WhatToEat
๐
> Get-WhatToEat
๐ฃ
> Get-WhatToEat
๐ฃ
> Get-WhatToEat
๐Pizza it is then.
12
7
3
35
u/howmanywhales Aug 07 '20
where's that salad emoji brother
4
u/ryan_bop Aug 07 '20
Salad โ does not compute
15
Aug 07 '20
[removed] โ view removed comment
1
4
u/ForcedProgrammer Aug 07 '20
I didn't claw my way to the top of the food chain to eat a salad.
Salad isn't food, it is what food eats.
3
u/hypnoticoil Aug 07 '20
Well based on your dental records you still have the teeth required to chew salad. And this has been a food source for your kind for more than 2,000 years or so. :-)
10
4
4
4
Aug 07 '20
I wrote something similar at my last job, installed it as a module on everyoneโs computer. I called get-lunch and it had a listing of every restaurant near us and would spit out a random restaurant unless get-date was Friday which was our designated Hawaiian BBQ day.
4
u/jevans_ Aug 08 '20
I went a bit wild with the same idea back in June
<#
.NOTES
Developed one evening when we could not think of what to order in.
Code development process powered by hunger.
Created: 28/06/2020
Author: jevans_
#>
Function Get-RandomMeal {
[CmdletBinding()]
param (
[Parameter()]
[Switch]
$Delivered,
[Parameter()]
[Switch]
$Favourite
)
# Import parameters
$PowerMealParams = Get-Content -Path "$PSScriptRoot\..\PowerMealParams.json" | ConvertFrom-Json
Write-Verbose "Params loaded:"
Write-Verbose $PowerMealParams
# Delivery
If($Delivered){
# Get date, used to determine what is open when function is run
$Date = Get-Date
$FoodEstablishment = $PowerMealParams.delivery.psobject.properties.Name | ForEach-Object {
If($_ -notlike "*template*"){
$_
}
}
do {
$RandomFoodEstablishment = Get-Random $FoodEstablishment | Where-Object {
((Get-Date $PowerMealParams.Delivery.$_.CloseTime) -gt $Date) -and
((Get-Date $PowerMealParams.Delivery.$_.OpenTime) -lt $Date)
}
} until ($null -ne $RandomFoodEstablishment)
Write-Host "Food Establishment Picked: " -NoNewline -ForegroundColor Yellow
Write-Host $RandomFoodEstablishment -ForegroundColor Green
# Favourite
If($Favourite){
Write-Host "K's favourites: " -ForegroundColor Yellow
$PowerMealParams.Delivery.$RandomFoodEstablishment.KFavourites | ForEach-Object {
Write-Host $_ -ForegroundColor Green
}
Write-Host "J's favourites: " -ForegroundColor Yellow
$PowerMealParams.Delivery.$RandomFoodEstablishment.JFavourites | ForEach-Object {
Write-Host $_ -ForegroundColor Green
}
}
Write-Host "Open\Close Times: " -ForegroundColor Yellow
Write-Host ($PowerMealParams.Delivery.$RandomFoodEstablishment.OpenTime + '-' + $PowerMealParams.Delivery.$RandomFoodEstablishment.CloseTime) -ForegroundColor Cyan
}
}3
u/jevans_ Aug 08 '20
JSON used as params:
{ "Delivery": { "Template": { "DisplayName": "", "KFavourites": [ "", "" ], "JFavourites": [ "", "" ], "KCompatible": true, "JCompatible": false, "DeliveryPlatforms": [ "Uber Eats", "Deliveroo", "Menulog" ], "OpenTime": "00:00:00", "CloseTime": "00:00:00" } }, "HomeMade": { "Recipes": {}, "InventoryPath": "" }, "Allergies": { "K": [], "J": [] } }3
u/jevans_ Aug 08 '20
I really want to take this a step further and take advantage of the Uber Eats API to place the order when the function is run, but to be honest I'm kinda worried about my credit card getting nuked...
1
u/Mayki8513 Aug 10 '20
Haha this is great, I did this a few months ago but had it randomly select a number, a restaurant, then pop up a window that read "Menu item $i from $Restaurant" Made a shortcut so I can call it from a hotkey any time I get hungry, apparently I was taking almost half my lunch hour trying to decide what to eat ๐
Btw, you should add this to your script just 'cause: #Requires -version 7.0
2
3
u/brungy Aug 07 '20
Whereโs the option thatโs my wife saying; โI donโt care you pickโ or โI donโt know โ lol
9
1
1
u/Burning_Ranger Aug 07 '20
Oohhh.... I can think of some great ideas, like getting certain foods based on time of day, day of the week, the weather, local temperature etc. Could be a nice little waste of time....
EDIT: Someone's already done half the work: https://geekeefy.wordpress.com/2017/08/24/get-weather-report-using-powershell/
1
u/randyvitorivich Aug 08 '20
Sometimes something like this has more value at that perfect moment than the fully automated powershell tool that saves you hours of your work day! Kudos!!
1
u/AutoModerator Aug 08 '20
Sorry, your submission has been automatically removed.
Accounts must be at least 1 day old, which prevents the sub from filling up with bot spam.
Try posting again tomorrow or message the mods to approve your post.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
1
u/jsiii2010 Aug 08 '20 edited Aug 08 '20
I did some column editing in the ise (alt-shift) using this page: Food & Drink Emoji Meanings - Emojipedia Oh, that's a nice way to skip the commas. Most of them fall between u+1f32d and u+1f9ca.
$list =
'๐', # Grapes
'๐', # Melon
'๐', # Watermelon
'๐', # Tangerine
'๐', # Lemon
'๐', # Banana
'๐', # Pineapple
'๐ฅญ', # Mango
'๐', # Red Apple
'๐', # Green Apple
'๐', # Pear
'๐', # Peach
'๐', # Cherries
'๐', # Strawberry
'๐ฅ', # Kiwi Fruit
'๐
', # Tomato
'๐ฅฅ', # Coconut
'๐ฅ', # Avocado
'๐', # Eggplant
'๐ฅ', # Potato
'๐ฅ', # Carrot
'๐ฝ', # Ear of Corn
'๐ถ', # Hot Pepper
'๐ฅ', # Cucumber
'๐ฅฌ', # Leafy Green
'๐ฅฆ', # Broccoli
'๐ง', # Garlic
'๐ง
', # Onion
'๐', # Mushroom
'๐ฅ', # Peanuts
'๐ฐ', # Chestnut
'๐', # Bread
'๐ฅ', # Croissant
'๐ฅ', # Baguette Bread
'๐ฅจ', # Pretzel
'๐ฅฏ', # Bagel
'๐ฅ', # Pancakes
'๐ง', # Waffle
'๐ง', # Cheese Wedge
'๐', # Meat on Bone
'๐', # Poultry Leg
'๐ฅฉ', # Cut of Meat
'๐ฅ', # Bacon
'๐', # Hamburger
'๐', # French Fries
'๐', # Pizza
'๐ญ', # Hot Dog
'๐ฅช', # Sandwich
'๐ฎ', # Taco
'๐ฏ', # Burrito
'๐ฅ', # Stuffed Flatbread
'๐ง', # Falafel
'๐ฅ', # Egg
'๐ณ', # Cooking
'๐ฅ', # Shallow Pan of Food
'๐ฒ', # Pot of Food
'๐ฅฃ', # Bowl with Spoon
'๐ฅ', # Green Salad
'๐ฟ', # Popcorn
'๐ง', # Butter
'๐ง', # Salt
'๐ฅซ', # Canned Food
'๐ฑ', # Bento Box
'๐', # Rice Cracker
'๐', # Rice Ball
'๐', # Cooked Rice
'๐', # Curry Rice
'๐', # Steaming Bowl
'๐', # Spaghetti
'๐ ', # Roasted Sweet Potato
'๐ข', # Oden
'๐ฃ', # Sushi
'๐ค', # Fried Shrimp
'๐ฅ', # Fish Cake with Swirl
'๐ฅฎ', # Moon Cake
'๐ก', # Dango
'๐ฅ', # Dumpling
'๐ฅ ', # Fortune Cookie
'๐ฅก', # Takeout Box
'๐ฆช', # Oyster
'๐ฆ', # Soft Ice Cream
'๐ง', # Shaved Ice
'๐จ', # Ice Cream
'๐ฉ', # Doughnut
'๐ช', # Cookie
'๐', # Birthday Cake
'๐ฐ', # Shortcake
'๐ง', # Cupcake
'๐ฅง', # Pie
'๐ซ', # Chocolate Bar
'๐ฌ', # Candy
'๐ญ', # Lollipop
'๐ฎ', # Custard
'๐ฏ', # Honey Pot
'๐ผ', # Baby Bottle
'๐ฅ', # Glass of Milk
'โ', # Hot Beverage
'๐ต', # Teacup Without Handle
'๐ถ', # Sake
'๐พ', # Bottle with Popping Cork
'๐ท', # Wine Glass
'๐ธ', # Cocktail Glass
'๐น', # Tropical Drink
'๐บ', # Beer Mug
'๐ป', # Clinking Beer Mugs
'๐ฅ', # Clinking Glasses
'๐ฅ', # Tumbler Glass
'๐ฅค', # Cup with Straw
'๐ง', # Beverage Box
'๐ง', # Mate
'๐ง', # Ice
'๐ฅข', # Chopsticks
'๐ฝ', # Fork and Knife with Plate
'๐ด', # Fork and Knife
'๐ฅ' # Spoon1
1
u/setmehigh Aug 10 '20
I made something similar for restaurants in JavaScript, let you pick ones to take out of the running and a big dice roll to figure out where we were going to eat.
0
0
Aug 07 '20
[deleted]
11
16
u/[deleted] Aug 07 '20
Made some changes to add suspense :