This file contains hidden or 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
# Load rbindkeys-helper | |
require "path-to-rbindkeys-helper" | |
# Emacs-like settings | |
def define_emacs_keys() | |
bind "C-g", "ESC" | |
# cursor move | |
bind "C-f", "<right>" | |
bind "C-b", "<left>" |
This file contains hidden or 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 my:byte-to-various-units (size-byte) | |
"Display `size-byte' in various units." | |
(interactive "nBytes: ") | |
(let ((size size-byte) | |
(size-kib size-byte)) | |
(with-output-to-temp-buffer "*unit*" | |
(princ (format "%d B\n-----------\n" size-byte)) | |
(dolist (unit '("K" "M" "G" "T" "P")) | |
(setq size (/ size 1000.0)) | |
(setq size-kib (/ size-kib 1024.0)) |
This file contains hidden or 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
#!/usr/bin/env ruby | |
require "rios/easy" | |
# http://ascii-table.com/ansi-escape-sequences.php | |
key_remaps = { | |
"j" => "\e[B", # down | |
"k" => "\e[A", # up | |
"o" => "\r\n", # enter | |
"u" => "\e[D", # left |
This file contains hidden or 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
// Reflect API from xpcshell | |
var Cc = Components.classes; | |
var Ci = Components.interfaces; | |
var Cu = Components.utils; | |
function openFile(aPath) { | |
var file = Cc["@mozilla.org/file/local;1"] | |
.createInstance(Ci.nsILocalFile); | |
file.initWithPath(aPath); |
This file contains hidden or 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 fix-japanese-number-usages () | |
"Fix improper japanese number usages like 1つ and 2つ." | |
(interactive) | |
(require 'japan-util) | |
(require 'cl) | |
(let ((from-regexp "\\([1-9123456789]+\\)[ \n\r\t]*つ") | |
(to-regexp "\\,(replace-digit-to-japanese \\1)つ") | |
(japanese-numbers (list "零" "一" "二" "三" "四" "五" "六" "七" "八" "九" "十"))) | |
(flet ((query-replace-read-from | |
(prompt regexp-flag) |
This file contains hidden or 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
(setq minibuffer-history | |
(mapcar (lambda (history-string) | |
(substring-no-properties history-string)) | |
(remove-if-not #'stringp minibuffer-history))) |
This file contains hidden or 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
function tmux-attach() { | |
# Launching tmux inside a zle widget is not easy | |
# Hence, We delegate the work to the parent zsh | |
BUFFER=" { tmux list-sessions >& /dev/null && tmux attach } || tmux" | |
zle accept-line | |
} | |
zle -N tmux-attach | |
# Define a shortcut key for launching tmux (Ctrl+t) | |
bindkey '^T' tmux-attach |
This file contains hidden or 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
(defadvice magit-blame-file-on (around magit-blame-ignore-whitespace activate) | |
(let ((buffer (ad-get-arg 0))) | |
(save-excursion | |
(with-current-buffer buffer | |
(save-restriction | |
(with-temp-buffer | |
(magit-git-insert (list "blame" | |
"-w" ; ignore coding-style related changes | |
"--porcelain" "--" | |
(file-name-nondirectory |
This file contains hidden or 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
;; Display commit author and datetime in magit-log | |
(setq magit-present-log-line-function 'my:magit-present-log-line) | |
(defface my:magit-log-author | |
'((((class color) (background light)) :foreground "SkyBlue") | |
(((class color) (background dark)) :foreground "SkyBlue")) | |
"Face for the sha1 element of the log output." | |
:group 'magit-faces) |
This file contains hidden or 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
class LazyArray(object): | |
""" | |
Wraps an iterable object and provides lazy array functionality, | |
namely, lazy index access and iteration. Lazily got iteration | |
results are cached and reused to provide consistent view | |
for users. | |
""" | |
def __init__(self, iterable_source): | |
self.source = iterable_source |