Skip to content

Instantly share code, notes, and snippets.

@reedip
reedip / python_request_create_gist.py
Created October 31, 2022 10:53 — forked from joshisumit/python_request_create_gist.py
Create GIST from your python code with python requests module and OAuth token.
'''
HTTP Reuests has following parameters:
1)Request URL
2)Header Fields
3)Parameter
4)Request body
'''
#!/usr/bin/env python
import requests
def download(url, filepath):
print "downloading %s to %s" % (url, filepath)
parts = urlparse(url)
login, account, password = netrc.netrc().authenticators(parts.netloc)
request = urllib2.Request(url)
creds = base64.encodestring('%s:%s' % (login, password)).strip()
request.add_header("Authorization", "Basic %s" % creds)
result = urllib2.urlopen(request)
assert result.getcode() == 200
f = open(filepath, 'wb')

Pastebin

Design Pastebin, a website where you can store and share text online for a set period of time. Note: Bit.ly is a similar service, with the distinction that Pastebin requires storing the paste contents instead of the original unshortened URL.

NOTE: This is taken from Pramp, an excellet tool from Exponent. The objective here is to answer scenarios as well as possible for a System Design Interview

Attributes

  • Features scope
SNo. MySQL ( RDBMS) NoSQL
1 Most RDBMS scale Vertically, by increasing the H/W specs ( MariaDB is an exception, so is CloudSpanner) NoSQL scales horizontally by adding more nodes to the system
2 Flexible , support for easier query language Predictable performance
@reedip
reedip / database.md
Last active February 23, 2022 04:54
Use case Solution Example Notes
@reedip
reedip / gist:afc38dce9f06095b2061343e0f9bc067
Last active June 23, 2021 02:59
query-exporter to be deployed
FROM openstack-base:0.0.1-3 AS compile-image
RUN yum install -y git epel-release && yum clean all
RUN yum install -y python3-virtualenv
RUN virtualenv-3 /opt/openstack
ENV PATH="/opt/openstack/bin:$PATH"
RUN yum install -y python3 gcc gcc-c++ python3-pip python3-devel
RUN yum install -y mariadb-devel libpq-devel && \
yum install -y unixODBC \
yum install -y unixODBC-devel && yum install -y bash
RUN yum install -y bash mariadb-devel libpq-devel
@reedip
reedip / multithreadedPythonDebug.py
Created November 7, 2019 05:36
Debug multithreaded programs
"""Stack tracer for multi-threaded applications.
Usage:
import stacktracer
stacktracer.start_trace("trace.html",interval=5,auto=True) # Set auto flag to always update file!
....
stacktracer.stop_trace()