How to determine whether a sequence converges or diverges

Question: For this question, I know this sequence converges, but I'm not sure how to get to the final answer. Here is what I have so far, can anyone please help me out?
Determine whether the sequence converges or diverges.
$\left\{\dfrac{1}{2^n} -3\right\}$
$\lim_{n\to \infty} \left(\dfrac{1}{2^n} -3\right) = -3$
Let $\epsilon>0$ be arbitrary.
Choose N  $ \geq 0$
Suppose $n>N$
$\left|\dfrac{1}{2^n} -3 -(-3)\right| < \epsilon$
$\left|\dfrac{1}{2^n}\right| < \epsilon$
$\dfrac{1}{2^n} < \dfrac{1}{2^N}$
Comment: do you want to prove by definition?
Comment: once we fix $\epsilon$ then we find $N$ such that...
Comment: At a high-school level this may be good enough for part marks, and perhaps also at a professional level,  because the pro can look at it & say "I know what you mean."  But it is better to write in complete sentences, especially explaining the connection between the lines. Your are less likely to err, and will help in your own insight. You  omitted saying that you choose $N$ large enough that $1/2^n<\epsilon.$
Comment: I wanted to try to do the computation first and then pick the N.
Comment: @dg123 Please remember that you can choose an answer among the given if the OP is solved, more details here https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work
Answer: From here we obtain
$$\left|\frac{1}{2^n}\right| < \epsilon\iff 2^n>\frac1{\epsilon}\iff n>\log_2\frac1{\epsilon}\implies n>N=\lceil\log_2\frac1{\epsilon}\rceil$$
Comment: Ok so N would be $ln(\frac{1}{\epsilon})?$
Comment: @dg123 More precisely is the first natural $>\ln(\frac{1}{\epsilon})$ which is not necessesarly integer. Note indeed that I've used the ceiling symbol, but it is almost a detail here.
Comment: Do you mean n when you say first natural?
Comment: Also what happened to the 2?
Comment: Why did the 2 disappear?
Comment: @dg123 I mean that $\ln(\frac{1}{\epsilon})$ is not integer thus if we want explicitely fix an integer bound for n we can set it as $n>N=\lceil\log\frac1{\epsilon}\rceil$ but also simply $n>\log\frac1{\epsilon}$ is ok.
Comment: @dg123 I've assumed $log_2$ of course but we can also adapt to $log_e$.
Comment: @dg123 I've edited clarifying thus point!
Comment: So we can use $ln(\frac{1}{\epsilon})$?
Comment: @dg123 Yes of course, in this case we have $$\left|\frac{1}{2^n}\right| < \epsilon\iff 2^n>\frac1{\epsilon}\iff n\log 2>\log \frac1{\epsilon}\implies n>N=\lceil\frac1{\log 2}\log \frac1{\epsilon}\rceil$$
Comment: How would this question change if say the sequence was $(-2)^n + pi
Comment: @dg123 $(-2)^n$ doesn't converge, we can prove considering two subsequences with different limits  $(-2)^{2k}\to +\infty$ and $(-2)^{2k+1}\to -\infty$


Plotly: How to add extra information to marker of 3D scatter plot?

Question: What I'd like to do is adding each string info into only each balloon like below capture. But without showing them next to each plot because it looks messy when plots are many.

My data frame is below, I added info to each row as string.
import plotly.express as px
import numpy as np
import pandas as pd
from sklearn import datasets
from sklearn.manifold import TSNE

digits = datasets.load_digits()

X_reduced = TSNE(n_components=3, random_state=0).fit_transform(digits.data)

myinfo = ['ID' + str(i+1) for i in range(X_reduced.shape[0])]
df = pd.DataFrame(data=X_reduced, columns=columns, dtype='float')

df['info'] = myinfo          ## <- This is what i want to show in a balloon.

print(df)

              a         b          c    info
0     18.150545 -1.938995   1.192057     ID1
1     -8.773806  2.475938 -10.885373     ID2
2      4.305762  5.132519  -7.347726     ID3
3      5.327038  7.438313   8.786077     ID4
4    -15.810744 -9.374986   0.310686     ID5
...         ...       ...        ...     ...
1792   1.192152 -0.850245  12.781646  ID1793
1793  14.183956 -3.544634  -1.009673  ID1794
1794  -0.907307  2.596647  -4.307703  ID1795
1795   1.608326  0.700724   9.267643  ID1796
1796   1.809730  5.428222  -1.771497  ID1797

What I tried is that I assigned the string info as text='info' of px.scatter_3d() as following code.
fig = px.scatter_3d(df, x='a', y='b', z='c', color='a', size_max=6 , text='info', opacity=0.7)

fig.show()

