2022年7月20日星期三

docker images save and load , export and import

# docker save image to tar file      
docker save image:version -o imagename.tar 

# docker load image from tar file      
docker load < imagename.tar    #create image:latest

# docker export container to tar file       
docker export sample-container > sample-container.tar

# docker import  from tar file to image   
docker import sample-container.tar > sample-image:latest

2022年7月15日星期五

javascript match and exec

 3Q4:  https://step-learn.com/article/javascript/124-diff-match-exec.html

JavaScript では、正規表現にマッチした文字列を取得するメソッドとして、 match() メソッドと exec() メソッドがあります。

オブジェクト、書式の違い

まず、「どのオブジェクトのメソッドか」という違いがあります。 match() メソッドは String オブジェクトのメソッドで、 exec() メソッドは RedExp オブジェクトのメソッドです。

ですから、書式はそれぞれ次のようになります。


// match()
文字列.match(正規表現)

// exec()
正規表現.exec(文字列)

match() メソッド

// 文字列
var str = "cat map cut bat cute cap";

// 正規表現
var ex = /c.t/g;

var arr = str.match(ex);

for (var i = 0, len = arr.length; i < len; i++){
    console.log(arr[i]);
}

// 実行結果
cat
cut
cut


exec() メソッド

// 文字列
var str = "〒 135-0064\n〒 105-7444";

// 正規表現
var ex = /(\d{3})-(\d{4})/g;

var arr = [];

while((arr = ex.exec(str)) != null){
    console.log(arr);
    console.log('マッチ文字列:', arr[0]);
    console.log('lastIndex:', ex.lastIndex);
}

// 実行結果

Array [ "135-0064", "135", "0064" ]
マッチ文字列: 135-0064
lastIndex: 10

Array [ "105-7444", "105", "7444" ]
マッチ文字列: 105-7444
lastIndex: 21




chmod -R 760 destfolder

 ex. chmod -R 776 /var/local/resin/imart

2022年7月12日星期二

windows bat find key from string

set str=abcdefg

set key=abc

echo "%str%" | find "%key%" >NUL
if not ERRORLEVEL 1 goto OK_FOUND
:NOT_FOUND echo "NOT FOUND %key% in %str%. " pause exit /b :OK_FOUND


echo "GOOD! FOUND %key% in %str%. "
pause

2022年7月11日星期一

powershell PSSecurityException, FullyQualifiedErrorId : UnauthorizedAccess

REF:https://qiita.com/Targityen/items/3d2e0b5b0b7b04963750

現象:

c:\tmp.\test.ps1
... + .\test.ps1
+ ~~~~~~~~~~
+ CategoryInfo : セキュリティ エラー: (: ) []、PSSecurityException 
+ FullyQualifiedErrorId : UnauthorizedAccess 

原因:
PS C:\tmp\> get-executionPolicy
Restricted

実行ポリシー署名あり署名なし/ローカル署名なし/非ローカル説明
Restrictedxxxすべてのスクリプトの実行を制限 (初期設定)
AllSignedoxx署名のあるスクリプトのみ実行可能
RemoteSignedooxローカル上のスクリプトと非ローカル上の署名のあるスクリプトのみ実行可能
Unrestrictedooすべてのスクリプトが実行可能だが非ローカル上のスクリプトは実行時に許可が必要
Bypassoooすべてのスクリプトが実行可能

対策:
1. ps1ファイルに個別指定
c:\tmp>PowerShell -ExecutionPolicy RemoteSigned .\test.ps1


2. ps1ファイルに共通指定
c:\tmp>PowerShell Set-ExecutionPolicy RemoteSigned

linux alias

1. alias lla='ls -la' 

[root@ip-xxx ~]$ lla

total 112
drwx------ 18 root  root   4096 Jul  8 11:20 .
drwxr-xr-x  5 root  root        47 May 19 09:47 ..

2. unalias lla # delete alias lla


3.  function findjssp () { find $1 -type f  -name "*.js" -o -name "*.html" | xargs grep -ine "$2" 2>/dev/null; }

     $  findjssp  "imart/WEB-INF/jssp/src/"  "test" 

4. unset findjssp  # delete function findjssp 


2022年7月8日星期五

git branch upstream

git branch --set-upstream-to remotename/branchname

git branch -u remotename  # same branch name


# delete upstream between remote andd local

git branch -d -r origin/<remote branch name>

2022年7月7日星期四

git commit comment 整理

======git  history: ======

commit: comment1 

commit: comment2 

commit: comment3 

commit: comment4 

commit: comment5 

commit: comment6 

commit: comment7 

commit: comment8 

commit: comment9 

commit: comment10 

commit: comment11 

======git  history: ======

目標: 

comment1 ~comment5:  commit => project1

comment6 ~comment10: commit => project2

方法:

git rebase -i HEAD~10

--edit commit: comment1 

--edit commit: comment2 

--edit commit: comment3 

--edit commit: comment4 

--edit commit: comment5 

--edit commit: comment6 

--edit commit: comment7 

--edit commit: comment8 

--edit commit: comment9 

--edit commit: comment10 

git commit --amend 

commit: comment1  -> project1: comment1  

git rebase --continue 

git commit --amend 

commit: comment2 -> project1: comment2 

git rebase --continue 

git commit --amend 

... 

git rebase --continue 

git commit --amend 

commit: comment10 -> project2: comment10

Successfully rebased and updated refs/heads/$branchname


=================

pick -そのまま保留

edit -コメント編集へ

squash - 前のcommitにマージする,コメント変更可

fixup - 前のcommitにマージする,コメントも前のコメントに従う

drop -該当commitを削除