Skip to content

Instantly share code, notes, and snippets.

View SKaplanOfficial's full-sized avatar

Stephen Kaplan SKaplanOfficial

View GitHub Profile
@SKaplanOfficial
SKaplanOfficial / classical_radio_stations.json
Created February 8, 2023 06:52
A set of many classical radio stations for use with the Internet Radio extension for Raycast.
{"New England Public Radio WFCR":{"name":"New England Public Radio WFCR","website":"https://www.nepm.org","stream":"https://nepr.streamguys1.com/WFCR.mp3","genres":["community","news","classical","jazz","public",""],"description":["News"," jazz"," and classical music."],"discontinued":"false"},"Venice Classic Radio":{"name":"Venice Classic Radio","website":"https://www.veniceclassicradio.eu","stream":"https://uk2.streamingpulse.com/ssl/vcr2","genres":["classical","baroque","opera","italian",""],"description":["A repertoire of early"," baroque"," classical and romantic music!"],"discontinued":"false"},"Minnesota Public Radio YourClassical":{"name":"Minnesota Public Radio YourClassical","website":"https://www.yourclassical.org/playlist/classical-mpr","stream":"https://cms.stream.publicradio.org/cms.aac","genres":["classical","public",""],"description":"YourClassical MPR provides lively classical music and good company to listeners throughout the day.","discontinued":"false","location":["Minneapolis"," Minnesota
@SKaplanOfficial
SKaplanOfficial / finder_window_snap.py
Created November 15, 2022 15:30
PyXA script for mimicking Window's window snapping feature on macOS
# Tested with PyXA 0.1.1
import PyXA
from enum import Enum
class LockPosition(Enum):
NONE = 0
LOCK_TOP_LEFT = 1
LOCK_TOP = 2
LOCK_TOP_RIGHT = 3
LOCK_RIGHT = 4
@SKaplanOfficial
SKaplanOfficial / genre_scatterplot.py
Last active January 18, 2023 21:40
PyXA script to create a scatterplot of the average duration of songs per genre in your Music.app library
from collections import Counter
import matplotlib.pyplot as plt
import numpy as np
import PyXA # Version 0.2.0
app = PyXA.Application("Music")
tracks = app.tracks().greater_than("duration", 0)
@SKaplanOfficial
SKaplanOfficial / music_genre_histogram.py
Last active January 18, 2023 22:01
PyXA script to generate a histogram of track genres in your Music.app library
from collections import Counter
import matplotlib.pyplot as plt
import numpy as np
import PyXA # Version 0.2.0
app = PyXA.Application("Music")
genre_data = Counter(app.tracks().genre()).most_common()
@SKaplanOfficial
SKaplanOfficial / stitch_images.py
Last active October 19, 2022 19:04
PyXA script to stitch images together vertically and horizontally
import PyXA
from random import random
# Horizontal stitching
colors = [PyXA.XAColor(random(), 0, random()) for i in range(100)]
swatches = [c.make_swatch(10, 500) for c in colors]
PyXA.XAImage.horizontal_stitch(swatches).show_in_preview()
# Vertical stitching
files = ["/Users/exampleUser/Desktop/cat1.jpeg", "/Users/exampleUser/Desktop/cat2.jpeg", "/Users/exampleUser/Desktop/cat3.jpeg"]
@SKaplanOfficial
SKaplanOfficial / entity_tagging.py
Last active January 18, 2023 21:58
Named entity tagging with PyXA
import PyXA # Version 0.2.0
text = PyXA.XAText("Tim Cook is the CEO of Apple.")
print(text.tag_entities())
# [('Tim', 'PersonalName'), ('Cook', 'PersonalName'), ('is', 'Verb'), ('the', 'Determiner'), ('CEO', 'Noun'), ('of', 'Preposition'), ('Apple', 'OrganizationName')]
@SKaplanOfficial
SKaplanOfficial / simple_sentiment_tagging.py
Last active January 18, 2023 21:57
Sentiment tagging with PyXA
import PyXA # Version 0.2.0
# Use the default sentiment scale
text = PyXA.XAText("This sucks.\nBut this is great!")
print(text.tag_sentiments())
# [('This sucks.\n', 'Negative'), ('But this is great!', 'Positive')]
# Use a custom sentiment scale
text = PyXA.XAText("This sucks.\nBut this is good!\nAnd this is great!")
print(text.tag_sentiments(sentiment_scale=["Very Negative", "Negative", "Somewhat Negative", "Neutral", "Somewhat Positive", "Positive", "Very Positive"]))
@SKaplanOfficial
SKaplanOfficial / junk_email_classifier.py
Last active January 18, 2023 21:56
PyXA script to classify email subject lines as junk or other using Latent Semantic Mapping
import PyXA # Version 0.2.0
app = PyXA.Application("Mail")
dataset = {
"junk": app.accounts()[0].mailboxes().by_name("Junk").messages().subject(),
"other": app.accounts()[0].mailboxes().by_name("INBOX").messages().subject()
}
queries = [
"Amazon Web Services Billing Statement Available",
@SKaplanOfficial
SKaplanOfficial / run_flow_when_notes_open.py
Last active January 18, 2023 21:54
PyXA script to run a Flow session only when a specific application (Notes) is open. Session stops when Notes is closed and restarts if the app is opened again.
import PyXA # Version 0.2.0
from time import sleep
flow = PyXA.Application("Flow")
in_session = False
while True:
apps = PyXA.running_applications().localized_name()
if "Notes" in apps and not in_session:
flow.start()
@SKaplanOfficial
SKaplanOfficial / sort_desktop_files.py
Last active January 18, 2023 22:52
PyXA script to sort files on the desktop into appropriate category folders
import PyXA # Version 0.2.1
app = PyXA.Application("System Events")
desktop_files = app.desktop_folder.files()
desktop_folders = app.desktop_folder.folders()
# Create sorting bin folders
images_folder = app.make("folder", {"name": "Images"})
videos_folder = app.make("folder", {"name": "Videos"})
audio_folder = app.make("folder", {"name": "Audio"})