Skip to content

Instantly share code, notes, and snippets.

View leftmove's full-sized avatar

Anonyo Noor leftmove

View GitHub Profile
@leftmove
leftmove / chat.py
Last active May 29, 2024 17:38
Gemini API Command Line Chat Bot
import os
import json
from datetime import datetime
from dotenv import load_dotenv
from colorama import Fore, Back, Style
load_dotenv()
import google.generativeai as genai
let keepLooking = true
XMLHttpRequest.prototype._originalOpen = XMLHttpRequest.prototype.open;
XMLHttpRequest.prototype.open = function(method, url, async, user, password) {
const isDelivery = url.includes("deliveries")
const isM3u8 = url.includes("m3u8")
if (keepLooking && isDelivery && isM3u8) {
@leftmove
leftmove / ticker.py
Last active May 29, 2024 21:10
Company name to ticker using Yahoo Finance API endpoint
def get_ticker(company_name):
yfinance = "https://query2.finance.yahoo.com/v1/finance/search"
user_agent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36'
params = {"q": company_name, "quotes_count": 1, "country": "United States"}
res = requests.get(url=yfinance, params=params, headers={'User-Agent': user_agent})
data = res.json()
company_code = data['quotes'][0]['symbol']
return company_code
@0x4f53
0x4f53 / getticker.py
Created June 9, 2021 22:20
Get company ticker symbol / code from name in Python
import requests
def getTicker (company_name):
url = "https://s.yimg.com/aq/autoc"
parameters = {'query': company_name, 'lang': 'en-US'}
response = requests.get(url = url, params = parameters)
data = response.json()
company_code = data['ResultSet']['Result'][0]['symbol']
return company_code