Skip to content

Instantly share code, notes, and snippets.

View mamedshahmaliyev's full-sized avatar

Mamed Shahmaliyev mamedshahmaliyev

View GitHub Profile
@mamedshahmaliyev
mamedshahmaliyev / chroot.sh
Last active October 29, 2019 19:49
How to create chroot user
useradd sftp_user
passwd sftp_user
#################################################################################################################
# VERY IMPORTANT: all the elements in /path/to/chroot_folder must be owned by root with at most 755 permissions #
#################################################################################################################
echo '''
Match User sftp_user
X11Forwarding no
AllowTcpForwarding no
@mamedshahmaliyev
mamedshahmaliyev / python_tips.py
Last active December 8, 2020 10:13
diffrent ad-hoc tasks in python
# pickle save and load
import pickle
pickle.dump(obj, open(file, 'wb'))
obj = pickle.load(open(file, 'rb'))
# datetime tasks
import datetime
datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
# get execution time
@mamedshahmaliyev
mamedshahmaliyev / centos7_tips.sh
Created November 19, 2019 07:14
CentOS 7 tips
# install vmware tools
yum install -y open-vm-tools
@mamedshahmaliyev
mamedshahmaliyev / extend_lvm_linux.sh
Last active June 8, 2020 07:03
extend linux disk volume size in virtual machina
reboot # if no free sector error occurs
fdisk -l
fdisk /dev/sda
# type n -> p -> 3
# type t -> 3 -> 8e
# type w
reboot
pvcreate /dev/sda3
vgdisplay
vg_name='centos'
@mamedshahmaliyev
mamedshahmaliyev / flutter_overlay.dart
Created May 7, 2020 13:32
flutter overlay with opacity
Stack(
children: <Widget>[
Column(
children: <Widget>[
Container(),
Container(),
],
),
_overlay(True)
],
@mamedshahmaliyev
mamedshahmaliyev / windows_hiberante.bat
Created May 28, 2020 06:18
windows hibernation commands
# enable hibernate
Powercfg /h on
# disable hibernate
Powercfg /h off
# specifiy hibernation file size as percentage of total RAM (between 50 and 100)
Powercfg /h /size nn
# view hibernation file size
@mamedshahmaliyev
mamedshahmaliyev / android_debug_wifi.bat
Last active October 16, 2020 06:19
android usb debug without cable over wireless
adb devices
adb -s 15a5e8fc(deviceId) tcpip 5555
adb connect 192.168.0.100:5555
adb devices
adb -s LGLS992a4b7c95d tcpip 5555
adb connect 192.168.0.157:5555
su - postgres
psql
# change user password
ALTER USER user_name WITH PASSWORD 'new_password';
\l #list databases
\c db_name # use database
\dt # list tables
@mamedshahmaliyev
mamedshahmaliyev / HtmlTableFillPopulateVanillaJS.js
Created October 26, 2020 07:04
Populate or fill HTML table with random data in vanilla JavaScript
var table_selector = '#table_id';
var i = 0;
var content_length = 15;
document.querySelectorAll(table_selector + ' tr').forEach((row, i) => {
row.querySelectorAll('td').forEach((td, j) => {
td.innerHTML = Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, content_length);
});
});
# random between 10 and 5
select FLOOR(RAND()*(10-5+1)+5)