Tag Archives: ProgrammerAH

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).

ASP.NET How to deal with “unexpected character” when writing code

Compiler error message: CS1056: Handling of unexpected characters

error generated:

An “unexpected character” error occurred in C# code while compiling an ASP. NET 4.0 website using VS2010.

does not use UTF-8 format for display and save, the compiler can not correctly recognize such characters, resulting in compilation error.

:

set the file open mode of VS 2010, make it in view of the error file using utf-8 format to open. The specific operation is as follows:

1) In Solution Explorer, select the file you want to open

2) Right mouse button pops up the menu, select “Open mode”, and use “Charp editor with encoding function” to open it. As shown in the figure below:

Instead, select the following in the code:

then rebuild the solution, error elimination.

Matlab im show squeeze

clc, clear
firstns = imread(‘Noisy_image1.jpg’);
% [M, N,L,P] = size(firstns)
% Ns = zeros(8,M,N,L);
% b =size(Ns);
for i = 1:8

tempname = strcat('Noisy_image',num2str(i),'.jpg');
Ns(i,:,:,:) = imread(tempname);

% N = imread(tempname);
% imshow (Ns (I, : 😅)

% end imge = squeeze (Ns (1, :, : 😅);
imshow(imge);
imshow(imge);
imshow(imge);
imshow(imge);

Mobile app development: installation and configuration of react native

Mobile APP development: React Native installation and configuration

Node (version 12 above)
K (version 1.8)
y>(NPM install -g Yarn)
Android>dio (update)
Android SDK <>> Use stable scientif>eb tools
Node (version 12 or higher)

1. Double-click to run
. Enter node-verson on the console to see the current version
JDK (version 1.8)
(1.9 and higher is not currently supported. Note that 1.8 is also officially called 8).
JDK download https://www.oracle.com/java/technologies/javase-downloads.html
configuration JDK environment variables:
1, enter the system environment variables, a new environment variable, added to the Path.
2, enter the console, enter Java and javac respectively, to determine whether the installation is successful.
Android Studio (Update)

Update it to the latest by selecting the Updata update in Configure.
After the update:
select the “Custom” option in the installation screen and make sure the following items are selected:

Android SDK Platform
droid Virtual Device
T>click “Next” to install the selected component.
Android SDK
In SDK Manager, select the “SDK Platforms” TAB, and then check “Show Package Details” in the lower right corner. Expand the Android 10 (Q) option and make sure the following components are checked (again you must have a stable agent or you may not see the screen) :
Android SDK Platform 29
Intel x86 Atom_64 System Image (the official simulator Image file, use unofficial simulator does not need to install this component
then click on the “SDK Tools” TAB, the same hook in the lower right corner of “Show Package Details”. Expand the “Android SDK Build-Tools” option and make sure the React Native required version 29.0.2 is selected. You can install multiple other versions at the same time.
Then, again in the “SDK Tools” TAB, click “NDK (Side by Side)”, also check “Show Package Details” in the lower right corner, and select version 20.1.5948944 to install.
Finally, click “Apply” to download and install the components.
(For some reasons, there may not be an NDK (Side by Side). If there is no NDK, click to continue.)
Configure the Android_Home environment variable
to open the control panel ->; Systems and Security -> System – & gt; Advanced System Settings ->; Advanced – & gt; The environment variable, select the PATH variable, and then click Edit. Click New and add these tools directory paths: platform-tools, emulator, tools, tools/bin
%ANDROID_HOME%\platform-tools
%ANDROID_HOME%\emulator
%ANDROID_HOME%\tools
%ANDROID_HOME%\tools\bin

Pychar console error: xmlrpc.client.Fault : Fault 0: ‘ java.lang.NullPointerException

I just opened the PyCharm console and received an error:

/usr/bin/python3.5 /mnt/hgfs/vm_share/pycharm-2018.2.4/helpers/pydev/pydevconsole.py 37963 43001
import sys; print('Python %s on %s' % (sys.version, sys.platform))
sys.path.extend(['/home/wangjinyu/work1/work_practice'])
PyDev console: starting.
Python 3.5.2 (default, Nov 12 2018, 13:43:14) 
[GCC 5.4.0 20160609] on linux
Process (4857) start...
I (4857) just created a child process (4875).
I am child process (4875) and my parent is 4857.
Traceback (most recent call last):
  File "/usr/lib/python3.5/socketserver.py", line 681, in __init__
    self.handle()
  File "/usr/lib/python3.5/http/server.py", line 422, in handle
    self.handle_one_request()
  File "/usr/lib/python3.5/http/server.py", line 411, in handle_one_request
    self.wfile.flush() #actually send the response if not already done.
  File "/usr/lib/python3.5/socket.py", line 593, in write
    return self._sock.send(b)
BrokenPipeError: [Errno 32] Broken pipe
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/lib/python3.5/socketserver.py", line 313, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/usr/lib/python3.5/socketserver.py", line 341, in process_request
    self.finish_request(request, client_address)
  File "/usr/lib/python3.5/socketserver.py", line 354, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python3.5/socketserver.py", line 683, in __init__
    self.finish()
  File "/usr/lib/python3.5/socketserver.py", line 742, in finish
    self.wfile.close()
  File "/usr/lib/python3.5/socket.py", line 593, in write
    return self._sock.send(b)
BrokenPipeError: [Errno 32] Broken pipe
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 55852)
----------------------------------------
Traceback (most recent call last):
  File "/mnt/hgfs/vm_share/pycharm-2018.2.4/helpers/pydev/_pydevd_bundle/pydevd_comm.py", line 309, in run
    self._on_run()
  File "/mnt/hgfs/vm_share/pycharm-2018.2.4/helpers/pydev/_pydevd_bundle/pydevd_comm.py", line 1526, in _on_run
    self.send_result(xml)
  File "/mnt/hgfs/vm_share/pycharm-2018.2.4/helpers/pydev/_pydevd_bundle/pydevd_comm.py", line 1548, in send_result
    self.frame_accessor.ReturnFullValue(self.seq, xml.getvalue())
  File "/usr/lib/python3.5/xmlrpc/client.py", line 1092, in __call__
    return self.__send(self.__name, args)
  File "/usr/lib/python3.5/xmlrpc/client.py", line 1432, in __request
    verbose=self.__verbose
  File "/usr/lib/python3.5/xmlrpc/client.py", line 1134, in request
    return self.single_request(host, handler, request_body, verbose)
  File "/usr/lib/python3.5/xmlrpc/client.py", line 1150, in single_request
    return self.parse_response(resp)
  File "/usr/lib/python3.5/xmlrpc/client.py", line 1322, in parse_response
    return u.close()
  File "/usr/lib/python3.5/xmlrpc/client.py", line 655, in close
    raise Fault(**self._stack[0])
xmlrpc.client.Fault: <Fault 0: 'java.lang.NullPointerException'>

Thread. py is the name of the module that I created. The name of Thread. py is in conflict with the name of the system.

Linux c running error killed

A program running on the server found the kill. /var/log/messages: /var/log/messages:

Aug 11 16:28:11 kernel: Out of memory: Kill process 3080 (forward) score 559 or sacrifice child
Aug 11 16:28:11 kernel: Killed process 3080, UID 0, (forward) total-vm:1429064kB, anon-rss:1130444kB, file-rss:136kB

Linux also has a memory OOM processing, unlike Android to kill the OOM process, Linux is the most memory use process.
when Linux to OOM, means that the memory of the whole system is insufficient, if you don’t kill the process, will lead to the collapse of the system. Each process has an oom_score parameter, such as an output of the oom_score with a PID of 988:

cat /proc/988/oom_score

OOM Killer kills the process with the highest current score when the system reports OOM Killer.

>
One is to increase the system memory,
The second is to optimize the process, so that it occupies less memory.
The oom_score_adj parameter can be used. This parameter will be counted into the oom_score and will prevent the process from being killed (not recommended).

Advanced parameter search of GitHub

GitHub’s advanced parameter search

    in:name example — “example” in:readme example — “example” in:readme — “example” in:description example — “example” stars:>; 1000 – star> 1000forks:> 1000 – fork> 1000pushed:> 2019-09-01 — Language: Java — Projects written in Java

Composer require — dev barryvdh / laravel ide helper error resolution

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - barryvdh/laravel-ide-helper[dev-master, v2.9.0] require illuminate/console ^8 -> found illuminate/console[v8.0.0, ..
., 8.x-dev] but it conflicts with another require.
    - barryvdh/laravel-ide-helper 2.9.x-dev is an alias of barryvdh/laravel-ide-helper dev-master and thus requires it to
be installed too.
    - Root composer.json requires barryvdh/laravel-ide-helper ^2.9 -> satisfiable by barryvdh/laravel-ide-helper[v2.9.0, 2
.9.x-dev (alias of dev-master)].


Installation failed, reverting ./composer.json and ./composer.lock to their original content.

Since PHP 8 is out, this support depends on the version, and I currently have Laravel 7 installed, so the default version of Laravel-id-helper is not supported, we will install the lower version

composer require --dev barryvdh/laravel-ide-helper 2.8