问:
How to make Superfish menu horizontal width 100%?
I am using Superfish 1.4.8 as a horizontal menu

The menu is inside of a fixed-width div of 900px

I would like Superfish's width to be 100% (900px), and have each li's width automatically scaled depending on the number of items. The number of items in this menu will change over time.

Basically I want the same behavior of a 100% width TABLE and the auto-sizing behavior of TD's

I found the following CSS additions from an old 2009 post on how to do this:

```<code>.sf-menu { width: 100%; float: left; display: table;}
.sf-menu ul { display: table-row; }
.sf-menu ul li { display: table-cell; min-width: 20%; }
</code>```

It looks like it should work, but it does not, the menu still appears exactly the same

Here it is on jsFiddle:
http://jsfiddle.net/xRcJL/

Has anyone been able to make Superfish scale to 100% of a container?

答:
UPDATE:

Check out this article for "jQuery Full-Width Navigation Plug-In": http://exscale.se/archives/2007/11/09/jquery-full-width-navigation-plugin/

It's because your .sf-menu li list items are floated to the left.

Check out edited JSfiddle with the updated style for:

```<code>.sf-menu li {
    /*float: left;*/
    position: relative;
}
</code>```

Updated JSfiddle link: http://jsfiddle.net/xRcJL/1/

If you want to centre your NAV, you could do something like:

```<code>}
.sf-menu{
    text-align:center;
    background-color:#ccc;
}
.sf-menu li {
    position: relative;
    display:inline-block;
    margin:0 -2px;
}
</code>```

See updated JSfiddle v2: http://jsfiddle.net/xRcJL/3/

*Works in Chrome, Firefox and IE8. Haven't tested in IE7&6.

Body:
I am using Superfish 1.4.8 as a horizontal menu

The menu is inside of a fixed-width div of 900px

I would like Superfish's width to be 100% (900px), and have each li's width automatically scaled depending on the number of items. The number of items in this menu will change over time.

Basically I want the same behavior of a 100% width TABLE and the auto-sizing behavior of TD's

I found the following CSS additions from an old 2009 post on how to do this:

.sf-menu { width: 100%; float: left; display: table;}
.sf-menu ul { display: table-row; }
.sf-menu ul li { display: table-cell; min-width: 20%; }

It looks like it should work, but it does not, the menu still appears exactly the same

Here it is on jsFiddle:
http://jsfiddle.net/xRcJL/

Has anyone been able to make Superfish scale to 100% of a container?

Body:
UPDATE:

Check out this article for "jQuery Full-Width Navigation Plug-In": http://exscale.se/archives/2007/11/09/jquery-full-width-navigation-plugin/

It's because your .sf-menu li list items are floated to the left.

Check out edited JSfiddle with the updated style for:

.sf-menu li {
    /*float: left;*/
    position: relative;
}

Updated JSfiddle link: http://jsfiddle.net/xRcJL/1/

If you want to centre your NAV, you could do something like:

}
.sf-menu{
    text-align:center;
    background-color:#ccc;
}
.sf-menu li {
    position: relative;
    display:inline-block;
    margin:0 -2px;
}

See updated JSfiddle v2: http://jsfiddle.net/xRcJL/3/

*Works in Chrome, Firefox and IE8. Haven't tested in IE7&6.


来源: stackexchange

问:
How to get object from nested entities in Spring/JPA/Hibernate?
I have this entities:

```<code>public class AnswerEntity {
    @ManyToOne
    private UserEntity user;
    @ManyToOne
    private AnswerDirectoryEntity answer;
    @ManyToOne
    private QuestionEntity question;
}
</code>```

```<code>public class QuestionEntity {
    @ManyToOne
    private QuestionnaireEntity questionnaire;
}
</code>```

```<code>public class QuestionnaireEntity  {
    private String code;
}
</code>```

I need to take all user answers by user ID and corresponding code from QuestionnaireEntity.

I do it by create query like this:

```<code>List<AnswerEntity> answerList = answerRepository.findAllByUserId(userId);
</code>```

and iterate over each object in my list and with using equals I compare each object to my questionnaire code:

```<code>for(AnswerEntity answerEntity : answerList){
            if(answerEntity.getQuestion().getQuestionnaire().getCode().equals(questionnaireId)){
     ///
}
</code>```

but this solution is very slow because it must iterate each object from my database,

can anybody tell my how to create an query in my repository which can help me?

答:
You can use JPA method query this way in repository</p>

```<code>List<AnswerEntity> findByUserIdAndQuestionQuestionnaireCode(Integer userId, String code);
</code>```

ContentLicense: CC BY-SA 4.0

Body:
I have this entities:

public class AnswerEntity {
    @ManyToOne
    private UserEntity user;
    @ManyToOne
    private AnswerDirectoryEntity answer;
    @ManyToOne
    private QuestionEntity question;
}

public class QuestionEntity {
    @ManyToOne
    private QuestionnaireEntity questionnaire;
}

public class QuestionnaireEntity  {
    private String code;
}

I need to take all user answers by user ID and corresponding code from QuestionnaireEntity.

I do it by create query like this:

List<AnswerEntity> answerList = answerRepository.findAllByUserId(userId);

and iterate over each object in my list and with using equals I compare each object to my questionnaire code:

