Skip to content

Instantly share code, notes, and snippets.

View thoughtspeed7's full-sized avatar

Raj Chaudhary thoughtspeed7

View GitHub Profile
@thoughtspeed7
thoughtspeed7 / index.js
Last active October 2, 2022 12:52
Azure Cognitive Services Computer Vision Read API Using Axios
const axios = require('axios').default;
const { setTimeout } = require('timers/promises');
module.exports = async function (context, req) {
// Replace your_sub_domain with your Computer Vision's endpoint sub domain
const analyzeURL =
'https://your_sub_domain.cognitiveservices.azure.com/vision/v3.2/read/analyze';
// Get imageURL from query string
// Example: https://raw.githubusercontent.com/Azure-Samples/cognitive-services-sample-data-files/master/ComputerVision/Images/printed_text.jpg
@thoughtspeed7
thoughtspeed7 / main.py
Created September 23, 2022 12:10
AWS Glue - Ingest Data From External REST APIs Into Amazon S3
import requests
import boto3
import json
def main():
data = requests.get('https://dummyjson.com/products').json()
s3_client = boto3.client('s3')
s3_client.put_object(Body=json.dumps(data), Bucket='aws-glue', Key='products.json')
main()
@thoughtspeed7
thoughtspeed7 / app.yaml
Created September 5, 2021 15:49
Connect To Redis Memorystore From Cloud Functions, Cloud Run and App Engine Using Serverless VPC Access | Google Cloud
# om namah shivaya
service: default
runtime: nodejs14
instance_class: F1
automatic_scaling:
min_instances: 0
max_instances: 1
target_cpu_utilization: 0.90
handlers:
@thoughtspeed7
thoughtspeed7 / index.js
Created September 5, 2021 15:37
Connect To Redis Memorystore From Cloud Functions, Cloud Run and App Engine Using Serverless VPC Access | Google Cloud
// om namah shivaya
// require scripts
const { promisify } = require('util');
const redis = require('redis');
const express = require('express');
startService();
async function startService() {
@thoughtspeed7
thoughtspeed7 / deploy.sh
Created September 5, 2021 14:22
Connect To Redis Memorystore From Cloud Functions, Cloud Run and App Engine Using Serverless VPC Access | Google Cloud
#! /bin/bash
GCP_PROJECT_ID=rajchaudhary #replace rajchaudhary with your gcp project id
GCP_REGION=us-central1 #replace us-central1 with your gcp region
gcloud builds submit \
--tag gcr.io/$GCP_PROJECT_ID/hello-redis
gcloud run deploy hello-redis \
--allow-unauthenticated \
--image gcr.io/$GCP_PROJECT_ID/hello-redis \
@thoughtspeed7
thoughtspeed7 / index.js
Created September 5, 2021 14:18
Connect To Redis Memorystore From Cloud Functions, Cloud Run and App Engine Using Serverless VPC Access | Google Cloud
// om namah shivaya
// require scripts
const { promisify } = require('util');
const redis = require('redis');
const express = require('express');
startService();
async function startService() {
@thoughtspeed7
thoughtspeed7 / deploy.sh
Created September 5, 2021 12:48
Connect To Redis Memorystore From Cloud Functions, Cloud Run and App Engine Using Serverless VPC Access | Google Cloud
#! /bin/bash
GCP_REGION=us-central1 #replace us-central1 with your gcp region
gcloud functions deploy hello-redis \
--allow-unauthenticated \
--entry-point main \
--region $GCP_REGION \
--runtime nodejs14 \
--trigger-http \
--vpc-connector hello-redis-vpc-connector
@thoughtspeed7
thoughtspeed7 / index.js
Created September 5, 2021 12:39
Connect To Redis Memorystore From Cloud Functions, Cloud Run and App Engine Using Serverless VPC Access | Google Cloud
// om namah shivaya
const { promisify } = require('util');
const redis = require('redis');
// replace 127.0.0.1 with your redis instance ip
const redisHost = '127.0.0.1';
const client = redis.createClient({
host: redisHost,
@thoughtspeed7
thoughtspeed7 / .dockerignore
Created August 16, 2021 00:40
Run Google Cloud Functions Everywhere Using Functions Framework
# om namah shivaya
# directories
node_modules
# files
.dockerignore
.gitignore
.prettierrc
Dockerfile
@thoughtspeed7
thoughtspeed7 / Dockerfile
Created August 16, 2021 00:34
Run Google Cloud Functions Everywhere Using Functions Framework
# om namah shivaya
# Use the official lightweight Node.js 14 image.
# https://hub.docker.com/_/node
FROM node:14-slim
# Create and change to the app directory.
WORKDIR /usr/src/app
# Copy application dependency manifests to the container image.