MariaDB crashed and now won't start

Question: While activating a wordpress plugin MariaDB crashed on me, and it won't restart.
I am using Centos 7.1.
systemctl status:
systemctl status mariadb.service
mariadb.service - MariaDB database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled)
   Active: failed (Result: exit-code) since Tue 2015-10-27 20:22:02 EDT; 2min 29s ago
  Process: 3587 ExecStartPost=/usr/libexec/mariadb-wait-ready $MAINPID (code=exited, status=1/FAILURE)
  Process: 3586 ExecStart=/usr/bin/mysqld_safe --basedir=/usr (code=exited, status=0/SUCCESS)
  Process: 3559 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n (code=exited, status=0/SUCCESS)
 Main PID: 3586 (code=exited, status=0/SUCCESS)

Oct 27 20:22:01 s1.pavelow.net mysqld_safe[3586]: 151027 20:22:01 mysqld_safe Logging to '/var/log/mariadb/mariadb.log'.
Oct 27 20:22:01 s1.pavelow.net mysqld_safe[3586]: 151027 20:22:01 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
Oct 27 20:22:01 s1.pavelow.net mysqld_safe[3586]: 151027 20:22:01 mysqld_safe mysqld from pid file /var/run/mariadb/mariadb.pid ended
Oct 27 20:22:02 s1.pavelow.net systemd[1]: mariadb.service: control process exited, code=exited status=1
Oct 27 20:22:02 s1.pavelow.net systemd[1]: Failed to start MariaDB database server.
Oct 27 20:22:02 s1.pavelow.net systemd[1]: Unit mariadb.service entered failed state.

journalctl -xn
-- Logs begin at Tue 2015-10-27 20:05:31 EDT, end at Tue 2015-10-27 20:24:34 EDT. --
Oct 27 20:24:34 s1.pavelow.net NetworkManager[533]: <info>  (eth1): DHCPv4 state changed timeout -> done
Oct 27 20:24:34 s1.pavelow.net NetworkManager[533]: <info>  (eth1): Activation: Stage 4 of 5 (IPv4 Configure Timeout) scheduled...
Oct 27 20:24:34 s1.pavelow.net NetworkManager[533]: <info>  (eth1): Activation: Stage 4 of 5 (IPv4 Configure Timeout) started...
Oct 27 20:24:34 s1.pavelow.net NetworkManager[533]: <info>  (eth1): device state change: ip-config -> failed (reason 'ip-config-unavailable')
Oct 27 20:24:34 s1.pavelow.net NetworkManager[533]: <info>  Disabling autoconnect for connection 'Wired connection 1'.
Oct 27 20:24:34 s1.pavelow.net NetworkManager[533]: <warn>  (eth1): Activation: failed for connection 'Wired connection 1'
Oct 27 20:24:34 s1.pavelow.net NetworkManager[533]: <info>  (eth1): Activation: Stage 4 of 5 (IPv4 Configure Timeout) complete.
Oct 27 20:24:34 s1.pavelow.net NetworkManager[533]: <info>  (eth1): device state change: failed -> disconnected (reason 'none') [120 30 0]
Oct 27 20:24:34 s1.pavelow.net NetworkManager[533]: <info>  (eth1): deactivating device (reason 'none') [0]
Oct 27 20:24:34 s1.pavelow.net avahi-daemon[506]: Withdrawing address record for fe80::601:7cff:fef5:3c02 on eth1.

MariaDB.log (superlong full file:http://pastebin.com/dgDDVgLv) :
151027 19:58:18 mysqld_safe mysqld from pid file /var/run/mariadb/mariadb.pid ended
151027 19:58:50 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
151027 19:58:50 [Note] /usr/libexec/mysqld (mysqld 5.5.44-MariaDB) starting as process 14311 ...
151027 19:58:50 InnoDB: The InnoDB memory heap is disabled
151027 19:58:50 InnoDB: Mutexes and rw_locks use GCC atomic builtins
151027 19:58:50 InnoDB: Compressed tables use zlib 1.2.7
151027 19:58:50 InnoDB: Using Linux native AIO
151027 19:58:50 InnoDB: Initializing buffer pool, size = 128.0M
InnoDB: mmap(137756672 bytes) failed; errno 12
151027 19:58:50 InnoDB: Completed initialization of buffer pool
151027 19:58:50 InnoDB: Fatal error: cannot allocate memory for the buffer pool
151027 19:58:50 [ERROR] Plugin 'InnoDB' init function returned error.
151027 19:58:50 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
151027 19:58:50 [ERROR] mysqld: Out of memory (Needed 128917504 bytes)
151027 19:58:51 [Note] Plugin 'FEEDBACK' is disabled.
151027 19:58:51 [ERROR] Unknown/unsupported storage engine: InnoDB
151027 19:58:51 [ERROR] Aborting

151027 19:58:51 [Note] /usr/libexec/mysqld: Shutdown complete

151027 19:58:51 mysqld_safe mysqld from pid file /var/run/mariadb/mariadb.pid ended

Thanks for the help in advanced.
Comment: The errors clearly state that you don't have enough memory. That is where you should begin looking.
Comment: Post your my.cnf, lower your innodb pool
Answer: According your error log, you don't have enough memory to start MariaDB with current configuration. There is some solutions: add additional RAM, if it possible; add additional swap  according this instruction; change MariaDB configuration to prevent high memory usage, for example decrease innodb_buffer_pool_size to 80% of your RAM according this blog post.

MariaDB crashed and now won't start


How can I copy a file on the server using JSch's SCP support?

Question: I managed to create a method which uploads a file into a directory.
How would I have to change this so I could copy a file from /123.html to /en/123.html via JSch?
public void upFile(String source, String fileName, String destination) throws Exception {
    try {

        try {
            // 改变当前路径
            client.cd(destination);
        } catch (Exception e) {
            System.out.println("当前目录不存在,新建目录!");
            JschCreateDir.createDir(host, port, username, password, destination);
            client.cd(destination);
        }

        // 上传本地文件 到当前目录
        File file = new File(source + fileName);
        client.put(new FileInputStream(file), fileName);

    } catch (Exception e) {
        logout();
        throw e;
    }
}

Comment: Just a note: If you are already on the server (with your `client` object) and note that a directory doesn't exist, then use this connection to create the new directory, not a separate one in your `createDir` method.
Answer: I understand your question that you want to copy a file on the server from one directory to another one (and not a local file to the server, which your code already seems to do).
Unfortunately, the SFTP protocol (which is implemented by JSch's ChannelSFTP class) doesn't support copying directly on the server.
You certainly can combine the put and get to copy the file from one location to another, but this will send the contents twice through the wire from server to client and back.
A better way would be to use an exec channel, and simply directly issue the server's system's copy command. On a unixoid server, this would be cp  /123.html /en/123.html.  (This assumes you have shell access to the server, not an sftp-only access, as I already did see somewhere.)
Here is some code (not tested, you might need to add exception handling):
public void copyFile(Session session, String sourceFile, String destinationFile) {
    ChannelExec channel = (ChannelExec) session.openChannel("exec");
    channel.setCommand("cp " + sourceFile + " " + destinationFile);
    channel.connect();
    while(channel.isConnected()) {
        Thread.sleep(20);
    }
    int status = channel.getExitStatus();
    if(status != 0)
      throw new CopyException("copy failed, exit status is " + status);
}

Comment: great @Paŭlo Ebermann. One minor correction: session.openChannel("exec");


Conteudo da div se ajustando com seu tamanho?

Question: Tenho uma div que controla o tamanho maximo que uma imagem pode ter. Gostaria que a imagem se ajustasse ao tamanho da div, sem que cortasse parte dela (como acontece no overflow: hide).
Usei o overflow:hide para a imagem nao ultrapassar o limite da div.
HTML:

CSS:
#controlImg{
max-width: 400px;
max-height: 500px;
border: 1px solid green;}

#controlImg img {
    width: 100%;
    height: 100%;
}

No overflow: auto, cria-se uma barra de scroll ao inves de cortar a imagem, mas gostaria mesmo é que ela se adaptasse ao tamanho da div pai (controlImg)
Na imagem, inseri width:100% e height:100%, mas a imagem nao obedeceu, como mostra na imagem:
Comment: max-width: 100%;
max-height: 100%;
Answer: Pode usar um width: 100% para a imagem ocupar toda a largura do elemento pai:

#controlImg {
    max-width: 400px;
    max-height: 500px;
    border: 1px solid red
}

#controlImg img {
  width: 100%
}

Ou utilizando como background do elemento:

div {
  width: 500px;
  height: 400px;
  border: 1px solid red
}

.rice {
  background: url(https://i.stack.imgur.com/6Jgo0.jpg);
  background-size: 100% 100%
}

Comment: Renan obrigado pela resposta. Eu fiz assim, e ainda adicionei o height 100%, mas nao funcionou, como na imagem que inseri
Comment: Se for aplicar o tamanho na altura (ao invés da largura), seu elemento pai deverá ter um tamanho definido (um `height` e não `max-height`). E nesse caso não vai adiantar usar `height` e `width` juntos com 100%, a imagem não vai "se expandir" e ocupar todo o elemento, para isso você teria que usar a imagem como `background` do elemento.
Comment: @WesLipe editei.
Comment: Funcionou, mas infelizmente nao se encaixa no que eu preciso, pois a imagem (no caso do arroz) virá do banco, entao sera uma imagem por produto, nao posso setar no css uma padrao
Comment: O meu erro era que eu estava inserindo o max height e width na div, ao inves da imagem.

Ao informar pra imagem que o maximo de altura e largura que ela deve ter é 100% em relação ao pai, a imagem se comportou bem.

O codigo:
#modalProduto #controlImg{
 border: 1px solid green;
}

#controlImg img {
 /* largura e altura maxima de 100% da div pai */
 max-width: 100%;
 max-height: 100%;
}


Codenameone: Screen(form) load issue

Question: I want to load screen dynamically reflected with changes that I made dynamically through program.
Currently when I load screen(form) it first shows  screen which i designed with GUI builder. then after that changed screen appears. I have written my code in protected void beforeHome(Form f) {}
Can you please let me know how to resolve it. My application needs to be supported on all platforms (Android, iOS, Windows) and I don't want to write native code for all platforms separately.
Comment: can you provide us with more information, e.g more source and pictures what exactly your problem is?
Answer: You can call the reloadForm() method which will cause the before* method to run again.
Comment: protected void beforeHome(Form f) { findTxtName.setText(" shekhar");} here i did set name on text field dynamically. when this form(screen) open it just show textfield name which i did set on gui builder at the time of designing after that it show my dynamically set value on textfield.so i just want to start or display this form(screen) with dynamically set value not by default screen(form) which i designed with gui builder
Comment: Is this only on iOS devices for the first screen in the application?
Comment: No. its for all devices
Comment: Based on your other question: http://stackoverflow.com/questions/38893690/keyboard-not-showing-when-textfield-is-focused-in-codenameone-for-ios you are clearly doing something seriously problematic in your app. I suggest including code in your questions

