Skip to content

Instantly share code, notes, and snippets.

@abhijitmamarde
abhijitmamarde / rfind.py
Created April 4, 2016 10:25
Search files matching with patterns from current directory.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import fnmatch
import os
import sys
def find_files(filepath, patterns):
matches = 0
if os.path.exists(filepath):
@abhijitmamarde
abhijitmamarde / findinpath.py
Created April 4, 2016 10:16
Search a file from environment PATH
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
import os
import sys
import os.path
path_dirs = os.getenv('PATH').split(':')
cmd = sys.argv[1]
@abhijitmamarde
abhijitmamarde / timeit_demo.py
Created December 19, 2015 11:01
Script which uses timeit module to check execution times for all functions written in it.
from random import random
import types
def list_without_comprehension():
l = []
for i in xrange(1000):
l.append(int(random()*100 % 100))
return l
def list_with_comprehension():