2019年12月15日 星期日

Razor 頁面中變數在html中的處理方法

Ref: https://stackoverflow.com/questions/3696071/razor-syntax-inside-attributes-of-html-elements-asp-mvc-3

1. for loop 中變數處理問題
<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<body>
    @for (int i=1; i<6; i++)
    {
        <a href="wk0@i.html">test0@i</a>
    }
</body>
</html>

在0@間須有space 否則無法視@為變數。

2. 解決方法
<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<body>
    @for (int i=1; i<6; i++)
    {
        <a href="wk0@(i).html">test0@(i)</a>
    }
</body>
</html>

2019年12月12日 星期四

WPF webcam capture : 呼叫執行緒無法存取此物件,因為此物件屬於另一個執行緒

Ref: 1.  https://ponchi961.pixnet.net/blog/post/199057831
  2. https://github.com/emgucv/emgucv/blob/master/Emgu.CV.Example/CameraCapture/CameraCapture.cs


VS2017 @ Windows 10x64 : NET.Framework 4.6.1


//---xaml
<Window x:Class="wk1401.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:wk1401"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800">
    <Grid>
        <Image Name="imageBox1"/>
    </Grid>
</Window>
//---xaml.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace wk1401
{
    // nuget add emgu.cv
    // ref add System.ServiceModel 4.0
    using Emgu.CV;
    using Emgu.CV.CvEnum;
    using Emgu.CV.Structure;
    using Emgu.Util;
    using System.Drawing;
    using System.IO;
    /// <summary>
    /// MainWindow.xaml 的互動邏輯
    /// </summary>
    public partial class MainWindow : Window
    {
        private VideoCapture _capture = null;
        private Mat _frame;
        public MainWindow()
        {
            InitializeComponent();
            this.Closing += MainWindow_Closing;
            _capture = new VideoCapture();
            _capture.ImageGrabbed += _capture_ImageGrabbed;
            _frame = new Mat();
            _capture.Start();
        }

        private void MainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            _capture.Dispose();
        }

        private void _capture_ImageGrabbed(object sender, EventArgs e)
        {
            if (_capture != null && _capture.Ptr != IntPtr.Zero)
            {
                _capture.Retrieve(_frame, 0);
                this.Dispatcher.Invoke((Action)(() =>
                {
                    // your code or function here.
                    // https://ponchi961.pixnet.net/blog/post/199057831
                    imageBox1.Source = ConvertBitmapToImageSource(_frame.Bitmap);
                }));
             
            }
        }
        private ImageSource ConvertBitmapToImageSource(Bitmap imToConvert)
        {
            Bitmap bmp = new Bitmap(imToConvert);
            MemoryStream ms = new MemoryStream();
            bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
            BitmapImage image = new BitmapImage();
            image.BeginInit();
            ms.Seek(0, SeekOrigin.Begin);
            image.StreamSource = ms;
            image.EndInit();
            ImageSource sc = (ImageSource)image;
            return sc;
        }
    }
}


//---- webcam @ 3D
// Add helixtoolkit.wpf.dll
//-- xaml
<Window x:Class="wk1401.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:wk1401"
        xmlns:h="http://helix-toolkit.org/wpf"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800">
    <Grid>
        <h:HelixViewport3D>
            <h:DefaultLights/>
            <ModelVisual3D>
                <ModelVisual3D.Content>
                    <Model3DGroup >
                        <Model3DGroup.Children>
                            <DirectionalLight Color="#FFFFFFFF" Direction="3,-4,5" />
                            <GeometryModel3D>
                                <GeometryModel3D.Geometry>
                                    <MeshGeometry3D
              Positions="-1 -1 0  1 -1 0  -1 1 0  1 1 0"
              Normals="0 0 1  0 0 1  0 0 1  0 0 1"
              TextureCoordinates="0 1  1 1  0 0  1 0   "
              TriangleIndices="0 1 2  1 3 2" />
                                </GeometryModel3D.Geometry>
                                <GeometryModel3D.Material>
                                    <DiffuseMaterial>
                                        <DiffuseMaterial.Brush>
                                            <ImageBrush x:Name="imageBox1"/>
                                        </DiffuseMaterial.Brush>
                                    </DiffuseMaterial>
                                </GeometryModel3D.Material>
                            </GeometryModel3D>
                        </Model3DGroup.Children>
                    </Model3DGroup>
                </ModelVisual3D.Content>
            </ModelVisual3D>
        </h:HelixViewport3D>
        <!--<Image Name="imageBox1"/>-->
    </Grid>
</Window>
//--- xaml.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace wk1401
{
    // nuget add emgu.cv
    // ref add System.ServiceModel 4.0
    using Emgu.CV;
    using Emgu.CV.CvEnum;
    using Emgu.CV.Structure;
    using Emgu.Util;
    using System.Drawing;
    using System.IO;
    /// <summary>
    /// MainWindow.xaml 的互動邏輯
    /// </summary>
    public partial class MainWindow : Window
    {
        private VideoCapture _capture = null;
        private Mat _frame;
        public MainWindow()
        {
            InitializeComponent();
            this.Closing += MainWindow_Closing;
            _capture = new VideoCapture();
            _capture.ImageGrabbed += _capture_ImageGrabbed;
            _frame = new Mat();
            _capture.Start();
        }

        private void MainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            _capture.Dispose();
        }

        private void _capture_ImageGrabbed(object sender, EventArgs e)
        {
            if (_capture != null && _capture.Ptr != IntPtr.Zero)
            {
                _capture.Retrieve(_frame, 0);
                this.Dispatcher.Invoke((Action)(() =>
                {
                    // your code or function here.
                    // https://ponchi961.pixnet.net/blog/post/199057831
                    //imageBox1.Source = ConvertBitmapToImageSource(_frame.Bitmap);
                    imageBox1.ImageSource = ConvertBitmapToImageSource(_frame.Bitmap);
                }));
               
            }
        }
        private ImageSource ConvertBitmapToImageSource(Bitmap imToConvert)
        {
            Bitmap bmp = new Bitmap(imToConvert);
            MemoryStream ms = new MemoryStream();
            bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
            BitmapImage image = new BitmapImage();
            image.BeginInit();
            ms.Seek(0, SeekOrigin.Begin);
            image.StreamSource = ms;
            image.EndInit();
            ImageSource sc = (ImageSource)image;
            return sc;
        }
    }
}


2019年11月23日 星期六

emgu 4.1.1.3497 capture video by a webcam.

ref: https://github.com/emgucv/emgucv/tree/master/Emgu.CV.Example/CameraCapture

Visual Studio 2017 @ Windows 10 x64 @ ASUS  x450J

1. Form Application
1-1. New project by Form Template.
1-2. nuget Add emgu 4.1.1.3497
1-3. Toolbox add Emgu.CV ImageBox (imageBox1)
1-4. Form1.cs
add System.ServiceModel 4.0
namespace wk12webcam
{
    // nuget add emgu.cv
    // ref add System.ServiceModel 4.0
    using Emgu.CV;
    using Emgu.CV.CvEnum;
    using Emgu.CV.Structure;
    using Emgu.Util;

    public partial class Form1 : Form
    {
        private VideoCapture _capture = null;
        private Mat _frame;
        public Form1()
        {
            InitializeComponent();
            this.FormClosing += Form1_FormClosing;
            _capture = new VideoCapture();
            _capture.ImageGrabbed += _capture_ImageGrabbed;
            _frame = new Mat();
            _capture.Start();
        }

        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            _capture.Dispose();
        }

        private void _capture_ImageGrabbed(object sender, EventArgs e)
        {
            if (_capture != null && _capture.Ptr != IntPtr.Zero)
            {
                _capture.Retrieve(_frame, 0);
                imageBox1.Image = _frame;
            }
        }
    }
}

1-5. Results:



2. WPF
2-1. New project by WPF Template.
2-2. nuget Add emgu 4.1.1.3497
2-3. MainWindow.xaml
 <Grid>
        <Image Name="imageBox1"/>
 </Grid>
2-4. MainWindow.xaml.ccs
Similar procedure causes error as follows

ref: http://csjoublog.blogspot.com/2018/12/emgu-webcam-capture-wpf.html
namespace wk12WPFWebcam
{
    // Add System.ServiceModel 4.0
    using Emgu.CV;
    using Emgu.CV.CvEnum;
    using Emgu.CV.Structure;
    using Emgu.Util;
    using System.Drawing;
    using System.IO;
    using System.Threading;
    using System.Runtime.InteropServices;
    using System.Windows.Interop;

