Skip to content

Instantly share code, notes, and snippets.

@ongaeshi
ongaeshi / save-frame-size.el
Created March 11, 2011 02:03
終了時のフレームサイズを記憶する
;;--------------------------------------------------------------------------
;; 終了時のフレームサイズを記憶する
;; http://www.bookshelf.jp/soft/meadow_30.html#SEC419
;;--------------------------------------------------------------------------
(defun my-window-size-save ()
(let* ((rlist (frame-parameters (selected-frame)))
(ilist initial-frame-alist)
(nCHeight (frame-height))
(nCWidth (frame-width))
(tMargin (if (integerp (cdr (assoc 'top rlist)))
@ongaeshi
ongaeshi / install.rdf
Created March 11, 2011 13:57
自作のFirefoxアドオンが4.0になったらまた動かなくなった
addon-sdk-1.0b1/python-lib/cuddlefish/app-extension/install.rdf が原因
<!-- Firefox -->
<em:targetApplication>
<Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>3.6</em:minVersion>
<em:maxVersion>4.0.*</em:maxVersion>
</Description>
</em:targetApplication>
@ongaeshi
ongaeshi / recentf.el
Created March 16, 2011 01:59
recentf設定 自動セーブ付き
;;--------------------------------------------------------------------------
;; recentf-exte.el
;; (install-elisp-from-emacswiki "recentf-ext.el")
;;--------------------------------------------------------------------------
(when (require 'recentf-ext nil t)
(setq recentf-max-saved-items 2000)
(setq recentf-exclude '(".recentf"))
(setq recentf-auto-cleanup 10)
(setq recentf-auto-save-timer (run-with-idle-timer 30 t 'recentf-save-list))
(recentf-mode 1))
@ongaeshi
ongaeshi / unzip.rb
Created March 16, 2011 08:26
rubyでunzipを実現するスクリプト
# -*- coding: utf-8 -*-
#
# gem install archive-zip
#
require 'rubygems'
require 'archive/zip'
zip = ARGV[0]
dst = File.basename ARGV[0], '.zip'
@ongaeshi
ongaeshi / meadow3-encode.el
Created March 17, 2011 00:32
UTF-8の「〜」(U+FF5E)と「〜」(U+301C) http://gaju.jp/diary/20091218.html
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; UTF-8の「〜」(U+FF5E)と「〜」(U+301C)
;; http://gaju.jp/diary/20091218.html
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defadvice utf-translate-cjk-load-tables (after my-subst-windows activate)
(mapc
(lambda (pair)
(let ((uc (car pair))
(ch (cadr pair)))
(puthash uc ch ucs-unicode-to-mule-cjk)
@ongaeshi
ongaeshi / .irbrc
Created March 17, 2011 07:26
.irbrc
#
# setup
#
require 'rubygems'
require 'rubywho'
require 'irb/completion'
require 'irb/ext/save-history'
ARGV.concat [ "--readline", "--prompt-mode", "simple" ]
@ongaeshi
ongaeshi / shell-command-prev.el
Created March 17, 2011 13:56
直前に実行したシェルコマンドを実行
(defun shell-command-prev ()
(interactive)
(shell-command (car shell-command-history) nil nil))
(global-set-key (kbd "C-c C-c") 'shell-command-prev)
@ongaeshi
ongaeshi / j2-tab-setting.el
Created April 16, 2011 04:28
スペースではなくタブでインデントタブ幅4の場合のjs2-modeでのタブ設定
; スペースではなくタブでインデント
; タブ幅4
;
; の場合のjs2-modeでのタブ設定
(setq tab-width 4
espresso-indent-level 4
indent-tabs-mode t
c-basic-offset 4)
@ongaeshi
ongaeshi / redirect.textile
Created April 18, 2011 10:38
DOSプロンプトから、標準出力もエラー出力もまとめてリダイレクトする方法

DOSの場合

標準出力をsystem.logにリダイレクト

command > system.log

標準出力と標準エラー出力をまとめてsystem.logにリダイレクト

command > system.log 2>&1

Unixの場合

@ongaeshi
ongaeshi / gist:928607
Created April 19, 2011 16:06
ruby md5 calc oneliner
$ ruby -r'digest/md5' -e 'puts Digest::MD5.hexdigest("example@example.com")'
23463b99b62a72f26ed677cc556c44e8
# ex. gravatar
# http://ja.gravatar.com/site/implement/hash/
<img src="http://www.gravatar.com/avatar/23463b99b62a72f26ed677cc556c44e8" />