for(AnswerEntity answerEntity : answerList){
            if(answerEntity.getQuestion().getQuestionnaire().getCode().equals(questionnaireId)){
     ///
}

but this solution is very slow because it must iterate each object from my database,

can anybody tell my how to create an query in my repository which can help me?

Body:
You can use JPA method query this way in repository

List<AnswerEntity> findByUserIdAndQuestionQuestionnaireCode(Integer userId, String code);


问:
Jmeter correlation for values with no left or right boundries
I wanna correlate a alphanumeric 81fe8bfe87576c3ecb22426f8e57847382917acf value returned from a POST API request as Response which consists of no left or right boundaries, I am using ^[a-zA-Z0-9]+$ as regex expression which is a correct regex expression with Jmeter RegExp Tester, but unable to extract the alphanumeric value from the response and store in a variable as determined by the logs using Regular Expression Extractor.

But, Values returned by the logs shows unable to extract alphanumeric value using Regular Expression Extractor.

Here is my Regular Expression Extractor to extract the alphanumeric value

I already have tried out all the Fields to check options available, nothing works. I am not sure , exactly why is it not working as the regex expression ^[a-zA-Z0-9]+$ is correct, maybe it's related to empty or no left and right boundaries.

Would really appreciate any resolution provided.

答:
Your ^[a-zA-Z0-9]+$ regex contains no capturing groups, but your template, $1$, retrieves Group 1 value from the match. Since the match has no Group 1, the value is not found.

There are two solutions:

Replace your ^[a-zA-Z0-9]+$ with ^([a-zA-Z0-9]+)$ and keep on using $1$ template.

Replace $1$ with $0$ so as to access the whole match value, Group 0, rather than Group 1 (that is missing in the original regex).


问:
Make sure the same array items are not next to each other in php
I am struggling with this case. I have a random array that similar items can be in the next to each other and I don't want it to happen.

Example :

```<code>array("red","red","blue","green","green","blue");

Expected Output : array("red","blue","red","green","blue","green")
</code>```

So I was thinking about shuffle the items until there are no similar items in the next to each other. But it will take a lot of time if the array has a lot of values.

Is there any effective way to make it happen?

Any help would be appreciated. Thanks

答:
Just an idea:

Shuffle the original array.

Compare the first two. If they are the same, swap second with the last.

Move to the next pair.

Repeat until end reached.

Here we assume the worst case shuffle having the same values next together.

$colors = ["red", "red", "blue", "blue", "green", "green"];

for ($i = 0; $i < count($colors) - 1; $i++) {
    if ($colors[$i] !== $colors[$i + 1]) continue;
    $last = $colors[count($colors) - 1];
    $colors[count($colors) - 1] = $colors[$i];
    $colors[$i + 1] = $last;
}

print_r($colors);

```

```Array
(
    [0] => red
    [1] => green
    [2] => blue
    [3] => red
    [4] => green
    [5] => blue
)
```

Body:
I am struggling with this case. I have a random array that similar items can be in the next to each other and I don't want it to happen.

Example :

array("red","red","blue","green","green","blue");

Expected Output : array("red","blue","red","green","blue","green")

So I was thinking about shuffle the items until there are no similar items in the next to each other. But it will take a lot of time if the array has a lot of values.

Is there any effective way to make it happen?

Any help would be appreciated. Thanks

Body:
Just an idea:

Shuffle the original array.

Compare the first two. If they are the same, swap second with the last.

Move to the next pair.

Repeat until end reached.

Here we assume the worst case shuffle having the same values next together.

$colors = ["red", "red", "blue", "blue", "green", "green"];

for ($i = 0; $i < count($colors) - 1; $i++) {
    if ($colors[$i] !== $colors[$i + 1]) continue;
    $last = $colors[count($colors) - 1];
    $colors[count($colors) - 1] = $colors[$i];
    $colors[$i + 1] = $last;
}

print_r($colors);

Array
(
    [0] => red
    [1] => green
    [2] => blue
    [3] => red
    [4] => green
    [5] => blue
)


问:
AWS Elastic Beanstalk: WSGI path incorrect?
I'm attempting to deploy my first application to EB and am following along with this turorial: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-django.html

Unfortunately, I'm still getting a 502 error when deploying the final app. I'm confused because I've followed the directions to the tee.

I'm getting the following error

```<code>ImportError: Failed to find application, did you mean 'ebdjango/wsgi:application'?
</code>```

I'm not sure what this means. Per the instructions, I edited the django.config file to include this text:

```<code>option_settings:
  aws:elasticbeanstalk:container:python:
    WSGIPath: ebdjango/wsgi.py
</code>```

This appears to match my file structure:

```<code>- ebdjango
  -.ebextensions
    - django.config
  - .elasticbeanstalk
  - ebdjango
    _ __init__.py
    - settings.py
    - urls.py
    - wsgi.py
  - manage.py
  - requirements.txt
</code>```

So the config file is set up correctly, right?

I'm running Python 3.7 and Django 2.2.

I know that EB searches for application.py, and I thought the config file is supposed to point the server towards my custom app? What am I missing here?

EDIT: I'm also getting this error:

```<code>ModuleNotFoundError: No module named 'ebdjango/wsgi'
</code>```

Is something off about my file structure?

EDIT 2: I forgot to include the init.py file in my post, see Ben's comment.

答: I had the same problem today messing around with the django.config file. It finally worked for me when I changed the WSGI path in the configuration tab to ebdjango.wsgi:application.</p>

Body:
I'm attempting to deploy my first application to EB and am following along with this turorial: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-django.html

Unfortunately, I'm still getting a 502 error when deploying the final app. I'm confused because I've followed the directions to the tee.

I'm getting the following error

ImportError: Failed to find application, did you mean 'ebdjango/wsgi:application'?

I'm not sure what this means. Per the instructions, I edited the django.config file to include this text:

option_settings:
  aws:elasticbeanstalk:container:python:
    WSGIPath: ebdjango/wsgi.py

This appears to match my file structure:

- ebdjango
  -.ebextensions
    - django.config
  - .elasticbeanstalk
  - ebdjango
    _ __init__.py
    - settings.py
    - urls.py
    - wsgi.py
  - manage.py
  - requirements.txt

So the config file is set up correctly, right?

I'm running Python 3.7 and Django 2.2.

I know that EB searches for application.py, and I thought the config file is supposed to point the server towards my custom app? What am I missing here?

EDIT: I'm also getting this error:

ModuleNotFoundError: No module named 'ebdjango/wsgi'

Is something off about my file structure?

EDIT 2: I forgot to include the init.py file in my post, see Ben's comment.


问:
Pandas UserWarning when using df.loc based on condition
I've below dataframe where I want to change values based on condition

```<code>    name    checker data
0  user1  user122AB   10
1  user2  user132AB   12
2  user3  user346AB   14
3  user4  user108AB   16
4  user5  user122CD   10
5  user6  user132CD   12
6  user7  user346CD   14
7  user8  user108CD   16
</code>```

Expected output:

```<code>    name    checker data
0  user1  user122AB   10
1  user2  user132AB   12
2  user3  user346AB   14
3  user4  user108AB   16
4  user5  user122CD  900
5  user6  user132CD  900
6  user7  user346CD  900
7  user8  user108CD  900
</code>```

I'm using below code for same.

```<code>import pandas as pd
import re

df = pd.DataFrame([["user1", "user122AB", "10"], ["user2", "user132AB", "12"], ["user3", "user346AB", "14"], ["user4", "user108AB", "16"], ["user5", "user122CD", "10"], ["user6", "user132CD", "12"], ["user7", "user346CD", "14"], ["user8", "user108CD", "16"]], columns=["name", "checker", "data"])
df.loc[df.checker.str.contains("\d+\w*(CD)$"), "data"] = "900"
print(df)
</code>```

It is doing the exact thing that I want but throwing below warning along with output.

```<code>UserWarning: This pattern has match groups. To actually get the groups, use str.extract.
</code>```

Please help if I'm doing something wrong or please share any better way to achieve this.

答:
You have this warning because of the parenthesis. You are searching for matching patterns, to be returned. I think this is unnecessary.
pandas (1.0.3) is coded to send a warning is the regex match one ore more parenthesis patterns (if regex.groups > 0: warnings.warn(...)).

The line below is then working without warning:

df.loc[df.checker.str.contains("\d+\w*CD$"), "data"] = "900"
```

Body:
I've below dataframe where I want to change values based on condition

    name    checker data
0  user1  user122AB   10
1  user2  user132AB   12
2  user3  user346AB   14
3  user4  user108AB   16
4  user5  user122CD   10
5  user6  user132CD   12
6  user7  user346CD   14
7  user8  user108CD   16

Expected output:

    name    checker data
0  user1  user122AB   10
1  user2  user132AB   12
2  user3  user346AB   14
3  user4  user108AB   16
4  user5  user122CD  900
5  user6  user132CD  900
6  user7  user346CD  900
7  user8  user108CD  900

I'm using below code for same.

import pandas as pd
import re

df = pd.DataFrame([["user1", "user122AB", "10"], ["user2", "user132AB", "12"], ["user3", "user346AB", "14"], ["user4", "user108AB", "16"], ["user5", "user122CD", "10"], ["user6", "user132CD", "12"], ["user7", "user346CD", "14"], ["user8", "user108CD", "16"]], columns=["name", "checker", "data"])
df.loc[df.checker.str.contains("\d+\w*(CD)$"), "data"] = "900"
print(df)

It is doing the exact thing that I want but throwing below warning along with output.

UserWarning: This pattern has match groups. To actually get the groups, use str.extract.

Please help if I'm doing something wrong or please share any better way to achieve this.


问:
How to get the output of javap to multiple text files
I know this is a simple question but I am quite new to programming and I want to know if there is a way to get the output of a javap file to multiple different named text files. Eg. In the case of one output file it would be javap -c abc.class > nameOfTheFileYouWant.txt what about in the event that where I want it to output more than one uniquely named text file.</p>

答:
The javap tool is used to get the information of any class or interface.The javap command disassembles one or more class files. Its output depends on the options used. If no options are used, javap prints out the package, protected, and public fields and methods of the classes passed to it. javap prints its output to stdout.

For more info check this out!


问:
Solving the algorithm question using javascript
I don't know how to think about a question. Since I know the people here are much more experienced and guiding, I would like to ask you. I'd appreciate it if you could solve the problem and explain it. Question:

"Think that you have an unlimited number of carrots, but limited number of carrot types. Also, you have one bag that can hold a limited weight. Each type of carrot has a weight and a price. Write a function that takes carrotTypes and capacity and return the maximum value the bag can hold."

I'm not sure I fully understand the question and understand how I can do it. I'd be very happy if you could help me.

let carrotTypes = [{
    price: 100,
    kg: 2
  },
  {
    price: 120,
    kg: 4
  },
  {
    price: 80,
    kg: 7
  }
];

let bagCapacity = 36; //kg

getMaxValue(carrotTypes, bagCapacity)

function getMaxValue(carrotTypes, capacity) {

  carrotTypes.forEach(carrot => {
     console.log(carrot);
  });

}```

答:
I would suggest building your thinking like this. Start breaking the problem in smaller parts. What if your bag is able to hold 2kg weight?

For better understanding, I am modifying the values. So let's suppose you have 3 carrot types

 let carrotTypes = [{
    price: 50,
    kg: 1
  },
  {
    price: 100,
    kg: 2
  },
  {
    price: 80,
    kg: 3
  }
];
```

<p>Random small numbers so that you can get a feel of it and your bag can hold is 3Kg.</p>

<p>Now proceed to this problem, assuming max weight bag can handle is 0 what will be the answer then, and then increase the maximum weight one by one.
Also, what if you have only 1 type of carrot, and then increase the types of carrot.</p>

<p>Max Weight Bag can handle</p>

```             0       1       2        3
(50)  1      0       50     100     150
(100) 2      0       50     100     150
(80)  3      0       50     100     150

```

Either you can choose to select that carrot type or not.
So if you choose to select(only if you can i.e., CarrotTypeWeight < WeightBag can hold)

CarrotTypePrice + Answer(WeightBag can hold - CarrotTypeWeight) -> moving left in the table

If you choose not to select

Answer(WeightBag can hold when you don't have this type) -> moving up in the table

I hope you can visualize it. Last number matrix[n-1][n-1] will be your answer.

Body:
I would suggest building your thinking like this. Start breaking the problem in smaller parts. What if your bag is able to hold 2kg weight?

For better understanding, I am modifying the values. So let's suppose you have 3 carrot types

 let carrotTypes = [{
    price: 50,
    kg: 1
  },
  {
    price: 100,
    kg: 2
  },
  {
    price: 80,
    kg: 3
  }
];

Random small numbers so that you can get a feel of it and your bag can hold is 3Kg.

Now proceed to this problem, assuming max weight bag can handle is 0 what will be the answer then, and then increase the maximum weight one by one.
Also, what if you have only 1 type of carrot, and then increase the types of carrot.

Max Weight Bag can handle

             0       1       2        3
(50)  1      0       50     100     150
(100) 2      0       50     100     150
(80)  3      0       50     100     150

Either you can choose to select that carrot type or not.
So if you choose to select(only if you can i.e., CarrotTypeWeight < WeightBag can hold)

CarrotTypePrice + Answer(WeightBag can hold - CarrotTypeWeight) -> moving left in the table

If you choose not to select

Answer(WeightBag can hold when you don't have this type) -> moving up in the table

I hope you can visualize it. Last number matrix[n-1][n-1] will be your answer.


问:
LZ77 optimization
I have a code for LZ77 compression algorithm. It works fine with small files. But if I want to compress 100 kB and bigger files, it takes a lot of time.

I think, it's all because of this part:

```<code>do { // searchin for longest mathcing
                j++;
                i++;
                if(!lookBuffer[i]) fread(&lookBuffer[i], 1, 1, from);

                if (j == strlen(searchBuffer) && lookBuffer[addJ] == lookBuffer[i]) {
                    do {
                        i++;
                        j++;
                        if(!lookBuffer[i]) fread(&lookBuffer[i], 1, 1, from);
                        addJ++;
                    } while (lookBuffer[addJ] == lookBuffer[i] && i < lookLen);
                }
            } while (searchBuffer[j] == lookBuffer[i] && i < lookLen);
</code>```

This part searches the longest matching between search buffer and look-ahead buffer.

So, is there faster way to find this matching?

Full code for LZ77 compression:

```<code> void lz77(char *fileName, FILE *from, FILE *path, long long size) {

char *searchBuffer = (char*)malloc((searchLen) * sizeof(char)); // search array
memset(searchBuffer, 0x00, searchLen);

long i = 0, j = 0, length = 0, offset = 0, isMatching = 0, iForSearchBuff = 0, iForLookBuff = 0;
int isFirst = 1, n = 0;
unsigned char symbol;

while(!feof(from)) {
    isMatching = 0;
    length = 0;
    iForSearchBuff = 0;
    iForLookBuff = 0;
    offset = strlen(searchBuffer);
    if (isFirst) { // first symbol
        fread(searchBuffer, 1, 1, from);
        writeBit(0, 0, *searchBuffer, tmpFile); // writing(0, 0, symbol)
        isFirst = 0;
    } else {
        char *lookBuffer = (char*)malloc((lookLen) * sizeof(char)); // look array
        memset(lookBuffer, 0x00, lookLen);

        fread(lookBuffer, 1, 1, from);

        for (j = 0; j <= strlen(searchBuffer); j++) {

            i = 0;
            if (searchBuffer[j] == lookBuffer[i]) { // MATCHING
                isMatching = 1;
                long fixJ = j, fixI = i, addJ = 0;

                do { // searchin for longest mathcing
                    j++;
                    i++;
                    if(!lookBuffer[i]) fread(&lookBuffer[i], 1, 1, from);

                    if (j == strlen(searchBuffer) && lookBuffer[addJ] == lookBuffer[i]) {
                        do {
                            i++;
                            j++;
                            if(!lookBuffer[i]) fread(&lookBuffer[i], 1, 1, from);
                            addJ++;
                        } while (lookBuffer[addJ] == lookBuffer[i] && i < lookLen);
                    }
                } while (searchBuffer[j] == lookBuffer[i] && i < lookLen);

                if (((strlen(searchBuffer) - fixJ) <= offset) && ((i - fixI) >= length)) {
                    length = i - fixI;
                    offset = strlen(searchBuffer) - fixJ;
                    iForSearchBuff = fixI;
                    iForLookBuff = i;
                }

                j = fixJ;

            } else if (j >= (strlen(searchBuffer))) {
                if (isMatching) {
                    if (lookBuffer[iForLookBuff] == '\0') { writeBit(offset, length, ' ', tmpFile);}
                    else {
                        writeBit(offset, length, lookBuffer[iForLookBuff], tmpFile);
                        searchBuffer = insertIntoBuffer(searchBuffer, length + 1, &lookBuffer[iForSearchBuff]);
                    }

                    isMatching = 0;
                    break;
                } else {
                    writeBit(0, 0, lookBuffer[i], tmpFile);

                    searchBuffer = insertIntoBuffer(searchBuffer, 1, &lookBuffer[i]);
                    break;
                }
            }

        }
    }
}
</code>```

}

答:
I'm not an expert, but clever people have devised efficient search algorithms that may apply here.
For example check out the Knuth–Morris–Pratt algorithm https://en.wikipedia.org/wiki/Knuth%E2%80%93Morris%E2%80%93Pratt_algorithm</p>

Title: LZ77 optimization

Body:
I have a code for LZ77 compression algorithm. It works fine with small files. But if I want to compress 100 kB and bigger files, it takes a lot of time.

I think, it's all because of this part:

do { // searchin for longest mathcing
                j++;
                i++;
                if(!lookBuffer[i]) fread(&lookBuffer[i], 1, 1, from);

                if (j == strlen(searchBuffer) && lookBuffer[addJ] == lookBuffer[i]) {
                    do {
                        i++;
                        j++;
                        if(!lookBuffer[i]) fread(&lookBuffer[i], 1, 1, from);
                        addJ++;
                    } while (lookBuffer[addJ] == lookBuffer[i] && i < lookLen);
                }
            } while (searchBuffer[j] == lookBuffer[i] && i < lookLen);

This part searches the longest matching between search buffer and look-ahead buffer.

So, is there faster way to find this matching?

Full code for LZ77 compression:

 void lz77(char *fileName, FILE *from, FILE *path, long long size) {

char *searchBuffer = (char*)malloc((searchLen) * sizeof(char)); // search array
memset(searchBuffer, 0x00, searchLen);

long i = 0, j = 0, length = 0, offset = 0, isMatching = 0, iForSearchBuff = 0, iForLookBuff = 0;
int isFirst = 1, n = 0;
unsigned char symbol;

while(!feof(from)) {
    isMatching = 0;
    length = 0;
    iForSearchBuff = 0;
    iForLookBuff = 0;
    offset = strlen(searchBuffer);
    if (isFirst) { // first symbol
        fread(searchBuffer, 1, 1, from);
        writeBit(0, 0, *searchBuffer, tmpFile); // writing(0, 0, symbol)
        isFirst = 0;
    } else {
        char *lookBuffer = (char*)malloc((lookLen) * sizeof(char)); // look array
        memset(lookBuffer, 0x00, lookLen);

        fread(lookBuffer, 1, 1, from);

        for (j = 0; j <= strlen(searchBuffer); j++) {

            i = 0;
            if (searchBuffer[j] == lookBuffer[i]) { // MATCHING
                isMatching = 1;
                long fixJ = j, fixI = i, addJ = 0;

                do { // searchin for longest mathcing
                    j++;
                    i++;
                    if(!lookBuffer[i]) fread(&lookBuffer[i], 1, 1, from);

                    if (j == strlen(searchBuffer) && lookBuffer[addJ] == lookBuffer[i]) {
                        do {
                            i++;
                            j++;
                            if(!lookBuffer[i]) fread(&lookBuffer[i], 1, 1, from);
                            addJ++;
                        } while (lookBuffer[addJ] == lookBuffer[i] && i < lookLen);
                    }
                } while (searchBuffer[j] == lookBuffer[i] && i < lookLen);

                if (((strlen(searchBuffer) - fixJ) <= offset) && ((i - fixI) >= length)) {
                    length = i - fixI;
                    offset = strlen(searchBuffer) - fixJ;
                    iForSearchBuff = fixI;
                    iForLookBuff = i;
                }

                j = fixJ;

            } else if (j >= (strlen(searchBuffer))) {
                if (isMatching) {
                    if (lookBuffer[iForLookBuff] == '\0') { writeBit(offset, length, ' ', tmpFile);}
                    else {
                        writeBit(offset, length, lookBuffer[iForLookBuff], tmpFile);
                        searchBuffer = insertIntoBuffer(searchBuffer, length + 1, &lookBuffer[iForSearchBuff]);
                    }

                    isMatching = 0;
                    break;
                } else {
                    writeBit(0, 0, lookBuffer[i], tmpFile);

                    searchBuffer = insertIntoBuffer(searchBuffer, 1, &lookBuffer[i]);
                    break;
                }
            }

        }
    }
}

}


问:
CSS and Bootstrap not loading in Rails 6 app when deployed to Heroku
I have a Rails 6 project with the default webpacker. I loaded bootstrap and jQuery by followign a tutorial and everything works locally.
Here's the structure of the relevant files:

app/javascript/packs/application.js

```<code>require("@rails/ujs").start()
require("turbolinks").start()
require("@rails/activestorage").start()
require("channels")
require('jquery')

#This file that is being imported handles importing in bootstrap and custom CSS files
import '../stylesheets/application'
</code>```

app/javascript/stylesheets/applications.scss

```<code>@import "~bootstrap/scss/bootstrap";
#files below are custom css files
@import "reset";
@import "general";
@import "header";
@import "menu-overlay";
</code>```

It works locally but when I deploy it to Heroku, the bootstrap styles nad my custom css do not show up.

Things I've tried

1) I've tried running rake assets:precompile locally then deploying it again

2) I've tried running the rake assets precompile in the Heroku CLI: heroku rake assets:precompile --app staging-app

