What are next steps to release an EP or an album, once I will finish recording?

Question: I wanted to know, what are steps to do once I will record a DIY ep ?
Actualy, I started this project : recording songs, and make out of them a punk rock ep.
I do play all instruments, I record using my macbook (garageband is enough for me).
But what to do once I will finish recording? Do I need to call a label? What about copyrights? Do spotify (or any other tool) can help me with all these questions from A to Z ?
Comment: Huh, I thought the next steps would be figuring out which recording clips to use, then mastering, *then* distributing your works.
Comment: https://artists.spotify.com/en/providers
Comment: @Tetsujin Even in the old days, getting a record deal didn't necessarily have anything to do with talent.
Comment: There are plenty of companies these days who will take your dollar & push whatever you like to the streaming services & iTunes etc. No barrier to entry like the old days of trying to get a record deal. Literally no talent required any more, just money.
Comment: @PiedPiper - true, though I know several people whose job it was to aggressively filter the total no-hopers, before taking the rest to A&R meetings ;))
Comment: If you are recording any non-original songs you will have to go to an agency like the Harry Fox Agency to pay royalties to the original composer and publisher based on what your usage of their material will be.
Answer: Nobody is going to help you "from A to Z" for free.  The streaming services (like Spotify) do have services for artists if you seek them out and pay.
Definitely, do register copyrights as soon as the recordings are completed.  If you're in the US, the hardest part is understanding the arcane interface of the Copyright Office website.  Then, you pay your fee and upload your audio.
You don't need to call (or email, text, etc.) a label.  You can try, but I wouldn't wait for a label's help to proceed.
As long as you can get your audio to meet the technical and quality standards of the streaming services, you can do the rest yourself, but it will still cost some money.
You could simply post the tracks to Bandcamp, and they will be "out there", but the only people aware of their existence will be the ones you tell and the only way for people to hear them is on the Bandcamp website or app, or as a download.
You could also use a digital distribution service to get the tracks onto the major streaming and download platforms.  Some of them have affiliations with mastering houses (whose services I suspect you can benefit from if you can afford them).  FWIW, I have used CDBaby for more than 20 years. They used to be the only one doing what they do, but there are many more choices now.  You will pay a flat rate to get it distributed and you will collect a substantial share of the proceeds, but keep in mind the proceeds from streaming are vanishingly small.
Some additional notes:
You will probably need album cover artwork.  Read the technical and content requirements of streaming services before you expend effort creating it.
The digital distribution services will help you collect royalties (small as they are) from radio, satellite radio, YouTube, etc.
In a home studio you are probably unable to accurately assess the sound overall.  It may sound good to you there, but in other acoustic environments it may not.  One of the benefits of mastering is the controlled listening environment of the mastering studio.
Without knowing you or your music I can't say for sure, but I suspect you would also benefit greatly from critical listening by someone knowledgeable and trustworthy, yet independent of the project.  There is always something that can be improved, and better to do it now when it's only your labor at stake.
Even once your recordings are on the streaming services, it's still incredibly difficult to get anyone to find them, unless you already have some following, e.g., from live performances.  (I suspect you don't have this if you're doing everything yourself.)
Answer: First thing first (1) If you got your mix finished and you have your stereo or 2 track mix, get it Mastered. While that's being done get your album art together and song titles and credits written up like you want them to appear on the Album. Sign up with a PRO (Performance Rights Organization) example; BMI, ASCAP are your two most used in the United States. Register all the songs, they collect songwriter and publishing royalties for you. You will earn royalties even if you're not registered with the USCO. Then go online to the United States Copyright Office https://www.copyright.gov and copyright your work. Then go online and look up distributors such as CD Baby and TuneCore, decide on the one that you think will work best for you. Then they will walk you through the rest. Be sure to have all songs in order accord to how they are listed on the credits and each song must be on a separate .wav file, Album art must be HD quality I set my jpg. or png. resize to 3000 x 3000 pixels. You will need those two things to upload to complete your release.


Page Arguments Not Getting Passed

Question: My code was working perfectly, but at some point my hook_menu page arguments stopped getting passed.
I am using versioning and can revert back to the previous code, but the page arguments are still broken.
Is there some change that could be causing page arguments to not get passed?
Thanks a million!
Disclaimer:  Sorry, I am not a Drupal developer, so the code is an attempt at injecting plain php into a site.
Inventory.module
    function inventory_menu() {
  $items = array();

  $items['admin/commerce/inventory'] = array(
    'title' => 'Inventory',
    'description' => 'View inventory reports for your store.',
    'access arguments' => array('access commerce reports'), // Inherited by children.
    'page callback' => 'inventory_reports_dashboard',
    'page arguments' => array( '10', 'DESC', 'false', 'firstname.lastname@example.com', 'false'),     // page_arguments = threshold amount,  sort direction, hide zero inventory, email report to, save_to_email bool, download_csv
    'file' => 'inventory.dashboard.inc',
    'weight' => 0,
  );

  $items['admin/commerce/inventory-download-csv'] = array(
    'page callback' => 'inventory_download_csv',
    'access arguments' => array('access commerce reports'),
    'file' => 'inventory.dashboard.inc',
    //'type' => MENU_CALLBACK,
  );

  return $items;
}

Inventory.dashboard.inc
/**
 * Renders the inventory reports.
 */
function inventory_reports_dashboard( $threshold='10', $sort_direction='DESC', $hide_zero_inventory='false', $email@example.com', $save_to_email = 'false') {
  drupal_add_js(drupal_get_path('module', 'commerce_reports') . '/theme/js/dashboard.js', 'file');
  drupal_add_css(drupal_get_path('module', 'commerce_reports') . '/theme/css/commerce_reports_dashboard.css');

  // on first load we want to grab all of the default values
  // after first load, we want updated values to pass through
  //$threshold = 18;
  $render = file_get_contents('http://' . $_SERVER['HTTP_HOST'] . "/sites/all/modules/inventory/inventory.php?threshold=$threshold&sort_direction=$sort_direction&hide_zero_inventory=$hide_zero_inventory&email=$email&save_to_email=$save_to_email");

  return $render;
}

function inventory_download_csv(){
  $file = './inventory.csv';
  $filename = 'inventory.csv';
  //drupal_set_header('Content-Type: text/csv');
  //drupal_set_header('Content-Disposition: attachment; filename=' . $filename);
  drupal_add_http_header('Content-Type: text/csv');
  drupal_add_http_header('Content-Disposition: attachment; filename=' . $filename);
  if($file) {
    //file_transfer($file, array('Content-disposition', 'attachment; filename='.$filename));
    $csv_contents = file_get_contents('http://' . $_SERVER['HTTP_HOST'] . "/sites/all/modules/inventory/inventory.csv");
  }
  else {
    return drupal_access_denied();
  }
  $fp = fopen('php://output', 'w');
  //$csv_text = array2csv($db_result);
  fputs($fp, $csv_contents);
  fclose($fp);
  exit();

}

Inventory.php
<?php

define('DRUPAL_ROOT', $_SERVER['DOCUMENT_ROOT']);

require_once DRUPAL_ROOT . '/sites/all/modules/myfunctionlib/myfunctionlib.module';
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';

//require_once DRUPAL_ROOT . '/includes/common.inc';
//require_once DRUPAL_ROOT . '/includes/module.inc';
//require_once DRUPAL_ROOT . '/includes/unicode.inc';
//require_once DRUPAL_ROOT . '/includes/file.inc';

//drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
drupal_bootstrap(DRUPAL_BOOTSTRAP_DATABASE);
clean_dump($_GET);

When I change the url:
firstname.lastname@example.com
The get parameters no longer reflect changes
array(6) {
  ["threshold"]=>
  string(2) "10"
  ["sort_direction"]=>
  string(4) "DESC"
  ["hide_zero_inventory"]=>
  string(5) "false"
  ["email"]=>
  string(16) "email@example.com"
  ["save_to_email"]=>
  string(5) "false"
  ["q"]=>
  string(0) ""
}

Comment: I made a mistake. You already have three fragments in your url. It must be :  'page arguments' => array( 3, 4, 5, 6, 7),     and you should define your menu as  $items['admin/commerce/inventory/%/%/%/%/%']
Comment: Can you post some of your code so we can see what's going on?
Comment: Try passing your arguments like this: 'page arguments' => array( 0, 1, 2, 3, 4),
Comment: @Jance Yes, I add or remove a module to clear the cache.  But, I meant I just changed one of the url segments in the browser.
Comment: Nice suggestion J Reynolds. Are those not the defaults?  'page arguments' => array( '10', 'DESC', 'false', 'firstname.lastname@example.com', 'false')

What do these numbers represent?  'page arguments' => array( 0, 1, 2, 3, 4),
Comment: @Bryan I don't think `page arguments` is doing something here, you can simple remove it, your callback function's args will work.. Dont forget to clear the cache.
Comment: @J.Reynold That sounds correct.  I didn't realize that they were the url segments.   I don't think I should change my definition. I define my menu with % placeholders, those segments are no longer optional, right?
Comment: No they are not. In that case just leave 'page arguments' out of the menu definition and pick up the arguments in your callback.
Comment: I could, but just changing to 'page arguments' => array( 3, 4, 5, 6, 7) works perfectly!  Thanks so much!!!
Answer: I would change your code to (as @J.Reynolds specified):
  $items['admin/commerce/inventory/%/%/%/%'] = array(
    'title' => 'Inventory',
    'description' => 'View inventory reports for your store.',
    'access arguments' => array('access commerce reports'), // Inherited by children.
    'page callback' => 'inventory_reports_dashboard',
    'page arguments' => array(3,4,5,6),     // page_arguments = threshold amount,  sort direction, hide zero inventory, email report to, save_to_email bool, download_csv
    'file' => 'inventory.dashboard.inc',
    'weight' => 0,
  );

Comment: The admin/commerce/inventory/%/%/%/% placeholder % don't seem necessary.  Mode code will provide default values.  Or maybe not.  But I'd like admin/commerce/inventory/ to use defaults.

Page Arguments Not Getting Passed


Regarding perfect squares

