Skip to content

Instantly share code, notes, and snippets.

View UtsavChokshiCNU's full-sized avatar

Utsav Chokshi UtsavChokshiCNU

  • Codenation
  • Banglore
View GitHub Profile
@UtsavChokshiCNU
UtsavChokshiCNU / .gitignore
Created October 11, 2017 06:54
git ignore for java , gradle and intellij
# Created by https://www.gitignore.io/api/java,gradle,intellij+all
### Intellij+all ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff:
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/dictionaries
@UtsavChokshiCNU
UtsavChokshiCNU / RoslynTry.cs
Created November 2, 2017 12:23
C# Roslyn Demo
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
namespace GettingStartedCS
@UtsavChokshiCNU
UtsavChokshiCNU / moto_example.py
Created November 18, 2020 08:37
Moto Example
# pip install moto boto3
import boto3
from moto import mock_iam
@mock_iam
def test_create_user():
iam_client = boto3.client('iam', region_name='us-east-1')
library_name = 'xyz'
response1 = iam_client.create_user(
@UtsavChokshiCNU
UtsavChokshiCNU / ajv-example.js
Created December 7, 2020 06:28
Valdiating JSON schema using JSON Schema validator (AJV)
// Install package before running this file : npm install ajv
// Node.js require:
var Ajv = require('ajv');
var schema = {
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "http://example.com/example1.json",
"title": "Core schema meta-schema",
"definitions": {
@UtsavChokshiCNU
UtsavChokshiCNU / cicd_eyk.yaml
Created July 23, 2022 09:34
Setup CI/CD on github repo using EYK (EngineYard Kontainers). Put this file under `.github/workflows` on github
name: deploy-to-eyk
on:
push:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
#!/usr/bin/env python3
"""Command line interface for chalice.
Contains commands for deploying chalice.
"""
from __future__ import annotations
import functools
import logging
import os
import platform
import json
import os
import time
import traceback
import base64
from datetime import datetime
from langchain.chains.qa_with_sources import load_qa_with_sources_chain
from langchain.llms import OpenAI
from opentelemetry import trace
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
@UtsavChokshiCNU
UtsavChokshiCNU / qa_websocket_server.py
Last active August 9, 2023 09:26
Sample Websocket Server that follows Query Pipeline contract and mocks it
"""
### How to use it ?
### Run following commands :
pip install simple-websocket-server==0.4.4 pydantic==2.1.1
python3 qa_websocket_server.py
### Send following request in postman using websocket :
ws://localhost:8000
{
"id": "test123",
@UtsavChokshiCNU
UtsavChokshiCNU / validate_openai_creds.py
Created December 18, 2023 13:27
Validate open ai creds as well as check for required model access
import openai
# OpenAI Models used
OPENAI_GPT_35_MODEL = "gpt-3.5-turbo-16k"
OPENAI_GPT_4_MODEL = "gpt-4"
def is_valid_openai_creds(
openai_api_key: str, openai_organization_id: str
) -> Tuple[bool, str]:
"""Checks if OpenAI API Key and Organization ID is valid as well as have access to required OpenAI models"""