    /// <summary>
    /// MainWindow.xaml 的互動邏輯
    /// </summary>
    public partial class MainWindow : Window
    {
        private VideoCapture _capture = null;
        private Mat _frame;
        public MainWindow()
        {
            InitializeComponent();
            this.Closing += MainWindow_Closing;
            _capture = new VideoCapture();
            //_capture.ImageGrabbed += _capture_ImageGrabbed;
            _frame = new Mat();
            //_capture.Start();
            ComponentDispatcher.ThreadIdle += ComponentDispatcher_ThreadIdle;
        }

        private void ComponentDispatcher_ThreadIdle(object sender, EventArgs e)
        {
            using (var imageFrame = _capture.QueryFrame().ToImage<Bgr, Byte>())
            {
                if (imageFrame != null)
                {
                    imageBox1.Source = ConvertBitmapToImageSource(imageFrame.Bitmap);
                }
            }
        }
        private void MainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            _capture.Dispose();
        }
        private ImageSource ConvertBitmapToImageSource(Bitmap imToConvert)
        {
            Bitmap bmp = new Bitmap(imToConvert);
            MemoryStream ms = new MemoryStream();
            bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
            BitmapImage image = new BitmapImage();
            image.BeginInit();
            ms.Seek(0, SeekOrigin.Begin);
            image.StreamSource = ms;
            image.EndInit();
            ImageSource sc = (ImageSource)image;
            return sc;
        }
    }
}

2019年11月22日 星期五

emgu (4.1.1.3497) WPF example 2019/11/23

Ref: https://github.com/emgucv/emgucv/tree/master/Emgu.CV.Example/WPF

1. Visual Studio 2017 @ Windows 10 x64 @ ASUS X450J
2. emgu WPF example
3. failure : mat to image.source
    image1.Source = image.ToBitmapSource();
4. 轉換 mat to image.imagesource @ WPF
https://frasergreenroyd.com/how-to-convert-opencv-cvmat-to-system-bitmap-to-system-imagesource/
         private void image1_Initialized(object sender, EventArgs e)
        {
            Mat image = new Mat(100, 400, DepthType.Cv8U, 3);
            image.SetTo(new Bgr(255, 255, 255).MCvScalar);
            CvInvoke.PutText(image, "Hello, world", new System.Drawing.Point(10, 50),           Emgu.CV.CvEnum.FontFace.HersheyPlain, 3.0, new Bgr(255.0, 0.0, 0.0).MCvScalar);
            image1.Source = ConvertBitmapToImageSource(image.Bitmap); //.ToBitmapSource();
        }

        private ImageSource ConvertBitmapToImageSource(Bitmap imToConvert)
        {
            Bitmap bmp = new Bitmap(imToConvert);
            MemoryStream ms = new MemoryStream();
            bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
            BitmapImage image = new BitmapImage();
            image.BeginInit();
            ms.Seek(0, SeekOrigin.Begin);
            image.StreamSource = ms;
            image.EndInit();
            ImageSource sc = (ImageSource)image;
            return sc;
        }

2019年11月14日 星期四

csjou.github.io 建置程序

Ref: https://lazyteatime.like.community/2019/03/13/《如何在github架網站》%EF%BC%9A簡易教學/

Windows 10 x64 @ ASUS X450J

1. github.com 建立帳號
2. 登入
3. 建立 xxx.github.io 專案  (xxx : username)

4.建立首頁 index.html
<html>
<head>
       <title> csjou @ github </title>
</head>
<body>
     <h1> csjou@github test </h1>
     <marquee>走馬燈標籤測試</marquee>
</body>
</html>



