Difference between getelementsbyname and getelementbyid

The difference between getElementsByName and getElementById
GetElementsByName gets an array
getElementById gets a number

function sum(n, m) {
            var summary = 0;
            var a = document.getElementsByName(n.toString());
            for (var i = 0; i < a.length; i++) {
                summary = summary + Number(a[i].value);
            }
            
            //1
            var b = document.getElementById(m);
            b.value = summary;
            //2
            var f = document.getElementsByName(m);
            f[0].value = summary;
        }

Configure QT designer in pychar

Then configure Qt Designer in Pycharm
1. First install Qt and Qt Dsigner PIP Install PyQt5 PIP install PyqT5-Tools

5 in pycharm is D:\anaconda3\Library\bin\designer. Exe means the path to install designer.
do not know their own installation path:
win+s
enter designer, right click display path can

and then configure:

3 D:\anaconda3\Scripts\pyuic5 exe the same for their own installation program path
4 for:

F

i

l

e

N

a

m

e

FileName

FileName-o

F

i

l

e

N

a

m

e

W

i

t

h

o

u

t

E

x

t

e

n

s

i

o

n

FileNameWithoutExtension

FileNameWithoutExtension. Py
click ok below.


Practice — CSS3 — frame animation to achieve special effects

Practice ING – Frame animation to achieve special effects
Recently, I wrote another requirement, which used a lot of CSS3 animation, but it is still very deep to go into each attribute of CSS3 animation carefully. Here, I will write down the understanding of the steps attribute of frame animation
We know that CSS3 Animation has eight attributes
animation-name
animation-duration
animation-delay
animation-iteration-count
animation-direction
animation-play-state
animation-fill-mode
animation-timing-function
Most 1-7 are introduced, but the animation-timing function is an attribute that controls the time
In addition to the three Bessel curves commonly used, there is the confusing steps() function
By default, the animation ease the transition. It inserts a tween between each key frame, so the animation is coherent
In addition to ease, transition functions such as Linear, Cubic – Bezier will insert the tween for it. However, some effects do not require tween, but only a jump between key frames, where steps should be used
Understand the steps
The Steps function specifies a step function
The first parameter specifies the number of intervals in the time function (must be positive integers)
The second parameter, which is optional, accepts both start and end values, specifying a step change at the start or end point of each interval, which defaults to end.
Step -start is equal to steps(1,start). The animation is divided into 1 step. The part that starts the left endpoint when the animation is executed is the beginning.
Step-end is the same as steps(1,end) : the animation is divided into steps, and the animation is executed starting with the end endpoint, with the default value of end.
Look at the W3C specification
The wrong understanding of the first parameter of steps:
Steps (5, start)
The first parameter “number” of steps() is the specified number of intervals, that is, the animation is divided into N-step phased display, which is estimated to be the number of changes written for keyframes by most people
A look at the cSS2 frame animation I wrote also gave me a good understanding of cSS3 animation
@-webkit-keyframes circle {
0% {}
25%{}
50%{}
75%{}
100%{}
}

I also wrote a js, please refer to

How to add directory plug-ins to jubyter notebook

This part of the content is in accordance with the experience of baidu on the operation of the article records, in accordance with the steps of the operation can be, there is no problem. The article addresses is:
https://jingyan.baidu.com/article/9c69d48f5bb44552c8024e65.html
The steps are as follows:

    first close the running jupyter notebook plug-in package:
pip3 install jupyter_contrib_nbextensions
    configuration nbextension:

       jupyter contrib nbextension install --user --skip-running-check
    

    After

      is equipped, we launch jupyter; at that moment, we see the nbexlogo appearing on the menu bar, that is, the installation is successful; and then, we click on the configuration to enter nbexschematic; and we see that there are many items; after the modification, click on TableOfContents to update the webpage or restart jupyter; that is,

Browser performance tool

Why use Performance
The purpose of GC is to realize the virtuous cycle of memory space
; the cornerstone of the virtuous cycle is to use
properly at all times to determine whether it is reasonable
Performance provides multiple monitoring methods
Open a browser and enter the target website
into the developer tools panel. Select the Performance
to open the recording function. Visit the specific interface
to perform user behaviors

interface appears lazy loading or frequent pauses
interface continues to show poor performance
interface performance becomes worse and worse with time delay
The way to monitor memory
standard
memory leak: is the continuous increase of memory
memory bloat: performance problems exist on most devices
frequent garbage collection: analyzed by memory change graph
Method:
browser task manager
Timeline graph record
heap snapshot lookup decouple DOM
determines whether frequent garbage collection occurs

Several methods of deleting all empty lines in text under Linux

Method 1: Use Grep
grep -v ‘^\s*$’ test.txt
Note: -v means to reverse the matching result and the regular expression matches the blank line. (Blank lines can include whitespace characters such as space TAB characters)
Method 2: Use SED
sed ‘/^\s*$/d’ test.txt
Note: D stands for delete the line
Method 3: Use AWK
awk NF test.txt
Note: NF represents the number of fields in the current row. If the line is blank, the number of fields is 0, which is interpreted as false by AWK, so it will not be output.
 
All three of these methods can handle blank lines containing whitespace characters (Spaces, tabs, etc.).
 
Method 4: If blank lines are caused by ‘\n’, you can also use the tr command to remove them
tr -s ‘\n’ < test.txt
Note: -s represents the compression of multiple consecutive characters into a character. In this case, multiple ‘\n’ is compressed into a ‘\n’ to remove empty lines.
A weakness of method 4: If the first line is empty, the first line cannot be removed
The level is limited, if has the improper place, also hoped corrects!

Oracle error – ora-12519, TNS:no appropriate service handler found

Navicat Premium15 connection Oracle error Oracle error – ora-12519, TNS:no appropriate service handler found
most of the web said the solution was to modify the maximum number of connections, but I passed select count(*) from v$process; found that my connection number is only 30, there is no such thing as the preset number of 150, so it should not be this problem.
is found to be the Listener. Ora and tnsnames.ora files that have been modified before. Change the HOST value in the file to the local IP address, which was localhost before.
is hoping to help someone with this problem.

node url.parse()

Assume that this is a url http://localhost:8080/a/b/c?a=1&
protocol: ‘HTTP:’,// protocol
host: ‘localhost:8080’,
port: ‘8080’,// port
hostname: ‘localhost’, domain
hash: ‘#abcd’,
search: ‘?a=1& B = 2 ‘,
query: ‘a = 1 & amp; B =2 ‘,
pathname: ‘/a/b/c’,
path: ‘/a/b/c?a=1& B = 2 ‘,
href: ‘http://localhost:8080/a/b/c?a=1& B = 2 # ABC ‘
Url.parse () can break a complete URL into many parts, such as host, port, Pathname, path, and Query

var http = require("http");
var url = require("url");

var server = http.createServer(function(req,res){
    var pathname = url.parse(req.url).pathname;
    var query = url.parse(req.url).query;
    console.log("patname:"+ pathname);
    console.log(query);
    res.end();
});
server.listen(80,"127.0.0.1");

Putty remote login VMware virtual machine Linux

Install SSH service
There is no SSH service installed in Ubuntu by default. If you connect to Ubuntu via SSH, you need to manually install sSH-Server yourself. To determine whether to install SSH service, the following command can be used:

    : www.linuxidc.com@linuxidc:~$SSH localhost SSH: connect to host localhost port 22: Connection destination: Connection union

 
As shown above, it means that it has not been installed yet. It can be installed through APT. The command is as follows:

    : www.linuxidc.com@linuxidc:~$sudo apt-get install openssh-server

 
The system will be installed automatically. After the installation is completed, the service will be started first:

    www.linuxidc.com@linuxidc:~$sudo/etc/init. D/SSH start
     
    After startup, you can check to see if the service started correctly with the following command
    Ps

      www.linuxidc.com@linuxidc:~$- e | grep SSH 6212?00:00:00 SSHD
       
      As indicated above, start OK. Note that the default port for SSH is 22. You can change the port, stop,
      and then start. The configuration is under /etc/ssh/sshd_config, as shown below.

        www.linuxidc.com@linuxidc:~$vi /etc/ SSH /sshd_config # Package generated configuration file # See the SSHD (8) manpage for details # What ports, IPs and protocols we listen for Port 22
         
        Finally, it’s time to connect. See the following command:
        SSH [email protected]

          www.linuxidc.com@linuxidc:~$
          Disconnect:
          The

            exit
             
            Log into the virtual machine via Putty
            First of all, make sure that the virtual machine and host can ping each other. If you can’t ping the general, then the follow-up work cannot be carried out. You can search the Web for references to articles on VIRTUAL machine IP configuration
            Next, open the Putty client and the following interface appears. Fill in the relevant parameters:

            Where the IP address is the IP address of Ubuntu in the virtual machine.
            finally click Open to enter Putty, enter the user name and password to log in.

Pandas get column name