Question: Is there any positive integer $n > 2$ such that $(n - 1)(5n - 1)$ is a perfect square? It is observed that $(n - 1)(5n - 1)$ is of the form $4k$ or $4k+ 1$.
Affirmative answers were given by Pspl and Mindlack (by providing some examples).
Now my question is the following:
Is there any characterization of positive integer $n$ such that $(n - 1)(5n - 1)$ is a perfect square?
Comment: Take $n=65$, $5n-1=18^2$ and $n-1=8^2$. More generally, let $a_k\sqrt{5}+b_k=2(9+4\sqrt{5})^k$, then $n=a_k^2+1$ works, because $5n=b_k^2+1$, since $b_k^2-5a_k^2=4(9^2-5\cdot 4^2)^k=4$.
Comment: For $n=2$ there is...
Comment: "Affirmative answers were given by Pspl and Mindlack" - Could you please provide a link?
Comment: Sorry, I want to write $n>2$.
Comment: Ok... For $n=10$ there is...
Comment: Thanks, I did not check for 10. Is there any characterization of such numbers?
Answer: The following are solutions: $n= 10, 65, 442, 3026, 20737, 142130, 974170.$.
Comment: Thank you very much for your answer. Now, let me edit my question once again.
Answer: As $(n-1)(5n-1)=m^2$ for some $m\in\mathbb{N}$, then
$$\begin{split}(3n-1)^2-(2n)^2&=m^2\\m^2+(2n)^2&=(3n-1)^2\end{split}$$
By the formula for Pythagorean Triple, we can use it.
Let $m=x^2-y^2, 2n=2xy, 3n-1=x^2+y^2$ and assume $x>y>0$. Then
$$\begin{cases}
(x + y)^2 =5n-1 \\
(x-y)^2 = n-1
\end{cases}$$
By the assumption, $x+y,x-y>0$. So $x=\frac{\sqrt{5n-1}+\sqrt{n-1}}{2},y=\frac{\sqrt{5n-1}-\sqrt{n-1}}{2}$.
$\because x,y\in\mathbb{N}$
$\therefore n-1,5n-1$ must be perfect squares in order to have $(n-1)(5n-1)$ be a perfect square.
Comment: Are their infinitely many positive integers having that property?
Answer: If $m^2=(n-1)(5n-1)$, then $5m^2=5(n-1)(5n-1)=(5n-3)^2-4$.
Write this as $x^2-5y^2=4$, for $x=5n-3$ and $y=m$.
Write this as $N\left(\frac{x+y\sqrt5}{2}\right)=1$. Then $\frac{x+y\sqrt5}{2}=\left(\frac{1+\sqrt5}{2}\right)^{2k}$, since $\frac{1+\sqrt5}{2}$ is a fundamental unit of norm $-1$.
Thus, $\frac{x+y\sqrt5}{2}=\left(\frac{3+\sqrt5}{2}\right)^{k}$. We just need to find those $x$ such that $x \equiv -3 \equiv 2 \bmod 5$.
Write $\frac{x_k+y_k\sqrt5}{2}=\left(\frac{3+\sqrt5}{2}\right)^{k}$. Then $x_{k+1}=\frac{3x_k+5y_k}{2}$ and $y_{k+1}=\frac{x_k+3y_k}{2}$, with $x_0=2, y_0=0$.
Then, $x_{k+2}=\frac{7x_k+15y_k}{2}$ and $y_{k+2}=\frac{3x_k+7y_k}{2}$. This gives $x_{k+2} \equiv x_k \bmod 5$. Thus $x_{2k} \equiv 2 \bmod 5$, since $x_0 = 2$.
Thus, the solutions of $m^2=(n-1)(5n-1)$ are exactly $n=\frac{x_{2k}+3}{5}$ and $m=y_{2k}$.
Equivalently, $n_k=\frac{u_{k}+3}{5}$ and $m=v_{k}$, where $\frac{u_k+v_k\sqrt5}{2}=\left(\frac{1+\sqrt5}{2}\right)^{4k}=\left(\frac{7+3\sqrt5}{2}\right)^{k}$, which gives $u_{k+1}=\frac{7u_k+15v_k}{2}$ and $v_{k+1}=\frac{3u_k+7v_k}{2}$, with $u_0=2, v_0=0$.

Regarding perfect squares


$_FILES retornando vazio

Question: Esse é o formulário que estou usando para enviar o arquivo
<form id="form_converter" enctype="multipart/form-data">
    <input type="file" name="arquivo" />
    <input type="submit" value="Enviar" />
</form>

$(document).on("submit", "#form_converter", function(){
    var dados  = $('#form_converter').serialize();
    jQuery.ajax({
        type: "POST",
        url: "sys/cv_unique_file.php",
        data: dados,
        success: function(data)
        {
            console.log(data);
        }
    });
    return false;
});

E no meu PHP
if(isset($_FILES)){
    print_r($_FILES);
}

