Skip to content

Commit

Permalink
Deploying to gh-pages from @ e0e82d8 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
JackMcKew committed Jul 25, 2024
1 parent 3f90b54 commit aa60b02
Show file tree
Hide file tree
Showing 235 changed files with 2,392 additions and 8,162 deletions.
6 changes: 3 additions & 3 deletions 3d-gradient-descent-in-python.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@
</a>
<h1><a href="https://jackmckew.dev">Jack McKew's Blog</a></h1>

<p>Engineer | Software Developer | Data Scientist</p> <p>Number of Posts: 108</p>
<p>Number of Words: 81,240</p>
<p>Number of Lines of Code 5,782</p>
<p>Engineer | Software Developer | Data Scientist</p> <p>Number of Posts: 109</p>
<p>Number of Words: 81,824</p>
<p>Number of Lines of Code 5,803</p>
<form class="navbar-search" action="/search.html" role="search">
<input type="text" name="q" id="tipue_search_input" placeholder="Search..">
</form>
Expand Down
6 changes: 3 additions & 3 deletions 3d-terrain-in-python.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@
</a>
<h1><a href="https://jackmckew.dev">Jack McKew's Blog</a></h1>

<p>Engineer | Software Developer | Data Scientist</p> <p>Number of Posts: 108</p>
<p>Number of Words: 81,240</p>
<p>Number of Lines of Code 5,782</p>
<p>Engineer | Software Developer | Data Scientist</p> <p>Number of Posts: 109</p>
<p>Number of Words: 81,824</p>
<p>Number of Lines of Code 5,803</p>
<form class="navbar-search" action="/search.html" role="search">
<input type="text" name="q" id="tipue_search_input" placeholder="Search..">
</form>
Expand Down
16 changes: 8 additions & 8 deletions actions-and-reducers-in-react-redux.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@
</a>
<h1><a href="https://jackmckew.dev">Jack McKew's Blog</a></h1>

<p>Engineer | Software Developer | Data Scientist</p> <p>Number of Posts: 108</p>
<p>Number of Words: 81,240</p>
<p>Number of Lines of Code 5,782</p>
<p>Engineer | Software Developer | Data Scientist</p> <p>Number of Posts: 109</p>
<p>Number of Words: 81,824</p>
<p>Number of Lines of Code 5,803</p>
<form class="navbar-search" action="/search.html" role="search">
<input type="text" name="q" id="tipue_search_input" placeholder="Search..">
</form>
Expand Down Expand Up @@ -162,14 +162,14 @@ <h1 id="actions-and-reducers-in-react-redux">Actions and Reducers in React-Redux
<p><img alt="Redux State Diagram" class="img-fluid" src="https://jackmckew.dev/img/redux-diagram.png"/></p>
<p>Let's use <code>react-redux</code> 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.</p>
<p>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</p>
<table class="table-striped highlighttable table"><tbody><tr><td class="linenos"><div class="linenodiv"><pre>1
<table class="table highlighttable table-striped"><tbody><tr><td class="linenos"><div class="linenodiv"><pre>1
2</pre></div></td><td class="code"><div class="highlight"><pre><span></span><code><span class="k">export</span> <span class="kd">const</span> <span class="nx">SET_ALERT</span> <span class="o">=</span> <span class="s2">"SET_ALERT"</span>
<span class="k">export</span> <span class="kd">const</span> <span class="nx">REMOVE_ALERT</span> <span class="o">=</span> <span class="s2">"REMOVE_ALERT"</span>
</code></pre></div>
</td></tr></tbody></table>
<h2 id="action">Action</h2>
<p>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 <code>uuid</code>.</p>
<table class="table-striped highlighttable table"><tbody><tr><td class="linenos"><div class="linenodiv"><pre> 1
<table class="table highlighttable table-striped"><tbody><tr><td class="linenos"><div class="linenodiv"><pre> 1
2
3
4
Expand Down Expand Up @@ -212,7 +212,7 @@ <h2 id="action">Action</h2>
</td></tr></tbody></table>
<p>The action is declared as a function, which takes in 3 arguments (2 required): <code>msg</code>, <code>alertType</code> and <code>timeout</code>. 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.</p>
<p>Note that we curry the dispatch function in this case, this is only possible from using the middleware <code>redux-thunk</code>, which can also be represented as:</p>
<table class="table-striped highlighttable table"><tbody><tr><td class="linenos"><div class="linenodiv"><pre>1
<table class="table highlighttable table-striped"><tbody><tr><td class="linenos"><div class="linenodiv"><pre>1
2
3
4
Expand All @@ -230,7 +230,7 @@ <h2 id="component">Component</h2>
<blockquote>
<p>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]</p>
</blockquote>
<table class="table-striped highlighttable table"><tbody><tr><td class="linenos"><div class="linenodiv"><pre> 1
<table class="table highlighttable table-striped"><tbody><tr><td class="linenos"><div class="linenodiv"><pre> 1
2
3
4
Expand Down Expand Up @@ -278,7 +278,7 @@ <h2 id="component">Component</h2>
<p>To break it down, we've created a React component (class) <code>Alert</code> which takes in <code>alerts</code> as an array, verifies it isn't null or empty, and finally iterates over each element in the <code>alerts</code> array to return a <code>div</code> stylized with the appropriate information.</p>
<h2 id="reducer">Reducer</h2>
<p>Lastly we have the reducer which we want to handle all the states that can be created by the <code>alert</code> action. Luckily we can do this with a switch statement:</p>
<table class="table-striped highlighttable table"><tbody><tr><td class="linenos"><div class="linenodiv"><pre> 1
<table class="table highlighttable table-striped"><tbody><tr><td class="linenos"><div class="linenodiv"><pre> 1
2
3
4
Expand Down
26 changes: 13 additions & 13 deletions api-routes-in-nodejs.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@
</a>
<h1><a href="https://jackmckew.dev">Jack McKew's Blog</a></h1>

