Skip to content

Instantly share code, notes, and snippets.

@akinniyi
akinniyi / main.py
Created November 10, 2024 14:27 — forked from serg-yalosovetsky/main.py
example fastapi server with redis pubsub listener
import asyncio
import uvicorn
from fastapi import FastAPI
from fastapi.routing import APIRouter
from fastapi_websocket_pubsub import PubSubEndpoint
import redis.asyncio as redis
STOPWORD = "STOP"
@akinniyi
akinniyi / sheets.py
Created March 31, 2021 15:15 — forked from AO8/sheets.py
Read, write, and delete data from a Google Spreadsheet using Python and the gspread module, nice for building a quick CRUD app with Google Sheets as a backend.
# Full getting started tutorial by Greg Baugues at:
# https://www.twilio.com/blog/2017/02/an-easy-way-to-read-and-write-to-a-google-spreadsheet-in-python.html
import gspread
from oauth2client.service_account import ServiceAccountCredentials
# use creds to create a client to interact with the Google Drive API
scope = ["https://spreadsheets.google.com/feeds"]
creds = ServiceAccountCredentials.from_json_keyfile_name("client_secret.json", scope) # json file from your Google API Console
client = gspread.authorize(creds)
@akinniyi
akinniyi / convert_milliseconds_to_datetime.py
Last active October 16, 2020 14:59 — forked from evnm/gist:d17336bf42e887c6e756
Script to convert milliseconds since epoch to a human-readable timestamp
import datetime
import sys
milliseconds_to_convert = 1602858657059
return datetime.datetime.fromtimestamp(milliseconds_to_convert/1000)
@akinniyi
akinniyi / chess.py
Created November 8, 2019 21:38 — forked from rsheldiii/chess.py
chess program for python
"""CONVENTIONS:
positions are done row-column from the bottom left and are both numbers. This corresponds to the alpha-number system in traditional chess while being computationally useful. they are specified as tuples
"""
import itertools
WHITE = "white"
BLACK = "black"