This file contains 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
;; 2.3.2 test | |
(defun rails-core:current-test-name () | |
(save-excursion | |
(when (search-backward-regexp "^[ ]*test[ ]*\"\\([a-z0-9_ ]+\\)\"" nil t) | |
(format "test_%s" | |
(replace-regexp-in-string " " "_" (match-string-no-properties 1)) | |
)))) | |
(defun rails-test:run-current-method () | |
"Run a test for the current method." |
This file contains 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
# どうせcdした後はlsも打つんでしょ? | |
# => .bashrc などに以下を記述。 | |
function cd() { | |
builtin cd "$@" | |
#ls -lrt | |
ls | |
} |
This file contains 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
# ruby-debug でリモートデバッグ | |
require 'ruby-debug' | |
Debugger.wait_connection = true | |
Debugger.start_remote | |
# これでプログラムを起動すれば待ち受け状態になるので、$rdebug -c とすればサーバーに接続できる |
This file contains 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
MacRuby0.5動かしてみた。めちゃめちゃ速い。 | |
@MacBook Core2Duo 2.2GHz/4MB二次キャッシュ/4GBメモリ/800MHzバス | |
tmaeda-no-macbook:tmp tmaeda$ time ruby -v fib.rb 41 | |
ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin9] | |
165580141 | |
real 3m18.873s | |
user 3m14.033s | |
sys 0m1.499s |
This file contains 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
-- プログラミングHaskell 5章 | |
import Data.Char | |
let2int :: Char -> Int | |
let2int c = ord c - ord 'a' | |
int2let :: Int -> Char | |
int2let n = chr (ord 'a' + n) | |
shift :: Int -> Char -> Char |
This file contains 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
require 'rubygems' | |
require 'active_support' | |
def return_(v) | |
lambda{|input| [[v, input]]} | |
end | |
def failure | |
lambda{|input| []} | |
end |
This file contains 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 -*- | |
# カレントディレクトリに存在するjpgsディレクトリ以下の全てのファイルに | |
# 顔認識を試行して、何らかの顔が検出できたファイルのみを | |
# detectedディレクトリ以下に保存します。 | |
require 'opencv' | |
include OpenCV | |
# 顔検出に使うカスケードをロード | |
detector = CvHaarClassifierCascade::load('/usr/local/share/opencv/haarcascades/haarcascade_frontalface_alt2.xml') |
This file contains 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
require 'win32ole' | |
excel = WIN32OLE.new('Excel.Application') | |
excel.visible = TRUE | |
workbook = excel.Workbooks.Add(); | |
worksheet = workbook.Worksheets(1); | |
worksheet.Range("A1:C1").Name = "hani" | |
worksheet.Range("hani").value = [1,2,3] | |
This file contains 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
bash-3.2$ ruby -v -r yaml -e "" | |
ruby 1.8.7 (2010-12-23 patchlevel 330) [i686-darwin10.6.0] | |
bash-3.2$ ruby -d -v -r yaml -e "" | |
ruby 1.8.7 (2010-12-23 patchlevel 330) [i686-darwin10.6.0] | |
Exception `NoMethodError' at /Users/tmaeda/.rvm/rubies/ruby-1.8.7-p330/lib/ruby/1.8/rational.rb:78 - undefined method `gcd' for Rational(1, 2):Rational | |
bash-3.2$ ruby -d -v -r yaml -e "" | |
ruby 1.9.2p136 (2010-12-25 revision 30365) [x86_64-darwin10.6.0] | |
Exception `NameError' at /Users/tmaeda/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/syck/tag.rb:81 - method `yaml_as' not defined in Module |
This file contains 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
(require 'anything-startup) | |
(defun my-anything-filelist+ () | |
"Preconfigured `anything' to open files/buffers/bookmarks instantly. | |
This is a replacement for `anything-for-files'." | |
(interactive) | |
(anything-other-buffer | |
'(anything-c-source-ffap-line | |
anything-c-source-ffap-guesser |
OlderNewer