1
+ | export const SET_ALERT = "SET_ALERT"
export const REMOVE_ALERT = "REMOVE_ALERT"
|
Action
We'll start by creating the action which will signify when an alert is triggered. We want all of our alerts to be unique so multiple alerts can handled without a problem which we will use uuid .
- 1
+ 1
2
3
4
@@ -212,7 +212,7 @@ Action
|
The action is declared as a function, which takes in 3 arguments (2 required): msg , alertType and timeout . Which we then use call the dispatch function with an object constructed from the arguments, and then after a specified timeout we dispatch another object to remove the same alert.
Note that we curry the dispatch function in this case, this is only possible from using the middleware redux-thunk , which can also be represented as:
- 1
+ 1
2
3
4
@@ -230,7 +230,7 @@ Component
This post won't go into detail around how to build a React component, which you can find over at another post: [INSERT REACT COMPONENT POST]
- 1
+ 1
2
3
4
@@ -278,7 +278,7 @@ Component
To break it down, we've created a React component (class) Alert which takes in alerts as an array, verifies it isn't null or empty, and finally iterates over each element in the alerts array to return a div stylized with the appropriate information.
Reducer
Lastly we have the reducer which we want to handle all the states that can be created by the alert action. Luckily we can do this with a switch statement:
- 1
+ 1
2
3
4
diff --git a/api-routes-in-nodejs.html b/api-routes-in-nodejs.html
index 298cdbc92..9d0a2c3d9 100644
--- a/api-routes-in-nodejs.html
+++ b/api-routes-in-nodejs.html
@@ -60,9 +60,9 @@
- Engineer | Software Developer | Data Scientist Number of Posts: 109
- Number of Words: 80,941
- Number of Lines of Code 5,735
+ Engineer | Software Developer | Data Scientist Number of Posts: 110
+ Number of Words: 81,726
+ Number of Lines of Code 5,763
@@ -159,7 +159,7 @@ API Routes in Node.js
First off what's an API and more specifically what's an API route? API stands for Application Programming Interface, meaning it's how to communicate with the system you are creating. A route within an API is a specific path to take to get specific information or data out of. This post will dive into how to set up API routes in Nodejs with express.
We start by 'importing' express into our route and instantiating a router from the express library.
- 1
+ | const express = require('express');
const router = express.Router();
@@ -204,7 +204,7 @@ API Routes in Node.js
These 4 methods make up the basic CRUD functionality (Create, Read, Update and Delete) of an application.
POST
Let's create a scaffold POST method in node.js.
-1
+ | router.post('/',function(req,res) {
res.send('POST request to homepage');
@@ -212,7 +212,7 @@ POST
|
Similarly to do this asynchronously with arrow functions:
- 1
+ | router.post('/',async(req,res) => {
res.send('POST request to homepage');
@@ -220,7 +220,7 @@ POST
|
As we can see above, the first argument to our API route method is the path, and the following is the callback function (what should happen when this path is hit). The callback function can be a function, array of functions, series of functions (separated by commas), or a combination of all of them. This is useful if you are wanting to do validation before the final POST request is made. An example of this is:
- 1
+ | router.post('/',[checkInputs()], async (req, res) => {
res.send('POST request to homepage and inputs are valid');
@@ -229,7 +229,7 @@ POST
|
GET
All the methods within Express.js follow the same principles so to create a scaffold GET request:
- 1
+ | router.get('/',async (req, res) => {
res.send('GET request to homepage');
@@ -238,7 +238,7 @@ GET
|
PUT
Similarly:
- 1
+ | router.put('/',async (req, res) => {
res.send('PUT request to homepage');
@@ -247,7 +247,7 @@ PUT
|
DELETE
Similarly:
- 1
+ | router.delete('/',async (req, res) => {
res.send('PUT request to homepage');
@@ -279,7 +279,7 @@ Express Middleware
|
An example of using all of the arguments is:
- 1
+ 1
2
3
4
diff --git a/archives.html b/archives.html
index 2336c3c33..59cd66ec6 100644
--- a/archives.html
+++ b/archives.html
@@ -51,9 +51,9 @@
- Engineer | Software Developer | Data Scientist Number of Posts: 109
- Number of Words: 80,941
- Number of Lines of Code 5,735
+ Engineer | Software Developer | Data Scientist Number of Posts: 110
+ Number of Words: 81,726
+ Number of Lines of Code 5,763
@@ -141,6 +141,8 @@ Archives
+ - Thu 22 August 2024
+ - Reinforcement Learning in Unity
- Thu 25 July 2024
- ML Agents for Unity on Apple Silicon (M1/M2/M3)
- Tue 19 March 2024
diff --git a/australia-post-codes-connected.html b/australia-post-codes-connected.html
index 7e3eb2fb9..aa072e68a 100644
--- a/australia-post-codes-connected.html
+++ b/australia-post-codes-connected.html
@@ -61,9 +61,9 @@
- Engineer | Software Developer | Data Scientist Number of Posts: 109
- Number of Words: 80,941
- Number of Lines of Code 5,735
+ Engineer | Software Developer | Data Scientist Number of Posts: 110
+ Number of Words: 81,726
+ Number of Lines of Code 5,763
diff --git a/author/jack-mckew.html b/author/jack-mckew.html
index 803156486..152a2a1fc 100644
--- a/author/jack-mckew.html
+++ b/author/jack-mckew.html
@@ -51,9 +51,9 @@
- Engineer | Software Developer | Data Scientist Number of Posts: 109
- Number of Words: 80,941
- Number of Lines of Code 5,735
+ Engineer | Software Developer | Data Scientist Number of Posts: 110
+ Number of Words: 81,726
+ Number of Lines of Code 5,763
@@ -137,6 +137,27 @@
Home Archives Categories Tags Sitemap Atom
+
+
+
+
+ I find machine's working automatically to complete a task one of the most fascinating things, imagine how good it feels to watch a machine that learns to do the task on it's own! Especially if you're the teacher, in this blog post, we're going to go through:
+
+- How to set …
+
+ Continue reading
+
+
+
-
-
-
-
-
- This post is dedicated to my late partner Jackie, who I absolutely couldn't of done any part of this blog without. Life will never be the same without you, but I'm trying to make the most of every day for the both of us.
- If you're reading this, this is …
-
- Continue reading
-
-
-
-
-
-
- One of the biggest skills in any career path comes solely from knowing where to look and what to look for when breaking down a problem. The same principle applies for Python programming. Since there are millions of different packages out there that all serve different purposes, it is often …
-
- Continue reading
-
-
-
-
-
-
-
- Kubernetes is a portable, extensible, open-source platform for managing containerized workloads and services, that facilitates both declarative configuration and automation. We use Kubernetes as a platform for orchestrating multiple Docker containers for our application, and enables us to scale our application easily.
- Kubernetes is managed via a master node, and …
-
- Continue reading
-
-
-
-
-
-
-
- This post will go into ways we can use Kali Linux to gain access to the target PCs! What is Kali Linux? "Kali Linux is a Debian-based Linux distribution aimed at advanced Penetration Testing and Security Auditing". Kali Linux is free to download and you can find it at: https …
-
- Continue reading
-
-
-
-
-
-
- Pandas-Alive is an open source Python package for making animated charts from Pandas dataframes. This project was first inspired by a very specific COVID-19 visualisation, so I set out to make this visualisation a reality.
- This visualisation consisted of a bar chart race showing regions, a line chart showing new …
-
- Continue reading
-
-
-
-
-
-
-
- Excel is the undisputed leader in the spreadsheet world, with over 750 million users worldwide. It is a household name when it comes to analyzing data, so personally I find myself in Excel for most of the work I do. One powerful option that in my experience is underused is …
-
- Continue reading
-
-
-
-
-
-
-
- Document code automatically through docstrings with Sphinx
- This post goes into how to generate documentation for your python projects automatically with Sphinx!
- First off we have to install sphinx into our virtual environment. Pending on your flavour, we can do any of the following
-
-
- Continue reading
-
-
-
-
-
-
- As Python is a high level, general purpose programming language, which supports users to define their own types using classes, which are most often following the concept of object-oriented programming. Object-oriented programming is a type of software design in which users not only define the data type (eg, int) of …
-
- Continue reading
-
-
-
-
-
-
- Data security is becoming more and more prevalent in today's society than ever before. We must make a conscious effort to secure both our physical lives, but also our digital lives as well. With data privacy, sharing of information and access control becoming integrated into most people's life in some …
-
- Continue reading
-
-
-
-
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|