difining stub raise IO::WaitReadable Exception

# in RSpec
socket.stub(:recv_nonblock).and_raise(IO::WaitReadable)

Error(IO::WaitReadable don't have method initialize)

Failure/Error: instance.handle_request(socket)
     NameError:
       undefined method `initialize' for module `IO::WaitReadable'

solution

IO::WaitReadable is extended to exception object.
c.f. module IO::WaitReadable (japanese)

socket.stub(:recv_nonblock).and_raise(StandardError.new.extend(IO::WaitReadable))

add struct(CGPoint, CGSize etc) for NSArray Value in Objective-C

CGPoint p1 = CGPointZero;
CGPoint p2 = CGPointZero;
CGPoint p3 = CGPointZero;
CGPoint p4 = CGPointZero;

NSArray *ary = @[
    [NSValue valueWithBytes:&p1 objCType:@encode(struct CGPoint)],
    [NSValue valueWithBytes:&p2 objCType:@encode(struct CGPoint)],
    [NSValue valueWithBytes:&p3 objCType:@encode(struct CGPoint)],
    [NSValue valueWithBytes:&p4 objCType:@encode(struct CGPoint)]
];

(addition) [NSArray of struct wraped NSValue] to [CArray of struct].

CGPoint cAry[ [ary count] ];
CGPoint p;
int i = 0;
for (id wrapedItem in ary) {
    [wrapedItem getValue:&p];
    cAry[i++] = p;
}

use emacs keybind in vim comand line mode

" ~/.vimrc
cnoremap <C-A> <Home>
cnoremap <C-E> <End>
cnoremap <C-F> <Right>
cnoremap <C-B> <Left>
cnoremap <C-P> <UP>
cnoremap <C-N> <Down>
" add at 2012/10/4 (from http://vim.g.hatena.ne.jp/tyru/20100116)
cnoremap <C-k> <C-\>e getcmdpos() == 1 ? '' : getcmdline()[:getcmdpos()-2]<CR>