Skip to content

Instantly share code, notes, and snippets.

@aloni636
aloni636 / ics_google_calendar_unmerge.py
Last active June 23, 2024 00:02
ICS Google-Calendar Unmerge
# Added .ics file mistakenly to google calendar? Undo using this script.
# Iterate over all events and delete ones with icalUID which contains a unique identifier of events in the .ics file
# %%
# pip install gcsa
from gcsa.google_calendar import GoogleCalendar
from datetime import datetime
TARGET_GOOGLE_CALENDAR_NAME = None # None => default calender
ICALUID_IDENTIFIER = "some_name" # icalUID
@aloni636
aloni636 / utils.py
Created March 12, 2024 12:53
General Python Utilities
from typing import Callable
def conditional_decorator(condition: bool, decorator: Callable, *args, **kwargs):
if condition:
if len(args) == 0 and len(kwargs) == 0:
return decorator
return decorator(*args, **kwargs)
return lambda x: x
@aloni636
aloni636 / pyspark_utils.py
Last active November 4, 2024 13:47
General PySpark utilities I didn't find anywhere else.
# dev environment: https://github.com/jplane/pyspark-devcontainer
from pyspark.sql import functions as F, Column
import string
from typing import Dict, Union, Callable
from functools import reduce
def interpolate_string(template: str, strict: bool = True, **kwargs: Dict[str, Union[str, Column]]):
"""
- `template`: string with python string placeholders
- `strict`: if False, placeholders with no matching kwarg will be automaticity replaced with column of their name
@aloni636
aloni636 / Profile.ps1
Created February 11, 2024 12:12
Windows PS1 Profile
# file location: $HOME\Documents\PowerShell\Profile.ps1
# ref: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_profiles?view=powershell-7.4#profile-types-and-locations
# aliases
New-Alias -Name Unzip -Value Expand-Archive
New-Alias -Name Which -Value Get-Command
function Get-Size {
param (