How to Run PostgreSQL Server and Database?
1. Online Tutorials
2. Issues
2.1 psycopg2.OperationalError: could not connect to server: Connection refused
Relevant resource:
- Connection refused with postgresql using psycopg2
- Getting error: Peer authentication failed for user “postgres”, when trying to get pgsql working with rails
Solution:
Just modify this file /etc/postgresql/12/main/pg_hba.conf
:
local all postgres peer
=>local all postgres trust
local all all peer
=>local all all md5
2.2 Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432?
Relevant resource:
- Postgres could not connect to server
- Is the server running on host “localhost” (::1) and accepting TCP/IP connections on port 5432?
- psql: could not connect to server: No such file or directory (Mac OS X)
- How to change the default unix socket location from /tmp for PostgreSQL
Solution:
- find the folder containing the file
postmaster.pid
, and remove it:rm /var/lib/postgresql/12/main/postmaster.pid
- edit file
/etc/postgresql/12/main/postgresql.conf
, in which, set:listen_addresses = '*'
port = 5432
unix_socket_directory = '/var/run/postgresql'
2.3 CREATE EXTENSION in PostgreSQL
Relevant resource:
- How do I import modules or install extensions in PostgreSQL 9.1+?
- Using psql how do I list extensions installed in a database?
Solutions:
- Please make sure
postgresql-contrib
has been installed.
2.4 Deal With GinIndex
Relevant resource:
- How to create GIN index in Django migration
- What is gin_trgm_ops of PostgreSQL?
- gin_trgm_ops does not exist for access method “gin”
- Creating a Gin Index with Trigram (gin_trgm_ops) in Django model
- A Guide to Create User-Defined Extension Modules to Postgres
Solutions:
- Please make sure
btree_gin
andpg_trgm
EXTENSIONs have been CREATEed for the user username in PostgreSQL database. Namely, you need to\c database username
beforeCREATE EXTENSION btree_gin
andCREATE EXTENSION pg_trgm
.
2.5 django.db.utils.ProgrammingError: syntax error at or near "FUNCTION"
Solutions:
- Use PROCEDURE instead of FUNCTION.
2.6 django.db.migrations.exceptions.InconsistentMigrationHistory: Migration site.0001_initial is applied before its dependency account.0003_initial on database 'default'.
Relevant resource:
Solutions:
- Please make sure
\c database username
is run from withinpsql
.
2.7 LOG: SSL is not supported by this build
Relevant resource:
Solutions:
1 | ⋊> ~ sudo su - postgres |
3. Process
Step 1. Install postgresql
and postgresql-contrib
1 | ⋊> ~ apt list --installed | grep postgresql 22:46:41 |
Step 2. Open a FIRST terminal:
1 | ⋊> ~ sudo su - postgres 22:03:23 |
Step 3. Open a SECOND terminal:
- with user postgres,
psql
will do - with other users, such as longervision, you’ve got to do
psql -U postgres
1 | ⋊> ~ psql -U postgres 22:06:18 |
Step 4. Saleor Reset Migrations (Optional)
Refer to How to Reset Migrations
Run the following 2 lines:
find . -path "*/migrations/*.py" -not -name "__init__.py" -delete
find . -path "*/migrations/*.pyc" -delete
Modify saleor/settings.py
From
1 | DATABASE_CONNECTION_DEFAULT_NAME: dj_database_url.config( |
to
1 | DATABASE_CONNECTION_DEFAULT_NAME: dj_database_url.config( |
correspondingly.
Start Migration
1 | ⋊> /v/w/v/saleor on main ⨯ python manage.py makemigrations 22:32:00 |
1 | ⋊> /v/w/v/saleor on main ⨯ python manage.py migrate 00:02:56 |
How to Prepare and Upload PPA to Launchpad?
Refer to Launchpad PPA:
- Launchpad Packaging/PPA
- Launchpad Installing Software
- Launchpad Building A Source Package
- Building debian packages with debuild
- Launchpad Uploading
- Launchpad Copying
- Basic Overview of the debian/ Directory
Solution
- dput Way
1
dput ppa:longervision/googletest googletest_1.11.0_amd64.changes
- FTP
Edit~/.dput.cf
as:1
2
3
4
5
6[googletest]
fqdn = ppa.launchpad.net
method = ftp
incoming = ~longervision/ubuntu/
login = jiapei100
allow_unsigned_uploads = 0
How to build QtWebEngine?
NEVER successfully built out QtWebEngine before. Today, I’d love to have a try. From this tutorial Building QtWebEngine, it looks possible.
Hugo
Tutorials
Nothing but a collection of various tutorials.
0. Comprehensive
0.1 Tutorials
- GeeksforGeeks
- Guru99
- tutorialspoint
- RIP Tutorials
- LeetCode Explore
- Kaggle Courses
- C语言中文网
- W3 Schools
- JaveTPoint
- Beginners Book
0.2 Quizzes
0.3 Interviews
0.4 E-Books
0.5 Blogs
1. Programming Languages
1.1 C
- Cprogramming
- learn-c
- Functions Pointers in C Programming with Examples
- C Tutorial
- C Tutorial
- C17 StackOverflow
- C Standard Library Reference Tutorial
1.2 C++
- learn-cpp
- C++ Tutorial
- Magic Enum C++ Stop the war right away please
- OpenGL vs. DirectX: A Comparison
1.3 GDB
1.4. Java
1.5. Python
- The Python Tutorial
- Python for Programmers
- Python Tutorial
- Python Tutorial
- Python Tips
- Understanding Python Decorators in 12 Easy Steps!
1.6 Golang
1.7 Rust
1.8 Dart
2. Algorithms
3. Robotics
3.1 Comprehensive Open Source
- Top 10 Python Libraries For Robotics
- Top 5 Free and Open Source Robotics Frameworks
- Top 5 Open Source Robotics Software Solutions
3.2 Robotic Arm
4. Linux
4.1 Linux Operating System
4.2. Shell Scripts
- Shell Scripting Tutorial
- Shell Scripting Tutorial: How to Create Shell Script in Linux/Unix
- Advanced Bash-Scripting Guide
- Shell Tips!
5. Coding Tricks
5.1. Regular Expressions
5.2. Git
6. Cheat Sheets
XGBoost vs. LightGBM vs. CatBoost vs. H2O vs. MLflow
Happened to come across a blog XGBoost vs LightGBM: How Are They Different. Let’s investigate a bit wider and deeper into the following 4 machine learning open source packages.
- XGBoost: XGBoost Doc, XGBoost Source Code
- LightGBM: LightGBM Doc, LightGBM Source Code
- CatBoost: CatBoost Doc, CatBoost Source Code
- H2O: H2O Doc, H2O Source Code
- MLflow: MLflow Doc, MLflow Source Code
1. Some Readings
- XGBoost vs LightGBM: How Are They Different
- Gradient Boosted Decision Trees [Guide]: a Conceptual Explanation
- AdaBoost and Gradient Boost – Comparitive Study Between 2 Popular Ensemble Model Techniques
- AdaBoost Vs Gradient Boosting: A Comparison Of Leading Boosting Algorithms
- A Primer to Ensemble Learning – Bagging and Boosting
- Ensemble methods: bagging, boosting and stacking
- CatBoost Classifier in Python
- Tutorial: CatBoost Overview
Cited from XGBoost vs LightGBM: How Are They Different
1 | Two of the most popular algorithms that are based on Gradient Boosted Machines are XGBoost and LightGBM. |
2. Concepts
- Bootstrap Aggregating: also named Bagging. A typical Bagging method is Random Forest.
- Boosting: A typical Boosting method is AdaBoost, short for Adaptive Boosting.
- Ensemble: As summarized, Bagging, Boosting, and Stacking ALL belong to Ensemble.
- Cascading: citing:
Unlike voting or stacking ensembles, which are multiexpert systems, cascading is a multistage one.
- Gradient Boosting: citing:
originated in the observation by Leo Breiman
, an American academician, also proposed Random Forest.
3. Amazon.com - Employee Access Challenge
In this blog, I’m going to use a very old Kaggle dataset Amazon.com - Employee Access Challenge.
4. XGBoost
Please make sure:
- either rebuild your own XGBoost
- or download my built wheel from https://longervision.us/
1 | ➜ ~ pip show xgboost |
5. LightGBM
Please make sure:
- either rebuild your own LightGBM
- or download my built wheel from https://longervision.us/
1 | ➜ ~ pip show lightgbm |
Pay Attention: In order to have XGBoost or LightGBM successfully built, you may have to:
- either rebuilt your own CuPy
- or download my built wheel from https://longervision.us/
6. CatBoost
1 | ➜ ~ pip show catboost |
7. H2O
1 | ➜ ~ pip show h2o |
8. MLflow
1 | ➜ pip show mlflow |
Please make sure:
- either rebuild your own MLflow
- or download my built wheel from https://longervision.us/
Exploratory Data Analysis (EDA)and t-distributed Stochastic Neighbor Embedding (t-SNE)
1. Definition of EDA
Directly refer to Rapid-Fire EDA process using Python for ML Implementation.
Clearly, PCA is a part of EDA.
Here is another good tutorial for EDA: A Starter Pack to Exploratory Data Analysis with Python, pandas, seaborn, and scikit-learn.
2. Visualization with t-SNE
- Definition: t-SNE on Wikipedia
- t-SNE in scikit-learn: sklearn.manifold.TSNE
- Tutorials:
3. Try Analyzing and Visualizing MNIST
Let’s just refer to the FIRST tutorial and try out how to analyze and visualize the famous dataset MNIST.
Please refer to my copy-paste-modification jupyter notebook
code at https://github.com/LongerVision/Kaggle.
4. Try Analyzing and Visualizing Fashion-MNIST
Let’s then refer to the SECOND tutorial and try out how to analyze and visualize Fashion-MNIST.
Please refer to my copy-paste-modification jupyter notebook
code at https://github.com/LongerVision/Kaggle.
Activation Functions
Happy new year everyone. Such a long time I haven’t taken a look at activation functions. It might be a good time for me to review and check.
1. Resource
Let’s first take a look at activation functions of year 2022.
- Wikipedia
- Swish Vs Mish: Latest Activation Functions
- Smish: A Novel Activation Function for Deep Learning Methods, strongly recommend to read this article
- ACON - Activate or Not: Learning Customized Activation, CVPR 2021., same thing can be found at Summary of neural network activation function. 2022.01, strongly recommend to read this article
- Activation Functions for Neural Networks and their Implementation in Python
- 12 Types of Neural Network Activation Functions: How to Choose?
I would strongly recommend you to read the 2 articles mentioned above, particularly: Smish.