Sales forecast with an ARIMA model

Question: I'm trying to understand if an ARIMA model could be improved.
This is my dataset (sales):
28.35, 51.89, 37.26, 48.22, 30.93, 43.54, 35.3, 59.45, 49.41, 65.61, 36.59, 51.25, 31.42, 53.16, 39.41, 64.45, 43.94, 79.36, 52.93, 74.99, 55.03, 86.93, 41.69, 62.77, 41.29, 59.95, 40.07, 66.13, 47.15, 85.12, 74.44, 76.42, 49.17, 82.66, 49.88, 70.98, 52.83, 75.85, 61.4, 85.2, 61.99, 90.68, 48.05, 74.2, 41.7, 68, 46.41, 82.23, 62.18, 88.65, 65.21, 100.9, 46.63, 83.53, 56.57, 108.87, 51.01, 80.15, 57.03, 87.91, 62.41, 96.11, 71.41, 82.08, 62.5, 88.52, 60.53, 100.15, 67.74, 111.88, 74.64, 138.64, 97.88, 153.88, 111.34, 176.4, 67.57, 111.95, 72.36, 118.85, 82.19, 136.88, 84.95, 160.58, 64.13, 111.32, 64.65, 113.82, 74.75, 118.76, 86.28, 166.36, 71.82, 119.83, 67.64, 116.17, 77.83, 130.64, 95.23, 149.84, 115.97, 189.69, 96.35, 137.51, 82.04, 139.19, 70.68, 135.22, 69.84, 105.7, 65.47, 111.47, 63.71, 108.23, 66.81, 117.96, 86.82, 141.74, 71.97, 122.65, 89.35, 133.97, 110.07, 159.18, 117.4, 196.9, 167.69, 244.75, 85.43, 135.54, 70.51, 118.3, 78.83, 139.85, 108.57, 162.66, 139.03, 203.72, 94.37, 135.92, 80.35, 128.63, 90.2, 157.56, 112.91, 177.07, 147.28, 221.67, 90.86, 142.66, 93.96, 157.89, 121.5, 200.35, 140.08, 306.36, 187.86, 171.39, 113.52, 174.2, 108.89, 170.53, 121.49, 193.65, 148.72, 210.61, 168.46, 250.4, 213.54, 181.78, 126.56, 190.46, 137.85, 226.25, 148.68, 235.04, 170.39, 275.04, 106.68, 163.24, 109.15, 186.46, 129.33, 156.18, 91.03, 159.87, 119.43, 164.51, 92.84, 145, 87.02, 156.55, 92.76, 140.93, 102.72, 143.41, 92.11, 159.72, 96.44, 156.98,
151.38, 221.12, 174.89, 242.53, 117.66, 163.44, 111.25, 169.58, 103.27, 163.09, 105.62, 186.64, 124.75, 145.65, 108.31, 165.3, 101.91, 156.55, 101.72, 147.11, 106.25, 185.68, 146.83, 192.05, 101.46, 153.65, 105.91, 170.1, 97.07, 165.05, 106.06, 167.25, 102.68, 197.21, 99.19, 169.58, 106.66, 196.44, 103.46, 165.62, 108.77, 188.32, 117.03, 241.48, 171.6, 189.78, 110.79, 166.22, 116.14, 229.75, 144.17, 205.75, 137.51, 216.51, 111.98, 186.34, 138.92, 218.35, 172.29, 271.53, 143.24, 272.35, 274.9, 232.97, 238, 234.88, 172.19, 260.82, 143.12, 217.38, 136.56, 209.91, 144.57, 253.58, 171.79, 264.78, 189.01, 298.97, 231.23, 315.29, 198.05, 318.52, 183.21, 232.33, 161.4, 261.82, 145.56, 218.09, 140.13, 215, 154.87, 293.88, 164.71, 256.85, 192.69, 306.87, 255.16, 382.27, 298.13, 438.22, 183.88, 279.56, 217.82, 371.55, 269.81, 383.89, 211.72, 330.02, 217.97, 312.64, 227.47, 329.25, 238.65, 363.8, 280.39, 453.38, 363.84, 486.65, 647.67, 534.41, 219.69, 292.16, 209.73, 336.33, 226.43, 336.23, 249.48, 359.84, 188.05, 307.73, 231.67, 330.43, 252.22, 379.3, 293.54, 413.67, 384.64, 515.86, 482.36, 438.12

sales = as.ts(sales, frequency=2)

Two data each week.
In this time series I see seasonality and trend. Correct me if I'm wrong.
After a log transformation to stabilize variance:
sales.transformed <- log(sales)

The model given by auto.arima is:
fit <- auto.arima(sales.transformed, seasonal=TRUE)
summary(fit)

    Series: sales.transformed
    ARIMA(3,1,1) with drift

Coefficients:
         ar1     ar2      ar3      ma1   drift
      0.2340  0.6310  -0.4893  -0.8913  0.0064
s.e.  0.0541  0.0471   0.0485   0.0407  0.0018

sigma^2 estimated as 0.03276:  log likelihood=96.98
AIC=-181.96   AICc=-181.71   BIC=-159.01

But residuals don't behave like white noise:
res <- residuals(fit)
Acf(res, main="ACF of residuals")

Then I tried a seasonal ARIMA model.
fit <- Arima(sales.transformed, order=c(3,1,1),
             seasonal=list(order=c(3,0,1), period=2))

Things are getting better:
Series: sales.transformed
ARIMA(3,1,1)(2,0,1)[2]

Coefficients:
          ar1     ar2     ar3     ma1    sar1     sar2     sma1
      -1.3075  0.2398  0.5474  0.9721  0.0648  -0.0803  -0.7839
s.e.   0.0630  0.1221  0.1010  0.0401  0.0848   0.0657   0.0606

sigma^2 estimated as 0.02667:  log likelihood=131.05
AIC=-246.09   AICc=-245.65   BIC=-215.48

Now things are even better.
ARIMA(5,1,0) with drift
Box Cox transformation: lambda= 0

Coefficients:
          ar1     ar2      ar3      ar4      ar5   drift
      -0.4224  0.0143  -0.2956  -0.0849  -0.3238  0.0015
s.e.   0.0516  0.0563   0.0541   0.0564   0.0516  0.0009

sigma^2 estimated as 0.001257:  log likelihood=649.72
AIC=-1285.44   AICc=-1285.1   BIC=-1258.65

I don't know if the model can be improved or if this is the best an ARIMA can do, given my time series. I should probably try with autoregressive mixed models and add new predictors...
Any advice would be really appreciated.
Comment: You say two data points per week. What do these data points represent? If they are the reason you get the crazy negative autocorrelation, perhaps you should treat them as two separate time series, or two related time series (VAR).
Comment: time series methods (ARIMA) require equally spaced observations as @wayne suggested. Why don't you take the average of your two readings per week and repost the data as a csv file (1 col)
Comment: Just for info: the auto.arima function does not build an arimax model, but rather a regression with arima errors, so you don't necessarily get white noise residuals.
Look here: http://robjhyndman.com/hyndsight/arimax/
Answer: Since your data has an upward trend to it, it is good that your model has an upward trend.  The data looks exponential, so using a log transform is a good idea.
However, it looks like your model's variance is lower than your data's variance.  I would try more auto-regressive values.  e.g. ARIMA(7,1,0), ARIMA(9,1,0), etc.  This might help.
You could also average every 2 data points before analyzing.  This would produce one data point per week and eliminate that short, regular fluctuation which is really not that interesting.  (If possible...)  This should produce a better forecast.
Also, check that you reversed your log transform on the model results before plotting it against the actual data.  This might be the cause of the variance mis-match.
I like your idea of looking for other predictors.  This would probably help with those outlier points that don't follow the underlying patterns.
Answer: The forecast is upward trending which seems way too aggressive.
If you aren't looking or adjusting for outliers, your model isn't robust. For example, periods 263, 301, 319, 321, 322 and 339 don't follow the up down pattern.
A model with double differencing, an AR2 and a separate AR1 plus adjusting for the outliers mentioned above would do it.  The model changed over time and the first 167 has different parameters then after so you can use the Chow test to identify this and just use the data from 168 and on.
Comment: Really helpful, thanks! I haven't found so far a way to perform the Chow test for ARIMA models in R. Strucchange in R doesn't accept object from arima function. Do you have any advice?
Comment: I would look to a software I helped develop called Autobox or perhaps standard econ packages like Eviews, Stat or Gretl which all offer it.

Sales forecast with an ARIMA model


Population change differential equations

Question: Lake has 400 fish, estimated carrying capacity is 10,000 for that year. Fish tripled in first year.
a) Assuming size of the fish population satisfies the logisitic equation find an expression for the size of population after t years.
b) How long will it take for population for increase to 5000?
I do not know which logisitical equation to use or how to put the numbers in it, this is not like the practice problems.
Comment: Am away from your book. The DE will have shape $\frac{dy}{dt}=ky(10000-y)$.
Answer: As Andre commented above, the logistic equation has the form
$$
\frac{dy}{dt}=ry(10000-y),
$$
and your initial condition $y(0)=400$.
This is a separable equation, whose solution is given by
$$
y(t)=\frac{1000 e^{10000rt}}{24+e^{10000 rt}}.
$$
You also have the condition that $y(1)=3\cdot y(0)=1200$, from which it is possible to estimate $r$:
$$
r\approx 0.0001185.
$$
Now you can find the moment $t$ when $y(t)=5000$ (it is $2.6805$).


EF Core One-To-One Bi-Directional Self-Referencing Table

Question: I got some problems with EF Core.
I'm getting this error:

InvalidOperationException: Unable to save changes because a circular dependency was detected in the data to be saved

Here is my model:
public class Transaction
{
    public int TransactionId { get; set; }

    public int? MutualTransactionId { get; set; }
    public virtual Transaction MutualTransaction { get; set; }

    public long Debit { get; set; }
    public long Credit { get; set; }
}

And here is my OnModelCreating configuration:
public class Repository : DbContext
{
    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        modelBuilder.Entity<Transaction>(entity =>
        {
            entity.HasKey(x => x.TransactionId);

            entity.HasOne(x => x.MutualTransaction)
                .WithOne()
                .HasForeignKey<Transaction>(x => x.MutualTransactionId)
                .OnDelete(DeleteBehavior.NoAction)
                .HasConstraintName("FK_Transactions_Mutuals");
        });
    }
}

The problem occurs when I want to seed a range of data into the database.
The error itself is not important. I just want to know how to make an one-to-one bi-directional self-referencing table using EF Core.
Each row refers to another row from the same table and the referred to row also refers back to this row using the same property in the model class.
Comment: You **MUST NOT** Capitalize Each And Every Single Word In Your English!
Comment: You can only insert a directed acyclic graph in one call to save changes. Either [add, save, update, save], or maybe write a trigger to fixup the first record when the second one is inserted.
Answer: you can try this may works :
 public class Transaction
    {
        public int TransactionId { get; set; }
        [ForeignKey("MutualTransaction"), Column(Order = 0)]
        public int? MutualTransactionId { get; set; }

        public long Debit { get; set; }
        public long Credit { get; set; }
        public virtual Transaction MutualTransaction { get; set; }

    }

Answer: What you are referring to as a "One to One" relationship isn't actually what a "One to One" relationship is, it is a self-referencing "Many to One" relationship.
You don't need explicit mapping for this relationship, a simple attribute mapping will work just fine, but if you want explicit mapping /w modelBuilder:
    modelBuilder.Entity<Transaction>(entity =>
    {
        entity.HasKey(x => x.TransactionId);

        entity.HasOne(x => x.MutualTransaction)
            .WithMany()
            .HasForeignKey(x => x.MutualTransactionId)
            .OnDelete(DeleteBehavior.NoAction)
            .HasConstraintName("FK_Transactions_Mutuals");
    });

One to One relationships are between two different tables that typically share the same PK. For example if a Transaction has some big binary column that you don't typically need and don't want the overhead of loading when retrieving a transaction.
This is a typical self-referencing parent style many-to-1 relationship. If you want to ensure that an entity only is ever referenced by one other entity (1 child) and that child can only have that 1 parent then you either have to enforce that by application logic, or adopt a joining many-to-many table with unique constraints added on each of the keys making up the composite PK.
Update: If you want MutualTransaction to reference co-dependents, then this is allowed, but not enforced. For example if I want Transaction A and B to be co-dependent, where A's Mutual is B and B's is A, then you can accomplish this with the above mapping and a Many-to-One, but it is an implied rule that has to be enforced by the application (not the database) so you have to rely on code, and possibly database script health checks to regulate it's enforcement. The catch is that it requires 2 explicit saves:
var transactionA = new Transaction{ Name = "A" };
var transactionB = new Transaction{ Name = "B", MutualTransaction = transactionA };
context.Transactions.Add(transactionA);
context.Transactions.Add(transactionB);
context.SaveChanges();
transactionA.MutualTransaction = transactionB;
context.SaveChanges();

Now you can load either entity and access the reference to the mutual partner.
I.e.
var test = context.Transactions
    .Include(x => x.MutualTransaction)
    .Single(x => x.Name == "A");
// or
var test2 = context.Transactions
    .Include(x => x.MutualTransaction)
    .Single(x => x.Name == "B");

It'd be nice if this worked:
var transactionA = new Transaction{ Name = "A" };
var transactionB = new Transaction{ Name = "B", MutualTransaction = transactionA };
transactionA.MutualTransaction = transactionB;
context.Transactions.Add(transactionA);
context.Transactions.Add(transactionB);
context.SaveChanges();

but that results in the circular reference issue within EF.
Comment: But then how can I access parent from child or vice versa? I mean I can get Mutual Transacrion by simply calling for example ```var transaction2 = transaction1.MutualTransaction``` but can it be accessed backward from the same property? I mean is this true : ```transaction2.MutualTransaction.TransactionId == transaction1.TransactionId```
Comment: I had to try it out when I got back to my test projects before I replied, but it looks like it is possible to use that mutual transaction for your co-dependent references. I've updated my answer above to outline how that's done and the caveats of that approach.


How useful is factoring large numbers - Not for cryptography!

Question: This is a question for my curiosity.
Apart from its implications to cryptography. Is factoring large numbers really useful?
Are there any examples of where the ability to factor huge numbers, 1K bits plus would be useful?
Sorry if this is not really a mathematical question, but I reasoned someone with a maths background would be more able to answer this question. I guess I could have asked on physics forums as well.
Comment: In computer science, primes are useful for hashing.
Comment: @DeveloperChris: I would say not much at all. However, this may lead to some excellent spin-offs in algorithms, parallelization, optimization... and that is very useful. Look at the computational resources for this factoring challenge: http://math-fail.com/2010/01/the-232-digit-number-rsa-768-has-been-factored.html. If that can be reduced by a huge amount, it may lead to the very hot topic of data mining and big data analytics, which is currently the rage.
Comment: @MasterOfBinary You don't need factoring to get large primes.
Comment: You have to specify what you mean with "useful".
Answer: Some examples:
Suppose you want to know all integers whose reciprocals in base $b$ have repeating digit patterns with period dividing $n$. This amounts to finding all factors of $b^n-1$, cf. the Cunningham project. Likewise you may have given some integer $b$ and want to find all integers modulo which $b$ has multiplicative order dividing $n$. For example, with $b=2$, $n=2^k$, knowing suitable moduli would enable optimization of algorithmic details in FFT-based multiplications of long numbers. Again, this means factoring $b^n-1$, which for the choice $b=2$ and $n=2^k$ boils down to factoring Fermat numbers: Note that $2^{2^k}-1 = \prod_{j=0}^{k-1}(2^{2^j}+1)$.
On the theoretical side, factorizations of numbers up to a few hundred decimal digits help raising the lower bound for odd perfect numbers, cf. papers by Brent, Cohen and te Riele and the oddperfect project.
Comment: I have chosen this as the most 'correct' answer given the question and no other candidates. It would seem the answer is there is no real need for factoring large primes (apart from crypto) The oddperfect and Cunningham project seem to be no more than curiosities. Please feel free to contradict me if they add some important component to math and science.


Hey Admins, What's your way to query rdp session opened on a Windows Server and Kill/logoff/Reset a rdp session?

Question:
Possible Duplicate:
How do I find out which remote desktop sessions are active?

Hey Admins,
What's the fastest way to find out who is connected (via RDP) to a server ?
And also how to reset on the connections ?
Thanks in advance
Comment: See http://serverfault.com/questions/47897/how-do-i-find-out-which-remote-desktop-sessions-are-active
Answer: See this question for similar answers using the command line.
Alternetively you can use the terminal services manager mmc to view sessions and disconnect them.
Answer: Open up the task manager, and go to the users tab.  If there is anything in the "client Name" tab they are connected via remote desktop.  That same screen gives you the option to disconnect or log off those users.
Answer: Use:
qwinsta /server:server
and
rwinsta /server:server <sessionid>
to reset sessions (with proper privileges).
Answered in this question.
Answer: Use Terminal Services Manager, bundled with the Windows Server Admin Pack for your version of Windows.
Answer: On a terminal server, I just log on and check the task manager.  On other servers, I telnet into it and logoff 0.


Associação condição E como formatação ente intervalos númericos

Question: Gostaria de um dica de como faço para viabilizar a equação abaixo:
=SE(E($Q1744=W10;8>=$R1744<=12,99);1;0)

Comment: Um problema ai é você estar misturando >= e =< na mesma expressão, em geral, tem que separar em 2 condições diferentes. (Python é uma exceção, permite 1 > x > 7 por exemplo.
Comment: O que tem de "inviável" nela? Seria bom explicar o que quer fazer, e qual o problema encontrado.
Comment: Não entendi... Ela é inviável?
Comment: O título do assunto e a explicação do seu problema estão bem confusos e incoerentes. Sugiro que os refaça para ficar mais claro para a comunidade o objetivo do tópico.
Answer: Reavalie o segundo argumento lógico da função =E ([8>=$R1744<=12,99]). Se separarmos em 2 equações separadas temos:
R1744 <= 8
R1744 <= 12,99

Meio redundande, não acha? Mas talvez vc queira dizer que é um número entre 8 e 12,99 ([8<=$R1744<=12,99]). De qualquer forma, separe os termos lógicos, assim:
=SE(E($Q1744=W10;8<=$R1744;$R1744<=12,99);1;0)


Asymptotic t test question- regression when you do not assume normality of errors

Question: Say you are running a regression:
$Y_i$= $X_i$$\beta$ + $\eta_i$
And we are not assuming normality of $\eta_i$.
My understanding is that as long as your sample size is relatively large (and i know how large is arbitrary), you can rely on the CLT to justify using the same formula of the t -statistic anyways as a close approximation to the actual underlying sampling distribution, i.e. $\hat{\beta}$ converges in distribution to a normal distribution, and using consistent estimators of the asymptotic covariance matrix, you can use a formulation that looks like a t statistic, i.e.
$\frac{(\hat{\beta}-\beta)}{s_\hat{\beta}}$
where $s_i$ is the consistent estimator of the derived asymptotic variance of the estimator, for hypothesis testing. With this, is it accurate to say, that
1). this is NOT a t-test (I have heard it described as an 'asymptotic t test' before)
2). this is a test statistic that is 'asymptotically z'
3). given 2), we use the z table for p-values, essentially assuming that we can use the z distribution as an approximation of the underlying sampling distribution?
If the above are true, then is it correct than to just use z tables in this case as approximation of the sampling distribution? is the effect no different than just using a t table with large b, as that converges to standard normal too?
Comment: Yes It should, I meant it as a (lazy) short hand for that. I can edit it to clear any confusion
Comment: Should your denominator be $s_{\hat{\beta}}$? (Welcome to CV, also!)
Comment: What do you mean that it is asymptotically z' ? Do you mean normal ?
Comment: Yes I mean asymptotically normal ( I believe asymptotically N(0,1)? which is why I used 'z')
Comment: @Pohoua I take that to mean that the t-stat is asymptotically $t_{\infty}=N(0,1)$, so if we're assuming convergence to a t-distribution, why not take the convergence all the way to standard normal?
Comment: so is it correct than to just use z tables in this case as approximation of the sampling distribution? is the effect no different than just using a t table with large b, as that converges to standard normal too?
Comment: @Steve You should edit this explicit question into your original post.
Answer: Since you are considering large sample theory where $n$ tends to infinity,
there are some additional assumptions you may need in order to make the assertion.
(1) $(\eta_1,\ldots,\eta_n)$ are uncorrelated with equal variance
(2) The design matrix $X$ grows as $n$ becomes larger. We should have something like: $\frac1n X'X$ tends to a finite limit in some way. For example, if we assume that $X_1,\ldots,X_n$ are iid from a distribution with mean 0 and finite variance, then $\frac1n X'X$ tends to the variance matrix in probability.
These are the things that you need to say that the test statistics are "asymptotically" normal.
Comment: Yes, this is exact. This test statistic does not follow a t-distribution.
I would agree with you that the name "asymptotic z-test" would be relevant.
Comment: So when you have these (these are conditions for the CLT, correct?) at is is 'asymptotically' normal, you just use the z statistic/distribution for hypothesis testing? so it is more accurately described as an 'asymptotic z test' rather than an 'asymptotic t test?'
Comment: When n tends to infinity, t-distribution with n-k degrees of freedom will converge in distribution to z-distribution (std normal distribution), so they are asymptotically the same. It is more customary to use z-distribution but theoretically they should yield similar results for large n.
Comment: Just to clarify what this implies - this 'asymptotic' z test I described above, doesn't necessarily have a defined sampling distribution, but we approximate it with Z when n is large. But it should still give equivalent or near equivalent results if we assumed normality of errors, and used a t distribution with a large n, sinc e the t distribution will also converge to z? so one may be more 'technically' correct but with large enough n, they both would yield the same inference?
Comment: Yes. You are right.


Help understanding Gödel's theorems?

Question: What are the prerequisites to even begin to understand Gödel's theorems? I'm reading Hofstadter's book but would like a more fundamental approach to understanding these theorems. I have no knowledge in formal logic.
Answer: You have come to the right place (the (book-recommendation) tag)! There is a book on sale at Google Play called An Introduction to Gödel's Theorems. It discusses the basic arithmetic parts of his theorems, and explains it to where you may be able to understand his theorems. You can also buy Gödel's Theorem: An Incomplete Guide to its Use and Abuse. It talks about his incompleteness theorem and other mathematical things related to Gödel's theorem. But, it isn't complete (hence the title), but I'm sure it will help you. There's lots more out there, but here are two that I suggest you read.
Answer: It stands to reason the best approach would be to understand proofs. An excellent and often recommended book is "How to Prove It" by Daniel J. Velleman, which also contains a primer on sentential logic.
If you can formally prove (convince yourself of the truth of) the theorems yourself then you will certainly come to understand them. If you only seek explanations of just those theorems then you may miss knowledge that could only come about by you yourself following the proofs.
Lastly, the ability to read and write proofs is fundamental to mathematics. These would be essential skills to truly investigate the deepest understanding possible of not only his theorems, but all others.
Comment: I looked through a page of the book you recommended, and it does support what you are saying. It also relates how mathematical proofs are constructed to the way `do-while` loops are constructed in the Java programming language.

Help understanding Gödel's theorems?


Formatting the scientific notation phone number in python

Question: I have my phone_number column listed below.
phone_number
--------------
001 1234567890
380 1234567890
 27 1234567890
001 +11234567890
2.56898E+11
1 1234567890
123-456-7890
 +1 (123) 456-7890
(123) 456-7890
NaN

The following step worked fine
character = '[^0-9]+'
df.phone_number.str.replace(character, '')

The result I got is
phone_number
--------------
11234567890
3.80123E+12
2.71234E+11
11234567890
2.56898E+11
11234567890
1234567890
11234567890
1234567890
NaN

Is there any elegant way to deal with the scientific notation format? I want them to be 11234567890 or longer because of the country code. From there I think I can figure out how to get both international and the US phone number formats. Thanks in advance.
Comment: @SUTerliakov - Yeah, the "excellent" csv!!! Well, I just figured out, no matter how to convert those scientific numbers into numbers, it's not correct. Once I expanded numbers, it has 0s all the way to the end... that's an invalid phone number
Comment: Show us the column definition/data type for phone_number.
Comment: Scientific notation needs to be converted to fixed format before this data becomes a string.
Comment: @JohnGordon - it shows `object`
Comment: Try this example
[Number with code](https://ru.stackoverflow.com/questions/975604/%D0%A4%D0%BE%D1%80%D0%BC%D0%B0%D1%82%D0%B8%D1%80%D0%BE%D0%B2%D0%B0%D0%BD%D0%B8%D0%B5-%D1%82%D0%B5%D0%BB%D0%B5%D1%84%D0%BE%D0%BD%D0%BD%D1%8B%D1%85-%D0%BD%D0%BE%D0%BC%D0%B5%D1%80%D0%BE%D0%B2-%D0%BA-%D0%B5%D0%B4%D0%B8%D0%BD%D0%BE%D0%BC%D1%83-%D0%B2%D0%B8%D0%B4%D1%83)
Comment: Was your data source created in goddamn MSExcel? If yes, go to the original file and fix the column format. Also try to examine that value in scientific notation to check if there are other digits remaining. Most probably they are not, then this number is irrecoverable in dataframe and may be fixed in original source only.
Comment: It was valid, when somebody entered it. Excel assumed (how? don't ask) that cell type should be float, thus converting to exponential and (seems that) discarding non-significant digits.
Answer: You can use conversion to Int64/string dtypes:
s1 = (pd.to_numeric(df['phone_number'], errors='coerce')
        .astype('Int64').astype('string')
      )

s2 = df['phone_number'].str.replace(r'\D+', '', regex=True)

df['phone_number_clean'] = s1.fillna(s2)

print(df)

Output:
        phone_number phone_number_clean
0     001 1234567890      0011234567890
1     380 1234567890      3801234567890
2      27 1234567890       271234567890
3   001 +11234567890     00111234567890
4        2.56898E+11       256898000000
5       1 1234567890        11234567890
6       123-456-7890         1234567890
7  +1 (123) 456-7890        11234567890
8     (123) 456-7890         1234567890

Note that depending on the float precision and the way the number was converted to scientific notation, you might lose important digits.


openldap: huge logfiles at log level 'stats'

Question: I have a linux server running openldap for the user administration. The log level is set to 'stats', which I saw to be the "recommended" log level somewhere. Now the problem is that the log files are growing rapidly, with the vast part of entries generated by inquiries from the few KDE 4 clients: Per second, dozends of entries of the following form are created
Apr 19 13:21:50 ###### slapd[1429]: conn=1001 op=26379 SRCH base="dc=###" scope=2 deref=0 filter="(&(objectClass=posixAccount)(uid=####))"
Apr 19 13:21:50 ###### slapd[1429]: conn=1001 op=26379 SRCH attr=uid userPassword uidNumber gidNumber cn homeDirectory loginShell gecos description objectClass
Apr 19 13:21:50 ###### slapd[1429]: conn=1001 op=26379 SEARCH RESULT tag=101 err=0 nentries=1 text=
Apr 19 13:21:50 ###### slapd[1429]: conn=1001 op=26380 SRCH base="dc=###" scope=2 deref=0 filter="(&(objectClass=posixAccount)(uidNumber=####))"
Apr 19 13:21:50 ###### slapd[1429]: conn=1001 op=26380 SRCH attr=uid userPassword uidNumber gidNumber cn homeDirectory loginShell gecos description objectClass
Apr 19 13:21:50 ###### slapd[1429]: conn=1001 op=26380 SEARCH RESULT tag=101 err=0 nentries=1 text=

I don't have a clear idea which exact component of the clients is creating this flood of inquiries. My strong guess is that it is coming from some standard KDE component running in the background when some user is logged in.

Is this normal behaviour, or are the clients going wild? Any guess where the inquiries come from?
If this is normal, I cannot use the 'stats' level. Is there something more verbose than the log level 'none', which makes sense in my situation?
Answer: The loglevel=stats is indeed the default log level as described in the manual.
Those seem perfectly valid queries for a Linux system that has a LDAP backend.
The filter: "(&(objectClass=posixAccount)(uid=####))" is lookup for an account with a specific login name.  I would expect such queries from your PAM stack when a user tries to log in.
The filter: (&(objectClass=posixAccount)(uidNumber=####)) is lookup for the information associated with the numerical uidNumber.  I would expect such queries when your system needs to translate the numerical UID  numbers used by your system to the more human friendly loginnames, for instance when a ls -l is performed.
The following account attributes are requested: attr=uid userPassword uidNumber gidNumber cn homeDirectory loginShell gecos description objectClass which are the normal POSIX account attributes for a user account.
That LDAP query is successful and as expected yields exactly 1 result: SEARCH RESULT tag=101 err=0 nentries=1 text. 0 results would also be expected, a username or the numerical uidNumber is unknown, more than 1 result would be interesting,  user accounts and numerical uidNumber are supposed to be unique and distinct for each unique user.
You can configure your Linux clients to create and maintain a cache with the results of such queries to a central user directory, which should reduce the load on your LDAP server, result in fewer log entries,  and make the clients perform better as well.
Install and enable the nscd (the Name Service Caching Daemon) on the clients. Tuning of the nscd is usually not needed.
Comment: Many thanks for this comprehensive answer! Installing nscd at the clients immediately stopped that ldap inquiry flood.


How to add OG to the menu?

Question: I have Organic Groups installed within Drupal 7 and I am attempting to get the groups to display in the menu. For all authenticated users I want the group(s) they belong to show up in the menu (could be the user menu).
Addition:
The picture below shows how far I have gotten. This is within the edit view window. The closest window shoes the fields that can be added. The only group-specific fields I found are Group: Group permissions and Group: Group user roles and for the filter there aren't any group-specific choices. Is there some roundabout way to add them or a specific permission I may be missing. I have given my administrator (currently logged in) all of the permissions listed for the groups.
Answer: Do you need this in an existing menu?
Personally I would do this with Views. If you have it installed try the below.

Create a new view
Add a Block Display
Set Access to Authenticated Users
Change the Basic Settings > Style to "Table"
Add Fields for Node Title & Organic Group Post count
Add Filters for Organic Group Member "True"

This will now display a table with the titles and a "new" post count. You can make it look more like a traditional menu by changing the view settings further.
Comment: Hi Westie. I was able to do the first 3 steps but I have no idea how to do steps 4, 5 and 6. Do you need any special modules installed? I have OG and Views. Also to what do I add the fields to (the block or view) and how. And where can I access and add the filter? Thanks for your help. :)
Comment: Hi @Kyra , In the view you have created you will have all the options above. It is a bit difficult as there is a wall of options. What I do is press ctrl + f and type in "style" for example so the browser highlights it. Providing you have the appropriate permissions set it will be there, no addtional modules required :)
Comment: Hi @Westie. I was finally able to find how to edit the view. The view already shows the node title by default; however, when I go to add fields or add filters I am unable to find the organic group post count or the organic group member to true from the list. Is there a specific permission I am missing? Thank you for your help.
Comment: Hmm interesting, I just updated my views module on a local Drupal 7 install. The UI for views has changed a great deal. I noticed before the update I had several og views by default. These have all gone now and I too dont have the options for og in fields or filters. I suggest you report it on views / og issues queue

How to add OG to the menu?


Higher order Poincaré inequalities on $\mathbb R$

Question: So, I know that for $f\in H^1(I) = W^{1,2}(I)$ one has
$$
\|f-f_I\|_{L^2(I)}^2\,\le\,|I|^2\|f'\|_{L^2(I)}^2,
$$
where $I$ is a bounded interval. I also know that for $f\in H^s(\mathbb R)$, $s\in (0,1)$, we have
$$
\|f-f_I\|_{L^2(I)}^2\,\le\,|I|^{2s}\int_I\int_I\frac{|f(x)-f(y)|^2}{|x-y|^{1+2s}}\,dx\,dy.
$$
But what about $f\in H^s(\mathbb R)$, when $s > 1$? Will we then have something like
$$
\|f-f_I\|_{L^2(I)}^2\,\le\,|I|^{2s}\left(\|f\|_{H^s(I)}^2-\|f\|_{L^2(I)}^2\right)\,?
$$
I already googled a lot, but could not find anything on this.
Comment: Try out $ f (x)=x $ and s=2
Answer: As Bananach noted, in order for the higher order of smoothness to yield higher decay of the norm, you need to subtract more than just a constant term (otherwise, the decay cannot be any faster than for a linear function). In general, this leads to estimates $\|f-P_{f,I}\|_{L^2(I)} \le \cdots $ where $P$ is a polynomial of some degree, depending on the smoothness of $f$. The key term is (higher order) Campanato space. Some references:

Morrey-Campanato Spaces: an Overview by
Humberto Rafeiro, Natasha Samko and Stefan Samko
On the theory of homogeneous Lipschitz spaces and Campanato spaces by Harvey Greenwald (open access)
Comment: Actually, I am only interested in the difference $f-f_I$. So, I can forget about this. Thank you.


consulta entre 2 tabelas laravel

Question: Tenho a tabelas produtos(tbl_produtos) e a tabela categorias(tbl_categorias):
- tbl_produtos -
id_produto
nome
id_categoria

- tbl_categorias -
id_categoria
nome

O que quero é: apresentar na view a lista de produtos, em que por cada produto, diz o nome da categoria que está relacionada. Qual será a melhor opção para fazer esta consulta? No model ou há problema de fazer no controller?
No meu controller tenho o seguinte:
public function getIndex(){
    $produtos= ProdutoDados::get();
    return View::make('produtos.lista', compact('produtos'));
}

No model dos produtos tenho apenas o seguinte:
<?php
    class ProdutosDados extends Eloquent{
        protected $table = 'tbl_produtos';
        protected $primaryKey = 'id_produto';
        protected $guarded = array('id_produto');
    }
?>

Model categorias:
<?php
    class CategoriaDados extends Eloquent{
        protected $table = 'tbl_categorias';
        protected $primaryKey = 'id_categoria';
        protected $guarded = array('id_categoria');
    }
?>

Comment: Como está o relacionamento entre seus models?
Comment: Fiz a alteração na pergunta @gmsantos
Answer: Tem várias formas de fazer...
Mas tem duas que sempre uso.
Usando JOIN no Laravel ou usando funções de relacionamentos no Model correspondente.
Usando JOIN:
$query = DB::table('tbl_produtos')
             ->join('tbl_categorias', 'tbl_produtos.id_categoria', '=', 'tbl_categoria.id')
             ->select('tbl_produtos.nome as Produto', 'tbl_categorias.nome as Categoria')
             ->get();

Usando Relacionamento no Model - O link abaixo pode te ajudar.
http://laravel.com/docs/4.2/eloquent#one-to-one

consulta entre 2 tabelas laravel


Display node in multiple context

Question: I'm using Drupal 7, and this problem have been tormenting me these past few days :
let's say I'm using the basic content type Article, with basic view mode : full and teaser.

Now I'm creating a new content type Magazine, which reference multiple Article (with the module entity reference). On Magazine full view mode, I have set that every Article will be diplayed in teaser and linked to its content.

Easy isn't it ? Everything work fine. Noted that the red block in the sidebar are the same (with contexte module), and as the title.
Now I'm creating another new content type Book, which also reference multiple Article. On Book full view mode, Article are also displayed as teaser linked to  its content.
And now we have a problem when clicking on a Article from book: the sidebar and the title is from Magazine, and what I need is to display green block and title from Book.
What I get :

What I want :

Is there a way to achieve that ? By contrib or Custom ?
P.S. An article can be referenced in Book, or in Magazine, or both, or neither of them.
Answer: You can add query string or another argument to the link of article, for example:
node/[nid]/magazine or node/[nid]?ct=magazine
node/[nid]/book or node/[nid]?ct=book

After that you need to add visibility to the Book and Magazine block that appears in sidebar.
For Book block:
node/*/book

For Magazine block:
node/*/magazine

Hope it will help.
P.S. You can add argument or query string to the link of article through template_preprocess_node function by changing $vars['node_url'].
P.P.S. Just figured out that you can only use new argument, not query string.
Comment: Yes, exactly. Maybe it would be good to add "node/[nid]/argument" and you can create some automatic url alias on node create or node update. You can do that with rules, of course.
Comment: Is this working with alias ?
Comment: Also it seems to solve the problem for the block display. But on Magazine/Book full mode, I will have to alter the link's render the article teaser to "[node_url/node_alias]/[argument]", isn't it ?
Comment: I didn't manage to get it worked the way you told me, but it help to understand more my need and to find a solution. Thanks you :)
Answer: Sorry all, I had completely forgotten about this un-responded question.
It's been a long time so I don't remember the details. After a deep dive in custom and contrib', I managed to get it done with view_mode_page and context
At first view_mode_page didn't seems to respond to my need, but after more thorough tests, it do the job pretty smoothly.
Comment: In reference to euphoricMV post, it don't work with alias

Display node in multiple context


Jenkins URL with own domain

Question: I have installed Jenkins Continues Integration system on my windows server successfully and it works without any errors. But I was unable to get Jenkins URL working with my host domain. The default Jenkins address which is http://localhost:8080 works well. My domain/server name is projectdev so I want to give Jenkins the http://projectdev/jenkins URL so that other developers in my network will be able to access Jenkins dashboard easily.
Although I added http://projectdev/jenkins as the Jenkins URL from the Jenkins configuration sections, it doesn't work. I can't access it from other computers in my network. But when I use http://localhost:8080 I can access the dashboard directly.
I also tried to add Jenkins as a web application on IIS and give it the address I want.  But I don't know what to provide as the physical path of Jenkins as it was installed using Jenkins.jar file.
It would be really great if someone can help me to get this done as I want.
Thank you.
Answer: You have to configure IIS to re-route requests to {domain}/jenkins to {domain}:8080/jenkins
check the info on:
http://www.iis.net/learn/web-hosting/microsoft-web-farm-framework-20-for-iis-7/setting-up-a-server-farm-with-the-web-farm-framework-20-for-iis
Comment: An easier (similar) method https://blog.dangl.me/archive/installing-and-configuring-jenkins-on-windows-server-with-iis/
Answer: Try this address: http://projectdev:8080/jenkins If you type without 8080 port , the port will be 80 by default.
Comment: Thank you! but I want it to be {hostname}/jenkins, because that's the formation I have used for application I have hosted in my server.
Comment: If your host is just for Jenkins, take the 80 port for your jenkins.
Comment: does that mean it is impossible to have such a url with 8080 port number? i already have configured another application with 80 port. so i can't use that.

Jenkins URL with own domain


How to use correlation function?

Question: If I have a normal distribution and some autocorrelation function $\rho(\tau) = Exp[-\tau/\xi]$.
Where $\xi$ is a correlation length, $\tau$ is a lag.
How to use it? Does it mean $Correlation({\tau}_{0},{\tau}_{1})$ need to be always greater than  $\rho(\tau)$? Or am I wrong?
Answer: Autocorrelation can be performed on any time series, and in general, the value of the autocorrelation function will depend on times $\tau_1, \tau_2$ explicitly. If the value depends only on lag, then the corresponding time series must be at least weakly stationary. You seem to have one of those. One example of an autocorrelation function is the one you gave: $exp(-\Delta \tau/\xi)$, where $\xi$ is the correlation time. This exponential decay is a property of time series with an autoregressive component, $p>0$ in the ARIMA $(p,d,q)$ model.
This is a broad statistical feature of the time series. It holds on average. It does not mean $x(\tau_2)-\mu=(x(\tau_1)-\mu) exp(-|\tau_2-\tau_1|/\xi)$, but it does mean $E(x(\tau_2)-\mu)=(x(\tau_1)-\mu) exp(-|\tau_2-\tau_1|/\xi)$ after averaging over the zero-mean noise, which is additive at every step in the time series. Here $\mu=E(x(\tau))=constant.$
You refer to $Correlation(\tau_1,\tau_2)$, giving explicit times. Under the condition of stationary, this would not be a function of the times, but the lag. The only other possible confusion I sense is that your definition of $Correlation$ may or may not involve $\mu$. Certainly the ACF $\rho$ does subtract the long-time average value $\mu$ from all numbers, per the requirements of autocorrelation.

How to use correlation function?


Cannot move files from gcloud VM Instance to laptop

Question: I can move files from my laptop to a gcloud VM instance just fine, the other way around however is not so easy.  According to this website I am to use this syntax:
<code>scp -i ~/.ssh/my-ssh-key username@ip-address:remote-file-path local-file-path
</code>
I have done all that.  At first I got the warning:

The authenticity of host 22.214.171.124 can't be established.
  ECDSA key fingerprint is zzzzz
  Are you sure you want to continue connecting (yes/no)? yes
  Warning: Permanently added 188.8.131.52 (ECDSA) to the list of known hosts.

Then I got the error message:

firstname.lastname@example.com: Permission denied (publickey).

I am putting these commands in the terminal of my local laptop.  I then went and changed all of the permissions for each folder, subfolder and file.  But that did not help.
Answer: I don't why the above syntax did not work but the following syntax does work in command line
gcloud compute scp --zone us-west2-a [instance-name]:[path-to-file] [local-path]
That incidentally was the syntax I was using to move files from the laptop to the vm instance but I did not think it would work.


Module and functions goes missing intermittently

Question: Looking for ideas as to why a custom module might "go missing" intermittently.
It has been put into production, serves thousands of page views and works well most of the time.  Every now and then it just "seems" to go missing.
Symptoms are:

Fieldable panels pane plugins (declared by the same module) can't
make callbacks to functions within the module, getting "undefined function" errors.
Template files which call functions from the module get the same errors above.
The module declares a hook_menu URL which starts returning 404s.
Form callbacks functions in the module get "not found or invalid
function name in drupal_retrieve_form()"

All of this is intermittent, runs fine for a week, or maybe a couple of hours, then it starts happening.  I clear the caches, sometimes once or twice and it comes back to normal.  There are no errors in the logs that I can see, nothing in watchdog that stands out.
How is it possible for a module and its functions to randomly go missing?
Answer: I may have tracked this down to memcache, though it's such a strange error I can't be sure.  Sometimes a group of nodes we put into cache was over the memcache 1mb default limit.
So instead of caching the nodes, I ran them through the theme layer first and reduced the required caching space by about 80%.
This didn't exhibit on my local host as I don't have memcache installed, rather relying on Drupals database caching.  Running some queries like this helped identify the potential problem:
<code>SELECT cid, LENGTH(data) AS Cache_Size FROM cache ORDER BY Cache_Size;
</code>


Should the group decisions be independent in Wilcoxon rank sum test?

Question: In case you want to compare the average income of a group of male employees against the average income of a group of female employees, the observations are clearly independent.
Now, I have a network of a certain number of nodes. These nodes are linked by edges and I can characterize each node by the number of links it has to other nodes. (this is $k$: called the degree)
I can also characterize the nodes by their average nearest neighbour degree. That is the sum of the degree of all nodes, to which one node is linked to. (this is $k_{nn}$; $k_{nn}$ of node i = $\sum k_j$ for any node $j$ that is linked to $i$).
When I create a scatter plot of these nodes ($k$ vs $k_{nn}$) I can clearly distinguish two groups of nodes by a certain threshold value for $k$ and $k_{nn}$.
My nodes also have a color. Now I want to test if a certain color in these two groups is overrepresented.
I can do that using the Wilcoxon rank test, because the color is an independent observation. Fine.
But is the color really an independent observation?
Implicitly the association to a group is not only based on the node's own property, but also on the properties of the other nodes (because of $k_{nn}$).
So can I really use the Wilcoxon rank test here?
Actually, my question is:
Does the Wilcoxon rank test require only an independent observation.
Or does it also require an association to a group that is based on independent observations?
Answer: Regardless of the graph's coloring, associated with each of its nodes is a pair $(k, k_{nn})$.  You have used these pairs to classify the nodes into two groups.  The coloring separately classifies the nodes by color.  This is the situation of a $c$ by $2$ contingency table with fixed margins.  To assess whether color is associated with node group, use an appropriate test of association: Fisher's Exact Test if the counts are not too large; otherwise a chi-squared test.


ASP.Net MVC Jquery UI Autocomplete - list not showing up when I debug

Question: I have implemented an autocomplete in my app for zip codes.  I am debugging in Firebug and I see in my console that the action is performing and I get a list of zip codes in the list of results, but the actual list is not displaying when I debug.
Here's the action in my Customers controller:
//the autocomplete request sends a parameter 'term' that contains the filter
public ActionResult FindZipCode(string term)
{
    string[] zipCodes = customerRepository.FindFilteredZipCodes(term);

    //return raw text, one result on each line
    return Content(string.Join("\n", zipCodes));
}

Here's the markup (abbreviated)
<% using (Html.BeginForm("Create", "Customers")) {%>
<input type="text" value="" name="ZipCodeID" id="ZipCodeID" />
<% } %>

and here's the order I load my scripts:

Anything obvious that I'm missing?  Like I say the script is grabbing the list of zip codes, they just won't display on my page when I test.
EDIT:  I added an image that shows what I see in firebug - it appears that I get my zip codes back, but just won't display the dropdown.

I also updated my text box so that it's inside of the ui-widget div like so:

    <input type="text" name="ZipCodeID" id="ZipCodeID" />

and this is the script that I'm using:

Answer: I was able to get the autocomplete suggestions working using the following code:
Controller:
public JsonResult FindZipCode(string term)
    {
        VetClinicDataContext db = new VetClinicDataContext();

        var zipCodes = from c in db.ZipCodes
                       where c.ZipCodeNum.ToString().StartsWith(term)
                       select new { value = c.ZipCodeID, label = c.ZipCodeNum};

        return this.Json(zipCodes, JsonRequestBehavior.AllowGet);
    }

Markup:

<input type="text" name="ZipCodeID" id="ZipCodeID" />

Answer: I had huge problems with autocomplete few months ago when first setting it up. For instance, the simple default wireup like you do it never worked for me. I had to specify everything and also attach the result function to it.
This works 100% but it might not be suitable for you. But I hope it helps. Put both in document.ready() function.
$("#products").autocomplete('<%:Url.Action("GetProducts", "Product") %>', {
    dataType: 'json',
    parse: function (data) {
        var rows = new Array(data.length), j;
        for (j = 0; j < data.length; j++) {
            rows[j] = { data: data[j], value: data[j].Title, result: data[j].Title };

        }
        return rows;
    },
    formatItem: function (row, y, n) {
        return row.PrettyId + ' - ' + row.Title + ' (' + row.Price + ' €)';
    },
    width: 820,
    minChars: 0,
    max: 0,
    delay: 50,
    cacheLength: 10,
    selectFirst: true,
    selectOnly: true,
    mustMatch: true,
    resultsClass: "autocompleteResults"
});
$("#products").result(function (event, data, formatted) {
    if (data) {

        var item = $("#item_" + data.PrettyId),
                    edititem = $("#edititem_" + data.PrettyId),
                    currentQuantity;
        // etc...
    }
});

Answer: Try returning JSON from your controller action:
public ActionResult FindZipCode(string term)
{
    string[] zipCodes = customerRepository.FindFilteredZipCodes(term);
    return Json(new { suggestions = zipCodes }, JsonRequestBehavior.AllowGet);
}

Also don't forget to include the default CSS or you might not see the suggestions div appear.
Comment: Thanks!  I'm using the CSS that I got with the Theme I'm using (peppergrinder) and it's working for other Jquery ui stuff - like the accordian.  What would the default CSS be?  I don't have one of those...
Comment: Yes, by default I meant the one you got with the theme. Precisely.
Comment: I double checked my CSS and changed my action to retun JSON and it now returns JSON, but still does not show the suggestions div. In fact - I don't have a suggestions div - I just have the UI Widget div and the text input within. Should I have another div for suggestions to show or does the autocomplete functionality handle that?


manipulating strings

Question: I am trying to remove some special characters from a string.
I have got the following string
[_fesd][009] Statement

and I want to get rid of all '_' '['  and ']'
I managed to remove the first characters with TrimStart and I get   fesd][009] Statement
How should I remove the special characters from the middle of my string?
Currently Im using the following code
string newStr = str.Trim(new Char[] { '[', ']', '_' });

where str is the strin that should be manupulated and the result should be stored in newStr
Comment: I would read up on Regex mate. (Regular Expressions). CLeanest way to do things like this.
Comment: Please update your title with your specific problem..
Comment: If performance is a consideration, you may want to review this answer: http://stackoverflow.com/questions/11899668/replacing-multiple-characters-in-a-string-the-fastest-way
Answer: string newStr = str.Replace("[", "").Replace("]", "").Replace("_", "");

Answer: var newStr = Regex.Replace("[_fesd][009] Statement", "(\\[)|(\\])|(_)", string.Empty);

Answer: Use string.Replace with string.Empty as the string to replace with.
Answer: You could use Linq for it:
static void Main(string[] args)
{
    var s = @"[_fesd][009] Statement";
    var unwanted = @"_[]";

    var sanitizedS = s
        .Where(i => !unwanted.Contains(i))
        .Aggregate<char, string>("", (a, b) => a + b);

    Console.WriteLine(sanitizedS);
    // output: fesd009 Statement
}

Answer: var chars = new Char[] { '[', ']', '_' };
var newValue = new String(str.Where(x => !chars.Contains(x)).ToArray());

manipulating strings


Getting WSOD, can't view any errors even after editing index.php

Question: I've tried entering:
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);