Getting the column name of DataFrame is a simple operation with the following methods:
Column for column in df]
2. Df.columns. Values return array
3. List (df)
4. Df.columns return Index (tolist(), or list(array)

import pandas as pd
from numpy.random import randint
df = pd.DataFrame(columns=list('abcdefghij'))

%timeit [column for column in df]

%timeit list(df.columns.values)

%timeit list(df)

%timeit list(df.columns)
# 100000 loops, best of 3: 2.24 µs per loop

%timeit df.columns.tolist()
# 1000000 loops, best of 3: 1.77 µs per loop

How to clean up the disk space of Linux server

Sometimes, a service suddenly hangs and starts again but fails to start. A look, the original disk space is full, so, how to clean it. The introduction is as follows:
Df-h, this command is used to view the server space. The rendering after running is as follows:

As you can see, I have 8 grams left.

Du-h — Max-depth =1, this command is used to see the current directory, which file occupies the most space, the operation effect is as follows:

As you can see, the IOV directory takes up a lot of space, 20G.
In addition, du-sh *, this command is also used to see the size of each file and folder under the current directory. The operation effect is as follows:

As you can see, the IOV directory takes up a lot of space, 12G.
Enter ioV directory, repeatedly execute the above view command, follow up all the way, find each directory takes up more space of the file, useless can be deleted.

As you can see, this nohup.out log file takes up a lot of space (1.9g). Now leave it empty.
The command can be used: cp /dev/null nohup.out. After clearing, check again, the occupancy is reduced (696K) as expected.

So, how do you clean up if the nohup.out file isn’t taking up space?

Very simple, just use the normal delete command.
Delete command: RM [options] file or directory

Option description:
-F-force ignores files that do not exist and forces deletion without prompting
-i– Interactive for interactive deletion
-r |-r –recursive deletes all directories and files under a listed directory
-v — Verbose verbose displays details of the steps performed
Command instance:
1. Delete the a.T.Xt file
Rm – rf a.t xt
2. Delete the Mplogs directory
rm -rf mplogs

Here we use example 2 to delete, and the effect is as follows:

Now that I’ve cleaned up a little bit, I go back to the root directory, and I’ve reduced the footprint.

Implementation of Python switch / case statements

It struck me as odd that, unlike languages such as Java, C\C++, Switch /case statements are not available in Python. We can implement the switch/ Case statement in several ways.
Use the if… Elif… Elif… Else to realize the switch/case
You can use if… Elif… elif.. An else sequence instead of a switch/case statement is the easiest way to think about it. However, with more branches and frequent modifications, this alternative is not easy to debug and maintain.
Use a dictionary to implement switch/ Case
A dictionary can be used to implement switch/ Case in a way that is easy to maintain and reduces the amount of code. The following is a switch/ Case implementation using a dictionary simulation:


def num_to_string(num):
    numbers = {
        0 : "zero",
        1 : "one",
        2 : "two",
        3 : "three"
    }

    return numbers.get(num, None)

if __name__ == "__main__":
    print num_to_string(2)
    print num_to_string(5)

The execution results are as follows:

two
None

The Python dictionary can also include functions or Lambda expressions, as follows:

def success(msg):
    print msg

def debug(msg):
    print msg

def error(msg):
    print msg

def warning(msg):
    print msg

def other(msg):
    print msg

def notify_result(num, msg):
    numbers = {
        0 : success,
        1 : debug,
        2 : warning,
        3 : error
    }

    method = numbers.get(num, other)
    if method:
        method(msg)

if __name__ == "__main__":
    notify_result(0, "success")
    notify_result(1, "debug")
    notify_result(2, "warning")
    notify_result(3, "error")
    notify_result(4, "other")

The execution results are as follows:

success
debug
warning
error
other

The above example shows that the Switch /case statement can be fully implemented with a Python dictionary, and is flexible enough. is especially handy at run time to add or remove a switch/case option from a dictionary.
Switch/Case can be implemented in a class using scheduling methods
If you are not sure which method to use in a class, you can use a scheduling method at run time to determine. The code is as follows:

class switch_case(object):

    def case_to_function(self, case):
        fun_name = "case_fun_" + str(case)
        method = getattr(self, fun_name, self.case_fun_other)
        return method

    def case_fun_1(self, msg):
        print msg

    def case_fun_2(self, msg):
        print msg

    def case_fun_other(self, msg):
        print msg


if __name__ == "__main__":
    cls = switch_case()
    cls.case_to_function(1)("case_fun_1")
    cls.case_to_function(2)("case_fun_2")
    cls.case_to_function(3)("case_fun_other")

The execution results are as follows:

case_fun_1
case_fun_2
case_fun_other

conclusion
Personally, using a dictionary to implement the switch/case is the most flexible, but it is also difficult to understand.