Weekly Playlist [3]

  1. #FiveThings Why TypeScript is for You
    Anders Hejlsberg (Creator of C# and TypeScript) and John Papa as they discuss how these and how to get started.
  2. #FiveThings that TypeScript Can Do for You
  3. Stanford Seminar – Current Status of tinyML and the Enormous Opportunities Ahead (panel discussion)
    An informative panel discussion about TinyML and opportunities.
  4. tinyML Talks – Pete Warden: Getting started with TinyML
    Pete Warden explains all about TinyML, so cool.
  5. I am also following this short video series of into to data science. Introduction to the Developer’s Intro to Data Science Video Series (1 of 28)

#tinyml #datascience #typescript

Weekly Playlist [2]

  1. Future of C#
    A fantastic session with Mads Torgersen as we cover the new features of C#9.0, the future of the language and some of the amazing features built for you.
  2. Computer Vision for Spatial Analysis
    Computer Vision is an Azure Cognitive Service which runs vision AI on images, and is a new feature of the Computer Vision service. It runs Vision AI on live and recorded video streams to understand people’s movement in physical spaces.
  3. What is Azure SQL Edge | Data Exposed
    In part one of this three-part series, Vasiya Krishnan introduces Azure SQL Edge and its features that make it the optimized database engine for IoT Scenarios. In part two, Vasiya will review customer examples and use cases, and in part three, she’ll conclude with a demo that demonstrates how to use Azure SQL Edge to build smarter renewable resources.
  4. Azure SQL Edge: Industry Use Cases & Customer Success | Data Exposed
    In part two of this three-part series, Vasiya Krishnan shares an example of how customers are using Azure SQL Edge as well as use cases.
  5. Azure SQL Edge: Demo, Renewable Energy | Data Exposed
    In the final episode of this three-part series, Vasiya Krishnan walks us through a demo that shows us how to use Azure SQL Edge to build smarter renewable resources.
  6. What’s New in the Cognitive Services Face API
    The Azure Cognitive Services Face service provides algorithms that detect, recognize, and analyze human faces in images. The ability to process human face information is important in many different software scenarios. In this episode we walk you through the latest innovation in Face API.
  7. Visual Studio Code Crash Course freeCodeCamp

#playlist #ml #csharp #vscode #edge #azure #computervision

Weekly Playlist

  1. Run your Vue and Node app anywhere
  2. Gregg Pollack – Introduction into the Composition API
  3. What you always wanted to know about Deep Learning, but were afraid to ask – Wei Meng Lee
  4. Getting the best out of Entity Framework Core – Jon P Smith
  5. ML and the IoT: Living on the Edge – Brandon Satrom
  6. Single Page Architectures with VueJS and ASP.NET Core – Kevin Griffin
  7. Machine Learning for .NET developers – Olia Gavrysh
  8. Evan You // Keynote: Live Free Online Announcement // Vuejs Global Online 
  9. ASP.NET Core Beyond the Basics – Chris Klug
  10. Let’s talk patterns – Chris Klug

#watchlist #ndc-conferences #vue #ml #aspnetcore #edgecomputing #deeplearning

Simple Accordion with VueJS

 <button type="button" class="btn btn-info btn-block" @click="toggleAccordion(0)">Information</button>
        <section class="bilgi font-text" v-if="accordions[0]">
          <div class="card p-1 m-1">
            <div class="card-body">Information</div>
          </div>
        </section>

        <button type="button" class="btn btn-warning btn-block" @click="toggleAccordion(1)">Data</button>
        <section class="bilgi font-text" v-if="accordions[1]">
          <div class="card p-1 m-1">
            <div class="card-body">Data</div>
          </div>
        </section>
data() {
    return {
      accordions: []
    };
  }
  methods: {
    toggleAccordion(id) {
   if (this.accordions[id]) {
        this.accordions = this.accordions.map((p) => (p = false));
      } else {
        this.accordions = this.accordions.map((p) => (p = false));
        this.accordions[id] = true;
      }
    }
  },

#vuejs #accordion

Azure Static Web Apps

Long-waited service from Azure is now in preview phase. I never understood why Azure did not have this product. Publishing a static page to blob storage is a nightmare, it is stupid. Anyway, finally, the service is here and can be used. Here are the steps to publish a static app to azure.

  1. Create the js app (Angular Vue etc) and publish it to GitHub
  2. Create the app from Azure Static Web App (Preview)
  3. Enter details, App is the root path of the app, and dist is the folder where the output of the project is.
  4. You will be asked to connect your GitHub repo, follow the instructions.
  5. The app will be compiled and published by using Github actions.

I haven’t seen a way to publish it manually, which again, I do not understand why. I usually prefer publishing manually (or with a bash/ps1 script) for smaller projects, where I need to make several deploys a day. But It is what we have, let use it.

Netlify is an awesome service for hosting static apps. But since we have so many products in Azure, we wanted to keep all projects in a single place, I hope after the preview phase, it will get better. If you prefer a better service, go ahead and use netlify, it is so cool.

Note: You can add your custom domain name with a CNAME record. An SSL certificate is issued for you.

[1]: Azure static web app: https://docs.microsoft.com/en-us/azure/static-web-apps/getting-started?tabs=vue
[2]: Netlify: https://www.netlify.com/

#azure #static-web-app #vue #angular #netlify

One line of CSS…

One line of CSS – not only centering things but more

Back in those times, centering things was a huge challenge. In order to marry the woman you love, you had to get something centered by CSS….

Nowadays, things have changed…

A good explanation from Una Kravets.

https://web.dev/one-line-layouts

#css #flex-box #css-grid

.NET Core Worker Service with EF Core

In ASP.NET Core applications, the services can be scoped, that can be resolved or instantiated at the start of a request, and disposed of at the end of a request. But in Worker Service type of applications, the definition of scope is not clear. That’s why we need to implement scoping ourselves. Let’s say every time the code runs, we assume it is a request.

1. Register DbContext in services

 public static IHostBuilder CreateHostBuilder(string[] args) =>
            Host.CreateDefaultBuilder(args)
                .ConfigureServices((hostContext, services) =>
                {
                    var configuration = hostContext.Configuration;
                    services.AddHostedService<Worker>();
                    services.AddScoped<MyDbContext>(s => new MyDbContext(configuration));
                });

2. Create the scope in the Worker

        private readonly IServiceProvider _provider;
        public Worker(ILogger<Worker> logger, IServiceProvider provider)
        {
            _logger = logger;
            _provider = provider;
        }

….

        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            while (!stoppingToken.IsCancellationRequested)
            {
                _logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now);
                using var scope = _provider.CreateScope();
                var db = scope.ServiceProvider.GetRequiredService<PodiumDb>();
                var notes= db.Notes.AsNoTracking().FirstOrDefault(p => p.NoteId== 340);
                await Task.Delay(1000, stoppingToken);
            }
        }

This is all. The DI container will create a new instance for us everytime the worker service loops.
Note that I used “using” statement without braces, it is a new feature of C# 8.0 https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-8#using-declarations1 The variable will be disposed at the end of enclosing scope, which means just after “await…” line.

#net-core #worker-service #entityframework-core

Executing code in intervals with…

Executing code in intervals with JS: setTimeout() and setInterval()

There are two ways you can execute the code in intervals with JS, but which one to use?

rtIXD7RoYl

OD9HaMdfuk

How do recursive setTimeout() and setInterval() differ?

The difference between the two versions of the above code is a subtle one.

  • Recursive setTimeout() guarantees the same delay between the executions. (For example, 100ms in the above case.) The code will run, then wait 100 milliseconds before it runs again—so the interval will be the same, regardless of how long the code takes to run.
  • The example using setInterval() does things somewhat differently. The interval you chose includes the time taken to execute the code you want to run in. Let’s say that the code takes 40 milliseconds to run — the interval then ends up being only 60 milliseconds.
  • When using setTimeout() recursively, each iteration can calculate a different delay before running the next iteration. In other words, the value of the second parameter can specify a different time in milliseconds to wait before running the code again.
    When your code has the potential to take longer to run than the time interval you’ve assigned, it’s better to use recursive setTimeout() — this will keep the time interval constant between executions regardless of how long the code takes to execute, and you won’t get errors.

Resource: https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Asynchronous/Timeouts_and_intervals

#javascript #setinterval #settimeout

Linode Object Storage with .NET and C#

Linode Object Storage is now available on Frankfurt data centre [1]. It is much more affordable and easier to manage unstructured data such as content assets (images, files etc..), sophisticated and data-intensive storage challenges around artificial intelligence and machine learning.

Since it is S3-compatible object storage, we can use AWS SDK for .NET for any operations needed.

1. Create a Project

dotnet new console 

2. Add Amazon SDK

dotnet add package AWSSDK.S3 

3. Example: List the buckets

class Program
    {
        static void Main(string[] args)
        {
            string accessKey = "**";
            string secretKey = "**";

            var config = new AmazonS3Config
            {
                RegionEndpoint = RegionEndpoint.EUCentral1, // Our bucket is on eu data center
                ServiceURL = "https://eu-central-1.linodeobjects.com" 
            };
            var amazonS3Client = new AmazonS3Client(accessKey, secretKey, config);
            ListMehmetBuckets(amazonS3Client).Wait();

        }

        static async Task ListMehmetBuckets(AmazonS3Client amazonS3Client)
        {
           var listBucketResponse = await amazonS3Client.ListBucketsAsync();
            foreach (var bucket in listBucketResponse.Buckets)
            {
                Console.Out.WriteLine("bucket '" + bucket.BucketName + "' created at " + bucket.CreationDate);
            }
            if (listBucketResponse.Buckets.Count > 0)
            {
                var bucketName = listBucketResponse.Buckets[1].BucketName;
                var listObjectsResponse = await amazonS3Client.ListObjectsAsync(bucketName);
                foreach (var obj in listObjectsResponse.S3Objects)
                {
                    Console.Out.WriteLine("key = '" + obj.Key + "' | size = " + obj.Size + " | tags = '" + obj.ETag + "' | modified = " + obj.LastModified);
                }
            }

        }
    }

You need to enable Object Storage in your Linode account before all. Check Linode docs for the details.
That’s all.

[1] Linode Storage Solutions
#linode #objectstorage #amazon-s3 #amazon-sdk-net

ASP.NET Core 3 Service…

ASP.NET Core 3 Service Registration – AddControllers() AddControllersWithViews() AddRazorPages()

With v3 and higher, there are several ways to register MVC. This way the application can only use what it requires, not the whole framework. This would result with a smaller size and being not sure, better performance.

AddControllers()

If you are developing an API, go with this. This is only for API-related features, Views or pages are not supported.

AddControllersWithViews();

This adds API + Views but not Pages. If you “dotnet new mvc”, it uses this code.

AddRazorPages()

This adds support for Razor Pages and minimal controller support. If you “dotnet new web”, it uses this code.

These can be combined as well. The following is equivalent to calling AddMvc in ASP.NET Core 2.2:

  
services.AddControllersWithViews();
services.AddRazorPages();

Resources:

https://docs.microsoft.com/en-us/aspnet/core/migration/22-to-30?view=aspnetcore-3.1&tabs=visual-studio-code#mvc-service-registration

https://www.strathweb.com/2020/02/asp-net-core-mvc-3-x-addmvc-addmvccore-addcontrollers-and-other-bootstrapping-approaches/

#aspnetcore #dotnet #net-core