Skip to content

Instantly share code, notes, and snippets.

View fswair's full-sized avatar
🤠
coding

Mert fswair

🤠
coding
View GitHub Profile
@fswair
fswair / waifu.py
Last active April 3, 2024 20:11
WaifuPics API Wrapper
from aiohttp import ClientSession
from enum import Enum, auto
import asyncio
class InvalidResponse(Exception):
"""Error class for invalid responses."""
pass
class InvalidInput(Exception):
"""Error class for invalid inputs."""
@fswair
fswair / main.py
Created November 14, 2023 13:49
cppreference.com impl. python
from requests import get
from bs4 import BeautifulSoup
class CPPReference:
def __init__(self, keyword: str) -> None:
self.keyword = keyword
self.url = f"https://en.cppreference.com/w/cpp/keyword/{keyword}"
def request(self):
self.response = get(self.url, headers={"User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:89.0) Gecko/20100101 Firefox/89.0"})
if self.response.status_code != 200:
@fswair
fswair / nowpayments.examples.py
Created August 8, 2023 15:39
telepaidev.NowPaymentsAPI Using Example
from nowpayments import (
currency,
exchanges,
Plugins,
Payments,
NowPaymentsAPI,
GetPaymentContext
)
from nowpayments.dataclasses import IPNCompatibleResponse
@fswair
fswair / api.py
Last active July 30, 2023 19:16
distance calculator api with locations
import geopy, haversine as hs
from fastapi import FastAPI
app = FastAPI()
@app.get("/get/locationDistance")
async def distanceCalc(loc1: str, loc2: str):
locator = geopy.Nominatim(user_agent="MacOS 13.5;")
location: geopy.Location = (locator.geocode(loc1))
location2: geopy.Location = (locator.geocode(loc2))
point1 = (location.latitude, location.longitude)