3) I've added this line to my environments/production.rb file
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?

I noticed that whenever I make any changes locally to my assets, the console shows webpacker compiling.. Could it be Heroku is not running my webpacker compile?

Do I have to add a dependency to start he webpacker server in production in my package.json file?

```<code>"dependencies": {
    "@rails/actioncable": "^6.0.0-alpha",
    "@rails/activestorage": "^6.0.0-alpha",
    "@rails/ujs": "^6.0.0-alpha",
    "@rails/webpacker": "^4.0.7",
    "bootstrap": "^4.3.1",
    "jquery": "^3.4.1",
    "popper.js": "^1.15.0",
    "turbolinks": "^5.2.0"
  },
  "version": "0.1.0",
  "devDependencies": {
    "webpack-dev-server": "^3.8.2"
  }
</code>```

Thanks for any inputs!

Edit 1
Here is the output of my heroku logs:

```<code>-----> Ruby app detected
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-2.6.3
-----> Installing dependencies using bundler 1.17.3
       Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
       The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`.
       Using rake 13.0.0
       Using concurrent-ruby 1.1.5
       Using i18n 1.7.0
       Using minitest 5.12.2
       Using thread_safe 0.3.6
       Using tzinfo 1.2.5
       Using zeitwerk 2.1.10
       Using activesupport 6.0.0
       Using builder 3.2.3
       Using erubi 1.9.0
       Using mini_portile2 2.4.0
       Using nokogiri 1.10.4
       Using rails-dom-testing 2.0.3
       Using crass 1.0.4
       Using loofah 2.3.0
       Using rails-html-sanitizer 1.2.0
       Using actionview 6.0.0
       Using rack 2.0.7
       Using rack-test 1.1.0
       Using actionpack 6.0.0
       Using nio4r 2.5.2
       Using websocket-extensions 0.1.4
       Using websocket-driver 0.7.1
       Using actioncable 6.0.0
       Using globalid 0.4.2
       Using activejob 6.0.0
       Using activemodel 6.0.0
       Using activerecord 6.0.0
       Using mimemagic 0.3.3
       Using marcel 0.3.3
       Using activestorage 6.0.0
       Using mini_mime 1.0.2
       Using mail 2.7.1
       Using actionmailbox 6.0.0
       Using actionmailer 6.0.0
       Using actiontext 6.0.0
       Using msgpack 1.3.1
       Using bootsnap 1.4.5
       Using bootstrap_form 4.3.0
       Using bundler 1.17.3
       Using dotenv 2.7.5
       Using method_source 0.9.2
       Using thor 0.20.3
       Using railties 6.0.0
       Using dotenv-rails 2.7.5
       Using erubis 2.7.0
       Using ffi 1.11.1
       Using temple 0.8.2
       Using tilt 2.0.10
       Using haml 5.1.2
       Using sexp_processor 4.13.0
       Using ruby_parser 3.14.0
       Using html2haml 2.2.0
       Using haml-rails 2.0.1
       Using jbuilder 2.9.1
       Using pg 1.1.4
       Using puma 3.12.1
       Using rack-proxy 0.6.5
       Using sprockets 3.7.2
       Using sprockets-rails 3.2.1
       Using rails 6.0.0
       Using rb-fsevent 0.10.3
       Using rb-inotify 0.10.0
       Using sass-listen 4.0.0
       Using sass 3.7.4
       Using sass-rails 5.1.0
       Using turbolinks-source 5.2.0
       Using turbolinks 5.2.1
       Using webpacker 4.0.7
       Bundle complete! 26 Gemfile dependencies, 69 gems now installed.
       Gems in the groups development and test were not installed.
       Bundled gems are installed into `./vendor/bundle`
       Bundle completed (0.47s)
       Cleaning up the bundler cache.
       The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`.
-----> Installing node-v10.15.3-linux-x64
-----> Installing yarn-v1.16.0
-----> Detecting rake tasks
-----> Preparing app for Rails asset pipeline
       Running: rake assets:precompile
       yarn install v1.16.0
       [1/4] Resolving packages...
       [2/4] Fetching packages...
       info fsevents@1.2.9: The platform "linux" is incompatible with this module.
       info "fsevents@1.2.9" is an optional dependency and failed compatibility check. Excluding it from installation.
       [3/4] Linking dependencies...
       warning " > webpack-dev-server@3.8.2" has unmet peer dependency "webpack@^4.0.0".
       warning "webpack-dev-server > webpack-dev-middleware@3.7.2" has unmet peer dependency "webpack@^4.0.0".
       [4/4] Building fresh packages...
       Done in 21.74s.
       Compiling…
       Compiled all packs in /tmp/build_779b19b5de4194c7cd435766a173995c/public/packs
       Asset precompilation completed (45.01s)
       Cleaning assets
       Running: rake assets:clean
-----> Detecting rails configuration
###### WARNING:
       You set your `config.active_storage.service` to :local in production.
       If you are uploading files to this app, they will not persist after the app
       is restarted, on one-off dynos, or if the app has multiple dynos.
       Heroku applications have an ephemeral file system. To
       persist uploaded files, please use a service such as S3 and update your Rails
       configuration.

       For more information can be found in this article:
         https://devcenter.heroku.com/articles/active-storage-on-heroku

###### WARNING:
       We detected that some binary dependencies required to
       use all the preview features of Active Storage are not
       present on this system.

       For more information please see:
         https://devcenter.heroku.com/articles/active-storage-on-heroku

###### WARNING:
       No Procfile detected, using the default web server.
       We recommend explicitly declaring how to boot your server process via a Procfile.
       https://devcenter.heroku.com/articles/ruby-default-web-server
-----> Discovering process types
       Procfile declares types     -> (none)
       Default types for buildpack -> console, rake, web
-----> Compressing...
       Done: 61.3M
-----> Launching...
       Released v17
       https://career-lode-stage.herokuapp.com/ deployed to Heroku
</code>```

As for errors in the console, there's no error. I ran heroku logs --app staging and there were no errors. I also opened up the inspector and there were no errors

Edit 3
I've added a test javascript file in packs which I then imported in from my application.js file:

```<code>require("@rails/ujs").start()
require("turbolinks").start()
require("@rails/activestorage").start()
require("channels")
require('jquery')

import './test.js'
import '../stylesheets/application'
</code>```

In my test.js file I had some code which output to the console and it works. I would expect it to not work if the css fiels are not working/brought it but it seems that the javascript files works.

答:
Had same problem! Heroku needs both solutions mention above:

layouts>application.html.erb

```<code>stylesheet_pack_tag "application", media: 'all', 'data-turbolinks-track': 'reload'
</code>```

-and-

assets/stylesheets/application.scss

-or- (where ever your main stylesheet exists)

assets/javascript/stylesheets/application.scss

```<code>@import "bootstrap/scss/bootstrap.scss";
</code>```

You'll notice that your local dev server will need the <%= stylesheet_link_tag ... %>

just switch it out for the <%= stylesheet_pack_tag ... %> when pushing to Heroku for production.

Hope this clarifies :)

Body:
I have a Rails 6 project with the default webpacker. I loaded bootstrap and jQuery by followign a tutorial and everything works locally.
Here's the structure of the relevant files:

app/javascript/packs/application.js

require("@rails/ujs").start()
require("turbolinks").start()
require("@rails/activestorage").start()
require("channels")
require('jquery')

#This file that is being imported handles importing in bootstrap and custom CSS files
import '../stylesheets/application'

app/javascript/stylesheets/applications.scss

@import "~bootstrap/scss/bootstrap";
#files below are custom css files
@import "reset";
@import "general";
@import "header";
@import "menu-overlay";

It works locally but when I deploy it to Heroku, the bootstrap styles nad my custom css do not show up.

Things I've tried

1) I've tried running rake assets:precompile locally then deploying it again

2) I've tried running the rake assets precompile in the Heroku CLI: heroku rake assets:precompile --app staging-app

3) I've added this line to my environments/production.rb file
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?

I noticed that whenever I make any changes locally to my assets, the console shows webpacker compiling.. Could it be Heroku is not running my webpacker compile?

Do I have to add a dependency to start he webpacker server in production in my package.json file?

"dependencies": {
    "@rails/actioncable": "^6.0.0-alpha",
    "@rails/activestorage": "^6.0.0-alpha",
    "@rails/ujs": "^6.0.0-alpha",
    "@rails/webpacker": "^4.0.7",
    "bootstrap": "^4.3.1",
    "jquery": "^3.4.1",
    "popper.js": "^1.15.0",
    "turbolinks": "^5.2.0"
  },
  "version": "0.1.0",
  "devDependencies": {
    "webpack-dev-server": "^3.8.2"
  }

Thanks for any inputs!

Edit 1
Here is the output of my heroku logs:

-----> Ruby app detected
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-2.6.3
-----> Installing dependencies using bundler 1.17.3
       Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
       The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`.
       Using rake 13.0.0
       Using concurrent-ruby 1.1.5
       Using i18n 1.7.0
       Using minitest 5.12.2
       Using thread_safe 0.3.6
       Using tzinfo 1.2.5
       Using zeitwerk 2.1.10
       Using activesupport 6.0.0
       Using builder 3.2.3
       Using erubi 1.9.0
       Using mini_portile2 2.4.0
       Using nokogiri 1.10.4
       Using rails-dom-testing 2.0.3
       Using crass 1.0.4
       Using loofah 2.3.0
       Using rails-html-sanitizer 1.2.0
       Using actionview 6.0.0
       Using rack 2.0.7
       Using rack-test 1.1.0
       Using actionpack 6.0.0
       Using nio4r 2.5.2
       Using websocket-extensions 0.1.4
       Using websocket-driver 0.7.1
       Using actioncable 6.0.0
       Using globalid 0.4.2
       Using activejob 6.0.0
       Using activemodel 6.0.0
       Using activerecord 6.0.0
       Using mimemagic 0.3.3
       Using marcel 0.3.3
       Using activestorage 6.0.0
       Using mini_mime 1.0.2
       Using mail 2.7.1
       Using actionmailbox 6.0.0
       Using actionmailer 6.0.0
       Using actiontext 6.0.0
       Using msgpack 1.3.1
       Using bootsnap 1.4.5
       Using bootstrap_form 4.3.0
       Using bundler 1.17.3
       Using dotenv 2.7.5
       Using method_source 0.9.2
       Using thor 0.20.3
       Using railties 6.0.0
       Using dotenv-rails 2.7.5
       Using erubis 2.7.0
       Using ffi 1.11.1
       Using temple 0.8.2
       Using tilt 2.0.10
       Using haml 5.1.2
       Using sexp_processor 4.13.0
       Using ruby_parser 3.14.0
       Using html2haml 2.2.0
       Using haml-rails 2.0.1
       Using jbuilder 2.9.1
       Using pg 1.1.4
       Using puma 3.12.1
       Using rack-proxy 0.6.5
       Using sprockets 3.7.2
       Using sprockets-rails 3.2.1
       Using rails 6.0.0
       Using rb-fsevent 0.10.3
       Using rb-inotify 0.10.0
       Using sass-listen 4.0.0
       Using sass 3.7.4
       Using sass-rails 5.1.0
       Using turbolinks-source 5.2.0
       Using turbolinks 5.2.1
       Using webpacker 4.0.7
       Bundle complete! 26 Gemfile dependencies, 69 gems now installed.
       Gems in the groups development and test were not installed.
       Bundled gems are installed into `./vendor/bundle`
       Bundle completed (0.47s)
       Cleaning up the bundler cache.
       The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`.
-----> Installing node-v10.15.3-linux-x64
-----> Installing yarn-v1.16.0
-----> Detecting rake tasks
-----> Preparing app for Rails asset pipeline
       Running: rake assets:precompile
       yarn install v1.16.0
       [1/4] Resolving packages...
       [2/4] Fetching packages...
       info fsevents@1.2.9: The platform "linux" is incompatible with this module.
       info "fsevents@1.2.9" is an optional dependency and failed compatibility check. Excluding it from installation.
       [3/4] Linking dependencies...
       warning " > webpack-dev-server@3.8.2" has unmet peer dependency "webpack@^4.0.0".
       warning "webpack-dev-server > webpack-dev-middleware@3.7.2" has unmet peer dependency "webpack@^4.0.0".
       [4/4] Building fresh packages...
       Done in 21.74s.
       Compiling…
       Compiled all packs in /tmp/build_779b19b5de4194c7cd435766a173995c/public/packs
       Asset precompilation completed (45.01s)
       Cleaning assets
       Running: rake assets:clean
-----> Detecting rails configuration
###### WARNING:
       You set your `config.active_storage.service` to :local in production.
       If you are uploading files to this app, they will not persist after the app
       is restarted, on one-off dynos, or if the app has multiple dynos.
       Heroku applications have an ephemeral file system. To
       persist uploaded files, please use a service such as S3 and update your Rails
       configuration.

       For more information can be found in this article:
         https://devcenter.heroku.com/articles/active-storage-on-heroku

###### WARNING:
       We detected that some binary dependencies required to
       use all the preview features of Active Storage are not
       present on this system.

       For more information please see:
         https://devcenter.heroku.com/articles/active-storage-on-heroku

###### WARNING:
       No Procfile detected, using the default web server.
       We recommend explicitly declaring how to boot your server process via a Procfile.
       https://devcenter.heroku.com/articles/ruby-default-web-server
-----> Discovering process types
       Procfile declares types     -> (none)
       Default types for buildpack -> console, rake, web
-----> Compressing...
       Done: 61.3M
-----> Launching...
       Released v17
       https://career-lode-stage.herokuapp.com/ deployed to Heroku

As for errors in the console, there's no error. I ran heroku logs --app staging and there were no errors. I also opened up the inspector and there were no errors

Edit 3
I've added a test javascript file in packs which I then imported in from my application.js file:

require("@rails/ujs").start()
require("turbolinks").start()
require("@rails/activestorage").start()
require("channels")
require('jquery')

import './test.js'
import '../stylesheets/application'

In my test.js file I had some code which output to the console and it works. I would expect it to not work if the css fiels are not working/brought it but it seems that the javascript files works.

Body:
Had same problem! Heroku needs both solutions mention above:

layouts>application.html.erb

stylesheet_pack_tag "application", media: 'all', 'data-turbolinks-track': 'reload'

-and-

assets/stylesheets/application.scss

-or- (where ever your main stylesheet exists)

assets/javascript/stylesheets/application.scss

@import "bootstrap/scss/bootstrap.scss";

You'll notice that your local dev server will need the <%= stylesheet_link_tag ... %>

just switch it out for the <%= stylesheet_pack_tag ... %> when pushing to Heroku for production.

Hope this clarifies :)


问:
Swift didSet for var that gets changed in child with @Binding
I have something of the following:

```<code>struct ContentView: View {
    @State var a = 0 {
        didSet {
            print("Change detected in Parent")
        }
    }
    var body: some View {
        VStack{
            Text(String(self.a))
            Content2(a: self.$a)
        }
    }
}

struct Content2: View {
    @Binding var a: Int {
        didSet {
            print("Change detected in Child")
        }
    }

    var body: some View {
        Text(String(a)).onTapGesture {
            if self.a == 1 {
                self.a = 2
            }else {
                self.a = 1
            }

        }
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

</code>```

Why is the didSet of the parent never called? As it is clearly changing. How can I make sure it gets called or notified in some other way?

It is important to me to take notice of the change on the ContentView and not outsource this to a PublishableObject. As I want to make further changes on the ContentView once this change has been detected. Catching the didSet on an outsourced Class would not help.

To clear things up my use case is as follows:
I am counting up a Int on the child View. Once this Int reached a certain number it should trigger a new Firebase getDocuments function on the ParentView.

答:
Here is a solution for your use-case</p>

```<code>struct ContentView_: View {
    @State var a = 0

    var body: some View {
        let counterBinding = Binding( // << proxy biding
            get: { self.a },
            set: {
                self.a = $0  // decision case below
//                if $0 > CONSTANT {
//                   // ... call getDocuments here
//                }
            }
        )
        return VStack{
            Text(String(self.a))
            Content2(a: counterBinding) // inject proxy !!
        }
    }
}

struct Content2: View {
    @Binding var a: Int

    var body: some View {
        Text(String(a)).onTapGesture {
            if self.a == 1 {
                self.a = 2
            }else {
                self.a = 1
            }
        }
    }
}
</code>```

Body:
I have something of the following:

struct ContentView: View {
    @State var a = 0 {
        didSet {
            print("Change detected in Parent")
        }
    }
    var body: some View {
        VStack{
            Text(String(self.a))
            Content2(a: self.$a)
        }
    }
}

struct Content2: View {
    @Binding var a: Int {
        didSet {
            print("Change detected in Child")
        }
    }

    var body: some View {
        Text(String(a)).onTapGesture {
            if self.a == 1 {
                self.a = 2
            }else {
                self.a = 1
            }

        }
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

Why is the didSet of the parent never called? As it is clearly changing. How can I make sure it gets called or notified in some other way?

It is important to me to take notice of the change on the ContentView and not outsource this to a PublishableObject. As I want to make further changes on the ContentView once this change has been detected. Catching the didSet on an outsourced Class would not help.

To clear things up my use case is as follows:
I am counting up a Int on the child View. Once this Int reached a certain number it should trigger a new Firebase getDocuments function on the ParentView.

Body:
Here is a solution for your use-case

struct ContentView_: View {
    @State var a = 0

    var body: some View {
        let counterBinding = Binding( // << proxy biding
            get: { self.a },
            set: {
                self.a = $0  // decision case below
//                if $0 > CONSTANT {
//                   // ... call getDocuments here
//                }
            }
        )
        return VStack{
            Text(String(self.a))
            Content2(a: counterBinding) // inject proxy !!
        }
    }
}

struct Content2: View {
    @Binding var a: Int

    var body: some View {
        Text(String(a)).onTapGesture {
            if self.a == 1 {
                self.a = 2
            }else {
                self.a = 1
            }
        }
    }
}


问:
Why does Tkinter make a new window for my button?
Im trying to add a button into my window, but it makes a new window for the button, how can I add it to the same window where I have a background on?</p>

```<code>from tkinter import *
from tkinter.filedialog import askopenfilename
from tkinter import messagebox
from PIL import ImageTk

top = Tk()

C = Canvas(top, bg ="blue", height=1920, width=1080)
filename = ImageTk.PhotoImage(file = "C:/Users/plapl/Desktop/ching.jpg")
background_label = Label(top, image=filename)
background_label.place(x=0, y=0, relwidth=1, relheight=1)
C.pack()

root = Tk()

myButton = Button(root, text = "Add a task")
myButton.pack()

root.mainloop()
</code>```

答:
It's because you have created a new instance for Tk().
change it to this:</p>

```<code>from tkinter import *
from tkinter.filedialog import askopenfilename
from tkinter import messagebox
from PIL import ImageTk

top = Tk()

C = Canvas(top, bg ="blue", height=1920, width=1080)
filename = ImageTk.PhotoImage(file = "C:/Users/plapl/Desktop/ching.jpg")
background_label = Label(top, image=filename)
background_label.place(x=0, y=0, relwidth=1, relheight=1)
C.pack()

myButton = Button(top, text = "Add a task")
myButton.pack()

root.mainloop()
</code>```

Body:
Im trying to add a button into my window, but it makes a new window for the button, how can I add it to the same window where I have a background on?

from tkinter import *
from tkinter.filedialog import askopenfilename
from tkinter import messagebox
from PIL import ImageTk

top = Tk()

C = Canvas(top, bg ="blue", height=1920, width=1080)
filename = ImageTk.PhotoImage(file = "C:/Users/plapl/Desktop/ching.jpg")
background_label = Label(top, image=filename)
background_label.place(x=0, y=0, relwidth=1, relheight=1)
C.pack()

root = Tk()

myButton = Button(root, text = "Add a task")
myButton.pack()

root.mainloop()

Body:
It's because you have created a new instance for Tk().
change it to this:

from tkinter import *
from tkinter.filedialog import askopenfilename
from tkinter import messagebox
from PIL import ImageTk

top = Tk()

C = Canvas(top, bg ="blue", height=1920, width=1080)
filename = ImageTk.PhotoImage(file = "C:/Users/plapl/Desktop/ching.jpg")
background_label = Label(top, image=filename)
background_label.place(x=0, y=0, relwidth=1, relheight=1)
C.pack()

myButton = Button(top, text = "Add a task")
myButton.pack()

root.mainloop()


问:
iPhone Status Bar for custom message ala Evernote, In-Call, etc
I am trying to find how to implement a custom message on the status bar, something like the Evernote "Downloading changes..." message seen here.

Is this a private API call?  Any suggestions or pointers?

答:
As @sam has pointed out, MTStatusBarOverlay is a good choice and I'm currently using it in my apps.  However I just found something that exactly fits what the original poster (and I) have been looking for.  I love all the folks on GitHub who see some cool UI element in a new app and recreate it for the masses ... this is one of those cases.  Awesomeness!
Tweetbot-Like Alert Panels (Blog), and the repository is MKInfoPanelDemo at Github.

ContentLicense: CC BY-SA 2.5

ContentLicense: CC BY-SA 3.0


问:
Is there a way to make gitlab runnder produce a verbose output on deploy
Here is my job from .gitlab-ci.yml

```<code>deploy:
  variables:
    CI_DEBUG_TRACE: "true"
  stage: deploy
  image: registry.gitlab.com/gitlab-org/cloud-deploy aws-base:latest # see the note below
  script:
    - aws s3 ...
    - aws create-deployment ...
  only:
    - master
</code>```

the deployment process fails with
 ERROR: Preparation failed: invalid reference format (docker.go:198:0s)

trace variable has no effect on output.

答:
Thank you very much. But the build process still fails. Here are new logs:  </p>

```<code> ++ export CI_DEBUG_TRACE=true
 ++ CI_DEBUG_TRACE=true
 ++ export CI_DISPOSABLE_ENVIRONMENT=true
 ++ CI_DISPOSABLE_ENVIRONMENT=true
 ++ export CI_RUNNER_VERSION=13.0.0
 ++ CI_RUNNER_VERSION=13.0.0
 ++ export CI_RUNNER_REVISION=c127439c
 ++ CI_RUNNER_REVISION=c127439c
 ++ export CI_RUNNER_EXECUTABLE_ARCH=linux/amd64
 ++ CI_RUNNER_EXECUTABLE_ARCH=linux/amd64
 ++ cd /builds/Zyubenko/humans
 + exit 0
 ERROR: Job failed: exit code 1
</code>```

Body:
Here is my job from .gitlab-ci.yml

deploy:
  variables:
    CI_DEBUG_TRACE: "true"
  stage: deploy
  image: registry.gitlab.com/gitlab-org/cloud-deploy aws-base:latest # see the note below
  script:
    - aws s3 ...
    - aws create-deployment ...
  only:
    - master

the deployment process fails with
 ERROR: Preparation failed: invalid reference format (docker.go:198:0s)

trace variable has no effect on output.

Body:
Thank you very much. But the build process still fails. Here are new logs:

 ++ export CI_DEBUG_TRACE=true
 ++ CI_DEBUG_TRACE=true
 ++ export CI_DISPOSABLE_ENVIRONMENT=true
 ++ CI_DISPOSABLE_ENVIRONMENT=true
 ++ export CI_RUNNER_VERSION=13.0.0
 ++ CI_RUNNER_VERSION=13.0.0
 ++ export CI_RUNNER_REVISION=c127439c
 ++ CI_RUNNER_REVISION=c127439c
 ++ export CI_RUNNER_EXECUTABLE_ARCH=linux/amd64
 ++ CI_RUNNER_EXECUTABLE_ARCH=linux/amd64
 ++ cd /builds/Zyubenko/humans
 + exit 0
 ERROR: Job failed: exit code 1


问:
bootstrap responsive table content wrapping
I have HTML similar to this:

```<code>    <div class="table-responsive">
         <table class="table borderless">
             <caption>
                  <h3>Announcements</h3>
             </caption>
             <tbody>
                 <tr >
                     <td>
                         If you are waiting for your certificate from your trainer, please contact them. Our turnaround time is between 1-2 months from the time we receive your details from your trainer, which we expect to be at the start of your program. The remainder is dependent upon how quickly your trainer has send in all the required paperwork and made payment, etc.
                     </td>
                 </tr>
             </tbody>
         </table>
     </div>
</code>```

When I view the output in a small view-port, the table is re-sized properly, but the paragraph content in the table cells are not wrapped, so scroll-bars are shown. I expected the responsive behavior would have been to wrap the paragraph content. How do I achieve this?

答:
use it in css external file.</p>

```<code>.td-table
{
word-wrap: break-word;
word-break: break-all;
white-space: normal !important;
text-align: justify;
}
</code>```

Body:
I have HTML similar to this:

Announcements

                         If you are waiting for your certificate from your trainer, please contact them. Our turnaround time is between 1-2 months from the time we receive your details from your trainer, which we expect to be at the start of your program. The remainder is dependent upon how quickly your trainer has send in all the required paperwork and made payment, etc.

When I view the output in a small view-port, the table is re-sized properly, but the paragraph content in the table cells are not wrapped, so scroll-bars are shown. I expected the responsive behavior would have been to wrap the paragraph content. How do I achieve this?

Body:
use it in css external file.

.td-table
{
word-wrap: break-word;
word-break: break-all;
white-space: normal !important;
text-align: justify;
}


问:
Search box for value within range but to stay in column
Since 5 hours I am struggling with the following code, which I'd love to extend.
I simply want to mimic the built in ctrl + F search tool via an Input Box, adding the feature to stay in row/column (ActiveCell) while looking for the name (letters not numbers).

working code:

```<code>Sub Jarvis()

Dim sResult As String

  On Error Resume Next

  sResult = InputBox("Bitte Produktname angeben")

  If IsNumeric(sResult) Then 'row
    Cells(sResult, ActiveCell.Column).Select
  Else 'Select column - Here I want to add a way to search for names/values and to jump to them, while staying in the current column - Unfortunately didn't find the suiting command
    Cells(ActiveCell.Row, sResult).Select

  End If

End Sub
</code>```

not working code:

```<code>Sub Jarvis2()

Dim sResult As String

  On Error Resume Next

  sResult = InputBox("Bitte Produktname angeben")

  If IsNumeric(sResult) Then 'row
    Cells(sResult, ActiveCell.Column).Select
  Else 'Select column - Here I want to add a way to search for names/values and to jump to them, while staying in the current column - Unfortunately didn't find the suiting command
    Columns("AW2:JZ5", sResult).Select

  End If

End Sub
</code>```

Could anyone of the pros help me out?

答:
Thank you for your help PEH.

Here is my solution:

```<code> Sub Jarvis()

    Dim word, cellRange, firstAddress, c, FindNext, BottomRight As String

    word = InputBox("insert search term", "")

    If word = "" Then Exit Sub

    cellRange = "aw2:ku5"
    'change search range

    With ActiveSheet.Range(cellRange)
        Set c = .Find(word)
        If Not c Is Nothing Then
            firstAddress = c.Address
            Do
                Range(c.Address, ActiveCell).Select
                    With Selection
                        BottomRight = .Cells(.Rows.Count, .Columns.Count).Select
                    End With
            Loop While Not c Is Nothing And c.Address <> firstAddress
        End If
    End With
End Sub
</code>```

If anyone of the pros finds a more efficient way, please correct it.

Body:
Since 5 hours I am struggling with the following code, which I'd love to extend.
I simply want to mimic the built in ctrl + F search tool via an Input Box, adding the feature to stay in row/column (ActiveCell) while looking for the name (letters not numbers).

working code:

Sub Jarvis()

Dim sResult As String

  On Error Resume Next

  sResult = InputBox("Bitte Produktname angeben")

  If IsNumeric(sResult) Then 'row
    Cells(sResult, ActiveCell.Column).Select
  Else 'Select column - Here I want to add a way to search for names/values and to jump to them, while staying in the current column - Unfortunately didn't find the suiting command
    Cells(ActiveCell.Row, sResult).Select

  End If

End Sub

not working code:

Sub Jarvis2()

Dim sResult As String

  On Error Resume Next

  sResult = InputBox("Bitte Produktname angeben")

  If IsNumeric(sResult) Then 'row
    Cells(sResult, ActiveCell.Column).Select
  Else 'Select column - Here I want to add a way to search for names/values and to jump to them, while staying in the current column - Unfortunately didn't find the suiting command
    Columns("AW2:JZ5", sResult).Select

  End If

End Sub

Could anyone of the pros help me out?

Body:
Thank you for your help PEH.

Here is my solution:

 Sub Jarvis()

    Dim word, cellRange, firstAddress, c, FindNext, BottomRight As String

    word = InputBox("insert search term", "")

    If word = "" Then Exit Sub

    cellRange = "aw2:ku5"
    'change search range

    With ActiveSheet.Range(cellRange)
        Set c = .Find(word)
        If Not c Is Nothing Then
            firstAddress = c.Address
            Do
                Range(c.Address, ActiveCell).Select
                    With Selection
                        BottomRight = .Cells(.Rows.Count, .Columns.Count).Select
                    End With
            Loop While Not c Is Nothing And c.Address <> firstAddress
        End If
    End With
End Sub

If anyone of the pros finds a more efficient way, please correct it.


问:
get the value of a cell in a different worksheet by referring the name of the worksheet contains in some other cell
I want to get the value of a cell in a different worksheet by referring the name of the worksheet contains in some other cell.
For an instance, I have this formula to get the value from a cell from another sheet ='Sheet2'!H25. But I want to replace the 'Sheet2' of the formula of a cell contains the text "sheet2".
Cell A25 contains the name of a sheet titled "Sheet2" which I got from the formula =MID(CELL("filename", A1),FIND("]",CELL("filename", A1))+1,31)

So, instead of ='Sheet2'!H25 I tried the formula =INDIRECT("'" A25 & "'!" & H25) But it doesn't work. How to make it work.

P.S: A25 is in the Sheet1 and H25 is in the sheet2

答:
You just forgot to double-quote H25 .

Either:

```<code>=INDIRECT("'" & A25 & "'" & "!" & "H25")
</code>```

or

```<code>=INDIRECT("'" & A25& "'!H25")
</code>```

(the second equation combines the various parts after the sheet-name)

Body:
You just forgot to double-quote H25 .

Either:

=INDIRECT("'" & A25 & "'" & "!" & "H25")

or

=INDIRECT("'" & A25& "'!H25")

(the second equation combines the various parts after the sheet-name)


问:
S3 bucketpolicy and EMR - example
I can not find example of S3 BucketPolicy that allows only EMR to read data from it. EMR would be in the same account as S3. Anyone has any example to share?</p>

答:
I guess this will work.

{
  "Id": "Policy1590853624822",
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "Stmt1590853616750",
      "Action": "s3:*",
      "Effect": "Allow",
      "Resource": [
        "arn:aws:s3:::my-bucket",
        "arn:aws:s3:::my-bucket/*"
      ],
      "Principal": {
        "AWS": [
          "arn:aws:elasticmapreduce:us-east-1:1234567890:cluster/*"
        ]
      }
    }
  ]
}
```

You can create your own policies here in aws policy generator

Title: S3 bucketpolicy and EMR - example

Body:
I guess this will work.

{
  "Id": "Policy1590853624822",
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "Stmt1590853616750",
      "Action": "s3:*",
      "Effect": "Allow",
      "Resource": [
        "arn:aws:s3:::my-bucket",
        "arn:aws:s3:::my-bucket/*"
      ],
      "Principal": {
        "AWS": [
          "arn:aws:elasticmapreduce:us-east-1:1234567890:cluster/*"
        ]
      }
    }
  ]
}

You can create your own policies here in aws policy generator


问:
Field must be entered not shown
I have a required field. It has two triggers:

key next item

when validate item

The built-in message FRM-40202 - field must be entered is not shown in status bar, but when I delete key next item trigger it is shown .

Please, explain to me why this happened and how can I solve this or - at least -  how to show the built in message .

thanks

答:
Check form's Property Palette, its "Validation Unit" property. What is it set to? Should be "Item" if you want that validation fires when you leave that required item.

Apart from that, KEY-NEXT-ITEM trigger is here for backward compatibility to Forms 3.0 which was the last version that used character mode, where there was no mouse involved (i.e. navigation was only through keyboard actions).

Nowadays, people use mouse and click here and click there to move through the form, so there's no guarantee that KEY-NEXT-ITEM will ever fire. Its code should be moved to WHEN-VALIDATE-ITEM which you already have. So, if both of them contain same code, and if you (as you said) deleted the KEY-NEXT-ITEM trigger, so be it. It is useless anyway.

Title: Field must be entered not shown


问:
Deleting last linked list
I can't seem to get rid of an extra linked list. I know there are many ways to do it, but i just want to a simple way of freeing it because it was created as an extra in my loop. here's the code:</p>

```<code>    current = first = malloc (sizeof (NODE));
    while( fscanf( fin, "%s", current -> seq) != EOF) {
            for (i = 0; i < 300; i++){
                    if (current->seq[i] == 'a')
                            current->seq[i] = 'A';
                    else if (current->seq[i] == 't')
                            current->seq[i] = 'T';
                    else if(current->seq[i] == 'g')
                            current->seq[i] = 'G';
                    else if(current->seq[i] == 'c')
                            current->seq[i] = 'C';
            }
            if ( (current -> next = malloc ( sizeof(NODE) ) ) == NULL){
                    fprintf(fout, "Out of memory\nCan't add more DNA sequences\n");
                    return EXIT_FAILURE;
            }
            current = current -> next;
    }
</code>```

答:
replace last part of code with</p>

```<code>prev= NULL;
current = first =...
...
} //end if
prev = current;
current = current->next;
} //end while

free(current)
if(prev !=NULL)
prev->next = Null;
</code>```

Title: Deleting last linked list

Body:
I can't seem to get rid of an extra linked list. I know there are many ways to do it, but i just want to a simple way of freeing it because it was created as an extra in my loop. here's the code:

    current = first = malloc (sizeof (NODE));
    while( fscanf( fin, "%s", current -> seq) != EOF) {
            for (i = 0; i < 300; i++){
                    if (current->seq[i] == 'a')
                            current->seq[i] = 'A';
                    else if (current->seq[i] == 't')
                            current->seq[i] = 'T';
                    else if(current->seq[i] == 'g')
                            current->seq[i] = 'G';
                    else if(current->seq[i] == 'c')
                            current->seq[i] = 'C';
            }
            if ( (current -> next = malloc ( sizeof(NODE) ) ) == NULL){
                    fprintf(fout, "Out of memory\nCan't add more DNA sequences\n");
                    return EXIT_FAILURE;
            }
            current = current -> next;
    }

Body:
replace last part of code with

prev= NULL;
current = first =...
...
} //end if
prev = current;
current = current->next;
} //end while

free(current)
if(prev !=NULL)
prev->next = Null;


问:
How to get file size in byte using wc -c
when I use the command to get the file size in bye using wc -c the command return two values, the size in byte and the file name, ex:
the output for wc -c my_file is 322 my_file
I need to get only the first value to use it if condition, and I need to use this specific command not any other one..
Any help please, thank you.

答:
Redirect stdin and wc wont know or echo the file name

```<code>wc -c < my_file
</code>```

Body:
Redirect stdin and wc wont know or echo the file name

wc -c < my_file


问:
Unexpected result of fromkeys method
I am new to Python and learning its basics.

I came across this piece of code:

```<code>keys = {'a', 'e', 'i', 'o', 'u' }
vowels = dict.fromkeys(keys)
print(vowels)
</code>```

My expectation was that the output will be like:

```<code>{'a': None, 'e': None, 'i': None, 'o': None, 'u': None}
</code>```

But when I executed this piece of code in pyCharm, I got the following as the result:

```<code>{'u': None, 'o': None, 'e': None, 'a': None, 'i': None}
</code>```

Please help me to understand what is happening here. Is there any logic behind it?

Edit 1 (After initial comments on the question):

My understanding is the following:

when the dictionary 'keys' was created, the memory blocks would have been assigned in that sequence of keys, with the address of the next member block (like a linked list).

when the 'fromkeys' method will get executed, it will follow the same pattern and will get a clone.

答:
set is not an ordered iterable object in Python. so when you iterate you get random item.

but when make keys as a list or tuple object you get what you want:

```<code>keys = ['a', 'e', 'i', 'o', 'u']
vowels = dict.fromkeys(keys)
print(vowels)
#{'a': None, 'e': None, 'i': None, 'o': None, 'u': None}
</code>```

Title: Unexpected result of fromkeys method

Body:
I am new to Python and learning its basics.

I came across this piece of code:

keys = {'a', 'e', 'i', 'o', 'u' }
vowels = dict.fromkeys(keys)
print(vowels)

My expectation was that the output will be like:

{'a': None, 'e': None, 'i': None, 'o': None, 'u': None}

But when I executed this piece of code in pyCharm, I got the following as the result:

{'u': None, 'o': None, 'e': None, 'a': None, 'i': None}

Please help me to understand what is happening here. Is there any logic behind it?

Edit 1 (After initial comments on the question):

My understanding is the following:

when the dictionary 'keys' was created, the memory blocks would have been assigned in that sequence of keys, with the address of the next member block (like a linked list).

when the 'fromkeys' method will get executed, it will follow the same pattern and will get a clone.

Body:
set is not an ordered iterable object in Python. so when you iterate you get random item.

but when make keys as a list or tuple object you get what you want:

keys = ['a', 'e', 'i', 'o', 'u']
vowels = dict.fromkeys(keys)
print(vowels)
#{'a': None, 'e': None, 'i': None, 'o': None, 'u': None}


问:
How to delete ALL Azure resources with powershell
I need to empty my Azure account from all resources and there's too much to remove individually in the portal. Looking for a powershell script to do this. Thanks.</p>

答:
here is a one-line (please log in using az login)</p>

```<code>az group list | ConvertFrom-Json | % {az group delete --name $_.name -y}
</code>```

Body:
here is a one-line (please log in using az login)

az group list | ConvertFrom-Json | % {az group delete --name $_.name -y}


问:
How do I get the index of the common integer element from two separate lists and plug it to another list?

I have 3 lists.

```<code>A_set = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
</code>```

```<code>Q_act = [2, 3]
</code>```

```<code>dur = [0, 4, 5, 2, 1, 3, 4, 8, 2, 3]
</code>```

All lists are integers.

What I am trying to do is to compare Q_act with A_set then obtain the indices of the numbers that match from A_set.

(Example:
Q_act has the elements [2,3]
it is located in indices [1,2] from A_set)

Afterwards, I will use those indices to obtain the corresponding value in dur and store this in a list called p_dur_Q_act.

(Example: using the result from the previous example, [1,2]

The values in the dur list corresponding to the indices [1,2] should be stored in another list called p_dur_Q_act

i.e. [4,5] should be the values stored in the list p_dur_Q_act)

So, how do I get the index of the common integer element (which is [1,2]) from two separate lists and plug it to another list?

So far here are the code(s) I used:

This one, I wrote because it returns the index. But not [4,5].

```<code>p_Q = set(Q_act).intersection(A_set)
    p_dur_Q_act = [i + 1 for i, x in enumerate(p_Q)]
    print(p_dur_Q_act)
</code>```

I also tried this but I receive an error TypeError: argument of type 'int' is not iterable

```<code> p_dur_Q_act = [i + 1 for i, x in enumerate(Q_act) if any(elem in x for elem in A_set)]
    print(p_dur_Q_act)
</code>```

答:
Use index function to get the index of the element in the list.</p>

```<code>>>> a_set = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
>>> q_act = [2, 3]
>>> dur = [0, 4, 5, 2, 1, 3, 4, 8, 2, 3]
>>>
>>> print([dur[a_set.index(q)] for q in set(a_set).intersection(q_act)])

[4, 5]
</code>```

Body:
I have 3 lists.

A_set = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

Q_act = [2, 3]

dur = [0, 4, 5, 2, 1, 3, 4, 8, 2, 3]

All lists are integers.

What I am trying to do is to compare Q_act with A_set then obtain the indices of the numbers that match from A_set.

(Example:
Q_act has the elements [2,3]
it is located in indices [1,2] from A_set)

Afterwards, I will use those indices to obtain the corresponding value in dur and store this in a list called p_dur_Q_act.

(Example: using the result from the previous example, [1,2]

The values in the dur list corresponding to the indices [1,2] should be stored in another list called p_dur_Q_act

i.e. [4,5] should be the values stored in the list p_dur_Q_act)

So, how do I get the index of the common integer element (which is [1,2]) from two separate lists and plug it to another list?

So far here are the code(s) I used:

This one, I wrote because it returns the index. But not [4,5].

p_Q = set(Q_act).intersection(A_set)
    p_dur_Q_act = [i + 1 for i, x in enumerate(p_Q)]
    print(p_dur_Q_act)

I also tried this but I receive an error TypeError: argument of type 'int' is not iterable

 p_dur_Q_act = [i + 1 for i, x in enumerate(Q_act) if any(elem in x for elem in A_set)]
    print(p_dur_Q_act)

Body:
Use index function to get the index of the element in the list.

>>> a_set = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
>>> q_act = [2, 3]
>>> dur = [0, 4, 5, 2, 1, 3, 4, 8, 2, 3]
>>>
>>> print([dur[a_set.index(q)] for q in set(a_set).intersection(q_act)])

[4, 5]


问:
Import a remote repository as subdirectory with full history
I want to merge and decouple from a remote repository as subdirectory with full history. There are several ways and questions how to do that.

My first try was to use subtree but it seems not to rewrite the history of the files, so I can't look into the history of the merged repository.

Next try was to manual merge it like Seth Robertson shown up in his answer:

And the trick to making this work: force Git to recognize the rename
  by creating a subdirectory and moving the contents into it.

```<code>mkdir bdir
git mv B bdir
git commit -a -m bdir-rename
</code>```

Return to repository "A" and fetch and merge the contents of "B":

```<code>cd ../a
git remote add -f B ../b
git merge -s ours --no-commit B/master
git read-tree --prefix= -u B/master
git commit -m "subtree merge B into bdir"
</code>```

To show that they're now merged:

```<code>cd bdir
echo BBB>>B
git commit -a -m BBB
</code>```

To prove the full history is preserved in a connected chain:

```<code>git log --follow B
</code>```

Works fine so far, but it seems that most tools like doesn't use the follow option for git log.

So I need another way to do this. Can anyone tell me a way which works without renaming and keeping the history?

Thanks in advance.

答:
Both solutions in the question are subtree merges. And indeed to simplify inspecting history in the target repository, you need to rewrite history in the source one, and do the merge. But filter-branch is discouraged.

Say you want to merge repository a into b (I'm assuming they're located alongside one another):

```<code>cd a
git filter-repo --to-subdirectory-filter a
cd ..
cd b
git remote add a ../a
git fetch a
git merge --allow-unrelated-histories a/master
git remote remove a
</code>```

For this you need git-filter-repo installed.

An example of merging 2 big repositories, putting one of them into a subdirectory: https://gist.github.com/x-yuri/9890ab1079cf4357d6f269d073fd9731

More on it here.

Body:
I want to merge and decouple from a remote repository as subdirectory with full history. There are several ways and questions how to do that.

My first try was to use subtree but it seems not to rewrite the history of the files, so I can't look into the history of the merged repository.

Next try was to manual merge it like Seth Robertson shown up in his answer:

And the trick to making this work: force Git to recognize the rename
  by creating a subdirectory and moving the contents into it.

mkdir bdir
git mv B bdir
git commit -a -m bdir-rename

Return to repository "A" and fetch and merge the contents of "B":

cd ../a
git remote add -f B ../b
git merge -s ours --no-commit B/master
git read-tree --prefix= -u B/master
git commit -m "subtree merge B into bdir"

To show that they're now merged:

cd bdir
echo BBB>>B
git commit -a -m BBB

To prove the full history is preserved in a connected chain:

git log --follow B

Works fine so far, but it seems that most tools like doesn't use the follow option for git log.

So I need another way to do this. Can anyone tell me a way which works without renaming and keeping the history?

Thanks in advance.

Body:
Both solutions in the question are subtree merges. And indeed to simplify inspecting history in the target repository, you need to rewrite history in the source one, and do the merge. But filter-branch is discouraged.

Say you want to merge repository a into b (I'm assuming they're located alongside one another):

cd a
git filter-repo --to-subdirectory-filter a
cd ..
cd b
git remote add a ../a
git fetch a
git merge --allow-unrelated-histories a/master
git remote remove a

For this you need git-filter-repo installed.

An example of merging 2 big repositories, putting one of them into a subdirectory: https://gist.github.com/x-yuri/9890ab1079cf4357d6f269d073fd9731

More on it here.


问:
docker container runs from Dockerfile but not from docker-compose
I have the following Dockerfile:

```<code>FROM python:3.8-slim

RUN apt-get update && \
    apt-get install -y --no-install-recommends gcc libc-dev

WORKDIR /app

COPY . .

RUN pip install --no-cache-dir -r requirements.txt

CMD [ "python", "proxy-scraper-checker/main.py" ]
</code>```

And the following docker-compose.yml:

```<code>version: "3.3"

services:
    proxy-app:
        build:
            context: .
            dockerfile: Dockerfile
        container_name: proxy-app
        environment:
           - PYTHONUNBUFFERED=1
</code>```

If I run the Dockerfile manually through the docker cmd in the following way:

```<code>C:\Projects\myprojects\docker-example>docker build --tag my_app .
C:\Projects\myprojects\docker-example>docker run --rm -it my_app
</code>```

Everything seems to work fine and I get the application output logs that it is actually executing:

```<code>2020-05-30 13:38:53,454 - Thread-1 - INFO - Starting scheduler...
2020-05-30 13:38:55,457 - Thread-1 - INFO - Running job Every 2 seconds do run_pldown_job(<uvloop.Loop running=False closed=False debug=False>) (last run: [never], next run: 2020-05-30 13:38:55)
2020-05-30 13:38:55,457 - Thread-1 - INFO - Pldown Job starting...
80.187.140.26:8080 HTTPS Server/OS Error:
80.187.140.26:80 HTTP Server/OS Error:
146.148.59.22:80 HTTPS Server/OS Error:
89.216.39.217:4145 Error: Connection closed unexpectedly
185.49.93.102:4145 Error: Connection closed unexpectedly
80.240.250.222:4145 Error: Connection closed unexpectedly
185.123.2.170:1080 Error: Connection closed unexpectedly
</code>```

However, when I try to execute my application through docker-compose in the following way:

```<code>C:\Projects\myprojects\docker-example>docker-compose up
</code>```

My application seems to start up fine, but then it doesn't continue execution. Below is the output:

```<code>Creating proxy-app ... done
Attaching to proxy-app
proxy-app    | 2020-05-30 13:28:02,638 - Thread-1 - INFO - Starting scheduler...
</code>```

I tried executing the show logs command:

```<code>C:\Projects\myprojects\docker-example>docker logs proxy-app
</code>```

But the only log I got was the first line being:

```<code>2020-05-30 13:28:02,638 - Thread-1 - INFO - Starting scheduler...
</code>```

Any suggestions?

Update:

I tried building the image through docker using:

```<code>docker build --tag my_app .
</code>```

And I used this image in the compose file:

```<code>version: "3.3"

services:
    proxy-app:
        image: my_app
</code>```

And it actually works like this.

However, the question still stands, why it doesn't work when I do it this way:

```<code>version: "3.3"

services:
    proxy-app:
        build:
            context: .
            dockerfile: Dockerfile
        container_name: proxy-app
</code>```

答:
It seems like I had to add a volume in my docker-compose file for my python application, so that any changes I made there, would be actually reflected when I build from docker-compose.

So my new docker-compose.yml looks like:

```<code>version: '3'

services:
    db:
        image: postgres:latest
        container_name: postgres
        environment:
          - POSTGRES_DB=proxydb
          - POSTGRES_USER=danny
          - POSTGRES_PASSWORD=123
        ports:
            - "5432:5432"
        volumes:
            - ./init.sql:/docker-entrypoint-initdb.d/init.sql
    proxy-app:
        build: .
        container_name: proxy-app
        volumes:
            - ./src:/src
</code>```

Body:
I have the following Dockerfile:

FROM python:3.8-slim

RUN apt-get update && \
    apt-get install -y --no-install-recommends gcc libc-dev

WORKDIR /app

COPY . .

RUN pip install --no-cache-dir -r requirements.txt

CMD [ "python", "proxy-scraper-checker/main.py" ]

And the following docker-compose.yml:

version: "3.3"

services:
    proxy-app:
        build:
            context: .
            dockerfile: Dockerfile
        container_name: proxy-app
        environment:
           - PYTHONUNBUFFERED=1

If I run the Dockerfile manually through the docker cmd in the following way:

C:\Projects\myprojects\docker-example>docker build --tag my_app .
C:\Projects\myprojects\docker-example>docker run --rm -it my_app

Everything seems to work fine and I get the application output logs that it is actually executing:

2020-05-30 13:38:53,454 - Thread-1 - INFO - Starting scheduler...
2020-05-30 13:38:55,457 - Thread-1 - INFO - Running job Every 2 seconds do run_pldown_job(<uvloop.Loop running=False closed=False debug=False>) (last run: [never], next run: 2020-05-30 13:38:55)
2020-05-30 13:38:55,457 - Thread-1 - INFO - Pldown Job starting...
80.187.140.26:8080 HTTPS Server/OS Error:
80.187.140.26:80 HTTP Server/OS Error:
146.148.59.22:80 HTTPS Server/OS Error:
89.216.39.217:4145 Error: Connection closed unexpectedly
185.49.93.102:4145 Error: Connection closed unexpectedly
80.240.250.222:4145 Error: Connection closed unexpectedly
185.123.2.170:1080 Error: Connection closed unexpectedly

However, when I try to execute my application through docker-compose in the following way:

C:\Projects\myprojects\docker-example>docker-compose up

My application seems to start up fine, but then it doesn't continue execution. Below is the output:

Creating proxy-app ... done
Attaching to proxy-app
proxy-app    | 2020-05-30 13:28:02,638 - Thread-1 - INFO - Starting scheduler...

I tried executing the show logs command:

C:\Projects\myprojects\docker-example>docker logs proxy-app

But the only log I got was the first line being:

2020-05-30 13:28:02,638 - Thread-1 - INFO - Starting scheduler...

Any suggestions?

Update:

I tried building the image through docker using:

docker build --tag my_app .

And I used this image in the compose file:

version: "3.3"

services:
    proxy-app:
        image: my_app

And it actually works like this.

However, the question still stands, why it doesn't work when I do it this way:

version: "3.3"

services:
    proxy-app:
        build:
            context: .
            dockerfile: Dockerfile
        container_name: proxy-app

Body:
It seems like I had to add a volume in my docker-compose file for my python application, so that any changes I made there, would be actually reflected when I build from docker-compose.

So my new docker-compose.yml looks like:

version: '3'

services:
    db:
        image: postgres:latest
        container_name: postgres
        environment:
          - POSTGRES_DB=proxydb
          - POSTGRES_USER=danny
          - POSTGRES_PASSWORD=123
        ports:
            - "5432:5432"
        volumes:
            - ./init.sql:/docker-entrypoint-initdb.d/init.sql
    proxy-app:
        build: .
        container_name: proxy-app
        volumes:
            - ./src:/src


问:
How to do dot product in Rust using ndarray?
I have a vector, I reshaped it to 2D array using ndarray crate. Now I wanted to do a dot product with a column vec. An example,

```<code>use ndarray::*;

pub fn main() {

    let vec1 = //Read from file
    let vec2 = //Read from file
    let mat = Array2::from_shape_vec((row, cols), vec1).unwrap();
    let final_mat = mat.dot(&vec2);
}
</code>```

I get below error,

```<code>the trait `ndarray::linalg::impl_linalg::Dot<std::vec::Vec<f32>>` is not implemented for
`ndarray::ArrayBase<ndarray::data_repr::OwnedRepr<i16>, ndarray::dimension::dim::Dim<[usize; 2]>>`
</code>```

答:
The error has all the information you need: the trait Dot<Vec<f32>>, which represents the ability to call the .dot() method with an argument of type &Vec<f32>, is not implemented for Array2<i16>.

You need to convert vec2 to a type T for which Array2<i16> implements Dot<T>.

According to the documentation for the Dot trait:

impl Dot<ArrayBase<S2, Dim<[usize; 1]>>> for ArrayBase<S, Ix2> where
    S: Data<Elem = A>,
    S2: Data<Elem = A>,
    A: LinalgScalar,
```

<p>Which, with the fancy types simplified, means that <code>Array2<T></code> implements <code>Dot<Array1<T>></code>. This also means that the element types of the two arrays need to be the same, but at the moment <code>vec1</code> consists of <code>i16</code>s and <code>vec2</code> consists of <code>f32</code>s.</p>

<p>Solution: convert <code>vec2</code> to an <code>Array1</code> and make the elements of <code>vec1</code> <code>f32</code>s.</p>

<pre class="lang-rust prettyprint-override"><code>use ndarray::{Array1, Array2};

fn main(){
    let vec1 = // read from file, converting i16s to f32s
    let vec2 = // read from file
    let mat = Array2::from_shape_vec((row, cols), vec1).unwrap();
    let col_vec = Array1::from(vec2);
    let final_mat = mat.dot(&col_vec);
}
</code>```

Body:
I have a vector, I reshaped it to 2D array using ndarray crate. Now I wanted to do a dot product with a column vec. An example,

use ndarray::*;

pub fn main() {

    let vec1 = //Read from file
    let vec2 = //Read from file
    let mat = Array2::from_shape_vec((row, cols), vec1).unwrap();
    let final_mat = mat.dot(&vec2);
}

I get below error,

the trait `ndarray::linalg::impl_linalg::Dot<std::vec::Vec<f32>>` is not implemented for
`ndarray::ArrayBase<ndarray::data_repr::OwnedRepr<i16>, ndarray::dimension::dim::Dim<[usize; 2]>>`

Body:
The error has all the information you need: the trait Dot<Vec<f32>>, which represents the ability to call the .dot() method with an argument of type &Vec<f32>, is not implemented for Array2<i16>.

You need to convert vec2 to a type T for which Array2<i16> implements Dot<T>.

According to the documentation for the Dot trait:

impl<A, S, S2> Dot<ArrayBase<S2, Dim<[usize; 1]>>> for ArrayBase<S, Ix2> where
    S: Data<Elem = A>,
    S2: Data<Elem = A>,
    A: LinalgScalar,

Which, with the fancy types simplified, means that Array2<T> implements Dot<Array1<T>>. This also means that the element types of the two arrays need to be the same, but at the moment vec1 consists of i16s and vec2 consists of f32s.

Solution: convert vec2 to an Array1 and make the elements of vec1 f32s.

use ndarray::{Array1, Array2};

fn main(){
    let vec1 = // read from file, converting i16s to f32s
    let vec2 = // read from file
    let mat = Array2::from_shape_vec((row, cols), vec1).unwrap();
    let col_vec = Array1::from(vec2);
    let final_mat = mat.dot(&col_vec);
}


问:
How to install package in "R" namely "questionr"
Please help me solve this error in "R", I tried with with many packages and still this error is occurring:</p>

```<code> library(agricolae)
Error: package or namespace load failed for ‘agricolae’ in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]):
 there is no package called ‘questionr’
</code>```

答:
install.packages("agricolae", dep = TRUE)
 install.packages("questionr", dep = TRUE)

These will install the packages with their dependencies, also uninstalling and reinstalling the dependency packages would worth a shot as well

Body:
Please help me solve this error in "R", I tried with with many packages and still this error is occurring:

 library(agricolae)
Error: package or namespace load failed for ‘agricolae’ in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]):
 there is no package called ‘questionr’


问:
Using Bool In Struct in SwiftUI
I have a problem when trying to use a bool as part of a swift struct.

```<code>struct MapPrefs: Identifiable {
    var id = UUID()
    var name: String
    var isShown: Bool

}
</code>```

An array of these prefs are provided by a store to a swift-UI view

```<code>class MapPrefsStore : ObservableObject {

    var willChange = PassthroughSubject<Void, Never>()

    @Published var MapPrefs: [MapPrefs] {
        didSet { willChange.send(()) }
    }

    init(mapPrefs: [MapPrefs]) {
        self.MapPrefs = mapPrefs
    }

}
</code>```

The Settings View Observes the Store and passes the array to a cell view

```<code>struct SettingsView: View {

    @ObservedObject var mapPrefsStore = MapPrefsStore(mapPrefs: MapPrefsTestData)

    var body: some View {

        NavigationView {
            List {

                 Section(header: Text("Map Preferences"), footer: Text("")) {

                    ForEach(mapPrefsStore.MapPrefs) { mapPrefs in
                        MapPrefsCell(mapPrefs: mapPrefs)
                    }
                    .onMove(perform: moveMap)
                                }
                .background(Color.clear)
            }
            .navigationBarTitle(Text("Settings"))
            .navigationBarItems(trailing: EditButton())
            .listStyle(GroupedListStyle())
        }
    }
    func moveMap(from source: IndexSet, to destination: Int) {
        guard let sourceIndex = Array(source).first else { return }
        mapPrefsStore.MapPrefs.insert(mapPrefsStore.MapPrefs.remove(at: sourceIndex), at: destination)
    }
}

struct MapPrefsCell : View {
    let mapPrefs: MapPrefs

    var body: some View {

        Toggle(isOn: mapPrefs.isShown) {
            Text(mapPrefs.name)
        }
    }
}
}
</code>```

this gives me the following error

Cannot convert value of type 'Bool' to expected argument type 'Binding<Bool>'

I can't figure out how to allow the called function (MapPrefsCell) the ability to access the isShown property.  I tried various combinations of adding the $ sign.

答:
The Answer above works partially but because I am sharing those settings with other views I needed to be able to read and write on the toggle change so I converted the struct into a class

Here is what I did so that others can benefit.

```<code>import SwiftUI
import Combine

class MapPrefs: Identifiable, ObservableObject {

    var willChange = PassthroughSubject<Void, Never>()

    var id = UUID()
    @Published var name: String = "" {didSet { willChange.send(()) }}
    @Published var isShown: Bool = false  {didSet { willChange.send(()) }}

    init (name: String , isShown: Bool) {
        //self.id = UUID()
        self.name = name
        self.isShown = isShown
    }
}
</code>```

Then in the creation of the view I can access the property and the toggle works

```<code>struct MapPrefsCell : View {
    @ObservedObject var mapPrefs: MapPrefs

    var body: some View {

        Toggle(isOn: $mapPrefs.isShown ) {
            Text(mapPrefs.name)
        }
    }
}
</code>```

Title: Using Bool In Struct in SwiftUI

Body:
I have a problem when trying to use a bool as part of a swift struct.

struct MapPrefs: Identifiable {
    var id = UUID()
    var name: String
    var isShown: Bool

}

An array of these prefs are provided by a store to a swift-UI view

class MapPrefsStore : ObservableObject {

    var willChange = PassthroughSubject<Void, Never>()

    @Published var MapPrefs: [MapPrefs] {
        didSet { willChange.send(()) }
    }

    init(mapPrefs: [MapPrefs]) {
        self.MapPrefs = mapPrefs
    }

}

The Settings View Observes the Store and passes the array to a cell view

struct SettingsView: View {

    @ObservedObject var mapPrefsStore = MapPrefsStore(mapPrefs: MapPrefsTestData)

    var body: some View {

        NavigationView {
            List {

                 Section(header: Text("Map Preferences"), footer: Text("")) {

                    ForEach(mapPrefsStore.MapPrefs) { mapPrefs in
                        MapPrefsCell(mapPrefs: mapPrefs)
                    }
                    .onMove(perform: moveMap)
                                }
                .background(Color.clear)
            }
            .navigationBarTitle(Text("Settings"))
            .navigationBarItems(trailing: EditButton())
            .listStyle(GroupedListStyle())
        }
    }
    func moveMap(from source: IndexSet, to destination: Int) {
        guard let sourceIndex = Array(source).first else { return }
        mapPrefsStore.MapPrefs.insert(mapPrefsStore.MapPrefs.remove(at: sourceIndex), at: destination)
    }
}

struct MapPrefsCell : View {
    let mapPrefs: MapPrefs

    var body: some View {

        Toggle(isOn: mapPrefs.isShown) {
            Text(mapPrefs.name)
        }
    }
}
}

this gives me the following error

Cannot convert value of type 'Bool' to expected argument type 'Binding<Bool>'

I can't figure out how to allow the called function (MapPrefsCell) the ability to access the isShown property.  I tried various combinations of adding the $ sign.

Body:
The Answer above works partially but because I am sharing those settings with other views I needed to be able to read and write on the toggle change so I converted the struct into a class

Here is what I did so that others can benefit.

import SwiftUI
import Combine

class MapPrefs: Identifiable, ObservableObject {

    var willChange = PassthroughSubject<Void, Never>()

    var id = UUID()
    @Published var name: String = "" {didSet { willChange.send(()) }}
    @Published var isShown: Bool = false  {didSet { willChange.send(()) }}

    init (name: String , isShown: Bool) {
        //self.id = UUID()
        self.name = name
        self.isShown = isShown
    }
}

Then in the creation of the view I can access the property and the toggle works

struct MapPrefsCell : View {
    @ObservedObject var mapPrefs: MapPrefs

    var body: some View {

        Toggle(isOn: $mapPrefs.isShown ) {
            Text(mapPrefs.name)
        }
    }
}


问:
Google Picker API - Word Vesion
I want to use the Google Picker API to allow users to upload MS Word documents from their Google Drive to our system. I have everything working fine in on the client (javascript) but the problem is the URL I get from the Google Picker API (var fileurl = data.docs[0].url -> https://drive.google.com/file/d/[google_file_id]/view?usp=drive_web) doesn't link to an "MS Word" version of the file - it links to a Google Docs version.  How can I get the URL link to the actual MS Word version of the file?

Thanks in advance!

答:
Found it thanks to this site https://appsevents.com/blog/2014/04/how-to-bypass-google-drive-viewer-and-create-direct-download-links.html</p>

```<code>https://drive.google.com/uc?export=download&id=[FILE-ID]
</code>```

Title: Google Picker API - Word Vesion

Body:
Found it thanks to this site https://appsevents.com/blog/2014/04/how-to-bypass-google-drive-viewer-and-create-direct-download-links.html

https://drive.google.com/uc?export=download&id=[FILE-ID]


问:
How do I get the sum of a txt file and a binary file both of which have array size of 10?
My code is very likely to be incorrect everywhere since I just go started on learning files.
The array of the text file is {3 2 1 3 4 5 6 1 2 3}
The array of the binary is {1 2 3 4 5 6 7 8 9 10}</p>

```<code>#include <stdio.h>
#define ARR_SIZ 10
int main()
{
    int arr_in[ARR_SIZ];
    int arr_bin[ARR_SIZ];
    int i = 0;
    FILE * fp_in = fopen("data/in.txt", "r");
    FILE * fp_bin = fopen("data/in.bin", "wb");
    fread(arr_in, sizeof(int), ARR_SIZ, fp_in);
    fread(arr_bin, sizeof(int), ARR_SIZ, fp_bin);
    int sum[ARR_SIZ];
    for (i=0; i < ARR_SIZ; i++){
            fscanf("%d", arr_in);
    fscanf("%d", arr_in);
    sum[i] = arr_in[i] + arr_bin[i];
    } printf("%d", sum[i]);
    return 0;
    }
</code>```

答:
fread() reads binary data even when the file is not opened with "b" which just means it doesn't do funny stuff with things like Windows-style line breaks.
If you want to read a text file you will how to do more complex work like reading in the data, look for line breaks, and than use the data before each line break. As that data is still a string you will need to convert it to an integer (e.g. using atoi())

Body:
My code is very likely to be incorrect everywhere since I just go started on learning files.
The array of the text file is {3 2 1 3 4 5 6 1 2 3}
The array of the binary is {1 2 3 4 5 6 7 8 9 10}

#include <stdio.h>
#define ARR_SIZ 10
int main()
{
    int arr_in[ARR_SIZ];
    int arr_bin[ARR_SIZ];
    int i = 0;
    FILE * fp_in = fopen("data/in.txt", "r");
    FILE * fp_bin = fopen("data/in.bin", "wb");
    fread(arr_in, sizeof(int), ARR_SIZ, fp_in);
    fread(arr_bin, sizeof(int), ARR_SIZ, fp_bin);
    int sum[ARR_SIZ];
    for (i=0; i < ARR_SIZ; i++){
            fscanf("%d", arr_in);
    fscanf("%d", arr_in);
    sum[i] = arr_in[i] + arr_bin[i];
    } printf("%d", sum[i]);
    return 0;
    }


问:
How to create space between icon and text field with Vuetify
I have the following code for the username section:

```<code><v-text-field
         prepend-icon="fas fa-user"
         height="60px"
         placeholder="Username"
         outlined
></v-text-field>
</code>```

How can I create space between the user icon and the text field?

While I'm here I might as well also ask how I can make the width of the input field adjust to the width of the screen? Right now it's very small for some reason.

答:
You need to add icon onto prepend slot and then add margin-x</p>

```<code><v-text-field
  label="Regular"
  solo
  >
  <template v-slot:prepend>
    <v-icon class="mx-5">mdi-account</v-icon>
  </template>
</v-text-field>
</code>```

Body:
I have the following code for the username section:

<v-text-field
         prepend-icon="fas fa-user"
         height="60px"
         placeholder="Username"
         outlined
></v-text-field>

How can I create space between the user icon and the text field?

While I'm here I might as well also ask how I can make the width of the input field adjust to the width of the screen? Right now it's very small for some reason.

Body:
You need to add icon onto prepend slot and then add margin-x

<v-text-field
  label="Regular"
  solo
  >
  <template v-slot:prepend>
    <v-icon class="mx-5">mdi-account</v-icon>
  </template>
</v-text-field>