JSON Type with MySQL & EF Core

As of MySQL 5.7.8, it has support for Json type. Setting the column type to json would do the job.

  [Column(TypeName = "json")]
  public string Settings{ get; set; }

Or with fluent api:

       modelBuilder.Entity<Blog>(eb =>
        {
            eb.Property(b => b.Settings).HasColumnType("json");
        });

If you send an invalid JSON, MySQL will throw an error of “Invalid JSON text”.
Details on usage are in the official documentation:
https://dev.mysql.com/doc/refman/5.7/en/json.html

In the case of custom objects, Pomelo has a feature as well: https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql/issues/14

A nive tutorial from scotch.io:
https://scotch.io/tutorials/working-with-json-in-mysql

#json #mysql #mysqlJson #efcore

Google translate in google sheets

https://support.google.com/docs/answer/3093331?hl=en&dark=1

Gif from: https://jakemiller.net/translate-in-google-sheets/

#GoogleSheets #GoogleTranslate

gcloud basics cheat sheet

GCloud Cheat Sheet:

App Deploy

  • gcloud app deploy ~/my_app/app.yaml
    [Resource]

List Versions

  • gcloud app versions list
  • JSON: gcloud app versions list --format json

List services

Delete services:

gcloud app services delete
[Resource]

List versions

  • “`gcloud app versions list“
  • Powershellgcloud app versions list --format json | ConvertFrom-Json
    [Resource]

Delete Versions

  • gcloud app versions delete

Read logs / tail

  • Read: gcloud app logs read
    [Resource]
  • Tail: gcloud app logs tail
  • Tail: gcloud app logs read --limit 10 --service=default
  • Tail: gcloud app logs read --version=v1
    [Resource]

Deploy google function with node

gcloud functions deploy pplusFunction --runtime nodejs8 --trigger-http

Split Traffic

To send all traffic to ‘v2’ of service ‘s1’, run:
gcloud app services set-traffic s1 –splits v2=1
To split traffic evenly between ‘v1’ and ‘v2’ of service ‘s1’, run:
gcloud app services set-traffic s1 –splits v2=.5,v1=.5

Google Cloud Build Trigger: ASP.NET Core and Angular


steps:
# run npm install for Angular
- name: 'gcr.io/cloud-builders/npm'
  args: ['install']
  dir: 'MyProject.Web/ClientApp'
# build Angular for production
- name: 'gcr.io/cloud-builders/npm'
  args: ['run', 'build','--','--prod']
  dir: 'MyProject.Web/ClientApp'
# publish asp.net core solution  
- name: microsoft/dotnet:2.2-sdk
  args: ['dotnet', 'publish','-c','Release']
# deploy the webapi to the AppEngine
- name: gcr.io/cloud-builders/gcloud
  args: ['app', 'deploy', './MyProject.Web/bin/Release/netcoreapp2.2/publish/app.yaml','--version','staging']
timeout: 660s

Other examples:
https://stackoverflow.com/questions/52725046/google-cloud-builder-how-to-trigger-build-configuration-in-a-subdirectory

#GoogleCloud #gcp #BuildTrigger

Compiling vs Transpiling

A question that I heard recently: Compiling vs Transpiling 

It seems that Wikipedia has enough information as well: “A source-to-source compiler, transcompiler or transpiler is a type of compiler that takes the source code of a program written in one programming language as its input and produces the equivalent source code in another programming language. A source-to-source compiler translates between programming languages that operate at approximately the same level of abstraction, while a traditional compiler translates from a higher level programming language to a lower level programming language.”

Here is the part that NativeScript has in its tooling section: https://docs.nativescript.org/tooling/transpilers

Well, considering how Typescript plays an important role nowadays, transpiling will be a term that we hear a lot.

#typescript #angular #nativescript

The 7 Steps of Machine Learning

Machine learning simply Yufeng explains…

Visit the whole playlist too: https://www.youtube.com/playlist?list=PLIivdWyY5sqJxnwJhe3etaK7utrBiPBQ2

#machinelearning

OpenCV 3.4.1 with Visual Studio 2017

  1. Download the prebuilt libraries and extract it (https://opencv.org/releases.html)
  2. Create a Visual C++ Console Project by using Visual Studio 2017
  3. Open the project properties by right-clicking the project and clicking Properties
  4. Select x64 from Platform
  5. Under C/C++ go to General > Additional Include Directories, Edit and add directory: YOUR_OPENCV_FOLDER\build\include
  6. Under Linker go to General > Additional Library Directories, Edit and add the directory: YOUR_OPENCV_FOLDER\build\x64\vc15\lib
  7. Under Linker go to Input, Aditional Dependencies add the name of the lib file opencv_world341d.lib which is under the folder build\x64\vc15\lib
  8. Write the code to read an image and display it
  9. Build the project
  10. In the directory of your solution, there is a folder named x64 and sub-folder Debug. Put your image in that folder and run yourProject.exe that you see in the same folder.

Read an image and display it.

include "stdafx.h"
include <opencv2/core/core.hpp>
include <opencv2/highgui/highgui.hpp>
include <iostream>
using namespace cv; using namespace std;

int main(int argc, char** argv) {

Mat image;

image = imread("MehmetImage.jpg", IMREAD_COLOR);

if (!image.data) // Check for invalid input
{
    cout << "Could not open or find the image" << std::endl;
    return -1;
}

namedWindow("Display window", WINDOW_AUTOSIZE); // Create a window for display.
imshow("Display window", image); // Show our image inside it.

waitKey(0); // Wait for a keystroke in the window
return 0;
}

#opencv #opencvwithvisualstudio2018 #computervision #machinelearning