Skip to content

Instantly share code, notes, and snippets.

View kkrishnan90's full-sized avatar

Krishna kkrishnan90

View GitHub Profile
@kkrishnan90
kkrishnan90 / genai-text.py
Last active May 31, 2023 10:59
Leveraging Google Cloud GenAI Python API using service account key file.
# Create a service account and associate a "Vertex AI User" role
import google.auth
import google.auth.transport.requests
from google.oauth2 import service_account
import vertexai
from vertexai.preview.language_models import TextGenerationModel
key_path = "<YOUR_KEY_PATH>"
credentials = service_account.Credentials.from_service_account_file(key_path,scopes=['https://www.googleapis.com/auth/cloud-platform'])
auth_req = google.auth.transport.requests.Request()
credentials.refresh(auth_req)
@kkrishnan90
kkrishnan90 / single-page-report.py
Created October 13, 2022 09:04
single-page-report-aws
import pandas as pd
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
from matplotlib.backends.backend_pdf import PdfPages
import os, time
from os import path
from google.cloud import storage
import re
import pandas as pd
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
from matplotlib.backends.backend_pdf import PdfPages
import os, time
from os import path
from google.cloud import storage
import re
import pandas as pd
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
from matplotlib.backends.backend_pdf import PdfPages
import os, time
from os import path
from google.cloud import storage
import re
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
doctype html
html(lang="en")
head
title Static Files
meta(charset='utf-8')
link(rel="stylesheet", href="/static/main.css")
body
p=content
img(src="#{publicUrl}")
doctype html
html(lang="en")
head
title Static Files
meta(charset='utf-8')
link(rel="stylesheet", href="/static/main.css")
body
form(method="POST", action="/upload", enctype="multipart/form-data")
input(type="file", name="file")
input(type="submit")
{
"name": "appengine-storage",
"description": "Node.js Google Cloud Storage sample for Google App Engine",
"scripts": {
"start": "node app.js",
"test": "mocha system-test/*.test.js --exit --timeout=30000"
},
"engines": {
"node": ">= 12.20.0"
},
'use strict';
const process = require('process'); // Required to mock environment variables
// [START gae_flex_storage_app]
const {format} = require('util');
const express = require('express');
const Multer = require('multer');
const axios = require('axios');
// By default, the client will authenticate using the service account file
from flask import escape
from flask import jsonify
def hello_http(request):
request_json = request.get_json(silent=True)
request_args = request.args
if request_json and 'image' in request_json:
res = detect_handwritten_ocr_uri(request_json['image'])
else:
res = "Error in payload data. Attach image"