Compare commits

...

10 Commits

Author SHA1 Message Date
b34178a86f added library download 2025-11-04 22:29:41 +09:00
6d8ecb3368 added memo 2025-08-23 01:07:13 +09:00
48e1760230 Added golang note 2025-07-10 20:30:27 +09:00
Nik Afiq
aa6568149b edited git memo 2025-07-02 11:11:40 +09:00
b793728a38 Added note 2025-07-01 23:54:05 +09:00
Nik Afiq
dfb6337190 added pipenv 2025-05-12 14:22:03 +09:00
Nik Afiq
d46465ab47 added nodenv 2025-03-24 09:17:35 +09:00
Nik Afiq
d907334da6 gitignore update 2025-03-14 16:37:48 +09:00
Nik Afiq
0728cc190d added git hook and systemd guide 2025-03-14 16:37:13 +09:00
5ec72108ad added some note 2025-03-13 12:40:25 +09:00
12 changed files with 367 additions and 1 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.DS_Store

3
memo/ffmpeg-command.md Normal file
View 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
View 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
View 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
View 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
View 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
View 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-naghttps://github.com/stelligent/cfn_nag
cdk-nag

View File

@ -31,7 +31,10 @@ cd <repository>
2. Add remote repository 2. Add remote repository
```bash ```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 3. Push code as main

43
memo/spanner-setting.md Normal file
View 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

View File

@ -30,3 +30,6 @@ Start the service:
sudo systemctl start page_host 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
View 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]
```

View File

@ -1,5 +1,25 @@
# Venv
```bash ```bash
python -m venv <env-name> python -m venv <env-name>
source <env-name>/bin/activate source <env-name>/bin/activate
deactivate 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
``` ```