This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- encoding: utf-8 -*- | |
import os | |
import sys | |
import os.path | |
path_dirs = os.getenv('PATH').split(':') | |
cmd = sys.argv[1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- encoding: utf-8 -*- | |
import time | |
import string | |
from datetime import datetime | |
from os.path import expanduser, join | |
import json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
import time | |
from pprint import pprint | |
# duration of each slot, in mins | |
mins_of_slot = 15 | |
# default time slots info | |
default_time_slots = [ | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- encoding: utf-8 -*- | |
''' | |
Simple utility to change the active global git profile. | |
sample profile config file (yaml): | |
mygit: | |
user: Abhijit | |
email: abhijit.XXXX@gmail.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ git status -s | |
?? bmp.log | |
?? log.html | |
?? output.xml | |
?? report.html | |
$ git ls-files --others --exclude-standard | |
bmp.log | |
log.html | |
output.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from unittest.mock import Mock | |
import builtins | |
len = builtins.len | |
def new_len(o): | |
return builtins.len(o) + 1 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from os.path import exists as orig_exists | |
from unittest.mock import Mock | |
exists = orig_exists | |
def new_exists(file): | |
print(f"new_exists: checking if '{file}' exists:", orig_exists(file)) | |
print("but will send exists = True") | |
return True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import zmq | |
import baker | |
from multiprocessing import Process | |
@baker.command | |
def start(name, topicfilter="10001", port="5566"): | |
print(f"listening pub-server at port:{int(port)}; topic:{topicfilter}") | |
# Socket to talk to server | |
context = zmq.Context() |
OlderNewer