问:
spark-submit dependency conflict
I'm trying to submit a jar to spark but my jar contains dependencies that conflict with spark's built-in jars (snakeyml and others).

Is there a way to tell spark to prefer whatever dependencies my project has over the jars inside /jar
UPDATE

When i run spark-submit, i get the following exception:

```<code>Caused by: java.lang.NoSuchMethodError: javax.validation.BootstrapConfiguration.getClockProviderClassName()Ljava/lang/String;
at org.hibernate.validator.internal.xml.ValidationBootstrapParameters.<init>(ValidationBootstrapParameters.java:63)
at org.hibernate.validator.internal.engine.ConfigurationImpl.parseValidationXml(ConfigurationImpl.java:540)
at org.hibernate.validator.internal.engine.ConfigurationImpl.buildValidatorFactory(ConfigurationImpl.java:337)
at javax.validation.Validation.buildDefaultValidatorFactory(Validation.java:110)
at org.hibernate.cfg.beanvalidation.TypeSafeActivator.getValidatorFactory(TypeSafeActivator.java:501)
at org.hibernate.cfg.beanvalidation.TypeSafeActivator.activate(TypeSafeActivator.java:84)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.hibernate.cfg.beanvalidation.BeanValidationIntegrator.integrate(BeanValidationIntegrator.java:132)
... 41 more
</code>```

which is caused by spark having an older version of validation-api (validation-api-1.1.0.Final.jar)
My project has a dependency on the newer version and it does get bundled with my jar (javax.validation:validation-api:jar:2.0.1.Final:compile)

I submit using this command:

```<code>/spark/bin/spark-submit --conf spark.executor.userClassPathFirst=true --conf spark.driver.userClassPathFirst=true
</code>```

but i still get the same exception

答:
This is controlled by setting the following confs to true:</p>

```<code>spark.driver.userClassPathFirst
spark.executor.userClassPathFirst
</code>```

Title: spark-submit dependency conflict

Body:
I'm trying to submit a jar to spark but my jar contains dependencies that conflict with spark's built-in jars (snakeyml and others).

Is there a way to tell spark to prefer whatever dependencies my project has over the jars inside /jar
UPDATE

When i run spark-submit, i get the following exception:

Caused by: java.lang.NoSuchMethodError: javax.validation.BootstrapConfiguration.getClockProviderClassName()Ljava/lang/String;
at org.hibernate.validator.internal.xml.ValidationBootstrapParameters.<init>(ValidationBootstrapParameters.java:63)
at org.hibernate.validator.internal.engine.ConfigurationImpl.parseValidationXml(ConfigurationImpl.java:540)
at org.hibernate.validator.internal.engine.ConfigurationImpl.buildValidatorFactory(ConfigurationImpl.java:337)
at javax.validation.Validation.buildDefaultValidatorFactory(Validation.java:110)
at org.hibernate.cfg.beanvalidation.TypeSafeActivator.getValidatorFactory(TypeSafeActivator.java:501)
at org.hibernate.cfg.beanvalidation.TypeSafeActivator.activate(TypeSafeActivator.java:84)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.hibernate.cfg.beanvalidation.BeanValidationIntegrator.integrate(BeanValidationIntegrator.java:132)
... 41 more

which is caused by spark having an older version of validation-api (validation-api-1.1.0.Final.jar)
My project has a dependency on the newer version and it does get bundled with my jar (javax.validation:validation-api:jar:2.0.1.Final:compile)

I submit using this command:

/spark/bin/spark-submit --conf spark.executor.userClassPathFirst=true --conf spark.driver.userClassPathFirst=true

but i still get the same exception

Body:
This is controlled by setting the following confs to true:

spark.driver.userClassPathFirst
spark.executor.userClassPathFirst


来源: stackexchange

问:
ClassNotFoundException: org.slf4j.Logger
I'm trying to deploy a web app to tomcat using ANT but I ran into this error (the app compiles fine in a simple ant task. The issue occurs when Tomcat is restarted):

Stacktrace:

```<code>Caused by: java.lang.ClassNotFoundException: org.slf4j.Logger
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
    ... 24 more
</code>```

I red a couple of answers around here which state that besides slf4j an implementation such as log4j. This is an excerpt of the build.xml file:

```<code><pathelement location="${slf4j-api-1.7.2.jar}"/>
<pathelement location="${log4j.jar}"/>
</code>```

These are path elements used in the classpath of the build's javac command.

Besides not adding log4j as a dependency, what may be other reasons for this issue.
Any kind of help would be appreciated. Thanks!

答:
I solved this problem copying this 2 JARs below.

from (assuming you are using Maven to manage your dependecies):

.m2/repository/org/slf4j/slf4f-api/N.N.NN/slf4j-api-N.N.NN.jar

.m2/repository/org/slf4j/slf4f-log4j12/N.N.NN/slf4j-log4j12-N.N.NN.jar

to (apache installation folder):

apache-tomcat-M.M.MM/lib

ContentLicense: CC BY-SA 3.0

Body:
I'm trying to deploy a web app to tomcat using ANT but I ran into this error (the app compiles fine in a simple ant task. The issue occurs when Tomcat is restarted):

Stacktrace:

Caused by: java.lang.ClassNotFoundException: org.slf4j.Logger
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
    ... 24 more

I red a couple of answers around here which state that besides slf4j an implementation such as log4j. This is an excerpt of the build.xml file:

<pathelement location="${slf4j-api-1.7.2.jar}"/>
<pathelement location="${log4j.jar}"/>

These are path elements used in the classpath of the build's javac command.

Besides not adding log4j as a dependency, what may be other reasons for this issue.
Any kind of help would be appreciated. Thanks!

ContentLicense: CC BY-SA 4.0


问:
Why won't my keystroke in AppleScript command turn an open email message into an "outgoing" message?
I am trying to implement an AppleScript to find emails in a mailbox that are saved drafts of outgoing emails. Each one found there should then be opened, , turned into an outgoing message and then sent. I have gotten really close, but in the following script The keystroke command does nothing. It should turn the message into an outgoing message by invoking "Send Again".

```<code>using terms from application "Mail"
    tell application "Mail"
        set theMailbox to mailbox "OutgoingEmail" of account "iCloud"
        set foundMsgs to (every message in theMailbox)
        set the messageCount to the count of foundMsgs
        repeat with i from 1 to the messageCount
            set newMsg to item i of foundMsgs
            tell newMsg
                open
                tell application "System Events"
                    tell application process "Mail"
                        keystroke "D" using {shift down, command down}
                    end tell
                end tell
            end tell
        end repeat
    end tell
end using terms from
</code>```

It does nothing though. The message is opened, but the keystroke has no effect. The next step would be to send the message, but that is not shown in the script.

答:
I don't think you need to be using the "using terms from Mail" command, since you then have a tell block for mail on the very next line.

Try this code and see if it works.

```<code>    tell application "Mail"
        set theMailbox to mailbox "OutgoingEmail" of account "iCloud"
        set foundMsgs to (every message in theMailbox)
        set the messageCount to the count of foundMsgs
        repeat with i from 1 to the messageCount
            set newMsg to item i of foundMsgs
            tell newMsg
                open

            end tell
tell application "System Events"
                    tell application process "Mail"
                        keystroke "D" using {shift down, command down}
                    end tell
                end tell
        end repeat
    end tell
</code>```

Also try a seperate script of just the system events commands to see if they work on their own...

```<code>tell application "System Events"
                    tell application process "Mail"
                        keystroke "D" using {shift down, command down}
                    end tell
                end tell
</code>```

Body:
I am trying to implement an AppleScript to find emails in a mailbox that are saved drafts of outgoing emails. Each one found there should then be opened, , turned into an outgoing message and then sent. I have gotten really close, but in the following script The keystroke command does nothing. It should turn the message into an outgoing message by invoking "Send Again".

using terms from application "Mail"
    tell application "Mail"
        set theMailbox to mailbox "OutgoingEmail" of account "iCloud"
        set foundMsgs to (every message in theMailbox)
        set the messageCount to the count of foundMsgs
        repeat with i from 1 to the messageCount
            set newMsg to item i of foundMsgs
            tell newMsg
                open
                tell application "System Events"
                    tell application process "Mail"
                        keystroke "D" using {shift down, command down}
                    end tell
                end tell
            end tell
        end repeat
    end tell
end using terms from

It does nothing though. The message is opened, but the keystroke has no effect. The next step would be to send the message, but that is not shown in the script.

Body:
I don't think you need to be using the "using terms from Mail" command, since you then have a tell block for mail on the very next line.

Try this code and see if it works.

    tell application "Mail"
        set theMailbox to mailbox "OutgoingEmail" of account "iCloud"
        set foundMsgs to (every message in theMailbox)
        set the messageCount to the count of foundMsgs
        repeat with i from 1 to the messageCount
            set newMsg to item i of foundMsgs
            tell newMsg
                open

            end tell
tell application "System Events"
                    tell application process "Mail"
                        keystroke "D" using {shift down, command down}
                    end tell
                end tell
        end repeat
    end tell

Also try a seperate script of just the system events commands to see if they work on their own...

tell application "System Events"
                    tell application process "Mail"
                        keystroke "D" using {shift down, command down}
                    end tell
                end tell


问:
Table with no primary key due to lots of duplicates, trying to speed up my query to get rid of duplicates etc
I have a table of products from various suppliers all added together, so there are lots of duplicate SKU's (ManuPartNo), there are other elements, Price, Qty etc.  However I want to Choose the Highest Price based on the SKU (ManuPartNo) and also add together all of the Qty's for any matching SKU. I have a working query but was wondering if anyone could suggest how to speed it up, the table I am querying has 1.3 million rows and my query takes about 40 seconds to run.  Its not too slow but I am trying to learn more about optimization and this question is very hard to google so if anyone could give me any tips or point me in the right direction it would be much appreciated.

Here is the structure of the table I'm querying and my query its self.

```<code>CREATE TABLE [dbo].[AllProductsFromAllDistis](
[ProdName] [varchar](max) NULL,
[ManuPartNo] [varchar](150) NULL,
[Manufacturer] [varchar](150) NULL,
[Price] [decimal](10, 2) NOT NULL,
[Qty] [int] NOT NULL,
[Weight] [decimal](10, 2) NULL,
[UpcCode] [varchar](50) NULL,
[Supplier] [varchar](50) NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
</code>```

and my query to return only the values with the highest price and to add all qty's of any duplicate sku.

```<code>SELECT ProdName, ManuPartNo, Price, TotalQty, Weight, UPCCode, Supplier,
Manufacturer
FROM
(SELECT dbo.AllProductsFromAllDistis. *,
    ROW_NUMBER() OVER(PARTITION BY ManuPartNo ORDER BY Price ASC) AS RN,
    SUM(Qty) OVER(PARTITION BY ManuPartNo) AS TotalQty
        FROM AllProductsFromAllDistis) AS t
WHERE RN = 1
ORDER BY ManuPartNo
</code>```

As I say this works just fine but I am looking for suggestions on speeding it up.

答:
I recommend you this

```<code>SELECT t.ProdName, t.ManuPartNo, t.Price, t.TotalQty, t.Weight, t.UPCCode, t.Supplier,
t.Manufacturer
FROM
(SELECT ProdName,ManuPartNo,Price,Weight,UPCCode,Supplier,Manufacturer
    ROW_NUMBER() OVER(PARTITION BY ManuPartNo ORDER BY Price ASC) AS RN,
    SUM(Qty) OVER(PARTITION BY ManuPartNo) AS TotalQty
        FROM AllProductsFromAllDistis (Nolock) ) AS t
WHERE t.RN = 1
ORDER BY t.ManuPartNo
</code>```

Never forget it allways specify all column ( NOT --> Select * From
TableProduction)

If you are using subqueries put "t" in all your columns

Never forget it set a (Nolock) ...could cause blocked

Use "Execution Plan" in Menu->Query

I hope this can help you a little

Body:
I have a table of products from various suppliers all added together, so there are lots of duplicate SKU's (ManuPartNo), there are other elements, Price, Qty etc.  However I want to Choose the Highest Price based on the SKU (ManuPartNo) and also add together all of the Qty's for any matching SKU. I have a working query but was wondering if anyone could suggest how to speed it up, the table I am querying has 1.3 million rows and my query takes about 40 seconds to run.  Its not too slow but I am trying to learn more about optimization and this question is very hard to google so if anyone could give me any tips or point me in the right direction it would be much appreciated.

Here is the structure of the table I'm querying and my query its self.

CREATE TABLE [dbo].[AllProductsFromAllDistis](
[ProdName] [varchar](max) NULL,
[ManuPartNo] [varchar](150) NULL,
[Manufacturer] [varchar](150) NULL,
[Price] [decimal](10, 2) NOT NULL,
[Qty] [int] NOT NULL,
[Weight] [decimal](10, 2) NULL,
[UpcCode] [varchar](50) NULL,
[Supplier] [varchar](50) NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

and my query to return only the values with the highest price and to add all qty's of any duplicate sku.

SELECT ProdName, ManuPartNo, Price, TotalQty, Weight, UPCCode, Supplier,
Manufacturer
FROM
(SELECT dbo.AllProductsFromAllDistis. *,
    ROW_NUMBER() OVER(PARTITION BY ManuPartNo ORDER BY Price ASC) AS RN,
    SUM(Qty) OVER(PARTITION BY ManuPartNo) AS TotalQty
        FROM AllProductsFromAllDistis) AS t
WHERE RN = 1
ORDER BY ManuPartNo

As I say this works just fine but I am looking for suggestions on speeding it up.

Body:
I recommend you this

SELECT t.ProdName, t.ManuPartNo, t.Price, t.TotalQty, t.Weight, t.UPCCode, t.Supplier,
t.Manufacturer
FROM
(SELECT ProdName,ManuPartNo,Price,Weight,UPCCode,Supplier,Manufacturer
    ROW_NUMBER() OVER(PARTITION BY ManuPartNo ORDER BY Price ASC) AS RN,
    SUM(Qty) OVER(PARTITION BY ManuPartNo) AS TotalQty
        FROM AllProductsFromAllDistis (Nolock) ) AS t
WHERE t.RN = 1
ORDER BY t.ManuPartNo

Never forget it allways specify all column ( NOT --> Select * From
TableProduction)

If you are using subqueries put "t" in all your columns

Never forget it set a (Nolock) ...could cause blocked

Use "Execution Plan" in Menu->Query

I hope this can help you a little


问:
i can't Send Mail Using Contact Form With PHPMailer and Gmail SMTP
I'm trying to send an email from contact by using PHPMailer and Gmail SMTP, I actually don't know where is the issue?
I download PHPMailer from githup.
I tried to do it as this gay did.

contact.html

```<code>  <form action="contact.php" method="POST" class="p-5 ">
            <div class="row form-group">
              <div class=" mb-3 ">
                <label class="text-black" for="first-name">الاسم الاول</label>
                <input type="text" name="first-name" class="form-control" />
              </div>
              <div class="col">
                <label class="text-black" for="last-name">الاسم الاخير</label>
                <input type="text" name="last-name" class="form-control" />
              </div>
            </div>

            <div class="row form-group">
              <div class="col">
                <label class="text-black" for="email">إيميل</label>
                <input type="email" name="email" class="form-control" />
              </div>
            </div>

            <div class="row form-group">
              <div class="col">
                <label class="text-black" for="subject">الموضوع</label>
                <input type="subject" name="subject" class="form-control" />
              </div>
            </div>

            <div class="row form-group">
              <div class="col">
                <label class="text-black" for="message"
                  >محتوى الرسالة</label
                >
                <textarea
                  name="message"
                  cols="30"
                  rows="7"
                  class="form-control"
                  placeholder="اكتب هنا ..."
                ></textarea>
              </div>
            </div>

            <div class="row form-group">
              <div class="col2">
                <input
                  type="submit"
                  name="submit"
                  value="إرسال"
                  class="px-4 text-white"
                />
              </div>
            </div>
          </form>
</code>```

contact.php

```<code> <?php

       $result="";

if (isset($_POST['submit'])){
require 'PHPMailer/PHPMailerAutoload.php';
$mail = new PHPMailer;

$mail->isSMTP();
$mail->Host='smtp.gmail.com';
$mail->Port=587;
$mail->SMTPAuth=true;

$mail->SMTPSecure='tls';
$mail->Username='secret';
$mail->Password='secret';

$mail->setForm($_POST['email'],$_POST['first-name']);
$mail->addAddress('secret');
$mail->addReplyTo($_POST['email'],$_POST['last-name']);

$mail->isHTML(true);
$mail->subject='Contact Us: '.$_POST['subject'];
$mail->Body='<h1 align=center>الأسم :'.$_POST['first-name'].$_POST['last-name'].' الايميل: '.$_POST['email'].' العنوان: '.$_POST['subject'].' العنوان: '.$_POST['message'].'</h1>';

if(!$mail->send()){
    $result="حدث خطاء حاول مرة اخرى ، وشكراً";
}
else{
    $result="شكراً".$_POST['fname']."لتواصلك معنا ،سيتم الرد عليكم
        قريباً";
  }
 }
 ?>
</code>```

the error message page  Doesn't exist

thank you

答:
i found the problem but i didn't understand why ,
in line 18 in the php file ,

$mail->setForm($_POST['email'],$_POST['first-name']);
if i remove it i can send the email to my gmail account.
can anyone tell what is that about ?
and if the message in arabica language , it will not read it?

Body:
I'm trying to send an email from contact by using PHPMailer and Gmail SMTP, I actually don't know where is the issue?
I download PHPMailer from githup.
I tried to do it as this gay did.

contact.html

  <form action="contact.php" method="POST" class="p-5 ">

                الاسم الاول
                <input type="text" name="first-name" class="form-control" />

                الاسم الاخير
                <input type="text" name="last-name" class="form-control" />

                إيميل
                <input type="email" name="email" class="form-control" />

                الموضوع
                <input type="subject" name="subject" class="form-control" />

                محتوى الرسالة
                <textarea
                  name="message"
                  cols="30"
                  rows="7"
                  class="form-control"
                  placeholder="اكتب هنا ..."
                ></textarea>

                <input
                  type="submit"
                  name="submit"
                  value="إرسال"
                  class="px-4 text-white"
                />

          </form>

contact.php

 <?php

       $result="";

if (isset($_POST['submit'])){
require 'PHPMailer/PHPMailerAutoload.php';
$mail = new PHPMailer;

$mail->isSMTP();
$mail->Host='smtp.gmail.com';
$mail->Port=587;
$mail->SMTPAuth=true;

$mail->SMTPSecure='tls';
$mail->Username='secret';
$mail->Password='secret';

$mail->setForm($_POST['email'],$_POST['first-name']);
$mail->addAddress('secret');
$mail->addReplyTo($_POST['email'],$_POST['last-name']);

$mail->isHTML(true);
$mail->subject='Contact Us: '.$_POST['subject'];
$mail->Body='
الأسم :'.$_POST['first-name'].$_POST['last-name'].' الايميل: '.$_POST['email'].' العنوان: '.$_POST['subject'].' العنوان: '.$_POST['message'].'
';

if(!$mail->send()){
    $result="حدث خطاء حاول مرة اخرى ، وشكراً";
}
else{
    $result="شكراً".$_POST['fname']."لتواصلك معنا ،سيتم الرد عليكم
        قريباً";
  }
 }
 ?>

the error message page  Doesn't exist

thank you


问:
nginx redirect loop with ssl
This is a very similar problem to Nginx configuration leads to endless redirect loop but that discussion has not led me to an answer yet. I'm learning how to work with nginx and ssl and everything works perfectly on the regular http:// example.com side of things, but when routing to the https:// example.com/admin I instead see:

This webpage has a redirect loop

Here is my config file:

```<code>map $uri $example_org_preferred_proto {
        default "http";
        ~^/(images|css|javascript)/ "none";
        ~^/admin/ "https";
}

server {
    listen 80;
    root /usr/share/nginx/www/example.com/blog;

    server_name example.com;
        if ($example_org_preferred_proto = "https")
            return 301 https://example.com$request_uri;
        }

    location ~ / {
        proxy_set_header X-Real-IP  $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Host $host;
        proxy_pass http://127.0.0.1:2368;
    }

}

server {
    listen 443;
    ssl on;
    root /usr/share/nginx/www/example.com/blog;

    server_name example.com;
    ssl_certificate /usr/share/nginx/<redacted>.crt;
    ssl_certificate_key /usr/share/nginx/<redacted>.key;
    if ($example_org_preferred_proto = "http") {
        return 301 http://example.com$request_uri;
    }

    location ~ / {
        proxy_set_header X-Real-IP  $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Host $host;
        proxy_pass http://127.0.0.1:2368;
    }

}
</code>```

Basically what I want to accomplish is having a site that normally runs unencrypted, but when I point to my admin page the browser redirects to https and encrypts my login.

Note: the mapping idea came from http://www.redant.com.au/ruby-on-rails-devops/manage-ssl-redirection-in-nginx-using-maps-and-save-the-universe/ and seems like a much better approach than using rewrite

答: I've toyed around with other answers but nothing worked for me. Then I realized since I use Cloudflare the problem may not be in the server but with Cloudflare. Lo and behold when I set my SSL to Full (Strict) everything works as it should!

Title: nginx redirect loop with ssl

Body:
This is a very similar problem to Nginx configuration leads to endless redirect loop but that discussion has not led me to an answer yet. I'm learning how to work with nginx and ssl and everything works perfectly on the regular http:// example.com side of things, but when routing to the https:// example.com/admin I instead see:

This webpage has a redirect loop

Here is my config file:

map $uri $example_org_preferred_proto {
        default "http";
        ~^/(images|css|javascript)/ "none";
        ~^/admin/ "https";
}

server {
    listen 80;
    root /usr/share/nginx/www/example.com/blog;

    server_name example.com;
        if ($example_org_preferred_proto = "https")
            return 301 https://example.com$request_uri;
        }

    location ~ / {
        proxy_set_header X-Real-IP  $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Host $host;
        proxy_pass http://127.0.0.1:2368;
    }

}

server {
    listen 443;
    ssl on;
    root /usr/share/nginx/www/example.com/blog;

    server_name example.com;
    ssl_certificate /usr/share/nginx/<redacted>.crt;
    ssl_certificate_key /usr/share/nginx/<redacted>.key;
    if ($example_org_preferred_proto = "http") {
        return 301 http://example.com$request_uri;
    }

    location ~ / {
        proxy_set_header X-Real-IP  $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Host $host;
        proxy_pass http://127.0.0.1:2368;
    }

}

Basically what I want to accomplish is having a site that normally runs unencrypted, but when I point to my admin page the browser redirects to https and encrypts my login.

Note: the mapping idea came from http://www.redant.com.au/ruby-on-rails-devops/manage-ssl-redirection-in-nginx-using-maps-and-save-the-universe/ and seems like a much better approach than using rewrite


问:
Is there anything like GetDlgItemInt but for a Window that has been created? Win32 Api
Using C++ Win32 API, I've created a window ( CreateWindow() ) instead of a dialogue box.  Are there any commands similar to "GetDlgItemInt" or "SetDlgItemInt" that is used for getting and setting data in an edit window for Win 32 API instead?  Otherwise I'll have to make a dialogue box or do a heap of code for converting INTs to a string then back again.

The idea is that the user specifies the window width and height by typing in the two edit dialogue boxes within the window I have created.  There are nice easy tutorials that basically tell me how to do that through a dialogue box, but I would like to know if there are similar functions that I can use that are not dependent on a dialogue box?

I'm hoping to have something like this...

```
xVal = 1280;
yVal = 720;
hwndResoX = CreateWindow("edit",xVal, WS_CHILD|WS_VISIBLE|WS_BORDER|ES_NUMBER,20,20,40,20, _hwnd, NULL, NULL, NULL);
hwndResoY = CreateWindow("edit",yVal, WS_CHILD|WS_VISIBLE|WS_BORDER|ES_NUMBER,80,20,40,20, _hwnd, NULL, NULL, NULL);
```

But as you can imagine, I can not use the xVal or yVal in the CreateWindow() because I get a compile error stating I can not convert from INT to CHAR*

答: You can use GetDlgItemInt, just specify an int ID for the HMENU parameter in CreateWindow.</p>

ContentLicense: CC BY-SA 2.5

Body:
Using C++ Win32 API, I've created a window ( CreateWindow() ) instead of a dialogue box.  Are there any commands similar to "GetDlgItemInt" or "SetDlgItemInt" that is used for getting and setting data in an edit window for Win 32 API instead?  Otherwise I'll have to make a dialogue box or do a heap of code for converting INTs to a string then back again.

The idea is that the user specifies the window width and height by typing in the two edit dialogue boxes within the window I have created.  There are nice easy tutorials that basically tell me how to do that through a dialogue box, but I would like to know if there are similar functions that I can use that are not dependent on a dialogue box?

I'm hoping to have something like this...

xVal = 1280;
yVal = 720;
hwndResoX = CreateWindow("edit",xVal, WS_CHILD|WS_VISIBLE|WS_BORDER|ES_NUMBER,20,20,40,20, _hwnd, NULL, NULL, NULL);
hwndResoY = CreateWindow("edit",yVal, WS_CHILD|WS_VISIBLE|WS_BORDER|ES_NUMBER,80,20,40,20, _hwnd, NULL, NULL, NULL);

But as you can imagine, I can not use the xVal or yVal in the CreateWindow() because I get a compile error stating I can not convert from INT to CHAR*


问:
How to import data from .csv text files with different column headings into memory
I am trying to read in data from a CSV file one line at a time. The first line, column headings, determines the data type in each row. I already know all the data belongs to a class I have in my project called UserModel, but I am trying to do this with out hard coding the data to UserModel fields. I am able to read the first couple of lines, and create the first instance of the user model correctly. But things fall apart when I try to read the third line. I am using a Dictionary, and I am trying to use the instance of the created Dictionary when I read the first couple of lines. Meaning use the order of keys in the Dictionary instance, and just update the values with the next set of data, but I can not figure out why the set of data just does not line up with the right keys. </p>

<p>I got some great code here and used it. DictionaryToObject() method is one of them. I think I am using more loops than I need to, and do not know enough to use some other way of accessing some of the data structures like string array, list, and the Dictionary that I have. I am a novice, and may have used the wrong data structure and or even some unnecessary code in my attempt to get the result I want. </p>

```<code>public class MyData
{
    BindingList<UserModel> users = new BindingList<UserModel>();
    UserModel currentUser = new UserModel();

    public BindingList<UserModel> GetUsers()
    {

        string[] lines = File.ReadAllLines("StandardDataSet.csv");
        // Add error handing to make sure all lines have four enteris
        foreach (string line in lines.Skip(1))
        {
            //I am not sure how to handle the first line that is a header
            string [] values = line.Split(',').Select(x => x.Trim()).ToArray();
            currentUser.FirstName = values[0];
            currentUser.LastName = values[1];
            int.TryParse(values[2], out int age);
            currentUser.Age = age;
            bool.TryParse(values[3], out bool alive);
            currentUser.IsAlive = alive;
            users.Add(currentUser);
        }
        return users;
    }
private static T DictionaryToObject<T>(IDictionary<string, object> dict) where T : new()
    {
        T t = new T();
        PropertyInfo[] properties = t.GetType().GetProperties();

        foreach (PropertyInfo property in properties)
        {
            if (!dict.Any(x => x.Key.Equals(property.Name, StringComparison.InvariantCultureIgnoreCase)))
                continue;
            KeyValuePair<string, object> item = dict.First(x => x.Key.Equals(property.Name, StringComparison.InvariantCultureIgnoreCase));
            Type tPropertyType = t.GetType().GetProperty(property.Name).PropertyType;
            Type newT = Nullable.GetUnderlyingType(tPropertyType) ?? tPropertyType;
            //if (item.Value is '0') Convert.ToBoolean(Convert.ToInt32(item.Value));
            object newA = Convert.ChangeType(item.Value, newT);
            t.GetType().GetProperty(property.Name).SetValue(t, newA, null);
        }
        return t;
    }
public BindingList<UserModel> GetUsersAdvanced()
    {
        users = new BindingList<UserModel>();
        var dict= new Dictionary<string,object>();
        string[] lines = File.ReadAllLines("AdvancedDataSet.csv");
        var header = lines.First().Split(',');
        var data = lines.Skip(1).First().Split(',');

        for (int i = 0; i < header.Length; i++)
            {
                if (data[i] == "0" || data[i] == "1")
                    {
                        Boolean IsAlive = Extensions.ToBoolean(data[i]);
                        dict.Add(header[i], IsAlive);
                    }
                else
                //if (data[i]!= "0" || data[i]!="1")
                dict.Add(header[i], data[i]);
        }
        currentUser = DictionaryToObject<UserModel>(dict);
        var dictCopy = new Dictionary<string, object>(dict);
        var dictConcurrent = new ConcurrentDictionary<string, object>(dict);

    foreach (var line in lines.Skip(1))
    {
    if (line != null)  data = line.Split(',');

                foreach (var key in dict.Keys)
                {
                int i = 0;
                if (data[i] == "0" || data[i] == "1")
                    {
                        Boolean IsAlive = Extensions.ToBoolean(data[i]);
                        dictCopy[key] = IsAlive;
                        i++;
                        continue;
                    }
                    else
                    dictCopy[key] = data[i];
                    i++;
                 }
                 currentUser = DictionaryToObject<UserModel>(dictCopy);
                 users.Add(currentUser);
                 currentUser = new UserModel();

    }
 return users;
}
</code>```

答:
As the comments from people says, I also recommend to use existing libraries. They typically also support such data mapping to object and data conversion that you do in your code. so, try one or two first.

How about:

CsvHelper

FileHelpers

By the way, in terms of the order of items in Dictionary, you can read the reason here

For purposes of enumeration, each item in the dictionary is treated as a KeyValuePair structure representing a value and its key. The order in which the items are returned is undefined.

So, what about keeping the column headers in a list? In this way, you can keep the order. The code would be something like below.

But please take it just as an example for ordered items. Again, try some libraries first, then you'll see cooler functionalities and get tidier code with those.

```<code>public BindingList<UserModel> GetUsersAdvanced()
{
    users = new BindingList<UserModel>();
    string[] lines = File.ReadAllLines("AdvancedDataSet.csv");
    var cols = lines.First().Split(',').ToList();

    // validate column name duplication here!

    foreach (var line in lines.Skip(1))
    {
        if (line != null)  data = line.Split(',');

        for (var i = 0; i < cols.Count(); i++)
        {
            var key = cols[i];
            var dict = new Dictionary<string, object>();

            if (data[i] == "0" || data[i] == "1")
            {
                Boolean IsAlive = Extensions.ToBoolean(data[i]);
                dict.Add(key, IsAlive);
            }
            else
                dict.Add(key, data[i]);

            var currentUser = DictionaryToObject<UserModel>(dict);
            users.Add(currentUser);
        }

        return users;
    }
}
</code>```

Body:
I am trying to read in data from a CSV file one line at a time. The first line, column headings, determines the data type in each row. I already know all the data belongs to a class I have in my project called UserModel, but I am trying to do this with out hard coding the data to UserModel fields. I am able to read the first couple of lines, and create the first instance of the user model correctly. But things fall apart when I try to read the third line. I am using a Dictionary, and I am trying to use the instance of the created Dictionary when I read the first couple of lines. Meaning use the order of keys in the Dictionary instance, and just update the values with the next set of data, but I can not figure out why the set of data just does not line up with the right keys.

I got some great code here and used it. DictionaryToObject() method is one of them. I think I am using more loops than I need to, and do not know enough to use some other way of accessing some of the data structures like string array, list, and the Dictionary that I have. I am a novice, and may have used the wrong data structure and or even some unnecessary code in my attempt to get the result I want.

public class MyData
{
    BindingList<UserModel> users = new BindingList<UserModel>();
    UserModel currentUser = new UserModel();

    public BindingList<UserModel> GetUsers()
    {

        string[] lines = File.ReadAllLines("StandardDataSet.csv");
        // Add error handing to make sure all lines have four enteris
        foreach (string line in lines.Skip(1))
        {
            //I am not sure how to handle the first line that is a header
            string [] values = line.Split(',').Select(x => x.Trim()).ToArray();
            currentUser.FirstName = values[0];
            currentUser.LastName = values[1];
            int.TryParse(values[2], out int age);
            currentUser.Age = age;
            bool.TryParse(values[3], out bool alive);
            currentUser.IsAlive = alive;
            users.Add(currentUser);
        }
        return users;
    }
private static T DictionaryToObject<T>(IDictionary<string, object> dict) where T : new()
    {
        T t = new T();
        PropertyInfo[] properties = t.GetType().GetProperties();

        foreach (PropertyInfo property in properties)
        {
            if (!dict.Any(x => x.Key.Equals(property.Name, StringComparison.InvariantCultureIgnoreCase)))
                continue;
            KeyValuePair<string, object> item = dict.First(x => x.Key.Equals(property.Name, StringComparison.InvariantCultureIgnoreCase));
            Type tPropertyType = t.GetType().GetProperty(property.Name).PropertyType;
            Type newT = Nullable.GetUnderlyingType(tPropertyType) ?? tPropertyType;
            //if (item.Value is '0') Convert.ToBoolean(Convert.ToInt32(item.Value));
            object newA = Convert.ChangeType(item.Value, newT);
            t.GetType().GetProperty(property.Name).SetValue(t, newA, null);
        }
        return t;
    }
public BindingList<UserModel> GetUsersAdvanced()
    {
        users = new BindingList<UserModel>();
        var dict= new Dictionary<string,object>();
        string[] lines = File.ReadAllLines("AdvancedDataSet.csv");
        var header = lines.First().Split(',');
        var data = lines.Skip(1).First().Split(',');

        for (int i = 0; i < header.Length; i++)
            {
                if (data[i] == "0" || data[i] == "1")
                    {
                        Boolean IsAlive = Extensions.ToBoolean(data[i]);
                        dict.Add(header[i], IsAlive);
                    }
                else
                //if (data[i]!= "0" || data[i]!="1")
                dict.Add(header[i], data[i]);
        }
        currentUser = DictionaryToObject<UserModel>(dict);
        var dictCopy = new Dictionary<string, object>(dict);
        var dictConcurrent = new ConcurrentDictionary<string, object>(dict);

    foreach (var line in lines.Skip(1))
    {
    if (line != null)  data = line.Split(',');

                foreach (var key in dict.Keys)
                {
                int i = 0;
                if (data[i] == "0" || data[i] == "1")
                    {
                        Boolean IsAlive = Extensions.ToBoolean(data[i]);
                        dictCopy[key] = IsAlive;
                        i++;
                        continue;
                    }
                    else
                    dictCopy[key] = data[i];
                    i++;
                 }
                 currentUser = DictionaryToObject<UserModel>(dictCopy);
                 users.Add(currentUser);
                 currentUser = new UserModel();

    }
 return users;
}

Body:
As the comments from people says, I also recommend to use existing libraries. They typically also support such data mapping to object and data conversion that you do in your code. so, try one or two first.

How about:

CsvHelper

FileHelpers

By the way, in terms of the order of items in Dictionary, you can read the reason here

For purposes of enumeration, each item in the dictionary is treated as a KeyValuePair structure representing a value and its key. The order in which the items are returned is undefined.

So, what about keeping the column headers in a list? In this way, you can keep the order. The code would be something like below.

But please take it just as an example for ordered items. Again, try some libraries first, then you'll see cooler functionalities and get tidier code with those.

public BindingList<UserModel> GetUsersAdvanced()
{
    users = new BindingList<UserModel>();
    string[] lines = File.ReadAllLines("AdvancedDataSet.csv");
    var cols = lines.First().Split(',').ToList();

    // validate column name duplication here!

    foreach (var line in lines.Skip(1))
    {
        if (line != null)  data = line.Split(',');

        for (var i = 0; i < cols.Count(); i++)
        {
            var key = cols[i];
            var dict = new Dictionary<string, object>();

            if (data[i] == "0" || data[i] == "1")
            {
                Boolean IsAlive = Extensions.ToBoolean(data[i]);
                dict.Add(key, IsAlive);
            }
            else
                dict.Add(key, data[i]);

            var currentUser = DictionaryToObject<UserModel>(dict);
            users.Add(currentUser);
        }

        return users;
    }
}


问:
Rails helper method to display email with sub mask asterisk
How to write like a helper method for email address to display with sub mask asterisk.

If user email address is like "john.a@stackoverflow.com", But in view I want to display joh***@***.com

```<code><%= sub_masked_email("john.a@stackoverflow.com") %>
##joh***@***.com
</code>```

答:
So you can write a helper method which can be reused multiple time by calling it on any string. Here is what I came up with below:

helper_method

```<code>def sub_masked_email(string)
  string.gsub(/(?<=.{2}).*@.*(?=\S{2})/, '****@****')
end
</code>```

calling it on any string

```<code>sub_masked_email("john.a@stackoverflow.com")
</code>```

output

```<code>"jo*****@****om"
</code>```

So this method shows the first two letters and shows the last two letters and replaces all other text with ****@****

Just a pointer to what you need and can still be better than this.

Body:
How to write like a helper method for email address to display with sub mask asterisk.

If user email address is like "john.a@stackoverflow.com", But in view I want to display joh***@***.com

<%= sub_masked_email("john.a@stackoverflow.com") %>
##joh***@***.com

Body:
So you can write a helper method which can be reused multiple time by calling it on any string. Here is what I came up with below:

helper_method

def sub_masked_email(string)
  string.gsub(/(?<=.{2}).*@.*(?=\S{2})/, '****@****')
end

calling it on any string

sub_masked_email("john.a@stackoverflow.com")

output

"jo*****@****om"

So this method shows the first two letters and shows the last two letters and replaces all other text with ****@****

Just a pointer to what you need and can still be better than this.


问:
Can we use Scala to Perform UPDATE and DELETE operations on Databricks Delta tables?
I am able to create databricks delta tables using scala and able to  perform append and overwrite operations over it.

Is there any way I can perform DELETE and UPDATE operations using scala and not through Databricks runtime.

```<code>val target = Seq(
  Data("a", "0"),
  Data("b", "1"),
  Data("c", "2"),
  Data("d", "3")
).toDF().write.format("delta").mode("overwrite").saveAsTable("target")
val DF1 = spark.table("target")
DF1.show()

val NewInserts = Seq(
  Data("a", "0"),
  Data("b", "1"),
  Data("c", "2"),
  Data("d", "3")
).toDF().write.format("delta").mode("append").saveAsTable("target")

val DF2 = spark.table("target")
DF2.show()
</code>```

答: Not yet!  Only sql commands support the update/delete/merge.  Databricks is working on releasing the scala/python equivalents.</p>

Body:
I am able to create databricks delta tables using scala and able to  perform append and overwrite operations over it.

Is there any way I can perform DELETE and UPDATE operations using scala and not through Databricks runtime.

val target = Seq(
  Data("a", "0"),
  Data("b", "1"),
  Data("c", "2"),
  Data("d", "3")
).toDF().write.format("delta").mode("overwrite").saveAsTable("target")
val DF1 = spark.table("target")
DF1.show()

val NewInserts = Seq(
  Data("a", "0"),
  Data("b", "1"),
  Data("c", "2"),
  Data("d", "3")
).toDF().write.format("delta").mode("append").saveAsTable("target")

val DF2 = spark.table("target")
DF2.show()


问:
ionic - resize background image when keyboard open
I have a background image in ioniv-view tag class and when the keyboard open on this page, the image resizing ..
the code:

```<code>.bgImage {
background: url('../img/LoginBackground.png')  no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
background-size: cover;
</code>```

}

How can I fix it?

答:
Cordova ionic-webview 4.1.1

global.scss:

```<code>ion-app {
    background-color: transparent !important;
    --background: none;
    background: url(/assets/img/file_name.jpg) no-repeat 0 0;
    background-size: 128% 105%;
    align-items: flex-start;
    background-position: -46px 0;

    ion-router-outlet, ion-modal {
       ion-content {
          background-color: transparent !important;
          --background: none;
       }
    }
}
</code>```

app.component.ts:

```<code>window.addEventListener('native.keyboardshow', (e) => {
  const ionAppEl = <HTMLElement>(document.getElementsByTagName('ion-split-pane')[0]);
  if ( ionAppEl ) {
    ionAppEl.setAttribute('keyboard', 'true');
    const active: any = document.activeElement;
    if ( active ) {
      if ( (this.platform.is('android') || this.platform.is('ios')) && e['keyboardHeight'] ) {
        ionAppEl.setAttribute('style', 'height: calc(100% - ' + e['keyboardHeight'] + 'px);');
      }
      if ( active.scrollIntoViewIfNeeded ) {
        active.scrollIntoViewIfNeeded(true); // ensure input focus
      }
    }
  }
});

window.addEventListener('keyboardWillHide', (e) => {
  const ionAppEl = <HTMLElement>(document.getElementsByTagName('ion-split-pane')[0]);
  if ( ionAppEl && (this.platform.is('android') || this.platform.is('ios')) ) {
    ionAppEl.setAttribute('style', 'height: 100%;');
  }
});
</code>```

config.xml:

```<code><platform name="android">
    <edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application/activity">
        <activity android:windowSoftInputMode="adjustPan" />
    </edit-config>
</code>```

With cordova ionic-webview 2.2.0, I was using background-size: cover; and the background would resize when I tap on an input field. I wasn't using ionic framework but some of it's plugin for example

cordova-plugin-ionic-webview^2.2.0

cordova-plugin-ionic-keyboard^2.1.3

corodva-plugin-keyboard (this was required to move to the position of the input field)

Here's my solution:

CSS:

```<code>.content-background {
    background-size: 180% auto;
    background-image: url("img_path.jpg");
}
</code>```

JS:

```<code>document.addEventListener('deviceready', function () {

    var widthHeightRatio = parseFloat((window.screen.width * window.devicePixelRatio) / (window.screen.height * window.devicePixelRatio)).toFixed(2);

    if(widthHeightRatio > 0.56){
        $('.content-background').css('background-size', '160% auto');
    }else if(widthHeightRatio < 0.56){
        $('.content-background').css('background-size', '210% auto');
    }
});
</code>```

Android:

Alcatel 1x
480x960 1.5 0.5 210%
(width x height |  devicePixelRatio  |  widthHeightRatio  |  width)

Pixel C Tablet
1800x2560 2 0.70 150%

Nexus 7 Tablet
1200x1920 2 0.63 150%

7” Tablet
600x1024 1 0.59 160%

iOS:

iPhone SE/5S
640x1136 2 0.56 180%

iPad 2 Pro (3rd gen)
2048x2732 2 0.749 140%

iPhoneX
1125x2436 3 0.46 210%

iPhone 5S
640x1136 2 0.56 180%

iPhone 6 Plus
1242x2208 3 0.56 180%

iPhone 7
750x1334 2 0.56 180%

iPhone 8 Plus
1242x2208 3 0.56 180%

iPhone XR
828x1792 2 0.46 210%

iPad Air (3rd gen)
1668x2224 2 0.75 140%

iPad Pro (9.7inch)
1536x2048 2 0.75 140%

iPad Pro (11inch)
1668x2388 2 0.70 150%

Body:
I have a background image in ioniv-view tag class and when the keyboard open on this page, the image resizing ..
the code:

.bgImage {
background: url('../img/LoginBackground.png')  no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
background-size: cover;

}

How can I fix it?

Body:
Cordova ionic-webview 4.1.1

global.scss:

ion-app {
    background-color: transparent !important;
    --background: none;
    background: url(/assets/img/file_name.jpg) no-repeat 0 0;
    background-size: 128% 105%;
    align-items: flex-start;
    background-position: -46px 0;

    ion-router-outlet, ion-modal {
       ion-content {
          background-color: transparent !important;
          --background: none;
       }
    }
}

app.component.ts:

window.addEventListener('native.keyboardshow', (e) => {
  const ionAppEl = <HTMLElement>(document.getElementsByTagName('ion-split-pane')[0]);
  if ( ionAppEl ) {
    ionAppEl.setAttribute('keyboard', 'true');
    const active: any = document.activeElement;
    if ( active ) {
      if ( (this.platform.is('android') || this.platform.is('ios')) && e['keyboardHeight'] ) {
        ionAppEl.setAttribute('style', 'height: calc(100% - ' + e['keyboardHeight'] + 'px);');
      }
      if ( active.scrollIntoViewIfNeeded ) {
        active.scrollIntoViewIfNeeded(true); // ensure input focus
      }
    }
  }
});

window.addEventListener('keyboardWillHide', (e) => {
  const ionAppEl = <HTMLElement>(document.getElementsByTagName('ion-split-pane')[0]);
  if ( ionAppEl && (this.platform.is('android') || this.platform.is('ios')) ) {
    ionAppEl.setAttribute('style', 'height: 100%;');
  }
});

config.xml:

<platform name="android">
    <edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application/activity">
        <activity android:windowSoftInputMode="adjustPan" />
    </edit-config>

With cordova ionic-webview 2.2.0, I was using background-size: cover; and the background would resize when I tap on an input field. I wasn't using ionic framework but some of it's plugin for example

cordova-plugin-ionic-webview^2.2.0

cordova-plugin-ionic-keyboard^2.1.3

corodva-plugin-keyboard (this was required to move to the position of the input field)

Here's my solution:

CSS:

.content-background {
    background-size: 180% auto;
    background-image: url("img_path.jpg");
}

JS:

document.addEventListener('deviceready', function () {

    var widthHeightRatio = parseFloat((window.screen.width * window.devicePixelRatio) / (window.screen.height * window.devicePixelRatio)).toFixed(2);

    if(widthHeightRatio > 0.56){
        $('.content-background').css('background-size', '160% auto');
    }else if(widthHeightRatio < 0.56){
        $('.content-background').css('background-size', '210% auto');
    }
});

Android:

Alcatel 1x
480x960 1.5 0.5 210%
(width x height |  devicePixelRatio  |  widthHeightRatio  |  width)

Pixel C Tablet
1800x2560 2 0.70 150%

Nexus 7 Tablet
1200x1920 2 0.63 150%

7” Tablet
600x1024 1 0.59 160%

iOS:

iPhone SE/5S
640x1136 2 0.56 180%

iPad 2 Pro (3rd gen)
2048x2732 2 0.749 140%

iPhoneX
1125x2436 3 0.46 210%

iPhone 5S
640x1136 2 0.56 180%

iPhone 6 Plus
1242x2208 3 0.56 180%

iPhone 7
750x1334 2 0.56 180%

iPhone 8 Plus
1242x2208 3 0.56 180%

iPhone XR
828x1792 2 0.46 210%

iPad Air (3rd gen)
1668x2224 2 0.75 140%

iPad Pro (9.7inch)
1536x2048 2 0.75 140%

iPad Pro (11inch)
1668x2388 2 0.70 150%


问:
Sorting an Vector of Objects with std::sort
I am new at C++. I want to sort an Vector "Konten" of type vector Konto.

I've searched for a soulution and found the std::sort function. I have overloaded the operator< for the "Konto" class.
But when i try to sort the vector of Konto and compile my code i get the error message:

Error C2678 Binary operator "=": No operator could be found that
  accepts a "const account" left-hand operand (or proper conversion is
  not possible) c: \ program files (x86) \ microsoft visual studio \
  2017 \ community \ vc \ tools \ msvc \ 14.15.26726 \ include \
  algorithm 3835

```<code>//KontenManager.h
#pragma once

#include "Konto.h"
#include <vector>

class Kontenmanager
{
private:
    vector<Konto> Konten;

public:
    Kontenmanager();
    ~Kontenmanager();
    string getKontenListe() const;
};

//Kontenmanager.cpp
#include "pch.h"
#include "Kontenmanager.h"
#include <sstream>
#include <algorithm>
#include <iomanip>

Kontenmanager::Kontenmanager()
{
}

Kontenmanager::~Kontenmanager()
{
}

string Kontenmanager::getKontenListe() const
{
    stringstream out;
    sort(Konten.begin(), Konten.end());            //<----------- Here is my problem

//do some stuff

}

//Konto.h
#pragma once

#include <string>

using namespace std;

class Konto
{
private:
    int kontoNr;
    double saldo;
    string inhaber;
    int pin;

public:
    Konto(int Kontonummer, string inhaber, int pin);
    ~Konto();
    int getKontonummer() const;
};

bool operator<(const Konto &k1, const Konto &k2);
bool operator==(const Konto &k1, const Konto &k2);

//Konto.cpp
#include "pch.h"
#include "Konto.h"

Konto::Konto(int Kontonummer, string inhaber, int pin) :kontoNr(Kontonummer)
{
    this->kontoNr = Kontonummer;
    this->inhaber = inhaber;
    this->pin = pin;
    this->saldo = 0.0;
}

Konto::~Konto()
{
}

int Konto::getKontonummer() const
{
    return kontoNr;
}

bool operator<(const Konto &k1, const Konto &k2)
{
    return k1.getKontonummer() < k2.getKontonummer();
}

bool operator==(const Konto &k1, const Konto &k2)
{
    return k1.getKontonummer() == k2.getKontonummer();
}
</code>```

答:
When you have an error in Visual Studio, you can press F1 on your computer keyboard to get help on that error.

Also any developer should know about google.com Type C2678 in the search box and press enter.

Here is the documentation:

https://learn.microsoft.com/en-us/cpp/error-messages/compiler-errors-2/compiler-error-c2678?view=vs-2019

Answer: Remove extra const specifier as mentionned by others.

Body:
I am new at C++. I want to sort an Vector "Konten" of type vector Konto.

I've searched for a soulution and found the std::sort function. I have overloaded the operator< for the "Konto" class.
But when i try to sort the vector of Konto and compile my code i get the error message:

Error C2678 Binary operator "=": No operator could be found that
  accepts a "const account" left-hand operand (or proper conversion is
  not possible) c: \ program files (x86) \ microsoft visual studio \
  2017 \ community \ vc \ tools \ msvc \ 14.15.26726 \ include \
  algorithm 3835

//KontenManager.h
#pragma once

#include "Konto.h"
#include <vector>

class Kontenmanager
{
private:
    vector<Konto> Konten;

public:
    Kontenmanager();
    ~Kontenmanager();
    string getKontenListe() const;
};

//Kontenmanager.cpp
#include "pch.h"
#include "Kontenmanager.h"
#include <sstream>
#include <algorithm>
#include <iomanip>

Kontenmanager::Kontenmanager()
{
}

Kontenmanager::~Kontenmanager()
{
}

string Kontenmanager::getKontenListe() const
{
    stringstream out;
    sort(Konten.begin(), Konten.end());            //<----------- Here is my problem

//do some stuff

}

//Konto.h
#pragma once

#include <string>

using namespace std;

class Konto
{
private:
    int kontoNr;
    double saldo;
    string inhaber;
    int pin;

public:
    Konto(int Kontonummer, string inhaber, int pin);
    ~Konto();
    int getKontonummer() const;
};

bool operator<(const Konto &k1, const Konto &k2);
bool operator==(const Konto &k1, const Konto &k2);

//Konto.cpp
#include "pch.h"
#include "Konto.h"

Konto::Konto(int Kontonummer, string inhaber, int pin) :kontoNr(Kontonummer)
{
    this->kontoNr = Kontonummer;
    this->inhaber = inhaber;
    this->pin = pin;
    this->saldo = 0.0;
}

Konto::~Konto()
{
}

int Konto::getKontonummer() const
{
    return kontoNr;
}

bool operator<(const Konto &k1, const Konto &k2)
{
    return k1.getKontonummer() < k2.getKontonummer();
}

bool operator==(const Konto &k1, const Konto &k2)
{
    return k1.getKontonummer() == k2.getKontonummer();
}


问:
Is there ArgumentsType<T> like ReturnType<T> in Typescript?
ReturnType<T> extracts return type of a function.

Is there a way to define ArgumentsType<T> that extracts parameter types of a function in tuple format?

For example,

ArgumentsType<(a: number, b: string) => boolean> will be [number, string].

答:
I created a collection of common helper types like this: https://github.com/joonhocho/tsdef

Here's you can find many helper patterns for typescript.
you can install via npm or yarn as well.
npm i -D tsdef


问:
SQL: Subtract one query from another
Let's say I have two tables called tbl1 & tbl2 (different number of columns and IDs), and I get the monthly total of each table using the following queries:

query1:

```<code>SELECT MONTHNAME(tbl1_date), SUM(col1+col2+col3+col4)
FROM myTbl1
GROUP BY YEAR(tbl1_date), MONTH(tbl1_date);
</code>```

query2:

```<code>SELECT MONTHNAME(tbl2_date), SUM(col1+col2+col3+col4+col5+col6)
FROM myTbl2
GROUP BY YEAR(tbl2_date), MONTH(tbl2_date);
</code>```

How can I subtract query2 from query1 and get the difference of SUMs?

答:
Join the two queries and then subtract.</p>

```<code>SELECT t1.month, t1.year, t1.total - t2.total AS diff
FROM (
    SELECT MONTHNAME(tbl1_date) AS month, YEAR(tbl1_date) AS year, SUM(col1+col2+col3+col4) AS total
    FROM myTbl1
    GROUP BY YEAR(tbl1_date), MONTH(tbl1_date)
) AS t1
JOIN (
    SELECT MONTHNAME(tbl2_date) AS month, YEAR(tb2_date) AS year, SUM(col1+col2+col3+col4+col5+col6) AS total
    FROM myTbl2
    GROUP BY YEAR(tbl2_date), MONTH(tbl2_date)
) AS t2 ON t1.month = t2.month AND t1.year = t2.year
</code>```

Title: SQL: Subtract one query from another

Body:
Let's say I have two tables called tbl1 & tbl2 (different number of columns and IDs), and I get the monthly total of each table using the following queries:

query1:

SELECT MONTHNAME(tbl1_date), SUM(col1+col2+col3+col4)
FROM myTbl1
GROUP BY YEAR(tbl1_date), MONTH(tbl1_date);

query2:

SELECT MONTHNAME(tbl2_date), SUM(col1+col2+col3+col4+col5+col6)
FROM myTbl2
GROUP BY YEAR(tbl2_date), MONTH(tbl2_date);

How can I subtract query2 from query1 and get the difference of SUMs?

Body:
Join the two queries and then subtract.

SELECT t1.month, t1.year, t1.total - t2.total AS diff
FROM (
    SELECT MONTHNAME(tbl1_date) AS month, YEAR(tbl1_date) AS year, SUM(col1+col2+col3+col4) AS total
    FROM myTbl1
    GROUP BY YEAR(tbl1_date), MONTH(tbl1_date)
) AS t1
JOIN (
    SELECT MONTHNAME(tbl2_date) AS month, YEAR(tb2_date) AS year, SUM(col1+col2+col3+col4+col5+col6) AS total
    FROM myTbl2
    GROUP BY YEAR(tbl2_date), MONTH(tbl2_date)
) AS t2 ON t1.month = t2.month AND t1.year = t2.year


问:
Pandas identify # of items which generate 80 of sales
I have a dataframe with for each country, list of product and the relevant sales
I need to identify for each country how many are # of top sales items of which cumulative sales represent 80% of the total sales for all the items in each country.

E.g.

```<code>Cnt Product, units
Italy apple 500
Italy beer 1500
Italy bread 2000
Italy orange 3000
Italy butter 3000
</code>```

Expected results

```<code>Italy 3
</code>```

(Total units are 10.000 and the sales of the top 3 product - Butter, Orange, Bread, is 8.000 which is the 80% of total)

答:
Need play a little bit logic here </p>

```<code>df=df.sort_values('units',ascending=False)
g=df.groupby('Cnt').units
s=(g.cumsum()>=g.transform('sum')*0.8).groupby(df.Cnt).sum()
df.groupby('Cnt').size()-s+1
Out[710]:
Cnt
Italy    3.0
dtype: float64
</code>```

Body:
I have a dataframe with for each country, list of product and the relevant sales
I need to identify for each country how many are # of top sales items of which cumulative sales represent 80% of the total sales for all the items in each country.

E.g.

Cnt Product, units
Italy apple 500
Italy beer 1500
Italy bread 2000
Italy orange 3000
Italy butter 3000

Expected results

Italy 3

(Total units are 10.000 and the sales of the top 3 product - Butter, Orange, Bread, is 8.000 which is the 80% of total)

Body:
Need play a little bit logic here

df=df.sort_values('units',ascending=False)
g=df.groupby('Cnt').units
s=(g.cumsum()>=g.transform('sum')*0.8).groupby(df.Cnt).sum()
df.groupby('Cnt').size()-s+1
Out[710]:
Cnt
Italy    3.0
dtype: float64


问:
How I can return "ok" immediately without waiting for a an internal method to finish
I need Implement a method that does not expect the return of a call to another method to return OK. How to do this?

i try use 'await' but this wait a finish to return "OK"

```<code>[WebMethod] //WebServiceMethod
public string ImportaDadosPosLeilaoValores(string fileName)
{
    // this call may take several minutes and should NOT be expected
    ImportaDados(fileName);
    return "OK - Received";     // immediately
}
</code>```

A call to the method that IMMEDIATELY returns an OK informing the receiving of the file, in the background, the called method will work until finished and will not return anything when finished

答:
You want to spin off a new async Task. This example uses the static Task.Run and passes in an anonymous async task. The call to Task.Run() is executed synchronously, but the execution of the anonymous task inside Task.Run() isn't, it just completes so fast it seems like it.

```<code>using System.Threading.Tasks;

[WebMethod] //WebServiceMethod
public string ImportaDadosPosLeilaoValores(string fileName)
{
    // this call may take several minutes and should NOT be expected
    Task.Run(() => {
        ImportaDados(fileName);
    });
    return "OK - Received";     // immediately
}
</code>```

I'm not familiar with what [WebMethod] is from, but you may want to go full async. In this example, your calling and called methods are async, and the called task isn't awaited, this will execute how you want.

```<code>using System.Threading.Tasks;

[WebMethod] //WebServiceMethod
public async Task<string> ImportaDadosPosLeilaoValores(string fileName)
{
    // this call may take several minutes and should NOT be expected
    ImportaDados(fileName);
    return "OK - Received";     // immediately
}

public async Task ImportaDados(string filename)
{

}
</code>```

Tasks run on threads, and are executed by a scheduler that manages the sync state of each task. Don't use threads directly unless you have a specific reason to.

Body:
I need Implement a method that does not expect the return of a call to another method to return OK. How to do this?

i try use 'await' but this wait a finish to return "OK"

[WebMethod] //WebServiceMethod
public string ImportaDadosPosLeilaoValores(string fileName)
{
    // this call may take several minutes and should NOT be expected
    ImportaDados(fileName);
    return "OK - Received";     // immediately
}

A call to the method that IMMEDIATELY returns an OK informing the receiving of the file, in the background, the called method will work until finished and will not return anything when finished

Body:
You want to spin off a new async Task. This example uses the static Task.Run and passes in an anonymous async task. The call to Task.Run() is executed synchronously, but the execution of the anonymous task inside Task.Run() isn't, it just completes so fast it seems like it.

using System.Threading.Tasks;

[WebMethod] //WebServiceMethod
public string ImportaDadosPosLeilaoValores(string fileName)
{
    // this call may take several minutes and should NOT be expected
    Task.Run(() => {
        ImportaDados(fileName);
    });
    return "OK - Received";     // immediately
}

I'm not familiar with what [WebMethod] is from, but you may want to go full async. In this example, your calling and called methods are async, and the called task isn't awaited, this will execute how you want.

using System.Threading.Tasks;

[WebMethod] //WebServiceMethod
public async Task<string> ImportaDadosPosLeilaoValores(string fileName)
{
    // this call may take several minutes and should NOT be expected
    ImportaDados(fileName);
    return "OK - Received";     // immediately
}

public async Task ImportaDados(string filename)
{

}

Tasks run on threads, and are executed by a scheduler that manages the sync state of each task. Don't use threads directly unless you have a specific reason to.


问:
Get date ISO string without conversion to UTC timezone
Is there a way in JavaScript to obtain an ISO string of a new Date object:

while maintaining the original local timezone (i.e. not converting to UTC)

with time component set to midnight

without resorting to manually rebuilding a new Date via individual date parts and reformatting the result?

I've been trying this

```<code>var date = new Date();
date.setHours(0, 0, 0, 0);
document.write(date.toISOString());
</code>```

and I am getting this

```<code>2017-04-20T04:00:00.000Z
</code>```

I want to get this

```<code>2017-04-20T00:00:00.000
</code>```

(The lack of the trailing Z would indicate local time)

Essentially, I want a local timezone string, but formatted in the the "ISO" way. Relying on the "toLocale..." formatter method of JS Date provides inconsistent results depending on the locale settings.

Is there a built-in function or way as I've been trying to do to get the desired output (without rebuilding a date object with the date parts)?

答:
var isoDate = new Date().toISOString().substring(0,10);
console.log(isoDate);```

Body:
Is there a way in JavaScript to obtain an ISO string of a new Date object:

while maintaining the original local timezone (i.e. not converting to UTC)

with time component set to midnight

without resorting to manually rebuilding a new Date via individual date parts and reformatting the result?

I've been trying this

var date = new Date();
date.setHours(0, 0, 0, 0);
document.write(date.toISOString());

and I am getting this

2017-04-20T04:00:00.000Z

I want to get this

2017-04-20T00:00:00.000

(The lack of the trailing Z would indicate local time)

Essentially, I want a local timezone string, but formatted in the the "ISO" way. Relying on the "toLocale..." formatter method of JS Date provides inconsistent results depending on the locale settings.

Is there a built-in function or way as I've been trying to do to get the desired output (without rebuilding a date object with the date parts)?


问:
Selenium opens browser but doesn't load page
This is an extension from a previous post which I could not get to work, but I am now getting a new error after updating Selenium.

I am using Python 3.5, Windows 8.1, and Selenium 3.0.1.

I know the code works because it works on my Mac, but when I bring it over to my work computer which is described above, the only thing that happens is the browser will open, but it won't load anything, not even a homepage.

From everything I could find on search I downloaded the geckodriver, renamed it to wires.exe, and I added the directory to the system PATH environment variable.

I am completely lost on what to do to get this to work. Here is the code I'm using:

```<code>from selenium import webdriver

driver = webdriver.Firefox()

driver.get('https://www.google.com')
</code>```

Here are the errors I am getting:

答:
For Windows 10, download geckodriver and extract it on like below. Customize it for yourself. My username is yasin in Windows 10.

```<code>C:\Users\yasin\AppData\Local\Programs\Python\Python37\Scripts
</code>```

Body:
This is an extension from a previous post which I could not get to work, but I am now getting a new error after updating Selenium.

I am using Python 3.5, Windows 8.1, and Selenium 3.0.1.

I know the code works because it works on my Mac, but when I bring it over to my work computer which is described above, the only thing that happens is the browser will open, but it won't load anything, not even a homepage.

From everything I could find on search I downloaded the geckodriver, renamed it to wires.exe, and I added the directory to the system PATH environment variable.

I am completely lost on what to do to get this to work. Here is the code I'm using:

from selenium import webdriver

driver = webdriver.Firefox()

driver.get('https://www.google.com')

Here are the errors I am getting:

Body:
For Windows 10, download geckodriver and extract it on like below. Customize it for yourself. My username is yasin in Windows 10.

C:\Users\yasin\AppData\Local\Programs\Python\Python37\Scripts


问:
Rails - Turn 2-dimensional array into list and back
I have an array like this:

```<code>[["09:00",4,15],["09:00",4,15]]
</code>```

And I want to output this in a text area like this:

```<code>"09:00",4,15
"09:00",4,15
</code>```

The user can edit it and then I want to convert it back into an array with sub-arrays.

For the first step I could do an each and remove the [] with gsub but this does not seem to be the best way. And then to turn it back into an array I would need even more code.

It's kind of a CSV output but I am not working with any files here.

答:
To produce the output, something like this could work:

```<code>input = [["09:00",4,15],["09:00",4,15]]

output = input
  .map { |list| list.join(",") }
  .join("\n")

puts output
</code>```

which prints:

```<code>09:00,4,15
09:00,4,15
</code>```

Then you can turn it back into the input using split:

```<code>result = output
  .split("\n")
  .map { |line| line.split(",") }
# => [["09:00", "4", "15"], ["09:00", "4", "15"]]
</code>```

The problem, as you maybe noticed, is that the numbers are transformed into strings. This is because when you print something to the page, you are inevitably turning it into a string, and Ruby can't just know that it's supposed to be a number.

You could, if you wanted, turn the second and third elements to numbers:

```<code>result2 = result.map do |(time, num1, num2)|
  [time, num1.to_i, num2.to_i]
end
</code>```

Body:
I have an array like this:

[["09:00",4,15],["09:00",4,15]]

And I want to output this in a text area like this:

"09:00",4,15
"09:00",4,15

The user can edit it and then I want to convert it back into an array with sub-arrays.

For the first step I could do an each and remove the [] with gsub but this does not seem to be the best way. And then to turn it back into an array I would need even more code.

It's kind of a CSV output but I am not working with any files here.

Body:
To produce the output, something like this could work:

input = [["09:00",4,15],["09:00",4,15]]

output = input
  .map { |list| list.join(",") }
  .join("\n")

puts output

which prints:

09:00,4,15
09:00,4,15

Then you can turn it back into the input using split:

result = output
  .split("\n")
  .map { |line| line.split(",") }
# => [["09:00", "4", "15"], ["09:00", "4", "15"]]

The problem, as you maybe noticed, is that the numbers are transformed into strings. This is because when you print something to the page, you are inevitably turning it into a string, and Ruby can't just know that it's supposed to be a number.

You could, if you wanted, turn the second and third elements to numbers:

result2 = result.map do |(time, num1, num2)|
  [time, num1.to_i, num2.to_i]
end


问:
Footer floats to middle on the page
Is there any way to set footer at the bottom of the page?
Footer should be 100% width and .wrapper 960px as well.

I already tried:

position: relative; - sticks between .content tags

position: absolute; - sticks to .nav

position: fixed; - could be a solution, but I don't need it all the time, just at bottom of the last page.

to move .footer outside .wrapper and set .wrapper:not(footer); - footer sticked to the bottom, but the width hasn't changed.

Any suggestion how is possible to set it up at the bottom?

@charset "UTF-8";
@import url('https://fonts.googleapis.com/css?family=Montserrat|Nunito+Sans|Roboto&display=swap');
* {
  margin: 0;
  padding: 0;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  word-wrap: break-word;
}

html,
body,
header,
main {
  height: 100%;
}

body {
  width: 100%;
  font-family: Roboto, Verdana, sans-serif;
  font-size: 1em;
  background-image: url(../images/extra_clean_paper.png);
  background-repeat: repeat;
}

header {
  text-align: center;
  background-color: yellow;
}

#hero-header {
  position: relative;
  top: 50%;
  left: 50%;
  -webkit-transform: translate(-50%, -50%);
  -ms-transform: translate(-50%, -50%);
  transform: translate(-50%, -50%);
}

#hero-btn {
  width: 50px;
  height: 50px;
  position: absolute;
  bottom: 4em;
  left: 50%;
  -webkit-transform: translateX(-50%);
  -ms-transform: translateX(-50%);
  transform: translateX(-50%);
}

.hero-btn a {
  position: relative;
  display: inline-block;
  color: black;
  text-decoration: none;
  -webkit-transition: opacity .3s;
  -o-transition: opacity .3s;
  transition: opacity .3s;
}

.hero-btn a:hover {
  opacity: 0.5;
}

header a {
  padding-top: 70px;
}

header a span {
  position: absolute;
  top: 0;
  left: 50%;
  width: 24px;
  height: 24px;
  margin-left: -12px;
  border-left: 1px solid black;
  border-bottom: 1px solid black;
  -webkit-transform: rotate(-45deg);
  -ms-transform: rotate(-45deg);
  transform: rotate(-45deg);
  -webkit-animation: sdb07 2s infinite;
  animation: sdb07 2s infinite;
  opacity: 0;
}

header a span:nth-of-type(1) {
  -webkit-animation-delay: 0s;
  animation-delay: 0s;
}

header a span:nth-of-type(2) {
  top: 16px;
  -webkit-animation-delay: .15s;
  animation-delay: .15s;
}

header a span:nth-of-type(3) {
  top: 32px;
  -webkit-animation-delay: .3s;
  animation-delay: .3s;
}

@-webkit-keyframes sdb07 {
  0% {
    opacity: 0;
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

@keyframes sdb07 {
  0% {
    opacity: 0;
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

#resp-nav {
  text-align: center;
  display: none;
  background-color: grey;
}

#resp-nav i {
  font-size: 2em;
  color: white;
}

#nav {
  text-align: center;
  background-color: dimgray;
  z-index: 2;
}

main:not(#footer) {
  max-width: 960px;
  margin: 0 auto;
}

.container {
  background-color: #eeeeee;
  border: 1px solid red;
  border-radius: 5px;
  clear: both;
  overflow: hidden;
  margin-top: 1em;
  min-height: 100%;
  padding: 3.125em 0.625em;
  -webkit-box-shadow: 0 15px 20px rgba(0, 0, 0, 0.3);
  box-shadow: 0 15px 20px rgba(0, 0, 0, 0.3);
}

.aboutme img {
  width: 100%;
  height: auto;
}

.aboutme .col-40 {
  margin-top: 1em;
  padding-left: 1em;
  padding-right: 1em;
  width: 39%;
}

.aboutme .col-60 {
  margin-top: 1em;
  padding-left: 1em;
  padding-right: 1em;
  width: 59%;
}

.left {
  float: left;
}

.right {
  float: right;
}

.table {
  display: table;
  border-collapse: collapse;
  table-layout: fixed;
}

.hobbies .table-row {
  display: table-row;
  border-bottom: 0.1em solid darkgrey;
}

.hobbies .table-row:last-child {
  border: 0;
}

.hobbies .table-cell {
  display: table-cell;
  padding-left: 1em;
  padding-right: 1em;
  vertical-align: middle;
  text-align: center;
  width: 50%;
}

.portfolio .col-50 {
  margin-top: 1em;
  padding-left: 1em;
  padding-right: 1em;
  width: 49%;
}

.projects .flex-row {
  display: flex;
  flex-wrap: wrap;
  width: 100%;
  padding-right: 15px;
  padding-left: 15px;
  margin-right: auto;
  margin-left: auto;
}

.projects .col-33 {
  position: relative;
  width: 100%;
  max-width: 33%;
  -ms-flex: 0 0 33%;
  -webkit-box-flex: 0;
  -webkit-flex: 0 0 33%;
  flex: 0 0 33%;
}

.projects .services-box {
  background: #f9f9f9;
  padding: 10px;
  margin: 20px 5px 0 5px;
}

footer {
  background: red;
  height: 50px;
  width: 100%;
  position: relative;
  bottom: 0;
  left: 0;
  margin-top: 10px;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><header id="link-hero-page">
  <div id="hero-header">
  </div>
</header>
<nav>
  <ul id="nav">
  </ul>
</nav>
<main>
  <section id="link-main" class="aboutme container">
    <div class="col-40 left">
    </div>
    <article class="col-60 right">
    </article>
  </section>
  <section id="link-hobbies" class="hobbies container">
    <div class="table">
      <div class="table-row">
        <article class="table-cell">
        </article>
      </div>
      <div class="table-row">
        <div class="table-cell">
        </div>
        <article class="table-cell">
        </article>
      </div>
      <div class="table-row">
        <article class="table-cell">
        </article>
      </div>
    </div>
  </section>
  <section id="link-portfolio" class="portfolio container">
    <article class="col-50 left">
    </article>
    <article class="col-50 right">
    </article>
  </section>
  <section id="link-projects" class="projects container">
    <div class="flex-row">
      <div class="col-33">
        <article class="services-box">
        </article>
      </div>
      <div class="col-33">
        <article class="services-box">
        </article>
      </div>
      <div class="col-33">
        <article class="services-box">
        </article>
      </div>
    </div>
  </section>
  <section id="link-contacts" class="contacts container">

  </section>
</main>
<!--FOOTER-->
<footer>
  <address>
    <p style="text-align: center;">LOREM LOREM LOREM LOREM LOREM</p>
   </address>
</footer></code>```

https://jsfiddle.net/1adkjLw0/

答:
One option is to turn your container into a vertical flexbox and set margin-top: auto on the footer which will push it to the bottom of the flex container.  You also need to set height: 100% on the container so it fills the whole page

* {
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  width: 100%;
}

.nav {
  background: green;
  height: 50px;
}

.wrapper {
  max-width: 500px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.content {
  background: yellow;
  margin-top: 10px;
  height: 100px;
}

.footer {
  background: red;
  height: 50px;
  width: 100%;
  position: relative;
  margin-top: auto;
  bottom: 0;
  left: 0;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><body>

<div class="nav"></div>

<div class="wrapper">

  <div class="content"></div>
  <div class="content"></div>
  <div class="content"></div>
  <div class="content"></div>
  <div class="content"></div>
  <div class="content"></div>

  <div class="footer"></div>

</div>

</body></code>```

Title: Footer floats to middle on the page

Body:
Is there any way to set footer at the bottom of the page?
Footer should be 100% width and .wrapper 960px as well.

I already tried:

position: relative; - sticks between .content tags

position: absolute; - sticks to .nav

position: fixed; - could be a solution, but I don't need it all the time, just at bottom of the last page.

to move .footer outside .wrapper and set .wrapper:not(footer); - footer sticked to the bottom, but the width hasn't changed.

Any suggestion how is possible to set it up at the bottom?

@charset "UTF-8";
@import url('https://fonts.googleapis.com/css?family=Montserrat|Nunito+Sans|Roboto&display=swap');
* {
  margin: 0;
  padding: 0;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  word-wrap: break-word;
}

html,
body,
header,
main {
  height: 100%;
}

body {
  width: 100%;
  font-family: Roboto, Verdana, sans-serif;
  font-size: 1em;
  background-image: url(../images/extra_clean_paper.png);
  background-repeat: repeat;
}

header {
  text-align: center;
  background-color: yellow;
}

#hero-header {
  position: relative;
  top: 50%;
  left: 50%;
  -webkit-transform: translate(-50%, -50%);
  -ms-transform: translate(-50%, -50%);
  transform: translate(-50%, -50%);
}

#hero-btn {
  width: 50px;
  height: 50px;
  position: absolute;
  bottom: 4em;
  left: 50%;
  -webkit-transform: translateX(-50%);
  -ms-transform: translateX(-50%);
  transform: translateX(-50%);
}

.hero-btn a {
  position: relative;
  display: inline-block;
  color: black;
  text-decoration: none;
  -webkit-transition: opacity .3s;
  -o-transition: opacity .3s;
  transition: opacity .3s;
}

.hero-btn a:hover {
  opacity: 0.5;
}

header a {
  padding-top: 70px;
}

header a span {
  position: absolute;
  top: 0;
  left: 50%;
  width: 24px;
  height: 24px;
  margin-left: -12px;
  border-left: 1px solid black;
  border-bottom: 1px solid black;
  -webkit-transform: rotate(-45deg);
  -ms-transform: rotate(-45deg);
  transform: rotate(-45deg);
  -webkit-animation: sdb07 2s infinite;
  animation: sdb07 2s infinite;
  opacity: 0;
}

header a span:nth-of-type(1) {
  -webkit-animation-delay: 0s;
  animation-delay: 0s;
}

header a span:nth-of-type(2) {
  top: 16px;
  -webkit-animation-delay: .15s;
  animation-delay: .15s;
}

header a span:nth-of-type(3) {
  top: 32px;
  -webkit-animation-delay: .3s;
  animation-delay: .3s;
}

@-webkit-keyframes sdb07 {
  0% {
    opacity: 0;
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

@keyframes sdb07 {
  0% {
    opacity: 0;
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

#resp-nav {
  text-align: center;
  display: none;
  background-color: grey;
}

#resp-nav i {
  font-size: 2em;
  color: white;
}

#nav {
  text-align: center;
  background-color: dimgray;
  z-index: 2;
}

main:not(#footer) {
  max-width: 960px;
  margin: 0 auto;
}

.container {
  background-color: #eeeeee;
  border: 1px solid red;
  border-radius: 5px;
  clear: both;
  overflow: hidden;
  margin-top: 1em;
  min-height: 100%;
  padding: 3.125em 0.625em;
  -webkit-box-shadow: 0 15px 20px rgba(0, 0, 0, 0.3);
  box-shadow: 0 15px 20px rgba(0, 0, 0, 0.3);
}

.aboutme img {
  width: 100%;
  height: auto;
}

.aboutme .col-40 {
  margin-top: 1em;
  padding-left: 1em;
  padding-right: 1em;
  width: 39%;
}

.aboutme .col-60 {
  margin-top: 1em;
  padding-left: 1em;
  padding-right: 1em;
  width: 59%;
}

.left {
  float: left;
}

.right {
  float: right;
}

.table {
  display: table;
  border-collapse: collapse;
  table-layout: fixed;
}

.hobbies .table-row {
  display: table-row;
  border-bottom: 0.1em solid darkgrey;
}

.hobbies .table-row:last-child {
  border: 0;
}

.hobbies .table-cell {
  display: table-cell;
  padding-left: 1em;
  padding-right: 1em;
  vertical-align: middle;
  text-align: center;
  width: 50%;
}

.portfolio .col-50 {
  margin-top: 1em;
  padding-left: 1em;
  padding-right: 1em;
  width: 49%;
}

.projects .flex-row {
  display: flex;
  flex-wrap: wrap;
  width: 100%;
  padding-right: 15px;
  padding-left: 15px;
  margin-right: auto;
  margin-left: auto;
}

.projects .col-33 {
  position: relative;
  width: 100%;
  max-width: 33%;
  -ms-flex: 0 0 33%;
  -webkit-box-flex: 0;
  -webkit-flex: 0 0 33%;
  flex: 0 0 33%;
}

.projects .services-box {
  background: #f9f9f9;
  padding: 10px;
  margin: 20px 5px 0 5px;
}

footer {
  background: red;
  height: 50px;
  width: 100%;
  position: relative;
  bottom: 0;
  left: 0;
  margin-top: 10px;
}

  <address>

LOREM LOREM LOREM LOREM LOREM

   </address>

https://jsfiddle.net/1adkjLw0/

Body:
One option is to turn your container into a vertical flexbox and set margin-top: auto on the footer which will push it to the bottom of the flex container.  You also need to set height: 100% on the container so it fills the whole page

* {
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  width: 100%;
}

.nav {
  background: green;
  height: 50px;
}

.wrapper {
  max-width: 500px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.content {
  background: yellow;
  margin-top: 10px;
  height: 100px;
}

.footer {
  background: red;
  height: 50px;
  width: 100%;
  position: relative;
  margin-top: auto;
  bottom: 0;
  left: 0;
}

<body>

<div class="nav"></div>

<div class="wrapper">

  <div class="content"></div>
  <div class="content"></div>
  <div class="content"></div>
  <div class="content"></div>
  <div class="content"></div>
  <div class="content"></div>

  <div class="footer"></div>

</div>

</body>