Skip to content

Commit

Permalink
Adds CLI, upgrades to 3.12, back-post from Micro.Blog
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhariri committed May 18, 2024
1 parent cf43e0a commit b4bb126
Show file tree
Hide file tree
Showing 14 changed files with 128 additions and 11 deletions.
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Use the specified image as the base
FROM python:3.11.0-slim-buster
FROM python:3.12.2-slim-buster

# Set the working directory
WORKDIR /usr/src/app
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
post:
python cli.py

run:
flask run --port=5001

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
## Develop

```
pyenv virtualenv 3.11.0 site
pyenv activate site
pip install poetry
poetry shell
poetry install --sync
make run
```
Expand Down
33 changes: 33 additions & 0 deletions cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import datetime
import os
import click
from werkzeug.utils import secure_filename

POST_TEMPLATE = """---
title: {title}
date: {date}
tags:
-
description:
---
"""

@click.command()
@click.option("--title", prompt="Enter the title of the new post", help="Title of the new post")
def create_new_post(title):
date = datetime.datetime.now(datetime.timezone(datetime.timedelta(hours=-5))).isoformat()
filename = secure_filename(title).replace("_", "-").lower() + ".md"
filepath = os.path.join("posts", filename)

if os.path.exists(filepath):
click.echo("A post with the same title already exists. Please choose a different title.")
return

with open(filepath, "w") as file:
file.write(POST_TEMPLATE.format(title=title, date=date))

click.echo(f"New post created at {filepath}")

if __name__ == "__main__":
create_new_post()
6 changes: 3 additions & 3 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions posts/craft-is-an-advantage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
title: Craft as Advantage
date: 2024-05-07T22:29:20.097611-05:00
tags:
- craft
description:
---
Tonight, Mike asked Tobi what Canada’s competitive advantage could become. Tobi’s answer was “craft”. I think he’s right and we should all hold each other to a higher bar by buying each others things and giving each other the hard, but necessary feedback to make Canada the Bauhaus of software.

![Mike asking Tobi](https://davidhariri.micro.blog/uploads/2024/5c6dbe06c5.jpg)
9 changes: 9 additions & 0 deletions posts/duty.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
title: Duty
date: 2024-05-12 17:14:17.701380-05
tags:
- philosophy
---
> "We ought to do good to others as simply as a horse runs, or a bee makes honey, or a vine bears grapes season after season without thinking of the grapes it has borne." — Marcus Aurelius, Meditations
The answer to 'why work hard?', 'why strive for perfection?', 'why care about craft?' does not need to be more complicated than **'duty'**. When was the last time you saw a bee be lazy? Humans were made to make.
10 changes: 10 additions & 0 deletions posts/jim-simons-on-beauty.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
title: Jim Simons on beauty
date: 2024-05-10T17:27:00.986233-05:00
tags:
- philosophy
description: Jim Simons' loved beauty
---
[Jim Simons](https://en.wikipedia.org/wiki/Jim_Simons_(mathematician)) passed away today. One of the more interesting books I read last year was his biography 'The man who solved the market'.

> "Be guided by beauty. I really mean that. Pretty much everything I’ve done has had an aesthetic component, at least to me. Now you might think ‘well, building a company that’s trading bonds, what’s so aesthetic about that?’ But, what’s aesthetic about it is doing it right. Getting the right kind of people, and approaching the problem, and doing it right [] it’s a beautiful thing to do something right."
11 changes: 11 additions & 0 deletions posts/on-duty.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
title: Duty
date: 2024-05-12 22:19:23.517465-05
tags:
- philosophy
description: A reminder to myself that duty to ones nature is reason enough
---

> "We ought to do good to others as simply as a horse runs, or a bee makes honey, or a vine bears grapes season after season without thinking of the grapes it has borne." — Marcus Aurelius, Meditations
The answer to 'why work hard?', 'why strive for perfection?', 'why care about craft?' does not need to be more complicated than **'duty'**. When was the last time you saw a bee be lazy? Humans were made to make.
9 changes: 9 additions & 0 deletions posts/science.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
title: Science
date: 2024-05-17 17:10:19.079915-05
description: Science is writing it down
---

> “The only difference between screwing around and science is writing it down”
- [Alex Jason via Simon Willison](https://simonwillison.net/2024/Apr/25/alex-jason-via-adam-savage/#atom-everything)
11 changes: 11 additions & 0 deletions posts/somebody-doesnt-work-here.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
title: Somebody doesn't work here
date: 2024-05-10T22:25:18.602236-05:00
tags:
- teams
- startups
description: A great quote about creating a culture of ownership from the tale of Slack's first years
---
> _Somebody_ doesn’t work here.” As in, “Somebody should fix the typing lag in the search input” or “Somebody should follow up with the teams that churned last week.” Nope.
Slack was made in Canada. Thanks to Johnny Rogers and Ali Rayl for [documenting](https://buildingslack.com/you-asked/) the creation of Slack.
22 changes: 22 additions & 0 deletions posts/the-bauhaus-of-software.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
title: The Bauhaus of Software
date: 2024-05-08T09:08:23.409323-05:00
tags:
- design
- craft
description:
---
> "[We could make] Canada The Bauhaus of Software"
I just threw this out there last night [in a tweet](https://twitter.com/davehariri/status/1788030703680037155) before bed, but it seemed to touch on something others want for Canada. Here's what I was envisioning when I wrote that.

## Integration of Disciplines
Should designers code? Should coders design? Should you know about art? The answer is yes. The Bauhaus institute married fine and applied arts by placing artists, engineers, architects and industrial designers under a single roof. Artists designed buildings and architects made furniture. Collaboration ensued, forming a revolutionary definition of craft. The world was better for it and creative professionals were empowered. Why should software be any different? Makers of software could share and obsess over masters of their craft and draw inspiration laterally from any creative discipline.

## A Common Sensibility
Is there one right design? No, but I believe there are "more right" and "less right" designs. Ultimately, nature (or 'markets' in economic terms) decides what ought to last and what ought to die, but we can engage vigorously in uncovering the common patterns in what endures. Too often I hear people say "I don't know how to design" or "good design is subjective". I do not think this is good to engage with. Design is making trade offs. Every software writer engages in design as they write code.

Some products are fast and easy to use at the expense of customizability, others are nearer to code, but incredibly flexible. Every product will exist on this continuum. But, many products are not deliberate in the trade offs they make. Many products conflate aesthetic choices with better design, often at the expense of usability. A common sensibility could seek to make the most common dimensions of product design apparent and easy to understand so that software writers can make more deliberate choices for their customers. Canadian-made, open source frameworks for building user interfaces and software systems that are fast, legible, easy to extend, aesthetically pleasing and highly usable could be offered for free to better the average user experience.

## Decentralized Contribution
The Bauhaus institute was a community of like-minded creatives who collaborated intensely to find "more right", more natural answers to what good design was for the greater good of their users. The institute closed in 1933, but the movement continued for decades afterwards. I think this proves that a Bauhaus of Software can be fostered more loosely by businesses and schools engaging in discourse online, hosting in-person community events and sharing our individual knowledge on the web.
8 changes: 3 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ description = "David Hariri's place on the web"
authors = ["David Hariri <[email protected]>"]
license = "MIT"
readme = "README.md"
package-mode = false

[tool.poetry.dependencies]
python = "^3.11"
python = "^3.12"
flask = "^3.0.0"
gunicorn = "^21.2.0"
flask-caching = "^2.1.0"
Expand All @@ -18,6 +19,7 @@ pydantic = "^2.4.2"
python-frontmatter = "^1.0.0"
python-dotenv = "^1.0.0"
pygments = "^2.17.2"
click = "^8.1.7"


[tool.poetry.group.dev.dependencies]
Expand All @@ -29,7 +31,3 @@ pytest = "^7.4.3"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[pyright.config]
venvPath = "."
venv = "venv"

0 comments on commit b4bb126

Please sign in to comment.