programmer group

Better authority authentication method than RBAC (Auth type authentication)

The Auth class has been in the ThinkPHP code warehouse for a long time, but because there has been no tutorial, few people know it, it is actually more convenient than RBAC.  RBAC authenticates by node. It's a little difficult to control permissions that are more detailed than nodes. For example, the operation button on the page, I want to judge user permissions to display this button. If I don't have permissions, I won't display this button. For example, I want to perform authorization authentication by integral, what can I do when the...

programmer group

Built in function supplement, anonymous function and closure

Built in function, anonymous function and closure Anonymous function def func(x,y): return (x,y) print(func(1,2)) # Result: (1,2) f = lambda x,y:(x,y) # lambda keyword print(f(1,2)) # Result: (1,2) print((lambda x,y:(x,y))(1,2)) # Result: (1,2) # The definition and call of anonymous function with one line of code print(lambda :1) print((lambda :1)()) # Anonymous functions may not write parameters, but must have a return value. The return value must be one, which can be any data type. # Result: <function...

programmer group

2019 multi university training contest 1 - 1011 - function - Number Theory

http://acm.hdu.edu.cn/showproblem.php?pid=6588 We have learned a fast method to find the sum of gcd within n and m. This is S1 below. 1. \[ \sum_{i=1}^{n}gcd(m,i) \] ② enumeration d: \[ \sum_{d|m} d \sum_{i=1}^{n} [gcd(m,i)==d] \] Obviously, \[ \sum_{d|m} d \sum_{i=1}^{\lfloor\frac{n}{d}\rfloor} [gcd(\frac{m}{d},i)==1] \] At this stage, it can be recursively solved. Qi Qi said it is \ (O(n^{\frac{3}{4}) \), but the solution can continue. ④ from $\ sum\limit{d|n}\mu(d)=[n==1] $obviously: \[ \sum_{d|m} d \sum_{i=1}^{n} [gcd(m,i)==d] ...

programmer group

Learning of pressure DP

What is DP? Here is my personal understanding: Shape pressure DP is to compress the number of answers by using binary to eliminate the situation that does not meet the question, so that a very violent algorithm can become acceptable in time. For a more detailed explanation, you can see here: Understanding of DP There are also some problems and explanations of DP with pressure. Let's take a look at how DP prunes the answers. HDU 1074 Question meaning: you have n assignments (n < = 15), each...

programmer group

Login page hide password digits (Vue)

Requirement: the length of the password displayed when the user enters the password is different from the length of the actual number of digits. Solution: each time a bit is input, randomly generate a string of 1-5 bits after the input value before adding, and record the length of the generated random string for deletion. Solution: 1. input adds on change event (iview writing method) <Input type="password" v-model.trim="form.password" @on-change="passwordChange" :placeholder="Please input a...

programmer group

Multiprocess programming exercises (implemented in Python)

IP address home location batch query task Note: multithreaded tasks are implemented by creating subclasses Implementation code: import json import requests from threading import Thread class GetHostAliveThread(Thread): def __init__(self, ip): super(GetHostAliveThread, self).__init__() self.ip = ip def run(self): url = 'http://ip-api.com/json/%s' % (ip) count = requests.get(url).text dict_data = json.loads(count) city = dict_data.get('city') country =...

programmer group

Spring automatically assembles and injects arrays, collections and maps by type

