/Library/LaunchDaemons以下とかにあるplistを手で編集するのって、

「嫌だな〜 怖いなあ〜 怖いなあ〜 怖いなあ〜」

って思ってたんですが、Lingonは開発止まってるらしいし、launchdに限らず、そもそもplistの標準エディタとか無いのかなと思ってTwitterで呟いたら@kyannyさんに教えて貰いました。

Property List Editorっていうのが最初からユーティリティの中に入ってるんですね・・・。(Spotlightで"pro"とか入れたら出てくる)

(launchdのpostfixのplist)

実際には結局viで編集しちゃってるんですが標準エディタがあることで何か安心しました。

JavascriptのInflectionライブラリ。

<html>
<head>
<title>Inflection</title>
<script src="../js/inflection.js" type="text/javascript"></script>
</head>
<body>
<script type="text/javascript">
document.write('<p>'+'project'.pluralize()+'<p>')
document.write('<p>'+'project'.pluralize().singularize()+'<p>')
</script>
</body>
</html>

Inflection

便利。

デモ:Inflection

参照:inflection-js - Project Hosting on Google Code

jquery.unk.jsプラグイン。

(function($){
$.fn.unk = function() {
$(this).text('unk')
return $(this) // 一応Chain出来るようにしとく
}
})(jQuery)
<html>
<head>
<title>jQuery Plugin Sample</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
<script src="jquery.unk.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
$('body').unk()
})
</script>
</head>
<body>
</body>
</html>

結構簡単に書けちゃうんだね。仕方ないね・・・。

jQuery Plugin Sample

デモ:jQuery Plugin Sample

komagata_s help-me-hackers at master - GitHub

君達は一体何を望んでいる?

更なるcommitを望むか?

情け容赦のない糞の様なmergeを望むか?

鉄風雷火の限りを尽くし三千世界の鴉を殺す嵐の様なrebaseを望むか?

『git! git! git!』

よろしい ならばgithubだ

「今度のプロジェクトは"あの機能"の実装がキモだなー。難しそう・・・」

「このバグがどうしても治らん・・・」

というのをとりあえずHelp me, hackers!に書いといたらマジでそっこう(7時間ぐらい)で解決した・・・。

なんぞこれ。なんでこんなにありがたいことが起こるのか、考えてみた。

仮想開発部

Aはプログラマー。今回のプロジェクトはJavascriptでのリッチなUI実装がキモだ。しかしAはクライアントサイドプログラムには明るくない。

A:「ここでこのイベントが取れれば・・・。あれ?ここでのthisは一体何を指しているんだ?」

BはAの隣の席のプログラマー。Aのプロジェクトは佳境を迎えているがBは別のプロジェクトが終わったばかりで暇だ。

B:(ちょうど未読RSSが無くなったところだしAをひやかすか)

B:「Aさんどうすか、JS。」

A:「キモイ。Java書きたいよ。thisがthisじゃないんだよ。どういうこと、これ?」

B:「ッハハ。大変っすねー。ちょwww、AさんFirefoxのAddon入れ過ぎじゃないすかwww」

CはAの向かいの席のプログラマー。Javaのプロジェクトに参加中。AやBとはあまり親しくは無い。

C:(向かいの席がうるさくて集中できん。どうせベタベタなJava風クラスを書いてるんだろ。JQueryのClickイベントハンドラ内だったらthisはそのボタンだろ。ボケが!)

Dはプログラマー。新人だがJavascriptは学生時代から書き慣れている。

D:(勉強のためにAさんのプロジェクトをチェックアウトして見てみたけどこれはひどいwww。冗長でソースの見通しが悪すぎる。136行目、これ動かないだろう、常識的に考えて・・・)

D:(まあ僕には関係無いから黙っとこう。下手なこと言ってあのデスマプロジェクトに入れられたらたまらないからな。)

隣の席のプログラマーが超いっぱいいる状態

通常、隣の席のプログラマーは数人しかいない。しかし、ネットにタスクがアップされていると沢山の人が冷やかしにくる。

タスクをアップした本人は自分の責任であるコードがバグってて本当に困っているんだけど、見に来る人にとっては、直らなくてもまったく困らない。ちょっと覗いてみて、もしなおっちゃったらラッキーぐらい。

なおらなくても、「ハハー、たいへんだねぇ〜」程度。

友人や同僚で「それわかるかもしれないので僕もちょっと見てみますね」といって問題を解決してくれる人がいるでしょう?そういう隣の席のひやかし同僚が超いっぱいいる状態になってるから1日もたたずに問題が解決されるんじゃないだろうか。

Heroku用Redmine簡単セットをforkしときました。バージョンは0.9.6で日本語用の初期データが入っている状態です。

% sudo gem install heroku rails -v=2.3.5 sqlite3-ruby taps
% git clone git://github.com/komagata/redmine.git -b 0.9.6-for-heroku
% cd redmine
% heroku create issues-fjord
% heroku db:push
% git push heroku 0.9.6-for-heroku:master

