Skip to content

Instantly share code, notes, and snippets.

View adityaarakeri's full-sized avatar
:octocat:
Always learning

Adi adityaarakeri

:octocat:
Always learning
  • San Francisco Bay Area
View GitHub Profile
@adityaarakeri
adityaarakeri / random_choice.py
Created October 17, 2018 23:31
Random choice of socks
"""
If your sock drawer has 6 black socks, 4 brown socks, 8 white socks, and 2 tan socks, how many socks would you have to pull out in the dark to be sure you had a matching pair?
"""
# Data
collection = {
'black': 6,
'brown': 4,
'white': 8,
@adityaarakeri
adityaarakeri / curl.md
Created March 20, 2019 06:39 — forked from btoone/curl.md
A curl tutorial using GitHub's API

Introduction

An introduction to curl using GitHub's API.

The Basics

Makes a basic GET request to the specifed URI

curl https://api.github.com/users/caspyin
@adityaarakeri
adityaarakeri / dummy.json
Created March 20, 2019 06:52
Demo returns a dummy json
{
"name": "base-policy",
"version": 1.0,
"type": "dummy",
"compatible": [4.0, 4.1, 4.2, 4.3],
"customer": "XYZ - Client",
"data": [
{
"name": "test-name-1",
"value": "test-val-1"
import httplib
import base64
try:
import json
except ImportError:
import simplejson as json
config = {"username": "your-sauce-username",
"access-key": "your-sauce-api-key"}
@adityaarakeri
adityaarakeri / Makefile
Created May 2, 2019 20:55 — forked from mpneuried/Makefile
Simple Makefile to build, run, tag and publish a docker containier to AWS-ECR
# import config.
# You can change the default config with `make cnf="config_special.env" build`
cnf ?= config.env
include $(cnf)
export $(shell sed 's/=.*//' $(cnf))
# import deploy config
# You can change the default deploy config with `make cnf="deploy_special.env" release`
dpl ?= deploy.env
include $(dpl)
@adityaarakeri
adityaarakeri / requests.py
Created June 26, 2019 07:06 — forked from random-robbie/requests.py
Python Requests Ignore Bad SSL certificate
import requests
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
URL = "https://www.somesitewithbadssl.com"
headers = {"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:54.0) Gecko/20100101 Firefox/54.0","Connection":"close","Accept-Language":"en-US,en;q=0.5","Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8","Upgrade-Insecure-Requests":"1"}
response = session.get(URL, headers=headers, timeout=15, verify=False)
result = response.text
print (result)
import asyncio
loop = asyncio.get_event_loop()
async def hello():
await asyncio.sleep(3)
print('Hello!')
if __name__ == '__main__':
loop.run_until_complete(hello())
@adityaarakeri
adityaarakeri / OffensivePython.ipynb
Created September 18, 2019 04:03 — forked from fheisler/OffensivePython.ipynb
Hunter2: Offensive Python Workshop
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@adityaarakeri
adityaarakeri / retry_decorator.py
Created September 19, 2019 17:14
Retry decorator in Python
import time
from functools import wraps
def retry(ExceptionToCheck, tries=4, delay=3, backoff=2, logger=None):
"""Retry calling the decorated function using an exponential backoff.
http://www.saltycrane.com/blog/2009/11/trying-out-retry-decorator-python/
original from: http://wiki.python.org/moin/PythonDecoratorLibrary#Retry
@adityaarakeri
adityaarakeri / curl.md
Created October 25, 2019 04:06 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.