5. https://xxx.github.io/
6. 測試 page2
 (Ref:https://www.w3schools.com/bootstrap/tryit.asp?filename=trybs_theme_me_grid&stacked=h)


2019年10月21日 星期一

jekyll blog 建置

1. jekyll 套件有blog template,可見置static blog, 發佈到github,使用https://csjou-hwu.github.io/


Ref: https://ithelp.ithome.com.tw/articles/10198964



2. Windows 10 x64 @ ASUS DM6660

3. https://jekyllrb.com/docs/installation/windows/

Install Ruby @ Windows 10

    3-1 download https://rubyinstaller.org/downloads/
Ruby+Devkit 2.6.5-1 (x64)  132MB

    3-2 Install


    3-3 Enable Linux sub System

    3-3 Download/Install Ubuntu 18.04 LTS


    sudo apt-get update -y && sudo apt-get upgrade -y       //很久
    sudo apt-add-repository ppa:brightbox/ruby-ng
    sudo apt-get update
    sudo apt-get install ruby2.5 ruby2.5-dev build-essential dh-autoreconf
    sudo gem update
    sudo gem install jekyll bundler
--- Takes longer time far more than what I was expected.
4. jekyll new myblog1

5. cd blog

6. bundle exec jekyll serve --host=0.0.0.0





git clone https://github.com/csjou-hwu/csjou-hwu.github.io.git




2019年10月13日 星期日

helixtoolkit 3D基本元件

ASUS X450J @ Windows 10 x64/ VS2017

<h:HelixViewport3D>
            <h:HelixViewport3D.Camera>
                <PerspectiveCamera Position="0 0 50"
                                   LookDirection="0 0 -1"
                                   UpDirection="0 1 0"/>
            </h:HelixViewport3D.Camera>
            <h:DefaultLights/>
            <!-- 3D Model -->
<h:HelixViewport3D>

1.  <h:BillboardVisual3D Position="1 1 40" Width="240" Height="140"></h:BillboardVisual3D>
2. <h:BillboardTextVisual3D Position="1 1 40" Text="周重石" FontSize="60"/>

3. <h:ArrowVisual3D Point1="-20 7 0" Point2="1 1 40" Diameter="1" Direction="1 1 0"></h:ArrowVisual3D>
4. <h:BoxVisual3D Center="1 1 30" Width="2" Height="2" Length="2"  Fill="Green" />
5. <h:CubeVisual3D Center="1 1 30" SideLength="2"  >
6. <h:EllipsoidVisual3D Center="1 1 30" PhiDiv="3" RadiusX="2" RadiusY="2" RadiusZ="3">

7. <h:HelixVisual3D  Diameter="3" Fill="GreenYellow" Length="25" Radius="1">
8. <h:LinesVisual3D Color="Black" Thickness="15"  Points="0 0 0 5 5 0">
9. <h:PieSliceVisual3D Center="0 -10 0" Fill="Red" EndAngle="120" StartAngle="0" OuterRadius="20" InnerRadius="5">
10. <h:RectangleVisual3D Length="5"    LengthDirection="1 1 1" Width="2">
11. <h:PipeVisual3D Diameter="10" Fill="Yellow" InnerDiameter="5" Point1="0 0 0" Point2="-10 -10 0"  >
12.<h:SphereVisual3D Radius="5" Center="-10 0 0"/>
13. <h:TubeVisual3D AddCaps="True" Angles="45" Diameter="8" Fill="Aqua" Path="0 0 0 -10 10 10 -10 10 -10">




2019年10月6日 星期日

System.Speech vs Microsoft.Speech

Ref: https://www.wpf-tutorial.com/audio-video/speech-recognition-making-wpf-listen/
        Kinect SDK 1.8 SpeechBasic-WPF
1-1. ASUS X450J @ Windows 10 x64 Edu
1-2. Kinect SDK 1.8
1-3. Visual Studio 2017

2 Ex from https://www.wpf-tutorial.com/audio-video/speech-recognition-making-wpf-listen/
2-1 New WPF Project
2-2 Add System.Speech.DLL
2-3 using System.Speech.Recognition;
2-4
SpeechRecognitionEngine speechRecognizer = new SpeechRecognitionEngine();
        public MainWindow()
        {
            InitializeComponent();
            speechRecognizer.SpeechRecognized += SpeechRecognizer_SpeechRecognized;

            GrammarBuilder grammarBuilder = new GrammarBuilder();
            Choices commandChoices = new Choices("weight", "color", "size", "顏色");
            grammarBuilder.Append(commandChoices);

            Choices valueChoices = new Choices();
            valueChoices.Add("normal", "bold");
            valueChoices.Add("red", "green", "blue");
            valueChoices.Add("small", "medium", "large");
            valueChoices.Add("紅色", "黑色", "白色");
            grammarBuilder.Append(valueChoices);

            speechRecognizer.LoadGrammar(new Grammar(grammarBuilder));
            speechRecognizer.SetInputToDefaultAudioDevice();
            speechRecognizer.RecognizeAsync(RecognizeMode.Multiple);
        }
    private void SpeechRecognizer_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            this.Content = e.Result.Text;
            //string command = e.Result.Words[0].Text.ToLower();
            //string value = e.Result.Words[1].Text.ToLower();
          }

        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            speechRecognizer.RecognizeAsyncStop();
            speechRecognizer.Dispose();
        }

3. Ref : SpeechBasic-WPF and ex2 Notes: The default CultureInfo is zh-TW
     @ Microsoft.Speech ==> without zh-TW.
3-1 Add Ref
C:\WINDOWS\assembly\GAC_MSIL\Microsoft.Speech\11.0.0.0__31bf3856ad364e35\Microsoft.Speech.dll
3-2 using Microsoft.Speech.Recognition;
3-3
public partial class MainWindow : Window
    {
        SpeechRecognitionEngine speechRecognizer = new SpeechRecognitionEngine(new System.Globalization.CultureInfo("en-US"));
        public MainWindow()
        {
            InitializeComponent();
            speechRecognizer.SpeechRecognized += SpeechRecognizer_SpeechRecognized;

            GrammarBuilder grammarBuilder = new GrammarBuilder();
            grammarBuilder.Culture = new System.Globalization.CultureInfo("en-US"); 
           // System.Threading.Thread.CurrentThread.CurrentCulture;
            Choices commandChoices = new Choices("weight", "color", "size");
            grammarBuilder.Append(commandChoices);

            Choices valueChoices = new Choices();
            valueChoices.Add("normal", "bold");
            valueChoices.Add("red", "green", "blue");
            valueChoices.Add("small", "medium", "large");
            //valueChoices.Add("紅色", "黑色", "白色");
            grammarBuilder.Append(valueChoices);

            speechRecognizer.LoadGrammar(new Grammar(grammarBuilder));
            speechRecognizer.SetInputToDefaultAudioDevice();
            speechRecognizer.RecognizeAsync(RecognizeMode.Multiple);
        }
   
    private void SpeechRecognizer_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            this.Content = e.Result.Text;
            string command = e.Result.Words[0].Text.ToLower();
            string value = e.Result.Words[1].Text.ToLower();
        }

        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            speechRecognizer.RecognizeAsyncStop();
            speechRecognizer.Dispose();
        }


2019年7月4日 星期四

docker jsp server

Ref: https://gist.github.com/hallazzang/c346e544b1c6fce8f304fdd5b2295fb6

ASUS X450J @ Windows 10 x64
docker

1. 檔案架構
yourproject/
    Dockerfile
    webapp/
        WEB-INF/
          classes/
          lib/
          web.xml
        index.jsp

yourproject/webapp/WEB-INF/web.xml

<web-app>
</web-app>

yourproject/webapp/index.jsp

<!doctype html>
<h1>It works!</h1>
<%
  for (int i = 0; i < 5; ++i) {
      out.println("<p>Hello, world!</p>");
  }
%>

Dockerfile

FROM tomcat:9.0.1-jre8-alpine
ADD ./webapp /usr/local/tomcat/webapps/webapp
CMD ["catalina.sh", "run"]
$ docker build -t mywebapp .

$ docker run --rm -it -p 8888:8080 mywebapp


2019年6月4日 星期二

nginx-ssl @ docker

Ref: http://www.ruanyifeng.com/blog/2018/02/nginx-docker.html

ASUS X450 @ Windows 10 x64 Prof
Docker version 18.09.2, build 6247962
openssl http://slproweb.com/products/Win32OpenSSL.html

