Author Archives: Robins

Yield usage in Python



The function of yield in the function is similar to return. The difference is that the function does not exit after yield returns the result each time, but returns the result

Each time the yield keyword is encountered, the corresponding result is returned, and the current running state of the function is retained, waiting for the next call. If

A function needs to execute an action repeatedly, and the result of each execution is needed. This scenario is very suitable for using yield.

The function containing yield becomes a generator, which is also an iterator. It supports getting the next value through the next method.

Basic use of yield:

def func():
    for i in range(0,3):
        yield i

f = func()
f.next()
f.next()


For the generator, when the function next is called, the value of the expression after yield of the generator will be obtained;

When the yield statement ends after the last loop, the generator will throw stopiteration exception;

In addition to the next function, the generator also supports the send function. This function can pass parameters to the generator.

def func(n):
    for i in range(0,n):
        val = yield i        
        print val

f = func(10)
f.next()
#f.send(None)
f.send(2)
f.send(10)
print f.next()

Android artifact xposed framework user guide

1 Introduction

Xposed is known as the most powerful artifact on Android. If you don’t know what xposed is, then you are really out. This blog will let bloggers take you to understand xposed.

(1) What is xposed?
Xposed is a framework. There are many modules on it. These modules all depend on xposed. The reason why xposed is the first artifact is that these modules can complete many incredible functions, such as modifying the wechat interface, automatically grabbing red packets module, self defining the text of the program, preventing wechat messages from withdrawing, and preventing the three hooligans of bat from calling each other Wake up, chain start, lock the screen automatically after the app to prevent background operation power consumption, there are many modification app or mobile data installed B module and so on.

(2) How does xposed work?
xposed The principle is to modify the key files of the system, and then when the app calls the system API, it first goes through xposed, and these xposed based modules can selectively do some “bad” things when the app calls these APIs, or modify the returned results, so that the effect of the app will change when it runs, but the app itself is not damaged, just when it calls the system API Wait, the performance of Android system has changed. This is hook, the technical term hook. So, to put it bluntly, xposed is a powerful hook framework.

Let’s have a professional explanation

By replacing / system / bin / APP_ The precess program controls the zygote process so that it loads a jar file of the xposed framework during the system startup XposedBridge.jar So as to complete the hijacking of zygote process and its Dalvik virtual machine, and allow the development

The video cannot be played because you have disabled the cookie

Today, I suddenly want to see “happy dramatist”, Google browser Click to play, the result is “because you disable the cookie, the video can’t play…” this situation…

It’s not a big problem either. I just found out where the cookie is after a round of setting. It’s still Baidu… So it’s this

In content settings

OK, I don’t have any problem. I just didn’t know what happened before. I went back to refresh the website and came out… It’s so funny. I don’t know if I can refresh the web page before. But at least we can find something that we hope we can use in the future.

XML tag has empty body less… (Ctrl+F1) Reports empty tag body. The validation works in XML / JSP

The activity of the Android manifest file has been warned several times. The first reaction is that you can’t remember to look it up online. Just wrap it or end it with a ‘/’.

On the Internet:

It appears to have worked by getting rid of the closing tags and replacing them with the self closing tags

<activity
    android:name="com.np.npvideoserver.UserConfig"
    android:configChanges="orientation|keyboard"></activity>

Change to

<activity
    android:name="com.np.npvideoserver.UserConfig"
    android:configChanges="orientation|keyboard">
</activity>

or

<activity
    android:name="com.np.npvideoserver.UserConfig"
    android:configChanges="orientation|keyboard"/>

 

Prompt “XXX is” when debugging real machine busy:Processing symbol Files “and” Xcode will continue when XXX is finished“

Original address: https://www.jianshu.com/p/fdbe7ec1ec44

 

Related articles

1. Xcode debugging device connection has been busy—- https://blog.csdn.net/sily_ 13/article/details/52698907

2、XXX is busy: Processing symbol files—- https://blog.csdn.net/lymm000/article/details/69484083

3、xcode will continue when iPhone is finished iPhone is busy:Processing symbol files—- https://blog.csdn.net/u014599371/article/details/79970486?utm_ source=blogxgwz1