E apenas recebo um array vazio Array (), já cheque a permissão das pastas e ta tudo 777
Comment: Relacionada: [Fazer upload de arquivo com AJAX](http://pt.stackoverflow.com/questions/9704/fazer-upload-de-arquivo-com-ajax)
Comment: Ralacionada: [Upload de imagem com Jquery](http://pt.stackoverflow.com/questions/130422/upload-de-imagem-com-jquery)
Comment: Relacionada: [upload sem refresh com FormData, jquery](http://pt.stackoverflow.com/questions/43405/upload-sem-refresh-com-formdata-jquery)
Comment: Leo, a um tempo atrás eu fiz [assim](http://pt.stackoverflow.com/questions/32537/fileupload-sem-refresh-na-p%C3%A1gina), está em C# a parte do back-end. Na época eu precisei incluir o arquivo em `FormData`. Acho que com o exemplo você pode ajustar seu back-end. Espero que ajude :)
Answer: a função serialize() não inclui campos do tipo file na "string query" gerada, suponhamos que em seu formulário você tivesse 2 campos do tipo text, deste modo o serialize() geraria uma string parecida com esta.
<form action="">
   <input type="text" name="nome">
   <input type="text" name="telefone">
   <input type="file" name="arquivo">
   <input type="submit" value="Enviar">
</form>

$('form').on('submit', function(event) {
   event.preventDefault();

   console.log($(this).serialize());
});

// Resultado do console.log: nome=aew&telefone=aew

Essa string gerada pelo serialize() é que sera enviada através do ajax.
Para enviar arquivos utilizando ajax você precisa usar a classe FormData, desta maneira:
$('form').on('submit', function(event) {
   event.preventDefault();

   var formData = new FormData(this);

   $.ajax({
     type: "POST",
     url: "sys/cv_unique_file.php",
     data: formData,
     success: function(data) {
        console.log(data);
     }
   });
});

Comment: Não sabia disso sobre o serialize(), mas sua função está retornando o seguinte erro: Uncaught TypeError: Illegal invocation

$_FILES retornando vazio


Why I'm not able to debug twig templates? sites/default/files/php directory is empty

Question: As in question. I'm following this tutorial: https://dev.acquia.com/blog/debugging-drupal-8/debugging-twig-templates-in-drupal-8-with-phpstorm-and-xdebug/25/08/2016/16586
but directory

sites/default/files/php/twig

is always empty
I'v tried cr all, checked file system page, did drush cron, checked theme page - no errors.
I got some errors related to permissions at theme settings page, but:

chmod 777 -R sites/default/files

seems to solved those.
Any advices?
Answer: Probably the directory sites/default/files/php/twig is empty because the container parameter twig.config.cache is set to false.
The approach used in the linked article is arguable.. put a breakpoint in every twig compiled template is not a viable solution. For debugging twig templates with xdebug there are better alternatives:

use the devel module + this patch (Committed)
use the twig_xdebug module


VS Code Remote Development giving back error

Question: I'm trying to connect my Vs code using SSH extension to my Debian VM on azure.
I tried running the SSH connection on terminal and it's working fine
ssh -i Desktop/Emdad/testing/magento-testing-key.pem email@example.com
But when I tried doing it on VS code, I get this error:
`

C:\Users\Dell PC\Desktop\testing\magento-testing-key.pem: terminating, 39 bad configuration options                                                            [22:07:26.089] > The process tried to write to a nonexistent pipe.
[22:07:27.366] "install" terminal command done
[22:07:27.368] Install terminal quit with output: g, 39 bad configuration options
[22:07:27.368] Received install output: g, 39 bad configuration options
[22:07:27.371] Failed to parse remote port from server output
[22:07:27.374] Resolver error: Error:at m.Create (c:\Users\Dell PC.vscode\extensions\ms-vscode-remote.remote-ssh-0.100.0\out\extension.js:1:584145)
at t.handleInstallOutput (c:\Users\Dell PC.vscode\extensions\ms-vscode-remote.remote-ssh-0.100.0\out\extension.js:1:582705)
at t.tryInstall (c:\Users\Dell PC.vscode\extensions\ms-vscode-remote.remote-ssh-0.100.0\out\extension.js:1:681555)
at async c:\Users\Dell PC.vscode\extensions\ms-vscode-remote.remote-ssh-0.100.0\out\extension.js:1:643798
at async t.withShowDetailsEvent (c:\Users\Dell PC.vscode\extensions\ms-vscode-remote.remote-ssh-0.100.0\out\extension.js:1:647116)
at async t.resolve (c:\Users\Dell PC.vscode\extensions\ms-vscode-remote.remote-ssh-0.100.0\out\extension.js:1:644848)
at async c:\Users\Dell PC.vscode\extensions\ms-vscode-remote.remote-ssh-0.100.0\out\extension.js:1:720590
[22:07:27.393] ------`

I tried modifying the ssh_config file on my remote and add :
#   PermitRootLogin yes
on the 55 line, but didn't work, and I know the source of this issue is from the remote VM since I tried this process on couple machines. but same error.
Answer: I experienced a similar error and managed to get it working again by installing a previous version of Visual Studio Code. All of my extensions and settings remained in place.
Also, you'll need to disable auto updating by going to Settings->'Update'->none
https://code.visualstudio.com/updates/


Velocity Obstacles -- Probabilistic Collision Cone concept

Question: I have been working with the Velocity Obstacles concept. Recently, I came across a probabilistic extension of this and couldn't understand the inner workings.
Source: Recursive Probabilistic Velocity Obstacles for Reflective Navigation http://www.morpha.de/download/publications/FAW_ASER03_Kluge.pdf

What does the equation at the bottom and the top mean? Vij is the relative velocity of agent i to agent j. ri & ci and rj & cj are their respective radius and centers.
Update: (based on Dale M's answer)
What does inf(ri + rj) and sup(ri + rj) mean? Does it mean that I should define a function that goes from 1 to 0 from inf to sup? And if not, then how do I calculate the value of PCC at any given point?
Answer: The statement (not an equation):
$$PCC_{i,j}:\mathbb{R}^2\to [0,1]$$
means that $PCC_{i,j}$ is a function from the 2 dimensional plane (the floor presumably) to the closed interval $[0,1]$ representing the probability of a collision from no chance $0$ to certainty $1$.
The equation states that the probability of a collision is the same as the probability that the sum of the radii of the objects $r_i$ and $r_j$ is greater than the minimum of the initial distance between the centres $c_i-c_j$ plus the future (relative) position of their centres $\mu v_{ij}$ over all future time $/mu$. That is, if the size of the bodies is bigger than the distance between them in the future then they will be coincident in space-time - i.e. they crash.
Comment: Thank you, that helps a lot. I guess the "min" threw me off because ci - cj + uVij will only have *one* value at given time instant. So I was wondering why the min.

Follow up question: What does inf(ri + rj) and sup(ri + rj) mean? Does it mean that I should define a function that goes from 1 to 0 from inf to sup? And if not, then how do I calculate the value of PCC at any given point?
Comment: http://en.wikipedia.org/wiki/Infimum_and_supremum - in this context  it is the least and greatest possible value of the sum of the 2 radii.


mongodb query for or operator

Question: As in ravendb Or operation are not available we have a query in ravendb. iwant the expression to be written in mongodb query using Query.Or
  var customerIdExpression = string.Format("CustomerId:({0})", string.Join(" OR "item.CustomerId));

Comment: I don't think I fully understand your question. Do you want to use a logical or in the query expression? or do you want to contains type query. Please provide a little more information for clarity
Comment: i want the query where Query.Or is used.
Comment: somehting like: `var or = []; for(i in items){ var or[or.length-1]={CustomerId: items[i].CustomerId}; } db.col.find({$or: or});` is what your asking for aint it?
Answer: I knocked together a test app that is my interpretation of what you are looking for:
var item = new {CustomerId = "123"};
var item2 = new { CustomerId = "123" };
var query1 = new QueryDocument("CustomerId", item.CustomerId);
var query2 = new QueryDocument("CustomerId", item2.CustomerId);
var logicalOrBetweenSubQueries = Query.Or(query1,query2);

If this is what your looking for I can't but think there might be a better way to achieve set membership semantics. Something like this might be useful:
var membership = Query.In("CustomerId", new[] { BsonValue.Create(item.CustomerId), BsonValue.Create(item2.CustomerId)});

All predicated on my understanding of your problem.
Hope this helps
p.s. some links
http://docs.mongodb.org/manual/reference/operator/or/
http://docs.mongodb.org/manual/reference/operator/in/

mongodb query for or operator


What are "names which are not lvalues"?

Question: There's an entry in the errata of Effective Modern C++ which says that

not all names are lvalues

What are these names? Specifically,

is Scott just referring to the nullptr and this named prvalues?
Are there any others?
In case the answer to 1 is yes, then what makes nullptr special with respect to true and false? They are all values of some type (true/false of type bool, nullptr of type std::nullptr_t). After all true stays to bool just like 1 stays to int, and 1 is not a "name which is not an lvalue", is it? At this point I'd ask why is true not a name then?
Comment: E.g. an enumerator - `X` declared as `enum E { X };`
Comment: Back in the olden days, "lvalue" meant a name that could appear on the left-hand side of an assignment (and, similarly, an "rvalue" could only appear on the right-hand side). So, basically, any name that you can't assign a value to is not an lvalue. (note the word **assign**, which is not the same as **initialize**; `const int x = 5;` initializes `x`, but `x` is not an lvalue, because you cannot write `x = 3;`).
Comment: @PeteBecker isn't that only a _non-modifiable lvalue_?
Comment: @Enrico -- as I said, that was back in the olden days. There was no notion of a non-modifiable lvalue, since an lvalue by definition could appear on the left-hand side of an assignment, i.e., it was modifiable.
Answer: An expression X where X is the name of an enumerator (declared e.g. as enum E { X };) has rvalue value category.

Similarly for non-type template parameters (hat tip to @PasserBy), as in
template <int X>
int f() { return X; /* X is an rvalue */}

Comment: @PasserBy Most of these can't be used as expressions (being an lvalue is a property of an expression, so "a name is an lvalue" can only be understood as "an *id-expression* that consists of this name is an lvalue"), but I grant you non-type template parameters. Answer modified accordingly.
Comment: And template parameters, template themselves, labels, namespaces and packs. Not sure about bit fields.
Comment: @IgorTandetnik, would you comment on the points in my question? For instance, it's not obvious to me if `true`, which is an rvalue, is indeed a _name_.
Comment: `true` is not a name (it's not introduced by a declaration). It's a keyword, denoting a literal.
Comment: @IgorTandetnik, so also `nullptr` and `this` are not names but keywords?
Comment: Correct. `nullptr` is also a literal (of type `nullptr_t`). `this` is a kind of expression.

What are "names which are not lvalues"?


prove $F[x]/g(x)$ is not an integral domain

Question: If $g(x)$ is reducible in $F[x]$ then $F[x]/g(x)$ is not an integral domain.
I know that an integral domain must have no zero divisors but Im I little confused on how this works with polynomials. So far Im thinking: If $g(x)$ is reducible then
$$g(x)=f(x)h(x)$$
for some $f, g \in F[x]$. I can't see how this leads $F[x]/g(x)$ having a $a(x),b(x)$ such that $a(x)b(x)=0$
I've seen some other answers that use this notation: $\langle g(x)\rangle$ but Im not too sure what that means. I think maybe the congruence class of $g(x)$?
Comment: @rschwieb yes sorry that was a mistake. For a couple minutes I thought $F[x]/g(x)$ meant, the set of all polynomials minus $g(x)$ but it definitely does not mean this. I will delete the question shortly. Very sorry.
Comment: $\langle g(x)\rangle$ means the ideal generated by $g(x)$, also written $(g(x))$.
Answer: Reduce modulo $\;\langle g(x)\rangle\;$ :
$$(f+\langle g\rangle)+(h+\langle g\rangle):=fh+\langle g\rangle=g+\langle g\rangle =\overline 0$$
All you need now is to convince yourself that $\;f+\langle g\rangle\,,\,\,h+\langle g\rangle\neq\overline 0\;$


Servlet - which is more efficient when providing a downloadable file?

Question: I am currently writing a dropbox sort of servlet and am at the stage that I can provide downloadable files and I was wondering which if there is a difference in efficience between these following two methods.
This is the method I am using at the moment to provide a download, I am using a FileInputStream to write the file that is getting downloaded:
            PrintWriter out = response.getWriter();
            response.setContentType("APPLICATION/OCTET-STREAM");
            response.setHeader("Content-Disposition","attachment; filename=\"" + "/" + fileName + "\"");
            FileInputStream fileInputStream = new FileInputStream(filePath[1]);
            int i;
            while ((i=fileInputStream.read()) != -1)
            {
                out.write(i);
            }
            fileInputStream.close();
            out.close();

But after doing some research I found out that the majority of people uses a byte kind of approach instead:
OutputStream out = response.getOutputStream();
FileInputStream in = new FileInputStream(my_file);
byte[] buffer = new byte[4096];
int length;
while ((length = in.read(buffer)) > 0){
    out.write(buffer, 0, length);
}
in.close();
out.flush();

Is my approach inferior in any way? or is the above method just more popular because it is less code?
Answer: PrintWriter is optimized to work with CharSequence:

Prints formatted representations of objects to a text-output stream.
Abstract class for writing to character streams. (from Writer documentation)

In you code you read from the file byte by byte and you copy that byte on the PrintWriter. It will be more efficient to read line by line and write a complete line to the PrintWriter.

Using directly the OutputStream you read and write chunk of 4096 bytes. This is more efficient in terms of cpu because you make less while loops.
In any case the difference is very limited because here the speed is not related to the cpu, but to the speed of the network. If you try to test the speed of both methods you will see that there is no measurable difference and that they can be strongly influenced from the network traffic.
Additionally the PrintWriter should be used only with text files, instead the OutputStream solution is not dependent from the type of file.
Answer: You can use org.apache.commons.io.IOUtils for this task
        try {
             // getting output and input streams
             // Setting response headers.
               out.write(IOUtils.toByteArray(inputStream));
               out.flush();
        } catch(Exception e) {//or you can handle the appropriate Exception.
        } finally {
               IOUtils.closeQuietly(inputStream);
        }

Comment: What if you're trying to send a 10GB file?  How well will that work with a 64MB JVM?
Comment: @stdunbar It will throw OOM . My code is just an example of the better way of copying stream to the response.  If it's 10GB file , you will get OOM anyway if you use 64MB JVM , unless you send the file in chunks.  I would rather prefer some other way , like cloud storage and file sharing services make sending large files easier than ever, and an often be much faster and more reliable.


Installing Nginx "Headers More" module with YUM

Question: I would really like to avoid the custom patching/compiling stuff as upgrades are a nightmare. On Nginx, which I've installed using yum install nginx18, I'd also like to enable the popular module: https://www.nginx.com/resources/wiki/modules/headers_more/
However, it's hard to find any instructions on how to enable the module in a yum-friendly way. Could someone please direct me to instructions, or mention the command? Thank you.
Comment: Very good question ! With Dedian Ubuntu you can apt-get install nginx-extras but I've got idea on how to do that with Centos.
Answer: Sorry to give a not-answer, but I don't think there is a yum-friendly way to install headers_more (but it would be great if I were wrong on this!), unless you want to go through the effort of creating the nginx+headers_more RPM yourself (and someone has worked on this apparently: https://github.com/feedforce/nginx-headers-more-rpm), but you need to maintain it then, and you would be repeating the steps of patching and upgrading anyway.
On the other hand, building nginx from source is incredibly easy, as is patching it, and can be easily automated from a script, too. Nginx even allows for binary upgrading on the fly, so you can upgrade without downtime. Checking configuration arguments is easy too, so you don't even need to keep track of them for the next upgrade, just use nginx -V to see them.
Comment: Building from source may be easy on a development machine, but it's not easy to do it from a base AMI on AWS with Chef or Puppet when the production system needs to start up quickly and is not allowed to contain gcc or make. Really kind of stinks this is not in epel or remi.
Comment: Thank you @suitablyawesome. That is a non-answer :) Sadly the truth is that CentOS land has no easy Yum way of doing this, the way Debian/Ubuntu communities have.
Answer:
Download the latest webtatic-release rpm from
http://repo.webtatic.com/yum/el7/x86_64/.
Install webtatic-release rpm:
# rpm -Uvh webtatic-release*rpm

Install nginx1w rpm package:
# yum --enablerepo=webtatic install nginx1w

Module Headers
# yum --enablerepo=webtatic install nginx1w-module-headers-more

Answer: try to convert the debian package with alien


Session "NT Kernel Logger" failed to start

Question: I have encountered an error on windows server 2012 recently.
<code>Session "NT Kernel Logger" failed to start with the following error: 0xc0000022
</code>
More Details:
LogName: Microsoft-Windows-Kernel-EventTracing/Admin
Event ID: 2
Level: error
OpCode: start

What causes this error?
Is this an important error or I can ignore it?
Answer: If you look into the Event properties details, you will find the associated ProcessID and ThreadID:

If the event is relatively current, the Process ID  should still be registered by the offending process. Open task manager and go to processes tab and list processes by PID.
Now you can find out which process causes this event.
for more info please refer to this link


cannot resolve nativescript ui component

Question: tns --version: 4.1.0
tns creat demo --ng
update package.json for nativescript-webpack
<code>{
      "description": "NativeScript Application",
      "license": "SEE LICENSE IN <your-license-filename>",
      "readme": "NativeScript Application",
      "repository": "<fill-your-repository-here>",
      "nativescript": {
        "id": "org.nativescript.test",
        "tns-android": {
          "version": "4.1.3"
        }
      },
      "dependencies": {
        "@angular/animations": "~6.0.6",
        "@angular/common": "~6.0.6",
        "@angular/compiler": "~6.0.6",
        "@angular/core": "~6.0.6",
        "@angular/forms": "~6.0.6",
        "@angular/http": "~6.0.6",
        "@angular/platform-browser": "~6.0.6",
        "@angular/platform-browser-dynamic": "~6.0.6",
        "@angular/router": "~6.0.6",
        "nativescript-angular": "~6.0.0",
        "nativescript-theme-core": "~1.0.4",
        "reflect-metadata": "~0.1.8",
        "rxjs": "~6.0.0 || >=6.1.0",
        "tns-core-modules": "~4.1.0",
        "zone.js": "^0.8.26"
      },
      "devDependencies": {
        "@angular-devkit/build-angular": "~0.7.0-rc.0",
        "@angular/compiler-cli": "~6.1.0-beta.1",
        "@ngtools/webpack": "^6.0.8",
        "babel-traverse": "6.4.5",
        "babel-types": "6.4.5",
        "babylon": "6.4.5",
        "clean-webpack-plugin": "~0.1.19",
        "copy-webpack-plugin": "~4.5.2",
        "lazy": "1.0.11",
        "nativescript-dev-typescript": "~0.7.0",
        "nativescript-dev-webpack": "^0.14.2",
        "tns-platform-declarations": "^4.1.0",
        "typescript": "~2.7.2",
        "webpack-bundle-analyzer": "^2.13.1"
      }
    }
</code>
./node_modules/.bin/update-ns-webpack --configs
tns build android --bundle
a lot of errors occur, as follows:
ERROR in ../node_modules/tns-core-modules/bundle-entry-points.js
Module not found: Error: Can't resolve 'ui/button'
Answer: "nativescript-dev-webpack" at 0.14.1 works fine.


BeautifulSoup - don't crawl tag if in certain div class

Question: I need to crawl plain text from around ~2000 websites which don't have a common page structure and probably makes it hard to crawl with one script, I think.
So as a 'first time crawler' I did a couple of try and errors with BeautifulSoup. Currently I managed to crawl some plain text by looking at the content between certain tags (<p> and all the heading tags) with the following:
<code>soup.findAll(['p', re.compile('h[0-9]'), 'title'])
</code>
However, sometimes there's some rss/news-feed from which I don't want to have the text. From what I saw in the source code of the pages, it is surrounded by a css div-class. So my question would be if I can tell the above command not to crawl the text if it's surrounded by a certain div-class.
Answer: You can use a function as a filter:
<code>`def my_filter(tag):
return (tag.name == 'p' or re.compile('h[0-9]').match(tag.name) or tag.name== 'title') and (tag.parent['class'] != 'certain_div_class' or not tag.parent.has_attr('class'))

my_tags = soup.findAll(my_filter)`
</code>
Comment: Unfortunately, this code is not working for some reason. If I copy&paste it, it's not working at all because of this part:

`(tag.parent['class'] != 'certain_div_class' or not tag.parent.has_attr('class')`

But still, when I remove this part, I don't get the output that I want and that I got with my code from above. I think your code is not filtering out the text surrounded by the heading tags. This maybe needs another approach then? Not sure...
Comment: I've missed the closing bracket in that long expression, sorry for that. Edited the code now. And don't forget to change 'certain_div_class' to the proper class name.
Comment: No problem about the bracket but that's what I already took account for when trying it out. And I also filled out the desired class. The actual problem is rather the regex-expression which doesn't work with you approach. When I hard-type the heading tags, i.e. 'h1' then I get the output with the my previous output. Do you might have any idea how I could make that work in a nice way without typing 'h1' or 'h2' and so on...?
Comment: Yep, right, we both used `re` in a wrong way. There should be `re.compile('h[0-9]').match(tag.name)` instead of `tag.name == re.compile(...)` I also would make it `^h[0-9]{1}` as a precise regex.


How to set timezone inside alpine base docker image?

Question: I want to set time zone in my docker container. I follow this article but can't find working solution for alpine base image.
Could you please guide me?
https://dev.to/0xbf/set-timezone-in-your-docker-image-d22
Answer: You need to install the tzdata package and then set the enviroment variable TZ to a timezone. (List with all the timezones)
FROM alpine:latest
RUN apk add --no-cache tzdata
ENV TZ=Europe/Copenhagen

Output
$ docker run --rm alpine date
Tue Aug 31 09:52:08 UTC 2021

$ docker run --rm myimage date
Tue Aug 31 11:52:13 CEST 2021

Comment: note that you can save some image size by: `RUN apk add --no-cache tzdata`
Comment: @henrikstroem Try it on the base Alpine image. It needs tzdata. The images you've tried must have it installed already. I checked nginx:alpine and it has tzdata installed.
Comment: Thx so much, this problem was killing me today!
Comment: I found that simply setting an `env_file` on `docker-compose` containing `TZ=Europe/Copenhagen` did the job. No need to install `tzdata`, at least on Python and nginx Alpine based images.
Answer: This is my Dockerfile and it works:
FROM alpine:latest

# Essentials
RUN apk add -U tzdata
ENV TZ=America/Santiago
RUN cp /usr/share/zoneinfo/America/Santiago /etc/localtime

you have to replace 'America/Santiago' with your timezone
Comment: Is there a reason to create /etc/localtime? It works fine with `tzdata`and `ENV TZ=`
Comment: Hi @JesperGrannLaursen , thank you for your question. The simple answer is that it is necessary for some applications to accurately display the correct time in the specified time zone. However, as you say, it's not necessary one hundred percent. That depends on what you're doing exactly. I added that line because it works with my specific configuration in my project, but you can remove it if you want.


How to aggregate two json data with doing maths

Question: I have two json file one which have contain all team name and code and the second one contain match details and score.i want to make another json which aggregate Total Matches Won-Lost total Goals
json1:https://api.jsonbin.io/b/5d07165d4f234842a566d0b4
json2:https://api.jsonbin.io/b/5d07168c2808a77fb80a2254
i tried to use ... rest operator.
Json 1
{
"name": "English Premier League 2011/12",
"clubs": [
{
"key": "chelsea",
"name": "Chelsea",
"code": "CHE"
},
{
"key": "arsenal",
"name": "Arsenal",
"code": "ARS"
},
{
"key": "tottenham",
"name": "Tottenham Hotspur",
"code": "TOT"
}
]
}

Json2
{
  "name": "English Premier League 2011/12",
  "rounds": [
    {
      "name": "Round 1",
      "matches": [
        {
          "date": "2012-01-11",
          "team1": {
            "key": "tottenham",
            "name": "Tottenham Hotspur",
            "code": "TOT"
          },
          "team2": {
            "key": "everton",
            "name": "Everton",
            "code": "EVE"
          },
          "score1": 2,
          "score2": 0
        },
        {
          "date": "2011-08-15",
          "team1": {
            "key": "mancity",
            "name": "Manchester City",
            "code": "MCI"
          },
          "team2": {
            "key": "swansea",
            "name": "Swansea",
            "code": "SWA"
          },
          "score1": 4,
          "score2": 0
        },
        {
          "date": "2011-08-14",
          "team1": {
            "key": "westbrom",
            "name": "West Bromwich Albion",
            "code": "WBA"
          },
          "team2": {
            "key": "manutd",
            "name": "Manchester United",
            "code": "MUN"
          },
          "score1": 1,
          "score2": 2
        },
        {
          "date": "2011-08-14",
          "team1": {
            "key": "stoke",
            "name": "Stoke City",
            "code": "STK"
          },
          "team2": {
            "key": "chelsea",
            "name": "Chelsea",
            "code": "CHE"
          },
          "score1": 0,
          "score2": 0
        }
]
}
]
}

Expected JSON Result
"clubs": [
{
"key": "chelsea",
"name": "Chelsea",
"code": "CHE",
"total_matches":38,
"won":"21",
"lost":"15",
"ties":"2",
"total-goals":"33",
"scored-against":"28"

},
{
"key": "arsenal",
"name": "Arsenal",
"code": "ARS",
"total_matches":38,
"won":"21",
"lost":"15",
"ties":"2",
"total-goals":"33",
"scored-against":"28"
}]

Answer: Something similar to this might help you need to add extra error checking and few modifications to get the exact result.

let a = {
    "name": "English Premier League 2011/12",
    "clubs": [{
            "key": "chelsea",
            "name": "Chelsea",
            "code": "CHE"
        },
        {
            "key": "arsenal",
            "name": "Arsenal",
            "code": "ARS"
        },
        {
            "key": "tottenham",
            "name": "Tottenham Hotspur",
            "code": "TOT"
        }
    ]
}
let b = {
    "name": "English Premier League 2011/12",
    "rounds": [{
        "name": "Round 1",
        "matches": [{
                "date": "2012-01-11",
                "team1": {
                    "key": "tottenham",
                    "name": "Tottenham Hotspur",
                    "code": "TOT"
                },
                "team2": {
                    "key": "everton",
                    "name": "Everton",
                    "code": "EVE"
                },
                "score1": 2,
                "score2": 0
            },
            {
                "date": "2011-08-15",
                "team1": {
                    "key": "mancity",
                    "name": "Manchester City",
                    "code": "MCI"
                },
                "team2": {
                    "key": "swansea",
                    "name": "Swansea",
                    "code": "SWA"
                },
                "score1": 4,
                "score2": 0
            },
            {
                "date": "2011-08-14",
                "team1": {
                    "key": "westbrom",
                    "name": "West Bromwich Albion",
                    "code": "WBA"
                },
                "team2": {
                    "key": "manutd",
                    "name": "Manchester United",
                    "code": "MUN"
                },
                "score1": 1,
                "score2": 2
            },
            {
                "date": "2011-08-14",
                "team1": {
                    "key": "stoke",
                    "name": "Stoke City",
                    "code": "STK"
                },
                "team2": {
                    "key": "chelsea",
                    "name": "Chelsea",
                    "code": "CHE"
                },
                "score1": 0,
                "score2": 0
            }
        ]
    }]
}
let teamCodes = a.clubs.map(e => e['code']);
console.log("Team codes");
console.log(teamCodes)
let output = {'clubs': []};
teamCodes.map(e=> output.clubs.push({"code": e}))
b.rounds[0].matches.map(ef => {
    var total_matches = 0
    var won  = 0
    var lost = 0
    var tie  = 0
    var total_goals = 0
    teamCodes.forEach(function(e, index){
        var codeIndex = output.clubs.findIndex(function(element, index, array){return element.code ===e})

        if(ef.team1.code == e){
            output.clubs[codeIndex].code = e
            output.clubs[codeIndex].name = ef.team1.name;
            output.clubs[codeIndex].key = ef.team1.key;
            output.clubs[codeIndex].total_matches = total_matches + 1
            output.clubs[codeIndex].total_goals = total_goals + ef.score1
            if(ef.score1 > ef.score2) {
                output.clubs[codeIndex].won = won + 1
            } else if(ef.score1 < ef.score2) {
                output.clubs[codeIndex].lost = lost + 1
            } else {
                output.clubs[codeIndex].tie = tie + 1
            }

        } else if(ef.team2.code == e) {
            output.clubs[codeIndex].code = e
            output.clubs[codeIndex].name = ef.team2.name;
            output.clubs[codeIndex].key = ef.team2.key;
            output.clubs[codeIndex].total_matches = total_matches + 1
            output.clubs[codeIndex].total_goals = total_goals + ef.score2
            if(ef.score1 > ef.score2) {
                output.clubs[codeIndex].won = won + 1
            } else if(ef.score1 < ef.score2) {
                output.clubs[codeIndex].lost = lost + 1
            } else {
                output.clubs[codeIndex].tie = tie + 1
            }
        }
    })
})
console.log("Output")
console.dir(output)


If a license plate has no numbers, what is the probability of it being a vanity plate?

Question: I have this theory that a license plate with no digits has a high probability of being a vanity plate. Lets assume license plates are $9$ characters, and are chosen by random unless they're a vanity plate. I figure that the probability of a license having no digits if chosen by chance is $\left(\frac{26}{36}\right)^9$, or about $5\%$. Is my math for that correct?
Given that probability, is there a way to determine the probability that a license plate with no digits was randomly chosen and is not a vanity plate?
Comment: "Lets assume license plates are 9 digits" Do you mean 9 symbols?
Comment: Well, since absolutely no state or country that I know of *has* a policy that a license plate can be nine random symbols but all states and countries have instead a policy of a specific number of numbers and a specific number of letters and that every position is designated as either always for a number or always for a letter, I would say all your assumptions are invalid and a plate with only letters has a 100% chance of being vanity.
Comment: You meant to say "assume license plates are $9$ *characters* ...".
Comment: That's correct, updated the question
Answer: No. At the very least, you also need to know the a priori probability that a plate is a vanity plate. That is, when you ask:

is there a way to determine the probability that a license plate with no digits was randomly chosen and is not a vanity plate?

you are asking for the conditional probability $P(V|N)$ with $V$ being the event of the plate being a vanity plate, and $N$ being the event of the plate having no digits.
Now, you could of course try to use Bayes' formula:
$$P(V|N)=\frac{P(N|V)\cdot P(V)}{P(N)}=\frac{1\cdot P(V)}{P(N)}= \frac{ P(V)}{P(N)}$$
But, like I said, you'd need to know the a priori probability $P(V)$ to use this.
Moreover, the $P(N)$ that this formula refers to is not the same as the $P(N)$ that you calculated: the $P(N)$ you calculated was the probability of getting no digits on a plate where all symbols are picked randomly, i.e. this was assuming no one has requested a vanity plate!
Now, here is something you can do: find the actual $P(N)$, i.e. find the percentage of plates that are actually out there being used that have no numbers.  If you find that this is far more than that $5$% that you would get when creating plates randomly, then you have good reason to believe that lots of people got vanity plates.  If, however, you find that this $P(N)$ is close to that $5$%, then that suggest not many people order vanity plates. So .. start counting! :)
Answer: You are right about the probability of a randomly-generated 9-"letter" plate having no digits (if the "letters" are 0-9 and A-Z), but there's no way to know how an all-letter plate was chosen. I might have requested the vanity plate YHEOEBNWX. Maybe there are only 2 vanity plates in your state, or maybe there are millions. The fraction of all-letter plates that were human-selected is not something that can be determined mathematically.

Added: Also, there is the practical problem of how randomly-selected plates can avoid matching already-issued plates, so in practical terms, random generation of license plates is, well, not practical, at least not without some collision-avoiding rules, which may come into play more (or less) often for all-letter plates than for other plates.
Answer: Bayes' formula is the way to go. But you do first need to know how common vanity plates are in general. To illustrate that you need to know this, consider the two extremes: no one has vanity plates, at all, or everyone had vanity plates. In these cases, the probability of a digitless plate to be vanity is still either $0$ or $1$.
Answer: We can't do this without knowing probability of vanity plates and what proportions of vanity plates have no numbers.
If $0.1\%$ of cars have vanity plates and half of them have no numbers then then $.999*(\frac {26}{36})^9\approx .05$ of the cars are no numbered standards and $.001*.5 = .0005$ are no numbered vanity then the probability of a no numbered plate being vanity is $\approx \frac {0.0005}{0.0505}\approx 1\%$.
But of $25\%$ of the cars have vanity plates and $90\%$  have no numbers then there are $.75*(\frac {26}{36})^9 \approx 4\%$ of the cars have standard issue plates with no numbers and $.25*.9=22.5\%$ of the cars have vanity plates with no numbers so the probality a plate with no numbers is $\approx \frac {22.5}{26.5}\approx 85\%$.
So that makes a huge difference how common vanity plates are.
Rule of thumb if a vanity plate with no numbers is more likely than five percent then it is likely the plate is vanity but if a vanity plate with no numbers is less likely than five percent it is likely or not.
A similare example is if you flip a coin five times and got all heads.  That a one in thirty-two probability.  That's unlikely, maybe you have a fake coin.  Well, fake coins are really rare... a lot fewer than one in thirty-two so you probably have a good coin and it was just a fluke.  But if you flip it $20$ times in a row and got all heads, the probability is less than one in a million.  Okay, we don't know how likely it is that you got a bad coin but it's probably higher than one in a million so this probably a fake coin.
(On the other hand this event, flipping 20 heads and not knowing if the coin was fake, has probably never happened to you or anyone you know.)
If we don't know the likelihood of vanity plates in general, $5\%$ likelihood of a standard issue plate being all numbers just isn't rare enough for us to suspect a vanity plate unless vanity plates without numbers are more than $5\%$ of the cars as well.


Estimate exponential equation from graph

Question: Output y of a system is a non increasing function of an input x
Based on my studies I have found that it can be estimated as below
$$
y = be^{ax}+c
$$
From measurement I have five values of y for x that are not equally spaced. I.e I have values of y for x= 5,10,20,40,50.
Values of y are exponentially decreasing and hence should fit the generic equation above.
The task at hand is to find values of a,b and c from these five measurement data. I understand that I have enough points of data for calculating three unknowns. I want to know a iterative/generic logic to come up with estimations of these unknowns, since I have to do this for hundreds of measurements.
PS:
Some points already known to me

c can be estimated by looking for asymptotes
a is negative as my function is exponentially decreasing with x

I am new to this community, Please consider that while you answer/comment
Comment: have you tried the Least Squares method?
Answer: If $c$ is known then we have points of the form
$$(x_i,be^{ax_i})$$
after shifting the data by $(0,-c)$. This relation can be rewritten as
$$y=be^{ax}\implies\ln{(y)}=ax+\ln{(b)}$$
So the variables $\ln{(y)}$ and $x$ are linearly related. The Least Squares Regression line can then be found for $\ln{(y)}$ and $x$ giving a relation of the form
$$\ln{(y)}=mx+c=ax+\ln{(b)}$$
Hence the value of $a$ is given by the gradient $m$ of the Least Squares Regression line between $\ln{(y)}$ and $x$. Also, the value of $b$ is given by $e^c$ where $c$ is the $y$-axis intercept of the Least Squares Regression line between $\ln{(y)}$ and $x$.
Comment: I was curious on how to start if C is unknown.
Answer: You must be careful with this type of problems. In the least square sense, what you want is to minimize
$$SSQ(a,b,c)=\sum_{i=1}^n(b\,e^{a\,x_i}+c-y_i)^2$$ which is nonlinear because of $a$ and then you need reasonable estimates to start the nonlinear regression.
If $c$ is known, the problem is quite simple because you can, in a first step, linearize the model as
$$\log(y-c)=\log(b)+a x=\beta + ax$$ as Peter Foreman did explain. Then, a standard linear regression gives estimates of parameters $(a,b)$. However, you must not stop at this point because what has been measured is $y$ and not any of its possible transforms.
This post could be of interest for you.


Where/how can I get a song's backing track without a specific instrument so I can play for it?

Question: I've been playing with the violin for a while now.
The latest song I learned was He's a Pirate from Pirates of the Caribbean. 'cuz it is a lot of fun.
I want to make a video of me playing it. And it works. However, this song has many instruments other than the violin, so it is a bit boring to just listen to me playing the violin.
So I wanted to append to my video the actual soundtrack. The problem is, of course, that the soundtrack includes violins. And it makes no sense to have me playing the violin because the soundtrack already does it.
So essentially, I need the He's a pirate soundtrack, without the violin part so that I can play such part by my own while enjoying the other instruments match my notes.
This isn't just about He's a Pirate. I probably will want to achieve the same effect for a lot of other songs, and I have no idea where/how can I get soundtracks missing specific instruments.
If you explore some YouTube videos, well, you'll notice that many performers already seem to do this: Grab a popular soundtrack which is somehow missing the violin part (I think), play it in the background, and then play by themselves with their violins.
Is there some kind of resource or perhaps software to get this file type?
Comment: We have a very similar question [here](http://music.stackexchange.com/questions/3143/how-can-i-get-the-instrumentals-for-a-song/). It's focus on removing the vocal track, but the same advice should apply for other instruments, presuming you can isolate (identify) pitch-range. Or get a friend to play a piano-accompaniment.
Answer: There are a number of companies that provide recorded audio tracks of popular music of all sorts, from classical to jazz and pop music -- with the solo instrument or lead vocal part missing from the recording, so that you can play this part yourself with the recording as an accompaniment.
Foremost among these companies is Music Minus One in the US, which has been in business since 1950. Today Music Minus One sells their own accompaniment tracks as well as those by other companies including the giant music publishing company Hal Leonard. Everything that they sell is fully licensed and legal for the uses that are specificied.
At MusicMinusOne.com, and elsewhere, you can find a huge variety of accompaniment tracks for solo instrumentalists of all types, as well as singers. Most come in a package with sheet music. Depending on the nature of the copyright on the material, and the license you purchase, you may or may not be able to use these recordings to make your own commercial recording. There are solo musicians who use these recordings to accompany themselves in live performance, too.
Here is the package you are asking about, from the Music Minus One company:
Instrumental Play-Along: Violin Edition. Pirates of the Carribean
Published by Hal Leonard.
Format:  Play-Along (Book+CD)
Instrument:  Violin
Genre:  Broadway/Film/TV
16 Songs
They even have audio previews for you to stream online. Here is the MP3 preview of their recording of "He's a Pirate":
http://musicminusone.com/media/uploads/mp3/MMO8731HL-CD01-06-desv.us.mp3
Comment: Wheat, do you think you would be able to generalize this a bit?  The question is already falling into too-localized shopping rec territory and I hope we can turn it into something more useful for others who need this sort of track.
Answer: Standard MIDI Files
In the early 1990s there were several commercial companies that licensed the rights to a lot of pop songs and made and sold libraries of Standard MIDI File sequencer data, which contained note-for-note recreations of the arrangements of hit pop songs played and programmed by keyboardists on MIDI controllers. The libraries were sold on floppy disks. Unfortunately this was a fad that did not last. Most of those companies went out of business, and their rights to use those copyrighted songs in the products they sold were for a limited time and expired.
However, you can find lots of Standard MIDI files of pop songs on the Internet.
You can play a Standard MIDI File in Windows or the Mac OS using their built-in (very crude) General MIDI sound libraries. You can also import a Standard MIDI file into many sequencer programs, DAWs, and music notation programs like Finale or Sibelius, for playback using their General MIDI sound libraries. Once you have the MIDI data in a sequencer, you can edit things to provide better sounds from the software virtual instruments you work with.
If you have a full arrangement of a song as a Standard MIDI sequence, obviously you can mute the tracks of the instruments you don't want and you can play along with them yourself and make your own recordings.
Classical Archives
I should also mention this surprisingly rich resource for Standard MIDI files of classical music in the public domain which is free, based on the contributions of enthusiasts. It has everything from piano works to full orchestral scores. The quality of the MIDI sequences varies depending on the creator.
http://www.classicalarchives.com
Answer: SmartMusic is a music education software and hardware product for learning to play an instrument (or to sing). It offers a large library of pre-programmed accompaniments, and the system actually listens to the playing of the student and adjusts the tempo and phrasing to match the student's playing. Its catalog of material leans heavily on the standards of classical and jazz music taught to intermediate students in schools. They have partnered with the Jamey Aebersold company to provide its jazz accompaniment tracks formatted to work with the SmartMusic interactive system.
SmartMusic is a brand of the MakeMusic company, which also owns the Finale music notation app. Apparently, you can create your own custom scores in Finale and export them for use in the SmartMusic system; I do not know the details.
https://www.smartmusic.com/products/educators/
Answer: The Jamey Aebersold company has a large library of recorded backing tracks for learning jazz soloing and accompaniment. Their system is well-regarded among jazz educators. Their website is jazzbooks.com, and as mentioned above, some of their products are also sold through Music Minus One and SmartMusic.
Answer: Yamaha makes the Disklavier line of acoustic player pianos, which get the music from MIDI data. Accordingly, Yamaha sells libraries of piano songs which are MIDI sequences in Disklavier format. I believe some of them also have orchestral accompaniments which can be used with a Yamaha acoustic piano which has the Disklavier player system as well as a General MIDI sound module built-in.
This is a specialized application, but there is a lot of music available for this system.
Yamaha Disklavier System
Answer: Commercial Auto-accompaniment software for jazz musicians.
These programs enable one to construct a song arrangement and chord progression, select various instruments, select a specific musical style with specific parameters, and then the program can generate an algorithmically-created accompaniment ensemble, usually played back through a General MIDI virtual instrument and/or with loops of performance by live musicians. You can save the output as an audio file, or export a Standard MIDI file for further work in a music notation or sequencer or DAW application.
Band-in-a-Box for Windows and Mac OS
iReal b for iPad, Android and Mac OS
The user community for both of these programs have made thousands of song files of popular jazz standards available for use with the programs -- many free, some sold in sets. The song files generally are based on the chord progression only, and do not include a melody, lyrics or lead instruments, thus avoiding copyright challenges.


div fixa no rodapé do navegador

Question: Eu estou precisando deixar uma div que seria um botão de "Comprar" fixa no rodapé do navegador. Deixar ela no final do monitor, e mesmo que o scroll role para baixo, continua na mesma posição, no final. Como poderia fazer usando HTML / CSS ?
Answer: tenta:
<code>position:fixed;
bottom:0px;
</code>

div fixa no rodapé do navegador


How to deal with zero inflated panel data?

Question: For a research project, I created a panel dataset that counts violent events in subnational administrative units from 2000 to 2015, thus my unit of analysis is district-year. Out of 20.000 district-years, only 2000 record violent events. Therefore I decided to proceed with a zero inflated negative binomial regression model. I understood that this model assumes that there is a reason why the population is zero-inflated, which you try to assess with the zero-inflated component of the regression model. Did I understand this correctly?
In my specific case, however, over the period of 15 years, 47% of my units of analysis experienced conflict at least once. This made me doubt if a zero-inflated model is actually necessary. I am grateful for any suggestions.
Answer: Keep in mind, having lots of zeroes does not necessarily mean your data is zero-inflated. For example, a Poisson with mean 0.5 has 60% zeroes, but it's not zero-inflated - it's a just a distribution that has lots of zeroes.
If there truly is excess zeroes (you can check this with R DHARMa simulated residual plots and compare performance with non ZI distribution (e.g. ZANB vs NB), then there are two ways to deal with it, which have different One is a Zero-Inflated model, and the other is the Zero-Altered (or "hurdle) model.
The hurdle model interpretation assumes there is a process that generates zero, and if that's non-zero, there's a second process that is always positive. For example, say we were modelling "number of items bought at the supermarket in a day". If you don't go to the supermarket, you can't buy stuff. so that's the zero-generating process. If you do go (presumably) you do buy stuff, so that's the positive component (usually modelled with something like a truncated Poisson or truncate NB).
The zero-inflation model assumes there's a process that generates zeroes, and if that's non-zero, there's a second process that could be zero or non-zero. For example, say we were modelling "number of car trips in a day". Owning a car could be the zero-generating process. However, even if you own a car, you may make 0, 1, 2, ... car trips in a day.
Whether or not you need a model to deal with excess zeroes should hopefully both be informed by your theory of the behavior, and the empirical data.


Is using nodes for a notification system a performance concern?

Question: I am building a user activity notification system whereby each new notification message is created as a new node which is displayed by Views. To prevent an infinite number of nodes being created there is a system in place to delete notification nodes once they have reached a certain age.
This still begs the question however of whether using nodes in this way is a good idea for future performance. If a single user gets 20 notifications in a day, that is 20 nodes; now if there are potentially several hundred to a thousand users that is a lot of nodes in a short period of time. The main reason I use nodes is because they are easy to access and manipulate using Rules and also are very flexible when used with Views.
Therefore is it worth considering an alternative to nodes and if so what? The Messaging module comes to mind, but since each new Message is a new entity I'm not quite sure whether in terms of performance this would be any different to using nodes. Is there a module that offers the same flexibility of nodes but also has better performance?
Answer: I would go with Messaging. Dedicated Entity (if implement properly) is always faster than Node. I participated in the big D7 project and we were happy with Message API. By using a custom entity you can switch to custom storage, like: https://www.drupal.org/project/mongo_entity
This can be helpful for D8:
https://drupalwatchdog.com/blog/2015/3/entity-storage-drupal-8-way
Answer: There can be some performance issues because all your messages will be stored in the node table along with the other nodes.  This will slow down any node loading or any kind of node type handling.  I would suggest creating your own entity which would result in these being in their own table.  They can also be referenced via entity reference and into views.  Check out how to create entities and check out my entity feature on github.
Comment: That would be a downside to using a custom entity so you may have to resort to using a node, or build a comment type system using fields instead.
Comment: Yeah that's what I'm concerned about. I have considered using [ECK](https://www.drupal.org/project/eck) to build a custom "notification" entity, but the problem is that in D7 there is no standard way to add commenting to Entities. I am using nodes because they have comments already built in.
Comment: Hmm I thought so. I may do things the other way around then and use nodes for only notifications but custom entities for everything else that doesn't need comments etc.


Patterns on sum of any two consecutive counting number

Question: I am looking for patterns in this condition, fortunately I found some but I cannot prove despite of simplicity of the condition... please give me some lead on how Im going to prove any of this pattern and maybe any of these questions will lead to the proof of other patterns. Let n be a a counting number $$1, 2, 3, 4, 5, 6, 7. . $$ this will serve as the first layer. If I add every two consecutive counting numbers it will result to $$3,5,7,9,11,13,...$$ this is the second layer. If I repeat the process I came up with $$8,12, 16, 20, 24$$ 3rd layer and so on...
The following are the patterns I observe:

The difference between any two elements in kth layer is equal to $2^{k-1}$...
The gcf of 1st and 2nd layer, 3rd and 4th layer, 5th and 6th layer and so on is 1,4,16 and so on respectively which are all power of two but with skipping...
The sum of all elements included in a triangle of any odd numbered size will always be a multiple of the middle number on its base. For example adding those number:$$1,2,3,4,5$$$$3,5,7,9$$$$8,12,16$$$$20,28$$$$48$$ is equal to 171 which is a multiple of 3 (the middle entry on its base).

Any idea will of great help thanks!
Comment: What exactly pattern are you interested in? The fact that the difference of the elements in $k$-th level is $2^{k-1}$ is pretty obvious, is not it?
Comment: Yes sir, but obvious is not enough to justify the initial observation thats why Im looking for a proof to generalize my observation...
Answer: For convenience of the presentation we start counting the "levels" from $0$,
so that
$$
\{1,2,3\dots\}
$$
is the $0$-th level.
Denote the difference at the $k$-th level as $\Delta_k$. Let us prove that every level is an arithmetic progression with common difference $\Delta_k=2^{k}\Delta_0$. For $k=0$ it is obvious. Assume it is true at the level $n$. Then it is valid for $(n+1)$-th level as well.
Proof.
By induction hypothesis the elements of the $n$-th level represent an arithmetic progression: $$a_{ni}=a_{n0}+i\Delta_n.$$
Summing the neighboring elements of the $n$-th level one obtains for the elements of the $(n+1)$-th level the expression:
$$a_{n+1,i}=a_{ni}+a_{n,i+1}=(a_{n0}+i\Delta_n)+(a_{n0}+(i+1)\Delta_n)=(2a_{n0}+\Delta_n)+i(2\Delta_n).$$
Thus, the $(n+1)$-th level also represents an arithmetic progression with
$$
a_{n+1,0}=2a_{n0}+\Delta_n,\text{ and } \Delta_{n+1}=2\Delta_n\stackrel{I.H.}=2\cdot 2^{n}\Delta_0=2^{n+1}\Delta_0.\tag1
$$
It can be similarly shown by induction using $(1)$, that the initial term at the $n$-th level is:
$$
a_{n0}=2^{n-1}(2a_{00}+n\Delta_0).
$$
For $a_{00}=\Delta_0=1$ this reads:
$$
a_{n0}=2^{n-1}(n+2)\to \{1,3,8,20,48,\dots\}.
$$
Comment: My thinking is shallow, i simply assume that $2^{L-1}$ to be $2^{(L+1)-1}$ to come up with $2^L$ thanks for the wider insight sir/maam...
Comment: Sir/maam can i used the generated formula for initial term at nth level and the idea of arithmetic progression to answer my 2nd and third question?
Comment: As the expression allows you effectively to calculate any term at any level,   you can plug their values in any of your conjectures. The second one is again simple. From the expression $a_{ni}=2^{n-1}(n+2+2i)$ it follows immediately that gcd of the terms is $2^n$ for even $n$, and $2^{n-1}$ for odd $n$ (do not forget that in my notation the levels are counted from $0$).
Comment: Thanks a lot sir/maam!
Comment: You are welcome. And you can name me simply @user.


Para que serve e como usar o "static"?

Question: Estou com muita dúvida em relação a como usar o "static" em um atributo , se alguém puder me tirar essa dúvida eu agradeceria muito, obrigado.
Comment: static em um classe ou função? tem diferença
Comment: métodos e atributos
Answer: Palavra-Chave 'static'
Declarar membros ou métodos de uma classe como estáticos faz deles acessíveis sem precisar instanciar a classe. Um membro declarado como estático não pode ser acessado com um objeto instanciado da classe (embora métodos estáticos podem).
<code>Exemplo #1 Exemplo de membro estático

<?php
class Foo
{
    public static $meu_estatico = 'foo';

    public function valorEstatico() {
        return self::$meu_estatico;
    }
}

class Bar extends Foo
{
    public function fooEstatico() {
        return parent::$meu_estatico;
    }
}

print Foo::$meu_estatico . "\n";

$foo = new Foo();
print $foo->valorEstatico() . "\n";
print $foo->$meu_estatico . "\n";      // "Propriedade" Indefinida $meu_estatico

print $foo::$meu_estatico . "\n";
$classname = 'Foo';
print $classname::$meu_estatico . "\n"; // No PHP 5.3.0

print Bar::$meu_estatico . "\n";
$bar = new Bar();
print $bar->fooEstatico() . "\n";
?>
</code>
Referência: http://php.net/manual/pt_BR/language.oop5.static.php
Comment: Muito obrigado, consegui entender melhor com o seu exemplo, obrigado mesmo !

Para que serve e como usar o "static"?


XSLT split based on child of child data

Question: I have:
<?xml version="1.0" encoding="utf-8"?>
<parent>
 <parentspecialinfo>blond</parentspecialinfo>
  <child>
    <grandchild>
      <grandchildtype>special</grandchildtype>
      <specialvalue>123</specialvalue>
      <otherstuff>123</otherstuff>
      <otherstuff2>abc</otherstuff2>
      <otherstuff3>zxc</otherstuff3>
    </grandchild>
    <grandchild>
      <grandchildtype>red</grandchildtype>
      <specialvalue>345</specialvalue>
      <otherstuff>123</otherstuff>
      <otherstuff2>abc</otherstuff2>
      <otherstuff3>zxc</otherstuff3>
    </grandchild>
    <grandchild>
      <grandchildtype>blue</grandchildtype>
      <specialvalue>678</specialvalue>
      <otherstuff>123</otherstuff>
      <otherstuff2>abc</otherstuff2>
      <otherstuff3>zxc</otherstuff3>
    </grandchild>
    <otherchildthings>tiger</otherchildthings>
  </child>
  <child>
    <grandchild>
      <grandchildtype>special</grandchildtype>
      <specialvalue>123</specialvalue>
      <otherstuff>123</otherstuff>
      <otherstuff2>abc</otherstuff2>
      <otherstuff3>zxc</otherstuff3>
    </grandchild>
    <otherchildthings>tiger</otherchildthings>
  </child>
  <child>
    <grandchild>
      <grandchildtype>red</grandchildtype>
      <specialvalue>345</specialvalue>
      <otherstuff>123</otherstuff>
      <otherstuff2>abc</otherstuff2>
      <otherstuff3>zxc</otherstuff3>
    </grandchild>
    <grandchild>
      <grandchildtype>blue</grandchildtype>
      <specialvalue>678</specialvalue>
      <otherstuff>123</otherstuff>
      <otherstuff2>abc</otherstuff2>
      <otherstuff3>zxc</otherstuff3>
    </grandchild>
    <grandchild>
      <grandchildtype>special</grandchildtype>
      <specialvalue>999</specialvalue>
      <otherstuff>123</otherstuff>
      <otherstuff2>abc</otherstuff2>
      <otherstuff3>zxc</otherstuff3>
    </grandchild>
    <otherchildthings>tiger</otherchildthings>
  </child>
</parent>

I need to copy the entire set of child records into a new parent element retaining all parental node information for each unique set of specialvalue where grandchildtype is special.  So for this example we only have 2, 123 and 999.  But there could be many sets of unique values.  I am having some trouble moving back up the chain to retain all the elements.  I was experimenting using the xsl:key element, but have not gotten far.  Is that a good solution for this problem?
So this would be the result:
<?xml version="1.0" encoding="utf-8"?>
<parent>
  <parentspecialinfo>blond</parentspecialinfo>
  <child>
    <grandchild>
      <grandchildtype>special</grandchildtype>
      <specialvalue>123</specialvalue>
      <otherstuff>123</otherstuff>
      <otherstuff2>abc</otherstuff2>
      <otherstuff3>zxc</otherstuff3>
    </grandchild>
    <grandchild>
      <grandchildtype>red</grandchildtype>
      <specialvalue>345</specialvalue>
      <otherstuff>123</otherstuff>
      <otherstuff2>abc</otherstuff2>
      <otherstuff3>zxc</otherstuff3>
    </grandchild>
    <grandchild>
      <grandchildtype>blue</grandchildtype>
      <specialvalue>678</specialvalue>
      <otherstuff>123</otherstuff>
      <otherstuff2>abc</otherstuff2>
      <otherstuff3>zxc</otherstuff3>
    </grandchild>
    <otherchildthings>tiger</otherchildthings>
  </child>
  <child>
    <grandchild>
      <grandchildtype>special</grandchildtype>
      <specialvalue>123</specialvalue>
      <otherstuff>123</otherstuff>
      <otherstuff2>abc</otherstuff2>
      <otherstuff3>zxc</otherstuff3>
    </grandchild>
    <otherchildthings>tiger</otherchildthings>
  </child>
</parent>
<parent>
  <parentspecialinfo>blond</parentspecialinfo>
  <child>
    <grandchild>
      <grandchildtype>red</grandchildtype>
      <specialvalue>345</specialvalue>
      <otherstuff>123</otherstuff>
      <otherstuff2>abc</otherstuff2>
      <otherstuff3>zxc</otherstuff3>
    </grandchild>
    <grandchild>
      <grandchildtype>blue</grandchildtype>
      <specialvalue>678</specialvalue>
      <otherstuff>123</otherstuff>
      <otherstuff2>abc</otherstuff2>
      <otherstuff3>zxc</otherstuff3>
    </grandchild>
    <grandchild>
      <grandchildtype>special</grandchildtype>
      <specialvalue>999</specialvalue>
      <otherstuff>123</otherstuff>
      <otherstuff2>abc</otherstuff2>
      <otherstuff3>zxc</otherstuff3>
    </grandchild>
    <otherchildthings>tiger</otherchildthings>
  </child>
</parent>

As I have been asked for clarification here is my psuedo code walk through from my LINQ solution.  I hope it helps:
1) Create shell node set by copying <parent>.
2) Remove all <child> elements from shell node.
3) Query original document for all <child> nodes.
4) For each <child> node find the <specialvalue> value where <grandchildtype> value is "special"
5) Check if we have already seen the <specialvalue> if not then add the entire <child> to  a collection.  If we have already seen it then find it in the collection and add it to the collection at that location.
6) For each collection value, add the <child> nodes to a new shell node created in step 1.
7) Add all nodes created above to the same document.
Thank you.
Comment: I don't understand the question. Please, reduce the problem to minimum expression.
Comment: @Alejandro: I can give you the pseudocode walkthrough of my LINQ solution.  I am not sure I can simplify the XML much more.  I will add the walkthrough to the question.
Comment: There is no `blond` data in input source.
Answer: Update: With the new input source, this stylesheet (overwriting identity rule):
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:key name="kChildBySpecialvalue"
             match="child"
             use="concat(
                     generate-id(..),'+',
                     grandchild[grandchildtype='special']/specialvalue
                  )"/>
    <xsl:template match="node()|@*">
        <xsl:copy>
            <xsl:apply-templates select="node()|@*"/>
        </xsl:copy>
    </xsl:template>
    <xsl:template match="parent">
        <xsl:variable name="vCurrent" select="."/>
        <xsl:for-each select="child[
                                 count(.|key('kChildBySpecialvalue',
                                             concat(
                                                generate-id($vCurrent),'+',
                                                grandchild[
                                                   grandchildtype = 'special'
                                                ]/specialvalue
                                             )
                                         )[1]
                                 ) = 1
                              ]">
            <xsl:variable name="vGroup"
                          select="key('kChildBySpecialvalue',
                                      concat(
                                         generate-id($vCurrent),'+',
                                         grandchild[
                                            grandchildtype = 'special'
                                         ]/specialvalue
                                      )
                                  )"/>
            <xsl:for-each select="$vCurrent">
                <xsl:copy>
                    <xsl:apply-templates
                         select="node()[not(self::child)]|$vGroup|@*"/>
                </xsl:copy>
            </xsl:for-each>
        </xsl:for-each>
    </xsl:template>
