2021年1月8日金曜日

progressive-web-app and react-redux

https://eh-career.com/engineerhub/entry/2019/10/24/103000

PWAの作り方をサクッと学ぶ - 「ホーム画面に追加」「キャッシュ操作」「プッシュ通知」の実装

but -universal-project angular-pwa   not required

https://dev.classmethod.jp/articles/angular8-pwa/ :: ok

----------------------------------------------------------------------------------------------------------

index.js and app.js at tuyano textbook

import React from 'react';
import ReactDOM from 'react-dom';
import { createStore} from 'redux';
import { Provider } from 'react-redux';
import './index.css';
import App from './App';


// ステートの値
let state_value = {
counter:0,
message:"COUNTER"
}


// レデューサー
function counter(state = state_value, action) {
switch (action.type) {
case 'INCREMENT':
return {
counter:state.counter + 1,
message:"INCREMENT"
};
case 'DECREMENT':
return {
counter:state.counter - 1,
message:"DECREMENT"
};
default:
return state;
}
}


// ストアを作成
let store = createStore(counter);


// 表示をレンダリング
ReactDOM.render(
<Provider store={store}>
<App />
</Provider>,
document.getElementById('root')
);



import React, { Component } from 'react';
import { connect } from 'react-redux';
import './App.css';

// ステートのマッピング
//function mappingState(state) {
// return state;
//}
// Appコンポーネント
class App extends Component { // 3 lines belo are unnncessary
//constructor(props){
// super(props);
// }
render() {
return (
<div>
<h1>R edux example with 2 component :: Message and Button </h1>
<Message />
<Button />
</div>
);
}
}
// ストアのコネクト
//App = connect()(App); // unnecessary

// メッセージ表示のコンポーネント
class Message extends Component {
style = {
fontSize:"20pt",
padding:"20px 5px"
}
// this.props is store provided by Provider Tag in index.js
render(){
return (
<p style={this.style}>
{this.props.message}: {this.props.counter}
</p>
);
}
}
// ストアのコネクト
//Message = connect(mappingState)(Message);
Message = connect( (state) => state )(Message);

//
class Button extends Component {
style = {
fontSize:"16pt",
padding:"5px 10px"
}

constructor(){
super();
this.doAction = this.doAction.bind(this);
}

// ボタンクリックでディスパッチを実行
doAction(e){
if (e.shiftKey){
this.props.dispatch({ type:'DECREMENT' }); // passed to reducer named counter in index.js
} else {
this.props.dispatch({ type:'INCREMENT' });
}
}


render(){
return (
<button style={this.style}
onClick={this.doAction}>
click
</button>
);
}
}
// ストアのコネクト
Button = connect()(Button);

export default App;










2020年12月13日日曜日

mssql, asp.net core // c# and sqlite

dotnet ef dbcontext scaffold "Server=localhost\SQLEXPRESS;Database=blazordb;Trusted_connection=True" Microsoft.EntityFrameworkCore.SqlServer -o Models

文字列はsqlサーバインスト時以外に確認むつかしい

--------------------------------------------------------------------------------------

tuyano shoda の asp.net core 3.0入門の第四章から最新のasp.net core 5.0 に

置き換えてスキャホールディングに成功(core,design,sqlserver....sqlite not ye)

--------------------------------------------------------------https://3ryupg.hatenablog.com/entry/2018/03/12/2000002018-03-12 

原文を数か所変更したら成功した

(.Net,SQLite)データベースにSQLiteを使ってみた

.Net開発 ADO.Net SQLite C#

.Netアプリでスタンドアロンデータベースを使うときはいつもMDBを使ってたんですが、

今回はじめてSQLiteを使ってみました。

.Netアプリケーションから SQLite にアクセスする方法はいくつかあるらしいですが、

今回はVB.NETから組み込みデータベースのSQLiteを操作する方法 

| ラシカル開発記 を参考にさせてもらい System.Data.SQLite を使ってみました。


環境設定

System.Data.SQLite は http://sourceforge.net/projects/sqlite-dotnet2/files/から

ダウンロードできます。

setup版と、バイナリ版がありますが、バイナリ版をダウンロードし、System.Data.SQLite.DLL と System.Data.SQLite.XML を 

VisualStudioのプロジェクトフォルダに置けばOKです。(System.Data.SQLite.Linq.dllも]あるので、これを使えばLINQでアクセスできるのかもしれません)


VS側では、System.Data.SQLite.DLL を参照設定してやります。


