Skip to content

Instantly share code, notes, and snippets.

View dkgndianko's full-sized avatar

Mouhamad Ndiankho THIAM dkgndianko

View GitHub Profile
@dkgndianko
dkgndianko / sub_element_list_updater.py
Created October 24, 2019 18:17
This is a method for updating a list of elements.
def updator(initial_list: Set[T], new_list: Set[T], creator: Callable[T, U], getter: Callable[T, U], deleter: Callable[T]) -> List[U]:
result = []
for e in new_list:
element = getter(e)
if not element:
element = creator(e)
result.append(element)
to_delete = initial_list.difference(new_list)
for e in to_delete:
deleter(e)
@dkgndianko
dkgndianko / gist:015494a165c9166ad95083e02b933e89
Created August 24, 2019 10:44 — forked from lonnen/gist:3101795
git grep and git blame. two great tastes that taste great together
# from i8ramin - http://getintothis.com/blog/2012/04/02/git-grep-and-blame-bash-function/
# runs git grep on a pattern, and then uses git blame to who did it
ggb() {
git grep -n $1 | while IFS=: read i j k; do git blame -L $j,$j $i | cat; done
}
# small modification for git egrep bash
geb() {
git grep -E -n $1 | while IFS=: read i j k; do git blame -L $j,$j $i | cat; done
}