Skip to content

Commit

Permalink
🎉 First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
WeiChiaChang committed Aug 1, 2017
0 parents commit a50339a
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
16 changes: 16 additions & 0 deletions main.js
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)] + "吧!")
10 changes: 10 additions & 0 deletions show.sh
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
9 changes: 9 additions & 0 deletions src/testLunch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"lunch": [
"黯然銷魂飯", "叉燒飯", "85 度 C 的黑森林蛋糕配杯中熱拿",
"阿偉的大碗火雞肉飯加貢丸湯", "董娘的五更腸旺",
"貴桑桑的南紡 Coco 咖喱飯", "哈囉果汁店的西瓜牛奶", "大苑子的鮮桔檸檬",
"摩斯漢堡的咖哩豬排堡", "鍋貼 10 個外加一碗紫菜蛋花湯", "萬客樓的酸辣湯麵外加喝到飽的豆漿",
""
]
}

0 comments on commit a50339a

Please sign in to comment.