Optimizing a threshold value on a dependent metric using a classifier trained to optimize a threshold-independent metric

Question: Is it a reasonable approach to train a probabilities classifier by optimizing a threshold-independent metric such as AUC, and then using the trained classifier to calibrate the decision threshold value on a train/validation (which used to choose the trained classifer's hyperparameters values)or both, to maximize a threshold-dependent metric like F1 score?
Answer: That is a completely standard approach. (Although - rather than AUROC - folks would usually maximize a proper scoring rule such as the Brier score / mean squared error or log loss during training.)
In particular, the combination of log loss optimization on the training set + subsequent threshold selection (e.g. maximizing F1) on the validation set is probably the single most common approach.
So yes, without knowing any more details about your particular application, that sounds like a very reasonable approach.
Comment: I choose the model's hyperparameters that has the best auc score on a validation set, and then using the same val set for tuning the trained model's threshold value. Are you recommend to train the model just using the training set, and the using the validation set for tuning the threshold?
Comment: Using the val set for both hyperparameter tuning and threshold selection is fine. (In fact, the decision threshold *is* a hyper parameter.) A slightly better way might be to use cross-validation for hyper param (incl. threshold) selection instead of a single fixed pair of train/val set. See, e.g., [here](https://datascience.stackexchange.com/q/52632/105519). The only really important thing is to never do any model selection or parameter tuning whatsoever on the test set - unless you do *not* need an unbiased estimate of i.i.d. model performance.
Comment: Let:
$H$ are the model's set of hyperparameters (The threshold is not part of
$H$). $AUC(M,H)$ is  model $M$  accuracy when using $H$ on a validation dataset.
First, we try to find $H^* = \arg\max_H AUC(M, H)$.When tuning the threshold, the problem is different and can be defined as: $t^* = \arg\max_{t} F1(M, H^*, t)$
where $F1(M, H^*, \text{t})$ represent the F1 score of model $M$ with hyperparameters $H^*$ when using the threshold value $\text{t}$ on a validation dataset. However, I assume from your answer that it is valid using the same validation set for the not identical problems.


Nginx does not display custom 404 page with Gunicorn + Flask

Question: I'm trying to display a custom 404 error page on my site, but it seems that Nginx does not catch the 404. Instead, it shows a 404 page from Gunicorn(flask app)
nginx.conf:
server {
listen 80 default_server;
server_name example.com www.example.com;

location / {
    proxy_pass http://flask:8080/;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $host;
    proxy_redirect off;
}

error_page 404 /notfound.html;
location /notfound.html {
    root /var/www/html;
}

error_page 500 502 503 504 /maintenance.html;
location /maintenance.html {
    root /var/www/html;
}
}

Both flask app and Nginx are running on separate docker containers.

I purposefully brought the flask app down to see what happens, after a
while It redirects to 504(Timeout) and the maintenance.html appeared. - works fine.

But on a 404 error instead of displaying this custom notfound.html, it displays a 404 Not Found from Flask App (The 404 page did not had any nginx version on it).
Comment: Use [`proxy_intercept_errors`](https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_intercept_errors) directive: `proxy_intercept_errors on;`
Comment: Oh! I didn't thought it would be that easy.
Answer: proxy_intercept_errors on; should solve this problem.


Bug in Moment.js?

Question: I'm facing an issue which I just can't solve.
In AngularJS I created a directive that checks the validity of a date. For this I use Moment.js
This is my directive:
/* @ngInject */
function modelDate() {
    return {
        restrict: 'A',
        require: 'ngModel',
        link: function (scope, element, attrs, ngModel) {
            var validate = function (value) {
                if (!value) {
                    // don't validate an undefined value. required or ng-required should handle that
                    ngModel.$setValidity('date', true);
                    ngModel.$setValidity('maxDate', true);
                    ngModel.$setValidity('minDate', true);
                    return value;
                }

                var date = moment(value, ['DD-MM-YY', 'DD-MM-YYYY', 'DD-MM']);
                if (!date.isValid()) {
                    // invalid date, so no validity check on max and min date
                    ngModel.$setValidity('date', false);
                    ngModel.$setValidity('maxDate', true);
                    ngModel.$setValidity('minDate', true);
                    return value;
                } else {
                    ngModel.$setValidity('date', true);
                }

                if (ngModel.$viewValue !== date.format('DD-MM-YYYY')) {
                    // format and set value
                    value = date.format('DD-MM-YYYY');
                    element.val(value);
                }

                return value;
            };

            ngModel.$parsers.push(validate); // for DOM -> model validation
            ngModel.$formatters.push(validate); // for model -> DOM validation
        }
    };

My issue is the following:
When I enter the date 29-02-2015, moment(value, ['DD-MM-YY', 'DD-MM-YYYY', 'DD-MM']) returns me 29-02-2020. While I expect an invalid date. This is also for 2001, 2002 etc.
Basically every none leap year from 2001 till now.
Did someone faced this issue before?
I created a small fiddle to demonstrate the issue:
http://jsfiddle.net/r42jg/1183/
Answer: Just a reflection: I used moment.js for general date validity checks a while back, and I also noticed that it can be very forgiving.
What I did was to compare the input with the result; if they don't match, the date is invalid.
That of course assumes that the format of the input date is known.
Comment: Thanks for your reply, that would be a nice solution, but in my case unusable .. My users may use different formats.
Answer: I think this is not a bug.
From the docs:

Prefer formats resulting in valid dates over invalid ones.
http://momentjs.com/docs/#/parsing/

So the first format 'DD-MM-YY' produces a valid date.
Comment: This is exactly what I just figured. DD-MM-YY returns me a valid result, so Moment.js formats the date in a correct one. I deleted the formatting rules now to only DD-MM-YYYY, so it gives me the expected result now
Answer: It looks to be due to you passing an array of formats to moment.  As far as I can tell, moment doesn't support accepting an array of formats, only a format string.
See http://momentjs.com/docs/#/parsing/string-format/
If you change the format to just a string, then you will get the expected behaviour: http://jsfiddle.net/wc9bstux/
So change: moment(value, ['DD-MM-YY', 'DD-MM-YYYY', 'DD-MM']) to be moment(value,'DD-MM-YYYY').
Comment: That's not true, moment.js does support multiple formats
Comment: Ah yeah - just noticed they actually have two sections (string-format and string-formats).

Bug in Moment.js?


Nagios notification_interval for weekday vs weekend

Question: I would like to configure Nagios to send a page once every 6 hours Monday through Friday, but only once every 24 hours Saturday & Sunday. I am having a hard time wrapping my mind around how to have one group of admins have two different paging frequencies.
Answer: Here is an example how it could be done but I hope somebody has a better method. Define your service for weekdays:
define service{
    name                    foo-weekday
    host_name               linux-server
    service_description     check-disk-sda1-weekday
    check_command           check-disk!/dev/sda1
    max_check_attempts      5
    check_interval          5
    retry_interval          3
    check_period            weekday
    notification_interval   360
    notification_period     weekday
    notification_options    w,c,r
    contact_groups          linux-admins
    }

Then inherit from it, overriding the check_period, notification_interval, notification_period, and service_description (which must be unique per-host) for the weekend:
define service{
    name                    foo-weekend
    use                     foo-weekday
    service_description     check-disk-sda1-weekend
    check_period            weekend
    notification_interval   1440
    notification_period     weekend
    }

Edit: I wonder if user macros would work in this situation? E.g., only have 1 service definition:
define service{
    host_name               linux-server
    service_description     check-disk-sda1
    check_command           check-disk!/dev/sda1
    max_check_attempts      5
    check_interval          5
    retry_interval          3
    check_period            24x7
    notification_interval   $USER21$
    notification_period     24x7
    notification_options    w,c,r
    contact_groups          linux-admins
    }

Then, have two different resource files. One defines USER21 as "360" and one as "1440". When the weekend starts copy the latter in place and reload the nagios config. When the weekend ends copy the former into place and reload.
Comment: Thanks for the advice. I am digesting it all right now. The idea of the user macro came to me is a (slightly) different idea of just having cron switchout the services.cfg file on Friday at 5pm and then back to normal Monday at 9am. I like the idea of just changing the notification_interval even better
Comment: Hey @Mark, so I am trying to get the user macro working and having some trouble.

resources.cfg
$USER3$=/usr/local/nagios/etc/time.marcro

time.macro
1440

services.cfg
`
define host {
 name    generic-host
 max_check_attempts  5
 check_interval    5
 check_command   check_host_alive
 first_notification_delay 30
 notification_interval  $USER3$
 notification_period  24x7
 notification_options  d,r
 contact_groups   admins
}
`

Do you see any glaring errors?
Comment: Sorry the formatting is garbage.... clearly I'm doing something wrong trying to post that.
Comment: I never used a macro in that context so maybe it doesn't work. I do not use Nagios anymore so I can't test it.
Comment: Thanks for the follow up Mark. It might just be that I need to replace the whole services.cfg rather than doing it the (far more elegant) way you suggested.


Group of 28 divided into 4 teams, probability of at least 1 girl on each team when there are 7 girls.

Question: Hello we had a group divided into 4 teams of 7 each and there is a girl on each team. One of the girls thinks there was foul play in choosing the teams so I thought I'd calculate the chance of a girl on each team. This proved to be harder than I expected so I'm asking for help.
I think that since there are 28 total and 7 girls that we would have $\binom{28}{7}\binom{21}{7}\binom{14}{7}$ ways to assign the people to labelled teams.
I think now I would need to count the number of ways girls could be on teams and then divide?
I am unsure if I am doing anything correctly at this point, been years since I took math.
Comment: Observe that there are $4^7$ ways of assigning seven girls to four teams without restriction.  You want to subtract from that the number of ways that at least one of the four teams has no girls.  To do so, you can use the [Inclusion-Exclusion Principle](https://en.wikipedia.org/wiki/Inclusion%E2%80%93exclusion_principle).
Comment: @fleablood: Your second comment is along the same lines as rsadhvika's comment. As rsadhvika observed, on average, a team should be $25$% girls, so an average of $1.75$ girls per team. Hence it's not surprising for it to be the case that each team has at least one girl.
Comment: Since boys:girls = 21:7 = 3:1, a fair team should have 75% boys and 25% girls.
Comment: @rsadhvika what does that have to do with the question asked?
Comment: Although out of curiosity with does the girl think it was unfair.  You can't have more than one girl on every team (because you have fewer than 8 girls total) so at least one team will have to have at most one girl.  What was she expecting.
Comment: @N. F. Taussig: There are $4^7$ ways of assigning the seven girls to the $4$ teams, but those $4^7$ assignments are not equally likely.
Comment: Which is why it is odd that the girl thought it was unfair.  Usually they'd thing it was unfair if a team has too  many or too few girls. At least one girl on all four teams is neither too few or too many.  Was it that one team had four girls and the rest had one?
Comment: @fleablood: The teams ended up being 3 girls on team A, 1 on team B, 2 on team C, and 1 on team D. I think she may have been upset that she was on a team with 6 guys where another team had 3 girls. Based on all the answers here I feel that it is safe to conclude that there was no foul play and that is just how the randomness played out.
Answer: Label the teams as $1,2,3,4$.

The total number of ways to form the $4$ teams is
$$
n
=
\binom{28}{7}
\binom{21}{7}
\binom{14}{7}
\binom{7}{7}
$$
Let $v$ be the list of counts, sorted in ascending order, for the number of girls on each of the $4$ teams.

Consider $3$ cases .  . .

Case $(1)$:$\;v=[1,1,1,4]$.

For case $(1)$, the number of ways to form the $4$ teams is
$$
x_1
=
\left(\binom{4}{1}\binom{3}{3}\right)
{\cdot}
\left(\binom{7}{4}\binom{21}{3}\right)
{\cdot}
\left(\binom{3}{1}\binom{18}{6}\right)
{\cdot}
\left(\binom{2}{1}\binom{12}{6}\right)
{\cdot}
\left(\binom{1}{1}\binom{6}{6}\right)
$$
hence the probability for case $(1)$ is
\begin{align*}
p_1&=\frac{x_1}{n}\\[4pt]
&={\Large{\frac
{
\left(\binom{4}{1}\binom{3}{3}\right)
{\cdot}
\left(\binom{7}{4}\binom{21}{3}\right)
{\cdot}
\left(\binom{3}{1}\binom{18}{6}\right)
{\cdot}
\left(\binom{2}{1}\binom{12}{6}\right)
{\cdot}
\left(\binom{1}{1}\binom{6}{6}\right)
}
{
\binom{28}{7}
\binom{21}{7}
\binom{14}{7}
\binom{7}{7}
}}}
\\[4pt]
&=\frac{2401}{59202}\approx .04055606230\\[4pt]
\end{align*}

Case $(2)$:$\;v=[1,1,2,3]$.

For case $(2)$, the number of ways to form the $4$ teams is
$$
x_2
=
\left(\binom{4}{1}\binom{3}{1}\binom{2}{2}\right)
{\cdot}
\left(\binom{7}{3}\binom{21}{4}\right)
{\cdot}
\left(\binom{4}{2}\binom{17}{5}\right)
{\cdot}
\left(\binom{2}{1}\binom{12}{6}\right)
{\cdot}
\left(\binom{1}{1}\binom{6}{6}\right)
$$
hence the probability for case $(2)$ is
\begin{align*}
p_2&=\frac{x_2}{n}\\[4pt]
&={\Large{\frac
{
\left(\binom{4}{1}\binom{3}{1}\binom{2}{2}\right)
{\cdot}
\left(\binom{7}{3}\binom{21}{4}\right)
{\cdot}
\left(\binom{4}{2}\binom{17}{5}\right)
{\cdot}
\left(\binom{2}{1}\binom{12}{6}\right)
{\cdot}
\left(\binom{1}{1}\binom{6}{6}\right)
}
{
\binom{28}{7}
\binom{21}{7}
\binom{14}{7}
\binom{7}{7}
}}}
\\[4pt]
&=\frac{2401}{6578}\approx .3650045607\\[4pt]
\end{align*}

Case $(3)$:$\;v=[1,2,2,2]$.

For case $(3)$, the number of ways to form the $4$ teams is
$$
x_3
=
\left(\binom{4}{3}\binom{1}{1}\right)
{\cdot}
\left(\binom{7}{2}\binom{21}{5}\right)
{\cdot}
\left(\binom{5}{2}\binom{16}{5}\right)
{\cdot}
\left(\binom{3}{2}\binom{11}{5}\right)
{\cdot}
\left(\binom{1}{1}\binom{6}{6}\right)
$$
hence the probability for case $(3)$ is
\begin{align*}
p_3&=\frac{x_3}{n}\\[4pt]
&={\Large{\frac
{
\left(\binom{4}{3}\binom{1}{1}\right)
{\cdot}
\left(\binom{7}{2}\binom{21}{5}\right)
{\cdot}
\left(\binom{5}{2}\binom{16}{5}\right)
{\cdot}
\left(\binom{3}{2}\binom{11}{5}\right)
{\cdot}
\left(\binom{1}{1}\binom{6}{6}\right)
}
{
\binom{28}{7}
\binom{21}{7}
\binom{14}{7}
\binom{7}{7}
}}}
\\[4pt]
&=\frac{7203}{32890}\approx .2190027364\\[4pt]
\end{align*}
Hence the probability that each team has at least one girl is
$$
p
=
p_1+p_2+p_3
=
\frac{2401}{59202}
+
\frac{2401}{6578}
+
\frac{7203}{32890}
=
\frac{16807}{26910}\approx .6245633593
$$
Comment: Wow! Now that you've done it, it almost looks obvious to split it out into the 3 different possibilities for teams and add the probabilities together. We did end up having the girls split like case 2 which looks to be the most probable outcome. Thank you for your answer!
Answer: You only need consider ways to arrange the 7 girls among 28 places (4 teams of 7 places each), and use the principle of inclusion and exclusion to count ways that some teams have no girls.
$$\mathsf P(\text{no team has no girls})=1- \dfrac{{\dbinom 41\dbinom{21}7}-{\dbinom42\dbinom{14}7}+{\dbinom 43\dbinom 77}}{\dbinom{28}7}=\dfrac{16807}{26910}$$

Remark: How does this work?
A method of fairly assigning teams might be to draw names out of a hat, or such lottery, then assign teams based on order of draw.  There are $28!$ ways to do so.
Now this process is equivalent drawing girls and boys from separate hats, with a fair way to select 7 from 28 positions in the draw to come from the girls' hat. We can see that indeed:$$28!=\binom{28}7 7!\,21!$$
So we just need to focus on the selection of those positions.
Okay, there are $\tbinom 41$ ways to select a team to have all boys and $\tbinom {21}7$ ways to select positions among the rest for the girls.  However, this includes cases where two or more teams have all boys, so we use the principle of exclusion and inclusion to avoid overcounting.  Thus the numerator above.
Comment: Thank you for your answer! It really helped make it click in my head.
Answer: This may be a terrible way to do this.
There are $7!$ ways to line up the girls along a wall and $21!$ ways to line up the boys along another wall.  Now we do a single riffle shuffle to mix the girls into the boys without changing the order of the girls or the boys.  We look at the four "packets" of $7$; that is positions $1-7,8-14,15-21,22-28$.
If we add A to J up we get $508,232$
A) One team has seven girls.
All the girls in the same packet.  There are four packets so $4$ ways to do this:  $4$.
Or $0.0008\%$.
B) One team has six girls and one has one girl.
$4$ choices for one packet with six girls. and $3$ choices for one packet with one girl.  ${7 \choose 6}$ choices for the positions of the six girls and ${7\choose 1}$ choices for the position of the one girl:  $4*3*7*7 = 588$.
Or $0.1\%$
C) One team with five girls and one with two girls.
$4*3$ for which two packets to pick.  ${7\choose 5}$ and ${7\choose 2}$ for the positions within the packets.  $12*21*21 = 5292$
Or $1\%$
D) One team with five girls and two teams with one girl.
$4$ choices for the packet with five girls and ${3\choose 2} =3$ choices for the packets with one girl.  ${7\choose 5}$ ways to place the five girls in a packet and ${7\choose 1}$ for each of the two packets with one girl: $4*3*21*7*7= 12348$
$2.5%$
E) One team with four, one with 3.
$4*3*{7\choose 4}{7\choose 3} = 12*35*35= 14,700$.
$2.9\%$
F) One team with four, one with two, one with one.
$4*3*2*{7\choose 4}{7\choose 2}{7\choose 1} = 24*35*21*7=123480$
$24.3\%$.
G) One team with four, three with one.
$4*{7\choose 4}{7\choose 1}{7\choose 1}{7\choose 1} = 1372$
$0.3\%$
H) two teams with $3$, one with one.
${4\choose 2}{2\choose 1}{7\choose 3}{7\choose 3}{7\choose 1} = 6*2*35*35*7 = 102,900$
$20.2\%$
H) one team with $3$, two with two.
$4*3*35*21*21 = 185,220$
$36.4\%$.
I) one team with $3$, one with two, two with one.
$4*3*35*21*7= 61,740$
$12\%$
(According to you comment this is the one that occurred.
J) three teams with $2$, and one with one.
$4*{7\choose 2}^3*{7\choose 1} = 4*21*7 = 588$.
$1.1\%$
Notice this "fairest" of distributions is actually one of the less likely options.  This is not all that unusual.


