文字列の配列から正規表現にマッチする部分を抜き出す
Enumerable
1 Dir["config/environments/ *.rb"].grep(%r{(\w+)\.rb$}){$1} 2 #=> ["developmen t", "production ", "rake", "staging", "test"]
痒いところに手が届く感じですね。
Enumerable
1 Dir["config/environments/ *.rb"].grep(%r{(\w+)\.rb$}){$1} 2 #=> ["developmen t", "production ", "rake", "staging", "test"]
痒いところに手が届く感じですね。
Sassを使うようになって、属性とタグの区別がつきにくいなと感じていたので、シンタックスハイライトをする方法を探してみました。
これを使うと、こんな感じになります。
だいぶ見やすくなりました。
例えばJavaScript
1 [0x3000].pack("U") == " " #=> true
長い事迂回していた問題だったのでスッキリしました :-)
Special Thanks
Hello, Merbists!
Today, I explain how to develop Merb apps that runs on GAE/J environmen
First of all, here is whole source code of an example app. Please check it out.
After checking it out,
you must edit appengine-
1 MERB_ROOT%jruby -S warble war
It generates files under tmp/war.
So far, you are ready to deploy this app to GAE/J Of course, you need an account of GAE/J to do it. Please get it in advance :-)
Let us go to deploy by this command.
1 MERB_ROOT%appcfg.sh update -e {youraccoun t@gmail.com} tmp/war
This process takes a time for the first time. If the log didn't say any errors, you got success!
Now your first Merb app on GAE/J is here at
http://{your app name}.appspot.c
Congrats!
Further improvemen
APPENDIX
All required gems are being packed into jar file located at lib/merb.j
Enjoy!
Cloud Computingに関する文献をメモしておきます。
Rails勉強会#40のセッションでも言いましたが、 エラーが発生した時等に表示されるbacktraceの表示は、 コンソールのように上から下に流れる画面上では 通常の逆順のほうが追いやすいと思います。
ということで、ちょっと試しにそのような挙動にしてみました。 以下のようなコードを実行するとテストできます。
1 class Exception 2 def set_backtrace(bt) 3 puts bt.reverse.map{|i| 4 i.sub(/^([\/\.\w]+):(\d+)/, 5 "\e[33m\\1\e[m:\e[32m\\2\e[m") 6 }.join("\n") 7 end 8 end 9 10 def foo 11 raise StandardEr ror 12 end 13 14 def bar 15 foo 16 end 17 18 bar
こんな感じに、エラーが発生した場所に近い順に、 下から上にたどっていく感じに表示されます。
上から下のbacktraceに目が慣れてしまっているので、最初は追いかけにくさを感じますが、一旦慣れてしまえば、スタックが深くて相当スクロールアップしなければエラーの発生源までたどり着けないという場合には良さそうな気がします。
stackという概念のイメージのせいで、新しいものが上の方に来るようになっているのだと思いますが、実用上は新しいものが下にくるこのスタイルの方が便利ではないでしょうか。
情報系学生必須(?)のTeX環境をWindowsにインストールします。
これで、論文・レポートなど、ばっちりです!
ここでは、WindowsでのTeX環境のほかに、エディタのEmacsやtex-modeのYaTeXを導入します。
Vi派の人は今すぐこのページを閉じましょう。
阿部 紀行さん作のTeXインストーラを使いましょう。
ここからダウンロードできます。
解凍するとインストーラが出てくるので、適当にインストールしましょう。
Windowsで使えるEmacsはいくつかありますが、ここではNTEmacsを使います。
ここから適当にダウンロードして、インストールします。
Vistaの場合は、
1 C:\Users\(ユーザ名)\AppData\Roaming
の下にあるものが読み込まれるようです。 なければ作りましょう。
誰か教えてください!
YaTeXとは、Yet AnotherなEmacsのtex-modeです。
Yet Another LaTeX mode for Emacs.からダウンロードしましょう。
ダウンロードしたら解凍し、.emacs.dあたりにyatexという名前で放り込んでおきましょう。
Yet Another tex-mode for Emacs - 野鳥起動のための設定を参考にします。
.emacsに以下のものをコピー&ペースト
1 ;; 2 ;; YaTeX 3 ;; 4 (setq auto-mode-alist 5 (cons (cons "\\.tex$" 'yatex-mode ) auto-mode- alist)) 6 (autoload 'yatex-mode "yatex" "Yet Another LaTeX mode" t) 7 (setq load-path (cons (expand-fil e-name "~/.emacs.d /yatex/") load-path))
これで設定は終わりです。
使い方は、YaTeXのドキュメントを参考のこと・・・。
この環境が手に入ったら、ついでにOMakeを導入してみてはどうでしょうか?
JRubyで相対パスを含む場合に、Jarファイルの中のファイルを読めるようにするためのモンキーパッチの最新版です。
1 def cleanup_path(path) 2 if path.to_s.match(/^file:/) && path.is_a?(String) 3 jar_path, inner_path = path.split('!', 2) 4 inner_path = File.expand_pat h(inner_path ) 5 path = [jar_path, inner_path ].join('!') 6 end 7 path 8 end 9 10 alias :require_or iginal :require 11 def require(path) 12 require_or iginal cleanup_pa th(path) 13 rescue Exception => e 14 raise e unless path.to_s.match(/^file:/) 15 end 16 17 alias :load_origi nal :load 18 def load(path) 19 load_origi nal cleanup_pa th(path) 20 rescue Exception => e 21 raise e unless path.to_s.match(/^file:/) 22 end 23 24 class Dir 25 class << self 26 alias :aref_origi nal :[] 27 def [](*args) 28 aref_origi nal *(args.map{|path| cleanup_pa th(path)}) 29 end 30 end 31 end 32 class File 33 class << self 34 alias :mtime_orig inal :mtime 35 def mtime(path) 36 if path.match(/^file:/) 37 jar_file, = path.split('!', 2) 38 path = jar_file.sub(/^file:/, '') 39 end 40 mtime_orig inal(path) 41 end 42 end 43 end
Merbでconfig/rou
1 resource :users, 2 :collection=> {:active => :get}, 3 :member => {:password => :get}
:collectio
:memberで指定したアクションは、resource(@user, :password) などのように参照できて、"/users/1/p
アプリをリリースするとき、日付はとても大事です。
(プレスリリースなどに関係するし)
Shopping Pinkをリリースしようとした際、iTunes ConnectにあるAvailabili
その国のローカル時間でStoreに出される(ようだ)
Availabili