This is usually for some quick testing.
-
python -i myscript.pyThen you can reference functions and variables in the script directly.
-
While you are already in a Python shell:
pip was broken after I installed pip3.8 and removed some other python links.
To fix pip:
python2 -m pip install --user --upgrade pip
python3 -m pip install --user --upgrade pip
| Set environment variables for proxies. | |
| Windows: | |
| set http_proxy=http://xxx.xxx.xxx.xxx:80 | |
| set https_proxy=http://xxx.xxx.xxx.xxx:80 | |
| Bash: | |
| http_proxy=http://xxx.xxx.xxx.xxx:80 | |
| https_proxy=http://xxx.xxx.xxx.xxx:80 |
Show all users in the mysql database:
MariaDB [(none)]> select * from mysql.user;
Delete a null user:
Install WordPress v5.3.2 and self-host it over https using Nginx.
MariaDB 10.4.13 (Reference How To Install MariaDB 10.4 on Ubuntu 18.04 / Ubuntu 16.04)
php 7.4.3 (Reference How To Install PHP 7.4 on Ubuntu 20.04/18.04/16.04)
php installs Apache2 too. Disable it and remove it if you want to use Nginx.
| Perl: | |
| print "$^V\n"; # 5.26.1 | |
| print "$]\n"; # 5.026001 | |
| Python: | |
| import sys | |
| print(sys.version) # 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)] | |
| print(sys.version_info) # sys.version_info(major=3, minor=7, micro=0, releaselevel='final', serial=0) | |
| import platform | |
| print(platform.python_version()) # 3.7.0 |
| const fs = require('fs'); | |
| function packFile(filename, outfilename, noOfBytesToPrefix = 100) { | |
| const filenameEncoded = new Buffer.from(filename, 'utf8'); | |
| const filenameLength = filenameEncoded.length; | |
| if (filenameLength > noOfBytesToPrefix) { | |
| throw new Error("file name after utf-8 encoding is too long"); | |
| } | |
| let prefixBuffer = new Buffer.allocUnsafe(noOfBytesToPrefix).fill(0); |
| const crypto = require('crypto'); | |
| const util = require('util'); | |
| const randomBytes = util.promisify(crypto.randomBytes); | |
| async function hashPassword(password) { | |
| // Hash a password for storing. | |
| try { | |
| const buf = await randomBytes(64); | |
| const salt = crypto.createHash('sha256').update(buf.toString('hex')).digest('hex'); |
| import hashlib, binascii, os | |
| def hash_password(password): | |
| """Hash a password for storing.""" | |
| salt = hashlib.sha256(os.urandom(60)).hexdigest().encode('ascii') | |
| pwdhash = hashlib.pbkdf2_hmac('sha512', password.encode('utf-8'), | |
| salt, 100000) | |
| pwdhash = binascii.hexlify(pwdhash) | |
| return (salt + pwdhash).decode('ascii') |
| def pack_file(file_name, outfile_name, no_of_bytes_to_prefix=100): | |
| file_name_encoded = bytes(file_name, encoding='utf-8') | |
| file_name_length = len(file_name_encoded) | |
| if file_name_length > no_of_bytes_to_prefix: | |
| raise Exception('file name after utf-8 encoding is too long') | |
| prefixed_bytes = bytearray(no_of_bytes_to_prefix) | |
| prefixed_bytes[0:file_name_length] = file_name_encoded | |
| chunk_buffer = 4096 | |
| with open(file_name, 'rb') as infile, open(outfile_name, 'wb') as outfile: |