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 urllib3 import BaseHTTPResponse, Retry | |
import time | |
class GitHubRetry(Retry): | |
def get_retry_after(self, response: BaseHTTPResponse) -> float | None: | |
if 'X-RateLimit-Remaining' in response.headers and 'X-RateLimit-Reset' in response.headers: | |
remaining_requests = int(response.headers['X-RateLimit-Remaining']) | |
if remaining_requests > 0: | |
return None | |
else: |
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
\documentclass[margin=1cm]{standalone} | |
\usepackage{tikz} | |
\definecolor{ACMYellow}{RGB}{255, 214, 0} | |
\definecolor{ACMOrange}{RGB}{252, 146, 0} | |
\definecolor{ACMRed}{RGB}{253, 27, 20} | |
\definecolor{ACMLightBlue}{RGB}{131, 206, 226} | |
\definecolor{ACMGreen}{RGB}{166, 188, 9} | |
\definecolor{ACMPurple}{RGB}{101, 1, 107} | |
\definecolor{ACMDarkBlue}{RGB}{9, 53, 122} |
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 pathlib import Path | |
lines_not_200 = [] | |
log_file_dir = '.' | |
for log_file in Path(log_file_dir).glob('*.log'): | |
with open(log_file, 'r') as f: | |
for line in f.readlines(): | |
if not line.startswith('INFO:root:HTTP status 200'): | |
lines_not_200 += [line] |
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 timeit | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
# measuring | |
numpy_results = {} | |
python_results = {} | |
config = {'number': 100, 'repeat': 100} |
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 bz2 | |
import orjson | |
from requests.adapters import HTTPAdapter, Retry | |
from requests_cache import CachedSession, SerializerPipeline, Stage, serializers | |
from requests_futures.sessions import FuturesSession | |
SERIALIZER = SerializerPipeline([ | |
serializers.preconf.orjson_preconf_stage, | |
orjson, |
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 shutil | |
from pathlib import Path | |
data_dir = './data' # please speficy the data dir | |
for path in Path(data_dir).rglob('timeline'): | |
print(path) | |
shutil.rmtree(path) |
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
# pylint: disable=locally-disabled, multiple-statements, line-too-long, missing-module-docstring, no-member, missing-class-docstring, missing-function-docstring | |
import argparse | |
from pathlib import Path | |
import hashlib | |
import bz2 | |
import logging | |
from datetime import datetime | |
import orjson |
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
# pylint: disable=locally-disabled, multiple-statements, line-too-long, missing-module-docstring, no-member, missing-class-docstring, missing-function-docstring | |
import argparse | |
from pathlib import Path | |
from datetime import datetime | |
import logging | |
import bz2 | |
from concurrent.futures import as_completed | |
from urllib.parse import urlparse, parse_qs |
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 requests | |
import json | |
api_url = 'review.gerrithub.io' # or, for example, 'android-review.googlesource.com' | |
test_pages = [1, 100, 1000, 10000] | |
changes = [] | |
for page in test_pages: | |
response = requests.get(f'https://{api_url}/changes/?o=MESSAGES&o=DETAILED_ACCOUNTS', timeout=10*60, params={'S': 0}) | |
changes += json.loads(response.text[len("]}\\\'\n"):]) |
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 agithub.GitHub import GitHub | |
import pandas as pd | |
token = "" | |
client = GitHub(token=token, paginate=True) | |
for repo in ['echarts']: | |
status, issues = client.repos['apache'][repo].issues.get(state='open') | |
assert status==200, str(status) |
NewerOlder