Skip to content

Instantly share code, notes, and snippets.

@crucialfelix
Last active October 8, 2023 20:37
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save crucialfelix/e53eb81ab07db618e36afb0570fd2358 to your computer and use it in GitHub Desktop.
Save crucialfelix/e53eb81ab07db618e36afb0570fd2358 to your computer and use it in GitHub Desktop.
Get Chrome history for a single day and create a markdown file summarizing browsing activity
# [[2023-01-13]] log
## URLs
- <strong>www.amazon.de</strong>
- [Prime Video - Video on Demand - Online-Videothek: Filme und Serien online ansehen oder als Einzelabruf online leihen oder kaufen](https://www.amazon.de/Amazon-Video/b/?node=3010075031&ref=atv_surl_aiv&redirectToCMP=1) /Amazon-Video/b/
- <strong>www.youtube.com</strong>
- [Parwal vs Kundru | कुंदरु या परवल | Pointed Gourd Vs Ivy Gourd | Everyday Life # 267 - YouTube](https://www.youtube.com/watch?v=6v4XD9T9-Rg&themeRefresh=1) /watch
- [YouTube](https://www.youtube.com/) /
- <strong>youtube.com</strong>
- [YouTube](http://youtube.com/) /
- <strong>news.ycombinator.com</strong>
- [Hacker News](https://news.ycombinator.com/) /
- [Twitter's API is down? | Hacker News](https://news.ycombinator.com/item?id=34363743) /item
- <strong>www.newyorker.com</strong>
- [Franz Kafka, Party Animal | The New Yorker](https://www.newyorker.com/magazine/2023/01/16/the-diaries-of-franz-kafka-party-animal) /magazine/2023/01/16/the-diaries-of-franz-kafka-party-animal
- <strong>mail.google.com</strong>
- <strong>chat.openai.com</strong>
- [New chat](https://chat.openai.com/chat) /chat
- [Just a moment...](https://chat.openai.com/?__cf_chl_rt_tk=zXEr3YQujxDv6LRFk5ZeQ16VE5EpoOi4F2cGZ1S69iQ-1673594822-0-gaNycGzNFmU) /
- <strong>antonsmindstorms.com</strong>
- [EV3 vs Robot Inventor: LEGO 51515 and 31313 sets compared](https://antonsmindstorms.com/2020/10/11/robot-inventor-vs-ev3/) /2020/10/11/robot-inventor-vs-ev3/
- <strong>pybricks.com</strong>
- [Ev3rstorm - Python project for LEGO MINDSTORMS EV3 Main models (31313) - Pybricks](https://pybricks.com/projects/sets/mindstorms-ev3/home-main/ev3rstorm/) /projects/sets/mindstorms-ev3/home-main/ev3rstorm/
- <strong>www.google.com</strong>
- [kundru - Google Search](https://www.google.com/search?q=kundru&oq=kundru&aqs=chrome.0.0i355i512j46i512j0i512l5j69i61.1369j0j7&sourceid=chrome&ie=UTF-8) /search
- [Parwal vs Kundru | कुंदरु या परवल | Pointed Gourd Vs Ivy Gourd | Everyday Life # 267 - YouTube](https://www.google.com/url?sa=i&url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D6v4XD9T9-Rg&psig=AOvVaw0vtDoRQwsdaQwRh3q2JFSb&ust=1673678869389000&source=images&cd=vfe&ved=0CBIQ3YkBahcKEwigmL_l-cP8AhUAAAAAHQAAAAAQBA) /url
- <strong>www.lego.com</strong>
- [LEGO® MINDSTORMS® | Invent a Robot | Official LEGO® Shop US](https://www.lego.com/en-us/themes/mindstorms) /en-us/themes/mindstorms
- [Robot Inventor 51515 | MINDSTORMS® | Buy online at the Official LEGO® Shop US](https://www.lego.com/en-us/product/robot-inventor-51515) /en-us/product/robot-inventor-51515
- [LEGO® MINDSTORMS® | Invent a Robot | Official LEGO® Shop US](https://www.lego.com/en-us/mindstorms/downloads/download-software) /en-us/mindstorms/downloads/download-software
- <strong>lego.com</strong>
- [LEGO® MINDSTORMS® | Invent a Robot | Official LEGO® Shop US](https://lego.com/mindstorms/software) /mindstorms/software
- <strong>twitter.com</strong>
- [Notifications / Twitter](https://twitter.com/notifications) /notifications
- [(1) Home / Twitter](https://twitter.com/home) /home
- [https://twitter.com](https://twitter.com/) /
- [Chris Sattinger on Twitter: "@stolinski Maintenance is the big issue. The css and the html diverge, lots of zombie css—and that takes time to prune safely. Frameworks make the problem even worse." / Twitter](https://twitter.com/crucialfelix/status/1613848623070040065) /crucialfelix/status/1613848623070040065
- [Liked / Twitter](https://twitter.com/i/timeline) /i/timeline
- [(2) Scott Tolinski - Syntax.fm - Level Up Tuts on Twitter: "Is it possible to get @code to actually go to definition instead of the type definition? I swear this was supposed to be fixed, but I've never had it working." / Twitter](https://twitter.com/stolinski/status/1613596150564638720) /stolinski/status/1613596150564638720
- [Scott Tolinski - Syntax.fm - Level Up Tuts on Twitter: "At this point why not just write css." / Twitter](https://twitter.com/stolinski/status/1613699772111638530) /stolinski/status/1613699772111638530
- [Scott Tolinski - Syntax.fm - Level Up Tuts on Twitter: "At this point why not just write css." / Twitter](https://twitter.com/compose/tweet) /compose/tweet
- [Freya Holmér on Twitter: "wait wouldn't a world with a sophisticated ChatGPT and voice synthesis effectively allow for the social equivalent of DDOS attacks? like, flooding any service with legitimately believable callers and emails, indistinguishable from real people" / Twitter](https://twitter.com/FreyaHolmer/status/1613519058691035138) /FreyaHolmer/status/1613519058691035138
- [Home / Twitter](https://twitter.com/FredKSchott/status/1613668211593183232/photo/1) /FredKSchott/status/1613668211593183232/photo/1
- [Home / Twitter](https://twitter.com/crucialfelix/status/1613840783945105411/photo/1) /crucialfelix/status/1613840783945105411/photo/1
- [Home / Twitter](https://twitter.com/compose/tweet/media) /compose/tweet/media
- [Shiv Aroor on Twitter: "Annual reminder that Kundru / Tendle / Kovakkai / Tondekayi is the worst vegetable on earth. https://t.co/dODU1QFCes" / Twitter](https://twitter.com/ShivAroor/status/1613558052577505285) /ShivAroor/status/1613558052577505285
- [Shiv Aroor on Twitter: "Annual reminder that Kundru / Tendle / Kovakkai / Tondekayi is the worst vegetable on earth. https://t.co/dODU1QFCes" / Twitter](https://twitter.com/smitaprakash/status/1612822697343619075/photo/1) /smitaprakash/status/1612822697343619075/photo/1
- [RC Shukl on Twitter: "@ShivAroor इसको पूर्वी उत्तर प्रदेश में बुद्धि नाशक कहते हैं।" / Twitter](https://twitter.com/RC_Shukl/status/1613584987529543681) /RC_Shukl/status/1613584987529543681
- <strong>docs.djangoproject.com</strong>
- [Built-in template tags and filters | Django documentation | Django](https://docs.djangoproject.com/en/4.1/ref/templates/builtins/) /en/4.1/ref/templates/builtins/
- <strong>localhost</strong>
- [author_tweet · Streamlit](http://localhost:8501/) /
- [FastAPI - Swagger UI](http://localhost:8000/docs) /docs
- [FastAPI - ReDoc](http://localhost:8000/redoc#tag/nodes/operation/get_accepted) /redoc
- [Mapping Demo](http://localhost:8501/Mapping_Demo) /Mapping_Demo
- [DataFrame Demo](http://localhost:8501/DataFrame_Demo) /DataFrame_Demo
- [Plotting Demo](http://localhost:8501/Plotting_Demo) /Plotting_Demo
- [Animation Demo](http://localhost:8501/Animation_Demo) /Animation_Demo
- <strong>vincelwt.com</strong>
- [🛰️ Liu Cixin's technologies of the future | vincelwt.com](https://vincelwt.com/darkforest) /darkforest
- <strong>alpinejs.dev</strong>
- [Alpine.js](https://alpinejs.dev/) /
- <strong>www.theatlantic.com</strong>
- [America Is on the Right Track - The Atlantic](https://www.theatlantic.com/ideas/archive/2023/01/american-optimism-productivity-innovation-rise/672714/) /ideas/archive/2023/01/american-optimism-productivity-innovation-rise/672714/
- <strong>meet.google.com</strong>
- [Meet - bzy-wkix-rzy](https://meet.google.com/bzy-wkix-rzy?authuser=0&hs=122&ijlm=1673618290143) /bzy-wkix-rzy
- <strong>www.linkedin.com</strong>
- [Post | Feed | LinkedIn](https://www.linkedin.com/feed/update/urn:li:activity:7019632246105993216/?origin=SHARED_BY_YOUR_NETWORK) /feed/update/urn:li:activity:7019632246105993216/
- [LinkedIn](https://www.linkedin.com/notifications/?filter=all) /notifications/
- [(7) Feed | LinkedIn](https://www.linkedin.com/feed/) /feed/
- [(7) LinkedIn](https://www.linkedin.com/) /
- <strong>linkedin.com</strong>
- [(7) LinkedIn](https://linkedin.com/) /
- <strong>regex101.com</strong>
- [regex101: build, test, and debug regex](https://regex101.com/codegen?language=python) /codegen
- [regex101: build, test, and debug regex](https://regex101.com/) /
- <strong>beta.openai.com</strong>
- [Billing overview - OpenAI API](https://beta.openai.com/account/billing/overview) /account/billing/overview
- [Payment methods - OpenAI API](https://beta.openai.com/account/billing/payment-methods) /account/billing/payment-methods
- [Account - OpenAI API](https://beta.openai.com/account/billing) /account/billing
- [Account - OpenAI API](https://beta.openai.com/account/usage) /account/usage
- [API Reference - OpenAI API](https://beta.openai.com/account) /account
- [API Reference - OpenAI API](https://beta.openai.com/docs/api-reference/completions/create) /docs/api-reference/completions/create
- [API Reference - OpenAI API](https://beta.openai.com/docs/api-reference/completions) /docs/api-reference/completions
- [API Reference - OpenAI API](https://beta.openai.com/docs/api-reference/models?lang=python) /docs/api-reference/models
- [API Reference - OpenAI API](https://beta.openai.com/docs/api-reference/making-requests?lang=python) /docs/api-reference/making-requests
- [Introduction - OpenAI API](https://beta.openai.com/docs/introduction) /docs/introduction
- [Examples - OpenAI API](https://beta.openai.com/docs) /docs
- [Examples - OpenAI API](https://beta.openai.com/examples) /examples
- [Examples - OpenAI API](https://beta.openai.com/examples/default-summarize) /examples/default-summarize
- [Examples - OpenAI API](https://beta.openai.com/examples/default-tldr-summary) /examples/default-tldr-summary
- [Examples - OpenAI API](https://beta.openai.com/examples/default-third-person) /examples/default-third-person
- [API Reference - OpenAI API](https://beta.openai.com/docs/api-reference/models/retrieve) /docs/api-reference/models/retrieve
- [API Reference - OpenAI API](https://beta.openai.com/docs/api-reference/models/list) /docs/api-reference/models/list
- [API Reference - OpenAI API](https://beta.openai.com/docs/api-reference/engines) /docs/api-reference/engines
- [API Reference - OpenAI API](https://beta.openai.com/docs/api-reference/embeddings/create) /docs/api-reference/embeddings/create
- [API Reference - OpenAI API](https://beta.openai.com/docs/api-reference/embeddings) /docs/api-reference/embeddings
- [API Reference - OpenAI API](https://beta.openai.com/docs/api-reference/images/create-variation) /docs/api-reference/images/create-variation
- [API Reference - OpenAI API](https://beta.openai.com/docs/api-reference/images/create-edit) /docs/api-reference/images/create-edit
- [API Reference - OpenAI API](https://beta.openai.com/docs/api-reference/images/create) /docs/api-reference/images/create
- [API Reference - OpenAI API](https://beta.openai.com/docs/api-reference/images) /docs/api-reference/images
- [API Reference - OpenAI API](https://beta.openai.com/docs/api-reference/edits/create) /docs/api-reference/edits/create
- [API Reference - OpenAI API](https://beta.openai.com/docs/api-reference/edits) /docs/api-reference/edits
- [Just a moment...](https://beta.openai.com/account/api-keys?__cf_chl_rt_tk=pzD4E7CC.dYAMSOiPvvWZj4rg10iGilH6dVIC8.NIlc-1673602340-0-gaNycGzNDeU) /account/api-keys
- [API Reference - OpenAI API](https://beta.openai.com/docs/api-reference/authentication?lang=python) /docs/api-reference/authentication
- [API Reference - OpenAI API](https://beta.openai.com/docs/api-reference/introduction?lang=python) /docs/api-reference/introduction
- [API Reference - OpenAI API](https://beta.openai.com/docs/api-reference?lang=python) /docs/api-reference
- [Embeddings - OpenAI API](https://beta.openai.com/docs/guides/embeddings) /docs/guides/embeddings
- [Overview - OpenAI API](https://beta.openai.com/overview) /overview
- [OpenAI API](https://beta.openai.com/auth/callback?code=6NdKalPvabJwJNp4qlsV6tbumWodYvbPWEWNPwN391zSV&state=SEN3NXB3U3F4QzZfLTZOTHR0MUtFN0lJV255UUlyb0FrUDcwNlRoaXBvcg%3D%3D) /auth/callback
- [Just a moment...](https://beta.openai.com/login/?__cf_chl_rt_tk=mVB5QEf0f6WE1bJ0DWK0ZKOC5mimbNKJJM2zJN0VHFY-1673594882-0-gaNycGzNCb0) /login/
- <strong>docs.streamlit.io</strong>
- [💤 st.markdown - Streamlit Docs](https://docs.streamlit.io/library/api-reference/text/st.markdown) /library/api-reference/text/st.markdown
- [Text elements - Streamlit Docs](https://docs.streamlit.io/library/api-reference/text) /library/api-reference/text
- [Layouts and Containers - Streamlit Docs](https://docs.streamlit.io/library/api-reference/layout) /library/api-reference/layout
- [st.button - Streamlit Docs](https://docs.streamlit.io/library/api-reference/widgets/st.button) /library/api-reference/widgets/st.button
- [st.selectbox - Streamlit Docs](https://docs.streamlit.io/library/api-reference/widgets/st.selectbox) /library/api-reference/widgets/st.selectbox
- [Input widgets - Streamlit Docs](https://docs.streamlit.io/library/api-reference/widgets) /library/api-reference/widgets
- [Chart elements - Streamlit Docs](https://docs.streamlit.io/library/api-reference/charts) /library/api-reference/charts
- [Data display elements - Streamlit Docs](https://docs.streamlit.io/library/api-reference/data) /library/api-reference/data
- [API Reference - Streamlit Docs](https://docs.streamlit.io/library/api-reference) /library/api-reference
- [Streamlit documentation](https://docs.streamlit.io/) /
- [Multipage apps - Streamlit Docs](https://docs.streamlit.io/library/get-started/multipage-apps) /library/get-started/multipage-apps
- [Create an app - Streamlit Docs](https://docs.streamlit.io/library/get-started/create-an-app) /library/get-started/create-an-app
- [Installation - Streamlit Docs](https://docs.streamlit.io/library/get-started/installation) /library/get-started/installation
- [Get started - Streamlit Docs](https://docs.streamlit.io/library/get-started) /library/get-started
- [Main concepts - Streamlit Docs](https://docs.streamlit.io/library/get-started/main-concepts) /library/get-started/main-concepts
- [Deploy Streamlit apps - Streamlit Docs](https://docs.streamlit.io/knowledge-base/tutorials/deploy) /knowledge-base/tutorials/deploy
- [Tutorials - Streamlit Docs](https://docs.streamlit.io/knowledge-base/tutorials) /knowledge-base/tutorials
- [Components - Streamlit Docs](https://docs.streamlit.io/library/components) /library/components
- [Advanced features - Streamlit Docs](https://docs.streamlit.io/library/advanced-features) /library/advanced-features
- <strong>doc-buton.streamlit.app</strong>
- [st.button - Streamlit Docs](https://doc-buton.streamlit.app/?embedded=true) /
- [st.button - Streamlit Docs](https://doc-buton.streamlit.app/~/+/?embedded=true) /~/+/
- <strong>doc-selectbox1.streamlit.app</strong>
- [st.selectbox - Streamlit Docs](https://doc-selectbox1.streamlit.app/?embedded=true) /
- [st.selectbox - Streamlit Docs](https://doc-selectbox1.streamlit.app/~/+/?embedded=true) /~/+/
- <strong>doc-selectbox.streamlit.app</strong>
- [st.selectbox - Streamlit Docs](https://doc-selectbox.streamlit.app/?embedded=true) /
- [st.selectbox - Streamlit Docs](https://doc-selectbox.streamlit.app/~/+/?embedded=true) /~/+/
- <strong>www.gradio.app</strong>
- [Gradio Docs](https://www.gradio.app/docs/) /docs/
- <strong>gradio.app</strong>
- [Sharing Your App](https://gradio.app/sharing_your_app/) /sharing_your_app/
- <strong>github.com</strong>
- [explosion/spacy-streamlit: 👑 spaCy building blocks and visualizers for Streamlit apps](https://github.com/explosion/spacy-streamlit) /explosion/spacy-streamlit
- [openai/openai-python](https://github.com/openai/openai-python) /openai/openai-python
- [ChrisDelClea/streamlit-agraph: A Streamlit Graph Vis](https://github.com/ChrisDelClea/streamlit-agraph) /ChrisDelClea/streamlit-agraph
- [ChrisDelClea/streamlit-agraph: A Streamlit Graph Vis](https://github.com/ChrisChross/streamlit-agraph) /ChrisChross/streamlit-agraph
- <strong>stackoverflow.com</strong>
- [sockets - Python ConnectionRefusedError: [Errno 61] Connection refused - Stack Overflow](https://stackoverflow.com/questions/40814712/python-connectionrefusederror-errno-61-connection-refused) /questions/40814712/python-connectionrefusederror-errno-61-connection-refused
- [bash - Set environment variables from file of key/value pairs - Stack Overflow](https://stackoverflow.com/questions/19331497/set-environment-variables-from-file-of-key-value-pairs) /questions/19331497/set-environment-variables-from-file-of-key-value-pairs
- <strong>fastapi.tiangolo.com</strong>
- [FastAPI](https://fastapi.tiangolo.com/) /
- <strong>streamlit.io</strong>
- [Streamlit • The fastest way to build and share data apps](https://streamlit.io/) /
- [Components • Streamlit](https://streamlit.io/components?category=nlp) /components
- <strong>roadmap.streamlit.app</strong>
- [Streamlit](https://roadmap.streamlit.app/) /
- [Streamlit](https://roadmap.streamlit.app/~/+/) /~/+/
- <strong>towardsdatascience.com</strong>
- [Plotly Dash vs Streamlit — Which is the best library for building data dashboard web apps? | by JP Hwang | Towards Data Science](https://towardsdatascience.com/plotly-dash-vs-streamlit-which-is-the-best-library-for-building-data-dashboard-web-apps-97d7c98b938c?gi=db8c1d1646d0) /plotly-dash-vs-streamlit-which-is-the-best-library-for-building-data-dashboard-web-apps-97d7c98b938c
- <strong>medium.com</strong>
- [Plotly Dash vs Streamlit — Which is the best library for building data dashboard web apps? | by JP Hwang | Towards Data Science](https://medium.com/m/signin?actionUrl=https%3A%2F%2Fmedium.com%2F_%2Fp%2F97d7c98b938c%2Fquotes%2Fcreate%3FendOffset%3D76%26paragraphName%3De75f%26startOffset%3D0%26versionId%3Df49a31da1b8a&operation=register&redirect=https%3A%2F%2Ftowardsdatascience.com%2Fplotly-dash-vs-streamlit-which-is-the-best-library-for-building-data-dashboard-web-apps-97d7c98b938c&source=--------------------------highlight_text-----------) /m/signin
- <strong>www.webdesignmuseum.org</strong>
- [netscape-navigator-2-01-preview.png (450×300)](https://www.webdesignmuseum.org/uploaded/old-software/web-browsers/netscape-navigator/netscape-navigator-2-01-preview.png) /uploaded/old-software/web-browsers/netscape-navigator/netscape-navigator-2-01-preview.png
- <strong>www.datarevenue.com</strong>
- [Data dashboarding tools | Streamlit v.s. Dash v.s. Shiny vs. Voila vs. Flask vs. Jupyter](https://www.datarevenue.com/en-blog/data-dashboarding-streamlit-vs-dash-vs-shiny-vs-voila#:~:text=Streamlit%20is%20more%20structured%20and,Dash%20is%20more%20adaptable.) /en-blog/data-dashboarding-streamlit-vs-dash-vs-shiny-vs-voila
- <strong>accounts.google.com</strong>
- <strong>openai.com</strong>
- [OpenAI API](https://openai.com/api/login) /api/login
- [OpenAI API](https://openai.com/api/) /api/
- [OpenAI](https://openai.com/) /
- <strong>share.streamlit.io</strong>
- <strong>chrisdelclea-word-knowledge-graph-main-luylof.streamlit.app</strong>
- [Streamlit](https://chrisdelclea-word-knowledge-graph-main-luylof.streamlit.app/~/+/) /~/+/
- [Streamlit](https://chrisdelclea-word-knowledge-graph-main-luylof.streamlit.app/) /
- <strong>chrisdelclea-word-knowledge-graph-main-luylof.streamlitapp.com</strong>
- [Streamlit](https://chrisdelclea-word-knowledge-graph-main-luylof.streamlitapp.com/) /
- <strong>dfir.blog</strong>
- [Hindsight](https://dfir.blog/hindsight/) /hindsight/
- <strong>www.programmableweb.com</strong>
- [96 Sustainability APIs (2022) | ProgrammableWeb](https://www.programmableweb.com/category/sustainability/api) /category/sustainability/api
- <strong>marketplace.visualstudio.com</strong>
- [GitHub Copilot Labs - Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=GitHub.copilot-labs) /items
- <strong>githubnext.com</strong>
- [GitHub Next | Code Brushes](http://githubnext.com/projects/code-brushes) /projects/code-brushes
- <strong>t.co</strong>
- [GitHub Next | Code Brushes](https://t.co/pbdcEj3vgm) /pbdcEj3vgm
- [Green World - Berlin - Jan 29](https://t.co/GAeCtfvoNL?twclid=23ea5dpnj2znat7j83ocggljjl) /GAeCtfvoNL
- <strong>greenworld.wtf</strong>
- [Green World - Berlin - Jan 29](https://greenworld.wtf/?twclid=23ea5dpnj2znat7j83ocggljjl) /
- <strong>www.greenworld.wtf</strong>
- [Green World - Berlin - Jan 29](https://www.greenworld.wtf/?twclid=23ea5dpnj2znat7j83ocggljjl) /
- <strong>www.wandb.courses</strong>
- [W&B Courses](https://www.wandb.courses/pages/w-b-courses?utm_source=twitter&utm_medium=cpc&utm_campaign=course-11dec22&twclid=2-7315k2cghe809hckuna57pug5) /pages/w-b-courses
#!/bin/bash
# print Chrome browser history for a single day as CSV to STDOUT
# date format: YYYY-MM-DD
set -e
set -u
args=("$@")
if [ $# -eq 0 ]
then
echo "No arguments supplied"
exit 1
fi
day=${args[0]}
# echo "day: $day"
# till one day later
till=$(date -v+1d -j -f "%Y-%m-%d" $day "+%Y-%m-%d")
if [ -z "$till" ]
then
echo "till is empty. Failed to parse date."
exit 1
fi
SQL="SELECT url,title,last_visit_time,datetime(last_visit_time / 1000000 - 11644473600, 'unixepoch', 'localtime') as visit_time FROM urls where visit_time >= '$day' and visit_time < '$till' order by last_visit_time desc;"
# echo $SQL
# copy to tmp so you can read locked database
cp ~/Library/Application\ Support/Google/Chrome/Default/History /tmp/History
sqlite3 -readonly /tmp/History -header -csv "$SQL"
"""Create a markdown page listing my Chrome browser history for a single day
Usage:
```bash
# summarize yesterday
python summarize_day.py
# summarize a day (3 month chrome history limit)
python summarize_day.py --date 2023-01-12
# summarize the last 90 days
python summarize_day.py --days 90
```
Saves as:
~/org/YYYY/MM/DD.log.md
Requirements:
- https://typer.tiangolo.com/
- https://mdutils.readthedocs.io/
"""
from collections import defaultdict
from urllib.parse import urlparse
from mdutils import MdUtils
import typer
import subprocess
import csv
import datetime
from pathlib import Path
HOME = Path("/Users/crucialfelix")
ORG = HOME / "org"
def get_history(day: str):
# get chrome history as csv
result = subprocess.run(
[HOME / "bin" / "chrome-history-for-day.sh", day],
capture_output=True,
text=True,
)
out = result.stdout
# print(result.stdout)
# print(result.stderr)
# load csv from result stdout
lines = out.splitlines()
reader = csv.DictReader(lines)
for row in reader:
p = urlparse(row["url"])
host = p.hostname
visit_time = datetime.datetime.strptime(row["visit_time"], "%Y-%m-%d %H:%M:%S")
yield {
"url": row["url"],
"path": p.path,
"host": host,
"title": row["title"],
"visit_time": visit_time,
}
# create markdown file
# group by hosts, sort by first time
# list urls with titles and sort by time
def main(date: str = "yesterday", days: int = typer.Option(0)):
print(days, date)
if days:
for days_ago in range(days):
dt = datetime.datetime.now() - datetime.timedelta(days=days_ago + 1)
date = dt.strftime("%Y-%m-%d")
summarize_date(date)
print(date)
return
if date == "yesterday":
dt = datetime.datetime.now() - datetime.timedelta(days=1)
date = dt.strftime("%Y-%m-%d")
summarize_date(date)
return
summarize_date(date)
def summarize_date(date):
year, month, day = date.split("-")
file_name = ORG / year / month / f"{date}.log.md"
mdFile = MdUtils(file_name=file_name.as_posix())
mdFile.new_header(level=1, title=f"[[{date}]] log")
mdFile.new_header(level=2, title="URLs")
hosts = defaultdict(dict)
for h in get_history(date):
host = h["host"]
url = h["url"]
path = h["path"]
text = h["title"]
# text = h['url']
link = mdFile.new_inline_link(link=url, text=text)
hosts[host][path] = link + " " + path
urls = []
for host, links in hosts.items():
urls.append(f"<strong>{host}</strong>")
urls.append(list(links.values()))
mdFile.new_list(urls)
print(urls)
mdFile.new_header(level=2, title="Modified files")
mdFile.new_paragraph(f"{date}")
mdFile.create_md_file()
if __name__ == "__main__":
typer.run(main)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment