Skip to content

Instantly share code, notes, and snippets.

@stablexbt
Created February 12, 2026 12:43
Show Gist options
  • Select an option

  • Save stablexbt/71faaf58ae8d53487b62bb86d2a13a26 to your computer and use it in GitHub Desktop.

Select an option

Save stablexbt/71faaf58ae8d53487b62bb86d2a13a26 to your computer and use it in GitHub Desktop.
web dev essentials

Web

Postgre

  • Install
sudo apt update
sudo apt install postgresql postgresql-contrib
  • Create db
sudo -u postgres createdb db_name
  • Shell
sudo -u postgres psql -d db_name
  • User
# Create user
create user test with password 'password';

# Grant permission

GRANT ALL PRIVILEGES ON DATABASE db_name to user_name;z
  • Commands
# Tables list
\dt

# Users list
\du

# Show databases
\l

# Connect to db
\c db_name

Node

Get Node

wget https://nodejs.org/dist/v12.18.3/node-v12.18.3-linux-x64.tar.xz

Unpack

tar -xf node.tar.xz

Set path

nano ~/.bashrc
export PATH=$PATH:/root/node/bin

Processes

npm i -g nodemon
npm i -g pm2

Node permission error

// sh: 1: node: Permission denied

npm config set user 0
npm config set unsafe-perm true

SQL

Install

sudo apt update
sudo apt install mysql-server
sudo mysql_secure_installation

Fix Permissions

#login as sudo
sudo mysql

# give permission
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';

Import SQL

mysql -u username -ppassword database_name < demo.sql

Export SQL

mysqldump -u username -p database_name > demo.sql

Export Format Error

# Find
ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;
# in .sql file, and swap it with
ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;

Node

npm i mysql
var mysql = require('mysql');
const util = require('util');

var connection = mysql.createConnection({
    host: process.env.MYSQLHOST,
    user: process.env.MYSQLUSER,
    password: process.env.MYSQLPASSWORD,
    database: process.env.MYSQLDB
});

exports.query = util.promisify(connection.query).bind(connection);

// await query('select * from users')

Telegram

const noti_bot = require('noti_bot');
const notifyTelegram = noti_bot.telegram;
let TELEGRAM_BOT_TOKEN = "";
let TELEGRAM_TARGET_CHAT_ID = "";
notifyTelegram("hello bot", TELEGRAM_BOT_TOKEN, TELEGRAM_TARGET_CHAT_ID)

Get the list of updates for your BOT:

https://api.telegram.org/bot<YourBOTToken>/getUpdates

Sqlite

 PRAGMA journal_mode=WAL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment