This cheat sheet contains runnable Python examples across Core Python, ETL/Data Processing, Algorithmic Thinking, Pandas/SQL, and Real-world Scenarios.
This script is a lightweight synthetic monitoring tool using Selenium + Chrome DevTools Protocol (CDP) that allows you to load a web page without triggering internal or external analytics scripts.
Ideal for enterprise use cases where you want to:
- Monitor uptime or check page content
- Avoid polluting internal analytics data
- Block self-hosted tracking domains
This file contains hidden or 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 boto3 | |
import hashlib | |
from dotenv import load_dotenv | |
from botocore.exceptions import ClientError | |
load_dotenv() | |
# Initialize DynamoDB client | |
dynamodb = boto3.resource('dynamodb') | |
table = dynamodb.Table('gen_cache') |
This file contains hidden or 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 csv | |
def position_to_row_col(csv_file_path, byte_position): | |
try: | |
with open(csv_file_path, 'r', encoding='utf-8') as file: | |
csv_reader = csv.reader(file) | |
current_pos = 0 | |
for row_num, row in enumerate(csv_reader, start=1): | |
for col_num, cell in enumerate(row, start=1): |
This file contains hidden or 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 csv | |
import re | |
def has_special_characters(text): | |
# Define a regular expression to match non-alphanumeric and non-Markdown special characters | |
special_char_pattern = re.compile(r'[^a-zA-Z0-9\s,.!?;:()"\'*?_~`\-+=<>{}\[\]\\\\|/^#]', re.UNICODE) | |
return bool(special_char_pattern.search(text)) | |
def find_rows_with_special_characters(file_path): |