-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a50339a
Showing
3 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
* Get a random integer between `min` and `max`. | ||
* | ||
* @param {number} min - min number | ||
* @param {number} max - max number | ||
* @return {int} a random integer | ||
*/ | ||
|
||
let getRandomInt = (min, max) => { | ||
return Math.floor(Math.random() * (max - min + 1) + min) | ||
} | ||
|
||
const fs = require('fs') | ||
let obj = JSON.parse(fs.readFileSync('./src/testLunch.json', 'utf8')) | ||
// console.log(obj.lunch.length) | ||
console.log("台南億載金城武,今天去吃" + obj.lunch[getRandomInt(0, obj.lunch.length - 1)] + "吧!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash | ||
|
||
# 找到相對應的目錄 | ||
cd $HOME/Desktop/what-to-eat | ||
# 執行 main.js 取得隨機店家,並 assign 給 lunch | ||
lunch=`node main.js` | ||
# 跑 Mac 內建的 script,製造推播推知 | ||
osascript -e "display notification \"$lunch\" with title \"今天午餐吃什麼 ?\"" | ||
# 我叫 Mac 唸給妳聽! | ||
say $lunch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"lunch": [ | ||
"黯然銷魂飯", "叉燒飯", "85 度 C 的黑森林蛋糕配杯中熱拿", | ||
"阿偉的大碗火雞肉飯加貢丸湯", "董娘的五更腸旺", | ||
"貴桑桑的南紡 Coco 咖喱飯", "哈囉果汁店的西瓜牛奶", "大苑子的鮮桔檸檬", | ||
"摩斯漢堡的咖哩豬排堡", "鍋貼 10 個外加一碗紫菜蛋花湯", "萬客樓的酸辣湯麵外加喝到飽的豆漿", | ||
"屎" | ||
] | ||
} |