The proof of this tensor identity

Question: I found that $\epsilon^{ijk}g_{jm}g_{kn}=\det(g)g^{il}\epsilon_{lmn}$, is it correct? What's proof of it? This formula was found when I was studying tensor cross product, I tried to prove that if $A\times B=C$ holds for $A^i,B^i,C^i$, it will also holds for $A_i,B_i,C_i$.
For example:
Comment: There seems to be a discrepancy between indices on the left-hand and the right-hand sides of the equation.  Did you mean to write $$\epsilon^{ijk}g_{{\color{red}{j}}m}g_{kn}=\ldots\,?$$
Comment: g is metric tensor
Answer: Presumably, you are dealing with a three-dimensional space.  If you are dealing with a $d$-dimensional space, then I think this is true:
$$\epsilon^{i_1i_2\ldots i_d}g_{i_2j_2}g_{i_3j_3}\cdots g_{i_dj_d}=\det(g)\,g^{i_1j_1}\,\epsilon_{j_1j_2\ldots j_d}\,.$$
The proof for the general case is essentially the same.
Back to the original problem, let $(x^l)$, $(y^m)$, and $(z^n)$ be arbitrary ($3$-dimensional) vectors.  We want to show that
$$\epsilon^{ijk}g_{jm}g_{kn}x_iy^mz^n=\det(g)\,g^{il}\epsilon_{lmn}x_iy^mz^n\,.$$
However, $x_i=g_{il}x^l$, so
$$\epsilon^{ijk}g_{jm}g_{kn}x_iy^mz^n=\epsilon^{ijk}g_{il}g_{jm}g_{kn}x^ly^mz^n\,,$$
whereas
$$\det(g)\,g^{il}\epsilon_{lmn}x_iy^mz^n=\det(g)\,\epsilon_{lmn}x^ly^mz^n\,.$$
Thus, it suffices to prove that
$$\epsilon^{ijk}g_{il}g_{jm}g_{kn}=\det(g)\,\epsilon_{lmn}\,.\tag{*}$$
In the right-hand side of (*), if $l$, $m$, and $n$ are not pairwise distinct, then it equals $0$.  If $l=m$, for instance, then the left-hand side is
$$\epsilon^{ijk}g_{il}g_{jm}g_{kn}=\epsilon^{ijk}g_{im}g_{jl}g_{kn}=\epsilon^{jik}g_{jm}g_{il}g_{kn}=-\epsilon^{ijk}g_{il}g_{jm}g_{kn}\,.$$
Therefore, the left-hand side is $0$ as well.
Now, suppose that $(l,m,n)$ is a permutation of $(1,2,3)$ with sign $s\in\{-1,+1\}$.  Thus, the right-hand side of (*) is numerically $s\,\det(g)$.  On the other hand, by a direct expansion of determinant, we get
$$\epsilon^{ijk}g_{il}g_{jm}g_{kn}=\det\left(\begin{bmatrix}g_{1l}&g_{1m}&g_{1n}\\g_{2l}&g_{2m}&g_{2n}\\g_{3l}&g_{3m}&g_{3n}
\end{bmatrix}\right)\,.$$
Because
$$\begin{bmatrix}g_{1l}&g_{1m}&g_{1n}\\g_{2l}&g_{2m}&g_{2n}\\g_{3l}&g_{3m}&g_{3n}
\end{bmatrix}=\begin{bmatrix}g_{11}&g_{12}&g_{13}\\g_{21}&g_{22}&g_{23}\\g_{31}&g_{32}&g_{33}
\end{bmatrix}P=gP\,,$$ where $P$ is the permutation matrix corresponding to the permutation $(1,2,3)\mapsto(l,m,n)$, we get that the numerical value of the left-hand side of (*) is $$\epsilon^{ijk}g_{il}g_{jm}g_{kn}=\det(gP)=\det(g)\,\det(P)=s\,\det(g)\,,$$
as $\det(P)=s$.

The proof of this tensor identity


Network Shared Drive

Question: We have window server 2016. The server are configured as a domain.
I tried to explore in the disk management, but stuck after creating new volume for E (external hard disk). D is the existed network shared folder  access that are granted for users.

What do I need to do, to increase the storage size? Currently the storage size is 1.36TB and we are left with 240GB in the server.

How do I go about the configuration?
Thanks so much.
Answer: Do you have any RAID configuration in the server? (I assume and I hope so), However if you need more space you have to replace the disk (s), this depends on your eventual RAID configuration.
Comment: Yes we have it unde RAID. Wanted to extend the network shared folder but got lost on how to go about it as scared if the network will be down as user not able to access the file and server.
Answer: Do you mean increasing the size of the D: Drive on your Server, making the size of the Network Drive the same as the D: Drive, or just increasing the Network drive capacity?
To increase the size of your D: Drive you need to know what kind of drive that is. If its a RAID you might be able to extend it but how will wary between type and manufacturer. If its just a drive you can replace it or make it a RAID through a physical controller (formates the drive!) or windows dynamic disks.
If you want to expand the size of your network storage, having multiple network drives will make your live easier as you can just move the network share to a newly installed drive.
Comment: Apparently our D drive is set to mirrored the L drive. L drive is the official shared folder that is being access through the network for the users. They had been granted with permission rights.

Network Shared Drive


How do I change the position of "sidebar first" for the Arabic version of website?

Question: Can I change the position of the "sidebar first" if I change the website language?
More Details: My default website language is now English, and my "sidebar first" is in left position. This is what I want: to change the position of the "sidebar first" if I make the website in the Arabic language.
Comment: yes, but how depends on the theme, and how you're implementing the multi-language site
Comment: I have the interlocalization module and all configuration by default
Comment: that's not the name of a module I am aware of... do you mean internationalization?
Comment: Yes that's it !!!
Comment: then J.Reynolds answer should work
Answer: Install the Context module.

Context allows you to manage contextual conditions and reactions for
  different portions of your site. You can think of each context as
  representing a "section" of your site. For each context, you can
  choose the conditions that trigger this context to be active and
  choose different aspects of Drupal that should react to this active
  context.

Make sure that Multilingual select which is part of the Internationalization module is also installed (this will provide the proper condition).
You can now create a new context that has a condition of 'Language' and a reaction of 'Blocks'.
You will create a condition-reaction pair for two cases. First for all the LTR languages, second for all the RTL languages.
Allthough this does not directly answer your question as to regions, you can play around with the reactions, such as template suggestions etc to achieve your objective.
Comment: @SeifBh why doesn't this help you - you need to provide more information - does it not work, does it not work the way you want, do you not want to include a module for some reason, etc. Your response doesn't help us, help you
Comment: You'r answer dosen't help me


ASP.NET Not Recognizing Added Wizard Step

Question: So I'm adding a step to the basic register user Wizard on the default register.aspx page in ASP.NET. I added the step into the markup and everything looks right, but when I load up the page in Chrome/IE, that step isn't showing up after i complete the first step. All i changed in the first, default step was the button (to make it say "Next"), but when i click that it just completes the form and redirects to default.aspx - never loading that second step.
Here's my markup (I removed some of the generic stuff that i didn't touch for readability's sake)
UPDATE: I redid the wizard from scratch (deleted and added a new one) and added one step in via markup. Now, when i view the page, i see the first step (and the "next" button reads "create user"). I fill it out and hit "create user" and i see the same step, except this time the button says "next"... i fill it out again and hit next and see the second step. fill that out and hit finish and all goes as planned.
<asp:CreateUserWizard ID="RegisterUser" runat="server"  OnFinishButtonClick="RegisterUser_CreatedUser">
    <WizardSteps>
        <asp:WizardStep runat="server" StepType="Start">
            /*Generic Stuff */
            </asp:WizardStep>
        <asp:WizardStep ID="personalinfo" runat="server" StepType="Auto" >
         /* Custom Wizard Step Content */
        </asp:WizardStep>

    </WizardSteps>
</asp:CreateUserWizard>

So basically, that middle step gets skipped. I hit the "Next" button on step 1 and it just completes the wizard. Here's my Code Behind:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Account_Register : System.Web.UI.Page
{

    protected void Page_Load(object sender, EventArgs e)
    {
        RegisterUser.ContinueDestinationPageUrl = Request.QueryString["ReturnUrl"];
    }

    protected void RegisterUser_CreatedUser(object sender, EventArgs e)
    {
        FormsAuthentication.SetAuthCookie(RegisterUser.UserName, false /* createPersistentCookie */);

        string continueUrl = RegisterUser.ContinueDestinationPageUrl;
        if (String.IsNullOrEmpty(continueUrl))
        {
            continueUrl = "~/";
        }
        // My Custom Stuff Here
        Response.Redirect(continueUrl);
    }

}