Does someone know how to get rid of these info beside plots?
Thank you in advance.
Comment: Does [Plotly 3D plot annotations](https://stackoverflow.com/questions/68262505/plotly-3d-plot-annotations/68267109#68267109) answer your question?
Answer: Using your setup, all you have to do is run:
fig.update_traces(mode = 'markers')

...or:
fig.for_each_trace(lambda t: t.update(mode = 'markers'))

This removes the strings associated with the markers, but retains the added information in the hoverlabel:

This approach lets you keep your call to px.scatter_3d(..., text='info') as it stands.
Another approach would be to edit the hoverinfo directly with a custom_value as described in the post Plotly 3D plot annotations


Markov chains: is "aperiodic + irreducible" equivalent to "regular"?

Question: I have two books on stochastic processes.
In one book, it says that the limiting matrix is possible to find if the matrix is regular, that is, if for some $n$ $P^n$ has only positive values.  The other book says that the limiting values are possible to find if the Markov chain is recurrent, irreducible and aperiodic; it is then called ergodic.
Does this then hold:
aperiodic + irreducible $\Leftrightarrow$ ergodic $\Leftrightarrow$ regular?
And is there any difference whether it is a finite-state chain or not?
Comment: Is late now I guess but it woud be great to have the name of the books
Answer: For a finite MC it holds that
aperiodic + irreducible $\Leftrightarrow$ ergodic $\Leftrightarrow$ regular
as you expected. For an infinite MC it holds that
aperiodic + irreducible + positive recurrent $\Leftrightarrow$ ergodic,
and being "regular" in the infinite setting would require a more precise definition.
................................ explanations following ................................
For every finite or inifinite Markov chain (MC) it holds that
$aperiodic + irreducible + positive~recurrent \Leftrightarrow ergodic$.
See for example here for a proof. For every finite MC, irreducibility already implies positive recurrence, see here for a proof.
Further, for every finite MC we have that
$aperiodic + irreducible \Leftrightarrow regular$.
Proof sketch: the definition of a finite irreducible MC gives that $\forall i, j \in \Omega : \exists k > 0 : P^k[i,j] > 0$.
However, there might be no $k$ such that all entries are simultaneously positive - due to periodicities. But if the chain is additionally aperiodic, it follows that
$\exists k > 0 : \forall i, j \in \Omega : P^k[i,j] > 0$,
which matches your definition of being regular.
Finally, I don't see a canonical way how you would generalize the property "regular" to infinite Markov chains. So, I just ignore the term "regular" for infinite chains here.
Comment: Thank you very much!, it cleared the situation up for me!
Comment: Are you sure that the "+⇔" part is correct? What raises my concerns, is the following sentence on p.598 in Murphy, Machine Learning: A Probabilistic Perspective, 2012: *"One can show that **sufficient conditions** to ensure regularity are that the chain be irreducible (singly connected) and that every state have a self-transition."* The self-transition implies aperiodicity, but the condition is entitled as only sufficient, but not necessary.
Comment: It is not necessary to have self-transitions, that's probably what the book means.
Comment: Regarding the last point, my first guess would be to explore countably infinite Markov processes as a limit of finite Markov processes, each of which is regular?


What is the formula for Standardized Root Mean Residual (SRMR) in the context of latent variable models (e.g., SEM, CFA)?

Question: SRMR is a measure of badness of fit commonly used in the context of evaluating latent variable models. I understand that it in some ways measures the average discrepancy between the model implied covariance matrix and the observed covariance matrix. And I understand that there is a standardisation process to make it more interpretable regardless of the metric of the covariance matrix. However, I'm still looking for a more precise formula that explains how the averaging occurs and how the standardisation occurs.

What is the formula for SRMR?
And therefore, what it is the concrete interpretation of a given value?
Answer: After a bit of searching I found the formula in Hu and Bentler (1999):

Thus, the formula involves:

Getting the square of the scaled discrepancy between model implied and observed covariances, where the scaling makes the comparison more like comparing the correlation. E.g., imagine implied and observed correlations r = .2 and r = .3; this becomes (.2 - .3)^2 = .01
Getting the average of these discrepancies (i.e., dividing by $p(p+1)/2$; the number of sample moments (i.e., covariances plus variances; e.g., 3 variables = 6 moments [3 covariances and 3 variances)).
Squaring the average discrepancy obtained in step 2.

So the metric of SRMR can broadly be considered an average (specifically the quadratic mean) difference between implied and observed correlations (albeit with particular forms of averaging, and using the variances as well).
A Little exploration in R
We'll use personality data (bfi) from the psych package and run a cfa in lavaan (four items on a single factor) using the correlation matrix of the data as input.
library(psych)
library(lavaan)
data(bfi)

model <- "agree =~ A1 + A2 + A3 + A4"
fit <- cfa(model, scale(bfi))

We then extract the observed and model implied covariance matrices (which in this case are correlation matrices).
# get observed and implied covariance matrices
obs <- lavTech(fit, "sampstat")[[1]]$cov
imp <- unclass(fitted(fit)$cov)

This is what they look like along with the absolute differences
> # Observed, implied
> round(obs, 2);
      [,1]  [,2]  [,3]  [,4]
[1,]  1.00 -0.34 -0.27 -0.15
[2,] -0.34  1.00  0.49  0.34
[3,] -0.27  0.49  1.00  0.36
[4,] -0.15  0.34  0.36  1.01
> round(imp, 2)
      A1    A2    A3    A4
A1  1.00 -0.30 -0.28 -0.20
A2 -0.30  1.00  0.50  0.35
A3 -0.28  0.50  1.00  0.33
A4 -0.20  0.35  0.33  1.01
> # absolute differences:
> round(abs(obs - imp), 2)
     A1   A2   A3   A4
A1 0.00 0.04 0.02 0.05
A2 0.04 0.00 0.01 0.01
A3 0.02 0.01 0.00 0.04
A4 0.05 0.01 0.04 0.00

So in general, the sample correlations are being estimated reasonably well, but we're off in our estimates of correlations by between .01 and .05.
We can then calculate SRMR manually and using the built in calculation.
# extract diagonal and upper triangle cells
lobs <-  obs[!lower.tri(obs)]
limp <-  imp[!lower.tri(imp)]

# compare "srmr" to manual calculation
> fitmeasures(fit)["srmr"]
      srmr
0.02526347
> sqrt(mean((limp - lobs)^2))
[1] 0.02531431

They seem to be pretty much the same (i.e., about .025).
Hu, L.; Bentler, Peter (1999). "Cutoff criteria for fit indexes in covariance structure analysis: Conventional criteria versus new alternatives". Structural Equation Modeling. 6 (1): 1–55. https://dx.doi.org/10.1080%2F10705519909540118
Comment: Hi, I tried this on a longitudinal model, but the manual result and result using fitMeasures(..) differs. What formula is being used in the longitudinal calculation?


multiple select query in single laravel query

Question: I want to write the laravel query qhich want to has multiple select query in single query
select name,owner from project where owner in (select a.user_name from users a left join users b on a.manager=b.firstname where a.user_name='sridhar.ps' or a.manager like '%sridhar p%' or b.manager like '%sridhar p%') and customer_code='OTH_0071'

The above query list the outpu what I want exactly.I want to change the query in laravel
Answer: with the help of whereRaw you can do that like this
DB::table('project')->where('customer_code','OTH_0071')->whereRaw("owner in (select a.user_name from users a left join users b on a.manager=b.firstname where a.user_name='sridhar.ps' or a.manager like '%sridhar p%' or b.manager like '%sridhar p%')")->select('name','owner')->get();

for using variable
DB::table('project')->where('customer_code','OTH_0071')->whereRaw("owner in (select a.user_name from users a left join users b on a.manager=b.firstname where a.user_name='sridhar.ps' or a.manager like '%".$manager."%' or b.manager like '%sridhar p%')")->select('name','owner')->get();

for more info vist laravel $manager
hope it will help you!
Comment: in raw query I want to use variable
Comment: you can just concatenate it
Comment: $project_code=DB::table('project')->where('customer_code',$customer_name)->whereRaw("owner in (select a.user_name from users a left join users b on a.manager=b.firstname where a.user_name=".$user_name." or a.manager =".$first_name." or b.manager =".$first_name.")")->pluck('name','code')->all();             i have tried.but not working
Comment: Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/156524/discussion-between-gaurav-gupta-and-user3386779).
Answer: I might first rewrite your query using a series of joins:
SELECT
    p.name,
    p.owner
FROM project p
INNER JOIN
(
    SELECT a.user_name
    FROM users a
    LEFT JOIN users b
        ON a.manager = b.firstname
    WHERE
        a.user_name = 'sridhar.ps'   OR
        a.manager LIKE '%sridhar p%' OR
        b.manager LIKE '%sridhar p%'
) t
    ON p.owner = t.user_name
WHERE
    p.customer_code = 'OTH_0071';

Then build the Laravel query using a raw subquery to represent the table aliased as t above:
$subquery  = "(SELECT a.user_name FROM users a LEFT JOIN users b ";
$subquery .= "ON a.manager = b.firstname ";
$subquery .= "WHERE a.user_name = 'sridhar.ps' OR a.manager LIKE '%sridhar p%' ";
$subquery .= "OR b.manager LIKE '%sridhar p%') AS t";
DB:table('project)
    ->select('name', 'owner')
    ->join(DB::raw($subquery), 'p.owner', '=', 't.user_name')
    ->where('customer_code','OTH_0071')
    ->get();

This join approach might be more performant than what you currently have.  In any case, you can test this answer, compare it against the answer by @Gaurav, and then use whichever works the best.
Comment: @user3386779 Sorry I had omitted that.  I updated my answer.  Just make the call to `where` as you normally would; you don't need a raw query for this.
Comment: I have tried to select name and code but not working
Comment: _but not working_ ... can you be more precise than this?  What is the error message?  Can you try running my raw MySQL query as well?


gawk - sorting values from array of arrays

Question: Using gawk 4 to build arrays of arrays and need to figure out percentile data from it. Need to sort values in ascending order which doesn't appear possible using asort when working with multidimensional arrays. Some of my values will be duplicate integers, but I need to keep all duplicates.
Here is what my data looks like. Element names for [a] and [b] end up being unique strings. Array [b] then has elements that are named 1,2,3,etc and contain as values the data I need to sort on.

mArray[a][b][1]=3456
mArray[a][b][2]=1456
mArray[a][b][3]=1456
...
mArray[a][b][1]=9233
mArray[a][b][2]=9233
mArray[a][b][3]=1234
...
mArray[a][b][1]=4567
mArray[a][b][2]=4567
mArray[a][b][3]=3097

I figure I can create regular arrays from each unique [a] element and insert values from it's corresponding [b][x] and then asort on that, but then I lose whatever duplicate values exist. Right now I am hacking it by walking mArray and writing to different files based on name of [a], printing out all values under [b][x] then running sort. Curious if there is a more elegant way of doing it.
Here is what I tried using asort against my mArray to test getting proper output. After 30mins I get no output or errors.
for ( a in mArray ) {
 for ( b in mArray[a] ) {
  n=asort(mArray[a][b][c])
  print n
 }
}

Background: parsing CSV reports from a network monitoring system, grabbing throughput sample data then aggregating those values across all interfaces to determine 95th percentile for total throughput of a device.
Edit
Desired output format after sorting would be:

mArray[a][b][1]=1456
mArray[a][b][2]=1456
mArray[a][b][3]=3456
.
mArray[a][b][1]=1234
mArray[a][b][2]=9233
mArray[a][b][3]=9233
...
mArray[a][b][1]=3097
mArray[a][b][2]=4567
mArray[a][b][3]=4567

Comment: consider editing your question to show the output you need, given the above input. Good luck.
Answer: Well you have to sort myArray[a][b], not myArray[a][b][c], because c even doesn't exist ;)
If you don't want to sort in place, you have to add the destination as a second parameter to asort. At least this works in gawk, though I don't know since which version. In gawk 4 it does.
And then you have to print an array one by one...
for ( a in myArray ) {
 for ( b in myArray[a] ) {
  asort(myArray[a][b], n)
  for( i in n ) print "m["a"]["b"]["i"]="n[i]
 }
}

Comment: Oh, just saw how old this question is :D


Use the axiom of regularity to demonstrate that if $A$ and $B$ are two sets, then either $A\notin B$ or $B\notin A$ (or both): Proof Assistance

Question: In Tao's Analysis I, the following exercise is posed:

Use the axiom of regularity (and the singleton set axiom) to show that if $A$ is a set, then $A \notin A$. Furthermore, show that if $A$ and $B$ are two sets, then either $A\notin B$ or $B\notin A$ (or both).

I was able to demonstrate the first portion of this (i.e. that $A \notin A$), but I am having trouble formulating the proof necessary to demonstrate the second claim. Here is what I have so far.
Firstly, if $A = B$, then we know by $A\notin A$ that the statement $A\notin B \lor B\notin A$ is true, so let's consider the case where $A \neq B$.
Define $A=\{...\}$ and $B=\{...'\}$. (just my shorthand notation for denoting that they contain different elements and are therefore not equal).
Consider the case where $A \in B$. Then we have $B = \{A,...' \}$. Suppose also, by contradiction, that $B\in A$. Then we could rewrite $B=\{A,...'\}$ as $B=\{\{B,...\},...'\}$. But because $A\in B$, we could then rewrite $B$ as $B=\{\{\{A,...'\},...\},...'\}$. This process would continue infinitely.
I believe there is a contradiction here because I remember reading something about infinitely nested sets not being allowed in set theory where the axiom of regularity is asserted...so I think I am close.
What I see so far (in the little nested examples that I presented), is that $A=\{\{A,...'\},...\}$. I feel like this somehow contradicts the idea that $A \notin A$, but I am not certain why.
Any help is greatly appreciated!
Answer: Hint.  By regularity,
{A,B} has an element that is disjoint from {A,B}.
Comment: Yes, you can take a hint.
Comment: $(A \cap \{A,B\} = \emptyset) \lor (B \cap \{A,B\}=\emptyset)$. This results in the statement: $(A \notin A \land B \notin A) \lor (B \notin B \land A\notin B)$ . Is that what you're getting at?


Adding Sticky header to div elements in same page automatically

Question: I have some long divs all in one page, each with its own style. like this:

.... (pages of text)

...(pages of text)

any way to have the classname as a sticky header when a user scrolls through the text in each div? So if a person is scrolling inside the div with class:"joe" then the word "joe" would appear at the top of the screen until the user scrolls through to the end of the div. Then it disappears until he enters the next div which would display the classname of that div.
There are many dozens of such divs with various classnames so a manual solution won't work. needs to be automatic through css and/or js.
Comment: *to have the classname as a sticky header* ?
Comment: @TemaniAfif yes. what's not clear?
Comment: the whole sentence. What is a *classname* for you? what do you mean by *classname as a sticky header* ?
Comment: @TemaniAfif ok tried to clarify some more
Answer: You can consider data-attribute that you can convert to a pseudo element:

div[data-name]::before{
   content:attr(data-name);
   display:block;
   position:sticky;
   top:0;
   text-align:center;
   background:red;
   font-size:20px;
}

body {
 max-width:50%;
}

  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum at felis quis lacus fringilla suscipit vitae mollis eros. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus malesuada arcu efficitur, consectetur nunc nec, pulvinar odio.
  Morbi tincidunt nec erat vitae luctus. Cras elit ligula, rhoncus et feugiat quis, bibendum euismod nulla. Phasellus faucibus turpis erat, non bibendum tellus laoreet at. Vestibulum aliquam blandit lobortis. Nunc varius ac risus quis pharetra. In molestie,
  dui eu pulvinar commodo, justo metus auctor urna, vel ultrices nunc nisl in neque. Nullam at magna quis nibh lobortis euismod vel id augue. Nunc placerat sapien eget metus convallis, sed commodo dui interdum.
  dui eu pulvinar commodo, justo metus auctor urna, vel ultrices nunc nisl in neque. Nullam at magna quis nibh lobortis euismod vel id augue. Nunc placerat sapien eget metus convallis, sed commodo dui interdum.
  dui eu pulvinar commodo, justo metus auctor urna, vel ultrices nunc nisl in neque. Nullam at magna quis nibh lobortis euismod vel id augue. Nunc placerat sapien eget metus convallis, sed commodo dui interdum.
  dui eu pulvinar commodo, justo metus auctor urna, vel ultrices nunc nisl in neque. Nullam at magna quis nibh lobortis euismod vel id augue. Nunc placerat sapien eget metus convallis, sed commodo dui interdum.

  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum at felis quis lacus fringilla suscipit vitae mollis eros. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus malesuada arcu efficitur, consectetur nunc nec, pulvinar odio.
  Morbi tincidunt nec erat vitae luctus. Cras elit ligula, rhoncus et feugiat quis, bibendum euismod nulla. Phasellus faucibus turpis erat, non bibendum tellus laoreet at. Vestibulum aliquam blandit lobortis. Nunc varius ac risus quis pharetra. In molestie,
  dui eu pulvinar commodo, justo metus auctor urna, vel ultrices nunc nisl in neque. Nullam at magna quis nibh lobortis euismod vel id augue. Nunc placerat sapien eget metus convallis, sed commodo dui interdum.
  dui eu pulvinar commodo, justo metus auctor urna, vel ultrices nunc nisl in neque. Nullam at magna quis nibh lobortis euismod vel id augue. Nunc placerat sapien eget metus convallis, sed commodo dui interdum.
  dui eu pulvinar commodo, justo metus auctor urna, vel ultrices nunc nisl in neque. Nullam at magna quis nibh lobortis euismod vel id augue. Nunc placerat sapien eget metus convallis, sed commodo dui interdum.
  dui eu pulvinar commodo, justo metus auctor urna, vel ultrices nunc nisl in neque. Nullam at magna quis nibh lobortis euismod vel id augue. Nunc placerat sapien eget metus convallis, sed commodo dui interdum.

And you can add a small JS if you want to append automatically the data-attribute:

var all = document.querySelectorAll('div[class]');
for(var i=0;i<all.length;i++) {
  all[i].setAttribute('data-name',all[i].className);
}
div[data-name]::before{
   content:attr(data-name);
   display:block;
   position:sticky;
   top:0;
   text-align:center;
   background:red;
   font-size:20px;
   margin-bottom:20px;
}

body {
 max-width:50%;
}

  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum at felis quis lacus fringilla suscipit vitae mollis eros. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus malesuada arcu efficitur, consectetur nunc nec, pulvinar odio.
  Morbi tincidunt nec erat vitae luctus. Cras elit ligula, rhoncus et feugiat quis, bibendum euismod nulla. Phasellus faucibus turpis erat, non bibendum tellus laoreet at. Vestibulum aliquam blandit lobortis. Nunc varius ac risus quis pharetra. In molestie,
  dui eu pulvinar commodo, justo metus auctor urna, vel ultrices nunc nisl in neque. Nullam at magna quis nibh lobortis euismod vel id augue. Nunc placerat sapien eget metus convallis, sed commodo dui interdum.
  dui eu pulvinar commodo, justo metus auctor urna, vel ultrices nunc nisl in neque. Nullam at magna quis nibh lobortis euismod vel id augue. Nunc placerat sapien eget metus convallis, sed commodo dui interdum.
  dui eu pulvinar commodo, justo metus auctor urna, vel ultrices nunc nisl in neque. Nullam at magna quis nibh lobortis euismod vel id augue. Nunc placerat sapien eget metus convallis, sed commodo dui interdum.
  dui eu pulvinar commodo, justo metus auctor urna, vel ultrices nunc nisl in neque. Nullam at magna quis nibh lobortis euismod vel id augue. Nunc placerat sapien eget metus convallis, sed commodo dui interdum.

  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum at felis quis lacus fringilla suscipit vitae mollis eros. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus malesuada arcu efficitur, consectetur nunc nec, pulvinar odio.
  Morbi tincidunt nec erat vitae luctus. Cras elit ligula, rhoncus et feugiat quis, bibendum euismod nulla. Phasellus faucibus turpis erat, non bibendum tellus laoreet at. Vestibulum aliquam blandit lobortis. Nunc varius ac risus quis pharetra. In molestie,
  dui eu pulvinar commodo, justo metus auctor urna, vel ultrices nunc nisl in neque. Nullam at magna quis nibh lobortis euismod vel id augue. Nunc placerat sapien eget metus convallis, sed commodo dui interdum.
  dui eu pulvinar commodo, justo metus auctor urna, vel ultrices nunc nisl in neque. Nullam at magna quis nibh lobortis euismod vel id augue. Nunc placerat sapien eget metus convallis, sed commodo dui interdum.
  dui eu pulvinar commodo, justo metus auctor urna, vel ultrices nunc nisl in neque. Nullam at magna quis nibh lobortis euismod vel id augue. Nunc placerat sapien eget metus convallis, sed commodo dui interdum.
  dui eu pulvinar commodo, justo metus auctor urna, vel ultrices nunc nisl in neque. Nullam at magna quis nibh lobortis euismod vel id augue. Nunc placerat sapien eget metus convallis, sed commodo dui interdum.

Comment: anyway to make it disappear automatically when user scrolls beyond the div? (may have other elements before the next div) preferably without adding some blank divs in between
Comment: @michael you can consider margin-bottom on the sticky element (check the update on the second snippet
Comment: anyway to make it disappear altogether? don't need it for all div elements
Comment: @michael I think the only why is to have margin between divs then
Comment: ok thanks. actually i see it does disappear when i scroll down below the div.
Answer: You need to make a header (the best way to do this is to use the new  tag added in HTML5) and in CSS you should add this:
header {
position: sticky;/*makes object sticky*/
top: 0;/*set header to the top of the page*/
z-index: 100;/*changes the header position to the front of the page*/
}

I hope that I helped


Does OpenEBS Jiva support if underlying storagepool fs is ZFS?

Question: When using jiva datadirhost on a ZFS mountpoint(with xattr enabled)  I got this
time="2018-12-02T20:39:48Z" level=fatal msg="Error running start replica command: failed to find extents, error: invalid argument".
If we create an ext4 zvol based storagepool it works. Is this expected behaviour? I am using Kubernetes 1.9.7 on ubuntu 16.04 with ZFS.
Comment: Extents are not used in ZFS, so that seems likely.
Answer: OpenEBS has two storage engines currently supported,

cStor (Recommended)
Jiva

Jiva volumes are created from local filesystem or mounted file-system, and can't consume the block device directly. This makes Jiva will work only with those file systems which provides extent mapping. ZFS does not support filefrag as of now that's why it gives above error.
On Other hand, cStor storage engine, volumes are created on a pool created on block devices. Storage pool create by cStor is native zpool(ZFS). You can get more details Concepts-> CASEngines from openEBS doc site.


Disable download images colorbox popup

Question: How can I disable "right click" in colorbox Popup so the visitor could not directly download images.
Comment: Please keep in mind that smart visitors will still be able to download images. But more important: we don't do "code from scratch" here. If this question is about code you attempted to write, share said code. If it's purely about code, not directly related to Drupal, it's off-topic here anyway. And if it's a feature request for a module, it's off-topic and should be posted in module's issue queue, not here.
Answer: You can use Copy Prevention module.
This module will Place transparent image above all your images - this will protect your real images from being saved using context menu or drag-and-drop to desktop
More from module page:

Anything you put out there in the Internet (public pages) is available for anyone else to copy and save/re-use. So if you really want your content to be safe and protected - do not put it online.
But if you want you can try to protect your content/images and prevent/disable at least the most simple ways to copy it. In fact, anyone can "view source", check the browser cache for images, use "Print Screen" or "site copy" software, etc. - these things can't be disabled, but they require additional knowledge and skills than just selecting the content and copying it or dragging an image from browser window to the desktop.
This module includes several different technical ways/methods to make copying/stealing information/images from your site harder than it usually is:
This module includes several different technical ways/methods to make copying/stealing information/images from your site harder than it usually is:

Disable text selection

Disable copy to clipboard

Disable right-click context menu on all site content

Disable right-click context menu only on images ( tag)

Place transparent image above all your images - this will protect
your real images from being saved using context menu or drag-and-drop
to desktop

Protect/hide your images from search engine indexes so that your
images don't show up in image searches - add "noimageindex" robots
tag and disallow image files indexing in robots.txt

Disable download images colorbox popup


Importing Haskell modules

Question: I'm new to Haskell.  How come when I try to use Days from Data.Time I get this error:
Could not find module `Data.Time':
      It is a member of the hidden package `time-1.1.4'.
      Perhaps you need to add `time' to the build-depends in your .cabal file.

I am importing Data.List and Control.Monad, and neither gives me this error message, but the code import Data.Time does.
What am I missing?
Thanks for the help!
EDIT:  I'm getting a similar error message when I use: import Directory
Thanks guys, your answers got me on track!
Comment: From the error message, I assume you're using cabal to build your project.  In that case, you need to list the packages your project depends on in its cabal file.  I think the syntax is something like "build-depends: time, directory"; I'm sure someone here will know the exact syntax if that's not it.
Comment: I've been using Leksah.  Maybe its using Cabal behind the scenes and I need to manually configure the build???
Answer: Fire up Leksah with this project, open the package menu and select "edit package" from it. Now, choose "dependencies" and add the dependency you need (in your case time). You may also choose a version.
PS: Don't forget to hit the "save" button afterwards. (I think this is a design failure...).
Answer: Just edit the projects .cabal file, usually in the top directory named ProjectName.cabal and find the line(s) with "build-depends:" and add "time" to this list.  No need for Leksah, unless you already use it.
EDIT: To answer your question of "why now and not with module X"
Data.Time is in the time package, which evidently isn't included in your build dependencies.  Similar story for the Directory module.  You don't get these errors with Data.List or Control.Monad because they are part of the base package which I'll bet is in your build-deps.
On a side note, it is worth taking time to learn what modules are in base and what functionality those modules provide.  Base is rather large and very useful.

Importing Haskell modules


CSS transform to rotate an element in an oval path

Question: I have a jsfiddle here - http://jsfiddle.net/w23v50h5/1/
<code>        div {
            position: absolute;
            left: 315px;
            top: 143px;
            width: 50px;
            height: 50px;
            background: red;

            -webkit-animation: myOrbit 6s linear infinite;
               -moz-animation: myOrbit 6s linear infinite;
                 -o-animation: myOrbit 6s linear infinite;
                    animation: myOrbit 6s linear infinite;

        }

        @-webkit-keyframes myOrbit {
            from { -webkit-transform: rotate(0deg) translateX(5px) translateY(120px) rotate(0deg);}
            to   { -webkit-transform: rotate(360deg) translateX(5px) translateY(120px) rotate(-360deg); }
        }

        @-moz-keyframes myOrbit {
            from { -moz-transform: rotate(0deg) translateX(100px) rotate(0deg); }
            to   { -moz-transform: rotate(360deg) translateX(100px) rotate(-360deg); }
        }

        @-o-keyframes myOrbit {
            from { -o-transform: rotate(0deg) translateX(100px) rotate(0deg); }
            to   { -o-transform: rotate(360deg) translateX(100px) rotate(-360deg); }
        }

        @keyframes myOrbit {
            from { transform: rotate(0deg) translateX(100px) rotate(0deg); }
            to   { transform: rotate(360deg) translateX(100px) rotate(-360deg); }
        }
</code>
I'm using css trasform to move an element in an oval shape.
I'd like the path the element is moving on to be a flatter oval shape.
I also like to scale the element so it's smaller at the top of the oval and larger at the bottom so it gives the impression of oval orbit going backwards and coming forwards.
Can anyone help to make the orbit flatter and scale the element.
Comment: I found this SO question that is similar that has a working demo. http://stackoverflow.com/questions/17022491/how-rotate-an-image-around-on-oval-shape-image-in-css3-animation
Comment: What is the reason that you use rotate(360deg) and rotate(-360deg) in the same sentence if i may ask?
Answer: you can use a % instead "from to" in your animation like this:
<code> 0%  { -webkit-transform: rotate(0deg) translateX(5px) translateY(120px) rotate(0deg) scale(1); }
 25%  { -webkit-transform: rotate(90deg) translateX(5px) translateY(120px) rotate(-90deg) scale(.75); }
 50%  { -webkit-transform: rotate(180deg) translateX(5px) translateY(120px) rotate(-180deg) scale(.60); }
 75%  { -webkit-transform: rotate(270deg) translateX(5px) translateY(120px) rotate(-270deg) scale(.75); }
 100%  { -webkit-transform: rotate(360deg) translateX(5px) translateY(120px) rotate(-360deg) scale(1); }
</code>
A jsfiddle implementation:
http://jsfiddle.net/jutmLgud/


Find the remainder of the following

Question: Given that
 $F(1)=1,F(2)=1$ and $F(n)=F(n-1)+F(n-2)$ , $n>2$ for this series, now if $f(n)$ is the remainder if $F(n)$  is divided by $5$  then the value of $f(2000)$   is

1
0
3
2

For doing this it is obvious that problem is indicating the Fibonacci Series. Now we know that
$n th$  term of Fibonacci series can be determined by the formula
$$[ (Phi)^n - (phi)^n ]/\sqrt 5 , Phi=(1+\sqrt5)/2 ,  phi=(1-\sqrt5)/2 $$
I dont no whether this is needed for this problem or not but I observed that $F(5)=5, F(10)=55, F(15)=610$ so I guess $F(2000)$ must be  divisible by 5 so answer is 0.
I'm not satisfy with this and need better explanation or analytic solution. help me...
Answer: To prove your statement "$F(5)=5,F(10)=55,F(15)=610$ so I guess $F(2000)$ must be divisible by $5$ so answer is $0$", you may use mathematical induction to prove "$F(5n)$ is divisible by $5$".
The base case, $F(5) = 5$, is true.
Assume the case $n = k$ is true, therefore we can write $F(5k) = 5p$ for some positive integer $k$ and $p$, now for $n = k+1,$
$F(5(k+1)) = F(5k+5) = F(5k+4) + F(5k+3) = 2 \times F(5k+3) + F(5k+2) $
$ = 2 \times (F(5k+2) + F(5k+1)) + F(5k+1) + F(5k) $
$ = 2 \times F(5k+2) + 3 \times F(5k+1) + F(5k) $
$ = 2 \times (F(5k+1) + F(5k)) + 3 \times F(5k+1) + F(5k) $
$ = 5 \times F(5k+1) + 3 \times F(5k) $
$ = 5 \times F(5k+1) + 15p$
$ = 5 \times (F(5k+1) + 3p)$
Hence by mathematical induction, $F(5n)$ is divisible by $5$ for all positive integers $n$.
From the proof, you can also see that $F(n+5) = 5\times F(n+1) + 3\times F(n)$. Therefore if $F(n)$ is divisible by 5, so is $F(n+5)$. Applying this repeatedly you will get $F(n)$ is divisible by $5$ when $n$ is divisible by $5$. This is a simple explanation of your observation.
Comment: Nice and rigorous!
Answer: From wiki, $F_{5m}$ is divisible by $F_5=5$ where $m$ is any integer
See also : on the divisibility properties of fibonacci numbers
and  Fibonacci GCD
Comment: See [this answer](http://math.stackexchange.com/a/60353/242) for proofs of these divisibility properties of Fibonacci numbers.
Comment: Don't you think that a link-only answer like this should be a comment?
Answer: Compute the recurrence, $\bmod5$. As there are just $25$ possible pairs of input values, you quickly find the period.
$$\color{blue}{1, 1, 2, 3, 0, 3, 3, 1, 4, 0, 4, 4, 3, 2, 0, 2, 2, 4, 1, 0,} 1, 1, 2, 3, 0, 3, 3, 1, 4, 0, \cdots$$
Comment: See [this answer](http://math.stackexchange.com/a/34795/242) for more on why it is periodic.

Find the remainder of the following


Using NiFi to pull Elasticsearch Indexes

Question: I am working with NiFi (was recently turned onto it and it seems to suit my needs). We have recently stood up a Spark/Hadoop cluster and have had Elasticsearch in place for about 2 years now. My goal is to get specific indexes from Elasticsearch into HDFS (syslog, specifically). I am doing a machine learning project for anomaly detection, but want to work on the data from HDFS to speed things up.
So, a little background - our syslog indexes are different every day (logstash-syslog-2017-11-20, and so forth). I only need the messages from the syslog, so essentially what I want to do is:
ES -> NiFi -> Parse JSON to give me back text -> write each message to its own line in a text file.

In the end, in my HDFS I'd have text files of messages for each index (day), such as:
syslog-2017-11-19
syslog-2017-11-20
syslog-2017-11-21

and so forth....
I am stumped on a couple things:

What are the components needed to build this? I see there are GenerateFlowFile, which I think I need to make the index names dynamic.
Since I want to pull an entire index, I think I need to use "ScrollElasticSearchHttp", but I am not sure. There are other options, but I don't know what is best. When using PySpark, I have done simple queries using the ES-Hadoop connector to grab whole indexes, but had to increase the scroll size to 10k, to make it run faster. Just confused on what processor I should be using.

If someone can give me an idea of the structure of this (what processors, connectors, etc.) I need to get indexes of messages from syslog from ES to my HDFS, this would be great. Still learning this, so please excuse my ignorance on this. Thanks so much for any help!
Comment: Comments are not for extended discussion; this conversation has been [moved to chat](http://chat.stackoverflow.com/rooms/160304/discussion-on-question-by-azdatasci-using-nifi-to-pull-elasticsearch-indexes).
Answer: There is also ListenBeats processor. You can redirect Logstash to NiFi and Nifi could write to both EL and HDF. It's true that this will put NiFi on your critical path.
There is also the possibility to write your own processors and you can do that very easily. Just follow this article
I've also found Nifi recently and I think is great. Played a bit with it and thus I am no expert.
Comment: Just follow the link from the answer. You will find there a guide and examples.
Comment: I ended up using the ScrollElasticsearchHttp processor, as per my commment above, it seemed that I had some options formatted incorrectly. Once I got the right format, it worked. I wish that the NiFi docs had more examples / explicit examples that showed the format and differentiates it from how the ES-Hadoop formatted options are. Anyway things are working now. I'd be interested in looking into writing my own processors - is there a guide or something out there for this?
Comment: Duh... sorry, you totally gave me the link and then I asked about it. I checked that link out, good stuff. I think the ScrollElasticSearchHttp is my answer for now, but I think, based on our huge inventory of disparate data sources, I most likely will need this at some point. Good info.
Answer: I am posting my first comment as the answer, as that is what ended up being my solution.
I ended up using the ScrollElasticsearchHttp processor, as per my commment above, it seemed that I had some options formatted incorrectly. Once I got the right format, it worked. I wish that the NiFi docs had more examples / explicit examples that showed the format and differentiates it from how the ES-Hadoop formatted options are. Anyway things are working now. I'd be interested in looking into writing my own processors - is there a guide or something out there for this?
Comment: can you share the documentations you referred
Comment: azdatasci, could you please post an screenshot of your NiFi dataflow here. Specifically the options that you set.


Como funciona um método dentro de outro? E.g: service.metodo(argumentos).execute();

Question: Eu não estou entendendo isso esse método dentro de outro método alguém me explica isso?
Outro exemplo da minha dúvida:
ImageKeywords keywords =  service.getImageKeywords(image, forceShowAll, knowledgeGraph).execute();

Ele tem um método que chama outro método dentro dele.
Answer: Não há um método dentro do outro, há uma sequência de métodos.
Com o objeto servicechama o método getImageKeywords() passando alguns argumentos. Ele produzirá um resultado (em geral os métodos retornam alguma coisa), esse resultado é um objeto que pode invocar outros métodos, no caso está invocando o execute() no objeto retornado pelo getImageKeywords(). O resultado de execute() é que será guardado na variável keywords.
Esse código poderia ser escrito assim (ou quase, usei var, que ainda não tem em Java, porque não sei o tipo do método):
var temp = service.getImageKeywords(image, forceShowAll, knowledgeGraph);
ImageKeywords keywords = temp.execute();

Exemplo mais visível:
public static void main (String[] args) {
    String x = teste().toString(); //teste retorna um inteiro 42 que é usado pelo toString
    System.out.println(x); //x já é uma string "42"
}
public static Integer teste() {
    return 42;
}

Veja funcionando no ideone. E no repl.it. Também coloquei no GitHub para referência futura.
Uma coisa que as pessoas não costumam percebem é que variáveis servem para guardar valores intermediários. Há casos que elas são necessárias, ou pelo menos mais vantajosas, mas nem sempre elas precisam ser usadas. Um valor intermediário de uma expressão pode ser usado direto onde seja necessário sem o uso de variável.
Uma expressão é, geralmente, composta de sub-expressões que produzem valores intermediários. Pura matemática.
Comment: Sim, e é óbvio que o método seguinte terá que estar disponível para o objeto retornado. Posso melhorar a resposta, tem o contexto onde este código está sendo usado? Tem a documentação de `getImageKeywords`?
Comment: Entendi! Que ótimo exemplo. Mas me surgiu uma dúvida, @bigown, sempre terá que retornar algo para fazer a chamada a outro método?
Comment: Não precisa não, eu entedi.


Facebook: User Like/Become fan of page

Question: In any facebook api (connect, graph, rest, etc) is there a way to prompt the user to become a fan of a page (now known as liking a page).
Answer:

Take note of the: http%3A%2F%2Fwww.yoursiteurlencodedhere.com section.
Answer: It is not possible through the Facebook APIs. Above iframe solution might work.
Answer: Here's the details for adding a Facebook like button.
http://developers.facebook.com/docs/reference/plugins/like/
You can use the iframe method:

Or you can use the xfbml method:
<fb:like show_faces="true" width="450"></fb:like>

Personally I think the xfbml method is cleaner. Unfortunately this doesn't actively prompt the user, it merely adds the button to your page. There is no way in their api to prompt someone.

Facebook: User Like/Become fan of page


value returned by flags into my struct

Question: How can I assign the string value returned by flag into my struct?  I have the following code.
destDbCfg = &dbhelper.DbConfig {}

destDbCfg.Database = flag.String( "destDBName", "", "Destination DB Database Name")
flag.Parse()

Database is a string
Comment: see also: https://stackoverflow.com/a/71061616/9935654
Answer: Use the *Var methods to set set values to existing variables from flags, in this case you want flag.StringVar
destDbCfg = &dbhelper.DbConfig{}

flag.StringVar(&destDbCfg.Database, "destDBName", "", "Destination DB Database Name")
flag.Parse()

Comment: Thank you so much!

value returned by flags into my struct


Cursor / Lead function

Question: Using the lead analytical function in PL/SQL block however, the result is not getting a display. Please guide.
 SET SERVEROUTPUT ON
DECLARE
CURSOR C_11 IS SELECT * FROM EMP;
TYPE DD IS TABLE OF EMP%ROWTYPE;
CC DD;
TYPE RR IS  RECORD
(
ID EMP.ID%TYPE,
ENAME EMP.ENAME%type,
JOB EMP.JOB%TYPE,
HIREDATE EMP.HIREDATE%TYPE,
HIREDATE_LEAD EMP.HIREDATE%TYPE
);
HH RR;
BEGIN
OPEN C_11;
LOOP
FETCH C_11 BULK COLLECT INTO CC LIMIT 1000;
FOR I IN 1..cc.count
loop
SELECT ID,ENAME,JOB,HIREDATE, LEAD(HIREDATE) OVER(ORDER BY HIREDATE) into HH FROM EMP  where id=cc(i).id;
DBMS_OUTPUT.PUT_LINE (HH.ID ||' '||HH.ENAME||' '||HH.JOB ||' '||HH.HIREDATE||' ' || HH.HIREDATE_LEAD);
end loop;
EXIT WHEN C_11%NOTFOUND;
END LOOP;
CLOSE C_11;
END;

Answer: When you deal with Record and BULK Operation you need to make sure that you follow the correct syntax. See below working code and inline comments:
DECLARE
  CURSOR c_11 IS SELECT * FROM emp;

  TYPE dd IS TABLE OF emp%rowtype;

  cc              dd;

  TYPE rr IS RECORD (
            id              emp.empno%TYPE,
            ename           emp.ename%type,
            job             emp.job%TYPE,
            hiredate        emp.hiredate%TYPE,
            hiredate_lead   emp.hiredate%TYPE
  );
  -- This is needed to be created to hold records.
  Type v_rr is table of rr index by pls_integer;
  hh              v_rr;

BEGIN
  OPEN c_11;
  LOOP
    FETCH c_11 BULK COLLECT INTO cc LIMIT 1000;

    FOR i IN 1..cc.count
    loop
      SELECT empno,
             ename,
             job,
             hiredate,
             nvl(LEAD(hiredate) OVER( ORDER BY hiredate) ,hiredate)
     Bulk Collect into  hh  -- Since you are using collection,you need to use BULK collect
      FROM emp;
      --where empno = cc(i).empno;  -- This looks redundant.

     -- Iterate through the loop to print the result.
      For j in 1.. hh.count
      loop
       dbms_output.put_line(hh(j).id || ' ' || hh(j).ename || ' ' || hh(j).job || ' ' || hh(j).hiredate || ' ' || hh(j).hiredate_lead);
      end loop;
    end loop;

    EXIT WHEN c_11%notfound;
  END LOOP;

  CLOSE c_11;
END;

Output:
SQL> /
7369 SMITH CLERK 17-DEC-80 20-FEB-81
7499 ALLEN SALESMAN 20-FEB-81 22-FEB-81
7521 WARD SALESMAN 22-FEB-81 02-APR-81
7566 JONES MANAGER 02-APR-81 01-MAY-81
7698 BLAKE MANAGER 01-MAY-81 09-JUN-81
7782 CLARK MANAGER 09-JUN-81 08-SEP-81
7844 TURNER SALESMAN 08-SEP-81 28-SEP-81
7654 MARTIN SALESMAN 28-SEP-81 17-NOV-81
7839 KING PRESIDENT 17-NOV-81 03-DEC-81
7900 JAMES CLERK 03-DEC-81 03-DEC-81
7902 FORD ANALYST 03-DEC-81 23-JAN-82

Comment: still result of  hh(j).hiredate_lead is not there
Comment: @JaspreetSingh Check your query, When you loop across and try put where clause  and try to match on `empno` then `no` matching record is found. If you comment  `where empno = cc(i).empno;` you get the result
Comment: I did that  (SELECT ID,
             ename,
             job,
             hiredate,
             LEAD(hiredate) OVER( ORDER BY hiredate )
     Bulk Collect into  hh
      FROM emp
      where ID = cc(i).ID);  but still result of lead function is not there.
Comment: @JaspreetSingh Run the updated code. See the same code is working for me. Result is in answer.

Cursor / Lead function


Is there a Hotelling's T2 function for multivariate data using python?

Question: I am looking at a multivariate time series data, which looks like this:

I am trying to create a threshold, so that when a huge peak comes up (like the one in the picture), it will output an alert.
The resource that I've found suggested Hotelling's T2 to calculate the threshold.
https://blog.pivotal.io/data-science-pivotal/products/multivariate-time-series-forecasting-for-virtual-machine-capacity-planning
So, does anyone know if there's any packages or functions for Hotelling's T2 in python. I've checked pandas, numpy and statsmodels, but can't find any. Not sure if it's under a different name or something.
Thanks for the help
Answer: spm1d package contains many statistics, especially for multivariate time series data like yours.
for example Hotelling's T2 test see:
http://www.spm1d.org/doc/Stats1D/multivariate.html
Comment: We are looking for long answers. This is rather a comment. As soon as you have enough reputation you can comment everywhere.
Answer: One option could be to install:

Python package rpy2
R package Hotelling
Anaconda if you haven't already

Then you can use a Jupyter Notebook to run both Python and R in the same Notebook.  Once you've started the Jupyter Notebook, run:
%load_ext rpy2.ipython
%R require(Hotelling)
And you should be able to run the analysis you need.


How to make blinking button from two images objective c sprite node

Question: I want to create blinking button from two images using sprite Kit, now I have :
resButt = [SKSpriteNode spriteNodeWithImageNamed : @"retry.png"]

I saw couple posts about how to do it using UIButton, but my question is how to do it in Sprite Kit using objective c?
Answer: The thing required is an SKAction that changes your sprite's texture (an image applied to geometry).  If you mean "blink" indefinitely, that action must be repeated, and there's an action for that, too.
// create textures for the sprite
UIImage *imageA = [UIImage imageNamed:@"retryA.png"];
UIImage *imageB = [UIImage imageNamed:@"retryB.png"];
SKTexture *textureA = [SKTexture textureWithImage:imageA];
SKTexture *textureB = [SKTexture textureWithImage:imageB];

// create an action that applies the textures in sequence
NSArray *textures = @[textureA, textureB];
SKAction *blink = [SKAction animateWithTextures:textures timePerFrame:0.5];

// create an action that repeats the texture sequence
SKAction *blinkForever = [SKAction repeatActionForever:blink];

// run it
[myButtonSprite runAction:blinkForever withKey:@"blinkForever"];

Forever is a long time, of course, so this begs the question of how to stop blinking.  That's why we added the withKey: qualifier to the run action above.  With it, you can refer to the action in order to stop it.
[myButtonSprite removeActionForKey:@"blinkForever"];


Actionscript 2: A class loaded into a parent class, get parent variables

Question: I have a child class that is loaded into the parent class when the swf begins, like so:
var myvar = 'hello';
public function Parent()
{
     this.child = new Child();
};

How can I retrieve the variable 'myvar' from within child?
Answer: Child has no reference to the parent, so there is no way to retrieve myvar.
You could create child like this:
public class Child
{
   private var parent:Parent;

   public Child(parent:Parent)
   {
       this.parent = parent;
   }
   ...
}

This will allow the child to access it's parent through it's parent property and will be able to see all the public members that belong to parent.
Comment: I was hoping there was some other way but... thanks! I will do this then.


google/zx tar Gives "No such file or directory"

Question: I am using google/zx to create a simple backup script using tar. The code I'm using to generate the tar command looks like this:
  const tarCommandString = `tar czf "${absoluteBackupFile}" -P "${folder}"`;
  const tarCommand = await $`${tarCommandString}`.exitCode;

I keep getting the following error /usr/bin/bash: line 1: tar czf "/home/syssu/backup/home-syssu-testToBackup/1692150304.tar.gz" -P "/home/syssu/testToBackup": No such file or directory.
However I can literally take that command tar czf "/home/syssu/backup/home-syssu-testToBackup/1692150304.tar.gz" -P "/home/syssu/testToBackup" and manually run it without any issue.
Comment: Any chance it runs it without `PATH`, in other words, what if you specify the full path to `tar` instead?
Comment: I was thinking maybe it could not find tar as well, but if I run `which tar` it finds it at `/usr/bin/tar`. I also changed the command from `tar` to `/usr/bin/tar` but that did not work either.
Answer: The documentation says:

Everything passed through ${...} will be automatically escaped and quoted.

In other words
$`${tarCommandString}`

here entire tarCommandString is treated as a single command.
You should
await $`tar czf "${absoluteBackupFile}" -P "${folder}"`

instead.
Comment: Ah I think what the problem is, is that I have the double quotes around `"${absoluteBackupFile}" ` and `"${folder}"`?
Comment: OK, I think I understand now, but it seems weird. I see this reported issue someone has a workaround: https://github.com/google/zx/issues/126


Bootstrap Changing the active radiobutton CSS when clicked

Question: I am using 3 radio buttons with Bootstrap3.

    <input type="radio" name="options" id="option1" class="namesort" autocomplete="off" checked/>Name

    <input type="radio" name="options" id="option2" class="agesort" autocomplete="off" /> Age

    <input type="radio" name="options" id="option3" class="salarysort" autocomplete="off" />Salary

The buttons need to use the btn-default css when unselected and the btn-primary active css when selected.
So if I clicked the Age button, it would look like this:

    <input type="radio" name="options" id="option2" class="agesort" autocomplete="off" /> Age

I tried using the Jquery .removeClass() and .addClass() but can't get it working.
Does anyone know how to do this?
Comment: Can you post the jQuery code from your attempt?
Answer: With bootstrap, what is being clicked aren't the radio buttons but the labels. You should bind your functionality to the radio button's click events.
$('label').click( function() {
  $(this).addClass('btn-primary').removeClass('btn-default').siblings().removeClass('btn-primary').addClass('btn-default');
});

(It is also likely that, if you use the function in this solution, you should limit the selector in your code as opposed to applying to all labels)
Added a bootply: http://www.bootply.com/FQKkiIUGlY
Comment: You also need to add the active class to the one getting `btn-primary`.
Comment: @MattD You don't need to add the active class. Bootstrap does that on its own afterwards.
Answer: You can get your result by doing this.
$('label').click(function() {
    $('label.btn-primary').removeClass('btn-primary').addClass('btn-default');
    $(this).removeClass('btn-default').addClass('btn-primary');
});

FIDDLE


Taylor series for tetration

Question: I would like to know what is known about Taylor series for tetration (and other hyper-exponentiations).
Surprisingly, such information is rare on internet. Numerical values for expansion in hyperexponent for tetration with basis $e$ can be found here:
http://en.citizendium.org/wiki/Tetration#Taylor_expansion_at_zero
However I am interested in expansion in the basis of tetration. I look for
$$ x \uparrow \uparrow m = \sum_{n=0}^{\infty} c_n(m)x^n $$
Wolfram mathematica gives me wired result (obviously a bug) at $x=0$ for $x \uparrow 3$:
https://www.wolframalpha.com/input/?i=taylor+series+x%5E(x%5Ex)
where in the output $log(x)$ appears (not a polynomial).
It is better at $x=1$
https://www.wolframalpha.com/input/?i=taylor+series+x%5E(x%5Ex)+at+x%3D1
I imagine the point $x=0$ may be "peculiar", but at least expansion at $x=1$ should be possible.
List of my questions:
1) Is tetration analytic at $x=0$? At $x=1$?
2) If yes, is an explicit closed-form formula for $c_n(m)$ known? (at any of these points)
3) If not, is an explicit closed-form formula for $c_n(m)$ know for some specific values of $m$?
4) Same questions for extension to higher hyper-exponentiations...
Thank you.
Comment: I little advice, don't loose too much time on these themes : either on the point of view of practical applications or on the theoretical side, hyper-exponentiations of different kinds are a little a deadend.
Comment: I know it's a long time now, but I happened to be looking up the very same question. I couldn't help being amused by your little _admonishon_ - yes it is a very frustrating subject all this _hyperoperations_ business; and one gets the distinct impression that the series of mathematical operations defined recursively as the previous one applied to n instances of the variable _does not_ (except for natural numbers alone) extend beyond the third - _exponentiation_. However, I do think this little 'island' of tractibility is truly a gem; and I would say to OP "have this amongst your crown jewels"!
Comment: There should be a method for solving finding coefficients at $x=1$ of height $m$ and at $x=0$ for $e^x\uparrow\uparrow m$ as multiple finite sums like [here](https://math.stackexchange.com/questions/3314712/calculating-the-nth-super-root-when-n-is-greater-than-2/4697772#4697772).
Answer: $x \uparrow \uparrow m$ is never analytic at $x = 0$ for $m > 1$. For example, consider $m = 2$, then you have the function $x \uparrow \uparrow 2 = x^x = e^{x \ln x}$ which clearly has a branch point at $x = 0$ and hence is not analytic. You can see this if we substitute $\ln x = 2\pi i n + \log x$ where $\log$ represents the principal branch of the logarithm, in which case we have $x^x = e^{x (2\pi i n + \log x)} = e^{x 2 \pi i n} e^{x\log x}$, which certainly depends on $n$ as long as $x$ is not an integer. You have similar problems for all $m > 1$.
The function $x \uparrow \uparrow m$ is always analytic at $1$, which can be seen inductively: Clearly for $m=1$ it is analytic at $1$. If $x \uparrow \uparrow m$ is analytic at 1, then $x \uparrow \uparrow{(m+1)} = e^{(\ln x)(x\uparrow \uparrow m)}$ is analytic at $1$ because $\exp$ is analytic everwhere and $\ln$ is analytic at 1. The Taylor series of $x \uparrow \uparrow m$ at $1$ is not very nice, but the terms can be computed explicitly. Wolfram Mathworld tells us that $$ (e^x) \uparrow\uparrow m = \sum_{n=0}^m \frac{(n+1)^n}{(n+1)!} x^n + \sum_{n = m+1}^\infty a_{m n} x^n$$ where $a_{m n}$ have a rather complicated recursive formula. To compute the Taylor series of $x \uparrow\uparrow m$ at $1$, you could compose the above series with the series for $\ln(x)$ at $1$ using Faa di Bruno's formula. Not very simple, but it probably as close to a closed form as you will get.
Comment: Surprisingly, discussing the *tetration of the pascalmatrix $P$*, I arrived at the same powerseries solution for the tetration as your's here. If interested, see http://go.helms-net.de/math/tetdocs/PascalMatrixTetrated.pdf at my webspace.
Comment: Interesting (and probably a computationally friendlier method) but it shouldn't be surprising. Power series are unique, so whatever other tetration techniques you have they must agree with this for integer heights.
Answer: Consider the tetration of the function $e^x$
$$^n(e^x)=(e^x)_1^{(e^x)_2^{(e^x)_3^{_..^{.e^x_n}}}}$$
For a natural number n, the taylor series of that function is
$$^n(e^x)=\sum_{k}^{\infty}\frac{1}{k!}*T(n,k)*x^k$$
where $T(n,k)$ is the OEIS A210725 (if k<n, $T(n,k)=T(k,k)$)
then, for $n\in\mathbb{N}$:
$$^n(x)=\sum_{k}^{\infty}\frac{1}{k!}*T(n,k)*(ln(x))^k$$
On the limit for $n\to\infty$, the T(n,k)=T(k,k) are the coefficients of the Lambert w function.
There are other series, that you can find here.
For code able to calculate tetrations with high precision, (for a limited set of bases, and $n\in\mathbb{R}$) check Sheldonison's fatou.gp code
In Wolframalpha, you can get the series of $^n(x+1)$, and it will produce the Stirling transform of $^n(e^x)$. The series has power of x, and no logarithms.
Answer: I think really the extension of the progression of operations by introducing a new one that is the $n$-fold iteration of the thus-far highest one is a process that on the face of it kindof looks like it ought to be susceptible of being plied indefinitely ... but at the end of the day isn't! (Except in this case to the natural numbers only.) You get it with complex-quaternion-octonion-etc also - that progression seems also to fizzle-out rather disappointingly; and a similar principle seems to be abroad in very many areas of mathematics. Sometimes I so want this or that progression to be extensible without limit ... but then I find eventually that I need to resign myself to the first two or three items of the progression being beautiful special cases. I must admit, though ... sometimes it's actually quite a relief!
However - I do think that business of relating the tetration by $n$ of the exponential function to the Lambert w function as $n\rightarrow\infty$, and the way there is a taylor series for the function at finite $n$ with coefficients that can be found by a recursion algorithm - and the way they 'peel-away' term-by-term to leave the coefficients of the lambert w function: I do find that to be an extraordinarily sweet little oasis in the midst of a parched desert ... and it is certainly an item that I treasure amongst my crown jewels!
Answer: Just for your curiosity.
Expanding as Taylor series aound $x=1$ as
$$f_n=\sum_{k=0}^\infty c_k\,(x-1)^k$$ see how fast converge the coefficients
$$f_1=\left\{1,1,1,\frac{1}{2},\frac{1}{3},\frac{1}{12},\frac{3}{40},-\frac{1}{120},\frac{59}
   {2520},-\frac{71}{5040},\frac{131}{10080}\right\}$$
$$f_2=\left\{1,1,1,\frac{3}{2},\frac{4}{3},\frac{3}{2},\frac{53}{40},\frac{233}{180},\frac{56
   27}{5040},\frac{2501}{2520},\frac{8399}{10080}\right\}$$
$$f_3=\left\{1,1,1,\frac{3}{2},\frac{7}{3},3,\frac{163}{40},\frac{1861}{360},\frac{33641}{504
   0},\frac{8363}{1008},\frac{22391}{2160}\right\}$$
$$f_4=\left\{1,1,1,\frac{3}{2},\frac{7}{3},4,\frac{243}{40},\frac{3421}{360},\frac{71861}{504
   0},\frac{54371}{2520},\frac{69281}{2160}\right\}$$
$$f_5=\left\{1,1,1,\frac{3}{2},\frac{7}{3},4,\frac{283}{40},\frac{4321}{360},\frac{102941}{50
   40},\frac{85871}{2520},\frac{61333}{1080}\right\}$$
$$f_6=\left\{1,1,1,\frac{3}{2},\frac{7}{3},4,\frac{283}{40},\frac{4681}{360},\frac{118061}{50
   40},\frac{106661}{2520},\frac{81583}{1080}\right\}$$
$$f_7=\left\{1,1,1,\frac{3}{2},\frac{7}{3},4,\frac{283}{40},\frac{4681}{360},\frac{123101}{50
   40},\frac{115481}{2520},\frac{93013}{1080}\right\}$$
$$f_8=\left\{1,1,1,\frac{3}{2},\frac{7}{3},4,\frac{283}{40},\frac{4681}{360},\frac{123101}{50
   40},\frac{118001}{2520},\frac{97333}{1080}\right\}$$
$$f_9=\left\{1,1,1,\frac{3}{2},\frac{7}{3},4,\frac{283}{40},\frac{4681}{360},\frac{123101}{50
   40},\frac{118001}{2520},\frac{97333}{1080}\right\}$$
Comment: Are these continued fractions?
Comment: @RanjitKumarSarkar. No, they are the coefficients $c_k$

Taylor series for tetration


How to convert query string http://example.com/myview?page=1 to http://example.com/myview/page/1 in views?

Question: I have to make url of views seo friendly. I need to convert query string http://example.com/myview?page=1 to http://example.com/myview/page/1.
Can you please suggest, how can i do this.
Comment: Not an answer, but you can use example.com instead of calling test.com in your example URLs.
Answer: Try using the module: Query parameter to url(https://www.drupal.org/project/query_parameters_to_url), It will work for you.
Just specify the pattern {^myview} inside /admin/config/search/query-parameters-to-url after installing and activating the module.
Let me know if any helps needed.


Removing values from a Java hashmap

Question: Lets say I do Map<String, Integer> map = new HashMap<String, Integer>();
map.containsValue(value) returns true whether or not the value is found in the hashmap. But I found that there is no way to remove a value. Like map.removeValue(value). You can only remove the key, as in, map.removeKey(key).
Now, my question is, does removing the key also remove the value?
So when I search map.containsValue(value), will it return false if I deleted the key associated with the value with map.removeKey?
Comment: You prefer wasting other people's time... Makes sense...
Comment: It's not much code. Trying it would improve your knowledge. It's obvious that you don't like programming.
Comment: @user2817240 You wasted more time for asking this question here than trying to test it yourself or reading the documentation.
Comment: Why don't you try? Also `removeKey` does not exists. And if you read the doc it states : _"Removes the mapping for a key from this map if it is present (optional operation)."_
Comment: What did you get from trying it?
Comment: Waste of time, its more helpful if you just give me the answer.
Comment: Sorry I meant remove.
Comment: @assylias, saying yes or no doesn't take time at all, comparing to setting up code, and everything to test a simple thing.
Comment: Testing it probably takes less time than writing your question...
Comment: lol fine, w/e I guess I'll try it. Didn't think a simple question would stir so much trouble. Simple question = simple answer.
Comment: And you don't know me enough to determine whether I like coding or not. Rude.
Comment: I don't like *wasting time* would be more appropriate.
Answer:
Now, my question is, does removing the key also remove the value?

Yes.  Sort of.
Actually, it removes the specific entry that consists of the key and the value.
If the value is also used in another entry, then that other entry is unaffected, and the value will still show up in the values collection.

So when I search map.containsValue(value), will it return false if I deleted the key associated with the value with map.removeKey?

It depends ... see above.

This information can easily be found by reading the javadoc carefully.
(The problem with the "try it and see" approach is that it is easy to write a "black box" test that will cause you to drawing the wrong conclusions.  I would only suggest "try it and see" if the javadoc did NOT contain the information.  And I'd add "read the source" ... )
Comment: Alright thanks for the answer. Many of the other replies were telling me to "try it and see" but ya I"ll read the java doc.

Removing values from a Java hashmap


How to search with cypher 2.0 case insensitive?

Question: How to search with cypher 2.0 / Neo4j 2.1.7 case insensitive on a indexed field?

regex does not use index WHERE a.X =~ ('(?i)' + b.Y) ...
using lower() does not use index WHERE lower(a.X) = lower(b.Y) ...
adding a extra field with lower case property value for indexing is ugly

Not using the index will result in more them 2 mio DB Hits.
Comment: Have you tried lucene full-text indexes?  I've never tried using `PROFILE` with one of them so I'm not 100% sure they will reduce dbhits, but it's worth looking into.  http://neo4j.com/docs/stable/indexing-create-advanced.html
Comment: No, you can create legacy lucene indexes via configuration, outside of java (http://neo4j.com/docs/stable/rest-api-configurable-auto-indexes.html#rest-api-create-an-auto-index-for-nodes-with-specific-configuration)  and the `START` clause in cypher can exploit them.
Comment: What I can't answer for you is whether exploitation of these indexes will reduce dbhits, but I think they will.
Comment: Using lucene indexes with cypher:  http://stackoverflow.com/questions/22360489/passing-a-lucene-query-to-neo4j-rest-api-using-cypher-2-0
Comment: Yep agreed with @FrobberOfBits use the manual indexes via REST.
Comment: No, i'm only using the new schema indexes. Looks like the legacy indexes could only be set via the Java API, i'm using cypher only via REST API :(
Answer: For fulltext search using legacy indexes with Neo4j 2.x which is also case-insensitive check my blog post:
http://jexp.de/blog/2014/03/full-text-indexing-fts-in-neo4j-2-0/


How to prove $\sum_{n=1}^{\infty}\frac{n\sqrt[n]{(a_1a_2\cdots a_n)(b_1b_2\cdots b_n)}}{b_{n+1}b_n}$ is convergent?

Question:
Assume $a_n,b_n>0$, $b_{n+1}-b_n\ge \delta>0$ and
$\sum_{n=1}^{\infty}a_n<+\infty$. Prove
$$\sum_{n=1}^{\infty}\frac{n\sqrt[n]{(a_1a_2\cdots a_n)(b_1b_2\cdots
 b_n)}}{b_{n+1}b_n}$$ is convergent.

First, we can obtain
$$\frac{n\sqrt[n]{(a_1a_2\cdots a_n)(b_1b_2\cdots b_n)}}{b_{n+1}b_n}\le \frac{(a_1+a_2+\cdots+a_n)\sqrt[n]{b_nb_n\cdots b_n}}{b_nb_n}\le\frac{M}{b_n}\le \frac{M}{a_1+(n-1)\delta},$$
but this seems to be helpless, since $\sum \frac{1}{n}$ is not convergent.
Comment: You probably meant $\frac{M}{b_n}\le \frac{M}{\mathbf{b_1}+(n-1)\delta}$ at the end of the inequality chain.
Answer: You have $ \sqrt[n]{b_1 b_2 \cdots b_n} \le b_n$, and $n/b_{n+1}$ is bounded above, so that it suffices to show that
$$
\sum_{n=1}^\infty \sqrt[n]{a_1 a_2 \cdots a_n}
$$
is convergent, and that follows from Carleman's inequality:
$$
\sum_{n=1}^\infty \sqrt[n]{a_1 a_2 \cdots a_n}
\le e \sum_{n=1}^\infty a_n \, .
$$


Closed sets as compact sets

Question: While playing around with some basic general topology, I have thought of some problems whose solutions are not so obvious (at least to me), and surprisingly I do not remember having seen these anywhere.
Disclaimer #1 : I have already posted those problems elsewhere, but I was unlucky and received no answer.
Disclaimer #2 : The French and English notions of compact sets are notoriously different. I will try to write it right (and it might be actually easier in English).
So, let us take any topological space $(X, T)$. As a matter of prophylaxy, I will assume that $X$ is not empty. A subset $K$ of $X$ is said to be compact if, from any covering of $K$ by open sets one can extract a finite sub-cover.
My first question is: When are the compact subsets for the topology $T$ the closed subsets for another topology $T^*$ (modulo the whole space $X$)?
Trivially, any finite union of compact subsets is compact. If any intersection of compact subsets is compact, then the set of compact subsets plus $X$ are the closed subsets for some topology $T^*$ on $X$. One can see the open subsets of $(X,T^*)$ as the open neighborhoods of infinity for the Alexandroff compactification of $(X, T)$, without said infinity. If $(X,T)$ is Hausdorff then any intersection of compact sets is compact (this is because the compact sets are then closed). However, this condition is not necessary: with the coarse or cofinite topology, any subset is compact, so that any intersection of compact subsets is compact. Do the topological spaces for which this property holds have a name, or a characterization?
My second question is: Assuming that the property discussed above is satisfied, is there anything interesting to be said about the operation $T \to T^*$?
For instance, if $T$ has the property that any intersection of compact subsets is compact, then does $T^*$ have the same property? This would be important as it would allow us to iterate the operation $T \to T^*$. In addition, it looks like $T^*$ can be seen, in some cases, as a dual topology on $X$. If $T$ is the coarse topology on $X$, then $T^*$ is the discrete topology, and $T^{**}$ is the cofinite topology. Then the sequence stabilizes, as $T^{***}$ is again the discrete topology. In a similar way, If $T$ is the usual topology on $\mathbb{R}^d$, I think (I have not written down the argument properly) that $T=T^{**}$. Are those special cases, or is there a more general pattern?
Comment: [KC-space](http://topospaces.subwiki.org/wiki/KC-space) is a space in which every compact subset is closed. So every KC-space has this property. (But as your example with indiscrete spaces shows, the two properties are not equivalent.)
Answer: I don't have an answer to the first question, but I can show that the desired property isn't necessarily preserved by the $\tau\mapsto\tau^*$ operation. (Barring mental hiccups, anyway: keeping track of these topologies is a bit of a pain.)
Here's an example of a non-Hausdorff KC-space $\langle X,\tau\rangle$ such that $\langle X,\tau^*\rangle$ is also a non-Hausdorff KC-space, but $\langle X,\tau^{**}\rangle$ does not have the desired property: $\langle X,\tau^{**}\rangle$ is the space obtained by splitting the point $\omega_1$ in two in the compact Hausdorff space $\omega_1+1$ (with the order topology), as is done in constructing the line with two origins. The space $\langle X,\tau\rangle$ was originally constructed by Bill Fleissner as an example of a KC-space whose topology contains no minimal KC-topology.
Let $p$ and $q$ be two points not in $\omega_1$, and let $X=\omega_1\cup\{p,q\}$. Let $\tau_0$ be the order topology on $\omega_1$. Let $I=\{0\}\cup\{\xi+1:\xi\in\omega_1\}$, the set of isolated points of $\omega_1$. For $\alpha<\omega_1$ let $$B_\alpha(p)=\{p\}\cup I\setminus\alpha\text{ and }B_\alpha(q)=\{q\}\cup I\setminus\alpha\;,$$ and let $\tau$ be the topology on $X$ generated by the base $$\tau_0\cup\{B_\alpha(p):\alpha<\omega_1\}\cup\{B_\alpha(q):\alpha<\omega_1\}\;.$$ Let $\mathscr{K}_0$ be the set of $\tau_0$-compact subsets of $\omega_1$; $\mathscr{K}_0$ is simply the set of countable $\tau_0$-closed subsets of $\omega_1$. Let $\mathscr{K}\;$ be the set of $\tau$-compact subsets of $X$; clearly $$\mathscr{K}=\big\{K\cup F:K\in\mathscr{K}_0\land F\subseteq \{p,q\}\big\}\;,$$ which is precisely the set of countable $\tau$-closed subsets of $X$, and it follows that $$\tau^*\triangleq\{X\setminus K:K\in\mathscr{K}\;\;\}\cup\{\varnothing\}$$ is a topology on $X$.
Let $\tau_0^*=\tau^*\cap\wp(\omega_1)\setminus\{\varnothing\}$; $\tau_0^*$ is the set of co-countable $\tau_0$-open subsets of $\omega_1$, and $$\tau^*=\big\{V\cup F:V\in\tau_0^*\land F\subseteq \{p,q\}\big\}\cup\{\varnothing\}\;.$$
Let $\mathscr{K}\;^*$ be the set of $\tau^*$-compact subsets of $X$; $$\mathscr{K}\;^*=\mathscr{K}\cup\big\{C\cup F:C\subseteq\omega_1\text{ is a }\tau_0\text{-cub} \land F\subseteq \{p,q\}\big\}\;.$$
Clearly $\tau^{**}\triangleq \{X\setminus K:K\in\mathscr{K}\;^*\}$ is a topology on $X$, and it's not hard to see that $$\tau^{**}=\big\{V\cup F:V\in\tau_0\land F\subseteq\{p,q\}\big\}\subsetneqq\tau\;.$$
The subspaces $\omega_1\cup\{p\}$ and $\omega_1\cup\{q\}$ of $\langle X,\tau^{**}\rangle$ are homeomorphic in an obvious way to the compact Hausdorff space $\omega_1+1$ (with the order topology), and $\langle X,\tau^*\rangle$ is therefore $\omega_1+1$ with the point $\omega_1$ split into $p$ and $q$, as mentioned above.
Finally, let $\mathscr{K}\;^{**}$ be the set of $\tau^{**}$-compact subsets of $X$; $$\mathscr{K}\;^{**}=\mathscr{K}\cup\big\{C\cup F:C\subseteq\omega_1\text{ is a }\tau_0\text{-cub} \land\varnothing\ne F\subseteq \{p,q\}\big\}$$ and is not closed under intersections, since $X\setminus\{p\},X\setminus\{q\}\in\mathscr{K}\;^{**}$, but $X\setminus\{p,q\}\notin\mathscr{K}\;^{**}$.
Comment: Thank you for your answer (that I've only remarked now). It may take me some time to understand it, but it looks nice.

Closed sets as compact sets


standard way of adding button

Question:

I need to know on my navigationItem i add back, title uiSegmentedController and itemAdd button's.
Is it proper way to add that?
If it is yes..... how to add sigmentedcontroller near to ItemAdd button
Comment: Good Lord; all those buttons in the navigation bar are _fugly_
Comment: Can you ask your question more specifically?
Comment: Is it proper way to add three button's on navigation Item. i added three button's on navigation item in the give picture. On is back.. another one is UISegmentedController and another one is ItemAdd style button. on the NavigationItem..... Is it proper way. to do like that.
Comment: Yeap.....its really fugly..... i want it to be in standard passion... can you help me out. abizern
Answer: You dont need to add back button on navigation bar if you are using a navigationController.
Assuming that you are using a navigationController just add
<code>
self.title = @"Title";
</code>
in the previous view.
If not than its fine
Answer: HI
This is a proper and absolutely correct way to add buttons in the navgation controller,though you could do with a smaller back button.
Cheers

standard way of adding button


How do you export configuration from configuration module

Question: I need to include the configuration that I track in configuration modules into my install profile or however I will allow so that it will be initialised on install. How do I do this?
Answer: Enable Configuration Management UI submodule
Goto yoursite.com/admin/config/system/configuration/migrate
There is links for Export & Import


Aprendiz de C (Fatoração em C)

Question: Galera alguém pode me ajuda na lógica desse código ? o começo dele eu entendo mas fico meio atrapalhado na parte do for, alguém pode me ajudar a entender ?
#include <stdio.h>

int main(){

int fatorial, n;
printf("insira o numero que vc quer fatorar\n");
scanf("%i",&n);

for(fatorial=1;n>=1; n--){
    fatorial *= n;

}
printf("o fator do seu numero e: %i",fatorial);
return 0;
}

Comment: Você testou esse código?
Comment: sim sim testei.
Answer: Sabendo que a fatoração é a multiplicação de um número por todos os seus números positivos menores que ele. Por exemplo: Fatorial de 5 = 5 x 4 x 3 x 2 x 1 = > 120
Então:
A cada iteração no loop, o número escolhido (n) é multiplicado pelo antecessor dele (n-1)
for(fatorial=1;n>=1; n--){
    fatorial = fatorial * n;

}

talvez assim dê pra entender um pouco melhor.
iteração 1: fatorial = 1 * 5; (fatorial vale 5)
iteração 2: fatorial = 5 * 4; (fatorial vale 20)
iteração 3: fatorial = 20 * 3; (fatorial vale 60)
iteração 4: fatorial = 60 * 2; (fatorial vale 120)
iteração 5: fatorial = 120 * 1; (fatorial vale 120)

Answer: Ele esta iniciando um fatorial em 1 e vai até o n (informado pelo usuário)
E a cada interação ele vai multiplicar o fatorial (inicia = 1) pelo n, o *= faz o mesmo que fatorial = fatorial * n
Existem outras maneiras de calcular o fatorial, por exemplo utilizando essa bem simples com um laço while.
unsigned long long fatorial( int n )
{
    unsigned long long f = 1;

    while( n > 0 )
        f *= n--;

    return f;
}

Ou essa que talvez seja um pouco mais complicada de entender pois é recursiva.
long long fatorial(int n){
long long fat;
if ( n <= 1 )
    return (1);
else{
   return n * fatorial(n - 1);
}
}

Aprendiz de C (Fatoração em C)


Displaying menu bar in Webpage

Question: I have a menu in which some of the menu should be on right and some of it must be on left.

I'm able to do this using BootStrap Framework,I want to do this without it. Here is my code.
HTML

    <title>TODO supply a title</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    // <link href="http://s3.amazonaws.com/codecademy-content/courses/ltp/css/bootstrap.css" rel="stylesheet">
     <link rel="stylesheet" href="index_style.css">

Home

Categories

About Us

Contact Us

Register

Login

CSS
    .nav a {
  color: #5a5a5a;
  font-size: 11px;
  font-weight: bold;
  padding: 14px 10px;
  text-transform: uppercase;
}

.nav li {
  display: inline;
}

body{
    margin: 0;
}

Answer: You have to separate/define your CSS rules: Pull-right/Pull-left aren't defined in anyway along with the majority of your classes.
*You tagged your question with Twiiter-Bootstrap which most of these classes are used in.

html {
  box-sizing: border-box;
}
*,
*:before,
*:after {
  box-sizing: inherit;
}
body {
  margin: 0;
}
.nav {
  margin-left: -35px;
}
.container {
  padding-right: 15px;
  padding-left: 15px;
  margin-right: auto;
  margin-left: auto;
}
ul.pull-left {
  float: left;
}
ul.pull-right {
  float: right;
}
.nav li {
  display: inline-block;
}
.nav ul > li > a {
  color: #5a5a5a;
  font-size: 11px;
  font-weight: bold;
  padding: 14px 10px;
  text-transform: uppercase;
}

Home

Categories

About Us

Contact Us

Register

Login

Comment: I don't want to use any framework. I want to do using attributes alone in my css file.
Comment: Are you using Bootstrap or not then because your question is tagged twitter-bootstrap.
Comment: No,I'm not using it. I just want to indicate that I get the solution with bootstrap. Can I know how to do without it?
Comment: Yes, you can easily Google how to do this. You do not need StackOverflow for it. See my updated answer.
Answer: Yes you can make navigation menubar without Bootstrap.Here,I make Demo.
http://jsfiddle.net/Xroad/33ovfgeL/

Home

Categories

About Us

Contact Us

Register

Login

  .nav a {
  color: #5a5a5a;
  font-size: 11px;
  font-weight: bold;
  padding: 14px 10px;
  text-transform: uppercase;
}

.nav li {
  display: inline;
}
.pull-left{float:left}
.pull-right{float:right}
.clear{clear:both}
.container{background-color:#bbb}

Comment: it just clears the float effect so next elements won't affected by float.

Displaying menu bar in Webpage


Custom e-mail translation in Drupal 8

Question: I need to send some e-mails depending on some actions. These e-mails should be translated depending on the target user's preferred language. I've seen that the mail function has a language parameter, but for me, it's not really do anything.
  $renderArray = [
    '#theme' => 'email_notification_content_update',
    '#name' => $node->getOwner()->getDisplayName(),
    '#content_title' => $node->getTitle(),
    '#content_url' => $node->toUrl('canonical', ['absolute' => TRUE])
      ->toString(),
    '#unfollow_url' => Url::fromRoute('flag.field_entry.delete', [
      'flag' => 'flag_name',
      'entity_id' => $node->id(),
    ])->setAbsolute()->toString(),
  ];

  $this->mailManager->mail(
    'my_module',
    'email_notification_content_update',
    $follower->getEmail(),
    $follower->language()->getId(),
    [
      'body' => $this->renderer->renderRoot($renderArray),
      'subject' => $this->t('An update of the content @title has been updated.', ['@title' => $node->getTitle()]),
    ]
  );

Currently, the e-mail text is in twig file (with links) and the parameters are passed to it at render. Now I can put the whole twig file in {% trans %} tags, but is there a better way? Like using the mail function's language parameter? Is there a better way to make a custom e-mail sending and have translations to them?
Answer: Be aware that the rendering (and therefore the translation) happens at $this->renderer->renderRoot(). I'd create a mail key handler, and build the body inside that handler. I'm not sure, but it may be that drupal switches to the given language at the ->mail function before processing the custom hook.
  $this->mailManager->mail(
    'mymodule',
    'content_update',
    $follower->getEmail(),
    $follower->language()->getId(),
    [
      'node' => $node,
    ]
  );

/mymodule.module
<?php

use Drupal\Core\Url;

/**
 * Implements hook_mail().
 */
function mymodule_mail($key, &$message, $params) {
  $renderer = Drupal::service('renderer');

  if ($key === 'content_update') {
    $node = $params['node'];
    $renderArray = [
      '#theme' => 'email_notification_content_update',
      '#name' => $node->getOwner()->getDisplayName(),
      '#content_title' => $node->getTitle(),
      '#content_url' => $node->toUrl('canonical', ['absolute' => TRUE])
        ->toString(),
      '#unfollow_url' => Url::fromRoute('flag.field_entry.delete', [
        'flag' => 'flag_name',
        'entity_id' => $node->id(),
      ])->setAbsolute()->toString(),
    ];
    $message['body'] = $renderer->renderRoot($renderArray);
    $message['subject'] = t("Content :title has been updated", [':title' => $node->label()]),
  }
}

Comment: How to respond to the mail key: https://code-examples.net/en/docs/drupal~8/core-core.api.php/function/hook_mail/8.1.x
Comment: Well, I sill don't see actually why the language parameter exists, I tried to debug but I didn't find the usage and I totally don't see currently why should I define the body and subject in the `hook_mail` when it will won't change anything... And I also guessing body can't be a renderable array...
Comment: I updated the answer, since hook_mail has no sign of language parameters I asume that drupal has a magic way to change to the given language before executing hook_mail. You can alter the subject and body parameter inside hook_mail.

Custom e-mail translation in Drupal 8


Creation of FloatBuffer Array with for ¿overwrites values?

Question: I'm creating an array of FloatBuffers with a for loop like this:
FloatBuffer[] buffer = new FloatBuffer[sizebuffer];

float[] farray = new float[sizeArray];

for(int i=0;i<sizebuffer;i++){
    for(int j=0;j<sizeArray;j++){

     farray[j]= I get the float values from other buffer....
    }

    buffer[i]= FloatBuffer.wrap(farray);  (*)

}

But for some reason it's changing the values on each row of the FloatBuffer array ("buffer") each time this line (*) is executed. For example, after buffer[0] is given its value, I printed buffer[0].get(0), then after buffer[1] was given its values, I printed buffer[0].get(0) again, but the value had been changed.
It's coping the values for each new buffer[i] on each of the previous ones buffer[0], buffer[1]...
I don't understand why is this happening?
Answer: The FloatBuffer.wrap method effectively retains the array passed to it. So all your buffers will end up with whatever values you last process in the for loop. A simple, but relatively expensive way of avoiding this problem would be to System.arraycopy the array before wrapping it in each buffer.
To be honest, you should just use one of the put family of methods to set the float values into the buffers while you are reading them from your external source.
for(int i=0;i<sizebuffer;i++){
    for(int j=0;j<sizeArray;j++){
        farray[j]= some value from other buffer....
    }

    buffer[i]= FloatBuffer.allocate(farray.length);
    buffer[i].put(farray);
}

Comment: Thanks for the explanation! And you are completely right, I could have just used "put" directly: buffer[i].put(j, float value); Changed it and works perfectly.
Answer: This is what is stated in JavaDOC
public static FloatBuffer wrap(float[] array)
Wraps a float array into a buffer.

The new buffer will be backed by the given float array; that is, **modifications to the buffer will cause the array to be modified and vice versa.** The new buffer's capacity and limit will be array.length, its position will be zero, and its mark will be undefined. Its backing array will be the given array, and its array offset will be zero.

Parameters:
    array - The array that will back this buffer
Returns:
    The new float buffer


how to insert image inside an existing image

Question:
hi i'm working on my sample site.in that I've done the background image blue sky into the respective region how can i add one more image in center of that like below ? and more over
I've to add an web form in that center image i'm going to add? how can i achieve this?
Comment: I'm voting to close this question as off-topic because it's about implementing feature from screenshot - defined as off-topic in Help Center.
Comment: `file:// .... / index.html` ... how is this Drupal related again?
Comment: thanks for noticing..i've just taken the screen shot of what i actually need..
Answer: It depends on your theme which you're using. Normally you've to create a block with image in its content and assign to the right region.
If you don't have the right region to assign to, try changing the existing content, or expand your theme and add new region based on your needs, or use Panels and replace your current page with custom layout (e.g. by using a flexible layout).


Simplificação de expressão booleana

Question: Boa noite, galera!
Estou a realizar um trabalho que tenho que simplificar uma expressão algébrica booleana de um circuito:

E a expressão mais simples que achei foi essa:

Mas acho que ela pode ser mais simples, alguém teria uma solução melhor que esta?
Comment: Desculpe ter trocado o NOR com NAND. Já arrumei as duas respostas.
Comment: A fórmula está correta. Sua intenção é ter menos níveis de porta `and`/porta `or`?
Comment: Essa questão trata de uma das ferramentas usadas para diminuir a profundidade para o mínimo possível de portas n-árias, o mapa de Karnaugh: https://pt.stackoverflow.com/q/228005/64969
Answer: Esta resposta é uma solução por meio de redução de expressões booleanas. Também postei uma outra resposta baseada na análise da tabela-verdade.
A primeira porta NOR na figura produz isso:
(1) j = NOT (a OR b OR c)

A porta NOT abaixo dessa NOR:
(2) k = NOT b

A porta XOR:
(3) m = d XOR k

A porta NOT acima da XOR:
(4) n = NOT d

A penúltima porta NAND:
(5) p = NOT (j AND n)

A porta final:
(6) f = NOT (p AND m)

Substituindo-se (5) em (6):
(7) f = NOT (NOT (j AND n) AND m)

Substituindo-se (4) em (7):
(8) f = NOT (NOT (j AND NOT d) AND m)

Substituindo-se (3) em (8):
(9) f = NOT (NOT (j AND NOT d) AND (d XOR k))

Substituindo-se (2) em (9):
(10) f = NOT (NOT (j AND NOT d) AND (d XOR NOT b))

Substituindo-se (1) em (10):
(10) f = NOT (NOT (NOT (a OR b OR c) AND NOT d) AND (d XOR NOT b))

Essa é a expressão equivalente. Agora, vamos simplificá-la. Aplicando a lei de Morgan nos parênteses mais internos de (10):
z = NOT (a OR b OR c)
f = NOT (NOT (z AND NOT d) AND (d XOR NOT b))
z = NOT a AND NOT b AND NOT c
(11) f = NOT (NOT ((NOT a AND NOT b AND NOT c) AND NOT d) AND (d XOR NOT b))

Aplicando a lei de Morgan de novo em (11):
z = NOT ((NOT a AND NOT b AND NOT c) AND NOT d)
x = (NOT a AND NOT b AND NOT c)
y = NOT d
z = NOT (x AND y)
z = NOT x OR NOT y
z = NOT (NOT a AND NOT b AND NOT c) OR d
(12) f = NOT ((NOT (NOT a AND NOT b AND NOT c) OR d) AND (d XOR NOT b))

Mais uma vez:
z = NOT (NOT a AND NOT b AND NOT c)
z = a OR b OR c
(13) f = NOT (((a OR b OR c) OR d) AND (d XOR NOT b))

De novo:
x = ((a OR b OR c) OR d)
y = (d XOR NOT b)
f = NOT (x AND y)
f = NOT x OR NOT y
(14) f = NOT ((a OR b OR c) OR d) OR NOT (d XOR NOT b)

Simplificando os parênteses:
(15) f = NOT (a OR b OR c OR d) OR NOT (d XOR NOT b)

Aplicando de Morgan de novo:
z = NOT (a OR b OR c OR d)
z = NOT a AND NOT b AND NOT c AND NOT d
(16) f = (NOT a AND NOT b AND NOT c AND NOT d) OR NOT (d XOR NOT b)

Considerando que (x XOR NOT y) é a equivalente a (x <-> y), então:
(17) f = (NOT a AND NOT b AND NOT c AND NOT d) OR NOT (d <-> b)

Considerando que NOT (x <-> y) é a equivalente a (x XOR y), então:
(18) f = (NOT a AND NOT b AND NOT c AND NOT d) OR (d XOR b)

Considerando que (x XOR y) é equivalente a (x AND NOT y) OR (NOT x AND y):
(19) f = (NOT a AND NOT b AND NOT c AND NOT d) OR (d AND NOT b) OR (NOT d AND b)

Agora, temos duas possibilidades, agrupar o NOT d AND alguma-coisa. Ou agrupar o NOT b AND alguma-coisa. Vamos começar com o NOT d:
(20a) f = (NOT d AND ((NOT a AND NOT b AND NOT c) OR b)) OR (d AND NOT b)

Distribuindo-se o OR b:
(21a) f = (NOT d AND (NOT a OR b) AND (NOT b OR b) AND (NOT c OR b)) OR (d AND NOT b)

Ora, NOT b OR b é verdadeiro! Então:
(22a) f = (NOT d AND (NOT a OR b) AND TRUE AND (NOT c OR b)) OR (d AND NOT b)

E temos que (x AND TRUE) = x. Logo:
(23a) f = (NOT d AND (NOT a OR b) AND (NOT c OR b)) OR (d AND NOT b)

Colocando-se o b em evidência de novo:
(24a) f = (NOT d AND ((NOT a AND NOT c) OR b)) OR (d AND NOT b)

Distribuindo-se o NOT d AND:
(25a) f = (NOT d AND NOT a AND NOT c) OR (NOT d AND b) OR (d AND NOT b)

Considerando que (NOT d AND b) OR (d AND NOT b) é o mesmo que (d XOR b):
(26a) f = (NOT a AND NOT c AND NOT d) OR (d XOR b)

Se tivéssemos agrupado com o NOT b ao invés do NOT d:
(20b) f = (NOT b AND ((NOT a AND NOT c AND NOT d) OR d)) OR (NOT d AND b)

Distribuindo-se o OR d:
(21b) f = (NOT b AND (NOT a OR d) AND (NOT c OR d) AND (NOT d OR d)) OR (NOT d AND b)

Ora, NOT d OR d é verdadeiro! Então:
(22b) f = (NOT b AND (NOT a OR d) AND (NOT c OR d) AND TRUE) OR (NOT d AND b)

E temos que (x AND TRUE) = x. Logo:
(23b) f = (NOT b AND (NOT a OR d) AND (NOT c OR d)) OR (NOT d AND b)

Colocando-se o b em evidência de novo:
(24b) f = (NOT b AND ((NOT a AND NOT c) OR d)) OR (NOT d AND b)

Distribuindo-se o NOT b AND:
(25b) f = (NOT b AND NOT a AND NOT c) OR (NOT b AND d) OR (NOT d AND b)

Considerando que (NOT b AND d) OR (NOT d AND b) é o mesmo que (d XOR b):
(26b) f = (NOT a AND NOT b AND NOT c) OR (d XOR b)

Temos como resultados:

f = (NOT a AND NOT c AND NOT d) OR (d XOR b).
f = (NOT a AND NOT b AND NOT c) OR (d XOR b).

Essas são as possíveis soluções.
Comment: Creio que está seja a solução mais completa que achei, simplesmente sensacional! Muito obrigado pela ajuda e contribuição,amigo!
Comment: em (1) você faz menção a uma porta NAND, quando na verdade é uma porta NOT OR.
Answer: Esta resposta é uma solução por meio de análise da tabela-verdade. Também postei uma outra resposta baseada em redução de expressões booleanas.
Vamos ver como fica a tabela-verdade:
A B C D F
0 0 0 0 1
0 0 0 1 1
0 0 1 0 0
0 0 1 1 1
0 1 0 0 1
0 1 0 1 0
0 1 1 0 1
0 1 1 1 0
1 0 0 0 0
1 0 0 1 1
1 0 1 0 0
1 0 1 1 1
1 1 0 0 1
1 1 0 1 0
1 1 1 0 1
1 1 1 1 0

Vamos reorganizar as colunas, colocando na ordem CABD e permutando as linhas de acordo para ficar na ordem onde os números das quatro colunas da esquerda crescem em ordem binária do 0000 até o 1111:
C A B D F
0 0 0 0 1
0 0 0 1 1
0 0 1 0 1
0 0 1 1 0
0 1 0 0 0
0 1 0 1 1
0 1 1 0 1
0 1 1 1 0
1 0 0 0 0
1 0 0 1 1
1 0 1 0 1
1 0 1 1 0
1 1 0 0 0
1 1 0 1 1
1 1 1 0 1
1 1 1 1 0

Observe que os valores de F da primeira metade da tabela são quase idênticos aos da segunda, com exceção da primeira linha de cada (0000 e 1000). Vamos ver o que há de especial nessas linhas (e para essa parte, o C não importa):
A B D F
0 0 1 1
0 1 0 1
0 1 1 0
1 0 0 0
1 0 1 1
1 1 0 1
1 1 1 0

Observe que os casos onde a saída é um são os casos B XOR D.
Voltando na primeira linha de cada metade da tabela:
C A B D F
0 0 0 0 1
1 0 0 0 0

Isso daí equivale a (NOT A AND NOT B AND NOT C AND NOT D).
Juntando as duas subexpressões temos:
(NOT A AND NOT B AND NOT C AND NOT D) OR (B XOR D)

No entanto, se voltarmos a olhar na tabela, dá para simplificar (NOT A AND NOT B AND NOT C AND NOT D) cortando uma (mas não as duas) subexpressões NOT B ou NOT D. Assim, chega-se em duas possíveis soluções:

(NOT A AND NOT B AND NOT C) OR (B XOR D)
(NOT A AND NOT C AND NOT D) OR (B XOR D)
Comment: @Dwcleb Não. Observe a coluna do F. Onde era "*B=1, C=0, D=1, F=0*", agora é "*C=0, B=1, D=1, F=0*". Onde era "*B=1, C=1, D=1, F=0*", agora é "*C=1, B=1, D=1, F=0*". Não apenas permutei as colunas, mas também as linhas para ficar na ordem 000 -> 111.
Comment: Na terceira tabela vc diz ter colocado o C na frente, mas apenas trocou a leta, e a coluna permanece a mesma...
Comment: @Dwcleb Editei a resposta para explicar melhor.

Simplificação de expressão booleana


Deriving a composed matrix function

Question: I'm interested in deriving the following function, with respect to the matrix  $W$,
\begin{align}
R\left({G}; H\right) =
     \log \bigg|{I} +s \cdot \big({G}^H{G}\big)^{-1}{G}^H{H}{H}^H{G}\bigg|.
\end{align}
where $G = WA$, and $G,W,A,H \in \mathbb{C}^{M\times M}$ and $s \in \mathbb{C}$.
I used matrixcalculus.org to reach the final answer, but I want to understand the way:
\begin{align}
    \nabla_{W} R({W},{A}) =
    \bigg(s\!\cdot\!{A} \notag
     \Big({I}+ s\!\cdot\!({{G}^H{G}\big)^{-1}
    {G}^H{H}{H}^H{G}}\Big)^{-1}\notag
     \Big(2({G}^H{G})^{-1}{G}^H{H}{H}^H\Big)\notag
    \Big({I}_M-{G}({G}^H{G})^{-1}{G}^H\Big)\bigg) ^H.
\end{align}
To facilitate the calculations I defined:
$Y = G^H G, \quad P = GY^{-1}G^H, \quad Z = PHH^H, \quad Q = I + s\cdot Z$
So, we have $R = \log \det Q$.
I used the differential method, but then I got stuck:
\begin{align}
\quad dR = Q^{-T} : dQ \\
\quad = Q^{-T} :s\cdot dZ  \\
\end{align}
And now I'm not sure how should I move forward.
what is $dZ, $what is $dP$, and what is $dY$? and how do I substitute them?
Answer: $
\def\s{\sigma}
\def\LR#1{\left(#1\right)}
\def\op#1{\operatorname{#1}}
\def\trace#1{\op{Tr}\LR{#1}}
\def\frob#1{\left\| #1 \right\|_F}
\def\qiq{\quad\implies\quad}
\def\p{\partial}  \def\grad#1#2{\frac{\p #1}{\p #2}}
$I'll keep most of your variable names, but I need to rename $H\to F,\:$ since $H^H$ is one keystroke away from disaster.
Also, in the complex domain, one typically uses Wirtinger derivatives (i.e. treating $\,\{dG,\,dG^H\}\,$ as independent variables).
First, note that the pseudoinverse can be used to shorten the expression
$$\eqalign{
G\LR{G^HG}^{-1}G^H = GG^+ \equiv P \\
}$$
The differential of this ortho-projector is well known
$$\eqalign{
dP &= \LR{I-P} \;dG\; G^+ + \LR{G^+}^H dG^H \LR{I-P} \\
}$$
Applying this to the current problem
$\LR{{\rm and\:ignoring\;the\;} dG^H {\rm\:term}}$
$$\eqalign{
dR &= Q^{-T}:dQ \\
 &= s\,Q^{-T}:dZ \\
 &= s\,Q^{-T}:dP\;FF^H \\
 &= \LR{sFF^HQ^{-1}}^T:dP \\
 &= \LR{sFF^HQ^{-1}}^T:\LR{I-P} \;dG\; G^+ \\
 &= \LR{s\,G^+FF^HQ^{-1}\LR{I-P}}^T:dG \\
 &= \LR{s\,G^+FF^HQ^{-1}\LR{I-P}}^T:dW\,A \\
 &= \LR{sAG^+FF^HQ^{-1}\LR{I-P}}^T:dW \\
\grad{R}{W} &= \LR{sAG^+FF^HQ^{-1}\LR{I-P}}^T \\
}$$
Where did the factor of $\,2\,$ go?
This is a typical occurrence when dealing with Wirtinger derivatives.
As a simple example, consider the Frobenius norm (squared)
$$\phi = \frob{A}^2$$
When $A$ is $\sf real$, the gradient wrt $A$ is
$$\eqalign{
\phi &= A:A \\
d\phi &= 2A:dA \\
\grad{\phi}{A} &= 2A \\
}$$
But when $A$ is $\sf complex$, the Wirtinger gradient wrt $A$ is
$$\eqalign{
\phi &= A^* : A \\
d\phi &= A^*:dA \\
\grad{\phi}{A} &= A^* \\
}$$
BTW, this is also the reason why the (outer) Hermitian conjugate in your result has been replaced by a simple transpose in my result.
To reorder the matrices, you can take advantage of the identity
$$ \det(I+AB) \;=\; \det(I+BA) $$
before differentiating.
Comment: Can you explain why the term $G^+FF^H$ comes before $Q^{-1}$, unlike my result?
And, where has the constant $2$ gone to?
Comment: Huge thanks. Your contribution is priceless!

Deriving a composed matrix function