This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
from PIL import Image | |
import io | |
rekognition_client = boto3.client("rekognition") | |
def get_face_details(image_bytes): | |
response = rekognition_client.detect_faces(Image={"Bytes": image_bytes}, Attributes=["ALL"]) | |
# Assuming the first face is the one we need | |
face_details = response["FaceDetails"][0] if response["FaceDetails"] else None |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Implementation 1 | |
async function makeRequest({ | |
method = RequestMethod.GET, | |
path, | |
body = {}, | |
tokenStore, | |
isLoginRequest = false, | |
}) { | |
// We can avoid this branching by using implementation 2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getIntersection(setA, setB) { | |
const intersection = new Set( | |
[...setA].filter(element => setB.has(element)) | |
); | |
return intersection; | |
} | |
// const set1 = new Set(['a', 'b', 'c']); | |
// const set2 = new Set(['a', 'b', 'd', 'e']); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Given an API - /all_data which returns all the schools, all the students and all the books from DB. And return the reponse with minimum possible latency. | |
And if any of the query fails, returns balnk array for only that entity. | |
Example - | |
router.get("/all_data", async (req,res,next)=>{ | |
let schools = await School.find(); // takes 300ms to complete | |
let students = await Student.find(); // takes 300ms to complete | |
let books = await Book.find(); // takes 300ms to complete | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const char *wifiSSID = "MY_WIFI"; | |
const char *wifiPassword = "MY_PASS"; | |
#define MQTT_HOST "mybroker" | |
#deinfe MQTT_PORT 1883 | |
#include <ESP8266WiFi.h> | |
WiFiClient wifiClient; | |
#include <AsyncMqttClient.h> | |
AsyncMqttClient mqttClient; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# base Image | |
FROM python:3.6-stretch | |
# install build utilities | |
RUN apt-get update && \ | |
apt-get install -y gcc make apt-transport-https ca-certificates build-essential git | |
#Install Pytorch and dependencies | |
RUN pip3 install torch==1.7.1+cpu torchvision==0.8.2+cpu torchaudio==0.7.2 -f https://download.pytorch.org/whl/torch_stable.html |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask | |
from flask import request | |
app = Flask(__name__) | |
from mood_tagging import get_emotion | |
@app.route('/get_emotion', methods=['POST']) | |
def get_emotion_of_text(): | |
if request.method == 'POST': | |
text = request.json.get('text') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Bunch of setting up Steps | |
pip install transformers[sentencepiece] | |
pip install sentencepiece | |
import os | |
# Load the Pretrained Model | |
from transformers import AutoTokenizer, AutoModelWithLMHead, PreTrainedModel | |
tokenizer = AutoTokenizer.from_pretrained("mrm8488/t5-base-finetuned-emotion", use_fast=False) | |
model = AutoModelWithLMHead.from_pretrained("mrm8488/t5-base-finetuned-emotion") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let p = new Promise((resolve,reject)=>{ | |
setTimeout(()=>{ | |
resolve("Hello"); | |
console.log("Will I be printed"); | |
}, 2000); | |
}); | |
p.then(data=>{ | |
console.log(data); | |
}).catch(err=>{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let _arr = []; | |
let count = 0; | |
class Lock { | |
constructor() { | |
this._locked = false; | |
this._waiting = []; | |
} |
NewerOlder