at the beginning of my index.php file (after begin php tag and it hasn't done anything.  When I run cron, it comes back and tells me that everything is ok.
Here's a brief overview of things that have transpired today:

I updated my views modules and made a database backup (i have no idea
how to restore from this, btw)
I updated to core .24
I ran cron andfixed errors concerning .htaccess files. I followed this tutorial:
https://drupal.org/SA-CORE-2013-003
I turned off error reporting (cause it's a production server: www.jcoledesign.com is the address)
All hell broke loose.  At first it stopped loading some images, then it stopped loading all CSS, this is likely due to caching
I added the above code to my index.php file
I cleared cache, went back and tried to replace my .htdocs files with something more simplistic and still no go.
I'm running out of ideas and nothing I try from here or google seems to work.

Please help and thanks in advance!
Comment: Did you also run the update.php?
Comment: Related: [How to see the error messages when I get the white screen of death?](http://drupal.stackexchange.com/questions/7560/how-to-see-the-error-messages-when-i-get-the-white-screen-of-death)
Comment: Too many things changed at a time. Can you tell us exactly between which steps site stopped working? I guess turning error reporting off wasn't the trigger and it must have happened earlier? Can you restore from backup and then try, testing step by step? And can you access server's error.log ?
Comment: When I try to run update.php it just gives me a blank screen.  I'm guessing that it's something to do with a server call.
Comment: I'm guessing that messing with the htaccess files is what screwed it up, cause it seemed like it stopped uncaching things afterwords.  I had a WSOD problem earlier when I first installed and a server admin from my hosting company said he fixed it by changing my htaccess files.  I reviewed some of the changes he made and it looks like he just added

SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006

and commented out Options +FollowSymLinks   I tried remaking these changes but it was to no avail.
Comment: Also, after I updated the core to 7.24, I did ran update.php and it noticed that I needed to update the image module.  I did that shortly before running cron and trying to fix the HTACCESS issues. I didn't notice anything not caching after I did this though.
Answer: I figured it out!
The .htaccess file in sites/defaults/files/  CAN NOT include Deny from all
The tutorial I referenced earlier mentioned that /temp/.htaccess should have this included, but it didn't say that if you included it in other files that it would crash your site.
As a side note: It would be great if there was a basic tutorial out there for .htaccess files so that I can get an understanding of everything that's going on here without having to spend months/years learning everything else associated with hosting a drupal website completely inside and out.
Comment: There are tutorials on htaccess files all right. My google search results: [1](http://www.javascriptkit.com/howto/htaccess.shtml) [2](http://www.freewebmasterhelp.com/tutorials/htaccess/) [3](http://httpd.apache.org/docs/2.2/howto/htaccess.html) [4](http://net.tutsplus.com/tutorials/other/the-ultimate-guide-to-htaccess-files/) (randomized order).
Comment: I just found out the same issue. It was because some of my theming files are located in sites/default/files. So most of the css stopped working. After removing 'Deny from all' from the .htacess everything went back to normal. Now, is it mandatory to have 'Deny from all' to get on the safe side?
Comment: Yes, you should have it in /temp/.htaccess  , but apparently not in /defaults/files/ since it kills everything.


Installing MySQLdb for python2.7

Question: I have various versions of python (python2.4 and python2.7) installed on the CentOS machine. I installed MySQL-python, but I can only import the MySQLdb module on python2.4 but not python2.7
<code>root# python2.7
Python 2.7.11 |Continuum Analytics, Inc.| (default, Dec  6 2015, 18:08:32)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> import MySQLdb
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
ImportError: No module named MySQLdb

root# python
Python 2.4.3 (#1, Mar  5 2011, 21:26:05)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-50)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
>>>
</code>
I've tried alias'ing python to /usr/bin/python2.7 and then doing a 'yum remove MySQL-python' and then doing a 'yum install MySQL-python' but no luck. Any clues/insights? Thanks.
Answer: The yum will install the MySQL-python to the system default python's directory.
maybe you can try virtualenv and pip.

install the pip
pip install virtualenv
virtualenv -p /the/localtion/of/python27 python27
active the new python envirement, and pip install MySQL-python

Installing MySQLdb for python2.7


Trouble starting OpenVPN for the first time. Address already in use (errno=98)

Question: I have installed and configured OpenVPN on CentOS 7 for the first time and can't seem to get it to start. I am attempting to create a VPN in bridge mode so that connected clients are assigned IPs in the 192.168.2.0/24 range and so that they can talk with our servers on the 192.168.1.0/24 range. I would really appreciate any advice on where I'm making a mistake on configuration. Thank you!
Below are the errors I am running into and related config files / iptables.
systemctl status email@example.com:
● email@example.com - OpenVPN Robust And Highly Flexible Tunneling Application On server
   Loaded: loaded (/usr/lib/systemd/system/openvpn@.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Wed 2020-03-04 13:47:57 EST; 34min ago
  Process: 30058 ExecStart=/usr/sbin/openvpn --cd /etc/openvpn/ --config %i.conf (code=exited, status=1/FAILURE)
 Main PID: 30058 (code=exited, status=1/FAILURE)

Mar 04 13:47:57 atlgate systemd[1]: Starting OpenVPN Robust And Highly Flexible Tunneling Application On server...
Mar 04 13:47:57 atlgate openvpn[30058]: Options error: In [CMD-LINE]:1: Error opening configuration file: server.conf
Mar 04 13:47:57 atlgate openvpn[30058]: Use --help for more information.
Mar 04 13:47:57 atlgate systemd[1]: email@example.com: main process exited, code=exited, status=1/FAILURE
Mar 04 13:47:57 atlgate systemd[1]: Failed to start OpenVPN Robust And Highly Flexible Tunneling Application On server.
Mar 04 13:47:57 atlgate systemd[1]: Unit firstname.lastname@example.com entered failed state.
Mar 04 13:47:57 atlgate systemd[1]: email@example.com failed.

openvpn --config /etc/openvpn/server/server.conf:
Wed Mar  4 14:25:35 2020 OpenVPN 2.4.8 x86_64-redhat-linux-gnu [Fedora EPEL patched] [SSL (OpenSSL)] [LZO] [LZ4] [EPOLL] [PKCS11] [MH/PKTINFO] [AEAD] built on Nov  1 2019
Wed Mar  4 14:25:35 2020 library versions: OpenSSL 1.0.2k-fips  26 Jan 2017, LZO 2.06
Wed Mar  4 14:25:35 2020 NOTE: when bridging your LAN adapter with the TAP adapter, note that the new bridge adapter will often take on its own IP address that is different from what the LAN adapter was previously set to
Wed Mar  4 14:25:35 2020 Diffie-Hellman initialized with 2048 bit key
Wed Mar  4 14:25:35 2020 TUN/TAP device tap0 opened
Wed Mar  4 14:25:35 2020 TUN/TAP TX queue length set to 100
Wed Mar  4 14:25:35 2020 Could not determine IPv4/IPv6 protocol. Using AF_INET
Wed Mar  4 14:25:35 2020 Socket Buffers: R=[212992->212992] S=[212992->212992]
Wed Mar  4 14:25:35 2020 TCP/UDP: Socket bind failed on local address [AF_INET][undef]:1194: Address already in use (errno=98)
Wed Mar  4 14:25:35 2020 Exiting due to fatal error
Wed Mar  4 14:25:35 2020 Closing TUN/TAP interface

service.conf:

# Which local IP address should OpenVPN
# listen on? (optional)
;local a.b.c.d

# Which TCP/UDP port should OpenVPN listen on?
# If you want to run multiple OpenVPN instances
# on the same machine, use a different port
# number for each one.  You will need to
# open up this port on your firewall.
port 1194

# TCP or UDP server?
;proto tcp
proto udp

# "dev tun" will create a routed IP tunnel,
# "dev tap" will create an ethernet tunnel.
# Use "dev tap0" if you are ethernet bridging
# and have precreated a tap0 virtual interface
# and bridged it with your ethernet interface.
# If you want to control access policies
# over the VPN, you must create firewall
# rules for the the TUN/TAP interface.
# On non-Windows systems, you can give
# an explicit unit number, such as tun0.
# On Windows, use "dev-node" for this.
# On most systems, the VPN will not function
# unless you partially or fully disable
# the firewall for the TUN/TAP interface.
dev tap0
;dev tun

# Windows needs the TAP-Win32 adapter name
# from the Network Connections panel if you
# have more than one.  On XP SP2 or higher,
# you may need to selectively disable the
# Windows firewall for the TAP adapter.
# Non-Windows systems usually don't need this.
;dev-node MyTap

# SSL/TLS root certificate (ca), certificate
# (cert), and private key (key).  Each client
# and the server must have their own cert and
# key file.  The server and all clients will
# use the same ca file.
#
# See the "easy-rsa" directory for a series
# of scripts for generating RSA certificates
# and private keys.  Remember to use
# a unique Common Name for the server
# and each of the client certificates.
#
# Any X509 key management system can be used.
# OpenVPN can also use a PKCS #12 formatted key file
# (see "pkcs12" directive in man page).
ca /etc/openvpn/easy-rsa/pki/ca.crt
cert /etc/openvpn/easy-rsa/pki/issued/server.crt
key /etc/openvpn/easy-rsa/pki/private/server.key
#original:
;key server.key  # This file should be kept secret

# Diffie hellman parameters.
# Generate your own with:
#   openssl dhparam -out dh2048.pem 2048
#suggested from setup guide
dh /etc/openvpn/easy-rsa/pki/dh.pem
#Original
#dh dh2048.pem

# Network topology
# Should be subnet (addressing via IP)
# unless Windows clients v2.0.9 and lower have to
# be supported (then net30, i.e. a /30 per client)
# Defaults to net30 (not recommended)
topology subnet

# Configure server mode and supply a VPN subnet
# for OpenVPN to draw client addresses from.
# The server will take 10.8.0.1 for itself,
# the rest will be made available to clients.
# Each client will be able to reach the server
# on 10.8.0.1. Comment this line out if you are
# ethernet bridging. See the man page for more info.
;server 192.168.2.0 255.255.255.0

# Maintain a record of client <-> virtual IP address
# associations in this file.  If OpenVPN goes down or
# is restarted, reconnecting clients can be assigned
# the same virtual IP address from the pool that was
# previously assigned.
ifconfig-pool-persist ipp.txt

# Configure server mode for ethernet bridging.
# You must first use your OS's bridging capability
# to bridge the TAP interface with the ethernet
# NIC interface.  Then you must manually set the
# IP/netmask on the bridge interface, here we
# assume 10.8.0.4/255.255.255.0.  Finally we
# must set aside an IP range in this subnet
# (start=10.8.0.50 end=10.8.0.100) to allocate
# to connecting clients.  Leave this line commented
# out unless you are ethernet bridging.
server-bridge 192.168.2.1 255.255.255.0 192.168.2.100 192.168.2.200

# Configure server mode for ethernet bridging
# using a DHCP-proxy, where clients talk
# to the OpenVPN server-side DHCP server
# to receive their IP address allocation
# and DNS server addresses.  You must first use
# your OS's bridging capability to bridge the TAP
# interface with the ethernet NIC interface.
# Note: this mode only works on clients (such as
# Windows), where the client-side TAP adapter is
# bound to a DHCP client.
server-bridge

# Push routes to the client to allow it
# to reach other private subnets behind
# the server.  Remember that these
# private subnets will also need
# to know to route the OpenVPN client
# address pool (10.8.0.0/255.255.255.0)
# back to the OpenVPN server.
push "route 192.168.1.0 255.255.255.0"
;push "route 192.168.20.0 255.255.255.0"

# To assign specific IP addresses to specific
# clients or if a connecting client has a private
# subnet behind it that should also have VPN access,
# use the subdirectory "ccd" for client-specific
# configuration files (see man page for more info).

# EXAMPLE: Suppose the client
# having the certificate common name "Thelonious"
# also has a small subnet behind his connecting
# machine, such as 192.168.40.128/255.255.255.248.
# First, uncomment out these lines:
;client-config-dir ccd
;route 192.168.40.128 255.255.255.248
# Then create a file ccd/Thelonious with this line:
#   iroute 192.168.40.128 255.255.255.248
# This will allow Thelonious' private subnet to
# access the VPN.  This example will only work
# if you are routing, not bridging, i.e. you are
# using "dev tun" and "server" directives.

# EXAMPLE: Suppose you want to give
# Thelonious a fixed VPN IP address of 10.9.0.1.
# First uncomment out these lines:
;client-config-dir ccd
;route 10.9.0.0 255.255.255.252
# Then add this line to ccd/Thelonious:
#   ifconfig-push 10.9.0.1 10.9.0.2

# Suppose that you want to enable different
# firewall access policies for different groups
# of clients.  There are two methods:
# (1) Run multiple OpenVPN daemons, one for each
#     group, and firewall the TUN/TAP interface
#     for each group/daemon appropriately.
# (2) (Advanced) Create a script to dynamically
#     modify the firewall in response to access
#     from different clients.  See man
#     page for more info on learn-address script.
;learn-address ./script

# If enabled, this directive will configure
# all clients to redirect their default
# network gateway through the VPN, causing
# all IP traffic such as web browsing and
# and DNS lookups to go through the VPN
# (The OpenVPN server machine may need to NAT
# or bridge the TUN/TAP interface to the internet
# in order for this to work properly).
;push "redirect-gateway def1 bypass-dhcp"

# Certain Windows-specific network settings
# can be pushed to clients, such as DNS
# or WINS server addresses.  CAVEAT:
# http://openvpn.net/faq.html#dhcpcaveats
# The addresses below refer to the public
# DNS servers provided by opendns.com.
;push "dhcp-option DNS 18.104.22.168"
;push "dhcp-option DNS 18.104.22.168"

# Uncomment this directive to allow different
# clients to be able to "see" each other.
# By default, clients will only see the server.
# To force clients to only see the server, you
# will also need to appropriately firewall the
# server's TUN/TAP interface.
;client-to-client

# Uncomment this directive if multiple clients
# might connect with the same certificate/key
# files or common names.  This is recommended
# only for testing purposes.  For production use,
# each client should have its own certificate/key
# pair.
#
# IF YOU HAVE NOT GENERATED INDIVIDUAL
# CERTIFICATE/KEY PAIRS FOR EACH CLIENT,
# EACH HAVING ITS OWN UNIQUE "COMMON NAME",
# UNCOMMENT THIS LINE OUT.
;duplicate-cn

# The keepalive directive causes ping-like
# messages to be sent back and forth over
# the link so that each side knows when
# the other side has gone down.
# Ping every 10 seconds, assume that remote
# peer is down if no ping received during
# a 120 second time period.
keepalive 10 120

# For extra security beyond that provided
# by SSL/TLS, create an "HMAC firewall"
# to help block DoS attacks and UDP port flooding.
#
# Generate with:
#   openvpn --genkey --secret ta.key
#
# The server and each client must have
# a copy of this key.
# The second parameter should be '0'
# on the server and '1' on the clients.
;tls-auth ta.key 0 # This file is secret

# Select a cryptographic cipher.
# This config item must be copied to
# the client config file as well.
# Note that v2.4 client/server will automatically
# negotiate AES-256-GCM in TLS mode.
# See also the ncp-cipher option in the manpage
cipher AES-256-CBC

# Enable compression on the VPN link and push the
# option to the client (v2.4+ only, for earlier
# versions see below)
;compress lz4-v2
;push "compress lz4-v2"

# For compression compatible with older clients use comp-lzo
# If you enable it here, you must also
# enable it in the client config file.
;comp-lzo

# The maximum number of concurrently connected
# clients we want to allow.
;max-clients 100

# It's a good idea to reduce the OpenVPN
# daemon's privileges after initialization.
#
# You can uncomment this out on
# non-Windows systems.
;user nobody
;group nobody

# The persist options will try to avoid
# accessing certain resources on restart
# that may no longer be accessible because
# of the privilege downgrade.
persist-key
persist-tun

# Output a short status file showing
# current connections, truncated
# and rewritten every minute.
status openvpn-status.log

# By default, log messages will go to the syslog (or
# on Windows, if running as a service, they will go to
# the "\Program Files\OpenVPN\log" directory).
# Use log or log-append to override this default.
# "log" will truncate the log file on OpenVPN startup,
# while "log-append" will append to it.  Use one
# or the other (but not both).
;log         openvpn.log
;log-append  openvpn.log

# Set the appropriate level of log
# file verbosity.
#
# 0 is silent, except for fatal errors
# 4 is reasonable for general usage
# 5 and 6 can help to debug connection problems
# 9 is extremely verbose
verb 3

# Silence repeating messages.  At most 20
# sequential messages of the same message
# category will be output to the log.
;mute 20

# Notify the client that when the server restarts so it
# can automatically reconnect.
explicit-exit-notify 1

ifconfig -a: (external IP modified)
enp12s0: flags=4098<BROADCAST,MULTICAST>  mtu 1500
        ether 00:1e:4f:c9:8a:86  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 16

enp2s4f0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.34  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::2e0:edff:fe0d:2284  prefixlen 64  scopeid 0x20<link>
        ether 00:e0:ed:0d:22:84  txqueuelen 1000  (Ethernet)
        RX packets 133312286  bytes 32872147591 (30.6 GiB)
        RX errors 0  dropped 127  overruns 0  frame 0
        TX packets 243540257  bytes 353658118727 (329.3 GiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 24

enp2s4f1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 55.50.033.1  netmask 255.255.255.248  broadcast 220.127.116.11
        inet6 fe80::2e0:edff:fe0d:2285  prefixlen 64  scopeid 0x20<link>
        ether 00:e0:ed:0d:22:85  txqueuelen 1000  (Ethernet)
        RX packets 243468624  bytes 353664332100 (329.3 GiB)
        RX errors 0  dropped 157  overruns 0  frame 0
        TX packets 132681627  bytes 32817632124 (30.5 GiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 28

enp3s6f0: flags=4098<BROADCAST,MULTICAST>  mtu 1500
        ether 00:e0:ed:0d:22:86  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 29

enp3s6f1: flags=4098<BROADCAST,MULTICAST>  mtu 1500
        ether 00:e0:ed:0d:22:87  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 30

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1  (Local Loopback)
        RX packets 46  bytes 3844 (3.7 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 46  bytes 3844 (3.7 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

tap0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 192.168.2.1  netmask 255.255.255.0  broadcast 192.168.2.255
        inet6 fe80::2012:feff:fe7c:ffd4  prefixlen 64  scopeid 0x20<link>
        ether 22:12:fe:7c:ff:d4  txqueuelen 100  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 2 overruns 0  carrier 0  collisions 0

tun1: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST>  mtu 1500
        inet 192.168.41.1  netmask 255.255.255.0  destination 192.168.41.1
        inet6 fe80::a93e:39b1:d3b6:6669  prefixlen 64  scopeid 0x20<link>
        unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  txqueuelen 100  (UNSPEC)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 10993  bytes 660776 (645.2 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     udp  --  anywhere             anywhere             udp dpt:openvpn
RH-Firewall-1-INPUT  all  --  anywhere             anywhere
ACCEPT     udp  --  anywhere             anywhere             state NEW udp dpt:openvpn

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination
RH-Firewall-1-INPUT  all  --  anywhere             anywhere

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

Chain RH-Firewall-1-INPUT (2 references)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere
ACCEPT     icmp --  anywhere             anywhere             icmp any
ACCEPT     all  --  anywhere             anywhere             state RELATED,ESTABLISHED
ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:ici
ACCEPT     udp  --  anywhere             anywhere             state NEW udp dpt:openvpn
ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:pptp
ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:snapenetio
ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:optocontrol
ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:22020
ACCEPT     udp  --  anywhere             anywhere             state NEW udp dpt:isakmp
ACCEPT     udp  --  anywhere             anywhere             state NEW udp dpt:l2tp
ACCEPT     udp  --  anywhere             anywhere             state NEW udp dpt:ipsec-nat-t
REJECT     all  --  anywhere             anywhere             reject-with icmp-host-prohibited

Comment: something is already using port 1194.  What do you see from `ss -nlp | grep :1194`
Comment: hmmm: `udp    UNCONN     0      0         *:1194                  *:*                   users:(("openvpn",pid=1010,fd=6))`
Comment: So now I don't know if its actually running or not...but `systemctl status openvpn@server` shows `Failed to start OpenVPN Robust And Highly Flexible Tunneling Application On server.`
Comment: the output shows that something is running.  Perhaps you have another instance of openvpn.  Perhaps it got started incorrectly earlier.  You will have to investigate.  The `ss` output shows you the pid.
Comment: It looks there already openvpn running on the 1194 with the same subnet you have in your file. So check also if there is another systemd unit for the same configuration file
Comment: Thanks everyone, there was an openvpn already setup on 1194. Solved.
Answer: Thanks everyone, there was a previously configured session pf openvpn already running on this server. Solved.


Fourier transform of an $L^p$ function need not be a function

Question: Fourier transforms can be defined for any $L^p$ function for $1\leq p \leq \infty$ by treating them as a tempered distribution. I am looking for an explicit example of an $L^p$ function whose Fourier transform is a tempered distribution which is not generated by any function.
Explicit counter example, with a justification as to why its Fourier transform is not of function type will be greatly appreciated.
Thanks in advance.
Comment: Fourier transform of a constant is just a weighted Dirac Delta distribution, which of course is not a function.
Answer: We can replace "Fourier transform" in your question with "inverse Fourier transform", by Fourier inversion, in the sense of distributions. Recall the $\text{pv}(\frac{1}{x})$ distribution defined by
$$
\text{pv}(\frac{1}{x})(\varphi) = \lim_{\epsilon \to 0^+}\int_{|x|\ge\epsilon} \frac{\varphi(x)}{x}\ \mathrm{d}x
$$
for Schwartz $\varphi$. The Fourier transform of this distribution is $-i\pi \text{sgn}(\xi)$ which belongs to $L^{\infty}(\mathbb{R})$, yet $\text{pv}(\frac{1}{x})$ is not a function. If it were, then it would agree with $1/x$ away from the origin, and in particular almost everywhere. However $1/x$ is not locally integrable, so it is not a distribution on $\mathbb{R}$.
Answer: The constant function $x\mapsto 1$ belongs to $L^\infty(\mathbb R)$ and has Fourier transform $2\pi\delta,$ which is not a function.


Listview dentro de Listview ou Repeat dentro de Repeat?

Question: Preciso exibir alguns produtos divididos por categoria, as categorias sao criadas pelo usuario e ambos vem do banco de dados TB_CATEGORIA, TB_PRODUTOS, tem como fazer com Listview, Repeat?
Por exemplo:

Especiais
Produto 1
  Produto 2
Livros
Livro 1
  Livro 2
Antigos
Produto1 Produto2
Comment: É possível fazer os famigerados "Nested Repeaters" ou "Nested ListViews" da vida sim, e isso provavelmente vai resolver seu problema, mas vou confessar que colocar um repeater dentro do outro me deu uma baita dor de cabeça por conta de alguns detalhes infelizes da implementação deles. basta escrever "nested repeater" no google e você verá e enxurrada de perguntas relacionadas a isso (meu evento não dispara, meus dados nao carregam, etc)
Answer: Aspx:
<form id="form1" runat="server">
    <asp:Repeater ID="rptCategorias" runat="server">
        <ItemTemplate>
            <asp:Label ID="lblCategoria" runat="server" Text='<%# Bind("Nome") %>'></asp:Label>

            <asp:Repeater ID="rptProdutos" runat="server">
                <ItemTemplate>
                    <asp:Label ID="lblProduto" runat="server" Text='<%# Bind("Nome") %>'></asp:Label>
                </ItemTemplate>
            </asp:Repeater>

        </ItemTemplate>
    </asp:Repeater>
</form>

Aspx.cs:
public partial class _default : Page
{

    private DataSet1 ds = new DataSet1();

    protected void Page_Load(object sender, EventArgs e)
    {
        ds.TB_CATEGORIA.AddTB_CATEGORIARow(1, "Especiais");
        ds.TB_PRODUTOS.AddTB_PRODUTOSRow(1, ds.TB_CATEGORIA.FindById(1), "Produto 1");
        ds.TB_PRODUTOS.AddTB_PRODUTOSRow(2, ds.TB_CATEGORIA.FindById(1), "Produto 2");

        ds.TB_CATEGORIA.AddTB_CATEGORIARow(2, "Livros");
        ds.TB_PRODUTOS.AddTB_PRODUTOSRow(3, ds.TB_CATEGORIA.FindById(2), "Livro 1");
        ds.TB_PRODUTOS.AddTB_PRODUTOSRow(4, ds.TB_CATEGORIA.FindById(2), "Livro 2");

        ds.TB_CATEGORIA.AddTB_CATEGORIARow(3, "Antigos");
        ds.TB_PRODUTOS.AddTB_PRODUTOSRow(5, ds.TB_CATEGORIA.FindById(3), "Antigos 1");
        ds.TB_PRODUTOS.AddTB_PRODUTOSRow(6, ds.TB_CATEGORIA.FindById(3), "Antigos 2");

        rptCategorias.DataSource = ds;
        rptCategorias.DataMember = "TB_CATEGORIA";
        rptCategorias.ItemDataBound += rptCategorias_ItemDataBound;
        rptCategorias.DataBind();
    }

    protected void rptCategorias_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            var rptProdutos = (Repeater)e.Item.FindControl("rptProdutos");
            var row = ((DataRowView) e.Item.DataItem).Row;

            rptProdutos.DataSource = row.GetChildRows(ds.Relations["TB_CATEGORIA_TB_PRODUTOS"]);
            rptProdutos.DataBind();
        }
    }

}

Comment: E se o segundo Repeater tiver ItemCommand, ItemCreated?
Answer: No aspx, inclua dentro de ItemTemplate
<asp:LinkButton runat="server" ID="btnEdit" CommandName="Edit"
CommandArgument='<%# Bind("Id") %>' Text="Add"></asp:LinkButton>

No codebehind, inclua no evento rptCategorias_ItemDataBound
rptProdutos.ItemCommand += rptProdutos_ItemCommand;

Crie o evento
private void rptProdutos_ItemCommand(object source, RepeaterCommandEventArgs e)
{
    switch (e.CommandName)
    {
        case "Edit":
            // Your code
            break;
    }
}


symfony 2.8 locale reseting every request

Question: Example:
I am trying to set locale to English:
public function innerPageAction(Request $request, $slug)
{
    $request->setLocale('en');
    return $this->render('@App/Front/Default/inner.html.twig', [
        ...
    ]);
}

Then I get back to homepage
public function indexAction(Request $request)
{
    $locale = $request->getLocale();
    return $this->render('@App/Front/Default/home.html.twig', [
        'locale' => $locale,
    ]);
}

And this returns my default locale ('lt').
My config file looks like:
parameters:
    locale: lt
framework:
    default_locale:  "%locale%"

I am trying to make locale sticky as it is described here: http://symfony.com/doc/current/session/locale_sticky_session.html
but it seems that its setting locale always to defaultLocale. Why?
How I can achieve that when im moving from inner page to homepage, it would return "en" not default locale "lt"?
Answer: $request->setLocale('en');

is only temporary meaning it is not persisted, so when you visit another page the request locale takes the default value from the configuration file, if you follow this link (same link that you provided)
class LocaleListener implements EventSubscriberInterface
{
    private $defaultLocale;

    public function __construct($defaultLocale = 'en')
    {
        $this->defaultLocale = $defaultLocale;
    }

    public function onKernelRequest(GetResponseEvent $event)
    {
        $request = $event->getRequest();
        if (!$request->hasPreviousSession()) {
            return;
        }

        // try to see if the locale has been set as a _locale routing parameter
        if ($locale = $request->attributes->get('_locale')) {
            $request->getSession()->set('_locale', $locale);
        } else {
            // if no explicit locale has been set on this request, use one from the session
            $request->setLocale($request->getSession()->get('_locale', $this->defaultLocale));
        }
    }

    public static function getSubscribedEvents()
    {
        return array(
            // must be registered after the default Locale listener
            KernelEvents::REQUEST => array(array('onKernelRequest', 15)),
        );
    }
}

the onKernelRequest method is executed on every request, if the locale was set in session it is applied by using $request->setLocale($locale), this way you'll have a 'sticky' locale on every page.
Comment: I understand this, but as I said, its not working. I never get to this: $request->getSession()->set('_locale', $locale); and $request->setLocale($request->getSession()->get('_locale', $this->defaultLocale)); sets locale to 'lt' all the time. And I dont understand why.
Comment: Symfony 4.3 here, I'm experiences the same problem. `$request->getLocale()` and `$request->getSession()->get('_locale')` always return the default locale, never the locale set in the url
Answer: In your event listener's (or subscriber's) onKernelRequest need an extra line:
    // try to see if the locale has been set as a _locale routing parameter
    if ($locale = $request->attributes->get('_locale')) {
        $request->getSession()->set('_locale', $locale);
        $request->setLocale($locale); // seems that it's SIGNIFICANT
    } else {
        // if no explicit locale has been set on this request, use one from the session
        $request->setLocale($request->getSession()->get('_locale', $this->defaultLocale));
    }


Erro por causa desconhecida: "SyntaxError: invalid range in character class"

Question: Situação:
Tenho uma página que contém um  de outra, nesta outra página, tenho um simples elemento HTML input:
<input type="text" required="" pattern="[a-Z]{2,35}" tabindex="6" name="edtCidade" id="edtCidade">

Tenho certeza e me certifiquei que não há nenhum tipo de evento atribuído à ele ou código alterando suas propriedades.
Porém, toda vez que eu digito, qualquer tecla, pode ser número, pode ser letra, qualquer coisa, à cada vez que eu digito me gera este erro no console:

SyntaxError: invalid range in character class

Exemplo:
Se eu digitar "az123" eu vou ter 5 erros de SyntaxError no console de meu navegador.
Importante:
Este erro não me causa nenhum problema, ele é insignificante porém está me incomodando, e gostaria de saber a origem dele.
Pergunta:
Como resolver este erro? Porque ele é ocasionado? Gostaria de uma explicação detalhada.
Answer: O erro é associado à expressões regulares, sendo causado pelo range a-Z (a minúscula e Z maiúsculo) no atributo pattern.
Como o atributo pattern é um elemento do input incluído no HTML5, a expressão será executada mesmo sem nenhum plugin ou evento adicional.
Para aceitar letras maiúsculas e minúsculas, use [a-zA-Z], pois parece não haver uma forma de tornar o padrão case insensitive.
Nota: no Chrome não ocorre essa exceção, ele apenas ignora a validação. Imagino, então, que você esteja usando o Firefox. :)
Demo no JsFiddle
Answer: As listas em expressões regulares são baseadas na tabela ASCII (http://www.asciitable.com/). Segundo essa tabela, a é o caractere de número 97 e Z é o caractere de número 90 – por causa disso, não faz sentido você escrever uma lista que diz "aqui são válidos todos os caracteres entre 97 e 90" (o primeiro número deve ser menor do que o segundo).
O comum é fazer [a-zA-Z0-9_]+ ou, simplesmente, \w+. Para validar apenas números use [0-9]+, ou \d+.
Comment: Só pra complementar o `\w` pega `[a-zA-Z0-9_]`
Comment: É verdade, já corrigi. Obrigado!
Comment: O padrão correto a ser utilizado no lugar do `[a-Z]{2,35}` inválido seria `[A-z]{2,35}` correspondente, na tabela ASCII, ao intervalo 65 à 122. No entanto, como já dizia o Mestre Aurélio: `Não use o intervalo A-z, prefira A-Za-z`, isso porque esse intervalo abrange seis outros caracteres, a saber: [ \ ] ^ _ ` os quais sem a devido cautela podem ser um problema para a Aplicação.
Answer: É um erro de expressão regular.
[a-Z]{2,35} não é vlálido
Use [a-zA-Z]{2,35}

Tente usar
<input type="text" required="" pattern="[a-zA-Z]{2,35}" tabindex="6" name="edtCidade" id="edtCidade">


ACCEPT statements in policy DROP

Question: I'm trying to set up some rules using IPtables under Debian (Wheezy) and have been running in to some problems i think.
The policy of INPUT is set to DROP.
Does this drop everything based on the rules I put into INPUT or is it like a standard ACL-list in some routers, meaning that everything not matched by the statements (if they are set with ACCEPT) will result in a DROP?
Take this as an example:
Chain INPUT (policy DROP)
target     prot opt source               destination
ACCEPT     tcp  --  anywhere             anywhere             tcp dpts:ftp-data:ftp

Will these ftp-packets drop or will they be accepted and everything else will drop?
I hope I'm not messing it up to much.
Answer: "meaning that everything not matched by the statements (if they are set with ACCEPT) will result in a DROP?" - correct. It's a default.
Answer: From man iptables:
-j, --jump target
 This specifies the target of the rule; i.e., what to do
 if the packet matches it. The target can be...one of the
 special builtin targets which decide the fate of the
 packet immediately

and
ACCEPT means to let the packet through.

Logging always helps for understanding the flow. Try: iptables -A INPUT -j LOG.
If you're particularly trying to set up FTP, have a look at --state RELATED.

ACCEPT statements in policy DROP


Couldn't able to hit the register page of Spring Security UI

Question: Hi I have installed the spring security UI plugin in my grails app. I'm trying to create the registration page from Facebook registration, rather than from plugins default register page.
I'm decoding the response and getting back the username,email and password.
Now I wish I need to send them to the RegisterController's register action. Like:
 redirect(controller:"register",action:"register",params:[username:username,email:email])

But when I do redirect, I get an 405 error.
But I can see RegisterController in the plugin directory.
What I'm missing here?
Thanks in advance
Answer: If you look at the RegisterController what methods are allowed for the register action? A 405 error is method not allowed. Which may mean you a doing a GET on an action that only allows POST.
Looking at the spring security UI plugin it looks like it is expecting a Post with a command object for that action but if you don't need the user to enter any more details you should be able to just create the user directly from the data you have now.
Comment: Ya now I have all the data, I even do the `post` call to `register` but how do I show the successful registration, to the user? I can see only the view of the controller from which `register` is been called!


(How) Do the terms "open" and "close" position apply to chords with multiple doublings?

Question: Based on Open/Close Position Chords: What I am missing?

a simple triad (no doubling) is in "close position" if the chord tones are packed as closely together as possible, and
in a four-voice texture, "close/open position" refers to the distance between the tenor and soprano, but the bass is allowed to be separated.

Do the terms apply beyond that? For example, in a comment on an answer to The F chord is F0, A0, C1. If you change the octaves of one of the notes, is it still an F chord?, the following voicing is proposed:

So i can have 5 notes - F1,F2,F3 A0, C1 and its still F major?

Would this be open or close position? And why?
One can imagine all sorts of other doubled voicings that don't fit cleanly into the usual definitions. There can also be incomplete but unambiguous chords, such as seventh chords, which often omit the fifth, and, in context, even major and minor triads can omit the fifth and retain their essential character.
I'm looking for a general answer to whether, when, and how the terms "open" and "close" apply beyond the basic definitions.
Comment: We seem to be having a lot of questions lately about "what is the _official_, authoritative definition of (some musical term)". As there _is_ no authority that officially defines musical terms I always feel there's somethng a bit off about such questions. In a way, you've already answered your question. Per the received idea of what the official meaning is, when you ask "Do the terms apply beyond that?", the answer is "no".
Comment: I agree. While some definitions obviously are more strict and not open to interpretation, things like these are absolutely more vague. I'd say that, actually, it's also not that important: close and open are definitions that do not define an aspect in a definite way, and they're more used as reference, indication, partial description. It's almost as asking if a piece of music is "slow or fast": yes, if it's an Adagio is slow, if there's a Vivace it certainly is fast, but then there's a whole gray area in the middle, and we already know that we don't need those absolute definitions there.
Comment: @JudyN. - it actually is an opposite! Open the door, close the door. As in open - shut. But those are verbs. Here we have adjectives - and as such , an *open* door, a *closed* door. Which actually is a lot closer (sic) to the matter in hand. An open chord, compared to a closed chord. To me, as an ex English teacher, it makes sense. And yes, in Br. Eng.
Comment: Is this the most useful way of dealing with musical terms? I certainly don't think so. But this constant reaching for an authoritative, settled answer on usage of terms surely leads inevitably to this. We may prefer to ask "in what way is the distinction between open and closed position useful in this wider context and how best should it be applied"
Comment: I'll go with you on 'close' - my bible says so. But an incredible number of references to 'closed' out there.Close to me is evocative of barber shop harmony. Now *that's* close.
Comment: @Tim 'Close' also isn't an antonym of 'open' (or, at least not in British English.......)
Comment: @JudyN. - and, we don't know whether it's 'cloce' or 'cloze' - or do we?
Comment: @Tim: we do. It's "close" not "cloze". "Cloze" is a (very!) common misnomer for exactly the reasons you state: it makes sense as an antonym to "open".
Answer: While these terms are most commonly used in introductory textbooks to describe three-note chords or four-part harmony (with bass treated as a sort of separate part of the texture), I've definitely seen the terms used with other types of chords on occasion.
The implication, to me, with "close position" is that all notes are clustered on adjacent chord tones.  As noted, the bass is sometimes treated as independent, so its location doesn't matter.  Also, I'm pretty sure I've seen the term used to refer to a subsection of a texture, e.g., "these three instruments are in close position," where other instruments may be further distanced.
So, it's not necessarily always applicable to an entire texture.  It's referring to voices that are directly placed on adjacent chord tones.  If there's a gap where a chord tone is skipped between adjacent voices, those voices -- however many there are -- are no longer in "close position."  It seems reasonable to extend this definition to more than three voices, again as long as there are no gaps.
Anything else, I suppose, is by definition "open," which is sort of how that term works with 3 or 4 voices anyway.  These terms certainly aren't meant to express great nuance in possible texture/voicing.  There is also an informal sense where "open" means something like "spread out," again referring to some group (or subgroup) of voices that tend to have greater gaps between the voices, rather than being on adjacent chord tones.
When referencing an entire large chord with 5 or more notes, these terms aren't generally that useful.  My sense in that case is that they can occasionally be used to refer to subgroups of voices within a larger texture.  The only time the terms might be useful for the whole chord is if all the notes were on adjacent chord tones (and thus all "close").
But the problem is once you get textures like that, you inevitably start to have doublings at the unison as well as at octaves, and that seems to disrupt the whole classification system -- wouldn't three or four voices in literal unison be the "closest" possible?  Yet, I've never seen the term used that way.
I don't know that I can come up with a source for the above definitions, as it's mostly informal usage when it occurs outside of an introductory textbook.  But I could dig around and find some examples if necessary.
Comment: I have clear memories (in a very different context) of a math professor drilling into our heads that "open is not the same as not closed! closed is not the same as not open!" Again, totally different context, and at the same time it might be that many who use the words "open" and "close" to describe chord voices wouldn't always agree that anything not close is by definition open. Other than that possibility I felt inclined to point out, excellent answer. I think both sonically and theoretically, it makes sense to discount unisons or octaves of the chord root when evaluating open/close.
Answer: Is this...

...really the chord example?
There seems more to talk about with that chord than whether it's in open or close voicing!
Anyway, if the issue is one of sticking hard and fast to a definition, the thing I notice is the question brings in a matter of pitch class. The idea is any voices within a pitch class should be treated the same (or apparently octave doublings within a class are to be reduced to some particular octave.)
But that's a problem for two reasons. I've never seen pitch class explicitly stated as a factor in defining open/close voicing. But the other more important thing is you must differentiate octaves in order to distinguish open/close voicing.
F4 A4 C5 is clearly close, and F4 C5 A5 is clearly open. If we eliminate the octaves we just have F A C and F C A and it simply is unclear about the specific voicing.
With F1 F2 F3 A0 C1 - in ascending order A0 C1 F1 F2 F3 we either have ambiguous A C F or arbitrarily say the Fs all reduce to a particular octave. Perhaps A0 C1 F1 for close or A0 C1 with either F2 or F3 for open.
So, while the OP wasn't specifically suggesting how to reduce the octaves and most definitions don't get into listing octave numbers, showing lots of octave doublings, or mentioning pitch class, it's clear that specific octave must be considered to determine open/close voicing.
At least by my reasoning A0 C1 F1 F2 F3 must be called open.
Comment: In defense of the originator of the bizarre chord example, it began life just as an abstraction to clarify that its OP understood what made an F chord an F chord. It just happened to get me thinking about the scope of the terms "open" and "close".
Comment: @Aaron, I didn't think it was your chord. It serves the purpose regardless. Mostly, I thought it an odd example as voicing definitions usually come up in basic part writing, balanced voicing, etc. and that chord is so far removed from that!
Comment: To say the least. :-)