Compile GO code in Windows for a Debian server

Compile GO code in Windows for a Debian server

I have been learning Golang recently, and came to a point where I needed to deploy my app to a Debian server to test. I had created a simple API. In order to compile the app for Linux, I followed these steps:

  1. Set GOOS env. variable to Linux by $env:GOOS=’linux’ (you may also have to set GOARCH depending on your target operation system. Please check [5] in the resources below.
  2. Build the app by go build and copy the file to your server by sFTP
  3. Give user needed permission to run the file by sudo chmod ug+x yourFileName
  4. Run your file by sudo ./filename
  5. Allow the port in your firewall if set, by sudo ufw allow 8080(yourport)
  6. Test your URL, and if you want to use it in production, you can configure nginx as a proxy server.

Another option, I think better, is to compile your app in your server, and of course, the best would be integrating a CI/CD in the flow.

Example API

package main

import (

func get(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
w.Write([]byte(`{"message": "get called"}`))

func post(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
w.Write([]byte(`{"message": "post called"}`))

func put(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
w.Write([]byte(`{"message": "put called"}`))

func delete(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
w.Write([]byte(`{"message": "delete called"}`))

func notFound(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
w.Write([]byte(`{"message": "not found"}`))

func main() {
r := mux.NewRouter()
r.HandleFunc("/", get).Methods(http.MethodGet)
r.HandleFunc("/", post).Methods(http.MethodPost)
r.HandleFunc("/", put).Methods(http.MethodPut)
r.HandleFunc("/", delete).Methods(http.MethodDelete)
r.HandleFunc("/", notFound)
log.Fatal(http.ListenAndServe(":8080", r))

3. Set environment variables in PowerShell:
4. Configure firewall UFW:
5. List of target operating systems you can compile for:
6. Cross Compilation:
#golang #debian #go

Weekly Playlist [4]

Most of the resources for this week is about CosmosDB.

Reading list
1. Order of Precedence when Configuring ASP.NET Core
It is always good to review the basics: Configuring ASP.NET Core
Read about local functions

Azure Cosmos DB

  1. Azure Cosmos DB, Azure Functions, and Visual Studio Integration
  2. 2-minute data modeling with Azure Cosmos DB: improve your application’s speed and performance
  3. Data modeling for lower latency with Azure Cosmos DB
  4. 2-minute data partitioning with Azure Cosmos DB: optimize reads and writes for speed at any scale
  5. Build a zero-cost database: a step-by-step guide to moving to Azure Cosmos DB Free Tier
  6. Create Azure Cosmos DB Functions Trigger (.NET) in 2 minutes!
  7. Technical overview of Azure Cosmos DB Features and Capabilities
  8. IoT and Cosmos DB
  9. Intro: Azure Cosmos DB Data Indexing – Best Practices for optimal query performance
  10. Explaining Azure Cosmos DB Concepts – Partitioning/Throughput RUs/Reserved Capacity
  11. From SQL to Azure Cosmos DB – Jimmy Bogard very good and informative talk

#cosmosdb #azure #local-functions

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>

        <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>
data() {
    return {
      accordions: []
  methods: {
    toggleAccordion(id) {
   if (this.accordions[id]) {
        this.accordions = => (p = false));
      } else {
        this.accordions = => (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:
[2]: Netlify:

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

#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) =>
                .ConfigureServices((hostContext, services) =>
                    var configuration = hostContext.Configuration;
                    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 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?



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.


#javascript #setinterval #settimeout