Compare commits
2 Commits
a75429421c
...
9692e06cca
Author | SHA1 | Date |
---|---|---|
publicmatt | 9692e06cca | |
publicmatt | eb32384a4e |
|
@ -0,0 +1,2 @@
|
||||||
|
.env
|
||||||
|
.venv
|
|
@ -0,0 +1,16 @@
|
||||||
|
PYTHON=.venv/bin/python
|
||||||
|
|
||||||
|
.PHONY: build install
|
||||||
|
|
||||||
|
install: requirements.txt
|
||||||
|
$(PYTHON) -m pip install -r $^
|
||||||
|
|
||||||
|
build: build-svg.py template.svg
|
||||||
|
$(PYTHON) $<
|
||||||
|
git add '*.svg' && \
|
||||||
|
GIT_AUTHOR_NAME='publicmatt' GIT_AUTHOR_EMAIL='git@publicmatt.com' \
|
||||||
|
GIT_COMMITTER_NAME='publicmatt' GIT_COMMITTER_EMAIL='git@publicmatt.com' \
|
||||||
|
git commit -m "Auto-updating git readme"
|
||||||
|
git push publicmatt
|
||||||
|
git push github
|
||||||
|
|
|
@ -0,0 +1,96 @@
|
||||||
|
import os
|
||||||
|
import requests
|
||||||
|
import pendulum
|
||||||
|
import json
|
||||||
|
from dotenv import load_dotenv
|
||||||
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
# load env files
|
||||||
|
load_dotenv()
|
||||||
|
|
||||||
|
# part of current dir
|
||||||
|
app_path = Path(__file__).parent
|
||||||
|
|
||||||
|
# Environment variable for API key
|
||||||
|
WEATHER_API_KEY = os.getenv("WEATHER_API_KEY")
|
||||||
|
WEATHER_DOMAIN = "http://dataservice.accuweather.com"
|
||||||
|
|
||||||
|
# emojis that accuweather uses
|
||||||
|
emojis = {
|
||||||
|
1: "☀️",
|
||||||
|
2: "☀️",
|
||||||
|
3: "🌤",
|
||||||
|
4: "🌤",
|
||||||
|
5: "🌤",
|
||||||
|
6: "🌥",
|
||||||
|
7: "☁️",
|
||||||
|
8: "☁️",
|
||||||
|
11: "🌫",
|
||||||
|
12: "🌧",
|
||||||
|
13: "🌦",
|
||||||
|
14: "🌦",
|
||||||
|
15: "⛈",
|
||||||
|
16: "⛈",
|
||||||
|
17: "🌦",
|
||||||
|
18: "🌧",
|
||||||
|
19: "🌨",
|
||||||
|
20: "🌨",
|
||||||
|
21: "🌨",
|
||||||
|
22: "❄️",
|
||||||
|
23: "❄️",
|
||||||
|
24: "🌧",
|
||||||
|
25: "🌧",
|
||||||
|
26: "🌧",
|
||||||
|
29: "🌧",
|
||||||
|
30: "🥵",
|
||||||
|
31: "🥶",
|
||||||
|
32: "💨",
|
||||||
|
}
|
||||||
|
|
||||||
|
dayBubbleWidths = {
|
||||||
|
"Monday": 235,
|
||||||
|
"Tuesday": 235,
|
||||||
|
"Wednesday": 260,
|
||||||
|
"Thursday": 245,
|
||||||
|
"Friday": 220,
|
||||||
|
"Saturday": 245,
|
||||||
|
"Sunday": 230,
|
||||||
|
}
|
||||||
|
|
||||||
|
# Time since graduating
|
||||||
|
today = pendulum.now()
|
||||||
|
todayDay = today.format("dddd")
|
||||||
|
|
||||||
|
psTime = pendulum.instance(today).diff_for_humans(
|
||||||
|
pendulum.datetime(2023, 12, 14), absolute=True
|
||||||
|
)
|
||||||
|
|
||||||
|
# Today's weather
|
||||||
|
locationKey = "331416" # Bellingham
|
||||||
|
url = f"forecasts/v1/daily/1day/{locationKey}?apikey={WEATHER_API_KEY}"
|
||||||
|
|
||||||
|
try:
|
||||||
|
response = requests.get(f"{WEATHER_DOMAIN}/{url}")
|
||||||
|
response.raise_for_status()
|
||||||
|
json_data = response.json()
|
||||||
|
|
||||||
|
degF = round(json_data["DailyForecasts"][0]["Temperature"]["Maximum"]["Value"])
|
||||||
|
degC = round((degF - 32) * 5 / 9)
|
||||||
|
icon = json_data["DailyForecasts"][0]["Day"]["Icon"]
|
||||||
|
|
||||||
|
with open(app_path / "template.svg", "r", encoding="utf-8") as file:
|
||||||
|
data = file.read()
|
||||||
|
|
||||||
|
data = data.replace("{degF}", str(degF))
|
||||||
|
data = data.replace("{degC}", str(degC))
|
||||||
|
data = data.replace("{weatherEmoji}", emojis[icon])
|
||||||
|
data = data.replace("{psTime}", psTime)
|
||||||
|
data = data.replace("{todayDay}", todayDay)
|
||||||
|
data = data.replace("{dayBubbleWidth}", str(dayBubbleWidths[todayDay]))
|
||||||
|
|
||||||
|
with open(app_path / "chat.svg", "w", encoding="utf-8") as file:
|
||||||
|
file.write(data)
|
||||||
|
|
||||||
|
except requests.exceptions.RequestException as err:
|
||||||
|
print(err, file=sys.stderr)
|
20
chat.svg
20
chat.svg
|
@ -248,10 +248,10 @@
|
||||||
|
|
||||||
</g>
|
</g>
|
||||||
|
|
||||||
<!-- Hi, I'm Jason -->
|
<!-- Hi, I'm Matt -->
|
||||||
<g transform="translate(10, 0)" class="msg-1 bubble">
|
<g transform="translate(10, 0)" class="msg-1 bubble">
|
||||||
<rect width="133" height="42" rx="18.0355" />
|
<rect width="133" height="42" rx="18.0355" />
|
||||||
<text x="15" y="27">Hi, I'm Jason</text>
|
<text x="15" y="27">Hi, I'm Matt</text>
|
||||||
</g>
|
</g>
|
||||||
|
|
||||||
<!-- typing 2 -->
|
<!-- typing 2 -->
|
||||||
|
@ -272,11 +272,11 @@
|
||||||
|
|
||||||
</g>
|
</g>
|
||||||
|
|
||||||
<!-- From Columbus... -->
|
<!-- From Bellingam... -->
|
||||||
<g transform="translate(10, 48)" class="msg-2">
|
<g transform="translate(10, 48)" class="msg-2">
|
||||||
<rect width="439" height="66.1302" rx="18.0355" class="bubble" />
|
<rect width="439" height="66.1302" rx="18.0355" class="bubble" />
|
||||||
<text x="15" y="27">I live in Columbus, Ohio where it’s supposed to be</text>
|
<text x="15" y="27">I live in Bellingham, Washington where it’s supposed to be</text>
|
||||||
<text x="15" y="50">49° F (9° C) and <tspan class="emoji">🌧</tspan> today.</text>
|
<text x="15" y="50">46° F (8° C) and <tspan class="emoji">🌦</tspan> today.</text>
|
||||||
</g>
|
</g>
|
||||||
|
|
||||||
<!-- typing 3 -->
|
<!-- typing 3 -->
|
||||||
|
@ -300,8 +300,8 @@
|
||||||
<!-- Work ... -->
|
<!-- Work ... -->
|
||||||
<g transform="translate(10, 120)" class="msg-3">
|
<g transform="translate(10, 120)" class="msg-3">
|
||||||
<rect width="439" height="66.1302" rx="18.0355" class="bubble" />
|
<rect width="439" height="66.1302" rx="18.0355" class="bubble" />
|
||||||
<text x="15" y="27">I’m a product designer. I used to work at GitHub,</text>
|
<text x="15" y="27">I write software. I work with web tech, data and machine learning,</text>
|
||||||
<text x="15" y="50">but I’ve been at PlanetScale for almost 3 years now.</text>
|
<text x="15" y="50">and graduated from Western Washington University with a MS in Computer Science 5 days ago.</text>
|
||||||
</g>
|
</g>
|
||||||
|
|
||||||
<!-- typing 4 -->
|
<!-- typing 4 -->
|
||||||
|
@ -322,12 +322,12 @@
|
||||||
|
|
||||||
</g>
|
</g>
|
||||||
|
|
||||||
<!-- Twitter -->
|
<!-- Contact -->
|
||||||
<g transform="translate(10, 192)" class="msg-4">
|
<g transform="translate(10, 192)" class="msg-4">
|
||||||
<rect width="513" height="42" rx="18.0355" class="bubble" />
|
<rect width="513" height="42" rx="18.0355" class="bubble" />
|
||||||
<text x="15" y="27">
|
<text x="15" y="27">
|
||||||
You can find me on Twitter at
|
You can find me online at
|
||||||
<a xlink:href="https://twitter.com/jasonlong">https://twitter.com/jasonlong</a>
|
<a xlink:href="https://www.publicmatt.com">https://www.publicmatt.com/</a>
|
||||||
</text>
|
</text>
|
||||||
</g>
|
</g>
|
||||||
|
|
||||||
|
|
Before Width: | Height: | Size: 134 KiB After Width: | Height: | Size: 134 KiB |
|
@ -0,0 +1,4 @@
|
||||||
|
requests
|
||||||
|
pendulum
|
||||||
|
quantiphy
|
||||||
|
python-dotenv
|
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 134 KiB |
Loading…
Reference in New Issue