4. Xcode real machine debugging appears “is busy: Processing symbol files”—- http://www.cocoachina.com/bbs/read.php?tid-1678685.html

5. Xcode real machine debugging appears “is busy: Processing symbol files”—- https://blog.csdn.net/joker_ wlk/article/details/52299007

6. When IOS Xcode debugging device is connected, there is always a prompt “iPhone name” is busy: Processing symbol files—- https://blog.csdn.net/csdn_ hhg/article/details/79770068

 

Before, I met the following prompt when testing the real apple mobile phone

 

Later, restart the phone, restart Xcode, and even restart the Mac. In a few minutes, you can debug the real machine. At that time, I didn’t think much about it. I thought it was really the CPU of the mobile phone that was busy with other things. Recently, when cleaning up the Mac computer, I found the real reason for this prompt: install something on a mobile phone. For example, the mobile phone system is 10.3.3. If the computer has not run the debugging app on the mobile phone of the 10.3.3 system before, some things in the mobile phone will be copied to the / users / zhangxicheng / library / Developer / Xcode / IOS devicesupport directory of the computer through USB. Basically, a system takes two to three gigabytes. It’s useless for us to do anything while copying files. After copying, you can debug the app. So just wait a few minutes.

In addition: when I cleaned up the Mac, I found that there are many things in the IOS devicesupport directory. I have about a dozen systems, which account for more than 40 gigabytes. I want to delete them, but I feel that I have to copy them next time I connect. It’s rather tangled.

Author: Xiaoxi IOS
link: https://www.jianshu.com/p/fdbe7ec1ec44
Source: Jianshu
the copyright of Jianshu belongs to the author. For any form of reprint, please contact the author for authorization and indicate the source.

[solved] runtimeerror: module compiled against API version 0xc but this version of numpy is 0xb

This article records the solutions for bloggers to report errors in Import torch in Python. Updated on March 20, 2019.

This error is due to the current version of numpy does not meet the requirements.

First, run on the terminal:

python
import numpy
numpy.version

View the current version of numpy. Run after

pip3 install –upgrade numpy

Just update the numpy version. If it’s python2, use PIP .

More, welcome to the planet discussion.

go :Multiple-value strconv.Atoi() (int, error) in single-value context

code

devicePositionType := strconv.Atoi(info[0]["device_position_type"].(string))

report errors

Multiple-value strconv.Atoi() (int, error) in single-value context

This is because the returned data has two parameters, and only one is defined in the code, so the code needs to add another parameter, which is generally defined as err

devicePositionType,err := strconv.Atoi(info[0]["device_position_type"].(string))

But I can’t use err. If I don’t use err, go will still report an error

Unused variable 'err'

So it needs to be written like this

devicePositionType,_ := strconv.Atoi(info[0]["device_position_type"].(string))

It means that I will not call it later, and I have defined two parameters and will not report an error

Null hypothesis

Summary of null hypothesis

Zero hypothesis, H0 is a generally accepted fact; it is contrary to the alternative hypothesis. Researchers are committed to rejecting, abolishing or refuting the null hypothesis. The researchers put forward an alternative hypothesis that they thought explained a phenomenon and then tried to reject the null hypothesis.

The famous zero hypothesis in history is that the earth is flat. Later scientists tried to prove that the hypothesis was wrong under this assumption which was generally considered correct in the early stage.

Accordingly, its alternative hypothesis is that the earth is round.

Why zero (null)

In this case, the word “null” means that researchers are trying to nullify such a generally accepted fact. This does not mean that the assumption itself is null! (the word should be called “nullifiable hypothesis” to reduce confusion).

Null means: nullifiable. Can, or allowed to be nullified

The short answer is that the null hypothesis is the research method needed as a scientist; it’s part of the scientific process. Science uses a series of processes to prove or disprove theories to ensure that no new hypothesis is flawed. Including null and void assumptions is a safeguard to ensure that your research is flawless. It is considered very bad by the scientific community not to include zero hypothesis in your research. If you are going to prove an alternative hypothesis without considering it, you are likely to let yourself fail. At least, your experiment may not be taken seriously.

