text:
Q: Curves and semi-abelian varieties Fix $k$ a number field, and let $C$ be a smooth geometrically integral affine curve over $k$. We can "associate" to $C$ a semi-abelian variety in the following way:
One knows that $C$ is a finite number of (closed) points away from its smooth compactification, which is a projective curve $X$. Let these points be denoted by $p_1,...,p_n$, they lie in $X(\bar{k})$. Let $D$ be the divisor in $\mathrm{Div}_\bar{k}(X)$ given by $$D = p_1+...+p_n.$$
In the book Algebraic groups and class fields by Serre, one can talk about the generalized Jacobian $J_D$ of $X$ which fits in the exact sequence $$0 \rightarrow T \rightarrow J_D \rightarrow J(X) \rightarrow 0,$$
where $T$ is an $(n-1)$-dimensional torus and $J(X)$ is the Jacobian of $X$, it is an abelian variety.
Thus $J_D$ is an extension of $J(X)$ by $T$ and by definition, it is a semi-abelian variety. I have the following questions:

*

*How is this extension defined? I know it is almost never true that this is the direct product $J_D = T \times J(X)$.

*Does one have a (canonical) map $C \rightarrow J_D$?

A: Let me treat in some details the case $n=2$ — the general case is similar. Consider the nodal curve $Y$ obtained from $X$ by identifying $p_1$ and $p_2$. Then $J_D$ is the Jacobian $JY$ of $Y$. Pulling back to $X$ gives an exact sequence
$$0\rightarrow \mathbb{G}_m\rightarrow JY\rightarrow JX\rightarrow 0\,.$$
Such an extension is parameterized by a class  in $\operatorname{Ext}^1(JX,\mathbb{G}_m) $, say in the category of abelian group schemes. This group is canonically isomorphic to the dual abelian variety of $JX$, which is canonically isomorphic to $JX$ through the principal polarization; the extension class  corresponds to the class of the divisor $p_1-p_2$.
To answer your question 2), if $s$ is the node of $Y$ and $p\in Y\smallsetminus s$, there is an Abel-Jacobi map $\alpha _p:Y\smallsetminus s\rightarrow JY$ mapping a point $x\in X$ to the class of the divisor $x-p$. Note that this map is canonical only up to translation, as is the case already when $Y$ is smooth. And it is definitely not defined at $s$ — in fact there is a natural compactification of $JY$, and $\alpha _p$ maps $s$ into the divisor at infinity.
Finally this works for any $n$ — you must consider the curve obtained by identifying the $n$ points.


text:
Q: How can I bring an actor to front in clutter In my clutter program written in c I have two Textures that overlap. One of them stays the same while the program is running and the other moves in to overlap from somewhere else on the stage. Because the second texture was created after the first one, it covers part of it up, but I want the first Texture to stay on top. How can I do this? The only way I can think of doing it is deleting the first Texture and making a new one using exactly the same picture every time a new Texture overlaps it, but this seems very inefficient to me. Is there a function that brings an actor to the front using the clutter API?

A: you can use clutter_actor_raise() and clutter_actor_lower():
http://developer.gnome.org/clutter/stable/ClutterActor.html#clutter-actor-raise
if the actors belong to the same container.

redpajama_set_name: RedPajamaStackExchange


text:
Q: HDMI audio disappears when the TV is turned off and on I have a new HTPC build (it's running Windows 7 Ultimate x64) and it has a ATI Radeon 6450 as graphics card.
When I boot the PC, everything works fine. However, when the TV is turned off and then back on I notice there's no sound anymore. There are lots of other people who have this issue aswell. I've found this workaround however it doesn't seem to work for me.
I have the newest drivers (12.4). Someone said it was fixed in 9.1 but I still have the issue.

A: You should see this thread. It solves the issue for some user.
In short: The 12.4 drivers are buggy, revert to 12.3 until fixed drivers are released.


text:
Q: Cannot get permission to read/write collection throughput using Cosmos DB role-based access control We are using Core(SQL) Cosmos DB. Now we are trying to add a role and here are the requirements:

*

*Read permission of all metrics.

*Read and write permission of all settings, including database account level, database level and (container)collection level.

*No read or write permission of documents.

We have added all the following permissions to the role. However, we are still unable to

*

*Read and write throughput(scale) of collection

*Write all kinds of account level settings

*Read the throughput(number of requests) metric. But other metrics like storage, availability, latency, consistency are available.

Do we miss anything?
```"Microsoft.DocumentDB/databaseAccountNames/read",
  "Microsoft.DocumentDB/databaseAccounts/cassandraKeyspaces/operationResults/read",
  "Microsoft.DocumentDB/databaseAccounts/cassandraKeyspaces/read",
  "Microsoft.DocumentDB/databaseAccounts/cassandraKeyspaces/tables/operationResults/read",
  "Microsoft.DocumentDB/databaseAccounts/cassandraKeyspaces/tables/read",
  "Microsoft.DocumentDB/databaseAccounts/cassandraKeyspaces/tables/throughputSettings/read",
  "Microsoft.DocumentDB/databaseAccounts/cassandraKeyspaces/tables/throughputSettings/write",
  "Microsoft.DocumentDB/databaseAccounts/cassandraKeyspaces/tables/write",
  "Microsoft.DocumentDB/databaseAccounts/cassandraKeyspaces/throughputSettings/read",
  "Microsoft.DocumentDB/databaseAccounts/changeResourceGroup/action",
  "Microsoft.DocumentDB/databaseAccounts/databases/collections/metricDefinitions/read",
  "Microsoft.DocumentDB/databaseAccounts/databases/collections/metrics/read",
  "Microsoft.DocumentDB/databaseAccounts/databases/collections/partitionKeyRangeId/metrics/read",
  "Microsoft.DocumentDB/databaseAccounts/databases/collections/partitions/metrics/read",
  "Microsoft.DocumentDB/databaseAccounts/databases/collections/partitions/read",
  "Microsoft.DocumentDB/databaseAccounts/databases/collections/partitions/usages/read",
  "Microsoft.DocumentDB/databaseAccounts/databases/metricDefinitions/read",
  "Microsoft.DocumentDB/databaseAccounts/databases/metrics/read",
  "Microsoft.DocumentDB/databaseAccounts/databases/usages/read",
  "Microsoft.DocumentDB/databaseAccounts/getBackupPolicy/action",
  "Microsoft.DocumentDB/databaseAccounts/gremlinDatabases/graphs/operationResults/read",
  "Microsoft.DocumentDB/databaseAccounts/gremlinDatabases/graphs/throughputSettings/operationResults/read",
  "Microsoft.DocumentDB/databaseAccounts/gremlinDatabases/graphs/throughputSettings/read",
  "Microsoft.DocumentDB/databaseAccounts/gremlinDatabases/operationResults/read",
  "Microsoft.DocumentDB/databaseAccounts/gremlinDatabases/read",
  "Microsoft.DocumentDB/databaseAccounts/gremlinDatabases/throughputSettings/operationResults/read",
  "Microsoft.DocumentDB/databaseAccounts/gremlinDatabases/throughputSettings/read",
  "Microsoft.DocumentDB/databaseAccounts/metricDefinitions/read",
  "Microsoft.DocumentDB/databaseAccounts/metrics/read",
  "Microsoft.DocumentDB/databaseAccounts/mongodbDatabases/collections/operationResults/read",
  "Microsoft.DocumentDB/databaseAccounts/mongodbDatabases/collections/throughputSettings/operationResults/read",
  "Microsoft.DocumentDB/databaseAccounts/mongodbDatabases/collections/throughputSettings/read",
  "Microsoft.DocumentDB/databaseAccounts/mongodbDatabases/operationResults/read",
  "Microsoft.DocumentDB/databaseAccounts/mongodbDatabases/read",
  "Microsoft.DocumentDB/databaseAccounts/mongodbDatabases/throughputSettings/operationResults/read",
  "Microsoft.DocumentDB/databaseAccounts/mongodbDatabases/throughputSettings/read",
  "Microsoft.DocumentDB/databaseAccounts/operationResults/read",
  "Microsoft.DocumentDB/databaseAccounts/percentile/metrics/read",
  "Microsoft.DocumentDB/databaseAccounts/percentile/read",
  "Microsoft.DocumentDB/databaseAccounts/percentile/sourceRegion/targetRegion/metrics/read",
  "Microsoft.DocumentDB/databaseAccounts/percentile/targetRegion/metrics/read",
  "Microsoft.DocumentDB/databaseAccounts/privateEndpointConnectionProxies/operationResults/read",
  "Microsoft.DocumentDB/databaseAccounts/privateEndpointConnections/operationResults/read",
  "Microsoft.DocumentDB/databaseAccounts/read",
  "Microsoft.DocumentDB/databaseAccounts/region/databases/collections/metrics/read",
  "Microsoft.DocumentDB/databaseAccounts/region/databases/collections/partitionKeyRangeId/metrics/read",
  "Microsoft.DocumentDB/databaseAccounts/region/databases/collections/partitions/metrics/read",
  "Microsoft.DocumentDB/databaseAccounts/region/databases/collections/partitions/read",
  "Microsoft.DocumentDB/databaseAccounts/region/metrics/read",
  "Microsoft.DocumentDB/databaseAccounts/restore/action",
  "Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers/operationResults/read",
  "Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers/storedProcedures/operationResults/read",
  "Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers/throughputSettings/operationResults/read",
  "Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers/throughputSettings/read",
  "Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers/triggers/operationResults/read",
  "Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers/userDefinedFunctions/operationResults/read",
  "Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers/userDefinedFunctions/read",
  "Microsoft.DocumentDB/databaseAccounts/sqlDatabases/operationResults/read",
  "Microsoft.DocumentDB/databaseAccounts/sqlDatabases/throughputSettings/operationResults/read",
  "Microsoft.DocumentDB/databaseAccounts/sqlDatabases/throughputSettings/read",
  "Microsoft.DocumentDB/databaseAccounts/tables/operationResults/read",
  "Microsoft.DocumentDB/databaseAccounts/tables/throughputSettings/operationResults/read",
  "Microsoft.DocumentDB/databaseAccounts/tables/throughputSettings/read",
  "Microsoft.DocumentDB/databaseAccounts/usages/read",
  "Microsoft.DocumentDB/locations/operationsStatus/read",
  "Microsoft.DocumentDB/operationResults/read",
  "Microsoft.DocumentDB/operations/read",
  "Microsoft.DocumentDB/register/action",
  "Microsoft.DocumentDB/register/action",```

We also tries Cosmos DB Operator Role. Scale/Setting/Explore buttons even disappear with Operator Role.

A: You do not need a custom role for this. Take a look at the Cosmos DB Operator Role which provides access to all management (control plane) data and operations except for keys to prevent access to data.
You can learn more here.
Role-based access control in Azure Cosmos DB
Hope this helps.


text:
Q: How to specify to show a navigation bar on one screen and not to show it on another? I have two viewControllers, vcA and vcB.
vcA is the initial view controller and it's embedded in a navigation controller, navVC. To display vcB I push vcB with navVC.
However, for vcA I don't want to display the navigation bar and for vcB I do want to display the navigation bar.
I've seen this answer but it doesn't solve my problem because I need to support backswipe. When I try to cause the navigation controller to disappear on backswipe the navigation controller immediately disappears or slowly disappears depending on if animation is enabled.
My navVC is presenting with a page sheet animation as well so if I set the nav bar to disappear in viewWillDisappear it disappears as I modally pan down.
Is there a way to specify to not have a navigation bar shown on the first vc and have it shown on the second? Or is there some better way to do this I'm not familiar with?

A: While the default view controllers make life really great initially, they usually come with very specific ways they operate and trying to operate outside those paradigms will be difficult if not impossible.
I would suggest not using the default navigation view controller on the view that you don't want the bar to appear on and instead customize your own view to support the exact behavior you're trying to replicate.
For example you can use a regular view without a bar at the top for viewA and then segue to the navigation view controller and make view B its default view.

A: Why do you want to hide the navigation bar on vcA ?
Instead you can just make the barTintColor same as the vcA background color , you need not have to hide the navigation bar.
if #available(iOS 15.0, *) {
   let appearance = UINavigationBarAppearance()
   appearance.configureWithOpaqueBackground()
   appearance.backgroundColor = color
   vcA.navigationController?.navigationBar.standardAppearance = appearance
   vcA.navigationController?.navigationBar.scrollEdgeAppearance = vcA.navigationController?.navigationBar.standardAppearance
} else {
   vcA.navigationController?.navigationBar.barTintColor = color
}


