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
#An async Ninja endpoint that calls two remote systems concurrently | |
#(e.g., inventory + billing) and merges results | |
from ninja import NinjaAPI | |
import httpx | |
import asyncio | |
api = NinjaAPI() | |
@api.get("/order-summary") |
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
# t24.py — PyFlink wordcount with clean shutdown (no noisy gRPC at exit) | |
# A PyFlink mini streaming job. It takes a small list (["apple", "banana", "apple"]), maps each word to (word, 1), groups by word, and reduces counts. Then it prints the running totals. | |
# So the flow is: | |
# "banana" → ('banana', 1) | |
# "apple" → ('apple', 1) | |
# second "apple" → updates to ('apple', 2) | |
import os |
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 os | |
import logging | |
from typing import Optional | |
from tenacity import retry, stop_after_attempt, retry_if_exception_type | |
from openai import AsyncOpenAI, APIError, APIConnectionError | |
# --- Configure Logging --- | |
logging.basicConfig( | |
level=logging.INFO, |
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
{ | |
"keys": [ | |
{ | |
"kty": "RSA", | |
"kid": "demo-key-001", | |
"use": "sig", | |
"alg": "RS256", | |
"n": "vg2gksIn5um5GnBx15LpzTtVTHHtGGQLD_F-10PKZyckjhZLJM_vtoOwoxFAg1ysi6jH_OPl9EYudUYLpKzNwbK6Q89zwfT2vJEMf-4mIKabcVz-hOLR9GIlDpy6ouoPBBqx-youANM1wUiTTPJb7RpUKZ4_MC5o0BRlLBP7uAIENdy4PWcFvWeatNkqSlaKS1pws7JNdb2qa3p0Xn_wMzII1scmXFJh6KPOHL3P-X4ps3beY9k3xJBIBSD0D6auArRgC1Wo2a4rlOKKs3243auHsvSrt9_dPOb06GFN6ZSYG-Aiaqc6quQwaxpIJiQ3IpIORQYz1FqTW44TA4WYeQ", | |
"e": "AQAB" | |
} |
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 openai | |
# ✅ Use your actual API key here (never share it in public code) | |
openai.api_key = "sk-proj-GyQv44xNGlYPhFSOp6UaOxQ44oH_ZtUH_VpUutCuGiw2Wgc2pB7TQiGEkY6eyOB5uadZzgT3BlbkFJKr6segLT2r0fjqSV9jtQbV23XtxrXxxJIEk-s9kfgauib3EbD-m_ap81NajCOkpsLZsGwvqQA" | |
# Define a concise system message | |
system_prompt = ( | |
"You are a helpful assistant. Respond in a semi-formal tone. " | |
"Keep your answer under 3 lines. Be informative and friendly." | |
) |
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
# Your code goes here | |
import time | |
import re | |
import threading | |
from pynput import keyboard | |
# Keyword-to-replacement mappings | |
keyword_map = { | |
"marketing": "Focus on customer engagement for better sales.", | |
"ai": "AI is revolutionizing industries.", |
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 librosa | |
import numpy as np | |
import whisper | |
# Load Whisper model and force CPU usage | |
model = whisper.load_model("medium").to("cpu") | |
# Load audio file | |
audio_path = "/Users/homesachin/Downloads/20250221_125939.aac" | |
audio, sr = librosa.load(audio_path, sr=16000) |
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
#!/bin/bash | |
# Get the repository URL from the current folder | |
REPO_URL=$(git config --get remote.origin.url) | |
if [ -z "$REPO_URL" ]; then | |
echo "Error: No remote GitHub repository detected in this folder." | |
exit 1 | |
fi |
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
# Full Description: nal transcription. | |
# Full Description: nal transcription. | |
import os | |
import speech_recognition as sr | |
# Initialize the recognizer | |
recognizer = sr.Recognizer() |
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
# Full Description: nal transcription. | |
import os | |
import speech_recognition as sr | |
# Initialize the recognizer | |
recognizer = sr.Recognizer() | |
# Folder containing chunks | |
chunk_folder = "." |
NewerOlder