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
;; 句読点変換(M-x tenmaru / M-x commamaru / M-x commaperiod) | |
;; http://d.hatena.ne.jp/takehikom/20120713/1342122621 | |
(defun replace-punctuation (a1 a2 b1 b2) | |
"Replace periods and commas" | |
(let ((s1 (if mark-active "選択領域" "バッファ全体")) | |
(s2 (concat a2 b2)) | |
(b (if mark-active (region-beginning) (point-min))) | |
(e (if mark-active (region-end) (point-max)))) | |
(if (y-or-n-p (concat s1 "の句読点を「" s2 "」にしますがよろしいですか?")) | |
(progn |
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 | |
# -*- coding: utf-8 -*- | |
class StringAndHash | |
def initialize(s, h) | |
@string = s | |
@hash = h | |
@length_zero = (/^0+/ =~ @hash) ? $&.length : 0 | |
end |
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 now() { | |
case ${1:-_} in | |
-h*|--h*) # now --help | |
echo usage: now '[date|httpdate|rfc2822|iso8601]' ;; | |
d*) # now date | |
LC_ALL=C date ;; | |
h*) # now httpdate | |
ruby -e 'require "time"; puts Time.now.httpdate' ;; | |
i*|x*) # now iso8601, now xmlschema | |
ruby -e 'require "time"; puts Time.now.iso8601'\(${2:-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 | |
# -*- coding: utf-8 -*- | |
# cpuinfo.rb : get processor name, number of processors and clock speed | |
# using Win32OLE | |
require "win32ole" | |
wmi = WIN32OLE.connect("winmgmts://") | |
query = wmi.ExecQuery("select * from Win32_Processor") |
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 | |
# -*- coding: utf-8 -*- | |
# Numerical Character References | |
if RUBY_VERSION < "1.9" | |
$KCODE = "u" | |
class String | |
def ord |
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 | |
# -*- coding: utf-8 -*- | |
# When you execute this Ruby script, | |
# two SVG files "tri3a.svg" and "tri3b.svg" will be generated. | |
# Those files show a tripartition of an equilateral triangle, | |
# and you can make sure it by SVG-readable browsers (Firefox), | |
# SVG drawers (Inkscape), or even text editors (Emacs). | |
class Point |
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/ruby -Ku | |
# -*- coding: utf-8 -*- | |
# commit-email.rb for Ruby 1.9/1.8 | |
# http://d.hatena.ne.jp/takehikom/20121111/1352572653 | |
require "rubygems" | |
require "mail-iso-2022-jp" # gem install mail-iso-2022-jp | |
require "kconv" |
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 match-paren-japanese (arg) | |
"Go to the matching parenthesis." | |
(interactive "p") | |
(cond ((looking-at "[([{({[「『《〔【〈]") (forward-sexp 1) (backward-char)) | |
((looking-at "[])}){]」』》〕】〉]") (forward-char) (backward-sexp 1)) | |
(t (message "match-paren-japanese ignored")))) | |
(global-set-key [f5] 'match-paren-japanese) | |
;; 対応するカッコまでをコピー |
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
;; 領域を選択して M-x url-quote-region-utf8 で," => URLエンコード文字列" を | |
;; 挿入します.UTF-8 でエンコードします. | |
;; また直後に C-x C-x や C-w などとすると,URLエンコード文字列に対する | |
;; 領域処理となります. | |
;; Thanks: https://gist.github.com/436913 | |
;; もし (load "htmlutils") をしていなければ | |
;; 以下のコメントを外してください. | |
;(defun url-escape-point (c) |
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 | |
# -*- coding: utf-8 -*- | |
# grid-explorer.rb : Solver of Grid Search Problems | |
# by takehikom (http://d.hatena.ne.jp/takehikom/) | |
if RUBY_VERSION < "1.9" | |
$KCODE = "u" | |
end |