text:
Q: Microsoft Cognitive Services: is it possible to use video processing api on streaming url? I see that microsoft cognitive service video api provides video processing on downloaded video.I need to test video motion detection on a streaming url, so is it possible to do that on streaming video ? if so how can we achieve that ?

A: Unfortunately, this is not possible today. The team is thinking about it. The best way to help them to prioritize would be to open a thread in the Uservoice at https://cognitive.uservoice.com/


text:
Q: azure storage tables and best performance/value I was wondering which of the following two archititchers would have higher performance/value?
Having THREE tables with the following structure:
1 - Users table
[userid(as primarykey), pass(as Rowkey), phone_number]
2 - Sports
[userid(as primarykey), sportid(as Rowkey), sport_name]
3 - Games
[sportid(as primarykey), gameid(as Rowkey), game_date]

Or having ONE table with the following structure:
[userid(as primarykey), (Sport or Game as text)(as Rowkey), sport_name or game_date]

Or maybe there is even better solution/idea for this data structure.
Thanks in advance


text:
Q: Using sub classes with Zend_Rest_Server Zend_Rest_Server and Zend_Rest_Client is pathetically under-documented, so I keep running into these mind numbingly irritating problems.
So, in order to streamline my API methods I would invoke Zend_Rest_Server() and then set the server class to "X", which in turn would extend my "api_server" class. And in my api_server class would I put things like authentication, hash key processing and all that stuff.
But as soon as I use the "class mdb extends api_server {" instead of just "class mdb {" my entire api application dies. Without an error. Nothing in the logs. no output. Here is the code:
$server = new Zend_Rest_Server();
$server->setClass("mdb");
$server->handle();

class mdb extends api_server { .... }

And as soon as I remove the entire "extends api_server" it will work (although I don't have any authentication methods for the server, so it fails, but the server is running and responds..
So is this some sort of undocumented limit of Zend_Rest_Server() or am I doing something really stupid?
It doesn't seem to be about about autoloading, even if I require the file that the api_server class is kept in, it won't work.

A: Apparently, if you extend another class, you need to define it first, so the correct syntax would be:
class mdb extends api_server { .... }

$server = new Zend_Rest_Server();
$server->setClass("mdb");
$server->handle();


text:
Q: Comparing SQLite databases on Android In my application I have an existing SQLite database attached. On start it's copied to phone and then being used. I know how to check if this database is already copied, but I want to check if database on the phone is the same as stored in APK. Is there any way to compare them? I want to do that programmatically.
Original database is stored in assets folder.

A: If you have a rooted Phone then you can Watch the Details of It. but if your phone is not rooted then you are won't be able to see it.
Another thing if you have copied the Application in your Phone then it will definitely work.
So Conclusion is that If you have a Rooted Phone then you will be able to See and Compare, if possible try to compare its size or Time on which it is Installed.

A: If you have attach a DataBase with your APK and you successfully copied to your phone that exactly means that you have your old data base copied.So i think no need to compare.If you want to compare then compare all record in Table.
Second if you want to remember that your data base is already copied then use one flag in share preferences.Save true once copied.Then check its value
Updated
To listing all Table
select name from sqlite_master where type = 'table'

If both data base have same table then compare record of these corresponding Table


text:
Q: How to check if any string in array contains any other string (substring) in other array? (PostgreSQL) I've got 2 string arrays, and I wanna to compare if any string of first array - contains SUBstring from other one, which storing these SUBstrings.
In other words: I don't wanna compare these arrays and their strings fully, I need to find exactly if strings from one array contains a SUBstrings from other array.

A: You can use the following approach, if the two arrays are not too big:
SELECT * FROM
    (SELECT unnest('{apple pie,sugar,brown sugar}'::varchar[]) a1) t1,
    (SELECT unnest('{pie,sugar}'::varchar[]) a2) t2
    where t1.a1 like ('%' || t2.a2 || '%')

Otherwise I suggest you to use ts_vectors and the full text search operators: https://www.postgresql.org/docs/current/textsearch.html


text:
Q: PCA on correlation or covariance? What are the main differences between performing principal component analysis (PCA) on the correlation matrix and on the covariance matrix? Do they give the same results?

A: Bernard Flury, in his excellent book introducing multivariate analysis, described this as an anti-property of principal components.   It's actually worse than choosing between correlation or covariance.   If you changed the units (e.g. US style gallons, inches etc. and EU style litres, centimetres) you will get substantively different projections of the data.
The argument against automatically using correlation matrices is that it is quite a brutal way of standardising your data.   The problem with automatically using the covariance matrix, which is very apparent with that heptathalon data, is that the variables with the highest variance will dominate the first principal component (the variance maximising property).
So the "best" method to use is based on a subjective choice, careful thought and some experience.

A: UNTRANSFORMED (RAW) DATA: If you have variables with widely varying scales for raw, untransformed data, that is, caloric intake per day, gene expression, ELISA/Luminex in units of ug/dl, ng/dl, based on several orders of magnitude of protein expression, then use correlation as an input to PCA.  However, if all of your data are based on e.g. gene expression from the same platform with similar range and scale, or you are working with log equity asset returns, then using correlation will throw out a tremendous amount of information.
You actually don't need to think about the difference of using the correlation matrix $\mathbf{R}$ or covariance matrix $\mathbf{C}$ as an input to PCA, but rather, look at the diagonal values of $\mathbf{C}$ and $\mathbf{R}$.  You may observe a variance of $100$ for one variable, and $10$ on another -- which are on the diagonal of $\mathbf{C}$.  But when looking at the correlations, the diagonal contains all ones, so the variance of each variable is essentially changed to $1$ as you use the $\mathbf{R}$ matrix.
TRANSFORMED DATA: If the data have been transformed via normalization, percentiles, or mean-zero standardization (i.e., $Z$-scores), so that the range and scale of all the continuous variables is the same, then you could use the Covariance matrix $\mathbf{C}$ without any problems.  (correlation will mean-zero standardize variables).  Recall, however, that these transformations will not remove skewness (i.e., left or right tails in histograms) in your variables prior to running PCA.  Typical PCA analysis does not involve removal of skewness; however, some readers may need to remove skewness to meet strict normality constraints.
In summary, use the correlation matrix $\mathbf{R}$ when within-variable range and scale widely differs, and use the covariance matrix $\mathbf{C}$ to preserve variance if the range and scale of variables is similar or in the same units of measure.
SKEWED VARIABLES: If any of the variables are skewed with left or right tails in their histograms, i.e., the Shapiro-Wilk or Lilliefors normality test is significant $(P<0.05)$, then there may be some issues if you need to apply the normality assumption.  In this case, use the van der Waerden scores (transforms) determined from each variable.  The van der Waerden (VDW) score for a single observation is merely the inverse cumulative (standard) normal mapping of the observation's percentile value.  For example, say you have $n=100$ observations for a continuous variable, you can determine the VDW scores using:

*

*First, sort the values in ascending order, then assign ranks, so you would obtain ranks of $R_i=1,2,\ldots,100.$

*Next, determine the percentile for each observation as $pct_i=R_i/(n+1)$.

*Once the percentile values are obtained, input them into the inverse mapping function for the CDF of the standard normal distribution, i.e., $N(0,1)$, to obtain the $Z$-score for each, using $Z_i=\Phi^{-1}(pct_i)$.

For example, if you plug in a $pct_i$ value 0.025, you will get $-1.96=\Phi^{-1}(0.025)$. Same goes for a plugin value of $pct_i=0.975$, you'll get $1.96=\Phi^{-1}(0.975)$.
Use of VDW scores is very popular in genetics, where many variables are transformed into VDW scores, and then input into analyses.  The advantage of using VDW scores is that skewness and outlier effects are removed from the data, and can be used if the goal is to perform an analysis under the contraints of normality -- and every variable needs to be purely standard normal distributed with no skewness or outliers.

A: I personally find it very valuable to discuss these options in light of the maximum-likelihood principal component analysis model (MLPCA) [1,2]. In MLPCA one applies a scaling (or even a rotation) such that the measurement errors in the measured variables are independent and distributed according to the standard normal distribution. This scaling is also known as maximum likelihood scaling (MALS) [3]. In some case, the PCA model and the parameter defining the MALS scaling/rotation can be estimated together [4].
To interpret correlation-based and covariance-based PCA, one can then argue that:

*

*Covariance-based PCA is equivalent to MLPCA whenever the variance-covariance matrix of the measurement errors is assumed diagonal with equal elements on its diagonal. The measurement error variance parameter can then be estimated by applying the probabilistic principal component analysis (PPCA) model [5]. I find this a reasonable assumption in several cases I have studied, specifically when all measurements are of the same type of variable (e.g. all flows, all temperatures, all concentrations, or all absorbance measurements). Indeed, it can be safe to assume that the measurement errors for such variables are distributed independently and identically.

*Correlation-based PCA is equivalent to MLPCA whenever the variance-covariance matrix of the measurement errors is assumed diagonal with each element on the diagonal proportional to the overall variance of the corresponding measured variable. While this is a popular method, I personally find the proportionality assumption unreasonable in most cases I study. As a consequence, this means I cannot interpret correlation-based PCA as an MLPCA model. In the cases where (1) the implied assumptions of covariance-based PCA do not apply and (2) an MLPCA interpretation is valuable, I recommend to use one of the MLPCA methods instead [1-4].

*Correlation-based and covariance-based PCA will produce the exact same results -apart from a scalar multiplier- when the individual variances for each variable are all exactly equal to each other. When these individual variances are similar but not the same, both methods will produce similar results.

As stressed above already, the ultimate choice depends on the assumptions you are making. In addition, the utility of any particular model depends also on the context and purpose of your analysis.  To quote George E. P. Box: "All models are wrong, but some are useful".
[1] Wentzell, P. D., Andrews, D. T., Hamilton, D. C., Faber, K., & Kowalski, B. R. (1997). Maximum likelihood principal component analysis. Journal of Chemometrics, 11(4), 339-366.
[2] Wentzell, P. D., & Lohnes, M. T. (1999). Maximum likelihood principal component analysis with correlated measurement errors: theoretical and practical considerations. Chemometrics and Intelligent Laboratory Systems, 45(1-2), 65-85.
[3] Hoefsloot, H. C., Verouden, M. P., Westerhuis, J. A., & Smilde, A. K. (2006). Maximum likelihood scaling (MALS). Journal of Chemometrics, 20(3‐4), 120-127.
[4] Narasimhan, S., & Shah, S. L. (2008). Model identification and error covariance matrix estimation from noisy data using PCA. Control Engineering Practice, 16(1), 146-155.
[5] Tipping, M. E., & Bishop, C. M. (1999). Probabilistic principal component analysis. Journal of the Royal Statistical Society: Series B (Statistical Methodology), 61(3), 611-622.

A: A common answer is to suggest that covariance is used when variables are on the same scale, and correlation when their scales are different. However, this is only true when scale of the variables isn't a factor. Otherwise, why would anyone ever do covariance PCA? It would be safer to always perform correlation PCA.
Imagine that your variables have different units of measure, such as meters and kilograms. It shouldn't matter whether you use meters or centimeters in this case, so you could argue that correlation matrix should be used.
Consider now population of people in different states. The units of measure are the same - counts (number) of people. Now, the scales could be different: Vermont has 600K and CA - 38M people. Should we use correlation matrix here? It depends. In some applications we do want to adjust for the size of the state. Using the covariance matrix is one way for building factors that account for the size of the state.
Hence, my answer is to use covariance matrix when variance of the original variable is important, and use correlation when it is not.

A: You tend to use the covariance matrix when the variable scales are similar and the correlation matrix when variables are on different scales.
Using the correlation matrix is equivalent to standardizing each of the variables (to mean 0 and standard deviation 1). In general, PCA with and without standardizing will give different results. Especially when the scales are different.
As an example, take a look at this R heptathlon data set. Some of the variables have an average value of about 1.8 (the high jump), whereas other variables (run 800m) are around 120.
library(HSAUR)
heptathlon[,-8]      # look at heptathlon data (excluding 'score' variable)

This outputs:
                   hurdles highjump  shot run200m longjump javelin run800m
Joyner-Kersee (USA)   12.69     1.86 15.80   22.56     7.27   45.66  128.51
John (GDR)            12.85     1.80 16.23   23.65     6.71   42.56  126.12
Behmer (GDR)          13.20     1.83 14.20   23.10     6.68   44.54  124.20
Sablovskaite (URS)    13.61     1.80 15.23   23.92     6.25   42.78  132.24
Choubenkova (URS)     13.51     1.74 14.76   23.93     6.32   47.46  127.90
...

Now let's do PCA on covariance and on correlation:
# scale=T bases the PCA on the correlation matrix
hep.PC.cor = prcomp(heptathlon[,-8], scale=TRUE)
hep.PC.cov = prcomp(heptathlon[,-8], scale=FALSE)

biplot(hep.PC.cov)
biplot(hep.PC.cor)

Notice that PCA on covariance is dominated by run800m and javelin: PC1 is almost equal to run800m (and explains $82\%$ of the variance) and PC2 is almost equal to javelin (together they explain $97\%$). PCA on correlation is much more informative and reveals some structure in the data and relationships between variables (but note that the explained variances drop to $64\%$ and $71\%$).
Notice also that the outlying individuals (in this data set) are outliers regardless of whether the covariance or correlation matrix is used.

A: The arguments based on scale (for variables expressed in the same physical units) seem rather weak. Imagine a set of (dimensionless) variables whose standard deviations vary between 0.001 and 0.1. Compared to a standardized value of 1, these both seem to be 'small' and comparable levels of fluctuations. However, when you express them in decibel, this gives a range of -60 dB against -10 and 0 dB, respectively. Then this would probably then be classified as a 'large range' -- especially if you would include a standard deviation close to 0, i.e., minus infinity dB.
My suggestion would be to do BOTH a correlation- and covariance-based PCA. If the two give the same (or very similar, whatever this may mean) PCs, then you can be reassured you've got an answer that is meaningul. If they give widely different PCs don't use PCA, because two different answers to one problem is not sensible way to solve questions.

A: Straight and simple: if the scales are similar use cov-PCA, if not, use corr-PCA; otherwise, you better have a defense for not. If in doubt, use an F-test for the equality of the variances (ANOVA). If it fails the F-test, use corr; otherwise, use cov.


text:
Q: VB.Net Multi-Threading InvokeRequired and Passing Thread I need to be able to pass the thread name into a subroutine in order to abort it when I need to.
So I have this so far:
 Dim BrowserSpawn As New System.Threading.Thread(AddressOf BrowserSub)
    BrowserSpawn.Start()

 Private Async Sub BrowserSub(BrowserSpawn)
...
End Sub

Because the subroutine creates a browser within Form1 groups I needed to invoke access to these controls within the sub.
Note: This works fine when I'm not passing in the thread name.
 If Me.GroupNamehere.InvokeRequired Then
            Me.GroupNamehere.Invoke(New MethodInvoker(AddressOf BrowserSub))
        Else
           'Do nothing
        End If

When I'm passing in the thread name these become a problem when trying to compile:
Method does not have a signature compatible with delegate 'Delegate Sub MethodInvoker()'.

I'm hoping this is just a syntax thing but I can't seem to get it to work. Is there any way I'm able to pass in this thread name without breaking my invokerequired check?
If I try and change it to the obvious:
Me.GroupNamehere.Invoke(New MethodInvoker(AddressOf BrowserSub(BrowserSpawn)))

It tells me Addressof operand must be the name of a method (without parentheses). Although without the parentheses it's not happy either so I don't know where to go from here.
/edit:
Stumbled across How can I create a new thread AddressOf a function with parameters in VB?
Which seems to confirm what I was trying passing something like:
Private Sub test2(Threadname As Thread)
    ' Do something
End Sub

And the sub seems happy with that. But I'm not sure how to do that without breaking the invoker part.
 Me.GroupNameHere.Invoke(New MethodInvoker(AddressOf SubNameHere))

Works normally. If SubNameHere() becomes SubNameHere(threadname as thread) then that seems happy enough but the invoke line breaks and doesn't want more than the address of.

A: Two slight syntax changes sorted it:
Private Async Sub SubName(ThreadNameAs Thread)

and
GroupName.Invoke(New MethodInvoker(Sub() Me.SubName(ThreadName)))


text:
Q: Question about Dedekind domain having Krull dimension 0 or 1 I am reading a lemma on Dedekind domain but I have difficulties understanding it, I am bring it up here hoping for help. The original passage is in one big fat paragraph but I broke it down here for your easy reading. Thanks beforehand for all your time and help, let me know if I forget to include any underlying lemmas.
LEMMA: Dedekind domains have Krull dimension 0 or 1.
PROOF: (1) Let R be a Dedekind domain, let T be a nonzero prime ideal of R, and let U be a maximal ideal of R such that T $\subseteq$ U. We shall see that T = U.
(2) Since R is assumed to be a Dedekind domain, we obtain from T $\subseteq$ U an ideal V of R such that T = UV.
(3) Thus, as T is a prime ideal of R, U $\subseteq$ T or V $\subseteq$ T.
(4) Assume first that V $\subseteq$ T. Then, as T = UV, T $\subseteq$ UT.
[Here is my question from #(4): How do you go from T = UV to T $\subseteq$ UT ?]
(5) Thus, as T $\neq${0}, R $\subseteq$ U; see Lemma below.
[The lemma referred aboved is this: "Let R be a Dedekind domain, and let U and V be ideals of R. Assume that R possesses a nonzero ideal T with TU $\subseteq$ TV . Then U $\subseteq$ V." But even after arduous reading, I still don't know how R $\subseteq$ U is derived in #(5).]
(6) This contradicts the fact that U is a maximal ideal of R. Thus, U $\subseteq$ T.
(7) Thus, as T $\subseteq$ U, T = U.
[How does T = U relate to dimension of 0 or 1?]
As always, thank you so much for your time and help.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
EDIT:
Here is how Dedekind domain defined in the text: An integral domain R is called Dedekind domain if, for any two ideals T and U of R with T $\subseteq$ U, there exists an ideal V of R such that T = UV.

A: (4) From $V\subseteq T$ we get $UV\subseteq UT$ and since $T=UV$ ...
(5) Set in your lemma $U=R$ and $V=U$. Note that $TR=T$.
(7) You have actually shown that every non-zero prime is maximal, so you can't have a chain of three primes in $R$.


text:
Q: Why are object's private members accessible to objects of the same type? I was surprised to discover that this compiles.
class A
{
    int i;
public:
    A() {}
    A(A &a) {i = a.i;}
};

int main(void)
{
    A a1;
    A a2(a1);
}

That is, the object a2 has access to the private members of the object a1. Why is this the case i.e. why is this useful? How can this access be restricted, if needed?


text:
Q: Trigger Collider Flickering I'm very new to unity and I'm making a simple tag game with car like players. However, I'm having problems with my trigger collider. When I tag the other car it kind of flickers the is tagged true/false. Here is my code.
public Color TaggedColor;
public Color NoTaggedColor;
public bool Tagged;

// Start is called before the first frame update
void Start()
{
    Tagged = true;
    GetComponent<Image>().color = TaggedColor;
}

// Update is called once per frame
void Update()
{

}

void OnTriggerEnter2D(Collider2D other)
{

    if (other.tag == "P2")
    {
        if (Tagged == false)
        {
            Tagged = true;
            GetComponent<Image>().color = TaggedColor;
        }
        else
        {
            if (Tagged == true)
            {
                Tagged = false;
                GetComponent<Image>().color = NoTaggedColor;
            }
        }

        Debug.Log("TAG!");
    }

}

void GotTagged()
{
    if (Tagged == false)
    {
        Tagged = true;
        //GetComponent<Image>().color = TaggedColor;
    }

}

void TaggedOtherPlayer()
{
    if (Tagged == true)
    {
        Tagged = false;
        GetComponent<Image>().color = NoTaggedColor;
    }

}

I have a Second code for P2 that the only change is the start and the tag is P1. I'm not sure if this problem is something in my code or if it's the collider it's self. If anyone has any idea why this is happening I would love to hear it!
Update: I bevile the issue is coming from the Colliders because I have an empty as a child of both players that is the trigger collider. However when I tag one the other trigger goes off as well. Should I have only one trigger? And if so how would I go about doing it?
Thanks

A: once you tag a player SetActive(false) the empty triggers for about 1 second or so. If you had a button that whenever its pressed it changes s value from true to false the false to true if you press and hold that button it will "flicker" back and forth between true and false. Thats what's happening with your players the trigger is constantly being pulled while you're touching so make it inactive for long enough for you to not be touching anymore. I hope that makes sense.


text:
Q: Symbology of a point layer on attributes of a child layer I have created a project in which I want to monitor technical systems. The systems are serviced at different annual intervals. I have created a point layer that shows the plant locations and contains the main information about the plant. I would like to keep the maintenance dates in a child layer (without geometry). The relationship between parent and child layer runs through the ID.
In order to quickly get an overview of which systems have already been checked in the current year, I would like to color the point layer (= parent) based on the features from the child layer, for example green (if the system has already been checked).
I've already written about 4 hours with the expression-editor in different ways today, but I can't find a way to do create this connection.


text:
Q: Java keystore slows encryption / decryption down I am building a little program for encryption and decryption of some personal data, in order to learn more about encryption. The program uses RSA and AES encryption, depending on the content size that needs to be encrypted.
In a first, draft implementation, I stored the keys just to a text file, and read them from there. The different tests that I ran were quite fast. In general, encrypting small to large strings, took not more than 30ms, and in general 15ms.
I then moved the keys to a java Keystore and read them from there. This slowed the encryption down drastically. A test function that used to take about 15ms went to 1 to 2 seconds, sometimes even nearing 3 seconds, depending on the content that needed to be tokenized.
From here Java Keystore.getKey() slow while Key store size Increase I learned that storing the keys in a ConcurrentHashMap should increase the speed of the encryption/decryption. I tried this and now indeed, the encryption/decryption, became faster, taking about 800 to 900ms. This is certainly an improvement compared to the 1/2 seconds I was experiencing with reading the keys each time from the keystore, but it is still not as fast as the 16ms that the original method took, in which the keys were just read from a text file.
This leaves me with two questions:

*

*Are there other 'tricks' I should explore, that could make the encryption process faster. Ideally, the encryption/decryption time would be marginal, so when I want to use this e.g. to encrypt my database, there would not be a drastic performance issue.

*Does storing the keys in a ConcurrentHashMap come with other disadvantages (let's say security wise) that I need to be aware of?

I am using the java keystore.


text:
Q: Cell formatted as "Date" recognized in VBA as Vartype 8 - String I stumbled upon something weird today.
I have a script, that check for vartype of a cell in order to convert it to a date. If it is not recognized ass Vartype 7, it gets parsed into date and replaces the original cell value.
However the script broke when other colleague tried to use it, so the problem is most probably somewhere in regional settings, but the weird part is that the cell is formatted as Date. As far as I can tell, it really is a date, excel formulas like DAY or MONTH work on it, as does Format or Month or Day in VBA. The issue however is that the Vartype is 8 - String.
Using CDate converts the format correctly as far as I can tell, not sure about dates that could have ambiguous day and month number.
What could be causing this? How can it be formatted and recognized as Date within excel, but VBA telling me it is a String?
Thank you
EDIT: Just checked, the format even within excel is not recognized as Date and ambiguous dates get their Date/Month swapped.


text:
Q: Making an animated time-series graph that progresses through the data in real time I am attempting to graph some heartrate data that is collected over the course of 4 minutes. The ideal graph will be an animation of the heart rate that moves in real time with the data (i.e., a 4 minute animated graph). The data looks like something this:
import pandas as pd
import random
import more_itertools as mit

data = pd.DataFrame({'time': mit.random_combination(range(708709, 987067), r=410),
                   'HR': [random.randint(70,110) for x in range(410)]})

The original code I tried from this very helpful article (https://towardsdatascience.com/dynamic-replay-of-time-series-data-819e27212b4b) managed to make a dynamic time series graph that was unable to stretch across the needed 4 minutes. As you can see there are inconsistent lapses when the device collected HR data and thus the original solution was not ideal. (Original solution below). Ideally I would like to avoid imputing missing time values.
Thanks for your time!
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from collections import deque
%matplotlib qt5
plt.ion()

Heartrate = 'HR'
%matplotlib qt5

plt.ion()

visible = 40

dy1 = deque(np.zeros(visible), visible)
dx = deque(np.zeros(visible), visible)

#interval = np.linspace(0, data.shape[0], num=data.shape[0])
interval = data['time']
fig = plt.figure(figsize=(15,10))

ah1 = fig.add_subplot(111)
ah1.set_xlabel("Time [ms]", fontsize=14, labelpad=10)
ah1.set_ylabel("Heart Rate Last 5 Seconds", fontsize=14, labelpad=5)
l1, = ah1.plot(dx, dy1, color='rosybrown', label='HR')
ah1.legend(loc="upper right", fontsize=12, fancybox=True, framealpha=0.5)

start = 0

while start+visible <= data.shape[0]-1:

    # extend deques (both x and y axes)
    dy1.extend(data[Heartrate].iloc[start:start+visible])
    dx.extend(interval[start:start+visible])

    # update axes
    l1.set_ydata(dy1)
    l1.set_xdata(dx)

    # get mean of deques
    mdy1 = np.mean(dy1)

    # set x- and y-limits based on their mean
    dist = 20
    ah1.set_ylim(-dist+min(data['HR']), max(data['HR'])+dist) # static y-axis
    #ah1.set_ylim(-35+mdy1, 35+mdy1) # dynamic y-axis
    ah1.set_xlim(interval[start], interval[start+visible])

    # control speed of moving time-series
    start += 1

    fig.canvas.draw()
    fig.canvas.flush_events()


text:
Q: dynamically rendering plain .html page on webmatrix I'm trying to render a .html webpage using @Renderpage() method in Webmatrix but the .html extension is not supported by the method. I guess the method only supports cshtml extensions. Is there a way I can render html pages dynamically on my site (Webmatrix). I dont want to use an iframe because I'll definitely have issues with my jquery files.
I attempted something i feel is safe yet feels unsafe. I resolved to read the html file and inject it to the DOM manually using:
Array html = null;
var mypage = Server.MapPath(page);
if(File.Exists(mypage)){
    html = File.ReadAllLines(mypage);
}

After reading the file.....i injected it to the DOM

            @foreach (var data in html) {
                <text>@Html.Raw(data)</text>
            }

All this runs on compilation time before the page is created for rendering.....I attempted some security measures by attempting to inject server-side C# code in the HTML file but was useless. Makes me feel safe atleast. Is this risky? What is the possible threat to this alternative. i wish i can still have an alternative proper solution from the house. Thanks though.

A: Assuming @Renderpage() doesn't support HTML files, why don't you try Jquery.load or Ajax. There are lots of tutorials based on dynamic loading of html content.

A: I do something similar but I don't use @Renderpage or an html file. Instead I am using the "onclick" event and a javascript function which opens a cshtml file. You just put this and the java script function in your main cshtml file in the hmtl section. It will open a file in the current directory called my_window.cshtml when clicked
Open when clicked


text:
Q: What has the best performance for async calls on iOS? I search for a better performance for asynchronous calls on iOS if there's a performance issue in a threaded call and I want to optimize it.
[self performSelector:@selector(switch) withObject:nil afterDelay:delay inModes:@[NSRunLoopCommonModes]];

has a GCD call like:
dispatch_time_t delay = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC); dispatch_after(delay, dispatch_get_main_queue(), ^(void){
[self switch];
});

a better performance? Or anybody an idea? I guess a timer would only be more glue...

A: If you have a performance problem in your app, it's not here. There are two possibilities:

*

*You are making vast numbers of these calls in which case the performance of the dispatch mechanism is actually a problem. In that case, rework your application logic so that you don't need to make so many calls!

*You are not making that many calls, in which case the performance of the dispatch is simply a non-issue compared to whatever it is in your code that is the real problem.
Why do you think you have a performance problem here?

A: mytimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(callAfteroneSecond) userInfo:nil repeats:YES];
[[NSRunLoop mainRunLoop] addTimer:mytimer forMode:NSRunLoopCommonModes];

or
  [self performSelectorInBackground:@selector(Fav_function) withObject:nil];


text:
Q: Minecraft Vanilla elevator How can I use command blocks to test for whenever a player is standing on a certain block within a certain area, and then teleport them?

A: I got the answer from Stefnotch from youtube. The command is:
/execute @a ~ ~ ~ detect ~ ~-1 ~ sand -1 tp @a ~ ~-5 ~

A: You can use this command. Note that the location of the command block doesn't matter.
/tp @a[x,y,z,r] tx ty tz

x, y, and z are the coordinates of the block where you want to test for players.
r is the circular radius that the player must be inside. The location you specified with x, y, and z is the central point of this radius.
tx, ty, and tz are the coordinates that you want to teleport the player to.
Some examples:
/tp @a[0,0,0,10] 1 2 3

See if a player is within 10 blocks of 0, 0, 0. If so, teleport them to 1, 2, 3.
/tp @a[100,6,38] 1 2 3

See if a player is at 100, 6, 38. If so, teleport them to 1, 2, 3. The radius isn't specified, so the player has to be on the exact block.
Make sure you pay attention to the details. No space between "a" and "[". Commas between x, y, and z but not between tx, ty, and tz. Good luck!

A: A more user-interface style would be to have buttons on the wall with signs above them that say things like "Level 2" or "Second Floor: Storage" and command blocks behind them or activated by a /testforblock command that have /tp commands such as

/tp @p x y z
/tp @a[team=Elevator] x y z
/tp @a[r=2] x y z

I used this system very much when i was building my first command block world called "Megalopolis". It involved players exploring a vast city and trading with villagers to get title deeds, keys and coins. When using this a lot on structures with evenly spaced elevators, copied commands and relative coordinates sped up programming significantly.
Obviously, you could use the detect function used in previous answers, but this is simple and rather more decorative.


text:
Q: VBA Fields.Count returns 2 instead of 3 i try to update the links of my word document with a excel file. i already got this code from the internet
Dim fieldCount As Integer
fieldCount = ActiveDocument.Fields.Count

but its returning 2 instead of 3.
My link Settings which shows 3 Items but i only get 2 with the code above
How can i count all the items in the link window as i need to update all of them? For me logically the count it return should be 3 not 2.
Is it because the first 2 got the same setting? Same Row so it recognized it as 1 item ?
My full code is changing the first 2 but leave the 3rd as it is.
Tried to +1 the for loop but the item in not recognized then.
Hopefully someone from this Community can help me with that as i really need it :)

A: That could be because your fields are in different part of document, in different StoryRanges. Try with the following loop which goes through all StoryRanges and list number of Fields in each of Range
Sub ListAllFields()

    Dim SR As Range
    For Each SR In ActiveDocument.StoryRanges
        Debug.Print SR.Fields.Count

    Next SR
End Sub


text:
Q: How to protect user specified table name from SQL Injection in C#, using MySQL As a reaction to MySqlParameter as TableName, it seems that MySQL's Connector/NET library doesn't support table names from user input in the following way:
MySqlCommand cmd = new MySqlCommand("SELECT * FROM @table");
cmd.Parameters.AddWithValue("@table",TableNameFromUserInput);

So I tried to find another way, but I couldn't find any libraries that did this for me.
When searching for how to do this manually, I couldn't found anything that didn't tell you to use "prepared statements" from some already defined library, no matter the language.
To my limited knowledge of SQL, I only think it's necessary to put backticks (`) around the user input and then check the input for backticks - but I wanted to be sure.
Question
How do you protect a user specified table name from SQL-Injection when the MySQL Connector doesn't support it?

A: Check if
TableNameFromUserInput

is an existing table, before executing the query.
That prevents other errors like "table doesnt exist" aswell.

A: you cannot add tableName (as well as columnName) as parameter in prepared statements because it only supports for a value. For your safety, add additional code to validate tableName, ex.
string tableName = "hello";
tableName = UDFunctionClean(tableName);
string query = String.Format("SELECT * FROM `{0}`", tableName);
MySqlCommand cmd = new MySqlCommand(query);


text:
Q: Why I need to use height inherit for every component I create I have angular app with 3 nested components:
App Component
Inside the App component there is the tabs Component
Inside the tabs component I have tabs
In order to give this components full height of the screen, I needed to go to each one of the components styles and to give it height: inherit or height: 100%, otherwise the nested component is not taking the full height of the page even though its parent have the full height.
My styles.scss:
html, body{
  height: 100vh;
  margin: 0px;
}

app-root {
  display: block;
  height: 100%;
}

What is the correct approach, how to fix this problem correctly?
Thanks


text:
Q: Prove that the solution set of $a_n \not= n$, $n \in \mathbb{N}$ is finite. Problem:For fixed positive integers $s, t$, define $a_n$ as the following.
$a_1 = s, a_2 = t$, and $\forall n \ge 1$, $a_{n+2} = \lfloor \sqrt{a_n+(n+2)a_{n+1}+2008} \rfloor$.
Prove that the solution set of $a_n \not= n$, $n \in \mathbb{N}$ is finite.
I have try prove $a_{n}\ge n$,We already know $a_3 \ge 3$ and $a_4 \ge 4$.
We prove by induction that $a_n \ge n$ for all $n\ge 3$.
Assume that $a_n \ge n$ and $a_{n+1} \ge n+1$.
Then
$$(a_{n+2}+1)^2 > a_n + (n+2)a_{n+1} +2008 \ge n+(n+2)(n+1) + 2008 > (n+2)^2$$, so $a_{n+2} \ge n+2$.
Therefore, we have $a_n \ge n$ for $n \ge 3$.then I can't Thanks

A: Let $A_n=\max\{a_n;a_{n+1}\}$
Lemma 1. $a_n \ge n$ for all $n \ge 2008$. You already proved this lemma.
Lemma 2. $A_n \ge n$ for all $n \ge 2008$.
Proof. Since $A_n \ge a_n$ and $a_n \ge n$ then  $A_n \ge n$.
Lemma 3. There is $n_0 \ge 2008$ such that $A_{n_0} \le n_0+1$. Proof by contradiction. Assume that $A_n \ge n+2$ for all $n \ge 2008$. Then $a_{n+2} \le \sqrt{a_n+(n+2)a_{n+1}+2008}\le \sqrt{A_n+(n+2)A_{n}+2008} \le\sqrt{A_n+A_{n}^2+2008}=$ $=\sqrt{(A_n+0.5)^2+2007.75}<A_n+0.5+\frac{2007.75}{2(A_n+0.5)}\le A_n+0.5+\frac{2007.75}{2(2008+0.5)}<A_n+1$. Then $a_{n+2} \le A_n$ for all $n \ge 2008$. Since $a_{n+2} \le A_n$ and $a_{n+1} \le A_n$ (by definition of $A_n$) then $\max\{a_{n+1};a_{n+2}\} \le A_n$. Then $A_{n+1}\le A_n$ for all $n \ge 2008$. Then $A_{n}\le A_{2008}$ for all $n \ge 2008$. But $A_n \ge n$. Contradiction.
Lemma 4. $a_{n+2} \le A_n+1$ for all $n \ge 2008$. Proof. If $n \ge 2008$ then $a_{n+2} \le \sqrt{a_n+a_{n+1}+(n+1)a_{n+1}+2008}\le\sqrt{a_n+a_{n+1}+a_{n+1}^2+2008} \le \sqrt{2A_n+A_{n}^2+2008}=$ $=\sqrt{(A_{n}+1)^2+2007}<A_n+1+\frac{2007}{2(A_n+1)}\le A_n+1+\frac{2007}{2(2008+1)}<A_n+1.5$. Then $a_{n+2} \le A_n+1$ for all $n \ge 2008$.
Lemma 5. $a_{n+k} \le A_n+k-1$ for all $n\ge 2008$ and for all $k \ge 1$. Proof by induction. It is true for $k=1$ by definition of $A_n$. It is true for $k=2$ by Lemma $4$. Assume that $a_{n+k} \le A_n+k-1$ and $a_{n+k+1} \le A_n+k$. Then by Lemma $4$ we have $a_{n+k+2}\le A_{n+k}+1=\max\{a_{n+k};a_{n+k+1}\}+1\le \max\{A_n+k-1;A_n+k\}+1=$ $=A_n+k+1$.
Lema 6. There is $m\ge 2009$ such that $a_n=n$ for all $n\ge m$. Proof. By Lemma $5$ we have $a_{n_0+k} \le A_{n_0}+k-1$ for all $k \ge 1$. But by Lemma $3$ $A_{n_0} \le n_0+1$. Then $a_{n_0+k} \le n_0+1+k-1=n_0+k$ for all $k \ge 1$. But $a_{n_0+k} \ge n_0+k$ by Lemma $1$. Then $a_{n_0+k}=n_0+k$ for all $k \ge 1$.

A: Let $n > 20080$ (large enough).
Let $ b_n = a_n - n$.
We want to show that for some $N$, for any $ n > N$, $ b_n = 0 $.
Claim: $b_{n+2} \leq \frac{ b_{n+1} + \frac{2b_{n+1} + b_n + 2010 } { 20080 }} {2}    $

 Proof: $ (a_{n+2})^2 \leq n + b_n + (n+2)(n+ 1+b_{n+1}) + 2008 $
$= n^2 + n (4 + b_{n+1} ) + 2b_{n+1} + b_n + 2010 $
$ < n^2 + n (4 + b_{n+1} + \frac{ 2b_{n+1} + b_n + 2010 } { 20080 }) $
$< ( n + 2+\frac{b_{n+1} + \frac{ 2b_{n+1} + b_n + 2010 } { 20080 }} {2} )^2 $

Corollary: There is an $N_1$ such that for any $n \geq N_1$, $b_n \leq 0$.
Given that you've shown $ b_n \geq 0$, we conclude that for $ n > N$, $b_n = 0$.


text:
Q: Using Python to playback mic input to PC in real-time I'm trying to use Python to 'mic-monitor', i.e., to playback the mic signal through the headphones in real-time, in addition to any other output signal from the PC.
I can accomplish this by amending my PC's playback settings, but I want to do it with Python, so that I can program a Raspberry Pi to mic-monitor my cheap headset for the PS4.
I can almost accomplish this with PyAudio or sounddevice, but there is a small but significant delay. So:

*

*Is there a way to eradicate that latency with Python, for example by somehow accessing my PC's inputs more directly?

*Otherwise, why is it not possible with Python?

*Can I somehow configure the Raspberry Pi to mic monitor in the same way as my PC?

Sounddevice code is shown below for reference:
import sounddevice as sd
duration = 5.5  # seconds

def callback(indata, outdata, frames, time, status):
    if status:
        print(status)
    outdata[:] = indata

with sd.Stream(channels=2, callback=callback):
    sd.sleep(int(duration * 1000))

A: There will always be latency with a computer in-between. Professional audio gear is usually custom built for minimal latency (or it's just analog). To reduce latency you need to record smaller chunks at a time before sending them to the output which does introduce more processing overhead. Using smaller chunks can also at some point introduce more jitter in the signal because the inter-frame latency might not keep up with the sample rate. PortAudio is probably likely able to be configured to have a bit less latency, but you're probably getting a lot of the delay from the OS and audio drivers as well. Here's a page discussing how you can optimize the OS and audio drivers for minimal latency on a Raspberry Pi. PortAudio (the driver behind most python audio libraries), also has a discussion on audio driver latency based on your operating system.
looking at the documentation for sd.Stream, it looks like even if you specify a smaller blocksize, due to the implementation, it may make latency even worse.
There is however an option to specify an exact latency (if a particular delay is desirable) or to achieve a best effort "as fast as possible" by specifying latency = "low" This attempts to take into account the specific hardware you're using, and go as fast as possible.


text:
Q: Alternate colors on click with jQuery I'm sure there is a simple solution to this, and I'm sure this is a duplicate question, though I have been unable to solve my solution particularly because I don't really know how to phrase it in order to search for other questions/solutions, so I'm coming here hoping for some help.
Basically, I have spans with classes that assigns a background-color property, and inside those spans are words. I have three of these spans, and each time a user clicks on a span I want the class to change (thus changing the background color and inner text).
HTML:

    Lorem
    Ipsum
    Dolor

CSS:
.alternate span { display : none }
.alternate .showing { display : inline }
.blue { background : blue }
.green { background : green }
.red { background : red }

jQuery:
$(".alternate span").each(function() {
    $(this).on("click", function() {
        $(this).removeClass("showing");
        $(this).next().addClass("showing");
    });
});

This solution works great using $.next until I get to the third click, whereafter .showing is removed, and is not added since there are no more $.next options. How do I, after getting to the last-child, add .showing to the first-child and then start over? I have tried various options including if($(".alternate span:last-child").hasClass("showing")) { etc. etc. }, and I attempted to use an array and for loop though I failed to make it work.
Newb question, I know, but I can't seem to solve this so as a last resort I'm coming here.

A: try this:
$(".alternate span").each(function() {
   $(this).on("click", function() {
        $(this).removeClass("showing");

        if($(this).is(":last-child"))
            $(".alternate span:first-child").addClass("showing");
        else
            $(this).next().addClass("showing");
    });
});

http://jsfiddle.net/NPx2x/

A: Check this, and also it performs faster. .next() returns undefined if no element found.
$(".alternate span").on("click", function() {

    $(this).removeClass("showing");
     var next = $(this).next();

     next.length ? next.addClass("showing") : $("span.blue").addClass("showing");
});


text:
Q: Mining not working in Dwarf Fortress v0.43 Whenever I try to mine, it doesn't work. I press D for designate, then D again for mine. Then I press Enter, and it makes the green cross. But once I press Enter in a different place, it just gets rid of the green cross and doesn't make a highlighted box. I've tried using <and >, but going onto a different level doesn't help either.

A: First of all, they key combination is dd, not DD. But you already know this, because the first part ("green cross") worked.
It seems that you have accidentally selected "automining" (a), and the area you are trying to mine doesn't contain useful minerals - if so, press a a few more times until it chooses "normal mining".


text:
Q: How to add a placeholder to a radio button? I was wondering if there was a way to add a placeholder to a radio button. I tried to do it, code below, but it did not work. I want the first button to have the placeholder value "1", and the second to have the value "2" and so on. Is there a way to do that? I mean that the button, when the user looks at it, will have number "1" in it.
  function drawTable(daysInMonth) {
          var cellsToDraw = daysInMonth;
          var table = document.getElementById("table");
          table.innerHTML = "";
          for (r = 0; r < (daysInMonth / 7); r++) {
            var newRow = document.createElement("tr");
            table.appendChild(newRow);
            for (c = 0; c < 7 && cellsToDraw > 0; c++) {
              var newCell = document.createElement("input");
              newCell.setAttribute("type", "radio");
              newCell.setAttribute("name", "day");
              newCell.setAttribute("placeholder", 1)
              newRow.appendChild(newCell);
              newCell.innerHTML = //add the numbers here?
              cellsToDraw--;
            }
          }
        }

CSS:
input[type=radio] {
  border: 1px solid;
  padding: 0.5em;
  -webkit-appearance: none;
  width: 95px;
  height: 100px;
  margin-right: -4px;
  margin-top: -8px;
}

All help is appriciated!

A: Radio buttons don't support placeholders, and there wouldn't be any space to render one in anyway.
It sounds like you are confusing placeholders with labels (see this article).
Use a LABEL element instead.

Aside: INPUT elements are not allowed to be children of TR elements. Only TD and TH elements may be children of a TR.

function drawTable(daysInMonth) {
  var cellsToDraw = daysInMonth;
  var table = document.createElement("table");
  document.body.appendChild(table);
  for (r = 0; r < (daysInMonth / 7); r++) {
    var newRow = document.createElement("tr");
    table.appendChild(newRow);
    for (c = 0; c < 7 && cellsToDraw > 0; c++) {
      var newCell = document.createElement("td");
      var input = document.createElement("input");
      var label = document.createElement("label");
      input.setAttribute("type", "radio");
      input.setAttribute("name", "day");
      label.appendChild(input);
      label.appendChild(document.createTextNode("1"));
      newCell.appendChild(label);
      newRow.appendChild(newCell);
      cellsToDraw--;
    }
  }
}

drawTable(30);

A: instead of innerHTML you can set value
newCell.value = c


text:
Q: What is the difference between "." and "->"? I've grasped the concept of pointers using these symbols (* and &) for declaring pointers and getting the value(s) of them. However I do not know how to use -> properly for pointers.
I'd appreciate it if someone could provide me a link with info about ( -> ) or explain it to me.

A: a->b means (*a).b.  When using multiple indirection, -> can be considerably more convenient, as in a->b->c->d.

A: Let's assume that you have a struct foo_t:
typedef struct foo_t
{
    int bar;
};

Now, let's create an instance on the stack and access bar:
foo_t foo;
foo.bar = 1;

When we have an object (as opposed to a pointer to an object), as we do here, we use the dot operator to access fields within it.
However, if we have a pointer to the object, we use the arrow operator rather than the dot operator:
foo_t* foo2 = &foo;
foo2->bar = 1;

If we have a pointer to a pointer to the object, there's no special syntax and the notation gets a little uglier:
foo_t** foo3 = &foo2;
(*foo3)->bar = 1;


text:
Q: Insert Form data to Jquery Datatable I am trying to inserting data to jquery Datatable. But it did not insert correctly.

$(document).ready(function() {
  var t = $('#example').DataTable();

  var branchName = $("#branchName option:selected").val();
  var accountNo = $("#accountNo").val();

  $('#addRow').on('click', function() {
    t.row.add([branchName, accountNo]).draw();
  });

});
<link href="//cdnjs.cloudflare.com/ajax/libs/datatables/1.10.7/css/jquery.dataTables.min.css" rel="stylesheet">

  Branch

    <select class="form-control" name="branches" id="branchName">
      <option>--Select--</option>
      <option value="C01">C01</option>
      <option value="C02">C02</option>
    </select>

  Account No.

    <input type="text" class="form-control" id="accountNo" name="accountNo">

    <button type="button" class="btn btn-primary-action" id="addRow"> Add to Grid</button>

      Branch
      Acc. No.

I alerted drop down and text box value. It's working well. I think there is an issue when record insert into data-table. If you know any solution please mention.

A: You need to move the variables into the click handler, otherwise they are set on page load and not updated after you change the values.
$(document).ready(function() {
  var t = $('#example').DataTable();

  $('#addRow').on('click', function() {
    var branchName = $("#branchName option:selected").val();
    var accountNo = $("#accountNo").val();
    t.row.add([branchName, accountNo]).draw();
  });
});

Updated snippet:

$(document).ready(function() {
  var t = $('#example').DataTable();

  $('#addRow').on('click', function() {
    var branchName = $("#branchName option:selected").val();
    var accountNo = $("#accountNo").val();
    t.row.add([branchName, accountNo]).draw();
  });
});
<link href="//cdnjs.cloudflare.com/ajax/libs/datatables/1.10.7/css/jquery.dataTables.min.css" rel="stylesheet">

  Branch

    <select class="form-control" name="branches" id="branchName">
      <option>--Select--</option>
      <option value="C01">C01</option>
      <option value="C02">C02</option>
    </select>

  Account No.

    <input type="text" class="form-control" id="accountNo" name="accountNo">

    <button type="button" class="btn btn-primary-action" id="addRow"> Add to Grid</button>

      Branch
      Acc. No.


text:
Q: Unexpected token error when migrating to native classes for components I upgraded to Ember 3.11 and I want to start using native classes for my components.
When I change a component class to something similar like:
    export default class MyClassName extends BaseComponent {

        myFieldName;

    }

I get a build error
"Parsing error: Unexpected token ;" because of the class field.
Ideas how to make sure ember-cli doesn't complain about the new syntax are more than welcome.
Thanks
UPDATE:
Following jelhan's suggestion below I updated my package.json file as in ember-cli/ember-new-output (https://github.com/ember-cli/ember-new-output/blob/master/package.json). This didn't help. I also created a brand new ember project with a single component in it and I still have the same problem.
This is the package.json file which gets generated when creating new ember project (ember-cli 3.11.0):
{
  "name": "my-project",
  "version": "0.0.0",
  "private": true,
  "description": "Small description for my-project goes here",
  "repository": "",
  "license": "MIT",
  "author": "",
  "directories": {
    "doc": "doc",
    "test": "tests"
  },
  "scripts": {
    "build": "ember build",
    "lint:hbs": "ember-template-lint .",
    "lint:js": "eslint .",
    "start": "ember serve",
    "test": "ember test"
  },
  "devDependencies": {
    "@ember/jquery": "^0.6.0",
    "@ember/optional-features": "^0.7.0",
    "broccoli-asset-rev": "^3.0.0",
    "ember-ajax": "^5.0.0",
    "ember-cli": "~3.11.0",
    "ember-cli-app-version": "^3.2.0",
    "ember-cli-babel": "^7.7.3",
    "ember-cli-dependency-checker": "^3.1.0",
    "ember-cli-eslint": "^5.1.0",
    "ember-cli-htmlbars": "^3.0.1",
    "ember-cli-htmlbars-inline-precompile": "^2.1.0",
    "ember-cli-inject-live-reload": "^1.8.2",
    "ember-cli-sri": "^2.1.1",
    "ember-cli-template-lint": "^1.0.0-beta.1",
    "ember-cli-uglify": "^2.1.0",
    "ember-data": "~3.11.0",
    "ember-export-application-global": "^2.0.0",
    "ember-load-initializers": "^2.0.0",
    "ember-maybe-import-regenerator": "^0.1.6",
    "ember-qunit": "^4.4.1",
    "ember-resolver": "^5.0.1",
    "ember-source": "~3.11.1",
    "ember-welcome-page": "^4.0.0",
    "eslint-plugin-ember": "^6.2.0",
    "eslint-plugin-node": "^9.0.1",
    "loader.js": "^4.7.0",
    "qunit-dom": "^0.8.4"
  },
  "engines": {
    "node": "8.* || >= 10.*"
  }
}

Seems like the new syntax works fine. The javascript code executes as expected. I guess the errors I see in the build output are eslint errors only. I need to figure out how to configure eslint to understand the new syntax.

A: as @Lux pointed out in a comment, the value is missing.
This will fix your syntax error:
export default class MyClassName extends BaseComponent {
  myFieldName = undefined;
}

Also, be sure to have the latest version of ember-cli-babel installed to ensure that you have the latest bundled set of babel plugins -- earlier versions of ember-cli-babel did not support classes. The latest at the time of writing this is 7.10.0 https://www.npmjs.com/package/ember-cli-babel
In classic syntax, this would be the equivalent of:
export default BaseComponent.extend({
  myFieldName: undefined,
});

If you're curious about more of the differences -- here is a bit more information on native javascript classes in Ember from the ember-decorators documentation: https://ember-decorators.github.io/ember-decorators/docs/native-class-basics

On a somewhat related note:
I know it's been common in Ember to define all the properties a component may receive at the top to declare its API, but now is actually a really good time to get in to TypeScript, so that you may add more semantic meaning to your classes.
Initializing a property as undefined is the same as not specifying it, so with TypeScript, you can attain better semantics with:
interface Args {
  myFieldName: string;
}

export default class MyClassName extends BaseComponent<Args> {

}

Assuming BaseComponent is a Glimmer Component, info here: https://octane-guides-preview.emberjs.com/release/upgrading/editions/#toc_tracked-properties
(EmberComponents don't accept Type Arguments, as far as I know)


text:
Q: How to detect an error in a Tcl thread fileevent or after script In my main thread I am trying to detect and respond to an error that occurs in a worker thread's fileevent script. I wrote a test script to try to detect thread errors in four cases:

*

*Synchronous thread::send, immediate error in thread

*Synchronous thread::send, error in thread after script

*Asynchronous thread::send, immediate error in thread

*Asynchronous thread::send, error in thread after script

I used an after command in my test thread to (hopefully) mimic a fileevent script. As expected, the case 1 thread error is caught via a catch of the thread::send command and the case 3 thread error is caught by the thread::errorproc procedure and by my custom bgerror procedure. The cases 2 and 4 thread errors are reflected in the main thread but I can't seem to catch them via my custom procedures.
Following is my test script:
    #!/usr/bin/env tclsh

    package require Thread;

    # Custom error handling procedure for errors during asynchronous thread::send
    proc error_proc {id error} {
            puts "\n---------- error_proc: $id $error **********\n";
    }
    thread::errorproc error_proc;

    # Custom error and bgerror procedures to try to see the thread error
    rename error original_error;
    proc error {err} {
            puts "---------- error: $err\n";
    }
    proc bgerror {err} {
            puts "---------- bgerror: $err\n";
    }

    # Non-blocking wait procedure to keep the output in order
    proc waitms {ms} {
            set ::done 0;
            after $ms {set ::done 1};
            vwait ::done;
    }

    # Create the worker thread
    set tid [thread::create {

            proc test_error_immediately {s} {
                    error "test_error_immediately ($s)";
            }

            proc test_error_after {ms s} {
                    after $ms [list error "test_error_after ($s)"];
            }

            thread::wait;

            puts "---------- Exiting thread";
    }]

    # Test case 1 - synchronous thread::send, immediate error
    if {[catch {thread::send $tid [list test_error_immediately "Case 1"]} result]} {
            set state "ERROR";
    } else {
            set state "OK";
    }
    puts "---------- Synchronous test_error_immediately $state ($result)\n"

    # Test case 2 - synchronous thread::send, error in thread after script
    if {[catch {thread::send $tid [list test_error_after 1000 "Case 2"]} result]} {
            set state "ERROR";
    } else {
            set state "OK";
    }
    puts "---------- Synchronous test_error_after $state ($result)\n";

    # Wait so that the output is in order
    waitms 1500;

    # Test case 3 - asynchronous thread::send, immediate error
    if {[catch {thread::send -async $tid [list test_error_immediately "Case 3"] result} catch_result]} {
            set state "ERROR";
            set result $catch_result;
    } else {
            set state "OK";
            vwait result;
    }
    puts "---------- Asynchronous test_error_immediately $state ($result)\n";

    # Wait so that the output is in order
    waitms 100;

    # Test case 4 - asynchronous thread::send, error in thread after script
    if {[catch {thread::send -async $tid [list test_error_after 1000 "Case 4"] result} catch_result]} {
            set state "ERROR";
            set result $catch_result;
    } else {
            set state "OK";
            vwait result;
    }
    puts "---------- Asynchronous test_error_after $state ($result)\n";

    # Clean up
    if {[thread::exists $tid]} {

            after 2000 {
                    thread::release $::tid;
                    puts "\n---------- $::tid released\n";
            }
    }

    puts "---------- Waiting forever ...\n";

    vwait forever;

Following is the output on my computer:
    ---------- Synchronous test_error_immediately ERROR (test_error_immediately (Case 1))

    ---------- Synchronous test_error_after OK (after#0)

    test_error_after (Case 2)
        while executing
    "error {test_error_after (Case 2)}"
        ("after" script)

    ---------- error_proc: tid0x7f5673e9d700 test_error_immediately (Case 3)
        while executing
    "error "test_error_immediately ($s)""
        (procedure "test_error_immediately" line 2)
        invoked from within
    "test_error_immediately {Case 3}" **********

    ---------- Asynchronous test_error_immediately OK (test_error_immediately (Case 3))

    ---------- bgerror: test_error_immediately (Case 3)

    ---------- Asynchronous test_error_after OK (after#1)

    ---------- Waiting forever ...

    test_error_after (Case 4)
        while executing
    "error {test_error_after (Case 4)}"
        ("after" script)

    ---------- tid0x7f5673e9d700 released

    ---------- Exiting thread

I am using Tcl 8.5 and Ubuntu 10.04 LTS.
Do you have any other suggestions on how to detect an error that occurs within a thread's fileevent or after script?
Regards,
smercer


text:
Q: Refer to previous of previous page in ASP.NET Core 3.1 Razor Pages in my Razor app I am trying to make back redirections to previous pages. I find good solution from this post https://stackoverflow.com/a/42228327/6485612 using Request.Headers["Referer"], however, the problem is how to remember the previous backUrl of the previous page. When i want to go two pages back, I end up in a loop between two pages I was lastly on.
Do you have any ideas how to achieve to go multiple pages back?

A: you can use
Use @Html.ActionLink("Go Back","Actio Name","Controller Name")

or you can use javascript adding a back button
<button onclick="window.history.back()">Back</button>


text:
Q: view controller does not load with content I have a button that when clicked shows a view controller. The code for that event is:

and my view controller looks like this:

note the segmented control and background image.
Here is my h and m files of my view controller in case you need them:

when I run my app here is how that view control looks on my iPad:

why do the background image and segmented control do not appear? why are contents not being loaded? It looks like another view controller is being loaded but I have already make sure that I am placing the correct name in the string for the view controller.

    - (IBAction) vaClick
{
    imgVa.image = [UIImage imageNamed:@"bt-valores.png"];

UIViewController *control = [[NuestrosValoresViewController alloc] initWithNibName:@"NuestrosValoresViewController"
                                                                            bundle:nil];
UINavigationController *navControl = [[UINavigationController alloc]
initWithRootViewController:control];

[self presentModalViewController:navControl animated:NO];

[navControl setNavigationBarHidden:YES];

[control release];
[navControl release];

//UINavigationController *navControl = [[UINavigationController alloc]
//initWithRootViewController:control];
//[self presentModalViewController:navControl animated:NO];

}
should I release it like this? sorry I basically have to translate a power point presentation to an app therefore I know very little about objective-c. thanks for the help and sorry for the dumb question.

A: You're not setting the root view controller of your UINavigationController.
Use this line instead when initializing the navigation controller:
UINavigationController *navControl = [[UINavigationController alloc] initWithRootViewController:control];
You'll also want to release navControl after you present it modally. I'll write out the code for you if you post your code instead of using screenshots.


text:
Q: How to connect words correctly
Needle set/ Needles set

or

Set of needles

Are all these constructions in conformity with the English grammar? Do they possess different meanings?

A: Without a doubt, it would be best to use "a set of needles"; "needles set" is definitely incorrect, whereas "needle set" has the risk of sounding like informal jargon and can be confusing to the reader unless more context is given beforehand. As for which of these conform(s) to English grammar, "a set of needles" is the only one that works formally. If you ignore the informality of "needle set" and invalidity of "needles set," they all essentially carry the same meaning.


text:
Q: imgareaselect on scaled image with preview not working properly I have been trying to make imgareaselect plugin work on scaled image, the image is scaled dynamically using css max-width:100% and max-height:100% to make it fit into its container.
try: http://jsfiddle.net/37wcJ/
As you can see in the fiddle above, the preview is not showing the same thing in the selection, try selecting the horizon behind the tree you can see it clearly.
HTML:

Jquery with imgareaselect plugin
$(document).ready(function(){
     function preview(img, selection) {
         if (!selection.width || !selection.height)
            return;
            var scaleX = 150 / selection.width;
            var scaleY = 150 / selection.height;

         $('#preview').css({
            width: Math.round(scaleX * 300),
            height: Math.round(scaleY * 300),
            marginLeft: -Math.round(scaleX * selection.x1),
            marginTop: -Math.round(scaleY * selection.y1)
          });
      }

    //dynamic aspect ratio
   var daspectratio = $('#croptarget').height() /  $('#croptarget').width();
  var paspectratio = $('#preview-cont').height() / $('#preview-cont').width();
   var dyap =daspectratio+":" + paspectratio;

                        $('#croptarget').imgAreaSelect({
                            aspectRatio: dyap,
                            handles: true,
                            fadeSpeed: 200,
                            onSelectChange: preview
                        });
});

CSS
   #container{
        background-color:#ccc;
        width:400px;
        height:300px;
    }

    #croptarget{
        max-width:100%;
        max-height:100%;
    }

    #preview-cont{
        width:150px;
        height:150px;
        overflow:hidden;
        border:1px solid #000;
        float:right;
    }

You can see im trying to make a dynamic aspect ratio, which I think its not working too.

A: Maybe I'm late, but I here it goes.
If your preview container is 150px * 150px, then it doesn't look nice to have a dynamic aspectRatio, you can simply set it to "1:1".
//static aspectRatio

$('#croptarget').imgAreaSelect({
    aspectRatio: "1:1",
    handles: true,
    fadeSpeed: 200,
    onSelectChange: preview
});

Then, you can change the preview function to something like this:
$('#preview').css({
    width: Math.round(scaleX * $("#croptarget").width())+"px",
    height: Math.round(scaleY * $("#croptarget").height())+"px",
    marginLeft: -Math.round(scaleX * selection.x1),
    marginTop: -Math.round(scaleY * selection.y1)
});

You need to get the large image width and height, so the function calculates de exact width and height the preview image needs.
Here's your modified jsfiddle

A: Because aspectRatio is used to force an aspect ratio to the selection.
If you want to modify your image size with css, and cut accurately, you need to pass imageWidth and imageHeight:
$(selector).imgAreaSelect({
    imageWidth: 1920,
    imageHeight: 1080
});


text:
Q: Postman Icon missing on Ubuntu14.04 sidebar launcher after version update I have updated the native postman version from 5.2.0 to 6.2.5 in my Ubuntu 14.04 system and all my previous version API collections are available without any issues.
When I tried to lock Postman to the sidebar Launcher on my Ubuntu system, I noticed the Postman icon is not displaying and it is displaying ? symbol instead. I have restarted the Postman application as well but no luck. Anyone solved this problem before or can I safely ignore this since there is no issues with Postman functional features?


text:
Q: What value should a dialog procedure return on WM_NOTIFY if a particular notification is not processed? My dialog procedure:
INT_PTR CALLBACK DlgProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)
{
    INT_PTR result = TRUE;
    switch(iMessage)
    {
    case WM_NOTIFY:

        switch (((LPNMHDR)lParam)->idFrom)
        {
            case ID_xxx:
                // process notify from control ID_xxx
                break;
            case ID_yyy:
                // process notify from control ID_yyy
                break;
            default:
                result = FALSE;
        }
        default:
        result = FALSE;
    }
    return result;
}

In case the notification is from a control that I don't use, or suppose I am not interested in the LVN_ITEMCHANGED notification of a particular listcontrol, I would set result to FALSE, causing the default windows procedure to be called.
Do I always have to do this? Is it a problem if I don't?

A: In case of notification messages, whether you return TRUE or FALSE from the DlgProc normally doesn't matter. These messages are sent to notify the parent about something that happens in a child. The default window procedure of the parent does not know what to do in response to something that happens in a child, so even when you return FALSE from DlgProc it will do nothing.
Anyway I would return TRUE for notifications that I handled to make immediately clear for any reader of my code that I handled the message completely on my own and don't need any default processing.
So I would write DlgProc like this:
INT_PTR CALLBACK DlgProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)
{
    switch(iMessage)
    {
        case WM_NOTIFY:
            switch (((LPNMHDR)lParam)->idFrom)
            {
                case ID_xxx:
                    // process notify from control ID_xxx
                    return TRUE;
                case ID_yyy:
                    // process notify from control ID_yyy
                    return TRUE;
            }
            break;
    }

    // We are not interested in the message. Let dialog manager do any default processing.
    return FALSE;
}

By getting rid of the result variable and returning early from the case branches, the code is simplified and becomes easier to read and maintain. When trying to figure out what a particular case branch does, I no longer have to trace in my mind the state of the result variable down to the final return statement. When I see a return statement in a case branch I can just skip over reading the remaining part of the code.

A: Per the WM_NOTIFY documentation:

The return value is ignored except for notification messages that specify otherwise.

So, return whatever value you want, except for specific notifications that actually define a return value.
For instance, the LVN_ITEMCHANGED documentation states:

No return value.

However, the DialogProc documentation states:

Return value
Type: INT_PTR
Typically, the dialog box procedure should return TRUE if it processed the message, and FALSE if it did not. If the dialog box procedure returns FALSE, the dialog manager performs the default dialog operation in response to the message.
If the dialog box procedure processes a message that requires a specific return value, the dialog box procedure should set the desired return value by calling SetWindowLong(hwndDlg, DWL_MSGRESULT, lResult) immediately before returning TRUE. Note that you must call SetWindowLong immediately before returning TRUE; doing so earlier may result in the DWL_MSGRESULT value being overwritten by a nested dialog box message.
The following messages are exceptions to the general rules stated above. Consult the documentation for the specific message for details on the semantics of the return value.

*

*WM_CHARTOITEM

*WM_COMPAREITEM

*WM_CTLCOLORBTN

*WM_CTLCOLORDLG

*WM_CTLCOLOREDIT

*WM_CTLCOLORLISTBOX

*WM_CTLCOLORSCROLLBAR

*WM_CTLCOLORSTATIC

*WM_INITDIALOG

*WM_QUERYDRAGICON

*WM_VKEYTOITEM

So, just return TRUE for any message that you don't want the default message handler to see, and use DWL_MSGRESULT for any message that requires a return value.


text:
Q: Searching for specific duplicate ID's I've written a perl script which reads in 2 different files, compares the ID's in these two files and only prints out the data where the ID's match. The ID file is read into an array, while the data file is read line by line. This all works rather well, however now I need to add more to it. In my data file, I'll sometimes have rows where the ID is duplicated, as the subject has been for more than one visit to give samples. I therefore need to look for these duplicates and take only the latest date of visit.
So my data file looks something like this:
   ID  DOV  Data1  Data2 etc etc

Now I've seen hashes are the way to search for duplicates, however all the fixes I've seen have been to simply remove the duplicates indiscriminately, which isn't what I want.
Any ideas?

A: This will show the last DOV for each ID, making a lot of assumptions about the input data, so there's a good chance that it won't work out-of-the-box for you.  (In particular, if your input data isn't sorted by date, it won't work at all because it just takes the last date seen for each ID.  Also, if dates are formatted in a way that includes spaces, such as "Mon Jul  9 15:51:22 CEST 2012", it will only get the date up to the first space ("Mon" in this example).)  The point here is just to demonstrate the basic technique, not to provide a full solution.
#!/usr/bin/env perl

use strict;
use warnings;

my %visit;
while (<DATA>) {
  my ($id, $date) = split;
  $visit{$id} = $date;
}

for my $id (sort keys %visit) {
  print "$id => $visit{$id}\n";
}

__DATA__
1       2012-01-01
2       2012-01-02
1       2012-02-03
3       2012-02-04
2       2012-03-05
3       2012-03-06
4       2012-04-07
1       2012-04-08
5       2012-05-09
1       2012-05-10

A: # read id file
my %id_hash;
while (<IDFILE>) {
  chomp;
  $id_hash{$_} = 1;
}

#read data file
while (<DATAFILE>) {
  my @arr = split(/\s+/, $_);
  if (defined $id_hash{$arr[0]}) { # only process if exists in id file
    # and only if this is the first data entry or a later visit
    if ( (not ref $id_hash{$arr[0]}) or ($id_hash{$arr[0]}[1] < $arr[1]) ) {
      # store all data in an array ref
      $id_hash{$arr[0]} = [ @arr ];
    }
  }
}

for my $id (keys %id_hash) {
  print join(" ", @{$id_hash{$id}}), "\n";
}


text:
Q: How could I align the label and select box I included this theme in my website
and It seems  label and select dropdown can not be aligned well.
How could I fix the the layout broken problem ?
here's the live demo http://lazyair.co/user/index

A: Remove the 20px top margin from the drop-down:
.btn.selectpicker{
    margin-top:0;
}

A: <button type="button" class="btn dropdown-toggle selectpicker btn-light" data-toggle="dropdown" title="高雄" aria-expanded="false">高雄 </button>

you can remove the top margin from this button for this select field only.

A: You should remove margin-top from:

/* line 5, /home/poc/lazy-bird-website/app/assets/stylesheets/city.scss */
#nav-btn-monthly, .btn, .btn-large, .btn-flat {
  padding: 0 0.1rem;
  width: 90px;
  /* margin-top: 20px; */
  color: white;
  font-size: 1.0rem;
}


