Skip to content

Instantly share code, notes, and snippets.

@arunbear
arunbear / .vimrc
Last active April 27, 2025 12:07
Selecting a whole method in Vim (Java)
" Select the current method
"
" ]M move to the end of the method
" V enter visual line mode
" % move to the matching open brace
"
nnoremap <leader>m ]MV%
" Copy the current method and paste below
" Use this after the above
@arunbear
arunbear / lvalue.pl
Created December 26, 2020 16:39
lvalue methods in Perl
pirl @> sub hats : lvalue { my ($self) = @_; $self->{hats}; }
@var = ();
pirl @> $obj = bless {}
@var = (
bless( {}, 'Shell::Perl::sandbox' )
);
pirl @> $obj->hats
@var = (
undef
);
@arunbear
arunbear / mm.py
Created March 26, 2020 17:29
Multimethods in Python
# Example usage of https://www.artima.com/weblogs/viewpost.jsp?thread=101605
# with added commutativity
import itertools
registry = {}
class MultiMethod(object):
def __init__(self, name):
self.name = name