Skip to content

Instantly share code, notes, and snippets.

View shravanasati's full-sized avatar
🎯
Learning

Shravan Asati shravanasati

🎯
Learning
View GitHub Profile
@shravanasati
shravanasati / periodic_sentence.ts
Created May 31, 2024 13:16
check if a sentence can be written using only elements from the periodic table
interface PeriodicTableElement {
no: number,
symbol: string,
name: string
}
const elements: PeriodicTableElement[] = [
{ no: 1, symbol: "H", name: "Hydrogen" },
{ no: 2, symbol: "He", name: "Helium" },
{ no: 3, symbol: "Li", name: "Lithium" },
@shravanasati
shravanasati / cookie_clicker.py
Created May 1, 2024 04:28
cookie clicker automation using selenium
@shravanasati
shravanasati / determinant.py
Created January 9, 2024 09:30
calculate determinant of a (square) matrix
from typing import TypeVar
T = TypeVar("T", int, float)
Matrix = list[list[T]]
def is_square(matrix: Matrix):
n = len(matrix)
for row in matrix:
if len(row) != n:
@shravanasati
shravanasati / monkeytype.py
Created December 6, 2023 17:06
monkeytype automation with selenium
from selenium import webdriver
from selenium.webdriver.firefox.service import Service as FirefoxService
# from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.common.exceptions import NoSuchElementException
driver = webdriver.Firefox(service=FirefoxService())
driver.get("https://monkeytype.com")
try:
@shravanasati
shravanasati / which.py
Created November 16, 2023 07:54
which command for windows, place it on PATH and include '.py' in PATHEXT
import shutil, sys
try:
result = shutil.which(sys.argv[1])
print(result if result else f"unable to find '{sys.argv[1]}'")
except IndexError:
print("not enough arguments", file=sys.stderr)
except Exception as e:
print("an unknown error occured:", e, file=sys.stderr)
@shravanasati
shravanasati / spotlight.py
Created September 23, 2023 10:57
simple python scraper to download images from windows10spotlight.com
from concurrent.futures import Future, ThreadPoolExecutor, as_completed
from pathlib import Path
import re
import httpx
from bs4 import BeautifulSoup
DOMAIN = "https://windows10spotlight.com"
PAGE_ENDPOINT = DOMAIN + "/page"
NPAGES = 1011
NTHREADS = 50
@shravanasati
shravanasati / analog_clock.py
Created September 21, 2023 15:56
a simple analog clock using pygame
from datetime import datetime
from math import cos, sin, radians
import pygame
WIDTH, HEIGHT = 800, 600
ORIGIN = (WIDTH // 2, HEIGHT // 2)
def polar_to_cartesian(length: float, theta: float):
return (length * cos(radians(theta)), length * sin(radians(theta)))
@shravanasati
shravanasati / typing_animation.py
Created July 22, 2023 17:37
simple typing animation in python using rich
from time import sleep
from rich import print
from rich.align import Align
from rich.layout import Layout
text = "Hi there! This text is gonna be animated."
duration = 10
sleeping_duration = duration / len(text)
blinking_duration = 0.5
blinking_times = 3
@shravanasati
shravanasati / coordinator.go
Last active July 5, 2023 06:58
simple go program to illustrate a central goroutine accepting requests and sending back responses to multiple waiting goroutines
package main
import (
"fmt"
"sync"
"time"
"github.com/google/uuid"
)
@shravanasati
shravanasati / ciphers.py
Last active April 5, 2023 16:22
Caeser cipher and Vigenere cipher in python.
import string
class CaesarCipher:
def __init__(self, shift: int = 11) -> None:
self.shift = shift
self.keys_upper = string.ascii_uppercase
self.keys_lower = string.ascii_lowercase
def __perform_shift(self, text: str, positive: bool) -> str: