Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View harishkashyap's full-sized avatar

Harish Kashyap harishkashyap

View GitHub Profile
import bisect
class NFA(object):
EPSILON = object()
ANY = object()
def __init__(self, start_state):
self.transitions = {}
self.final_states = set()
self._start_state = start_state
@harishkashyap
harishkashyap / gist:0a5a3fe0f79ab8bbd592e6d09eb3c562
Created March 8, 2022 20:01
Dockerfile for Deployment of a Python Module to an EC2 instance
FROM python:3.8-slim
WORKDIR /usr/app/src
RUN pip install --upgrade pip
COPY requirements.txt ./requirements.txt
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
RUN pip install .
@harishkashyap
harishkashyap / opt-3d.json
Created November 26, 2022 00:05
optimization function template
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"width": 500,
"height": 500,
"background": {
"signal": "theme === 'dark'?'black':'white'"
},
"title": {
"text": "3D Matrix",
"color": {
@harishkashyap
harishkashyap / gist:ae502e7951dd89f0a062e3b5648016aa
Created December 21, 2022 05:28
risk and outage probability
# enter first two supplier values in a list
def compute_risk(cost_map, quality_map, outage_map, min_risk, max_risk, hyp_traffic_list):
outage_risk_val = 0.0
param_list = []
if len(hyp_traffic_list) == 3:
param_list = hyp_traffic_list[0:2]
elif len(hyp_traffic_list) == 2:
param_list = hyp_traffic_list[0:1]
else:
@harishkashyap
harishkashyap / out_json.json
Last active January 12, 2023 01:00
sample json
{"width": 100, "height": 100, "values": [6631, 6435, 6243, 6055, 5871, 5691, 5515, 5343, 5175, 5011, 4851, 4695, 4543, 4395, 4251, 4111, 3975, 3843, 3715, 3591, 3471, 3355, 3243, 3135, 3031, 2931, 2835, 2743, 2655, 2571, 2491, 2415, 2343, 2275, 2211, 2151, 2095, 2043, 1995, 1951, 1911, 1874, 1842, 1814, 1790, 1770, 1754, 1742, 1734, 1730, 1730, 1734, 1742, 1754, 1770, 1790, 1814, 1842, 1874, 1910, 1950, 1994, 2042, 2094, 2150, 2210, 2274, 2342, 2414, 2490, 2570, 2654, 2742, 2834, 2930, 3030, 3134, 3242, 3354, 3470, 3590, 3714, 3842, 3974, 4110, 4250, 4394, 4542, 4694, 4850, 5010, 5174, 5342, 5514, 5690, 5869, 6053, 6241, 6433, 6629, 6435, 6241, 6051, 5865, 5683, 5505, 5331, 5161, 4995, 4833, 4675, 4521, 4371, 4225, 4083, 3945, 3811, 3681, 3555, 3433, 3315, 3201, 3091, 2985, 2883, 2785, 2691, 2601, 2515, 2433, 2355, 2281, 2211, 2145, 2083, 2025, 1971, 1921, 1875, 1833, 1794, 1760, 1730, 1704, 1682, 1664, 1650, 1640, 1634, 1632, 1634, 1640, 1650, 1664, 1682, 1704, 1730, 1760, 1794, 1832, 1874, 1920, 1970, 2024,
@harishkashyap
harishkashyap / pandita-risk
Created January 28, 2023 07:10
pandita endpoint for risk
import boto3
import datetime
import time
import tarfile
import boto3
import pandas as pd
import sagemaker
from sagemaker import sklearn, get_execution_role
sm_boto3 = boto3.client("sagemaker")
embed({
"$schema": "https://vega.github.io/schema/vega/v5.json",
"width":500,
"height":500,
"background":{"signal":"theme === 'dark'?'black':'white'"},
"title": {
"text": "Maungawhau volcano",
"color": {"signal": "theme === 'dark' ? 'lightgrey':'black'"},
"dy": 25
},