ローカルのSQLiteの中身をWindowsPC上で編集したりデータ覗いたりするのはPupSQLite、もしくはTkSQLiteが便利です。

(WEBだと、SQLiteManagerが定番らしいですが。。)


なお、Windows用のコマンドは、http://www.sqlite.org/download.htmlからダウンロードできます。

接続

System.Data.SQLite はよくできており他のデータプロバイダとほぼ同じ感覚で使うことができます。接続は以下のような感じで出来ます。

using System.Data.SQLite;

//コネクションオブジェクト生成

SQLiteConnection sqlite_con = new SQLiteConnection();

//SQLite接続文字列定義

sqlite_con.ConnectionString = "Version=3;Data Source=test.sqlite;Compress=True;";

//DB接続

sqlite_con.Open();


//クエリ実行


//DBクローズ

sqlite_con.Close();

接続文字列についてです。


"Data Source=":SQLiteのデータベーファイルへのパスを指定。

"New=":Trueを入れると、新規データベーファイルを作成。(既にファイルが存在するとエラーになります) Falseなら既に存在するデータベーファイルを開くことになる。

"Version=":3固定。

"Password=":データベースのパスワードを指定。

"Synchronous=": 同期の設定。Normalだとディスク書き込み中にクラッシュした場合確率は低いがデータベースが壊れる可能性有り。 

Fullだと最も安全だが低速。Offだと高速だけどクラッシュすると壊れる可能性高い。

"Max Pool Size=":接続プールの最大接続数。この値を超えた接続要求があると、接続が空くまで待ち状態。

"Read Only=": Trueだと読み取り専用で開く。

詳しくは、System.Data.SQLiteの接続文字列で使用できる引数の説明 | ラシカル開発記で詳しく説明されています。


データベースファイル、テーブル作成::データベースファイルを新規に作成し、テーブルを作るサンプルはこんな感じです。


using System.Data.SQLite;

using System.Data; // DbTypeが定義されている

//コネクションオブジェクト生成

SQLiteConnection sqlite_con = new SQLiteConnection();

//SQLite接続文字列定義

sqlite_con.ConnectionString = "Version=3;Data Source=test.sqlite;New=True;Compress=True;";

//DB接続

sqlite_con.Open();

//コマンドオブジェクト生成

SQLiteCommand sqlite_cmd = sqlite_con.CreateCommand();


//テーブル作成クエリ

sqlite_cmd.CommandText  = "CREATE TABLE hoge (  id INTEGER , name TEXT , value  REAL)";

//クエリ実行

sqlite_cmd.ExecuteNonQuery();


//データ挿入

sqlite_cmd.CommandText = "INSERT INTO hoge ( id , name , value ) VALUES ( @id , @name , @value  )"

//クエリのパラメータ設定

sqlite_cmd.Parameters.Add("id", DbType.Int32);

sqlite_cmd.Parameters["id"].Value = 1;

sqlite_cmd.Parameters.Add("name", DbType.String);

sqlite_cmd.Parameters["name"].Value = "test";

sqlite_cmd.Parameters.Add("value", DbType.Double);

sqlite_cmd.Parameters["value"].Value = 0.002;


//挿入処理実行。戻り値は影響を受けた行数

int ret = sqlite_cmd.ExecuteNonQuery();


//DBクローズ

sqlite_con.Close(); 

----------------------------------------------------------------ここまで成功

データ参照クエリ

selectする場合はこんな感じ。


SQLiteConnection sqlite_con = new SQLiteConnection();

//SQLite接続文字列定義

sqlite_con.ConnectionString = "Version=3;Data Source=test.sqlite;Compress=True;";

//DB接続

sqlite_con.Open();

SQLiteCommand sqlite_cmd = sqlite_con.CreateCommand();

sqlite_cmd.CommandText = "SELECT id , name , value FROM hoge WHERE name LIKE @nameparam ";

//クエリのパラメータ設定

sqlite_cmd.Parameters.Add("nameparam", DbType.String);

sqlite_cmd.Parameters["nameparam"].Value = "test%";

//クエリ実行 結果はDataReaderで取得

SQLiteDataReader reader = sqlite_cmd.ExecuteReader();


 DataReaderでループして読み込む場合は以下のようにする。

while (reader.Read())

{

    Console.WriteLine(reader["id"] + "," + reader["name"] + "," + reader["value"] );

}


//接続終了

sqlite_con.Close();

------------------------------------------------------------------ これも成功

使ってみた感想としては十分MDBの代わりになるんじゃないかと思います。ただ、今回DLLを直接参照しただけなので、

VisualStudioのデータセットデザイナのウィザードからデータベースを参照することは出来ませんでした。インストール版であればいけるのかもしれません。

------------------------------------------------------------------- 以下は参考程度

https://codezine.jp/article/detail/2823 :: mono and sqlite 1

https://codezine.jp/article/detail/2851 :: mono and sqlite 2

2020年11月15日日曜日

c# mono sqlite3

https://kledgeb.blogspot.com/2019/12/net-core-88-deb-net-core-310.html 

:: .net  core 3.1 deb install 

------------------------------------------------

https://codezine.jp/article/detail/2823?p=2 

データベースへのパスを自分用にすればOKだった

gmcs new2.cs -r:System.Data.dll とあったがだめでmcsでOK!
https://codezine.jp/article/detail/2851 が別だてであった

2020年11月13日金曜日

mono でvb.net,csharpのGUIなどをやる

 http://simplesandsamples.com/ :: 実に詳しい

mcs below-program.cs -r:System.Windows.Forms -r:System.Drawing

using System;

using System.Windows.Forms;

using System.Drawing;

 

namespace MyFrmApp

{

    public class MyForm : Form

    {

        public MyForm()

        {

            Label label = new Label();

            label.Text = "Welcome to C#!";

            label.Font = new Font("Geneva",18,FontStyle.Regular);

            label.Height = 30;

            label.Width = 300;

            this.Controls.Add(label);

            this.Width = 300;

            this.Height = 200;

        }

    }

}


namespace MyFrmApp

{

    class Program

    {

        [STAThread]

        private static void Main(string[] args)

        {

            Application.Run(new MyForm());

        }

         

    }

}

以上は、libro tuyanoのソースコード monodevelop統合環境での開発記事だが

もうないので、最上のサイトを参考に、コマンドラインでコンパイルする


2020年10月18日日曜日

Vim & Julia with gcc & Rust & Curl & Php-Mysql & Prodel wiht mono & swift on linux

https://www.hpc.co.jp/support/hello_vi_01/ vim tutorial

---------------------------

Julia からC を呼び出す簡単なサンプル

https://qiita.com/SatoshiTerasaki/items/f699cdfa26291524b47a

ただし export LD_LIBRARY_PATH="."が必要

https://myenigma.hatenablog.com/entry/2018/11/13/212347#2-%E7%92%B0%E5%A2%83%E5%A4%89%E6%95%B0%E3%81%AE%E8%A8%AD%E5%AE%9A

ーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー

 http://hensa40.cutegirl.jp/archives/1032 :: fork and pipe

https://qiita.com/MoriokaReimen/items/5c4256ef620499a88bb3 プロセス間通信総括
 https://qiita.com/argama147/items/2f636a2f4fd76f6ce130 
http://linuxc.info/library/library1.html ライブラリ

http://www.mediapalace.co.jp/~skel/upload/contents/sound/Z1-smxhJtxuHRUAAAL0CaYAAAAC :: 動的ロードの実例 -ldlがでてくる

https://sleepy-yoshi.hatenablog.com/entry/20090510/p1 :: 動的リンクの実例

共有ライブラリパスの指定は,環境変数LD_LIBRARY_PATHで行う.

% LD_LIBRARY_PATH=./ ./main

自分でつくった共有ライブラリを置く場所が決まっていれば,

% export LD_LIBRARY_PATH=~/lib/

ただ,LD_LIBRARY_PATHの指定はあまりよろしくないらしい.

-----------------------------------------------------------------------------------------------

まず明確にしておかなけばならないのは、Copyトレイトを実装した型で行われる値のコピーと、Cloneトレイトを実装した型で行われる値のclone()は多くの場合は異なる操作だということです。

前者はメモリ上のバイト列を単純にコピーする操作で、Cのmemcpyに相当します。このような操作は一般的にはshallow copy(浅いコピー)と呼ばれます。

後者はその型に実装されたclone()メソッドを呼び出す操作です。どういうことをするかはclone()メソッドの実装に依存しますが、多くの場合はmemcpyよりも複雑なdeep copy(深いコピー)を行います。

