Finding User Sessions With Sql

In the PC era, when a user asks for a page, we will first check whether a SessionId exists in the user’s cookie, and if it does not exist, we will generate a SessionId by random number and store it in the cookie. If it exists, we will update the expiration time of this cookie (after 30 minutes). That is, as long as the user visits the interval within 30 minutes is considered the same Seesion, more than 30 minutes will generate a new SeesionId and define browsing as a new Session.

Universally Unique Identifier

In complex distributed systems, it is often necessary to uniquely identify a large number of data and messages. A unique ID is needed to identify a piece of data or a message after the data is divided into libraries and tables, and the self-incrementing ID of the database obviously does not meet the demand at this time a system that can generate a globally unique ID is very necessary. To

Readability, a web body extraction tool

What is Readability? If you see a good article on the Internet and want to save it for later reading, but don’t want to save a lot of green ads or irrelevant web elements at the same time, then you can try Readability! Readability is a unique “read later” web favorites service that not only allows you to bookmark articles you like, but also has the best feature of automatically and intelligently eliminating some unimportant elements on the web page and reformatting them to present you with a clean and tidy body part, making your better reading experience!

Using the Python Logging Module

logging module is a standard module built in Python, mainly used for outputting runtime logs, you can set the output log level, log save path, log file rollback, etc. Compared with print, it has the following advantages. you can set different logging levels to output only important information in the release version without having to display a lot of debugging information print outputs all the information to the standard output,

Python modules, packages, libraries, frameworks

In the process of using Python, I often get confused by the concepts of modules, libraries, packages, and frameworks. Today, we will take time to sort out these concepts. Module A module is a file with a .py suffix in which constants and functions are defined. The name of a module is the name of that .py file. The name of the module is taken as a global variable __name__ that can be fetched or imported by other modules.

Matplotlib Beginner Tutorial

Matplotlib Beginner Tutorial MATLAB MATLAB is a combination of the words Matrix & Laboratory, meaning matrix factory (matrix laboratory). It is a high-tech computing environment mainly for scientific computing, visualization and interactive programming released by Mathworks, Inc. It integrates many powerful functions such as numerical analysis, matrix calculation, scientific data visualization, and modeling and simulation of nonlinear dynamic systems in an easy-to-use Windows environment, providing a comprehensive solution for scientific

Jupyter Learning Notes: IPython Magic Commands

Jupyter with IPython IPython is a much better interactive command line interface for Python than the default Python Shell. It supports variable auto-completion, auto-indentation, Bash Shell commands, and has many useful built-in functions and features. Greatly improves the productivity of interactive computing and software development. Jupyter Notebook (formerly IPython Notebook) is a web-based interactive computing environment for creating Jupyter Notebook documents.Notebook is a web based IPython wrapper that makes it possible to use IPython in the browser.

Installation and use of the WordPress LaTeX plugin

Introduction to LaTeX LaTeX is a powerful typesetting tool that is rarely touched by the general scene, but is very much used in the field of mathematics, mainly because he can generate various mathematical formulas very easily. To learn how to use LaTeX you only need to learn a few simple concepts. Display Mode Display mode mainly controls whether you need to display the formula content between the body lines

The difference between break/continue/pass in Python

There are two types of loops you can use in Python: for loops and while loops. You can use them for repetitive tasks. As a result, repetitive tasks will happen automatically, making the process more efficient. Unfortunately, you may run into some problems with your loops. Sometimes your program may run into problems that require it to skip a part of the loop or exit the loop altogether. Or you may need it to ignore external factors that affect the program.

Compressing and Decompressing with Python

In your daily work, in addition to using Python to process text files, sometimes you will also be involved in processing compressed files. The compression file formats that are usually involved are rar: the more used compression under Windows environment, the more famous GUI tool is winrar tar: a packaging tool for Linux systems, only packaging, not compression gz: or gzip, usually can only compress one file. Combined with tar,

Connecting to Hive using PySpark in Jupyter

The company’s Jupyter environment supports PySpark. this makes it very easy to use PySpark to connect to Hive queries and use. Since I had no prior exposure to Spark at all, I put together some reference material. Spark Context The core module in PySpark is SparkContext (sc for short), and the most important data carrier is RDD, which is like a NumPy array or a Pandas Series, and can be

Decision tree visualization methods and techniques

One advantage of decision trees over other algorithms is the ability to visualize decision tree models. Decision trees are subdivided into classification trees, which are used to predict classifications, and regression trees, which are used to predict values. The visualization of decision trees can help us to understand the details of the algorithm in a very intuitive way. However, some problems may be encountered during the specific use. The following

Grafana Loki Concise Tutorial

Loki, the latest open source project from the Grafana Labs team, is a horizontally scalable, high-availability, multi-tenant log aggregation system. It is designed to be very cost effective and easy to use because it does not index log content, but rather configures a set of tags for each log stream. Project inspired by Prometheus , the official description is: Like Prometheus, but for logs , similar to the Prometheus logging

Renew a Kubernetes certificate with a 10-year expiration date

It is very convenient to use kubeadm to install kubernetes cluster, but there is also a more annoying problem is that the default certificate is only valid for one year, so you need to consider the issue of certificate upgrade, the demo cluster version of this article is v1.16.2 version, there is no guarantee that the following operation is also applicable to other versions, before the operation must first backup

Customize Helm Charts with Kustomize

If you use Kubernetes a lot, you should be familiar with Helm and Kustomize. Both tools are used to manage Kubernetes resource lists, but they work in different ways. Helm uses templates, a Helm Chart package that contains a number of templates and value files, and when rendered the variables in the templates are replaced with the corresponding values in the value files. Kustomize uses a template-free approach, which patches

Merging and Joining DataFrames in Pandas

When working with data in Pandas, it is sometimes necessary to merge and concatenate multiple data, the most common of which include merging multiple split files. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 import pandas as pd import glob file_list = glob.glob('data/*') df_list = [] for file in file_list: df_temp = pd.read_csv(file, sep="<pre class="EnlighterJSRAW" data-enlighter-language="generic">import pandas as pd import glob file_list = glob.

Pandas+SQLAlchemy interaction with database

When using Pandas to analyze data, besides reading text-based data, such as Excel and CSV files, database reading is also involved. The usual solution is Pandas+ SQLAlchemy. The following is a record of some operations, as a memo. Connecting to a database using sqlalchemy Engine translates to engine, the car is driven by the engine, and SQLAlchemy is driven by the Engine, which maintains a connection pool (Pool) object and

Python Automation - Timed Tasks

In our daily work, we often use tasks that need to be executed periodically, one way is to use Linux crond in combination with command line implementation. Another way is to use Python directly, and the following is a list of common ways to implement Python timed tasks. Use while True: + sleep() to implement a timed task The sleep(secs) function in the time module allows you to pause the

Service High Availability Flow Limiting

The definition of flow limiting varies in different scenarios, and can be the number of requests per second, the number of transactions per second, or the network traffic. By rate limit, we mean a limit on the number of concurrent requests arriving at the system, so that the system can handle some of the users’ requests properly to ensure the stability of the system. The English word for rate limit

Python garbage collection mechanism and implementation

Python, as an interpreted language, is known for its clean and easy to understand code. We can assign values to names directly, without having to declare types. The Python interpreter determines name types and allocates and frees memory space at runtime, and this automatic memory management greatly reduces the burden on the programmer. For a high-level language like Python, developers can complete their work without concern for its internal garbage