<p>Engineer | Software Developer | Data Scientist</p> <p>Number of Posts: 108</p>
<p>Number of Words: 81,240</p>
<p>Number of Lines of Code 5,782</p>
<p>Engineer | Software Developer | Data Scientist</p> <p>Number of Posts: 109</p>
<p>Number of Words: 81,824</p>
<p>Number of Lines of Code 5,803</p>
<form class="navbar-search" action="/search.html" role="search">
<input type="text" name="q" id="tipue_search_input" placeholder="Search..">
</form>
Expand Down Expand Up @@ -159,7 +159,7 @@ <h1 id="api-routes-in-nodejs">API Routes in Node.js</h1>
<div>
<body><p>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.</p>
<p>We start by 'importing' express into our route and instantiating a router from the express library.</p>
<table class="table-striped highlighttable table"><tbody><tr><td class="linenos"><div class="linenodiv"><pre>1
<table class="table highlighttable table-striped"><tbody><tr><td class="linenos"><div class="linenodiv"><pre>1
2</pre></div></td><td class="code"><div class="highlight"><pre><span></span><code><span class="kd">const</span> <span class="nx">express</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">'express'</span><span class="p">);</span>
<span class="kd">const</span> <span class="nx">router</span> <span class="o">=</span> <span class="nx">express</span><span class="p">.</span><span class="nx">Router</span><span class="p">();</span>
</code></pre></div>
Expand All @@ -170,7 +170,7 @@ <h1 id="api-routes-in-nodejs">API Routes in Node.js</h1>
</blockquote>
<p>Next we can create routes as straightforward as using the corresponding method within <code>router</code>. Pending on the type of API that is being created, if you are using Express.js, it's mostly likely a web API and thus the methods follow HTTP method routes.</p>
<p>The primary or most-commonly-used HTTP methods are:</p>
<table class="table-striped table">
<table class="table table-striped">
<thead>
<tr>
<th>Method Name</th>
Expand Down Expand Up @@ -204,23 +204,23 @@ <h1 id="api-routes-in-nodejs">API Routes in Node.js</h1>
<p>These 4 methods make up the basic CRUD functionality (Create, Read, Update and Delete) of an application.</p>
<h2 id="post">POST</h2>
<p>Let's create a scaffold <code>POST</code> method in node.js.</p>
<table class="table-striped highlighttable table"><tbody><tr><td class="linenos"><div class="linenodiv"><pre>1
<table class="table highlighttable table-striped"><tbody><tr><td class="linenos"><div class="linenodiv"><pre>1
2
3</pre></div></td><td class="code"><div class="highlight"><pre><span></span><code><span class="nx">router</span><span class="p">.</span><span class="nx">post</span><span class="p">(</span><span class="s1">'/'</span><span class="p">,</span><span class="kd">function</span><span class="p">(</span><span class="nx">req</span><span class="p">,</span><span class="nx">res</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">res</span><span class="p">.</span><span class="nx">send</span><span class="p">(</span><span class="s1">'POST request to homepage'</span><span class="p">);</span>
<span class="p">})</span>
</code></pre></div>
</td></tr></tbody></table>
<p>Similarly to do this asynchronously with arrow functions:</p>
<table class="table-striped highlighttable table"><tbody><tr><td class="linenos"><div class="linenodiv"><pre>1
<table class="table highlighttable table-striped"><tbody><tr><td class="linenos"><div class="linenodiv"><pre>1
2
3</pre></div></td><td class="code"><div class="highlight"><pre><span></span><code><span class="nx">router</span><span class="p">.</span><span class="nx">post</span><span class="p">(</span><span class="s1">'/'</span><span class="p">,</span><span class="k">async</span><span class="p">(</span><span class="nx">req</span><span class="p">,</span><span class="nx">res</span><span class="p">)</span> <span class="p">=&gt;</span> <span class="p">{</span>
<span class="nx">res</span><span class="p">.</span><span class="nx">send</span><span class="p">(</span><span class="s1">'POST request to homepage'</span><span class="p">);</span>
<span class="p">})</span>
</code></pre></div>
</td></tr></tbody></table>
<p>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:</p>
<table class="table-striped highlighttable table"><tbody><tr><td class="linenos"><div class="linenodiv"><pre>1
<table class="table highlighttable table-striped"><tbody><tr><td class="linenos"><div class="linenodiv"><pre>1
2
3</pre></div></td><td class="code"><div class="highlight"><pre><span></span><code><span class="nx">router</span><span class="p">.</span><span class="nx">post</span><span class="p">(</span><span class="s1">'/'</span><span class="p">,[</span><span class="nx">checkInputs</span><span class="p">()],</span> <span class="k">async</span> <span class="p">(</span><span class="nx">req</span><span class="p">,</span> <span class="nx">res</span><span class="p">)</span> <span class="p">=&gt;</span> <span class="p">{</span>
<span class="nx">res</span><span class="p">.</span><span class="nx">send</span><span class="p">(</span><span class="s1">'POST request to homepage and inputs are valid'</span><span class="p">);</span>
Expand All @@ -229,7 +229,7 @@ <h2 id="post">POST</h2>
</td></tr></tbody></table>
<h2 id="get">GET</h2>
<p>All the methods within Express.js follow the same principles so to create a scaffold <code>GET</code> request:</p>
<table class="table-striped highlighttable table"><tbody><tr><td class="linenos"><div class="linenodiv"><pre>1
<table class="table highlighttable table-striped"><tbody><tr><td class="linenos"><div class="linenodiv"><pre>1
2
3</pre></div></td><td class="code"><div class="highlight"><pre><span></span><code><span class="nx">router</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s1">'/'</span><span class="p">,</span><span class="k">async</span> <span class="p">(</span><span class="nx">req</span><span class="p">,</span> <span class="nx">res</span><span class="p">)</span> <span class="p">=&gt;</span> <span class="p">{</span>
<span class="nx">res</span><span class="p">.</span><span class="nx">send</span><span class="p">(</span><span class="s1">'GET request to homepage'</span><span class="p">);</span>
Expand All @@ -238,7 +238,7 @@ <h2 id="get">GET</h2>
</td></tr></tbody></table>
<h2 id="put">PUT</h2>
<p>Similarly:</p>
<table class="table-striped highlighttable table"><tbody><tr><td class="linenos"><div class="linenodiv"><pre>1
<table class="table highlighttable table-striped"><tbody><tr><td class="linenos"><div class="linenodiv"><pre>1
2
3</pre></div></td><td class="code"><div class="highlight"><pre><span></span><code><span class="nx">router</span><span class="p">.</span><span class="nx">put</span><span class="p">(</span><span class="s1">'/'</span><span class="p">,</span><span class="k">async</span> <span class="p">(</span><span class="nx">req</span><span class="p">,</span> <span class="nx">res</span><span class="p">)</span> <span class="p">=&gt;</span> <span class="p">{</span>
<span class="nx">res</span><span class="p">.</span><span class="nx">send</span><span class="p">(</span><span class="s1">'PUT request to homepage'</span><span class="p">);</span>
Expand All @@ -247,7 +247,7 @@ <h2 id="put">PUT</h2>
</td></tr></tbody></table>
<h2 id="delete">DELETE</h2>
<p>Similarly:</p>
<table class="table-striped highlighttable table"><tbody><tr><td class="linenos"><div class="linenodiv"><pre>1
<table class="table highlighttable table-striped"><tbody><tr><td class="linenos"><div class="linenodiv"><pre>1
2
3</pre></div></td><td class="code"><div class="highlight"><pre><span></span><code><span class="nx">router</span><span class="p">.</span><span class="k">delete</span><span class="p">(</span><span class="s1">'/'</span><span class="p">,</span><span class="k">async</span> <span class="p">(</span><span class="nx">req</span><span class="p">,</span> <span class="nx">res</span><span class="p">)</span> <span class="p">=&gt;</span> <span class="p">{</span>
<span class="nx">res</span><span class="p">.</span><span class="nx">send</span><span class="p">(</span><span class="s1">'PUT request to homepage'</span><span class="p">);</span>
Expand All @@ -256,7 +256,7 @@ <h2 id="delete">DELETE</h2>
</td></tr></tbody></table>
<h2 id="express-middleware">Express Middleware</h2>
<p>All of the callback functions defined above are known as Middleware functions in Express.js. Middleware functions have access to 3 elements: <code>req</code>, <code>res</code>, and <code>next</code>.</p>
<table class="table-striped table">
<table class="table table-striped">
<thead>
<tr>
<th>Argument</th>
Expand All @@ -279,7 +279,7 @@ <h2 id="express-middleware">Express Middleware</h2>
</tbody>
</table>
<p>An example of using all of the arguments is:</p>
<table class="table-striped highlighttable table"><tbody><tr><td class="linenos"><div class="linenodiv"><pre>1
<table class="table highlighttable table-striped"><tbody><tr><td class="linenos"><div class="linenodiv"><pre>1
2
3
4
Expand Down
8 changes: 5 additions & 3 deletions archives.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@
</a>
<h1><a href="https://jackmckew.dev">Jack McKew's Blog</a></h1>

<p>Engineer | Software Developer | Data Scientist</p> <p>Number of Posts: 108</p>
<p>Number of Words: 81,240</p>
<p>Number of Lines of Code 5,782</p>
<p>Engineer | Software Developer | Data Scientist</p> <p>Number of Posts: 109</p>
<p>Number of Words: 81,824</p>
<p>Number of Lines of Code 5,803</p>
<form class="navbar-search" action="/search.html" role="search">
<input type="text" name="q" id="tipue_search_input" placeholder="Search..">
</form>
Expand Down Expand Up @@ -141,6 +141,8 @@ <h1 id="archives"> Archives</h1>
</header>
<div>
<dl>
<dt>Thu 25 July 2024</dt>
<dd><a href="https://jackmckew.dev/how-to-set-up-ml-agents-for-unity-on-apple-silicon-m1m2m3.html">How to set up ML Agents for Unity on Apple Silicon (M1/M2/M3)</a></dd>
<dt>Tue 19 March 2024</dt>
<dd><a href="https://jackmckew.dev/reinforcement-learning-with-pytorch.html">Reinforcement Learning with PyTorch</a></dd>
<dt>Mon 26 February 2024</dt>
Expand Down
10 changes: 5 additions & 5 deletions australia-post-codes-connected.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@
</a>
<h1><a href="https://jackmckew.dev">Jack McKew's Blog</a></h1>

<p>Engineer | Software Developer | Data Scientist</p> <p>Number of Posts: 108</p>
<p>Number of Words: 81,240</p>
<p>Number of Lines of Code 5,782</p>
<p>Engineer | Software Developer | Data Scientist</p> <p>Number of Posts: 109</p>
<p>Number of Words: 81,824</p>
<p>Number of Lines of Code 5,803</p>
<form class="navbar-search" action="/search.html" role="search">
<input type="text" name="q" id="tipue_search_input" placeholder="Search..">
</form>
Expand Down Expand Up @@ -863,7 +863,7 @@ <h1 id="australia-post-codes-connected">Australia Post Codes Connected</h1>
text-align: right;
}
</style>
<table border="1" class="table-striped table dataframe">
<table border="1" class="table dataframe table-striped">
<thead>
<tr style="text-align: right;">
<th></th>
Expand Down Expand Up @@ -1118,7 +1118,7 @@ <h1 id="australia-post-codes-connected">Australia Post Codes Connected</h1>
text-align: right;
}
</style>
<table border="1" class="table-striped table dataframe">
<table border="1" class="table dataframe table-striped">
<thead>
<tr style="text-align: right;">
<th></th>
Expand Down
Loading

0 comments on commit aa60b02

Please sign in to comment.