问:
Column overlapping on first page load only
Hi I am using Bootstrap 4, I am working on a project here http://eatout.sanaalitech.com/products.php I am facing a very strange problem.I am using bootstrap grid and my columns overlaps on the first page load only on mobile view,on desktop it works fine, when I refresh the page it works fine on the mobile as well.
I have tried the following but still not working
 1) .col-lg-3{ display:block; position:relative;}
2) I have tried enclosing every 4 products in a row instead of taking all of them in a single row like this

    content here
    content here
    content here
    content here

    content here
    content here
    content here
    content here

    content here
    content here
    content here
    content here

3) I have also completely deleted this and made it again with cards but they also overlap on the first load only on mobile view.

Problem appears on the first load only.

I have added image on first page load .

```<code><div class="container" style="margin-top:5em;">
     <div class="row ">
        <div class="col-lg-12" >
            <ul class="filter-tabs text-center">
                <li data-filter=".maincourse"><a href="#!" >Main Courses</a></li>
                <li data-filter=".desserts"><a href="#!" id="desserts">Desserts</a></li>
                <li class="active" data-filter="*"><a href="#!">View All</a></li>
                <li data-filter=".starters"><a href="#!">Starters</a></li>
                <li data-filter=".extras"><a href="#!">Extras</a></li>
            </ul>
            <div class="projects">
                <div class="row">

                        <div class="col-lg-3 item maincourse mb-3" >
                            <div class="product ">
                                <img src="Images/banner-image4.jpg" class="img-fluid">
                                <div class="text-center mb-3 mt-3">
                                    <h4>Meal Platter</h4>
                                    <h7>£8.99</h7>
                                </div>
                            </div>

                        </div>

                        <div class="col-lg-3  item desserts mb-3" >
                            <div class="product ">
                                <img src="Images/dessert.jpg" class="img-fluid">
                                <div class="text-center mb-3 mt-3">
                                    <h4>Meal Platter</h4>
                                    <h7>£8.99</h7>
                                </div>
                            </div>
                        </div>

                            <div class="col-lg-3 item maincourse mb-3">
                                <div class="product ">
                                        <img src="Images/main-meal-5.jpg" class="img-fluid img-filter">
                                        <div class="text-center mb-3 mt-3">
                                            <h4>Meal Platter</h4>
                                            <h7>£8.99</h7>
                                        </div>
                                </div>
                            </div>

                            <div class="col-lg-3  item starters mb-3">
                                <div class="product ">
                                    <img src="Images/banner-image3.jpg" class="img-fluid">
                                    <div class="text-center mb-3 mt-3">
                                        <h4>Meal Platter</h4>
                                        <h7>£8.99</h7>
                                    </div>
                                </div>
                            </div>

                            <div class="col-lg-3 item maincourse mb-3">
                                <div class="product ">
                                    <img src="Images/main-meal-2.jpg" class="img-fluid">
                                    <div class="text-center mb-3 mt-3">
                                        <h4>Roll Platter</h4>
                                        <h7>£8.99</h7>
                                    </div>
                                </div>

                            </div>

                            <div class="col-lg-3 item starters mb-3">
                                <div class="product ">
                                    <img src="Images/main-meal-4.jpg" class="img-fluid">
                                    <div class="text-center mb-3 mt-3">
                                        <h4>Vege Starter</h4>
                                        <h7>£7.99</h7>
                                    </div>
                                </div>
                            </div>

                            <div class="col-lg-3 item desserts mb-3">
                                <div class="product ">
                                    <img src="Images/dessert-2.jpg" class="img-fluid img-filter">
                                    <div class="text-center mb-3 mt-3">
                                        <h4>Rasberry cake</h4>
                                        <h7>£4.99</h7>
                                    </div>
                                </div>
                            </div>
                            <div class="col-lg-3 item maincourse mb-3">
                                <div class="product ">
                                        <img src="Images/main-meal-3.jpg" class="img-fluid">
                                        <div class="text-center mb-3 mt-3">
                                            <h4>Burger Meal</h4>
                                            <h7>£8.99</h7>
                                        </div>
                                </div>
                            </div>

                                <div class="col-lg-3 item extras mb-3">
                                    <div class="product">
                                        <img src="Images/extras-1.jpg" class="img-fluid">
                                        <div class="text-center mb-3 mt-3">
                                            <h4>Macaroni Sallad</h4>
                                            <h7>£7.99</h7>
                                        </div>
                                    </div>

                                </div>
                                <div class="col-lg-3 item maincourse mb-3">
                                    <div class="product ">
                                        <img src="Images/main-meal-6.jpg" class="img-fluid">
                                        <div class="text-center mb-3 mt-3">
                                            <h4>Fish & Beans</h4>
                                            <h7>£12.99</h7>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-lg-3 item extras mb-3">
                                    <div class="product ">
                                        <img src="Images/extras-2.jpg" class="img-fluid img-filter">
                                        <div class="text-center mb-3 mt-3">
                                            <h4>Avacado Sallad</h4>
                                            <h7>£9.99</h7>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-lg-3 item desserts mb-3">
                                    <div class="product">
                                        <img src="Images/dessert-3.jpg" class="img-fluid">
                                        <div class="text-center mb-3 mt-3">
                                            <h4>Chocolate Cake</h4>
                                            <h7>£7.99</h7>
                                        </div>
                                    </div>
                            </div>

                    </div>

                </div>

            </div>
        </div>
    </div>
</code>```

答:
When your grid overflows, run this in the console.

(Code from javascript.js at line 217)

```<code> var $projects = $(".projects");
   $projects.isotope({
     itemSelector: ".item",
     layoutMode:'fitRows'

  });
</code>```

I think that this function runs before everything loads.
I don't know what is going on because sometimes this fixes the issue once called but most of the time it does not. But one is for sure. A function defines the absolute position, so the issue lays somewhere within the javascript source.

Body:
Hi I am using Bootstrap 4, I am working on a project here http://eatout.sanaalitech.com/products.php I am facing a very strange problem.I am using bootstrap grid and my columns overlaps on the first page load only on mobile view,on desktop it works fine, when I refresh the page it works fine on the mobile as well.
I have tried the following but still not working
 1) .col-lg-3{ display:block; position:relative;}
2) I have tried enclosing every 4 products in a row instead of taking all of them in a single row like this

    content here
    content here
    content here
    content here

    content here
    content here
    content here
    content here

    content here
    content here
    content here
    content here

3) I have also completely deleted this and made it again with cards but they also overlap on the first load only on mobile view.

Problem appears on the first load only.

I have added image on first page load .

Main Courses

Desserts

View All

Starters

Extras

Meal Platter

                                    <h7>£8.99</h7>

Meal Platter

                                    <h7>£8.99</h7>

Meal Platter

                                            <h7>£8.99</h7>

Meal Platter

                                        <h7>£8.99</h7>

Roll Platter

                                        <h7>£8.99</h7>

Vege Starter

                                        <h7>£7.99</h7>

Rasberry cake

                                        <h7>£4.99</h7>

Burger Meal

                                            <h7>£8.99</h7>

Macaroni Sallad

                                            <h7>£7.99</h7>

Fish & Beans

                                            <h7>£12.99</h7>

Avacado Sallad

                                            <h7>£9.99</h7>

Chocolate Cake

                                            <h7>£7.99</h7>

Body:
When your grid overflows, run this in the console.

(Code from javascript.js at line 217)

 var $projects = $(".projects");
   $projects.isotope({
     itemSelector: ".item",
     layoutMode:'fitRows'

  });

I think that this function runs before everything loads.
I don't know what is going on because sometimes this fixes the issue once called but most of the time it does not. But one is for sure. A function defines the absolute position, so the issue lays somewhere within the javascript source.


来源: stackexchange

问:
What is DateFormat skeleton for this format?
What is DateFormat skeleton for this format

Apr-27-2020 | 12:00 PM

I tried my best and got it halfway done.

DateFormat("MMM-d-yyyy | h:m")

But I don't know how to add the AM/PM at the end.

答:
Okay I got it now.

Answer is DateFormat("MMM-d-yyyy | h:m a")

ContentLicense: CC BY-SA 4.0


问:
How do you initialize variables inside function scope and avoid global scope?
I have in the global space a variable set as follows:

```<code>let hoverMessageLock = 0;
</code>```

This allows the function below to operate how I want. Its function is to add a message upon button hover and then delete said message and replace it with a new message upon another hover.

The issue I'm having is I would like to NOT use the global space for variables and instead put it inside the function itself. However the function itself is getting called over and over again per each hover event, so if I set hoverMessageLock = 0 in the function scope, it just keeps getting set to 0 over and over again. Therefor my switch statement doesn't work as intended as when its in the global scope.

I know in other programming languages that utilizes classes, you can set variables in the class scope and then alter them in the same way you would global scope inside your functions. Is there a way to do this as well here in Javascript?

```<code>let macroManager = {
    hoverMessage: function(message, style = "hovertext noTextSelect"){
        switch (hoverMessageLock){
            case 0:
                uiManager.messageDirector.addMessage(""+message+"", 0, 0, style);
                hoverMessageLock = 1;
                break;
            case 1:
                uiManager.messageDirector.removeMessage();
                uiManager.messageDirector.addMessage(""+message+"", 0, 0, style);
                break;
        }
    },
}
</code>```

答:
You can use an Immediately Executed Function Expression (IIFE) for this.

let macroManager = (function(hoverMessageLock) {
  return {
    hoverMessage: function(message, style = "hovertext noTextSelect") {
      switch (hoverMessageLock) {
        case 0:
          uiManager.messageDirector.addMessage("" + message + "", 0, 0, style);
          hoverMessageLock = 1;
          break;
        case 1:
          uiManager.messageDirector.removeMessage();
          uiManager.messageDirector.addMessage("" + message + "", 0, 0, style);
          break;
      }
    },
  };
})(0);```

Body:
I have in the global space a variable set as follows:

let hoverMessageLock = 0;

This allows the function below to operate how I want. Its function is to add a message upon button hover and then delete said message and replace it with a new message upon another hover.

The issue I'm having is I would like to NOT use the global space for variables and instead put it inside the function itself. However the function itself is getting called over and over again per each hover event, so if I set hoverMessageLock = 0 in the function scope, it just keeps getting set to 0 over and over again. Therefor my switch statement doesn't work as intended as when its in the global scope.

I know in other programming languages that utilizes classes, you can set variables in the class scope and then alter them in the same way you would global scope inside your functions. Is there a way to do this as well here in Javascript?

let macroManager = {
    hoverMessage: function(message, style = "hovertext noTextSelect"){
        switch (hoverMessageLock){
            case 0:
                uiManager.messageDirector.addMessage(""+message+"", 0, 0, style);
                hoverMessageLock = 1;
                break;
            case 1:
                uiManager.messageDirector.removeMessage();
                uiManager.messageDirector.addMessage(""+message+"", 0, 0, style);
                break;
        }
    },
}


问:
unset form submit button
```<code><body>

<?php

if(isset($_POST['vendor_add_submit'])){

//INSERT INTO DB

unset(  $_POST['vendor_add_submit'] );
}

?>

<form method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>" >

<label>Email</label>
<input type="text" name="vendor_email" value="" />

<input type="submit" name="vendor_add_submit" value="SAVE" />

</form>
</body>
</code>```

unset(  $_POST['vendor_add_submit'] ); is used to prevent more than one time insertion into db on page refresh. I tested with print_r($_POST['vendor_add_submit'] ) before and after the unset and found that the unset() function does not work.

How can I achieve the purpose of the unset function, plz?

答:
Your approach cannot work, you would just be editing the data that the PHP script has recieved. If the user refreshes the browser then it will submit the same data again, and PHP will populate a fresh new $_POST with the data the browser sent.

If you want to stop a refresh resubmitting the data, then use the POST-REDIRECT-GET pattern.

ContentLicense: CC BY-SA 3.0

Title: unset form submit button

Body:
<?php

if(isset($_POST['vendor_add_submit'])){

//INSERT INTO DB

unset(  $_POST['vendor_add_submit'] );
}

?>

<form method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>" >

Email
<input type="text" name="vendor_email" value="" />

<input type="submit" name="vendor_add_submit" value="SAVE" />

</form>

unset(  $_POST['vendor_add_submit'] ); is used to prevent more than one time insertion into db on page refresh. I tested with print_r($_POST['vendor_add_submit'] ) before and after the unset and found that the unset() function does not work.

How can I achieve the purpose of the unset function, plz?


问:
Control contents of email address fields
I want to send the body of a Word document as an email from MS Word 2016.

I want the user to select recipients from the address book. I want them to only be put in the BCC field.

How do I monitor the to/from/CC/BCC fields for changes, and then move those changes to BCC?

The documentation indicates the use of Inspectors, but nothing specific about accessing the contents of these fields.

I have two approaches:

open a new Outlook mail item, load the contents of the Word file to it, and then try to monitor the fields that way.

send directly from Word using the Quick Access Toolbar option "Send to Mail Recipient".

I don't know if that is an option based on what I was reading and if those fields are accessible via VBA.

Code example of what I have so far:

Sub SendDocumentInMail()

Dim bStarted As Boolean
Dim oOutlookApp As Outlook.Application
Dim oItem As Outlook.MailItem

On Error Resume Next

'Get Outlook if it's running
Set oOutlookApp = GetObject(, "Outlook.Application")
If Err <> 0 Then
    'Outlook wasn't running, start it from code
    Set oOutlookApp = CreateObject("Outlook.Application")
    bStarted = True
End If

'Create a new mailitem
Set oItem = oOutlookApp.CreateItem(olMailItem)

With oItem
    'Set the recipient for the new email
   .To = "recipient@mail.com"
    'Set the recipient for a copy
    .CC = "recipient2@mail.com"
    'Set the subject
    .Subject = "New subject"
    'The content of the document is used as the body for the email
    .Body = ActiveDocument.Content
    .Send
End With

If bStarted Then
    'If we started Outlook from code, then close it
    oOutlookApp.Quit
End If

'Clean up
Set oItem = Nothing
Set oOutlookApp = Nothing

End Sub
```

答:
It seems you are interested in the SelectNamesDialog object which displays the Select Names dialog box for the user to select entries from one or more address lists, and returns the selected entries in the collection object specified by the property SelectNamesDialog.Recipients.

The dialog box displayed by SelectNamesDialog.Display is similar to the Select Names dialog box in the Outlook user interface. It observes the size and position settings of the built-in Select Names dialog box. However, its default state does not show Message Recipients above the To, Cc, and Bcc edit boxes.

The following code sample shows how to create a mail item, allow the user to select recipients from the Exchange Global Address List in the Select Names dialog box, and if the user has selected recipients that can be completely resolved, then send the mail item.

```<code>Sub SelectRecipients()
 Dim oMsg As MailItem
 Set oMsg = Application.CreateItem(olMailItem)
 Dim oDialog As SelectNamesDialog
 Set oDialog = Application.Session.GetSelectNamesDialog
 With oDialog
 .InitialAddressList = _
 Application.Session.GetGlobalAddressList
 .Recipients = oMsg.Recipients
 If .Display Then
 'Recipients Resolved
 oMsg.Subject = "Hello"
 oMsg.Send
 End If
 End With
End Sub
</code>```

Body:
It seems you are interested in the SelectNamesDialog object which displays the Select Names dialog box for the user to select entries from one or more address lists, and returns the selected entries in the collection object specified by the property SelectNamesDialog.Recipients.

The dialog box displayed by SelectNamesDialog.Display is similar to the Select Names dialog box in the Outlook user interface. It observes the size and position settings of the built-in Select Names dialog box. However, its default state does not show Message Recipients above the To, Cc, and Bcc edit boxes.

The following code sample shows how to create a mail item, allow the user to select recipients from the Exchange Global Address List in the Select Names dialog box, and if the user has selected recipients that can be completely resolved, then send the mail item.

Sub SelectRecipients()
 Dim oMsg As MailItem
 Set oMsg = Application.CreateItem(olMailItem)
 Dim oDialog As SelectNamesDialog
 Set oDialog = Application.Session.GetSelectNamesDialog
 With oDialog
 .InitialAddressList = _
 Application.Session.GetGlobalAddressList
 .Recipients = oMsg.Recipients
 If .Display Then
 'Recipients Resolved
 oMsg.Subject = "Hello"
 oMsg.Send
 End If
 End With
End Sub


问:
I am using firebase and Android studio
I have a registration form, and I wish the administrator can enable or disable (via code, from his account inside the app) a user when asked to register.

In other words, I would like that the registration of a user can be approved (via code, not using the Firebase console) by a administrator before become effective.

How can I get this? I did not found sufficiently complete answer to this question.

Thanks!

答:
From the sounds of things you need a user to:

Sign up > Await Approval > Enter Main app

A potential way of implementing this would be to have them sign up using Firebase Authentication then within your splash activity each time the app is started have it check for a boolean value within firebase database of either true or false.

If true - they are authorised and they go to the main activity, if false then they go to the waiting screen.

How you implement the approval process is up to you but essentially your Approver will just need to turn the boolean value from false to true.

Title: I am using firebase and Android studio


问:
How can I get elastic beanstalk to allow large files to be uploaded?
I saw this https://kroltech.com/2014/09/14/quick-tip-increase-upload-size-in-aws-elastic-beanstalk-node-js-env/

and created a file called .ebextensions/00_reload_nginx.conf with:

```<code>files:
  "/etc/nginx/conf.d/proxy.conf":
    mode: "000755"
    owner: root
    group: root
    content: |
      client_max_body_size 100M;
</code>```

However, when I ssh into the machine, that file doesn't exist and nor doe the content. What am I doing wrong?

答:
I have tried all .ebextensions method of adding implementation level configuration and it didn't help me in the latest Amazon Linux AMI. You need to follow this structure to increase the upload size.
You need to follow this structure to increase the upload size limit.

Add the below folder setup in the root level of your project folder.

Folder structure (.platform/nginx/conf.d/proxy.conf)

```<code>.platform/
         nginx/
              conf.d/
                    proxy.conf
</code>```

Add this line to proxy.conf (Inside .platform/nginx/conf.d/ folder)

client_max_body_size 50M;

commit this file and deploy again using eb deploy.

Body:
I saw this https://kroltech.com/2014/09/14/quick-tip-increase-upload-size-in-aws-elastic-beanstalk-node-js-env/

and created a file called .ebextensions/00_reload_nginx.conf with:

files:
  "/etc/nginx/conf.d/proxy.conf":
    mode: "000755"
    owner: root
    group: root
    content: |
      client_max_body_size 100M;

However, when I ssh into the machine, that file doesn't exist and nor doe the content. What am I doing wrong?

Body:
I have tried all .ebextensions method of adding implementation level configuration and it didn't help me in the latest Amazon Linux AMI. You need to follow this structure to increase the upload size.
You need to follow this structure to increase the upload size limit.

Add the below folder setup in the root level of your project folder.

Folder structure (.platform/nginx/conf.d/proxy.conf)

.platform/
         nginx/
              conf.d/
                    proxy.conf

Add this line to proxy.conf (Inside .platform/nginx/conf.d/ folder)

client_max_body_size 50M;

commit this file and deploy again using eb deploy.


问:
C++: What is the size of an object of an empty class?
I was wondering what could be the size of an object of an empty class. It surely could not be 0 bytes since it should be possible to reference and point to it like any other object. But, how big is such an object?

I used this small program:

```<code>#include <iostream>
using namespace std;

class Empty {};

int main()
{
    Empty e;
    cerr << sizeof(e) << endl;
    return 0;
}
</code>```

The output I got on both Visual C++ and Cygwin-g++ compilers was 1 byte! This was a little surprising to me since I was expecting it to be of the size of the machine word (32 bits or 4 bytes).

Can anyone explain why the size of 1 byte? Why not 4 bytes? Is this dependent on compiler or the machine too? Also, can someone give a more cogent reason for why an empty class object will not be of size 0 bytes?

答:
That's really an implementation detail. Once long ago, I thought it could be zero bytes or a thousand bytes, that it has no bearing on the language specification. But, after looking at the C++17 standard (expr.sizeof), sizeof is defined as always returning one or greater, no matter what.

The size of a most derived class shall be greater than zero.

This is required for, among other things, allowing you to handle arrays of objects and pointers to them. If your elements were allowed to be zero-sized then &(array[0]) would be identical to &(array[42]), which is going to cause all sorts of havoc to your processing loops.

The reason why it may not be a machine word is that there are no elements within it that actually require it to be aligned on a word boundary (such as an integer). For example, if you place char x; int y; inside the class, my GCC clocks it at eight bytes (since the second int must be aligned in that implementation).

Having said that, that particular wording appears to have been removed from C++20, allowing for at least the possibility of objects that can take up no space. However, the following text has been added to that same section:

When applied to a class, the result is the number of bytes in an object of that class including any padding required for placing objects of that type in an array.

Since arrays need to be able to distinguish between elements, that would mean sizeof would have to return at least one, even if the object itself technically took up no space.

So, different wording, but the same overall effect.

OwnerDisplayName: Ash

ContentLicense: CC BY-SA 2.5

Body:
I was wondering what could be the size of an object of an empty class. It surely could not be 0 bytes since it should be possible to reference and point to it like any other object. But, how big is such an object?

I used this small program:

#include <iostream>
using namespace std;

class Empty {};

int main()
{
    Empty e;
    cerr << sizeof(e) << endl;
    return 0;
}

The output I got on both Visual C++ and Cygwin-g++ compilers was 1 byte! This was a little surprising to me since I was expecting it to be of the size of the machine word (32 bits or 4 bytes).

Can anyone explain why the size of 1 byte? Why not 4 bytes? Is this dependent on compiler or the machine too? Also, can someone give a more cogent reason for why an empty class object will not be of size 0 bytes?

LastEditorDisplayName: Ash

OwnerDisplayName: Pax

LastEditorDisplayName: Pax


答:
Unset isn't going to stop the refresh from being able to replay the POSTed data to the script.  The unset function eliminated it for the remaining execution of that script, but a refresh is a fresh execution.

You could simply re-direct the browser to the entry pageafter doing your insert, that way a subsequent refresh will be safe.

```<code>//INSERT INTO DB
//...
header('Location: samepage.php');
exit();
</code>```

I'm sure there are other ways to accomplish this as well.

Title: unset form submit button

Body:
Unset isn't going to stop the refresh from being able to replay the POSTed data to the script.  The unset function eliminated it for the remaining execution of that script, but a refresh is a fresh execution.

You could simply re-direct the browser to the entry pageafter doing your insert, that way a subsequent refresh will be safe.

//INSERT INTO DB
//...
header('Location: samepage.php');
exit();

I'm sure there are other ways to accomplish this as well.


问:
How to fill missing values based on grouped average?
My data has missing values for 'Age' and I want to replace them by average based on groupby column 'Title'. After the command:

```<code>df.groupby('Title').mean()['Age']
</code>```

I get a list for example

Mr 32

Miss 21.7

Ms 28

etc.

I tried:

```<code>df['Age'].replace(np.nan, 0, inplace=True)
df[(df.Age==0.0)&(df.Title=='Mr')]
</code>```

to just see the cells where age is missing and title is of one type but it doesn't work.

Question 1. Why the code above doesn't show any cells, despite multiple cells satisfying both conditions at the same time (age = 0.0 and title is mr)

Question2. How can I replace all missing values based on the group average as described above?

答:
I cannot reproduce the first error, so if i use an example like below:

```<code>import pandas as pd
import numpy as np
np.random.seed(111)
df = pd.DataFrame({'Title':np.random.choice(['Mr','Miss','Mrs'],20),'Age':np.random.randint(20,50,20)})
df.loc[[5,9,10,11,12],['Age']]=np.nan
</code>```

the data frame looks like:

```<code>Title   Age
0   Mr  42.0
1   Mr  28.0
2   Mr  25.0
3   Mr  32.0
4   Mrs 26.0
5   Miss    NaN
6   Mrs 32.0
7   Mrs 33.0
8   Mrs 25.0
9   Mr  NaN
10  Miss    NaN
11  Mr  NaN
12  Mrs NaN
13  Miss    38.0
14  Mr  31.0
15  Mr  42.0
16  Mr  24.0
17  Mrs 23.0
18  Mrs 49.0
19  Miss    27.0
</code>```

And we can replace it just doing one more step:

```<code>ave_age = df.groupby('Title').mean()['Age']
df.loc[pd.isna(df['Age']),'Age'] = ave_age[df.loc[pd.isna(df['Age']),'Title']].values
</code>```

Body:
My data has missing values for 'Age' and I want to replace them by average based on groupby column 'Title'. After the command:

df.groupby('Title').mean()['Age']

I get a list for example

Mr 32

Miss 21.7

Ms 28

etc.

I tried:

df['Age'].replace(np.nan, 0, inplace=True)
df[(df.Age==0.0)&(df.Title=='Mr')]

to just see the cells where age is missing and title is of one type but it doesn't work.

Question 1. Why the code above doesn't show any cells, despite multiple cells satisfying both conditions at the same time (age = 0.0 and title is mr)

Question2. How can I replace all missing values based on the group average as described above?

Body:
I cannot reproduce the first error, so if i use an example like below:

import pandas as pd
import numpy as np
np.random.seed(111)
df = pd.DataFrame({'Title':np.random.choice(['Mr','Miss','Mrs'],20),'Age':np.random.randint(20,50,20)})
df.loc[[5,9,10,11,12],['Age']]=np.nan

the data frame looks like:

Title   Age
0   Mr  42.0
1   Mr  28.0
2   Mr  25.0
3   Mr  32.0
4   Mrs 26.0
5   Miss    NaN
6   Mrs 32.0
7   Mrs 33.0
8   Mrs 25.0
9   Mr  NaN
10  Miss    NaN
11  Mr  NaN
12  Mrs NaN
13  Miss    38.0
14  Mr  31.0
15  Mr  42.0
16  Mr  24.0
17  Mrs 23.0
18  Mrs 49.0
19  Miss    27.0

And we can replace it just doing one more step:

ave_age = df.groupby('Title').mean()['Age']
df.loc[pd.isna(df['Age']),'Age'] = ave_age[df.loc[pd.isna(df['Age']),'Title']].values


问:
Excel CSV. file with more than 1,048,576 rows of data
I have been given a CSV file with more than the MAX Excel can handle, and I really need to be able to see all the data. I understand and have tried the method of "splitting" it, but it doesnt work.

Some background: The CSV file is an Excel CSV file, and the person who gave the file has said there are about 2m rows of data.

When I import it into Excel, I get data up to row 1,048,576, then re-import it in a new tab starting at row 1,048,577 in the data, but it only gives me one row, and I know for a fact that there should be more (not only because of the fact that "the person" said there are more than 2 million, but because of the information in the last few sets of rows)

I thought that maybe the reason for this happening is because I have been provided the CSV file as an Excel CSV file, and so all the information past 1,048,576 is lost (?).

DO I need to ask for a file in an SQL database format?

答: The best way to handle this (with ease and no additional software) is with Excel - but using Powerpivot (which has MSFT Power Query embedded). Simply create a new Power Pivot data model that attaches to your large csv or text file. You will then be able to import multi-million rows into memory using the embedded X-Velocity (in-memory compression) engine. The Excel sheet limit is not applicable - as the X-Velocity engine puts everything up in RAM in compressed form. I have loaded 15 million rows and filtered at will using this technique. Hope this helps someone... - Jaycee</p>


问:
Select a top 10 list by number of times that person was entered
I have a table that keeps track of how many times a user accomplishes something.

I want a query that can help me create a top 10 list to display the leaders.

Anon - 10

Anon2 - 7

Anon 3 -3

My query which currently selects the entire count of something and only 1 user returns the following:

Anon - 20

Below is the query:

```<code>Select count(referral_person) AS C, referral_person
from item_referral
ORDER by count(referral_person) DESC;
</code>```

What am i doing wrong?

答:
Your query is missing a group by clause - but it has an aggregate function in the select clause. So MySQL gives you just one row, with the overall count of rows in the table and an arbitrary value of referral_person.

In most other databases, this would generate a syntax error - and in MySQL too, if sql mode ONLY_FULL_GROUP_BY was enabled - which would make it much easier for you to spot the problem.

Also, to select the top 10, you can use order by and limit.

It seems like you want:

```<code>select referral_person, count(*) cnt
from item_referral
group by referral_person
order by cnt desc
limit 10
</code>```

Body:
I have a table that keeps track of how many times a user accomplishes something.

I want a query that can help me create a top 10 list to display the leaders.

Anon - 10

Anon2 - 7

Anon 3 -3

My query which currently selects the entire count of something and only 1 user returns the following:

Anon - 20

Below is the query:

Select count(referral_person) AS C, referral_person
from item_referral
ORDER by count(referral_person) DESC;

What am i doing wrong?

Body:
Your query is missing a group by clause - but it has an aggregate function in the select clause. So MySQL gives you just one row, with the overall count of rows in the table and an arbitrary value of referral_person.

In most other databases, this would generate a syntax error - and in MySQL too, if sql mode ONLY_FULL_GROUP_BY was enabled - which would make it much easier for you to spot the problem.

Also, to select the top 10, you can use order by and limit.

It seems like you want:

select referral_person, count(*) cnt
from item_referral
group by referral_person
order by cnt desc
limit 10


问:
As the window resizes resize everytinhg in tkinter GUI as well
So I've made this simple program. The problem is that I did not think in advance that when the window is resized I want all objects inside it to resize as well. Is there any way to write something simple which would affect everything below instead of writing something to every single line? To make things more clear you can run my code and resize window. You will understand where the problem is:</p>

```<code>from tkinter import *
import sys
from PIL import ImageTk, Image
import math
import tkinter.font as TkFont

root = tk.Tk()

#Lango dydis
#root.geometry("500x600+0+0")
HEIGHT = 500
WIDTH = 600

canvas = tk.Canvas(root, height=HEIGHT, width=WIDTH )
canvas.pack()

frame=Frame(root, bg='#80c1ff', bd=5)
frame.place(relwidth=1, relheight=1)

trikampis = ImageTk.PhotoImage(Image.open("E:/Pytono projektai/240px-Rtriangle.png"))
trikampis2 = Label(root, image=trikampis)
trikampis2.place(relx= 0.29, rely= 0.2)

def skaiciuotuvas():
    error = Label(root, width=1, bg='#80c1ff', fg='#80c1ff')
    error.place(relwidth=0.8, relheight=0.04, relx= 0.12, rely= 0.905)
    a1 = ae.get()
    b1 = be.get()
    c1 = ce.get()
    if a1 == '':
        b11 = float(b1)
        c11 = float(c1)
        a11 = float(c11)**2 - float(b11)**2
        a12 = math.sqrt(a11)
        a13 = '{:.5}'.format(a12)
        ae.insert(0, a13)
        a111 = '{:.5}'.format(a11)
        saknies.config(text=a111)
        a20 = '{:.10}'.format(a12)
        galutinis.config(text=a20)
        b20 = b11
        c20 = c11
    if b1 == '':
        a11 = float(a1)
        c11 = float(c1)
        b11 = float(c11)**2 - float(a11)**2
        b12 = math.sqrt(b11)
        b13 = '{:.5}'.format(b12)
        be.insert(0, b13)
        b111 = '{:.5}'.format(b11)
        saknies.config(text=b111)
        b20 = '{:.10}'.format(b12)
        galutinis.config(text=b20)
        a20 = a11
        c20 = c11
    if c1 == '':
        a11 = float(a1)
        b11 = float(b1)
        c11 = float(a11)**2 + float(b11)**2
        c12 = math.sqrt(c11)
        c13 = '{:.5}'.format(c12)
        ce.insert(0, c13)
        c111 = '{:.5}'.format(c11)
        saknies.config(text=c111)
        c20 = '{:.10}'.format(c12)
        galutinis.config(text=c20)
        a20 = a11
        b20 = b11
    elif (a1 != '') and (b1 != '') and (c1 != ''):
        error = Label(root, width=1, text='BENT VIENA REIKŠMĖ TURI BŪTI NEŽINOMA!', font='Verdana 12 bold', bg='white', fg='red')
        error.place(relwidth=0.8, relheight=0.04, relx= 0.12, rely= 0.905)
    ploto1 = float(a20)
    ploto2 = float(b20)
    plotass = (ploto1*ploto2)/2
    plotassg = '{:.10}'.format(plotass)
    plotoats.config(text=plotassg)
    perimetro1 = float(a20)
    perimetro2 = float(b20)
    perimetro3 = float(c20)
    perimetrof = perimetro1 + perimetro2 + perimetro3
    perimetroff = '{:.9}'.format(perimetrof)
    perimetroats.config(text=perimetroff)

def resetas():
    error = Label(root, width=1, bg='#80c1ff', fg='#80c1ff')
    error.place(relwidth=0.8, relheight=0.04, relx= 0.12, rely= 0.905)
    ae.delete(0, END)
    be.delete(0, END)
    ce.delete(0, END)
    saknies.config(text='')
    galutinis.config(text='')
    plotoats.config(text='')
    perimetroats.config(text='')

plotoats = Label(root, width=1, font='Verdana 12 bold', bg='white', text='')
plotoats.place(relwidth=0.2, relheight=0.04, relx= 0.55, rely= 0.85)

plotas = Label(root, width=1, font='Verdana 12 bold', bg='white', text='Trikampio plotas = ')
plotas.place(relwidth=0.3, relheight=0.04, relx= 0.24, rely= 0.85)

plotoats = Label(root, width=1, font='Verdana 12 bold', bg='white', text='')
plotoats.place(relwidth=0.2, relheight=0.04, relx= 0.55, rely= 0.85)

perimetras = Label(root, width=1, font='Verdana 12 bold', bg='white', text='Trikampio perimetras = ')
perimetras.place(relwidth=0.37, relheight=0.04, relx= 0.21, rely= 0.795)

perimetroats = Label(root, width=1, font='Verdana 12 bold', bg='white', text='')
perimetroats.place(relwidth=0.19, relheight=0.04, relx= 0.59, rely= 0.795)

ats = Label (root, width=1, font='Verdana 12 bold', bg='white', text='Ats.: ')
ats.place(relwidth=0.1, relheight=0.04, relx= 0.21, rely= 0.74)

im = Image.open("E:/Pytono projektai/square-root-symbol-png-3.png")
new_size = im.resize((36, 16))
ph = ImageTk.PhotoImage(new_size)
label = Label(image=ph)
label.place(relx= 0.32, rely= 0.74)

saknies = Label(root, width=1, font='Verdana 12 bold', bg='white', text='')
saknies.place(relwidth=0.1, relheight=0.04, relx= 0.40, rely= 0.74)

lygu = Label(root, width=1, font='Verdana 12 bold', bg='white', text='=')
lygu.place(relwidth=0.05, relheight=0.04, relx= 0.515, rely= 0.74)

galutinis = Label(root, width=1, font='Verdana 12 bold', bg='white', text='')
galutinis.place(relwidth=0.2, relheight=0.04, relx= 0.58, rely= 0.74)

skaiciuoti = Button(text='SKAIČIUOTI', font='Verdana 12 bold', command=skaiciuotuvas)
skaiciuoti.place(relwidth=0.4, relheight=0.04, relx= 0.29, rely= 0.62)

reset = Button(text='RESET', font='Verdana 12 bold', command=resetas)
reset.place(relwidth=0.4, relheight=0.04, relx= 0.29, rely= 0.68)

a = Label(root, width=1, text='a=', font='Verdana 12 bold', bg='white')
a.place(relwidth=0.04, relheight=0.04, relx= 0.18, rely= 0.38)

ae = Entry(root, width=1, font=10, border=2)
ae.place(relwidth=0.09, relheight=0.04, relx= 0.23, rely= 0.38)

b = Label(root, width=1, text='b=', font='Verdana 12 bold', bg='white')
b.place(relwidth=0.04, relheight=0.04, relx= 0.38, rely= 0.562)

be = Entry(root, width=1, font=10, border=2)
be.place(relwidth=0.09, relheight=0.04, relx= 0.43, rely= 0.562)

c = Label(root, width=1, text='c=', font='Verdana 12 bold', bg='white')
c.place(relwidth=0.04, relheight=0.04, relx= 0.50, rely= 0.37)

ce = Entry(root, width=1, font=10, border=2,)
ce.place(relwidth=0.09, relheight=0.04, relx= 0.545, rely= 0.37)

root.mainloop()```

</code>```

答:
I think the only way to solve your problem is to change every .place method you use into .grid or .pack. In my opinion using mentioned methods is way simpler and faster than using place.

Place method allows you to set relative or absolute position, which in fact you are doing. It is useful when you want to make your widgets change size/position according to it's parent. If it is not your intention you should use grid or pack

Body:
So I've made this simple program. The problem is that I did not think in advance that when the window is resized I want all objects inside it to resize as well. Is there any way to write something simple which would affect everything below instead of writing something to every single line? To make things more clear you can run my code and resize window. You will understand where the problem is:

from tkinter import *
import sys
from PIL import ImageTk, Image
import math
import tkinter.font as TkFont

root = tk.Tk()

#Lango dydis
#root.geometry("500x600+0+0")
HEIGHT = 500
WIDTH = 600

canvas = tk.Canvas(root, height=HEIGHT, width=WIDTH )
canvas.pack()

frame=Frame(root, bg='#80c1ff', bd=5)
frame.place(relwidth=1, relheight=1)

trikampis = ImageTk.PhotoImage(Image.open("E:/Pytono projektai/240px-Rtriangle.png"))
trikampis2 = Label(root, image=trikampis)
trikampis2.place(relx= 0.29, rely= 0.2)

def skaiciuotuvas():
    error = Label(root, width=1, bg='#80c1ff', fg='#80c1ff')
    error.place(relwidth=0.8, relheight=0.04, relx= 0.12, rely= 0.905)
    a1 = ae.get()
    b1 = be.get()
    c1 = ce.get()
    if a1 == '':
        b11 = float(b1)
        c11 = float(c1)
        a11 = float(c11)**2 - float(b11)**2
        a12 = math.sqrt(a11)
        a13 = '{:.5}'.format(a12)
        ae.insert(0, a13)
        a111 = '{:.5}'.format(a11)
        saknies.config(text=a111)
        a20 = '{:.10}'.format(a12)
        galutinis.config(text=a20)
        b20 = b11
        c20 = c11
    if b1 == '':
        a11 = float(a1)
        c11 = float(c1)
        b11 = float(c11)**2 - float(a11)**2
        b12 = math.sqrt(b11)
        b13 = '{:.5}'.format(b12)
        be.insert(0, b13)
        b111 = '{:.5}'.format(b11)
        saknies.config(text=b111)
        b20 = '{:.10}'.format(b12)
        galutinis.config(text=b20)
        a20 = a11
        c20 = c11
    if c1 == '':
        a11 = float(a1)
        b11 = float(b1)
        c11 = float(a11)**2 + float(b11)**2
        c12 = math.sqrt(c11)
        c13 = '{:.5}'.format(c12)
        ce.insert(0, c13)
        c111 = '{:.5}'.format(c11)
        saknies.config(text=c111)
        c20 = '{:.10}'.format(c12)
        galutinis.config(text=c20)
        a20 = a11
        b20 = b11
    elif (a1 != '') and (b1 != '') and (c1 != ''):
        error = Label(root, width=1, text='BENT VIENA REIKŠMĖ TURI BŪTI NEŽINOMA!', font='Verdana 12 bold', bg='white', fg='red')
        error.place(relwidth=0.8, relheight=0.04, relx= 0.12, rely= 0.905)
    ploto1 = float(a20)
    ploto2 = float(b20)
    plotass = (ploto1*ploto2)/2
    plotassg = '{:.10}'.format(plotass)
    plotoats.config(text=plotassg)
    perimetro1 = float(a20)
    perimetro2 = float(b20)
    perimetro3 = float(c20)
    perimetrof = perimetro1 + perimetro2 + perimetro3
    perimetroff = '{:.9}'.format(perimetrof)
    perimetroats.config(text=perimetroff)

def resetas():
    error = Label(root, width=1, bg='#80c1ff', fg='#80c1ff')
    error.place(relwidth=0.8, relheight=0.04, relx= 0.12, rely= 0.905)
    ae.delete(0, END)
    be.delete(0, END)
    ce.delete(0, END)
    saknies.config(text='')
    galutinis.config(text='')
    plotoats.config(text='')
    perimetroats.config(text='')

plotoats = Label(root, width=1, font='Verdana 12 bold', bg='white', text='')
plotoats.place(relwidth=0.2, relheight=0.04, relx= 0.55, rely= 0.85)

plotas = Label(root, width=1, font='Verdana 12 bold', bg='white', text='Trikampio plotas = ')
plotas.place(relwidth=0.3, relheight=0.04, relx= 0.24, rely= 0.85)

plotoats = Label(root, width=1, font='Verdana 12 bold', bg='white', text='')
plotoats.place(relwidth=0.2, relheight=0.04, relx= 0.55, rely= 0.85)

perimetras = Label(root, width=1, font='Verdana 12 bold', bg='white', text='Trikampio perimetras = ')
perimetras.place(relwidth=0.37, relheight=0.04, relx= 0.21, rely= 0.795)

perimetroats = Label(root, width=1, font='Verdana 12 bold', bg='white', text='')
perimetroats.place(relwidth=0.19, relheight=0.04, relx= 0.59, rely= 0.795)

ats = Label (root, width=1, font='Verdana 12 bold', bg='white', text='Ats.: ')
ats.place(relwidth=0.1, relheight=0.04, relx= 0.21, rely= 0.74)

im = Image.open("E:/Pytono projektai/square-root-symbol-png-3.png")
new_size = im.resize((36, 16))
ph = ImageTk.PhotoImage(new_size)
label = Label(image=ph)
label.place(relx= 0.32, rely= 0.74)

saknies = Label(root, width=1, font='Verdana 12 bold', bg='white', text='')
saknies.place(relwidth=0.1, relheight=0.04, relx= 0.40, rely= 0.74)

lygu = Label(root, width=1, font='Verdana 12 bold', bg='white', text='=')
lygu.place(relwidth=0.05, relheight=0.04, relx= 0.515, rely= 0.74)

galutinis = Label(root, width=1, font='Verdana 12 bold', bg='white', text='')
galutinis.place(relwidth=0.2, relheight=0.04, relx= 0.58, rely= 0.74)

skaiciuoti = Button(text='SKAIČIUOTI', font='Verdana 12 bold', command=skaiciuotuvas)
skaiciuoti.place(relwidth=0.4, relheight=0.04, relx= 0.29, rely= 0.62)

reset = Button(text='RESET', font='Verdana 12 bold', command=resetas)
reset.place(relwidth=0.4, relheight=0.04, relx= 0.29, rely= 0.68)

a = Label(root, width=1, text='a=', font='Verdana 12 bold', bg='white')
a.place(relwidth=0.04, relheight=0.04, relx= 0.18, rely= 0.38)

ae = Entry(root, width=1, font=10, border=2)
ae.place(relwidth=0.09, relheight=0.04, relx= 0.23, rely= 0.38)

b = Label(root, width=1, text='b=', font='Verdana 12 bold', bg='white')
b.place(relwidth=0.04, relheight=0.04, relx= 0.38, rely= 0.562)

be = Entry(root, width=1, font=10, border=2)
be.place(relwidth=0.09, relheight=0.04, relx= 0.43, rely= 0.562)

c = Label(root, width=1, text='c=', font='Verdana 12 bold', bg='white')
c.place(relwidth=0.04, relheight=0.04, relx= 0.50, rely= 0.37)

ce = Entry(root, width=1, font=10, border=2,)
ce.place(relwidth=0.09, relheight=0.04, relx= 0.545, rely= 0.37)

root.mainloop()```


问:
Problem of loading TableView in uiviewcontroller in iphone
I have a UIViewController and also i have UITableViewController ( this is for making table view). I am calling UITableViewController from UIViewController in self window. This is calling well and I am also getting output. But I want to show only 3 Rows and I am seeing 3 Rows with title are showing and also extra raw with blank title are showing on Simulator. It means it is covering whole windows. How will i fix for 3 Rows displaying ?

thanks in advance.

I am loading by this function code..

```<code> MyViewController *History_Back = [[MyViewController alloc] initWithNibName:@"MyViewController" bundle:[NSBundle mainBundle]];

[window addSubview:History_Back.view];

[self.view addSubview:History_Back.view];
</code>```

........

This is calling for Tableview but want to open in same windows. I am new in iPhone so it may i am right.

答: Quick alternative would be to use 3 UITableViewCell instead of a UITableView.</p>

Body:
I have a UIViewController and also i have UITableViewController ( this is for making table view). I am calling UITableViewController from UIViewController in self window. This is calling well and I am also getting output. But I want to show only 3 Rows and I am seeing 3 Rows with title are showing and also extra raw with blank title are showing on Simulator. It means it is covering whole windows. How will i fix for 3 Rows displaying ?

thanks in advance.

I am loading by this function code..

 MyViewController *History_Back = [[MyViewController alloc] initWithNibName:@"MyViewController" bundle:[NSBundle mainBundle]];

[window addSubview:History_Back.view];

[self.view addSubview:History_Back.view];

........

This is calling for Tableview but want to open in same windows. I am new in iPhone so it may i am right.


问:
Matlab using fzero to find intersecting points
i face an issue using fzero to find the x value where both graphs meet.
 Both sets of data are on the same figure.
  Data set 1

```<code>z = sqrt(D.^2 + x.^2)
zcost = CS1*z;
landcost = C01*(L-x);
totcost = @(x) zcost + landcost;
figure(2)
plot(x,totcost(x),'k-');
</code>```

Data set 2

```<code>C2sea = CS2*(1+0.5*alpha*ee*D)*(sqrt(x.^2+(1+ee.^2)*D.^2));
C2land = C02*(L-x);
C2cost = @(x) C2sea + C2land;
figure(2)  %figure 2
plot(x,C2cost(x),'r-');
</code>```

答:
I can't reproduce your code since you did not include the value of D, CS1, etc.,  but you can do something like:

```<code>% Make up some arbitrary functions
x = linspace(0,10);
y1 = @(t) (t - 3).^2 + 10;
y2 = @(t) (t - 7).^2 + 15;

% Plot them
plot(x, y1(x) ,x, y2(x))
ylim([0 50])

% Define another function of the difference between y1 and y2
% this difference should be zero when the functions intersect
z = @(t) y1(t) - y2(t);
fzero(z, 5)
</code>```

Which gives:

```<code>ans =

    5.6250
</code>```

Body:
i face an issue using fzero to find the x value where both graphs meet.
 Both sets of data are on the same figure.
  Data set 1

z = sqrt(D.^2 + x.^2)
zcost = CS1*z;
landcost = C01*(L-x);
totcost = @(x) zcost + landcost;
figure(2)
plot(x,totcost(x),'k-');

Data set 2

C2sea = CS2*(1+0.5*alpha*ee*D)*(sqrt(x.^2+(1+ee.^2)*D.^2));
C2land = C02*(L-x);
C2cost = @(x) C2sea + C2land;
figure(2)  %figure 2
plot(x,C2cost(x),'r-');

Body:
I can't reproduce your code since you did not include the value of D, CS1, etc.,  but you can do something like:

% Make up some arbitrary functions
x = linspace(0,10);
y1 = @(t) (t - 3).^2 + 10;
y2 = @(t) (t - 7).^2 + 15;

% Plot them
plot(x, y1(x) ,x, y2(x))
ylim([0 50])

% Define another function of the difference between y1 and y2
% this difference should be zero when the functions intersect
z = @(t) y1(t) - y2(t);
fzero(z, 5)

Which gives:

ans =

    5.6250


问:
Executing remote script by curl doesn't work
I'm trying to run one script (which installs and setups Postgres DB) from another script (test.sh). The problem is that the script which is called inside my script is remote (online on GitHub) and it doesn't work.

I tried to call the script three different ways.

locally - works

remotely using bash <(curl... - raises error

remotely using curl ... | bash -s - downloads script and hangs...

test.sh

```<code>#!/bin/bash

# this works correctly (it's the same but local)
sudo bash postgres/setup.sh

# this raises "bash: /dev/fd/63: No such file or directory"
sudo bash <(curl -s https://raw.githubusercontent.com/milano-slesarik/sh-ubuntu-instant/master/postgres/setup.sh)

# this hangs
curl https://raw.githubusercontent.com/milano-slesarik/sh-ubuntu-instant/master/postgres/setup.sh | sudo bash -s
</code>```

The last one probably downloads the script but then hangs...

```<code>  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1532  100  1532    0     0   8281      0 --:--:-- --:--:-- --:--:--  8281
</code>```

Do you know how to make it work?
I want my scripts to be online so I don't have to clone/download then all the time.

答:
This may achieve what you wanted :</p>

```<code>sudo bash -c "bash <(curl -s https://raw.githubusercontent.com/milano-slesarik/sh-ubuntu-instant/master/postgres/setup.sh)"
</code>```

Body:
I'm trying to run one script (which installs and setups Postgres DB) from another script (test.sh). The problem is that the script which is called inside my script is remote (online on GitHub) and it doesn't work.

I tried to call the script three different ways.

locally - works

remotely using bash <(curl... - raises error

remotely using curl ... | bash -s - downloads script and hangs...

test.sh

#!/bin/bash

# this works correctly (it's the same but local)
sudo bash postgres/setup.sh

# this raises "bash: /dev/fd/63: No such file or directory"
sudo bash <(curl -s https://raw.githubusercontent.com/milano-slesarik/sh-ubuntu-instant/master/postgres/setup.sh)

# this hangs
curl https://raw.githubusercontent.com/milano-slesarik/sh-ubuntu-instant/master/postgres/setup.sh | sudo bash -s

The last one probably downloads the script but then hangs...

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1532  100  1532    0     0   8281      0 --:--:-- --:--:-- --:--:--  8281

Do you know how to make it work?
I want my scripts to be online so I don't have to clone/download then all the time.

Body:
This may achieve what you wanted :

sudo bash -c "bash <(curl -s https://raw.githubusercontent.com/milano-slesarik/sh-ubuntu-instant/master/postgres/setup.sh)"


问:
Groovy cache for methodMissing not working
I implemented methodMissing() for my groovy class and then added the intercepted method to MetaClass. Assumption is that after first call to non-implement method, next time it won't invoke methodMissing(). But, it's not working like that. Instead, methodMissing is getting called every time.

Below is code snippet:

```<code>class MyDeveloper {

    List lang = []
    def methodMissing(String name, args) {
        println "$name method was called"

        if(name.startsWith("write")) {
            String language = name.split("write")[1]
            if( lang.contains(language) ) {
                def myImpl = { Object[] theArgs ->
                    println "love to write code in $language"
                }
                MyDeveloper.metaClass."$name" = myImpl
                return myImpl(args)
            }
        }
    }
}

MyDeveloper n = new MyDeveloper()
n.lang << "Groovy"
n.lang << "Java"

n.writeGroovy()
n.writeGroovy()
n.writeGroovy()

n.writeJava()
n.writeJava()
</code>```

O/P:

```<code>writeGroovy method was called
love to write code in Groovy
writeGroovy method was called
love to write code in Groovy
writeGroovy method was called
love to write code in Groovy

writeJava method was called
love to write code in Java
writeJava method was called
love to write code in Java
</code>```

Expected O/P:

```<code>writeGroovy method was called
love to write code in Groovy
love to write code in Groovy
love to write code in Groovy

writeJava method was called
love to write code in Java
love to write code in Java
</code>```

I am using:

```<code>➜  ~ groovy -v
Groovy Version: 3.0.4 JVM: 1.8.0_252 Vendor: AdoptOpenJDK OS: Mac OS X
➜  ~ java -version
openjdk version "1.8.0_252"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_252-b09)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.252-b09, mixed mode)
</code>```

答:
You are missing a piece in the constructor to enable "caching":

```<code>class Dev {

  Dev(){
    def mc = new ExpandoMetaClass(Dev, false, true)
    mc.initialize()
    this.metaClass = mc
  }

  def methodMissing(String name, args) {
     println "$name method was added"

     def myImpl = { Object[] a -> println ">> $name, $a" }
     this.metaClass."$name" = myImpl
     myImpl args
  }
}

def d = new Dev()

d.en 'a'
d.de 'b'
d.de 'b'
</code>```

And it prints:

```<code>en method was added
>> en, [a]
de method was added
>> de, [b]
>> de, [b]
</code>```

Body:
I implemented methodMissing() for my groovy class and then added the intercepted method to MetaClass. Assumption is that after first call to non-implement method, next time it won't invoke methodMissing(). But, it's not working like that. Instead, methodMissing is getting called every time.

Below is code snippet:

class MyDeveloper {

    List lang = []
    def methodMissing(String name, args) {
        println "$name method was called"

        if(name.startsWith("write")) {
            String language = name.split("write")[1]
            if( lang.contains(language) ) {
                def myImpl = { Object[] theArgs ->
                    println "love to write code in $language"
                }
                MyDeveloper.metaClass."$name" = myImpl
                return myImpl(args)
            }
        }
    }
}

MyDeveloper n = new MyDeveloper()
n.lang << "Groovy"
n.lang << "Java"

n.writeGroovy()
n.writeGroovy()
n.writeGroovy()

n.writeJava()
n.writeJava()

O/P:

writeGroovy method was called
love to write code in Groovy
writeGroovy method was called
love to write code in Groovy
writeGroovy method was called
love to write code in Groovy

writeJava method was called
love to write code in Java
writeJava method was called
love to write code in Java

Expected O/P:

writeGroovy method was called
love to write code in Groovy
love to write code in Groovy
love to write code in Groovy

writeJava method was called
love to write code in Java
love to write code in Java

I am using:

➜  ~ groovy -v
Groovy Version: 3.0.4 JVM: 1.8.0_252 Vendor: AdoptOpenJDK OS: Mac OS X
➜  ~ java -version
openjdk version "1.8.0_252"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_252-b09)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.252-b09, mixed mode)

Body:
You are missing a piece in the constructor to enable "caching":

class Dev {

  Dev(){
    def mc = new ExpandoMetaClass(Dev, false, true)
    mc.initialize()
    this.metaClass = mc
  }

  def methodMissing(String name, args) {
     println "$name method was added"

     def myImpl = { Object[] a -> println ">> $name, $a" }
     this.metaClass."$name" = myImpl
     myImpl args
  }
}

def d = new Dev()

d.en 'a'
d.de 'b'
d.de 'b'

And it prints:

en method was added
>> en, [a]
de method was added
>> de, [b]
>> de, [b]


问:
ASP.NET Core MVC: asp-for is rendering incomplete id and name attributes
When I iterate over a list in my .cshtml file, for some reason the id and name attribute values are rendered incomplete. For example:

```<code> @for (int i = 0; i < Model.product.ProductDetail.Count(); i++)
{
    <input type="text"
    asp-for="product.ProductDetail.ElementAt(i).Sku"
    class="form-control"
    placeholder="@SharedLocalizer["Sku"]" />
}
</code>```

Is rendered as:

```<code><input type="text" class="form-control" placeholder="Sku" id="Sku" name="Sku">
</code>```

Instead of:

```<code><input type="text" id="product.ProductDetail_0__Sku" name="product.ProductDetail[0].Sku" class="form-control" placeholder="Sku">
</code>```

I am using Entity Framework Core 3.1.3, here is my model:

Product:

```<code>public partial class Product
{
     public Product()
     {
          ProductDetail = new HashSet<ProductDetail>();
     }

     /* More properties here... */

     public virtual ICollection<ProductDetail> ProductDetail { get; set; }
}
</code>```

ProductDetail:

```<code>public partial class ProductDetail
{
    /* More properties here... */
    public string Sku { get; set; }
}
</code>```

ProductViewModel:

```<code>public class ProductViewModel
{
    public Product product { get; set; }
    /* More properties here... */
}
</code>```

Do you know why is this happening?

答:
The asp-for is a ModelExpression that is evaluated in order to build up the id and name attributes. If you use ElementAt(), this expression cannot be evaluated fully.

Try using a direct indexer int your collection instead. Example as follows:

<input type="text"
asp-for="product.ProductDetail[i].Sku"
class="form-control"
placeholder="@SharedLocalizer["Sku"]" />
```

Edit:
I strongly recommend using view models rather than data persistence level models with your views. You could then use a List in your view model (instead of an ICollection and apply the above indexing accordingly.

Body:
When I iterate over a list in my .cshtml file, for some reason the id and name attribute values are rendered incomplete. For example:

 @for (int i = 0; i < Model.product.ProductDetail.Count(); i++)
{
    <input type="text"
    asp-for="product.ProductDetail.ElementAt(i).Sku"
    class="form-control"
    placeholder="@SharedLocalizer["Sku"]" />
}

Is rendered as:

<input type="text" class="form-control" placeholder="Sku" id="Sku" name="Sku">

Instead of:

<input type="text" id="product.ProductDetail_0__Sku" name="product.ProductDetail[0].Sku" class="form-control" placeholder="Sku">

I am using Entity Framework Core 3.1.3, here is my model:

Product:

public partial class Product
{
     public Product()
     {
          ProductDetail = new HashSet<ProductDetail>();
     }

     /* More properties here... */

     public virtual ICollection<ProductDetail> ProductDetail { get; set; }
}

ProductDetail:

public partial class ProductDetail
{
    /* More properties here... */
    public string Sku { get; set; }
}

ProductViewModel:

public class ProductViewModel
{
    public Product product { get; set; }
    /* More properties here... */
}

Do you know why is this happening?

Body:
The asp-for is a ModelExpression that is evaluated in order to build up the id and name attributes. If you use ElementAt(), this expression cannot be evaluated fully.

Try using a direct indexer int your collection instead. Example as follows:

<input type="text"
asp-for="product.ProductDetail[i].Sku"
class="form-control"
placeholder="@SharedLocalizer["Sku"]" />

Edit:
I strongly recommend using view models rather than data persistence level models with your views. You could then use a List in your view model (instead of an ICollection and apply the above indexing accordingly.


问:
How to turn txt file to nice dataframe
I have a txt file containing Track ID, Song ID, Artist Name and Song name. I'd like to convert it into a dataframe in R to do some analysis. What would be a good function to use to separate the data? Below is the top row of the dataset. Thanks!</p>

```<code>TRMMMKD128F425225D<SEP>SOVFVAK12A8C1350D9<SEP>Karkkiautomaatti<SEP>Tanssi vaan
</code>```

答:
We can use separate

```<code>library(tidyr)
separate(df1, 'Col1', into = c('TrackID', 'SongID', 'ArtistName', 'SongName'),

         "\\<SEP\\>")
</code>```

Title: How to turn txt file to nice dataframe

Body:
I have a txt file containing Track ID, Song ID, Artist Name and Song name. I'd like to convert it into a dataframe in R to do some analysis. What would be a good function to use to separate the data? Below is the top row of the dataset. Thanks!

TRMMMKD128F425225D<SEP>SOVFVAK12A8C1350D9<SEP>Karkkiautomaatti<SEP>Tanssi vaan

Body:
We can use separate

library(tidyr)
separate(df1, 'Col1', into = c('TrackID', 'SongID', 'ArtistName', 'SongName'),

         "\\<SEP\\>")


问:
Django custom user model doesn't show up under Authentication and Authorization in the admin page
I have been trying to figure this out for a few hours and feel lost. I am new to django and have tried to create a custom user model. My struggle is that my user model won't show up under the Authentication and Authorization section of the admin page. Admin page pic

Here is my code for the model

```<code>from django.db import models
from django.contrib.auth.models import  AbstractUser

# Create your models here.
class User(AbstractUser):
    first_name = models.TextField(max_length = 300)
    last_name = models.TextField(max_length = 300)
</code>```

Here is the code for my admin.py file

```<code>from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from orders.models import User
# Register your models here.
admin.site.register(User,UserAdmin)
</code>```

here is a snippet of my settings.py file where i added the AUTH_USER_MODEL

```<code>AUTH_USER_MODEL='orders.User'
# Application definition

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'orders'
</code>```

]

答:
You should not name your custom user model User. It will create issues with the base User model that you are extending.

The important thing to note is if you are using AbstractUser, then you do not need to override the username, first_name and last_name field if you're not going to do anything special with them because they are already implemented.

Your refactored User model:

```<code>from django.contrib.auth import models

class MyUser(models.AbstractUser):
    # Fields that you are not obliged to implement
    # username = models.CharField(max_length=100)
    # first_name = models.CharField(max_length=100)
    # last_name = models.CharField(max_length=100)
    groups = None
    user_permissions = None

    def __str__(self):
        return self.username
</code>```

User admin:

```<code>@admin.register(MyUser)
class MyUserAdmin(admin.ModelAdmin):
    list_display = ['username']
</code>```

or,

```<code>admin.site.register(MyUser, MyUserAdmin)
</code>```

In settings.py you can take out the AUTH_USER_MODEL which is not necessary unless you are creating the User model from scratch.

Body:
I have been trying to figure this out for a few hours and feel lost. I am new to django and have tried to create a custom user model. My struggle is that my user model won't show up under the Authentication and Authorization section of the admin page. Admin page pic

Here is my code for the model

from django.db import models
from django.contrib.auth.models import  AbstractUser

# Create your models here.
class User(AbstractUser):
    first_name = models.TextField(max_length = 300)
    last_name = models.TextField(max_length = 300)

Here is the code for my admin.py file

from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from orders.models import User
# Register your models here.
admin.site.register(User,UserAdmin)

here is a snippet of my settings.py file where i added the AUTH_USER_MODEL

AUTH_USER_MODEL='orders.User'
# Application definition

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'orders'

]

Body:
You should not name your custom user model User. It will create issues with the base User model that you are extending.

The important thing to note is if you are using AbstractUser, then you do not need to override the username, first_name and last_name field if you're not going to do anything special with them because they are already implemented.

Your refactored User model:

from django.contrib.auth import models

class MyUser(models.AbstractUser):
    # Fields that you are not obliged to implement
    # username = models.CharField(max_length=100)
    # first_name = models.CharField(max_length=100)
    # last_name = models.CharField(max_length=100)
    groups = None
    user_permissions = None

    def __str__(self):
        return self.username

User admin:

@admin.register(MyUser)
class MyUserAdmin(admin.ModelAdmin):
    list_display = ['username']

or,

admin.site.register(MyUser, MyUserAdmin)

In settings.py you can take out the AUTH_USER_MODEL which is not necessary unless you are creating the User model from scratch.


问:
JQuery Tools Overlay Reload Parent On Close
This might be painfully easy, but I haven't found anything while searching,
I need to refresh the parent on close of the overlay.
Any Help is much appreciated. </p>

<p>Thanks Jcolebrand, this works </p>

```<code>$("a.help[rel]").overlay({

        effect: 'apple',
        onClose: function(){
            window.location.reload(true);
        },

        onBeforeLoad: function() {

            // grab wrapper element inside content
            var wrap = this.getOverlay().find(".contentWrap");

            // load the page specified in the trigger
            wrap.attr('src', this.getTrigger().attr("href"));
        }

   });
</code>```

答:
Thanks Jcolebrand,</p>

```<code>$("a.help[rel]").overlay({

        effect: 'apple',
        onClose: function(){
            window.location.reload(true);
        },

        onBeforeLoad: function() {

            // grab wrapper element inside content
            var wrap = this.getOverlay().find(".contentWrap");

            // load the page specified in the trigger
            wrap.attr('src', this.getTrigger().attr("href"));
        }

   });
</code>```

Body:
This might be painfully easy, but I haven't found anything while searching,
I need to refresh the parent on close of the overlay.
Any Help is much appreciated.

Thanks Jcolebrand, this works

$("a.help[rel]").overlay({

        effect: 'apple',
        onClose: function(){
            window.location.reload(true);
        },

        onBeforeLoad: function() {

            // grab wrapper element inside content
            var wrap = this.getOverlay().find(".contentWrap");

            // load the page specified in the trigger
            wrap.attr('src', this.getTrigger().attr("href"));
        }

   });

Body:
Thanks Jcolebrand,

$("a.help[rel]").overlay({

        effect: 'apple',
        onClose: function(){
            window.location.reload(true);
        },

        onBeforeLoad: function() {

            // grab wrapper element inside content
            var wrap = this.getOverlay().find(".contentWrap");

            // load the page specified in the trigger
            wrap.attr('src', this.getTrigger().attr("href"));
        }

   });


问:
org.scalacheck and org.scalatest not found after sbt->compile
```<code>[trace] Stack trace suppressed: run last *:update for the full output.
[error] (*:update) sbt.ResolveException: unresolved dependency: org.scalatest#scalatest_2.12;2.2.4: not found
[error] unresolved dependency: org.scalacheck#scalacheck_2.12;1.12.1: not found
[error] unresolved dependency: org.scalactic#scalatest;3.0.1: not found
[error] unresolved dependency: org.scalacheck#scalacheck;1.13.4: not found
[error] unresolved dependency: org.scalatest#scalatest;3.0.1: not found
</code>```

in scala-2.12.1/lib/ following files exists:
scalacheck_2.12-1.13.4.jar scalactic_2.11-3.0.1.jar scalatest_2.11-3.0.1.jar

in build.sbt contains:

```<code>scalaVersion := "2.12.1"
libraryDependencies += "junit" % "junit" % "4.10" % "test"
libraryDependencies ++= assignmentsMap.value.values.flatMap(_.dependencies).toSeq
libraryDependencies += "org.scalacheck" % "scalacheck" % "1.13.4" % "test"
libraryDependencies += "org.scalactic" % "scalatest" % "3.0.1"
libraryDependencies += "org.scalatest" % "scalatest" % "3.0.1" % "test"
</code>```

but $ sbt and then compile error is thrown:
scala> developer@cn-vm-yourname:~/example/quickcheck$ sbt
[info] Loading global plugins from /home/developer/.sbt/0.13/plugins
[info] Loading project definition from /home/developer/example/quickcheck/project
[info] Set current project to progfun2-quickcheck (in build file:/home/developer/example/quickcheck/)

compile

```<code>[info] Updating {file:/home/developer/example/quickcheck/}root...
[info] Resolving org.scalatest#scalatest_2.12;2.2.4 ...
[warn]  module not found: org.scalatest#scalatest_2.12;2.2.4
[warn] ==== local: tried
[warn]   /home/developer/.ivy2/local/org.scalatest/scalatest_2.12/2.2.4/ivys/ivy.xml
[warn] ==== activator-launcher-local: tried
[warn]   /home/developer/.activator/repository/org.scalatest/scalatest_2.12/2.2.4/ivys/ivy.xml
[warn] ==== activator-local: tried
[warn]   /home/developer/activator-dist-1.3.12/repository/org.scalatest/scalatest_2.12/2.2.4/ivys/ivy.xml
[warn] ==== public: tried
[warn]   https://repo1.maven.org/maven2/org/scalatest/scalatest_2.12/2.2.4/scalatest_2.12-2.2.4.pom
[warn] ==== typesafe-releases: tried
[warn]   http://repo.typesafe.com/typesafe/releases/org/scalatest/scalatest_2.12/2.2.4/scalatest_2.12-2.2.4.pom
[warn] ==== typesafe-ivy-releasez: tried
[warn]   http://repo.typesafe.com/typesafe/ivy-releases/org.scalatest/scalatest_2.12/2.2.4/ivys/ivy.xml
[info] Resolving org.scalacheck#scalacheck_2.12;1.12.1 ...
[warn]  module not found: org.scalacheck#scalacheck_2.12;1.12.1
[warn] ==== local: tried
[warn]   /home/developer/.ivy2/local/org.scalacheck/scalacheck_2.12/1.12.1/ivys/ivy.xml
[warn] ==== activator-launcher-local: tried
[warn]   /home/developer/.activator/repository/org.scalacheck/scalacheck_2.12/1.12.1/ivys/ivy.xml
[warn] ==== activator-local: tried
[warn]   /home/developer/activator-dist-1.3.12/repository/org.scalacheck/scalacheck_2.12/1.12.1/ivys/ivy.xml
[warn] ==== public: tried
[warn]   https://repo1.maven.org/maven2/org/scalacheck/scalacheck_2.12/1.12.1/scalacheck_2.12-1.12.1.pom
[warn] ==== typesafe-releases: tried
[warn]   http://repo.typesafe.com/typesafe/releases/org/scalacheck/scalacheck_2.12/1.12.1/scalacheck_2.12-1.12.1.pom
[warn] ==== typesafe-ivy-releasez: tried
[warn]   http://repo.typesafe.com/typesafe/ivy-releases/org.scalacheck/scalacheck_2.12/1.12.1/ivys/ivy.xml
[info] Resolving org.scalactic#scalatest;3.0.1 ...
[warn]  module not found: org.scalactic#scalatest;3.0.1
[warn] ==== local: tried
[warn]   /home/developer/.ivy2/local/org.scalactic/scalatest/3.0.1/ivys/ivy.xml
[warn] ==== activator-launcher-local: tried
[warn]   /home/developer/.activator/repository/org.scalactic/scalatest/3.0.1/ivys/ivy.xml
[warn] ==== activator-local: tried
[warn]   /home/developer/activator-dist-1.3.12/repository/org.scalactic/scalatest/3.0.1/ivys/ivy.xml
[warn] ==== public: tried
[warn]   https://repo1.maven.org/maven2/org/scalactic/scalatest/3.0.1/scalatest-3.0.1.pom
[warn] ==== typesafe-releases: tried
[warn]   http://repo.typesafe.com/typesafe/releases/org/scalactic/scalatest/3.0.1/scalatest-3.0.1.pom
[warn] ==== typesafe-ivy-releasez: tried
[warn]   http://repo.typesafe.com/typesafe/ivy-releases/org.scalactic/scalatest/3.0.1/ivys/ivy.xml
[info] Resolving org.scalacheck#scalacheck;1.13.4 ...
[warn]  module not found: org.scalacheck#scalacheck;1.13.4
[warn] ==== local: tried
[warn]   /home/developer/.ivy2/local/org.scalacheck/scalacheck/1.13.4/ivys/ivy.xml
[warn] ==== activator-launcher-local: tried
[warn]   /home/developer/.activator/repository/org.scalacheck/scalacheck/1.13.4/ivys/ivy.xml
[warn] ==== activator-local: tried
[warn]   /home/developer/activator-dist-1.3.12/repository/org.scalacheck/scalacheck/1.13.4/ivys/ivy.xml
[warn] ==== public: tried
[warn]   https://repo1.maven.org/maven2/org/scalacheck/scalacheck/1.13.4/scalacheck-1.13.4.pom
[warn] ==== typesafe-releases: tried
[warn]   http://repo.typesafe.com/typesafe/releases/org/scalacheck/scalacheck/1.13.4/scalacheck-1.13.4.pom
[warn] ==== typesafe-ivy-releasez: tried
[warn]   http://repo.typesafe.com/typesafe/ivy-releases/org.scalacheck/scalacheck/1.13.4/ivys/ivy.xml
[info] Resolving org.scalatest#scalatest;3.0.1 ...
[warn]  module not found: org.scalatest#scalatest;3.0.1
[warn] ==== local: tried
[warn]   /home/developer/.ivy2/local/org.scalatest/scalatest/3.0.1/ivys/ivy.xml
[warn] ==== activator-launcher-local: tried
[warn]   /home/developer/.activator/repository/org.scalatest/scalatest/3.0.1/ivys/ivy.xml
[warn] ==== activator-local: tried
[warn]   /home/developer/activator-dist-1.3.12/repository/org.scalatest/scalatest/3.0.1/ivys/ivy.xml
[warn] ==== public: tried
[warn]   https://repo1.maven.org/maven2/org/scalatest/scalatest/3.0.1/scalatest-3.0.1.pom
[warn] ==== typesafe-releases: tried
[warn]   http://repo.typesafe.com/typesafe/releases/org/scalatest/scalatest/3.0.1/scalatest-3.0.1.pom
[warn] ==== typesafe-ivy-releasez: tried
[warn]   http://repo.typesafe.com/typesafe/ivy-releases/org.scalatest/scalatest/3.0.1/ivys/ivy.xml
[info] Resolving jline#jline;2.14.1 ...
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  ::          UNRESOLVED DEPENDENCIES         ::
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  :: org.scalatest#scalatest_2.12;2.2.4: not found
[warn]  :: org.scalacheck#scalacheck_2.12;1.12.1: not found
[warn]  :: org.scalactic#scalatest;3.0.1: not found
[warn]  :: org.scalacheck#scalacheck;1.13.4: not found
[warn]  :: org.scalatest#scalatest;3.0.1: not found
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]
[warn]  Note: Unresolved dependencies path:
[warn]      org.scalatest:scalatest_2.12:2.2.4 (/home/developer/example/quickcheck/project/StudentBuildLike.scala#L27)
[warn]        +- progfun2-quickcheck:progfun2-quickcheck_2.12:0.1-SNAPSHOT
[warn]      org.scalactic:scalatest:3.0.1 (/home/developer/example/quickcheck/build.sbt#L11-12)
[warn]        +- progfun2-quickcheck:progfun2-quickcheck_2.12:0.1-SNAPSHOT
[warn]      org.scalacheck:scalacheck:1.13.4 (/home/developer/example/quickcheck/build.sbt#L10-11)
[warn]        +- progfun2-quickcheck:progfun2-quickcheck_2.12:0.1-SNAPSHOT
[warn]      org.scalatest:scalatest:3.0.1 (/home/developer/example/quickcheck/build.sbt#L12-13)
[warn]        +- progfun2-quickcheck:progfun2-quickcheck_2.12:0.1-SNAPSHOT
[warn]      org.scalacheck:scalacheck_2.12:1.12.1 (/home/developer/example/quickcheck/build.sbt#L9-10)
[warn]        +- progfun2-quickcheck:progfun2-quickcheck_2.12:0.1-SNAPSHOT
[trace] Stack trace suppressed: run last *:update for the full output.
[error] (*:update) sbt.ResolveException: unresolved dependency: org.scalatest#scalatest_2.12;2.2.4: not found
[error] unresolved dependency: org.scalacheck#scalacheck_2.12;1.12.1: not found
[error] unresolved dependency: org.scalactic#scalatest;3.0.1: not found
[error] unresolved dependency: org.scalacheck#scalacheck;1.13.4: not found
[error] unresolved dependency: org.scalatest#scalatest;3.0.1: not found
</code>```

答:
In the plugins.sbt file make sure that sbt-plugin version is greater than or equal to 2.3.8</p>

```<code>addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.3.8")
</code>```

Body:
[trace] Stack trace suppressed: run last *:update for the full output.
[error] (*:update) sbt.ResolveException: unresolved dependency: org.scalatest#scalatest_2.12;2.2.4: not found
[error] unresolved dependency: org.scalacheck#scalacheck_2.12;1.12.1: not found
[error] unresolved dependency: org.scalactic#scalatest;3.0.1: not found
[error] unresolved dependency: org.scalacheck#scalacheck;1.13.4: not found
[error] unresolved dependency: org.scalatest#scalatest;3.0.1: not found

in scala-2.12.1/lib/ following files exists:
scalacheck_2.12-1.13.4.jar scalactic_2.11-3.0.1.jar scalatest_2.11-3.0.1.jar

in build.sbt contains:

scalaVersion := "2.12.1"
libraryDependencies += "junit" % "junit" % "4.10" % "test"
libraryDependencies ++= assignmentsMap.value.values.flatMap(_.dependencies).toSeq
libraryDependencies += "org.scalacheck" % "scalacheck" % "1.13.4" % "test"
libraryDependencies += "org.scalactic" % "scalatest" % "3.0.1"
libraryDependencies += "org.scalatest" % "scalatest" % "3.0.1" % "test"

but $ sbt and then compile error is thrown:
scala> developer@cn-vm-yourname:~/example/quickcheck$ sbt
[info] Loading global plugins from /home/developer/.sbt/0.13/plugins
[info] Loading project definition from /home/developer/example/quickcheck/project
[info] Set current project to progfun2-quickcheck (in build file:/home/developer/example/quickcheck/)

compile

[info] Updating {file:/home/developer/example/quickcheck/}root...
[info] Resolving org.scalatest#scalatest_2.12;2.2.4 ...
[warn]  module not found: org.scalatest#scalatest_2.12;2.2.4
[warn] ==== local: tried
[warn]   /home/developer/.ivy2/local/org.scalatest/scalatest_2.12/2.2.4/ivys/ivy.xml
[warn] ==== activator-launcher-local: tried
[warn]   /home/developer/.activator/repository/org.scalatest/scalatest_2.12/2.2.4/ivys/ivy.xml
[warn] ==== activator-local: tried
[warn]   /home/developer/activator-dist-1.3.12/repository/org.scalatest/scalatest_2.12/2.2.4/ivys/ivy.xml
[warn] ==== public: tried
[warn]   https://repo1.maven.org/maven2/org/scalatest/scalatest_2.12/2.2.4/scalatest_2.12-2.2.4.pom
[warn] ==== typesafe-releases: tried
[warn]   http://repo.typesafe.com/typesafe/releases/org/scalatest/scalatest_2.12/2.2.4/scalatest_2.12-2.2.4.pom
[warn] ==== typesafe-ivy-releasez: tried
[warn]   http://repo.typesafe.com/typesafe/ivy-releases/org.scalatest/scalatest_2.12/2.2.4/ivys/ivy.xml
[info] Resolving org.scalacheck#scalacheck_2.12;1.12.1 ...
[warn]  module not found: org.scalacheck#scalacheck_2.12;1.12.1
[warn] ==== local: tried
[warn]   /home/developer/.ivy2/local/org.scalacheck/scalacheck_2.12/1.12.1/ivys/ivy.xml
[warn] ==== activator-launcher-local: tried
[warn]   /home/developer/.activator/repository/org.scalacheck/scalacheck_2.12/1.12.1/ivys/ivy.xml
[warn] ==== activator-local: tried
[warn]   /home/developer/activator-dist-1.3.12/repository/org.scalacheck/scalacheck_2.12/1.12.1/ivys/ivy.xml
[warn] ==== public: tried
[warn]   https://repo1.maven.org/maven2/org/scalacheck/scalacheck_2.12/1.12.1/scalacheck_2.12-1.12.1.pom
[warn] ==== typesafe-releases: tried
[warn]   http://repo.typesafe.com/typesafe/releases/org/scalacheck/scalacheck_2.12/1.12.1/scalacheck_2.12-1.12.1.pom
[warn] ==== typesafe-ivy-releasez: tried
[warn]   http://repo.typesafe.com/typesafe/ivy-releases/org.scalacheck/scalacheck_2.12/1.12.1/ivys/ivy.xml
[info] Resolving org.scalactic#scalatest;3.0.1 ...
[warn]  module not found: org.scalactic#scalatest;3.0.1
[warn] ==== local: tried
[warn]   /home/developer/.ivy2/local/org.scalactic/scalatest/3.0.1/ivys/ivy.xml
[warn] ==== activator-launcher-local: tried
[warn]   /home/developer/.activator/repository/org.scalactic/scalatest/3.0.1/ivys/ivy.xml
[warn] ==== activator-local: tried
[warn]   /home/developer/activator-dist-1.3.12/repository/org.scalactic/scalatest/3.0.1/ivys/ivy.xml
[warn] ==== public: tried
[warn]   https://repo1.maven.org/maven2/org/scalactic/scalatest/3.0.1/scalatest-3.0.1.pom
[warn] ==== typesafe-releases: tried
[warn]   http://repo.typesafe.com/typesafe/releases/org/scalactic/scalatest/3.0.1/scalatest-3.0.1.pom
[warn] ==== typesafe-ivy-releasez: tried
[warn]   http://repo.typesafe.com/typesafe/ivy-releases/org.scalactic/scalatest/3.0.1/ivys/ivy.xml
[info] Resolving org.scalacheck#scalacheck;1.13.4 ...
[warn]  module not found: org.scalacheck#scalacheck;1.13.4
[warn] ==== local: tried
[warn]   /home/developer/.ivy2/local/org.scalacheck/scalacheck/1.13.4/ivys/ivy.xml
[warn] ==== activator-launcher-local: tried
[warn]   /home/developer/.activator/repository/org.scalacheck/scalacheck/1.13.4/ivys/ivy.xml
[warn] ==== activator-local: tried
[warn]   /home/developer/activator-dist-1.3.12/repository/org.scalacheck/scalacheck/1.13.4/ivys/ivy.xml
[warn] ==== public: tried
[warn]   https://repo1.maven.org/maven2/org/scalacheck/scalacheck/1.13.4/scalacheck-1.13.4.pom
[warn] ==== typesafe-releases: tried
[warn]   http://repo.typesafe.com/typesafe/releases/org/scalacheck/scalacheck/1.13.4/scalacheck-1.13.4.pom
[warn] ==== typesafe-ivy-releasez: tried
[warn]   http://repo.typesafe.com/typesafe/ivy-releases/org.scalacheck/scalacheck/1.13.4/ivys/ivy.xml
[info] Resolving org.scalatest#scalatest;3.0.1 ...
[warn]  module not found: org.scalatest#scalatest;3.0.1
[warn] ==== local: tried
[warn]   /home/developer/.ivy2/local/org.scalatest/scalatest/3.0.1/ivys/ivy.xml
[warn] ==== activator-launcher-local: tried
[warn]   /home/developer/.activator/repository/org.scalatest/scalatest/3.0.1/ivys/ivy.xml
[warn] ==== activator-local: tried
[warn]   /home/developer/activator-dist-1.3.12/repository/org.scalatest/scalatest/3.0.1/ivys/ivy.xml
[warn] ==== public: tried
[warn]   https://repo1.maven.org/maven2/org/scalatest/scalatest/3.0.1/scalatest-3.0.1.pom
[warn] ==== typesafe-releases: tried
[warn]   http://repo.typesafe.com/typesafe/releases/org/scalatest/scalatest/3.0.1/scalatest-3.0.1.pom
[warn] ==== typesafe-ivy-releasez: tried
[warn]   http://repo.typesafe.com/typesafe/ivy-releases/org.scalatest/scalatest/3.0.1/ivys/ivy.xml
[info] Resolving jline#jline;2.14.1 ...
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  ::          UNRESOLVED DEPENDENCIES         ::
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  :: org.scalatest#scalatest_2.12;2.2.4: not found
[warn]  :: org.scalacheck#scalacheck_2.12;1.12.1: not found
[warn]  :: org.scalactic#scalatest;3.0.1: not found
[warn]  :: org.scalacheck#scalacheck;1.13.4: not found
[warn]  :: org.scalatest#scalatest;3.0.1: not found
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]
[warn]  Note: Unresolved dependencies path:
[warn]      org.scalatest:scalatest_2.12:2.2.4 (/home/developer/example/quickcheck/project/StudentBuildLike.scala#L27)
[warn]        +- progfun2-quickcheck:progfun2-quickcheck_2.12:0.1-SNAPSHOT
[warn]      org.scalactic:scalatest:3.0.1 (/home/developer/example/quickcheck/build.sbt#L11-12)
[warn]        +- progfun2-quickcheck:progfun2-quickcheck_2.12:0.1-SNAPSHOT
[warn]      org.scalacheck:scalacheck:1.13.4 (/home/developer/example/quickcheck/build.sbt#L10-11)
[warn]        +- progfun2-quickcheck:progfun2-quickcheck_2.12:0.1-SNAPSHOT
[warn]      org.scalatest:scalatest:3.0.1 (/home/developer/example/quickcheck/build.sbt#L12-13)
[warn]        +- progfun2-quickcheck:progfun2-quickcheck_2.12:0.1-SNAPSHOT
[warn]      org.scalacheck:scalacheck_2.12:1.12.1 (/home/developer/example/quickcheck/build.sbt#L9-10)
[warn]        +- progfun2-quickcheck:progfun2-quickcheck_2.12:0.1-SNAPSHOT
[trace] Stack trace suppressed: run last *:update for the full output.
[error] (*:update) sbt.ResolveException: unresolved dependency: org.scalatest#scalatest_2.12;2.2.4: not found
[error] unresolved dependency: org.scalacheck#scalacheck_2.12;1.12.1: not found
[error] unresolved dependency: org.scalactic#scalatest;3.0.1: not found
[error] unresolved dependency: org.scalacheck#scalacheck;1.13.4: not found
[error] unresolved dependency: org.scalatest#scalatest;3.0.1: not found

Body:
In the plugins.sbt file make sure that sbt-plugin version is greater than or equal to 2.3.8

addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.3.8")


问:
High Level Assembly (HLA) Programming
I'm having trouble figuring out this assignment that I have in HLA.

Write a program to produce a number table as described here. This table should be built from a single integer value provided by the user. The program will display a square 5X5 of various numbers.  The entered number should appear in an X like pattern across the table, diagonally across the table.  Every other spot besides the X pattern should be filled with a number.  Those excess numbers should start with one bigger than the entered number and increment by one for every additional excess number used.

For example, the following output should be produced when the user inputs the starting value 15:

Gimme a starting value: 15

15 16 17 18 15

19 15 20 15 21

22 23 15 24 25

26 15 27 15 28

15 29 30 31 15

For example, the following output should be produced when the user inputs the starting value 20:

Gimme a starting value: 20

20 21 22 23 20

24 20 25 20 26

27 28 20 29 30

31 20 32 20 33

20 34 35 36 20

(Hint:  Please don't worry about the formatting of the table, if it doesn't exactly match mine above.  The goal is to practice with HLA and we really don't know enough to get the spacing just perfect...)

I have the following code that I've tried but can't figure it out. I am a totally new in HLA programming.

```<code>program tableX;

#include( "stdlib.hhf" );

// Initiate variable
static
tblX : int32 := 0; // tblX value

// Columns for row 1
column1 : int32 := 0;

// Start the program
begin tableX;

// Ask the user to input a value
stdout.put("Gimme a starting value: ");

// Get the user's inputted value
stdin.get(tblX);

// Get the value into the register EAX
mov(tblX, EAX);
mov(0, EBX);

mov(column1, EAX);
mov(1, EBX);

// Add the values
add(EAX, EBX);
add(1, tblX);

add(EAX, EBX);
add(1, column1);

// Put the value back into the tblX variable
mov(EBX, tblX);

// 1st row
stdout.put(tblX);
stdout.put(column1);

// End the program
end tableX;
</code>```

I'm literally having trouble on figuring out how to display it in 5x5. Do I need to add more variables for columns for each rows. I only added one column for testing purposes. If you can help with this, I'd really appreciate it. Thank you!

答:
ENVIRONMENT

HLA (High Level Assembler - HLABE back end, POLINK linker)
Version 2.16 build 4413 (prototype)

Windows 10

NOTE

There are several ways to go about solving this problem and this example could be improved.

EXAMPLE

```<code>program tableX;
#include( "stdlib.hhf" );

// Initiate variable
static
    OriginalVal: int32 := 0; // Original value
    DuplicateVal: int32 := 0; // Duplicate value for incrementing
    XPatternArray: int32[9] := [0, 4, 6, 8, 12, 16, 18, 20, 24]; // Indexes for X pattern

// Start the program
begin tableX;

    // Ask the user to input a value
    stdout.put("Gimme a starting value: ");

    // Get the user's inputted value
    stdin.get(OriginalVal);
    mov(OriginalVal, DuplicateVal);

    // Build and Print Table
    xor(EDX, EDX);
    for ( mov(0, EBX); EBX <= 24; inc(EBX) ) do

        mov(EBX, EAX);
        mov(5, ECX);
        idiv(CL);
        if ( AH == 0 ) then
            stdout.newln();
        endif;

        if ( EBX == XPatternArray[EDX*4] ) then
            stdout.put(OriginalVal, " ");
            inc(EDX);

        else
            inc(DuplicateVal);
            stdout.put(DuplicateVal, " ");

        endif;

    endfor;

// End the program
end tableX;
</code>```

Title: High Level Assembly (HLA) Programming

Body:
I'm having trouble figuring out this assignment that I have in HLA.

Write a program to produce a number table as described here. This table should be built from a single integer value provided by the user. The program will display a square 5X5 of various numbers.  The entered number should appear in an X like pattern across the table, diagonally across the table.  Every other spot besides the X pattern should be filled with a number.  Those excess numbers should start with one bigger than the entered number and increment by one for every additional excess number used.

For example, the following output should be produced when the user inputs the starting value 15:

Gimme a starting value: 15

15 16 17 18 15

19 15 20 15 21

22 23 15 24 25

26 15 27 15 28

15 29 30 31 15

For example, the following output should be produced when the user inputs the starting value 20:

Gimme a starting value: 20

20 21 22 23 20

24 20 25 20 26

27 28 20 29 30

31 20 32 20 33

20 34 35 36 20

(Hint:  Please don't worry about the formatting of the table, if it doesn't exactly match mine above.  The goal is to practice with HLA and we really don't know enough to get the spacing just perfect...)

I have the following code that I've tried but can't figure it out. I am a totally new in HLA programming.

program tableX;

#include( "stdlib.hhf" );

// Initiate variable
static
tblX : int32 := 0; // tblX value

// Columns for row 1
column1 : int32 := 0;

// Start the program
begin tableX;

// Ask the user to input a value
stdout.put("Gimme a starting value: ");

// Get the user's inputted value
stdin.get(tblX);

// Get the value into the register EAX
mov(tblX, EAX);
mov(0, EBX);

mov(column1, EAX);
mov(1, EBX);

// Add the values
add(EAX, EBX);
add(1, tblX);

add(EAX, EBX);
add(1, column1);

// Put the value back into the tblX variable
mov(EBX, tblX);

// 1st row
stdout.put(tblX);
stdout.put(column1);

// End the program
end tableX;

I'm literally having trouble on figuring out how to display it in 5x5. Do I need to add more variables for columns for each rows. I only added one column for testing purposes. If you can help with this, I'd really appreciate it. Thank you!

Body:
ENVIRONMENT

HLA (High Level Assembler - HLABE back end, POLINK linker)
Version 2.16 build 4413 (prototype)

Windows 10

NOTE

There are several ways to go about solving this problem and this example could be improved.

EXAMPLE

program tableX;
#include( "stdlib.hhf" );

// Initiate variable
static
    OriginalVal: int32 := 0; // Original value
    DuplicateVal: int32 := 0; // Duplicate value for incrementing
    XPatternArray: int32[9] := [0, 4, 6, 8, 12, 16, 18, 20, 24]; // Indexes for X pattern

// Start the program
begin tableX;

    // Ask the user to input a value
    stdout.put("Gimme a starting value: ");

    // Get the user's inputted value
    stdin.get(OriginalVal);
    mov(OriginalVal, DuplicateVal);

    // Build and Print Table
    xor(EDX, EDX);
    for ( mov(0, EBX); EBX <= 24; inc(EBX) ) do

        mov(EBX, EAX);
        mov(5, ECX);
        idiv(CL);
        if ( AH == 0 ) then
            stdout.newln();
        endif;

        if ( EBX == XPatternArray[EDX*4] ) then
            stdout.put(OriginalVal, " ");
            inc(EDX);

        else
            inc(DuplicateVal);
            stdout.put(DuplicateVal, " ");

        endif;

    endfor;

// End the program
end tableX;


问:
Local and global temporary tables in SQL Server
What is the difference between local and global temporary tables in SQL Server?</p>

答:
I didn't see any answers that show users where we can find a Global Temp table.  You can view Local and Global temp tables in the same location when navigating within SSMS.  Screenshot below taken from this link.

Databases --> System Databases --> tempdb --> Temporary Tables


问:
301 redirects clashing possibly with CloudFlare
My old 301 redirects in .htaccess are no longer working because something is redirecting things twice.  Example of redirect:

```<code>Redirect 301 /oldpage.html //www.example.com/newpage.php
</code>```

This used to work, but now it goes to:

```<code>https://www.example.com//www.example.com/newpage.php
</code>```

In CloudFlare, I have a Page Rule for the www redirection:

```<code>https://example.com/*
Forwarding URL (Status Code: 301 - Permanent Redirect, Url: https://www.example.com/$1)
</code>```

And my "Always Use HTTPS" in CloudFlare is on.  What could be causing the double redirect?

答:
I put one of the URLs into a redirect checker http://www.redirect-checker.org/
and noticed that for some reason the URLs go back to http, then back to https again.  So I went back and edited my .htaccess file to explicitly include the https:

```<code>Redirect 301 /oldpage.html https://www.example.com/newpage.php
</code>```

And now the redirect works as expected, at least in the incognito window. The regular browser isn't yet reflecting the change.

Body:
My old 301 redirects in .htaccess are no longer working because something is redirecting things twice.  Example of redirect:

Redirect 301 /oldpage.html //www.example.com/newpage.php

This used to work, but now it goes to:

https://www.example.com//www.example.com/newpage.php

In CloudFlare, I have a Page Rule for the www redirection:

https://example.com/*
Forwarding URL (Status Code: 301 - Permanent Redirect, Url: https://www.example.com/$1)

And my "Always Use HTTPS" in CloudFlare is on.  What could be causing the double redirect?

Body:
I put one of the URLs into a redirect checker http://www.redirect-checker.org/
and noticed that for some reason the URLs go back to http, then back to https again.  So I went back and edited my .htaccess file to explicitly include the https:

Redirect 301 /oldpage.html https://www.example.com/newpage.php

And now the redirect works as expected, at least in the incognito window. The regular browser isn't yet reflecting the change.