Codenameone: Screen(form) load issue


jquery ui sortable table columns with fixed rows issues

Question: There is a jquery ui sortable widget extension which makes table columns sortable.
According to examples page it is possible to specify row as undruggable.
 $(function () {
    $('#ex7').sorttable({
        placeholder: 'placeholder',
        helperCells: ':not(.footerrow td)'
    }).disableSelection();
    });

I want to set several colspanned rows such way.
But there are several issues occur when i set fixed rows in the middle of the table.
First - fixed rows is not showed as dragged during drag&drop, second - after several movements table becomes broken.
jsfiddle example
Is there any way to correct it?
UPDATE:
found workaround using absolute positioned div with width=table width, but actually i don't like it
jsfiddle example
Answer: The problem you are having is that you set the first cell of your static row to a colspan of 4.
When you move that column to the second position the cell with the colspan is shifted into second position.
Now you end up with the second column sontaining the cell with the colspan of 4 which off-sets everything.
I would try and avoid colspans in cells if you wish to move around columns.
You can fix this by simply adding empty cells instead of using a colspan.
Replace this:

unsortable  colspan row

with this:

DEMO - v1 - Using individual empty cells instead of colspan
In addition I would probably add some styles to hide the column borders for that row.
Edit
I played around a little longer with this and was able to come up with another alternative. Mind you it is not as smooth as yours and could be seen more hacky as well.
I looked at the start and stop callbacks of the sortable extension and wondered if one could add 4 cells at start and replace them again at stop.
When using start you will see 4 cells during sorting, which I didn't like as much as I thought that you want to see the footers during the drag-drop action.
The I noticed that when stop executes it executes prior to the actual sorting being applied, making start for our purpose redundant.
This means at stop we can replace the single cell with 4, let it sort, add a small time-delay using window.setTimeout which then after a small delay replaces the 4 cells again with the 1 cell. That also means the footer stays intact during drag-drop.
DEMO - v2 - Using stop to re-draw footers before and after sorting
That seems to work but as I said it is not as smooth as yours as mine is redrawn and causes a little flicker. Also I'm not certain if 100 milliseconds will be enough on the setTimout call when you got a huge table.
Either way, I had fun working with this. I hope though this will give you at least some more ideas to play around with.
The code from the DEMO v2

HTML
  note I added a attribute data-title to the tr storing the title text to be able to
  dynamically add them. See the footer-row HTML below, all other HTML stay the same.

Script
  Added start callback. Let me know if you have any questions.

$(function() {
    $specialRows = $("#ex7 tr.footerrow");

    $('#ex7').sorttable({
        placeholder: 'placeholder',
        helperCells: ':not(.footerrow td)',
        stop: function(e, ui) {
            // This replaces the 1 cell with 4 and executes before the sorting actually occurs.
            buildFooterTemplates();

            // Adding a small timeout we rever to the single cell with colspan 4
            window.setTimeout(function() {
                buildFooterRows();
            }, 100);
        }
    }).disableSelection();

    var buildFooterTemplate = function(title) {
        return '				';
    };

    var buildFooterRow = function(title) {
        return '' + title + '	';
    };

    var buildFooterTemplates = function() {
        $specialRows.each(function() {
            var $row = $(this);
            var title = $row.attr("data-title");

            $row.empty().append(buildFooterTemplate());
        });
    };

    var buildFooterRows = function() {
        $specialRows.each(function() {
            var $row = $(this);
            var title = $row.attr("data-title");

            $row.empty().append(buildFooterRow(title));
        });
    };

    buildFooterRows();
});

Comment: Hi Francois, thanks for reply. Yes it's clear that using row without colspan should avoid such type of a problems. But i need to create named groups of cell values. That is why row with individual cells instead of colspan row are not suitable in my case.
Comment: @user947668: I'm not sure what you mean by named group but you can always apply data attributes or classes to your `td` or `tr` elements for logical grouping if that is something that would suit.
Comment: @user947668: I like your trick and it is smooth/seamless as well in the UI. Nice one. I had a little more fun with the extensions and added another way to deal with this, using the extension's `stop` callback. Though this might be even more hacky than yours and it is not as smooth but as I had fun working with this I thought I might as well post it for completeness. Maybe you find even a completely new way through all of this. If you do, post it please I would be very interested.


How can a well trained ANN have a single set of weights that can represent multiple classes?

Question: In multinomial classification, I'm using soft-max activation function for all non-linear units and ANN has 'k' number of output nodes for 'k' number of classes. Each of the 'k' output nodes present in output layer is connected to all the weights in preceding layer, kind of like the one shown below.

So, if the first output node intends to pull the weights in it's favor, it will change all the weights that precede this layer and the other sets will also pull which usually contradicts to the direction in which the first one was pulling. It seems more like a tug of war with single set of weights. So, do we need a separate set of weights(,which includes weights for every node of every layer) for each of the output classes or is there a different form of architecture present?
Comment: Your intuition is somewhat right if you consider a single example in isolation.  However, the network needs many many examples to learn its weights.  Moreover, the learning procedure always tends to minimise the total classification error _in expectation_, so the "tug-of-war" will always produce a better solution than the one you are currently at (it may not be the optimal, however).
Answer: I think you don't have a clear concept of what a neural network does.
The output nodes are mapped to the hidden layer (in this case) by a separate vector of weights for every node, thus the matrix-nature of the algorithm.
The fact that one node is pulling the weights in its favor does not contradict that the other are doing the same with ITS RELEVANT mappings (its own vector of weights). That's what makes difficult to visualize the concept of weight optimization/gradient descent, because it is happening in a (probably high) number of different dimensions, while we are used to understand only three spatial ones.
Hope to have helped.


Limited access to 'Edit' Commerce Order & limit line items to only 1 type

Question: With further to my earlier question regarding Services for Products, I have implemented as per the suggestions:
Following are the components:

Orders
Service Vendors - The individual or the Person who would provide service for an order request
Rating and Review - Fivestar rating and Editable text field added as fields for Commerce Order.

I am facing the following problems:

In order for user to rate and provide a review on the order I would have to expose the Order as editable for authenticated user which would let the user to edit all other order attributes. The fivestar rating module, allows rating the star without edit privilege but the review - (editable textfield) requires edit privileges on Order entity for the user. I have tried to use Field Permissions to limit edit access only to these 2 fields but with no success!
I am providing Voting and Review operations on Order because the Line items can be configured only in "Add to cart" form. Hence, I would have to limit a single order to contain only 1 line item type (which can contain multiple products / services of the same type). How can I achieve this?
As against the accepted answer here I am planning to create an order request when user needs it and then later update the price (also quantity in line item) after the service quotation actually takes place. Is there a way to edit the order to accommodate this functionality?

PS: I would need the rating module to be applied on Order (or Line item) because unlike regular E-Commerce this does not deal with product, it is service oriented. There is a possibility that different vendors can provide service for each order of same type, hence I will have to associate the rating and review system with either Order or Line Item and then pick up the average rating of a particular vendor who has serviced different orders in the past.
Also, if there are any better ways of achieving the same kindly let me know.
Answer: While it is possible for you to add those fields to the order, you should really create a new review content type and then use those for your reviews and then use an entity reference to connect the review content to the order. In the future, if you did want to allow line items to have reviews, you could then just add another entity reference field to the line items and you can reuse all of the UX you've built for the main review form for anywhere else.
Furthermore, by using a reference, you're not limiting yourself to a particular type of form. If you ever wanted to differentiate between certain types of services and provide different review criteria, you can much more easily do that with new content types + entity reference.
Brief overview of steps:

Create a new review content type with your fields and fivestar info.
Create an entity reference field on your Order. I believe you can use Entity connect to have it show a "create link" if no reference exists.
If that doesn't work, you can use Views to make it so that a user can only connect the entityreference field to orders that they own.


What algorithm does SPSS Modeler use for decision-lists

