Skip to content

Instantly share code, notes, and snippets.

saurabh hirani saurabh-hirani

Block or report user

Report or block saurabh-hirani

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View test_grequests_output_with_patch.log
# python3 test_grequests.py
2019-04-14 23:31:43,698 START
2019-04-14 23:31:43,724 Starting new HTTPS connection (1): localhost:8082
2019-04-14 23:31:43,725 Starting new HTTPS connection (1): localhost:8082
2019-04-14 23:31:43,726 Starting new HTTPS connection (1): localhost:8082
2019-04-14 23:31:43,727 Starting new HTTPS connection (1): localhost:8082
2019-04-14 23:31:43,728 Starting new HTTPS connection (1): localhost:8082
2019-04-14 23:31:43,728 Starting new HTTPS connection (1): localhost:8082
2019-04-14 23:31:43,729 Starting new HTTPS connection (1): localhost:8082
2019-04-14 23:31:43,730 Starting new HTTPS connection (1): localhost:8082
View test_grequests_output_without_patch.log
# python3 test_grequests.py
2019-04-14 23:30:41,697 START
2019-04-14 23:30:41,721 Starting new HTTPS connection (1): localhost:8082
2019-04-14 23:30:41,722 Starting new HTTPS connection (1): localhost:8082
2019-04-14 23:30:41,723 Starting new HTTPS connection (1): localhost:8082
2019-04-14 23:30:41,724 Starting new HTTPS connection (1): localhost:8082
2019-04-14 23:30:41,725 Starting new HTTPS connection (1): localhost:8082
2019-04-14 23:30:41,726 Starting new HTTPS connection (1): localhost:8082
2019-04-14 23:30:41,727 Starting new HTTPS connection (1): localhost:8082
View test_grequests.py
#!/usr/bin/env python
from __future__ import print_function
import gevent_openssl
gevent_openssl.monkey_patch()
import grequests
import logging
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
View run_https_server.sh
#!/bin/bash
cn='example.com'
host="0.0.0.0"
port=8082
openssl genrsa -out /tmp/$cn.key 2048
openssl req -new -x509 -sha256 -key /tmp/$cn.key -out /tmp/$cn.crt -days 3650 \
-subj "/CN=$cn\/emailAddress=admin@$cn/C=US/ST=Ohio/L=Columbus/O=Widgets Inc/OU=Some Unit"
docker run --rm -e HTTPS_CERT_FILE='/tmp/example.com.crt' -e HTTPS_KEY_FILE='/tmp/example.com.key' -e PORT=$port -p $port:$port -v /tmp:/tmp mccutchen/go-httpbin:v2.1.1
View test_grequests.py
from __future__ import print_function
import grequests
url = "https://google.com"
url_count = 10
pending_requests = []
for i in range(url_count):
pending_requests.append(grequests.get(url, params={'page': i}))
View test_requests_serial.py
from __future__ import print_function
import requests
url = "https://google.com"
url_count = 10
for i in range(url_count):
print(requests.get(url, params={'page': i}))
@saurabh-hirani
saurabh-hirani / understand-percentile-final.txt
Last active Dec 1, 2018
rough-notes-for-explaining-percentile
View understand-percentile-final.txt
1.
- if 10 students took a test and scored the following:
10 20 30 40 50 60 70 80 90 100
and the cutoff percentage for a college admission is 90% - how many students got in?
- average does not help - avg = (n * (n + 1)) / 2 = 55
@saurabh-hirani
saurabh-hirani / get_es_index_type_count.py
Last active Aug 5, 2018
For an ES host - call the _mappings API and get the type count for each index
View get_es_index_type_count.py
import sys
import json
import requests
# The following find function is a minor edit of the function posted here
# https://stackoverflow.com/questions/9807634/find-all-occurrences-of-a-key-in-nested-python-dictionaries-and-lists
def find(key, value):
for k, v in value.iteritems():
if k == key and not isinstance(v, dict) and not isinstance(v, list):
yield v
@saurabh-hirani
saurabh-hirani / sample-aws-credentials.sh
Created May 18, 2018
File path: ~/.aws/credentials
View sample-aws-credentials.sh
[profile_1]
aws_access_key_id = profile_1_access_key
aws_secret_access_key = profile_1_secret_key
[profile_2]
aws_access_key_id = profile_2_access_key
aws_secret_access_key = profile_2_secret_key
[profile_3]
aws_access_key_id = profile_3_access_key
You can’t perform that action at this time.