</xsl:stylesheet>

Output:
<parent>
    <parentspecialinfo>blond</parentspecialinfo>
    <child>
        <grandchild>
            <grandchildtype>special</grandchildtype>
            <specialvalue>123</specialvalue>
            <otherstuff>123</otherstuff>
            <otherstuff2>abc</otherstuff2>
            <otherstuff3>zxc</otherstuff3>
        </grandchild>
        <grandchild>
            <grandchildtype>red</grandchildtype>
            <specialvalue>345</specialvalue>
            <otherstuff>123</otherstuff>
            <otherstuff2>abc</otherstuff2>
            <otherstuff3>zxc</otherstuff3>
        </grandchild>
        <grandchild>
            <grandchildtype>blue</grandchildtype>
            <specialvalue>678</specialvalue>
            <otherstuff>123</otherstuff>
            <otherstuff2>abc</otherstuff2>
            <otherstuff3>zxc</otherstuff3>
        </grandchild>
        <otherchildthings>tiger</otherchildthings>
    </child>
    <child>
        <grandchild>
            <grandchildtype>special</grandchildtype>
            <specialvalue>123</specialvalue>
            <otherstuff>123</otherstuff>
            <otherstuff2>abc</otherstuff2>
            <otherstuff3>zxc</otherstuff3>
        </grandchild>
        <otherchildthings>tiger</otherchildthings>
    </child>
</parent>
<parent>
    <parentspecialinfo>blond</parentspecialinfo>
    <child>
        <grandchild>
            <grandchildtype>red</grandchildtype>
            <specialvalue>345</specialvalue>
            <otherstuff>123</otherstuff>
            <otherstuff2>abc</otherstuff2>
            <otherstuff3>zxc</otherstuff3>
        </grandchild>
        <grandchild>
            <grandchildtype>blue</grandchildtype>
            <specialvalue>678</specialvalue>
            <otherstuff>123</otherstuff>
            <otherstuff2>abc</otherstuff2>
            <otherstuff3>zxc</otherstuff3>
        </grandchild>
        <grandchild>
            <grandchildtype>special</grandchildtype>
            <specialvalue>999</specialvalue>
            <otherstuff>123</otherstuff>
            <otherstuff2>abc</otherstuff2>
            <otherstuff3>zxc</otherstuff3>
        </grandchild>
        <otherchildthings>tiger</otherchildthings>
    </child>
</parent>

Note: Gruping parent's child children by specialvalue when grandchildtype is equal to 'special'; copying itself, others children and group for each group.
Comment: Excellent answer!  Unfortunately I seem to lose the other elements at the parent level, the blond.  Is there a slight modification that might get those elements to copy?  Thanks!
Comment: @Jack: Check my update. This also use other aproach explicitly grouping parent content.
Comment: Would it be easy to add additional hierarchial element say: 444?
Comment: @Jack: Only `parent` content will be grouped into duplicates `parent` elements. All other elements in any hierarchy level will only be copied as is because the identity rule. This behavior is the closest to XSLT 2.0 `xsl:for-each-group` instruction.
Comment: I mean added another element around the  element with additional elements at that level.
Comment: @Jack: If you want to duplicate not only `parent` elements and its not `child` children, but also any ancestor... That would be another question.

XSLT split based on child of child data


I want to combine two table to get result

Question: i have two tables,
1.Orders,
2.Items.
1.Orders Skeleton
+-------+-------------+------+-----+---------+----------------+
| Field | Type        | Null | Key | Default | Extra          |
+-------+-------------+------+-----+---------+----------------+
| id    | int(11)     | NO   | PRI | NULL    | auto_increment |
| name  | varchar(50) | NO   |     | NULL    |                |
+-------+-------------+------+-----+---------+----------------+

2.Items Skeleton
+----------+-------------+------+-----+---------+----------------+
| Field    | Type        | Null | Key | Default | Extra          |
+----------+-------------+------+-----+---------+----------------+
| id       | int(11)     | NO   | PRI | NULL    | auto_increment |
| order_id | int(11)     | NO   | MUL | NULL    |                |
| name     | varchar(50) | NO   |     | NULL    |                |
| price    | int(11)     | NO   |     | NULL    |                |
+----------+-------------+------+-----+---------+----------------+

Records :
1.Orders Table with Data
+----+--------+
| id | name   |
+----+--------+
|  1 | Order1 |
|  2 | Order2 |
|  3 | Order3 |
+----+--------+

2.Items Table with Data
+----+----------+---------+-------+
| id | order_id | name    | price |
+----+----------+---------+-------+
|  1 |        1 | Mobile1 | 25000 |
|  2 |        1 | Mobile2 | 30000 |
|  3 |        1 | Mobile3 |  6500 |
|  4 |        2 | Mobile4 | 10000 |
+----+----------+---------+-------+