give an example

Long ago, people believed that the world was flat.
Zero hypothesis H0: the world is flat.
Alternative hypothesis H1: the world is round.
Several scientists, including Copernicus, began to refute the null hypothesis. This eventually leads to the rejection of null hypothesis and the acceptance of alternative hypothesis. Most people accepted it! What would have happened if Copernicus had not refuted it but only proved a substitute? No one will listen to him. In order to change people’s minds, he must first prove that they are wrong.

How to put forward zero hypothesis

Example question: the researchers believe that patients with knee surgery would have a longer recovery period if they received physical therapy twice a week instead of three times a week. The average recovery time was 8.2 weeks.

Step 1: find out the hypothesis from the question. This assumption is usually hidden in the question, sometimes a statement of what you want to happen in the experiment. The assumption of the above question is “I expect an average recovery period of more than 8.2 weeks.”
Step 2: transform the hypothesis into mathematics. Remember that the average is sometimes written as μ.

H1:μ> 8.2

Subdivided into H1 (hypothesis): μ (mean) & gt; (greater than) 8.2

Step 3: explain what will happen if the assumption fails. If the recovery time does not exceed 8.2 weeks, there are only two possibilities, that is, the recovery time is equal to or less than 8.2 weeks.

H0:μ≤8.2

It is decomposed again to H0 (null hypothesis): μ (mean value) ≤ (less than or equal to) 8.2

But what happens if researchers don’t know?

Sample question: researchers are studying the impact of aggressive exercise on patients undergoing knee surgery. Treatment is likely to shorten the recovery time, but it may also make the treatment worse. The average recovery time was 8.2 weeks.

Step 1: explain what happens if the experiment doesn’t make any difference. It’s a zero hypothesis – nothing will happen. In this experiment, if there was no response, the recovery time would remain at 8.2 weeks.

H0:μ= 8.2

That is, H0 (null hypothesis): μ (mean) = (equal to) 8.2

Step 2: find alternative hypotheses. The substitution hypothesis is opposite to the null hypothesis. In other words, what happens if our experiment does something?

H1:μ≠8.2

That is H1 (alternate hypothesis): μ (average) ≠ (not equal to) 8.2

This is how to state the null hypothesis!
https://www.statisticshowto.datasciencecentral.com/probability-and-statistics/null-hypothesis/

matplotlib 1.3.1 requires nose, which is not installed. matplotlib 1.3.1 requires tornado, which is

When installing tensorflow, execute the command

$ pip install https://storage.googleapis.com/tensorflow/mac/tensorflow-0.5.0-py2-none-any.whl

Reference:
1 http://www.tensorfly.cn/tfdoc/get_ started/os_ setup.html

The error is as follows:

Matplotlib 1.3.1 requirements nose, which is not installed.
Matplotlib 1.3.1 requirements tornado, which is not installed.
installing collected packages: numpy, six, tensorflow
found existing installation: numpy 1.8.0rc1
to solve the problem, the implementation is as follows:

  sudo easy_install nose
  sudo easy_install tornado

Android:Field can be converted to a local varible.

background

It’s been a while since Android studio was used to develop Android. Occasionally, as has a yellow highlight on some private variables field can be converted to a local variable . I still don’t want to see this yellow highlight for some obsessive-compulsive disorder. Baidu did not find any useful information, or Google search to find some answers.

analysis

The complete description of field can be converted to a local variable is (hand play only): field can be converted to a local variable :

This inspection searches for redundant class fields that can be replaced with local variables,if all local usages of a field are preceded by assignments to that field,the field can be removed and its usages replaced with local variables.

This means that it is detected that this variable can be replaced by a local variable. It is recommended to delete it and write it as a local variable.

Solution

Delete the sentence private XXX; and declare and instantiate it directly where it is used.
In Android studio for Mac , you can use the shortcut key Alt + enter to quickly convert local variables.

PS: you still need better English. In fact, you can understand it by reading the instructions. You don’t need to search in this way.