Thanks! Let me know if i need to provide any more info...(not that there's anything more to provide...)
Answer: You have a button in each wizard item.  This is causing the page to submit.  You should have a navigation bar as part of the Wizard that will navigate back & forth.....
The default registration wizard as part of a VS 2010 Web App only has one step so they put the button in the only step.  However, you want to add a step.  You'll need to work on the custom navigation to add the next buttons and your final submit.
Here's a nice article on modifying a wizard.
This link and this link are a little older but go into more specifically modifying the Create User wizard and are still relevant since very little has changed on this wizard.
Comment: thanks so much and sorry for my untimely reply. I acted on your solution and redid the wizard, but i'm stil getting problems. I updated the question with more details.


Arquivo .keystore e .jks Android

Question: Percebi que a Google tem o serviço Manage your app signing keys, que é possível substituir a minha chave com a chave do google.
Para isso devo seguir uns passos que é:

Faça o download da ferramenta PEPK para exportar e criptografar sua chave privada.
Use o comando abaixo para executar a ferramenta que exportará e criptografará sua chave privada. Certifique-se de substituir os argumentos destacados em negrito. Em seguida, digite as senhas da chave e da keystore nas solicitações.
$ java -jar pepk.jar --keystore=foo.keystore --alias=foo --output=encrypted_private_key_path --encryptionkey=chave criptografada
Faça o upload da sua chave privada de assinatura de app criptografada.
Gere uma nova chave de upload. Siga estas instruções para gerar uma nova chave.
Exporte o certificado da chave de upload gerada recentemente para o formato PEM. Certifique-se de substituir os argumentos destacados em negrito.
$ keytool -export -rfc -keystore upload-keystore.jks -alias upload
-file upload_certificate.pem
Faça o upload do certificado da sua chave de upload para fazer o registro no Google.

Só que eu parei na segunda porque não tenho o arquivo .keystore (pelo menos, eu acho) eu tenho o jks que eu criei no ato da criação do apk assinado.
A pergunta:
O arquivo .jks pode ser esse .keystore ? Ou tenho que gerar esse arquivo?
Comment: amigo, estava com as mesmas dúvidas talvez isso aqui possa ajudar https://stackoverflow.com/a/44103025
Answer: .keystore ou .jks são apenas variações de um mesmo tipo de arquivo. Existe também a possibilidade desse arquivo ser criado sem nenhuma extensão, pois é um tipo de arquivo que fica implícito pelo Java (Mas não recomendo fazer isso! Sempre crie-o com extensão para melhor identifica-lo quando precisar). Espero que tenha ajudado.

Arquivo .keystore e .jks Android


MCR: segmentation violation detected on Linux x64 machine

Question: we have just intalled MCR for a linux x64 machine, and we are getting the error below when trying to run our algorithm. No problem running that algorithm in other machine we are using.
Any help?
<code> ------------------------------------------------------------------------
         Segmentation violation detected at Tue May 26 10:27:27 2015
  ------------------------------------------------------------------------

  Configuration:
    Crash Decoding     : Disabled
    Current Visual     : 0x21 (class 4, depth 24)
    Default Encoding   : UTF-8
    GNU C Library      : 2.21 stable
    MATLAB Architecture: glnxa64
    MATLAB Root        : /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81
    MATLAB Version     : 18.104.22.1684 (R2013a)
    Operating System   : Linux 3.19.0-15-generic #15-Ubuntu SMP Thu Apr 16 23:32:37 UTC 2015 x86_64
    Processor ID       : x86 Family 6 Model 42 Stepping 7, GenuineIntel
    Virtual Machine    : Java 1.6.0_17-b04 with Sun Microsystems Inc. Java HotSpot(TM) 64-Bit Server VM mixed mode
    Window System      : The X.Org Foundation (11701000), display :0

  Fault Count: 1

  Abnormal termination:
  Segmentation violation

  Register State (from fault):
    RAX = 0000000000000000  RBX = 00007f257d226160
    RCX = 0000000000000000  RDX = 0000000000000003
    RSP = 00007f25f720fff0  RBP = 00007f25f7210110
    RSI = 0000000000000000  RDI = 00007f257d225350

     R8 = 0000000000000018   R9 = 0000000000000000
    R10 = 00007f257d225000  R11 = 00007f257d226478
    R12 = 00007f257d490fa0  R13 = 0000000000000006
    R14 = 00007f257d225758  R15 = 00007f25f2400580

    RIP = 00007f260e9158ba  EFL = 0000000000010206

     CS = 0033   FS = 0000   GS = 0000

  Stack Trace (from fault):
  [  0] 0x00007f260e9158ba                        /lib64/ld-linux-x86-64.so.2+00051386
  [  1] 0x00007f260e91e4b1                        /lib64/ld-linux-x86-64.so.2+00087217
  [  2] 0x00007f260e919464                        /lib64/ld-linux-x86-64.so.2+00066660
  [  3] 0x00007f260e91d9a3                        /lib64/ld-linux-x86-64.so.2+00084387
  [  4] 0x00007f260d28afc9                   /lib/x86_64-linux-gnu/libdl.so.2+00004041
  [  5] 0x00007f260e919464                        /lib64/ld-linux-x86-64.so.2+00066660
  [  6] 0x00007f260d28b62d                   /lib/x86_64-linux-gnu/libdl.so.2+00005677
  [  7] 0x00007f260d28b061                   /lib/x86_64-linux-gnu/libdl.so.2+00004193 dlopen+00000049
  [  8] 0x00007f26098d0ce1 /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81//bin/glnxa64/libut.so+00281825
  [  9] 0x00007f2602060354 /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwm_dispatcher.so+00328532
  [ 10] 0x00007f260205487d /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwm_dispatcher.so+00280701 _ZN13Mlm_MATLAB_fn8try_loadEv+00000045
  [ 11] 0x00007f260204b95e /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwm_dispatcher.so+00244062 _ZN13Mfh_MATLAB_fn11dispatch_fhEiPP11mxArray_tagiS2_+00000078
  [ 12] 0x00007f25ffe6d11c /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwmcos.so+02208028
  [ 13] 0x00007f260208a58c /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwm_dispatcher.so+00501132
  [ 14] 0x00007f260205fa6a /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwm_dispatcher.so+00326250
  [ 15] 0x00007f260204baf8 /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwm_dispatcher.so+00244472 _ZN13Mfh_MATLAB_fn11dispatch_fhEiPP11mxArray_tagiS2_+00000488
  [ 16] 0x00007f26010f3778 /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwm_interpreter.so+02107256
  [ 17] 0x00007f26010f31f9 /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwm_interpreter.so+02105849
  [ 18] 0x00007f2601051acc /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwm_interpreter.so+01444556 inCallFcnWithTrap+00000092
  [ 19] 0x00007f25fc21cbda /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libuij.so+00125914
  [ 20] 0x00007f25fc219039 /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libuij.so+00110649
  [ 21] 0x00007f25fc219268 /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libuij.so+00111208
  [ 22] 0x00007f25fc2193d9 /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libuij.so+00111577
  [ 23] 0x00007f25fc236977 /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libuij.so+00231799
  [ 24] 0x00007f25fc237f8d /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libuij.so+00237453
  [ 25] 0x00007f25fc238024 /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libuij.so+00237604 _Z16UIJ_SetJavaFrameP10WinRec_tagPvb+00000020
  [ 26] 0x00007f25fed65a05 /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwhg.so+05204485
  [ 27] 0x00007f25fed7351b /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwhg.so+05260571 UIJ_CreatePeerWindow+00000443
  [ 28] 0x00007f25fdd1c848 /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwuix.so+00493640 _Z20create_figure_windowP10WinRec_tag+00000424
  [ 29] 0x00007f25fedbc492 /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwhg.so+05559442
  [ 30] 0x00007f25fedbd5ff /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwhg.so+05563903
  [ 31] 0x00007f25fee61537 /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwhg.so+06235447
  [ 32] 0x00007f25ffa04e0d /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwudd.so+00728589
  [ 33] 0x00007f25ffa00e55 /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwudd.so+00712277 _ZN11UDInterface32notifyChildAddedAndParentChangedEPS_+00000213
  [ 34] 0x00007f25ffa01178 /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwudd.so+00713080 _ZN11UDInterface8addRightEPS_+00000328
  [ 35] 0x00007f25ffa014b8 /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwudd.so+00713912 _ZN11UDInterface13addFirstBelowEPS_+00000072
  [ 36] 0x00007f25fee3ba2f /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwhg.so+06081071
  [ 37] 0x00007f25fee62126 /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwhg.so+06238502
  [ 38] 0x00007f25ff9fe8f9 /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwudd.so+00702713 _ZN11UDInterface4setEEP16UDDatabaseClientP10UDPropInfoPvP13UDErrorStatus+00001065
  [ 39] 0x00007f25fee6053c /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwhg.so+06231356
  [ 40] 0x00007f25fee3939b /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwhg.so+06071195
  [ 41] 0x00007f25fee54741 /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwhg.so+06182721
  [ 42] 0x00007f25fee4437b /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwhg.so+06116219
  [ 43] 0x00007f25fee44b46 /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwhg.so+06118214
  [ 44] 0x00007f25fed736d3 /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwhg.so+05261011 hgFigure+00000243
  [ 45] 0x00007f25c66b7188 /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwhgbuiltins.so+00569736
  [ 46] 0x00007f25c668f43a /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwhgbuiltins.so+00406586
  [ 47] 0x00007f25c668f529 /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwhgbuiltins.so+00406825
  [ 48] 0x00007f260205fa6a /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwm_dispatcher.so+00326250
  [ 49] 0x00007f260204baf8 /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwm_dispatcher.so+00244472 _ZN13Mfh_MATLAB_fn11dispatch_fhEiPP11mxArray_tagiS2_+00000488
  [ 50] 0x00007f2601115256 /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwm_interpreter.so+02245206
  [ 51] 0x00007f26010c5a86 /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwm_interpreter.so+01919622
  [ 52] 0x00007f26010ca374 /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwm_interpreter.so+01938292
  [ 53] 0x00007f26010c6993 /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwm_interpreter.so+01923475
  [ 54] 0x00007f26010c7797 /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwm_interpreter.so+01927063
  [ 55] 0x00007f2601132e50 /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwm_interpreter.so+02367056
  [ 56] 0x00007f26020996b2 /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwm_dispatcher.so+00562866 _ZN8Mfh_file11dispatch_fhEiPP11mxArray_tagiS2_+00000594
  [ 57] 0x00007f2601301bf6 /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwm_interpreter.so+04262902
  [ 58] 0x00007f260130237a /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwm_interpreter.so+04264826
  [ 59] 0x00007f2601302eea /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwm_interpreter.so+04267754
  [ 60] 0x00007f2601165bbd /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwm_interpreter.so+02575293
  [ 61] 0x00007f2601191412 /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwm_interpreter.so+02753554
  [ 62] 0x00007f260119153f /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwm_interpreter.so+02753855
  [ 63] 0x00007f26012ae500 /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwm_interpreter.so+03921152
  [ 64] 0x00007f26010ca8ac /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwm_interpreter.so+01939628
  [ 65] 0x00007f26010c6993 /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwm_interpreter.so+01923475
  [ 66] 0x00007f26010c7797 /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwm_interpreter.so+01927063
  [ 67] 0x00007f2601132e50 /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwm_interpreter.so+02367056
  [ 68] 0x00007f26020996b2 /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwm_dispatcher.so+00562866 _ZN8Mfh_file11dispatch_fhEiPP11mxArray_tagiS2_+00000594
  [ 69] 0x00007f2601301bf6 /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwm_interpreter.so+04262902
  [ 70] 0x00007f260130237a /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwm_interpreter.so+04264826
  [ 71] 0x00007f2601302eea /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwm_interpreter.so+04267754
  [ 72] 0x00007f2601165bbd /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwm_interpreter.so+02575293
  [ 73] 0x00007f2601191412 /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwm_interpreter.so+02753554
  [ 74] 0x00007f260119153f /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwm_interpreter.so+02753855
  [ 75] 0x00007f26012ae500 /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwm_interpreter.so+03921152
  [ 76] 0x00007f26010ca8ac /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwm_interpreter.so+01939628
  [ 77] 0x00007f26010c6993 /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwm_interpreter.so+01923475
  [ 78] 0x00007f26010c7797 /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwm_interpreter.so+01927063
  [ 79] 0x00007f2601132e50 /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwm_interpreter.so+02367056
  [ 80] 0x00007f26020996b2 /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwm_dispatcher.so+00562866 _ZN8Mfh_file11dispatch_fhEiPP11mxArray_tagiS2_+00000594
  [ 81] 0x00007f26010f3778 /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwm_interpreter.so+02107256
  [ 82] 0x00007f26010f31f9 /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwm_interpreter.so+02105849
  [ 83] 0x00007f2601051acc /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwm_interpreter.so+01444556 inCallFcnWithTrap+00000092
  [ 84] 0x00007f26010b80fb /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwm_interpreter.so+01863931
  [ 85] 0x00007f2601050998 /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwm_interpreter.so+01440152 _Z28inCallFcnWithTrapInDesiredWSiPP11mxArray_tagiS1_PKcbP15inWorkSpace_tag+00000104
  [ 86] 0x00007f2601ab99a9 /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwiqm.so+02931113 _ZN3iqm15BaseFEvalPlugin7executeEP15inWorkSpace_tagRN5boost10shared_ptrIN14cmddistributor17IIPCompletedEventEEE+00000457
  [ 87] 0x00007f26028376a9 /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwmcr.so+00390825
  [ 88] 0x00007f2601a914fa /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwiqm.so+02766074
  [ 89] 0x00007f2601a804ad /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwiqm.so+02696365
  [ 90] 0x00007f25fdd195c6 /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwuix.so+00480710
  [ 91] 0x00007f25fdd26df2 /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwuix.so+00536050
  [ 92] 0x00007f260cc56862 /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81//bin/glnxa64/libmwservices.so+01845346
  [ 93] 0x00007f260cc5750f /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81//bin/glnxa64/libmwservices.so+01848591 _Z25svWS_ProcessPendingEventsiib+00001615
  [ 94] 0x00007f26028255ef /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwmcr.so+00316911
  [ 95] 0x00007f2602825f5c /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwmcr.so+00319324
  [ 96] 0x00007f260281f592 /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwmcr.so+00292242
  [ 97] 0x00007f260d85f6aa              /lib/x86_64-linux-gnu/libpthread.so.0+00030378
  [ 98] 0x00007f260d594eed                    /lib/x86_64-linux-gnu/libc.so.6+01076973 clone+00000109

  If this problem is reproducible, please submit a Service Request via:
      http://www.mathworks.com/support/contact_us/

  A technical support engineer might contact you with further information.
</code>
Comment: Maybe you should do exactly what the error message suggests: contact MathWorks to get a technical support engineer's feedback/advice.
Comment: I guess you should send this to the MATLAB support
Answer: NO, you don't need to run matlab a as root user. After installing Matlab, install matlab-support package,
<code> sudo apt-get purge matlab-support
</code>
, where you can configure who should able to the Matlab and so on.
Answer: You must run MATLAB as root user


Piping data from a file to a rendered page in Sails.js

Question: My application needs to read in a large dataset and pipe it to the client to manipulate with D3.js. The problem is, on large datasets, the reading/loading of the file contents could take a while. I want to solve this using streams. However, I'm unsure of how to do so in the context of the Sails framework.
What I want to do is read the contents of the file and pipe it to a rendered page. However, I can't figure out how to pipe it through if I use something like res.view('somePage', { data: thePipedData });.
I currently have something like this:
var datastream = fs.createReadStream(path.resolve(DATASET_EXTRACT_PATH, datatype, dataset, dataset + '.csv'));
datastream.pipe(res);
...
return res.view('analytics', { title: 'Analytics', data: ??? });

What's the best way to approach this?
Answer: Based on your example it seems like the best course of action would be to set up a separate endpoint to serve just the data, and include it on the client via a regular

MyViewController.js
res.view('analytics', {datatype: 'someDataType', etc...});

A slight variation on this strategy would be to use a JSONP-style approach; rather than wrapping the data in a variable in the data controller action, you would wrap it in a function.  You could then call the endpoint via AJAX to get the data.  Either way you'd have the benefit of a quick page load since the large data set is loaded separately, but with the JSONP variation you'd also be able to easily show a loading indicator while waiting for the data.
Comment: Thanks! If I use those script tags, how do I access the data within those tags?
Comment: In the simple case where `MyDataController.getData` outputs `var theData='';`, it'll be exposed as a global var called `theData` that you can use in other scripts on the page (or even other external scripts, provided they are loaded after the `/getdata` script tag)
Comment: Great, this is perfect!


Eclipse errors when creating a new android project

Question: I am getting these strange errors when I try to create an Android project in Eclipse (Mars). I tried to uninstall and reinstall both eclipse and the Android SDK but still getting the same error.
Is there some known error with the Android Wear system images in Eclipse?
Comment: why are you still using eclipse?
Comment: Your project isn't finding your styles - what is declared in your Manifest?
Comment: Not at my computer anymore, but I did solve the issue by reducing the target and compile Android version.
Comment: @njzk2 And I'm using eclipse because it works and Android studio is crazy slow. Is there something better out there I should be using?
Answer: Just reduced the target sdk and ignored the Android wear all together.


Is there a way to specify a lme model with more than one within-subjects factor?

Question: The data
Suppose we have a dataset d with two between-subject factors (i.e., groups), group and condition, and two within-subject factors (i.e., repeated-measures factors), topic and problem (I uploaded the data to pastebin, so everybody should be able to obtain it):
> d <- read.table(url("http://pastebin.com/raw.php?i=4hRFyaRj"), colClasses = c(rep("factor", 6), "numeric"))
> str(d)
'data.frame':   2928 obs. of  6 variables:
  $ code     : Factor w/ 183 levels "A03U","A08C",..: 1 1 1 1 1 1 1 1 1 1 ...
  $ group    : Factor w/ 2 levels "control","experimental": 2 2 2 2 2 2 2 2 2 2 ...
  $ condition: Factor w/ 3 levels "alternatives",..: 3 3 3 3 3 3 3 3 3 3 ...
  $ topic    : Factor w/ 4 levels "1","2","3","4": 1 1 1 1 2 2 2 2 3 3 ...
  $ problem  : Factor w/ 4 levels "AC","DA","MP",..: 3 4 1 2 3 4 1 2 3 4 ...
  $ mean     : num  94.5 94.5 86.5 84.5 80 46.5 73.5 43.5 51 39 ...

The data is from a behavioral experiment in which participants in six groups (2 levels of group times 3 levels of condition) worked on 16 tasks (for each of 4 topics 4 different problems). Allocation of participants to group/condition was fully random. Presentation of tasks was random insofar that problem was blocked within topic (i.e., for each topic all problems where presented sequentially), but order of problem and topic was random.
Update: The factor identifying the participant (in which topic and problem are nested) is code.
The Problem
How can I fit this dataset using lme?
(Sidenote: I would also consider using lme4, but I am kind of afraid of not having p-values, if there is something easily digestible as p-values, I would also consider lme4 an option).
So far I managed to fit an lme model with only one within-subject factor, but not two (see below).
What I tried
I can fit an lme model if I have just one within-subject factor:
require(nlme)
 m1 <- lme(mean ~ condition*group*problem, random = ~1|code/problem,
           data = d, subset = topic == "1")

anova(m1)
                        numDF denDF F-value p-value
(Intercept)                 1   531   12101  <.0001
condition                   2   177      31  <.0001
group                       1   177       2  0.2178
problem                     3   531      35  <.0001
condition:group             2   177       1  0.3672
condition:problem           6   531      24  <.0001
group:problem               3   531       1  0.2180
condition:group:problem     6   531       2  0.0281

This (especially the df) nicely correspond with the results from an standard ANOVA (using
ez):
require(ez)
ezANOVA(subset(d, topic == "1"), dv = .(mean), wid = .(code), between = .(condition, group), within = .(problem))$ANOVA

Warning: Data is unbalanced (unequal N per group). Make sure you specified a well-considered value for the type argument to ezANOVA().
                   Effect DFn DFd     F                             p p<.05     ges
2               condition   2 177 30.69 0.000000000003611248905859672     * 0.13079
3                   group   1 177  1.53 0.217821969825403999321267179       0.00374
5                 problem   3 531 34.85 0.000000000000000000014254103     * 0.10028
4         condition:group   2 177  1.01 0.367225806638525886782531416       0.00492
6       condition:problem   6 531 24.40 0.000000000000000000000000142     * 0.13503
7           group:problem   3 531  1.48 0.217959293081550348203379031       0.00472
8 condition:group:problem   6 531  2.38 0.028119961573665430004664856     * 0.01499

Trying to fit this data with two within-subject factors in lme fails (either per code, or per dfs):
m2 <- lme(mean ~ condition*group*problem*topic, random = ~1|code/(problem*topic), data = d)
# fails: Error in getGroups.data.frame(dataMix, groups) :
#  Invalid formula for groups

m3 <- lme(mean ~ condition*group*problem*topic, random = ~1|code/problem/topic, data = d)
# the next model takes some time (probably already an indicator, that it is the wrong model)
# and produces wrong denominator df!

# with both factors as ANOVA
m4 <- ezANOVA(d, dv = .(mean), wid = .(code), between = .(condition, group), within = .(problem, topic))

#effects are the same
all(row.names(anova(m3))[-1] == m4$ANOVA$Effect)

#denominator dfs are not:
anova(m3)$denDF[-1] == m4$ANOVA$DFd

# only for effects with topic:
row.names(anova(m3))[-1][!(anova(m3)$denDF[-1] == m4$ANOVA$DFd)]

UPDATE: As the precise error or nesting is somewhat unclear I here provide the equivalent aov call (this is the "standard" model via aov), which matches the results from ezANOVA. The critical error term is Error(code/(problem*topic)):
m5 <- aov(mean ~ (condition*group*problem*topic) + Error(code/(problem*topic)), d)
summary(m5)

Comment: There is a function called pvals.fnc in the languageR package that allows you to get p values (calculated using Markov chain Monte Carlo sampling) for lme4 models. Perhaps you could try that?
Comment: Also, I'm more familiar with lme4's syntax than nlme, but does "random = ~1|code/problem/topic" mean you're trying to get random slopes for each subject for each of the within subjects variables? The model might be too complex. I would have just started with random intercepts for each subject.
Comment: @Marius - that's quite an involved hierarchy, so I agree with your comment about it being a complicated model.
Comment: @Marius See my updates and my answer about this problem.
Comment: Hi there, could you describe more about how group, condition, topic, and problem are related to each other in the design?
Comment: Ohh, I am sorry I omitted this. It is a fully randomized experimental design. `group` and `condition` are two fully crossed between-subject factors (i.e., each cell consists of a unique set of participants). `topic` and `problem` are two fully crossed within-subject factors: Each participant responded to four different problems (denoted as `MP`, `MT`, ...) for each of the four different topics (1 to 4), in total each participant responded to 16 problems. The design is fully randomized (allocation to condition and order of topic and problems).
Comment: @Michelle see also my update.
Comment: Hi again, so `problem` is nested in `topic` and `group` and `condition` are not involved in any nesting?
Comment: @Michelle As far as I understand nested, I think `problem` and `topic` are both nested within `code` which is the variable identifying the participant. `group` and `condition` are not nested within `code`.
Comment: Are the p-values from `lme` actually reasonable? I don't know much about the topic, but `lme4` does several things different (like not giving p-values and not having a default `forecast` method) for what appear to be good reason.
Comment: @Wayne Totally. They are pretty much the same as the p-values from the ANOVA (which is the usual way to analyze this data in Psychology).
Answer: I found an answer to my question on this thread: Repeated measures ANOVA with lme in R for two within-subject factors (somehow this thread was already one of my favorites, I must have forgotten about it). The specification is a little unhandy.
m6 <- lme(mean ~ condition*group*problem*topic,
   random = list(code=pdBlocked(list(~1, pdIdent(~problem-1), pdIdent(~topic-1)))), data = d)
anova(m6)

However, the denominator dfs are still wrong, as noted in the thread and apparent in comparisons between the ANOVA and lme dfs.
data.frame(effect = rownames(anova(m6)), denDf= anova(m6)$denDF)

m4$ANOVA[,c("Effect", "DFd")]

As long as there are no other ideas, I think I will need to do the analysis in lme4, for which I wil need to post another question.
Comment: You should get the same results with `lme4` though, except with no dfs calculated at all.
Comment: @Aaron Thanks for your answer. Perhaps you have the time to look at my follow-up question: http://stats.stackexchange.com/q/23874/442


Absolute convergence requirement for Expectation

Question: In calculating the expectation of a discrete random variable $X$, we not only require that $\Sigma x_iP(X=x_i)$ converges, but also converges absolutely. I understand this requirement as probably stemming from the fact that a rearrangement of non-absolutely-convergent countably-infinite sum can have a different sum.
I was wondering if a similar requirement exists for purely continuous random variable $X$, when we compute the expectation using the Riemann integral $\int_{-\infty}^\infty x f(x) dx$.
[I have a similar question for computing expectation using Stieltjes integrals - is there some sort of "absolute convergence" requirement?]
I understand that the most general definition of expectation involves Lebesgue integrals, but I am not very familiar with Lebesgue theory, so to be concrete (if you intend to reply via Lebesgue theory): In the special case of a purely continuous random variable, does the Lebesgue integral, when reduced to Riemann integral, have any form of "absolute convergence" requirement, or it is automatically satisfied in some sense? What about the case of Stieltjes integral? How does the "absolute convergence" requirement manifest itself for the discrete case?
Answer: If $X$ is a random variable taking real values, then you could define an integer random variable by rounding down: let $A = \lfloor X \rfloor$, and another slightly higher by rounding up $B=\lceil X \rceil$.
If any of them have an expectation then they all do as $E[X]-1 \le E[A] \le E[X] \le E[B] \le E[X]+1$.
$A$ and $B$ are both discrete random variables, for which you say you understand the need for absolute convergence in calculating the expectation.   So a similar concept is needed for a continuous random variable to have a well-defined finite expected value.
Answer: Essentially the answer is yes, though I am not quite sure about the question: perhaps you are thinking about something like the Cauchy principal value of your integral.
If you can describe $X$ as taking the value $Y$ with probability $p$ where $0\lt p \lt 1$ and the value $Z$ with probability $1-p$, where $E[Y]=-\infty$ and $E[Z]=+\infty$, then $X$ does not have an expected value, since if it did then it could be calculated as $pE[Y]+(1-p)E[Z]$.
A simple case would be to let $Y=X$ if $X \lt 0$ and $Y=0$ otherwise, with $Z=X$ if $X \ge 0$ and $Z=0$ otherwise, so $p=\Pr(X\lt 0)$.
Answer: In short, a sufficient condition for an expectation $E[x]$ to be well defined is for $E[|x|]<\infty$.  The main reason you need to be careful is basically because we want to be able to define
$$\lim_{H\to\infty}\int_{-kH}^{H}xf(x)dx$$
In an unambiguous way (ie independent of $k$ for all $k>0$). Now we know that $-|x|\leq x \leq |x|\implies -E|x|\leq E(x) \leq E|x| $, so if $E|x|<\infty$ then $E(x)$ is well defined.
A classic statistical example is the Cauchy distribution, where $f(x)=\frac{1}{\pi(1+x^2)}$.  Now the anti-derivative of $xf(x)$ is given by $\frac{\log(1+x^2)}{2\pi}$ so the integral for finite $H$ is given as
$$ \int_{-kH}^{H}xf(x)dx=\frac{1}{2\pi}\log\left[\frac{1+H^2}{1+k^2H^2}\right]\to-\frac{1}{\pi}\log(k)$$
This depends on $k$ so we cannot give a definite meaning to the equation $\int_{-\infty}^{\infty}xf(x)$.  Thus we say the expectation does not exist.  Note that if we set $k=0$ we get $\infty$, showing that for a Cauchy $E(x|x>0)=\infty$ which implies $E|x|=\infty$.
Now we take a normal random variable and we have $xf(x)=\frac{x}{\sqrt{2\pi}}\exp\left(-\frac{x^2}{2}\right)$ which has anti-derivative $ -\frac{1}{\sqrt{2\pi}}\exp\left(-\frac{x^2}{2}\right)$.  Plugging this in, we get
$$ \frac{1}{\sqrt{2\pi}}\exp\left(-\frac{k^2H^2}{2}\right) -\frac{1}{\sqrt{2\pi}}\exp\left(-\frac{H^2}{2}\right)\to 0\;\;\;\forall k>0 $$
When $k=0$ the limit is $\frac{1}{\sqrt{2\pi}}$, showing that $E|x|=\sqrt{ \frac{2}{ \pi}}<\infty$.
Comment: I believe this argument, although it's on the right track, is invalid: you *must* consider the double limit $\lim_{H\to\infty, J\to-\infty}\int_{J}^{H}xf(x)dx$. It is possible for the single limit you consider to exist for *all* $k\gt 0$ yet for the double limit not to exist.
Comment: @whuber - My argument is that the single limit must both exist and be independent of $k$ (when $k>0$) for the expectation to be well defined.  My Cauchy example is exactly like this - the single limit exists for all $k>0$ but the limit depends on $k$.
Comment: Regardless of the success in handling some special cases like the Cauchy, your characterization is insufficient: the single limit can exist and be independent of $k$ even when the integral itself does not converge.
Comment: @whuber - I am curious: would having absolute convergence guarantee that the double limit "exists" - in a sense that all way sof calculating the integral give the same value? To put it another way, if there is no absolute convergence, is there ambiguity in calculating the doubel limit? It seems to me that the convention seems to be doing $\int_{-\infty}^a + \int_a^{\infty} $ and so there owuld be no ambiguity there.
Comment: Oh silly me. If $\int_{-\infty}^a$ and $\int_a^{\infty}$ are finite, then the integral has to converge absolutely. Okay, ignore my comment above.
Answer: My textbook uses this proof and I think it's simple!


Stopping time build by 'filtration'-Brownian motion

Question: So I got following problem:
Let $B_t$ be a $\{H_t\}_{t \in \mathbb{R}_+}$ Brownian motion where $\{H_t\}_{t \in \mathbb{R}_+}$ is a right-continuous complete filtration and consider
$$S_t := \inf \Bigl\{s \geq 0, B_s = \frac{t}{\sqrt{2}} \Bigr\}$$
$$T_t := \lim_{s \to t^+} S_t$$
Now we have to prove, that $T_t$ is a stopping time and almost surely finite.
We got the hint, that $P(\sup B_t = \infty, \inf B_t = - \infty) = 1$ for a standard Brownian motion and that a $H_t$-Brownian motion is also a martingale with respect to $H_t$.
I am totally lost. I tried (unsuccessfully) to use Borel-Cantelli. In addition, if a Brownian motion oscillates between $-\infty$ and $\infty$, I guess, it "has to catch the equality", but I wasn't able to formulate that thought further. So I would be thankful for every input.
Answer: (I presume that $t$ is to be $>0$.)
1. Convince yourself that
$$
\{T_t<u\}=\cup_{r\in(0,u)\cap\Bbb Q}\{B_r>t/\sqrt{2}\},
$$
for each $u>0$.
2. What does the oscillation property that you mention tell you about the range $\{B_t(\omega): t\ge 0\}$ for a typical $\omega$? (And then notice that $T_t\le S_{2t}$, at least if $t>0$.)
Comment: To 1.- "$\supset$": If it exists such $r \in (0,u)$, then by the continuity of $t \to B_t$, one can assume, that it exists $c \in (0,r) \subset (0,u)$ such that $B_t = t/\sqrt{2}$. So the Inf is smaller than u and therefore also the limit, right?
"$\subset$": If the limit is $L < u$, then $B_L = t/\sqrt{2}$ (or a sequence ...) and then it exists a $L < r < u$, such that $B_r > t/\sqrt{2}$, cause otherwise the Brownian motion would have a local maximum ... which is not possible?
I would say, the range of $\{B_t(\omega) \} = (-\infty, \infty)$, but I still can't see how that helps me :/
Comment: It tells you that $S_t<\infty$ a.s.
Comment: Ah thanks, I will try to finish the prove from now on!


How to show a list of users subscribed to the current node's taxonomy terms

Question: I've been boggling my brain on this for a while now and although I seem to be getting close, so far there is now awesomness kicking in.
Here's what I want:
I have a number of articles (nodes), each with their own list of taxonomy terms
I have a number of users, each with a list of interests defined in taxonomy terms
I want to generate a list of users subscribed to taxonomy terms of the -current- node
I've tried many different approaches and often had the feeling I got close but, so far, no dice.
The closest I've gotten so far is:
view of 'user'
relationship: 'User: content authored' (yes,I know, this limits the output to author only but it DOES expose the  "(nodes)Content: taxonomy terms on node" relationship, which exposes
'(term) Taxonomy term: name of the tax-list' etc..
SO:
If someone could point out the general outline of the approach (what view type, what relationships to use) that would get me where I need to be, that would be splendid!
REWARD:
A whole lotta love will go to the one who sets me on the right track!
Comment: Are the taxonomy terms that the user fancies the same as the taxonomy terms for the articles?
Answer: You can set the same vocabulary for users and your content type, so they will be related with the same terms, then you will be able to achieve your goal with these four steps:
#1
Create a View block with these settings:
View->name: Related users
Show -> taxonomy terms -> of type -> your vocabulary
#2
Create relationship:  Taxonomy term: User using [field_name]
* field_name: the name of the field with term reference in users account settings
check: Require this relationship
#3
Add field: (field_name) User: Name
* field_name: the name of the field with term reference in users account settings
#4
Add contextual filter: Taxonomy term: Term ID
Configure the contextual settings:
WHEN THE FILTER VALUE IS NOT AVAILABLE:
provide default value: taxonomy term id from URL
check: Load default filter from term page
check:  Load default filter from node page,  that's good for related taxonomy blocks
Select your vocabulary
Check: Filter to items that share any term
WHEN THE FILTER VALUE IS AVAILABLE OR A DEFAULT IS PROVIDED:
Specify validation criteria -> basic validation
Action to take if filter value does not validate -> hide view
MORE:
check: Allow multiple values

That's all. If the current node will have a relation with some user or users, then the block with the related users will be displayed.
Comment: It's been a while since I posted this question and I've since allowed myself to forget the problem (I seem to remember I wrote a flimsy module to get the result I wanted). But when reviewing my account I saw your awesome reply that, no doubt, would have been the answer I was looking for.
So, though late, here's the whole lotta love I promised! Many thanks for taking the time!
Cheers!


reading a data file into a struct c++

Question: I am trying to read this data file into a struct. however i am having trouble doing so.
here is the code i have so far. the part i am having trouble with is the readData function
#include<iostream>
#include<fstream>
#include<sstream>
#include<cstring>
#include<string>

using namespace std;

const int CAP = 100;
const int MAX_CHAR = 31;
int totalLines = 0;
struct Student
{
    char name[31];
    int score[10];
};

int readData(ifstream& iFile, Student list[]);
void findLowestEach(Student list[], int size);
void findHighestEach(Student list[], int size);
void calcAverage(Student list[], int size);

int main()
{
    Student list[CAP];

    ifstream inFile;

    inFile.open("data.txt");
    if (!inFile.is_open()) {
        cout << "Error: File cannot be opened.\n";
        exit(1);
    }
    readData(inFile, list);

    // calls all of the other functions
    //readData(inFile, list[]);
    //findLowestEach(list[], size);
    //cout << endl;
    //findHighestEach(scores, names);
    //cout << endl;
    //calcAverage(scores, names);
}

int readData(ifstream& iFile, Student list[])
{
    int i = 0;
    while (!iFile.eof())
        iFile >> list[i].name;
        for (int i = 0; i < 10; i++)
        {
            iFile >> list[i].score;
        }
    return 0;
}

here is the data file
Bob 56 67 83 76 84 94 68 86 78 56
John 76 89 95 64 78 34 99 89 104 98
Joe 65 68 89 78 45 69 98 101 99 89
Amy 86 77 89 76 94 54 78 89 78 66
Nick 76 69 95 94 78 64 99 89 110 88
Alex 95 88 89 78 95 69 88 101 99 89
Marga 96 67 89 76 64 94 98 83 78 56
Mike 76 89 95 64 78 34 99 89 104 98
Bella 85 68 89 78 45 69 98 101 99 89
Priya 86 77 89 76 94 94 78 89 78 96
Karen 78 69 95 94 78 94 99 89 110 88
Amit 95 88 79 78 95 89 88 101 99 89

Just hoping for a push in the right direction for reading in the data file. I think that I am sort of on the right track but im not sure
Comment: It seems you missed { and } around the while loop body. And read it https://stackoverflow.com/questions/5605125/why-is-iostreameof-inside-a-loop-condition-i-e-while-stream-eof-cons
Comment: What sort of "trouble"? (Did your computer explode? Unlikely, but at the same time definitely trouble.)
Answer: I'm not sure what exactly problem do you have. But if you want to write this code in C++, my suggestions are:

Don't use char name[31] in student struct. You should use std::string. If you are using C style strings, you have to manage by you own to handle copying memory and to be sure that array is big enough to handle all data in input. With std::string you don't have this problems and operator>> will work correctly.
I suggest to use std::vector as a container of you students struct. As it is standard library container you may use it in other functions from standard library to sort or find some elements.

Working code is below.
#include <iostream>
#include <fstream>
#include <sstream>
#include <cstring>
#include <string>
#include <vector>

using namespace std;

static constexpr int CAP = 100;

struct Student
{
    std::string name{};
    int score[10] = {};
};

std::vector<Student> readData(ifstream& iFile);
void findLowestEach(Student list[], int size);
void findHighestEach(Student list[], int size);
void calcAverage(Student list[], int size);
void printStudents(const std::vector<Student> &a_vector);

int main()
{
    ifstream inFile;

    inFile.open("text.txt");
    if (!inFile.is_open()) {
        cout << "Error: File cannot be opened.\n";
        exit(1);
    }
    printStudents(std::move(readData(inFile)));
}

void printStudents(const std::vector<Student> &a_vector) {
    for(const auto & s: a_vector) {
        std::cout << s.name << " ";
        int i = 0;
        while( i < 10) {
            std::cout << s.score[i] << " \n";
            i++;
        }
        std:: cout << std::endl;
    }

}

std::vector<Student> readData(ifstream& iFile)
{
    std::vector<Student> students;

    int i = 0;
    while (!iFile.eof()) {
        Student student{};
        iFile >> student.name;
           for (int i = 0; i < 10; i++)
            {
                iFile >> student.score[i];
            }
            students.push_back(student);
    }
    return students;
}

My conclusion is, that if you are using C++ please use standard library containers and algorithms. This will make writing code easier for you.

reading a data file into a struct c++


Linear Programming - A brute force approach

Question: I was wondering what the main drawback for using a brute force approach in Linear Programming would be. My idea would be to just iterate over all possible basic solutions, filter out the infeasible ones and pick the one that minimises the given linear function. How would this fare compared to more sophisticated methods?
Answer: Of course everything depends upon the problem at hand.  For small problems brute force may be appropriate but it is very easy indeed to create realistic problems for which brute force would exhaust all the computing and memory resources of the universe.
The performance of a brute force search stopped pre-maturely depends entirely on the starting conditions and the nature and scale of the problem.


The largest circle that touches a parabola and $(0,0)$ but does not cross the parabola

Question: What is the largest circle (of radius $r(a)$) that touches the parabola $y=ax^2$ ($a$ is a positive real number) and $(0,0)$ but does not cross the parabola ?
I know that the largest circle radius will change if a is changed. The problem is I can't find a condition that makes the circle touch the parabola and $(0,0)$ but does not cross the parabola in mathematical terms. If the circle is too large, it will cross the parabola if we make it pass $(0,0)$.
Comment: There is a theory of local curvature of a planar curve which answers your question, but you need to tell us more about what you know / are allowed to use.
Comment: Intersect the parabola with a circle. You can set up the equation of the circle. It will end up with an easy quartic equation where you want a double root at the origin. Think discriminant. The other 2 roots are irrelevant.
Comment: I don't know much about law and theory in geometry. I know some basic calculus. I will try to understand as much as I can.
Answer: The radius of such a circle is the inverse of the curvature of the parabola at the origin.
The curvature is found to be $2a$ so the radius is $\frac {1}{2a}$
The center of the circle is $(0,\frac {1}{2a})$
Thus the equation of the circle is $$x^2+(y-\frac {1}{2a})^2=\frac {1}{4a^2}$$
Answer: You can derive the condition you are looking for by arguing that the joint equations of the parabola and the circle
$$y=ax^2$$
$$x^2+(y-r)^2=r^2$$
allow only one solution at (0,0), i.e. a single contact point between the parabola and the circle.
After eliminating $x$, you get
$$y(y+1/a-2r)=0$$
which permits only one solution $y=0$ under the condition
$$1/a-2r=0$$
i.e. $r=1/(2a)$. Otherwise, the circle would cross the parabola at $y=2r-1/a$.
Answer: The answers above are fully right, in the "standard" sense.
But, for the way in which you worded your question,

the real answer is $r = \infty$.

because any circle tangent to the parabola, at the origin, from below will
"touch the parabola and not cross it" !
thereby including the $x$ axis


Changing the view mode of EntityReferenceFieldItems programmatically

Question: I have a paragraph (I'm using the Paragraphs module) that contains an entity reference field that contains references to other pages.
The display settings are set to use a particular view mode, e.g. teaser. This renders an teaser image, title and link to the page.
I would like the editor to be able to set the view mode on a per-paragraph basis. I have created a "view mode" field in the paragraph with two options: teaser, and teaser-text-only.
How can I use the view mode set in the "parent" entity (the paragraph) to add a template suggestion when rendering the "child" entities (the pages)?
Answer: At this point it should be no problem to change the view mode in the render element of the referenced node. The node has yet to be built and will, hopefully, use the modified view mode.
You can try something like this in a paragraph preprocess hook:
function mytheme_preprocess_paragraph(&$variables) {

  if ($variables['paragraph']->hasField('field_view_mode')) {
    $view_mode = $variables['paragraph']->field_view_mode->value;
    if (isset($variables['content']['field_ref_node']['0']['#view_mode'])) {
      $variables['content']['field_ref_node']['0']['#view_mode'] = $view_mode;
      unset($variables['content']['field_ref_node']['0']['#cache']['keys']);
    }
  }

}

Edit:
To prevent that the node gets cached on it's own in the wrong view mode remove the cache key.
Comment: @Tim `4k4` solution looks good then for what you need. An alternative to `hard coding` would be to use the `view_mode_selector module` as it would pull the `view modes` for you.
Comment: 4k4 again! Shouldn't I be setting new cache keys instead of just deleting them?
Comment: That depends on how often you use the referenced entity in different paragraphs and if it is worth caching it on it's own. One way or the other, you have to take care of that cache keys I pointed out.
Comment: Thanks!  I had to implement this in a module instead of the theme using `hook_node_view_alter()` to work.  In the theme neither `hook_node_view()` nor `hook_preprocess_node()` worked; all adjustments to the media image (entity reference) were ignored / reset.  See also https://drupal.stackexchange.com/questions/207092/changing-view-mode-in-content-types-render-array
Comment: @4k4 are you populating the `field_view_mode` field by running a query to pull the current `view modes` for Paragraph? Also, what `field type` if the `field_view_mode`?

Something along the lines of `$view_modes = Drupal::entityQuery('entity_view_mode')->condition('targetEntityType', 'paragraph')->execute();`
Comment: @usernameabc The view modes are "hard coded" into the field. They are not paragraph view modes though: they are the possible view modes for the referenced entity.
Answer: There is a module view_mode_selector that should allow for this now. There is currently a dev releases for D8.

A small module which allows you to change the view mode of an entity.
This module provides a new field type "View mode selector", so just go
  to "Manage fields" and create a field of that type and choose between
  a "select list" and a "radio buttons" widget. When you choose "radio
  buttons" it is possible to upload an icon which will be displayed
  instead of the view mode name.
In order to display your referenced entities with the new "View mode
  selector" view mode don't forget to change the view mode on "Manage
  display" which is used for displaying them.
If Display Suite is enabled, it can also display a live preview of the
  configured view mode layout. Here is an example:
Comment: I tested this module, this field only show display modes of current entity to which this field is attached for example paragraph, not the referenced entity (like nodes).
Answer: Bit late to the party here but here's how I just did it using Drupal 7.
I have a paragraph type called Related Content (related_content) with 2 fields: An entity reference field and a Select (text) field called field_related_content_view_mode
I have set the default display mode of the referenced entities / field_related content in the field display of the related content paragraph and use hook_field_display_alter() to alter the display mode to the one set by field_related_content_view_mode:
/**
 * Implements hook_field_display_alter().
 */
function mymodule_field_display_alter(&$display, $context) {
  if ($context['entity_type'] == 'paragraphs_item') {
    if ($context['field']['field_name'] == 'field_related_content') {
      $entity = $context['entity'];
      if (isset($entity->field_related_content_view_mode) && !empty($entity->field_related_content_view_mode)) {
        $view_mode = $entity->field_related_content_view_mode[LANGUAGE_NONE][0]['value'];
        $display['settings']['view_mode'] = $view_mode;
      }
    }
  }
}


incementing in double pointer

Question:     int main()
    {
static int x[]={100,200,300,400,500};
static int *p={x+2,x,x+3,x+4,x+1};
int **ptr=p;
ptr++;
printf("%d",*ptr);

return 0;

}
can anyone please explain why is the output 500, initially ptr contains x+2, after incrementation, it should contain x and the output should be 100, but the output is 500. I don't know why!
A lot of guys are concerned about the warning and norms of C , the thing is this is a textbook question and i need to find the output ,and how i got the output
Any help is appreciated!!
Comment: No, your code doesn't compile with GDB online compiler. It gives several errors. Concentrate on the first error which is `main.c:14:30: warning: excess elements in scalar initializer
     static int* p = { x + 2, x, x + 3, x + 4, x + 1 }; `
Comment: Do you have a [compilable version](http://coliru.stacked-crooked.com/a/a4e71fb444517b9e) of this code also?
Comment: This line is wrong: `static int *p={x+2,x,x+3,x+4,x+1};`, even if your compiler happens to accept it. It looks like it should be an array.
Comment: > the thing is this is a textbook question and i need to find the output ,and how i got the output Any help is appreciated!! I suspect your textbook suggest you to find errors here.
Comment: Are you not getting a warning for `int **ptr=p;`? Or `printf("%d",*ptr);`?
Comment: `ptr` is a pointer to a pointer. `*ptr` is a pointer. You print that pointer, not what `*ptr` is pointing to (which would be `**ptr`). A decent compiler should warn you about mismatching `printf` formatting and argument.
Comment: I am new to c programming, and i need to find the output of this code and how i got this , any help is appreciated??
Comment: Your code doesn't compile.
Comment: @Galik it does , try gdb online C complier
Comment: Sorry, you tagged this as `C++`, I didn't realize it's `C`.
Comment: Actually, you don't allocate memory for p array here. You should have had to write it as int p[] = {x+2,x+3,x+4,x+1};
Comment: what did you tried to do? you are playing with the pointers but it is not clear what you want to do here..
Comment: @AsafItach, this was my homework and i need to find the output.
Comment: @bimjhi i think you are right there should be int *p[];
Answer: if you change this
int main() {
  static int x[]={100,200,300,400,500};
  static int *p={x+2,x,x+3,x+4,x+1};
  int **ptr=p;
  ptr++;
  printf("%d",*ptr);
  return 0;
}

to this
int main() {
  static int x[]={100,200,300,400,500};
  static int *p[]={x+2,x,x+3,x+4,x+1};
  int **ptr=p;
  ptr++;
  printf("%d",**ptr);

  return 0;
}

the output will be: 100
change printf("%d",*ptr); to this printf("%d",**ptr);
and this static int *p={x+2,x,x+3,x+4,x+1}; to this
static int *p[]={x+2,x,x+3,x+4,x+1};
Consider compiling your C code with GCC invoked with all warnings and debug info:  gcc -Wall -Wextra -g then using the GDB debugger
Comment: @Sagarb is this answering your question?

incementing in double pointer


Custom Oauth Server and ampersand in query string issue

Question: I have been trying to use the oauth2 playground with the Laravel oauth2-server bundle and ran into an issue.  I'm using header('location: to take me back to google after the authorization has happened.   The string I'm putting into the redirect is
https://developers.google.com/oauthplayground/?state=1&code=d84024740acc22646b9636421406c88abeab9c8e

However, when I get to it the & has been replaced with & which is causing the playground to not go to step 2.  What is going on?
Answer: Have you tried using Laravel's Redirect class, rather than a header? It should handle the encoding better:
Redirect::to('https://developers.google.com/oauthplayground/?state=1&code=d84024740acc22646b9636421406c88abeab9c8e');


Measuring distance between cumulative distribution and empirical distribution

Question: What is an easy to understand step by step procedure on how to compute a distance between a cumulative distribution function and an empirical distribution function given a random sample using Kolmogorov-Smirnov distance.
An actual illustrative implementaton in R would be helpful.
Answer: The way to compare empirical distributions is to make cumulative distribution functions out of the raw data [use ecdf()] then compare them by plotting [via qqplot()]. And then use KS. Discreet distributions can have direct functions called probability mass functions. Continuous can not because any single realization instance (say 3.57867363474624) can not have a probability, only an interval can (say 3-4). You could compare histograms but ecdf are used far far more often.


what happens to dfs when the domain controller is offline?

Question: Windows Server 2008 R2
DFS Replication across two locations
If the domain controller is offline what happens?
Are users still able to access the DFS namespace?
Does replication still occur?
Comment: I would hope you have more than one domain controller in place.
Comment: doesn't answer my question :)
Comment: I would guess replication would still happen until the kerberos tickets expired.  Of course once tickets start to expire everything is going to be broken. If the DC is gone, I suspect clients with an **active connection** would lose their ability to find the DFS members would lose their connection in ~10 minutes depending on how you have set your DFS timeouts.  I am almost certain no new connections would be possible. What you are asking is so unusual and unthinkable, I suspect you are going to have to test it and research it on your own.  Or follow the best practice, and bring up another DC.
Comment: @Zoredache actually, we have this situation come up from time to time at some of our remote sites that only have one DC.  DFS seems to remain accessible for a lot longer than 10 minutes, but our priority tends to be kicking the DC and/or WAN connection back into functioning rather than testing timeout periods for science (or whatever).  New connections do get an authentication failure, so I'm fairly certain you're right about that part.
Answer: Depends entirely on how this is setup and what's cached.  Anything from "nothing will happen" to "it will break completely" are possible.
Basically, the Domain Controller here is needed for authentication to access the shares, and name resolution to translate your server names to IP addresses.  If you have a client that has the DNS entry for its DFS server cached, and has its authentication cached by the DFS server(s), then it will be able to access DFS just fine, until the cached values expire (or are flushed).  Likewise, if your DFS servers have each other's DNS entries cached, they should be able to replicate.
Anyone who doesn't have the DNS entries for these servers cached will be unable to access them by name, and anyone whose authentication isn't cached by the DFS servers will get a logon failure, because the DFS server will attempt to validate the logon attempt against the Domain Controller it can't reach (which generates an authentication failure).
Oh, and having only one Domain Controller is a problem, and a Bad Idea.  Get another one.
Comment: How about replication?

I have multiple DCs.  This was more of a question on how much DFS relied on DC to function.  Thank you for your answer.
Comment: @Michael The servers will need the DNS entries to replicate to each other, which can be cached, as well as authentication, which can be cached, albeit for a shorter time period, in most cases.  The only time we run into this issue, it's because something's rotten with the inter-site connections, so replication won't work for other reasons... meaning I don't have a meaningful answer except to say replication will fail when the cached authentications expire, which you'd expect to have a much shorter validity period than a DNS cache.
Answer: If your domain controller goes offline (assuming you only have one) you have bigger problems than users not being able to access the DFS namespace. A myriad of complications arise, the most notable is the fact that authentication doesn't take place.
With that said, users will not be able to access the namespace and replication will not occur.
Comment: -1, as you don't have to set your DC as a namespace server.  If you have two DCs and one is down, and your Namespace server is on a third server, then your namespace is still available.
Comment: Question is written as if there is only one domain controller
Comment: So make it clearer in your answer that this is only the case if they have ONE domain controller.
Comment: Three servers: 1 DC, DFS A, DFS B.  DFS replicates to A and B.  DC1 goes offline you're saying users won't be able to access DFS A or B?
Comment: @Cheekaleak I thought the *If your domain controller goes offline (assuming you only have one)* line was quite clear.
Comment: Yes that's what I'm saying @Michael. DFS requires Active Directory to function
Comment: Apologies - DFS *R* requires AD to function.
Comment: @DKNUCKLES DFS DOES NOT require AD to function...You can use DFS without AD, just certain features aren't available.
Comment: Features like replication and authentication?
Answer: The default TTL for DFS Link referrals is 30 minutes and the default TTL for DFS Root referrals is 5 minutes.
I would assume that for a Domain based DFS namespace that the DFS links would still be accessible after the DC has gone down for clients that already have the Link referral cached, for the remaining life of the referral.


How can i sort a string with numbers

Question: can anyone help me with this, please?
I have an input string
Console.WriteLine("Enter some numbers");
string numbers = Console.ReadLine();

And let's say the input will be "3145".
How can I ascending sort them (with loops if possible) and the output be "1345"?
I'm a very beginner...
Comment: does [this](https://stackoverflow.com/questions/6441583/is-there-a-simple-way-that-i-can-sort-characters-in-a-string-in-alphabetical-ord) answer your question?
Comment: Welcome to Stack Overflow. Read [ask] and try searching.
Comment: `string result = string.Concat(numbers.OrderBy(c => c));`
Comment: @styx because it is very likely a homework
Comment: I voted to reopen, I think the given answer doesn't answer to his question.
Comment: If you need to use for loop, do the following: `numbers.ToCharArray()`, then you have an array of 'chars'. Then check this out: https://stackoverflow.com/questions/239103/convert-char-to-int-in-c-sharp
Comment: @styx I actually need to do this with loops, somehow...but thank you tho :)
Comment: " (with loops if possible)" welcome to StackOverflow. If you present a general problem, then it is likely that we find a general duplicate that answers this general problem. If you post your personal attempt to solve this problem with a loop and tell us what your difficulties are with the loop, then we will try to address your personal issue and answer your personal problem instead of closing this general question with a duplicate. Think about it. Please post your personal attempt to solve it using loops
Comment: @M16 why do u need to use loops?
Comment: @MarcoSalerno "I think the given answer doesn't answer to his question" but it does. The expected result matches the one that the accepted answer in the duplicate will provide. OP has to edit the post, add the loop solving attempt, and make the problem description more individual by this
Comment: @MongZhu yes, that's right
Answer: This is a possible solution:
Console.WriteLine("Enter some numbers");
string numbers = Console.ReadLine();
string result = string.Concat(numbers.Select(x => int.Parse(x.ToString())).OrderBy(x => x));

Comment: I edited with the concat version anyway
Comment: Note: You can use `string.Concat(...)` instead of `string.Join(null, ...)`
Comment: @canton7 I may be wrong, but I found many benchmarks about better performance with string.Join
Comment: That would surprise me: their implementations look pretty much the same (grab a `StringBuilder` from the cache, add things to it). I'll do some benchmarking
Comment: `string.Join` comes in at ~120% the cost of `string.Concat` on both .NET Framework and Core. Not that such a difference to a relatively cheap method means much, anyway
Comment: Oh, I guess it's cause of separator handling, well idk maybe people concerning about better performance for string.Join were playing with billions strings..?
Comment: Yeah, not sure. I don't think it matters much

How can i sort a string with numbers


Is there similar function in c++ like subprocess.Popen() in python?

Question: I am wondering if there is similar function in c++ like subprocess.Popen() in python that would give me results given the execution list as the function's parameter.
Answer:
If you have POSIX available, popen() is a possibility: https://man7.org/linux/man-pages/man3/popen.3.html
More C++-ish is Boost::process, https://www.boost.org/doc/libs/1_65_1/doc/html/process.html

Both of those will take a small amount of wrangling to get from whatever list-of-arguments you have to something they can use (popen() expects a command to pass to the shell, like Popen() when args is a string).
Comment: Thanks. popen() is the command I was looking for.
Comment: Additionally this link have helped me: https://www.jeremymorgan.com/tutorials/c-programming/how-to-capture-the-output-of-a-linux-command-in-c/


Why Can't I SSH into my new EC2 instance

Question: I've set up an EC2 instance, and don't seem to be able to ssh into it.
Searching around and looking for general solutions to this, I've set it up with the following characteristics

I have used a subnet to which contains an internet gateway, and an 0.0.0.0/0 --> IGW rule
Security group has a rule that allows ssh inbound, and All, All, 0.0.0.0/0 outbound
EC2 has a public DNS and an elastic and Public IP - don't think I need both here, as public ip is sufficient, but I don't think providing an elastic ip does any harm
Subnet Network ACL has a rule specifically for ssh inbound, and TCP on port 49152-65535 outbound.
the AZ of the subnet matches that of the EC2 instance.

I think it's a network problem rather than anything to do with ssh keys at this stage, as when I run ssh -v to try connect to the machine, I don't even see it succeeding to get to the first part of the handshake.
Any thoughts on what steps I've missed!
Comment: What does ssh say? Timeout? Something else? Ideally update your question with the actual output of the ssh command.
Comment: update: I since made an instance that does seem to work, so now I can track backwards and work out what I did differently. Will update the question when I figure it out. Specifically on @MLu question - SSH was timing out...
Answer: First check your instance is answering to traffic from 22 port. https://ping.eu/port-chk/
Then please check if your terminal is capable of SSH. for example:
ssh -T email@example.com

Now if this works, try your credentials on your instance.
On AWS I would suggest:

Make sure instance is running.
Security group attached has the rule: inbound: TCP PORT 22 from 0.0.0.0
User name for SSH is usually set inside the image (AMI) e.g ec2-user for Amazon linux and ubuntu for Ubuntu LTS and so on.. so try look at the details panel for your instance.
Make sure the VPC is connected to the internet. then make sure this VPC is associated to the subnet that your instance is on.
Comment: Thanks, but I don't think it's a terminal problem, and as I can't even connect to the instance, I don't think its a user or key problem either.
Comment: Please run all what said above, and update your question with the results. we cannot assist, if we do not have the information.


How to strengthen my falsetto

Question: i've been practising singing for a few months now and i've quite comfortably found my mixed voice. However i quite enjoy the singing styles of artists such as Blackbear and Eden (vague similarity to Justin Timberlake) in the way they use drop in and out of their falsetto.
Now to me, falsetto is simply singing with your head voice in tune, I'm pretty sure I'm wrong because whenever I try to sing similarly it sounds like a gimmick, and hence very (very) comical. How do I go about making it sound more musical?
The falsetto I'm trying to emulate in question can be found in the following video:

It is present in the beginning and throughout all the hooks.
Comment: Falsetto is not quite the same as high head voice. The vocal cords engage differently. Falsetto usually sounds more breathy or screamy. If you are a classic rock fan: Robert Plant of Led Zeppelin sounds more falsetto, Geddy Lee of Rush sounds more head voice.
Answer: Falsetto is as you say, singing in a 'head voice' although both myself and my singing teacher have always agreed the term 'head voice' doesn't really mean anything so to speak it just differentiates chest, belt voice to the other softer, higher head voice.
One thing I will suggest is for you to get a singing teacher. I was always lucky in that I have always been able to do Falsetto safely. I say safely, because an untrained singer can do tremendous damage if they are just straining and that can lead to all sorts of complications (if you are on tour or on the stage for example, and you keep going it day after day you can cause a lot of damage).
My singing teacher always told me that more students go to her with bad technique more than bad voices. This is something to remember.
Falsetto should be 'easy'; you should just be able to do it, without your vocal chords screaming for help. Screaming being the operative word there.
When you're finding it difficult, or you can't go from chest to head that is fine, practice sorts everything, but practice safely. Get a singing teacher, tell them it is something you wish to work on and they'll gladly help you. They teach you how to spare your voice, but still sound like you're giving it everything. Of course, it depends how serious you are about it :-)
Comment: It's cartoon like sound is often (and I'm not a singing teacher) through force, lack of technique, but then again it could be just the way you sound. There are loads of professional singers who sound like the Bee Gees in head voice. Keep at it :-)
Comment: @cmp Yeah, I _wish_ my head voice sounded natural like Jared Leto or dramatic like Pavarotti or even edgy like Geddy Lee, but I am far more Brothers Gibb.
Comment: mm its not so much that i can do it, I simply can't make it musical without sounding like a cartoon

How to strengthen my falsetto


Intercept crashlytics privacy dialog button click

Question: I have integrated crashlytics into my Android application and the legal team wants me to save the user preference when the user clicks the Crashlytics privacy log so that a corresponding preference can be set in the application and be shown to the user. Is it possible?
Just to be clear, my app needs to have a 3 way preference Always Send/Always Ask/Never send for collecting the crash reports from users. This preference should remain in sync in the preference user opted in the privacy dialog. In addition, if the user has always selected 'Always Send' option in my preference, the dialog need not be shown even once.
Answer: Fabric/Firebaser here - if you're using Fabric, this doc should help you get started with enabling a privacy dialog that will ask your user if they'd like to upload their crash report. This has the don't send, send, and always send options, so not exactly your specifications but it's an option. You can also build your own dialog box that the user can interact with, and set your own options as per this example.
If you're using Firebase, there's a similar doc for letting users opt in and out using a flag you can set in your AndroidManifest.
Comment: Would you suggest reading the following preferences to know the action taken the user on seeing the dialog? CrashlyticsCore.getInstance().getContext().getSharedPreferences("com.crashlytics.android.core.CrashlyticsCore", 0);


Como se cria voids que mudam o valor de uma variável sem IF? (como métodos em Python)

Question: Para simplificar a minha pergunta, irei mostrar o Bubble Sort em python:
def bubbleSort(self):
    for i in range(len(self) - 1):
        for j in range(len(self) - 1):
            if self[j] > self[j+1]:
                self[j], self[j+1] = self[j+1], self[j]

l = [2, 8, 3, 5, 4, 6, 0, 7, 1]

bubbleSort(l)

print(l)

SAIDA:
[0, 1, 2, 3, 4, 5, 6, 7, 8]
Eu criei um código no C#:
using System;

public class ListFunction : Object
{
    public static int len(var l)
    {
        int len = 0;
        foreach (var i in l)
        {
            len++;
        }
        return len;
    }

    public static void bubbleSort(int[] l)
    {
        for (int i = 0; i < len(l); i++)
        {
            for (int j = 0; i < len(l); j++)
            {
                if (l[j] > l[j + 1])
                {
                    int temp = l[j];
                    l[j] = l[j + 1];
                    l[j + 1] = temp;
                }
            }
        }
    }
}

var l = new List { 2, 8, 3, 5, 4, 6, 0, 7, 1 };

bubbleSort(l);

Eu não testei, pois tinha erro. Erro não deixa testar, certo?
Comment: Você está usando `var` em tudo lembre-se que [tag:c#] é uma [linguagem fortemente tipada](https://pt.wikipedia.org/wiki/Linguagem_tipada) e que parâmetros devem ter o seu tipo explicitamente declarado. A linguagem não aceita processamento de dados fora da declaração de classe e controle de fluxo fora de métodos.
Comment: Ahh, Entendi. Pode me mostrar como se cria esse tipo de função?
Comment: Tem muitos erros  no seu código não vou perder o meu sábado os corrigindo. Exemplo a funcão `bubbleSort()` não retorna um valor, não possui tipo de retorno e na falta deste não possui um atributo de saída de parâmetro, a função `len()` não deveria existir,......
Comment: Ok. Mas eu também queria saber como se vê o tamanho de uma lista
Comment: [`List.Count`](https://docs.microsoft.com/pt-br/dotnet/api/system.collections.generic.list-1.count?view=net-5.0). Exemplo: `var l = new List { 2, 8, 3, 5, 4, 6, 0, 7, 1 };  Console.WriteLine(l.Count);`
Answer: Olha só, não vou detalhar todos os erros, até porque são muitos para escrever um ou dois parágrafos a respeito de todos eles, então aqui estão apenas algumas observações:
public class ListFunction : Object

Não precisa extender Object manualmente, toda classe estende Object.
public static int len(var l)

Você precisa definir o tipo de variável que você irá receber aqui, C# apenas infere o tipo da variável se ela for inicializada na mesma linha.
public static void bubbleSort(int[] l)

Você quer ordenar um array ou uma lista? Porque aqui você está declarando que você recebe um array, mas em seguida você invoca essa função passando uma lista.
for (int i = 0; i < len(l); i++)

Não deveria ser len(l) - 1, assim como no se código em Python?
for (int j = 0; i < len(l); j++)

Não deveria ser j ao invés de i?
var l = new List { 2, 8, 3, 5, 4, 6, 0, 7, 1 };

Você não está passando o tipo da lista para o construtor, deveria ser List<int>, além disso você não adicionou o namespace da List no seu escopo.
bubbleSort(l);

Se bubbleSort é um método da classe ListFunction, então você precisa chama-lo como ListFunction.bubbleSort(l)

Como deveria ser:
using System.Collections.Generic;

public class Program
{
    public static void Main()
    {
        var l = new List<int> { 2, 8, 3, 5, 4, 6, 0, 7, 1 };
        BubbleSort(l);
    }

    public static void BubbleSort(List<int> l)
    {
        for (int i = 0; i < l.Count -1; i++)
        {
            for (int j = 0; j < l.Count -1; j++)
            {
                if (l[j] > l[j + 1])
                {
                    int temp = l[j];
                    l[j] = l[j + 1];
                    l[j + 1] = temp;
                }
            }
        }
    }
}

Agora um exemplo de função que ordena qualquer tipo de lista e qualquer tipo de valor:
using System.Collections.Generic;

public class Program
{
    public static void Main()
    {
        var l = new List<int> { 2, 8, 3, 5, 4, 6, 0, 7, 1 };
        BubbleSort(l);
    }

    public static void BubbleSort<T>(IList<T> l)
    {
        for (int i = 0; i < l.Count -1; i++)
        {
            for (int j = 0; j < l.Count -1; j++)
            {
                if (Comparer<T>.Default.Compare(l[j], l[j + 1]) > 0)
                {
                    T temp = l[j];
                    l[j] = l[j + 1];
                    l[j + 1] = temp;
                }
            }
        }
    }
}

Comment: Eu não sabia que o tipo `System.Array` extende a interface `System.Collection.Generic.IList`. Ah, e poderia colocar o keyword `ref` no l.
Comment: Eu era um noob no dia que eu postei a pergunta.


Multilevel Modelling , 2 level -statistical significance test on random effects

Question: I have fitted two-level MLM for synthetic data. I have fitted the model using lme4 package and also imported lmerTest for the statistical significance test of fixed effects. But I am unable to do statistical significance tests on the random effects. I am new to this model and still exploring how MLM works.
a snippet of the code I am using
library(lmerTest)
library(lme4)

modelC <- lmer(Y ~ P1*Time+ (Time|ID), data = dataset, REML = FALSE)
summary(modelC)

If anyone can help/guide me with this it will be really helpful. Thank you all :)
Answer: Welcome to the site, Zubaer. There is no equivalent significance test for random effects as there are for fixed effects. Instead, you can run model comparison tests, in which you run a likelihood ratio test on nested models. In your case, you can run the following model, call it modelC0:
modelC0 <- lmer(Y ~ P1*Time + (1|ID), data = dataset, REML=FALSE)
Notice that this model differs in that it does not have a random slope for Time. Thus one can get from modelC to modelC0 by constraining the slope variance and slope-intercept co-variance to 0. The models differ by two degrees of freedom. The likelihood ratio test, anova(modelC, modelC0), which is $\chi^2$-distributed, is a test of whether the increased complexity of modelC provides a better fit to the data (significant p-value) or is no better (non-significant p-value). If it is not a better fit, one can move forward with modelC0 as their target model.
This is how one goes about testing random effects in mixed models.
Comment: It means that the difference in log-likelihoods follows a $\chi^2$ distribution. Hence, the likelihood ratio test uses a $\chi^2$ test with associated degrees of freedom (two in your case) to determine significance. In the `anova` output, the p-value shows up as `Pr(>Chisq)`. If that is less than .05, this is typically viewed as statistically significant.
Comment: thank you so much for your answer, can you please elaborate what does 2 -distributed means here? In the output of ANOVA, I can see the Chisq, but I don't know how to interpret it. thank you.


Trying to make presence of at least one optional parameter required, but its presence excludes the others

Question: so let me dive into an example:
type NodeOrMethod<T> =
    | {
          node?: Array<Filter<T>>;
          method: Condition<T>;
      }
    | {
          node: Array<Filter<T>>;
          method?: Condition<T>;
      };

interface BaseFilter {
    label: string;
    value?: string;
}

export type Filter<T> = BaseFilter & NodeOrMethod<T>;

Basically what I want to do is make it so the dev has to either include node or method - which this currently works; however, I want to take it a step further and say IF one of these is present the other CANNOT be. So if they try to include both node and method in the same object it would complain. Has anyone done something like this before?
Comment: Just remove the optional type?
Comment: @JonasWilms that doesn't seem to work. If I add both Node and Method it doesn't complain.
Comment: hmm. I'm always doing `{ type: "one", stuff } | { type: "two", other }` and that works. Seems that the union type is like an "OR", and is only exclusive if both types are mutualy excluding each other.
Comment: What happens if you do `method: never` (unfortunately im AFK so I can't try it myself)
Comment: @JonasWilms Hmm, I've never used `never`, I just tried it and it blew some stuff up, but I might have it formatted weirdly.
Answer: I would probably use tagged unions (see the relevant section of the docs) for what you are trying to do, something like
type Node<T> = {
    type: 'node',
    node: Array<Filter<T>>;
}
type Method<T> = {
    type: 'method',
    method: Condition<T>;
}
type NodeOrMethod<T> = Node<T> | Method<T>;

cost a: NodeOrMethod<T> = { // valid
  type: 'node',
  node: [...]
}

cost b: NodeOrMethod<T> = { // valid
  type: 'method',
  method: ...
}

cost c: NodeOrMethod<T> = { // type error
  type: 'method',
  node: [...],
  method: ...
}

Example
Comment: "I don't have the type property on there" thats what makes it mutualy exclusive.
Comment: I've added a link to a (simplified) playground demo
Comment: Yes kind of. But I don't know the actual semantics of the union type to give an adequate answer (I'm still waiting for one of those ts goldbadgers to arrive), but e.g. `{ exists: true, stuff } | { exists: false, other }` would also work
Comment: I feel like this should work for me, but for some reason it's not. It's still allowing both `node` and `method` to be present. It just complains when neither are there. Granted I don't have the `type` property on there.
Comment: @JonasWilms okay so I need to have a property like that to explicitly say which one is on there?
Answer: Node/JS philosophy doesn't really work this way. Objects are given permission to have whatever they want on them and consuming code only pays attention to what it cares about. Some ways to handle this include:

Use factory methods to ensure proper instantiation of your objects
Have a "type" property that indicates whether to look at the node or the method

All the same, the type is suspiciously overloaded with two meanings. I expect there is another pattern available that avoids this. If you're stuck in a corner with code that is not yours, then one of the above approaches should work fine.
Comment: Your first paragraph makes not much sense when talking about Typescript, as objects do have a certain shape. Factory methods would help to enforce a certain shape, but so do proper typings. "the type is suspiciously overloaded" oh well, thats what Typescript is all about.
Comment: @JonasWilms Typescript does nothing to ensure an object doesn't have properties I don't expect. Consider extending the object, or using type intersection. Typescript intends to ensure an interface is available, that's it. Not that it's *not* available. It doesn't do this because it's nonsense to try and a confusion of compile-time and runtime concerns.


A more structural proof using homomorphisms and similar tools that every ideal of $M_n(R)$ is of the form $M_n(I)$

Question: Let $R$ be a ring with unity , we know that if $J$ is an ideal of $M_n(R)$ then for some ideal $I$ of $R$ , $J=M_n(I)$ . The proof I know is very tedious and uses laborious manipulations using elementary matrices and all that . I was thinking , can we give a more structural proof , like using ring homomorphisms or so ? I kind of feel some hint of correspondence theorem in the result but cannot actually grasp it ... Please help
Answer:
I kind of feel some hint of correspondence theorem in the result but cannot actually grasp it

Well, there is a correspondence theorem going on, but I'm not sure that it will simplify matters.
The relationship is established through Morita's theorems, and this is just a special case. If you dig down into it, it will tell you the answer in terms of homomorphisms.
The "very tedious... laborious" version is more accessible, by comparison, and probably can be streamlined a bit to be tolerable.
Comment: Can you please present the tolerable version :) ? I really need it . And going by the link , I really did not except something so heavy ...
Comment: @SaunDev I don't have a tolerable version written out. I just mean that one can modify or come to terms with the elementary proof by changing the level of rigor. You could replace some matrix computation with something like "using elementary matrices, you can multiply to bring this entry to the upper left hand corner..." You are probably in the best position to create something that seems appropriate enough for you.


Hibernate mapping with two tables

Question: I am trying to learn Hibernate and I could create some simple CRUD operation using a Single Class and Single Table.  I am just reading the Hibernate Doc and some online tutorial.
But I have a problem on how to define this relationship with two tables involved. I basically have an Employee table with this structure.
CREATE TABLE EMPLOYEE
(
 EMP_ID VARCHAR(10) NOT NULL,
 EMP_FIRST_NAME VARCHAR(30) NOT NULL,
 EMP_LAST_NAME VARCHAR(30) NOT NULL,
 STATUS_ID INT NOT NULL,
 PRIMARY KEY (EMP_ID)
);

The STATUS_ID field references another table. STATUS_DESC can either be 'PERMANENT', 'CONTRACTUAL', 'ON-DEMAND'
CREATE TABLE EMP_STATUS
(
 STATUS_ID VARCHAR(10) NOT NULL,
 STATUS_DESC VARCHAR(100) ,
 PRIMARY KEY (STATUS_ID)
);

I am thinking of having an Entity class like this.  Now my goal is to return list of Employee object with status, but I don't know how to go about on doing this.
@Entity
public class Employee{
 //other private instance
 private EmployeeStatus empStatus;
 //getters and setters.
}

public class EmployeeStatus{
 private int statusID;
 private String statusDesc;
 //getters and setters
}

Comment: Its difficult to tell the exact question you are asking. How to do the mapping?  Is the table design correct?  etc....
Comment: @hvgotcodes Thanks for the reply sir! This has been the design.  For some reason, they want to have a master table of all the employee status.  This is so that they could add another entry into it like 'RESIGNED','TERMINATED'.  It would be easier to add other status in the future.
Comment: so is the question how to do the mapping?
Comment: @hvgotcodes Yes sir. I really dont have an idea on how to return a List of employee with Employee Status.  In plain JDBC, I will just create a native SQL query that join the two tables then instantiate the status class per each record.  I am thinking that hibernate can automate this.
Comment: then @sblundy has a good answer.
Answer: You want to know how to map it? ManyToOne?
Employee.java
@Entity
public class Employee{
   //other private instance

   @JoinColumn(name = "empStatus", referencedColumnName = "yourColName")
   @ManyToOne(optional = false)
   private EmployeeStatus empStatus;

   //getters and setters.
}

Dont forget to change "referencedColumnName" value...
EmployeeStatus.java
@Entity
public class EmployeeStatus{
   @Id //this is your pk?
   private int statusID;
   private String statusDesc;

   @OneToMany(cascade = CascadeType.ALL, mappedBy = "empStatus", fetch = FetchType.LAZY) //or EAGER
   private List<Employee> empList;

   //getters and setters
}

Comment: @Renan Thanks sir!  I will explore this code.  Will post back after some reading and testing.
Comment: @Renan: If there are a lot of employees but only a few status (and the poster lists only 3), this could cause memory and performance problems even if it's lazy loaded. So I wouldn't have empList. Otherwise, your annotations make sense.
Comment: @sblundy: yes I know, it'll be slow with a huge collection of employee (like 3 status for 1k+ employee). I was just answering the question.
Comment: @All I was just wondering about the EmployeeStatus class.  Do I need to configure the relationship at both sides? I mean does the EmployeeStatus class needs to have a List of Employees also?  Is it a requirement in Hibernate that the relationship should be configured at both sides?
Comment: @Renan Is the purpose of configuring the association at both sides of the association is that so that I could query for a list of employees at the two entities? Like this at the EmployeeStatus: 'select empList from EmployeeStatus  a where a.statusDesc = :status' and at the Employee Side : 'from Employee where empStatus.statusDesc = :status'
Comment: @sblundy Just a couple of comment sir if you would'nt mind.  Why would this query be slow?  And do you think, I should refactor my table design and have one table of employees only with the status field.  Thank you for your useful comments, these are the things that I havent thought of yet as a hibernate newbie.
Comment: No, you can map it only on Employee class. You can just find a EmployeeStatus and you'll get the list of Employee for each status. Example: EmployeeStatus e = entity.find(EmployeeStatus.class, 1); (Selecting just the status id 1) and the list will be filled with Employee, you just need to access the prop. e.empList (the list)
Comment: You asked for a list of Employee for each status, right? Or you just need Employee with a EmployeeStatus object? If you want just the EmployeeStatus object for each Employee, you can remove the mapping in EmployeeStatus class. Ah and about the other question, you can also just a find at Employee class to get EmployeeStatus at the prop. empStatus
Comment: @Mark Estrada: What would slow down the system is a reference from status to all employees with that status because the resulting collection could be in the 10s of thousands. Querying with 'from Employee where empStatus.statusDesc = :status' wouldn't necessarilly suffer from this problem because the employee objects would be loaded iteratively, not all at the same time.
Comment: @sblundy and @Renan  Thanks to both of you for your insights. I learned a lot just reading your comments.  Keep it coming please! =)
Answer: To create a relationship between two tables you need to decide:
Is the relationship bi-directional? That is, do the statuses know the employees or not? If no then it is uni-directional. In that case you can add the annotation on the Employee class like this:
@ManyToOne
@JoinColumn(name = "status")
private EmployeeStatus empStatus;

And there is a few other options that you may add.
Answer: You can do what you are doing, but I would suggest, if the status can only be one of three values, create an Enum with the three values.  No need for a separate table.
The downside for this is you need to create a hibernate custom type (the code is on the wiki) to support persisting enums.
A simpler answer is to not use a secondary table, and just save the status as a String on the domain object.  You can put business logic on your model to ensure the String is in the list of acceptable values.
If you really want to use a relationship between two entities, then check out the hibernate docs on many-to-one relationships.
Comment: Wouldn't @ManyToOne make more sense? Since many employees can have the same status.
Answer: You can use HQL to query the entities. Like so
Query q = s.createQuery("from Employee as e where e.empStatus = :status");
q.setParameter("status", status);
List emps= q.list();

Comment: Thanks for your accomodating newbie like me sir. But some question though.  Do I have to annotate the EmployeeStatus class also?  Sorry if I cannot understand it correctly but would it be possible for you to show some snippets of the classes involved with annotation?  I would really appreciate it. Thanks.
Comment: @Mark Estrada: You do have to annotate the status class.

Hibernate mapping with two tables


Prove the if $a\nmid x$ and $a\nmid y$ then $a\nmid xy$

Question: I need help proving that if $a\nmid x$ and $a\nmid y$ then $a\nmid xy$. I want to do this preferably without a counterexample. I already know that this is False, but I want to know how.
Comment: It is true if $a$ is prime however.
Comment: Huh? You're looking for a proof that the statement does not hold without actually giving a counterexample? Have you tried considering what the common theme in all counterexamples to the statement is (in particular, regarding factorizations)?
Comment: @T.Bongers Oh. Ok then what would be a counterexample?
Comment: $4, 2, 2 {}{}{}{}$
Comment: @T.Bongers Would $x=2,y=3,a=6$ work?
Comment: That also works.
Comment: "I want to do this preferably without a counterexample." Huh? Why?
Comment: @nhcs do you have thoughts on the provided answers?
Answer: This isn't true. $4\nmid 2,4\nmid 2,$ but $4|4$. If you want to disprove the statement, a counter example is all you need. How else would you disprove it?
Comment: Yep, exactly. I agree with this answer 100%.
Answer: a=6, x=2, y=3
That's enough.
But I need more characters.