Bridging a remote site through OpenVPN with broadcast traffic

Question: I am trying to set up a VPN connection between two sites.

The remote site has a camera running that broadcasts video using TCP, and additionally advertises itself on the network using mDNS/Bonjour.
In the middle there is a Linux server running on a cloud provider, hosting an OpenVPN server
The remote site's router (ASUS ROG Rapture GT-AX11000) is connected via OpenVPN to the server
The local site has a laptop that should be able to connect to the camera and receive the broadast.

Here's a diagram of the architecture:

So far I've used this script to set up OpenVPN and the client configurations. But I couldn't see the broadcast (which was expected).
What do I have to do to make sure I see the broadcast traffic locally on the laptop?
I've changed my OpenVPN config to use (selected parts):
port 1194
proto udp6
dev tap
user nobody
group nogroup
persist-key
persist-tun
keepalive 10 120
topology subnet
server 10.8.0.0 255.255.255.0
ifconfig-pool-persist ipp.txt
push "dhcp-option DNS 184.108.40.206"
push "dhcp-option DNS 126.96.36.199"
push "redirect-gateway def1 bypass-dhcp"
dh none
ecdh-curve prime256v1
tls-crypt tls-crypt.key
crl-verify crl.pem
ca ca.crt
cert server_rgpYVq742Cz4eLEj.crt
key server_rgpYVq742Cz4eLEj.key
auth SHA256
cipher AES-128-GCM
ncp-ciphers AES-128-GCM
tls-server
tls-version-min 1.2
tls-cipher TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256
client-config-dir /etc/openvpn/ccd
verb 4
client-to-client
log-append /var/log/openvpn.log

This works and lets the laptop and router connect, although I can only reach the router, not the camera and its broadcast.
I now also understand that what I need is not a typical server bridge, which assumes that the OpenVPN server sits behind the router to which outside clients connect.
Instead, I need to bridge the traffic from the LAN (with the camera) to the VPN network, using the capabilities of the ASUS router.
Is that possible, and if so, how?
Answer: From my point of view, changing the VPN to a TAP-setup is the only solution to your problem. Let me dig into the details a bit:
A routed vpn setup, which you currently have setup, works at network layer 3. You already noticed, that you need to advertise any network, which is supposed to go through the vpn via iroute. But broadcasts work differently, and there are many broadcasts which are at network layer 2 - you will not be able to make them work at all through a routed vpn. (And I have not talked about multicast yet...)
This is where an TAP-VPN comes into play: instead of working at the network layer, it works at layer 2: this kind of vpn wraps ethernet frames. This means any broadcast will simply work - at the cost of the higher overhead (the ethernet header on any ip packet). But up until now, you just have connected your locations with ethernet - you still need to setup your IP configuration on top of that. There are many configurations possible:

