PHP Clean Code (Part 2)

PHP Clean Code (Part I) Use default parameters instead of short circuit operation or condition judgment Bad practice: This is not good because $breweryName can be NULL function createMicrobrewery($breweryName = 'Hipster Brew Co.'): void { // ... }    It's OK: This approach is easier to understand than the above, but it needs to contr ...

Posted by Kiubbo on Fri, 27 Mar 2020 11:33:02 +0100

Briefly discussing the algorithm of snatching red envelopes

At first, I thought it should be random every time I grab a red envelope. The random upper limit is the amount of the remaining red envelopes. This is problematic. For example, if I send a red envelope of 100 yuan, the first person's random range is (0,100), and the average can grab 50 yuan.Then the second person's red envelope ...

Posted by roninblade on Wed, 25 Mar 2020 17:21:30 +0100

11-hash 3 QQ account application and login (25 points)

Simplified version of QQ new account application and old account login.The biggest challenge is: it is said that the QQ number now has 10 digits. Input format: Input first gives a positive integer NN (< 10^5), followed by a NN line instruction.The format of each line of instructions is "Command (space) QQ number (space) pass ...

Posted by Option on Wed, 25 Mar 2020 01:56:19 +0100

Setting method of static files on nginx cache server

1, Advantages of nginx caching As shown in the figure, nginx caching can reduce the processing pressure of the source server to a certain extent. Because many static files (such as css, js, pictures) are not updated frequently. nginx uses proxy cache to cache users' requests to a local directory. The next same request can directly fetch the ...

Posted by acabrera on Sun, 22 Mar 2020 18:39:44 +0100

Introduction to the open source project Humanizer

Humanizer meets all your.Net needs for operations and displays of the following types, including strings, enumerations, dates, times, time spans, numbers, and quantities.It uses MIT for authorized distribution.   1. Humanized string Humanized string extensions allow you to convert strings that were originally processed by your computer into hum ...

Posted by mastermike707 on Thu, 19 Mar 2020 04:44:26 +0100

Detailed explanation of total record optimization of count query in paging component

1 background When using the paging function of mybatis plus (hereinafter referred to as MBP). Found a JsqlParserCountOptimize The official didn't give a detailed introduction to the paging optimization processing class of, and didn't find a few words on the Internet to analyze the logic of this class, which we dare not use. It's also convenient ...

Posted by silas101 on Wed, 18 Mar 2020 08:21:33 +0100

Program design and algorithm week 09 test

Title: Naruto and Sasuke Sasuke was lured away by big snake pill. How long can Naruto catch up with him? A map (in the form of a two-dimensional matrix) and the location of Sasuke and Naruto are known. You can go to every position on the map, but there are some positions with big snake pill's subordin ...

Posted by mrjiggyhill on Tue, 17 Mar 2020 09:22:21 +0100

Assembly: Branch programming

Branch programming (1) Simple branch program: two branches are obtained by judging a condition, and the judgment result of the condition determines the execution direction of the program. The disadvantage lies in the limitation of execution flow direction, for example, when the condition is a multi se ...

Posted by Chalks on Mon, 16 Mar 2020 12:56:54 +0100

Angular form validation

Template driven validation Using template driven validation depends on Native HTML form validator Angular uses instructions to match these attributes with validation. There are two kinds of native HTMl validators Define by semantic type Define by verifying related properties semantic type ...

Posted by philicious on Mon, 16 Mar 2020 12:18:54 +0100

Data Structure and Algorithms collation-diagram

Collate Zhang Ming's Notes on Data Structure and Algorithms 7. Diagram 7.1 Diagram concepts and abstract data types Definitions and terminology of 7.1.1 diagrams 1.G=(V,E) Representation V is the set of vertices E is a set of edges 2. Complete Diagram 3. Sparse Map Sparsity (Sparsity Factor) The ...

Posted by cullouch on Sun, 15 Mar 2020 04:22:50 +0100