text:
Q: Links to games created by Windows when delphi projects create exes with specific names I have a Delphi project called VR that produces an executable named VR.exe. To my dismay I discovered Windows (I am running Window 7 64 bit Ultimate) has added links to the start menu and under games: Search & Rescue: Vietnam MED+EVAC. The icons for the links are the default delphi app icon.
Did a bit of research and I found this post:
http://social.technet.microsoft.com/Forums/windows/en-US/a5919fc1-db3d-4f13-b241-d059df2bf11f/renaming-a-file-into-vrexe
How can I prevent windows from doing this?
Update: I have another project MM, which produces mm.exe. This one created a link to the Steam Dark Messiah Might and Magic Single Player.
Another update: We submitted a support request to Microsoft. They acknowledged it is a bug, however, they failed to provide a timeline for a fix.
Update: This is the answer from Microsoft:
I am writing to inform you that this issue is reproducible at our end and we have been reported regarding this in past as well. Since this is already identified as "By design" with our code and to this point we do not have a resolution on this, there's not much I would be able to help with.
However, if you have any points that you would like to bring to our knowledge like how it is impacting business or any other concerns , do let me know.
I accepted Remy's answer.

A: According to MSDN, game apps are supposed to integrate themselves into Game Explorer, Windows should not be integrating anything automatically.  But I can confirm on a Win7 Home system that renaming any app to vr.exe and then running it causes Search & Rescue: Vietnam MED+EVAC to appear in Games Explorer (there was also a very noticeable delay when the app is run for the first time, which I imagine is due to the recognition/integraton taking place).
After running the app, I found the following Registry key associated with that game:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\GameUX\S-1-5-21-991038988-4040401710-2535580036-1000\{2A051900-E642-4D69-8D4E-1B3A2FD42CCF}

It contains a reference to this file
C:\Windows\system32\GameUXLegacyGDFs.dll

I looked at the file contents with a resource viewer, and see it is full of RC_DATA resources containing GDF game definitions.
I deleted the Registry key, and now the game no longer appears in Games Explorer, no matter how many times I run the renamed vr.exe file.


text:
Q: Group by each increasing sequence in data frame If I have a data frame with a column of monotonically increasing values such as:
x
1
2
3
4
1
2
3
1
2
3
4
5
6
1
2

How do I add a column to group each increasing sequence that results in:
x   y
1   1
2   1
3   1
4   1
1   2
2   2
3   2
1   3
2   3
3   3
4   3
5   3
6   3
1   4
2   4

I can only think of using a loop which will be slow.

A: You may choose cumsum function to do it.
> x <- c(1,2,3,4,1,2,3,1,2,4,5,1,2)
> cumsum(x==1)
 [1] 1 1 1 1 2 2 2 3 3 3 3 4 4

A: I would use diff and compute the cumulative sum:
df$y <- c(1, cumsum(diff(df$x) < 0 ) + 1)

> df
   x y
1  1 1
2  2 1
3  3 1
4  4 1
5  1 2
6  2 2
7  3 2
8  1 3
9  2 3
10 3 3
11 4 3
12 5 3
13 6 3
14 1 4
15 2 4


text:
Q: Secsh channel 0 open FAILED: open failed: Administratively prohibited ,paramiko.ssh_exception.ChannelException: Tried https://stackoverflow.com/questions/35304525/nested-ssh-using-python-paramiko this code and observing issue at vmchannel = vmtransport.open_channel("direct-tcpip", dest_addr, local_addr)
as below
Secsh channel 0 open FAILED: open failed: Administratively prohibited
paramiko.ssh_exception.ChannelException: ChannelException(1, 'Administratively prohibited')
i have gone through other docs it says @/etc/ssh/ssh_config file AllowTcpForwarding need to be set to "no" or needs to be commented out but my case its already commented out any idea on what might be causing this


text:
Q: Read one csv file and write to another csv file after doing some formatting in perl I am trying to manipulate a csv in perl.
The input csv has some new line characters in column data which is causing an other external program to fail. I have wrote below Perl script to do pre-process the csv to remove these characters.
use strict;
use warnings 'all';

# Using Text::CSV file to allow
# full CSV Reader and Writer
use Text::CSV;
use open ":std", ":encoding(UTF-8)";
my $file = $ARGV[0] or die;

my $csv = Text::CSV->new (
{
    binary => 1,
    auto_diag => 1,
    sep_char => ', '
});

my $sum = 0;

