Flask global variables
Are global variables thread-safe in Flask? How do I share data between requests?
Lots of questions are very generic, &quot;share an experience&quot; kinds of questions. In these cases, I am quite often interested in specific answers that may not have gotten that many upvotes. These questions also tend to elicit lots of responses, so going back to find the answers I'm interested in somewhere in the middle of a sea of responses is a pain. Is there a way to favorite or bookmark these answers? Is it a weakness to use a single shared secret for protecting messages using a Encrypt-then-MAC scheme?    Assuming a system is using AES-256-CBC and a SHA1-HMAC and the same secret key for both operations.  Upon intercepting one of these messages and attacker could brute force this secret key by trying to solve the HMAC or by successfully decrypting the first block of the ciphertext.  Performing  a decryption on a single block of AES-256 should be a lighter operation than performing a SHA1-HMAC on a potentially large message.  Therefore AES-256 is ideal for a massively parallel brute-force attack and the use of the SHA1-HMAC doesn't hurt the system.  Is this approach sound, or is there an attack that has not been taken into consideration? I use LINQ to Objects instructions on an ordered array.  Which operations shouldn't I do to be sure the order of the array is not changed? For which real values of t does the following system of linear equations:  $$ \left\{  \begin{array}{c} tx_1 + x_2 + x_3 = 1 \\  x_1 + tx_2 + x_3 = 1 \\  x_1 + x_2 + tx_3 = 1 \end{array} \right.  $$  Have:  a) a unique solution?  b) infinitely many solutions?  c) no solutions?  I haven't done linear algebra in almost a year, so I'm really rusty and could use some pushes in the right direction. I have a MySQL database that I "inherited" and I was not given the admin credentials.  I do however have access to the box that it runs on.  Is there a way to either recover the admin credentials or create new ones? Evaluate $\lim\limits_{n\to\infty}\frac{\sum_{k=1}^n k^m}{n^{m+1}}$ By considering:  $$\lim_{n\to\infty}\frac{\sum_{k=1}^n k^1}{n^{2}} = \frac 1 2$$ $$\lim_{n\to\infty}\frac{\sum_{k=1}^n k^2}{n^{3}} = \frac 1 3$$ $$\lim_{n\to\infty}\frac{\sum_{k=1}^n k^3}{n^{4}} = \frac 1 4$$  Determine if this is true: $$\lim_{n\to\infty}\frac{\sum_{k=1}^n k^m}{n^{m+1}} = \frac 1 {{m+1}}$$  If it is, prove it.  If it is not, evaluate $\lim\limits_{n\to\infty}\frac{\sum_{k=1}^n k^m}{{m+1}}$. A closed ball in a metric space is a closed set Escaping regex string I want to use input from a user as a regex pattern for a search over some text.  It works, but how I can handle cases where user puts characters that have meaning in regex? For example, the user wants to search for Word (s): regex engine will take the (s) as a group.  I want it to treat it like a string &quot;(s)&quot; .  I can run replace on user input and replace the ( with \( and the ) with \) but the problem is I will need to do replace for every possible regex symbol. Do you know some better way ? What are the taxation rules for US non-resident aliens with respect to qualified dividends? Are the rules different for qualified versus non-qualified dividends? Assuming no DTAA exists between the US and the country of residence. I have a trained logistic regression model that I am applying to a testing data set. The dependent variable is binary (boolean). For each sample in the testing data set, I apply the logistic regression model to generates a % probability that the dependent variable will be true. Then I record whether the acutal value was true or false. I'm trying to calculate an $R^2$ or Adjusted $R^2$ figure as in a linear regression model.  This gives me a record for each sample in the testing set like:  prob_value_is_true         acutal_value    .34                          0    .45                          1    .11                          0    .84                          0     ....                        ....             I am wondering how to test the accuracy of the model. My first attempt was to use a contingency table and say "if prob_value_is_true > 0.80, guess that the actual value is true" and then measure the ratio of correct to incorrect classifications. But I don't like that, because it feels more like I'm just evaluating the 0.80 as a boundary, not the accuracy of the model as a whole and at all prob_value_is_true values.  Then I tried to just look at each prob_value_is_true discrete value, as an example, looking at all samples where prob_value_is_true=0.34 and measuring the % of those samples where the acutal value is true (in this case, perfect accuracy would be if the % of samples that was true = 34%). I might create a model accuracy score by summing the difference at each discrete value of prob_value_is_true. But sample sizes are a huge concern here, especially for the extremes (nearing 0% or 100%), such that the averages of the acutal values are not accurate, so using them to measure the model accuracy doesn't seem right.  I even tried creating huge ranges to ensure sufficient sample sizes (0-.25, .25-.50, .50-.75, .75-1.0), but how to measure "goodness" of that % of actual value stumps me. Say all samples where prob_value_is_true is between 0.25 and 0.50 have an average acutal_value of 0.45. Is that good since its in the range? Bad since its not near 37.5% (the center of the range)?  So I'm stuck at what seems like should be an easy question, and hoping someone can point me to a resource or method to calculate an accuracy stastic for a logistic regression model. How do I sort a MySQL table by two columns? What I want are articles sorted by highest ratings first, then most recent date.  As an example, this would be a sample output (left # is the rating, then the article title, then the article date)  +================+=============================+==============+ | article_rating | article                     | article_time | +================+=============================+==============+ | 50             | This article rocks          | Feb 4, 2009  | +----------------+-----------------------------+--------------+ | 35             | This article is pretty good | Feb 1, 2009  | +----------------+-----------------------------+--------------+ | 5              | This Article isn't so hot   | Jan 25, 2009 | +================+=============================+==============+  The relevant SQL I'm using is: ORDER BY article_rating, article_time DESC  I can sort by one or the other, but not both. While talking about ships and countries, is it a good practice to use the feminine form?  For example:  "Her economy" - while referring to a country's economy "Her flag (or deck etc)" - while referring to a ship  Is this practice common? Is it used today? Error Message: It looks like your post is mostly code; please add some more details How do you solve the following error when creating a simple post?     It looks like your post is mostly code; please add some more details Let $F$ be a field and $v:F\rightarrow G\cup\{\infty\}$ be a valuation on $F$ so $G$ is a totally ordered abelian group with $\infty$ having the properties $\infty+\infty=g+\infty=\infty+g=\infty$ and $\infty\leq\infty$ for all $g\in G$, $\infty \notin G$.     Show if $v(a)\neq v(b)$ then $v(a+b)=\min(v(a),v(b)$).   I must be missing some trick here on how to show this is true.  My approach has been to use that $G$ is a totally ordered group so I start by assuming $v(a)\neq v(b)$ and letting my first case be $v(a)&lt;v(b)$ as trichotomy holds in $G$. By $v$ being a valuation on $F$, we then have that $v(a+b)\geq \min(v(a),v(b))=v(a)$. From here what I've tried doing doesn't seem to help much.  I've said lets assuming $v(a+b)&gt;\min(v(a),v(b))=v(a)$ and we also have $$v(a+b)&gt; v(a) \Rightarrow v(a+b)+v(a^{-1}) &gt; 0 \Rightarrow v(1+ba^{-1}) &gt; 0$$ and $$v(a)&lt;v(b) \Rightarrow 0&lt; v(b)+v(a^{-1}) \Rightarrow 0 &lt; v(ba^{-1})$$ also $$v(1+ba^{-1})\geq\min(v(1),v(ba^{-1}))=\min(0,v(ba^{-1}))=0.$$  How does one solve this? Turn off automatic preview in apple mail In SQL Server 2005, are there any disadvantages to making all character fields nvarchar(MAX) rather than specifying a length explicitly, e.g. nvarchar(255)? (Apart from the obvious one that you aren't able to limit the field length at the database level) How do I enable Cortana after the Anniversary Update (1607)? I have seen this construct in scripts a lot and used it myself, but it bothers me that I can't seem to find it in the documentation.  Example:  [ -f file1 ] &amp;&amp; [ -f file2 ] &amp;&amp; echo "Both files exist." || echo "One or the other file doesn't exist."   This could also be done with backslashes before the newlines, as mentioned in man bash:  If a \&lt;newline&gt; pair appears,  and  the  backslash  is  not itself  quoted,  the \&lt;newline&gt; is treated as a line continuation (that is, it is removed from the input stream and effectively ignored).   Example:  [ -f file1 ] &amp;&amp; \ [ -f file2 ] &amp;&amp; \ echo "Both files exist." || \ echo "One or the other file doesn't exist."   ...but this doesn't seem to be necessary.  The first version above works even without the backslashes.  Where can I find this in man bash?  (Also, is this bash specific or POSIX compliant?) Unable to send e-mail. Contact the site administrator if the problem persists When my web form is filled and submitted, I get redirected to a page that says:     Thank you for submitting.   but theres a red warning box there that says:     Unable to send e-mail. Contact the site administrator if the problem persists.   I think its the SMTP server, but I don't know how to fix that. Migrate database from Postgres to MySQL