Skip to content

Instantly share code, notes, and snippets.

irb(main):001:0> puts ENV['OS']
Windows_NT
We couldn’t find that file to show.
function assert( value, desc ) {
var output = value ? "Pass" : "Fail"
console.log("assert " + output , " => ", desc)
}
assert(1 == "1", "boolean")
assert(1 === "1", "boolean")
.zshrc
# screen で表示する時にタイトルにコマンドを表示する
preexec () {
if [ $TERM = "xterm" ]; then
echo -ne "\ek${1%% *}\e\\"
fi
}
respond_with で個別の処理をしたい場合
respond_with(@user) do |format|
format.html { redirect_to users_url }
end
http://ryandaigle.com/articles/2009/8/10/what-s-new-in-edge-rails-default-restful-rendering
bundle update したら rspec のバージョンがあがってありがたいお言葉をもろた
Thank you for installing rspec-rails-2.0.1!
This version of rspec-rails only works with versions of rails >= 3.0.0
To configure your app to use rspec-rails, add a declaration to your Gemfile.
If you are using Bundler's grouping feature in your Gemfile, be sure to include
rspec-rails in the :development group as well as the :test group so that you
can access its generators and rake tasks.
@sugamasao
sugamasao / mail.rb
Created October 26, 2010 08:02
Rail3 の Mail ライブラリ(mail)で ASCII文字 + JIS 文字がSubjectに入ってると死ぬ
==========
検証
==========
% cat mail.eml
Subject: hoge =?ISO-2022-JP?B?GyRCJUYlOSVIGyhC?=
Content-Type: text/plain; charset=ISO-2022-JP
Content-Transfer-Encoding: 7bit
sample
% rails c
@sugamasao
sugamasao / gist:650527
Created October 28, 2010 02:59
XML を JSのデータ形式に戻す
// 要 jQuery
var to_native = function(type, str) {
if(type === "integer") {
return str-0
} else if(type == "boolean") {
return !!str
} else if(type == "datetime") {
return new Date(Date.parse(str))
}
return str
#!/bin/sh
# カレントディレクトリにある erb ファイルを haml へ変換して old ディレクトリに .erb ファイルを移すワンライナー
# zsh で動作確認済み
# 要 html2haml
for file in `ls`;do;html2haml ${file} ${file%erb}haml;mkdir -p old; mv ${file} old;done
# こっちは old に移さないで消す
# for file in `ls`;do;html2haml ${file} ${file%erb}haml;rm ${file};done
@sugamasao
sugamasao / gist:702692
Created November 16, 2010 23:00
.txt のファイル一覧を取得する
Pathname.glob("/tmp/**/*").select {|path| path.to_s =~ /\.txt\z/}