Last active
December 21, 2015 12:58
-
-
Save kuanyui/6309242 to your computer and use it in GitHub Desktop.
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
(defun ramen-download-voice-file () | |
(if (not (file-exists-p "~/.emacs.d/ramen.ogg")) | |
(progn | |
(message "Please wait, it'll be downloading a voice file (169.6KB) to ~/.emacs.d/ramen.ogg") | |
(sleep-for 3) | |
(url-copy-file "https://dl.dropboxusercontent.com/u/1776218/ramen.ogg" "~/.emacs.d/ramen.ogg")))) | |
(let* (mins sec time-left a-flag title play-flag a-1-1 a-1-2 a-1-3 a-2-1 a-2-2 a-2-3 a-3-1 a-3-2 a-3-3) | |
(defun ask-minutes () | |
(setq mins (string-to-number (read-from-minibuffer "How many minutes?(1~10) "))) | |
(if (numberp mins) | |
(cond ((> mins 10) | |
(progn | |
(message "時間太長了,泡麵會泡到爛掉!") | |
(ask-minutes))) | |
((= mins 0) | |
(progn | |
(message "不到一分鐘你還不如直接啃乾的麵塊!") | |
(ask-minutes))) | |
((< mins 0) | |
(progn | |
(message (format "您的泡麵早在 %s 分鐘前就已經泡好了" (abs mins))))) | |
(t (progn | |
(setq sec (* mins 60)) ;這裡不確定需不需要string-to-number | |
(switch-to-ramen-buffer))) | |
(progn | |
(message "只能輸入1~10的數字。") | |
(ask-minutes))))) | |
(defun switch-to-ramen-buffer () | |
(switch-to-buffer "*ramen-timer*") | |
(buffer-disable-undo nil) | |
(if (or (< (window-body-width) 79) (< (window-body-height) 33)) | |
(delete-other-windows)) | |
(setq ramen-timer (run-at-time "0 sec" 1 'update-ramen-buffer)) | |
;; set local map | |
(setq instant-ramen-map (make-sparse-keymap)) | |
(define-key instant-ramen-map (kbd "q") 'ramen-stop) | |
(use-local-map instant-ramen-map)) | |
(defun update-ramen-buffer () | |
(with-current-buffer "*ramen-timer*" | |
(erase-buffer) | |
(cond ((> sec 0) | |
(progn (setq title (format " 剩下 %s 秒" sec)) | |
(cond ((equal a-flag 1) (progn (insert a-1-1 title) | |
(setq a-flag 2))) | |
((equal a-flag 2) (progn (insert a-1-2 title) | |
(setq a-flag 3))) | |
((equal a-flag 3) (progn (insert a-1-3 title) | |
(setq a-flag 1)))))) | |
((and (<= sec 0) (> sec -60)) | |
(progn (setq title (format "\n %s小妹妹,拎叨A泡麵已經煮好惹,拎阿罵限你一分鐘內趕回去吃!\n (在 %s 秒前)" (user-login-name) (abs sec))) | |
(play-ramen) | |
(cond ((equal a-flag 1) (progn (insert a-2-1 title) | |
(setq a-flag 2))) | |
((equal a-flag 2) (progn (insert a-2-2 title) | |
(setq a-flag 3))) | |
((equal a-flag 3) (progn (insert a-2-3 title) | |
(setq a-flag 1)))))) | |
((<= sec -60) | |
(progn (setq title (format "\n 泡麵已經泡爛超過 %s 秒了!" (abs sec))) | |
(cond ((equal a-flag 1) (progn (insert a-3-1 title) | |
(setq a-flag 2))) | |
((equal a-flag 2) (progn (insert a-3-2 title) | |
(setq a-flag 3))) | |
((equal a-flag 3) (progn (insert a-3-3 title) | |
(setq a-flag 1)))))))) | |
(setq sec (- sec 1))) | |
(defun play-ramen () | |
(if play-flag | |
(progn | |
(setq play-flag nil) | |
(call-process "/bin/bash" nil 0 nil "-c" "mplayer -volume 100 -loop 1 ~/.emacs.d/ramen.ogg")))) | |
(defun ramen-stop () | |
(interactive) | |
(cancel-timer ramen-timer)) | |
(defun instant-ramen-timer () | |
(interactive) | |
(ramen-download-voice-file) | |
(setq a-1-1 | |
" | |
__,,..........___ | |
_.--'' `'--._ | |
,-' `-. | |
/ \\ | |
`. ,' | |
\\`._ _.- | |
| `--...___ __,,..--' | | |
+._ `'-._,,o' _,.' | |
Y88db==..___ ___..oob888P | |
od:P88888888b8_bbbbbd88888888\":oo | |
`YYbo:i'''YP888888PP''''i,odPP'| | |
| '\"YPYbooooooooooodPPP\"' | | |
| `'''''''' | | |
| | | |
| .' | |
| | | |
| | | |
| | | |
:oo_ | | |
Y888o.__ _,oo88| | |
|`'Y888888oooooo88888888P'| | |
| `-'YPPPPPPPP\"\"''' | | |
'. | | |
`. ,' | |
``-..________...--' | |
") | |
(setq a-1-2 | |
" | |
__,,..........___ ,.-. | |
_.--'' `'--._ _, \\.. | |
,-' ,' `. | |
/ L _/' | |
`. `` | | |
\\`._ _.- `---`..' | |
| `--...___ __,,..--' | | |
+._ `'-._,,o' _,.' | |
Y88db==..___ ___..oob888P | |
od:P88888888b8_bbbbbd88888888\":oo | |
`YYbo:i'''YP888888PP''''i,odPP'| | |
| '\"YPYbooooooooooodPPP\"' | | |
| `'''''''' | | |
| | | |
| .' | |
| | | |
| | | |
| | | |
:oo_ | | |
Y888o.__ _,oo88| | |
|`'Y888888oooooo88888888P'| | |
| `-'YPPPPPPPP\"\"''' | | |
'. | | |
`. ,' | |
``-..________...--' | |
") | |
(setq a-1-3 | |
" | |
__,,..........___ | |
_.--'' `'--._ | |
,-''-,p----. `-. | |
_,- \\ \\ | |
,' `-. ,' | |
| '| _.- | |
P ../__ __,,..--' | | |
`.__ | `'-._,,o' _,.' | |
. =../__ ___..oob888P | |
`.,/\\ od:8-8888888b8_bbbbbd88888888\":oo | |
`--...:YYbo:i'''YP888888PP''''i,odPP'| | |
| '\"YPYbooooooooooodPPP\"' | | |
| `'''''''' | | |
| | | |
| .' | |
| | | |
| | | |
| | | |
:oo_ | | |
Y888o.__ _,oo88| | |
|`'Y888888oooooo88888888P'| | |
| `-'YPPPPPPPP\"\"''' | | |
'. | | |
`. ,' | |
``-..________...--' | |
") | |
(setq a-2-1 | |
" | |
,o--'i:-,,.,........___ | |
,,-'-' -''`. 'L. `'--._ | |
/ J,-' ` . `-. | |
.^ '-_ `.. \\ | |
b `.| `==._ _,' | |
`/ __.+'._ ./P88P8b\\:i --..._ _,:. | |
`._ . [ | `-'.::8i/'88:o\\o/\\p<:'::''' | | |
`-'--.,-' +._ `'':i::b'' _,.' | |
Y88db==..___ ___..oob888P | |
od:P88888888b8_bbbbbd88888888\":oo | |
`YYbo:i'''YP888888PP''''i,odPP'| | |
| '\"YPYbooooooooooodPPP\"' | | |
| `'''''''' | | |
| | Time to eat! | |
| .' | |
| | | |
| | | |
| | | |
:oo_ | | |
Y888o.__ _,oo88| _,oodP | |
|`'Y888888oooooo88888888P'| _,oodPP\"'' | |
| `-'YPPPPPPPP\"\"''' | _,oodPP\"'' | |
'. | _,oodPP\"'' __, | |
`. ,' _,oodPP\"'' ___ooooo8PPP\"\" | |
``-..________...--',dPP\"'' __,oooodPPP\"\"''' | |
__,ooooo8PPP\"\"''' | |
o8PPP\"\"''' | |
") | |
(setq a-2-2 | |
" | |
,o--'i:-,,.,........___ | |
'L. `'--._ | |
,-' ` . `-. | |
' `.. \\ | |
`. `==._ _.-'i,' | |
+'._ ./P88P8b\\:i --..._ ,.' b... | |
| `-'.::8i/'88:o\\o/\\p<,' \\. | |
+._ `'':i::b''| | | |
Y88db==..___ _|_ -+' | |
od:P88888888b8_bbbbbd888-8 .' | |
`YYbo:i'''YP888888PP''''i-od8/:._,,' | |
| '\"YPYbooooooooooodPPP\"' | | |
| `'''''''' | | |
| | Time to eat! | |
| .' | |
| | | |
| | | |
| | | |
:oo_ | | |
Y888o.__ _,oo88| _,oodP | |
|`'Y888888oooooo88888888P'| _,oodPP\"'' | |
| `-'YPPPPPPPP\"\"''' | _,oodPP\"'' | |
'. | _,oodPP\"'' __, | |
`. ,' _,oodPP\"'' ___ooooo8PPP\"\" | |
``-..________...--',dPP\"'' __,oooodPPP\"\"''' | |
__,ooooo8PPP\"\"''' | |
o8PPP\"\"''' | |
") | |
(setq a-2-3 | |
" | |
,o--'i:-,,.,........___ | |
'L. `'--._ | |
,-' ` . , .-''\\_ `-. | |
' `..,-' '` \\ | |
`. ,' . _,' | |
+'._ ./\\ _\\ _,:. | |
| `-'.:[ <:'::''' | | |
+._ .__`' | _,.' | |
Y88db==..___.._ _/...,__..oob888P | |
od:P88888888b8_bbbbbd88888888\":oo | |
`YYbo:i'''YP888888PP''''i,odPP'| | |
| '\"YPYbooooooooooodPPP\"' | | |
| `'''''''' | | |
| | Time to eat! | |
| .' | |
| | | |
| | | |
| | | |
:oo_ | | |
Y888o.__ _,oo88| _,oodP | |
|`'Y888888oooooo88888888P'| _,oodPP\"'' | |
| `-'YPPPPPPPP\"\"''' | _,oodPP\"'' | |
'. | _,oodPP\"'' __, | |
`. ,' _,oodPP\"'' ___ooooo8PPP\"\" | |
``-..________...--',dPP\"'' __,oooodPPP\"\"''' | |
__,ooooo8PPP\"\"''' | |
o8PPP\"\"''' | |
") | |
(setq a-3-1 | |
" | |
,o--'i:-,,.,........___ | |
'L. `'--._ | |
,./Y\\.:_. `-. | |
:/\"\\Y8b=/L.. \\ | |
/Lb..bL//\"Y>bi==._ _,' | |
|:/\\/bo88:dX=-8|8b_:i --..._ _,:. | |
|]/,o/b88YP.b:8|/:88:o\\o/\\p<:'::''' | | |
_/|:/Y'./=:'' /''':i::b'' _,.' | |
| ,=8+8db,'..___ ___..oob888P | |
' +\\b|bP88888888b8_bbbbbd88888888\":oo | |
\\|||'Y-bo:i'''YP888888PP''''i,odPP'| | |
|+`:\\' '\"YPYbooooooooooodPPP\"' | | |
|||'+| `'''''''' | | |
||| | | 泡到爛掉了啦! | |
| '. | .' | |
|| | | | |
`.| | | |
`. | | |
|od. | | |
Y88\\o.__ _,oo88| _,oodP | |
|`'Y\\88888oooooo88888888P'| _,oodPP\"'' | |
| `.'YPPPPPPPP\"\"''' | _,oodPP\"'' | |
'. | _,oodPP\"'' __, | |
`._ ,' _,oodPP\"'' ___ooooo8PPP\"\" | |
`-..________...--',dPP\"'' __,oooodPPP\"\"''' | |
__,ooooo8PPP\"\"''' | |
o8PPP\"\"''' | |
") | |
(setq a-3-2 | |
" | |
,o--'i:-,,.,........___ | |
'L. `'--._ | |
,./Y\\.:_. `-. | |
:/\"\\Y8b=/L.. \\ | |
/Lb..bL//\"Y>bi==._ _,' | |
|:/\\/bo88:dX=-8|8b_:i --..._ _,:. | |
|]/,o/b88YP.b:8|/:88:o\\o/\\p<:'::''' | | |
_/|:/Y'./=:'' /''':i::b'' _,.' | |
| ,=8+8db,'..___ ___..oob888P | |
' +\\b|bP88888888b8_bbbbbd88888888\":oo | |
\\|||'Y-bo:i'''YP888888PP''''i,odPP'| | |
|+`:\\' '\"YPYbooooooooooodPPP\"' | | |
|||'+| `'''''''' | | |
||| | | 泡到爛掉了啦! | |
| '. | .' | |
| || | | | |
\\ |`.| | | |
[| `. | | |
,'| |od. | | |
| | | Y88\\o.__ _,oo88| _,oodP | |
/ | | |`'Y\\88888oooooo88888888P'| _,oodPP\"'' | |
/ | \\ | `.'YPPPPPPPP\"\"''' | _,oodPP\"'' | |
| |'. ,' | _,oodPP\"'' __, | |
. `./ ,' _,oodPP\"'' ___ooooo8PPP\"\" | |
_/``-..________...--',dPP\"'' __,oooodPPP\"\"''' | |
__,ooooo8PPP\"\"''' | |
o8PPP\"\"''' | |
") | |
(setq a-3-3 | |
" | |
,o--'i:-,,.,........___ | |
'L. `'--._ | |
,./Y\\.:_. `-. | |
:/\"\\Y8b=/L.. \\ | |
/Lb..bL//\"Y>bi==._ _,' | |
|:/\\/bo88:dX=-8|8b_:i --..._ _,:. | |
|]/,o/b88YP.b:8|/:88:o\\o/\\p<:'::''' | | |
_/|:/Y'./=:'' /''':i::b'' _,.' | |
| ,=8+8db,'..___ ___..oob888P | |
' +\\b|bP88888888b8_bbbbbd88888888\":oo | |
\\|||'Y-bo:i'''YP888888PP''''i,odPP'| | |
|+`:\\' '\"YPYbooooooooooodPPP\"' | | |
|||'+| `'''''''' | | |
||| | | 泡到爛掉了啦! | |
| '. | .' | |
| || | | | |
\\ |`.| | | |
[| `. | | |
,'| |od. | | |
| | | Y88\\o.__ _,oo88| _,oodP | |
/ | | |`'Y\\88888oooooo88888888P'| _,oodPP\"'' | |
/ | \\ | `.'YPPPPPPPP\"\"''' | _,oodPP\"'' | |
| |'. ,' | _,oodPP\"'' __, | |
___ | `. `./ ,' _,oodPP\"'' ___ooooo8PPP\"\" | |
_.,'' ']=>.=P.:p. | _/``-..________...--',dPP\"'' __,oooodPPP\"\"''' | |
,=P...._ /'' ' '`'' __,ooooo8PPP\"\"''' | |
'' | o8PPP\"\"''' | |
") | |
(setq a-flag 1 | |
play-flag t) | |
(ask-minutes)) | |
) | |
(provide 'instant-ramen) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment