问:
How to pass Custom Authorization Header to my backend websocket service through WSO2 (API Manager)?
I am using a Websocket api in  WSO2. I need to pass custom header to my backend Websocket service.  I have found a documentation here
https://docs.wso2.com/display/AM210/Adding+Mediation+Extensions

but it's for rest api call not for Websocket. So how can i send custom header  to my backend Websocket service through WSO2.

答:
You can send a custom header to the Web Socket backend in the initial WebSocket handshake.
you can set it in the following format to the client handshake request.

```<code>websocket.custom.header.<required-header-name>
</code>```

Ex: If the expected header is X-JWT-Assertion, the header that should be sent is

```<code>websocket.custom.header.X-JWT-Assertion
</code>```

This feature support is added from API Manager v2.6.0

You could not use mediation sequences here since the rest of the communication is done with ws frames.

Adding more information.

Here is an example of a netty based web socket client which can be used to communicate with the WS API deployed in the API Manager. [1]

The authorization header is set in the Handshake as follows.

```<code>final WebSocketClientHandler handler = new WebSocketClientHandler(
                    WebSocketClientHandshakerFactory.newHandshaker(
                            uri, WebSocketVersion.V13, null, false, new DefaultHttpHeaders()
                    .add("Authorization", "Bearer e2238f3a-e43c-3f54-a05a-dd2e4bd4631f")));
</code>```

This Authorization header is to authenticate with API Manager. If you need to send a custom header, you can add another header by modifying the above example as follows.

```<code>DefaultHttpHeaders headers = new DefaultHttpHeaders();
headers.add("Authorization", "Bearer e2238f3a-e43c-3f54-a05a-dd2e4bd4631f");
headers.add("websocket.custom.header.X-WS-UserName", "bob");

final WebSocketClientHandler handler = new WebSocketClientHandler(
                    WebSocketClientHandshakerFactory.newHandshaker(
                            uri, WebSocketVersion.V13, null, false, headers));
</code>```

This header will be sent to the backend as,

```<code>X-WS-UserName : bob
</code>```

[1] https://docs.wso2.com/download/attachments/57748790/sample-ws-client.zip?version=2&modificationDate=1484568275000&api=v2

Body:
You can send a custom header to the Web Socket backend in the initial WebSocket handshake.
you can set it in the following format to the client handshake request.

websocket.custom.header.<required-header-name>

Ex: If the expected header is X-JWT-Assertion, the header that should be sent is

websocket.custom.header.X-JWT-Assertion

This feature support is added from API Manager v2.6.0

You could not use mediation sequences here since the rest of the communication is done with ws frames.

Adding more information.

Here is an example of a netty based web socket client which can be used to communicate with the WS API deployed in the API Manager. [1]

The authorization header is set in the Handshake as follows.

final WebSocketClientHandler handler = new WebSocketClientHandler(
                    WebSocketClientHandshakerFactory.newHandshaker(
                            uri, WebSocketVersion.V13, null, false, new DefaultHttpHeaders()
                    .add("Authorization", "Bearer e2238f3a-e43c-3f54-a05a-dd2e4bd4631f")));

This Authorization header is to authenticate with API Manager. If you need to send a custom header, you can add another header by modifying the above example as follows.

DefaultHttpHeaders headers = new DefaultHttpHeaders();
headers.add("Authorization", "Bearer e2238f3a-e43c-3f54-a05a-dd2e4bd4631f");
headers.add("websocket.custom.header.X-WS-UserName", "bob");

final WebSocketClientHandler handler = new WebSocketClientHandler(
                    WebSocketClientHandshakerFactory.newHandshaker(
                            uri, WebSocketVersion.V13, null, false, headers));

This header will be sent to the backend as,

X-WS-UserName : bob

[1] https://docs.wso2.com/download/attachments/57748790/sample-ws-client.zip?version=2&modificationDate=1484568275000&api=v2


来源: stackexchange

问:
I face below error when run the code : array assignment index out of range
I try to run this code but one error : array assignment index out of range</p>

```<code>def amir(st) :
    i = 0
    j = 0
    a = array.array('b')
    while i <= len(st)+1:
        a[i] = model[st[i]]
        i +=1
    return a[i]
</code>```

答:
First, it is out of range as when i takes value len(st) and len(st)+1, the index for st will be out of bound.

j is not used in your code.

You do not really need a loop, it seems that you just wantmodel[st[-1]].

```<code>def amir(st) :
    return model[st[-1]]
</code>```

ContentLicense: CC BY-SA 4.0

Body:
I try to run this code but one error : array assignment index out of range

def amir(st) :
    i = 0
    j = 0
    a = array.array('b')
    while i <= len(st)+1:
        a[i] = model[st[i]]
        i +=1
    return a[i]

Body:
First, it is out of range as when i takes value len(st) and len(st)+1, the index for st will be out of bound.

j is not used in your code.

You do not really need a loop, it seems that you just wantmodel[st[-1]].

def amir(st) :
    return model[st[-1]]


问:
Warning "Potential leak of an object allocated on line ..." when declaring a 2D array
Initially i declared a 2D array in this way:

```<code>subUrb = [[NSArray alloc] initWithObjects:
     [[NSArray alloc] initWithObjects:ALL_SUBURBS_LABEL, @"East",@"South", @"West", @"North", nil] ,
     [[NSArray alloc] initWithObjects:ALL_SUBURBS_LABEL, @"Kuala Lumpur SubUrb1", @"Kuala Lumpur SubUrb2", nil],
     [[NSArray alloc] initWithObjects:ALL_SUBURBS_LABEL, @"Jakarta SubUrb1",nil],
     nil];
</code>```

But when i try to 'analyze' the warnings of the project, i got three same type of issues in this chunk of code - "potential leak of an object allocated on line xxx"

I noticed that to get rid of it, i have to write sth like this:

```<code>subUrb =
    [[NSArray alloc] initWithObjects:
        [[[NSArray alloc] initWithObjects:ALL_SUBURBS_LABEL, @"East",@"South", @"West", @"North", nil] autorelease],
        [[[NSArray alloc] initWithObjects:ALL_SUBURBS_LABEL, @"Kuala Lumpur SubUrb1", @"Kuala Lumpur SubUrb2", nil] autorelease],
        [[[NSArray alloc] initWithObjects:ALL_SUBURBS_LABEL, @"Jakarta SubUrb1",nil] autorelease],
        nil];
</code>```

Then i will not get any analyze warnings. But i dun like this...it is not logical. This 2D array should never be released in my controller actually, the entire 2D array should be retained for the entire life time of the controller for a PickerView.

How should I declare the 2D array more elegantly?

答: Even if the array is needed through the entire life of the controller, you should release it on the controller's dealloc method, otherwise the objects will leak.</p>

ContentLicense: CC BY-SA 3.0

Body:
Initially i declared a 2D array in this way:

subUrb = [[NSArray alloc] initWithObjects:
     [[NSArray alloc] initWithObjects:ALL_SUBURBS_LABEL, @"East",@"South", @"West", @"North", nil] ,
     [[NSArray alloc] initWithObjects:ALL_SUBURBS_LABEL, @"Kuala Lumpur SubUrb1", @"Kuala Lumpur SubUrb2", nil],
     [[NSArray alloc] initWithObjects:ALL_SUBURBS_LABEL, @"Jakarta SubUrb1",nil],
     nil];

But when i try to 'analyze' the warnings of the project, i got three same type of issues in this chunk of code - "potential leak of an object allocated on line xxx"

I noticed that to get rid of it, i have to write sth like this:

subUrb =
    [[NSArray alloc] initWithObjects:
        [[[NSArray alloc] initWithObjects:ALL_SUBURBS_LABEL, @"East",@"South", @"West", @"North", nil] autorelease],
        [[[NSArray alloc] initWithObjects:ALL_SUBURBS_LABEL, @"Kuala Lumpur SubUrb1", @"Kuala Lumpur SubUrb2", nil] autorelease],
        [[[NSArray alloc] initWithObjects:ALL_SUBURBS_LABEL, @"Jakarta SubUrb1",nil] autorelease],
        nil];

Then i will not get any analyze warnings. But i dun like this...it is not logical. This 2D array should never be released in my controller actually, the entire 2D array should be retained for the entire life time of the controller for a PickerView.

How should I declare the 2D array more elegantly?


问:
PySpark: Not able to create SparkSession.(Java Gateway Error)
I have installed PySpark on windows and was having no problem till yesterday. I am using windows 10, PySpark version 2.3.3(Pre-build version), java version "1.8.0_201". Yesterday when I tried creating a spark session, I ran into below error.

```<code>Exception                                 Traceback (most recent call last)
<ipython-input-2-a9ef4ac1a07d> in <module>
----> 1 spark = SparkSession.builder.appName("Hello").master("local").getOrCreate()

C:\spark-2.3.3-bin-hadoop2.7\python\pyspark\sql\session.py in getOrCreate(self)
    171                     for key, value in self._options.items():
    172                         sparkConf.set(key, value)
--> 173                     sc = SparkContext.getOrCreate(sparkConf)
    174                     # This SparkContext may be an existing one.
    175                     for key, value in self._options.items():

C:\spark-2.3.3-bin-hadoop2.7\python\pyspark\context.py in getOrCreate(cls, conf)
    361         with SparkContext._lock:
    362             if SparkContext._active_spark_context is None:
--> 363                 SparkContext(conf=conf or SparkConf())
    364             return SparkContext._active_spark_context
    365

C:\spark-2.3.3-bin-hadoop2.7\python\pyspark\context.py in __init__(self, master, appName, sparkHome, pyFiles, environment, batchSize, serializer, conf, gateway, jsc, profiler_cls)
    127                     " note this option will be removed in Spark 3.0")
    128
--> 129         SparkContext._ensure_initialized(self, gateway=gateway, conf=conf)
    130         try:
    131             self._do_init(master, appName, sparkHome, pyFiles, environment, batchSize, serializer,

C:\spark-2.3.3-bin-hadoop2.7\python\pyspark\context.py in _ensure_initialized(cls, instance, gateway, conf)
    310         with SparkContext._lock:
    311             if not SparkContext._gateway:
--> 312                 SparkContext._gateway = gateway or launch_gateway(conf)
    313                 SparkContext._jvm = SparkContext._gateway.jvm
    314

C:\spark-2.3.3-bin-hadoop2.7\python\pyspark\java_gateway.py in launch_gateway(conf)
     44     :return: a JVM gateway
     45     """
---> 46     return _launch_gateway(conf)
     47
     48

C:\spark-2.3.3-bin-hadoop2.7\python\pyspark\java_gateway.py in _launch_gateway(conf, insecure)
    106
    107             if not os.path.isfile(conn_info_file):
--> 108                 raise Exception("Java gateway process exited before sending its port number")
    109
    110             with open(conn_info_file, "rb") as info:

Exception: Java gateway process exited before sending its port number
</code>```

I did check out the pyspark issues on github as well as stackoverflow answers realted to the same but the issue is not resolved.

I did try out the below methods:

1.) Tried uninstalling, installing and Changing the java installation directory. Currently, my java installation directory is C:/Java/ . Pyspark: Exception: Java gateway process exited before sending the driver its port number

2.) Tried setting PYSPARK_SUBMIT_ARGS, but of no help.

Please suggest me the possible resolutions.

答:
Please ensure that the JAVA_HOME environment variable should not contain any spaces otherwise it might throw the error , i removed the same and it worked like a charm for me .
Here is a short code to check your JAVA_HOME in python

import os
print(os.environ['JAVA_HOME'])

Body:
I have installed PySpark on windows and was having no problem till yesterday. I am using windows 10, PySpark version 2.3.3(Pre-build version), java version "1.8.0_201". Yesterday when I tried creating a spark session, I ran into below error.

Exception                                 Traceback (most recent call last)
<ipython-input-2-a9ef4ac1a07d> in <module>
----> 1 spark = SparkSession.builder.appName("Hello").master("local").getOrCreate()

C:\spark-2.3.3-bin-hadoop2.7\python\pyspark\sql\session.py in getOrCreate(self)
    171                     for key, value in self._options.items():
    172                         sparkConf.set(key, value)
--> 173                     sc = SparkContext.getOrCreate(sparkConf)
    174                     # This SparkContext may be an existing one.
    175                     for key, value in self._options.items():

C:\spark-2.3.3-bin-hadoop2.7\python\pyspark\context.py in getOrCreate(cls, conf)
    361         with SparkContext._lock:
    362             if SparkContext._active_spark_context is None:
--> 363                 SparkContext(conf=conf or SparkConf())
    364             return SparkContext._active_spark_context
    365

C:\spark-2.3.3-bin-hadoop2.7\python\pyspark\context.py in __init__(self, master, appName, sparkHome, pyFiles, environment, batchSize, serializer, conf, gateway, jsc, profiler_cls)
    127                     " note this option will be removed in Spark 3.0")
    128
