Compare commits
10 Commits
942ec2a062
...
b34178a86f
| Author | SHA1 | Date | |
|---|---|---|---|
| b34178a86f | |||
| 6d8ecb3368 | |||
| 48e1760230 | |||
|
|
aa6568149b | ||
| b793728a38 | |||
|
|
dfb6337190 | ||
|
|
d46465ab47 | ||
|
|
d907334da6 | ||
|
|
0728cc190d | ||
| 5ec72108ad |
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
.DS_Store
|
||||
3
memo/ffmpeg-command.md
Normal file
3
memo/ffmpeg-command.md
Normal file
@ -0,0 +1,3 @@
|
||||
```bash
|
||||
ffmpeg -ss 00:01:00 -to 00:02:30 -i input.mp4 -c copy output.mp4
|
||||
```
|
||||
33
memo/git-hook.md
Normal file
33
memo/git-hook.md
Normal file
@ -0,0 +1,33 @@
|
||||
# Automate update via Git Hook
|
||||
|
||||
1. Navigate to the bare repository:
|
||||
```bash
|
||||
cd ~/git/asobi.git/hooks
|
||||
```
|
||||
|
||||
2. Create `post-receive` Hook:
|
||||
```bash
|
||||
nano post-receive
|
||||
```
|
||||
|
||||
3. Add script you want to run:
|
||||
```bash
|
||||
#!/bin/bash
|
||||
|
||||
# Deployment directory
|
||||
DEPLOY_DIR="/home/nik/repo/asobi"
|
||||
|
||||
# Navigate to the deployment directory
|
||||
cd $DEPLOY_DIR
|
||||
|
||||
# Pull the latest changes
|
||||
git pull origin main
|
||||
|
||||
# Restart the service
|
||||
sudo systemctl restart asobi-web.service
|
||||
```
|
||||
|
||||
4. Make the hook executable:
|
||||
```
|
||||
chmod +x post-receive
|
||||
```
|
||||
36
memo/golang.md
Normal file
36
memo/golang.md
Normal file
@ -0,0 +1,36 @@
|
||||
# Golang basics
|
||||
## Initialize project
|
||||
```bash
|
||||
$ go mod init <project-name> #usually folder name
|
||||
```
|
||||
|
||||
## Insert package
|
||||
```go
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
// your code here
|
||||
}
|
||||
```
|
||||
|
||||
## Running code
|
||||
```bash
|
||||
$ go run main.go
|
||||
```
|
||||
|
||||
## Pointer in Go
|
||||
```go
|
||||
var userName string
|
||||
var userTickets int
|
||||
|
||||
fmt.Scan(&userName)
|
||||
// &userName point to the memory of the var
|
||||
```
|
||||
|
||||
## Import package
|
||||
```bash
|
||||
go get github.com/gin-gonic/gin
|
||||
```
|
||||
|
||||
45
memo/make-systemd.md
Normal file
45
memo/make-systemd.md
Normal file
@ -0,0 +1,45 @@
|
||||
1. Open new service file:
|
||||
```
|
||||
sudo nano /etc/systemd/system/<name>.service
|
||||
```
|
||||
|
||||
2. Content
|
||||
```
|
||||
[Unit]
|
||||
Description=Page Host Service
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
User=your_username
|
||||
WorkingDirectory=/home/your_username/repo/asobi
|
||||
Environment=PYENV_ROOT=/home/your_username/.pyenv
|
||||
ExecStart=/bin/bash -c "source $PYENV_ROOT/bin/pyenv && pyenv activate pyenv && python page_host.py"
|
||||
Restart=always
|
||||
RestartSec=5
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
```
|
||||
|
||||
3. Reload systemd, enable service:
|
||||
```
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable <name>.service
|
||||
sudo systemctl start <name>.service
|
||||
```
|
||||
|
||||
4. Check status:
|
||||
```
|
||||
sudo systemctl status <name>.service
|
||||
journalctl -u <name>.service
|
||||
```
|
||||
|
||||
5. Test reboot:
|
||||
```
|
||||
sudo reboot
|
||||
```
|
||||
|
||||
Check status
|
||||
```
|
||||
sudo systemctl status page_host.service
|
||||
```
|
||||
12
memo/mysql-al2.md
Normal file
12
memo/mysql-al2.md
Normal file
@ -0,0 +1,12 @@
|
||||
sudo yum update -y
|
||||
sudo amazon-linux-extras install epel -y
|
||||
|
||||
sudo wget https://dev.mysql.com/get/mysql80-community-release-el7-5.noarch.rpm
|
||||
sudo rpm -ivh mysql80-community-release-el7-5.noarch.rpm
|
||||
|
||||
sudo yum install mysql-server -y
|
||||
|
||||
/etc/yum.repos.d/*mysql*
|
||||
sed -i 's/gpgcheck=1/gpgcheck=0/g' filename
|
||||
|
||||
sudo grep 'temporary password' /var/log/mysqld.log
|
||||
159
memo/nodenv.md
Normal file
159
memo/nodenv.md
Normal file
@ -0,0 +1,159 @@
|
||||
AWS CDK ドキュメント : https://docs.aws.amazon.com/cdk/api/v2/docs/aws-construct-library.html
|
||||
npm version : 10.2.3
|
||||
nodenv version : 18.19.0
|
||||
|
||||
#nodenv導入
|
||||
github:https://github.com/nodenv/nodenv
|
||||
|
||||
1. nodenvをクローンする
|
||||
|
||||
```
|
||||
git clone https://github.com/nodenv/nodenv.git ~/.nodenv
|
||||
```
|
||||
|
||||
インストール時間を短縮するためダイナミックバッシュでコンパイルする(失敗してもインストールできる)
|
||||
|
||||
```
|
||||
cd ~/.nodenv && src/configure && make -C src
|
||||
```
|
||||
|
||||
2. nodenvを`PATH`に追加する
|
||||
|
||||
```
|
||||
echo 'export PATH="$HOME/.nodenv/bin:$PATH"' >> ~/.bashrc
|
||||
```
|
||||
|
||||
現在のシェルにbash適用する
|
||||
|
||||
```
|
||||
source ~/.bashrc
|
||||
```
|
||||
|
||||
3. nodenvをshellにセットアップする
|
||||
|
||||
```
|
||||
~/.nodenv/bin/nodenv init
|
||||
```
|
||||
|
||||
表示されたコマンドで実行する
|
||||
**プラットフォームによってコマンド違うので下記のコマンドを実行しない**
|
||||
|
||||
```
|
||||
echo 'eval "$(nodenv init - bash)"' >> ~/.bashrc
|
||||
source ~/.bashrc
|
||||
```
|
||||
|
||||
4. nodenvインストール確認
|
||||
|
||||
```
|
||||
curl -fsSL https://github.com/nodenv/nodenv-installer/raw/main/bin/nodenv-doctor | bash
|
||||
```
|
||||
|
||||
下記の画面表示されたら完了
|
||||
|
||||
```
|
||||
Checking for `nodenv' in PATH: /home/nik/.nodenv/bin/nodenv
|
||||
Checking for nodenv shims in PATH: OK
|
||||
Checking `nodenv install' support: not found
|
||||
Unless you plan to add Node versions manually, you should install node-build.
|
||||
Please refer to https://github.com/nodenv/node-build#installation
|
||||
|
||||
Counting installed Node versions: none
|
||||
There aren't any Node versions installed under `/home/nik/.nodenv/versions'.
|
||||
You can install Node versions like so: nodenv install <version>
|
||||
Auditing installed plugins: OK
|
||||
```
|
||||
|
||||
##node-buildインストール(オプション)
|
||||
*nodenv install使用するに最適化されるプラグイン*
|
||||
github: https://github.com/nodenv/node-build
|
||||
|
||||
```
|
||||
mkdir -p "$(nodenv root)"/plugins
|
||||
git clone https://github.com/nodenv/node-build.git "$(nodenv root)"/plugins/node-build
|
||||
```
|
||||
|
||||
##node version 18.19.0インストール
|
||||
|
||||
```
|
||||
nodenv install 18.19.0
|
||||
nodenv global 18.19.0
|
||||
```
|
||||
|
||||
nodeバージョン確認
|
||||
|
||||
```
|
||||
node --version
|
||||
npm --version
|
||||
npx --version
|
||||
```
|
||||
|
||||
# AWSプロファイル設定
|
||||
|
||||
```
|
||||
aws configure sso --profile <プロファイル名>
|
||||
```
|
||||
コマンドからユーザー情報が保存できる
|
||||
|
||||
```
|
||||
SSO session name (Recommended): its-pharma-core-dev
|
||||
SSO start URL [None]: https://d-95675820f8.awsapps.com/start/#
|
||||
SSO region [None]: ap-northeast-1
|
||||
SSO registration scopes [sso:account:access]:
|
||||
CLI default client Region [None]: ap-northeast-1
|
||||
CLI default output format [None]: json
|
||||
```
|
||||
|
||||
|
||||
### AWSアカウント切り替え
|
||||
|
||||
```
|
||||
export AWS_PROFILE=medaca
|
||||
```
|
||||
|
||||
### アカウントSSO(シングルサインオン)再認証
|
||||
|
||||
```
|
||||
aws sso login --profile <プロファイル名>
|
||||
```
|
||||
|
||||
### Alias設定 (WSLでコマンド省略):
|
||||
homeダイレクトリー変更
|
||||
|
||||
```
|
||||
cd ~
|
||||
```
|
||||
|
||||
.bashrcにaliasにしたいコマンド書く
|
||||
|
||||
```
|
||||
vi .bashrc
|
||||
```
|
||||
|
||||
例:
|
||||
|
||||
```
|
||||
alias medaca='export AWS_PROFILE=medaca'
|
||||
```
|
||||
この場合は`export AWS_PROFILE=medaca`コマンドが`medaca`に省略できる
|
||||
|
||||
最後にsourceで現在のshellに読み込み
|
||||
|
||||
```
|
||||
source ~/.bashrc
|
||||
```
|
||||
|
||||
## 便利なサイト
|
||||
|
||||
AWSワークショップ:https://cdkworkshop.com/20-typescript/20-create-project/100-cdk-init.html
|
||||
AWSサンプルCDKプロジェクト:https://github.com/aws-samples/aws-cdk-examples/tree/main
|
||||
AWS CDKベストプラクティス:https://docs.aws.amazon.com/cdk/v2/guide/best-practices.html
|
||||
https://docs.aws.amazon.com/pdfs/prescriptive-guidance/latest/best-practices-cdk-typescript-iac/best-practices-cdk-typescript-iac.pdf#introduction
|
||||
|
||||
### 命名規則:
|
||||
camelCase:変数、関数
|
||||
PascalCase:クラス、インターフェイス
|
||||
|
||||
## 脆弱性ツール
|
||||
cfn-nag:https://github.com/stelligent/cfn_nag
|
||||
cdk-nag
|
||||
@ -31,7 +31,10 @@ cd <repository>
|
||||
|
||||
2. Add remote repository
|
||||
```bash
|
||||
git remote add origin <server_credential>/~/<directory_name>/<project>.git
|
||||
git remote add origin <server_credential>:~/<directory_name>/<project>.git
|
||||
|
||||
# sample
|
||||
git remote add origin nik-deb:~/git/automation.git
|
||||
```
|
||||
|
||||
3. Push code as main
|
||||
|
||||
43
memo/spanner-setting.md
Normal file
43
memo/spanner-setting.md
Normal file
@ -0,0 +1,43 @@
|
||||
## Install gcloud cli
|
||||
https://cloud.google.com/sdk/docs/install
|
||||
|
||||
## Run spanner docker
|
||||
https://cloud.google.com/spanner/docs/emulator#start-emulator-gcloud
|
||||
|
||||
### Set gcloud cli to point to local
|
||||
```
|
||||
export SPANNER_EMULATOR_HOST=localhost:9010
|
||||
```
|
||||
|
||||
### Run spanner code on terminal
|
||||
|
||||
```
|
||||
# Create instances
|
||||
gcloud spanner instances create testinstance \
|
||||
--config=emulator-config \
|
||||
--description="Test Instance" \
|
||||
--nodes=1
|
||||
|
||||
# Create database
|
||||
gcloud spanner databases create testdb --instance=testinstance
|
||||
|
||||
# Create table
|
||||
gcloud spanner databases ddl update testdb --instance=testinstance \
|
||||
--ddl="CREATE TABLE Singers (
|
||||
SingerId INT64 NOT NULL,
|
||||
FirstName STRING(1024),
|
||||
LastName STRING(1024),
|
||||
SingerInfo BYTES(MAX)
|
||||
) PRIMARY KEY (SingerId)"
|
||||
```
|
||||
|
||||
|
||||
### Connect to spanner through dbeaver
|
||||
|
||||
1. Install DBeaver CE (free) on Mac.
|
||||
2. Install the Spanner JDBC driver.
|
||||
3. Create a new connection → Google Cloud Spanner.
|
||||
• Project ID: test-project
|
||||
• Instance: testinstance
|
||||
• Database: testdb
|
||||
• set autoConfigEmulator to true
|
||||
@ -30,3 +30,6 @@ Start the service:
|
||||
sudo systemctl start page_host
|
||||
```
|
||||
|
||||
$ realpath /home/ec2-user/repo/aws-test-kadai3/venv/bin/python
|
||||
/usr/bin/python3.7
|
||||
[ec2-user@ip-172-31-14-7 aws-test-kadai3]$ sudo setcap 'cap_net_bind_service=+ep' /usr/bin/python3.7
|
||||
8
memo/ufw-memo.md
Normal file
8
memo/ufw-memo.md
Normal file
@ -0,0 +1,8 @@
|
||||
```bash
|
||||
sudo ufw allow from 192.168.70.0/24 to any port 33060
|
||||
```
|
||||
|
||||
```bash
|
||||
sudo ufw status numbered
|
||||
sudo ufw delete [number]
|
||||
```
|
||||
@ -1,5 +1,25 @@
|
||||
# Venv
|
||||
|
||||
```bash
|
||||
python -m venv <env-name>
|
||||
source <env-name>/bin/activate
|
||||
deactivate
|
||||
```
|
||||
|
||||
# Freeze requirement
|
||||
```bash
|
||||
pip freeze > requirements.txt
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
# Pipenv
|
||||
```bash
|
||||
pyenv install --list | grep 3.9
|
||||
pyenv install 3.9.12
|
||||
```
|
||||
|
||||
```bash
|
||||
pyenv global 3.12.4
|
||||
cd /path/to/your/project
|
||||
pyenv local 3.9.17
|
||||
```
|
||||
Loading…
x
Reference in New Issue
Block a user