How to integrate vBulletin features into an external site

Question: I have a web site I'm building and the client wants to have features from vBulletin (blog, forums) integrated into the site.  Its not enough to simply add the sites skin to vBulletin.  Is there a way to do this?
I would expect there to be documentation on how, if it is possible, to do such a thing but haven't been able to find anything.
I'd rather not connect and query the vBulletin database directly.
Answer: After much research (see: cursing) I've found that external.php and blog_external.php do what I want though not quite as elegantly as I would like.
So if you want to incorporate forum threads into your web page then external.php is what you need.  It appears to be a bit more customizable in that you can have it output in JavaScript, XML, RSS, and RSS Enclosure (podcasting).
If you want to incorporate blog posts you appear to be limited to RSS only.  Like I said, less than ideal but at least its something.
There is more information here: http://www.vbulletin.com/docs/html/vboptions_group_external
Answer: There is no proper API for this yet, so you'd either have to rely on things like RSS, or query the database directly.  RSS won't get you old data, nor any forum structures, etc. just basics of new data.


Usar dotevn no JavaScript

Question: Olá, estou tendo problemas com o uso de dotenv, ele não funciona quando tento pelo navegador, estou fazendo apenas um exemplo simples. Abaixo vou dar a situação dos arquivos:

index.js

import 'dotenv/config'
import express from 'express'

dotenv.config()

const valor = process.env.SECRET;
console.log(valor);

.env

SECRET=789

index.html: Como usei a tag script

Error retornado pelo navegador:
Uncaught TypeError: Failed to resolve module specifier "dotenv/config". Relative references must start with either "/", "./", or "../".

Já tentei colocar um / na importação, mas só retornou outro error
import '/dotenv/config'
import express from '/express'

Failed to load resource: the server responded with a status of 404 (Not Found)

Estou usando a extensão live server para poder rodar a modulação pelo navegador
Answer: Acabei encontrando uma solução, para situações mais delicadas, consiste em criar uma API para esconder os dados, para depois enviar a resposta em formato json, para algum básico como isso não vale a pena, mas para algum mais delicado como chave de API é mais indicado.
Encontrei essa resposta aqui no stackOverflow: https://pt.stackoverflow.com/questions/477756/como-esconder-a-chave-de-uma-api-antes-de-colocar-o-projeto-no-github#:~:text=Para%20garantir%20que%20ningu%C3%A9m%20ver%C3%A1,poss%C3%ADvel%20hospedar%20um%20servidor%20backend.
Tem também esse vídeo do facebook da rocketSeat falando sobre: https://www.facebook.com/rocketseat/videos/vai-consumir-outra-api-e-precisa-esconder-a-chave-de-acesso-o-codedrops45-tem-um/473894586882837/
Vídeo que ele fala (CodeDrops #45): https://www.youtube.com/watch?v=vYlz3SmNXQQ
edit: acabei trazendo a pergunta de uma forma um tanto difícil de entender onde queria chegar, já que a ideia era trabalhar com dados sensíveis mas não falei na pergunta, então peço desculpas pela forma em que foi escrita

Usar dotevn no JavaScript


Couldn't read source object ACLs. Source bucket must not have storage.uniformBucketLevelAccess enabled and the service account must have storage.ob

Question: Attempting to manually test creating an exact backup for a GCS bucket via Data Transfer Service in the GCP browser UI and getting error...

Couldn't read source object ACLs. Source bucket must not have storage.uniformBucketLevelAccess enabled and the service account must have storage.objects.getIAMPolicy on the source object.

Yet, my source bucket does not have uniform Access Control and I do have storage.objects.getIAMPolicy permissions on the project. I'm not very experienced with GCP, so IDK what else could be going wrong here.
Does anyone have any thoughts on what could be going wrong here or any debugging things to try?
My DTS job configs look like this:

My source bucket configs look like...

My destination bucket configs look like...

And my user IAM permissions look like...

(IDK why there are no "excess permissions" added for my Storage Object Admin role (I think has something do do with this), but storage.objects.getIamPolicy was indeed part of the permissions diff list when I set that role.)
Tried looking at the docs here (https://cloud.google.com/storage-transfer/docs/source-cloud-storage#user_permissions), but IDK that these docs are accurate / up to date.

If you're using the Google Cloud console to create your transfer, and have the permissions listed in User permissions.

Looking at the User Permissions section...

The Storage Legacy Bucket Owner role (roles/storage.legacyBucketOwner) or the Storage Admin role (roles/storage.admin) provide the required permissions.

My personal user already has the Storage Admin role (the Storage Legacy Bucket role appear to not exist when I attempt to edit my user permissions) -- there is a Storage Transfer Admin role, but the policy change simulator shows this would not add any new permissions.
Following the instructions re. granting the required permissions to the service agent here to ID the DTS service agent principal email (https://cloud.google.com/storage-transfer/docs/source-cloud-storage#find), I followed along and found that the service agent principal was already added to the DTS source bucket with Storage Legacy Bucket Reader and Storage Object Viewer roles. So, unfortunately, it appears there was no issue with the automatic granting yet the DTS job does not work.
(And there is nothing in the Logs Explorer re. that bucket or GCS other than the logged actions of me creating it -- ie. as if it's not even registering the failed DTS job runs I manually triggered).
Does anyone have any thoughts on what could be going wrong here or any debugging things to try?
Answer: Got it working.
Google has extensive usage of Service Agents: https://cloud.google.com/iam/docs/service-agents
I was informed that something may have gone wrong with the automatic grant creation: https://cloud.google.com/storage-transfer/docs/source-cloud-storage#auto-granting_permissions_in_the
This is how I configured everything to get the DTS job working:
Source bucket Permissions configs for the STS agent (whoes full email/name I ID'ed by following the instructions here):

(The instructions on exactly which perms to grant the STS agent for a bucket are not clear, but I chose the ones that made sense for a bucket that is being considered the "source" bucket and that seemed to work).
Destination bucket Permissions configs for the STS service agent:

(The instructions on exactly which perms to grant the STS service agent for a bucket are not clear, but I chose the ones that made sense for a bucket that is being considered the "destination" bucket and that seemed to work). EDIT*: that first permission for the destination bucket should actually be Storage Legacy Bucket Writer, but it doesn't really matter in this basic solution because of the Storage Object Admin permission that I have (which I explain later).
Note that the storage.objects.getIAMPolicy permission is granted by the Storage Object Admin role; I also could have created a custom role that just included this specific permission, rather than give the STS agent that broader pre-existing role, but IDK that it is a big deal (though, for the sake of minimizing unneeded access, perhaps I should still do this (as having the admin role actually makes the other roles redundant, as confirmed by the Policy Test change simulation)).
This role is required, even though not specified in the instructions here because I guess it assumes you are using the Uniform ACL policy, but the source bucket I'm testing with (like the one I actually want to do the DTS from) uses Fine-Grained ACLs, this is why I think the storage.objects.getIAMPolicy perm is required to run the STS without error.
Note that this also means that when you are doing the DTS to the destination bucket, you have to also have the ACL settings be set to Fine-Grained for that as well.


image flowing to next line instead of shrinking in a flexbox two-column layout

Question: I have a two columns layout with flexbox. In the second column there is an image with the property width=100% and min-width=100px. I want it to shrink until it reaches the min-width and then flow to next line. But it doesn't. It only shrinks to the native image width and then it flows to the next line, and only after flowing it starts shrinking again. How I can get it to shrink without flowing to the next line?
You can see my page here: https://codepen.io/davjdek/pen/WMKbrY

.container {
  display: -webkit-flex;
  /* Safari */
  -webkit-flex-wrap: wrap;
  /* Safari 6.1+ */
  display: flex;
  flex-wrap: wrap;
}

h1 {
  font-size: 2em;
}

h1,
h3 {
  margin-top: 0;
  margin-bottom: 10px;
}

.containwrap {
  flex-grow: 1;
  margin-right: 50px;
}

#container1 {
  margin-left: auto;
  height: 120px;
}

#endtitleline {
  height: 4px;
  background-color: #aaa;
  border: 0;
  width: 100%
}

#pagetitle {
  margin-left: auto;
}

#name,
#subtitle {
  text-align: right;
}

.header {
  margin-top: 25px;
  display: -webkit-flex;
  /* Safari */
  -webkit-flex-wrap: wrap;
  /* Safari 6.1+ */
  display: flex;
  flex-wrap: wrap;
}

#pagetitle {
  font-family: 'Raleway', arial, sans-serif;
}

.sidebar {
  margin-top: 100px;
  margin-left: 25px;
  margin-right: 20px;
  width: 80px;
  height: 300px;
  background-color: red;
}

.central-img {
  width: 100%;
  min-width: 100px;
}
<link href="https://fonts.googleapis.com/css?family=Raleway" rel="stylesheet" />

          PORTFOLIO

          FLEXBOX LAYOUT

Answer: The img is forcing the width of the .containwrap element. Might be able to add width: 0; max-width: 100%; to .containwrap so it collapses to a width narrower than the image's actual width.
Here's the Codepen so you can try the responsiveness.

.container {
  display: -webkit-flex;
  /* Safari */
  -webkit-flex-wrap: wrap;
  /* Safari 6.1+ */
  display: flex;
  flex-wrap: wrap;
}

h1 {
  font-size: 2em;
}

h1,
h3 {
  margin-top: 0;
  margin-bottom: 10px;
}

.containwrap {
  flex-grow: 1;
  margin-right: 50px;
  width: 0;
  max-width: 100%;
}

#container1 {
  margin-left: auto;
  height: 120px;
}

#endtitleline {
  height: 4px;
  background-color: #aaa;
  border: 0;
  width: 100%
}

#pagetitle {
  margin-left: auto;
}

#name,
#subtitle {
  text-align: right;
}

.header {
  margin-top: 25px;
  display: -webkit-flex;
  /* Safari */
  -webkit-flex-wrap: wrap;
  /* Safari 6.1+ */
  display: flex;
  flex-wrap: wrap;
}

#pagetitle {
  font-family: 'Raleway', arial, sans-serif;
}

.sidebar {
  margin-top: 100px;
  margin-left: 25px;
  margin-right: 20px;
  width: 80px;
  height: 300px;
  background-color: red;
}

.central-img {
  width: 100%;
  display: inline-block;
  min-width: 100px;
}
<link href="https://fonts.googleapis.com/css?family=Raleway" rel="stylesheet" />

          PORTFOLIO

          FLEXBOX LAYOUT

Comment: It works, thank you! But I can't actually understand what happens. Can you explain in other words?
Answer: Add this code and see if it works
.containwrap {
    width: 10%;
}

i was able to get it to work i downloaded your codepen and this bit of code works
Comment: It works, but I can't understand the reason. Thank you!
Comment: its probably because if i bring down the width of the container than it gives it more space not really sure though


How do I interpret lagsarlm output from R's spdep?

Question: I've run lagsarlm on my dataset, using a mixed model and using a row-standardized adjacency matrix. I have results that I think are good, but would am not sure how to interpret them.

Does the p-value of 0.12 on rho mean I cannot count on spatial autocorrelation of the response?
Does the low p-value for the LM test mean that the error term is not spatially correlated to the response?
What about the various p-values of the coefficients: Should I remove predictors that have high p-values and run it again?

.
> summary(lm.lag)

Call:lagsarlm(formula = Y.scaled ~ Narcotics.Crime.Rate + Assault..Homicide. +
    Infant.Mortality.Rate + Below.Poverty.Level + Per.Capita.Income,
    data = X.scaled, listw = W.mat, type = "mixed")

