How can I deactivate or downgrade the Yarn package manager using corepack?

Question: Following Yarn#Installation guide to installing the email@example.com package manager using below command:
corepack prepare firstname.lastname@example.com --activate

yarn -v
3.4.1

Now, I want to deactivate or downgrade the Yarn to the previous version in the system. The previous version is v1. I didn't find any command or option for corepack to do this.
⚡  corepack -h
━━━ Corepack - 0.12.1 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  $ corepack <command>

━━━ General commands ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  corepack disable [--install-directory #0] ...
    Remove the Corepack shims from the install directory

  corepack enable [--install-directory #0] ...
    Add the Corepack shims to the install directories

  corepack hydrate [--activate] <fileName>
    Import a package manager into the cache

  corepack prepare [--activate] [--all] [--json] [-o,--output] ...
    Generate a package manager archive

You can also print more details about any of these commands by calling them with
the `-h,--help` flag right after the command name.

Answer: corepack prepare email@example.com --activate
downgraded mine from firstname.lastname@example.com
Let me know if there is a better way.
Comment: That's because it is using a shim system isn't it? I mean they both still exist on your machine, but only the one activated is being in use. Much like pyenv or nvm.


Error creating bean ... could not load JDBC driver class [oracle.jdbc.driver.OracleDriver]

Question: I have written code to run a query using JDBC on Spring but I get an exception (see below)
Here's my context.xml
 <bean id="dataSource"
       class="org.springframework.jdbc.datasource.DriverManagerDataSource">
   <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/>
   <property name="url" value="jdbc:oracle:thin:@Mohsen-PC:1521:mydb"/>
   <property name="username" value="system"/>
   <property name="password" value="123"/>
 </bean>

 <bean id="lobHandler" class="org.springframework.jdbc.support.lob.OracleLobHandler">
   <property name="nativeJdbcExtractor" ref="nativeJdbcExtractor"/>
 </bean>

 <bean id="nativeJdbcExtractor"
     class="org.springframework.jdbc.support.nativejdbc.CommonsDbcpNativeJdbcExtractor"/>

 <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
   <property name="dataSource" ref="dataSource"/>
 </bean>
</beans>

main.java
import javax.sql.DataSource;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.jdbc.core.JdbcTemplate;

class Main {

  public static void main(String args[]) throws Exception {

    ApplicationContext ac = new ClassPathXmlApplicationContext("context.xml");

    DataSource dataSource = (DataSource) ac.getBean("dataSource");

    JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);

    System.out.println(jdbcTemplate.queryForList("select EMPLOYEE_ID from EMPLOYEE",
                                                  Long.class));
  }
}

The exception I see is:
Exception in thread "main" org.springframework.beans.factory.BeanCreationException:
  Error creating bean with name 'dataSource' defined in class path resource [context.xml]:
  Error setting property values; nested exception is
  org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
  PropertyAccessException 1: org.springframework.beans.MethodInvocationException:
  Property 'driverClassName' threw exception; nested exception is
  java.lang.IllegalStateException: Could not load JDBC driver class
  [oracle.jdbc.driver.OracleDriver] at
  org.springframework.beans.factory.support.
                             AbstractAutowireCapableBeanFactory.applyPropertyValues(
                                                AbstractAutowireCapableBeanFactory.java:1396)

EDIT: cut remainder of stack trace as the above exception is sufficient to illuminate the problem.
What is going wrong here?
Comment: Have you put `ojdbcxxx.jar` in your classpath?
Comment: Not that. You need the JDBC driver JAR file from Oracle.
Comment: @adarshr, yeah, org.springframework.jdbc-3.1.0.RELEASE
Comment: In our case(Spring 4, eclipse Luna, JDK 7, ojdbc6.jar), we had to add the ojdbc jar as well as spring-jdbc.jar into /WEB-INF/lib folder and it started to work
Answer: Looks like you are missing the oracle jdbc driver in your classpath. Please download the jar file from this path and add this to your classpath.
EDITED
Spring jdbc is a template layer which works on top of the raw jdbc layer. It just provides us some utility methods to make the database access easier. This layer internally needs the jdbc layer to work so which every database you want to connect to that database's driver also has to be included, in your case you need to include Oracle driver.
Comment: @sami Not that. You need the JDBC driver JAR file from Oracle.
Comment: i have added this jar file:org.springframework.jdbc-3.1.0.RELEASE
Comment: Spring jdbc is a template layer which works on top of the raw jdbc layer. It just provides us some utility methods to make the database access easier. This layer internally needs the jdbc layer to work so which every database you want to connect to that database's driver also has to be included, in your case you need to include Oracle driver.
Answer: It looks like the (Oracle-supplied) jar file with the JDBC driver is not in your classpath.
Note the part of the stack trace that says: "IllegalStateException: Could not load JDBC driver class [oracle.jdbc.driver.OracleDriver"
Answer: In my case the problem was fixed setting the scope to runtime:
    <dependency>
        <groupId>com.microsoft.sqlserver</groupId>
        <artifactId>mssql-jdbc</artifactId>
        <version>7.0.0.jre8</version>
        <scope>runtime</scope>
    </dependency>

Reference: When would I need maven dependency with runtime scope


How to recover data from a Windows 2003 Server HP StorageWorks Ultrium 448 Backup via Linux?

Question: I have a scenario where I have to recover a backup from an Ultirum 448 tape medium that was made on Windows 2003 server.  The only system that I have available for recovery is a Linux server with comparable hardware.
Is there a way to use tape accessibility software available on Linux to recover tape data in such a scenario?
Comment: With what backup software?
Comment: Default Windows 2003 `Backup`.
Comment: Then Ultrium448 doesn't have anything to do with your problem?
Comment: @peterh I don't believe so, except I'm having a nightmare of a time with drivers for it and the SCSI adapter.  I'm considering trying to use perhaps Windows 7 or 8 to recover instead.  Linux would be a quicker path for me since I can use another server, but c'est la vie if not.
Comment: Ok, then you have two different questions packed into a single one. First you had to make a contact with the tape drive. What is the type of your scsi adapter, does it work? Can you scan it for devices? If yes, then comes the ultrium driver, and then the mfttar.
Answer:
First you have to make contact with your tape drive. Ultrium448 is a scsi one, but it has a linux driver, thus it can't be an issue. Probably you have to reach the tape disk on a char device. HP provides linux drivers for the task, if you have trouble, I suggest to ask detailed in a new question.
The backups are coming with a <code>.bkf</code> extension. If this is the case, then your problem is very simple to solve, because there is a tool named mtftar for the task:

mtftar is a filter to translate MTF/BKF backup streams from another operating system to the TAR archives used by the rest of the world.
Comment: Okay, the `mfttar` is all I needed to know.  I can get the tape drive working fine with Linux; it is Windows that is having a hard time (strangely enough) with the HP drivers.  Linux works right out of the box for the SCSI adapter AND the tape.


Searching a smartcard that's crossplatform

Question: I'm searching a smart card for storing (PKI) certificates. The certificates on the smart card need to be retrieved on Windows (supporting Active Directory login), Linux, and Mac OS X.
I found some like the Feitian PKI smart card but from what understand it's not supported on Mac OS X.
Are there any smart cards out there that have drivers on all three the platforms?
Answer: You might consider the OpenPGP smart card; since it's OpenPGP compliant, and that works on all three platforms, I have to conclude that the card does, too.
Whether you can find a smart card reader that works on everything is a different question.  I have an SCM Microsystems SCR335 that works very nicely with my FSFE Fellowship smart card (which is itself an OpenPGP smart card) under Linux; I'd be quite surprised if that didn't work under MacOS and Windows.
Answer: You might want to specify which specific PKI implementation & email encryption type, for example, x509 SMIME vice PGP/Openpgp as I am currently unaware of a card stock that supports both PGP/Openpgp and x509 SMIME implementations (no one really uses PGP with x509 certs)
I know the Gemalto TOP DL GX4 144k cardstock used with the Department of Defense's Common Access Card (CAC) is compatible with Windows, Linux, OS X, iOS, Blackberry, and many other operating systems, and has a ton of compatible readers and multiple middleware solutions.
Reference:
http://www.gemalto.com/public_sector/omb1111/index.html


Android application Internal timer

Question: How do I keep track of the runtime of an application.
Answer: What do you mean by runtime? The time elapsed after you launch an application?
I don't think there is any direct method that can give you the elapsed time. You can maintain a timer on you own.
You can also use System.nanoTime()  to get the most accurate timing.
long startTime = System.nanoTime();
// ... the code being measured ...
long estimatedTime = System.nanoTime() - startTime;

Edit---
Yes i think Ben is correct.. If you want to just measure how long a process is running then you can try using this approach
android.os.Process.getElapsedCpuTime() - This should return the elapsed milliseconds your process has run. I believe your application also should run on a unique process ID. So that time should be fine
Comment: Found this one interesting: http://developer.android.com/reference/android/os/SystemClock.html#elapsedRealtime%28%29
Answer: You could try to get the current time when you first start the app, and then when you want to know how long the app has run for just get the current time again and then subtract the two to get the difference.
// store this as a global variable when you start the app
long start = System.currentTimeMillis();

...

// run this method when you want to query how long the app has run for
public long getTimeInMillisecondsAppHasRun()
{
    long current = System.currentTimeMillis();
    return current - start;
}

Comment: Actually this may not be the best method.  If the system time is changed these measurements will be effected.  See http://developer.android.com/reference/java/lang/System.html#currentTimeMillis%28%29 for more details.

Android application Internal timer


Let $B\in M_{n\times n}$ so that $B^{3}=0$ and let $I$ be the identity matrix the same format. Also $A=I-B$

Question: Let $B\in M_{n\times n}$ so that $B^{3}=0$ and let $I$ be the identity matrix the same format. Also $A=I-B$
Prove that A is a regular matrix and express $A^{-1}$ via $I$ and $B$.
If $b\in R^{n}$ express the solution via $b$ and $B$
My idea was to consider 3 cases
1st case: $B=0$
2nd case: $B\neq 0$,$B^{2}=0$
3rd case: $B\neq 0$,$B^{2}\neq 0$,$B^{3}=0$
and to solve the equation $A=I-B$. In all three cases I get that $A=I$.
So $A^{-1} = I$ and I can write that like $1*I+0*B$
But I'm not sure if this is the right approach.
Could someone offer a solution?
Answer: Hint:
$$(I-B^3)=(I-B)(I+B+B^2)$$
Comment: Thank you for the explanation
Comment: Sorry but how exactly does this hint help me?
Comment: @DraganZrilić Think harder and you'll realize it is *exactly* the solution to your problem...
Comment: Okay, I've figured out that $A^{-1}=I+B+B^{2}$ if A is a regular matrix. But I have not proven that A is a regular matrix, so I cannot make this claim. How would I go about proving that A is a regular matrix with the conditions that I have given?
Comment: If you have figured out that $\;A^{-1}=\;$ whatever, **that means** $\;A\;$ is regular...! Anyway, since $\;A\;$ is a **square** matrix, if $\;AH=I\;$ then *automatically* $\;A\;$ is regular and $\;AH=HA=I\;,\;\;A^{-1}=H\;$ .


Throw custom exception from catch-exception-strategy

Question: Is it possible to throw our own custom exception from catch-exception-strategy or any other exception strategies.
I tried like below:
<catch-exception-strategy doc:name="Catch Exception Strategy">

   </scripting:component>
</catch-exception-strategy>

but ended up with the error:
org.mule.exception.CatchMessagingExceptionStrategy: Failed to dispatch message to error queue after it failed to process
Can anyone solve this? Thanks in advance.
Answer: Try to put the

   </scripting:component>

outside catch-exception-strategy and try...
Comment: I know, it works fine if I put the scripting component outside `catch-exception-strategy`. What I actually need is upon catching an exception inside `catch-exception-strategy`, I just need to wrap the cause and re-throw my custom exception. Is it possible?
Comment: This answer doesn't cover the re-throwing of an exception.
Comment: Indeed that seems impossible. I don't think above is a solution for this question.


AJAX call returning data but failing

Question: I've been trying to make an ajax call to retrieve some data from a database but i don't know why is returning an error.
there's the code
<code>$('#afegir_pagament').submit(function() {
                        var import_pagament = $('#import_pagament').val();
                        var id_reserva = $('#id_reserva_hidden').val();
                        url = "afegir_pagament.php";
                        data = {import: import_pagament, id_reserva: id_reserva};
                        $.ajax({
                            url: url,
                            dataType: 'application/json',
                            type: 'post',
                            data: data,
                            complete: function(xhr, statusText) {
                                console.log(xhr.responseText);
                            },
                            success: function(responseText) {
                                $('#pag_import_pagat_propietari').val(responseText.total);
                            },
                            error: function(req, status, err) {
                                alert('Error');
                            }

                        });
                        return false;
                    });
</code>
console.log(xhr.responseText) returns {"total":"230.00"}
ERROR: no conversion from text to application/json
Could somebody help me?
Comment: Check your network tab in the Chrome/Firefox dev tools. Check what the HTTP response and requests look like.
Comment: Just `JSON.parse(responseText)`.
Comment: It looks good. HTML: {"total":"230"} | JSON total    "230"
Answer: "application/json" is not a valid value for the dataType property. Change it to "json".
See here (comment #7):

Thanks for the report, but this is not a jQuery bug. application/json is not a valid value for the dataType property.
Answer: Just change application/json to datatype :"json" and exactly what you trying to do inside the
success function ..if you trying to display this value in your text field just try this..
<code>$("#pag_import_pagat_propietari").attr("#yourid",responseText.total);
</code>

AJAX call returning data but failing


How do i use the iOS shake gesture with react native?

Question: I'd like to use the shake gesture with React Native. Its currently used for the debug menu and i'm not sure how to override it. Does anyone know if this is possible?
Answer: You can disable developer mode and then provide your own shake handler.
https://github.com/facebook/react-native/issues/1054

You can either change the value [of RCT_DEV] in RCTDefines.h, or in the build
  settings for the React lib project, search for "Preprocessor Macros"
  and add RCT_DEV=0 to the section where DEBUG=1 is currently defined.

I think you would then have to implement an Obj-C extension that handles the shake gesture; AFAIK there's no way to do this purely in JavaScript. You may find the code for the Dev Menu a useful guide for this:
https://github.com/facebook/react-native/blob/98263c4f8f6365a8c0c25e5f509928b89d8f1c0c/React/Base/RCTDevMenu.m


Polynomial expression for $\frac 1{2^n} \sum_{i=0}^n \binom{n}{i}(2i-n)^{2k}$

Question: Let
$$F (n,k)=\frac {1}{2^n}\sum_{i=0}^n \binom{n}{i}(2i-n)^{2k},$$
where $n,k$ are non-negative integers.
By numerical tests the expression is an integer polynomial in $n $ of order $k $:
$$ F(n,0)=1;
F (n,1)=n;
F (n,2)=n (3n-2),$$
and so on.
Is there a simple general expression for the polynomial?
Comment: This expression comes out in Exercise 7 of [UMN Fall 2018 Math 5705 Homework set 4](http://www-users.math.umn.edu/~dgrinber/5705f18/hw4s.pdf), and also in Corollary 2.5 of [Stanley's *Algebraic Combinatorics*](http://www-math.mit.edu/~rstan/algcomb/algcomb.pdf) (but these two appearances are actually easily seen to be equivalent: a closed walk of length $n$ on the hypercube is uniquely determined by its starting point and the $n$-tuple of "signless step directions", which $n$-tuple is clearly all-even).
Comment: If there is a closed form, then Stanley could not find it. On the other hand, the polynomial claim is interesting.
Comment: Ah, I see why it is a polynomial. You can count the all-even $k$-tuples in $\left[n\right]^k$ according to the positions of equal entries (more formally: the set partition of $\left[k\right]$ that governs which of the entries of the tuple are equal). For any given such choice of positions, the number of tuples is a polynomial in $n$ with degree $k$ (namely, a power of $n$ times a power of $n-1$ times a power of $n-2$ and so on). Feel free to expand on this in an answer -- I am stuck in bed with a flu and not at my most productive.
Comment: That is a closed form. The sum is finite. I'd try expanding $(2i-n)^{2k}$ or computing some values and plugging them in into OEIS, in any case.
Comment: @ajotatxe I have edited the question to clarify what I meant by "closed - form expression".
Comment: @darijgrinberg Thank you very much for references and the idea of proof. I hope you post your answer as soon as you are well. I have no hurry with the problem. By the way I found a rather interesting pattern governing the coefficients of the polynomial.
Comment: $F(n,k)/2^{2k}$ is equal to the $2k^{th}$ central moment of a Bin$(n,1/2)$ random variable. Maybe this connection can help you find some references.
Answer: It  is convenient to use the  coefficient of operator $[z^n]$ to denote the coefficient of $z^n$ of a series. This way we can write for instance
\begin{align*}
n![z^n]e^{jz}=j^n\tag{1}
\end{align*}

We obtain
  \begin{align*}
\color{blue}{\frac{1}{2^n}}&\color{blue}{\sum_{j=0}^n\binom{n}{j}(2j-n)^{2k}}\\
&=\frac{1}{2^n}\sum_{j=0}^n\binom{n}{j}(2k)![z^{2k}]e^{(2j-n)z}\tag{2}\\
&=\frac{(2k)!}{2^n}[z^{2k}]e^{-nz}\sum_{j=0}^n\binom{n}{j}\left(e^{2z}\right)^j\tag{3}\\
&=\frac{(2k)!}{2^n}[z^{2k}]e^{-nz}\left(1+e^{2z}\right)^n\tag{4}\\
&=(2k)![z^{2k}]\left(\frac{e^{z}+e^{-z}}{2}\right)^n\tag{5}\\
&\,\,\color{blue}{=(2k)![z^{2k}]\left(\cosh z\right)^n}
\end{align*}
We see OPs formula is essentially the coefficient of $z^{2k}$ of $\left(\cosh z\right)^n$ which does not have a closed formula as far as I know.
Comment:

In (2) we apply the coefficient of operator according to (1).
In (3) use the linearity of the coefficient of operator.
In (4) we apply the binomial theorem.
In (5) we write the expression somewhat more conveniently.
Comment: I think I have found such a closed polynomial formula. See my answer below.
Comment: @user: A closed formula means there is no $\Sigma$ involved. Somewhat more concrete a closed formula in this context is a function in $n$ with a constant number of terms. When using something like $\Sigma_{j=0}^n$ the number of terms is not constant but increases with increasing $n$.
Comment: What was meant was a closed formula for the coefficients of the polynomial (which do not depend on $n $).
Comment: @user: I agree, you're right. (+1) for your nice approach.
Answer: Let $\omega $ be a $n$-dimensional vector with binary components $\omega_i=\pm1$ and $\Omega_n $ be a set of all such vectors, the size of the set obviously being $2^n $. The sum of elements of a vector with $i$
positive and $n-i $ negative components is $2i-n $ and the number of such vectors is $\binom {n}{i}$. Thus
$$
F (n,k)=\frac {1}{2^n}\sum_{\omega\in\Omega_n } \left (\sum_{i=1}^n\omega_i \right)^{2k}
=\frac {1}{2^n}\sum_{\omega\in\Omega_n } \sum_{p_i\ge0}^{\sum_i p_i=2k}\binom {2k} {p_1,p_2,\dots,p_n}\prod_i \omega_i^{p_i}
=\sum_{p_i\ge0}^{\sum_i p_i=2k}\binom {2k} {p_1,p_2,\dots,p_n}\left (\frac {1}{2^n}\sum_{\omega\in\Omega_n }\prod_i \omega_i^{p_i}\right)
=\sum_{p_i\ge0,\;p_i\,\text {mod}\,2=0}^{\sum_i p_i=2k}\binom {2k} {p_1,p_2,\dots,p_n}.
$$
To proceed further one splits the last sum into partial ones over terms with particular count $l$ of non-zero $p_i$ and ends up with:
$$
F (n,k)=\sum_{l=1}^n T (k,l)n^\underline{l},\tag {1}
$$
where $T (k,l)$ is the number of partitions of a set of size $2k$ into $l$ blocks of even size, and $n^\underline{l}$ is falling factorial. $T(k,l)$ can be recognized as the OEIS sequence A156289 with known close-form and recurrence expressions.

Note added: by numerical evidence  the polynomial (1) can be expressed in the terms of usual powers as:
$$
F (n,k)=\sum_{l=1}^n A (k,l)n^l,\tag {2}
$$
with $A (k,l) $ being the OEIS sequence A318146. In other words $F(n,k) $ is in fact  the so called Omega polynomial.
Answer: I'll play with the cosh and
see if I get
anything other than
the original problem.
$\begin{array}\\
\cosh^n(x)
&=\frac1{2^n}(e^x+e^{-x})^n\\
&=\frac1{2^n}\sum_{k=0}^n \binom{n}{k}e^ke^{(n-k)x}\\
&=\frac1{2^n}e^{nx}\sum_{k=0}^n \binom{n}{k}e^{-2kx}\\
&=\frac1{2^n}\sum_{i=0}^{\infty} \dfrac{(nx)^i}{i!}\sum_{k=0}^n \binom{n}{k}\sum_{j=0}^{\infty} \dfrac{(-2kx)^j}{j!}\\
&=\frac1{2^n}\sum_{k=0}^n \binom{n}{k}\sum_{i=0}^{\infty} \dfrac{(nx)^i}{i!}\sum_{j=0}^{\infty} \dfrac{(-2kx)^j}{j!}\\
&=\frac1{2^n}\sum_{k=0}^n \binom{n}{k}\sum_{m=0}^{\infty}\sum_{i=0}^{m} \dfrac{(nx)^i}{i!} \dfrac{(-2kx)^{m-i}}{(m-i)!}\\
&=\frac1{2^n}\sum_{k=0}^n \binom{n}{k}\sum_{m=0}^{\infty}x^m\sum_{i=0}^{m} \dfrac{(n)^i}{i!} \dfrac{(-2k)^{m-i}}{(m-i)!}\\
&=\frac1{2^n}\sum_{m=0}^{\infty}x^m\sum_{k=0}^n \binom{n}{k}\sum_{i=0}^{m} \dfrac{(n)^i}{i!} \dfrac{(-2k)^{m-i}}{(m-i)!}\\
&=\frac1{2^n}\sum_{m=0}^{\infty}x^m\sum_{i=0}^{m}\dfrac{(-2)^{m-i}(n)^i}{(m-i)!i!}\sum_{k=0}^n \binom{n}{k}  k^{m-i}\\
&=\frac1{2^n}\sum_{m=0}^{\infty}\dfrac{x^m}{m!}\sum_{i=0}^{m}\binom{m}{i}(-2)^{m-i}n^i\sum_{k=0}^n \binom{n}{k}  k^{m-i}\\
&=\frac1{2^n}\sum_{m=0}^{\infty}\dfrac{(-2)^mx^m}{m!}\sum_{i=0}^{m}\binom{m}{i}(-n/2)^i\sum_{k=0}^n \binom{n}{k}  k^{m-i}\\
&=\frac1{2^n}\sum_{m=0}^{\infty}\dfrac{(-2)^mx^m}{m!}\sum_{k=0}^n \binom{n}{k}\sum_{i=0}^{m}\binom{m}{i}(-n/2)^i  k^{m-i}\\
&=\frac1{2^n}\sum_{m=0}^{\infty}\dfrac{(-2)^mx^m}{m!}\sum_{k=0}^n \binom{n}{k}(-n/2+k)^m\\
&=\frac1{2^n}\sum_{m=0}^{\infty}\dfrac{x^m}{m!}\sum_{k=0}^n \binom{n}{k}(2k-n)^m\\
\end{array}
$
And this is the OP.
Oh well.


Set Difference Probability

Question: Here is the question:
Prove that for every $\epsilon>0$ and every set $A\in\mathcal{B}(\mathbb{R}^{n})$ there is a compact set $K\subset A$ such that $P(A\setminus K)\leq\epsilon$.
--I have previously shown that there is a closed set $F$ and an open set $G$ such that $F\subset A\subset G$ and $P(G\setminus F)\leq\epsilon$. For the current problem, I think that we can find $K$ as an approximation of the set $F$, such that $K=F_{N}=F\cap[-N,N]^{n}$, which is compact. I think I am just caught up in the set difference algebra, i.e.,$$P(A\setminus K)=P(A\setminus (F\cap[-N,N]^{n}))=P(A\cap(F^{c}\cup[-N,N]^{c})^{c})=\cdots$$
--Any help on how to finish this is appreciated!
Answer: You did the hardest part. Now, since you are going to intersect the closed set $F$ with a compact set $M$, you are, indeed, going to get a compact set, but its probability will be less (farther away from $A$).
So, first, assume that $P(G-F)<\epsilon/2$. So,
$$P(G)=P((G-F)\cup F)=P(G-F)+P(F)<P(F)+\epsilon/2$$
Then find $N$ large enough so that $P(M)=P([-N,N]^n)>1-\epsilon/2$.
Finally, use
$$P(F)=P(F\cap M\cup F\cap M^c)=P(F\cap M)+P(F\cap M^c)\le$$
$$\le P(F\cap M)+P(M^c)< P(F\cap M)+\epsilon/2$$
and, since $F\cap M\subseteq F\subseteq G$,
$$P(A-(F\cap M))\le P(G-(F\cap M))=P(G)-P(F\cap M)<\epsilon$$
Comment: Thanks a lot, great answer.

Set Difference Probability


How does the Windows /3gb switch relate to physical RAM?

Question: I have a 32-bit Windows server with 4 GB of RAM.
From reading various articles on the web, I reached the understanding that enabling the /3GB switch in boot.ini would mean that of my 4 GB of RAM, 3 could be allocated to user mode memory.  Without the switch, only 2 GB would ever be used for user mode, with the system reserving the other 2 GB for kernel mode use.
However, this article by Mark Russinovich has made me think that my previous conclusion was wrong - all the /3GB switch does is allow processes to use 3 GB of their 4 GB address space instead of only 2GB.
Let's set up a couple of scenarios to illustrate how I think it works and when the switch would be useful:
1: a database server - one memory intensive process
Without the /3GB switch the database process will only be able to use 2 GB of memory.  With the /3GB switch the process will be able to allocate up to 3 GB.  The switch is useful in this scenario.
2: a server running 4 processes that each consume 750 MB of memory.
Using the /3GB switch will not bring any advantages - each process can already allocate all the memory that it needs and the system can hold all of the processes in physical memory already.
Am I right or wrong?  If I'm wrong, how does the /3GB switch really effect physical memory usage?
Comment: Keep in mind that very few programs are able to use 3GB.  It takes special compile options.  So don't waste you time with this option unless the vendor explicitly mentions it.
Answer: The 3GB and PAE switches are independent and work on different things.
The 3GB switch - On x86 platforms programs receive a virtual memory space. They don't get actual memory addresses. This virtual memory space is divided up in to chunks for various purposes. Normally the first half (2GB) is reserved for the program's general use. The other half is reserved for other things (kernel memory commonly). TL/DR: This switch affects how the Virtual Address Space is sliced up.
The PAE switch - Original 80386 platforms could handle a maximum of 32bits of physical RAM; this is 4GB. To add more, Intel came up with 4 additional bits and called them Physical Address Extensions. As mentioned above, programs have no idea what physical memory looks like, they see a virtual address space. The OS however can use PAE to add more than 4GB of RAM (actually ~3.7GB because of the BIOS and memory mapped IO takes up space too). TL/DR: This switch affects how the OS addresses physical memory.
The above has been simplified slightly, things are never as simple as we'd like them to be.
Comment: That would be correct, virtual addresses spaces have basically nothing to do with physical/hardware address spaces.
Comment: So... "This switch affects how the Virtual Address Space is sliced up." -> Nothing to do with how physical RAM is sliced up..?


Different results meta vs metafor

Question: I'm running a meta-analysis of single proportions. I know this can be done in both meta and metafor but I am getting slightly different results using both the moment I add in smaller studies.
Suppose this dataset of just "larger" studies:
study         total   cases
study1  50         31
study2  80         37
study3  25         10
When I run meta and metafor I do get the same result (0.5047 (95% CI: 0.4271-0.5823)) but in my meta-analysis, I have a few smaller studies that I would like to include. That's when the two results diverge.
Suppose this dataset of all studies:
study         total   cases
study1  50         31
study2  80         37
study3  25         10
study4   3          2
study5   4          2
study6   3          3
I get different results:
meta: 0.5729 {95% CI: 0.3604-0.7855)
metafor: 0.5488  (95% CI:0.3846-0.7130)
After some investigation, I realize that the difference is in the weights each one is giving to the studies with meta giving more weight to the smaller studies but can someone explain to me why that is happening? (with the "larger" studies only dataset, they both give the same weights). For example, study6 has a weight of 12.6% in meta vs. 10.6% in metafor.
This is the code I am using to run both:
# metafor
escalc.test=escalc(xi=cases, ni=total, data=test, measure="PR")

rma.test=rma(yi, vi, data=escalc.test, method="DL", knha = TRUE)

# meta
metaprop(cases, total, data=test, studlab=paste(study), sm="PRAW", comb.random = TRUE, hakn=TRUE, method.tau="DL", prediction=TRUE)

Comment: Try registering and posting on https://stat.ethz.ch/mailman/listinfo/r-sig-meta-analysis//
Answer: There is one study where the number of cases equals the sample size, so the proportion is equal to 1. However, in metafor, the commonly used adjustment of adding 1/2 is applied for computing both the proportion and the corresponding sampling variance for this study, while meta only applies this adjustment for computing the sampling variance. To get identical results, use:
escalc.test=escalc(xi=cases, ni=total, data=test, measure="PR", addyi=FALSE)

With addyi=FALSE, the 1/2 adjustment is not applied when computing the proportions and then the results are the same.
Comment: Then, from a theoretical point of view, is it more correct to add 1/2 or not?

Different results meta vs metafor


Theorem 6.17 in Baby Rudin (Riemann-Stieltjes Integral)

Question: Theorem 6.17: Assume $\alpha$ increases monotonically and $\alpha'\in\mathscr{R}$ on $[a, b]$. Let $f$ be a bounded real function on [a, b]. Then $f\in\mathscr{R}(\alpha)$ iff $f\alpha'\in\mathscr{R}$, in which case $\int_{a}^{b}fd\alpha=\int_{a}^{b}f(x)\alpha'(x) dx$.
My question: Rudin never showed why $\overline{\int}_a^b f(x) \alpha^\prime(x) \,dx$ exists in the first place. Now, if $\alpha'$ is bounded on $[a, b]$, then it is not hard to show $f(x)\alpha'(x)$ is also bounded on $[a, b]$, which then implies that $infU(P, f\alpha')$ indeed exists; but such assumption is not given in the theorem statement. Please help.
Answer: Rudin does infact mention that $\alpha'$ is Riemann integrable, which implies that it is bounded. Recall that the definition of Riemann integrability given by Rudin applies to bounded functions only.
Comment: " I failed to prove that Riemann integrable implies boundedness." you really need to get into the habit of _knowing_ definitions!
Comment: I appreciate the help - that was precisely my conjecture; but I failed to prove that Riemann integrable implies boundedness.
Comment: Great advice David - I must.


Prevent from being spoofed by sendgrid

Question: Recently we received an odd mail coming from firstname.lastname@example.com to email@example.com
The problem is that address1 didn't send any email to address2. The email was sent using sendgrid.
Sendgrid has to be in our SPF due to the use of freshdesk which uses their system.
I was able to recreate the situation with the following:
- create a free sendgrid account with a fake email address (email@example.com)
- send a transactional email from: firstname.lastname@example.com (email@example.com) to email@example.com.
The email goes straight to spam but it stills delivered. However I would like to reject this email.
I have dkim for our principal server, and freshdesk (sendgrid), and SPF for our principal server and once again freshdesk.
I tried with dmarc to reject but the email is still being delivered. At this point I'm out of ideas and I don't know what could be missing.
If the email is sent by freshdesk then it's signed by company.com and if it's spoofed like I mentioned above it will be signed by sendgrid which is generating their own DKIM keys (apparently).
Our server runs in postfix with debian9.
Thank you,
Diogo Jesus
Comment: Your question might be easier to understand if you indicated which of the placeholder domain indicates domains under your control. What did did the *SendGrid* abuse team say about your complaint anyway?
Comment: @anx after 2 emails no statement were done.
Comment: the thing is that we're not sendgrid costumers. I don't understand how they can have a such breach in their systems were they allow users to send transitional emails without even verifying their account. It's just pure nonsense.
Answer: SPF / DKIM / DMARC won't necessarily solve this problem, perhaps better to find a way of adding a  header (tag) to the freshdesk emails that you can use header checks to validate if the email is genuine.
i.e.
email delivered via sendgrid and tagged with the secret freshdesk tag is genuine,
email sent via sendgrid without the tag is not and can be binned.
Comment: Great response and helpful to others who encounter similar, cheers!
Comment: I will validate this question since it was close enough to what I managed to do. Basically mails from sendgrid had a return path like firstname.lastname@example.com and those from freshdesk were email@example.com So adding a sender.pcre to smtpd_recipient_restrictions with a rule to block from any firstname.lastname@example.com fixed the issue.

Prevent from being spoofed by sendgrid


Nginx caching pages for logged in WordPress users (and showing admin bar to visitors!)

Question: I have setup nginx with caching in WordPress.
I am using the https://wordpress.org/plugins/nginx-helper/, however it seems the logged in page is being cached when it should not be (hence showing the logged in bar).
Some visitors who are not logged in (nor have any cookies/browser-cache) are seeing the logged in bar (if they click on anything within the bar it redirects them to login page).

In addition, when I click the purge cache button within WordPress, pages are still served and shown as XCache HIT... the only way to really purge is by rm -rf /dev/shm/nginx.
I do have the following modules installed:
nginx version: nginx/1.8.0
built with OpenSSL 1.0.1f 6 Jan 2014
TLS SNI support enabled
configure arguments: --with-cc-opt='-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2'
--with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro' --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log
--error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --http-client-body-temp-path=/var/lib/nginx/body
--http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi
--http-uwsgi-temp-path=/var/lib/nginx/uwsgi
--with-debug --with-pcre-jit --with-ipv6 --with-http_ssl_module
--with-http_stub_status_module --with-http_realip_module
--with-http_auth_request_module --with-http_addition_module
--with-http_geoip_module --with-http_gzip_static_module
--with-http_image_filter_module --with-http_spdy_module
--with-http_sub_module --with-http_xslt_module
--add-module=/build/buildd/nginx-1.8.0/debian/modules/headers-more-nginx-module
--add-module=/build/buildd/nginx-1.8.0/debian/modules/nginx-auth-pam
--add-module=/build/buildd/nginx-1.8.0/debian/modules/nginx-cache-purge
--add-module=/build/buildd/nginx-1.8.0/debian/modules/nginx-echo
--add-module=/build/buildd/nginx-1.8.0/debian/modules/ngx-fancyindex
--add-module=/build/buildd/nginx-1.8.0/debian/modules/nginx-lua
--add-module=/build/buildd/nginx-1.8.0/debian/modules/nginx-upload-progress
--add-module=/build/buildd/nginx-1.8.0/debian/modules/nginx-upstream-fair
--add-module=/build/buildd/nginx-1.8.0/debian/modules/ngx_http_substitutions_filter_module
--add-module=/build/buildd/nginx-1.8.0/debian/modules/ngx_pagespeed

Any idea what is wrong with my config please?
user www-data;
worker_processes 4;
pid /run/nginx.pid;

events {
        worker_connections 1024;
        multi_accept on;
}

http {
        geoip_country /usr/local/share/GeoIP/GeoIP.dat;
        geoip_city /usr/local/share/GeoIP/GeoLiteCity.dat;

        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
        types_hash_max_size 2048;

        client_max_body_size 300m;
        proxy_send_timeout 300;
        proxy_read_timeout 300;

        include /etc/nginx/mime.types;
        default_type application/octet-stream;

        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;

        gzip on;
        gzip_disable "msie6";

        # Upstream to abstract backend connection(s) for PHP.
        upstream php {
               server 127.0.0.1:9000;
        }

        include /etc/nginx/conf.d/*.conf;

        fastcgi_cache_path /dev/shm/nginx levels=1:2 keys_zone=WPCACHE:384m max_size=3072m inactive=480m;
        fastcgi_cache_key "$scheme$request_method$host$request_uri";

        server {
            server_name mysite.com;
            root /home/mysite/public_html/;
            index index.php;

            access_log /home/mysite/logs/access.log;
            error_log  /home/mysite/logs/error.log;

            fastcgi_cache_use_stale error timeout invalid_header http_500;
            fastcgi_ignore_headers Cache-Control Expires Set-Cookie;

            # Rules to work out when cache should or should not be used
            set $skip_cache 0;
            # POST requests and urls with a query string should always go to PHP

            if ($request_method = POST) {
                set $skip_cache 1;
            }

            if ($query_string != "") {
                set $skip_cache 1;
            }

            # Don't cache uris containing the following segments
            if ($request_uri ~* "/wp-admin/|/xmlrpc.php|wp-.*.php|/feed/|index.php|sitemap(_index)?.xml") {
                set $skip_cache 1;
            }

            # Don't use the cache for logged in users or recent commenters
            if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") {
                set $skip_cache 1;
            }

            location = /favicon.ico {
                log_not_found off;
                access_log off;
            }

            location / {
                try_files $uri $uri/ /index.php?$args;
            }

            # Add trailing slash to */wp-admin requests.
            rewrite /wp-admin$ $scheme://$host$uri/ permanent;

            location ~ \.php$ {
                try_files $uri =404;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                include fastcgi_params;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_pass php;

                fastcgi_cache WPCACHE;
                fastcgi_cache_valid 200 480m;

                fastcgi_cache_methods GET HEAD;
                fastcgi_cache_bypass $skip_cache;
                fastcgi_no_cache $skip_cache;

                #more_clear_headers Server; more_clear_headers "Pragma";
                add_header Z_LOCATION "PHP MAIN"; add_header URI $uri; # DEBUG
                add_header X-Cache $upstream_cache_status;
            }

            location ~ /purge(/.*) {
                fastcgi_cache_purge WPCACHE "$scheme$request_method$host$1";
            }

            location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
                access_log off;
                log_not_found off;
                expires max;
            }

            location = /robots.txt {
                access_log off;
                log_not_found off;
            }

            location ~ /\. {
                deny  all;
                access_log off;
                log_not_found off;
            }
        }
}

Answer: That config looks very familiar - I posted most of it in another thread :) Alas it's missing an important part.
location = /wp-login.php {
  fastcgi_keep_conn on;
  fastcgi_intercept_errors on;
  fastcgi_pass   php;
  include        fastcgi_params;
  fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;

  # No caching
  more_clear_headers "Cache-Control";
  add_header Cache-Control "private, max-age=0, no-cache, no-store";
  more_clear_headers "Expires";
}

Also, the Nginx Helper just doesn't work to clear the cache. I spent AGES trying to make it work, but it just doesn't. I couldn't get the Nginx Cache plugin working either.
Nginx Cache Update
From @rafa in the comments: the problem is nginx-helper has a hard-coded path for the cache files to be under /var/run/nginx-cache, and the OP's config indicates the path /dev/shm/nginx for the cache files. I just changed my fastcgi_cache_path to the "correct" path, and nginx-cache works
Comment: Thanks Tim, a question for understanding and not criticism I very much appreciate your help... any reason this wasn't listed in your original post? Is it doing something different? I don't see that section on other nginx cache tutorials (i.e. https://www.nginx.com/blog/9-tips-for-improving-wordpress-performance-with-nginx/) - clarification much appreciated.
Comment: I would've posted parts of a config to illustrate a principle or how to fix a problem, rather than to say "set up your Nginx like this". Though it has pretty good comments because they're taken from my AWS/Nginx/Wordpress tutorial, which is coming out before too long... all my sites are live on AWS now, so it's just tiding up the tutorial.
Comment: A small comment regarding _"nginx helper doesnt work to clear the cache"_; the problem is nginx-helper has a hard-coded path for the cache files to be under `/var/run/nginx-cache`, and the OP's config indicates the path `/dev/shm/nginx` for the cache files. I just changed my `fastcgi_cache_path` to the "correct" path, and nginx-cache works.
Comment: Thanks @Rafa , I'll have a try of that myself sometime and update my post when I've confirmed it.


Show child pages in parent node view details in a book

Question: I'm using the Book module to maintain the parent-child relationship between content. I want to see all child pages expanded when I see a parent node details page.
How can I achieve it?
I tried with THEMENAME_preprocess_book_tree(), but so far I have not been able to achieve that I wanted.
Is this the right hook to use in my case?
Comment: Does it have to be a code solution? You can use Views to create a Block with full child content listed on parent book pages. You also don't have to use the Book module for parent-child relationship, a more general way is to use Entity reference field.
Comment: Do you mean just list child pages titles? Isn't there a block with Book navigation that already does it? Just place it in a region that makes sense to you, below main content for example.
Comment: @prkos I want all contents inside child pages, not just title.
Answer: I managed to find a solution. I would like to post it here if somebody looking for similar solutions.
Make a view for the parent page with all needed configurations. In my case, I have the main chapter page as the parent, the content type is 'chapter'. And when I see the view in a page I want to see all subchapters coming under it. The further steps are followed:

Browse to /admin/structure/views and click on "Add view".
Enter a view  name, Select content type from view settings
Check the "Create a block" checkbox only. Then click on
"Save & edit".
On the right-hand side, click on "Advanced" so that the advanced
menu appears.
Click on "add" next to "Relationships" to add a relationship.
Select "1st parent" (the parent book node) and click on "Apply and
configure relationships".
Check the "Require this relationship" checkbox and click on "Apply".
Click on "add" next to "Contextual filters" to add a contextual
filter.
Select "ID" (The node ID) and click on "Add and configure contextual
filters". Choose relationship to "Book 1st Parent"
In the "when the filter value is not available" section, select
 "Provide default value" and in the "Type" drop-down menu, select
 "Content ID from URL"
click on "Apply" & Save the view
Place the just created block in the page by visiting structure >
 block layout
Comment: This was exactly what I needed - in my case, a View that shows the child nodes of a Book when the View itself is displayed on a Book parent page. It's a shame it's this convoluted now though - in D7, there was a simple contextual filter called 'Book: All sub nodes of this book page.' Much easier!
Comment: Thanks for sharing. I had to replace the core functionality of book tree navigation (the one under book nodes) with a view block to place it in a Layout Builder section and make a custom layout for book pages. I followed your instructions, but to make it work, in my case I chose "Parent" instead of "Book 1st Parent" to show all children of the passed parent page. Thank you very much!


Postgresql replication with pgpool or pgbouncer

Question: I'm looking for a good configuration for a postgresql replication with a robust failover strategy (self hosted).
Actually, I configured two postgresql instances in master / slave with repmgr.
Now, I don't know what to put before these two instances to have a good failover.
I would like that when the master goes down, the slave automatically promotes itself to the new master and with no downtime for clients; I think that I should put pgbool (or pgbouncer?) before the master/slave postgres, but to avoid to have it as a single point of failure I should have 2 instances of these, right? (this is an example of what I've in mind: https://i.stack.imgur.com/IGknG.png).
My fundamental problem is how to configure an automatical failover with two different instances of pgpool.
How can I be sure that both change the internal master/slave configuration? Should be pgpool to make the failover or repmgr (changing configuration of both pgpool instances)?
I have some doubts that I'm on the right way, basically because I didn't found lots of documentation about this type of configuration, and what can happen if for example the master comes back online maybe after some minutes of network problems (so postgres isn't really down, but it's unreachable by clients).
To make things more complicated, I'm trying to configure this infrastructure with docker (but maybe could be simpler because I can destroy a pg instance and create a new one with docker?).
Answer: I've never used docker, so can't comment on this, but I would recommend (and I'm using this in production for large, heavily used databases for a long time) the, in my opinion, way to go in (complex) cluster setups: corosync and pacemaker. Use the pgsql resource agent and a virtual, floating IP, to which you connect the clients.
If you've never worked with this kind of setup / software stack, have a look at this tutorial or that one; additionally here are slides (take care, it's a .pdf, in case this matters to you) about this topic from PGConf.Russia held last year. If you go this route and run into specific problems, open up a new question and ping me (for example, via a comment using @gf_), I might be able to help.
Edit: There is also a new project called PostgreSQL Automatic Failover PAF, which "[...] is a new OCF resource Agent dedicated to PostgreSQL. Its original wish is to keep a clear limit between the Pacemaker administration and the PostgreSQL one, to keep things simple, documented and yet powerful. [...]" The first commit was made in February 2016, so it's still quite young, but maybe this would be worth a look as well. (However, I can't comment nor judge about this, because I've never used it.)
Comment: Thanks for your suggestion!
It's a bit far from what I'm trying to do, but I'll check if I can use it (if it's not too complex to use and coexist with docker).
Comment: @LucaLeen I see. Some comments: This setup should work with docker containers as well. Using corosync and pacemaker gives you the possibility of using [STONITH](https://en.wikipedia.org/wiki/STONITH) as well, which is a must if you set up a cluster for production use (and your data is of some value to you). Besides this: If you're only using `repmgr`, how do you do the IP failover?
Comment: as I wrote, I would like to put 2 instances of pgpool (two docker containers on two different hosts), and IP failover is made by AWS route53 health check, so if an instance of pgpool is unreachable, dns uses the second one.
For postgres instead, if master goes down, repmgr should promotes the slave as a new master, then it should change the config of pgpool instances, or maybe pgpool should manages the failover and calls repmgr.. I don't know.

I'm also studying how bucardo works, maybe with master/master I don't have to worry about postgres failover and setup will be a lot simpler.
Comment: @LucaLeen I see. Am I right that your plan is to switch the DNS record in case of a failover? If so: Not sure what your requirements are in terms of high availability etc., but using this has some caveats. If records are cached "somewhere", this won't work like intended. (But this also depends on your environment and these of your clients; aka if this is a system just for internal, or public use.) Also, but again I'm unsure about your requirements: If you're just checking if the node hosting pgpool is reachable or not, this won't catch misbehaving code / applications / etc. "somewhere": ...
Comment: ...it's not that uncommon that nodes in clusters are reachable, but don't work as expected. (Just a hint.) Good luck!
Comment: Thank you very much for these suggestions. I'm very far for use this in production, but I would be sure that I'm on the right way.


Find numbers with n-divisors in a given range

Question: I'm trying to answer this question.
Are there positive integers $\le200$ which have exactly 13 positive divisors? What about 14 divisors? If yes, write them. If no, explain why not.
Because I'm only familiar with prime factorization, the sieve of Eratosthenes etc. about this topic I need help to understand how to reasoning with this kind of questions.
Comment: Well, I guess a number with 13 positive divisors can be written as the product
$$
p_1 p_2 p_3 \ldots p_{12}p_{13}
$$
where $p_i$ are prime numbers, not necessarily different ones. So then the smallest of such number would be obtained by choosing $p_i=2$, resulting in $2^{13}>200$.
Comment: Do you count repeated divisors? Like $2^3$ ?
Comment: @MattiP. Yes, I suppose
Comment: @PCNF are you familiar with $\tau(n)$ function ?
Comment: @someone only heard but never studied or used
Answer: For any number $n=p_1^{\alpha_1}p_2^{\alpha_2}p_3^{\alpha_3}\dots p_k^{\alpha_k}$ the number of divisors (including $1$ and $n$) is $d=\prod({\alpha_i +1})$. If $d=13$, since $13$ is prime, there is only one possibility: $n=p_i^{12}$. The smallest such number is $2^{12}$ which is larger than $200$, so there are no numbers satisfying this requirement. If $d=14=2\cdot 7$ candidate numbers will have the form $n=p_1\cdot p_2^6$. The smallest such number is $3\cdot 2^6 =192$ which meets your requirement of being less than $200$.
Added by edit: The formula $d=\prod({\alpha_i +1})$ is simply the $\tau (n)$ referred to in the comments. Also, just for completeness sake, the $14$ divisors of $192$ are: $1,2,4,8,16,32,64,3,6,12,24,48,96,192$.


Parsing dynamic key and value nested json

Question: <code>{
  "buildingNumber": 123,
  "apatmentNumber": "4567",
  "apartments": "123",
  "isActive": true,
  "possibleActions": [
    "ENTER",
    "EXIT"
  ],
  "enterVia": {
    "J1-B1": [
      "DEFAULT_ROUTE"
    ],
    "A1-D1": [
      "DEFAULT_ROUTE"
    ]
    },
  "SectionMap": {},
  "route": "abc|def (via xyz)"
  }
</code>
I have above sample JSON. Whole content inside "enterVia" is dynamic.
I have to read this nested Json (shown below) from a response and send it in another request.
<code>  {
    "J1-B1": [
      "DEFAULT_ROUTE"
    ],
    "A1-D1": [
      "DEFAULT_ROUTE"
    ]
}
</code>
Please suggest a way if it is possible using Gson, ObjectMapper.
Answer: I found a solution using ObjectMapper. Below is the code:
<code>import java.io.IOException;
import java.util.List;
import java.util.Map;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;

public class JsonParseTest {

    public static void main(String[] args) {

        String json = "{\r\n\t\"J1-B1\": [\r\n\t\t\"DEFAULT_ROUTE\"\r\n\t],\r\n\t\"A1-D1\": [\r\n\t\t\"DEFAULT_ROUTE\"\r\n\t]\r\n}";

        ObjectMapper objectMapper = new ObjectMapper();
        Map<String, List<String>> routesMap = null;
        try {
            routesMap = objectMapper.readValue(json, new TypeReference<Map<String, List<String>>>(){});
        } catch (JsonParseException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        } catch (JsonMappingException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        } catch (IOException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
        System.out.println("read response output: " +routesMap);

        objectMapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
        String jsonRequest = null;

        try {
            jsonRequest = objectMapper.writeValueAsString(routesMap);
        } catch (JsonProcessingException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        System.out.println("next request output: " +jsonRequest);
    }

}
</code>
Output of the program:
read response output: {J1-B1=[DEFAULT_ROUTE], A1-D1=[DEFAULT_ROUTE]}
next request output: {"J1-B1":["DEFAULT_ROUTE"],"A1-D1":["DEFAULT_ROUTE"]}


Piano player, bad traditional sight reading

Question: I'm mostly self taught with the piano. I've only played for ~12 months.
When I learned began playing, I didn't learn which notes were in what position on the staff (I  only recognize a couple of notes instantly).
Instead, I typically play using the intervals between notes starting with the beginning. So instead of thinking C->E with my right hand (c position), I know I began with my thumb on the C key and move two up to play the next note with my middle finger -- I typically won't recognize any successive notes.
But my real fear is that this method is damaging for me in the long run -- Is this a bad way to approach reading music? Will it be a big detriment if I want to improv?
Answer: Knowing intervals in music is a great start, but in my opinion, the ability to look at a piece of sheet music and immediately being able to pick out notes is very important, if not essential. Believe me – when you get a note 3 ledger lines up in the treble clef, you don't want to count up a 17th before you realize it's an E.
As for the second part of your question, it depends on what you mean by improvisation. If you mean playing off chords played by fellow band members, reading sheet music doesn't really apply to that. However, if you're improvising off a baseline on a piece of sheet music, you'll want to be able to identify those notes as quickly as possible.
Comment: hahaha I've been taught traditionally, and I still have to use the interval method when I get past 2 ledger lines!
Answer: I suspect everyone begins identifying notes like that. Just spend more time with music, recognizing the notes instantly will come naturally, like how you don't have to sound out words letter by letter anymore as you read this text. There's only five lines after all, so if you really wanted to, you could make flash cards I suppose...
Comment: Don't need to make them, just download them: https://ankiweb.net/shared/decks/music :)
Answer: Being able to play by intervals is fantastic for sight-reading and transposition, as well as for improvisation. It'll give you a good ad-hoc appreciation for harmony and chords.
In the long run, knowing the note names will be useful as well. As improvisation is usually based around chords, being able to identify the notes of a chord around a named note will help greatly.
You could try drilling where certain intervals will take you, both on sheet music and on your keyboard (for example, all the different fifths: C-G, D-A, E-B, F-C, G-D, A-E, B-F#), but as the example shows this can get a little technical (why B-F# and not B-F? It has to do with the number of semi-tones between the notes). However, in this way you could build on what you already know to shore up the weaker places.
Answer: Doesn't really matter how you read as long as you do so correctly. In my opinion, the best way to improve your sight reading skills is to play through a hymnal with four-part accompaniment. Do a few a day for a year and you'll be a pretty decent sight reader. After that, buy some Bach chorales to read through.


How to change the format of a date

Question: I am receiving the date in this 2018-10-03 format and I would like to switch to this format 03/10/2018

Comment: So can I assume `cmPaymentDate` is of type `string`? If so, you first need to convert `cmPaymentDate` to a `DateTime` for it be valid for your specified `StringFormat` - than a simple `string` won't know what to do with your `StringFormat` it just can't understand what `d` or `M` or `y` is in a simple `string`? Did I say `string` to often?
Comment: What is your current output?
Answer: you might try to use converter. Another thing is that it must be a DateTime otherwise stringFormat will have no effect.
<Window x:Class="StackPoC.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="clr-namespace:StackPoC"
    mc:Ignorable="d"
    Title="MainWindow" Height="450" Width="800">
<StackPanel>
    <StackPanel.Resources>
        <local:DateConverter x:Key="DateConverter" />
    </StackPanel.Resources>
    <TextBlock Text="{Binding CmPaymentDate, Converter={StaticResource DateConverter}}"  Foreground="Black" FontSize="14"/>
</StackPanel>

Code-Behind
public partial class MainWindow : Window, INotifyPropertyChanged
{
    public event PropertyChangedEventHandler PropertyChanged;

    private DateTime _cmPaymentDate;
    public DateTime CmPaymentDate
    {
        get
        {
            return _cmPaymentDate;
        }
        set
        {
            _cmPaymentDate = value;
            OnPropertyChanged("CmPaymentDate");
        }
    }

    public MainWindow()
    {
        InitializeComponent();
        this.DataContext = this;

        CmPaymentDate = new DateTime(2018, 09, 23);
    }

    // Create the OnPropertyChanged method to raise the event
    protected void OnPropertyChanged(string name)
    {
        PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
    }
}

and the converter:
public class DateConverter : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        DateTime dt = (DateTime)value;
        return dt.ToString("dd/MM/yyyy");
    }

    public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        throw new NotImplementedException();
    }
}

How to change the format of a date


What Windows ext3 driver should I use?

Question: I understand that there are several alternatives for using/accessing ext2/ext3 in Windows, such as those described in a HOWTO Forge article and in a another article from a year ago.  However, none of the listed items provide full read-write access to a fully implemented ext3.  That is, the two read-write options seem to not support the ext3 journal.  (ext2fsd will replay a non-empty journal, but otherwise doesn't use it, it looks like.  ext2fs.sys doesn't seem to use the journal at all.)
Is anyone aware of a driver I can install in Windows to provide full read-write access to ext3 partitions, including the journal, user rights, selinux attributes (if possible, at least preserve them) and other extended attributes?
Have any of you actually used one of these drivers?  Currently, I share data between OSes on a dual-boot system via a FAT32 partition.  I know that I could use NTFS, which has read-write access under Linux.  However, if it is possible, I would prefer to use ext3.
Answer: Unfortunately, there is no such driver (or if there is the author(s) chose not to publish.) All the existing drivers are of questionable quality - I have had data corruption issues with all of them. I would stick with ntfs-3g.
Edit: Just to clarify - by "all the existing drivers" I do mean all the existing drivers. That includes the commercial ones. None handle all common scenarios correctly (such as proper journal replay, unclean shutdowns, etc.)
Comment: Agreed. I have also found ntfs-3g to be the best solution after having issues with Windows ext3 drivers.
Comment: I use an NTFS partition to move files from one PC to another (with the included driver in Ubuntu), and I've never had any problems with it... Then again maybe I'm not pushing the limits of the NTFS implementation.
Comment: Thank you -- this is more valuable information than I've found in any review.
Answer: The way I solved this problem is through Ubuntu 9.04 guest in VirtualBox. I made VirtualBox guest see the host's USB with ext3. Then I mounted /dev/sdb2 under /media and copied all the files I needed to the folder shared between Windows host and Ubuntu guest. A bit laborious but surely beats fighting the buggy ext3 drivers on Windows (I tried 3 of them with no success) and risking the loss of data. In case you do nto have it already, setting up Ubuntu in VirtualBox on Windows is a piece of cake and works great both installing from scratch or just downloading an image from http://virtualbox.wordpress.com/images/ubuntu/
Hope this helps.
Comment: I've used colinux for this sort of thing in the past.
Answer: I'm using http://fs-driver.org/ for a few years. It does not provide all the features you require, but at least it does understand utf-8 file names, and I've never experienced any data corruption with it (may be I'm lucky?)
Another known workaround is to use a small coLinux installation on windows, give it full access to your linux partitions and mount them on windows using samba or NFS.
Comment: That is sad, but true.
Comment: This doesn't support inodes of over 128it, which means a common 256bit inode FS will be unreadable.
Answer: If you want to get read and write access to ext partitions from windows - have a look at paragon extfs driver for windows. It runs under all versions of Windows (8 as well) and can read any ext2/3/4 filesystem. And I don't have stability problems so far www.paragon-software.com/home/extfs-windows/

What Windows ext3 driver should I use?


Is this user agent string related to Safari?

Question: Mozilla/5.0 (iPhone; CPU iPhone OS 7_1 like Mac OS X) AppleWebKit/536.26
  (KHTML, like Gecko) GSA/22.214.171.124875 Mobile/11D167 Safari/8536.25

What's that "GSA" part?
I've tried to figure it out, but googling wasn't enough (the only meaningful results were about the gsa-crawler, but it doesn't look like it's the case). But for Safari I used to expect something like
Mozilla/5.0 (iPhone; CPU iPhone OS 7_1 like Mac OS X) AppleWebKit/537.51.2
  (KHTML, like Gecko) Version/7.0 Mobile/11D167 Safari/9537.53

Of course, I'm giving for granted that it's not a faked string...
Answer: I would like to pitch in on this. While I can not testify against i-CONICA's answer, as it is probably correct, I noticed that on both an iPad and iPhone (both running iOS 7.1) that if you open a website through the Google Search App, that the user agent will be changed to the "GSA" string, as opposed to the standard Safari user agent string.
It seems the culprit of this "GSA" string is people searching and opening a website using the Google Search App.
Comment: +1 for the detailed explanation.
Answer: It means the Safari on the iPhone that's running iOS 7.1 is using Google Search (Appliance) as it's default search engine.
Comment: I will have to disagree here. The GSA element of the user agent just refers to a WebView used by the Google Search App on iOS. Indeed, if you launch the "Google" app on an iPhone, make a search and go to a website, the UA reported will have the extra "GSA" element. So it's just an iphone browsing your site through the Google application.
Comment: As I understand it, [Google Search Appliance](https://www.google.fr/work/search/?utm_source=google&utm_medium=cpc&utm_campaign=emea-lcs-search-website-leads-fr-fr&utm_content=gsa-bring-intranet) is a piece of hardware from Google that does index your corporate network. So it doesn't make sense... What is GSA for you?
Comment: GSA stands for Google Search Appliance. In your case, it'll have GSA on it too, as the Google app also uses the GSA. This only appears if your safari browser is using the Google Search. If you switch to Bing, Yahoo, DDG, etc it won't have GSA on it.
Comment: How can it be hardware? And it's nothing to do with a corporate network. This user agent string is evident on every iOS device using Google search. It's just appended to the user agent so that Google service knows the search came from an iOS device which is using it's search service, for stats collection and offering relevant apps, etc such as the Google app for iOS (redirect link to app store) as opposed to the Google app for Android.
Comment: Search for "Google Search Appliance" on Google (or follow my link) and you'll see it's a piece of hardware. I've used iOS for about many many years now, always with Google as my default search engine, and I've never seen this GSA/X.X.X in any of my user-agents, from iOS 1 to iOS 8. However, when using the Google Search App (note it's also abbreviated to GSA) I see this in my user-agent string. So the question is, what is GSA/X.X.X in a user-agent: A piece of hardware sold by Google or the name of the App accessing the web through a WebView. I vote for the App which add this to the user-agent.


How to hide multiple selectors as once with jQuery

Question: How come this..
    $("div.toggle1").hide();
    $("div.toggle3").hide();
            $("div.toggle4").hide();
            $("div.toggle5").hide();

is not equvalent to this...
           $('#container div').not('.toggle2').hide();

that occurs on a click event, but it doesn't work the same as manually typing out multiple hide() tags.  I'm just trying to reduce the hide() tag usage for every div I keep adding on within my parent #container div.
Comment: The two are equivalent for me.. see: http://jsfiddle.net/jli1/nVNDA/ (just comment/uncomment and rerun)
Comment: Try to remove `#container` from the selector in the second case. Is the result the same in both cases now?
Answer: $("div.toggle1, div.toggle3, div.toggle4, div.toggle5").hide();

Or just give every DOM element that you will hide the same class and you can just do:
$('.hideClass').hide();

Comment: Ok, I didn't know you could add multiple selectors to the beginging like that and seperate them with commas.  thats cool and worked for me.
Comment: perfecto. hehehe
Comment: I really like the option of using a pseudo-class.  That's really the cleanest way to do it, in my opinion.
Answer: You can easily control it through css. Add a hidden class to parent container which will have a display:none style in it. If you don't want display:none for div with class toggle2 then override the style for this element. In this way you dont have to call hide on all the containers or select all the containers and call hide method.
Try this
.hidden{
   display:none;
}

.hidden .toggle2{
   display:block;
}

//This will add hidden class to the container which will
//ultimately hide all the inner divs except div with class toggle2
$('#container').addClass('hidden');


AWS CLI Commands not setting ENV Variables with Bash Script

Question: So I have created a very simple Shell Script. All it does it set 3 ENV variables for AWS so that I can send a .csv file to S3 in a separate script.
<code>#!/usr/bin/env bash
export AWS_DEFAULT_REGION=us-east-1
export AWS_SECRET_ACCESS_KEY=ksjdnkjsdnfkjsndfksjnfd
export AWS_ACCESS_KEY_ID=kjsdnfkjsndfkjsndfkjsdn
</code>
The SECRET KEY and KEY_ID have been changed for this post, just so we're clear
But for some reason, when I run this Shell Script, nothing seems to happen at all. When I run the ENV command, none of the variables are set. HOWEVER, when I copy and paste each command into my terminal individually, it sets the variable without issue. And then I am able to send my .csv file to S3 without issue.
I feel like I'm doing something extremely trivial that's causing the script to simply not run the commands.
Any ideas?
System: Raspberry Pi 3
Release: 10
-Joe
Answer: If you're just executing your script <code>./myscript.sh</code>, the environment variables won't be set in your shell just the subshell it executes in.
You can execute your script with a "dot space script" syntax or use source.  Both of which will execute the script in the current shell instead of launching a subshell.
<code>. myscript.sh
source myscript.sh
</code>
Comment: Unfortunately, this does not seem to work :/
Comment: In fact, any time I try to use the "dot space script" syntax OR use source, it immediately boots me out of the Pi and still does not change the environmental variables


How to get the row value to map with column using Excel?

Question: As part of my learning to work with excel, I got stuck in two places:
1 - Get to reference the row values in the column.
2 - Is there a better way to calculate the sequence.
Formula Used:
for 1st sequence
=SEQUENCE(A2, 1, 1,1)

for remaining sequence
=SEQUENCE(A3,1,LOOKUP(2,1/(B:B<>""),B:B)+ 1,1)
=SEQUENCE(A4,1,LOOKUP(2,1/(C:C<>""),C:C)+ 1,1)
=SEQUENCE(A5,1,LOOKUP(2,1/(D:D<>""),D:D)+ 1,1)
=SEQUENCE(A6,1,LOOKUP(2,1/(E:E<>""),E:E)+ 1,1)
...

Instead of manually reference A3, A4, A5, A6;
How do get row values to the column?
I have used LOOKUP() to get the last value from the previous column and start the sequence. Just wanted to know if we have a better approach to do the same?
Output:
Answer: You can use only one formula then drag across to fill desired output.
=SEQUENCE(INDEX($A$2:$A$10,COLUMN(A$1)),,IF(COLUMN()=2,1,MAX(A:A)+1))

Comment: @JohnSmith Are you using `google-sheet` or Excel?
Comment: @JohnSmith Sequence formula is only available to Excel-365. So earlier version will not work.
Comment: Error: Function SEQUENCE parameter 2 value is 0. It should be greater than or equal to 1.
Comment: =ARRAY_CONSTRAIN(ARRAYFORMULA(SEQUENCE(INDEX($A$2:$A$10,COLUMN(A$1)), ,IF(COLUMN()=2,1,MAX(A:A)+1))), 4, 1)
Comment: If you use `google-sheet` then use `=SEQUENCE(INDEX($A$2:$A$10,COLUMN(A$1)),1,IF(COLUMN()=2,1,MAX(A:A)+1))`
Comment: The same formula isn't working on excel 2003!
Answer: It's a rainy day here (again), so I have sat down to see if this can be accomplished in a single formula. Yes, it can:
=LET(data,A2:INDEX(A:A,COUNT(A:A)+1),
rows,ROW(A1:INDEX(A:A,COUNT(A:A))),
columns,TRANSPOSE(ROW(A1:INDEX(A:A,COUNT(A:A)))),
array10,IF(rows>=columns,1,0),
totals,MMULT(array10,data),
totalsPrev,totals-data,
rowsOut,ROW(A1:INDEX(A:A,MAX(A:A))),
startValues,INDEX(totalsPrev,columns),
values,startValues+rowsOut,
endValues,INDEX(totals,columns),
IF(values<=endValues,values,"")
)

The basic idea is to develop running totals of the data, then use those totals to define the start and end points of the data in each column of the output array.
Comment: Really nice. I thought of making a single formula as well, but was not far enough along before I had to quit and get some real work done. Some rain could have helped, I suppose. Just curious, why do you not do SEQUENCE? As LET is 365, SEQUENCE is in the same version. I time tested SEQUENCE once and found it to be slow and should be used sparingly, but never compared it to ROW(x:INDEX.
Comment: Thanks Mark. Good question - I don't have anything against using SEQUENCE at all (although I hadn't thought about the time implications), but in this case I wanted to use ROW and COLUMN with it and the only way I could think of was to start with an actual range rather than an array.
Comment: SEQUENCE has become a crutch to me, so I should use ROW(INDEX more often because it works in older versions. Someday (maybe) I will time test the two. I once did a reshaping & reordering formula with SEQUENCE for a range involving 1000's of cells and saw the impact of SEQUENCE, so I reworked the formula to do only 3 SEQUENCES instead of 6. At that scale, the impact was noticeable.


Xilinx loop has iterated 64 times error

Question: I am writing code for a pipeline multiplication algorithm and while synthesizing using xilinx 10.1, I am getting the following error:
"ERROR:Xst:1312 - Loop has iterated 64 times. Use "set -loop_iteration_limit XX" to iterate more".
How can I fix it or how can I find out what causes it?
Answer: Based on information from Xilinx webpage:

This error occurs if XST encounters a loop (typically a "while loop") that does not have a discrete termination. Rather than unrolling the loop forever, XST fails with this error during HDL analysis. A line number is not provided, but the error is reported within the context of the entity/module that is being analyzed.

You can solve that issue by adding e.g. set -loop_iteration_limit 256 to .xst file in your project. Additional information you can find here.

Xilinx loop has iterated 64 times error


Unusual Device Name In Windows Authentication Logs - JCIFS

Question: I've seen a few articles with similar host names, however, I can not seem to find a definitive cause.
We have seen some Windows security logs (from DC) linked to the lockout of an account; the host was not our usual format, but was in the following format:
JCIFS0_11_5C
Has anyone seen these, and could possibly shed light?
The user was connected in through VPN, so wondering if that caused issues.
Thanks!
Answer: JCIFS is a JAVA Linux component for connecting to Windows assets, via SMB(Samba).
If you are seeing that coming from a lockout event, it is most likely an issue in which some Linux system (appliance?) is configured to authenticate/authorize using a certain credential that most likely had a password change.
Some process was configured to do so at some point.
I am not very familiar with JCIFS but i have seen exactly the same issue you have, and also noticed the machine name comes in with JCIFS followed by numbers, in my case the numbers were 9_10_80. After extensive troubleshooting found the issue to be a RedHat system with the IP X.X.9.10 was causing the lockouts by attempting to use an account that had a password reset. So the 9_10 seems to have been the last two octets in my case.


Additive groups $\mathbb R$ and $\mathbb C$

Question: Are the additive groups $(\mathbb R,+)$ and $(\mathbb C,+)$ isomorphic in Zermelo–Fraenkel set theory with the negation of AC?
Added remark: I was told at a lecture that the groups are isomorphic while assuming the axiom of choice. A natural (above) question arose, but I was not able to sort that out. I did not realize before, that the negation of AC is a kind of useless axiom...
Comment: Note that for a specific statement like this, ZF with the negation of AC is functionally equivalent to just ZF. All that the negation of AC does is guarantee that some set of non-empty sets, somewhere, doesn't have a choice function. We have no way of knowing what that set is, and therefore it would be very difficult to leverage that existence into proving anything about the existence of certain functions between $\Bbb R$ and $\Bbb C$.
Comment: @JoséCarlosSantos More likely whether it's needed to define an isomorphism between them.
Comment: Try not to just post questions, as people won't know where to start to be able to help you (and you will get downvotes and close votes, as happened here). Try to explain what you have tried and where and why you got stuck/need help. It would also help if you said where you found this question (week X of course Y, where we covered topic Z).
Comment: Are you asking whether the axiom of choice is need to define $\mathbb R$, $\mathbb C$, and the addition on both of them?
Comment: @Arthur You are probably right.
Comment: To be more precise, are the additive groups above isomorphic in Zermelo–Fraenkel set theory with the negation of AC?
Comment: Your question has been closed, deleted, and now it is undeleted. To make sure it is not deleted again (and maybe even get back those downvotes), I suggest that you edit your question. Phrase it a bit better, explain what motivated you to ask it, what you had known at the time. Even though you received an answer (in fact two), you should still do it for posterity and for future readers.
Answer: As mentioned in the other answer, you cannot prove in $\sf ZF+\lnot AC$ that $\Bbb R$ and $\Bbb C$ are isomorphic as additive groups.
On the one hand, the failure of choice is not a localized statement. It tells you nothing about where it fails, it is consistent that any "reasonable set" and its power set are all well-orderable, so all the theorems with the axiom of choice follow immediately. In particular, it is perfectly reasonable that choice fails but $\Bbb R$ can be well-ordered, in which case there are Hamel bases for $\Bbb R$ and $\Bbb C$ over $\Bbb Q$, and the groups are isomorphic.
On the other hand, assumptions such as "Every set of reals has the Baire property" , "Every set of reals is Lebesgue measurable", or The Axiom of Determinacy (which itself implies the two former statements) imply—at least in the presence of Dependent Choice—that any homomorphism between Polish groups is continuous, so in particular any homomorphism between $\Bbb R$ and $\Bbb C$ is continuous. But it is fairly easy to show that no isomorphism can be continuous.
One should remark, however, about the consistency strength of such failures. If all sets are Lebesgue measurable (again, assuming Dependent Choice), then a theory stronger than just $\sf ZF$ is consistent. Even more in the case of Determinacy. However, the assumption that every set has the Baire property does not increase the consistency strength.
Answer: Without the axiom of choice (or a suitable similar assumption), you cannot prove that the two groups are isomorphic. On the other hand, you cannot prove that they aren't isomorphic either.
Assuming ZF is consistent, ZF is consistent both with axioms which let you prove the isomorphism (like AC), and with axioms which let you disprove it (see the answer by Asaf Karagila). That means that isoomorphism cannot be shown either way from ZF alone.
Comment: @byk7 No common axioms that I can think of right now. Although, you could probably add this non-isomorphicness specifically as an axiom. It would seem kindof forced, but I believe you would get a consistent system (as consistent as ZF) out of it.
Comment: Got it. A natural question arises – are the groups not isomorphic in some ZF + a suitable axiom?
Comment: @byk7: Every set of reals has the Baire Property/Lebesgue measurable. The former does not require stronger axioms.
Comment: *Why* can't one prove this?!
Comment: @user1729 Because (assuming ZF is consistent), ZF is consistent both with axioms which let you prove it (like AC), and with axioms which let you disprove it (see the answer by Asaf Karagila). That means that it cannot be shown either way from ZF alone.
Comment: @Arthur Your answer would be much improved if you edited in your comment... :-)


Como fazer um menu horizontal simples e responsivo?

Question: Olá.
Comecei a estudar front-end development recentemente(praticamente ontem) e estou tendo alguns problemas com CSS. Sou horrível com posicionamento das coisas, e o que me deixa furioso é que consigo fazer algumas gambiarras para deixar os elementos/itens bem posicionados na tela full, mas quando eu diminuo ela, os itens começam a sair do lugar, das caixas, dos headers etc. Fica tudo extremamente zuado.
Segue abaixo meu código e como ficou o menu.
obs: a classe "menu" está dentro da classe "containertopo".
*
{
 margin: 0px;
    padding: 0px;
    list-style: none;
    text-decoration: none;
}

.containertopo
{
    position: relative;
    width: 100%;
    height: 79px;
    background-color:deepskyblue;
    opacity: 0.5;

}

.containertopo img
{
width: 99px;
float: left;
margin-left: 17%;
}

.menu
{

display: inline-block;
}

.menu ul
{
    margin-left:4em;
}

.menu ul li
{

    display: inline-block;
    margin: 2em;
}

Answer: Apesar de não ter postado o seu HTML e não sabermos bem o que é o quê percebi o problema e acredito que consiga ajustar isto ao seu caso:
O truque neste caso é jogar com o comprimento em relação ao elemento pai, por ex
 em relação a
 e
 em relação a  etc.. e pô-lo em %, e também jogar com max-with

*, *:before, *:after {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}

nav {
  background-color: coral;
  width: 100%;
}
ul {
  width:100%;
  max-width: 800px;
  margin: 0 auto;
  text-align:center;
  padding:0;
  font-size:0;
}
img {
  width:60px;
}
li {
  width: 20%;
  display: inline-block;
  font-size:16px;
  border: 1px solid;
  vertical-align:middle;
}

    olá

    hey

    hello

    hola

Nota que com media queries você conseguia de facto mostrar um botão de menu se a janela estivesse a menos de X px, ou o logotipo desaparecer, etc...
PS: font-size: 0 é para retirar a margem com que os elementos filhos com display:inline-block ficam. Nunca percebi bem o porquê da margem acontecer. E box-sizing: border-box; é para a border ficar para dentro do elemento e não para fora, é só pelo exemplo.
Answer: Dê uma olhada nesse simples exemplo:
http://codepen.io/colombe/pen/YqZKxL?editors=1100
O que eu te aconselho é:

Não use px (pixels), use porcentagens para dar tamanho. Para textos, use EM´s.
Aprenda a usar display:flex no seu contenedor (isso fará que todos os elementos DENTRO desse contenedor se alinhem de forma mágica).
Além de por display:flex no contenedor, acrescente: flex-flow: row wrap; (isso vira mágica ao diminuir a janela do navegador).
Quando você diminui MUITO a janela, coloque uma media-query (ou seja, nas últimas linhas do seu CSS, ponha algo assim: @media (max-width:400px){flex-flow:column nowrap;}
Vc está dizendo o seguinte: quando diminua pra menos de 399, em vez de que meu menu fique em uma linha, ficará em uma coluna!!! Tudo o que estiver dentro dessa DIV contenedor, se comportará assim!!!

Te mostro outro exemplo: http://codepen.io/colombe/pen/ezmjXq
Espero ter ajudado


Recommend reading why we have 12 pitches and another metrics in microtonal music?

Question: I know there are many books which describe why we have 12 pitches (for example this book: R.H.M Bosanquet - An elementary treatise on musical intervals and temperament, 1876 in the public domain).
These books focus on attempts to make mathematical formulas for pitches but few look at why we like to listen to the specific tones in the Western scales.
Reading articles by the inventors of microtonal music systems also addresses some things in this area.
But I am looking for more direct/clear reading about this.
Comment: This looks like a list question.
Comment: I agree @neilfein. But this question is really nice. Addressing fundamental concepts can encourage learners to become more diligent  about music.
Comment: [This math stack exchange question is useful](https://math.stackexchange.com/questions/11669/mathematical-difference-between-white-and-black-notes-in-a-piano)
Answer: I would recommend connecting with the Just Intonation Network. They have a bookstore of many worthwhile books on the topic. David Doty, who used to be with the network, has an excellent primer on just intonation that's available at his website.
The best work I've read on the topic from an intuitive rather than mathematical perspective is W. A. Mathieu's Harmonic Experience. It's truly an amazing work, breaking down the ideas of harmony into their parts before putting it all back together again. I highly recommend it.
Hope this helps!
Answer: Go looking for Howard Goodall's Big Bangs in Music. It is intended for a mainstream audience but it covers natural intervals and the various historical attempts at harmonising them until we arrived at the Westen even-tempered scale.
Answer: If you really want to get deep into the theory and the reasons that 12 tones "sound right", I can't recommend Harry Partch's Genesis of a New Music enough. He does have his hobbyhorse to ride on why equal temperment is bad and why we really need 43 tones to the octave, but the presentation of the bases for tuning and the twelve-note scale are detailed, clear, and very well done. It's a more mathematical treatment, but you don't have to understand much more than ratios to understand it.
His take is that we listen to many intervals that are not perfect, i.e., properly-tuned ratios of notes - exact ratios of frequencies sound purer and "sweeter" than the compromise intervals we use in equal temperment - and accept them because of the difficulty of constructing instruments which can play arbitrary intervals: the 12-note keyboard being a particular problem from his perspective.
He throws out other temperments (meantone, etc.) as making one scale perfect at the expense of all the others sounding less good, or even actively bad; his take is that we should be able to construct a full "circle-of-fifths" of scales, all of which sound as consonant as the scale based on the note we choose as the base note for our scales. Fascinating book, and well worth reading.
Comment: Also worth reading, albeit unnecessarily confrontational: http://sonic-arts.org/mclaren/partch/errors.htm


Laravel Url Rewrite and avoid the public folder

Question: I've added the following to my public/.htaccess file in my laravel project.
#### Force lower case URL ####
RewriteCond %{REQUEST_URI} ^[^A-Z]*[A-Z].*
RewriteRule ^ ${lc:%{REQUEST_URI}} [L,R=301]

It works as far as converting all upper-case characters to lower, however it reroutes the url to the public folder.
ie. /jobs gets rerouted to /public/jobs
Is there away to avoid this?
Answer: You shouldn't edit or add .htaccess file, edit index.php etc. What you should do is point web server to a public directory instead of root one.
If you're using Apache, edit these lines in a virtual host block:
DocumentRoot "C:/projects/laravel/public"
<Directory "C:/projects/laravel/public">

Restart Apache and everything will work as expected.


Showing only one of the Field Collection fields through Views

Question: I created a Field Collection field for a content type. This FC has two fields inside: an image field where I can upload unlimited number of image; and the other one is the title field to be used as a caption for these images.
Now the problem arises when I try to view this content type through Views where I can not modify each FC field but the whole FC. For example, if I had a content type with an image and a title field in Views I could manipulate the image field controlling the image style, the linking if the image links to the file or nothing etc. But since I use FC I can not access the image field settings anymore through Views.
The reason I want to manipulate the FC image field is that I want to use Colorbox inside my image gallery. But first I want to link all these images shown through Views to the node of each image gallery and then I want it to be seen with Colorbox.
Note: I tried to use in the FC settings Output this field as a link but it links only from the title field of FC not from the image field and, as I explained above, I can't manipulate the image field to make it have these settings.
Can someone help me out with this problem?
Thank you!
Answer: Did you try to ad a new view with "Show: Field Collection Item" and then, you need different relationships and contextual filters. My Field collection Item is called Gallery and Caption
I've got the following relationships (right column of the views):

"Field collection item: entity with the Gallery and Caption" (this
one connects the field collection item with my contenttype gallery)
"(Field_gallery_and_caption) File Usage: File"  "Field collection
item: Gallery Image:fid"

And following Contextual Filters (also right column of the views):

(field_gallery_and_caption) Content: Nid
Field collection item: Gallery Image:fid

I'm not sure about the order of adjustment, you have to try a little bit. But through relationships and contextual filters, you can get new fields for the views. And while configuring the fields (left column of views), there appears a dropdown called "Relationship", try different settings here, it changes the result.
Not the most detailed help but try to change the settings and you gonna get a result...
Comment: Thank you for the explanation sinini, don't you worry it's helpful enough ;)
Comment: saved few hours !
Answer: Old question so maybe you couldn't do that but now you can:

Use the displays provided by Field Collection (Structure>Field Collections>Manage display). I used the token display for instance and put out the fields I didn' t want to show.
Go to your View, and for the configuration of the Field Collection you want to use, put Formatter to "Fields only" and then choose your view mode (as I said, I used Token)

And that's it! =)
Answer: A very easy way to limit amount of field-(collection)-items to show (and also skip some) is using the module Field multiple limit. From the modules description:

This is a simple module that provides settings to limit the number of values to display on fields with multiple values.
The module extends the field display settings for fields which permit multiple values. Site administrators can specify how many values to display for each display mode (e.g. teaser). Optionally, an off-set can be specified to skip some values.

The Drupal 7 version depends on Field formatter settings API module.


What is the difference between stochastic calculus and stochastic analysis?

Question: I guess one could say that Calculus is just a non-rigorous version of Analysis.
What about in subjects involving stochastic processes? I took up masteral classes called stochastic calculus. I plan to pursue a PhD with my dissertation in stochastic what? Calculus or Analysis? Some professors in mathematics department websites I've seen (including my own university's) say their area of research is "stochastic analysis" not "stochastic calculus".
When should I say Stochastic Calculus or Stochastic Analysis?
Comment: I feel like analysis had a lot of $\forall,\exists,\epsilon,\delta,<$ symbols, while calc has more $\int,\operatorname d\!x,\infty,=$ symbols. Not sure if my assessment is accurate.
Comment: @columbus8myhw Cool summary, but I'm primarily wondering how this applies to stochastic processes.
Answer: Stochastic calculus is to do with mathematics that operates on stochastic processes.
The best known stochastic process is the Wiener process used for modelling Brownian motion.
Other key components are Ito calculus & Malliavin calculus.
Stochastic calculus is used in finance where prices can be modelled to follow SDEs. In the Black-Scholes model, prices follow geometric Brownian motion.
The Ito integral is one of the major components in stochastic calculus. It is defined as the integral
\begin{equation*}
\int HdX
\end{equation*}
where $X$ is a semimartingale & $H$ is a locally bounded predictable process. Note that we cannot use the generalized Riemann-Stieltjes integral because strong bounded variation is assumed & Brownian motion is not of bounded variation.
Stochastic analysis is looking at the interplay between analysis & probability.
Examples of research topics include linear & nonlinear SPDEs, forward-backward SDEs, rough path theory, asymptotic behaviour of stochastic processes, filtering, sequential monte carlo methods, particle approximations, & statistical methods for stochastic processes.
Something I am interested in is how probabilistic techniques can be used to settle problems in in harmonic analysis, such as proving the $L^p$ boundedness of the Riesz transform. For $f\in C^1_K:$
\begin{equation*}
||R_jf||_p\leq c||f||_p,~1<p<\infty
\end{equation*}
for some constant $c.$
A technique is to give a probabilistic interpretation of the Riesz transform before proving $L^p$ boundedness:
\begin{equation*}
R_jf(x)=c\lim_{s\to\infty}\mathbb{E}^{(0,s)}_{x}\int^{\tau}_{0}A\bigtriangledown u(Z_r)\cdot
\end{equation*}
where  $u$ is the harmonic extension of $f,~f\in C^{\infty}_K.$ Here $A$ is the $(d+1)\times (d+1)$ matrix with $A_{ik}$ zero unless $i=d+1,~k=j,$ in which case it is one.  Here, $Z_t$ is Brownian motion in $\mathbb{R}^2.$
I hope this is okay. I am happy to expand on any points in more detail if you would like.
Comment: In the Ito integral definition, the measure you integrate with respect to is one-dimensional Brownian motion. Although it is my opinion, I agree with this inclusion. stochastic calculus is used to give a strong theory for stochastic integrals and it operators on stochastic processes. Stochastic analysis is the when rigorous analysis is involved, and includes topics such as Schramm Loewner evolutions.

I'm not really the most qualified on advising PhD proposals (I am a PhD student myself). I would check with a probabilist in your department or your supervisor.
Comment: Thanks for the extra reputation!
Comment: I spent a good portion of time learning about the Beurling-Ahlfors transform and Iwaniec conjecture. These are closely related to martingales, and so I had to brush up on my probability fast. Harmonic analysis is very closely linked to probability. I think Elias Stein pointed that certain problems in harmonic analysis could be approached via probabilistic techniques (such as the Iwaniec conjecture on the $L^p$ norm of the Beurling-Ahlfors transform).
Comment: Broadly, my current research interests are Euclidean harmonic analysis, spectral theory, wave equation techniques and restriction estimates. When reading, I sometimes get a bit carried away and end up looking at other topics such as calculus of variations, representation theory and lie algebras.
Comment: Both. I needed a good understanding of how harmonic analysis interacts with martingales to understand the Iwaniec conjecture, and I had not taken many advanced probability courses so I needed to teach myself topics on Brownian motion fast.
Comment: Cool thanks George S. 1 Where's Brownian motion in the Ito Integral definition? 2 What do you think of the inclusion in this comment?http://meta.math.stackexchange.com/questions/3805/whats-the-difference-between-the-various-stochastic-blah-tags#comment14188_3805
Comment: Oh also, does it make sense then for mathematicians to say their research is in 'stochastic calculus' ? Say for a PhD proposal, do I propose to research in 'stochastic calculus' or 'stochastic analysis' ? Going over your answer again, it seems indeed that the relationship between the two is very similar to the relationship between calculus and analysis
Comment: Whoa man https://en.wikipedia.org/wiki/Schramm%E2%80%93Loewner_evolution
Comment: Wait George, how do you know all this if your research area is [Euclidean harmonic analysis and PDEs.] (http://math.stackexchange.com/users/230715/george-simpson) ? Was probability or stochastic whatever your previous research area or something?
Comment: Cool. CoV is used in Malliavin calculus, I read. Uh, are the things in your answer from your being carried away or brushing up on probability?
Comment: Cool. Alright thanks George Simpson. For being such an inspiration: o7


Atom won't search (ctrl-p) files, that aren't in current git repo (grey folders)

Question: Atom won't search (ctrl-p) files, that aren't in current git repo (grey folders). I really need that function, and files that i have to look up (framwework files) are in grey folders, where ctrl-p (file search) doesn't reach.
Answer: The Fuzzy Finder ignores files that are ignored by your VCS (Git in your case) by default.
You can change that behavior by removing the check on the "Exclude VCS Ignored Paths" checkbox in the general settings:
Answer: You can choose Find - Find File from menu of Atom to search files.


Getting error "Unable to find replication strategy class 'org.apache.cassandra.locator.simplestrategy" while creating keyspace

Question: I have installed "DataStax Distribution of Apache Cassandra 3.9.0".
After opening cassandra CQL shell i ran the below command
Create keyspace KeyspaceName
with replicaton{'class':'simplestrategy','replication_factor': 1}

But i am getting an error:
Unable to find replication strategy class 'org.apache.cassandra.locator.simplestrategy'

Comment: I got the answer. Actually i was giving the name as 'simplestrategy'..It should be 'SimpleStrategy'. Also the keyspace name should be quoted  i.e it should be "KeyspaceName".
Comment: Keep in mind you need "" around your keyspace name if you want it to take the case sensitivity into account.
Answer: The replication strategy class name is case sensitive in CQL, the correct syntax for a SimpleStrategy with replication factor of 1 is:
CREATE KEYSPACE my_keyspace
WITH replication = {'class': 'SimpleStrategy', 'replication_factor' : 1}

Answer: Cassandra is case sensitive so you should use SimpleStrategy instead of simplestrategy and no spaces in between are appreciated.