This file contains 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
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" }, |
This file contains 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
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: |
This file contains 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
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: |
This file contains 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 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) |
This file contains 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
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 |
This file contains 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
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))) |
This file contains 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
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 |
This file contains 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
package main | |
import ( | |
"fmt" | |
"sync" | |
"time" | |
"github.com/google/uuid" | |
) | |
This file contains 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 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: |
NewerOlder