https://qrunch.net/@daiju/entries/xBrYr8cgiGUrLdyl :: mpscの意味が詳しい
------------------------------------------
https://qiita.com/takuyanin/items/949201e3eb100d4384e1 :: curl cheat sheet
-------------------------------------------------------------------
https://www.yokoweb.net/2018/05/12/ubuntu-18_04-apache2-php72/ basic
https://www.yokoweb.net/2020/08/14/ubuntu-20_04-apache-php/ better
https://qiita.com/witchcraze/items/c5573790fba73f973077 :: mysql install
https://ryotatake.hatenablog.com/entry/2019/11/12/access_denied_for_user_rootlocalhost :: mysql login (method 1 , I selected)
------------------------------------------------

https://maywork.net/computer/ubuntu-on-mono-csharp-compile/ :: mono

https://rdr.utopiat.net/files/mono.html :: MONO PRODEL

-------------------------------------------------------------------
https://techacademy.jp/magazine/15268 :: swift on linux :: .build内にある
-----------------------------------------------------------------
https://teratail.com/questions/173364 :: php-mysql のインスト仕方

    2020年10月16日金曜日

    Go by example // nvm node npm

    https://www.spinute.org/go-by-example/

    @Hello World

    @Values

    @Variables

    @Constants

    @For

    @If/Else

    @Switch

    @Arrays

    @Slices

    @Maps

    @Range

    @Functions

    @Multiple Return Values

    @Variadic Functions

    @Closures

    @Recursion

    @Pointers

    @Structs

    @Methods

    @Interfaces

    @Errors

    @Goroutines@

    @Channels@

    @Channel Buffering@

    @Channel Synchronization@

    @Channel Directions@

    @Select@

    @Timeouts@

    @Non-Blocking Channel Operations@

    @Closing Channels@

    @Range over Channels@

    @Timers@

    @Tickers@

    @Worker Pools@

    @WaitGroups@

    @Rate Limiting@ーーパッケージもある

    @Atomic Counters@

    @Mutexes@

    @Stateful Goroutines@

    @Sorting

    @Sorting by Functions

    @Panic

    @Defer

    @Collection Functions

    (generics not yet)

    @String Functions

    @String Formatting

    @Regular Expressions@

    @JSON

    @XML

    @Time

    @Epoch

    @Time Formatting / Parsing

    @Random Numbers

    @Number Parsing

    @URL Parsing

    @SHA1 Hashes

    @Base64 Encoding

    @Reading Files@

    @Writing Files@

    @Line Filters

    @File Paths

    @Directories

    @Temporary Files and Directories

    @Testing

    @Command-Line Arguments

    @Command-Line Flags

    @Command-Line Subcommands

    @Environment Variables--unix

    @HTTP Clients

    @HTTP Servers

    @Exit

    @Spawning Processes--unix

    @Exec'ing Processes--unix

    @Signals--unix

    Context---out of date:パッケージになった

    https://qiita.com/ffggss/items/94f1c4c5d311db2ec71a :: nvm,node,npm

    2020年10月15日木曜日

    シェクスピア全作品

     37作といわれる 最後の第38作は合作といわれる 読み残し12作品

    史劇 10 items

    悲劇 11 item

    喜劇 17items

    1. 間違いの喜劇(Comedy of Errors、1592年 - 1594年)@
    2. じゃじゃ馬ならし(Taming of the Shrew、1593年 - 1594年)
    3. ヴェローナの二紳士(The Two Gentlemen of Verona、1594年)@
    4. 恋の骨折り損( Love's Labour's Lost、1594年 - 1595年)
    5. 夏の夜の夢(A Midsummer Night's Dream、1595年 - 96年)
    6. ヴェニスの商人(The Merchant of Venice、1596年 - 1597年)
    7. ウィンザーの陽気な女房たち(The Merry Wives of Windsor、1597年)@
    8. 空騒ぎ(Much Ado About Nothing、1598年 - 1599年)
    9. お気に召すまま(As You Like It、1599年)@
    10. 十二夜(Twelfth Night, or What You Will、1601年 - 1602年)
    11. 終わりよければ全てよし(All's Well That Ends Well、1602年 - 1603年)P@
    12. 尺には尺を(Measure for Measure、1604年)P@
    13. ペリクリーズ(Pericles, Prince of Tyre、1607年 - 1608年)R
    14. シンベリン(Cymbeline、1609 - 10年)R@
    15. 冬物語(The Winter's Tale、1610年 - 1611年)R@
    16. テンペスト(The Tempest、1611年)R
    17. 二人のいとこの貴公子(The Two Noble Kinsmen、1613年)R@ 合作とされる

    Rはロマンス劇、Pは問題劇ともカテゴライズされる作品である。