1. Install openssl
2. Prepare certificate and key files
D:\ssl0604>"C:\Program Files\OpenSSL-Win64\bin\openssl.exe"
OpenSSL> req -newkey rsa:2048 -nodes -keyout key.pem -x509 -days 365 -out certificate.pem
OpenSSL> x509 -text -noout -in certificate.pem
3. copy *.pem into certs fold
4. docker run -d -p 8080:80 -p 8081:443 --name mynginx nginx
5. copy configuration fold
docker cp mynginx:/etc/nginx .
6. Modify conf.d/default.config
server {
    listen       80;
    server_name  localhost;

    #charset koi8-r;
    #access_log  /var/log/nginx/host.access.log  main;

    location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm;
    }

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    #location ~ \.php$ {
    #    root           html;
    #    fastcgi_pass   127.0.0.1:9000;
    #    fastcgi_index  index.php;
    #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
    #    include        fastcgi_params;
    #}

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}
}
server {
    listen 443 ssl http2;
    server_name  localhost;

    ssl                      on;
    ssl_certificate          /etc/nginx/certs/certificate.pem;
    ssl_certificate_key      /etc/nginx/certs/key.pem;

    ssl_session_timeout  5m;

    ssl_ciphers HIGH:!aNULL:!MD5;
    ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers   on;

    location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm;
    }
}
7. docker cp certs/. mynginx:/etc/nginx/certs/.
8. docker cp default.conf mynginx:/etc/nginx/conf.d/default.conf
9. docker exec -it mynginx  /bin/bash
10. nginx -s stop (logout automatically)
11. docker start mynginx
12 chech https://ip:8081/





2019年5月29日 星期三

docker save @cmd (Windows 10)

Ref: https://www.assistanz.com/import-and-export-docker-images/
ASUS Windows 10 Pro 1803
Docker version 18.09.2, build 6247962

docker save (儲存 image)

1. docker save -o xxxx.tar image_name:ooo
2. copy xxxx.tar into USB
3. dock USB into target PC
4. docker load –i g:\xxxx.tar
5. docker run -d -p 8000:80 ngaframe(image name)
6. Test OK

2019年5月8日 星期三

Get https://mcr.microsoft.com/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)

Ref: https://github.com/dotnet/dotnet-docker/tree/master/samples/aspnetapp
        https://stackoverflow.com/questions/46822391/docker-toolbox-tutorial-client-timeout-exceeded-while-awaiting-headers/48064026#48064026

docker for linux @ Windows 10 Prof 1803
1. Fail to build image as asp.net core app.
2. Error message:
Get https://mcr.microsoft.com/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
3. Change DNS Server from automatic to Fixed and Reset



4. Build aspnetapp images.
5. Test run
docker run --name aspnetcore_sample --rm -it -p 8000:80 aspnetapp

2019年5月5日 星期日

Test asp.net core ipv6

0-1. Hinet router
0-2. ASUS X450J @ Windows 10
0-3. asp.net core sdk 2.1

1. cmd ipconfig

ipv6 :   2001:b011:6c0b:1050:b976:96f3:d814:5fb

2. Program.cs (UseUrls("http://[ipv6]:5000/", "https://[ipv6]:5001")


3. chrome https://[2001:b011:6c0b:1050:b976:96f3:d814:5fb]:5001


4. mobile with the same WiFi Access Point




2019年4月14日 星期日

[C#] 目前沒有執行 ID 為 xxxx 的處理序

Ref: https://dotblogs.com.tw/onebin/2017/11/21/150815

VS 2017 @ Windows 10 x64

1. Download web (.net framework) solution folder from other computer.
2. 目前沒有執行 ID 為 xxxx 的處理序
3. Close vs2017
4. delete .vs (hidden) folder
5. Re-start


2019年2月17日 星期日

Windows 10 remote login ubuntu desktop

Ref: https://websiteforstudents.com/connect-to-ubuntu-16-04-17-10-18-04-desktop-via-remote-desktop-connection-rdp-with-xrdp/

1. Ubuntu desktop Install Xrdp Server
sudo apt install xrdp
sudo systemctl enable xrdp

2.
3. (取消查核)
4. 注意不可同時以相同帳號登入,遠端使用者須先自Ubuntu Desktop中登出,否則Remote desktop 會閃退。

2019年1月11日 星期五

Youtube直播不要急。

Youtube 經過(手機/語音)驗證後,需經啟用程序(**直播功能的啟用程序可能需要 24 小時才能完成)才可以使用,雖然顯示已經驗證,仍無法立刻開始直播。

2019年1月7日 星期一

更改 Google Form 樣式

Ref: https://www.brandeis.edu/communications/digital/toolkit/google-forms.html

1. Google Form template 選用
Google Form template 可以透過變更帳戶語言(English)方式,選用內建範本。

2. Google Form 字型變更,可以透過選取舊版本(click 右下角問號),進行編輯。