on the server side, you can build a bridge between the eth and tap network adapter, and leave the ip configuration to the DHCP server running on that site
you could create a dedicated network for you vpn, and let your vpn server assign ips

Reading your question, the most suitable setup for you would probably the bridge - that a local client and a VPN client are on the same network.
This part has nothing to do with vpn; openvpn just delivers the ethernet packets, and it is up to your linux running the openvpn, to "stuff" that ethernet frame into the correct network.
That is what the script you mentioned is made for. Concerning the values, you need to think of a suitable network layout, and implement that.
Let me give you an example:
file /etc/network/interfaces :
auto br0
iface br0 inet static
    address 192.168.100.10/24
    gateway 192.168.100.1
    bridge_ports eth0
    bridge_stp   off
    bridge_fd    0
    bridge_maxwait 0

start openvpn, and execute the following:
ifconfig tap0 up
brctl addif br0 tap0

This is my configuration to setup the network-bridge on boot - allowing the openvpn server to be started later (and being added to the bridge after startup).
If you want to do this setup with the script provided, you need to understand what is happening: The script is trying to create a bridge, and needs to add the "real" ethernet interface to the bridge. In order to do this, it needs to strip any ip configuration from the eth0 interface, create the bridge, add eth0 to it, and give the ip configuration which was previously on eth0 to the bridge interface. Because of the connectivity loss, I have setup the bridge on boot - that way, I can bring up and down openvpn without connectivity loss to the local network.
This way, whenever a vpn client sends a DHCP request, this request will be forwarded (in my example) into the local network, and being answered by the same DHCP server which is being used for your local clients. I would strongly suggest that you read about linux bridging - this knowlegde is essential, if you want to know what you are doing.
[edit]
concerning the IP address in my example - the correct value for you depends on the location of your openvpn-server! For my example, the openvpn-server runs on a device behind the router - which is why I specified .1 as gateway. If your openvpn runs on your gateway, you need to modify these values accordingly! depending on your setup, you even could assign the IP of the br0 interface via dhcp ...
when it comes to the server-bridge configuration option, lets have a look at what this option is made for. An exempt from Here :

For example, server-bridge 10.8.0.4 255.255.255.0 10.8.0.128 10.8.0.254 expands as follows:
mode server
tls-server
ifconfig-pool 10.8.0.128 10.8.0.254 255.255.255.0
push "route-gateway 10.8.0.4"

Note the ifconfig-pool directive! This option is just a shortcut for those, who want to keep their config file as short as possible. But if you want you vpn clients to get an IP via DHCP, this directive is wrong in your setup! It would configure the IP configuration of your clients, instead of leaving this to the DHCP server...
[edit2]
In reply to the comments, some clarification is needed. What does bridging mean? It means that you create an ethernet connection between the connected adapters, just like a network switch would do. In your setup, you created a link between your two openvpn clients and the eth interface of your server. Where is that interface going ? Following your picture, it goes into the public internet - that is not what you tried to achieve! you need to create a bridge to your camera...
Creating a bridge means that you link the virtual network to the real network. To be able to reach the camera from your laptop at "local site", you need your packets traverse from the vpn network into the real network at the remote site - and this is possible only, if there is a bridge between the vpn and the real network at the remote site.
Comment: This is great advice already, thank you! I understand now that a single bridge with the TAP interface would suffice. The `.10` IP address, is that the address of the VPN server in its own VPN? And in the `server-bridge` directive, should I use `.1` (for the router) or `.10` (for the server) as the first argument? Further, I am stuck with Ubuntu which uses netplan, so I cannot use `/etc/network/interfaces`, so I will check how to apply your example.
Comment: this is an example from ubuntu, too - there is a way to disable netplan (this is just a personal preference - I hate netplan... ) Concerning your other questions, these are important - I will enhance my answer.
Comment: I enhanced my answer ... and no, the .10 address is the real address of the device running the vpn server. In this setup, there is no difference anymore between "real" ips and ips from vpn... So actually, this ip is both ;-)
Comment: Thanks! Well, the location of the server is (as indicated in the image) on the public Internet without a router in front of it. The only other DHCP server in my setup would be the router at the remote site. It may, however, not always be connected. So I will split the pool, have the router assign its IPs from 1–127, and have the OpenVPN server assign IPs from 127–254, for example. So my `server-bridge` is set to `192.168.100.1 255.255.255.0 192.168.100.128 192.168.100.254`. This seems to have worked – at least I can connect with the clients –, now all I need to do is set up the bridge.
Comment: I updated my question once more. I cannot get it to work – would appreciate your insight. In particular, I am a bit confused since now the router has two IPs – the .1 and .129?
Comment: I should add: this is not like your typical office + mobile laptop setup where the VPN server sits behind the office router. That seems to make it more complex unfortunately.
Comment: well, just as I said, I was just giving an example, and in my example, the openvpn server stood "inside" the site which I wanted to be reachable. In your example, the openvpn server neither is inside the "remote site", nor in the local site. Not an ideal position... if the server should stay there, you could consider leaving the tap device at the server running standalone without any ip (and without being added to a bridge), and adding the tap interface of the client at the remote site to a linux bridge interface...
Comment: Hmm. I didn't figure that I would have to change your example, after all, you kindly included the IP addresses I was using. So I thought this should work in my case. So you mean I don't have to do any bridging stuff on the server. And by "client at the remote site", do you mean the router? So the router somehow needs to bridge its internal network to the VPN? Isn't it doing that anyway? I was able to reach the camera before, when using a TUN setup, by pushing an extra route.
Comment: I edited my answer again - hope this makes it clear now. You need to understand the difference between bridging and routing...
Comment: I do understand that difference. I guess I was further confused by the first examples given. But before switching to TAP, I was able to reach the camera very easily via the router. The router had a TUN connection to the VPN server, and I simply had to add the route for the internal subnet to the VPN setting. So the router already bridges its VPN connection with its local network, no? (It's an ASUS ROG Rapture GT-AX11000 btw.)
Comment: no! you were able to reach the camera because the router is able to ROUTE packets! but a broadcast started from either side will not be able to pass the router, because there is no ethernet bridge.
Comment: Got it. Now the obvious question is: can I do that with this particular router, or am I out of luck?
Comment: I do not know this router - but I am not aware of any router which is able to do network bridging. The obvious answer is: buy / get yourself a cheap network device (any raspi will do), plug it into the remote site's network, and install the openvpn server with bridge on that device...


How do you calculate a confidence interval for a parameter in multiple linear regression?

Question: Suppose $Y = Xβ + ε$, where $Y$ is a random $n$-vector, $X$ is a random $k × n$ matrix, $β$ is a fixed $k$-vector, and $ε$ is a random $n$-vector where the coordinates are independent (of each other and of $X$) and distributed as $N(0, σ^2)$. Given least-squares estimates $\hat β_1,\; \hat β_2,\; …,\; \hat β_k$ of the parameters, how do I compute a $(1 - α)$ confidence interval for one of the parameters $β_i$? Please provide a reference or a proof.
Although this is a pretty fundamental question, I couldn't find a previous CV question that exactly answers it, and poking around textbooks and websites seems to show some disagreement (e.g., should you use the quantile of a normal distribution or a $t$ distribution when multiplying by a standard error?). If there are several reasonable approaches, I'd appreciate a discussion of the differences.
Answer: The covariance matrix of the parameters is the residual variance multiplied by the inverse of the quadratic form of the design matrix. It is a result of the Gauss-Markov theorem (or, specifically, such a variance is a Best Linear Unbiased Estimator: BLUE).
Using matrix notation $\hat{\beta} = (\mathbf{X}^T\mathbf{X})^{-1}\mathbf{X}^TY$.
PROOF: The variance is:
$\text{var}(\hat{\beta}) = (\mathbf{X}^T\mathbf{X})^{-1}\mathbf{X}^T var(Y|X) \mathbf{X}(\mathbf{X}^T\mathbf{X})^{-1}$
$= (\mathbf{X}^T\mathbf{X})^{-1}\mathbf{X}^T diag(\sigma^2) \mathbf{X}(\mathbf{X}^T\mathbf{X})^{-1}$
$= \sigma^2 (\mathbf{X}^T\mathbf{X})^{-1}\mathbf{X}^T \mathbf{X}(\mathbf{X}^T\mathbf{X})^{-1}$
$= \sigma^2 (\mathbf{X}^T\mathbf{X})^{-1}$.
One result which does not require normal residuals: The limiting distribution of the $\hat{\beta}$ is normal.
Thus a 95% CI can be constructed: $\hat{\beta} \pm \mathcal{Z}_{1-\alpha/2} \sqrt{diag(\sigma^2 (\mathbf{X}^T\mathbf{X})^{-1})}$
Another result when we know residuals are normal but their variance unknown: the estimator is a linear combination of normals and thus is normal. To obtain finite sample inference, the values follow a T-distribution with degrees of freedom equal to the sample size minus the number of free parameters (including the intercept) so that the CI is expressed as:
$\hat{\beta} \pm \mathcal{T}_{1-\alpha/2, n-p} \sqrt{diag(\sigma^2 (\mathbf{X}^T\mathbf{X})^{-1})}$
Notationally, beta-hat a vector, the SEs also a vector and the $\pm$ a $\mathbb{R} \times \mathbb{R} \rightarrow \mathbb{R} \times \mathbb{R} $ operator, basically a sum with an outer product with the [-1, 1] vector.
Seber Lee, Linear Regression Analysis 2nd ed
Comment: The result is simpler than you suggest, because since $\hat \beta$ is a linear combination of the responses, it is conditionally Normal already: no limiting argument is needed. One then proceeds as usual to compute the ratio of the estimate to an estimated variance: this will be a suitable multiple of a Student t distribution. Your CI formula could be misinterpreted: it is not a 95% CI for $\hat\beta$.  It's just a collection of *separate* 95% CIs for the various components of $\hat \beta$.  (They are not necessarily conditionally independent.)
Comment: @whuber I find that in practice, I appeal to this result more frequently. By invoking the Lindeberg-Feller CLT, one does not require the residuals to be normally distributed. My next comment however, addresses your point here.  As far as generating a confidence *interval* versus a confidence ellipse (or hyper ellipse), I admit my notation is a little wonky, but I think it's clear that to generate a CI for the i-th element, one must select the i-th diagonal component from the covariance matrix as the i-th parameter variance.
Comment: I agree with everything in that comment.  The question did stipulate that $\varepsilon$ are normal, though, so it could be helpful to indicate at the outset that you're addressing both a generalization (to non-Normal errors) and a specialization (to large datasets) of the question.
Comment: @whuber great, edited.
Comment: Nice. Can you comment on the use of $t$-distributions by, e.g., R's `confint.lm`?
Comment: @Kodiologist If 1) the conditional variance is estimated from residuals, 2) the residuals are normally distributed and 3) finite sample inference is desired, then an exact CI can be obtained by using a T-distribution approximation to the sampling distribution of the $\hat{\beta}$ with degrees of freedom equal to the sample size minus the number of free parameters (for instance, with n=100 observations, p=4 covariates, the degrees of freedom would be **5** (with the intercept being the 5th "covariate").
Comment: Any idea why I'm failing to replicate `confint.lm` here? https://pastebin.com/qd8Fyqck
Comment: @Kodiologist 1) use DF correction for residual variance `sigma2 <- sum(resid(m)^2)/(length(resid(m)) - length(coef(m)))`. 2) model matrix (X) includes intercept (`X <- cbind(1,x1,x2)`).
Comment: @AdamO Thanks; I'm still getting a slightly different answer (-1.363002  and 4.396348). Is that just numerical error? The difference seems a bit too large for that.
Comment: @Kodiologist https://pastebin.com/KBkCwpUU