Residuals:
     Min       1Q   Median       3Q      Max
-0.96641 -0.33183 -0.13579  0.15113  3.00270

Type: mixed
Coefficients: (asymptotic standard errors)
                           Estimate Std. Error z value  Pr(>|z|)
(Intercept)                0.007063   0.069365  0.1018 0.9188960
Narcotics.Crime.Rate       0.465759   0.176160  2.6439 0.0081945
Assault..Homicide.         0.202034   0.156141  1.2939 0.1956925
Infant.Mortality.Rate      0.121582   0.130806  0.9295 0.3526420
Below.Poverty.Level        0.051494   0.129330  0.3982 0.6905098
Per.Capita.Income         -0.119833   0.171509 -0.6987 0.4847382
lag.Narcotics.Crime.Rate  -0.673492   0.284876 -2.3642 0.0180710
lag.Assault..Homicide.     0.366021   0.295266  1.2396 0.2151117
lag.Infant.Mortality.Rate  0.010755   0.240319  0.0448 0.9643038
lag.Below.Poverty.Level    0.232895   0.202924  1.1477 0.2510930
lag.Per.Capita.Income      0.885463   0.256441  3.4529 0.0005546

Rho: 0.26724, LR test value: 2.3413, p-value: 0.12598
Asymptotic standard error: 0.14187
    z-value: 1.8838, p-value: 0.059597
Wald statistic: 3.5486, p-value: 0.059597

Log likelihood: -70.92512 for mixed model
ML residual variance (sigma squared): 0.36337, (sigma: 0.6028)
Number of observations: 77
Number of parameters estimated: 13
AIC: 167.85, (AIC for lm: 168.19)
LM test for residual autocorrelation
test value: 14.516, p-value: 0.00013896

Comment: There is a detailed explanation at the end of this tutorial https://rpubs.com/corey_sparks/109650
Answer:
Your Rho is your spatial autoregressive parameter, and it is not
significant. Your likelihood ratio basically tells you that the
inclusion of the lagged values do not improve your model.
You LM test, a.k.a Lagrange Multiplier test for the absence of
spatial autocorrelation in the lag model residuals, is small so
you reject the Hypothesis Null of No Spatial Autocorrelation.
The simpler the model, the better.

Hope this helps!
Comment: The likelihood is a ratio of probabilities. The inclusion of more variables (lagged or not) increase you degrees of freedom, and may have an impact on your R^2.
Comment: How can one tell when the likelihood ratio indicates that the inclusion of the lagged values do improve the model? Is there a threshold value?


Basis for the null space of the vectorized identity matrix

Question: Let $\mathbf{I}_N$ be the $N \times N$ identity matrix. Let us define the $1 \times N^2$ matrix $\mathbf{A}$ as:
\begin{equation}
\mathbf{A} = \mathrm{vec}(\mathbf{I}_N)^T
\end{equation}
where $\mathrm{vec}$ is the column-wise vectorization operator.
Which is an orthonormal basis for the null space of $\mathbf{A}$?
Comment: A basis (orthonormal or not) for a matrix...? What is that?
Comment: Sorry, there was a typo. I forgot to write "for the null space of"
Comment: Ok...and now explain what is that "column-wise vectorization operator". I'm guessing is some kind of rolling out the $\;n\times n\;$ matrix into an (1\times n^2\;$ vector , but how **exactly**?
Comment: @DonAntonio Yes, it stacks the columns of the identity matrix one after the other to get a column vector of dimension $N^2 \times 1$. Consequently, its transposed version (the matrix $\mathbf{A}$) is a $1 \times N^2$ row vector.
Answer: So if I understood what you meant, we're talking about the matrix
$$A=\left(\,1,\overbrace{0,...,0}^{n-1\,\text{places}},0,1,\overbrace{0,...,0,0}^{n-2\;\text{places}},0,0,1,0,...,1\,\right)$$
and you thus want an orthonormal basis for the solution space of the homogeneous linear system of equation determined by that matrix, i.e. for the solution space of
$$x_1+x_{n+2}+x_{2n+3}+\ldots+x_{n^2}=0$$
This homogeneous system of one equation in $\;n^2\;$ unknowns have $\;n^2-n\;$ variables equal to zero:
$$x_2=x_3=\ldots=x_{n+1}=x_{n+3}=\ldots=x_{n^2-1}=0$$
and the general solution is given by the hyperplane of dimension $\;n-1\;$
$$M:=\left\{(x_1,...,x_{n^2})^t\in\Bbb F^{n^2}\;|\;x_1+x_{n+2}+\ldots+x_{n^2}=0\,,\,\,x_k=0\,,\,\,k\neq1, n+2, 2n+3,...,n^2\right\}\;$$
A basis for that, as we know from general hyperplanes(=kernels of linear functionals) is
$$\left\{\,(v_1, v_2,..., v_{n-1})\,\right\}\,,\,\,\text{with}\;v_1=\left(\,1,\overbrace{0,...,0}^{n-0\,\text{places}},0,0,\overbrace{0,...,0,0}^{n-2\;\text{places}},0,0,0,0,...,-1\,\right)$$
$$v_2=\left(\,0,\overbrace{0,...,0}^{n-1\,\text{places}},0,1,\overbrace{0,...,0}^{n-2\;\text{places}},0,...,-1\,\right)\,,\ldots,v_{n_1}=\left(\,0,\overbrace{0,...,0}^{n-1\,\text{places}},0,\overbrace{0,...,0}^{n-2\;\text{places}},0,1,0,...,-1\,\right)$$
If you "erase" (in your imagination) all the zeros, these are simply the $\;n-1\;$ vectors
$$(1,0,...,0,-1), (0,1,0,...,0,-1)\,...,(0,...,0,1,-1)$$
Well, now just apply Gram-Schmidt to this base and we shall be done.
Comment: Thanks! Yes, I was wondering if it would be possible to express this basis in a compact "matrix form"... I'll work on it!


How can I test the quality of a RNG?

