Skip to content

Instantly share code, notes, and snippets.

View mattboehm's full-sized avatar

Matthew Boehm mattboehm

View GitHub Profile
@mattboehm
mattboehm / gist:4234781
Created December 7, 2012 17:14
Count method/property usage in vim
"Copy all matches to a vim search and paste in new buffer separated by lines
"Source this file to try it out.
"Let's say you have a python file and want to find all the methods/properties
"on self mentioned in a file (commence esoteric example):
"class Student(object):
" def __init__(self, name):
" self.name = name
" def set_gpa(self, gpa):
import itertools
#ugly one-liner
def _ugly_split_at(pred, seq):
return list(itertools.ifilter(
None,
[
(
(seq[idx:idx+1] + list(itertools.takewhile(lambda x: not pred(x), seq[idx+1:])))
if idx == 0 or pred(el)
else []