How to add Facebook share/like icon in Blog Entry header?

Question: I want to add a header to my "blog entry" content type that will have a couple icons for sharing with Facebook, Twitter, email, and Google +1.
How can I do this?
I currently have the icons in a block in the sidebar.
Answer: The AddToAny module lets you do this.  You choose to have the button show in the content, and then use a negative weight to float the button to the top of your content (aka the header section).
Answer: Below are some alternatives to pick from (quotes are from their project pages).
Modules with a stable D7 release:

ShareThis:

Integration with the ShareThis social bookmarking utility on selected node types.
The code for this project was based on the original share project for Drupal 5.x. The code for this project has been trimmed down to only work with the ShareThis system, and not require any additional modules to work properly.

Service Links:

Service Links facilitates the adding of social networks links or javascript buttons within the content with a special focus on developers and themers interested to extend their number or customize their displaying. Built on Drupal for Drupal doesn't include commercial advertising or spying hidden code and doesn't require third part libraries.
The services included are various: del.icio.us, Digg, Facebook/Facebook Share/Facebook Like, Furl, Google Bookmark/Google Plus One, IceRocket, LinkedIn/Linkedin button counter, MySpace, Newsvine, Reddit, StumbleUpon, Technorati, Twitter/Twitter widget, Yahoo Bookmark, and many more, they are split for language in different packages: basque, dutch, farsi, german, hungarian, italian, polish, russian, spanish, swedish.
Other services are availables to be included within an extra module which can be built easily through a web interface.

ShareBar:

The Drupal Sharebar module lets you easily add a "floating" social media submission bar on your website (like that found on Mashable) that includes share buttons for the most popular social media websites online such as Facebook, Twitter, and Google +1 Buttons.

Share Buttons by AddToAny:

Share buttons for Drupal including AddToAny's universal sharing button, Facebook, Twitter, Google+, Pinterest, WhatsApp and many more.
Large vector share buttons use AddToAny SVG sharing icons. AddToAny vector icons load efficiently, are mathematically precise, scalable to any size, and stunning on High-PPI screens such as Retina and Retina HD displays.

Easy Social:

Centered in a single place, you don't need to worry in including external javascript libraries, and enabling several social modules.
Despite a bunch of other social modules, this module fits exactly if you want simple share buttons without worrying about messy configurations.
Easy Social is available both as blocks, attached to nodes, comments and also as a Views field.

Modules with an unstable D7 release:

Follow:

Follow adds sitewide and per user links that link to various social networking sites. The links reside in two blocks. The Follow Site block lists all the links for the site itself, and by default is visible on all pages. The Follow User block lists all the follow links for the user and is visible only on user profile pages.

AddThis:

Provides an AddThis.com button or toolbox to let your users share your content to social network sites.

Social media:

The Social media module helps integrate your website with social media sites such as Twitter, Facebook and Google+. It provides an centralized way of managing social media profile information and plug-in widgets such as follow and share buttons.

Recommended resources
For additional details, refer to these articles:

Comparison of Social Network connectors/Sharing modules.
The "best" social media modules.
4 Social Sharing Modules for Drupal.
Top 5 Drupal Social Networking Modules for Bloggers.
Answer: If you mean you want it at the top of each single blog entry...
In Administration >> Structure >> Contentypes,

select the content type where you want to place the share buttons. (In your case it maight be News content type)
Go to manage display and select the display mode where you need the buttons.
You should be able to see AddToAny in the Disabled section.
Move AddToAny at the top of the enabled fields section and click on save.

If you want to be at top of the page then you will need to

Go to /admin/structure/block, Select the region where you want the buttons
Click on "Place block"
Locate AddToAny buttons
Click on Place block
In the pop up window under Visibility, you will need to configure how to relate buttons with Drupal nodes. If you wan it only under News, and guessing your path to news is /news, you could select "Pages" here and add the following two lines:
/news
/news/*
having ticked "Show for the listed pages"

I recommend you to make some tests with visibility options to understand how it works.

Click on "Save block" in the pop-up
Click on Save Blocks

Hope this helps!


Sum of open ,closed neither open and closed sets

Question: Let A and B be subsets of $R^n$ Define
$A+B=\{a+b\ |\ a\in\, A , b\in \,B\}$
Consider the sets
 $W=\{(x,y) \in\,R^2\ |\ x>0 , y>0\}
\\ X=\{(x,y) \in\,R^2\ |\ x\in\,R , y=0\}
\\ Y=\{(x,y) \in\,R^2\ |\ xy=1\}
\\Z=\{(x,y) \in\,R^2\ |\ |x|\le 1,|y|\le 1\}$
Which of the following statements are true

The Set $W+X$ is open
The Set $X+Y$ is closed
The Set $Y+Z$ is closed

Try I sincerely don't know how to proceed The answer is 1 and 3 I do know that sum of two open set is open in $R^n$ but that doesn't work over here
Answer: Here are a few hints for each one.
$(1)$ Observe that $A$ is open (Why?), that the translation of any open set is open (Why?), and
$$ W+X=\bigcup_{x\in X}(W+x). $$
$(2)$ Find a sequence in $X+Y$ convergent in $\mathbb{R}^2$, that does not converge in $X+Y$.
$(3)$  Observe that $Z$ is compact (Heine-Borel), and $Y$ is closed (Why?).  Try to show that the sum of a closed and a compact set is closed.
Answer:
Prove that $W+X=\{(x,y):y>0\}.$
For positive integer $n$ let $p_n=(-n,0)\in X$ and $q_n=(n,1/n)\in Y.$ Then $p_n+q_n=(0,1/n)$ which converges to $(0,0)$ as $n\to \infty.$ But $(0,0)\not \in X+Y$ because if $a=(x_1,0)\in X$ and $b=(x_2,1/x_2)\in Y$ then the second co-ordinate of $a+b$ is $1/x_2 ,$ which can't be $0.$
A sequence $(z_n)_n$  in $Z$ has a subsequence $(z'_n)_n$ that converges to a member of $Z.$
$\quad$   So if $(y_n)_n$ is a sequence in $Y$ and $(z_n)_n$ is a sequence in $Z,$ such that $(y_n+z_n)_n$ converges to $p$, there is a subsequence $(y'_n+z'_n)_n,$ with $y'_n\in Y$ and $z'_n\in Z,$ such that $(z'_n)_n$ converges to  $z\in Z.$
$\quad$ Now $(y'_n+z'_n-p)$  and $(z-z'_n)$ both converge to $0$ as $n\to \infty,$ so their sum  also does. Their sum is $y'_n-(p-z).$ So $y'_n$ converges to $p-z.$
$\quad Y$ is closed, so  $p-z\in Y.$ Hence, with $p-z\in Y$ and $z\in Z$, we have $p=(p-z)+z\in Y+Z.$

Remark. There are examples of two unbounded closed subsets in $\mathbb R^2$ (even in $\mathbb R$) whose sum is not closed....  Let $A=\mathbb N$ and $B=\{-n-\frac {1}{n+1}:n\in \mathbb N\}.$ So $\{-\frac {1}{n+1}:n \in \mathbb N\}\subset A+B$ but $0\not \in A+B.$....In $\mathbb R^2,$ take $A\times \{0\}$ and $B\times \{0\}.$


How do I estimate the average size of objects

Question: We have a large number of (physical) legal files, and want to get an estimate of the average number of pages per file. I do not know what distribution of pages to expect, the number of pages will range from 1 to a large finite number.
My thought is to take a number of samples, count the number of pages in those files, and then use the average from that, but how many samples should I take to get a mildly accurate answer (no more than 20% off)?
Does it matter which distribution I assume? I assume it does, but given that those files grow until they are viewed as done, at uneven rates (some letters contain more pages than others), what would most likely be the distribution to describe this?
Comment: Don't forget to give some consideration of why you want to know the average. It's often not a very useful summary of a distribution.
Answer: This is the kind of problem treated in finite population sampling theory, as presented in the book http://www.amazon.com/Finite-Population-Sampling-Inference-Prediction/dp/0471293415/ref=sr_1_1?s=books&ie=UTF8&qid=1401276486&sr=1-1&keywords=finite+population+sampling+theory
(and many others).
First of all, you will want a practical way to do the sampling!  So we will need to know how your physical files are stored!  You should also think about if they are stored in completely random order, or in some other definite order (alphabetical? chronological? what???).  A simple random sampling will often be impractical --- could be practical if you have some list of all the files in your collection, wheather that list is on a computer or on paper (and if it is practical to access the files out of order).  If the answer to that question is NO, so simple random sampling is impractical, you can use some kind of cluster or stratified sampling. You can find explanations of this and related terms here:  https://en.wikipedia.org/wiki/Statistical_sampling
Without knowing more about the practical situation, only some brief hints:  sampling could be on the level of
--- shelfes
--- drawers
or some other units in which the physical storage is organized.  You should think about questions such as:  If the storage is is say, chronological order, might there be some trend in document size with time? Or some cyclical variation, that is , in some parts of the year, documents of a specific type are produced, which typically differs in length?
We can help more if you tell us more about the situation!
(Then, depending on the sampling plan choosen, there will be some specific formulas/methods to use to construct estimates and confidence intervals)
Answer: An interval for the mean will
(i) be probabilistic - that is, with random sampling, you could compute a mean that's no more than 20% off 99% of the time (or some other percentage) -- but not 100% unless your sample is your population.
(ii) depend on the standard deviation of the number of pages; since this will be unknown, you'll need some information about that (perhaps an upper bound, perhaps an estimate from a pilot sample) before you can calculate an estimate of the required sample size.
Answer: I would explore graphically the population by construncting some random samples of documents from your repository, then plot histograms of the number of pages for each document in the sample.
If the distributions do not resembles like a normal distribution, the mean alone is not so informative (as said in comments) and maybe you should need to estimate higher order moments like variance, kurtosis and skewness.
Another good tool to get a feel of the distributions are boxplots.
If data does not fit any theoretical distribution, you can still estimate these moments at some confidence interval by bootstrap.
Comment: I disagree that mean alone is non-informative for non-normal distributions. Consider Poisson.


For any real matrix $M$ let, $\lambda^{+}(M)$ be the number of positive eigenvalues of $M$ counting multiplicities.

Question: For any real matrix $M$, let $\lambda^{+}(M)$ be the number of positive eigenvalues of $M$ counting multiplicities. Let $A$ be an $n\times n$ real symmetric matrix and $Q$ be an $n\times n$ real invertible matrix . Then which of the followings are correct?
(1) $rank(A)=rank(Q^{T}AQ)$
(2) $rank(A)=rank(Q^{-1}AQ)$
(3) $\lambda^{+}(A)=\lambda^{+}(Q^{T}AQ)$
(4) $\lambda^{+}(A)=\lambda^{+}(Q^{-1}AQ)$
Comment: We know the rank of A and Q^TAQ are same. But what is the similarities of the number of positive eigen values between A and Q^TAQ?
Answer: From option 3 we can see that the given matrices are congruent and by Sylvester's law of inertia two congruent symmetric matrices have the same number of positive/ negative eigen values. For option 4, here two matrices are similar and so have same eigen values.
Answer: We assume $A$ is symmetric so we can find an orthonormal basis of eigenvectors $v_{1}, . . . ,v_{n}$ with
eigenvalues $\lambda_{1}, . . .,\lambda_{n}$. Let $P$ be the orthogonal matrix formed by putting the $v_{j}$ as the columns. Then
$P^{T}AP=D$ is the diagonal matrix with entries $\lambda_{1}, . . .,\lambda_{n}$. Setting
$x=y_{1}v_{1}+ · · · + y_{n}v_{n}=Py$,
the quadratic form turns into a sum of squares:
$$Q(x)=x^{T}Ax=y^{T}P^{T}APy=y^{T}Dy=\sum_{j=1}^{n}\lambda_{j}y_{j}^{2}.$$
From this representation, it is clear that $Q$ is positive definite if and only if all the eigenvalues are positive,


change data structure of pandas dataframe

Question: I have this sample data...
import pandas as pd

from StringIO import StringIO

stock_list="""EAN code, name, stock
, MONIN Syrups,
12345, Monin Mojito Mint Syrup 250 ml, 100
, BONNE MAMAN,
7890. Bonne Maman Strawberry Preserve 370g, 200
6543, Bonne Maman Raspberry 370g, 150"""

audit = pd.read_csv(StringIO(stock_list), sep="," )

If the EAN code is "Not A Number" then it is actually the product type. So the product name "MONIN syrups" should be moved to type column for the following products till the next NaN.
The final list will look something like this...
expected_list="""type,  EAN code,   name,   stock
MONIN Syrups,   12345,  Monin Mojito Mint Syrup 250 ml, 100
BONNE MAMAN,    7890,   Bonne Maman Strawberry Preserve 370g,   200
BONNE MAMAN,    6543,   Bonne Maman Raspberry 370g, 150"""

pd.read_csv(StringIO(expected_list), sep="," )

How do I take the current "stock_list" dataframe and change it such a way that it will look like expected_list?
Answer: Copy name column to type column, clear elements to NaN and ffill() it:
import pandas as pd

from io import StringIO

stock_list="""EAN code, name, stock
, MONIN Syrups,
12345, Monin Mojito Mint Syrup 250 ml, 100
, BONNE MAMAN,
7890, Bonne Maman Strawberry Preserve 370g, 200
6543, Bonne Maman Raspberry 370g, 150"""

audit = pd.read_csv(StringIO(stock_list), sep=",", skipinitialspace=True)

audit["type"] = audit["name"]

mask = ~audit["EAN code"].isnull()
audit.loc[mask, "type"] = np.nan
audit["type"].ffill(inplace=True)
res = audit.loc[mask].reset_index(drop=True)
print(res)

output:
   EAN code                                  name  stock          type
0   12345.0        Monin Mojito Mint Syrup 250 ml  100.0  MONIN Syrups
1    7890.0  Bonne Maman Strawberry Preserve 370g  200.0   BONNE MAMAN
2    6543.0            Bonne Maman Raspberry 370g  150.0   BONNE MAMAN


php: Does memory_limit setting influence running time / speed?

Question: If I increase php memory_limit could that increase the speed of a process?
Or if there is more memory allowed than needed the extra resource will not be used by the system to increase speed of the current process?
Comment: Dude, whoever downvoted it explain why. Lame troll.
Answer: No, it will not improve the performance. This is just a limit on the maximum allowed memory consumption of a php script. If your script tries to exceed this limit, you will get an error.


Manifold has a countable cover by compact sets.

Question: I was confused by Boothby's proof that a Manifold had a countable cover of compact sets. In his proof he says that as $M$ has a countable basis of open sets, we may assume that $M$ has a countable basis of relatively compact open sets $\{V_i\}$. I don't see why this is true. I don't know how to go about proving it. I've tried to come up with counter examples, but obviously I've failed (as the claim is true). I know I could prove it, if I could show that for each $(U,\phi)$ a coordinate chart there existed a basis element $B\subseteq U$, but can we show that? Any hints or help proving this?
I did look at some of the similar questions to my title, but I didn't understand them. For example, here
Does every manifold can be "covered" by compact sets?
The answer says we can cover the manifold by a countable collection of subseteq homeomorphic to $\mathbb{R}^n$. I know we can cover it by such sets, as we can take a coordinate chart and shrink so that it is homeomorphic to an open ball, which is in turn homeomorphic to $\mathbb{R}^n$, but I don't know why countable.
I would be able to prove the claim if I could verify the statement given here
https://mathworld.wolfram.com/TopologicalBasis.html
that:
"A topological basis is a subset B of a set T in which all other open sets can be written as unions or finite intersections of B. For the real numbers, the set of all open intervals is a basis."
But I don't see why that follows from the axioms they listen.
If anyone could provide any help it would be much appreciate, thank you.
Answer: Each point of $M$ has an open nbhd homeomorphic to $\Bbb R^n$ for some $n\in\Bbb N$. $\Bbb R^n$ is locally compact, so each point of $M$ has a local base of relatively compact open sets, and therefore $M$ has a base of relatively compact open sets. $M$ has a countable base, so by the result that I proved here it has a countable base of relatively compact open sets.
Comment: Forgive me for being ignorant, but why is $\bigcup \mathcal{B}(W)=W$? How do we know that we can choose $B\in\mathcal{B}$ such that $B\subseteq W$? Let along how do we know such $B$ cover $W$? Is there some condition on Base I'm not understanding, because I don't see how it follows from the two base axioms.
Comment: @Melody: Since $\mathscr{B}$ is a base for the topology, by definition every open set is a union of elements of $\mathscr{B}$. In particular, then, it must be the union of all of the members of $\mathscr{B}$ contained in it.
Comment: Thank you, I guess I was misreading the page here

https://mathworld.wolfram.com/TopologicalBasis.html

It doesn't list that every open set is a union of of basis elements as one of the two axioms it gives, but I'll take your word for it. Thank you very much.
Comment: @Melody: You're welcome. It doesn't list that as an axiom, but it mentions it in the first sentence. Those axioms are not the best way to think about a base for a topology: it's much better to think of it as a subset of the topology whose unions generate the whole topology.


unix logrotate specify chunk size

Question: How can I specify output file size which I want after rotation? For example lets say I want to run logrotate when log file reaches 10MB and I want to split this log into chunks which are 1MB max. I have found options "size" but this sets limit above which logrotate is run and not the size of desired chunk. Thanks
Answer: logrotate by itself doesn't support the splitting of the rotated log/s, only compression.
You may be able to get the desired behaviour by writing a script of your own that handles the splitting, and call that as a postrotate script in your logrotate configuration for that particular file/s.
update: based on your comment ("it is too late to split files, because they will be splitted by logrotate"), it seems you still have the idea that logrotate is doing splitting of files. This isn't correct, what actually happens is that logrotate renames the existing file and creates a new empty file with the original name.
An example:
<code>/var/log/syslog
{
        rotate 7
        daily
        missingok
        notifempty
        delaycompress
        compress
        postrotate
                reload rsyslog >/dev/null 2>&1 || true
        endscript
}
</code>
When logrotate runs:

it renames /var/log/syslog to /var/log/syslog.1
it then creates a new empty file /var/log/syslog.
renaming a file has no effect on any processes that had an open file handle, so after doing this, the rsyslog process is still writing to the old file, syslog.0. Typically, the way to get around this is to reload the process/es that write to the file, which is what happens in the postrotate script. rsyslog is told to reload, it closes its existing file handle to /var/log/syslog.0, and opens a new file handle using the filename /var/log/syslog, the new empty file created by logrotate.

Hopefully you have a better understanding of what logrotate is doing now.
update 2: I'll address your comments here, as formatting options in the comments section are limited.

So when I understand right in the post processing part it is necessary to reload rsyslog to enshure that old file descriptor (before rotation) will be closed and new file descriptor (after rotation) will be opened (because of: mv syslog syslog.1)?

100% correct. After logrotate moves the file, rsyslog is still writing to the old file descriptor. A process performs I/O on the file descriptor, the name is only of interest when performing the initial open on the file.

I thought that logrotate has some mechanism to achieve this automatically.

No, hence the need to do it in a postrotate script. Remember that not all logging is necessarily done by a process which keeps an open file descriptor. If you have a process which opens a file, writes to it and then closes (the file descriptor) repeatedly, then you needn't fuss with anything in the postrotate.

PS: Did you mean "syslog.0" not "syslog" in the following senetence: "the rsyslog process is still writing to the old file, syslog.0."? Becuse "old" log is /var/log/syslog not /var/log/syslog.0. Thank you

No. I mean that it's still writing to the existing file descriptor, which logrotate has renamed to syslog.0. When dealing with processes like rsyslog, always remember that the file name is only relevant at the point when rsyslog opens it, i.e. when it creates the file descriptor. After that you can rename, move, even delete the file, and the process continues performing I/O on the file descriptor unhindered.
Comment: I do not understand you well. How can I write postprocessing script which handles the splitting? I need to split files first and then compress them. When logrotate is done it is too late to split files, because they will be splitted by logrotate. Or am I missing something, what is the basic idea of logrotate? It just compress files after they reaches specific size and renames them to {file}.0.log (very basic overview)? I have read several tutorials about logrotate but now I am a little bit confused.
Comment: I updated my answer with some more info, hope it clears up the confusion.
Comment: So if I understand right in the post processing part it is necessary to reload rsyslog to enshure that old file descriptor (before rotation) will be closed and new file descriptor (after rotation) will be opened (because of syslog was moved to syslog.1 and syslog was created and thus is in fact new file)? I thought that logrotate has some mechanism to achieve this automatically. PS: Did you mean "syslog.0" not "syslog" in the following senetence: "the rsyslog process is still writing to the old file, syslog.0."? Becuse "old" log is /var/log/syslog not /var/log/syslog.0. Thank you
Comment: One more note: is it safe to move file on which is opened file descroptor? In unix terminology I hope that logrotate did not do "mv syslog syslog.0 && touch syslog" but rather "cat syslog > syslog.0 && echo > syslog", is the reload of rsyslog needed in this case? Thank you
Comment: One more question: Does logrotate somehow tracks the changes of the log so it is smart enought to know that if it was no change from last time logs was rotated there is no need to do it again?
Comment: I addressed your questions in my answer, since the comments section is quite limited.
Comment: Thank you for reply, can you please clarify how files are moved (my 3rd comment, I have several times edited comments last time, sorry for that). For clarification in your reply "100% correct. After logcheck moves the file," what does logcheck to do with logrotate? It is something completely different AFAIK.
Comment: One more note: logrotate does have option called "copytruncate" which will preserve the original file name, I think what it does is something like that was described in my 3rd comment. If it was not that way there may be serious problems with deleted files and opened file descriptors which may cause the full of file system, correct me if I am wrong. Thanks for all help.
Comment: Sorry, not I meant logrotate, not logcheck. I had a brainfart. :-) They way it moves the file is pretty much the same way 'mv' works. 'copytruncate' does work the way you described, but depending on the volume of logging, you run the risk of losing lines in your log. This is mentioned in the logrotate man page. Yes, you can run out of space if you use the default method of rotation and do not take care to clean up in a postrotate script (unless you opt to use 'copytruncate' which avoids the problem).

unix logrotate specify chunk size


When to use a custom model manager?

Question: Right now i'm reading about custom managers that you can use to add additional logic when doing a CRUD action like Create. You make a custom manager class and then initialize the objects attribute of the table class with an instance of the custom manager class.
I've also read that you can also use the pre_save and post_save signals to add additional save logic to the save action. My question is: When should i use a custom manager class over signals and is the use of a custom manager slower then the default manager of the Model class?
Thank you
Comment: When you (nearly) always want to filter/annotate/...
Comment: what do you mean with filter/annotate?
Comment: You have a `Book` with a ForeignKey to an `Author`. You define the Book manager such that all queries com back annotated with `author_name` which is more efficient than referring to `author.name`.
Comment: @nigel222 can you give a code example of what your trying to say? thx
Comment: @FAM_Maurice OK see my answer
Answer: OK, here's one I wrote earlier. I've cut out a lot of irrelevant stufff, hoping all the essentials remain.  You need to know there's a Foreign Key chain PRSBlock -> PRS2 -> Jobline -> Description. Using this, all queries for PRSBlock.objects.filter(... will return PRSBlock objects with extra fields membrane_t, substrate_t and material from the Description found by following this chain. They're almost always needed in this context, unlike most of the other things along that chain. select_related would be serious overkill.
class PRSBlock_Manager(models.Manager):

    def get_queryset(self):
        return super().get_queryset().annotate(
            membrane_t = F('PRS__jobline__description__mt'),
            substrate_t= F('PRS__jobline__description__ft'),
            material   = F('PRS__jobline__description__material')
        )

class PRSblock( models.Model):

    # override the default manager
    objects=PRSBlock_Manager()  # annotate always with description parametrs relevant to block LUTs

    PRS = models.ForeignKey( PRS2, models.CASCADE, related_name='prs_blocks')
    # and lots of other fields that aren't relevant

When to use a custom model manager?


Clarification on creating Objects

Question: This question might be a very simple question, but I am still kind of new to programming so please bear with me.
If I have for example a class name picture and another class name simplePicture.
Can I create a new object as: Picture a = new simplePicture();
So can I create an object using the constructor of another object? And if possible, how is that possible?
Answer: You can do that if SimplePicture has been defined with the words extends Picture after the name.  That would make SimplePicture a subclass of Picture, which means that any SimplePicture is also a Picture, and that therefore all objects of class SimplePicture can be referred to with a variable of type Picture.
public class SimplePicture extends Picture {
    // ... put things here that are specific to SimplePicture
}

Comment: There was a type mismatch. So that means not possible.
Comment: So I am guessing that if picture extends simplePicture, the object cannot be created the other way around.
Comment: Why don't you try it and see?
Answer: Basically it is only possible when there is a hierarchy.
 class SimplePicture extends Picture{

 }

Clarification on creating Objects


Practical Limits of Configuring WLAN SSIDs via Group Policy on Windows 7

Question: Is there a practical limit to the number of SSIDs that can be configured on a single WLAN profile via Group Policy on Windows 7? I am thinking about hundreds of SSIDs in a single WLAN profile.
Background info:
We are deploying a fleet of 4G mobile hotspots with unique SSIDs and passwords on them. We would like to use Group Policy to limit WiFi on our Windows 7 laptops, so that they can only connect to these pre-authorized corporate mobile hotspots, as described here. All of the SSIDs are configured to begin with the same prefix, but it appears that Group Policy on Windows 7 requires us to specify each unique SSID individually. That's fine, but wondering if configuring hundreds of unique SSIDs will have some negative effect on performance, or the user experience in any way. Most users will only have a password configured on their personally assigned hotspot, so if any of the others come within range they will hopefully not try to connect since a password will not have been set.
Answer: The defined limit on SSIDs per WLAN profile for XP and Windows 7 appears to be 256, per the version 1 WLANProfile XML schema defined here:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms707359%28v=vs.85%29.aspx
With Windows 8.1 (version 2 of the XML schema) it will allow up to 10,000 SSIDs per profile, as noted here:
http://msdn.microsoft.com/en-us/library/windows/hardware/dn408663.aspx


Invalid input data. Please verify unique constraints Strapi

Question: I'm trying to add a product data in my Strapi product, but sometimes it shows "Invalid input data. Please verify unique constraints" errors. Anyone have dealt with this before?
I got {statusCode: 400, error: "Bad Request", message: "Invalid input data. Please verify unique constraints"} in my console.
Answer: This happened to me due to mismatch in package versions. The ultimate solution that worked for me was to upgrade the package to 3.5.x.
More details here: https://github.com/strapi/strapi/issues/9369
Comment: Hello, my version right now is 3.5.0, so I should just upgrade?
Comment: Yes, go ahead and update it to the latest version. That would probably fix the issue.
Answer: This happened to me because I was missing const axios = require('axios'); in some of my model files. I did webhooks myself for each model using axios to send a POST request.
Try npm run strapi console It was very helpful. It did show an erorr in a console with enough info, as I tried to update a field in a single type.
Maybe you missing something in your model/service/controller. Strapi console will reveal it, hopefully.
Answer: If this is in the context of lifecycle hooks, I got this error while trying to do one in v3.
My mistake was not adding another parameter to the beforeUpdate method
Before :
async beforeUpdate(data) {
  console.log(data);
  data.ImageUrlTest = "testurlimage";
},

After:
async beforeUpdate(params, data) {
  console.log(params);
  data.ImageUrlTest = "testurlimage";
},

Answer: I ran into this same issue today. The "Invalid input data. Please verify unique constraints" displayed on the frontend seems to be a catch-all message and isn't always indicative of a unique constraint issue.
In my case, it was because the value I was trying to enter in a particular field was longer than the fields max length.
We had the data type Short text selected for the field, but the particular value I was trying to save when the error occurred was 283 chars long.
You might find your issue to be a similar DB error being masked by the generic error message as well.
I was able to find this error by reading the Strapi server logs - this revealed the actual error message value too long for type character varying(255)
1|strapi-dev  | [2023-02-22T19:07:19.844Z] error error: insert into "components_resources_content_resource_sections" ("sectionBodyRichText", "sectionVideoUrl") values ($1, $2) returning * - value too long for type character varying(255)
1|strapi-dev  |     at Parser.parseErrorMessage (/home/ec2-user/content-creation-service/app/node_modules/pg-protocol/dist/parser.js:278:15)
1|strapi-dev  |     at Parser.handlePacket (/home/ec2-user/content-creation-service/app/node_modules/pg-protocol/dist/parser.js:126:29)
1|strapi-dev  |     at Parser.parse (/home/ec2-user/content-creation-service/app/node_modules/pg-protocol/dist/parser.js:39:38)
1|strapi-dev  |     at Socket.<anonymous> (/home/ec2-user/content-creation-service/app/node_modules/pg-protocol/dist/index.js:10:42)
1|strapi-dev  |     at Socket.emit (events.js:315:20)
1|strapi-dev  |     at Socket.EventEmitter.emit (domain.js:486:12)
1|strapi-dev  |     at addChunk (_stream_readable.js:309:12)
1|strapi-dev  |     at readableAddChunk (_stream_readable.js:284:9)
1|strapi-dev  |     at Socket.Readable.push (_stream_readable.js:223:10)
1|strapi-dev  |     at TCP.onStreamRead (internal/stream_base_commons.js:188:23)
1|strapi-dev  | From previous event:
1|strapi-dev  |     at Child.<anonymous> (/home/ec2-user/content-creation-service/app/node_modules/bookshelf/lib/model.js:1160:42)
1|strapi-dev  | From previous event:
1|strapi-dev  |     at Child.<anonymous> (/home/ec2-user/content-creation-service/app/node_modules/bookshelf/lib/model.js:1159:14)
1|strapi-dev  |     at processImmediate (internal/timers.js:461:21)
1|strapi-dev  | From previous event:
1|strapi-dev  |     at Child.<anonymous> (/home/ec2-user/content-creation-service/app/node_modules/bookshelf/lib/model.js:1060:10)
1|strapi-dev  | From previous event:
1|strapi-dev  |     at runCreate (/home/ec2-user/content-creation-service/app/node_modules/strapi-connector-bookshelf/lib/queries.js:113:45)
1|strapi-dev  |     at wrapTransaction (/home/ec2-user/content-creation-service/app/node_modules/strapi-connector-bookshelf/lib/queries.js:52:29)
1|strapi-dev  |     at create (/home/ec2-user/content-creation-service/app/node_modules/strapi-connector-bookshelf/lib/queries.js:120:12)
1|strapi-dev  |     at Object.create (/home/ec2-user/content-creation-service/app/node_modules/strapi-connector-bookshelf/lib/queries.js:58:20)
1|strapi-dev  |     at fn (/home/ec2-user/content-creation-service/app/node_modules/strapi-database/lib/queries/helpers.js:31:54)
1|strapi-dev  |     at Object.create (/home/ec2-user/content-creation-service/app/node_modules/strapi-database/lib/queries/helpers.js:15:24)
1|strapi-dev  |     at async Promise.all (index 0)
1|strapi-dev  |     at async updateComponents (/home/ec2-user/content-creation-service/app/node_modules/strapi-connector-bookshelf/lib/queries.js:408:13)
1|strapi-dev  |     at async runUpdate (/home/ec2-user/content-creation-service/app/node_modules/strapi-connector-bookshelf/lib/queries.js:146:7)


Should I expect Google App Engine to randomly restart instances?

Question: I had one instance of the app (shame on me), running in the australia-southeast1 region yesterday.
Last night was a critical time for the app; people were relying on it working flawlessly, and then halfway through the event, the instance just disappeared. About 8 minutes later, a new instance was created and continued to serve traffic.
Is this something I should expect? Instances randomly disappearing and restarting? I realise I should have had a couple of versions running, but what if both versions restart at the same time?
The logs don't show any errors at the point the app (a standard, simple Rails app) restarts. The logs just have an 8 minute gap, followed by Puma booting up in the new instance.
CPU usage was constant, and rarely above about 5%. Memory usage was around 840MB, with a slight peak of 880MB just before the restart. "Disk Bytes" was a constant ~15KB/sec, with a large spike of 40MB/sec around the time of the restart.
app.yaml
<code>entrypoint: bundle exec rackup -p $PORT
env: flex
runtime: ruby

handlers:
- url: .*
  script: main.app
  secure: always

automatic_scaling:
  min_num_instances: 1
  max_num_instances: 4
  cpu_utilization:
    target_utilization: 0.75
</code>
Comment: Could you share your `app.yaml`? When you say"I realise I should have had a couple of versions running" you probably mean instances. I would recommended to [have more than one instance at all times](https://cloud.google.com/appengine/docs/flexible/ruby/reference/app-yaml#services) to provide some continuity.
Comment: It is however strange that number of instances goes below 1. How long does it take to spin up one of your instances?
Answer: According to the documentation there are 2 main reasons for an unexpected restart:

Instances restarted on a weekly basis [1].
A health check giving an HTTP code different from 200 [2].

If you provide some additional info we can discuss it.
Answer: Similar problem with me; new health checks do not check the application, only the VM and Docker (unless you set them up to check your application, which I have not), and so it seems pretty clear that the problem is with app engine itself.
Edit: Unsure why the neg, but to make this more clear.
Yes, you should expect them to randomly restart instances.  The behaviour you're seeing is not due to your app.


javascript: fadeout but clickable

Question: I'm building an JQM app and I'm having a few JS problems which im sure are quite easy to fix but I dont know much JS.
1) I'm placing divs on top of an image which links to over images. So when the app loads the divs are visible and then they fadeout. The problem is I want them to still be clickable and link to the other images when they are invisible.
CODE
 setTimeout(function () {

        $(".link").fadeIn(3000);

        $(".link").fadeOut('slow');
    }, 2000 /* Time to wait in milliseconds */);

    setTimeout();

