<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Michael Ceber on Medium]]></title>
        <description><![CDATA[Stories by Michael Ceber on Medium]]></description>
        <link>https://medium.com/@michaelceber?source=rss-9d0be8973d57------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*g6jNqsC1r4gq6aB_cWpETg.jpeg</url>
            <title>Stories by Michael Ceber on Medium</title>
            <link>https://medium.com/@michaelceber?source=rss-9d0be8973d57------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 04:51:40 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@michaelceber/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Chat Bot using Chat GPT 3.5 in C#]]></title>
            <link>https://michaelceber.medium.com/chat-bot-using-chat-gpt-3-5-in-c-bb9c9a21f7db?source=rss-9d0be8973d57------2</link>
            <guid isPermaLink="false">https://medium.com/p/bb9c9a21f7db</guid>
            <dc:creator><![CDATA[Michael Ceber]]></dc:creator>
            <pubDate>Sat, 04 Mar 2023 21:41:08 GMT</pubDate>
            <atom:updated>2023-03-04T22:40:12.661Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Unleashing the Power of OpenAI and C# to Build Your Own Chatbot</em></p><p>This code employs the power of OpenAI’s chat API to create a sophisticated chatbot. The bot’s neural network is trained on a vast corpus of text, enabling it to respond to user input with impressive fluency and flexibility. The chatbot is initialized with a set of messages that introduce it to the user, and then it waits for the user’s input.</p><p>Once the user enters a message, the code sends that message, along with all previous messages, to the OpenAI API for processing. The API uses cutting-edge natural language processing algorithms to generate a response, which is then parsed and displayed to the user. This process repeats indefinitely, allowing for a fluid and engaging conversation between the user and the bot.</p><p>The code uses a combination of asynchronous HTTP requests and JSON parsing to communicate with the OpenAI API and handle the responses. It also incorporates Spectre.Console, a powerful library for styling and formatting console output, to display the messages and responses in an attractive and readable format. Overall, this code represents a sophisticated and powerful example of how modern AI technologies can be leveraged to create compelling conversational interfaces.</p><p>Simply create a new c# .net console application and paste the following code into <em>program.cs</em></p><pre>// See: https://platform.openai.com/docs/guides/chat/introduction<br>// See: https://platform.openai.com/docs/api-reference/chat<br><br>using Newtonsoft.Json;<br>using Spectre.Console;<br><br>const string key = &quot;YOUR API KEY&quot;;<br>const string url = &quot;https://api.openai.com/v1/chat/completions&quot;;<br><br>// Initialise the chat by describing the assistant,<br>// and providing the assistants first question to the user<br>var messages = new List&lt;dynamic&gt;<br>{<br>    new {role = &quot;system&quot;,<br>        content = &quot;You are ChatGPT, a large language &quot; +<br>                                    &quot;model trained by OpenAI. &quot; +<br>                                    &quot;Answer as concisely as possible.  &quot; +<br>                                    &quot;Make a joke every few lines just to spice things up.&quot;},<br>    new {role = &quot;assistant&quot;, <br>        content = &quot;How can I help you?&quot;}<br>};<br>AnsiConsole.MarkupLine($&quot;[purple]MACHINE:[/] [blue]{Markup.Escape(messages[1].content)}[/]&quot;);<br><br>while (true)<br>{<br>    // Capture the users messages and add to<br>    // messages list for submitting to the chat API<br>    var userMessage = AnsiConsole.Ask&lt;string&gt;($&quot;[purple]USER:[/] &quot;);<br>    messages.Add(new { role = &quot;user&quot;, content = userMessage });<br><br>    // Create the request for the API sending the<br>    // latest collection of chat messages<br>    var request = new<br>    {<br>        messages,<br>        model = &quot;gpt-3.5-turbo&quot;,<br>        max_tokens = 300,<br>    };<br><br>    // Send the request and capture the response<br>    var httpClient = new HttpClient();<br>    httpClient.DefaultRequestHeaders.Add(&quot;Authorization&quot;, $&quot;Bearer {key}&quot;);<br>    var requestJson = JsonConvert.SerializeObject(request);<br>    var requestContent = new StringContent(requestJson, System.Text.Encoding.UTF8, &quot;application/json&quot;);<br>    var httpResponseMessage = await httpClient.PostAsync(url, requestContent);<br>    var jsonString = await httpResponseMessage.Content.ReadAsStringAsync();<br>    var responseObject = JsonConvert.DeserializeAnonymousType(jsonString, new<br>    {<br>        choices = new [] {new {message=new {role=string.Empty,content=string.Empty}}},<br>        error=new {message=string.Empty}<br>    });<br><br>   <br>    if (!string.IsNullOrEmpty(responseObject?.error?.message))  // Check for errors<br>    {<br>        AnsiConsole.MarkupLine($&quot;[bold red]{Markup.Escape(responseObject?.error.message)}[/]&quot;);<br>    }<br>    else  // Add the message object to the message collection<br>    {<br>        var messageObject = responseObject?.choices[0].message;<br>        messages.Add(messageObject);<br>        AnsiConsole.MarkupLine($&quot;[purple]MACHINE:[/] [blue]{Markup.Escape(messageObject.content)}[/]&quot;);<br>    }<br>}</pre><p>Ensure to add the following two nuget packages.</p><pre>&lt;PackageReference Include=&quot;Newtonsoft.Json&quot; Version=&quot;13.0.2&quot; /&gt;<br>&lt;PackageReference Include=&quot;Spectre.Console&quot; Version=&quot;0.46.0&quot; /&gt;</pre><p>Click <em>F5 </em>to run or <em>dotnet run</em> from command line!</p><p>Here is a sample conversation (ignore my bad spelling, chat gpt does!)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OKAnrD8l5G4PodBodseY9g.png" /></figure><p>p.s the opening 3 paragraphs was written by the ChatGPT API!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bb9c9a21f7db" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The most useful usage of a single character +on@ on the internet]]></title>
            <link>https://michaelceber.medium.com/the-most-useful-usage-of-a-single-character-on-on-the-internet-1183bfdf4a09?source=rss-9d0be8973d57------2</link>
            <guid isPermaLink="false">https://medium.com/p/1183bfdf4a09</guid>
            <category><![CDATA[awesome]]></category>
            <category><![CDATA[spam]]></category>
            <category><![CDATA[gmail]]></category>
            <category><![CDATA[email]]></category>
            <category><![CDATA[features]]></category>
            <dc:creator><![CDATA[Michael Ceber]]></dc:creator>
            <pubDate>Sun, 13 Dec 2020 13:16:01 GMT</pubDate>
            <atom:updated>2020-12-13T13:16:01.614Z</atom:updated>
            <content:encoded><![CDATA[<h3>The most useful usage of a single character +on@ the internet</h3><p><a href="https://www.broadbandsearch.net/blog/google-statistics-facts#post-navigation-2"><strong>Twenty seven percent</strong></a><strong> </strong>of all emails sent around the world are opened using <a href="https://mail.google.com/"><strong>Gmail</strong></a>, that’s 1.5 billion users and it&#39;s imperative that you are all aware of this feature.</p><p>Let’s imagine my email address is:</p><p><strong>Michael.On.Medium@gmail.com</strong></p><p>Gmail allows anyone or any system sending an email to this account to append after the address the <strong>+ </strong>symbol followed by any combination of characters, for example:</p><p><strong>Michael.On.Medium+Blogger.No1@gmail.com</strong></p><p>The email will arrive at Gmail and the plus symbol and anything following it will simply be ignored and the email will be received by the correct account i.e Michael.On.Medium@gmail.com.</p><p>The best bit is when you open the email in Gmail it still gets populated with the actual TO details used, for example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/806/1*wSIG1_iBmA30E4nd7qNM3Q.png" /></figure><p>This brings us to the most useful feature of all this. Let’s say you are presented with that all to familiar sign up page, at some random site called QuestionableCompany.com. You might then enter your email address as</p><p><strong>Michael.On.Medium+Questionable.Company@gmail.com</strong></p><p>Two things you can do with this. If an email ever comes in from another site or company sent to Michael.On.Medium+Questionable.Company@gmail.com then you know they have been sharing your email address with 3rd parties. Secondly you can setup a filter and either mark all emails to this address as “Spam” or with a label such as “Questionable Emails”, hence keeping your inbox nice and clean.</p><p>Another very useful feature is let&#39;s say you signed up to a company which had offered you a three day trial. A few days later you forgot to try it out. Very annoying! You can beg for an extension, or simply sign up again with for example Michael.On.Medium+more.trial@gmail.com. Job done, this is a completely new account and you are good to go!</p><p>In fact if you are pedantic and better if you use a decent password manager, why not append a unique ID every time you signup or register your email address? For example:</p><p><strong>Michael.On.Medium+7ghd2hb3d8sb@gmail.com</strong></p><p>By using a password manager in the same way it stores your password it will store your email address with the unique ID associated with that signup.</p><p>If you were to try achieve any of the above functionality not using the + symbol you would have to create a new email account every time which as we know can be slow and tiresome, and feels very redundant.</p><p>What started me using this feature myself was for software development purposes. When testing the signup process of an app I had been working on, I initially had to create and use numerous email accounts, whilst logging in and out of each one endlessly. This feature has saved A LOT of time!</p><p>One last thing in case you missed it the <em>dots </em>in any Gmail address are completely ignored, so if you prefer you could give out your address as <strong>MichaelOnMedium@gmail.com</strong>. However, be careful if you forget you signed up without the dots and later try with them as you may find that your account appears to not be registered!</p><p>Enjoy!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1183bfdf4a09" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Implementing a recursive projection query in C# and Entity Framework Core]]></title>
            <link>https://michaelceber.medium.com/implementing-a-recursive-projection-query-in-c-and-entity-framework-core-240945122be6?source=rss-9d0be8973d57------2</link>
            <guid isPermaLink="false">https://medium.com/p/240945122be6</guid>
            <category><![CDATA[entity-framework-core]]></category>
            <category><![CDATA[recursion]]></category>
            <category><![CDATA[c-sharp-programming]]></category>
            <category><![CDATA[dotnet]]></category>
            <category><![CDATA[sql]]></category>
            <dc:creator><![CDATA[Michael Ceber]]></dc:creator>
            <pubDate>Wed, 18 Nov 2020 01:01:09 GMT</pubDate>
            <atom:updated>2020-11-18T01:01:09.900Z</atom:updated>
            <content:encoded><![CDATA[<p>Imagine we have a table in the database called <em>Category</em> where each row may have a parent <em>Category </em>such that we end up with a hierarchical tree of categories and subcategories to some unknown depth.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BtJ3Zf1NyGcIFi7D5fQWoA.png" /></figure><p>Each <em>Category </em>contains an optional <em>ParentCategoryId </em>forming the basis of the table structure.</p><p>In C# you would have the corresponding class:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/968/1*zeOV04T4xbXa-gFaumoU0w.png" /></figure><p>Using <a href="https://docs.microsoft.com/en-us/ef/core/">Entity Framework Core</a> this would be configured like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Nbm8ndRzYD7Ce_nqGX9FLw.png" /></figure><p>So let&#39;s say we wish to produce a query to return a list of of the root most categories such that they also contain any child categories and in turn these child categories contain their subcategories and so on. Our first thought might be something like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/810/1*EjF-8hPEKQVOxSInzMWudA.png" /></figure><p>Unfortunately this will not work as the first levels subcategories children will not be loaded.</p><p>One way to get around this would be to load all categories first by enumerating a general <em>select all</em> query, like the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DocvY5y2QDQPnfcKn4fIjA.png" /></figure><p>This is ok for a small amount of data, but what if you have thousands or millions of rows and perhaps you are only interested in one root item this is not very efficient.</p><p>Furthermore we more often than not don’t want unnecessary data to be queried as typically we might be returning the data via a rest endpoint so would use some kind of DTO representation of our class, for example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/907/1*-1LUENiB2liYQnqHw0OFQQ.png" /></figure><p>Finally, one way to query the hierarchical would be to write a recursive method which applies a <a href="https://entityframeworkcore.com/querying-data-projection">projection </a>of Category to CategoryDTO and queries all subcategories as needed to a maximum specified depth.</p><p>Why do we need to specify a maximum depth? Well the recursive function which ultimately generates SQL needs to know when to stop and we want to achieve all this in a single query.</p><p>To do this we create a method which contains the required projection, in which makes a recursive call back to itself.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h5GrHt_3sgHT4HCJAT9DAA.png" /></figure><p>For each layer down we apply the projection recursively to the <em>SubCategories </em>property until we read the maximum depth. Ideally when picking the maximum depth a knowledge of the depth the hierarchy extends to is helpful to ensure nothing is missed. Going a few levels deeper than required is not a big problem as the underlying SQL <em>left joins</em> will just be populated with null data so not too costly.</p><p>Finally to use this we simply query the categories in the typical EF way, but noting for the root we only include <em>Categories </em>with a null <em>ParentCategory </em>and in the <em>Select</em> we initiate the recursive call to the projection method passing in a maximum depth and a starting depth of 0.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*06_PDdtCEjXZLRd9FSMooQ.png" /></figure><p>Thankyou and enjoy!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=240945122be6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[NHS England’s Covid App — What has gone wrong and where has the money gone?]]></title>
            <link>https://michaelceber.medium.com/nhs-englands-covid-app-what-has-gone-wrong-and-where-has-the-money-gone-ed711e94f1e6?source=rss-9d0be8973d57------2</link>
            <guid isPermaLink="false">https://medium.com/p/ed711e94f1e6</guid>
            <category><![CDATA[nhs]]></category>
            <category><![CDATA[covid19]]></category>
            <category><![CDATA[apps]]></category>
            <category><![CDATA[england]]></category>
            <category><![CDATA[contact-tracing]]></category>
            <dc:creator><![CDATA[Michael Ceber]]></dc:creator>
            <pubDate>Mon, 14 Sep 2020 20:49:02 GMT</pubDate>
            <atom:updated>2020-09-16T13:03:49.916Z</atom:updated>
            <content:encoded><![CDATA[<h3>NHS England’s Covid App — What has gone wrong and where has the money gone?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/718/1*odVsUHLXHZs4mrW-AH6rcQ.png" /></figure><p>The Republic of Ireland, Northern Ireland and Scotland as of writing this all have a <a href="https://en.wikipedia.org/wiki/Contact_tracing">contact tracing</a> “covid app” using the latest <a href="https://developer.apple.com/documentation/exposurenotification">Apple</a> /<a href="https://developers.google.com/android/exposure-notifications/exposure-notifications-api">Google</a> exposure notification technology. So where is England’s? What has gone wrong? Where has the money gone?</p><h3>Background</h3><p>Back in around March &amp; April governments began frantically working on developing a contact tracing app. Quite soon it became apparent that privacy was to be an issue, more specifically storing peoples locations on central servers would not go down nicely. Trying to solve this problem in conjunction with a functional contact tracing algorithm proved problematic. For example when attempting to scan other bluetooth devices would stop working if the user switched to any other application. This is a feature Apple and Google intentionally control. To get around this problem would required Apple and Google to develop a specialist feature which is exactly what they did.</p><p>By May Apple and Google announced that both would provide an “<a href="https://en.wikipedia.org/wiki/Exposure_Notification">Exposure Notification</a>” API which given government consent to specific developers would allow them to gain access and provide a fairly easy framework to implement a working contact tracing app.</p><p>At this point all developers ought to have stopped what they were working on and changed to using the new API. A no brainer really; the hard work has been done by Apple and Google. Any government body or development firm who continued on their current plan without such a pivot would be doomed to fail. This is where the decisions made by management of such a project really matters.</p><p>Better than just pivoting to new API, why should every state body whether written in house or contracted out all work in parallel on on effectively the same application? Surely even on top of Apple and Google API, the remaining 95% will also be common to every country?</p><h3>Covid Green App</h3><p>That’s exactly what the <a href="https://www.lfph.io/">Linux Foundation Public Health (LFPH)</a> had in mind and began working on their “Covid Green” app. Ths source code is available <a href="https://github.com/covidgreen/covid-green-app">here</a> and as of writing this is still actively being developed.</p><p>As time is of the essence what if you could have one code base for both Android and IOS? Well you can and so this was developed using <a href="https://reactnative.dev/">React Native</a> which allows you to write the vast majority of code once using <a href="https://www.javascript.com/">Javascript </a>or better <a href="https://www.typescriptlang.org/">Typescript</a> and pop out two apps one on the iPhone and the other on the Android.</p><p>The little bit of uncommon code specific to Android and IOS is dealt with using a “<a href="https://reactnative.dev/docs/native-modules-ios">Native Module</a>”, i.e the core module used by the <a href="https://github.com/covidgreen/react-native-exposure-notification-service">Covid Green app which interfaces to the Apple / Google exposure API</a>.</p><p>With such a wonderful open source project going on lets say roughly 95% of the work is done, and anyone one with experience running software projects would always have pounding at the back of their minds “<strong>do not reinvent the wheel</strong>”. This is a mantra heard throughout the IT industry and there are good reasons for it. If you reinvent the wheel your project may takes years instead of months and you only end up solving problems already solved.</p><p>So what if a team were to use the “Covid Green” app as a starting point and simply fine tuned the remaining few percent, such as the look and feel or country specifics.</p><h3>NearForm</h3><p>This is exactly what the company <a href="https://www.nearform.com/">NearForm </a>did. And they don’t hide this at all. Their open source code is “forked” from the Linux Foundation and can be found on <a href="https://github.com/nearform/covid-green-app">Github</a>.</p><p>You can read more about their decisions and journey to this point <a href="https://www.nearform.com/blog/4-lessons-learned-building-contact-tracing-apps/">here</a>.</p><p>By having a generous head start, a concise plan for a deliverable product was made possible as they have <a href="https://www.nearform.com/services/contact-tracing-app-development/">outlined</a> here.</p><p>So with most of the work done they were ready to deliver to the Republic of Ireland by adapting the code base to suit which is available to view here on <a href="https://github.com/HSEIreland/covid-tracker-app">GitHub</a>.</p><p>The underlying native modules developed by the Linux foundation was also cloned and can also be found on the <a href="https://github.com/HSEIreland/react-native-exposure-notification-service">HSE Ireland repository</a>.</p><p>To read more about their journey with Ireland see this <a href="https://www.nearform.com/work/covid-app-development">link on development</a> and <a href="https://www.nearform.com/blog/inside-the-collaborative-effort-behind-irelands-covid-tracker-app/">this on the collaboration effort.</a></p><p>So with Ireland out the way it was very quick to adapt for <strong>Northern Ireland</strong> and as of a few days ago <a href="https://www.nearform.com/blog/protect-scotland-covid-app/"><strong>Scotland </strong></a>(Protect Scotland)<strong> </strong>which can be <a href="https://protect.scot/">downloaded here</a>.</p><p>So now we are getting to the crux of the article. How much did this cost Scotland?</p><p>Only around £300,000. Does this sound like a lot? Well for software it’s a bargain in comparison from what you will read about shortly, but a realistic amount given the efficiency of NearForm being a provider for multiple countries.</p><h3>NHS England Money Waste</h3><p>So NHS England, as of now still don’t have an app. Worse it is estimated they have spent (thrown in the bin), and wait for it by June almost <a href="https://www.digitalhealth.net/2020/06/nhs-contact-tracing-app-cost/"><strong>£12 million pounds!</strong></a><strong> </strong>We are not in September so this figure has undoubtedly gone up.</p><p>Let us have a look at where the money has gone, and no better place to look than the government contracts website. This is not everything but will give you an idea of the bulk of it (apologies for the long list)</p><p><a href="https://www.contractsfinder.service.gov.uk/Notice/9e84084c-48ea-4ffb-9ee2-1b137c15e77c?origin=SearchResults&amp;p=1"><strong>#13.a. NHS Contact Tracing App — PMO and Project Mgmt Support from Accenture (2)</strong></a><strong> — <em>£308,679.06</em></strong><em> (</em>2 June 2020–30 June 2020)</p><p><a href="https://www.contractsfinder.service.gov.uk/Notice/3b999ddf-58cd-4089-8403-d2729fbd5b66?origin=SearchResults&amp;p=1"><strong>#13. NHS Contact Tracing App — PMO and Project Mgmt Support from Accenture (1)</strong></a><strong> — £560,587.20 (</strong>14 April 2020–1 June 2020)</p><p><a href="https://www.contractsfinder.service.gov.uk/Notice/290729b3-3889-449f-aa9b-483c16c63192?origin=SearchResults&amp;p=1"><strong>#18. NHS Contact Tracing App — Managed Cloud Service on the AWS platform</strong></a><strong> — £816,000 (</strong>ANS Group Limited)</p><p><a href="https://www.contractsfinder.service.gov.uk/Notice/2040fe59-d23d-4a9f-8b89-4a58617ee47a?origin=SearchResults&amp;p=1"><strong>#17. NHS Contact Tracing App — Technical Policy Support from Mason Advisory Ltd</strong></a><strong> — £266,400 (</strong>26 May 2020–17 August 2020)</p><p><a href="https://www.contractsfinder.service.gov.uk/Notice/6ca3808e-4b29-4f9e-834c-f3bf59d63e22?origin=SearchResults&amp;p=1"><strong>#14. NHS Covid-19 App: Contact Tracing App — Managed Load Test contract EggPlant</strong></a><strong> — £213,600 (</strong>16 May 2020–31 July 2020)</p><p><a href="https://www.contractsfinder.service.gov.uk/Notice/d192d980-6fcd-4137-b9e0-29c47a9141e3?origin=SearchResults&amp;p=1"><strong>#1. NHSX — Proximity (Contact Tracing) App Development and Support contract with Go Pivotal (UK) Ltd</strong></a><strong> — £500,243 (</strong>11 March 2020–30 June 2020)</p><p><a href="https://www.contractsfinder.service.gov.uk/Notice/cb8cc8c3-b7f1-4cca-b335-77f090f1c073?origin=SearchResults&amp;p=1"><strong>#4. NHSX — Proximity (Contact Tracing) App: Mobile Delivery team contract with Zuhlke Engineering Ltd</strong></a><strong> — £1,074,240 (</strong>23 March 2020–16 September 2020)</p><p><a href="https://www.contractsfinder.service.gov.uk/Notice/ca3887ff-9485-4729-aa30-faff9ea894ec?origin=SearchResults&amp;p=1"><strong>#2. NHSX — Proximity (Contact Tracing) App Development and Deployment, contract with Go Pivotal (UK) Ltd<br>Go Pivotal (UK) Limited</strong></a><strong> — £1,321,967 (</strong>23 March 2020–30 April 2020)</p><p><a href="https://www.contractsfinder.service.gov.uk/Notice/9f892f2a-57fd-4e72-a689-1d3409fe5c08?origin=SearchResults&amp;p=1"><strong>Cloud Services to Support the hosting of the Covid 19 Contact Tracing Application</strong></a><strong> — £240,000 </strong>(1 April 2020–31 May 2020)</p><p><a href="https://www.contractsfinder.service.gov.uk/Notice/6ca3808e-4b29-4f9e-834c-f3bf59d63e22?origin=SearchResults&amp;p=1"><strong>#14. NHS Covid-19 App: Contact Tracing App — Managed Load Test contract EggPlant</strong></a><strong> — £213,600 (</strong>16 May 2020–31 July 2020)</p><p><a href="https://www.contractsfinder.service.gov.uk/Notice/8b2ea454-4a45-46b8-bb3d-2923d63928c0?origin=SearchResults&amp;p=1"><strong>PHE — ICT — Contact Tracing (Covid-19)</strong></a><strong> — £313,262 (</strong>12 May 2020–30 July 2020)</p><p><a href="https://www.contractsfinder.service.gov.uk/Notice/53c08945-ae26-47e1-b669-2503e862c62f?origin=SearchResults&amp;p=2"><strong>IoW Pilot Survey NatCen Social Research</strong></a><strong> — £235,000 (</strong>4 May 2020–30 June 2020)</p><p><a href="https://www.contractsfinder.service.gov.uk/Notice/df4dab49-5149-456d-a82e-3bfe43055833?origin=SearchResults&amp;p=1"><strong>#8. NHSX Covid-19 App: Mobile App Development and Support in Live</strong> phase, contract with Zuhlke Engineering Ltd</a> — <strong>£4,725,600 (£974,592 ?) (</strong>6 May 2020–10 November 2020)</p><p><a href="https://www.contractsfinder.service.gov.uk/Notice/4b97a4ef-e95c-4276-b575-219654053341?origin=SearchResults&amp;p=1"><strong>#10. NHSX Covid-19 App: Security Testing contract with HeleCloud Ltd</strong><br>HeleCloud</a> — <strong>£162,768 (</strong>11 May 2020–3 July 2020)</p><p>This is outrageous and the worst bit is most contracts have skipped the normal tendering process most likely due to the ‘emergency’. On the surface it appears they have thought “throwing money” at the problem would bring about a solution.</p><p>This is where Software Engineering differs from established industries such as Civil Engineering. Adding more money and more “cooks” more often than not make the problem worse.</p><p>So who has made such poor decisions? Well lets go to the top of the list where we find a couple contracts for the “Project Manager”, who happens to be Accenture. Around £900,000 pounds has gone to just managing the project! Compare this again to Scotland who got a completed product for just £300,000 pounds.</p><p>So where was NHSX in this? Why could their in house technology team not have made similar outsourcing decisions as Ireland, Northern Ireland and Scotland.</p><p>According to this <a href="https://news.sky.com/story/coronavirus-government-defends-use-of-consultancy-to-lead-roll-out-of-uks-new-contact-tracing-app-12053085">article</a> <em>“Accenture’s involvement in the contact-tracing project has caused unease inside NHSX”. </em>I am curious as to exactly what is meant by this.</p><p>In England the government department for signing of such large contracts and managing NHS England is known as <a href="https://www.gov.uk/government/organisations/department-of-health-and-social-care">The Department of Health and Social Care</a> and as such they tendered the contracts and awarded to the likes of Accenture. Anyone who has been following the last 20 years would know the NHS has wasted billions of pounds giving contracts to Accenture and in the process got many failed IT projects.</p><p>As of now, there could be new contracts being dished out for the England Covid App but they may not be showing on the government website — perhaps they will appear later?</p><h3>Poor technological and managerial decisions by NHS England</h3><p>So lets get back to technology. On the NHSX website we can see source code for the first failed app as well as the second app which is currently being promised:</p><p><strong>First App (canned)</strong></p><p><a href="https://github.com/nhsx/COVID-19-app-iOS-BETA">https://github.com/nhsx/COVID-19-app-iOS-BETA</a><br><a href="https://github.com/nhsx/COVID-19-app-Android-BETA">https://github.com/nhsx/COVID-19-app-Android-BETA</a></p><p><strong>Second App(current)</strong></p><p><a href="https://github.com/nhsx/covid-19-app-ios-ag-public">https://github.com/nhsx/covid-19-app-ios-ag-public</a><br><a href="https://github.com/nhsx/covid-19-app-android-ag-public">https://github.com/nhsx/covid-19-app-android-ag-public</a></p><p>One thing stands out straight away. They have completely separate source code for the Android and IOS app. This is because both apps have been written entirely in Native code, unlike NearForms solutions as discussed earlier used React Native. The latter straight off reduces development time by 50% and by using such javascript framework has many other aspects which reduce development time further.</p><p>The NHSX decision to write two entirely separate native applications given the urgency feels naive.</p><p>On the other hand one known drawback of using frameworks such as React Native it could be argued it&#39;s too difficult to access native functionality such as Bluetooth in specific or bespoke ways. However, this is generally not the case and most often solved by using “Native Modules” as discussed earlier, or to summarise the developer simply imports the native module into the common React Native project and when the application is built the corresponding native code is used depending on whether the build is for IOS or Android.</p><h3>Summary of Failings</h3><p>To summarise NHS England’s app was bound to be months behind all other solutions such as Scotland, Ireland and Northern Ireland for these reasons:</p><ol><li>Chose to write two separate native applications one for Android and one for iOS (and not just the first time round but also the current attempt).</li><li>Not cutting losses soon enough. When it was apparent the centralised approach was not working, the moment Apple and Google announced their API a switch should have been made as appears to be the case with other developers. Why did they proceed even testing the first app on the Isle of Wight?</li><li>Ignorantly thinking throwing money at a technological challenge should produce a result sooner. This is not a Civil Engineering project with hundreds of years of established practices. Many cooks more often than not can make software undeliverable. Why have so many successful startups arisen from 1–2 developers coding in their bath tubs?</li><li>Failure to collaborate with other governments or groups working on the same problem. Again if everyone is doing the same thing let one open source project do that part and do it well leaving only the customisation needed for each specific application as appears to be what NearForm has done.</li><li>Finally the most important aspect which covers all the failures above. Assignment of the Project Manager. Why was such a project handed to a massive consultancy such as Accenture with a terrible record on delivery for the NHS? This app was urgent and simply needed a small number of intelligent software engineers with management and red tape kept to a minimum. Had this been done I am confident that such a small team would have picked up on all the points above. Why would a small team of developers choose to write from scratch? They would quite quickly realise they can take 95% of the code from the open source project? On the other hand Accenture charge a fortune for their project management and often quote for larger teams of developers than is really required and is simply not the right option for an urgent believe it or not relatively “simple” application. Accenture have charged around £1 Million pounds for managing this project, so of course would match this by advising higher figures for the actual development. As can be seen by the contracts well into the millions of pounds awarded to <strong>Zuhlke Engineering </strong>and <strong>Pivotal</strong>.</li></ol><p>What next? We are being told that NHS England will deliver the app on <a href="https://www.bbc.co.uk/news/technology-54118022">September the 24th</a>. Perhaps it will be amazing and it will negate everything I have written above. However, if they fail to make this date, all existing contracts should be scrapped, the public should request the payments be returned for the failures and NHSX should take the Scottish, Ireland and Northern Ireland app and adapt to suit NHS England. Job Done!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ed711e94f1e6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[.NET Core Web API — How to correctly Fire and Forget Database Commands from Controller end point…]]></title>
            <link>https://michaelceber.medium.com/net-core-web-api-how-to-correctly-fire-and-forget-database-commands-from-controller-end-point-cad7a879630?source=rss-9d0be8973d57------2</link>
            <guid isPermaLink="false">https://medium.com/p/cad7a879630</guid>
            <category><![CDATA[tasks]]></category>
            <category><![CDATA[entity-framework-core]]></category>
            <category><![CDATA[dot-net-core]]></category>
            <category><![CDATA[asyncawait]]></category>
            <category><![CDATA[c-sharp-programming]]></category>
            <dc:creator><![CDATA[Michael Ceber]]></dc:creator>
            <pubDate>Sat, 29 Aug 2020 22:01:38 GMT</pubDate>
            <atom:updated>2020-08-29T22:01:38.705Z</atom:updated>
            <content:encoded><![CDATA[<h3>.NET Core Web API — How to correctly <strong>Fire and Forget</strong> Database Commands from Controller end point methods.</h3><p><em>Full source code for the examples shown in the post can be found at:</em></p><p><a href="https://github.com/MikeyFriedChicken/WebAPI.FireForgetRepository"><strong><em>https://github.com/MikeyFriedChicken/WebAPI.FireForgetRepository</em></strong></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/451/1*9SgVK4UbF2qnXqppdpddUw.png" /></figure><p>Typically a <em>.Net Core Web API</em> project will consist of c<em>ontroller </em>classes to define your request end points and a <em>repository </em>class which contains your database operations. If you are using <em>Entity Framework</em> then the repository will contain a reference to your <em>DBContext</em> which manages the underlying SQL commands and execution.</p><p>This works great and typically methods executed from the controller class or your end point all the way to the final database commands all correctly use the async / await keywords. This means that no thread on thread pool will remain blocked. This is important as there is a limited number of threads in the threadpool which are designed to handle many thousands of simultaneous requests. Hence, by using async/await throughout they will never be waiting on blocking calls keeping usage of the threadpool to a minimum.</p><p>So what’s the problem? In some instances you may have required database calls in which the main calling request simply do not depend on. Furthermore, such calls may be time consuming so including in the request execution thread would only slow down the total time before a result is returned.</p><p>For example logging extra information to an audit table in the database does may not need to be waited on. A typical example shown highlighted below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FLXWnBk70-DP9qnPHKO7LQ.png" /></figure><p>In these instances you may want to fire off such a database command on another task or thread and not await the result.</p><p>One option might be to create a background service where you can queue the work, however, this in most cases is over kill as using a normal task is completely suitable. So the only problem to solve here is how to instantiate and access the database context correctly on another thread.</p><p>So why not just spawn off the task without the await keyword? Well in theory that’s the idea and may seem OK at first thought, however, simply doing this would fail because the injected database context is typically set to a lifetime of the of the request, i.e “scope”. If you were to use the provided database context directly in your newly created task it would no longer be available because most likely the original request has already returned by the time its executed and <em>bad stuff will happen</em>. For example if you were to implement the following <strong>INCORRECT </strong>code below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u35kV_C-uCDaEf4ySvvyaQ.png" /></figure><p>An exception will be throw when accessing the database context inside the repository class. This is because the database <em>context </em>inside the <em>repository </em>is only available to the original request context and not that of the newly created task. Expect this exception to be thrown:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v7wHcZi8J2P2EuTnFA4qmg.png" /></figure><p>To solve this problem we can use the <em>IServiceScopeFactory </em>which is singleton available by default to create a new scope and through its attached service provider get a newly scoped database context which will be created and cleaned up as part of the newly created task, thus allowing the original request to be returned independently of the new task.</p><p>To do this we <em>could </em>simply inject the IServiceScopeFactory into our controller either via the constructor or the end point method, create our scope, resolve a new scoped instance of the repository/database context and use it there and then. For example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RWiROJ_rtm1Oruc0k2SGtg.png" /></figure><p>Why not do this? In general we try not to have references and usage of the dependency injector container in our main code, this would be an anti-pattern known as the <em>service locator pattern</em>. In this case although we have to use this anti-pattern somewhere it can be nicely contained and out of sight. This is how the code in the controller should ideally should look as shown in the <strong>CORRECT</strong> <strong>SOLUTION </strong>below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TKUgH2JzzLz_yRzdKQybOw.png" /></figure><p>Here we injecting a lambda function into our fire and forget handler which contains a single argument for the <em>repository</em>. This will later be executed on a seperate thread pool thread with a newly created scoped repository and database context passed into our lambda function. <em>No errors</em> and <em>no slowing</em> down our original request and result.</p><p>So how do we implement the fire and forget repository handler?</p><p>This is quite simple, we just need a single method which creates the task, resolves a newly scoped <em>repository </em>and executes the injected lambda function as shown:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x8I8nYV9eHiZmJCSZPLbXQ.png" /></figure><p>To wire this up simply register the class in configure services like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*35nUvHtDiVRif6omusecjg.png" /></figure><p>That’s all there is to it! Thankyou.</p><p>To copy and paste the code in the screen shots above see the following snippets below, or for the complete source code go to:</p><p><a href="https://github.com/MikeyFriedChicken/WebAPI.FireForgetRepository">https://github.com/MikeyFriedChicken/WebAPI.FireForgetRepository</a></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f4769ac929d2b13b1c1c6d9d0cf64271/href">https://medium.com/media/f4769ac929d2b13b1c1c6d9d0cf64271/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cad7a879630" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why should I own an Electric Scooter when I have a Bicycle?]]></title>
            <link>https://michaelceber.medium.com/why-should-i-own-an-electric-scooter-when-i-have-a-bicycle-60f8d274887c?source=rss-9d0be8973d57------2</link>
            <guid isPermaLink="false">https://medium.com/p/60f8d274887c</guid>
            <category><![CDATA[electric-scooters]]></category>
            <category><![CDATA[urban]]></category>
            <category><![CDATA[bicycles]]></category>
            <category><![CDATA[electric-vehicles]]></category>
            <category><![CDATA[leisure]]></category>
            <dc:creator><![CDATA[Michael Ceber]]></dc:creator>
            <pubDate>Thu, 02 Jul 2020 19:27:08 GMT</pubDate>
            <atom:updated>2020-07-03T12:32:23.881Z</atom:updated>
            <content:encoded><![CDATA[<p>I have owned a <a href="https://www.mi.com/global/mi-electric-scooter-pro/"><strong>Mi Electric Scooter Pro</strong></a> for around a month now and I think its worth talking about the benefits of such a piece of equipment over your every day <strong><em>bicycle</em></strong>. In other words why should you own an E-Scooter when you can ride a bike?</p><p><strong>Here are TEN reasons why.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/340/1*xWwAV6nkR0lZWepV2Qtt_A.jpeg" /></figure><h3>1. Less overhead / Less wasting time</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/284/1*LVjDPeWktm0093wpy3Mi_A.jpeg" /></figure><p>Lets say you have a journey to the grocery store which might be a 30 minute walk, or say ten minute bicycle ride. Most likely your bike is stored in the garage. You have to grab your helmet, keys for the lock, maybe wear slightly suitable clothes for cycling, unlock your bike and then head out.</p><p>On the other hand your scooter sits nicely folded up under the living room sofa or nicely packed by the sidewall of the bedroom. Time to go for a shop? You simply roll your scooter out your front door and you are on your way.</p><p>With a bike on arriving at the grocery store you first need to find a place to park and lock it. It may also not be right next to the store. This all adds extra time.</p><p>On the scooter, you say a few words as you go in the store “mind if i bring this in”, and in my experience so far 90% of store owners have said no problem at all. In most cases i fold the scooter down and leave it at the store front, or on occasion at the back, and if its just a pint of milk I don’t leave the scooter at all.</p><p>This results in a massive amount of time saved. Since having the scooter I don’t care if I say forgot to buy one grocery item as I know i can shoot out again at any time with little time lost. This is a massive benefit over a bicycle.</p><h3>2. No Sweat</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/513/1*DPVsIeW8LlPPaxAgpM8WGQ.jpeg" /></figure><p>Let&#39;s say you have an appointment with your bank manager, or the dentist, or simply going to the office (huh? forgot about these since the pandemic!) Why prior to my scooter did i need to take public transport or taxis? Well if you cycle besides the overhead from the point above, you <strong>sweat. </strong>With this comes smell, so you pretty much have to have a shower at the other end and if you don’t then do you really want the dentist or your colleagues giving you those funny looks?</p><p>So if time is an issue or there are no showers and specially in the midst of a pandemic when public transport is not really an option the E-Scooter is an amazing win, because it is <em>effortless</em>. i.e you won’t sweat, in fact you will be fresher than if you walked. At your destination you will still be smelling like the roses and the lavender soap you used in the morning.</p><p>And of course you will be at your appointment on time, which is the next benefit.</p><h3><strong>3. Never late again, no more excuses needed</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*bEWctTrTSUbAJwiqzCEUqg.jpeg" /></figure><p>A follow on from the first point. With public transport or taxis undoubtedly you are often late beyond any control of your own. That is probably why you have been riding a bike, possibly up until you read this article. So whilst a bike is pretty reliable on getting to where you are going on time the fact that you are saving more time at either end, and no waiting for shower queues in the office the chances of being late have dropped one more notch. Further to this another important point. Lets say you are actually late, i.e a bike would not get you to your appointment on time, there is generally nothing you can do. I recently had an appointment 8 miles away through central London and I would have been late. However, the E-Scooter can take routes no bike can take, another win which brings me to the next point…</p><h3>4. Incredibly Agile / More Route Options</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/318/1*9D1Y-VZcvWXGkmvrNys5yg.jpeg" /></figure><p>After using the scooter for around 10 minutes you will start to realise its incredibly agile and can take routes or narrow paths, and every twist and cranny which if you were on a bicycle would require you to get off, walk a bit, get back on and most likely you would skip the potential shortcut. In my real example from East London to Oxford Street where normally you would ride on the road, stopping for red lights, I was able to kill half the journey flying along the canal with no stops at all, popping out only at the main road for the last half, this knocked off an incredible amount of time, mainly due the fact there was no stopping for traffic lights.</p><p>It is not just time and distance which I love about this, but all these amazing new parts of London I am discovering. It makes every journey incredibly interesting and potentially fresh and new each time.</p><h3>5. Environmentally friendly</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*F0Yc24aAtvwFHemrdgYWgw.jpeg" /></figure><p>Hold on, how can it before more environmentally friendly than a bike? This is because you will probably never get in a taxi or diesel bus again. As the previous points highlighted a bike is not always an option. The alternatives have really only been polluting trains, buses or cars. However, now that the electric scooter is an option and a fun one you will be using this more and more instead of a polluting means.</p><h3>6. Pandemic Friendly</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cAbBnhIoPJkUV3PDKpMWfg.jpeg" /></figure><p>Obviously a bike is good for stopping viruses spreading, but as already mentioned it does involve locker rooms for the bike, shower rooms all of which are hot spots for viruses. As you no longer need any of this, and you certainly will not get in a bus whilst COVID-19 is doing the rounds, the electric scooter is probably the most <em>COVID Secure </em>means of getting from one place to another.</p><h3>7. BUT… What about my waist line?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/898/1*yFStTAVoE8wlQd2lwFSNwA.jpeg" /></figure><p>This is a very important point as one “potential” downside of the electric scooter is the fact that you MAY stop walking, and riding and the pounds will pile on. This is something to be conscious of, but easily mitigated. You must not see the scooter as an alternative to normal exercise. You are using it for other reasons, in fact all the reasons mentioned in this article. If you were planning a 30km bike ride in the evening, or weekend, then don’t substitute it for the scooter, do the bike ride, then have a shower, and use the scooter later in the evening to shoot up to the top of the hill for sunset…</p><h3>8. Very Much Leisure</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/730/1*ac2UZp52ztxGfsHgvJ984w.jpeg" /></figure><p>I almost left this point out covering all these technicalities, but this is the most obvious one. An electric scooter is a lot of fun! Cruising effortlessly up and down hills, turning sharp circles, watching the birds glide next you, whilst seeing the sun travel slowly down at dusk is amazingly beautiful, relaxing and simply makes you feel great. As a keen surfer not many things have come even close to the feeling of calving a long the water, however, Imust say for moments on the scooter I get the same feeling. Only moments though! Do not forget the saying <em>Only a Surfer Knows the Feeling</em> but you will get a glimpse.</p><h3>9. Price</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/280/1*zCmWBNUMWjckqD7-SK-tbA.jpeg" /></figure><p>Can you put a price on freedom? Seriously, at say £500 for a decent scooter (maybe half that for a more budget one), it really is not much different to the price of an entry grade bike. What about the battery and the motor, won’t I have to replace that? You might ask. Well like a bike parts do need to be replaced, however, one advantage of the scooter compared to a bike is there is very little moving parts. The entire motor is located in the wheel. There is a battery in the middle, and a simple wheel with some disc break on the front. No complex gearing systems, no chains, so I would say it’s at least a par with a bicycle.</p><h3>10. Safety</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/454/1*cFUQZUlHmxCI7nqdbhDMgw.jpeg" /></figure><p>OK this one might be a little subjective, and only time will tell how it compares to cycling when the data comes out, hopefully it is scarce! In my personal opinion, I feel at least as safe as on a bicycle. But let me reiterate this really is down to how you use it. For me I go at the top speed of 25 km/hr everywhere I can and I feel in the worst case scenario if i do come off its not super fast that speed will be a big factor in my injuries. However, the main concern is how does it fair with bikes especially in relation to cars? I find when I am travelling on the road, I can fit much more closely to the side of the road than on a bike adding a little security. However, the big win for me, and I am not sure how legal this is (laws are still being established — but generally its not allowed), any time a main road is looking unsafe, more often than not there are plenty of paths on the side of the road, and of course if no pedestrians are in sight its often very easy to complete a leg on a side walk and return back to the road when its safe. If you are travelling on the road, then like a bike a helmet is generally recommended and of course in some places illegal to not wear one.</p><p>Away, hope that helps you make up your mind to get an electric scooter!</p><p><a href="https://www.youtube.com/watch?v=qcI7HRJD09Q">https://www.youtube.com/watch?v=qcI7HRJD09Q</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=60f8d274887c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Making a social media shareable link with c# .Net]]></title>
            <link>https://michaelceber.medium.com/making-a-social-media-shareable-link-with-c-net-b85fb4f18b95?source=rss-9d0be8973d57------2</link>
            <guid isPermaLink="false">https://medium.com/p/b85fb4f18b95</guid>
            <category><![CDATA[social-media]]></category>
            <category><![CDATA[dot-net-core]]></category>
            <category><![CDATA[deep-linking]]></category>
            <category><![CDATA[html]]></category>
            <category><![CDATA[c-sharp-programming]]></category>
            <dc:creator><![CDATA[Michael Ceber]]></dc:creator>
            <pubDate>Sat, 20 Jun 2020 22:22:49 GMT</pubDate>
            <atom:updated>2020-06-20T22:22:49.541Z</atom:updated>
            <content:encoded><![CDATA[<h3>Making a social media shareable link with c# .Net Core with “Universal Link” alternative to open up your iPhone app directly</h3><p>Firstly what are <strong>social media sharing link</strong>s? When you share a link or URL to an article or to some particular content or screen in a mobile app on social media such as <strong>WhatsApp </strong>or <strong>Facebook </strong>you get a really tidy sexy preview. For example look at the two links below how they appear on WhatsApp:</p><pre><a href="https://www.cnn.com/travel/article/asia-hotel-deals-covid-19/index.html">https://www.cnn.com/travel/article/asia-hotel-deals-covid-19/index.html</a></pre><pre><a href="https://www.netflix.com/title/80233783?s=i&amp;trkid=13747225">https://www.netflix.com/title/80233783?s=i&amp;trkid=13747225</a></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bD3NgIV_wqOA-N9F3VMbRg.jpeg" /></figure><p>When I paste the same links directly into this article as I write it Medium has been able to render the first link for CNN but notably not for Netflix.</p><p>Netflix (no preview is coming up): <a href="https://www.netflix.com/title/80233783?s=i&amp;trkid=13747225&amp;t=wha">https://www.netflix.com/title/80233783?s=i&amp;trkid=13747225</a></p><p>CNN (preview is similar to whats app)</p><p><a href="https://www.cnn.com/travel/article/asia-hotel-deals-covid-19/index.html">Luxury hotels in Asia offering stellar deals for travelers amid coronavirus</a></p><p><em>You can read more about how Medium do this here: </em><a href="https://help.medium.com/hc/en-us/articles/214981378-Embeds"><em>Embeds </em></a><em>. It seems they use the third party </em><a href="https://embed.ly/"><em>https://embed.ly</em></a></p><p>Now both links in these two examples were generated from the sharing links provided within the CNN and Netflix IOS mobile applications.</p><p>However, for CNN what I click on the link from WhatsApp, it simply opens the article in the default browser despite me having the CNN app installed.</p><p>On the other hand when I click the Netflix link it opens the iOS Netflix app directly to the title. <em>If you are on a mobile device now, give it a shot!</em></p><p><strong>The ability to have normal internet URLS open on specific screens in iOS applications is known as </strong><a href="https://developer.apple.com/ios/universal-links/"><strong>Universal Links</strong></a></p><p>Without universal links “deep links” would have to be used instead.</p><p>For example for Netflix a deep link looks like this:</p><pre>nflx://www.netflix.com/title/<a href="https://www.netflix.com/title/80233783?s=i&amp;trkid=13747225&amp;t=wha">80233783</a></pre><p>This is how one mobile application can talk to one another. Works well for that use, but not very useful for sharing. Why two problems I can think of:</p><p>Firstly, If you were to share the link above in for example an email it’s extremely unlikely for the email client to recognise it as a deep link and it would not work at all. It would simply show text which is not even clickable.</p><p>Secondly, using a deep link like the one above would be useless on social media sharing as it only operates locally to your device. It is not a typical internet URL (e.g <a href="http://www.mycoolap.com/">http://www.mycoolap.com</a> etc), i.e social media applications have no server to pickup the preview like in the examples above.</p><p>This is why we “Universal Links” are used, because it solves these problems.</p><p>They provide the ability for previews by pulling this information on the internet, and the primary use is to provide a direct link into the mobile application, and finally if the mobile application is not installed, you will be directed in the normal way to your default browser.</p><p>Whilst this article is focused on iOS the same thing is available on the Android and this is known as “<a href="https://developer.android.com/training/app-links">Android App Links</a>”</p><p>So what’s the problem with Universal Links. Well firstly you have to successfully get them registered with Apple and maintain the configuration and only changes can be made in new builds as well as updating the hosted configuration file. Even then there may be other problems stopping it working.</p><p><strong><em>Take back control!</em></strong></p><p>The solution I am about to present is simple, clear, robust and provides beautifully rendered shareable links simulating what Universal Links do without all the fuss.</p><p>Firstly, create a template HTML file say called share-template.html. Then at run time you will simply replace the {variables} with the relevant data.</p><p>The meta data that the social media applications use to generate the preview is entirely taken from the &lt;head&gt; meta data.</p><p>Obviously if you wish to actually show useful data on a website should the application not be installed then you will need something in the &lt;body&gt;.</p><p>However, if this is the case you will most likely need to redirect the request to your main website or return the website html itself.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/684/1*fPxV7LO8rzW3-joxZGoZlg.png" /></figure><p>Or copy and paste from below</p><pre>&lt;html&gt;<br>&lt;head prefix=&quot;og: http://ogp.me/ns#&quot;&gt;<br>&lt;title&gt;{title}&lt;/title&gt;&lt;meta name=&quot;description&quot; content=&quot;{description}&quot; /&gt;<br>&lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1&quot; /&gt;<br>&lt;meta name=&quot;Slurp&quot; content=&quot;NOODP&quot; /&gt;<br>&lt;meta name=&quot;Slurp&quot; content=&quot;NOYDIR&quot; /&gt;<br>&lt;meta name=&quot;theme-color&quot; content=&quot;#525050&quot; /&gt;<br>&lt;meta property=&quot;og:title&quot; content=&quot;{title}&quot;&gt;<br>&lt;meta property=&quot;og:description&quot; content=&quot;{description}&quot;&gt;<br>&lt;meta property=&quot;og:type&quot; content=&quot;product&quot;&gt;<br>&lt;meta property=&quot;og:site_name&quot; content=&quot;mycoolapp/&gt;<br>&lt;meta property=&quot;og:locale&quot; content=&quot;en_GB&quot; /&gt;<br>&lt;meta property=&quot;og:url&quot; content=&quot;{url}&quot;&gt;<br>&lt;meta property=&quot;og:image:alt&quot; content=&quot;{title}&quot; /&gt;<br>&lt;meta property=&quot;og:image:secure_url&quot; itemprop=&quot;image&quot; content=&quot;{image-share}&quot;&gt;<br>&lt;meta property=&quot;og:image:type&quot; content=&quot;image/jpeg&quot; /&gt;<br>&lt;meta property=&quot;og:image:width&quot; content=&quot;256&quot; /&gt;<br>&lt;meta property=&quot;og:image:height&quot; content=&quot;256&quot; /&gt;<br>&lt;meta property=&quot;og:updated_time&quot; content=&quot;{updated}&quot; /&gt;<br>&lt;meta property=&quot;fb:app_id&quot; content=&quot;xxxxxxx&quot;&gt;<br>&lt;meta name=&quot;twitter:card&quot; content=&quot;summary_large_image&quot;&gt;<br>&lt;meta name=&quot;twitter:site&quot; content=&quot;@mycoolapp&quot;&gt;<br>&lt;meta name=&quot;twitter:creator&quot; content=&quot;@mycoolapp&quot;&gt;<br>&lt;meta name=&quot;twitter:title&quot; content=&quot;{title}&quot;&gt;<br>&lt;meta name=&quot;twitter:description&quot; content=&quot;{description}&quot;&gt;<br>&lt;meta name=&quot;twitter:image&quot; content=&quot;{image-share}&quot;&gt;<br>&lt;meta name=&quot;twitter:image:src&quot; content=&quot;{image-share}&quot;&gt;<br>&lt;meta name=&quot;twitter:image:alt&quot; content=&quot;{title}&quot; /&gt;<br>&lt;meta name=&quot;twitter:domain&quot; content=&quot;www.MyCoolSite.co&quot;&gt;<br>&lt;meta name=&quot;apple-mobile-web-app-title&quot; content=&quot;mycoolapp&quot;&gt;<br>&lt;meta name=&quot;application-name&quot; content=&quot;MyCoolSite&quot;&gt;<br>&lt;meta name=&quot;msapplication-TileImage&quot; content=&quot;mycoolapp&quot;&gt;<br>&lt;meta name=&quot;msapplication-TileColor&quot; content=&quot;#bb1919&quot;&gt;<br>&lt;meta name=&quot;mobile-web-app-capable&quot; content=&quot;yes&quot;&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>&lt;div&gt;&lt;b&gt;{description}&lt;/b&gt;&lt;/div&gt;<br>&lt;img src=&quot;{image}&quot; alt=&quot;{title}&quot; width=&quot;400&quot; height=&quot;400&quot;&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>So now how to handle requests to the end point of the shareable link?</p><p>Remember we want the meta data to be returned in all cases, except when users on an iPhone actually click the link we want the actual application to open.</p><p>Let says the shareable link is:</p><pre><a href="https://www.mycoolsite.com/share/profile/566563">https://www.mycoolapp.com/share/profile/</a><a href="https://www.netflix.com/title/80233783?s=i&amp;trkid=13747225&amp;t=wha">80233783</a></pre><p>The deep link to our application migh be</p><pre><a href="https://www.mycoolsite.com/share/profile/566563">mycoolapp</a>:///profile?userid=<a href="https://www.netflix.com/title/80233783?s=i&amp;trkid=13747225&amp;t=wha">80233783</a></pre><p>Simple, when the request hits our server if its coming from a browser on an iPhone we redirect the user to the deep link, otherwise we return the HTML.</p><p>For example in c# .net core add a method to your controller like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/761/1*MgqW5crSpNd65QBevq3wpA.png" /></figure><p>i.e If the link comes from a web browser on an iPhone the user will be redirected straight to the app, otherwise the HTML with all the juicy meta data will be returned and social media will render it nicely.</p><p>Obviously this can be extended to handle other devices like Android’s or even return different meta data depending on the origin of the request.</p><p>For example, when you first paste such a link in WhatsApp, it goes off and reads the meta data, i.e makes a request to the server. When this happens the User-Agent field in the header will include the fact its come from WhatsApp.</p><p>For my usage I simply required the header to be returned in all cases except when its from a browser on the iPhone so that I could redirect the user to the application.</p><p><strong>No registering Universal Links with Apple, this is simple and just works.</strong></p><p>Enjoy.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b85fb4f18b95" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Wrapping React Navigation navigators in Redux Containers]]></title>
            <link>https://michaelceber.medium.com/wrapping-react-navigation-navigators-in-redux-containers-497b432b8911?source=rss-9d0be8973d57------2</link>
            <guid isPermaLink="false">https://medium.com/p/497b432b8911</guid>
            <category><![CDATA[redux]]></category>
            <category><![CDATA[react-navigation]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Michael Ceber]]></dc:creator>
            <pubDate>Tue, 02 Jun 2020 20:45:43 GMT</pubDate>
            <atom:updated>2020-06-21T00:44:16.240Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KQGZ6N3RXh8qh5PdlyvgaQ.png" /></figure><p>Sometimes you need access to your global redux state inside the navigationOptions function defined in each navigator.</p><p>For example you might want to hide the bottom navigator easily from deep within a nested navigator or component. It is virtually impossible to crawl up the tree and try do this using parameters and navigator state.</p><p>Trust me I tried for hours and it was a mess!</p><p>Another example might be your connection to the internet has dropped off and such state is available in redux, and perhaps what ever navigator is currently focused or perhaps showing but far up the tree needs to all change colour as a result. Need a simple easy way to do this.</p><p>So how to access the redux state and have any changes applied to the navigation components?</p><p>Simple, wire the redux state into the screenProps which is available to use via the navigation options. When the redux state changes, screenProps also changes and the navigator is rendered.</p><p>So for example below the title is set to the value stored in redux at ui.Title</p><pre>navigationOptions: ({ navigation, screenProps }) =&gt; {<br>return {<br>    title: screenProps.ui.Title<br>};</pre><p>To do this take for example the classical creation of the stack navigator</p><pre>const navigator = createStackNavigator(<br>{<br>    ...<br>}</pre><p>To wire this into redux easily we use a reusable helper function</p><pre>const navigator = CreateConnectedNavigatorWithState(createStackNavigator(<br>{<br>   ...<br>})</pre><p>In this example every navigator needs access to the ‘ui’ slice of redux so I was able to reuse the same function throughout the application and it looks like this: (a bit verbose due to the typescript!)</p><pre>import { NavigationStackProp } from &quot;react-navigation-stack&quot;;<br>import { connect } from &quot;react-redux&quot;;<br>import { IGlobalState } from &quot;../types/state/IGlobalState&quot;;</pre><pre>export interface IProps {<br>   screenProps: { ui: IGlobalState[&quot;ui&quot;] };<br>}</pre><pre>export interface IOwnProps {<br>   navigation: NavigationStackProp;<br>}</pre><pre>export type INavigatorWrapperComponentProps = IProps &amp; IOwnProps;</pre><pre>const mapStateToProps = (state: IGlobalState, ownProps: IOwnProps): IProps =&gt; ({ screenProps: { ui: state.ui } });</pre><pre>export const CreateConnectedNavigatorWithState = (component: any) =&gt; connect(mapStateToProps)(component);</pre><p>If you have different requirements throughout your application then it might make sense to write a bespoke mapStateToProps for every connected component.</p><p>That is it! Works a treat. Time to remove all those crazy untyped cross cutting setParam and state.param calls!</p><p>Enjoy!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=497b432b8911" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GPU Monitoring on Windows 10 for Machine Learning & CUDA]]></title>
            <link>https://michaelceber.medium.com/gpu-monitoring-on-windows-10-for-machine-learning-cuda-41088de86d65?source=rss-9d0be8973d57------2</link>
            <guid isPermaLink="false">https://medium.com/p/41088de86d65</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[gpu]]></category>
            <category><![CDATA[cuda]]></category>
            <category><![CDATA[windows-10]]></category>
            <dc:creator><![CDATA[Michael Ceber]]></dc:creator>
            <pubDate>Thu, 21 Feb 2019 13:13:53 GMT</pubDate>
            <atom:updated>2019-02-21T13:52:29.465Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*6stKzIKjdC7ioXO_n8KEPQ.jpeg" /></figure><h3>Introduction</h3><p>I recently installed a brand new RTX 2080 TI GPU in order to speed up the training process when running machine learning scripts.</p><p>I could not see the GPU usage go above 5% which just didn&#39;t make sense. To someone new, it was not so obvious why. The assumption I made was that that windows task manager would simply show the overall GPU usage.</p><p>After some thought I did notice the GPU memory usage was quite high, so it must be doing a lot of work, then I realised the metric I was after was ‘CUDA’ performance which simply does not show by default and is not an included metric in the main processes table in task manager.</p><h3>What the default view looks like</h3><p>The default view in the ‘Performance’ tab does not show much action, however, I am maxing out the GPU, specifically using CUDA. Note, you can see that the GPU memory is quite high 8.4GB/11GB.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nZDqEDL-i8t1joV_wUA97Q.png" /></figure><p>Looking back at the main processes view the column which says ‘GPU’ only shows 3%. I would have at least expected this column to include all the metrics of work happening inside the graphics card. Even this just does not show work from CUDA.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N7tILHUWI0Pabp1RFAohYg.png" /></figure><h3>Add CUDA monitoring</h3><p>So if we switch back to the ‘Performance’ tab and pick one of the graphs and right click on the drop down we see a list of other performance metrics.</p><p>Let&#39;s replace the ‘Copy’ graph with ‘CUDA’</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VIqM30trxba9CYoNn2iBTA.png" /></figure><p>Excellent, now I get confirmation of where the action is happening. Currently, you can see the GPU — Cuda is working at around 70%</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EcSTCqQ2-ZsGx6y_tfumow.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=41088de86d65" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to support Multiple Databases in Entity Framework Core]]></title>
            <link>https://michaelceber.medium.com/how-to-support-multiple-databases-in-entity-framework-core-1ccd24896829?source=rss-9d0be8973d57------2</link>
            <guid isPermaLink="false">https://medium.com/p/1ccd24896829</guid>
            <category><![CDATA[entity-framework-core]]></category>
            <category><![CDATA[dotnet-core]]></category>
            <category><![CDATA[csharp]]></category>
            <category><![CDATA[sql-server]]></category>
            <category><![CDATA[postgresql]]></category>
            <dc:creator><![CDATA[Michael Ceber]]></dc:creator>
            <pubDate>Thu, 03 Jan 2019 13:24:01 GMT</pubDate>
            <atom:updated>2020-08-30T09:51:17.452Z</atom:updated>
            <content:encoded><![CDATA[<h4>Introduction</h4><p>This post shows you how to easily switching between using different databases (DBContext’s) while allowing for database specific settings to be easily configured</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/380/1*CkS5el7wl9v-PCFx985dzA.png" /></figure><p>In this example I show how to configure the following databases …</p><ul><li>Microsoft SQL Server</li><li>Postgres SQL</li></ul><p>… and show how to use dependency injection and sub classes to achieve this.</p><p><a href="https://github.com/MikeyFriedChicken/MultiDatabaseEFCore">Sample code</a> available at:</p><pre><a href="https://github.com/MikeyFriedChicken/MultiDatabaseEFCore">https://github.com/MikeyFriedChicken/MultiDatabaseEFCore</a></pre><h4>Configuration</h4><p>Firstly, depending on the configuration create the appropriate instance of DBContext:</p><pre>public void ConfigureServices(IServiceCollection services)<br>        {<br>            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);<br><br>            var databaseSection = Configuration.GetSection(&quot;Database&quot;);<br>            services.Configure&lt;DatabaseSettings&gt;(Configuration.GetSection(&quot;Database&quot;));<br>            var databaseSettings = databaseSection.Get&lt;DatabaseSettings&gt;();<br><br>            if (databaseSettings.DatabaseType == &quot;SQLServer&quot;)<br>            {<br>                 services.AddDbContext&lt;PeopleDBContext,PeopleDBContextSQLServer&gt;(ConfigureSQLServer);<br>            }<br>            else<br>            {<br>                services.AddDbContext&lt;PeopleDBContext,PeopleDBContextPostGresSQL&gt;(ConfigurePostgresSQL);<br>            }<br>        }</pre><p>First: ‘ConfigureSQLServer’</p><pre>private void ConfigureSQLServer(DbContextOptionsBuilder options)<br>        {<br>            string sqlServerConnectionString = &quot;user id=sa;password=YourStrong!Passw0rd;server=localhost,1433;database=PeopleDatabase;Trusted_Connection=no&quot;;<br><br>            options.UseSqlServer(sqlServerConnectionString);<br>            options.EnableSensitiveDataLogging();<br>        }</pre><p>and ‘ConfigurePostgresSQL’</p><pre>private void ConfigurePostgresSQL(DbContextOptionsBuilder options)<br>        {<br>            string postgresSqlConnectionString = &quot;Host=localhost;Database=PeopleDatabase;Username=postgres;Password=example&quot;;<br><br>            options.UseNpgsql(postgresSqlConnectionString);<br>            options.EnableSensitiveDataLogging();<br>        }</pre><p>In this sample we have a Person entity as shown below. For FirstName and LastName we can set the typename as an attribute as all databases support this. However, we leave MetaInfo for now as we would like to have different types depending on whether SQL Server or Postgres SQL is used.</p><p>Our ‘Person’ model class:</p><pre>public class Person<br>    {<br><br>        [Key]<br>        public long PersonId { get; set; }<br><br>        [Column(&quot;FirstName&quot;, TypeName = &quot;varchar(50)&quot;)]<br>        public string FirstName { get; set; }<br><br>        [Column(&quot;LastName&quot;, TypeName = &quot;varchar(50)&quot;)]<br>        public string LastName { get; set; }<br><br>        // As attributes can only reference constants<br>        // we must set the typename in OnModelCreating in the database context<br>        // as we want this to vary depending on the type of context used, i.e sql server, or postgressql<br>        [Column(&quot;MetaInfo&quot;)]<br>        public string MetaInfo { get; set; }<br>    }</pre><p>In SQL Server we want to set the Meta column type to ‘varchar(max)’, however, in Postgres SQL we would like to use a type of ‘json’.</p><p>To do this we define all such differences in the OnModelCreating method of DBContext. Hence, we create a subclass for each database as follows:</p><p>Define a sub class for SQL Server</p><pre>public class PeopleDBContextSQLServer : PeopleDBContext<br>    {<br><br>        public PeopleDBContextSQLServer(DbContextOptions&lt;PeopleDBContextSQLServer&gt; options) : base(options)<br>        {<br><br>        }<br><br>        protected override void OnModelCreating(ModelBuilder modelBuilder)<br>        {<br>            modelBuilder.Entity&lt;Person&gt;()<br>                .Property(a =&gt; a.MetaInfo).HasColumnType(&quot;varchar(max)&quot;);<br>        }<br><br>    }</pre><p>Define a subclass for Postgres SQL</p><pre>public class PeopleDBContext : DbContext<br>    {<br><br>    public class PeopleDBContextPostGresSQL: PeopleDBContext<br>    {<br>        /// &lt;summary&gt;<br>        /// Options will be of this specific type and we pass this to the protected not typed base class constructor<br>        /// &lt;/summary&gt;<br>        /// &lt;param name=&quot;options&quot;&gt;&lt;/param&gt;<br>        public PeopleDBContextPostGresSQL(DbContextOptions&lt;PeopleDBContextPostGresSQL&gt; options) : base(options)<br>        {<br><br>        }<br>        protected override void OnModelCreating(ModelBuilder modelBuilder)<br>        {<br>            modelBuilder.Entity&lt;Person&gt;()<br>                .Property(a =&gt; a.MetaInfo).HasColumnType(&quot;json&quot;);<br>        }<br>    }</pre><p>And that is it!</p><p><em>Why do this?</em></p><p>Well my main use case is that I have an application which might be using SQL Server in development, however, I know at a later stage or perhaps a different customer will want to use another database. I want to keep duplication to a minimum and allow for seamless swapping of the database. So I consolidate all such differences to the the ‘OnModelCreating’ method of each database subclass keeping the code simple and maintainable.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1ccd24896829" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>