This file contains hidden or 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 concurrent.futures | |
| import time | |
| import requests | |
| import statistics | |
| URL = "http://localhost:8000" | |
| NUM_REQUESTS = 1024 | |
| CONCURRENT_THREADS = 32 | |
| def fetch_url(url): |
This file contains hidden or 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
| { | |
| "Afghanistan": [ | |
| "Aibak", | |
| "Andkhoy", | |
| "Asadabad", | |
| "Baghlan", | |
| "Balkh", | |
| "Bamyan", | |
| "Baraki Barak", | |
| "Bazarak", |
This file contains hidden or 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
| class Metaclass: | |
| def asdict(self): | |
| return self.__dict__ | |
| def astuple(self): | |
| return tuple(self.__dict__.values()) | |
| def fields(self): | |
| return list(self.__dict__.keys()) |
This file contains hidden or 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
| include /usr/local/Cellar/nano/5.5/share/nano/*.nanorc | |
| set autoindent | |
| set historylog | |
| set linenumbers | |
| set softwrap | |
| set tabsize 4 | |
| set tabstospaces |
This file contains hidden or 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
| # pip install progressbar2 | |
| from progressbar import progressbar | |
| def wallis(n): | |
| pi = 2. | |
| for i in progressbar(range(1, n)): | |
| left = (2. * i) / (2. * i - 1.) | |
| right = (2. * i) / (2. * i + 1.) | |
| pi = pi * left * right |
This file contains hidden or 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
| def match(group, array): | |
| array = str(array).strip("[]") | |
| group = str(group).strip("[]") | |
| return group in array | |
| print(match([1,3,4], [1,1,3,4,5])) |
This file contains hidden or 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/python | |
| import math | |
| import sys | |
| print sys.argv[1] | |
| print sys.argv[2] | |
| print sys.argv[3] | |
| R = float(sys.argv[1]) |
This file contains hidden or 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
| def qsort(list): | |
| if list == []: | |
| return [] | |
| pivot = list[0] | |
| l = qsort([x for x in list[1:] if x < pivot]) | |
| u = qsort([x for x in list[1:] if x >= pivot]) | |
| return l + [pivot] + u |
This file contains hidden or 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 django.utils.safestring import mark_safe | |
| def parser(text): | |
| ''' Convert plain text to HTML ''' | |
| limits = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_' | |
| digits = '0123456789' | |
| # unicode xml safe | |
| text = text.replace('&', '&').replace('<', '<').replace('>', '>') | |
| # replace (160) with space (32) | |
| text = text.replace(chr(160), chr(32)) |
This file contains hidden or 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
| def get_mentions(text): | |
| limits = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_' | |
| words = text.split() | |
| mentions = [] | |
| for word in words: | |
| if word.endswith(('.', ',', '!', '?', ':', ';')): | |
| word = word[:-1] | |
| if word.endswith(')'): | |
| word = word[:-1] | |
| if word.startswith('('): |
NewerOlder