--> 129         SparkContext._ensure_initialized(self, gateway=gateway, conf=conf)
    130         try:
    131             self._do_init(master, appName, sparkHome, pyFiles, environment, batchSize, serializer,

C:\spark-2.3.3-bin-hadoop2.7\python\pyspark\context.py in _ensure_initialized(cls, instance, gateway, conf)
    310         with SparkContext._lock:
    311             if not SparkContext._gateway:
--> 312                 SparkContext._gateway = gateway or launch_gateway(conf)
    313                 SparkContext._jvm = SparkContext._gateway.jvm
    314

C:\spark-2.3.3-bin-hadoop2.7\python\pyspark\java_gateway.py in launch_gateway(conf)
     44     :return: a JVM gateway
     45     """
---> 46     return _launch_gateway(conf)
     47
     48

C:\spark-2.3.3-bin-hadoop2.7\python\pyspark\java_gateway.py in _launch_gateway(conf, insecure)
    106
    107             if not os.path.isfile(conn_info_file):
--> 108                 raise Exception("Java gateway process exited before sending its port number")
    109
    110             with open(conn_info_file, "rb") as info:

Exception: Java gateway process exited before sending its port number

I did check out the pyspark issues on github as well as stackoverflow answers realted to the same but the issue is not resolved.

I did try out the below methods:

1.) Tried uninstalling, installing and Changing the java installation directory. Currently, my java installation directory is C:/Java/ . Pyspark: Exception: Java gateway process exited before sending the driver its port number

2.) Tried setting PYSPARK_SUBMIT_ARGS, but of no help.

Please suggest me the possible resolutions.


问:
How to Load Extend Number in sql Field Into Select Option Element by PHP?
I'm trying to load a number of fields in MySQL database to select option element as extending the number by PHP.

for example :
database field name = Numbers and value = 25
and in select option element should be : 1 to 25

to select one of those numbers.

and in other record :
field name = Numbers and value = 9
and in select option element should be : 1 to 9

How is it possible?
I'm confused.

答:
After 4 hours I finally did it.thanks all
sorry for my bad grammar typing, I`m Iranian and Love All the people of the world Especially Americans and Israelis and others. thanks again, this is my code that i wrote:

```<code><form method="POST" action="/Cart.php" >
<input type="hidden" id="id_pre_List_For_Change_Count" name="id_pre_List_For_Change_Count" value = "<?php echo $row'id_PreList'];?>">
<input type="hidden" id="Count_Filed" name="Count_Filed" value = "<?php echo $row['CurrentCoundAdded'];?>">

<select  id="count_Select_Box" name="count_Select_Box"onchange="this.form.submit();" >
<option selected="selected">
<?php echo $row['CountMany']; ?>
</option>
<?php
for($iz=1; $iz< $row['CurrentCoundAdded']+1; $iz++) {  ?>
<option value=<?php echo $iz ?> > <?php echo $iz ?></option>
<?php } ?>
</select>
</form>
</code>```

Body:
After 4 hours I finally did it.thanks all
sorry for my bad grammar typing, I`m Iranian and Love All the people of the world Especially Americans and Israelis and others. thanks again, this is my code that i wrote:

<form method="POST" action="/Cart.php" >
<input type="hidden" id="id_pre_List_For_Change_Count" name="id_pre_List_For_Change_Count" value = "<?php echo $row'id_PreList'];?>">
<input type="hidden" id="Count_Filed" name="Count_Filed" value = "<?php echo $row['CurrentCoundAdded'];?>">

<select  id="count_Select_Box" name="count_Select_Box"onchange="this.form.submit();" >
<option selected="selected">
<?php echo $row['CountMany']; ?>
</option>
<?php
for($iz=1; $iz< $row['CurrentCoundAdded']+1; $iz++) {  ?>
<option value=<?php echo $iz ?> > <?php echo $iz ?></option>
<?php } ?>
</select>
</form>


问:
I'm trying to display an image from my database, but the image wont populate the src of the img html attribute
I have an image saved to a database by converting to a byte array to a string then i am trying to remake the image on the view. But I wanted to make it for if the image was null(no image upload) that they will get a default "no image" image. But it seems when i try to make an if statement within my view with razor. The img src is not able to find the var in the if statement. The reason i need it to fill the src on the img outside of the if statement is because when i submit the form i need it to send the img data back to the action in the controller to reconvert it and save it on the database.

I trying a view different ways to fix it, the best i can do it make scripts inside my if statement. but it still will not connect to my img src.

```<code>    <!--Remaking the image from a stromg to a char
    array to a byte array to a imagefrom the
    database to the original image-->
    @if (Model.ImagePath != null)
    {

        char[] imageChars = Model.ImagePath.ToCharArray();
        byte[] imageBytes = imageChars.Select(b => (byte)b).ToArray();
        var base64 = Convert.ToBase64String(imageBytes);
        var imgSrc = String.Format("data:image/gif;base64,{0}", base64);
        <script>
            var img = getElementById("ImagePath").src;
            img.src = "@imgSrc";
        </script>
    }
    else
    {
        <script>
            var img = getElementById("ImagePath");
            img.src = "~/Content/no-image-icon.jpg";
            getElementById("ImagePath").width = "100";
            getElementById("ImagePath").height = "100";
        </script>
    }
    <img id="ImagePath" alt=""/>
</code>```

when i inspect the page the script has the image converted back into the right format it just wont send it to the img src.

答:
You have:

```

<p>That looks like it is setting img.src.src, which doesn't make sense. That should probably be this, correct? : </p>

<pre class="lang-html prettyprint-override"><code><script>
    var img = getElementById("ImagePath");
    img.src = "@imgSrc";
</script>
</code>```

And you could also make sure to remove all line breaks:

```

Also, as noted by Divya, your image element should come before your script tags, otherwise when you have getElementById("ImagePath");, it won't be able to find that element, since it has not loaded yet.

Body:
I have an image saved to a database by converting to a byte array to a string then i am trying to remake the image on the view. But I wanted to make it for if the image was null(no image upload) that they will get a default "no image" image. But it seems when i try to make an if statement within my view with razor. The img src is not able to find the var in the if statement. The reason i need it to fill the src on the img outside of the if statement is because when i submit the form i need it to send the img data back to the action in the controller to reconvert it and save it on the database.

I trying a view different ways to fix it, the best i can do it make scripts inside my if statement. but it still will not connect to my img src.

    @if (Model.ImagePath != null)
    {

        char[] imageChars = Model.ImagePath.ToCharArray();
        byte[] imageBytes = imageChars.Select(b => (byte)b).ToArray();
        var base64 = Convert.ToBase64String(imageBytes);
        var imgSrc = String.Format("data:image/gif;base64,{0}", base64);

    }
    else
    {

    }

when i inspect the page the script has the image converted back into the right format it just wont send it to the img src.

Body:
You have:

<script>
    var img = getElementById("ImagePath").src;
    img.src = "@imgSrc";
</script>

That looks like it is setting img.src.src, which doesn't make sense. That should probably be this, correct? :

<script>
    var img = getElementById("ImagePath");
    img.src = "@imgSrc";
</script>

And you could also make sure to remove all line breaks:

<script>
    var img = getElementById("ImagePath");
    var imgSrc = "@imgSrc";
    img.src = imgSrc.replace(/[\r|\n]/gm,'');
</script>

Also, as noted by Divya, your image element should come before your script tags, otherwise when you have getElementById("ImagePath");, it won't be able to find that element, since it has not loaded yet.


问:
bs4 can't recognize encoding python3
I am trying to scrape a few pages using Python3 for the first time. I have used Python2 many times with bs4 without any trouble, but I can't seem to be able to switch to python3, as I am always getting encoding errors.

For example, I am trying to scrape https://www.pgatour.com/webcom/tournaments/the-bahamas-great-exuma-classic/leaderboard.html

I have searched through a few threads here that have similar questions, without success.

Here is my code:

```<code>r = requests.get('https://www.pgatour.com/webcom/tournaments/the-bahamas-great-exuma-classic/leaderboard.html')
r.encoding = r.apparent_encoding
soup = bs.BeautifulSoup(r.text,'html5lib')
print(soup)
</code>```

I get the following error:

```<code>UnicodeEncodeError: 'ascii' codec can't encode character '\xd7' in position 28935: ordinal not in range(128)
</code>```

I also tried to change r.encoding = r.apparent_encoding to r.encoding = "utf-8", getting the same error.

答:
You can change the encoding as follows. This should fix your error.</p>

```<code>r = requests.get("https://s3.amazonaws.com/codecademy-content/courses/beautifulsoup/cacao/index.html")
print(r.encoding)

soup = BS(r.content, 'html.parser').encode('utf-8')

print(soup)
</code>```

Title: bs4 can't recognize encoding python3

Body:
I am trying to scrape a few pages using Python3 for the first time. I have used Python2 many times with bs4 without any trouble, but I can't seem to be able to switch to python3, as I am always getting encoding errors.

For example, I am trying to scrape https://www.pgatour.com/webcom/tournaments/the-bahamas-great-exuma-classic/leaderboard.html

I have searched through a few threads here that have similar questions, without success.

Here is my code:

r = requests.get('https://www.pgatour.com/webcom/tournaments/the-bahamas-great-exuma-classic/leaderboard.html')
r.encoding = r.apparent_encoding
soup = bs.BeautifulSoup(r.text,'html5lib')
print(soup)

I get the following error:

UnicodeEncodeError: 'ascii' codec can't encode character '\xd7' in position 28935: ordinal not in range(128)

I also tried to change r.encoding = r.apparent_encoding to r.encoding = "utf-8", getting the same error.

Body:
You can change the encoding as follows. This should fix your error.

r = requests.get("https://s3.amazonaws.com/codecademy-content/courses/beautifulsoup/cacao/index.html")
print(r.encoding)

soup = BS(r.content, 'html.parser').encode('utf-8')

print(soup)


问:
SQL query MAX() function
```<code>select ProductID,ProductName,QuantityPerUnit
from Products
where Products.UnitPrice=Max(UnitPrice)
</code>```

What is wrong in this query?

I had tried 'having' in place of 'where' tag.

```<code>select ProductID,ProductName,QuantityPerUnit
from Products
having Products.UnitPrice=Max(UnitPrice)
</code>```

it must produce result with max unit price,

```<code>ProductID   ProductName     QuantityPerUnit
38          Côte de Blaye   12 - 75 cl bottles
</code>```

答:
can use HAVING clause</p>

```<code>SELECT ProductID, ProductName, QuantityPerUnit FROM Products
     GROUP BY ProductID, ProductName, QuantityPerUnit
     HAVING UnitPrice = MAX(UnitPrice)
</code>```

Title: SQL query MAX() function

Body:
select ProductID,ProductName,QuantityPerUnit
from Products
where Products.UnitPrice=Max(UnitPrice)

What is wrong in this query?

I had tried 'having' in place of 'where' tag.

select ProductID,ProductName,QuantityPerUnit
from Products
having Products.UnitPrice=Max(UnitPrice)

it must produce result with max unit price,

ProductID   ProductName     QuantityPerUnit
38          Côte de Blaye   12 - 75 cl bottles

Body:
can use HAVING clause

SELECT ProductID, ProductName, QuantityPerUnit FROM Products
     GROUP BY ProductID, ProductName, QuantityPerUnit
     HAVING UnitPrice = MAX(UnitPrice)


问:
Question about functions being called from other files - Javascript
I am looking for some help understanding something on a project I am working on. I have written some code that is functioning, though I am not sure why.

In a Node.js server, in /public/js there are two scripts. One (file1.js) has a function func(). file2.js, in the same directory, calls func() successfully. There is no module.exporting or requireing anywhere, yet the two files work together. They are both referenced in the index.ejs file, however. Is this where they become able to communicate?

```<code>//file1.js
function func() {
    console.log("foo")
}
</code>```

```<code>//file2.js

func()
</code>```

```<code>//index.ejs
...
<script src="public/js/file1.js"></script>
<script src="public/js/file2.js"></script>
...
</code>```

I've spent all day reading and cannot find anything on this topic.

答:
You must understand how the global space behaves in Javascript.

This Code:

```<code><script src="public/js/file1.js"></script>
<script src="public/js/file2.js"></script>
</code>```

Is the same as this:

```<code><script>
    //file1.js
    function func() {
        console.log("foo");
    }

    func();
</script>
</code>```

Because soon as file1.js is loaded, everything that is defined inside of it, becomes available anywhere in that page from where it was included.

Since file2.js uses contents of file1.js, it will work because func is available to be used anywhere below file1.js inclusion.

Body:
I am looking for some help understanding something on a project I am working on. I have written some code that is functioning, though I am not sure why.

In a Node.js server, in /public/js there are two scripts. One (file1.js) has a function func(). file2.js, in the same directory, calls func() successfully. There is no module.exporting or requireing anywhere, yet the two files work together. They are both referenced in the index.ejs file, however. Is this where they become able to communicate?

//file1.js
function func() {
    console.log("foo")
}

//file2.js

func()

//index.ejs
...

...

I've spent all day reading and cannot find anything on this topic.

Body:
You must understand how the global space behaves in Javascript.

This Code:

<script src="public/js/file1.js"></script>
<script src="public/js/file2.js"></script>

Is the same as this:

<script>
    //file1.js
    function func() {
        console.log("foo");
    }

    func();
</script>

Because soon as file1.js is loaded, everything that is defined inside of it, becomes available anywhere in that page from where it was included.

Since file2.js uses contents of file1.js, it will work because func is available to be used anywhere below file1.js inclusion.


问:
Angular ngfor set empty grid if condition matches
I'm looping an array which it's length could change on a three column row ( on desktop view.

html

```<code><div  class="row" >
  <div *ngFor="let indicator of fiveElements; let index = index"
    class="col-12 col-sm-6 col-md-6 col-lg-4 col-xl-4 pb-4 pl-3 pr-3 indicatorContainer">
    <div>{{index}}</div>
  </div>
</div>
</code>```

ts

```<code>export class AppComponent  {
fiveElements = [1,2,3,4,5]

}
</code>```

I would that when the array length is equal to 4 the third column is empty

Here's a schema to explain

Here's a demo

答:
<s>If I understood your question right - I would do it like this:

```<code><div class="row">
    <div *ngFor="let indicator of fourElements; let index = index" class="col-12 col-sm-6 col-md-6 col-lg-4 col-xl-4 pb-4 pl-3 pr-3 indicatorContainer">
        <div *ngIf="index !== 3 && fourElements.length === 4">{{index}}</div>
        <!--- third column should get empty -->
    </div>
</div>
</code>```

</s>

Thanks for clarification - now I know what you  want :)
You can achieve this by using the longhand syntax for ngFor:

```<code><div class="row">
        <ng-template ngFor let-indicator [ngForOf]="fourElements" let-index="index">
            <div *ngIf="index === 2 && fourElements.length === 4" class="col-12 col-sm-6 col-md-6 col-lg-4 col-xl-4 pb-4 pl-3 pr-3 indicatorContainer">
            </div>
            <div class="col-12 col-sm-6 col-md-6 col-lg-4 col-xl-4 pb-4 pl-3 pr-3 indicatorContainer">
                <div>{{index+1}}</div>
            </div>
        </ng-template>
    </div>
</code>```

Body:
I'm looping an array which it's length could change on a three column row ( on desktop view.

html

{{index}}

ts

export class AppComponent  {
fiveElements = [1,2,3,4,5]

}

I would that when the array length is equal to 4 the third column is empty

Here's a schema to explain

Here's a demo

Body:
<s>If I understood your question right - I would do it like this:

<div class="row">
    <div *ngFor="let indicator of fourElements; let index = index" class="col-12 col-sm-6 col-md-6 col-lg-4 col-xl-4 pb-4 pl-3 pr-3 indicatorContainer">
        <div *ngIf="index !== 3 && fourElements.length === 4">{{index}}</div>
        <!--- third column should get empty -->
    </div>
</div>

</s>

Thanks for clarification - now I know what you  want :)
You can achieve this by using the longhand syntax for ngFor:

<div class="row">
        <ng-template ngFor let-indicator [ngForOf]="fourElements" let-index="index">
            <div *ngIf="index === 2 && fourElements.length === 4" class="col-12 col-sm-6 col-md-6 col-lg-4 col-xl-4 pb-4 pl-3 pr-3 indicatorContainer">
            </div>
            <div class="col-12 col-sm-6 col-md-6 col-lg-4 col-xl-4 pb-4 pl-3 pr-3 indicatorContainer">
                <div>{{index+1}}</div>
            </div>
        </ng-template>
    </div>


问:
RxJs - Jasmine marbles forkJoin operator test
Here is forkJoin operator jasmine marble test:

```<code>it('test1', () => {

 const a = cold('---a|', { a: 1 });
 const b = cold('---b|', { b: 2 });

 const observable = forkJoin(
   a,
   b
 );

 const expected = cold('---21');
 expect(observable).toBeObservable(expected);
});
</code>```

The test produces the following errors:

```<code>Expected $[0].frame = 40 to equal 30.
Expected $[0].notification.value = [ 1, 2 ] to equal '2'.
Expected $[1].frame = 40 to equal 50.
Expected $[1].notification.kind = 'C' to equal 'N'.
Expected $[1].notification.value = undefined to equal '1'.
Expected $[1].notification.hasValue = false to equal true.
</code>```

Could anyone tell me what I am doing wrong?

答:
First ---21 will wait three frames, then emit '2' and then emit '1.  Fork join is not a merge it will emit once, and it will emit [1, 2].

Alphanumeric marbles advance one frame when they emit.  So both a and b will complete at frame 4.  The forkJoin will then resolve emit.  The forkJoin will then immediately complete (also at frame 4).

So the errors you are getting:

Expected $[0].frame = 40 to equal 30. The first item emitted from the fork-join is at time 4 (because a and b complete at time 4) not at time 3.

Expected $[0].notification.value = [ 1, 2 ] to equal '2'. The value emitted is [1, 2] and not '2' as described above.

```<code>Expected $[1].frame = 40 to equal 50.
Expected $[1].notification.kind = 'C' to equal 'N'.
Expected $[1].notification.value = undefined to equal '1'.
Expected $[1].notification.hasValue = false to equal true.
</code>```

You are expecting a '1' at time 5.  It is getting a complete at time 4.

So you probably want...

```<code>const expected = cold('----(a|)', { a: [1, 2] });
expect(observable).toBeObservable(expected);
</code>```

Body:
Here is forkJoin operator jasmine marble test:

it('test1', () => {

 const a = cold('---a|', { a: 1 });
 const b = cold('---b|', { b: 2 });

 const observable = forkJoin(
   a,
   b
 );

 const expected = cold('---21');
 expect(observable).toBeObservable(expected);
});

The test produces the following errors:

Expected $[0].frame = 40 to equal 30.
Expected $[0].notification.value = [ 1, 2 ] to equal '2'.
Expected $[1].frame = 40 to equal 50.
Expected $[1].notification.kind = 'C' to equal 'N'.
Expected $[1].notification.value = undefined to equal '1'.
Expected $[1].notification.hasValue = false to equal true.

Could anyone tell me what I am doing wrong?

Body:
First ---21 will wait three frames, then emit '2' and then emit '1.  Fork join is not a merge it will emit once, and it will emit [1, 2].

Alphanumeric marbles advance one frame when they emit.  So both a and b will complete at frame 4.  The forkJoin will then resolve emit.  The forkJoin will then immediately complete (also at frame 4).

So the errors you are getting:

Expected $[0].frame = 40 to equal 30. The first item emitted from the fork-join is at time 4 (because a and b complete at time 4) not at time 3.

Expected $[0].notification.value = [ 1, 2 ] to equal '2'. The value emitted is [1, 2] and not '2' as described above.

Expected $[1].frame = 40 to equal 50.
Expected $[1].notification.kind = 'C' to equal 'N'.
Expected $[1].notification.value = undefined to equal '1'.
Expected $[1].notification.hasValue = false to equal true.

You are expecting a '1' at time 5.  It is getting a complete at time 4.

So you probably want...

const expected = cold('----(a|)', { a: [1, 2] });
expect(observable).toBeObservable(expected);


问:
How to get a Firestore document size?
From Firestore docs, we get that the maximum size for a Firestore document is:

Maximum size for a document 1 MiB (1,048,576 bytes)

QUESTION

How can I know the current size of a single doc, to check if I'm approaching
that 1mb limit?

Example:

```<code>var docRef = db.collection("cities").doc("SF");

docRef.get().then(function(doc) {
    if (doc.exists) {
        console.log("Document data:", doc.data());
        // IS THERE A PROPERTY THAT CAN DISPLAY THE DOCUMENT FILE SIZE?
    } else {
        // doc.data() will be undefined in this case
        console.log("No such document!");
    }
}).catch(function(error) {
    console.log("Error getting document:", error);
});
</code>```

答:
The calculations used to compute the size of a document is fully documented here.  There is a lot of text there, so please navigate there to read it.  It's not worthwhile to copy all that text here.

If you're having to manually compute the size of a document as it grows, my opinion is that you're probably not modeling your data scalably.  If you have lists of data that can grow unbounded, you probably shouldn't be using a list field, and instead put that data in documents in a new collection or subcollection.  There are some exceptions to this rule, but generally speaking, you should not have to worry about computing the size of a document in your client code.

Title: How to get a Firestore document size?

Body:
From Firestore docs, we get that the maximum size for a Firestore document is:

Maximum size for a document 1 MiB (1,048,576 bytes)

QUESTION

How can I know the current size of a single doc, to check if I'm approaching
that 1mb limit?

Example:

var docRef = db.collection("cities").doc("SF");

docRef.get().then(function(doc) {
    if (doc.exists) {
        console.log("Document data:", doc.data());
        // IS THERE A PROPERTY THAT CAN DISPLAY THE DOCUMENT FILE SIZE?
    } else {
        // doc.data() will be undefined in this case
        console.log("No such document!");
    }
}).catch(function(error) {
    console.log("Error getting document:", error);
});


问:
Looking for some nice & easy html 5 3d engine, similar to papervision3d for flash
I wan't to do some experimens with html5 and 3d and looking for some nice 3d engine. Any tips? </p>

答: Try to look at three.js or CubicVR.js.</p>

Body: Try to look at three.js or CubicVR.js.


问:
How to filter number and string in object array
i want to filter employee details.. in that i have select option containing both number and string... i can filter string in the object but cant make it number... please guide me</p>

```<code>        <select id="endDate" onchange="sortEDate()">
            <option value="All Years">All Years</option>
            <option value="Past Years">Past Years</option>
            <option value="Present">Present</option>
        </select>
        <p id="demo1"></p>
</code>```

```<code>const employees = [
    { firstname: "Dav", start: 2013, end: 2018 },
    { firstname: "Gemmy", start: 2016, end: "Present" }
]
function sortEDate() {
    const filterDate = [];
    let cDate = document.getElementById("endDate").value;
    employees.forEach(function(item, index, array) {
        if (item.end === cDate) {
            filterDate.push(item);
        }
    });

    let fDate = "<table>";
    filterDate.forEach(function(filterDate) {
        fDate += "<tr>";
        fDate += "<td>" + filterDate.firstname + "</td>";
        fDate += "<td>" + filterDate.start + "</td>";
        fDate += "<td>" + filterDate.end + "</td>";
        fDate += "</tr>";
    });
    fDate += "</table>";
    document.getElementById("demo1").innerHTML = fDate;

    let allEducation = document.getElementById("endDate").value;
    if (allEducation === "All Years") {
        showEmployees();
    }
}
</code>```

答:
In the below, if block try using == instead of ===

```<code>if (item.end == cDate) {
    filterDate.push(item);
}
</code>```

Body:
i want to filter employee details.. in that i have select option containing both number and string... i can filter string in the object but cant make it number... please guide me

        <select id="endDate" onchange="sortEDate()">
            <option value="All Years">All Years</option>
            <option value="Past Years">Past Years</option>
            <option value="Present">Present</option>
        </select>

const employees = [
    { firstname: "Dav", start: 2013, end: 2018 },
    { firstname: "Gemmy", start: 2016, end: "Present" }
]
function sortEDate() {
    const filterDate = [];
    let cDate = document.getElementById("endDate").value;
    employees.forEach(function(item, index, array) {
        if (item.end === cDate) {
            filterDate.push(item);
        }
    });

    let fDate = "
";
    filterDate.forEach(function(filterDate) {
        fDate += "
";
        fDate += "" + filterDate.firstname + "	";
        fDate += "" + filterDate.start + "	";
        fDate += "" + filterDate.end + "	";
        fDate += "
";
    });
    fDate += "
";
    document.getElementById("demo1").innerHTML = fDate;

    let allEducation = document.getElementById("endDate").value;
    if (allEducation === "All Years") {
        showEmployees();
    }
}

Body:
In the below, if block try using == instead of ===

if (item.end == cDate) {
    filterDate.push(item);
}


问:
Linked List From Text File
I'm very new to pointers and linked lists but I'm trying to write a simple program that reads in data from a text file into a linked list. I'm having trouble with the input function. It looks like this:

```<code>DVDNode* CreateList(string fileName)
{
    ifstream inFile;
    inFile.open(fileName.c_str());

    DVDNode* head = NULL;
    DVDNode* dvdPtr;
    dvdPtr = new DVDNode;

    while(inFile && dvdPtr != NULL)
    {
        getline(inFile, dvdPtr -> title);
        getline(inFile, dvdPtr -> leadActor);
        getline(inFile, dvdPtr -> supportingActor);
        getline(inFile, dvdPtr -> genre);
        cin >> dvdPtr -> year;
        cin >> dvdPtr -> rating;
        getline(inFile, dvdPtr -> synopsis);

        dvdPtr -> next = head;
        head = dvdPtr;
        dvdPtr = new DVDNode;
    }

    delete dvdPtr;
    inFile.close();

    return head;
}
</code>```

I also have an output function that looks like this:

```<code>void OutputList(DVDNode* head, string outputFile)
{
    ofstream outFile;
    outFile.open(outputFile.c_str());

    DVDNode* dvdPtr;
    dvdPtr = head;

    while(outFile && dvdPtr != NULL)
    {
        outFile << dvdPtr -> title;
        outFile << dvdPtr -> leadActor;
        outFile << dvdPtr -> supportingActor;
        outFile << dvdPtr -> genre;
        outFile << dvdPtr -> year;
        outFile << dvdPtr -> rating;
        outFile << dvdPtr -> synopsis;

        dvdPtr = dvdPtr -> next;
    }

    outFile.close();

}
</code>```

Here's what the main code looks like:

```<code>// Variables
string inputFile;
string outputFile;
DVDNode* head;

// Input
cout << "Enter the name of the input file: ";
getline(cin, inputFile);

head = CreateList(inputFile);

// Output
cout << "Enter the name of the output file: ";
getline(cin, outputFile);

OutputList(head, outputFile);
</code>```

I'm sorry if this is a stupid question, I can't find any good tutorials online about linked lists and I don't really understand why this just doesn't do anything after I type in the Input File Name.

Thanks in advance for your help.

EDIT:

So I fixed the cin problem, but now there's a different problem. When my input file looks like this:

```<code>Yankee Doodle Dandee
James Cagney
Joan Leslie
Musical
Biography
1942
8
This film depicts the life of the renowned musical composer, playwright, actor, dancer and singer George M. Cohan.

X-Men
Hugh Jackman
Patrick Stewart
Action
Action
2000
7
All over the planet, unusual children are born with an added twist to their genetic code.
</code>```

The list goes on, there are about 10 movies in this format. However, after running the program, the output file looks like this:

```<code>Title: Yankee Doodle Dandee
Lead Actor: James Cagney
Supporting Actor: Joan Leslie
Genre: Musical
Year: 1735357008
Rating: 544039282
Synopsis:
</code>```

If I add an inFile.ignore(100, '\n'); to the CreateList function right below the line where I read in genre, than the output looks like this:

```<code>Title: This film depicts the life of the renowned musical composer, playwright, actor, dancer and singer George M. Cohan.
Lead Actor:
Supporting Actor: X-Men
Genre: Hugh Jackman
Year: 0
Rating: 0
Synopsis:
Title: Yankee Doodle Dandee
Lead Actor: James Cagney
Supporting Actor: Joan Leslie
Genre: Musical
Year: 1942
Rating: 8
Synopsis:
</code>```

EDIT: Sorry, I figured it out. It was just a matter of a few more ignores. Thanks.

答:
It is not hanging, it is waiting for your input because you have:

```<code>cin >> dvdPtr -> year;   // read year from std input!!
cin >> dvdPtr -> rating;
</code>```

in the function CreateList. This function opens the user specified file and reads the DVD fields from it.

Change the above lines to:

```<code>inFile >> dvdPtr -> year;   // read year from file.
inFile >> dvdPtr -> rating;
</code>```

Title: Linked List From Text File

Body:
I'm very new to pointers and linked lists but I'm trying to write a simple program that reads in data from a text file into a linked list. I'm having trouble with the input function. It looks like this:

DVDNode* CreateList(string fileName)
{
    ifstream inFile;
    inFile.open(fileName.c_str());

    DVDNode* head = NULL;
    DVDNode* dvdPtr;
    dvdPtr = new DVDNode;

    while(inFile && dvdPtr != NULL)
    {
        getline(inFile, dvdPtr -> title);
        getline(inFile, dvdPtr -> leadActor);
        getline(inFile, dvdPtr -> supportingActor);
        getline(inFile, dvdPtr -> genre);
        cin >> dvdPtr -> year;
        cin >> dvdPtr -> rating;
        getline(inFile, dvdPtr -> synopsis);

        dvdPtr -> next = head;
        head = dvdPtr;
        dvdPtr = new DVDNode;
    }

    delete dvdPtr;
    inFile.close();

    return head;
}

I also have an output function that looks like this:

void OutputList(DVDNode* head, string outputFile)
{
    ofstream outFile;
    outFile.open(outputFile.c_str());

    DVDNode* dvdPtr;
    dvdPtr = head;

    while(outFile && dvdPtr != NULL)
    {
        outFile << dvdPtr -> title;
        outFile << dvdPtr -> leadActor;
        outFile << dvdPtr -> supportingActor;
        outFile << dvdPtr -> genre;
        outFile << dvdPtr -> year;
        outFile << dvdPtr -> rating;
        outFile << dvdPtr -> synopsis;

        dvdPtr = dvdPtr -> next;
    }

    outFile.close();

}

Here's what the main code looks like:

// Variables
string inputFile;
string outputFile;
DVDNode* head;

// Input
cout << "Enter the name of the input file: ";
getline(cin, inputFile);

head = CreateList(inputFile);

// Output
cout << "Enter the name of the output file: ";
getline(cin, outputFile);

OutputList(head, outputFile);

I'm sorry if this is a stupid question, I can't find any good tutorials online about linked lists and I don't really understand why this just doesn't do anything after I type in the Input File Name.

Thanks in advance for your help.

EDIT:

So I fixed the cin problem, but now there's a different problem. When my input file looks like this:

Yankee Doodle Dandee
James Cagney
Joan Leslie
Musical
Biography
1942
8
This film depicts the life of the renowned musical composer, playwright, actor, dancer and singer George M. Cohan.

X-Men
Hugh Jackman
Patrick Stewart
Action
Action
2000
7
All over the planet, unusual children are born with an added twist to their genetic code.

The list goes on, there are about 10 movies in this format. However, after running the program, the output file looks like this:

Title: Yankee Doodle Dandee
Lead Actor: James Cagney
Supporting Actor: Joan Leslie
Genre: Musical
Year: 1735357008
Rating: 544039282
Synopsis:

If I add an inFile.ignore(100, '\n'); to the CreateList function right below the line where I read in genre, than the output looks like this:

Title: This film depicts the life of the renowned musical composer, playwright, actor, dancer and singer George M. Cohan.
Lead Actor:
Supporting Actor: X-Men
Genre: Hugh Jackman
Year: 0
Rating: 0
Synopsis:
Title: Yankee Doodle Dandee
Lead Actor: James Cagney
Supporting Actor: Joan Leslie
Genre: Musical
Year: 1942
Rating: 8
Synopsis:

EDIT: Sorry, I figured it out. It was just a matter of a few more ignores. Thanks.

Body:
It is not hanging, it is waiting for your input because you have:

cin >> dvdPtr -> year;   // read year from std input!!
cin >> dvdPtr -> rating;

in the function CreateList. This function opens the user specified file and reads the DVD fields from it.

Change the above lines to:

inFile >> dvdPtr -> year;   // read year from file.
inFile >> dvdPtr -> rating;


问:
How to find .babelrc?
I want to create React app with Ant Design

In the docs, it says I need to change .babelrc to modularly load the files, also from https://medium.com/@GeoffMiller/how-to-customize-ant-design-with-react-webpack-the-missing-guide-c6430f2db10f..

But, I can't find any.. I'm very new to Webpack/Babel/other things...

I used create-react-app to make React app

Please help..

This is my package.json:

```<code>{
  "name": "ant",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "antd": "^3.0.3",
    "jquery": "^3.2.1",
    "react": "^16.2.0",
    "react-dom": "^16.2.0",
    "react-scripts": "1.0.17"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  },
  "devDependencies": {
    "babel-plugin-import": "^1.6.3",
    "css-loader": "^0.28.7",
    "less": "^2.7.3",
    "less-loader": "^4.0.5",
    "less-vars-to-js": "^1.2.1",
    "style-loader": "^0.19.1"
  }
}
</code>```

答: for anyone that ends up here in the future, some clarification: when you create your project with CRA, the babel configuration exists as part of the react-scripts setup (react-scripts is the package responsible for all the tooling magic of CRA). this means all babel related controls are nested somewhere inside of your project's node_modules directory. for all intents and purposes, they are not editable, and ejecting is required.

Title: How to find .babelrc?

Body:
I want to create React app with Ant Design

In the docs, it says I need to change .babelrc to modularly load the files, also from https://medium.com/@GeoffMiller/how-to-customize-ant-design-with-react-webpack-the-missing-guide-c6430f2db10f..

But, I can't find any.. I'm very new to Webpack/Babel/other things...

I used create-react-app to make React app

Please help..

This is my package.json:

{
  "name": "ant",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "antd": "^3.0.3",
    "jquery": "^3.2.1",
    "react": "^16.2.0",
    "react-dom": "^16.2.0",
    "react-scripts": "1.0.17"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  },
  "devDependencies": {
    "babel-plugin-import": "^1.6.3",
    "css-loader": "^0.28.7",
    "less": "^2.7.3",
    "less-loader": "^4.0.5",
    "less-vars-to-js": "^1.2.1",
    "style-loader": "^0.19.1"
  }
}


问:
What is the plugin name for Tomcat8 in Spring MVC maven project
This is what we use for Tomcat 7:

```<code><plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat7-maven-plugin</artifactId>
    <version>2.2</version>
    <configuration>
        <path>/</path>
        <contextReloadable>true</contextReloadable>
    </configuration>
</plugin>
</code>```

I want to know what the equivalent will be for Tomcat 8.

答:
if you need working on tomcat 8, no need tomcat 8 plugin, as it has not come out yet because of this issue.
tomcat7-maven-plugin can be used deploy to tomcat 8.

<plugin>
 <groupId>org.apache.tomcat.maven</groupId>
 <artifactId>tomcat7-maven-plugin</artifactId>
 <version>2.2</version>
 <configuration>
  <url>http:// localhost:8080/manager/text</url>
  <server>TomcatServer</server>    *(From maven > settings.xml)*
  <username>*yourtomcatusername*</username>
  <password>*yourtomcatpassword*</password>
 </configuration>
</plugin>
```

for more, please refer to here

Body:
This is what we use for Tomcat 7:

<plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat7-maven-plugin</artifactId>
    <version>2.2</version>
    <configuration>
        <path>/</path>
        <contextReloadable>true</contextReloadable>
    </configuration>
</plugin>

I want to know what the equivalent will be for Tomcat 8.

Body:
if you need working on tomcat 8, no need tomcat 8 plugin, as it has not come out yet because of this issue.
tomcat7-maven-plugin can be used deploy to tomcat 8.

<!-- Tomcat plugin -->
<plugin>
 <groupId>org.apache.tomcat.maven</groupId>
 <artifactId>tomcat7-maven-plugin</artifactId>
 <version>2.2</version>
 <configuration>
  <url>http:// localhost:8080/manager/text</url>
  <server>TomcatServer</server>    *(From maven > settings.xml)*
  <username>*yourtomcatusername*</username>
  <password>*yourtomcatpassword*</password>
 </configuration>
</plugin>

for more, please refer to here


问:
Negate number without using +, * and -
Is it possible to negate a number without using +,* and - operator.
I know it can be done using BigDecimal negate() Function.
Is it possible to do with out using external libraries.

For ex:
int n = 9
Output:
-9

答:
As far as i know, there is no java method for this.

So your options are to built it yourself by simply multiply by -1.
Or use another library.

public class NumberUtils {
    public static int negate(int i) {
        return i * -1;
    }
}
```

<p>Using this Utils class would look like:</p>

<pre class="lang-java prettyprint-override"><code>public class NumberUtilsTest {
  public static void main(String[] args) {
      Integer i = new Integer(9);
      int i2 = 9;
      System.out.println(NumberUtilsTest.negate(i)); // prints -9
      System.out.println(NumberUtilsTest.negate(i2)); // prints -9
  }
}

</code>```

Title: Negate number without using +, * and -

Body:
As far as i know, there is no java method for this.

So your options are to built it yourself by simply multiply by -1.
Or use another library.

public class NumberUtils {
    public static int negate(int i) {
        return i * -1;
    }
}

Using this Utils class would look like:

public class NumberUtilsTest {
  public static void main(String[] args) {
      Integer i = new Integer(9);
      int i2 = 9;
      System.out.println(NumberUtilsTest.negate(i)); // prints -9
      System.out.println(NumberUtilsTest.negate(i2)); // prints -9
  }
}


答: If it is never released then both ways won't leak, but the second is more "correct". The NSArrays won't be autoreleased till the parent array is (never), so it is fine.</p>

Title: Warning "Potential leak of an object allocated on line ..." when declaring a 2D array

Body:
Initially i declared a 2D array in this way:

subUrb = [[NSArray alloc] initWithObjects:
     [[NSArray alloc] initWithObjects:ALL_SUBURBS_LABEL, @"East",@"South", @"West", @"North", nil] ,
     [[NSArray alloc] initWithObjects:ALL_SUBURBS_LABEL, @"Kuala Lumpur SubUrb1", @"Kuala Lumpur SubUrb2", nil],
     [[NSArray alloc] initWithObjects:ALL_SUBURBS_LABEL, @"Jakarta SubUrb1",nil],
     nil];

But when i try to 'analyze' the warnings of the project, i got three same type of issues in this chunk of code - "potential leak of an object allocated on line xxx"

I noticed that to get rid of it, i have to write sth like this:

subUrb =
    [[NSArray alloc] initWithObjects:
        [[[NSArray alloc] initWithObjects:ALL_SUBURBS_LABEL, @"East",@"South", @"West", @"North", nil] autorelease],
        [[[NSArray alloc] initWithObjects:ALL_SUBURBS_LABEL, @"Kuala Lumpur SubUrb1", @"Kuala Lumpur SubUrb2", nil] autorelease],
        [[[NSArray alloc] initWithObjects:ALL_SUBURBS_LABEL, @"Jakarta SubUrb1",nil] autorelease],
        nil];

Then i will not get any analyze warnings. But i dun like this...it is not logical. This 2D array should never be released in my controller actually, the entire 2D array should be retained for the entire life time of the controller for a PickerView.

How should I declare the 2D array more elegantly?


问:
Sidebar pagination not shown when sidebar is in single.php
A quick question. So I have created a loop in a new file called sidebar-extra.php which I include via the header.php into my single.php file.

Problem: when I go to a post (single.php), I can't see this navigation, while I can see it on my homepage, where I also include sidebar-extra.php

```<code><ul class="pagination">
        <li class="page-item"><?php previous_posts_link('« Previous posts') ?></li>
        <li class="page-item"><?php next_posts_link('Next posts »') ?></li>
    </ul>
</code>```

Is there a way I can make sure that my sidebar-extra.php is showing the post navigation everywhere, including on single.php?

Edit..
This is how it looks like:

In sidebar.php

```<code> <?php
            // the query
            $the_query = new WP_Query(  array( 'posts_per_page' => 25,
                                               'paged' => $paged
                                                ) );
            $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;

            if ( $the_query->have_posts() ) :
            ?>
                <!-- pagination here -->
                <!-- the loop -->
                <?php
                while ( $the_query->have_posts() ) : $the_query->the_post();
                ?>
</code>```

In header.php

```<code>  <?php get_sidebar() ?>
</code>```

In single.php

```<code><?php get_header(); ?>
</code>```

答:
previous_posts_link() and next_posts_link() are intended for pages that contain a list of posts, switching to the next/previous set of posts (number depending on the "posts per page" setting)

To switch to the next and previous single  post / to use it on single pages, you should use next_post_link()  and previous_post_link()

(note: "post", not "posts", see also https://codex.wordpress.org/Template_Tags/previous_post_link)

Body:
A quick question. So I have created a loop in a new file called sidebar-extra.php which I include via the header.php into my single.php file.

Problem: when I go to a post (single.php), I can't see this navigation, while I can see it on my homepage, where I also include sidebar-extra.php

<?php previous_posts_link('« Previous posts') ?>

<?php next_posts_link('Next posts »') ?>

Is there a way I can make sure that my sidebar-extra.php is showing the post navigation everywhere, including on single.php?

Edit..
This is how it looks like:

In sidebar.php

 <?php
            // the query
            $the_query = new WP_Query(  array( 'posts_per_page' => 25,
                                               'paged' => $paged
                                                ) );
            $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;

            if ( $the_query->have_posts() ) :
            ?>

                <?php
                while ( $the_query->have_posts() ) : $the_query->the_post();
                ?>

In header.php

  <?php get_sidebar() ?>

In single.php

<?php get_header(); ?>


问:
AutoLayout Button, Gradient and won't adjust to height
I want to adjust every button's height to the screen size. To do so I've created the following class, which also contains my previously created gradient and shadow path:

```<code>extension UIButton {

    func typeMain() {
        self.translatesAutoresizingMaskIntoConstraints = false
        let height = UIScreen.main.bounds.height * 0.07
        self.heightAnchor.constraint(equalToConstant: height).isActive = true

        self.addCharacterSpacing()
        self.tintColor = UIColor.white
        let color = UIColor(red: 11/255, green: 95/255, blue: 244/255, alpha: 1)
        let sndColor = UIColor(red: 106/255, green: 178/255, blue: 255/255, alpha: 1)

        self.layer.cornerRadius = self.frame.size.height / 5.0

        self.applyGradient(colours: [color, sndColor], locations: [0.0, 1.0])

        let shadowSize : CGFloat = 2.0
        self.layer.shadowColor = UIColor(red: 106/255, green: 178/255, blue: 255/255, alpha: 1).cgColor
        self.layer.shadowOffset = CGSize(width: 0.0, height: 0.0)
        self.layer.shadowOpacity = 0.4
        let shadowPath = UIBezierPath(rect: CGRect(x: -shadowSize / 2,
                                                   y: shadowSize,
                                                   width: self.frame.size.width + shadowSize,
                                                   height: self.frame.size.height + shadowSize))
        self.layer.shadowPath = shadowPath.cgPath
        self.layer.shadowRadius = 5
        self.layer.masksToBounds = false
    }
}
</code>```

The button is being adjusted to the screen size, but both the gradient and shadow aren't. How can I do so?

Btw. no height constraint in Storyboard set.

答:
Subclass UIButton and override layoutSubviews to set layer.shadowPath, this will make sure that your shadow bounds match the view bounds

```<code>class CustomButton: UIButton {

    override func layoutSubviews() {
        super.layoutSubviews()

        let shadowSize: CGFloat = 2.0
        let shadowRect = CGRect(x: -shadowSize / 2,
                                y: shadowSize,
                                width: self.bounds.width + shadowSize,
                                height: self.bounds.height + shadowSize)
        self.layer.shadowPath = UIBezierPath(rect: shadowRect).cgPath
    }

}
</code>```

Suggestions

Not to add typeMain method as an extension to UIButton, but to move it within the above class

Keep the shadowPath simply to match view bounds, instead you can set shadowOffset

Here is the final class

```<code>class CustomButton: UIButton {

    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        setup()
    }

    override init(frame: CGRect) {
        super.init(frame: frame)
        setup()
    }

    override func awakeFromNib() {
        super.awakeFromNib()
        setup()
    }

    override func layoutSubviews() {
        super.layoutSubviews()
        self.layer.shadowPath = UIBezierPath(rect: self.bounds).cgPath
    }

    private func setup() {
        self.translatesAutoresizingMaskIntoConstraints = false
        let height = UIScreen.main.bounds.height * 0.07
        self.heightAnchor.constraint(equalToConstant: height).isActive = true

        self.tintColor = UIColor.white

        self.layer.cornerRadius = self.frame.size.height / 5.0
        self.layer.shadowColor = UIColor(red: 106/255, green: 178/255, blue: 255/255, alpha: 1).cgColor
        self.layer.shadowOffset = CGSize(width: -1.0, height: 2.0)
        self.layer.shadowOpacity = 1
        self.layer.shadowRadius = 5
        self.layer.masksToBounds = false
    }

    private func applyGradient(_ rect: CGRect, colors: NSArray, locations: NSArray) {
        guard
            let ctx = UIGraphicsGetCurrentContext(),
            let gradient = CGGradient(colorsSpace: CGColorSpaceCreateDeviceRGB(), colors: colors, locations: [0, 0.5])
        else {
            return
        }

        ctx.drawLinearGradient(gradient, start: .zero, end: CGPoint(x: bounds.width, y: 0), options: [])
    }

    override func draw(_ rect: CGRect) {
        let startColor = UIColor(red: 11/255, green: 95/255, blue: 244/255, alpha: 1).cgColor
        let endColor = UIColor(red: 106/255, green: 178/255, blue: 255/255, alpha: 1).cgColor
        self.applyGradient(rect, colors: [startColor, endColor], locations: [0.0, 1.0])
    }

}
</code>```

Following is a test of 2 buttons, 1st is UIButton, 2nd is subclassed CustomButton

```<code>class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        let button = UIButton()
        button.setTitle("UIButton", for: .normal)
        button.setTitleColor(.black, for: .normal)
        button.contentEdgeInsets = UIEdgeInsets(top: 0, left: 16.0, bottom: 0, right: 16.0)
        self.view.addSubview(button)
        button.typeMain()

        let subclassedButton = CustomButton()
        subclassedButton.setTitle("UIButton Subclassed", for: .normal)
        subclassedButton.setTitleColor(.black, for: .normal)
        subclassedButton.contentEdgeInsets = UIEdgeInsets(top: 0, left: 16.0, bottom: 0, right: 16.0)
        self.view.addSubview(subclassedButton)

        let salGuide = self.view.safeAreaLayoutGuide
        button.leadingAnchor.constraint(equalTo: salGuide.leadingAnchor, constant: 20.0).isActive = true
        button.topAnchor.constraint(equalTo: salGuide.topAnchor, constant: 20.0).isActive = true

        subclassedButton.leadingAnchor.constraint(equalTo: salGuide.leadingAnchor, constant: 20.0).isActive = true
        subclassedButton.topAnchor.constraint(equalTo: button.bottomAnchor, constant: 20.0).isActive = true
    }

}
</code>```

That yields

Body:
I want to adjust every button's height to the screen size. To do so I've created the following class, which also contains my previously created gradient and shadow path:

extension UIButton {

    func typeMain() {
        self.translatesAutoresizingMaskIntoConstraints = false
        let height = UIScreen.main.bounds.height * 0.07
        self.heightAnchor.constraint(equalToConstant: height).isActive = true

        self.addCharacterSpacing()
        self.tintColor = UIColor.white
        let color = UIColor(red: 11/255, green: 95/255, blue: 244/255, alpha: 1)
        let sndColor = UIColor(red: 106/255, green: 178/255, blue: 255/255, alpha: 1)

        self.layer.cornerRadius = self.frame.size.height / 5.0

        self.applyGradient(colours: [color, sndColor], locations: [0.0, 1.0])

        let shadowSize : CGFloat = 2.0
        self.layer.shadowColor = UIColor(red: 106/255, green: 178/255, blue: 255/255, alpha: 1).cgColor
        self.layer.shadowOffset = CGSize(width: 0.0, height: 0.0)
        self.layer.shadowOpacity = 0.4
        let shadowPath = UIBezierPath(rect: CGRect(x: -shadowSize / 2,
                                                   y: shadowSize,
                                                   width: self.frame.size.width + shadowSize,
                                                   height: self.frame.size.height + shadowSize))
        self.layer.shadowPath = shadowPath.cgPath
        self.layer.shadowRadius = 5
        self.layer.masksToBounds = false
    }
}

The button is being adjusted to the screen size, but both the gradient and shadow aren't. How can I do so?

Btw. no height constraint in Storyboard set.

Body:
Subclass UIButton and override layoutSubviews to set layer.shadowPath, this will make sure that your shadow bounds match the view bounds

class CustomButton: UIButton {

    override func layoutSubviews() {
        super.layoutSubviews()

        let shadowSize: CGFloat = 2.0
        let shadowRect = CGRect(x: -shadowSize / 2,
                                y: shadowSize,
                                width: self.bounds.width + shadowSize,
                                height: self.bounds.height + shadowSize)
        self.layer.shadowPath = UIBezierPath(rect: shadowRect).cgPath
    }

}

Suggestions

Not to add typeMain method as an extension to UIButton, but to move it within the above class

Keep the shadowPath simply to match view bounds, instead you can set shadowOffset

Here is the final class

class CustomButton: UIButton {

    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        setup()
    }

    override init(frame: CGRect) {
        super.init(frame: frame)
        setup()
    }

    override func awakeFromNib() {
        super.awakeFromNib()
        setup()
    }

    override func layoutSubviews() {
        super.layoutSubviews()
        self.layer.shadowPath = UIBezierPath(rect: self.bounds).cgPath
    }

    private func setup() {
        self.translatesAutoresizingMaskIntoConstraints = false
        let height = UIScreen.main.bounds.height * 0.07
        self.heightAnchor.constraint(equalToConstant: height).isActive = true

        self.tintColor = UIColor.white

        self.layer.cornerRadius = self.frame.size.height / 5.0
        self.layer.shadowColor = UIColor(red: 106/255, green: 178/255, blue: 255/255, alpha: 1).cgColor
        self.layer.shadowOffset = CGSize(width: -1.0, height: 2.0)
        self.layer.shadowOpacity = 1
        self.layer.shadowRadius = 5
        self.layer.masksToBounds = false
    }

    private func applyGradient(_ rect: CGRect, colors: NSArray, locations: NSArray) {
        guard
            let ctx = UIGraphicsGetCurrentContext(),
            let gradient = CGGradient(colorsSpace: CGColorSpaceCreateDeviceRGB(), colors: colors, locations: [0, 0.5])
        else {
            return
        }

        ctx.drawLinearGradient(gradient, start: .zero, end: CGPoint(x: bounds.width, y: 0), options: [])
    }

    override func draw(_ rect: CGRect) {
        let startColor = UIColor(red: 11/255, green: 95/255, blue: 244/255, alpha: 1).cgColor
        let endColor = UIColor(red: 106/255, green: 178/255, blue: 255/255, alpha: 1).cgColor
        self.applyGradient(rect, colors: [startColor, endColor], locations: [0.0, 1.0])
    }

}

Following is a test of 2 buttons, 1st is UIButton, 2nd is subclassed CustomButton

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        let button = UIButton()
        button.setTitle("UIButton", for: .normal)
        button.setTitleColor(.black, for: .normal)
        button.contentEdgeInsets = UIEdgeInsets(top: 0, left: 16.0, bottom: 0, right: 16.0)
        self.view.addSubview(button)
        button.typeMain()

        let subclassedButton = CustomButton()
        subclassedButton.setTitle("UIButton Subclassed", for: .normal)
        subclassedButton.setTitleColor(.black, for: .normal)
        subclassedButton.contentEdgeInsets = UIEdgeInsets(top: 0, left: 16.0, bottom: 0, right: 16.0)
        self.view.addSubview(subclassedButton)

        let salGuide = self.view.safeAreaLayoutGuide
        button.leadingAnchor.constraint(equalTo: salGuide.leadingAnchor, constant: 20.0).isActive = true
        button.topAnchor.constraint(equalTo: salGuide.topAnchor, constant: 20.0).isActive = true

        subclassedButton.leadingAnchor.constraint(equalTo: salGuide.leadingAnchor, constant: 20.0).isActive = true
        subclassedButton.topAnchor.constraint(equalTo: button.bottomAnchor, constant: 20.0).isActive = true
    }

}

That yields


问:
Preventing textarea scroll behaviour in chrome after newline added
Recently my version of chrome has been doing something strange (74.0.3729.131 on ubuntu 18.04) more and more often. I have a small editor script which has a textarea which displays code. The textarea has a fixed size and a vertical scroll bar. Beyond that nothing fancy.

Usually, when I insert a newline (normal behaviour of textarea), the scroll bar doesn't move. Now for some reason about 80% of the times it scrolls the textarea down till the position of the caret is at the top of the textarea. Strangely if I delete and enter the newline in the same position, it usually does not scroll.

I'm not sure if this is some new issue in Chrome. I usen't have this issue with previous versions with the identical editor.

Here is a codepen which demonstrates the issue, scroll to some line, press enter and the textarea should scroll down. Try this a few times to see the unpredictable behaviour (adding the code just to be able to add the link, as you can see it's just a textarea).

https://codepen.io/anon/pen/rgKqMb

```<code><textarea style="width:90%;height:300px"></textarea>
</code>```

The only solution that occurs to me to avoid this is to stop the normal behaviour of the enter key and add the newline to the text. Any other ideas/insights very much welcome.

答:
You can try avoiding the events on the textarea with css and js, then force the scroll to it's current position:

css:

```<code>textarea {
    overflow:auto;
    resize:none;
    width:90%;
    height:300px;
}
</code>```

js:
You'll need to insert the first answer from this question at A

```<code>function preventMoving(e) {
    var key = (e.keyCode ? e.keyCode : e.which);
    if(key == 13) {
        e.preventDefault();
        // A
    }
}
</code>```

Then on your HTML:

```<code><textarea onkeyup="preventMoving(event);"></textarea>
</code>```

Body:
Recently my version of chrome has been doing something strange (74.0.3729.131 on ubuntu 18.04) more and more often. I have a small editor script which has a textarea which displays code. The textarea has a fixed size and a vertical scroll bar. Beyond that nothing fancy.

Usually, when I insert a newline (normal behaviour of textarea), the scroll bar doesn't move. Now for some reason about 80% of the times it scrolls the textarea down till the position of the caret is at the top of the textarea. Strangely if I delete and enter the newline in the same position, it usually does not scroll.

I'm not sure if this is some new issue in Chrome. I usen't have this issue with previous versions with the identical editor.

Here is a codepen which demonstrates the issue, scroll to some line, press enter and the textarea should scroll down. Try this a few times to see the unpredictable behaviour (adding the code just to be able to add the link, as you can see it's just a textarea).

https://codepen.io/anon/pen/rgKqMb

<textarea style="width:90%;height:300px"></textarea>

The only solution that occurs to me to avoid this is to stop the normal behaviour of the enter key and add the newline to the text. Any other ideas/insights very much welcome.

Body:
You can try avoiding the events on the textarea with css and js, then force the scroll to it's current position:

css:

textarea {
    overflow:auto;
    resize:none;
    width:90%;
    height:300px;
}

js:
You'll need to insert the first answer from this question at A

function preventMoving(e) {
    var key = (e.keyCode ? e.keyCode : e.which);
    if(key == 13) {
        e.preventDefault();
        // A
    }
}

Then on your HTML:

<textarea onkeyup="preventMoving(event);"></textarea>


问:
3blue1brown | 1 problem related in getting manim to run (SquareToCircle example)
I'm following the instructions of the tutorial (https://talkingphysics.wordpress.com/2018/06/11/learning-how-to-animate-videos-using-manim-series-a-journey/) but, when I type

```<code>(manim37) C:\Users\PaKo>python3 C:\Users\PaKo\Desktop\Python\3blue_1brown\manim-master\extract_scene.py C:\Users\PaKo\Desktop\Python\3blue_1brown\manim-master\example_scenes.py
SquareToCircle -pl
</code>```

I get the following: (I'm working in python 3.7)

```<code>Traceback (most recent call last):
File "C:\Users\PaKo\Desktop\Python\3blue_1brown\manim-master\extract_scene.py", line 299, in
main()
File "C:\Users\PaKo\Desktop\Python\3blue_1brown\manim-master\extract_scene.py", line 259, in main
module = get_module(config["file"])
File "C:\Users\PaKo\Desktop\Python\3blue_1brown\manim-master\extract_scene.py", line 254, in get_module
return importlib.import_module(module_name)
File "C:\Users\PaKo\Anaconda2\envs\manim36\lib\importlib_init_.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "< frozen importlib._bootstrap >", line 994, in _gcd_import
File "< frozen importlib._bootstrap >", line 971, in _find_and_load
File "< frozen importlib._bootstrap >", line 941, in _find_and_load_unlocked
File "< frozen importlib._bootstrap >", line 219, in _call_with_frames_removed
File "< frozen importlib._bootstrap >", line 994, in _gcd_import
File "< frozen importlib._bootstrap >", line 971, in _find_and_load
File "< frozen importlib._bootstrap >", line 941, in _find_and_load_unlocked
File "< frozen importlib._bootstrap >", line 219, in _call_with_frames_removed
File "< frozen importlib._bootstrap >", line 994, in _gcd_import
File "< frozen importlib._bootstrap >", line 971, in _find_and_load
File "< frozen importlib._bootstrap >", line 941, in _find_and_load_unlocked
File "< frozen importlib._bootstrap >", line 219, in _call_with_frames_removed
File "< frozen importlib._bootstrap >", line 994, in _gcd_import
File "< frozen importlib._bootstrap >", line 971, in _find_and_load
File "< frozen importlib._bootstrap >", line 941, in _find_and_load_unlocked
File "< frozen importlib._bootstrap >", line 219, in _call_with_frames_removed
File "< frozen importlib._bootstrap >", line 994, in _gcd_import
File "< frozen importlib._bootstrap >", line 971, in _find_and_load
File "< frozen importlib._bootstrap >", line 941, in _find_and_load_unlocked
File "< frozen importlib._bootstrap >", line 219, in _call_with_frames_removed
File "< frozen importlib._bootstrap >", line 994, in _gcd_import
File "< frozen importlib._bootstrap >", line 971, in _find_and_load
File "< frozen importlib._bootstrap >", line 941, in _find_and_load_unlocked
File "< frozen importlib._bootstrap >", line 219, in _call_with_frames_removed
File "< frozen importlib._bootstrap >", line 994, in _gcd_import
File "< frozen importlib._bootstrap >", line 971, in _find_and_load
File "< frozen importlib._bootstrap >", line 941, in _find_and_load_unlocked
File "< frozen importlib._bootstrap >", line 219, in _call_with_frames_removed
File "< frozen importlib._bootstrap >", line 994, in _gcd_import
File "< frozen importlib._bootstrap >", line 971, in _find_and_load
File "< frozen importlib._bootstrap >", line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'C:'
</code>```

Can you help me to solve this issue so I can visualize the video?
Thank you in advanced,

答:
The tutorial you are speaking of was posted a few months earlier from your post, and they have a notice:

```<code>Important Note:  These posts are based on an earlier version of manim which uses Python 2.7.
The latest version of manim is using Python 3.
To follow along with these posts, use Python 2.7 and the May 9, 2018 commit of manim.
</code>```

I'd put high odds on the instructions in there being outdated.

It's unlikely that you haven't already solved the problem by now, but for posterity I'll try to answer your question:

If you have installed manim correctly, you are probably just entering the wrong command. The command for running manim has changed, so I would recommend cd-ing into your manim installation directory (manim-master if you downloaded from github) and running:

python -m manim example_scenes.py SquareToCircle -pl
instead of what you previously entered.

It may also be possible that you installed the python3 version of manim while you are running with python2. Try python3 instead of python instead in that case.

Body:
I'm following the instructions of the tutorial (https://talkingphysics.wordpress.com/2018/06/11/learning-how-to-animate-videos-using-manim-series-a-journey/) but, when I type

(manim37) C:\Users\PaKo>python3 C:\Users\PaKo\Desktop\Python\3blue_1brown\manim-master\extract_scene.py C:\Users\PaKo\Desktop\Python\3blue_1brown\manim-master\example_scenes.py
SquareToCircle -pl

I get the following: (I'm working in python 3.7)

Traceback (most recent call last):
File "C:\Users\PaKo\Desktop\Python\3blue_1brown\manim-master\extract_scene.py", line 299, in
main()
File "C:\Users\PaKo\Desktop\Python\3blue_1brown\manim-master\extract_scene.py", line 259, in main
module = get_module(config["file"])
File "C:\Users\PaKo\Desktop\Python\3blue_1brown\manim-master\extract_scene.py", line 254, in get_module
return importlib.import_module(module_name)
File "C:\Users\PaKo\Anaconda2\envs\manim36\lib\importlib_init_.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "< frozen importlib._bootstrap >", line 994, in _gcd_import
File "< frozen importlib._bootstrap >", line 971, in _find_and_load
File "< frozen importlib._bootstrap >", line 941, in _find_and_load_unlocked
File "< frozen importlib._bootstrap >", line 219, in _call_with_frames_removed
File "< frozen importlib._bootstrap >", line 994, in _gcd_import
File "< frozen importlib._bootstrap >", line 971, in _find_and_load
File "< frozen importlib._bootstrap >", line 941, in _find_and_load_unlocked
File "< frozen importlib._bootstrap >", line 219, in _call_with_frames_removed
File "< frozen importlib._bootstrap >", line 994, in _gcd_import
File "< frozen importlib._bootstrap >", line 971, in _find_and_load
File "< frozen importlib._bootstrap >", line 941, in _find_and_load_unlocked
File "< frozen importlib._bootstrap >", line 219, in _call_with_frames_removed
File "< frozen importlib._bootstrap >", line 994, in _gcd_import
File "< frozen importlib._bootstrap >", line 971, in _find_and_load
File "< frozen importlib._bootstrap >", line 941, in _find_and_load_unlocked
File "< frozen importlib._bootstrap >", line 219, in _call_with_frames_removed
File "< frozen importlib._bootstrap >", line 994, in _gcd_import
File "< frozen importlib._bootstrap >", line 971, in _find_and_load
File "< frozen importlib._bootstrap >", line 941, in _find_and_load_unlocked
File "< frozen importlib._bootstrap >", line 219, in _call_with_frames_removed
File "< frozen importlib._bootstrap >", line 994, in _gcd_import
File "< frozen importlib._bootstrap >", line 971, in _find_and_load
File "< frozen importlib._bootstrap >", line 941, in _find_and_load_unlocked
File "< frozen importlib._bootstrap >", line 219, in _call_with_frames_removed
File "< frozen importlib._bootstrap >", line 994, in _gcd_import
File "< frozen importlib._bootstrap >", line 971, in _find_and_load
File "< frozen importlib._bootstrap >", line 941, in _find_and_load_unlocked
File "< frozen importlib._bootstrap >", line 219, in _call_with_frames_removed
File "< frozen importlib._bootstrap >", line 994, in _gcd_import
File "< frozen importlib._bootstrap >", line 971, in _find_and_load
File "< frozen importlib._bootstrap >", line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'C:'

Can you help me to solve this issue so I can visualize the video?
Thank you in advanced,

Body:
The tutorial you are speaking of was posted a few months earlier from your post, and they have a notice:

Important Note:  These posts are based on an earlier version of manim which uses Python 2.7.
The latest version of manim is using Python 3.
To follow along with these posts, use Python 2.7 and the May 9, 2018 commit of manim.

I'd put high odds on the instructions in there being outdated.

It's unlikely that you haven't already solved the problem by now, but for posterity I'll try to answer your question:

If you have installed manim correctly, you are probably just entering the wrong command. The command for running manim has changed, so I would recommend cd-ing into your manim installation directory (manim-master if you downloaded from github) and running:

python -m manim example_scenes.py SquareToCircle -pl
instead of what you previously entered.

It may also be possible that you installed the python3 version of manim while you are running with python2. Try python3 instead of python instead in that case.