Fomentを読む(7)
一月経ったので続きを。前回はCompileSyntaxRules, ExpandSyntaxRulesのシグネチャを調べたのだった。
- CompileSyntaxRules(FSyntacticEnv se, expr) -> FSyntaxRules
- ExpandSyntaxRules(FSyntacticEnv se, FSyntaxRules sr, expr) -> expr
次は何をすれば良いかなぁ。
- FSyntacticEnvの定義を調べる?
一月経ったので続きを。前回はCompileSyntaxRules, ExpandSyntaxRulesのシグネチャを調べたのだった。
次は何をすれば良いかなぁ。
This blog is implemented with sinatra-activerecord and deployed with Capistrano 3.
Today I needed to add some modification to the DB schema, then I found that DB migration does not works well when I do cap production deploy
.
sinatra-activerecord provides a rake task to run DB migration like rake db:migrate RACK_ENV=production
. Note that the envvar is RACK_ENV, not RAILS_ENV. This does make sense because it is not a gem for Rails. However, you cannot run migration with capistrano-rails by this reason.
So here is my new settings in the config/deploy.rb
. This is mostly the same as what capistrano/rails/migrations does, except the envvar is rack_env
.
Postモデルにpermanentフラグというのを付けた。このフラグが立っていると、URLに日付が入らなくなる。例えば以下。
旧サイトの/w/に置いていたようなものに使う予定。/w/はブログとは別に雑多な記事を置いておくための場所で、最初はHikiというWikiエンジンを使っていたのだけど、そのあと別に他人でも編集できる必要はないなと思ってmiddlemanという静的ページジェネレータに移行した。その結果、自分はブラウザから編集できないと記事を書かなくなるという事実が判明した。
そういうわけで「ブログを作る」といいつつ、CMS的な機能も付けたいと思っていたのだった。 このあとはブログを2カラムレイアウトにして、サイドバーに上記ページへのリンクを入れたい。
Rouge is a syntax highlighting library for Ruby. I've added syntax highlight to this blog, so here's how.
Add gem "rouge"
to your Gemfile.
require 'rouge'
ということで3章から読んでいきます。URL等は第一回を参照してください。
FGJのサンプルプログラムがあります。コメントを足しつつ転記します。
// 2つのオブジェクトの組
class Pair<X extends Object, Y extends Object> extends Object {
X fst; // フィールド定義
新シリーズです。FJ (Featherweight Java)の論文のFGJのところを読んでいきます。 将来的にジェネリクスがある静的型言語を自作したいという目標があるのでその準備です。
型理論の研究のために考案された、Javaの「とても小さい」サブセットです。 論文はこちら。
RSSが壊れていたのを直した。
あと記事一覧画面を作った。いまのところタイトルだけを列挙している状態。一応ページネーションも入れてあるけど、タイトルだけなら当分の間は描画が重くなることもないだろうから、とりあえず100件/ページにしてある。
過去の記事を自分で参照したい場合にも便利(たとえばこの「ブログを作る」シリーズは何番まで書いたっけ、とか)。
While writing a programming language compiled into LLVM IR, I encountered this SEGV of the lli
command:
% lli a.ll
0 libLLVMSupport.dylib 0x00000001071a445d llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 43
1 libLLVMSupport.dylib 0x00000001071a3c79 llvm::sys::RunSignalHandlers() + 44
2 libLLVMSupport.dylib 0x00000001071a48c6 SignalHandler(int) + 165
3 libsystem_platform.dylib 0x00007fff9496452a _sigtramp + 26
4 libsystem_platform.dylib 0x00007fff594141d8 _sigtramp + 3299540168
5 libLLVMSelectionDAG.dylib 0x0000000107065b17 llvm::SelectionDAGBuilder::HandlePHINodesInSuccessorBlocks(llvm::BasicBlock const*) + 391
このブログも記事が増えてきたので、ページネーションを実装した。(そう、今までは http://yhara.jp にアクセスすると全部の記事がレンダリングされる仕様だったのである)
Railsでページネーションといえばkaminari gemであるが、Sinatraにも対応していて、kaminari-sinatraというgemがある。
…のだが、使ってみて困ったことが分かった。paginateヘルパを呼ぶと以下の箇所で「logger.debugは引数を1つしか取らないよ」というエラーが出るのである。
padrino-helpers-0.13.3.2/lib/padrino/rendering.rb in cache_template_path
このブログにKaminariを入れてページネーションをやろうと思ったのだが、gemのバージョンの関係で簡単には入らないことが分かった。
gem 'sinatra-activerecord', git: 'https://github.com/yhara/sinatra-activerecord', branch: 'sinatra2'
でなんとか動かせそう。