Commit graph

528 commits

Author SHA1 Message Date
Oliver Davies 18a1dd0e03 fix: remove unwanted URLs for daily emails 2022-10-13 08:49:55 +01:00
Oliver Davies 69112f3976 fix: add article content to description 2022-10-13 00:15:24 +01:00
Oliver Davies 5efaf23eca chore(daily-email): re-add form 2022-10-10 23:02:27 +01:00
Oliver Davies 5f7acceb93 docs(daily-email): add email 2022-10-10 22:58:04 +01:00
Oliver Davies 1cedd10c90 chore: re-add Plausible Analytics 2022-10-10 21:07:51 +01:00
Oliver Davies d1b76dda33 chore: replace Sculpin with Astro 2022-10-10 20:50:54 +01:00
Oliver Davies d0ef96dead
fix(daily-emails): typo 2022-10-08 22:44:27 +01:00
Oliver Davies fd8975c2b3
docs(daily-email): add 2022-10-08 2022-10-08 22:43:32 +01:00
Oliver Davies 3407a052b0
docs(daily-email): add 2022-10-03 2022-10-05 07:33:26 +01:00
Oliver Davies 1c317feeac
docs(daily-email): add 2022-10-02 2022-10-04 00:57:10 +01:00
Oliver Davies c935c174b0
docs(daily-email): add 2022-10-01.md 2022-10-03 00:55:57 +01:00
Oliver Davies f99561e66a docs(daily-email): add post
diff --git a/ansible/ansible.cfg b/ansible/ansible.cfg
deleted file mode 100644
index cc79c59..0000000
--- a/ansible/ansible.cfg
+++ /dev/null
@@ -1,2 +0,0 @@
-[defaults]
-inventory = ./hosts.ini
diff --git a/ansible/deploy.yml b/ansible/deploy.yml
deleted file mode 100644
index ea5647a..0000000
--- a/ansible/deploy.yml
+++ /dev/null
@@ -1,14 +0,0 @@
----
-- hosts: web
-  gather_facts: false
-
-  tasks:
-    - name: Update the code
-      git:
-        repo: https://github.com/opdavies/oliverdavies.uk
-        dest: ~/oliverdavies.uk
-
-    - name: Pull the latest images and re-generate the site.
-      shell: ./run run-production
-      args:
-        chdir: ~/oliverdavies.uk
diff --git a/ansible/hosts.ini b/ansible/hosts.ini
deleted file mode 100644
index 01a3341..0000000
--- a/ansible/hosts.ini
+++ /dev/null
@@ -1,5 +0,0 @@
-[web]
-18.132.197.147
-
-[web:vars]
-ansible_user=ubuntu
diff --git a/website/source/_daily_emails/2022-09-30.md b/website/source/_daily_emails/2022-09-30.md
new file mode 100644
index 0000000..f5a63eb
--- /dev/null
+++ b/website/source/_daily_emails/2022-09-30.md
@@ -0,0 +1,83 @@
+---
+title: "Store Wars: different state management in Vue.js"
+date: "2022-09-30"
+permalink: "/archive/2022/09/30/store-wars-vuejs"
+tags: ["vue"]
+---
+
+I'm currently working on a Vue.js application that I started building in Vue 2 before starting to use the Composition API, and then moved it to Vue 3.
+
+In the original version, I was using Vuex for state management within the application, and interacting with Vuex directly within my Vue components - calling `getters` and `dispatch` to retrieve and update data.
+
+As part of moving to Vue 3, I wanted to evaluate any new options, like Pinia which is now the default state management library for Vue.
+
+But because I was integrating with Vuex directly, switching to an alternative would mean changing code within my components.
+
+## Defining a Store interface
+
+This is a situation that often occurs in back-end development - where you may need to switch to a different type of database or a different payment provider in an eCommerce application.
+
+In that situation, you need a generic interface that can be used by different implementations. Because they have consistent methods, one implementation can be replaced with another or multiple can be added at the same time. This is called the Strategy design pattern, and related to the open-closed principle in SOLID.
+
+This is what I did by adding a `Store` interface:
+
+```javascript
+export default interface Store {
+  actions: {
+    addRow(): void;
+    init(): void;
+    removeRow(index: Number): void;
+  };
+
+  state: {
+    isLoading: boolean;
+    selection: {
+      items: [];
+    };
+  };
+}
+```
+
+Any store that I want to work with needs to have these defined actions and state values, so I can use them within my components knowing that they will always be available.
+
+## Creating a native Vue store
+
+This is one implementation of the `Store` interface, using just Vue's `reactive` function from the Composition API:
+
+```javascript
+let state = reactive({
+  isLoading: false,
+  selection: {
+    items: [],
+  },
+});
+
+let actions = {
+  addRow(): void {
+    state.selection.items.push({
+      // ...
+    });
+  },
+
+  init(): void {
+    state.isLoading = true;
+
+    // ...
+  },
+
+  removeRow(index: number): void {
+    state.selection.items.splice(index, 1);
+  },
+};
+
+const vueStore: Store = {
+  actions,
+  state: readonly(state),
+};
+
+export default vueStore;
+```
+
+If I needed to add a Pinia version or another library, I can create another implementation that complies with same interface.
+
+Each implementation being responsible for any specifics for that library - extracting that logic from the component code making it more flexible and reusable.
2022-10-01 22:54:10 +01:00
Oliver Davies 3c7db24f1c ci: re-add deploy job
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index e4202a6..c0598b0 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -14,7 +14,7 @@ env:
   DOCKER_TAG: ${{ github.sha }}

 jobs:
-  build-and-push-images:
+  build:
     runs-on: ubuntu-latest
     steps:
       - uses: actions/checkout@5a4ac9002d # v2.3.4
@@ -33,4 +33,22 @@ jobs:
       - run: |
           just push-images ${{ github.sha }}

+  deploy:
+    runs-on: ubuntu-latest
+    needs:
+      - build
+    steps:
+      - uses: actions/checkout@5a4ac9002d # v2.3.4
+      - uses: extractions/setup-just@95b912dc5d # 1.5.0
+
+      - name: Add the deployment SSH key
+        uses: shimataro/ssh-key-action@3c9b0fc6f2 # 2.3.1
+        with:
+          key: ${{ secrets.SSH_PRIVATE_KEY }}
+          name: id_rsa
+          known_hosts: ${{ secrets.SSH_KNOWN_HOSTS }}
+
+      - run: |
+          just deploy ${{ github.sha }}
+
 # vim: sw=2 ts=2
diff --git a/justfile b/justfile
index e4916d1..5afe23d 100644
--- a/justfile
+++ b/justfile
@@ -12,11 +12,11 @@ create-daily:
   touch "${filepath}/${filename}"
   eval "${EDITOR}" "${filepath}/${filename}"

-deploy:
+deploy sha:
   rm -fr _deploy
   docker container rm oliverdavies.uk-build || true

-  docker image pull ghcr.io/opdavies/oliverdavies.uk-build
+  docker image pull ghcr.io/opdavies/oliverdavies.uk-build:{{ sha }}
   docker container run --entrypoint sh --name oliverdavies.uk-build ghcr.io/opdavies/oliverdavies.uk-build
   docker container cp oliverdavies.uk-build:/app/ _deploy
2022-09-30 00:20:19 +01:00
Oliver Davies 7baf281e8a ci: start replacing run with just 2022-09-29 23:19:08 +01:00
Oliver Davies 6d551e354d docs(daily-email): add a link to GitHub
diff --git a/website/source/_daily_emails/2022-09-28.md b/website/source/_daily_emails/2022-09-28.md
index e9f6378..44a5770 100644
--- a/website/source/_daily_emails/2022-09-28.md
+++ b/website/source/_daily_emails/2022-09-28.md
@@ -13,6 +13,8 @@ We worked on the FizzBuzz kata in PHP, using Pest for our automated tests.

 We followed the Driver and Navigator model, with one person responsible for the typing and interpreting the instructions from the Navigators, and switched roles every ten minutes.

+You can [see the code that we wrote](1da5dd5a79/php/tests/FizzBuzzTest.php) on my code katas GitHub repository.
+
 It was a fun experience and nice to code with some people who I hadn't coded with before.

 We did some code kata sessions during our online meetups which also seemed to go well, so coding nights on katas or personal or open-source projects might be something that we do more of in the future.
2022-09-29 22:26:06 +01:00
Oliver Davies ae023bc09e docs(daily-email): add post
diff --git a/website/source/_daily_emails/2022-09-28.md b/website/source/_daily_emails/2022-09-28.md
new file mode 100644
index 0000000..e9f6378
--- /dev/null
+++ b/website/source/_daily_emails/2022-09-28.md
@@ -0,0 +1,18 @@
+---
+title: "Mob programming at PHP South Wales"
+date: "2022-09-28"
+permalink: "/archive/2022/09/28/mob-programming-php-south-wales"
+tags: []
+---
+
+Tonight was our September meetup for the PHP South Wales user group, where I ran a hands-on session on mob programming.
+
+I created [a small slide deck](https://speakerdeck.com/opdavies/an-introduction-to-mob-programming) before we started a mob session with the group.
+
+We worked on the FizzBuzz kata in PHP, using Pest for our automated tests.
+
+We followed the Driver and Navigator model, with one person responsible for the typing and interpreting the instructions from the Navigators, and switched roles every ten minutes.
+
+It was a fun experience and nice to code with some people who I hadn't coded with before.
+
+We did some code kata sessions during our online meetups which also seemed to go well, so coding nights on katas or personal or open-source projects might be something that we do more of in the future.
2022-09-29 22:22:37 +01:00
Oliver Davies a0681d966b docs(daily-email): add post 2022-09-28 22:56:36 +01:00
Oliver Davies 0f471622cf docs(daily-email): add post 2022-09-27 08:25:03 +01:00
Oliver Davies 35d778bd79 docs(daily-email): add post 2022-09-26 10:28:05 +01:00
Oliver Davies ac54cda1a6 fix(daily-email): add content 2022-09-25 00:21:13 +01:00
Oliver Davies 14055e8eb0 docs(daily-email): add post
diff --git a/website/source/_daily_emails/2022-09-23.md b/website/source/_daily_emails/2022-09-23.md
new file mode 100644
index 0000000..3c5edb5
--- /dev/null
+++ b/website/source/_daily_emails/2022-09-23.md
@@ -0,0 +1,7 @@
+---
+title: "ADRs and Technical Design Documents"
+date: "2022-09-23"
+permalink: "/archive/2022/09/23/adrs-technical-design-documents"
+tags: []
+---
+
2022-09-25 00:15:44 +01:00
Oliver Davies d4e0439a6d chore: update redirects 2022-09-23 12:24:53 +01:00
Oliver Davies bed1b899cf chore: update page URL 2022-09-23 12:15:36 +01:00
Oliver Davies 2d213ba656 docs(daily-email): add post 2022-09-23 08:14:26 +01:00
Oliver Davies 3560fd0e9c docs: mark posts as draft 2022-09-22 00:30:17 +01:00
Oliver Davies abfdc6b079 docs(daily-email): add post 2022-09-22 00:11:38 +01:00
Oliver Davies 8ff7cebcfa docs(daily-email): add post 2022-09-20 23:23:16 +01:00
Oliver Davies d3e4d1296c docs(daily-email): add post 2022-09-20 08:10:48 +01:00
Oliver Davies 817051314e docs(daily-email): add post 2022-09-18 23:07:37 +01:00
Oliver Davies 4c3ea3be8a docs(daily-email): add post 2022-09-17 01:41:01 +01:00
Oliver Davies d6b5978548 docs(daily-email): add post 2022-09-15 00:04:50 +01:00
Oliver Davies a1f5ff4325 docs(daily-email): add yesterday's post 2022-09-13 19:30:19 +01:00
Oliver Davies 98049127dc docs(daily-email): add yesterday's post 2022-09-12 16:14:41 +01:00
Oliver Davies 8f22ae704c docs(daily-email): changes 2022-09-10 23:41:11 +01:00
Oliver Davies acb52d7370 docs(daily-email): add post 2022-09-10 23:30:23 +01:00
Oliver Davies 49543000cb docs(daily-email): update title 2022-09-09 21:39:30 +01:00
Oliver Davies fa147c8432 docs(daily-email): add post 2022-09-09 21:35:18 +01:00
Oliver Davies 6cd0a2d25a docs(daily-email): add yesterday's email 2022-09-09 10:34:20 +01:00
Oliver Davies 4164fc41e0 docs(daily-email): Tailwind CSS origin story 2022-09-07 22:25:54 +01:00
Oliver Davies 7913aa2570 docs(daily-email): deploying with Ansible 2022-09-07 00:47:45 +01:00
Oliver Davies 7920339ce2 feat: add footer to other Ansible emails 2022-09-05 22:08:38 +01:00
Oliver Davies 3c9a8860d6 docs(daily-email): add today's email 2022-09-05 22:07:43 +01:00
Oliver Davies c651a3a71a docs(daily-email): add yesterday's email 2022-09-05 20:56:39 +01:00
Oliver Davies 44ea181581 Add Ansible course landing page 2022-09-05 20:50:30 +01:00
Oliver Davies 85f63d5d1c docs(daily-email): ansible part 2 2022-09-04 01:08:28 +01:00
Oliver Davies a1c7a0228c docs(daily-email): automating with Ansible 2022-09-02 23:37:51 +01:00
Oliver Davies c9eb1944c5 docs(daily-email): commits and CHANGELOGs 2022-09-02 00:21:17 +01:00
Oliver Davies c835a039ce docs(daily-email): monorepos 2022-09-01 10:30:10 +01:00
Oliver Davies ee10db7176 chore: replace RSS feed link with Daily List 2022-08-31 18:03:01 +01:00
Oliver Davies df78e0c0d7 docs(daily-email): add post 2022-08-31 00:04:31 +01:00