ブログをhtml5にする勇気がまだ無い糞野郎です。
Slimのソースを見てみると、!から始まるディレクティブ?にはdoctypeしか無いように見える。とりあえずこんな感じでしのいでいるが・・・。
% slimrb
| <?xml version="1.0" encoding="utf-8" ?>
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?xml version="1.0" encoding="utf-8" ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
きんもー!
$ curl -o latest.dump `heroku pgbackups:url`
所謂上記で取れるdumpファイルはPostgreSQLマニュアルで言うところの”非プレインテキスト形式のアーカイブ”なのでpg_restoreじゃないとリストア出来ない。不便に思うけど、pgbackupsというサービスを作る事を考えたら柔軟なデータ形式よりも、同じDBだったらroleとか全て取りこぼし無く復旧してくれそうな形式になっているのは納得出来る話だ。(ちょこっとcommentsテーブルだけ取りたいなんて今回の自分の用途にとってはうざいが・・・)
$ pg_restore -d foo foo.dump
roleは違うけどデータは取れた。
$ heroku pgbackups:capture --expire
個数制限があるのでこれで古いのを消しつつ新しいのをバックアップしてくれる。楽だなあ。
Webサーバーを立ち上げつつブラウザを開く簡単な方法は無いだろうか?
要はRailsで言えばこんな感じのことがやりたい。
#!/bin/sh
rails s
open http://localhost:3000/
Webサーバーは立ち上がりっぱなしなのでopenは走らない。バックグラウンドにしてもWebサーバーの起動には多少(1秒ぐらい)時間が掛かるのでopenもちょっとした待ち合わせをしなくちゃいけない。
(゚Д゚ )アラヤダ!!っていう簡単な解決方法がある気がするんだけど思いつかない・・・。
$ brew install postgresql
$ initdb /Users/komagata/homebrew/var/postgres
$ cp /Users/komagata/homebrew/Cellar/postgresql/9.0.2/org.postgresql.postgres.plist ~/Library/LaunchAgents
$ launchctl load -w ~/Library/LaunchAgents/org.postgresql.postgres.plist
起動。
$ pg_ctl -D /Users/komagata/homebrew/var/postgres -l /Users/komagata/homebrew/var/postgres/server.log start
終了。
$ pg_ctl -D /Users/komagata/homebrew/var/postgres stop -s -m fast
滅多に使わないので立ち上がらないようにunloadしておく。
$ launchctl unload -w ~/Library/LaunchAgents/org.postgresql.postgres.plist
% psql -l
List of databases
Name | Owner | Encoding | Collation | Ctype | Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
postgres | komagata | UTF8 | ja_JP.UTF-8 | ja_JP.UTF-8 |
template0 | komagata | UTF8 | ja_JP.UTF-8 | ja_JP.UTF-8 | =c/komagata +
| | | | | komagata=CTc/komagata
template1 | komagata | UTF8 | ja_JP.UTF-8 | ja_JP.UTF-8 | =c/komagata +
| | | | | komagata=CTc/komagata
(3 rows)
昔はなかったAccess privilegesなんて表示が追加されてる。CTcってのはどういう意味だろう。Capture The Flag?
% vagrant up
Vagrant has detected that you have VirtualBox version 3.2.12 installed!
Vagrant requires that you use at least VirtualBox version 4.0. Please install
a more recent version of VirtualBox to continue.
The Vagrant 0.6.x series supports VirtualBox 3.2, so if you're stuck with that
version, then please use the 0.6.x series of Vagrant.
Any earlier versions of VirtualBox are completely unsupported. Please upgrade.
VirtualBox 3.2系から4系へは自動アップデートが行われないので手動でアップデートする必要がある。忌々しい東京三菱UFJ銀行(法人版)とIE6の為に確保してあるWindows XP無印はアップデートしても問題無く動きました。
必要になるたびにググってる気がするので。
require 'webrick'
include WEBrick
class HelloServlet < HTTPServlet::AbstractServlet
def do_GET(req, res)
res['Content-Type'] = 'text/plain'
res.body = 'hello'
end
end
s = HTTPServer.new(:Port => 8080)
s.mount('/', HelloServlet)
trap(:INT){ s.shutdown }
s.start
:Portが大文字なところが注意。