Google Extensions

通过google chrome扩展, 我们可以增加浏览器的功能, 来帮助用户更好的使用我们的产品, 今天就简单的告诉大家,如何快速的开始google扩展。

首先我们来说说脚手架

  1. extension-boilerplate - https://github.com/EmailThis/extension-boilerplate
    这个脚手架的魅力在于,你的一套代码,可以生成Chrome/Opera/Firefox的扩展, 内置了热加载来方便开发
    PS: 在安装包的时候你会报错,原因为此项目的gulp-sass版本过低,你可以将其升级为3.1.0或者4.1.0
    PPS:然后假设你的nodejs版本过高,又会导致build时打包出现问题, 你可以选择降低你的nodejs版本或者增加一个npm-shrinkwrap.json文件,然后增加如下配置

    1
    2
    3
    4
    5
    6
    7
    {
    "dependencies": {
    "graceful-fs": {
    "version": "4.2.2"
    }
    }
    }
  2. react-chrome-extension-boilerplate - https://github.com/jhen0409/react-chrome-extension-boilerplate
    对React比较喜欢的可以使用这个脚手架, 包含了Redux,以及热加载

  3. 不适用脚手架, chrome-plugin-demo - https://github.com/sxei/chrome-plugin-demo
    直接使用demo, 在demo的基础上开发
    这个示例相对齐全, 作者的博客地址 - http://blog.haoji.me/chrome-plugin-develop.html

3 Steps To Import Excel At .Net Core

Today I will tell you 3 steps to import excel at .Net Core.

  1. Install Spire.XLS, you can manage this at NuGet Package manager.


Figure: If you don’t have licence, you can use FreeSpire.XLS.

  1. import Spire.Xls;
1
using Spire.Xls;
  1. Enjoy
1
2
3
4
5
Workbook workbook = new Workbook();
workbook.LoadFromFile([fileURL/fileStream]);
Worksheet sheet = workbook.Worksheets[0];
CellRange range = sheet.Range[sheet.FirstRow, sheet.FirstColumn, sheet.LastRow, sheet.LastColumn];
DataTable dt = sheet.ExportDataTable(range, true, true);

Thanks for watching

5 Steps to use Google Sign-In for Websites

Interesting video about this - https://www.youtube.com/watch?v=Oy5F9h5JqEU

Todays infomation is from google’s guides

  1. Create authorization credentials
    1.1 Go to the Credentials page - https://console.developers.google.com/apis/credentials
    1.2 Click Create credentials > OAuth client ID.
    1.3 Select the Web application application type.
    1.4 Name your OAuth 2.0 client and click Create

  2. Load the Google Platform Library

  3. Specify your app’s client ID

    Or you can also specify your app’s client ID with the client_id parameter of the gapi.auth2.init() method.

  4. Add a Google Sign-In button

  5. Get profile information

    1
    2
    3
    4
    5
    6
    7
    function onSignIn(googleUser) {
    var profile = googleUser.getBasicProfile();
    console.log('ID: ' + profile.getId()); // Do not send to your backend! Use an ID token instead.
    console.log('Name: ' + profile.getName());
    console.log('Image URL: ' + profile.getImageUrl());
    console.log('Email: ' + profile.getEmail()); // This is null if the 'email' scope is not present.
    }

More info here - https://developers.google.com/identity/sign-in/web/sign-in

Use Azure Blob Create Cloud Disk

After you know how to use Azure blob, Today I will tell you how to create Cloud disk with Azure blob and MySql

  1. When we upload file, we will get the file md5.
  2. Store that md5 to your Mysql.
  3. When you upload file, if the md5 exist, get the url from mysql, else upload file and save md5.

In that way, same md5 file will only have one file on your blob.

I will show you a story

Figure: User green and user red, they have 5 files


Figure: Only 4 files will be upload


Figure: If User blue want to upload file1, we will only link him with the file

Thanks for watching.

Azure blob Transfer

After you know how to use Azure blob, Today I will tell you how to Migrate your data from one account to another.
We will use AzCopy to do that, you can get more info on Azure Storage Doc - Here

  1. You should download the AzCopy V10 executable file, you can place it anywhere on your computer. - Windows


    Figure: Let’s assume you put it at D:

  2. Get “Blob service SAS URL” of two accounts.
    You will find it at “Azure | Storage accounts | [Your account] | Shared access signature”.
    Just click “Generate SAS and connection string”, you will get the url under the button.


    Figure: Get “Blob service SAS URL”

  3. Use CMD to run AzCopy command
    3.1 Open CMD.
    3.2 Type d:
    3.3 Type azcopy copy “[Source Blob service SAS URL]” “[Target Blob service SAS URL]” –recursive
    E.g. azcopy copy “https://testsourceblob.core.windows.net/?sv=2020-05-06&asdfsdfsagfdsgfdgsdfgfdg"https://testtargetblob.core.windows.net/?sv=2020-05-06&asdfsdfsagfdsgfdgsdfgfdg" –recursive
    PS: Don’t forget add quote at your url.

  4. You can find the log file at your CMD


    Figure: The transfer speed is about 71MB/s

Thanks for watching.

Azure blob

Today I will show you how to use Azure blob.

If you’re not sure what Azure Blob is, or why you would use it, you can see more info on Azure blob - Here


Figure: Relation (As mentioned above, I would expand on this a little)

If you don’t already have an account, you’ll need to sign up for an Azure account, you can register Here
Once registered, click “Portal” in the right corner


Figure: Go to portal

  1. Search blob at search bar, you will find the “Storage accounts” at the Services section


    Figure: Search blob

  2. Click “Add” in the left corner and fill in the required items


    Figure: Add account

  3. Azure blob need “Containers” and fill in the required items


    Figure: Add container
    PS: Pay attention to the Public access level

  4. Now you can upload file throw Azure panel or API (We might talk about this in tne next post)


    Figure: Upload blob

Thanks for watching.

.Net Core 3.1.x Deploy

Today I will show you How to setup .Net Core deploy environment.

  1. Install .net core - https://dotnet.microsoft.com/download/archives
  2. Use Choco to install dotnetcore-windowshosting (3.1.x version)
    2.1 Open powershell - (Run as Administrator)
    2.2 Type “choco install dotnetcore-windowshosting”

    Figure: That figure shows you have successfully installed dotnetcore-windowshosting
  3. Install IIS - use Control panel to install IIS.
  4. Deploy your .Net core web/api on the IIS. - Don’t forget to set “.NET CLR version” to “No Managed Code” at Application Pools

Thank you for see that.