Redmine on Heroku

admin / adminで入れます。

やっていることはこちらを参考にしただけなので下記を見て自分でやっても同じです。

参照:Herokuでredmineを動作させる。 - コンピュータわ難しくて分からない!!

複数タブを閉じるときに警告を出す

あっさり解決しちゃうんだね。仕方ないね・・・。

解決しねえ!C-qで終わる!

locale_railsの最新は2.0.5。rails2.3.8には対応してない。

でもgithubの先っちょは対応してるのでbundlerの場合はGemfileに下記のように書けばいい。

gem 'locale_rails', '2.0.6', :git => 'git://github.com/mutoh/locale_rails.git'

2.0.6なんて無いのに何故動くんだろう?

vendor/bundle/bundler/gems/locale_rails-xxxxxxxxx-masterの下に入ってるので、submoduleとして扱ってるのかも。gemspecは何処にも無いのでgemを作ってる訳ではなさそう。

普通のRoute

ActionController::Routing::Routes.draw do |map|
map.resources :tasks
end
% rake routes
tasks GET /tasks(.:format) {:action=>"index", :controller=>"tasks"}
POST /tasks(.:format) {:action=>"create", :controller=>"tasks"}
new_task GET /tasks/new(.:format) {:action=>"new", :controller=>"tasks"}
edit_task GET /tasks/:id/edit(.:format) {:action=>"edit", :controller=>"tasks"}
task GET /tasks/:id(.:format) {:action=>"show", :controller=>"tasks"}
PUT /tasks/:id(.:format) {:action=>"update", :controller=>"tasks"}
DELETE /tasks/:id(.:format) {:action=>"destroy", :controller=>"tasks"}

APIの場合、newとeditのページは要らないので絞る。

ActionController::Routing::Routes.draw do |map|
map.resources :tasks, :except => [:new, :edit]
end
% rake routes
tasks GET /tasks(.:format) {:action=>"index", :controller=>"tasks"}
POST /tasks(.:format) {:action=>"create", :controller=>"tasks"}
task GET /tasks/:id(.:format) {:action=>"show", :controller=>"tasks"}
PUT /tasks/:id(.:format) {:action=>"update", :controller=>"tasks"}
DELETE /tasks/:id(.:format) {:action=>"destroy", :controller=>"tasks"}

NESTしたRouteでも絞ろうとすると、

ActionController::Routing::Routes.draw do |map|
map.resources :project, :has_many => :tasks, :except => [:new, :edit]
end
% rake routes
project_tasks GET /project/:project_id/tasks(.:format) {:action=>"index", :controller=>"tasks"}
POST /project/:project_id/tasks(.:format) {:action=>"create", :controller=>"tasks"}
new_project_task GET /project/:project_id/tasks/new(.:format) {:action=>"new", :controller=>"tasks"}
edit_project_task GET /project/:project_id/tasks/:id/edit(.:format) {:action=>"edit", :controller=>"tasks"}
project_task GET /project/:project_id/tasks/:id(.:format) {:action=>"show", :controller=>"tasks"}
PUT /project/:project_id/tasks/:id(.:format) {:action=>"update", :controller=>"tasks"}
DELETE /project/:project_id/tasks/:id(.:format) {:action=>"destroy", :controller=>"tasks"}
project_index GET /project(.:format) {:action=>"index", :controller=>"project"}
POST /project(.:format) {:action=>"create", :controller=>"project"}
project GET /project/:id(.:format) {:action=>"show", :controller=>"project"}
PUT /project/:id(.:format) {:action=>"update", :controller=>"project"}
DELETE /project/:id(.:format) {:action=>"destroy", :controller=>"project"}

projectの方しか絞れない。

こっちの書き方なら両方絞れる。

ActionController::Routing::Routes.draw do |map|
map.resources :projects, :except => [:new, :edit] do |project|
project.resources :tasks, :except => [:new, :edit]
end
end
% rake routes
project_tasks GET /projects/:project_id/tasks(.:format) {:action=>"index", :controller=>"tasks"}
POST /projects/:project_id/tasks(.:format) {:action=>"create", :controller=>"tasks"}
project_task GET /projects/:project_id/tasks/:id(.:format) {:action=>"show", :controller=>"tasks"}
PUT /projects/:project_id/tasks/:id(.:format) {:action=>"update", :controller=>"tasks"}
DELETE /projects/:project_id/tasks/:id(.:format) {:action=>"destroy", :controller=>"tasks"}
projects GET /projects(.:format) {:action=>"index", :controller=>"projects"}
POST /projects(.:format) {:action=>"create", :controller=>"projects"}
project GET /projects/:id(.:format) {:action=>"show", :controller=>"projects"}
PUT /projects/:id(.:format) {:action=>"update", :controller=>"projects"}
DELETE /projects/:id(.:format) {:action=>"destroy", :controller=>"projects"}

スッキリ!