Question: On electronics.stackexchange we had a question about constructing a True Random Number Generator. Since the method relies on noise, which isn't deterministic, the only way to test the quality of the RNG seems to be empirical.
Not being a statistician I suggested to test a long bit sequence for normality, but I have no idea what outcome is acceptable and what isn't. For instance counting single bits I guess we have a thumbs-up for a 499500/500500 distribution, but when is the ratio too much skewed to be acceptable? Same for 2-bit and longer sequences.
Of course, if testing for normality is a Bad Idea™, I'd like to hear it, including better alternatives.
edit
Diehard was mentioned a few times, but I'm not sure this answers my question. The normality test should give a normal distribution, with better bell curve approximations for longer sequences. Diehard seems also to have tests which either should result in normal or exponential distributions. But my question remains: how do I judge the results? Just by looking at the curve and discern a bell curve in it? To get back at my first example, a 499500/500500 distribution is definitely OK, and a 950000/50000 distribution definitely is a no-no, so where does the switch-over happen?
Comment: Have you seen [Diehard](http://www.stat.fsu.edu/pub/diehard/)?
Comment: The TestU01 suite (http://simul.iro.umontreal.ca/testu01/tu01.html) , mentioned in a comment below, is still considered one of the state of the art test suites.  PractRand (https://sourceforge.net/projects/pracrand/) is another.  https://www.pcg-random.org/ is a helpful source for information on RNG quality and different algorithms.
Comment: If I recall correctly, Volume 2 of the Art of Computer Programming has a lot on this subject, though it may be out of date.
Comment: My understanding is that [Dieharder](http://webhome.phy.duke.edu/~rgb/General/dieharder.php) and [TestU01](http://simul.iro.umontreal.ca/testu01/tu01.html) are suites of tests to see whether an RNG is reasonable as a stand-in for a *uniformly* distributed source.  If one is starting from data that's supposed to be normal, maybe it would make sense to apply a transformation that would take normally distributed data and generate uniformly distributed data, and then apply one of the test suites?
Comment: There are books by [Kneusel](https://www.amazon.com/Random-Numbers-Computers-Ronald-Kneusel/dp/3319776967/ref=sr_1_1?keywords=random+numbers+and+computers&qid=1557632098&s=books&sr=1-1) and [Johnston](https://www.amazon.com/gp/product/1501515136/ref=ppx_yo_dt_b_asin_title_o05_s00?ie=UTF8&psc=1) that are very recent and include a lot of information that was unavailable at the time of the 3rd ed of TAOCP chapter 3, volume 2, but much of TAOCP is still relevant, and there is depth to the explanations in TAOCP that's unsurprisingly lacking in parts of the recent books. I've found all three useful.
Comment: Yeah (+1 to @jbowman), I somehow think this is a "mostly  solved" problem to really update anything significant in a decade. After a point we venture to a cryptographic strength point of view which in itself is an ongoing assessment rather than a one-time test. We can look to concepts like entropy too (e.g. look at the test suite [ENT](https://www.fourmilab.ch/random/)) but those aren't qualitative changing our findings from DieHarder for example.
Comment: I set up a bounty to incentivize an update on answers, [as per this meta question](https://stats.meta.stackexchange.com/q/3116/1352).
Answer: J.M. already mentioned the original Diehard battery of tests by George Marsaglia.  As far as I know, this test set is no longer being maintained.
Robert Brown has been working for years on DieHarder which is

a GPL'ed reimplementation of the DieHard suite
plus additional tests from the NIST suite
plus development of new tests

and you may find DieHarder useful.
Comment: [TestU01](http://simul.iro.umontreal.ca/testu01/tu01.html) is also worth considering.
Answer: You're right: testing is empirical.  It's all done in a standard hypothesis testing framework.  Different tests are applied to assess different alternative behaviors of RNGs.  As always, the user is free to choose the level of confidence with which each test is conducted.  This level determines the critical region of each test, which is the "switch over" between a "significant" result and one not considered significant.
In practice, the confidence level matters little, because most RNGs can generate such a long series of values that eventually any long-run departure from complete, independent, equidistributed randomness will be detectable with high confidence.  (This is the main reason that proper application of test suites like DieHard require you to generate a large number of bits at a minimum.  I recollect--it has been a while--that early versions demanded 80 million bits.)  Typically, an RNG will pass many tests thrown at it (otherwise it would never have seen the light of day) but it will clearly blow a few of them.

How can I test the quality of a RNG?


Leitura de PDF em R

Question: Estou efetuando um trabalho para a faculdade e gostaria obter a renda e o público de cada jogo do campeonato brasileiro dos últimos anos. A CBF diponibiliza em uma série de links, um exemplo é o Borderô. Para outros problemas parecidos eu uso o pacote tabulizer, como no código abaixo
library(tabulizer)
url <- 'https://conteudo.cbf.com.br/sumulas/2014/1421b.pdf'
d <- extract_tables(url, encoding = "UTF-8")

Para tabelas criadas em PDF ele funciona perfeitamente, mas para este tipo de pdf (que provavelmente foi impresso, escaneado e depois salvo em pdf) não funciona, o código retorna uma lista com 0 elementos. Alguma ideia ou pacote que eu possa utilizar?
Comment: `@Flavio Silva` nesse caso o problem não é extrair dados de um pdf, mas extrair dados da imagem. Veja que não há qualquer estrutura neste pdf, só a imagem. Você precisa de algum programa que extraia textos de imagens.
Answer: A tabela que consta no PDF, trata-se de uma imagem. Esse pacote do R busca por elementos textuais, ele retorna uma lista vazia justamente por isso, porque não há texto no arquivo. Você necessita de técnicas que façam reconhecimento de texto em imagem, eu sugiro que você busque por OCR, que é um processo que extrai texto de uma dada imagem.
No R, há o pacote tesseract, o qual realiza esse operação.
Segue o link de um tutorial do pacote Tesseract do R, que faz a extração de texto de imagem.
https://cran.r-project.org/web/packages/tesseract/vignettes/intro.html
Nesta parte do tutorial ele mostra como extrair de um PDF
https://cran.r-project.org/web/packages/tesseract/vignettes/intro.html#read_from_pdf_files
Comment: Lerei, muito obrigado pela resposta!

Leitura de PDF em R


Congruence modulo $n$ problem

Question: Let $ab\equiv cd\pmod{n}, a\equiv c\pmod{n}, (a,c)=1$. Show that $b\equiv d\pmod{n}$.
I have to somehow arrive at $n\mid (d-b)$.
I have $n\mid (cd-ab), n\mid (c-a)$ at my disposal and perhaps the fact that $a,c$ have no common factor.
$$n\mid (cd-ab)\land n\mid (c-a)\Longrightarrow n\mid a(d-b)$$
which is almost what I want. I just don't see how $(a,c)=1$ comes into play here. $(a,n)=1$ would make more sense (Euclid's lemma) or am I missing something?
Answer: If $\color{blue}{n|a}$, then $\color{red}{a\equiv c \pmod n \Rightarrow n|c}$.
So $n$ is a common factor of $a$ and $c$.
But it is given that $\color{brown}{gcd(a,c)=1}$.
Hence, contradiction $\Rightarrow \color{violet}{n \not | \, \,a}$.
Hope this helps you.
Answer: As you said the deduction we need is $(a,n)=1$. What we know is $a\equiv c\pmod n$ (which implies $a=c+nk$ for some $k$) and $(a,c)=1$. Now let $d=(a,n)$. Then $d\mid a-nk$, so $d\mid c$. Since $(a,c)=1$, we get $d=1$. We can also get $(c,n)=1$, thus $a$ and $c$ are invertible modulo $n$.

Congruence modulo $n$ problem


Cross Browser Issue

Question: My background is in WinForms programming and I'm trying to branch out a bit.  I'm finding cross-browser issues a frustrating barrier in general, but have a specific one that I just can't seem to work through.
I want to display an image and place a semi-transparent bar across the top and bottom.  This isn't my ultimate goal, of course, but it demonstrates the problem I'm having in a relatively short, self-contained, code fragment so let's go with it.
The sample code below displays as intended in Chrome, Safari, and Firefox.  In IE8, the bar at the bottom doesn't appear at all.  I've researched it for hours but just can't seem to come up with the solution.
I'm sure this is some dumb rookie mistake, but gotta start somewhere.  Code snippet...
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<title></title>

Answer: You are self-closing a div tag, which is not allowed to be self-closed.
You must close the div tag like this:
.
Some browsers will support stupid mistakes like these, and attempt to close the tags for you. IE, on the other hand, doesn't.
Try this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<title></title>

Comment: I've noticed IE dropping tags simply because it doesn't like how they're written in the code. Good eye.
Comment: Yeah, for a list of self-closing tags check out http://stackoverflow.com/questions/97522/what-are-all-the-valid-self-closing-tags-in-xhtml-as-implemented-by-the-major-br

Firefox and Webkit (Safari, Chrome) are smart enough to close those tags for you, which is why it worked in those browsers.
Comment: Rather, validate -for- the standards, since the validator is ideally a "multiple-browser-standards-check-in-a-can".
Comment: Just because you can rely on the browser to clean up your markup it doesn't  mean you should do it. Stick with the standards.
Comment: I knew it would be something stupid.  Nevertheless, your answer led me down an interesting path that ended with a better understanding of loose vs. strict doctypes and finding the w3c validator page which, had I known about it last night, would have identified this issue for me.  Thanks for all the comments, they were very helpful.

Cross Browser Issue


Nuget Class Libraries vs Local Class Libraries

Question: I have setup our internal class libraries to be built in VSTS and to create nuget package hosted in our VSTS upon each successful build.
Our application then references those class libraries by downloading the nuget package off of our own VSTS url.
If we want to make changes to our class library we modify the solution, increment the assembly number, rebuild it online and a new nuget package will replace the existing one.  Then update our application with the latest package.
Now because the class library is referenced through nuget in the application, what would be the best strategy to test changes made to the class library at the application level?

Should I remove the nuget package, reference the library locally then test, then re-add nuget reference?
Should I just create a new package each time and come up with an internal policy with other developers when it comes to managing assembly version numbers to only use specific assembly versions?
Answer: I'd go with option 2 - generate a pre-release nuget package.

"A pre-release version MAY be denoted by appending a hyphen and a
  series of dot separated identifiers immediately following the patch
  version" (http://semver.org/spec/v2.0.0.html)
Comment: By doing this I won't be able to debug the class library though right?
Comment: You can include symbols in your nuget package to help debugging.


Subrings of $\Bbb Z_p$

Question: Let $\Bbb Z_p$ be the ring of p-adic integers.
Then, I can list some subrings of $\Bbb Z_p$, like $\Bbb Z$, and... localization of $\Bbb Z$ at $(p^n)$ for some nonnegative integer $n$.
So I can say the number of subrings of $\Bbb Z_p$ is infinite, but I cannot concretely describe all of them.
Are there any known results?
I would be appreciated if you help me describing all of subrings of $\Bbb Z_p$. Thank you.
Comment: You could and maybe should have mentioned that you asked a strongly related question shortly before: https://math.stackexchange.com/q/3587674/96384. Note that the answers to both questions rely on the very same principles.
Answer: There are infinitely many subrings of $\mathbb Z_p$ of the form $\mathbb Z[\alpha]$ for $\alpha$ algebraic over $\mathbb Q$, of any degrees you like, via Hensel's lemma. For example, for $p=1\mod 4$, there is $\alpha\in\mathbb Z_p$ such that $\alpha^2=-1$. Generally, for an algebraic extension $\mathbb Q(\alpha)$ (with $\alpha$ integral over $\mathbb Z$) in which $p$ splits completely, $\mathbb Z_p$ contains a copy of the algebraic integers of the extension.
Also, on cardinality considerations, there are uncountably many $\alpha\in\mathbb Z_p$ that are transcendental over $\mathbb Q$.
I doubt that all subrings are classifiable...

Subrings of $\Bbb Z_p$


what do musicians do if they want to take a vacation?

Question: let's say you wanted to take a 3 month vacation
How would you 'keep practicing?'
I mean you don't just forget everything but won't you feel like 'ugh' once you get back on your instrument?
Comment: See: http://music.stackexchange.com/questions/4151/what-instruments-are-inexpensive-portable-and-not-too-loud
Answer: It's going to depend a lot on the destination. A violinist or guitarist wouldn't want to take their instrument into the jungle for even a few days. And the pianist...
If possible they would find somewhere to play. I used to go to the Canaries a lot, and found some nice schools of music - with instruments, of course. Went to Russia years ago, ended up buying a guitar to keep practising.
A lot of musos have at least one other instrument to play. Often, I'll put a clarinet or flute into the suitcase, small enough, and quiet enough to use almost anywhere.
Depending on the destination, (and genre!) there may well be a band, orchestra or open mic venue that could be explored even before the sojourn takes place.
You're right - an edge is usually lost with that sort of time away - trumpeter's lip, fluidity, reading, chords not so frequently played on guitar, but it soon (hopefully) comes back. But most musos would want to have their dose of music at a frequent level.
And let's not forget, he'll have his music to listen to, and maybe some dots to follow on the Ipad.
Comment: Second this, if I went on a long vacation I'd have harmonicas and a flute in my luggage, and my budget would certainly include a cheap nylon string in local currency which I'd sell or give away before leaving.  Not just to stay sharp, but because 3 months without instruments doesn't sound like much of a holiday to me!
Comment: also I know a fiddler who has a decent enough Chinese "travel fiddle" which she takes with her to gigs in more precarious locations.  I have a nice second hand student flute I use for jazz gigs where I know I'm likely to have a couple of drinks and probably leave it on a table somewhere at some point.  Obviously I wouldn't be pleased if something happened to it, but it would be a lot less of a night ruiner than if something happened to my main instrument.
Answer: Most musicians take a small instrument with them when on holiday, but even if you don't, you still have your voice. As long as you have a way to record or transcribe then you can still practice and learn.
I often find that a few days away from my main instrument really helps me change my improvisation structure, so I like to listen to a lot of different music on holiday. That stuff I don't usually hear makes its way into my head and when I return it comes out in my playing.
Answer: If you're a serious professional musician you just DON'T take a day off practicing, let alone a month.   If your standards (or those of your employer) are lower, you just cope.  Yes, your playing will drop.  Yes, it will come back.
Comment: @Aminopterin  you're starting to get the idea...
Comment: It sounds just hard to make music for living.... sounds as hard as an athlete.
Comment: Actually, there are plenty of niches for a professional musician that don't involve virtuoso-level performance. Just be at a level where what is required isn't hard FOR YOU.
Comment: not all musicians are strictly musicians by career. Some do it next to their main career.
Answer: The answer to this also depends on how bad you want it. If you simply play as a hobby, it may be good to take a hiatus to return with fresh creative inspiration and yearning to play.
For the die-hard, there's so many options with modern technology. For the pianist:

Funny story: my mentor, in the days before the technology pictured above, made this little board with a 2 octave run of piano keys. He had ingeniously carved the board and attached the keys in a way that perfectly mimicked a piano's action. Of course, it didn't produce sound... But, he constructed it for the explicit purpose of being able to practice fingering while on vacation/holiday. He'd continue to use it after that - even driving down the road. :P
Yo-Yo Ma buys an extra plane ticket for his cello when he flies.
A professional will sometimes ship their instruments to the destination, when they can't be carried. One can almost certainly line up a gig or two in order to cover any transit costs (playing music is never 'work' for some of us.)
I have basses in the homes of select friends and family for when I visit, so I don't have to carry around my main squeeze...
Or purchase something inexpensive at the destination, as Tim says.
Comment: oh, I didn't know this even existed, that's so cool
Answer: I'm not a pro but I have a cheap guitar and mini practice amp and headphones that I take with me, as well as a portable digital piano with a decent feel. I do spend two weeks away from my main gear every year but again, I'm not a pro. Also those two weeks I spend at the beach but at a rental cottage that has air conditioning so it's ok for wood and electronics.


Add a sheet counter in a cell

Question: i have a excel file with a lot of sheets. i want to make a sheet counter to put in a specific cell of each one of those sheets "sheet x of Y"
for example, if you are on the sheet 3 of 5, in the cell "X5" must to say "sheet 2" and in the cell "X6" say "of 5"
each sheet have a button to add other sheet, so the sheet counter must be update every time you add a sheet
i tried this code but doesn't work, it only puts "0" in the first sheet
Public Sub CountWorkSheets()
If Application.Sheets.Count = 2 Then
Sheets(1).Range("X5").Value = 1 And Sheets(2).Range("X5").Value = 2
End If
End Sub

Answer: I suggest go to ThisWorkbook and hook into the NewSheet event

Private Sub Workbook_NewSheet(ByVal Sh As Object)
    Call AddSheetCounters
End Sub

Public Sub AddSheetCounters()
    Dim i As Long, n As Long

    n = Me.Sheets.Count

    For i = 1 To n
        Me.Sheets(i).Range("X5").Value = "Sheet " & i
        Me.Sheets(i).Range("X6").Value = "of " & n
    Next i

End Sub

Edit the text for ranges X5 and X6 as you need. Every time a new sheet is added the macro is run. Unfortunately when a sheet is deleted, it won't and things will get out of sync.

Add a sheet counter in a cell


Shiny App works locally, disconnected from server when deployed globally

Question: I have a Shiny app that works fine when I run it on my own computer, but fails to deploy properly via shinyapps. Every time I deploy the app it turns grey and says 'Disconnected from server'. Here is the output from showLogs(), but I'm a bit confused as to how to interpret it. I don't know why it is having trouble installing some packages. Any help is appreciated, thanks!
<code>2016-07-29T21:02:49.317725+00:00 shinyapps[115742]:      9: tryCatchList
2016-07-29T21:02:49.317725+00:00 shinyapps[115742]:      8: tryCatch
2016-07-29T21:02:49.317726+00:00 shinyapps[115742]:      7: connect$retry
2016-07-29T21:02:49.317726+00:00 shinyapps[115742]:      6: eval
2016-07-29T21:02:49.317729+00:00 shinyapps[115742]:      3: eval
2016-07-29T21:02:49.317729+00:00 shinyapps[115742]:      2: eval.parent
2016-07-29T21:02:49.317729+00:00 shinyapps[115742]:      1: local
2016-07-29T21:02:49.317912+00:00 shinyapps[115742]: Error in install.packages(pkgs = x, repos = "http://cran.r-project.org") :
2016-07-29T21:02:49.317914+00:00 shinyapps[115742]:   unable to install packages
2016-07-29T21:02:49.317727+00:00 shinyapps[115742]:      5: eval
2016-07-29T21:02:49.317727+00:00 shinyapps[115742]:      4: eval
2016-08-01T14:50:49.315087+00:00 shinyapps[115742]: Server version: 0.4.5.2170
2016-08-01T14:50:49.470258+00:00 shinyapps[115742]: Starting R with process ID: '17'
2016-08-01T14:50:49.315120+00:00 shinyapps[115742]: R version: 3.3.0
2016-08-01T14:50:49.486190+00:00 shinyapps[115742]:
2016-08-01T14:50:49.315122+00:00 shinyapps[115742]: shiny version: 0.13.2
2016-08-01T14:50:49.486192+00:00 shinyapps[115742]: Listening on http://0.0.0.0:38250
2016-08-01T14:50:49.315126+00:00 shinyapps[115742]: rmarkdown version: NA
2016-08-01T14:50:49.315138+00:00 shinyapps[115742]: knitr version: NA
2016-08-01T14:50:49.315173+00:00 shinyapps[115742]: jsonlite version: 1.0
2016-08-01T14:50:49.315206+00:00 shinyapps[115742]: RJSONIO version: NA
2016-08-01T14:50:49.315226+00:00 shinyapps[115742]: htmltools version: 0.3.5
2016-08-01T14:50:49.464757+00:00 shinyapps[115742]: Using jsonlite for JSON processing
2016-08-01T14:50:49.470256+00:00 shinyapps[115742]:
2016-08-01T14:50:52.097553+00:00 shinyapps[115742]: Loading required package: twitteR
2016-08-01T14:50:52.107937+00:00 shinyapps[115742]:     50: PrepareTwitter [/srv/connect/apps/Other-app/server.R#14]
2016-08-01T14:50:52.108128+00:00 shinyapps[115742]:   unable to install packages
2016-08-01T14:50:52.098304+00:00 shinyapps[115742]: Warning in library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE,  :
2016-08-01T14:50:52.107937+00:00 shinyapps[115742]:     51: EnsurePackage [/srv/connect/apps/Other-app/server.R#6]
2016-08-01T14:50:52.107942+00:00 shinyapps[115742]:      4: eval
2016-08-01T14:50:52.098305+00:00 shinyapps[115742]:   there is no package called 'twitteR'
2016-08-01T14:50:52.107936+00:00 shinyapps[115742]:     52: install.packages
2016-08-01T14:50:52.107942+00:00 shinyapps[115742]:      3: eval
2016-08-01T14:50:52.100256+00:00 shinyapps[115742]: Installing package into '/usr/local/lib/R/site-library'
2016-08-01T14:50:52.107940+00:00 shinyapps[115742]:      7: connect$retry
2016-08-01T14:50:52.107942+00:00 shinyapps[115742]:      2: eval.parent
2016-08-01T14:50:52.100257+00:00 shinyapps[115742]: (as 'lib' is unspecified)
2016-08-01T14:50:52.107935+00:00 shinyapps[115742]: Stack trace (innermost first):
2016-08-01T14:50:52.107941+00:00 shinyapps[115742]:      5: eval
2016-08-01T14:50:52.100629+00:00 shinyapps[115742]: Warning in install.packages(pkgs = x, repos = "http://cran.r-project.org") :
2016-08-01T14:50:52.107938+00:00 shinyapps[115742]:     13: runApp
2016-08-01T14:50:52.107939+00:00 shinyapps[115742]:     11: doTryCatch
2016-08-01T14:50:52.107943+00:00 shinyapps[115742]:      1: local
2016-08-01T14:50:52.100630+00:00 shinyapps[115742]:   'lib = "/usr/local/lib/R/site-library"' is not writable
2016-08-01T14:50:52.107938+00:00 shinyapps[115742]:     12: fn
2016-08-01T14:50:52.107939+00:00 shinyapps[115742]:     10: tryCatchOne
2016-08-01T14:50:52.108126+00:00 shinyapps[115742]: Error in install.packages(pkgs = x, repos = "http://cran.r-project.org") :
2016-08-01T14:50:52.101513+00:00 shinyapps[115742]: Warning: Error in install.packages: unable to install packages
2016-08-01T14:50:52.107941+00:00 shinyapps[115742]:      6: eval
2016-08-01T14:50:52.107939+00:00 shinyapps[115742]:      9: tryCatchList
2016-08-01T14:50:52.107940+00:00 shinyapps[115742]:      8: tryCatch}
</code>
Comment: Exactly the same problem here.
Answer: Start an R session and install any required packages from your application with install.packages().  Then, stop/stat your shiny server.
Hope it helps.


Content Field Type Image not auto resizing

Question: I am fairly new to Drupal, I am currently working through Tom Geller's excellent video series on Lynda.com. All is going well, except I am having a problem when trying to set display properties for any content types containing an image field. If I keep the display settings for the image field as the original image then it will display. However if I try to set an image style for example to use as a thumbnail for a teaser, the image does not show. In Chromium there is an empty frame of the correct size but the image does not display. In Firefox only an empty space is shown where the image should appear.
I am running my site on a local Apache server which contains multiple sites, and the issue occurs in all the sites. I have the most recent stable versions of Apache, PHP and mySQL. I have come across other threads on various sites where people have had this issue however their fixes have not worked for me. I'm sure its simple fix but its been bugging me for hours!
Thanks in advance,
Jackson
Comment: Have you verified that the images are being created by checking `public://styles` (`/sites/default/files/styles`)?  If the images are not there, then you might have a permissions problem.  Check `/admin/reports/status` for any directory permission errors.
Comment: Thanks @PatrickRyan it was a permissions error. Nothing showed up in the status report but when I checked the permissions of the styles folder through the folder properties dialog the group www-data was set to access only. Changing that to Create and Delete files solved the problem. If you want to add an answer I will accept it. Cheers!
Answer: Verify that the images are being created by checking public://styles - (/sites/default/files/styles) by default.  If you see that the images are not being created then you might have your folder permissions set up incorrectly.  /admin/reports/status might hint at any permissions problems.


Calculate after how many bounces screen saver logo will hit a corners?

Question: I've always wondered if it is possible to calculate the number of bounces until the screen saver logo hit both sides of a tv at the same time? Or if it will hit at all?

Assuming that we know: The logos dimensions, it's starting position, angle of movement and the tv dimensions. Also assuming that after a bounce the ball leaves the wall with the same angle (just like light and mirror).
This is just a curiosity so I can know the limits of mathematics.
Answer: Basic approach. Imagine an infinite grid.  An imaginary ball, corresponding to the real ball on your screen, starts in the unit square.  It starts moving in some direction and continues moving forever in that direction.
When it passes a line of the form $x = j$, where $j$ is an integer, that corresponds to the real ball bouncing off either the left or the right side of the screen.  When it passes a line of the form $y = k$, where $k$ is an integer, that corresponds to the real ball bouncing off either the upper or the lower side of the screen.
The imaginary ball always moves in the same direction, but the real ball, of course, changes direction each time it passes one of these integer lines.
However, the moments at which the imaginary ball encounters a corner of the form $(j, k)$, where $j$ and $k$ are both integers, correspond to those moments when the real ball hits a corner as well.  So the question is, given an initial starting point $(x_0, y_0)$ and a velocity vector $(v_x, v_y)$, if the line
$$
\frac{y-y_0}{v_y} = \frac{x-x_0}{v_x}
$$
has an integer solution.  If so, the displacement between the initial point $(x_0, y_0)$ and the solution point $(j, k)$, along with the component velocities $v_x$ and $v_y$ will tell you how long it takes to get there.
I'll try to add more about this problem when I get more time.
Comment: @Arthur: You're right, although I think that if you shrink the dimensions of the screen by the diameter of the ball (and adjust the initial location of the ball accordingly) it will all work out.
Comment: Note that the imaginary ball has to be a single point. Otherwise, crossing a line takes time, while for the real ball, reflection is instantaneous. You have to make the distance between the lines narrower correspondingly.
Comment: I agree. It's easier to see how to do it when you adjust the original screen to accomodate a point-ball before expanding to the imaginary grid.


Attempt to make Jazz chord progression on 7-Limit tuning

Question: This is a sequel to this question. Refer to it for the just ratio of the tones.
Being septimal, I thought it could be used for Jazz. The chord progression I made is (Based on C):
CM7 - F♯ø7 - FM7 - G, repeated.
Is there a name for this particular chord progression? (Like C - G - Am - F is refered as 'The 4 Chords'?)
Is there any song based on this chord progression?
Comment: @Tim, I think he's referring not to a single specific progression, but how most "4 chord progressions" in popular music are built with the 1-4-5-6m in varying orders. E.g. the popularity of the [50s "Stand By Me" chords you mention](https://en.wikipedia.org/wiki/List_of_songs_containing_the_50s_progression) is certainly rivaled in pop music by [the "Let It Be" chords he mentioned](https://en.wikipedia.org/wiki/List_of_songs_containing_the_I%E2%80%93V%E2%80%93vi%E2%80%93IV_progression). Rhythm changes and ragtime are notable exceptions, but I feel like they're not as represented in modern pop.
Comment: @user45266 - seen it, love it. It speaks volumes about the state of pop music these days. Mind you, back in the '60s, it was either 12 bars or I vi IV V, so who are we to criticise..?
Comment: Not heard of 'the 4 chords' before. I vi IV V is far more often used.
Comment: @Tim look up Axis of Awesome's 4-chord song video. I've run across "the four chords" pretty often (I-V-vi-IV) under that name, or something to the same effect.
Comment: An example of the progression OP mentions: Chorus of "Love on Top" by Beyoncé.
Answer: I'm not aware of a term for that exact progression, but it does remind me a bit of the stomp with that #4o7 used to ascend and the dominant being stressed before it repeats.


Is there any way to create a differential equation from a set of data?

Question: For instance, I have two animal populations that fluctuate over time, in a predator-prey relationship. I collect some data of each of the populations over a course of time. With this data is there any mathematical technique that I could use to derive a differential equation?
Answer: If you assume a particular form for the model you might be able to fit a few parameters to the data. This tends to be rather tricky.  The kind of cycles
that you see in the standard Lotka-Volterra model are very hard to obtain in
controlled experiments, while in natural environments there are many complicating factors (other species, weather fluctuations, etc.).


Techniques for creating melodies

Question: I've posted this question:
Learning to create melodies
I've got a few ideas of techniques towards creating melodies but wanted to ask if there are any specific methods to help get better. I've read: The Complete's Idiot's Guide To Music Composition which explained a lot of details but I still find it difficult to create something 'good', whenever I play on my keyboard, it sounds rubbish. Is it something that comes with ample practice? What can I do to become better?
Comment: Kent Kennan's _Counterpoint_ has a good categorization of various types of melodies. While it doesn't tell you _how_ to write them per say, its lessons help you shape your melodies and phrases.
Answer: In my experience, unfortunately, writing melodies is one of the most "magical" parts of writing music. Some melodies just sound great, some just don't. There are, however, a few things to keep in mind that can help you deliberately write a melody for a particular emotion or style and help you understand why a particular melody sounds good.
Intervallic and Stepwise Motion:
Some melodies have large jumps in-between consecutive notes, and others move up or down consecutive notes in a scale. The former usually sounds more grand, especially with slow rhythms, and the latter, smoother.
Rising and Falling Motion:
Whether the notes in a melody generally get higher, get lower, or stay in the same range can have a big effect on the melody's emotion.
Rhythm:
The melody you pick for a rhythm makes a huge difference. Is it syncopated or straight? Fast or slow? Complex or simple? Does it use distinctive tricks like hemiola or tuplets? What beats does it start and end on?
Instrumentation:
In my experience, the instrument playing a melody makes a big difference. In the EDM track The End, the main melody is played by a number of bold, powerful synths, giving the melody a driving emotion. Then, at the end of the song, a lone acoustic guitar plays the same melody, which suddenly becomes very sad.
Major/Minor Quality:
Of course, whether a melody is written in a major or minor key makes a big difference.
And the list can go on forever: tonal center, articulation, etc. The important thing isn't that every melody can be broken apart like this. Instead, you can pick out a few qualities you know you would like a melody to have based on which emotion you want to portray.
For example, perhaps you need to write the leitmotif for the bad guy. It's probably going to be in a minor key, because he's so evil. Likewise, it might be played in a lower register on an instrument like a bassoon, not on a lighter instrument like a flute. And although the motif will be centered around a particular key, it might use a lot of chromatic, dissonant notes. You can play with all the other attributes of a melody while you try to figure out what you're ultimately going to go with, but starting with a plan like this makes it easier to begin writing a melody.
Answer: Sometimes just singing over a chord progression can do wonders. However a melody that sounds 'good' on vocals may flub on the keyboard (or other instruments).
Try changing the chords under the melody - sometimes its easy to dismiss a decent melody because it wasn't in a very good context (chord substitution is a great way to go here).
Try to identify what the problem is - does it sound to plain/simple/predictable? If so, maybe revisit chord substitution or mess with some rhythmic displacement. For example, lets say I have two measures in the key of C:
|  G  |  C  |
With a quarter note melody
| B C D B | C - - - |
Maybe I would want to throw an extra 'D' note into the second measure
| B C D B | D C - -|
to add a little extra dissonance - the second bar's melody doesn't immediately catch up with the chord change. It waits a beat and adds a little bit of unpredictability. This example is rather simple but it's little things like this that can make or break a melody.
Also, check out your performance of the melody. Are you playing it with emotion? Or, more importantly, are you playing it with dynamics?
Does your melody go anywhere? Is there a conversation implied such as a call and response?
Maybe let your melody hang out on a weird note for a second - something a little unsettling.
Look for motif's (repeating ideas) - a great example of a motif is Mozart's Rondo Alla Turca. It exhibits a rhythmic motive (buh-da-buh-da-BAAH REST buh-da-buh-da-BAAH REST) and then goes on to build on that motive (buh-da-buh-da-buh-da-buh-da-buh-da-buh-da-BAAH REST!). While this is happening there is also a melodic motive that dances around chord tones and jumps up to the next chord tone
(in A minor - B A G# A C REST! D C B C E REST)
This may not be in your genre but take some hints from the man himself!
Finally, and this is probably the biggest because every other 'hint' or 'trick' to writing good melodies comes from this, LISTEN TO GOOD MELODIES and figure out what makes them good. Is there that one note that just gets you going? Does the bridge (or B section or chorus or whatever you want to call it) take the listener to a different place? Is it catchy? If so, why? Does it haunt you (Beethoven's Sonata Pathetique for example)?
OK, FINALLY finally (for real this time) experience is invaluable. Just keep at it and don't try to write the perfect song right here, right now. The more you write and put into your portfolio, the stronger you will be. Go back and revisit earlier works and you might be surprised how much you like them.
Answer: Melody in Songwriting, by Jack Perricone.  It's the first thing I've seen that makes explicit all the things I was (usually) doing unconsciously.
Comment: Is it similar to Michael Miller - Complete idiot's guide to music composition?
Comment: I haven't read that, but reading the descriptions of it on Amazon, I'd say that Perricone is probably more melody-specific and probably goes deeper--that is, where Miller offers brief descriptions of techniques, Perricone talks about each one for a while, gives examples, exercises, etc. But again I haven't read Miller so that's just a guess.
Comment: Will try to get it, from the contents page it seems quite similar to the book I mentioned which dedicates 5 chapters to melody writing. I'm just always looking for more information. Another question I have, is that since this information is something some people unconsciously learn, how would I use it to become a better melody writer specifically? Does practicing other songs help with that?
Comment: I think what'll happen is that you'll start to notice the way melodies you hear (in songs you like, on the radio, as background music) are put together, and you'll start to develop a stronger sense of technique.  And instead of having to sit and say, gee, should I use this technique in this part of the melody I'm writing or that technique, you'll start to be able to say, oh, songs I like tend to use such-and-such a technique in this part of their melodies, so I'll try that.  And so on.  So I think that the more you LISTEN to songs you like, the easier it'll become.
Answer: Two books:
Exercises in Melody-Writing. by Percy Goetschius.
The Study of Counterpoint. by Johann Joseph Fux (translated by Alfred Mann)
Answer: You don't write melodies. You only find them.
In my experience, setting out to logically create music does not work very well. I am a very logical, mathematically-minded person, but I try to write music from the emotional part of my brain. Good music stirs the emotions; creating music should come from the soul!
When I write a song, I play my guitar and  start searching for the melody (or melodies) hidden within. Michelangelo is purported to have said that the sculpture already exists within the stone; the sculptor's job is simply to free it. I feel finding a melody is much the same.
One way you might do that is to record a simple chord progression (3 or 4 chords) and let it play back in an endless loop. Improvise over the top, trying to remember the bits you liked and immediately forgetting what sounded like rubbish. Here, you want to try and turn off the logical part of your brain and instead use the mystical part of your being (whatever your tradition would call it).
One "trick" I want to pass on is the melody sounds good when it moves opposite from the bass line. If the chord progression is heading down, especially with passing notes, try a melody that moves up. It should sound pretty good!
Mostly, though, I would suggest you study the artists that create the melodies that move you. Is it the Beatles? The Beach Boys? Beethoven or Bach?
Never give up. Keep working at your craft! I have found it takes a long time to mature as a songwriter. And remember: it only has to make you happy, no one else.
Good luck!
Answer: I would argue that learning all techniques and modes and theory will not really help you develop melodies.  There are great writers out there that don't even know the names of the notes they are playing.  Sometimes too much information can be crippling.  Having said that I would urge you to do a few things that may help.
The first is to listen more.  Take some time to really immerse yourself in listening to some of your favorite music.  Creativity is not all internal, it is a feed back loop process.  You feeding back to the world (to yourself first) after being stimulated by the external world.
Next, if you know a little about western music theory, sight reading, or have a good ear, start dissecting the music you listen to.  Look for patterns that are repeated.  Sometimes a melody can be one or two notes.  The rhythm is really key to making a distinct melody.  As an example Joy To The World is just the descending major scale!  Do, Ti, La, Sol, Fa, Mi, Ray, Do.  It's the rhythm that makes is a melody.  I like playing that same rhythm in Harmonic minor as a joke.  Like turning a Christmas song into some type of heavy metal satanic anthem.
Third, I would try constructing simple motifs.  These are riffs or licks that can be a few notes.  In Jazz Improv it is often taught as a method of building a musical vocabulary.  This applies to song writing as well.  Try getting a riff you like that is original.  The trick is to learn how to milk the riff to get mileage from it.  This touches upon classical techniques of movement through the I, IV, and V, as well as changing key, and from Major to Minor, and the use of embellishments to modify the riff without completely losing the character.
With this you can start to build longer elaborate melodies with a specific character.
Answer: I will not read all the above comments because they are waaay too long.
Simple solution: learn modes, you will have way more room to write music.
As for rhythm, you could watch Paul Gilbert's tutorial. It is for guitar, but can be applied for piano as well.

Techniques for creating melodies


PWA not visible as a share option

Question: I would like to allow users to share photos to my progressive web application.
I have followed this tutorial to achive it, but my pwa is still not visible as a share option.
Test device I use is android, I belive that my PWA meets all of these conditions because I can successfully download it to my screen.
App itself, and all of it other features work fine when I download it to the screen, but I still can't get it to show as a share option.
manifest.json
<code>{
    "name" : "appname",
    "short_name": "shortname",
    "theme_color": "#333333",
    "background_color": "#333333",
    "description": "app description",
    "start_url": "https://appHomeUrl.co",
    "display": "standalone",
    "icons": [
      {
        "src": "./assets/icons-192.png",
        "type": "image/png",
        "sizes": "192x192"
      },
      {
        "src": "./assets/icons-512.png",
        "type": "image/png",
        "sizes": "512x512"
      }
    ],
    "share_target": {
      "action": "/photos/dosomething/1",
      "method": "POST",
      "enctype": "multipart/form-data",
      "params": {
        "title": "name",
        "text": "description",
        "url": "link",
        "files": [
          {
            "name": "myImage",
            "accept": ["image/jpeg", "image/png"]
          }
        ]
      }
    }
}
</code>
Answer: I managed to get it working, I think that there were 2 problems:

Icons paths
./assets/icons-192.png probably only works on the homepage, I changed it to
/assets/icons-192.png
Downloading the app to the screen at the wrong time
I register my service worker only after login (I should probably change that) so when I downloaded my pwa to the homescreen, I didn't have registered service worker yet so the app didn't meet the requirements to be shown as a share option

PWA not visible as a share option


Solving $tu_t + u_x = x$, $u(t,0) = t^2$

Question: I wish to solve
$$tu_t + u_x = x, \quad u(t,0) = t^2.$$
Using the method of characteristics, I parameterize each variable by $r$ and $s$ to obtain the following system of ODEs:
$$\frac{dt(r,s)}{ds} = t\\
\frac{dx(r,s)}{ds} = 1\\
\frac{du(r,s)}{ds} = x$$
with initial conditions
$$x(r,0) = 0\\
t(r,0) = r\\
u(r,0) = r^2.$$
Solving the system of ODEs I have
$$t = c_1e^s\\
x = s+c_2\\
u = xs + c_3$$
which after accounting for the initial conditions results in
$$x = s\\
t = re^s = re^x\\
u = xs+ r^2 = x^2 + (te^{-x})^2.$$
However, plugging in my solution $u$ into the original PDE I do not retrieve $x$ and I am off by a factor of 2.
Should I not be solving these systems concurrently? I noticed if I solve the first two systems before approaching the last one I will instead have
$$\frac{du(r,s)}{ds} = x = s\\
\implies u = \frac{s^2}{2} + c_3$$
and so that
$$u = \frac{x^2}{2} + (te^{-x})^2$$
which satisfies the original problem.
My issue is this solution of solving the first two systems seems a little heuristic. Is this the standard approach, and should the variables in the integration always be expressed in terms of parameterized variables $r$ and $s$ instead?
Comment: The answer is yes.
Answer: Another approach consists in using Laplace transform.
Let $U(t,s)$ be the LT of $u(t,x)$.
The eq. writes in Laplace domain
$$
tU_t(t,s)+
[s U(t,s)- U(t,0)] =
\frac{1}{s^2}
$$
Rearranging terms, and denoting
$y(t)=U(t,s)$,
we obtain the first order differential equation with non constant coefficients
$$
y' + \frac{s}{t} y
=
\frac{1}{s^2 t} + t
$$
After multiplying on both sides by the
integrating factor
$\mu
=e^{\int \frac{s}{t} dt}
=t^s$, we obtain
$$
t^s y' + st^{s-1} y
=
[t^s y]'
=
\frac{t^{s-1}}{s^2} + t^{s+1}
$$
this gives after integration
$$
t^s y
=
\frac{t^s}{s^3}
+ \frac{t^{s+2}}{s+2}
+ C
$$
Finally the solution is
$$
y(t)
=U(t,s)
=\frac{1}{s^3}
+ \frac{t^2}{s+2}
$$
The constant is null
because of the finite initial condition.
Back in space, we finally obtain
$$
U(t,x)=
\frac{x^2}{2}+t^2 e^{-2x}
$$
Answer: The error here comes from solving the third equation "simultaneously". TDLR - The third equation should be understood as $x$ is an undetermined function (ie not fixed). (What you did was to assume that $x$ is fixed and did the integration directly.)
Details:
For the third equation,
$$\frac{\mathrm{d}u(r,s)}{ds} = x$$
should be understood as
$$\frac{\mathrm{d}u(r,s)}{ds} = x(r,s)$$
as we are looking at a system of ordinary differential equations here. In fact, to be understood as ODEs, this does not even make sense unless we treat $r$ as a constant.
The way in which I understand how the method of characteristic works is that it is basically a result of the multivariate chain rule. Since $u = u(t,x)$ is assumed to take such a form, we parameterize $t$ and $x$ by a common parameter (say $s$). This implies that $t(s)$ and $x(s)$ (that is, $t$ and $x$ both depends on a single variable, $s$). Looking back at our $u$ dependence explicitly, we have
$$u = u(t(s),x(s)).$$
Now, we proceed to apply the multivariate chain rule as we differentiate $u$ with respect to $s$ as follows.
$$\frac{\mathrm{d}}{\mathrm{d}s}u(t(s),x(s)) = \frac{\partial u(x,s)}{\partial t}\frac{\mathrm{d}t(s)}{\mathrm{d}s} + \frac{\partial u(x,s)}{\partial x}\frac{\mathrm{d}x(s)}{\mathrm{d}s}.$$
In the equation above, I have explicitly written the "correct" dependence of each of the functions on their corresponding variables. Now, under such a method, we hope that the left-hand side of the PDE can be written as $\frac{\mathrm{d}}{\mathrm{d}s}u(t(s),x(s))$. This implies that we should have
$$\begin{aligned} \frac{\mathrm{d}t(s)}{\mathrm{d}s} &= t \\  \frac{\mathrm{d}x(s)}{\mathrm{d}s} &= 1 \end{aligned}$$
such that the left-hand side of the given PDE is now
$$\frac{\mathrm{d}u(s)}{\mathrm{d}s} =\frac{\mathrm{d}u(x(s),t(s))}{\mathrm{d}s} = x(s). $$
The redundant equality above is to emphasize that we can view $u$ as a function of $s$, which is obtained by viewing $u$ as a function of $x$ and $t$, each as a function of $s$. From this equation above, it is clear that
$$u = xs + c_3 $$
as you have suggested would not have been the solution (as that is not the correct way to solve this ODE).


jQuery .load() function

Question: I'm generating table rows "N" times. If the user clicks "add row" buttons, I'm adding rows in the table.
So, I need to load one external file in one TD. How can I load an external page by class and not ID?
For example
<code>$('.classname').load('ajax/help.html');
</code>
Comment: Not really sure what you want, but your code is correct. It will load the contents of `'ajax/help.html'` in every element with class `classname`. If this is not what you want, you have to be more specific.
Answer: When you generate the td, you should have a reference (or be able to get one) and either load the file then. If you want to load the file later, give each td a generated, unique ID and then link a button or whatever to that td. If your scenario is different, amend your question and ill update my answer.
Comment: thanks for your answer. my questions in that i want to load one external page in many place. so shall i use class instead of id? like $('.classname').load('ajax/help.html');
Comment: @user566373: Yes. IDs have to be unique, so you can only address **one** element with an ID. If you want to select multiple, the easiest way is to use a class.

jQuery .load() function


Can't get template suggestions to be recognized

Question: I am using D7. I have declared a custom template facet-item.tpl.php in a module named dsfacet. My code goes as follows:
/**
 * Implements hook_theme().
 */
function dsfacet_theme($existing, $type, $theme, $path) {
  return array(
    'facet_item' => array(
      'variables' => array('facet_name' => NULL, 'facet_values' => array()),
      'template' => 'facet-item',
    ),
  );
}

This custom template is invoked from another template with the following code:
<?php foreach ($facets as $name => $values): ?>
<?php print theme('facet_item', array('facet_name' => $name, 'facet_values' => $values)); ?>
<?php endforeach; ?>

Everything works great so far, but I'd like my theme to use more specialized templates based on the facet name.
So here's what I did:
1) I declared a template suggestion based on the facet name:
/**
 * Implements template_preprocess_HOOK for facet-item.tpl.php.
 * Adds template suggestions.
 */
function template_preprocess_facet_item(&$variables) {
  $variables['theme_hook_suggestions'][] = 'facet_item__' . $variables['facet_name'];
}

2) I changed the theme invocation to take into account the facet name:
<?php print theme('facet_item__' . $name, array('facet_name' => $name, 'facet_values' => $values, 'node' => $node)); ?>

3) I created some templates based on facet names:
facet-item--address.tpl.php
facet-item--phone.tpl.php
...

I then cleared the cache but... nothing happens. Only the main template facet-item.tpl.php is used. After a few hours spent on this, I'm at my wit's end. Any ideas?
(I've tried hard-coding the facet name everywhere to make sure it wasn't a problem with my variables... I've also tried every possible permutation of singe/double dashes/underscores...)
Answer: It took me a bit to figure this out and what I came up with is that the issue appears to be that Drupal's Theme System will only look for dynamic templates if they are in an actual theme, not in with a module.
So, you can do one of two things, the first one obviously being to copy all of your facet-item templates into your theme directory and call it a day after clearing caches for Drupal to pick them up.
Or... you could get creative like the Views Module does and create theme registry hooks for each of the template files like so:
function dsfacet_theme($existing, $type, $theme, $path) {

  $hooks=array();
  $modulepath = drupal_get_path('module', 'dsfacet');

  $hooks['facet_item']= array(
    'variables' => array('facet_name' => NULL, 'facet_values' => array()),
    'pattern' => 'facet_item__',
    'template' => 'facet-item',
    'path' => $modulepath . '/tpl/facet-items',
  );

  $hooks += drupal_find_theme_templates($hooks, '.tpl.php', $hooks['facet_item']['path']);
  // $hooks += _views_find_module_templates($hooks, $hooks['facet_item']['path']);

  return $hooks;

}

which if you have Views installed will actually use Views' _views_find_module_templates() function to do all the work for you. (it basically goes through the directory passed to it and looks for template files and creates $hooks['facet_name__foo'] for each one it finds.) If you don't have or want Views installed, you can just copy it out of views.module and include and rename it accordingly in your own module.
ADDITION/CORRECTION:  DUH; YOU CAN USE drupal_find_theme_templates() just as easily without worry about using/including Views' similiar private implementation.
And now if you have put all your facet-item templates under your module in their own directory structure (mostly so the find template function doesn't find any other templates and spin its wheels doing extra work) and cleared caches, you should now see all of your templates.
Comment: Hey Jim, thank you so much for taking the time to look into this. I've just tried your two suggestions and both work great. I like your second suggestion even better (drupal_find_theme_templates) as I find it more convenient to have the templates in the module directory. You just made my day, thanks again!


How to declare @font-your-face local fonts in CSS?

Question: Pretty simple question, why does my CSS not render my fonts when I declare it programmatically (in my CSS) vs when I use the @font-your-face  UI?
For a number of reasons I'd like to be able to control this from my styles. I'm declaring the CSS font-family declaration correctly and the text is being changed but it's going to some sort of Sans-Serif or Helvetica default.
If it matters I'm using, or trying to use omega 4.
thanks in advance.
Here's my css for the relevant selector, I know it's trying to work because the text changes but not to this font.
<code>.l-page{width:960px;
    margin:0 auto;
    border:2px solid black;
    border-radius:15px;
    padding:2px;
    font-family: 'Cassannet - simple';
    font-weight: normal;
    font-style: normal;}
</code>
Comment: Just make sure the font is linked into the source, and use `font-family` as normal. There's nothing else to it, Drupal doesn't (and can't) change how the basic HTML/CSS works
Comment: Can you clarify what you mean by 'linking the font to it's'source?
Comment: It should be something like the following: `@font-face { font-family: 'MyWebFont'; src: url('myfont.woff2') format('woff2'), url('myfont.woff') format('woff'); }`. If you are not using anything like this, it doesn't work.
Comment: in my css/sass, I assume?
Comment: It seems that the syntax is more complicated than that, any link to a reference?
Answer: There is an option to apply the CSS in the theme in the drop down of the @font-your-face UI.


How to understand a fact in the proof of Sperner's Theorem?

Question: Consider the maximal chain in $(S,\varsubsetneqq)$. A maximal chain is made up of the null set, a subset of size 1, a subset of size 2,..., and finally the set itself. There are n choises for the subset of size 1. The subset of size 2 must contain the subset of size 1 that was picked previously. Thus there are n-1 choices for the second element in the subset. Continuing to build up the maximal chain in this way, we see that there are n! maximal chains. Suppose that A is an antichain. If $s\in A$ and $|s|=k$, then $s$ belongs to $k!(n-k)!$ maximal chains.
I don't understand why the last sentence is ture, can anyone help me to understand the last sentence of this proof? Thanks very much!!
Comment: @bof Sorry, I mean I don't know why it is true? Can you have a explaination to me? Thanks.
Answer: You didn't say what is $S$, and I do not see what is the relevance of $A$.
But, take $|s|=k$. A maximal chain containing $s$ would contain one set
of cardinality $k-1$, one set of cardinality $k-2$, etc. Also, going in the other direction, it will contain one set of cardinality $k+1$, one set of cardinality $k+2$,
etc (which of course needs to be made more precise, e.g. if $k=n$ then there will be no $k+1$, etc, but it ought to be clear anyway).
So starting from $k$ we may go down (picking sets of smaller and smaller size), or up (picking sets of bigger and bigger size) to form a maximal chain.
Going down is the same as scratching out (someone posted an answer but let me finish anyway) elements from $s$, one after the other. First we have $k$ many choices to scratch out an element, then $k-1$ choices, etc. This clearly leads to the $k!$ term in the product $k!(n-k)!$. Similarly, going up, is the same as picking elements from
the remaining $n-k$ many elements that are not in $s$ and adding them to $s$. First we have $n-k$ many choices, next $n-k-1$ many choices, etc, which accounts for the term $(n-k)!$ in the product $k!(n-k)!$
Comment: It's really helpful, thanks for your help
Answer: Each subset of size $k$ is an element of the same number of maximal chains, and two different subsets of size $k$ are never elements of the same maximal chain. There are $n\choose k$ different subsets of size $k$, and each is therefore an element of the same fraction, $\frac{1}{n \choose k}$, of the maximal chains. Since there are $n!$ maximal chains, each subsets of size $k$ is an element of $\frac{1}{n \choose k}\cdot n!=k!(n-k)!$ maximal chains. (The assumption that $s$ is an element of a particular antichain is irrelevant.)
Comment: I got it, thanks for your help


Demystifying HP VC-FC 4Gb Module on c7000 Chassis

Question: has anyone used the HP VC-FC 4Gb Modules before in a c7000? If so could you help me understand the "Connect To" column? It shows a WWPN, but when looking at our FC switch it is connected to I don't see that WWPN in the FLOGI database...Am I missing something with these FC module?
Here is a screen shot of the VC-FC Manager

Here is our Cisco MDS, were I attempt to find the WWPN of the Module:
Comment: Hmm. I see what you are saying Dennis, however this WWN is not the switch.. I still don't know where it is getting it from.
Answer: That VC-FC manager screenshot is showing the WWN of a Cisco device, presumably the switch it is connected to. I haven't used FC in a C7000 yet, but my instinct says: Check the 'Server Connections' tab instead to see the local node/port WWN.
Comment: Hmm. I see what you are saying Dennis, however this WWN is not the switch.. I still don't know where it is getting it from.


Carnival Game Odds: Thunderbolt

Question: I came across an interesting carnival game called Thunderbolt that involves 36 tiles numbered 1, 2, ..., 36. The game goes like this.

A participant chooses 18 tiles out of the 36 tiles randomly shuffled. Each tile has a back face so participants won't know what numbers they pick.
There is a 6x6 board that is written 1,2,3,4,5,6 on the first row, and 7,8,9,10,11,12 on the second, and so on until 31,32,33,34,35,36.
The participant then uncovers his 18 tiles and places them on the board corresponding to each tile number, i.e. tile #1 is placed on 1 on the board.
The participant wins when an entire row or column is filled by tiles. eg. 1,2,3,4,5,6 or 1,7,13,19,25,31. More points are given for additional rows/columns. Diagonals don't count.

By the time the participant chooses his 18 tiles, the game is nothing more than just discovering if he has won by placing the tiles on the board. I am interested in the probability of getting at least one row or column filled in this game.
Here's what I know
 - there are 12 possible unique rows and columns combined to win a point.
 - but instead of thinking in terms of rows and columns, I thought it might be more useful to think numerically of winning combinations and the probability of drawing them, i.e.

1,2,3,4,5,6.
7,8,9,10,11,12
13,14,15,16,17,18
...
and I find that for each combo, the probability of drawing that is ($\frac{1}{36}$)($\frac{1}{35}$)($\frac{1}{34}$)($\frac{1}{33}$)($\frac{1}{32}$)($\frac{1}{31}$) multiplied by a P or C which I can't figure out at this point...
Answer: The probability to get a specific row, say the top one, is $\frac {{6 \choose 6}{30 \choose 12}}{36 \choose 18}\approx 0.00953$  We might think we could multiply that by $12$ to get the chance to get any row, which would give a winning probability of about $11.4\%$, but we would be counting cases where we have two complete rows twice.  This is where inclusion-exclusion comes in.  There are $30$ ways to get two parallel rows, with each one giving $\frac {24 \choose 6}{36\choose 18}\approx 0.000015$ and $36$ ways to get two perpendicular rows with each giving a chance of $\frac {25 \choose 7}{36 \choose 18} \approx 0.000053$.  These are small enough corrections that we can stay with the $11.4\%$ chance of winning.
Comment: I was working on an answer that was giving me the same estimate that you gave,but wasn't sure if I was correct or not, so (+1). However, not that it would make a difference here, but if one wanted to be exact, would you also need to consider the cases where there are $3$ rows / columns filled?
Comment: Yes, you would.  However, the chance of two is so small I am sure the chance of three would be really negligible.  You would have counted the $3$ line cases three times in the one line calculation, then subtracted them three times in the two line calculation, so should add them in once.  That comes from the inclusion-exclusion principle.

Carnival Game Odds: Thunderbolt


Is TA-lib.org support on iOS on iphone?

Question: I would like to add Technical analysis support to my financial project on iphone. And I found TA-lib on www.ta-lib.org, this library supports many indicators I need.
I would like to ask: Can I use ta-lib on my iphone development? And how I can do it, because this library is written in C language? I knew that Cocoa can compile C but how I can do it, import this library to iOS?
Any help would be appreciated.
Thanks
Comment: Can anyone answer my question, please?
Answer: The iPhone SDK tools will compile most portable C code just fine (C is a pure subset of Objective C).  There appears to be C source code available for the library in which you're interested.  If so, you could try just including the source to the library in your iPhone Xcode project, and see if it all compiles, which it might if there are no dependency or collision problems.  You may or may not need the entire library, which might help simplify things (or not).
You could also compile a separate static library, and then include that library, and the headers, in your iPhone app; but that technique may be a bit more complicated that your requirements might indicate.
Comment: Thank you, this is the answer I am looking for. Actually I am doing with the second situation, compiling a static library and import it to my project. Many thanks to your response.
Comment: am trying to add the static library, but it throws linker error. any suggestions as how to add it properly? thanks

Is TA-lib.org support on iOS on iphone?


Identifying "Drop chords" from a given voicing

Question: I'm new to this concept of "drop chords" for guitar, and apparently other instruments as well. Well, I know about chord voicings in general, but not necessarily how the drop-n voicing system works.
For example, say I had some voicing like (left to right, ascending frequency):

E  A  C♯  F♯

or

A♯  F♯  B  D♯

or

D-C♯-A-F♯

How would I name these chord inversions in this system? Also, does this system provide a name for every possible voicing of any seventh chord? A general explanation would also be welcome, though I know that's been answered here before.
Answer: What are drop voicings?
Drop voicings are formed by taking a close voicing and dropping certain notes one octave. A drop-n voicing drops the nth note, counting from the top, one octave.
For example, a drop-2 voicing of a CMaj7 chord can be formed by starting with a close voicing C-E-G-B, i.e. a stack of thirds, and dropping the 2nd note from the top one octave to get G-C-E-B. This is a drop-2 voicing of a CMaj7 in second inversion.
You can find other inversions of the drop-2 voicing by raising each note to the next chord tone:
G-C-E-B --> B-E-G-C  (drop-2 CMaj7 in third inversion)
B-E-G-C --> C-G-B-E  (drop-2 CMaj7 in root position)
C-G-B-E --> E-B-C-G  (drop-2 CMaj7 in first inversion)
It is worth noticing that the drop-2 voicing of the Maj7 chord arranges the notes as 1-5-7-3. You can form other drop voicings the same way. Drop-2, drop-3, and drop-2&4 voicings are probably the most common on the guitar.
How to determine which notes have been dropped in a given voicing
Taking your example E-A-C#-F#, you can rotate through the inversions:
E-A-C#-F# --> F#-C#-E-A  (you might already recognize this as a drop-2 with 1-5-b7-b3)
F#-C#-E-A --> A-E-F#-C#
A-E-F#-C# --> C#-F#-A-E
The last inversion has the last three notes arranged so that raising the bottom note one octave (an inverse drop-2 operation) gives F#-A-C#-E, a close-voiced F#min7 chord. This means that E-A-C#-F# is a drop-2 voicing of F#min7 in third inversion.
Similarly, for A#-F#-B-D#:
A#-F#-B-D# --> B-A#-D#-F#
B-A#-D#-F# --> D#-B-F#-A#
The last inversion can be put into a close voicing by raising the D# one octave (an inverse drop-3 operation) to get B-D#-F#-A#. So A#-F#-B-D# is a drop-3 voicing of a BMaj7 chord. Notice the pattern here, a drop-3 voicing in root position is 1-7-3-5.
To figure out if you have a drop voicing, you can either remember the patterns for drop voicings in root position (or some other convenient inversion) and invert an unknown voicing until it matches a known pattern, or invert the unknown voicing until a sequence of inverse drop operations will put the chord into a close voicing.
There are lots of other ways to voice 7th chords; in particular, chord voicings with doubled notes don't fit the usual way of defining drop-voicings. Voicings that drop a note from a close voicing more than one octave are also not treated by this system. Still, drop voicings are a good beginning for developing a vocabulary of chords.
Down the rabbit hole
Before looking at how to apply all of this to the guitar, anyone who is interested should look at the answer by @MichaelCurtis for a great way to visualize these and a great alternative solution to finding out if a particular chord voicing is a drop voicing.
How to apply this on the guitar
Knowing how to spell a drop voicing is one thing, but knowing how to construct it on the fretboard is another. As an example, I'll construct the drop-2 voicings of a CMaj7 chord on the fretboard. The result will be a collection of four voicings (drop-2 in root position and three inversions), some of which may look familiar, and some of which may not.
%X/X.X/X.10/4.9/3.8/2.7/1[CMaj7]    %X/X.10/3.10/4.9/2.X/X.7/1[CMaj7]

%X/X.10/2.10/3.9/1.12/4.X/X[CMaj7]

Begin by constructing a close-voiced CMaj7 (C-E-G-B) on the top four strings; this is the first chord block in the diagram above. Next, drop the second note from the top (the G on the second string) one octave, to the 10th fret of the fifth string. The second chord block in the diagram shows this chord. The fingering is not impossible, but it is a little awkward, so let's adjust by moving the B on the first string to the (now vacant) second string; this is shown in the third chord block. This is a drop-2 voicing of the CMaj7 chord, and since G is in the bass it is a CMaj7 in second inversion. The notes of this chord are G-C-E-B.
To find the inversions, move each of the notes along the string that they are played on to the nearest chord tone. The third inversion is found by moving the voices up one chord tone (first chord block below): G-C-E-B --> B-E-G-C. The first inversion is found by moving the voices down one chord tone (second chord block below): G-C-E-B --> E-B-C-G. As an aside, I am very fond of this voicing of a Maj7 chord because of the minor 2nd in the inner voices. The root position is found by moving the voices of the first inversion voicing down one chord tone (third chord block below): E-B-C-G --> C-G-B-E.
%X/X.14/3.14/4.12/1.13/2.X/X[CMaj7]    %X/X.7/2.9/4.5/1.8/3.X/X[CMaj7]

%X/X.3/1.5/3.4/2.5/4.X/X[CMaj7]

You can't construct these every time you need them, so learn the shapes and learn where the root, third, fifth, and seventh are in each of the inversions. Learn how these shapes change when played on the top four strings or on the bottom four strings. Learn how to transform the Maj7 voicing into other chord types: 7, min7, etc.
Taking the drop-2 CMaj7 in first inversion, the 3rd is on the fifth string, and the 7th is on the fourth string, so you can adjust to create drop-2 C7 and Cmin7 in first inversion:
%X/X.7/2.8/3.5/1.8/4.X/X[C7] %X/X.6/2.8/3.5/1.8/4.X/X[Cmin7]

An alternative method
Instead of starting from a close voicing in root position to get a drop voicing and then moving the notes of that voicing around to find the inversions, you can start from the inversions of a close voicing. That is, you can start by constructing a close-voiced CMaj7 as we did above, then finding its inversions by moving the bottom notes up an octave. Once you have each of the inversions, drop the necessary notes to get all of the drop voicings. For CMaj7, starting with a close-voiced C-E-G-B, you have the inversions: E-G-B-C, G-B-C-E, and B-C-E-G. These respectively become the drop-2 voicings: B-E-G-C, C-G-B-E, and E-B-C-G. These are the same voicings that we had before.
This alternative method is a great way to think about drop voicings, but not a great way to work with them on the guitar. The fundamental issue is that close voiced chords and their inversions are difficult to play on guitar. For me, it is easier to work out fingerings using the first method, but it is good to know about both.
Comment: I'm not sure i understand the drop/invert process. When we drop 2, from `CEGB` to `G-CE-B` is it required that the upper voices remain `CE-B` without re-arranging to something like `E-BC`?
Comment: @DavidBowling How's my logic here? *GEBC-->BGCE--->CBEG so that would make the voicing from User Michael Curtis' answer a Cmaj7 drop 3 voicing in 2nd inversion?*
Comment: @user45266 -- You have it, since CBEG is 1-7-3-5. Or, continue rotating: CBEG --> ECGB, then raise the E 1 octave (inverse of drop-3) to get CEGB and see that ECGB is a drop-3 voicing.
Comment: For what is a basically simple way to alter the voicing of chords, it sounds quite complicated! On guitar it's not easy to see what's happening - I don't think it's always possible to keep the other notes in their original placings (tell me if that's not the case) - but on a keyboard, it's clear what actually happens. Great explanation! +1.
Comment: @Tim -- When I try to show this to students on the guitar, I think it is reasonably clear what is going on when you move from one inversion to the next going up the neck, but not as clear as seeing it on a piano. You have to know the notes on the fretboard pretty well to see it; and of course, some of the fingerings can be awkward. Guitars make everything complicated ;)
Comment: @MichaelCurtis -- that's right. The drop-2 voicing for **CMaj7** with a G in the bass has to have a fifth between E and B, and a third between C and E. Technically I think that it has to have a fourth between the G and C too, but some people will call it a drop-2 even when the G is dropped two octaves. Another way to think about this is to form the inversions of a close-voiced chord by putting the bottom notes on top, then dropping the 2nd note from the top of each inversion. This makes more sense on a piano, but doesn't translate quite as well to the guitar.
Answer: This is just an extension of @DavidBowlings answer - which really explains the drop voicing completely - with some visual charts.
I had a little confusion mentally switching between the "standard" inversion of the un-dropped chord and the inversion of the dropped chord. I made a chart to get that sorted out and I thought I would share it here. Please let me know if I've made any mistakes and I will update accordingly.
An interesting thing is all three common drop voicings - drop 2, drop 3, and drop 2 & 4 - follow the same pattern of "voices" and "skips" on a repeating 8 position pattern where V means voice and - means skip a voice: V-VV-V--. These are the permutations of that patterns...

The pattern of voice skips seems to be the defining characteristic of each drop voicing. I was surprised to see that all three drop types are just permutations of one pattern.
If we stay with the Cmaj7 example, the various inversions/positions of the drop chords are...

Personally, the timing of this question was perfect! Just the day before I was trying to come up with 'standard' forms for open position chords. Of course there is only one close position (with inversions), but there can be many open positions. I was looking for a systematic approach to open voicings/positions.
FWIW, I was aware of the jazz drop concept, but instead I came up with a "skip" concept: "skip 1" and "skip 2"...
Skip 1: C-G--E-B (I had to skip twice in the middle to not repeat C-G at the octave)
Skip 2: C--B--G--E
My "skip 1" is the same as "drop 2 & 4".
My "skip 2" is like "drop 3" except the 2nd voice is raised an octave.
These drop/open voicings can be overwhelming at first, but if my V-VV-V-- is correct, there is a single pattern which unifies everything.
You can create smooth voice leading with one drop type and alternating inversions...

Dm7   D-A--F-C drop 2&4 root pos.
G7    D-G--F-B drop 2&4 2nd inv.
Cmaj7 C-G--E-B drop 2&4 root pos.
Comment: Drop 2 and Drop 2&4 are sort of inversions of each other, pairs of P4 and P5, and I noticed like you, they fit nicely into quartal/quintal. Your question was great. It should get many more upvotes.
Comment: I really like these diagrams. This is exactly what I meant about rotating the voicing through the chord tones, but I usually think about it on the fretboard where you have four notes on four strings and you move along the strings to adjacent chord tones. These diagrams make the underlying patterns very clear. Another approach for voice leading is to stick to one drop type, e.g. play **ii-V-I** all in drop-2, but use alternating inversions: root-2nd-root, or  2nd-root-2nd, or 1st-3rd-1st work well. +1


ARIMAX with a specified nonlinear model using the arima function in R

Question: I am interested in fitting an ARIMAX model using R.
As known, ARIMAX can be understood as a composition of ARIMA models and regression models with exogenous (independent) variables. I have a time series $Y_i$, and want to estimate the ARIMA and nonlinear coefficients. The nonlinear model is the following:
$y_i=β_0+β_1t_i+β_2d+β_3 sin(2πt_i/β_4 )+β_5 (-1^{t_i})+ε_i$,  nonlinear
regression with an exogenous variable.
Where
$t_i$ =1, 2…, 60
and
d = dummy variable with 20 0's and 40 number 1's
d=c(rep(0,20),rep(1,40))

And an ARIMA model (1,1,1) for $Y_i$. Therefore, I want to estimate simultaneously the $β_i$ and the ARIMA coefficients in order to avoid the confusion between the exogenous coefficients and ARIMA coefficients.  I know that $arima()$ can deal with this formulation but, how do the nonlinear model can be set within function function?. It seems that the xreg term only deals with linear parameters.
Comment: As parameterized, your model isn't identifiable (choose some value for $\beta_3/\beta_4$, and then note that doubling both $\beta_3$ and $\beta_4$ leaves that ratio unchanged) - as the model stands, you can only estimate $\beta_3/\beta_4$. You have to fix that problem with your model before even considering trying to estimate it.
Answer: Do the parameters $\beta_3$ and $\beta_4$ have any particular interpretation or meaning in the context of your model? You can consider reparameterizing the model merging $\beta_3 t_i /\beta_4$ as $\theta\,t_i$. In this way the model becomes linear in the parameters and you can pass the regressors $t_i$ and $d_t$ through argument xreg in function arima.
You should include $t_i$ only once in the reparameterized model. In your model, the regressor $t_i$ is proportional to the regressor $2\pi t_i$. With this type of collinearity among the regressors the optimization algorithm won't be able to invert the system matrix.
Edit (updated answer for the new model defined in the question)
The function stats::arima does not allow you to specify this non-linear parameterization. You should modify the function arima, which is not straightforward since would require among other things recompiling the package. You can also try to create your own function, the functions that you would need are essentially: makeARIMA, KalmanLike and nlm, but this is also quite a hard work. You may ask for further guidance at
Stack Overflow.
Did you find this model in any paper? If you know some application of this model published in a paper and the data are available, it would be a nice exercise to do and someone could be willing to replicate it.
Comment: Thanks for your comments @Glen_b and javlacalle . I have edited my post and the model has varied a little. With the new model, $beta_3$ and $beta_4$ have a particular interpretation, period and amplitude of a sinus wave. Is there any way to estimate the ARMA parameters and this model parameters in only a single stage? (not estimating first the NLM and then the ARMA).


Multilevel Categories & Menu - How To?

Question: I would like to be able to create content of a particular type but be able to set multi-level categorisation. But I would like a menu where I can select a category and see all content including child categories as well.
e.g.

Fruit

Local

Apples
Pears

Tropical

Pineapple
Bananas

'Fruit' menu would show all fruit
'Local' Menu would show all local, apples and pears
'Apple' Menu would only show Apples
I am trying to achieve some thing like this side menu:
http://learningexchange.ptc.com/tutorials/by_product/ptc-creo/product_id:1
Answer: There won't be a definite answer to this question as this can be achieved in a lot of possible ways. Depending on your knowledge in drupal you could start with the built-in drupal taxonomy system that enables you to classify your content as needed (e.g. with a tree-like-hierarchy or even related terms). To build the menu you can try the taxonomy menu module or use Views to create this manually.
For a start i recommend reading through this overview: https://www.drupal.org/documentation/modules/taxonomy
Comment: I was thinking about using Taxonomy to create the categories and sub-categories. In the content type, allow the use of the term and then create a menu based upon taxonomy terms?
Comment: Essentially I am looking to replicate this menu: http://learningexchange.ptc.com/tutorials/by_product/ptc-creo/product_id:1

Multilevel Categories & Menu - How To?


Opening a .R file via a double click (Windows)

Question: I am looking for a way to double-click on file name in Windows Explorer directory (XP) that will open the R GUI and display the script (but not run it). In other works I want R to work in a similar way to opening a PDF (or pretty much every other program) from the Windows Explorer directory.
I have tried to find the appropriate .exe from Right Click -> Open With -> Choose Program route but to no avail. I have also tried moving the R icon from my Start | All Programs to the C:\Documents and Settings..\SendTo to allow me to select R from Right Click -> Send To -> R. This also failed.
Comment: I'd suggest you use a real editor like Tinn-R for example. R files are automatically linked to Tinn-R. The same can be obtained for any other editor, using the Open With path or setting it in the control panel.
Comment: Then you haven't looked hard enough. Give RStudio a go, you'll love it.
Comment: there is indeed no significant added value, apart from code highlighting, project templates, control over the workspace, easy sweaving of documents, ... Each to his own off course, but even if you don't really buy Tinn-R, I'd suggest you really take a look at RStudio.
Answer: Unless you have a compelling reason to use the default R editor, I recommend using one of the third party text editors for R. Lots of good details here: Recommendations for Windows text editor for R
I'll give a personal recommendation to the new kid on the block, R-studio: http://www.rstudio.org/
Comment: +1 for rstudio. Although I don't use it myself it seems like a very useful tool for beginners in R.

I personally prefer Notepad++ with NppToR: http://sourceforge.net/projects/npptor/
Comment: @Sacha : given the ease of installation, Rstudio seems far more appropriate for beginners in R.
Answer: The following url:
http://research.stowers-institute.org/efg/R/TechNote/WindowsExplorerWorkingDirectory/index.htm
has information on how to set up windows so that you can right click on a folder in windows explorer and start R (you will need to update the file to more recent versions of R, but it still works).
This will not open the .R file for you, but you can then easily do that from the folder icon in the R GUI.  I like this approach better, you still right click to run R and it runs in the folder you specify, but I often have 2 or more .R files that I want to open in the same instance of R (with your description above it is not clear whether the second file you did that with would open in the same instance of R or open a new one).
I also have the following line in my .Rprofile to help me keep track of the different instances of R that I have open:
<code>utils::setWindowTitle(getwd())
</code>


Is there a way to assign categories before the articles are added via the Aggregator module?

Question: I'm interested to aggregate posts with the built-in Aggregator module.
My problem is that it's not possible to assign a category at the same time. Users have to later find the post and manually set the category.
Is there a way to to assign categories when the post is created?
Answer: The aggregator is for importing feeds from other sites, but it sounds more like you're trying to create new feeds on your site from your content. For that use, you could use Views.