blog.sowatchasayin

Rails etc.

Sync crontab and Rails with Capistrano

1. Put `crontab -l` into a file and add it into your repository
2. Add lines below to your config/deploy.rb



that's all. crontab on production server will be refreshed after every deployment.

新しいの5個だけ残してあとは消す

Rubyで書こうとしましたが、間違いでした。
Unixすばらしい。

rails + passengerでbasic認証

こんな感じでを追加してあげればOK。
LocationディレクティブはDirectoryディレクティブとは違ってウェブ空間に対する設定を行うので、/adminとか相対URLで指定できると。


<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName xx.xxx.xxx.xxx
ServerAlias xx.xxx.xxx.xxx
DocumentRoot /var/www/myapp/current/public
<Directory /var/www/myapp/current/public>
Options FollowSymLinks -MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
<Location /admin>
AuthUserFile /home/somebody/.htpasswd
AuthGroupFile /dev/null
AuthName "Please enter your ID and password"
AuthType Basic
require valid-user
</Location>
</VirtualHost>


.htpasswdの場所はホームディレクトリ以外がいいような…。

こちらを参考にしました!
Slicehost Forum - Passenger and htaccess, multiple login prompts

カレントディレクトリの*.erbを*.hamlに変換

Hamlいいですねー 楽です。キモ綺麗。
Hamlが動けばZen Codingいらず。

Haml同梱のhtml2hamlってコマンドでerbをhamlにできるのですが、ディレクトリ内一括でやっちゃたいのでちょっと工夫しました。
備忘もかねて投稿。

ruby -e "Dir.glob('*.erb'){|erb|system \"html2haml #{erb} #{erb.sub('erb', 'haml')}\"}" 

ただ、erb.html.erbとかいうファイル名があったらおかしくなっちゃいます。

「開発者のキャリアプラン」は会社にとって損なだけ?

「アーキテクト」や「マネジメント」を目指すべきとされるキャリアプランに対して「ただいいものを作りたい」って答えると…上司が嫌な顔をする。そんなの無視するか、じゃなきゃ辞めちまえ、という反論に対して…

and this takes me to my second point - does this actually damage the organisation because people start leaving or, worse, playing political games, feeling stressed or distracted by the things they have to do in order to live up to the career structure

そう、誰かが辞めることは会社とって損害だと。

Weblogs Forum - Do Career Plans for Developers Actually Damage an Organisation?

Enumerable.all?は空だと常にtrueを返す

ううむ…空集合の全てって一体何だ?

irb(main):001:0> [].all?{false}
=> true
irb(main):002:0> [1].all?{false}
=> false


そして、安易なソリューション。

class Array
def not_empty_and_all?(&block)
return false if self.empty?
self.all? &block
end
end


Enumerable - Rubyリファレンスマニュアル

Author

Fujimura Daisuke
http://fujimuradaisuke.com

Labels