When Spring automatically assembles and injects arrays, collections, and maps by type, it assembles bean s of the corresponding type in the application context into the collection, rather than directly finding a collection of the corresponding type and injecting it. Take the following code as an example: @Component public class WmsProtocolFactory { @Autowired private Map<String, WmsRemoteProtocol> mediaPlayerMap; @Autowired private WmsRemoteProtocol[] addr; @Autowired ...

programmer group

ios solves the problem that horizontal screen is not allowed for app as a whole, and horizontal screen is required for sdk or individual pages.

The problem I encountered is that in the sdk, the app as a whole needs to prohibit horizontal screen, and the identification page inside the sdk needs horizontal screen, so there is a reference to the code of online Titan. Finally, I found that the best solution is runtime. OCFTOCRRotation.h ---------------------------------------------------- #import <Foundation/Foundation.h> NS_ASSUME_NONNULL_BEGIN @interface OCFTOCRRotation : NSObject /** Implementation of switching system method and...

programmer group

Construction of tornado framework

Construction of tornado framework First you need to think about what your site needs to look like. For example, I plan to open a blog, then provide some drawing tools, and put some personal introductions, etc., so I temporarily define the following categories: import tornado.ioloop import tornado.web from tornado.options import define, options class Application(tornado.web.Application): def __init__(self): handlers = [ (r"/", IndexHandler), (r"/index",...

programmer group

caffe source guide on Blob data structure

The reading notes of this book. In proto/caffe.proto, the Blob data structure is introduced at the beginning. This data structure is an important dependency of most other data structures. In the calculation of network layer in caffe, the input and output of each layer are buffered by Blob object, which is the basic storage unit of cagge. I. first look at the data structure description of Blob // Specifies the shape (dimensions) of a Blob. message BlobShape { //To achieve high-dimensional...

programmer group

HDU 2255 KM algorithm for making money

http://acm.hdu.edu.cn/showproblem.php?pid=2255 It is said that there is a very rich village in a distant place. One day, the village head decided to carry out institutional reform: redistribution of houses. It's a big deal. It's about people's housing. There are n rooms in the village. There are just n ordinary people. Considering that each family has to have a room (if there are ordinary people who don't have a house, it is easy to cause instability), each family must be allocated to one house and...

programmer group

String encryption and decryption

Title Description: 1. Encrypt and decrypt the input string and output. 2. Encryption method: When the content is an English letter, replace it with the next letter of the English letter. At the same time, letters change case, such as the letter A is replaced by B; the letter Z is replaced by a; When the content is a number, add 1 to the number, such as 0 for 1, 1 for 2, 9 for 0; Other characters do not change. 3. The decryption method is the reverse process of encryption. Input...

programmer group

C ා learning -- encapsulation of basic Oracle database operations (connection, addition, deletion, modification, query)

In the front: C encapsulation of SQLserver: https://www.cnblogs.com/mexihq/p/11636785.html Similar to the C-encapsulation of SQLserver in the previous article, the small edition encapsulates the Oracle database, which is convenient for later development and use, mainly including connection, addition, deletion, modification and query of Oracle database. If there is any problem, please give advice. In the future, several other commonly used databases will also be collated accordingly. Don't say much, just start the code. It indicates that a...

programmer group

centos builds face recognition environment

0. Official document of face & Recognition https://github.com/ageitgey/face_recognition   1. Install face recognition 1.1 installing dlib 1) installation and development Environmental Science [root@localhost ~]# yum update[root@localhost ~]#yum groupinstall "Development Tools"   2) install OpenCV [root@localhost ~]# yum install cmake python-devel numpy gcc gcc-c++ gtk2-devel libdc1394-devel libv4l-devel ffmpeg-devel gstreamer-plugins-base-devel libpng-devel libjpeg-turbo-devel jasper-devel openexr-devel libtiff-devel...

programmer group

Transformation of CSRF of CI

The CSRF of CI is defective. As long as two different pages involving csrf are opened at the same time, http://host/csrf1 http://host/csrf2 You will find that the pages directly affect each other (question 1). Even on the same page. http://host/csrf1 http://host/csrf1 Such problems will also be found (question 2). Solve simple problem 2 first You only need to set the configuration CSRF ﹣ register to false; that is, the cookie expires or is cleared. $config['csrf_regenerate'] = FALSE; Solving complex problems 1: 1. Filter the...

programmer group

LeetCode-Binary Tree Zigzag Level Order Traversal

Description: Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between). For example: Given binary tree [3,9,20,null,null,15,7], 3 / \ 9 20 / \ 15 7 return its zigzag level order traversal as: [ [3], [20,9], [15,7] ] Given a binary tree, it is required to output z-type sequence traversal. Solution: for hierarchical traversal, we can think of using queue to...

programmer group

StringUtils.isNumeric to determine whether it is a numeric string

StringUtils.isNumeric to determine whether it is a numeric string org.apache.commons.lang3.StringUtils The string utility class StringUtils can handle Java string problems easily, which is a magic weapon of Java string. Common functions can be recorded, which is easy to handle even if the string object is null. IsEmpty/IsBlank - checks if a String contains text Trim/Strip - removes leading and trailing whitespace Equals/Compare - compares two strings null-safe startsWith - check if a String starts...

programmer group

Pass ruleset to mixin

Allows wrapping of css blocks defined in mixin s. A detached ruleset is a set of CSS properties, nested rulesets, media declarations, or anything else stored in a variable that we can include in a ruleset or other structure and all properties are copied there; we can also use it as a mixin parameter and pass it as any other variable. // Rules for declaration separation @rule_set: { color: green; }; // Use separate rule sets .xkd { @rule_set(); } // Output result .xkd{ color: green; ...