Question: I am currently trying to find out what algorithm IBM SPSS Modeler is using during calculation of decision lists. However, on the help page I can only find options for using the decision-list function but no information on how this model is trained. I also found some papers about decision lists, but these mention multiple different training methods. Is there any further information about the actual algorithms used by SPSS Modeler or are these completely kept as a secret?
NOTE:
I am not just interested in any algorithm for decision lists. Rather, we are currently basing our work on a decision list provided to used based on SPSS Modeler and we would like to start of using the same exact methodology as a starting point. For this it would be crucial to use the same algorithm that is implemented in SPSS Modeler.
Answer: You need the "Algorithms Guide" pdf file from the SPSS Modeler documentation.
For Modeler 18.0, the decision list algorithm is on p.106.
The .pdf can be freely downloaded from IBM's website.
Just google the documentation for your version of SPSS Modeler.
Comment: This is being automatically flagged as low quality, probably because it is so short.
At present it is more of a comment than an answer by our standards. Can you expand
on it? We can also turn it into a comment.
Comment: This does not provide an answer to the question. Once you have sufficient [reputation](http://stats.stackexchange.com/help/whats-reputation) you will be able to [comment on any post](http://stats.stackexchange.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](http://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/low-quality-posts/132930)
Comment: @mdewey I believe it does provide an answer. This question contains everything need to find the information to implement the algorithm myself. The spss documentation, that Borsislav points to gives a detailed description of the algorithm. The only better explanation would be to give some papers of where this algorithm comes from (not in the documentation), or include the actual algorithm. However, taking an algorithm from an IBM documentation may cause copyright issues.
Comment: @LiKao: Is it worth preserving for posterity the information that an algorithm used by some software is described in the documentation for that software? We try to encourage answers that are going to be useful to others besides the one who asked the question.
Comment: LiKao: Thanks! Of course I won't presume to give you legal advice; but I look forward to your post.
Comment: @BorislavAymaliev: When I put "What algorithm does SPSS Modeler use for decision-lists" into Google I get "IBM SPSS Modeler 17 Algorithms Guide" as the fifth result. And though there *are* [a lot of  manuals](http://www-01.ibm.com/support/docview.wss?uid=swg27046871#en) for this software, *Algorithms Guide* is surely the strongest candidate for containing information on what algorithms it uses. Anyway, I've added the `references` tag to the question, making this answer more appropriate.
Comment: @Scortchi, should you remove the coinciding "algorithm" keyword from your search, or ever actually use SPSS modeler, then you may be able to understand the question.
Comment: I believe to have provided the straightforward answers to both questions - about the location of the information about SPSS Modeler algorithms and about the decision lists algorithm. Moreover, the post does not require clarification from the asker.
Comment: @Scortchi I agree, that the answer could provide more (e.g. a rundown of algorithm itself). Still even without that, I find the answer worthy for posterity, because the existence of this "algorithm guide" was not known for me (although I did google searches etc) nor to the people who trained the model (I asked about the algorithm, and they were not able to point me to that document). The document is not linked in the main user documentation anywhere, and therefore may be hard to find.
Comment: @Scortchi Since I am currently not sure about the copyright situation, I am worried about adding the description of the algorithm myself. If I can get that cleared up, I will most likely provide an edit or add an additional answer to include it and increase the value.
Comment: @Scortchi, in this case it is useful (funny as it may sound) to have the information that all algorithms, used by the spss modeler software can be found in the so-called "Algorithms Guide" from the numerous pdf files of its documentation. I had the very same problem a few months ago - google does not return relevant results when one wants to find the actual algorithm. All you get are guides on how to use nodes. And finding the answer, in my case, took a few days of asking around. Moreover, the specific algorithm, should anybody copy-paste it, would provide a less relevant answer.


Manage/Assign Roles to Users Other than Administrators

Question: I was asked to create a module that allows a user with the specific role to assign roles to other users w/no 'administer user' permissions or not an administrator. The user must not be allowed to edit info about the users with 'administer user' permission/admin.
How can I do this? Do I have to create a custom module for this? Is it possible to use Views module for this?
Answer: NOTE: Since Drupal 6 is un-supported now (check announcement), you won't get a module which still have the D6 version actively supported. Also don't expect the module to be supported for any issues.
You can check the Role Delegation module, which allow users to set user roles to other user. Following is the module description from module page:

This module allows site administrators to grant specific roles the
  authority to assign selected roles to users, without them needing the
  administer permissions permission.

The last release of this module for Drupal 6 version was made available on 9 Dec 2010, you can download it from here.
Comment: I'm not sure, but you can create a user list view with [Views Bulk Operations](https://www.drupal.org/project/views_bulk_operations) and try allowing user to change user role in user listing.
Comment: Thank you but Can this be achieved through Views?


PowerShell form event triggered by another form event

Question: I have created a form (in PowerShell Studio) and I am wondering if it is possible to see which event triggered another event? Example
<code>$button1_Click = {
   $combobox1.Text = 'This is a test'
}
$combobox1_SelectedIndexChanged = {
   Write-Host "I was triggered by button1!" #Is this possible?
}
</code>
Any help is highly appreciated!
Comment: The SelectedIndexChanged event fires whenever a new item is selected in the combobox. If you need to know somewhere in your code that a button was clicked I would suggest using a global semaphore variable that is set from within the Click event handler and checked in the SelectedIndexChanged event handler and reset after it is checked.
Comment: That is a good suggestion. I will try
Answer: Thank you EBGreen for the helpful suggestion!
<code>$button1_Click = {
    $global:buttonClicked = $true
    $combobox1.Text = 'This is a test'
}

$combobox1_SelectedIndexChanged = {
    If ($buttonClicked -eq $true)
    {
        Write-Host "I was triggered by button1!"
    }
    Else
    {
        Write-Host "I was triggered by user action!"
    }
    $global:buttonClicked = $false
}
</code>


How to add multiple links one under the other after input in convert box

Question: I've encountered some issues with a code.

function convert()
    {
      var text=document.getElementById("url").value;
      var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
      var text1=text.replace(exp, "$1");
      var exp2 =/(^|[^\/])(www\.[\S]+(\b|$))/gim;
      document.getElementById("converted_url1").innerHTML=text1.replace(exp2, '$1$2');

    }
 <textarea id="url" rows="3" cols="50">https://www.example.org
  </textarea>
  <input type="button" value="Convert" onclick="convert();">

So, after input, it adds the link below, but I'd like to be able to add links one under the other, not a single one. I am lost, any ideas? Thank you a lot :D (I'm still learning, please don't hate)
Comment: Could you show us some examples and the expected output?
Answer: You are only able to add one link because you are replacing the existing html inside converted_url1 with the newly generated html every time. Instead you want to be creating a new DOM Node and appending it to the document. This can be done many ways, one of which is to assign your new html to another DOM Node (typically one not on the page) and plucking the new content out. Seen below:

function convert()
    {
      var text=document.getElementById("url").value;
      var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
      var text1=text.replace(exp, "$1");
      var exp2 =/(^|[^\/])(www\.[\S]+(\b|$))/gim;

      var template = document.createElement('template');
      template.innerHTML = text1.replace(exp2, '$1$2');
      document.getElementById("converted_url1").appendChild(template.content);

    }
<textarea id="url" Placeholder="Enter Some Text With Links">
  </textarea>
  <input type="button" value="Convert" onclick="convert();">

Other approaches can have you just create the link, and assign it's properties to the desired values (as opposed to using an HTML string as in approach one). Just to demonstrate the syntax:
var link = document.createElement('a');
link.href = "http://somedomain.com";
document.getElementById('somecontainer').appendChild(link);

Comment: this solved it. OMG, i totally forgot about DOM nodes. I'm silly. Thank you a lot, sir!
Answer: Don't just set the innerHTML of the one
 tag, instead create a new element each time and append that new element into your output holder.

var textarea = document.querySelector('#url');
var outputEl = document.querySelector('#converted_url1');
var convertBtn = document.querySelector('#converter');

function convert() {
  var text = textarea.value;
  var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
  var text1 = text.replace(exp, "$1");
  var exp2 = /(^|[^\/])(www\.[\S]+(\b|$))/gim;
  var newP = document.createElement('p');
  newP.innerHTML=text1.replace(exp2, '$1$2');
  outputEl.append(newP);
}

convertBtn.addEventListener('click', convert);
<textarea id="url" Placeholder="Enter Some Text With Links"></textarea>

<input id="converter" type="button" value="Convert">

innerHTML` on one element. Instead create a new element each time:
Answer: Wrap it with a div:
$1
. Div has a display:block by default, so it will be located under the previous block element.

function convert()
    {
      var text=document.getElementById("url").value;
      var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
      var text1=text.replace(exp, "
$1
");
      var exp2 =/(^|[^\/])(www\.[\S]+(\b|$))/gim;
      document.getElementById("converted_url1").innerHTML+=text1.replace(exp2, '$1$2');

    }
<textarea id="url" rows="3" cols="50">https://www.example1.org
https://www.example2.org
https://www.example3.org
https://www.example4.org
  </textarea>
  <input type="button" value="Convert" onclick="convert();">

Comment: Good approach. I would just add a plus symbol on the fifth line:
`document.getElementById("converted_url1").innerHTML += text1.replace(exp2, '$1$2');`


Can this July 1958 NYC baseball game be identified?

Question: I've got two photos of a night game in NYC area after July 4, 1958 and before the end of August 1958 (when film was developed), likely around July 5 or 6.
Can anyone identify:

The Stadium
The Home Team
The Visiting Team
The likely game date
Any other info, such as current players on field

Detail of pitcher and batter/catcher:

Detail of pitcher and batter/catcher:
Comment: I'm voting to close this question as off-topic because memorabilia identification questions are not suitable for Sports Stack Exchange.
Comment: @Nij Can you please suggest a better site at StackExchange for it?
Comment: There isn't one.
Comment: Without doing too much research, I could tell you it's likely held at the old Yankees stadium based on [this picture](https://en.wikipedia.org/wiki/Yankee_Stadium_(1923)#/media/File:Yankee_Stadium_Color_1959.jpg) from Wikipedia's page on the old stadium. Compare the white railing on the second deck on each picture.  With that, it's safe to assume the home team is the Yankees. They had 5 opponent's at home after July 4th so it could be any of the [five teams](https://www.baseball-reference.com/teams/NYY/1958-schedule-scores.shtml) as the opponent.
Comment: Very well could be the Red Sox based on the... red socks.
Comment: @Steve-o169 That looks like an answer to me...
Comment: @WilliamKF Probably right, but I'm assuming this will be closed as off-topic so just gave some details in the comment.
Answer: I'll put this up as an answer because this question seems like it might not get closed...
From the description as being "in the NYC area", it was a quick leap to assume that we're talking about the Yankees here.  The time frame(1958) makes them the only likely choice given that the New York Mets did not exist and the New York Giants moved to San Francisco after the 1957 season.
This basically leaves only the Yankees in NYC and they played in the old Yankee Stadium from 1923 through 2008.  From the Wikipedia page for the old Yankee Stadium, I found this picture, which shows a similar white railing in the second deck along the first base line.  This and other features seem to match up with the pictures presented.

With the home team and location seemingly confirmed, looking at the Yankees schedule from 1958 shows a home stand from July 5th through the 20th including a 2-game series against the Red Sox,  a 5-game series against Cleveland, 3-game series' against the White Sox and Tigers, and a 4-game series against the Kansas City Athletics.  Based on the uniforms worn by the Red Sox during that season and the red stripe on the socks, it is probable that the Red Sox are the opponent in this game.  These games were played July 5th and 6th.
The Red Sox roster included a 39-year-old Ted Williams and the Yankees roster included the likes of Yogi Berra, Mickey Mantle, and Whitey Ford.  The best I can tell, the Yankees batter is wearing number 7 which would, in fact, be the number that Mickey Mantle wore that year. If the opponent is the Red Sox, the batter is either wearing 8 or 9 but the number is obscured by the bat being swung.  Number 8 is Pete Daley and number 9 would be Ted Williams.  Additional analysis would show that Pete Daley was a right-handed hitter -- which would mean this is most likely Ted Williams, who was a left-handed batter.
Comment: @WilliamKF I have a feeling it relates to [this meta post](https://sports.meta.stackexchange.com/questions/939/generalising-the-off-topicality-of-autograph-identification-questions).  No worries, in my opinion it was a specific and well presented question that gave enough details to answer it with reasonable certainty.  I understand the issue with most autograph/memorabilia questions, but this didn't fit the mold.
Comment: Awesome answer, thanks!  I'd say Ted Williams is most likely since the choice was made to only take two photographs during the game.
Comment: @WilliamKF Looks like we can actually eliminate Pete Daley as he was a right-handed batter.  I'll add that to the answer, but it's most probably Ted Williams based on that.


Linear mixed effect models with two independent variables

Question: I am estimating a random intercept and a random slope model using the following R code. My dependent and independent variable are both continuous.
randominterceptfixedslope<-lmer(y ~ x + (1|state),data=data,method="ML") # model with fixed slope but random intercept
randominterceptrandomslope<-lmer(y ~ x + (1+x|state),data=data,method="ML") # model with random slope and random intercept

anova(randominterceptfixedslope,randominterceptrandomslope)

Anova tells me that my randominterceptrandomslope model is a better fit on the data. So far good, please correct me if I am wrong.
My question is: If I have another independent variable $x_1$, can I put two independent variables in the above model i.e. can I have a randominterceptfixedslope and randominterceptrandomslope model with two independent variables. If yes, how do I do that? As in what the code should look like?
Thanks for your response. I got a second query. lets say my full model is this:
     randominterceptrandomslope<-lmer(y ~ x1 + x2 + x3 + x4 (1+x1+x2+x3+x4|state),data=data,method="ML")

If some of my independent variables are correlated, what is the procedure of reducing the collinearity issue in a linear mixed effect model?  I could spot collinerity  using VIF and retain the most significant independent variables but I can do this for each factor level (levels of state) individually. But won't it result in retaining some independent variables in one factor level while deleting the same in other factor level? I guess the main question is how to spot collinearity in a mixed effect model and what to do with it when you have 5 or 6 independent variables?
Answer: In linear mixed effects mode, definitely you can include more than one independent variable. The general linear mixed model has the form
$y_i=X_i \beta + Z_i bi + \epsilon_i$
where $b_i\sim N(0,D)$, $\epsilon_i\sim N(0,I_{n_i} \sigma^2)$, $X_i$ and $Z_i$ are the known design matrices for fixed($\beta's$) and random effects regression coefficients($bi's$) respectively. $I_{n_i}$ is the $n_i$ dimensional identity matrix and $D$ is the variance co-variance matrix of $b_i$.
So you can include as many independent variable you need in the model and also the random component. But you should be concerned that as you increase the dimension of random effects, the estimation procedure becomes more complex as $b_i$'s are unobserved and so does their variance covariance matrix $D$.
The R codes are as follows
randominterceptfixedslope<-lmer(y ~ x1 + x2 + (1|state),data=data,method="ML")
randominterceptrandomslope<-lmer(y ~ x1 + x2 + (1+x1+x2|state),data=data,method="ML")

Its not always the same set of covariate contribute both as fixed and random component. That means you can also think of the following model
randominterceptrandomslope<-lmer(y ~ x1 + x2 + (1+x1|state),data=data,method="ML")

or
randominterceptrandomslope<-lmer(y ~ x1 + x2 + (1+x2|state),data=data,method="ML")

You better use xyplot under lattice to see which covariate can be served in the random component.
Comment: @user3013423:  Probably a good idea to ask it in a separate question.
Comment: thanks a lot for your reply. But if I have collinearity in my independent variables, how to account for it in a lmer. I have edited my question to include this


Change water color in d3 orthographic transition map

Question: I am new to D3 and this is my first question to stackoverflow.
I am trying to change the color of the water in this example that contains transitions:
http://bl.ocks.org/mbostock/4183330
I am able to change the color in this example, which is static: http://bl.ocks.org/mbostock/3757125
I found this thread: How can I color ocean with topojson in d3 when I have coordinate info for land? However, this changes the area outside of the globe as well.
This section of the code appears to be the styling, but I can't figure what to add to change the water color.
c.fillStyle = "#bbb", c.beginPath(), path(land), c.fill();
c.fillStyle = "#f00", c.beginPath(), path(countries[i]), c.fill();
c.strokeStyle = "#fff", c.lineWidth = .5, c.beginPath(), path(borders), c.stroke();
c.strokeStyle = "#000", c.lineWidth = 2, c.beginPath(), path(globe), c.stroke();

Also, seeing the line of code below, I searched online for a reference list of possible topojson features and/or objects that might indicate water, and maybe I could figure out how to style that, but couldn't find one:
land = topojson.feature(world, world.objects.land),
I'm wondering if maybe this has something to do with canvas (which I don't really grasp).
Hopefully, I'm overlooking something obvious and noob-like.
Thanks much!
Answer: Ha! Of course:
Modify this line:
c.strokeStyle = "#ccc", c.lineWidth = .5 * ratio, c.beginPath(), path(globe), c.stroke();

To this:
c.fillStyle = "#000", c.beginPath(), path(globe), c.fill();

I feel silly, but I guess sometimes it takes writing it all out for the brain cells to click. Thanks!


Can "No front page content has been created yet. Add new content" be removed totally?

Question: I noticed that if there is content placed in the main content block, "No front page content has been created yet. Add new content" will appear on front page or perhaps any page. Most templates will be done in blocks, except node pages.
Can it be totally removed? If yes, how?
Answer: Add this to your theme's template.php file
function THEME_preprocess_page(&$variables) {
  if ($variables['is_front']) {
    unset($variables['page']['content']['system_main']);
  }
}

Comment: did that before but it wouldn't work. now it is working when I tried again. weird. thanks!
Comment: Template/theme changes often require a cache clear.
Answer: Easy. Specify a front page other than the default in your site configuration settings.
Answer: Actually you did not create an front page or home page yet.So you should create an page which will be your default home page.
So first create a page
And Go to
`Configuration->System->System Information`

and set the url Under 'Default front page'
You also can create a template file for front page as page--front.tpl.php
For more info check front page template
and front page
Comment: thanks but i have created page--front.tpl.php and it is still showing content. :( will look into the links


Features are sweet but what about content?

Question: I used features successfully to restore my VIEW and content type...but the data for the content type didn't make it? Did I miss the option or is this something you typically bring over manually?
Comment: Features does not do it on their own, you need to install UUID (to make IDs "migrate-able") and UUID_features (for the actual work). But what you do may be wrong. Usually you want code and config to go dev → live, and content to go live → dev, so think twice before you'll embed content in feature.
Answer: Features are useful to export (and import) configurations, but is not useful for "entities": users, nodes, files, terms, and so on.
A great module to export and import is Node Export
Comment: False, [features can be useful with content](http://drupal.stackexchange.com/q/20498/16495)
Comment: Yes, it works, but I think that this is the "right" way to export nodes. Feature go in "override" state if you edit the node? Features has been created for configurations, I'm not suggest to use it for nodes, simply.
Comment: Sometimes nodes are more a configuration than content. That's designed use case of UUID Features module. In cases like that "override mode" is exactly what should happen.
Comment: You can use nodes for many things, I'm simply saying that nodes should be used as nodes and it's a better developing practice to use other "tools" instead of nodes for configurations.
Comment: Especially for manual pages that are supposed to go with your feature? Why can't they be nodes?.. Of course you are free to have your opinion, but this site aims to be as opinion-less as possible.
Comment: On Drupal there many, many ways to obtain the same thing. Every suggestion is an opinion.. If Features works for you for this "task", it's a good thing, maybe in the future I'll use it in the same way.
Comment: It's not about how I use them; simply your answer does not cover what OP is asking. I wouldn't comment if your suggestion would be in the scope of OPs problem; suggesting that OP should change his planned workflow, when it's based only on your opinion, seems to be a bit too much - especially when his original idea may work pretty well.
Comment: Thanks for the input...I shall look into both solutions but I like the idea of less is more so if i can use features thats abonus


Am I using falsetto in this audio recording ? (vocal range test)

Question: I wanted to test my vocal range, and test how high I can go without forcing too much and without using falsetto. I tried to sing C4 to C5-D5 (I did 3 recordings), but I have the feeling that above B4 I'm forced to sing in falsetto (the last note which is D5 is definitely falsetto).
Can you tell me how high I can go without switching into falsetto?
Here are the 3 recordings :

https://vocaroo.com/i/s139fbfb2FFG
https://vocaroo.com/i/s0dnwmMTn4X5
https://vocaroo.com/i/s0NdW0M141e7
Comment: As Laurence Payne notes below, it would help if you could sing something where you're definitely in chest voice so we can hear the difference. Also, your age might be of importance; have you gone through a voice change?
Answer: Sounds to me that you're in falsetto all the way!   Or at least in such a light head voice as makes no difference.
Let's hear something starting (at least) an octave lower?
Answer: One technique a teacher showed me once (so, not a very scientific method) is to lightly touch the sides of you throat (or adam's apple, if you're a male) and start going up your range. When you stop feeling the vibration, it means you're using falsetto.
Disclaimer: I'm not a professional singer or teacher, so this may be very anecdotal.


How can I control access to group-private content based on organic groups roles?

Question: I would like my groups to be able to create content that is not only private to a group, but also private to certain roles within the group. For example, a post that is only accessible by members of Group A that also have the "officer" role.
Ideally, I'd be able to make the roles group-specific because different groups should be able to create and assign roles to their members.
How can this be accomplished?
Comment: Additional info: I'm using Organic Groups version 7.x-1.3.
Answer: I needed somewhat similar functionality for a drupal 6 site and gave up on using OG for this.
Instead I made a vocabulary that defined my groups and used tac_lite for setting access.
The setup is being ported to drupal 7 right now, and I haven't had any problems implementing the same functionality in d7 so far.
Maybe tac_lite is a solution for you? http://drupal.org/project/tac_lite
Answer: One possibility, which would twist your idea but still offer the same functionality would be http://drupal.org/project/og_subgroups (still in beta for D7 unfortunately).
Answer: OG User Roles allows group administrators of organic groups to grant additional user roles to individual members of a certain group.
Comment: Unfortunately, there is no version for Drupal 7. As far as I know, the module's functionality has been rolled into OG 7, but the roles I can grant still don't allow me to restrict _view_ permissions of a particular post to certain roles.
Answer: To allow permissions and roles to be changeable for groups, you need to add that feature to the 'group entity' This can be achieved by using this example link. http://yourwebsite/admin/config/group/fields.
http://vimeo.com/34032652


Trying to automaticall fill out a form with user data

Question: I am new to PHP, so please forgive my simple question (I'm not even sure of how to ask it or what keywords I need to use).
Basically, I'm trying to update a user's data in my database.  I have a php for listing out all customers (phpselect.php):

<?php
#
# Connect to the database
#
$conn=odbc_connect('database1','','');
if (!$conn)
{exit("Connection Failed: " . $conn);}

#
# SQL statements
#
$sql="SELECT * FROM customer";
$rs=odbc_exec($conn,$sql);
if (!$rs)
{exit("Error in SQL");}

#
# Make a table
#
echo "

";
echo "Action	";
echo "Customer ID	";
echo "Last Name	";
echo "First Name	";
echo "Middle Initial	";
echo "Home Phone	";
echo "Cell Phone	";
echo "Date of Birth	";
echo "Address	";
echo "City	";
echo "State	";
echo "Zip Code	";
echo "Employer	";
echo "Referrer	";
echo "Agent
";

#
# Fetch records from SQL result-set
#
while (odbc_fetch_row($rs))
{

#
# Set field variables...
#
$cust_ID=odbc_result($rs,"cust_ID");
$cust_last=odbc_result($rs,"cust_last");
$cust_first=odbc_result($rs,"cust_first");
$cust_mi=odbc_result($rs,"cust_mi");
$home_phone=odbc_result($rs,"home_phone");
$cell_phone=odbc_result($rs,"cell_phone");
$DOB=odbc_result($rs,"DOB");
$street=odbc_result($rs,"street");
$city=odbc_result($rs,"city");
$state=odbc_result($rs,"state");
$zip_code=odbc_result($rs,"zip_code");
$employer=odbc_result($rs,"employer");
$referrer=odbc_result($rs,"referrer");
$agent_ID=odbc_result($rs,"agent_ID");

#
#  ...and display them by variable name
#

echo "
";
echo "edit	";
echo "$cust_ID	";
echo "$cust_last	";
echo "$cust_first	";
echo "$cust_mi	";
echo "$cust_last	";
echo "$home_phone	";
echo "$cell_phone	";
echo "$DOB	";
echo "$street	";
echo "$city	";
echo "$state	";
echo "$zip_code	";
echo "$employer	";
echo "$referrer	";
echo "$agent_ID
";
}

#
# Close the connection to the database
#
odbc_close($conn);

#
# End the table
#
echo "
";
?>

...and I am trying to add in a link ('Update') on each line that will send that user's information (from the database) to the fields in a form in order for the fields to be edited (phpinsert.php):

Enter Customer Information

(* indicates required fields)

<form action="phpinsert.php" method="post">
Last Name*: <input type="text" name="cust_last">

First Name*: <input type="text" name="cust_first">

Middle Initial: <input type="text" name="cust_mi">

Home Phone*: <input type="text" name="home_phone">

Cell Phone: <input type="text" name="cell_phone">

Date of Birth (mm/dd/yyyy)*: <input type="text" name="DOB">

Street Address: <input type="text" name="street">

City: <input type="text" name="city">

State: <input type="text" name="state">

Zip Code: <input type="text" name="zip_code">

Employer: <input type="text" name="employer">

Referrer: <input type="text" name="referrer">

Agent*:

<select name="agent_ID" class="formEntry">
<option value="1">Guy Smiley</option></select>

<input type="submit">
</form>

I'm not sure how to do this or how to ask it correctly though?
Thanks for any help.
Comment: You would benefit from watching some of Alex Garret's FREE tutorials over at [phpAcademy](http://phpacademy.org)
Comment: A term you will come across a lot for this type of operation is CRUD, I will leave you to look it up and search for simple tutorials featuring PHP and CRUD.  Good luck!
Answer: You could send your values to the Update form's page in the URL:
<?php
$info = "cust_id=".$cust_id."&cust_last=".$cust_last; //etc.
$url = "http://".$_SERVER['HTTP_HOST']."/phpinsert.php?".$info;
?>

<a href="<?php echo $url; ?>">Update

And then in the update form:
Customer ID: <input type="text" name="cust_id" value="<?php echo $_GET['cust_id']; ?>">

Customer Last: <input type="text" name="cust_last" value="<?php echo $_GET['cust_last']; ?>">

Comment: I am trying to implement this, but whenever I try to href my 'Update' field (in my table), the page no longer displays (just a blank page).
Comment: When a php page is blank that is usually an indication you have a syntax error. Try checking your syntax and adding ini_set('display_errors',1);  Update your code and I'll post another answer to help you.
Answer: Here's the general idea (if you'd like to keep the form on the same page as the table):
Create a list for each line that contains all of the elements, ie:
PHP
$alldata= "'".$cust_ID."','".$cust_last."','".$cust_first."','". ... ;

Push that list into a javascript function, ie:
PHP
echo "$cust_ID	";
....
echo "$agent_ID	";
echo "Update
";

You'll need to add an id to each textbox, ie:
HTML
Last Name*: <input type="text" id="cust_last" name="cust_last">
First Name*: <input type="text" id="cust_first" name="cust_first">

Now use javascript to push those values into the form, ie:
Javascript
function populateForm(custid,cust_last,cust_first, ...) {
   document.getElementById('cust_last').value = cust_last;
   ...
}

Please comment if you need more help and I'll elaborate further.


A continuously differentiable function that can't be solution of an ODE

Question: Is it possible to find a continuously differentiable real function $f$ defined on  $\mathbb R$ such that $f$ can't be the solution of an ODE $f^\prime(x) = G(f(x))$ in any neighborhood of $0$?
Comment: A remark: if $G$ is injective, then we can always choose $G := f' \circ f^{-1}$. $C^1$ functions are at least (locally) injective so in any sufficiently small $(c,d) \subset [a,b]$, the restriction of $f$ to $(c,d)$ is always the solution to an ODE.
Comment: I think you should see https://en.wikipedia.org/wiki/Peano_existence_theorem
Comment: Maybe $f(x) = x^2$ on $[-1, 1]$, where plugging in $x = -1$ and $x = 1$ would give contradictory values of $G(1)$?
Comment: @MathematicsStudent1122 Thanks for the comment. Indeed we should consider non injective maps $f$.
Comment: A typo in my comment above: It should be "if $f$ is injective" not "if $G$ is injective", but I suppose you understood what I meant.
Answer: You don't mean an arbitrary ODE, you mean an autonomous first order ODE. And for that, the main point is that if the solution to the ODE IVP is unique, then there cannot be any nontrivial critical points, i.e. if $f'=0$ at any point then $f$ is constant. If $G$ is not nice enough to ensure uniqueness (e.g. $G(x)=|x|^{1/2}$) then even that property goes out the window.
Answer: The notation $G[a,b] \to \mathbb R$ isn't clear to me. If the domain of G is the set of function from [a,b] to R, then one can simply declare G(f) to be f', at which point f is a solution of f' = G(f).
EDIT: With you change, it seems like any function with different derivatives at the same y value would qualify. For instance, if f(x) = sin(x), then at x = 0, f(x) = 0 and f('(x) = 1. At x = pi, f(x) = 0 and f'(x) = -1. Since G(0) can't be both 1 and -1, there's no G that gives f as a solution over an interval that includes both 0 and pi.
Comment: I changed the original question.
Comment: Sorry for not being precise enough. The target is that $f$ can't be solution of an ODE in any neighborhood of $a$.
Answer: First let us summerize what has been mentioned in the comments/other answers:

as Ian mentioned, if we demand $G$ to be such that uniqueness of solution holds (e.g. locally Lipschitz) then it is not possible to find such a $G$.
as MathematicsStudent1122 mentioned in a comment, $C^1$ functions are locally invertible if the derivative is different from zero.

Thus, for given $f \in C^1$ a right-hand side of an autonomous ODE which is solved by $f$ is given by
$$
G(x) = \begin{cases}
0 , & \text{if} \,\, f'(x) = 0 \\
f' \circ \left(f{\big|_{B_r(x)}}\right)^{-1}(x), & \text{otherwise}.
\end{cases}
$$
where $B_r(x)$ is the ball of radius $r$ around $x$ such that $f$ is invertible on $B_r(x)$.


Exposed filter only allowing content types in list

Question: I have a view called (Resources) that displays content filtering by content type. These are the selected options:

Expose this filter to visitors, to allow them to change it: ✅
Filter type to expose: Single filter
Operator: Is one of
Content types: Article, Post, Story (NOTE: I have other content types, such as Basic Page that shouldn't be included in this view at all)
Allow multiple selections: ✅

However, when none of the options are selected, it also brings in other content types, such as Basic Page, which shouldn't be.
How can I make it so that when none of the content types in the exposed filter are selected, the results are still filtered such that the nodes must be of one of the chosen content types (Article, Post, Story)?
In other words, I would like the view to behave such that, when none of the content types are selected, it acts as though all of them are checked.
Answer: OK, I figured it out.
I simply added a duplicate of my "Content type" filter, except this filter is not exposed. Same settings as above ("Is one of", Article/Post/Story, etc.), just an extra restriction on the results to always filter by all of the desired content types, with the exposed filter being an additional option to further narrow down the results.


Concatentate all rows / alt. find using a regex across all rows

Question: I have a table like this:
+----+---------------------------------------------------+
| id |                       value                       |
+----+---------------------------------------------------+
|  1 | My favourite website is http://stackoverflow.com/ |
|  2 | This text doesn't have a link! :(                 |
|  3 | Hi! A link! http://www.google.com/                |
+----+---------------------------------------------------+

But of course with many rows. What I really want is a list of all the URLs in the fields. In reality they are blog posts, so some will have more than one link. I'm only interested in external links (i.e. start with (/http(s)?/) ).
So, my first thought was to perform a SQL query that returns something like:
My favourite website is http://stackoverflow.com/,This text doesn't have a link! :(,Hi! A link! http://www.google.com/

so I can use regex in PHP.
How do I write that query?
Alternatively, it would be great to go straight to list of URLs with SQL, but I suspect that might be too hard due to the multiple links thing.
Any ideas?
Answer: use GROUP_CONCAT
SELECT GROUP_CONCAT( value  )
FROM   tableName

SQLFiddle Demo

OTHER SOURCE

GROUP_CONCAT
Comment: there are functions for [Regular Expression in MySQL](http://dev.mysql.com/doc/refman/5.1/en/regexp.html) but i don't think it fits here. hehe
Comment: Cool, that's what I thought - matching = yep, but then returning matches seems to be nope. Thanks. Hopefully noone I work with notices that I posted this question!
Comment: Why didn't I think of doing this? I use GROUP_CONCAT all the time! Think the cold must be freezing my brain! Any ideas about whether I can also do the regex in SQL?
Comment: Actually, Guess I could narrow down the return string by specifying something like WHERE value LIKE '%http$'. Perhaps that would mean I had less memory/data exchange.
Comment: Some sql functions like `GROUP_CONCAT` is not usually taught :)
Comment: Turns out that there is a length limit for this, so it's not really going to work for me (I can override it, but I need it to be huge.) Oh well.
Comment: @RichBradshaw yep, GROUP_CONCAT has a limit.


Can an ARIMA model be used to forecast temperature data?

Question: I'm fairly new to statistics in general and R specifically and am taking a biophysics course which uses both.  My project is to determine trends in temperature and precipitation for my region, using daily measurements from a single monitoring station.  I have daily values for Ave. Temp, min, and max, as well as precipitation.  From what I have found in my research it seems like ARIMA may be the most effective option available (RHtestV4, etc. don't seem to be available to the public). Would you recommend using ARIMA modeling or is there another option available?
I've tried linear regression but even going to yearly means, there is still too much variance to obtain a decent trend line.  Any information or tips would be immensely appreciated.
Thank you.
Comment: Daily temperature can certainly be modeled as a time series given that you have daily measurements.  Take the average temperature over time and fit an ARIMA model and see if it fits well. The same can be done with precipitation. There are other forms of time series model that can be fit such as ARCH and GARCH.  Search the site and you will find lots of discussion about these models.
Comment: You will probably need to look into seasonality
Comment: Another idea which I now is used with temperature data is Kalman filters:http://www.ecmwf.int/sites/default/files/elibrary/1996/8348-application-kalman-filtering-numerical-weather-prediction.pdf   http://journals.ametsoc.org/doi/pdf/10.1175/1520-0434(1995)010%3C0689%3ADCOSTS%3E2.0.CO%3B2
Answer: I think it can. Campbell & Diebold (2005) use an ARX-GARCHX model for point and density forecasting of daily average temperature in Atlanta, Chicago, Las Vegas, and Philadelphia.
They compare their forecasts with a few competitors, the best among which is the forecasts from Earth Satellite (EarthSat) corporation which are used to settle temperature-related weather derivative products traded on the CME. In the end, ARX-GARCHX never beats EarthStat, but still looks quite well considering that the model is rather simple (conceptually -- and especially computationally) as compared to models used by professional weather forecasters.
Point forecasts: ARX-GARCHX does worse than EarthSat forecasts in 1-4 day horizons, but already in 5-8 day horizons the difference in forecast accuracy between the methods is not statistically significant. Beyond 8 days, ARX-GARCH does roughly as well as the EarthSat forecast.
Density forecasts: No comparison between EarthSat and ARX-GARCH (?).
References:

Campbell, Sean D., and Francis X. Diebold. "Weather forecasting for weather derivatives." Journal of the American Statistical Association 100.469 (2005): 6-16.


Getting client hostname in Node.js

Question: is it possible to get hostname in Node.js?
This is how I get client's IP:
var ip = request.header('x-forwarded-for');

So, how do I get client's hostname?
var hostname = request.header('???');

Thanks for reply!
Comment: What makes you think they have one? :)
Comment: Actually, even if HTTPD have this ability, it would be disabled in realworld installations. Because its slow. BTW, X-FORWARDED-FOR is proxy header, correct one is REMOTE_ADDR. (and REMOTE_HOST in case of hostname lookups)
Comment: definitely not, that's a reverse DNS lookup, and everyone may or may not have one.
Comment: So not everybody has hostname?
Answer: You can use the 'dns' module to do a reverse dns lookup:
require('dns').reverse('188.8.131.52', function(err, domains) {
    if(err) {
        console.log(err.toString());
        return;
    }
    console.log(domains);
});

See: http://nodejs.org/docs/v0.3.1/api/all.html#dns.reverse
Answer: I think this might help you. That's not exactly the client hostname but the ip address.
function getClientAddress(req) {
  return req.headers['x-forwarded-for'] || req.connection.remoteAddress;
}

Comment: not true, it uses the remote address if the connection wasn't proxied
Comment: You should make that clearer in your post, but +1 all the same
Comment: Solves the issue for local development and having the app on Heroku behind a reverse proxy! :)
Answer: I think the only way you can do it is like this:
<form method="post" action="/gethostname">
    What is your hostname?
    <input type="text" name="hostname" id="hostname">
</form>

But I would suggest you don't really need it, it's not like you can do anything useful with the information.  If you just want a string to identify with the user's machine then you can make something up.
If what you're really after is the FQDN then I would suggest it's still not really that useful to you, but for that you need Reverse DNS lookup.  If you're on a VPS or similar you can probably configure your box to do this for you, but note that it'll likely take a few seconds so it's not a good idea to do it as part of a response.  Also note, you'll not be getting the user's machine's FQDN in most cases but that of their router.
Answer: You can also achieve the same if you're using socket.io in the following manner:
// Setup an example server
var server = require('socket.io').listen(8080);

// On established connection
server.sockets.on('connection', function (socket) {

    // Get server host
    var host = socket.handshake.headers.host;

    // Remove port number together with colon
    host = host.replace(/:.*$/,"");

    // To test it, output to console
    console.log(host);
});

Answer: if you are using express,
then you can do as follows,
var express = require("express");
var app = express.createServer();
app.listen(8080);

app.get("/", function (req, res){
    console.log("REQ:: "+req.headers.host);
    res.end(req.headers.host);
});

Comment: When I try this, `req.headers.host` contains the host name of the *server* right down to the "8080" port being used.
Comment: As explained before, if the request has been proxied, the host header don't have the correct data.
Answer: You can get hostname from the os module:
var os = require("os");
os.hostname();

Comment: This gives server's hostname.

Getting client hostname in Node.js


Hierarchical clustering with categorical variables

Question: Can categorical variables be used in hierarchical clustering?  I have heard only continuous variables are used, but have seen people discussing categorical variables may / may not be used as well.  Can anyone provide insight?
Comment: Yes of course, categorical data are frequently a subject of cluster analysis, especially hierarchical. A lot of proximity measures exist for binary variables (including dummy sets which are the litter of categorical variables); also entropy measures. Clusters of cases will be the frequent combinations of attributes, and various measures give their specific spice for the frequency reckoning. One problem with clustering categorical data is stability of solutions. And [this](http://stats.stackexchange.com/q/218604/3277) recent question puts forward the issue of variable correlation.
Comment: Search this site for `hierarchical clustering categorical` to read related threads.
Comment: @ttnphns: do you want to post your comment(s) as an answer? [Better to have a short answer than no answer at all.](https://stats.meta.stackexchange.com/a/5326/1352) Anyone who has a better answer can post it.
Comment: Possible duplicate of [Clustering of mixed type data with R](https://stats.stackexchange.com/questions/24540/clustering-of-mixed-type-data-with-r)
Comment: I don't think this is a duplicate, exactly. The linked question is about R, and might even be off-topic now.  This question is about statistics and doesn't mention a software package.
Comment: [This article](http://www.sthda.com/english/articles/31-principal-component-methods-in-r-practical-guide/117-hcpc-hierarchical-clustering-on-principal-components-essentials/#case-2-clustering-on-categorical-data) shows how to perform cluster analysis on categorical variables using principle components to convert categorical variables into continuous ones.
Answer:
Yes of course, categorical data are frequently a subject of cluster
  analysis, especially hierarchical. A lot of proximity measures exist
  for binary variables (including dummy sets which are the litter of
  categorical variables); also entropy measures. Clusters of cases will
  be the frequent combinations of attributes, and various measures give
  their specific spice for the frequency reckoning. One problem with
  clustering categorical data is stability of solutions. And this recent
  question puts forward the issue of variable correlation.
Comment: I've copied this comment by @ttnphns as a community wiki answer because the comment is, more or less, an answer to this question. We have a dramatic gap between answers and questions. At least part of the problem is that some questions are answered in comments: if comments which answered the question were answers instead, we would have fewer unanswered questions.


What am I missing here: $U(144) \neq U(140)$

Question: I'm confused about the following exercise:
Prove that $U(144)$ is isomorphic to $U(140)$.
Here are my thoughts:
$$U(144) = U(12^2) = U(3^2)\oplus U(2^4) = \mathbb Z_{6} \oplus \mathbb Z_{8}$$
and
$$ U(140) = U(2^2 *7*5) = U(2^2) \oplus U(5) \oplus U(7) = \mathbb Z_{2} \oplus \mathbb Z_{4} \oplus \mathbb Z_{6}$$
And I have the following result:
$\mathbb Z_{n_1 \dots n_k}\cong \mathbb Z_{n_1}\oplus \dots \oplus \mathbb Z_{n_k}$ if and only if $n_i$ are pairwise coprime.
But $2$ and $4$ are not coprime therefore $\mathbb Z_{2} \oplus \mathbb Z_{4} \oplus \mathbb Z_{6}$ is not isomorphic to $\mathbb Z_{6} \oplus \mathbb Z_{8}$.

What am I doing wrong?
Comment: $U(p^n)$ is not, in general, cyclic when $p=2$. Check $U(8)$ by hand, for example.
Answer: Hint: $U(2^4)$ is not isomorphic to $\mathbb{Z}_8$.


In Ruby, how do I use the value of a key from JSON as the key for a ruby hash that has it's values composed of two concatenated values?

Question: I have JSON from an API of the form:
{
"result":[
  {  "sys_created_on":"2018-10-10",
     "number":"NUM54321",
     "short_description":"This is a short description.",
     "other":"this is other stuff"
  },{
     "sys_created_on":"2018-10-12",
     "number":"NUM12345",
     "short_description":"This is another short description.",
     "other":"more extra stuff"
  },{
     ... and so on for 1000's of lines

In Ruby, what I'd like to do, is create a structure that is of the form
{"sys_created_on(1)" => "number(1) + " | " + short_description(1)",
 "sys_created_on(2)" => "number(2) + " | " + short_description(2)",
 "sys_created_on(3)" => "number(3) + " | " + short_description(3)",
 etc...
}

specifically, using the example data:
{"2018-10-10" => "NUM54321 | This is a short description.",
 "2018-10-12" => "NUM12345 | This is another short description.",
 etc...
}

That is ... use the value of a key from the JSON as the key for a ruby hash that has it's values composed of two concatenated values from the same JSON.
I ended up solving this problem using the following code:
my_list = result.each_with_object({}) do |item, hash|
   hash[item['sys_created_on']] = item['number'] + " | " + item['short_description']
end

That gave me what I needed in the way I needed it.
Comment: How do you determine which values to concatenate? And is the key supposed to be `value1`? Could you give an example with clear inputs and the output you'd like? Finally, why are you deconstructing the hash like this?
Comment: It would be helpful if you would provide a fuller example to show what you want to do. Examples should be complete (no `...`, for example) and all inputs should be valid Ruby objects (strings should be in quotes, for example). That enables readers to test their code against your example to confirm that it provides the desired result. When giving examples please assign a variable to each input (e.g., `str = "..."` or `h = { ... }`) so that readers can refer to those variables in answers and comments. Always show the desired result (as you have) and make examples as concise as possible.
Comment: As the first step is obviously to create a hash from the JSON string, it would have been be simpler to begin with that hash and make no mention of JSON.
Comment: @CarySwoveland Thanks! I updated it and ended up solving the problem while I was editing this.
Answer: require 'json'

json = '{ "result":[{ "key1":"value1", "key2":"value2", "keyN":"valueN" }] }'

h = JSON.parse(json)
  #=> {"result"=>[{"key1"=>"value1", "key2"=>"value2", "keyN"=>"valueN"}]}
arr = h["result"].first.values
  #=> ["value1", "value2", "valueN"]
{ arr.shift=>arr.reduce(:+) }
  #=> {"value1"=>"value2valueN"}

The first two statements can of course be chained:
arr = JSON.parse(json)["result"].first.values
  #=> ["value1", "value2", "valueN"]

Comment: I suggest you edit your question to incorporate the content of your comment. In general, clarifications of questions should be done by editing the question rather than elaborating in comments, in part because not all readers read all comments.
Comment: Thanks -- this is close, but I need to be able to select certain keys by name and create the hash from those specific keys. I apologize if that wasn't clear. There are about 50 key:value pairs per item in result. I need to create a hash from where the hash key is the value of a json key called "sys_created_on" (a date) and map that to a hash value created from json key values "number" and "short_description" ... {"(value of) sys_created_on" => "(value of) number + (value of)short_description"} ... I think I see where you are going though and I'm working through some ideas now.
Answer: Here's what I ended up with:
  new_old = result.each_with_object({}) do |item, hash|
      hash[item['sys_created_on']] = item['number'] + " | " +
      item['short_description']
  end

This iterates over the given collection passing each element and the given object to the block. Perfect for building hashes.


pandas return index of rows having more than one 'NA' value

Question: my code:
import pandas as pd
from sklearn.preprocessing import LabelEncoder
column_names = ["age","workclass","fnlwgt","education","education-num","marital-status","occupation","relationship","race","sex","capital-gain","capital-loss","hrs-per-week","native-country","income"]

adult_train = pd.read_csv("adult.data",header=None,sep=',\s',na_values=["?"])
adult_train.columns=column_names
adult_train.fillna('NA',inplace=True)

I want the index of the rows which have the value 'NA' in more than one column. Is there an inbuilt method or I have to iterate row wise and check values at each column?
here is the snapshot of the data:
I want index of rows like 398,409(missing values at column B and G) and not of rows like 394(missing value only at column N)
Comment: Please see https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples., we need data and expected output
Comment: `adult_train.loc[adult_train.isnull().sum(axis=1) > 1].index` this might help, remove this `adult_train.fillna('NA',inplace=True)` which is inefficient.
Comment: I am using `adult_train.fillna('NA',inplace=True)` so that I can use `adult_train['column name'].value_counts()` to get counts of missng values in that column
Comment: Dude just use  `value_counts(dropna=False)`. You will miss most of the features over missing values if you replace it with a string.
Comment: If your case `adult_train.loc[adult_train.isnull().sum(axis=1) > 1].index` this is all your are after. Didn't this work?
Comment: Thank you, yes both of the solutions were what i needed.
Answer: Use isnull.any(1) or sum to get the boolean mask, then select the rows to get the index i.e
df = pd.DataFrame({'A':[1,2,3,4,5],
               'B' :[np.nan,4,5,np.nan,8],
               'C' :[2,4,np.nan,3,5],
               'D' :[np.nan,np.nan,np.nan,np.nan,5]})

   A    B    C    D
0  1  NaN  2.0  NaN
1  2  4.0  4.0  NaN
2  3  5.0  NaN  NaN
3  4  NaN  3.0  NaN
4  5  8.0  5.0  5.0

# If you want to select rows with nan value from Columns B and C
df.loc[df[['B','C']].isnull().any(1)].index
Int64Index([0, 2, 3], dtype='int64')

# If you want to rows with more than one nan then
df.loc[df.isnull().sum(1)>1].index
Int64Index([0, 2, 3], dtype='int64')

Comment: Thanks, I didn't know that one can use `sum` on boolean values.


Drupal views - 2 latest reports and related content

Question: My Drupal site contains a certain type of report, and these reports sometimes have 1 or more amendments, which will have field_related_content pointing to the report they're amending.
I'm trying to set up a view that will display the latest two reports, plus any amendments to those reports, but I haven't been able to figure out how to do it.
Can Views filters refer to results from other filters?
Answer: You can create view in a view using View Field View (https://drupal.org/project/views_field_view):

Create a view of reports
Create a view of amendments which takes a contextual filter of node id and filters amendments which have a field reference with that node id value
Put the view amendments view in a view of reports as a field (using above mentioned module - see it's documentation for more specific info if necessary)

Btw. just a thought - isn't it possible for you to switch the architecture and have the node reference field in the document content type, referencing the amendments? - this way you wouldn't need a view in a view and it would be easier to display it.
Comment: Thanks, I'll check out that module.  It is possible to switch, but that's a crummy workflow since the amendments typically come out later than the reports.  The desired workflow is to create an amendment and link it to the original report, which is easier than creating an amendment and then going back and editing the original report to reference the new amendment.


Is there a vertex-transitive graph with $n$ automorphisms that has $n \geq 3$?

Question: I've established that a lower bound for the automorphism group on a vertex-transitive undirected graph $G$ is $n$ using the orbit-stabilizer theorem. I'm now curious whether it's possible to achieve that bound nontrivially - I have boring examples for $n = 1$ and $n = 2$, but I'd like something more interesting.
Comment: can the graph be directed?
Comment: It's very easy to see for $n=3,4$ it is impossible for undirected. Also notice that cycles have exactly $2n $automorphisms
Comment: No, I should have specified I'm only working with undirected graphs.
Answer: This is wrong as noted in comments, I'll leave it here as a failed attempt.
Its impossible for all $n\geq 3$.
Notice that the only transitive subgroups of $S_n$ are those generated by $n$-cycles.
Therefore we can label our vertices $v_1,v_2\dots v_n$ in such a way that the only $n$ automorphisms are those of the form $f_i$ such that $f_i(v_j)=v_{i+j}$ (working $\bmod n$ of course).
We conclude that the graph can be formed in the following way.
Pick a subset $A$ of $\{1,2\dots n-1\}$ and connect $A_i$ to $A_j$ if and only if $i-j\in A$.
But notice that the graph is undirected, so not every selection gives us a correct graph(in the case in which we allow for directed graphs taking $A=\{1\}$ gives us a transitive graph with $n$ automorphisms (the directed cycle).
If you want to get an undirected graph you need for $A$ to satisfy the following condition: $a\in A \iff n-a\in A$.
Notice that by doing all of the automorphisms of $D_{2n}$ come into play, so for example the map that fixes $v_1$ and sends every other $v_j$ to $v_{-j}$ is also an automorphism.
Comment: $A_6$ is a transitive subgroup of $S_6$ and is not generated by 6-cycles.  A 6-cycle is an odd permutation.
Answer: Yes, there are larger graphs for which the bound is achieved.  Let $X$ be the Cayley graph of $S_7$ generated by a set $S$ of transpositions for which the transposition graph $T(S)$ is an asymmetric tree.  Then $X$ is a vertex-transitive graph on $7!=5,040$ vertices and it has exactly $5,040$ automorphisms.
More generally, (Godsil and Royle, Algebraic Graph Theory) proved that if $S$ is a set of transpositions generating $S_n$ and the transposition graph of $S$ is an asymmetric tree, then the Cayley graph of $S_n$ with respect to generating set $S$ has exactly $|S_n|$ automorphisms.  Such graphs are called graphical regular representations (GRRs) and have the smallest possible full automorphism group in some sense.


How to best isolate a wall for piano practice?

Question: I share one wall with the neighbor in the room where I practice piano. This is the direct point of contact with my neighbor. All the other walls are either to the street or my own apartment.
What is the best way to isolate this room?
How can I isolate from structural transmission?
Will isolating this wall be enough? This is a ground floor and no one lives directly above, but can the sound propagate through the upper floor to the next house?
Answer: First off, if you are renting where you live, then there's a limit on what you can do that will be effective. The most effective things you can do require modifications and therefore ownership.
A little bit of physics: When you play, the piano vibrates the air, the air hits the wall and starts the wall vibrating, some of the energy gets absorbed by the wall and some of it gets passed through the wall and vibrates the air on the other side of it, which then vibrates your neighbor's eardrums and they can hear you playing.
We don't want to change how the piano works, and we can't change anything on your neighbor's side of the wall, so we have to either change the transmission through air from the piano to the wall in your apartment, or we have to change the wall.
The essential property that we need to change in order to stop or diminish acoustic vibrations is mass. We want to put as much mass as possible (ideally mass that is effective at converting acoustic energy into heat) in between the piano and your neighbor. We have narrowed down our options to adding mass to your side of the wall, or adding mass in the air between the piano and the wall in your apartment.
Since sound waves diffuse around things, we can't just add a lump of mass somewhere in the room - it has to be spread out and be as large as possible. So in terms of attacking the air space between the piano and the wall, our best option is another wall. This can be a temporary wall (and this is pretty much your only option if you rent) or a permanent wall.
Temporary walls (usually called gobos, not to be confused with the concert lighting devices of the same name) can be purchased in many different configurations but are often made from materials available in hardware stores. Note that most gobos are designed to absorb and diffuse sound and less designed to stop transmission, with the exception of a specific type of gobo called a drum shield. If you are renting (or if this seems like the easiest thing your situation), a drum shield may be a very good solution to your problem.
If you own and you want to go with the "nuclear option", then you can build one or more walls within the room. The particular design for these walls is another question entirely, but this answer will touch on design elements below. Actually building a room within a room for isolation is the ultimate step. For a piano, that's probably overkill.
If you own and you want to reduce the sound transmitted through the wall itself, then again, you'll want to add mass. Not all mass is created equally, though. It turns out that gypsum board (also called drywall, sheet rock, or wallboard) has pretty good sound absorption for its weight, and of course is pre-made to be a wall construction material (particularly note that gypsum board is also effective at slowing the spread of fire). So, merely adding a layer of gypsum board (5/8" thickness seems to be popular for this) to the inside of the existing wall can make a big difference. One simple and affordable way to make a bigger difference when adding gypsum board is to use Green Glue to attach the gypsum board to the existing wall. Green Glue is specifically designed to both easily add a little more mass and to maximize the sound energy that is converted to heat by the augmented wall. Green Glue with 5/8" gypsum board is a very reasonable and effective option for augmenting the wall between you and your neighbor to reduce sound transmission.
If you do feel like building another wall is the way you want to go, there are likely to be a lot of code implications and other challenges. You could merely build half a wall right in front of the existing wall, with the interior side composed of two layers of gypsum board with Green Glue in between. If done correctly, that could be as or even more effective than building an entire wall, and it would also minimize the impact on the room size.
Yes, sound can go through the ceiling and then sideways and then back down into your neighbor's apartment, but that involves travelling through three walls instead of just one. I wouldn't worry too much about this unless and until you have taken some action to mitigate the more direct transmission and then determined that the "upper" route is also a problem. If it is, you'll notice drum shields are available with "ceilings" and gypsum board and green glue can be applied to ceilings as well. You could also put heavy rugs and or carpet on the floor above.
Comment: Sound transmission through the building structure is usually a bigger problem than through the air. Without vibration isolators, the piano's vibrations will go through the piano legs into your floor, and into the structural beams that support the floor. The floors of all the other rooms on the same level will then act as huge "loudspeaker cones" to transmit the sound back into the air in those rooms. If you can't hear your neighbours talking, or their TV playing, you don't have a problem with sound transmission through the *air and the wall*.
Comment: Great answer!! Can structural transmission be problem? This happens more when hammering something into a wall, but I am just wondering if the piano vibration travel trough structure, by contact?
Comment: Yes, good point. In this case, vibrations in the body of the piano travels down the legs, causes the floor to vibrate, which then could be more less effectively transmitted to the floor and/or walls of the neighbor's unit, depending on the construction. Here's a product designed to mitigate that: http://www.pianosupply.com/acoustic/ and a different design here: http://www.pianoforteservice.com/piano-noise-reduction/
Comment: Or they talk and watch their TV at levels lower than fortissimo on the piano. That is the case where I live. My walls are thin but it's hard for me to remember that because my neighbors are so quiet.
Answer: The only way to make a LOT of difference is to build 'a room inside a room' isolated from the main structure.  I imagine this isn't a practical option.  Other methods will only reduce the sound a little, and a neighbour inclined to be annoyed by 85dB of piano will be just as annoyed by 75dB.
You need a musical neighbour or a digital piano with headphones.  Sorry.
Answer: I've many years experience in soundproofing including nightclubs, film studios and the recent London British Museum extension. Most aspects have been covered here.
It is important to understand the part construction connectors make in transfer of vibration/noise. there are a number of aspects to consider. Screws bolts and direct fixings will act as a transfer element for noise. As others have said density/mass is important, but equally so is air space (this aids sealed double/triple glazed units in windows etc for example).
From my experience if approaching a project I try to introduce as many layers of different materials as possible with different elements of mass involved including acoustic/high density plasterboard (double layered of different thicknesses- important this, the best acoustic glass units will have two different thickness to avoid bridging and should have one pane in laminated glass), plasterboard should be mounted on resilient bars, if you can line walls with a combination of acoustic grade rock wool and a high density granite impregnated foam, and if your budget extends also a artificial lead liner. I appreciate this is a Rolls Royce approach.
My theory is that the utilising of different materials for want of a different description 'confuses' sound waves as it seeks an exit strategy. I also add resilient tape on timber batten/joist even when fixing resilient bars.
A note on windows. We have in the past used special made curtains comprising high density wool <(often used in theatres) double layered and bubble wrap or foam in between the layers. We are currently refurbishing our own project a Victorian postal office built in 1890 with big windows and skylights. This is to be used as an event space so we need to soundproof to accommodate our neighbours. We are not only putting in acoustic curtains but triple secondary glass on these windows.
Another tip is window plugs. We owned a foam factory and would make acoustic plugs for windows covered in the wool fabric I mentioned, this not only helps with acoustics but cuts down on energy costs. You can lift them in and take them out, they just need to be oversized to squeeze in. I use them at home in the winter at night time (its dark outside anyway so does not hinder light). To do this on the cheap find some old foam mattresses (these often end up in landfill) cut the foam to fit with a sharp breadknife and cover them if you can. These methods are for dealing with sound insulation cutting down echo/flatter is a whole different ball game.
Finally the biggest challenge I always found was that of soundproof v ventilation. There is often a trade off here.
good luck to anyone reading this
T


Besides Roman numeral analysis and chord analysis what other analyses are there?

Question: Besides Roman numeral analysis and chord analysis, what other analyses are there? What are those called?
Roman numeral analysis does, for example, say very little about the melody or non-chord tones.
Answer: There are many...

Cadence identification is very important for analyzing form. This is not the same as harmonic analysis V I isn't a cadence... unless you analyze it as such, symbols like: PAC, HC, DC are used for perfect authentic cadence, half cadence, deceptive cadence, etc.
Non-chord tones, as you mention, can be analyzed: sus, app, pt, etc. for suspension, appoggiatura, passing tone, etc.
Melody can be analyzed with scale degree symbols like ^1, ^2, ^3 which mean tonic, supertonic, mediant of the scale, these are similar to solfege syllabals like DO, RE, MI which can be used for analysis too.
Fugue has its own terminology: subject, answer, counter-subject, stretto, exposition, episode, etc. used to analyze the design of fugues.
Motivic development is another place for analysis combining some melodic aspects like sequence, inversion, interval transformation with rhythmic aspects like repetition, augmentation, diminution, etc.
Comment: It may be useful to Anglicise those cadence terms. A lot of us on the right hand side of the pond haven't much idea of what those terms represent!
Answer: One can also use a figured bass treatment (preferably along with Roman Numeral analysis). This gives one an idea of the harmonic skeleton (or foundation) being used. For stuff (not that there's much) that I analyze for myself, I use Roman Numerals with figured bass figures and note various cadence points or other interesting happenings. (When playing I call V7/V a II7 but when analyzing,it's a V7/V or even V65/V7 then when playing I think II65. I suppose one could be consistent.)
I do try to mark secondary dominants, Neapolitans, Augmented Sixths, even when secondary during analysis. I tend to incorporated "resolved" ninth chords into the harmony and everything else gets shoved into the melody.
If the music consists of mostly independent lines (like Renaissance Counterpoint), one probably needs to write out the melodies separately.


When no model comparison, should I use REML vs ML?

Question: I'm running LMM, and I will make no comparison of models. Could I ask which one should I use between REML and ML?
Comment: maybe this hemps: https://stats.stackexchange.com/questions/99895/why-does-one-have-to-use-reml-instead-of-ml-for-choosing-among-nested-var-cova/171529#171529
Answer:
When there is no model comparison, the difference between restricted
(or residual) maximum likelihood (REML) and maximum likelihood (ML)
is that, REML can give you unbiased estimates of the variance
parameters. Recap that, ML estimates for variance has a term $1/n$, but the
unbiased estimate should be $1/(n-p)$, where $n$ is the sample size, $p$
is the number of mean parameters. So REML should be used when you are
interested in variance estimates and $n$ is not big enough as
compared to $p$.
When there is model comparison, notice that REML cannot be used to
compare mean models, since REML transformes the
data thus makes the likelihood incomparable.
Answer: The restricted maximum likelihood (REML, aka RML) procedure separates the estimation of fixed and random parameters (Raudenbush & Bryk, 2002;  Searle, Casella & McCulloch, 1992). Snijders and Bosker (2012) noted that when J-q-1 is equal or larger than 50 (J is the number of clusters and q is the number of level-2 predictors), the difference between ML and REML estimates are negligible. If J-q-1 is smaller than 50; ML estimates of the variance components are biased, generally downward (Hox, 2010).
Raudenbush and Bryk (2002) posit that ML estimates for level-2 variances and covariances will be smaller than REML by a factor of approximately (J-F)/J where F is the total number of regression coefficients. To my experience, this adjustment works satisfactorily.
However, when deviance tests are the choice to compare models with different fixed effects but the same variance components, the REML deviance should not be used because it is a deviance for the variance components only. Instead the ML deviance should be used (Snijders & Bosker, 2012). If the models differ in both the fixed effects and the variance components, neither deviance can be used to conduct tests on the fixed effects.
Comment: would you provide a reference to better understand the following: "However, when deviance tests are the choice to compare models with different fixed effects but the same variance components, the REML deviance should not be used because it is a deviance for the variance components only. Instead the ML deviance should be used (Snijders & Bosker, 2012). If the models differ in both the fixed effects and the variance components, neither deviance can be used to conduct tests on the fixed effects." I am facing exactly this problem, as JASP outputs Deviance, REML Deviance, and AIC, which is clearly


How to detect element with DOM JavaScript?

Question: I want to detect an element and change the backgroundColor through JavaScript but am having trouble with it.
I can't check for the element because it is a tag+class + tag+class...
Here's my code :
var one = document.getElementsByTagName("div");
var two = document.getElementsByClassName("red");
var three = document.getElementsByTagName("h2");
var four = document.getElementsByClassName("title");
one.two three.four.style.backgroundColor ="#00c497";

The format is "div.red h2.title".
How can I correctly detect an element using DOM JavaScript?
Answer: If you can, use querySelector for this:

document.querySelector("div.red h2.title").style.backgroundColor = "#00c497";

Don't Touch

Don't Touch

Change


aws codecommit - is there a way to get all files under a folder including its subfolders

Question: Suppose I have a CodeCommit repo on AWS like this:
repo
-folder1
--file1
--folder2
---file2
---folder3
----file3

aws codecommit get-folder --folder-path "folder1"

only returns "file1" and "folder2"
Is there a way to get "file1" and "folder2/file2" and "folder2/folder3/file3" WITHOUT recursively call "get-folder" on all subfolders?
Answer: There does not seem to be an SKD or CLI call to do it as of February 2023 but there is an indirect way to do it. Run the following command:
aws codecommit get-differences --repository-name YOUR_REPOSITORY_NAME --after-commit-specifier "HEAD"

It will return a list of differences between the repository's HEAD and the empty repository. In this way, it will contain the entire tree of your current repository. And if you map the returned result by differences.afterBlob.path you will get a clean list of your current repository structure.


How to prove $\text{var}(X_1X_2)\geq \text{var}(X_1)$ when $E(X_2|X_1)=1$

Question: How to prove that $\text{var}(X_1X_2)\geq \text{var}(X_1)$ when $E(X_2|X_1)=1$ ?
I just try $\text{var}(X_1X_2)=E(X_1^2X_2^2)-E(X_1X_2)^2$ and $\text{var}(X_1)=E(X_1^2)-E(X_1)^2$,
but then I do not know how to proceed.
Comment: Please add your attempts and approach to the question and not as a comment. Elaborate your attempts clearly so that the community might be able to steer away any confusion or so.
Comment: What have you tried and where are you stuck?
Comment: I split the variance into the form of expectation, but I don't know how to relate it to the previous conditional expectation
Answer: Using the law of total variance,
$$\operatorname{Var}(X_1X_2)
  =E\underbrace{\operatorname{Var}(X_1X_2|X_1)}_{\ge 0}+\operatorname{Var}E(X_1X_2|X_1)
 \ge\operatorname{Var}(X_1\underbrace{E(X_2|X_1)}_{=1})
=\operatorname{Var}X_1.
$$
Answer: First note by the law of iterative expectation and assumption $E(X_2|X_1) = 1$, we have
\begin{align}
E(X_1X_2) = E[E(X_1X_2|X_1)] = E[X_1E(X_2|X_1)] = E(X_1).
\end{align}
Therefore,
\begin{align}
& \operatorname{Var}(X_1X_2) = E[(X_1X_2 - E(X_1X_2))^2] = E[(X_1X_2 - E(X_1))^2] \\
=& E[(X_1X_2 - X_1 + X_1 - E(X_1))^2] \\
=& E[(X_1X_2 - X_1)^2] + 2E[(X_1X_2 - X_1)(X_1 - E(X_1))] + \operatorname{Var}(X_1).
\tag{1}
\end{align}
The inequality $\operatorname{Var}(X_1X_2) \geq \operatorname{Var}(X_1)$ thus holds if we can prove the middle term in $(1)$ is $0$.  Indeed, applying the law of iterative expectation and $E(X_2|X_1) = 1$ again yields
\begin{align}
& E[(X_1X_2 - X_1)(X_1 - E(X_1))] = E[E[(X_1X_2 - X_1)(X_1 - E(X_1))|X_1]] \\
=& E[(X_1 - E(X_1))E[X_1X_2 - X_1 | X_1]] \\
=& E[(X_1 - E(X_1))(E(X_1X_2|X_1) - X_1)] \\
=& E[(X_1 - E(X_1))(X_1 - X_1)] = 0.
\end{align}
This completes the proof.