Author Archives: Robins

The difference between “?” and “?:” introduced by php7

Real knowledge comes from practice
The test code
Input test:

<?php
    $array = [
        'a' => 1,
        'b' => 2,
        'c' => [],
    ];

    $a = $array['c'] ?? 0;
    $b = $array['c'] ?: 0;
    $c = $array['d'] ?? 0;
    $d = $array['d'] ?: 0;
    $e = $array['c'] ? 1 : 0;
    $f = isset($array['c']) ? 1 : 0;
    $g = $array['d'] ? 1 : 0;
    $h = isset($array['d']['e']) ? 1 : 0;
    $i = !empty($array['c']) ? 1 : 0;
    $j = !empty($array['d']) ? 1 : 0;

    var_dump($a);
    var_dump($b);
    var_dump($c);
    var_dump($d);
    var_dump($e);
    var_dump($f);
    var_dump($g);
    var_dump($h);
    var_dump($i);
    var_dump($j);
                      1234567891011121314151617181920212223242526272829

Output results:

PHP Notice:  Undefined index: d in /home/fanyu/abc.php on line 11PHP Notice:  Undefined index: d in /home/fanyu/abc.php on line 14array(0) {}int(0)int(0)int(0)int(0)int(1)int(0)int(0)int(0)int(0)1234567891011121314

conclusion

    $a ??0 equals isset($a)?$a: 0. $a ?: 0 equals $a?$a: 0. Empty: determines if a variable is empty (null, false, 00, 0, ‘0’, “, etc., all return true). Isset: determines if a variable isset (false, 00, 0, ‘0’, “etc., which also returns true).

plt.show () and plt.imshow The difference between ()

Problem: Plt.imShow () cannot display image
Solution: Add: plt.show(), i.e

Plt.imShow (image) #image represents the image to be processed
plt.show()

How It Works: The plt.imShow () function is responsible for processing the image and displaying its format, while plt.show() displays the function processed by plt.imShow ().

Python modifies word document content and inserts pictures

The following code

#!/usr/bin/python
# coding:utf-8
import docx
def main():
    filepath = 'test.docx'
    filepath1 = 'wtest.docx'
    newdocx = docx.Document(filepath)
    table = newdocx.tables
    for oTable in table:
        rows_num = len(oTable.rows)
        columns_num = len(oTable.columns)
        cell = oTable.cell(3, 0)
        # cell.add_paragraph("a")
        cell.text = ""
        cell.paragraphs[-1].runs[0].add_picture('t1.jpg')
        print(rows_num)
        print(columns_num)
        newdocx.save(filepath1)
if __name__ == '__main__':
    main()

No power supply specified for net vdda / vssa in power rail configuration

No Power Supply Specified for NET VDDA/VSSA in Power Rail Configuration

Problems encountered:



Solution:

Add VDDA, VSSA to VCC/VDD in power management Settings.

The menu bar – & gt; Design-> Powe Rail Configuration-> Uncheck the box “Use default power rail connections” ->; Name-> VCC/VDD-> Move VDDA and VSSA into it.



Conclusion:

hope to help you

package golang.org/x/net/XXX: unrecognized import path “golang.org/x/net/xxx“…

bug:
package golang.org/x/net/websocket: unrecognized import path “golang.org/x/net/websocket”: https fetch: Get “https://golang.org/x/net/websocket?go-get=1”: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
Causes.
When you need to use the corresponding package, the automatic download error
Solution.
File->Settings->Go->Go Modules
Check Start Go Module Integration and enter GOPROXY=https://goproxy.io, apply it, then go to download again.

Windows git review reported an error. UnicodeDecodeError

Traceback (most recent call last):
File “c:\gary\software\tool\python\python38-32\lib\runpy. py”, line 193, in _run_module_as_main
return _run_code(code, main_globals, None,
File “c:\gary\software\tool\python\python38-32\lib\runpy. py”, line 86, in _run_code
exec(code, run_globals)
File “C:\Gary\software\Tool\Python\Python38-32\Scripts\git-review.exe\__main__. py”, line 9, in <module>
File “c:\gary\software\tool\python\python38-32\lib\site-packages\git_review\cmd. py”, line 1714, in main
_main()
File “c:\gary\software\tool\python\python38-32\lib\site-packages\git_review\cmd. py”, line 1587, in _main
check_remote(branch, remote, config[‘scheme’],
File “c:\gary\software\tool\python\python38-32\lib\site-packages\git_review\cmd. py”, line 781, in check_remote
has_color = check_color_support()
File “c:\gary\software\tool\python\python38-32\lib\site-packages\git_review\cmd. py”, line 696, in check_color_support
(status, output) = run_command_status(test_command)
File “c:\gary\software\tool\python\python38-32\lib\site-packages\git_review\cmd. py”, line 140, in run_command_status
(out, nothing) = p.communicate(stdin)
File “c:\gary\software\tool\python\python38-32\lib\subprocess. py”, line 1011, in communicate
stdout = self.stdout.read()
UnicodeDecodeError: ‘gbk’ codec can’t decode byte 0xa7 in position 21: illegal multibyte sequence

In the directory where python is installed, there is a file subprocess.py in Python38-32\Lib\ with encoding=NONE, change it to encoding=’utf-8′ and you can

Vue Error: command failed: npm install –loglevel error –registry=https://registry.npm.taobao.org

Use the vue – cli error creating project is reported as follows: the command failed: NPM install – loglevel error – registry=https://registry.npm.taobao.org – disturl=https://npm.taobao.org/dist
Summarizes the has the following solutions:
to ensure the vue – used in cli NPM, node and so on, the version. Then try the following methods:
1. NPM install chromedriver – chromedriver_cdnurl=http://cdn.npm.taobao.org/dist/chromedriver
2. NPM cache clean — force removal of NPM’s cache

C # generate data in DataGridView into XML file

Development environment: VS2019
code directly without more b words

  private void button1_Click(object sender, EventArgs e)
        {
           
            DataTable dt = GetDataGridView(dataGridView1);
            DataSet ds = new DataSet();
            ds.Tables.Add(dt);
            ds.WriteXml(File.OpenWrite(@"D:\emlout.xml"));
            MessageBox.Show("export xml file success", "note", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
        }

JS to determine whether the string contains a character

JS can use to determine whether a string contains another character
String method
1, the indexOf
IndexOf returns the position where the specified string was first found in that character. If it is not found, it returns -1
IndexOf takes two arguments. The first argument is the string to be searched and the second argument is the position to be retrieved

let str = 'abcde';
//For example, search from the third position of str 'a'
console.log(str.indexOf('a',2));// -1
console.log(str.indexOf('a'))// 0

2, lastIndexOf

LastIndexOf takes two arguments, the first is the string to be searched and the second is the position to be retrieved. The default is sting.length-1

let str = 'abcdea';
//For example, search from the third position of str 'a'
console.log(str.lastIndexOf('a',2));// 0
console.log(str.lastIndexOf('a'));// 5

3, includes
The includes() method determines whether a string contains the specified substring and returns true or false
Includes accepts two parameters, the first for the specified string and the second for the lookup location, which defaults to 0

let str = 'abcde';

console.log(str.includes('a'))//true
console.log(str.includes('a',1))//false

4, the match

g: Global search
: Ignoring case
I: The match method retrieving a specified value within a string, or finding a match of one or more regular expressions, returns null if not found (can also be used to query the number of occurrenches of a character in the string)

let str = 'abcdabcda';

console.log(str.match(/a/gi));//['a','a','a']
console.log(str.match(/z/gi));// null

5, the search
The seacrh method is used to retrieve the substring specified in the string, or to retrieve the substring that matches the regular expression, or to return -1 if none

let str = 'abcde';

console.log(str.search('a'));// 0

console.log(str.search(/A/i));//Use regular match to ignore case search Return 0

Regular expression RegExp objects
1. Test method
Retrieves the value specified in the string. Returns true or false.

let str = 'abcdef';

let reg = /A/i;
console.log(reg.test(str));// true

2. Exec method
Retrieves the value specified in the string. Returns the value found and determines its location.
Returns a matching value if there is one in the string, otherwise returns null.

let str = 'abcdef';

console.log(/a/.exec(str))// Return the matching object
console.log(/z/.exec(str))// null

Print regularly to activate the printer (for some printers that need to be activated to print)

Save the following code as prtxls.vbs, and then you can use it on the command line, such as printing a.xlsx under C drive with the command prtxls.vbs c:\a.xlsx
Dim objxls
On error resume next.
Set objxls = wscript getobject (” Excel. Application “)
If objxls = “” then.
Set objxls = wscript createobject (” Excel. Application”)
end If
the If Wscript.argument.count = 0 then
msgBox (” There are not enough arguments.”)
cript.quit
e>f
objxls.>books.open wscript.arguments(0),false
if objxls.wor>ks.count = 0 then
Wscript.quit
Else
objxls.workbooks(1).printout
objxls.quit
End if
wscript.quit


So that’s the code

prtxls.vbs c:\a.xlsx
: \a.xlsx
c:\a.xlsx
Note: A. Xlsx must add content, otherwise the printer will not print the content because it is empty.

Git prompts another git process sees to be running in this repository, e.g. an editor opened by

Another git process seems to be running in this repository, e.g. An editor is opened by ‘git commit’. Please make sure all processes are terminated then try again. a git process may have crashed in this repository earlier: remove the file manually to continue.

Another Git process appears to be running in this repository, such as the editor opened by ‘git commit’. Make sure all processes are terminated and try again. If it still fails, then a Git process may have crashed earlier in the repository: manually delete the file to continue.
If you have an editor with the “git commit” command on, close all git related processes and try again. If not, delete the file manually.
Windows for the process of synchronous mutually exclusive management, there is a resource lock mechanism. There must be a process to lock a resource, but because the process suddenly crashed, not in time to unlock, resulting in other processes can not access
We delete a mutex file on the line, into the workspace directory under the hidden file. Git, where the index.lock file deleted, the problem solved.