I want to get items which are having same order_id,
 Select id[Orders], order_id[items], name[items]1, name[items]2, name[items]3...

Suggestions Pls...
Comment: You want each name as a column? or all names as one column separated by comma?
Comment: That's not valid SQL syntax.
Comment: I don't think that it's possible to do that because you're (or mysql) unaware of how many rows it will fetch during the execution of the query. You need to get all the data first and use any programming language to print them in any way you want.
Answer: It seems that you only need to access table items to get what you need.
SELECT order_id, GROUP_CONCAT( name SEPARATOR ', ') item_names
FROM items
GROUP BY order_id;

Comment: But also i want those records(name) with separate column...

But this gives data's in single column..
Comment: Then you will need other techniques to convert row to columns. U can search on StackOverflow and there are already solutions. But more complicated.
Answer: I get solution for only known number of fields....
Row to Column:
STEP : 1
select @orderID:=order_id,
@name:=GROUP_CONCAT(name) item_names,
@price:=GROUP_CONCAT(price) item_price
from item group by order_id limit 1;

OUTPUT :
+----------+-------------------------+------------------+
| order_id | item_names              | item_price       |
+----------+-------------------------+------------------+
|        1 | Mobile1,Mobile2,Mobile3 | 25000,30000,6500 |
+----------+-------------------------+------------------+

STEP : 2
select @orderID,
SUBSTRING_INDEX(SUBSTRING_INDEX(@name, ',', 1),',',-1) as Name1,
SUBSTRING_INDEX(SUBSTRING_INDEX(@price, ',', 1),',',-1) as Price1,
SUBSTRING_INDEX(SUBSTRING_INDEX(@name, ',', 2),',',-1) as Name2,
SUBSTRING_INDEX(SUBSTRING_INDEX(@price, ',', 2),',',-1) as Price2,
SUBSTRING_INDEX(SUBSTRING_INDEX(@name, ',', 3),',',-1) as Name3,
SUBSTRING_INDEX(SUBSTRING_INDEX(@price, ',', 3),',',-1) as Price3;

OUTPUT :
+----------+---------+--------+---------+--------+---------+--------+
| @orderID | Name1   | Price1 | Name2   | Price2 | Name3   | Price3 |
+----------+---------+--------+---------+--------+---------+--------+
|        1 | Mobile1 | 25000  | Mobile2 | 30000  | Mobile3 | 6500   |
+----------+---------+--------+---------+--------+---------+--------+


