Skip to content

Instantly share code, notes, and snippets.

View kuanyui's full-sized avatar
❄️
なんでそんなに慣れてんだよ!

クエン酸 kuanyui

❄️
なんでそんなに慣れてんだよ!
View GitHub Profile
@kuanyui
kuanyui / dired-add-to-smplayer-playlist.el
Last active December 19, 2015 04:09
dired-add-to-smplayer-playlist
(defun dired-add-to-smplayer-playlist ()
"Add a multimedia file or all multimedia files under a directory into SMPlayer's playlist via Dired."
(interactive)
(require 'cl)
(let* (PATTERN FILE full-path-FILE n)
(setq PATTERN "\\(\\.mp4\\|\\.flv\\|\\.rmvb\\|\\.mkv\\|\\.avi\\|\\.rm\\|\\.mp3\\|\\.wav\\|\\.wma\\|\\.m4a\\|\\.mpeg\\|\\.aac\\|\\.ogg\\|\\.flac\\|\\.ape\\|\\.mp2\\|\\.wmv\\)$")
(setq FILE (dired-get-filename nil t))
(setq n 0)
(if (file-directory-p FILE) ;if it's a dir.
(progn
@kuanyui
kuanyui / gist:5911340
Created July 2, 2013 17:32
My temporary Emacs init file "for Windows"...
;;Emacs24開始內建的package.el相關設定
(require 'package)
(package-initialize)
(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/") t)
;;超變態的undo-tree-mode
;;(提醒:redo會變成C-?)
;;C-x u 進入 undo-tree-visualizer-mode,t顯示時間戳。
(require 'undo-tree)
(global-undo-tree-mode)
;;kuanyui's ~/.emacs
;;Time-stamp: "此文件最後是在2013-08-18 22:05:18由kuanyui修改"
;;掃描~/.emacs.d目錄
(add-to-list 'load-path "~/.emacs.d")
(add-to-list 'load-path "~/.emacs.d/lisps")
;;執行Shell外部程式的搜尋路徑(意同$PATH)
(setenv "PATH" (concat (getenv "PATH") ":/home/kuanyui/Dropbox/scripts/"))
(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) ")))
#!/bin/bash
cd ~
mkdir -p ~/.emacs.d
cd ~/.emacs.d
git clone https://gist.github.com/6309242.git ramen
if [ -f ~/.emacs ]
then
@kuanyui
kuanyui / gist:6504771
Last active December 22, 2015 17:18
程式碼超難看的livedoor reader的OPML轉Markdown
(defun opml-to-markdown ()
(interactive)
(let (output-markdown opml-copy-to trans input-file)
(setq output-markdown "~/Dropbox/Blog/source/blogrolls/index.md"
opml-copy-to "~/Dropbox/Blog/source/blogrolls/"
input-file (read-file-name "OPML file's location: "))
(if (not (string-match "\\(\.opml\\|\.xml\\)$" input-file))
(progn "It's not an OPML file."
(opml-to-markdown))
(progn
@kuanyui
kuanyui / html-entities-convert.el
Last active January 2, 2016 07:29
"Replace html entities. Example: (html-enetities-convert ">") => ">"
(defun html-entities-convert (string)
"Replace html entities.
Example:
(html-enetities-convert \"&gt\;\")
=> \">\""
(map 'array (lambda (x)
(if (string-match (aref x 0) string)
(setq string (replace-regexp-in-string (aref x 0) (aref x 1) string))
))
[
(let ((url-request-method "GET")
(url-request-extra-headers '(("Content-Type" . "application/x-www-form-urlencoded")))
output-buffer-name
)
(setq output-buffer-name (url-retrieve-synchronously "http://d.hatena.ne.jp/khiker/20111112/url_retrieve_with_timeout"))
(switch-to-buffer output-buffer-name)
(set-buffer-multibyte t)
(goto-char (point-min)))
;; Try this, a buffer will jumped out and you will find a lot of characters cannot be displayed correctly.
if [ `id -u` -ne 0 ]; then
echo "This script must be run as root" > /dev/stderr
exit 1
fi
PACKAGE_LIST_SUSE="
ack
acpi
aspell
autoconf
automake
;;確認後再關掉 Emacs 啦
(defun save-buffers-kill-terminal-after-confirm ()
"老是不小心關掉 Emacs,揪咪。"
(interactive)
(if (yes-or-no-p "Really quit Emacs?")
(save-buffers-kill-terminal)
"好極了!"))
(global-unset-key (kbd "C-x C-c"))
(global-set-key (kbd "C-x C-c") 'save-buffers-kill-terminal-after-confirm)