# Reading the file
open(my $data, '<:encoding(utf8)', $file) or die;

while (my $words = $csv->getline($data))
{
    tr/\r\n//d for @$words; #removing new lines
    tr/,/;/ for @$words;    #replacing comma with semicolon
    $csv->combine(@$words);
    print $csv->string, "\n";
}

# Checking for End-of-file
if (not $csv->eof)
{
    $csv->error_diag();
}
close $data;

I am using a below shell script as a wrapper to store the modified file in another csv. Shell wrapper below.
perl xyz.pl ${source_csv_file_name} > ${destination_processed_csv_file_name}

I was hoping I could use a out csv handler in the perl script itself to write the ouput to another file. I tried couple of ways but keep getting one or other error. Below is something which I tried.
my $outcsv = Text::CSV->new ( { binary => 1, quote_char => "", escape_char => "\\" } );
open(my $data, '<:encoding(utf8)', $file) or die;
open(my $fh, ">:encoding(utf8)", "new.csv") or die " new.csv: $!";
while (my $words = $csv->getline($data))
{
    tr/\r\n//d for @$words;
    tr/,/;/ for @$words;
    $csv->combine(@$words);
    # Open a handle to the file "new.csv"
    $outcsv->print ($fh, $_) for @words;

    #print $csv->string, "\n";
}

