Skip to content

Instantly share code, notes, and snippets.

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

クエン酸 kuanyui

❄️
なんでそんなに慣れてんだよ!
View GitHub Profile
;; Enhanced minibuffer & find-file! 加強minibuffer和find-file!
;; 我一直無法忍受helm和ido-mode的find-file設計,但又覺得他們有部份功能
;; 實在很方便,例如能夠按DEL直接刪回上個目錄的路徑,或者整個路徑重新輸
;; 入等。這裡做了幾個符合自己需要的功能:
;; 1. 如果minibuffer中是個目錄的樣式,按M-[DEL]就可以往前刪到parent dir
;; 2. 按一次C-a只是一般的beginning-of-line,但按第二次C-a的話:
;; (a) 如果是個路徑,會把~/或/以後的東西刪掉。
;; (b) 如果不是路徑,則整行刪掉。
;; 3. 以上行為都不會把刪過的東西存到 kill-ring,所以可以放心用力刪,
;; All Languages known to GitHub and their extensions.
;; Source: https://github.com/github/linguist/blob/master/lib/linguist/languages.yml
'(("ABAP" . (".abap"))
("ANTLR" . (".g4"))
("ASP" . (".asp" ".asax" ".ascx" ".ashx" ".asmx" ".aspx" ".axd"))
("ATS" . (".dats" ".atxt" ".hats" ".sats"))
("ActionScript" . (".as"))
("Ada" . (".adb" ".ads"))
("Agda" . (".agda"))
("ApacheConf" . (".apacheconf"))
(defun fsc-split-sentence-to-lists (vOriginal vLineCharNum)
"First arg is an ONE-LINE string as inputed sentence. The
second is 'How many characters in a line', an integer.
For example, when vLineCharNum = 3, Output is:
((\"一\" \"二\" \"三\")
(\"四\" \"五\" \"六\")
...)"
(let* ((vSplittedString (split-string-and-unquote vOriginal ""))
(vStart 0)
vOutput
@kuanyui
kuanyui / vertical-lines.el
Created May 4, 2014 17:29
使用方法: M-x fsc-rotate-text-from-minibuffer 後輸入文字、以及一行幾個字。
(defun fsc-split-sentence-to-lists (vOriginal vLineCharNum)
"First arg is an ONE-LINE string as inputed sentence. The
second is 'How many characters in a vertical line', an integer.
For example, when vLineCharNum = 3, Output is a reversed list."
;; (...
;; (\"四\" \"五\" \"六\")
;; (\"一\" \"二\" \"三\"))
(let* ((vOriginal (fsc-convert-halfwidth-to-fullwidth vOriginal))
(vSplittedString (split-string-and-unquote vOriginal ""))
(vStart 0)
;; loop
(defun frac (n)
(apply #'*
(loop for i from 1 to n
collect i)))
;; dotimes
;; (dotimes (x 5) ...) => 0, 1, 2, 3, 4
(defun frac (n)
(let (fin)
(dotimes (x n)
;; This .el file provide syntax highlighting for ruby tags in Emacs's markdown-mode
(defface markdown-ruby-mark '((((class color) (background light)) (:foreground "#fff" :background "#6c0099"))
(((class color) (background dark)) (:foreground "#6c0099" :background "#d187ff"))) "" :group 'faces)
(defface markdown-ruby-title '((((class color) (background light)) (:foreground "#6c0099"))
(((class color) (background dark)) (:foreground "#d187ff"))) "" :group 'faces)
(defface markdown-ruby-content '((((class color) (background light)) (:foreground "#d187ff"))
(((class color) (background dark)) (:foreground "#8700af"))) "" :group 'faces)
(font-lock-add-keywords 'markdown-mode
'(("\{\\(rb\\)\|.+?\|.+?\}" 1 'markdown-ruby-mark)
/*
footnote.js: A filter for Hexo to generate footnotes. Place this file in /scripts/footnote.js.
========================================================================
Author: kuanyui(azazabc123[at]g~~~m~~~a~~~i~~~l[dot]com)
Date: 20140518
License: WTFPL 1.0
========================================================================
The following string in article
{fn|I'm the a lot lot of content.}
@kuanyui
kuanyui / message-test-mind-before-send.el
Last active August 29, 2015 14:02
避免使用者在神智不清的情況下用message.el幹出無法挽回的蠢事、寄出不該寄的email。有了這個設定,在寄出信件前會先對您施行酒測。
;; 避免使用者在神智不清的情況下用message.el幹出無法挽回的蠢事、寄出不該寄的email
(setq message-confirm-send t)
(defun message-test-mind-before-send ()
(interactive)
(let* ((a (random 50))
(b (random 15))
(ans (+ a b))
(input (string-to-int (read-from-minibuffer (format "%s + %s = " a b)))))
(if (eq input ans)
(message-send-and-exit)
@kuanyui
kuanyui / resize-frame.el
Last active January 25, 2024 05:33
resize-frame.el --- A minor mode to resize frames easily.
;;; resize-frame.el --- A minor mode to resize frames easily. -*- lexical-binding: t; -*-
;; Copyright (C) 2014 kuanyui
;; Author: kuanyui <[email protected]>
;; Keywords: frames, tools, convenience
;; License: WTFPL 1.0
;;; Commentary:
@kuanyui
kuanyui / run-length.lisp
Last active August 29, 2015 14:03
Ugly and dumb solution for fucking run-length homework in PG's ACL.
(defun run-length (input)
(let (l fin)
(mapcar (lambda (x)
(if (null x)
(setq x "nil"))
(cond ((null l)
(setq fin (list (list 1 x)))
(setq l x))
((equal x l)
(setq fin (cons (list (1+ (car (car fin))) x) (cdr fin))))