diff --git a/3d-gradient-descent-in-python.html b/3d-gradient-descent-in-python.html index 421c7b04f..90a2f1856 100644 --- a/3d-gradient-descent-in-python.html +++ b/3d-gradient-descent-in-python.html @@ -62,9 +62,9 @@

Jack McKew's Blog

-

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/3d-terrain-in-python.html b/3d-terrain-in-python.html index cb16eb436..412824477 100644 --- a/3d-terrain-in-python.html +++ b/3d-terrain-in-python.html @@ -62,9 +62,9 @@

Jack McKew's Blog

-

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/actions-and-reducers-in-react-redux.html b/actions-and-reducers-in-react-redux.html index fa3057120..fef81513a 100644 --- a/actions-and-reducers-in-react-redux.html +++ b/actions-and-reducers-in-react-redux.html @@ -60,9 +60,9 @@

Jack McKew's Blog

-

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

@@ -162,14 +162,14 @@

Actions and Reducers in React-Redux

Redux State Diagram

Let's use react-redux to build a system which we can alert users when things trigger. For this we will need to build an action, a reducer and a component to display the alert.

To ensure that these three components are speaking the same language, we need to initialise types which will represent the states being passed around. These variables contain a string. For our alert system we need two variables

-
1
+
1
 2
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 @@
       
             

Jack McKew's Blog

-

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
+
1
 2
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
+
1
 2
 3
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
+
1
 2
 3
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
+
1
 2
 3
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
+
1
 2
 3
router.get('/',async (req, res) => {
     res.send('GET request to homepage');
@@ -238,7 +238,7 @@ 

GET

PUT

Similarly:

-
1
+
1
 2
 3
router.put('/',async (req, res) => {
     res.send('PUT request to homepage');
@@ -247,7 +247,7 @@ 

PUT

DELETE

Similarly:

-
1
+
1
 2
 3
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 @@
       
             

Jack McKew's Blog

-

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 @@

Jack McKew's Blog

-

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 @@

Jack McKew's Blog

-

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 @@

Jack McKew's Blog

Home Archives Categories Tags Sitemap Atom +
+
+

Reinforcement Learning in Unity

+

+ Posted by Jack McKew on Thu 22 August 2024 in Python + + • Tagged with + python, machine learning, ai + • 6 min read +

+
+
+ +

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:

+
    +
  1. How to set …
+
+ Continue reading +
+
+
-
- -
-
-

Lessons Learnt After 100 Blog Posts

-

- Posted by Jack McKew on Wed 10 May 2023 in Principles - - • Tagged with - habits, principles - • 3 min read -

-
-
-

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 -
-
- -
-
-

Episode 10 - Python Package Cheat Sheet

-

- Posted by Jack McKew on Fri 25 January 2019 in Python - - • Tagged with - python, packaging - • 3 min read -

-
-
-

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 -
-
- -
-
-

Intro to Kubernetes

-

- Posted by Jack McKew on Fri 13 November 2020 in Software - - • Tagged with - software - • 4 min read -

-
-
- -

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 -
-
- -
-
-

Gaining Access with Kali Linux

-

- Posted by Jack McKew on Fri 04 September 2020 in Software - - • Tagged with - software, infosec - • 10 min read -

-
-
- -

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 -
-
- -
-
-

How Pandas_Alive was Made

-

- Posted by Jack McKew on Fri 26 June 2020 in Python - - • Tagged with - Python - • 5 min read -

-
-
-

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 -
-
- -
-
-

Find Nth Visible Cell with VBA - Excel

-

- Posted by Jack McKew on Fri 17 April 2020 in Excel - - • Tagged with - vba, excel - • 4 min read -

-
-
- -

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 -
-
- -
-
-

Automatically Generate Documentation with Sphinx

-

- Posted by Jack McKew on Mon 03 February 2020 in Python - - • Tagged with - python - • 5 min read -

-
-
- -

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

-
1
-2
-3
pip install sphinx …
-
- Continue reading -
-
- -
-
-

Inheritance in Python

-

- Posted by Jack McKew on Fri 13 September 2019 in Python - - • Tagged with - python - • 2 min read -

-
-
-

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 -
-
- -
-
-

Python and Data Security (Hashing Algorithms)

-

- Posted by Jack McKew on Fri 21 June 2019 in Python - - • Tagged with - python, security - • 5 min read -

-
-
-

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 -
-
- -