# Checking for End-of-file
if (not $csv->eof)
{
    $csv->error_diag();
}
close $data;
close $fh or die "new.csv: $!";

Issue is the first code that I posted above works but to write the file I have used the shell wrapper. Now the second perl script (I have only posted the code which is different then the first one ), when I run it fails with an error. I understand the error but not sure how to fix it "Global symbol @words requires explicit package name at xyz.pl line 29. Execution of xyz.pl aborted due to compilation errors.
Would really appreciate if someone can help here.
Thanks

A: I am not sure what failed for you in the first program, but here it is a bit streamlined and cleaned up
use strict;
use warnings 'all';

use Text::CSV;
use open ":std", ":encoding(UTF-8)";

my $file = $ARGV[0] or die "Usage: $0 filename\n";

my $csv = Text::CSV->new({ binary => 1, auto_diag => 1 });

open my $data,   '<',        $file or die $!;
open my $fh_out, '>', 'new_'.$file or die $!;

while (my $words = $csv->getline($data))
{
    tr/\r\n//d for @$words;
    tr/,/;/    for @$words;

    $csv->say($fh_out, $words);
}

This runs correctly, and is nicely tested with an input file borrowed from Shawn's answer.
The combine+string+print from your program works as well for me -- but there is no reason for all that since print nicely combines them (I used say which also appends a newline).
A few comments on the program in the question

*

*Once you've used the open pragma as in your program then don't set encoding when you open files. (And it should be :encoding(UTF-8), not with utf8. See about that in Encode docs, and in this Effective Perler article.)

*When you use die print the actual error, most commonly in $! variable

*The two loops above are clearly less efficient than
for (@$words) { tr/\r\n//d; tr/,/;/ }

I left them as two loops to indicate separate processing steps.

The method say in Text::CSV used above was added to the module at some point, and a version older than that one won't have it.  Then one can

*

*Use print method and also set up eol in the constructor to get newlines printed
my $csv = Text::CSV->new ( { binary => 1, auto_diag => 1, eol => $/ });
...
$csv->print($fh_out, $words);

(there are other ways to get the newline, see docs for eol)

*Or, don't mess with the constructor but add that newline manually
$csv->print($fh_out, $words);
print $fh_out "\n";

*Or, use the roundabout way
$csv->combine(@$words);
print $fh_out $csv->string, "\n";

See docs for print

A: The Text::AutoCSV module (Installed through your OS package manager or favorite CPAN client) makes it easy to transform CSV files:
#!/usr/bin/env perl
use strict;
use warnings;
use Text::AutoCSV;

Text::AutoCSV->new(in_file => $ARGV[0],
                   out_file => $ARGV[1],
                   encoding => "UTF-8",
                   has_headers => 1, # Set to 0 if no header line
                   read_post_update_hr => \&normalize)->write();

sub normalize {
    my $hr = shift;
    for (values %$hr) {
        s/\r?\n//g;
        tr/,/;/;
    }
}

Example:
$ cat input.csv
id,message
1,"a string, with a comma"
2,"another
with a newline"
3,blah
$ perl demo.pl input.csv new.csv
$ cat new.csv
id,message
1,"a string; with a comma"
2,"another with a newline"
3,blah

A: Here's the code that's causing the problem:
while (my $words = $csv->getline($data))
{
    tr/\r\n//d for @$words;
    tr/,/;/ for @$words;
    $csv->combine(@$words);
    # Open a handle to the file "new.csv"
    $outcsv->print ($fh, $_) for @words;

    #print $csv->string, "\n";
}

And, in a comment, you give us the error:

Global symbol @words requires explicit package name at d2l_preprocess_csv_files.pl line 29.

I'm guessing that line 29 is:
$outcsv->print ($fh, $_) for @words;

The call to getline() gives you an array reference that you store in $words. If you want to treat that as an array, you need to dereference it (@$words - as you do in a few places). So on the problematic line you've just forgotten the $. You don't have an array called @words, you need to use $@words.


text:
Q: How to stop Highmaps on mouse hover to change SVG path orders In all Highmaps when we hover on any particular country, the hoverd country SVG path put at the bottom in order to show hovered country on the top of others (the way we achieve z-index in svg).
I don't want Highmaps on mouse hover to change SVG path orders.

A: You can wrap zIndexSetter method to call it only if the element is not a path:
(function(H) {
    H.wrap(H.SVGElement.prototype, 'zIndexSetter', function(proceed, value, key, el) {
        if (!el || (el && el.tagName !== 'path')) {
            return proceed.apply(this, Array.prototype.slice.call(arguments, 1));
        }
    });
}(Highcharts));

Live demo: https://jsfiddle.net/BlackLabel/31a0x4sL/
Docs: https://www.highcharts.com/docs/extending-highcharts