patch from working tree in git repository
# create patch $ git diff --no-prefix > topic-name.patch # confirm $ patch --dry-run -p0 < topic-name.patch # exec $ patch -p0 < topic-name.patch
build tmux from source
Tmux's version in apt is 1.1. (latest is 1.6)
So I built from source. There are some troublesome jobs. (needed libevent etc)
This is memo of at that time.
# install libevent $wget "http://downloads.sourceforge.net/project/levent/libevent/libevent-2.0/libevent-2.0.19-stable.tar.gz" $ tar zxvf libevent-2.0.19-stable.tar.gz $ cd libevent-2.0.19-stable $ if [ ! -d /opt/libevent ]; then sudo mkdir -p /opt/libevent; fi $ ./configure --prefix=/opt/libevent $ make -j8 $ sudo make install $ sudo unlink /usr/lib/libevent-2.0.so.5 $ sudo ln -s /opt/libevent/lib/libevent-2.0.so.5.1.7 /usr/lib/libevent-2.0.so.5 # install ncurses $ apt-get install libncurses5 $ apt-get install libncurses5-deb # install tmux $ wget "http://downloads.sourceforge.net/project/tmux/tmux/tmux-1.6/tmux-1.6.tar.gz" $ tar zxvf tmux-1.6.tar.gz $ cd tmux-1.6/ $ DIR="/opt/libevent/" $ if [ ! -d /opt/tmux1.6 ]; then sudo mkdir -p /opt/tmux1.6; fi $ ./configure CFLAGS="-I$DIR/include" LDFLAGS="-L$DIR/lib" --prefix=/opt/tmux1.6 $ make -j8 $ sudo make install
let vs instance variables in RSpec
merit of "let"
1. When you refactor from local variables into a "let", you should not add @ to variables prefix.
2. "let" is subjective.
3. "let" is lower cost than initialize instance methods by each. e.g. before(:each) { @foo = "foo" }.
Maybe instance variables is useful when you shouldn't save cost.
sample
# let context 'foo' do let(:bar) { :bar } it { bar.should eq(:bar) } end # instance variables context 'foo' do before do @user.role = Role.new(:role => :admin) end it { @bar.should eq(:bar) } end
3 things newly learned about tmux
[command] breake-pane
cut off target-pane from window including it, then make target-pane be single pane in new window.
[command] display-panes
show indicator in panes in current window (but, i don't know when needed)
[option] -r option in bind
this option enable to repeat
Presenter in Rails
My first idea.
I feel this is a waste of method_missing.
# app/model/application_model.rb class ApplicationModel < ActiveRecord::Base self.abstract_class = true def method_missing(name, *args, &block) begin klass = eval "#{self.class.to_s}Presenter" presenter = klass.new(self) method_name = name.to_s presenter.send(method_name) rescue super end end end # app/models/user.rb class User < ApplicationModel # ... end # app/presenters/user_presenter.rb class UserPresenter # ... end
My second idea.
This is more simple than first idea.
# app/models/user.rb class User < ActiveRecord::Base # ... include PostPresenter end # app/presenters/post_presenter.rb module PostPresenter # instanse methods module ClassMethods # class methods end def self.included(mod) mod.extend ClassMethods end end
hmm...
I am looking for better idea than these.