Skip to content

Instantly share code, notes, and snippets.

View vdparikh's full-sized avatar

Vishal Parikh vdparikh

View GitHub Profile
package main
import (
"crypto/rand"
"encoding/base64"
"fmt"
"log"
"os"
"strings"
@vdparikh
vdparikh / readme.md
Created January 28, 2025 23:32
istio

Istio is a powerful service mesh that provides a way to control, secure, and observe microservices in a Kubernetes environment. It works by injecting a sidecar proxy (Envoy) alongside each service, which handles communication between services. Istio provides features like traffic management, security (mTLS, RBAC), and observability (metrics, logs, tracing).


1. Key Concepts of Istio

Before diving into code, let’s understand the key components of Istio:

  1. Sidecar Proxy (Envoy):
  • Injected into each pod in your Kubernetes cluster.

Building a Key Management System (KMS) on top of an on-premises Hardware Security Module (HSM) involves creating a software layer that interacts with the HSM to provide key lifecycle management and cryptographic operations. This KMS can then expose APIs or SDKs for other services to use. Here’s what it takes to build such a system:


1. Understand HSM Capabilities

HSMs provide hardware-backed secure key storage and cryptographic operations. Before building the KMS, understand the following features of your HSM:

  • Key Storage: Maximum number of keys, supported key types (e.g., RSA, AES, ECC).
  • Cryptographic Operations: Supported algorithms (e.g., encryption, signing, HMAC).
  • APIs or SDKs: Interfaces provided for interacting with the HSM (e.g., PKCS#11, JCE, KMIP, proprietary APIs).
  • Access Control: User roles, permissions, and multi-tenancy support.
import os
import fnmatch
import pandas as pd
from presidio_analyzer import AnalyzerEngine, RecognizerResult, PatternRecognizer, Pattern
from presidio_anonymizer import AnonymizerEngine
from presidio_anonymizer.entities import EngineResult
from presidio_image_redactor import ImageRedactorEngine, ImageAnalyzerEngine
from PIL import Image
import docx2txt
from pdf2image import convert_from_path
@vdparikh
vdparikh / Problem.md
Created September 7, 2023 17:31
Insurance Policy Management

Imagine you are designing a simple system for an insurance company to manage their insurance policies. Each insurance policy has the following attributes:

  • Policy ID (a unique identifier)
  • Policyholder Name
  • Policy Start Date
  • Policy End Date
  • Premium Amount

Your task is to create a simple API or a command-line program in a programming language of your choice (e.g., Python, Java, C#) to manage these insurance policies. You need to implement the following functionalities:

@vdparikh
vdparikh / main.cs
Last active September 29, 2023 22:43
Key Store
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Newtonsoft.Json;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Threading.Tasks;
@vdparikh
vdparikh / Badge and Company.md
Last active September 6, 2023 17:30
Details

The following coding problem requires Senior engineer level or up to finish two questions within 50 minutes.

We are working on a security system for a badged-access room in our company's building.

  1. Given an ordered list of employees who used their badge to enter or exit the room, write a function that returns two collections: a. All employees who didn't use their badge while exiting the room – they recorded an enter without a matching exit. b. All employees who didn't use their badge while entering the room – they recorded an exit without a matching enter.
badge_records = [
 ["Martha", "exit"],
@vdparikh
vdparikh / main.py
Last active May 15, 2023 06:39
ChatGPT4All
wget https://the-eye.eu/public/AI/models/nomic-ai/gpt4all/gpt4all-lora-quantized.bin
pip install pyllama
mkdir llama
python -m llama.download --model_size 7B --folder llama/
# https://github.com/nomic-ai/pygpt4all/pyllamacpp
# pip install pyllamacpp fails and so directly download it from github
@vdparikh
vdparikh / GPT4all-langchain-demo.ipynb
Created May 8, 2023 17:13 — forked from psychemedia/GPT4all-langchain-demo.ipynb
Example of running GPT4all local LLM via langchain in a Jupyter notebook (Python)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Slack script to call ChatGPT and participate in conversations when mentioned, summarize long threads, and query a sqlite database containing an organizational knowledge-base