2018年2月17日 星期六

Downloading SDK Platform Android 8.1.0, API 27, revision 1 Download finished with wrong size. Expected 65606517 bytes, got 65738431 byt

Ref:https://stackoverflow.com/questions/47719420/sdk-platform-android-8-1-0-cant-download

1. copy
C:\Program Files (x86)\Android\android-sdk\temp\platform-27_r01.zip
2. unzip platform-27_r01.zip
3. md C:\Program Files (x86)\Android\android-sdk\platforms\android-27
4. copy all files into android-27

Test android simulator by visual studio 2017 and then
tns run android == > OK

2018年2月7日 星期三

docker mysql utf8

Ref:https://github.com/docker-library/docs/blob/93eaf4f47c52c4b65d1cd31a5dcaa257848e5f13/mysql/README.md#configuration-without-a-cnf-file

ASUS X450J / Windows 10 /  Docker version 17.12.0-ce, build c97c6d6

1. Excel file save quiz1.csv and re-save as utf-8
cols.
id, Ans, QS, A1, A2, A3, A4, IM1, OK1
2.
docker run --name mysql2 -e MYSQL_ROOT_PASSWORD=password -d mysql --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
3. copy quiz1.csv into container
docker cp quiz1.csv acc:/var/lib/mysql-files/quiz1.csv
4. Chrome MySQL Admin
5.
CREATE DATABASE quizs;
use quizs;
6.
CREATE TABLE quiz1 (id INT);
ALTER TABLE quiz1 ADD COLUMN Ans INT;
ALTER TABLE quiz1 ADD COLUMN QS VARCHAR(512);
ALTER TABLE quiz1 ADD COLUMN A1 VARCHAR(256);
ALTER TABLE quiz1 ADD COLUMN A2 VARCHAR(256);
ALTER TABLE quiz1 ADD COLUMN A3 VARCHAR(256);
ALTER TABLE quiz1 ADD COLUMN A4 VARCHAR(256);
ALTER TABLE quiz1 ADD COLUMN IM1 VARCHAR(256);
ALTER TABLE quiz1 ADD COLUMN OK1 VARCHAR(256);
7. Import data
LOAD DATA INFILE '/var/lib/mysql-files/quiz1.csv'
INTO TABLE quiz1
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'
IGNORE 1 ROWS;
8. C# code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace newMySQL
{
    using System.Data;
    using MySql.Data.MySqlClient;
    class Program
    {
        static void Main(string[] args)
        {
            string 連線字串 = "Server=localhost;Database=quizs;Uid=root;pwd=password;";
            MySqlConnection 連線物件 = new MySqlConnection(連線字串);
            DataTable 資料表 = new DataTable();
            string SQL = "Select * From quiz1";
            連線物件.Open();
            MySqlDataAdapter 配接器 = new MySqlDataAdapter(SQL, 連線物件);
            配接器.Fill(資料表);
            連線物件.Close();
            //Console.WriteLine(資料表.Rows.Count);
            for (int i=0; i<資料表.Rows.Count; i++)
            {
                for (int j=0; j<8; j++)
                Console.Write(資料表.Rows[i].ItemArray[j].ToString());

                Console.WriteLine();
            }
            Console.ReadLine();
        }
    }
}
9. Results



docker Error: driver failed programming external connectivity on endpoint

Ref: https://github.com/docker/for-win/issues/573
ASUS X450J / Windows 10 /  Docker version 17.12.0-ce, build c97c6d6


1.  docker run --name mysql1 -e MYSQL_ROOT_PASSWORD=mypassword -d -p 3306:3306 mysql
fail:
C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error response from daemon: driver failed programming external
connectivity on endpoint mysql1 (571b7c68da7b048831e01138e6d0aa39ca571dbb0914c1d950ab2b1b1ff2001a): Error starting userl
and proxy: mkdir /port/tcp:0.0.0.0:3306:tcp:172.17.0.2:3306: input/output error.

2. Restart docker can solve the problem.