Word Documents.Open returns null in ASP.NET windows server 2012 R2

Question: I have a web application that initial some information into word file (using text form).
when visual studio run it, its work currently but when I publish it and run in IIS, intrupt.word return null in open document .
I find some solution but that's not work for windows server 2012 R2 some solution like change the launching user to the interactive user or create "Desktop" directory in C:\Windows\SysWOW64\config\systemprofile path or C:\Windows\System32\config\systemprofile path all of this solution work very well for windows server 2008 and older but don't work for windows server 2012 R2
I find my own solution
In first I used interrupt for working with word while it's not good for web (unlike win App) application after searching I fined Aspose that have complete method for working with Word and it's compatible with web application.
Answer: Use an XML library (like ClosedXml) instead of Word Interop.
The most likely reason why it doesn't work via IIS is because Server-side automation of Office is not supported as per https://support.microsoft.com/en-us/kb/257757
Answer: I find my own solution
I do what Jeremy Thompson said
In first I used interrupt for working with word while it's not good for web application (unlike win App) after searching I fined Aspose that have complete method for working with Word and it's compatible with web application.


What are the most popular types or styles of pickups, and what is the genre of music most associated with them?

Question: I see humbuckers, single coil, active pickups, etc. I see P90's, PAFS, etc. Which are basically for jazz, blues, metal?
Answer: Well, it's a tough call; There's no set "rule" but i'll try and give you the lowdown on the "common" or stereotypical use of each pickup.
First let's talk about active pickups. Generally active pickups can get higher output and, due to that fact, they're a pretty popular choice for metal players. The most popular active pickups are EMGs. You'll see EMG 81's are a very popular bridge pickup for metal and EMG 85's are super popular for the neck (that's the Zakk Wylde combo). The 60 is popular too (James Hetfield uses those).
At the opposite end of the spectrum you see Steve Lukather from Toto uses EMGs in his guitars. He's known for rock, jazz, fusion and blues. So, active pickups aren't necessarily for metal, but they're popular with metal players.
Lots of folks claim active pickups sound sterile. Its all opinion.
OK single coils:
Single coils are the kind you'll see on Strats. They're very popular all around but are quite prolific in rock, surf music & blues (think SRV). A single coil at the bridge w/ some overdrive gives you that nice dirty blues type of tone.
But, then again, strats have been used by many, many folks for many varieties of music. One example is Pete Townsend: he's used and is currently using strats. So, again, you cannot pigeon-hole the pickup to a specific style of music. Also, Ritchie Blackmore from Deep Purple played a star a lot too.
One thing to keep in mind with the single coils is that they're often on strat-style guitars that have 3 pickups. With a 5 way switch you get the quacky tones w/ the in-between positions (combine neck or bridge pickup w/ the middle one). This combination of the 2 single coils is a very distinct tone & something you can't easily achieve w/ another pickup combination.
Tele style single coils are different than your strat style single coils and are well known for "twang". Think twangy country music.
P90s are single coil pickups. However they're hotter than the strat style single coils and have a less "crisp" tone. They can sound nice and mean too. The Les Paul Junior, in my opinion, is "the" P90 guitar.
P90's are pretty diverse and can be heard all over the last few Green Day albums. They're also the pickups George Thorogood has on his guitar - so they're great for blues as well as the Green Day style punk rock. They're great for country too. Check out http://www.youtube.com/watch?v=OSSjYFPTRAQ for an example.
OK... now off to humbuckers & PAFs. PAFs are the first humbucker pickups. PAF actually stands for Patent Applied For. Nowadays PAF designates a "class" of humbuckers.
Humbuckers come in 2 major varieties: high gain (things like the Duncan JB or a Dimarzio Super Distortion) & PAFs which denotes the not-super-high-gain type humbuckers.
Humbuckers don't hum like single coils do. Single coils have a 60 cycle hum to them. When you join 2 coils that hum is cancelled... or bucked =)
Like the other types on pickups you can't just say "humbuckers are used for x". They're used for many genres; from BB King to Slash to John Petriccui. All the way from blues to drop-tuned metal.
They've definitely got more body than both single coils and p90s. If you really, really want screaming pinch harmonics, you'll want a humbucker. If you want sweet, smooth & creamy tone you'll also want a humbucker w/ the tone knob cracked all the way down to 0.
Comment: Can you edit to explain what you mean by "hot"?
Comment: "Active" means you gotta stick a battery in it, right? Passive just uses EM induction with the string as a generator?


How to extend predicted value?

Question: This is the sample code which I got from this link
import pandas as pd
from sklearn import linear_model
import statsmodels.api as sm

Stock_Market = {'Year': [2017,2017,2017,2017,2017,2017,2017,2017,2017,2017,2017,2017,2016,2016,2016,2016,2016,2016,2016,2016,2016,2016,2016,2016],
                'Month': [12, 11,10,9,8,7,6,5,4,3,2,1,12,11,10,9,8,7,6,5,4,3,2,1],
                'Interest_Rate': [2.75,2.5,2.5,2.5,2.5,2.5,2.5,2.25,2.25,2.25,2,2,2,1.75,1.75,1.75,1.75,1.75,1.75,1.75,1.75,1.75,1.75,1.75],
                'Unemployment_Rate': [5.3,5.3,5.3,5.3,5.4,5.6,5.5,5.5,5.5,5.6,5.7,5.9,6,5.9,5.8,6.1,6.2,6.1,6.1,6.1,5.9,6.2,6.2,6.1],
                'Stock_Index_Price': [1464,1394,1357,1293,1256,1254,1234,1195,1159,1167,1130,1075,1047,965,943,958,971,949,884,866,876,822,704,719]
                }

df = pd.DataFrame(Stock_Market,columns=['Year','Month','Interest_Rate','Unemployment_Rate','Stock_Index_Price'])

X = df[['Interest_Rate','Unemployment_Rate']] # here we have 2 variables for multiple regression. If you just want to use one variable for simple linear regression, then use X = df['Interest_Rate'] for example.Alternatively, you may add additional variables within the brackets
Y = df['Stock_Index_Price']

# with sklearn
regr = linear_model.LinearRegression()
regr.fit(X, Y)

print('Intercept: \n', regr.intercept_)
print('Coefficients: \n', regr.coef_)

# prediction with sklearn
New_Interest_Rate = 2.75
New_Unemployment_Rate = 5.3
print ('Predicted Stock Index Price: \n', regr.predict([[New_Interest_Rate ,New_Unemployment_Rate]]))

# with statsmodels
X = sm.add_constant(X) # adding a constant

model = sm.OLS(Y, X).fit()
predictions = model.predict(X)

print_model = model.summary()
print(print_model)

This code predicts only one value forward but I want to predict five values forward.
New_Interest_Rate = 2.75, 3, 4, 1, 2

New_Unemployment_Rate = 5.3, 4, 3, 2, 1

How can I do this? I use jupyter notebook. Thank you.
Comment: where is five value that you want predict?
Comment: I added the new x values. Thanks.
Answer: try this:
New_Interest_Rate = [2.75, 3, 4, 1, 2]
New_Unemployment_Rate = [5.3, 4, 3, 2, 1]
for i in range(len(New_Interest_Rate)):
    print (str(i+1) + ' - Predicted Stock Index Price: \n',
           regr.predict([[New_Interest_Rate[i] ,New_Unemployment_Rate[i]]]))

instead of these lines:
New_Interest_Rate = 2.75
New_Unemployment_Rate = 5.3
print ('Predicted Stock Index Price: \n', regr.predict([[New_Interest_Rate ,New_Unemployment_Rate]]))

Comment: It worked. Thank you! I am not sure though if  this is additional question but how can I plot the new predictions together with the new predictions.
Comment: I made this question: https://stackoverflow.com/questions/69008185/how-to-extend-predicted-value.

Do you have suggestions please?
Comment: you might be interested in this question please: https://stackoverflow.com/questions/69008788/how-to-add-predicted-values-in-a-dataframe

How to extend predicted value?


Pi product + set builder notation - how to read

Question: From the low-discrepancy wiki I have:
$$\displaystyle \prod_{i=1}^s[a_i, b_i) = \{ \in \mathbb{R}^s : a_i \le x_i \le b_i\}$$
where $$0 \le a_i < b_i \le 1$$
How can I read it? Should I first make do a cartesian product of $[a_i,b_i)$? For example for $s=3$ I would have:
$$
  [a_1, b_1) \times [a_2, b_2) \times [a_3, b_3) = \{
\{a_1, a_2, a_3\}, \{a_1, a_2, b_3\}, \{a_1, b_2, a_3\}, \{a_1, b_2, b_3\},
\{b_1, a_2, a_3\}, \{b_1, a_2, b_3\}, \{b_1, b_2, a_3\}, \{b_1, b_2, b_3\}\}
$$
then I would put it into set-builder notation.. but for first $\{a_1, a_2, a_3\}$ I don't have $b_i$ value.
Comment: What is your question?
Comment: @lisyarus I am sorry. Stackexchenge posted my question when I was trying to add a link. I have edited it.
Answer: You should read, $\displaystyle \prod_{i=1}^s[a_i,b_i)$ as, "the product of all intervals closed $a_i$, open $b_i$ from $i=1$ to $s$". And $\displaystyle \{\tilde x\in \Bbb R^s:\tilde x=(x_1,x_2,\dots x_s) \text{ where }x_i\in[a_i,b_i),\forall i=1,2\dots s\}$ as, "the collection of all $\tilde x$ ($x$ tilde) in $\Bbb R^s$ such that $x$ tilde is of the form of $s$-tuple $(x_1,x_2,\dots x_s)$ where $x_i$ belongs to $[a_i,b_i)$ for all $i=1,2,... s$".
Hope it works.
Further, $\displaystyle \prod_{i=1}^s[a_i,b_i]=[a_1,b_1]\times [a_2,b_2]\times ... \times [a_s,b_s]$ where $\times$ is the cartesian product defined here.
Comment: Definitely yes. Thats what I mean.
Comment: After I compute $\displaystyle \prod_{i=1}^s[a_i, b_i) = \{ \in \mathbb{R}^s : a_i \le x_i \le b_i\}$ I will get collection of s-tuples: $\{ s-tuple, s-tuple...\}$. So, for $s = 1$ I will get $\{a_1, a_1 + v, a_1 + 2*v, ...a_1 + k*v\}$ where $v$ is some "small value" and $a_1 + k*v$ is smaller than $b_1$. So, for $v=0.4$, $a_1=0$ and $b_1=1$ I will get $\{0,0.4,0.8\}$. For $s=2$ I need to compute the Cartesian product: $\{0,0.4,0.8\}\times\{0,0.4,0.8| = \{\{0,0\},\{0,0.4\},\{0,0.8\},\{0.4,0\},\{0.4,0.4\},\{0.4,0.8\},\{0.8,0\},\{0.8,0.4\},\{0.8,0.8\}\}$. Is this correct? How do I find $v$?
Comment: I think you have confused with https://math.stackexchange.com/questions/2115752/what-is-an-interval-in-mathbbrn/2115757 this one. Further for $s=1$ you simply get an interval which cannot be written in your form $\{a1,a1+v...\}$ etc.
Comment: As for link: instead of $\{\{0,0\},...\}$ I should write $\{(0,0)\}$ and $\{0, 0.4, 0.8\}$ as $\{(0), (0.4), (0.8)\}$. That is what you mean?
As for $s=1$ do you mean that I have forgotten parenthesis ($()$)?