Skip to content

Instantly share code, notes, and snippets.

from functools import wraps, lru_cache
from contextlib import contextmanager
class _SkipCache(Exception):
def __init__(self, value):
self.value = value
class _CachedFunction(object):
def __init__(self, maxsize = 128, typed = False):
self.__is_skipped = False
@nivbend
nivbend / cdisable.vim
Last active August 29, 2015 14:27
Wrap C/C++ code in #if 0/#endif.
" Disable sections in C/C++ code using #if 0/#endif blocks.
" This uses <Leader>-i/e in normal/visual mode. In normal mode, it also takes a count (3<Leader>i to wrap 3 lines).
" The <Leader>-e option places the user inside the #else block.
function! s:wrap_disabling_if(num_lines)
execute "normal O#if 0"
execute "noraml " . a:num_lines . "j"
execute "normal o#endif"
endfunction
@nivbend
nivbend / run_pylint.py
Last active January 7, 2020 13:21
A simple git pre-commit hook to run pylint on all python scripts changed.
#! /usr/bin/env python
"""Git pre-commit hook to run pylint on python files.
To install:
wget https://gist.github.com/nivbend/7e0e306a98138916b3c9#file-run_pylint-py -O .git/hooks/pre-commit
"""
from __future__ import print_function
from subprocess import check_output, CalledProcessError
from sys import stderr