Simple but I want to just make them not viewable and keep the link.
2) my second problem is I have a sound file that plays onload and two images that turn the sound file on and off. The code I made will only change the image on the home page and will not work on any other page (turning the sound on and off works but the image wont change)
CODE
 function playSound() {
    sound.play();
}

sound.play();
newsrc  = "soundOff.png";

function changeImage() {

    if ( newsrc == "soundOff.png" ) {
        document.getElementById("sound").src = "img/soundOff.png";
        document.getElementById("sound").alt = "Sound Off";
        newsrc  = "soundOn.png";
        sound.pause();
    }

    else {
        document.getElementById("sound").src = "img/soundOn.png";
        document.getElementById("sound").alt = "Sound On";
        newsrc  = "soundOff.png";
        sound.play();
    }
};

Comment: The [animate](http://api.jquery.com/animate/) function might be better than `fadeOut` for you: `$('.link').animate({opacity: 0}, 2000, callback);` This way, `.link` is still present, just not visable. Also, if you're using jQuery, your `document.getElementBy...` stuff should probably be replaced with `$('#sound').attr('src')` and similar
Comment: Can you give us a [JSFiddle](http://jsfiddle.net) for some of this?
Answer: From the jQuery manual:

The .fadeOut() method animates the opacity of the matched elements. Once the opacity reaches 0, the display style property is set to none, so the element no longer affects the layout of the page.

If you set the display property back to inline or block after the fadeOut() is finished, the elements will remain clickable. You can do this using the complete paramater of fadeOut(). Something like this should work:
$(".link").fadeOut('slow', function(){
    $(".link").css({"display":"inline"});
});

Answer: When .fadeOut is complet element display is none and not clickable. You should change element display property and hide it by visibility property. I would do that this way:
$(".link").fadeOut('slow', function(){
    //animation complete callback
    $(this).show().css('visibility', 'hidden');
});

Comment: The opacity should already be 0 so there is no need to hide it again with `visibility`. Should work fine either way tho
Comment: yeah, that's true, but when you change `display` manually, you lose old `display` value, that was set before fading element out.

javascript: fadeout but clickable


markup that allows overlap

Question: How do I make my footer allow overlapping with other markup?

I have defined my footer to show page numbering:
\paper {
  oddFooterMarkup = \markup
    \fill-line { "" \on-the-fly #print-page-number-check-first \fromproperty #'page:page-number-string }
}

And I have a page that is completely full with markup (vertically). I added a \box for the footer and the last line of the stanza just for the picture, to show how full it is:

In order to keep the page number, I need to move it upwards (else it will be cropped away by the book printing service). But if I just add some vertical space below my footer, like this
oddFooterMarkup = \markup
  \column {
    \fill-line { "" \on-the-fly #print-page-number-check-first \fromproperty #'page:page-number-string }
    \null % or \vspace #1.0
  }

, then it will overlap with the stanzas markup and mess up everything (since there is no space to evade to). Again I added a \box before the footer just for the picture:

So I need a way to tell my footer that it's okay to overlap with other markup. Or alternatively, make the area that it occupies smaller - it doesn't really need the whole width of the page, it'd be okay if the \box would just be around the page number (and the space below it).
Answer: I'm not sure if this will do what you want, but I would suggest trying the \with-dimensions markup command. So instead of using
\markup\fill-line{... your footer here ...}

for your footer markup, I would try
\markup\with-dimensions #'(0 . 0) #'(0 . 0) \fill-line{... your footer here ...}

It should essentially tell Lilypond that the markup takes up zero space in both X and Y directions, but I'm not sure if it will do what you want, and I don't have the time to test it. Let me know whether it worked.
Comment: I used `\with-dimensions #'(0 . 0) #'(-2.1 . 0)` which moved the footer upwards to a position that is alright to me. The `\box` around the footer has still the full width as before, and if I change to `-2.2` or less, the page gets messed up as well. So it seems that your solution does not allow overlap in general. But it solved my actual problem, so I'm happy! (I don't mark it as the correct answer (yet) because I'd like to wait if someone knows a way to explicitly make overlap possible.)

markup that allows overlap


How can I implement another class into my JavaFX GUI?

Question: I've been working on a small adventure game as a final project for my AP Java class for a while now, and I've been trying to implement the classes that I made for the JavaFX GUI that I had built with Scene Builder.
But for some reason, the GUI refuses to recognize my method startAdventure(), in the Adventure class, which basically starts the whole thing. The GUI is launched, but it does not display properly what it is told to display in startAdventure().
startAdventure() appears not to be called at all until after the GUI is closed, resulting in a null pointer exception as startAdventure() is supposed to manipulate Text Area's and such in the GUI.
I apologize in advance if I am not providing enough information, not understanding suggestions, etc. I am a little challenged when it comes to coding, and I am completely new to posting stuff on this site.
Here is how the beginning of startAdventure() looks in my Adventure class (text and inputText are properly initialized variables from my AdventureGUI.fxml file, which was made using Scene Builder):
public void startAdventure()
{
    //welcome user
    text.setText("Welcome to the land of euphoria!" + "\n");
    //gets users name
    text.appendText("What's your name?" + "\n");
    p.playerName = inputText.getText();
    text.appendText("Welcome, " + p.playerName + "\n");

    //sets start location
    p.setNewLoc("START");

And here is how my main class looks:
public class RunAdventure extends Application
{

@Override
public void start(Stage primaryStage) throws Exception
{

    Parent root = FXMLLoader.load(getClass().getResource("AdventureGUI.fxml"));
    primaryStage.setScene(new Scene(root, 600, 600));
    primaryStage.setTitle("Adventure");
    primaryStage.show();
}

public static void main(String[] args)
{
    Adventure game = new Adventure();
    launch(args);
    game.startAdventure();
}
} //end class

If it were working properly, the GUI would launch and inside the Text Area, it would display text beginning with "Welcome to the land of euphoria!".
However, in its present state, the GUI is launched and has no text at all in the Text Area.
Once again, new to everything here, so let me know right away if you think there is something else you need me to show to assist the suggestion process.
Edit: When I attempted to change the order of where game.startAdventure() was, by putting it right before primaryStage.show() in the start method, a long list of exceptions occurred.
Here is the change I made:
   @Override
    public void start(Stage primaryStage) throws Exception
    {

        Parent root = FXMLLoader.load(getClass().getResource("AdventureGUI.fxml"));
        primaryStage.setScene(new Scene(root, 600, 600));
        primaryStage.setTitle("Adventure");
        Adventure game = new Adventure();
        game.startAdventure();
        primaryStage.show();
    }

And here are the exceptions that occurred:
Exception in Application start method
Exception in thread "main" java.lang.RuntimeException: Exception in Application start method
    at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:894)
    at com.sun.javafx.application.LauncherImpl.access$000(LauncherImpl.java:56)
    at com.sun.javafx.application.LauncherImpl$1.run(LauncherImpl.java:158)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException
    at Classwork.FinalExamProject.Adventure.startAdventure(Adventure.java:102)
    at Classwork.FinalExamProject.RunAdventure.start(RunAdventure.java:24)
    at com.sun.javafx.application.LauncherImpl$8.run(LauncherImpl.java:837)
    at com.sun.javafx.application.PlatformImpl$7.run(PlatformImpl.java:335)
    at com.sun.javafx.application.PlatformImpl$6$1.run(PlatformImpl.java:301)
    at com.sun.javafx.application.PlatformImpl$6$1.run(PlatformImpl.java:298)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl$6.run(PlatformImpl.java:298)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)

I should also mention that the Adventure class does also serve as a controller
EDIT (5/20): Alright, I have gotten most everything working in my program, but I am now running into a new issue. In my adventure, I have a function that allows the player to battle various monsters if they are in a given location. My problem is that once I get to this location in my program, the program stops responding. After doing some debug, I figured out that it was a while loop I had that does everything in the doBattle() method while player.isAlive and enemy.isAlive. The only problem is, once I remove the while loop, the program just jumps right to after either the monster is dead or the player is dead, whereas it's supposed to give you the choice on whether to attack the monster or not repeatedly until either entities are dead. I know I'm cramming way too much stuff into this question, but I don't know where else to put it, and so far I have gotten overwhelming support from everyone here. I cannot thank you people enough, but I have no idea how to solve this on my own.
Here is the code of the doBattle() method:
public void doBattle(Monster enemy)
    {
        //boolean fled = false;
        //Greets player into battle by telling what monster they are fighting
        text.appendText("\n" + "A wild " + enemy.getName() + " has appeared!" + "\n" );
        mobImagePane.setImage(enemy.getImage());

        //System.out.print("THIS RAN"); //debug

        while ( p.getHealth() > 0 && enemy.getHealth() > 0 ) //while enemy and player are alive
        {
            //Prompts user to attack or run
            text.appendText("Attack " + enemy.getName() + "? (Y/N) " + "\n");
            inputText.setOnAction(event ->
            {
                String fightChoice = inputText.getText();
                fightChoice = fightChoice.toUpperCase();
                //String fightChoice = this.choice;

                if (fightChoice.equals("Y"))//if they want to fight
                {
                    //Player turn
                    enemy.setHealth(enemy.getHealth() - p.getDamage()); //Sets the monsters health as their current health minus the players damage
                    text.appendText("You attack " + enemy.getName() + " for " + p.getDamage() + " damage!" + "\n" + "Enemy health is " + enemy.getHealth() + "\n");

                    //Monster turn
                    p.setHealth(p.getHealth() - enemy.getDamage()); //Sets the players health as their current health minus the monsters damage
                    text.appendText("The " + enemy.getName() + " hit you for " + enemy.getDamage() + " damage!" + "\n" + "Your health is " + p.getHealth() + "\n"); //prints how much damage the monster does to the player
                    if (p.health < 20.0) {
                        text.appendText("Your health is low, you should return home and restore health!" + "\n");
                    }

                    //checks if the player or monster is dead
                    this.checkLife();
                    enemy.checkLife();

                } else {
                    if (fightChoice.equals("N")) // if they don't want to fight
                    {
                        mobImagePane.setImage(null);
                        text.appendText("You fled from the fight!" + "\n");
                        this.setNewLoc("TOWN"); // brings you back to town
                        fled = true;
                        //JOptionPane.showMessageDialog(null, "You are now in " + this.currentLoc.getName() + "\n" + this.currentLoc.getDescription());
                        //String move2 = JOptionPane.showInputDialog(null,"Which way do you want to go? (N, E, S, W)");
                        //makeMove(move2);
                        //break;
                    } else // they don't make any sense
                    {
                        text.appendText("Unrecognized command" + "\n");
                    }
                }

                //}

                //when someone dies
                if (!fled) {
                    if (p.alive) // if you are still standing
                    {
                        //print results (money earned, health remaining)
                        mobImagePane.setImage(null);
                        p.wallet += enemy.getLoot();
                        playerInfo.setText(p.getPlayerName() + "\n" + "Health: " + p.getHealth() + "\n" + "Wallet: " + p.getWallet() + "\n");
                        text.setText("You shrekt the " + enemy.getName() + "\n" + "You got $" + enemy.getLoot() + " for winning!" + "\n" + "You now have $" + p.wallet + "\nYour health is " + p.getHealth() + "\n");
                    } else //if you died
                    {
                        mobImagePane.setImage(null);
                        text.setText("You have been shrekt by the " + enemy.getName() + "\n" + "GAME OVER" + "\n");
                        text.appendText("\nPlay again? (Y/N)" + "\n");
                        inputText.setOnAction(event2 -> {
                            String answer = inputText.getText();
                            answer.toUpperCase();
                            //String answer = this.choice;

                            if (answer.equals("Y")) //if they want to play again
                            {
                                text.appendText("Alright! Let's go!" + "\n");
                                this.reset();
                            } else //if they want to quit
                            {
                                text.appendText("Wow. What a skrub, okay bye." + "\n");
                                System.out.close();
                            }
                        });

                    }
                }
            });
        }
    } //end doBattle

Comment: have you tried placing the `game.startAdventure();` instruction before `launch(args);`?
Answer: (Some of) the things that are going wrong and how to fix them
As coded, your startAdventure() method isn't being called until after the JavaFX system has been shutdown, which is obviously not what you want.
The launch method javadoc states:

The launch method does not return until the application has exited, either via a call to Platform.exit or all of the application windows have been closed.

You are invoking startAdventure() at the wrong time, you should invoke it in your application's start() method rather than after the launch() method call.
game.startAdventure();
primaryStage.show();

Additionally, the Java launcher creates an instance of your application, so you don't need to create one explicitly.  Read up on the JavaFX application lifecycle to understand this process.  So your main method should be:
public static void main(String[] args) {
    launch(args);
}

Some speculation on my part
Additionally, your creation of a new Adventure() is a bit suspect, though it is difficult to say for sure without further code supplied.  Adventure might be a controller, so perhaps you don't need to create a new Adventure object at all, but can instead get the controller from the loader as outlined in:

Passing Parameters JavaFX FXML

And, if it is a controller, then the code to start the adventure could occur in the initialize() method of the controller, which will be automatically invoked by the FXMLLoader.
Eventually as the application grows, it may be beneficial to create an MVC style approach, where your Adventure class is just model data and logic which is passed into an AdventureView which is a controller that wires the model and the FXML view together.  Though discussion of detailed techniques on how to accomplish that is outside the scope of this answer, you might get some ideas from the passing parameters answer linked earlier.
Answers to additional follow-up questions

text and inputText are properly initialized variables from my AdventureGUI.fxml file, which was made using Scene Builder

Variables in your instance of the Adventure class will not be initialized by the FXMLLoader if you create your adventure class using new, instead the FXMLLoader will create it's own instance of Adventure and initialize that, and that will be separate from the instance you created.  As the text field is not initialized for your instance, you end up with a NullPointerException.

Also, text and inputText were declared in the Adventure class like this: '@FXML private TextArea text; @FXML private TextArea inputText;'

Yes, they need to be created by the FXMLLoader, which won't occur if you just write new Adventure().

So to fix all this, I need to create an initialize() method in my controller class? How would I go about doing that?

Option A (let the FXMLLoader implicitly initialize your Adventure)
Rename startAdventure() to initialize().
public void start(Stage primaryStage) throws Exception
{
    Parent root = FXMLLoader.load(getClass().getResource("AdventureGUI.fxml"));
    primaryStage.setScene(new Scene(root, 600, 600));
    primaryStage.setTitle("Adventure");
    primaryStage.show();
}

Option B (explicitly initialize your Adventure)
public void start(Stage primaryStage) throws Exception
{
    FXMLLoader loader = new FXMLLoader(
        getClass().getResource("AdventureGUI.fxml")
    );
    Parent root = loader.load();
    Adventure adventure = loader.<Adventure>getController();
    adventure.startAdventure();
    primaryStage.setScene(new Scene(root, 600, 600));
    primaryStage.setTitle("Adventure");
    primaryStage.show();
}

Sample Application

adventure/AdventureApp.java
package adventure;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

public class AdventureApp extends Application {
    @Override
    public void start(Stage stage) throws Exception {
        FXMLLoader loader = new FXMLLoader(
                getClass().getResource(
                        "AdventureGUI.fxml"
                )
        );
        Parent root = loader.load();

        stage.setScene(new Scene(root));
        stage.setTitle("Adventure");
        stage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}

adventure/Adventure.java
package adventure;

import javafx.application.Platform;
import javafx.fxml.FXML;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;

public class Adventure {
    @FXML
    private TextArea text;

    @FXML
    private TextField inputText;

    private Player player = new Player();

    public void initialize() {
        text.setText("Welcome to the land of euphoria!\n");
        text.appendText("What's your name?\n");

        Platform.runLater(() -> inputText.requestFocus());
        inputText.setOnAction(event -> {
            player.setName(inputText.getText());
            text.appendText("Welcome, " + player.getName() + "\n");
        });

        player.setLocation("START");
    }
}

adventure/Player.java
package adventure;

public class Player {
    private String name;
    private String location;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getLocation() {
        return location;
    }

    public void setLocation(String location) {
        this.location = location;
    }
}

adventure/Adventure.java
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>

<VBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="150.0" prefWidth="200.0" spacing="10.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="adventure.Adventure">
   <children>
      <TextArea fx:id="text" editable="false" prefHeight="200.0" prefWidth="200.0" wrapText="true" VBox.vgrow="ALWAYS" />
      <TextField fx:id="inputText" minHeight="-Infinity" />
   </children>
   <padding>
      <Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
   </padding>
</VBox>

Comment: Thank you for the quick response, I tried it right away, but it didn't work sadly. I wrote: Adventure game = new Adventure(); and game.startAdventure(); right before primaryStage.show() but it just resulted in a seemingly endless number of errors.
Comment: If you want a better answer, you will need to [supply more code](http://stackoverflow.com/help/mcve) and the error output, so that somebody could reasonably analyze the approach and replicate the results.
Comment: Thanks for adding the stack trace and additional info to your question.  The reason you are getting a NullPointerException is explained the updated answer and the linked StackOverflow NullPointerException Q&A.  Note, you   may have additional errors in code not supplied.
Comment: So to fix all this, I need to create an initialize() method in my controller class? How would I go about doing that? Also, text and inputText were declared in the Adventure class like this:                                          '@FXML private TextArea text;
    @FXML private TextArea inputText;'
Comment: See updated answer which addresses additional questions.
Comment: I updated the code, but now the GUI doesn't even pop up at all
Comment: OK, I can't help troubleshoot code that is not there.  I added an executable sample that you can copy and paste so you can see how this stuff works in context.
Comment: Alright, I've gotten almost everything working, but now I'm running into some problems of a different variety, see the updated question for info.
Comment: For new issues, you should ask a new questions.


Failed to load SSL keystore of type JKS for secured kafka topic

Question: Firstly, we are trying to send the Kafka messages using this JMeter for sasl_ssl enabled Kafka. So, for that purpose we have created a thread group(https://i.stack.imgur.com/H3OLH.png) in that we have added Kafka producer sampler(https://i.stack.imgur.com/FBa2k.png), Kafka producer config(https://i.stack.imgur.com/ShTrq.png).

In Kafka producer sampler I have added the variable name, Kafka topic and the payload message we want to send.
In Kafka producer config we have added Kafka broker i.e., host name and added the sasl.jaas.config and its value.
Now when we started running the JMeter we are getting the error like failed to load SSL keystore of type JKS. (https://i.stack.imgur.com/krfFo.png)
Answer: Have you tried to read documentation which states:

For example to enable SSL properties you can add below properties
<code>_ssl.key.password
_ssl.keystore.location
_ssl.keystore.password
_ssl.keystore.type
_ssl.truststore.location
_ssl.truststore.password
_ssl.truststore.type
</code>
Note: These are just sample properties, SSL properties are already included in kafka sampler.

You need to modify the properties to point to your keystore and make sure that the keystore contains the certificate required for secure connection to Kafka, the certificate can be added either using keytool or OpenSSL

More information: How to Do Kafka Testing With JMeter