Skip to content

Instantly share code, notes, and snippets.

View IrisNg's full-sized avatar
🎯
Focusing

IRIS NG IrisNg

🎯
Focusing
View GitHub Profile
@IrisNg
IrisNg / ansible
Last active March 13, 2023 16:39
ansible
# setup
in server host machines, make sure openssh is installed, if machine is windows, install wsl, use '$wsl ~' to go into linux mode
use '$hostname -I' to find ip address of server machine
read ssh lepton note, to generate ssh private-public key pairs on control node, copy public key over to root of server host, generate ansible ssh key, same, copy over to server hosts
add ip address of server host to ansible inventory file
add ansible private key path to inventory file
try connecting via ansible, if successful, create and run playbook
# Connect to all servers
cd to ansible folder with inventory file
@IrisNg
IrisNg / ssh
Last active March 13, 2023 15:17
ssh
# SSH login
ssh username@ip-address
# SSH create user
adduser newusername
# Check ssh is installed
ssh localhost
# If success, should not say connection refused
@IrisNg
IrisNg / redis soft cap config
Created October 14, 2022 08:11
redis soft cap config
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit replica 0 0 0
client-output-buffer-limit pubsub 0 0 0
requirepass password
bind 0.0.0.0
@IrisNg
IrisNg / format all files prettier
Created February 10, 2022 08:35
format all files prettier
npm install -g prettier
prettier --write .
@IrisNg
IrisNg / name db index
Last active February 9, 2022 15:26
name db index
{tablename}_{columnname(s)}_{suffix}
where the suffix is one of the following:
pkey for a Primary Key constraint
key for a Unique constraint
excl for an Exclusion constraint
idx for any other kind of index
fkey for a Foreign key
check for a Check constraint
@IrisNg
IrisNg / docker volume local windows
Created January 28, 2022 08:55
docker volume local windows
\\wsl$\docker-desktop-data\version-pack-data\community\docker\volumes\
@IrisNg
IrisNg / bind mount
Created January 28, 2022 07:44
bind mount
version: '3.9'
services:
fsgcrmfrontend:
build: .
ports:
- '6000:6000'
restart: unless-stopped
volumes:
- type: bind
source: C:\resources
@IrisNg
IrisNg / mysql date and datetime
Created December 9, 2021 11:47
mysql date and datetime
MySQL -> DATE ' YYYY-MM-DD ' format
DATETIME -> ' YYYY-MM-DD hh:mm:ss ' format.
@IrisNg
IrisNg / sequelize set many to many associations
Created October 13, 2021 04:16
sequelize set many to many associations
const foundBrands = await db.Brand.findAll({ where: { status: STATUS.ACTIVE } });
//Insert user
const newUser = new db.User({
firstName,
lastName,
accessRightId,
});
await newUser.save();
@IrisNg
IrisNg / Sequelize update auto incremented key if seed to database outside sequelize
Last active November 26, 2021 07:19
Sequelize update auto incremented key if seed to database outside sequelize
await db.sequelize.query(`select setval('users_id_seq', (select max(id) from users), true);`) //Update to max 'id' + 1
//If uppercase in table name
await db.sequelize.query(`select setval('"dataAnalytics_id_seq"', (select max(id) from "dataAnalytics"), true);`)
const something = await db.sequelize.query(`select nextval('users_id_seq');`) //Check if next id is correct
console.log('****', something)