2022年12月7日星期三
shell different between return and exit
2022年11月17日星期四
check file changed or not by md5 hash code
windows powershell command:
PS C:\Users\test> certutil -hashfile destfile.zip md5
MD5 hash (対象 destfile.zip):
f6cb78afe66b417cd3f79df8d1c86444
CertUtil: -hashfile コマンドは正常に完了しました。
linux command:
> md5sum destfile.zip
f6cb78afe66b417cd3f79df8d1c86444 destfile.zip
2022年11月11日星期五
git clone -b branchname url
git clone -b branchname https://domainname/group/project.git
git clone -b branchname https://userid:token@domainname/group/project.git
2022年11月8日星期二
linux shell setfacl /getfacl
$ setfacl --help
2022年11月1日星期二
shell if and or
&&
(AND) :if [ condition1 ] && [ condition2 ]; then
cp -rf $src/* $dest/
echo " directory $dest is not found, or no files under $src"
||
(OR) :if [ condition1 ] || [ condition2 ]
; then
2022年10月27日星期四
2022年10月19日星期三
linux uname distribution check
# uname -a
Linux 6cfa069b60a5 4.14.291-218.527.amzn2.x86_64 #1 SMP Fri Aug 26 09:54:31 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
# cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04.2 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.2 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
2022年10月14日星期五
shell sed insert. append replace
追加: i (insert), a(append) 注意:'中の処理は一つの処理とする'
sed -e '/pattern/ a内容' #pattern行の後ろに、aで内容をappend
sed -e '/pattern/ i内容' #pattern行の先頭に、iで内容をinsert
範囲限定の削除
sed -e '/fromPattern/,/toPattern/ d' #fromPattern行(含む)~toPattern行(含む)まで、dで削除する
範囲限定の置換
sed -e '/fromPattern/,/toPattern/ s/pattern/replacement/' #fromPattern行(含む)~toPattern行(含む)まで、sでpatternにmatchする文字列をreplacementで置換する。
2022年10月4日星期二
python3 regex .* vs .*? : match more or less, match, search, findall, sub
1. .* vs .*? :
r1=re.pattern(pattern1, input1)
r2=re.pattern(pattern2, input1)
>>> m = re.search('(?<=abc)def', 'abcdef') #?<=lookbehind match >>> m.group(0) 'def'
m = re.search(r'(?<=-)\w+', 'spam-egg') # must has - before \w+ >>> m.group(0) 'egg'
2022年9月28日星期三
Oracle Alter user account lock/unlock
- LOCK TEST_USER1
ALTER USER TEST_USER1 ACCOUNT LOCK;
ALTER USER TEST_USER1 ACCOUNT UNLOCK;
2022年9月21日星期三
kali linux mount shared folder to windows folder
1. windows
mkdir c:\my-shared
echo "test" > test.txt
2. add shared folder in virtual Manager like
shared foldername: shared
windows path: c:\my-shared
access auth: full
3. goto linux vm
$ mkdir ~/wk-shared
$ sudo mount -t vboxsf shared ~/wk-shared
$ ll ~/wk-shared
total 1
-rwxrwxrwx 1 root root 63 Sep 21 14:24 test.txt
kali linux mysql init login
service mysql start
sudo mysql -u root
MariaDB [(none)]> show databases
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.001 sec)
MariaDB [(none)]> select Host, User, Password from mysql.user;
+-----------+-------------+----------+
| Host | User | Password |
+-----------+-------------+----------+
| localhost | mariadb.sys | |
| localhost | root | invalid |
| localhost | mysql | invalid |
+-----------+-------------+----------+
3 rows in set (0.001 sec)
$ mysql -u root -p
mysql -u root mysql
FLUSH
PRIVILEGES
;
ALTER
USER
'root'
@
'localhost'
IDENTIFIED
BY
'NEW_PASSWORD'
;
FLUSH
PRIVILEGES
;
quit
sudo
kill
`
sudo
cat
/var/run/mysqld/mysqld
.pid`
2022年9月16日星期五
postgresql db info
login to gitlab-Postgre-db:
gitlab-rails dbconsole
gitlab-psql -d gitlabhq_production
postgres=# \c dvdrental
You are now connected to database "dvdrental" as user "postgres".
\l = SELECT datname FROM pg_database;
gitlabhq_production=> \d
#list all objects of the db. include table, sequence, and so on.
\d = select * from
gitlabhq_production=> \dt
(\dt + :#show size)
(\dt tablename :#show table columns)
#list all tables of the db
schemaname != 'information_schema';
--'テーブル名'に存在する列一覧を取得
select * from information_schema.columns
where table_name='テーブル名' order by ordinal_position;
Linux reset gitlab root init_password
# ls -l /etc/gitlab/initial_root_password
gitlab-rake "gitlab:password:reset[root]"
Linux gitlab info
$ gitlab-ctl status
# status of services
/# gitlab-rake gitlab:env:info
System information
System:
Proxy: no
Current User: git
Using RVM: no
Ruby Version: 2.7.5p203
Gem Version: 3.1.6
Bundler Version:2.3.15
Rake Version: 13.0.6
Redis Version: 6.2.7
Sidekiq Version:6.4.0
Go Version: unknown
GitLab information
Version: 15.3.3-ee
Revision: 1615d086ad8
Directory: /opt/gitlab/embedded/service/gitlab-rails
DB Adapter: PostgreSQL
DB Version: 13.6
URL: http://gitlab.wangxg.com
HTTP Clone URL: http://gitlab.wangxg.com/some-group/some-project.git
SSH Clone URL: git@gitlab.wangxg.com:some-group/some-project.git
Elasticsearch: no
Geo: no
Using LDAP: no
Using Omniauth: yes
Omniauth Providers:
GitLab Shell
Version: 14.10.0
Repository storage paths:
- default: /var/opt/gitlab/git-data/repositories
GitLab Shell path: /opt/gitlab/embedded/service/gitlab-shell
root@gitlab:/#
Linux swap check create and using.
1. check current swap size
$ free -m
total used free shared buff/cache available
Mem: 4931 699 3260 7 971 3992
Swap: 1023 0 1023
2. create swap
3. auto mount swap on os start
2022年9月12日星期一
linux grep output group capture
grep can't output all group captures after one grep action.
so. each grep a time.
ex.
input_string= "Caused by: java.io.FileNotFoundException: /tmp/storage/imart/public/storage/default/im_workflow/data/default/transaction/202107/21/16/ma_8g2mm9ovekgierj/result/ep_8g2mo7z76kgrmrj/flow.xml (No such file or directory)"
#I want to get
#[1]=/tmp/storage/imart/public/storage/default/im_workflow/data/default/transaction
#[2]=202107/21/16/
#[3]=ma_8g2mm9ovekgierj
#[4]=ep_8g2mo7z76kgrmrj
#cmd:
a1=$(echo $input_string | grep -ioE "/tmp/.+/transaction")
echo $a1
:/tmp/storage/imart/public/storage/default/im_workflow/data/default/transaction
a2=$(echo $input_string | grep -ioE "[0-9]{6}/[0-9]{2}/[0-9]{2}")
echo $a2
=> 202107/21/16
a3=$(echo $input_string | grep -ioE "[0-9]{6}/[0-9]{2}/[0-9]{2}/\w+" | grep -ioE "\w+$")
echo $a3
:ma_8g2mm9ovekgierj
a4=$(echo $input_string | grep -ioE "\w+/flow" | grep -ioE "^\w+")
echo $a4
:ep_8g2mo7z76kgrmrj
$ echo $input_string | grep -ioE "/tmp/.+/transaction"
2022年9月9日星期五
Linux ifconfig
#change network info
#first reset a IP
ifconfig eth0 192.168.1.123
#second reset netmask and broadcast for IP.
ifconfig eth0 192.168.1.123 netmask 255.255.0.0 broadcast 192.168.1.255
#before change MAC, stop the network-adapter ethX.
ifconfig eth0 down
#third reset ether MAC for eth0
ifconfig eth0 hw ether 00:11:22:33:44:55
ifconfig eth0 up #restart eth0
#request DHCP server for new IP
dhclient eth0
#linux dns conf
more /etc/resolv.conf
linux cmd sed example
1. sed s/mysql/MySQL/g test.conf >test2.conf
# replace all mysql to MySQL
2. sed s/mysql/MySQL/ test.conf >test2.conf
# replace first mysql to MySQL
3. sed s/mysql/MySQL/2 test.conf >test2.conf
# replace the second found mysql only to MySQL.
kali linux japanese keyboard layout setting
1. open setting/setting manager/keyboard.
2. tab to layout
3. add japanese and delete english
4. confirm keyboard layout = Generic 105-key PC (intl.)
5. close window. setting completed.
2022年9月7日星期三
AI の初級考え方1:お菓子を買う
背景:
こどもが300円までのお菓子を買うこと
条件:
質問:
計算式:
2022年8月31日星期三
intra-mart manul links
2022年8月22日星期一
git log --name-status
commit 482c51ab15
Author: wangxg
Date: Mon Aug 22 13:15:09 2022 +0900
A setting/database/ddl/BD0159.sql
A setting/database/ddl/BD0160.sql
A setting/database/ddl/BD0161.sql
A setting/database/ddl/BD0162.sql
(END)
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 < imagename.tar #create image:latest
# docker export container to tar file
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
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
現象:
... + .\test.ps1
+ ~~~~~~~~~~
+ CategoryInfo : セキュリティ エラー: (: ) []、PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
実行ポリシー | 署名あり | 署名なし/ローカル | 署名なし/非ローカル | 説明 |
---|---|---|---|---|
Restricted | x | x | x | すべてのスクリプトの実行を制限 (初期設定) |
AllSigned | o | x | x | 署名のあるスクリプトのみ実行可能 |
RemoteSigned | o | o | x | ローカル上のスクリプトと非ローカル上の署名のあるスクリプトのみ実行可能 |
Unrestricted | o | o | △ | すべてのスクリプトが実行可能だが非ローカル上のスクリプトは実行時に許可が必要 |
Bypass | o | o | o | すべてのスクリプトが実行可能 |