text:
Q: Every element of $U + V + W$ can be expressed uniquely in the form $u + v + w$ Suppose that $U$, $V$ and $W$ are subspaces of some given vector space. With the obvious definition of $U + V + W$, show that every element of $U + V + W$ can be expressed uniquely in the form $u + v + w$, where $u ∈ U$, $v ∈ V$ and $w ∈ W$, if and only if
$$\dim(U + V + W) = \dim(U) + \dim(V) + \dim(W)$$
1) Say every element of $U + V + W$ can be expressed uniquely in the form $u + v + w$. Let $u_1,...,u_n$, $v_1,...,v_m$, $w_1,...,w_q$ be respective bases. Then every element in $U + V + W$ can be expressed uniquely as
$$(\alpha_1u_1+...+\alpha_nu_n)+(\beta_1v_1+...+\beta_mv_m)+(\gamma_1w_1+...+\gamma_qw_q)$$
showing that
$$\dim(U + V + W) = \dim(U) + \dim(V) + \dim(W)$$
2) How do I prove the converse? Hints are appreciated (also verification, that what I did, is not useless :) ). Thanks!

A: People are really missing the point of the exercise. If I have two (finite-dimensional) subspaces $S,T$ in some larger vector space, the following are equivalent:
(1) $\dim (S + T) = \dim S + \dim T$
(2) $S \cap T = \{ \; \vec{0} \; \} $
(3) every vector in $S+T$ has only one expression as $s+t,$ with $s \in S, \; t \in T.$
About points (2) and (3), if I have some nonzero vector $v \in S \cap T,$ then I can write it as either $v \in S$ or $v \in T,$ which could be written in order as $v + 0 = 0 + v,$ giving non-uniqueness for the expression. For that matter, we get an alternative expression $0 = v + (-v).$ So, given any $w = s+t,$ we get a second expression $w = (s + v) + (t - v).$ That is called nonuniqueness.
Your question is about three subspaces $U,V,W$ which have (pairwise) trivial intersections.
The important words here are "uniquely" and "intersections."
EDIT, Monday, June 17. Notice that if you can prove the equivalence of the three properties above, a really good, careful proof, then the question for three subspaces is just proof by induction (just one such step), using some inequalities:
$$  \dim (U+V) \leq \dim U + \dim V.  $$
$$  \dim (U+V+W) \leq \dim (U+V) + \dim W.  $$
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
ANOTHER EDIT, same day:
THEOREM 1:
$$  \dim (U+V) \leq \dim U + \dim V,  $$ and equality holds if and only if $$ U \cap V = \{ \vec{0} \}. $$
PROOF: by @Sarunas
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
THEOREM 2:
$$  \dim (U+V + W) \leq \dim (U+V) + \dim W,  $$ and equality holds if and only if $$ (U+V) \cap W = \{ \vec{0} \}. $$
PROOF: apply Theorem 1.
CAUTION: the condition (for equality) in Theorem 2 above is sometimes stronger than just pairwise trivial intersections. The simplest example is three distinct one-dimensional spaces (lines through the origin) in the plane $\mathbb R^2.$ See MO_COMMON_FALSE_BELIEFS_TILMAN including the comment by @Willie Wong

A: This is a different approach, using a classical idea in linear algebra : expressing subspaces as images or kernels of linear maps.
First i will recall a few things about the cartesian product of vector spaces.

We know we can define $U\times V\times W $ to be the set of triples
  with first element in $U$, second in $V$, and third in $W$.  This set
  can be given a vector space structure by stating $$(u,v,w)+(u',v',w')
> = (u+u', v+v', w+w') ; \lambda(u,v,w) = (\lambda u,\lambda v,\lambda w)$$ We can show that if $(u_1, ..., u_m) ; (v_1, ..., v_n); (w_1,..., w_p)$ are basis of $U,V,W$ respectively, then $[(u_1,0,0), ...,(u_m,0,0) ; (0,v_1,0), ..., (0,v_n,0); (0,0,w_1), ..., (0,0,w_p)]$ is
  a basis of $U\times V\times W $.
Thus $$\dim(U\times V\times W) = \dim(U) + \dim(V) + \dim(W)$$

Let $$\phi : \cases{ U\times V\times W \rightarrow E \\(u,v,w) \mapsto u+v+w}$$
This is a linear map, it's the function that "builds" all the elements of $U + V + W$. Actually, we have $\text{im}(\phi) = U + V + W$. Remark that it automatically means that $U + V + W$ is a subspace of $E$ !
Asking for the uniqueness of the expression of elements of $U+V+W$ is the same as asking this function to be injective. This is the case if and only if $\ker(\phi) = {0}$, which by the fundamental theorem of linear algebra, is the cas if and only if $$\dim(U\times V\times W ) = \dim(\text{im}(\phi)) \\ \Leftrightarrow \dim(U\times V\times W) = \dim(U+V+W)\\ \Leftrightarrow \dim(U) + \dim(V) + \dim(W) = \dim(U+V+W)$$

A: Your proof of one implication is correct (of course finite dimension is assumed).
Now assume an element can be written in two distinct ways
$$
u+v+w=u'+v'+w'
$$
with $u,u'\in U$, $v,v'\in V$ and $w,w'\in W$. This implies $(u-u')+(v-v')+(w-w')=0$, so we can assume $u+v+w=0$ with at least one among $u$, $v$ and $w$ non zero. It's not restrictive to assume $u\ne0$.
Set $u=u_1$ and complete it to a basis $\{u_1,\dots,u_m\}$ of $U$. Fix also a basis $\{v_1,\dots,v_n\}$ of $W$ and a basis $\{w_1,\dots,w_p\}$ of $W$.
The union of these bases is clearly a set of generators of $U+V+W$, but we know it's linearly dependent, because we can write
$$
(\alpha_1u_1+\dots+\alpha_mu_m)+(\beta_1v_1+\dots+\beta_nv_n)+(\gamma_1w_1+\dots+\gamma_pw_p)=0
$$
where
\begin{gather}
\alpha_1=1,\alpha_2=\dots=\alpha_m=0\\
\beta_1v_1+\dots+\beta_nv_n=v\\
\gamma_1w_1+\dots+\gamma_pw_p=w
\end{gather}
Thus from this set of generators we can remove a vector, obtaining still a set of generators; therefore
$$
\dim(U+V+W)<m+n+p
$$
because from every set of generators we can extract a basis.

A: I think I understand now, what @WillJagy intended to hint, but I want to make sure, that I really do. So, the first part of my answer was correct, right? But then, for the converse:
Suppose $$\dim(U+V+W)=\dim(U)+\dim(V)+\dim(W)$$
Also, assume for contradiction, that one of the intersections contain at least one, nonzero vector, say $U\cap W=\{0,z_1\}$. Then I can write it as $z_1\in U$ or $z_1\in W$. But that means that one of the vectors in $U+W$ (or in $U+V+W$ for that matter) has a non-unique representation, meaning that
$$\dim(U+V+W)<\dim(U)+\dim(V)+\dim(W)$$ and contradicting the initial assumption. Thus we have a pairwise trivial intersections between the given subspaces
$$U\cap V=V\cap W=U\cap W=\{0\}$$
But then to express a vector in $U+V+W$, we need some basis $u_1,...u_n,v_1,...,v_m,w_1,...,w_q$, where $u_i\in U$, $v_i\in V$, $w_i\in W$. Since, pairwise intersections contain only the zero vector, these elements are linearly independent and thus every element in $U+V+W$ has a unique representation.
Am I right?


text:
Q: how to group by multiple columns and aggregate the last column in redshift Not sure if I am just having a brain fart because this problem seems VERY simple:
+----------+----------+---------------------+
| user_id  | country  | country_probability |
+----------+----------+---------------------+
| 10000022 | France   | 0.126396313         |
| 10000022 | Italy    | 0.343407512         |
| 10000022 | England  | 0.161236539         |
| 10000044 | China    | 0.061884698         |
| 10000044 | S. Korea | 0.043251887         |
| 10000044 | Japan    | 0.65095371          |
| 10000046 | USA      | 0.215771168         |
| 10000046 | Canada   | 0.214556068         |
| 10000046 | Mexico   | 0.081350066         |
+----------+----------+---------------------+

In Redshift, how do I group this so that my output is: unique user_id, country that is the max probability, and the probability of that country for that user_id?
Which would be:
+----------+---------+---------------------+
| user_id  | country | country_probability |
+----------+---------+---------------------+
| 10000022 | Italy   | 0.343407512         |
| 10000044 | Japan   | 0.65095371          |
| 10000046 | USA     | 0.215771168         |
+----------+---------+---------------------+

Thank you and sorry if this is a duplicate post... I tried searching but wasn't able to find much. The grouping function seems to work different in Redshift vs MySQL...

A: Maybe something like this?
select user_id, country, country_probability
from your_table
where (user_id, country_probability) in
      (select user_id, max(country_probability)
       from test
       group by user_id
      )

[EDIT: yet another option, using analytic RANK function]
select user_id, country, country_probability
from (select user_id, country,
        country_probability,
        rank() over (partition by user_id order by country_probability desc) rnk
        from your_table
     )
where rnk = 1;

A: It would be interesting to compare the performance of Littlefoot's methods with:
select distinct user_id,
       first_value(country) over (partition by user_id order by country_probability desc),
       min(country_probability) over (partition by user_id)
from t;

I am not generally a fan of using select distinct for aggregation, but Redshift only supports first_value() as a window function.

redpajama_set_name: RedPajamaStackExchange


text:
Q: How to enable other checkboxes in recycler view if previous checkbox is checked (other checkboxes are disabled at first)? What I want to do is if April and May have a due amount then a user cannot select May if April is not selected. First, a user has to select April then the May checkbox will get enabled. If May is selected then June will get enabled.
I am not able to get position of the checkboxes so that I can do the same.

@Override
  public void onBindViewHolder(@NonNull FeeHolder holder, int position) {
      holder.textView_fee.setText(Integer.toString(list.get(position).getFeeAmount()));
      holder.textView_due.setText(Integer.toString(list.get(position).getDueAmount()));
      holder.checkBox.setText(list.get(position).getInstallmentName());

      holder.checkBox.setTag(Integer.toString(position));
      arrayList.add(holder.checkBox);
      /*if (holder.checkBox.isChecked()) {
          arrayList.add(holder.checkBox);
      }*/
      holder.checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
          @Override
          public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {

          }
      });

A: Add a selected property (with getters and setters) to your list array and here's a code fragment to play with.
if (position > 0) {
  YourObject obj = list.get(position - 1);
  if(obj.dueAmount() > 0) {
    if(obj.isSelected()) {
      holder.checkBox.setEnabled(true)
    } else {
      holder.checkBox.setEnabled(false)
    }
  } else {
    holder.checkBox.setEnabled(true)
  }
}

Then, on your setOnCheckedChangeListener, update your object's selected property accordingly.
PS: This applies a chain effect if previous items have dueAmount > 0


text:
Q: Shopware 6: Product Slider data is null when use manual assignment I have a issue with the product slider.
First issue: In administration, i added a product slider that using dynamic product group and a product slider that using use manual assignment.
I created a my resolver class that inherit from ProductSliderCmsElementResolver for loading data on storefront.
But on Storefront only display data from dynamic product group , data from manual assignment is null.
Second issue: On Storefront can't display product's cover (I still using Product Slider). Do I need to do anything at resolver class ?
Thank everyone.

A: It was fixed by the OP by extending their resolver from ProductSliderCmsElementResolver. By this the existing logic / template is used and the data is displayed.


text:
Q: Android studio not saving variable Hello so I have a App about a fact and tip each 24 hours it displays a fact or tip!
I am pretty new to Android studio anyways to keep track of the fact and tip the user is in I used a variabe "timing" in the start timer i put when the mTimeLeftInMillis == 0 then make timing = 1 and if timing == 1 then do that but ya for that it's not the case!
when the user leaves the timing variable resets and goes back to 124!
Could someone please help me! I tried to do shared perferences in it but It didn't work!
here is my java code!
public class MainActivity extends AppCompatActivity implements View.OnClickListener{
    private static final long START_TIME_IN_MILLIS = 30000;

    Button tip;
    TextView texttip;
    TextView textfact;
    Button next;
    Button back;

    private TextView mTextViewCountDown;
    private Button mButtonStartPause;
    private Button mButtonStart;

    private CountDownTimer mCountDownTimer;

    private boolean mTimerRunning;

    private long mTimeLeftInMillis;
    private long mEndTime;
    private long timing = 124;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mTextViewCountDown = findViewById(R.id.text_view_countdown);

        mButtonStartPause = findViewById(R.id.button_start_pause);
        next = (Button)findViewById(R.id.next);
        next.setOnClickListener(this);
        back = (Button)findViewById(R.id.back);
        back.setOnClickListener(this);
        mButtonStart = findViewById(R.id.tip);
        tip = (Button) findViewById(R.id.tip);
        texttip = (TextView)findViewById(R.id.texttip);
        textfact = (TextView)findViewById(R.id.textfact);

        mButtonStartPause.setOnClickListener((new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(mTimerRunning) {
                    mButtonStartPause.setText("fact ");
                } else {
                    startTimer();
                }

            }
        }));

        mButtonStart.setOnClickListener((new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(mTimerRunning) {
                    mButtonStart.setText("Tip");
                } else {
                    startTimer();
                }

            }
        }));

    }

    @Override
    public void onClick(View view) {
        if(view.getId() == R.id.next){
            tip.setVisibility(view.INVISIBLE);
            mButtonStartPause.setVisibility(View.INVISIBLE);
            mButtonStart.setVisibility(View.INVISIBLE);
            textfact.setVisibility(View.INVISIBLE);
            texttip.setVisibility(View.INVISIBLE);
            mTextViewCountDown.setVisibility(View.INVISIBLE);
            next.setVisibility(View.INVISIBLE);
            back.setVisibility(View.VISIBLE);
        }
        if (view.getId() == R.id.back){
            tip.setVisibility(View.VISIBLE);
            mButtonStart.setVisibility(View.VISIBLE);
            mButtonStartPause.setVisibility(View.VISIBLE);
            textfact.setVisibility(View.VISIBLE);
            texttip.setVisibility(View.VISIBLE);
            mTextViewCountDown.setVisibility(View.VISIBLE);
            next.setVisibility(View.VISIBLE);
            back.setVisibility(View.INVISIBLE);
        }
    }

    private void startTimer() {
        if (timing == 5) {
            mTimeLeftInMillis = START_TIME_IN_MILLIS;
            updateCountDownText();
            updateButtons();
            textfact.setText("Makeup was invented by  egypt");
            texttip.setText("Spend time with a loved one");
        } else{
            mButtonStartPause.setText("fact ");
        }

        if (timing == 4) {
            timing = 5;
            mTimeLeftInMillis = START_TIME_IN_MILLIS;
            updateCountDownText();
            updateButtons();
            textfact.setText("The US flag was designed by a student");
            texttip.setText("Its okay to make mistakes because you will learn from them");
        } else{
            mButtonStartPause.setText("fact ");
        }

        if (timing == 3) {
            timing = 4;
            mTimeLeftInMillis = START_TIME_IN_MILLIS;
            updateCountDownText();
            updateButtons();
            textfact.setText("DID YOU KNOW THAT SCOTLAND HAS 421 WORDS FOR SNOW!!!");
            texttip.setText("Don't compare your self to others!");
        } else{
            mButtonStartPause.setText("fact ");
        }
        if (timing == 2) {
            timing = 3;
            mTimeLeftInMillis = START_TIME_IN_MILLIS;
            updateCountDownText();
            updateButtons();
            textfact.setText("There is no q in all 50 states of US!");
            texttip.setText("Do what you live. The purpose of life is to be happy!");
        } else{
            mButtonStartPause.setText("fact ");
        }

        if (timing == 1) {
            timing = 2;
            mTimeLeftInMillis = START_TIME_IN_MILLIS;
            updateCountDownText();
            updateButtons();
            textfact.setText("The phillipines has about 7,641 islands!!");
            texttip.setText("Develop good habits! Like running outside could benefit you and your mental health and your body by alot!");
        } else{
            mButtonStartPause.setText("fact ");
        }

        if (mTimeLeftInMillis == 0 && timing == 124) {
            timing = 1;
            mTimeLeftInMillis = START_TIME_IN_MILLIS;
            updateCountDownText();
            updateButtons();
            textfact.setText("Sudan has the most pyramids in the world");
            texttip.setText("Look for knowledge not results");
            textfact.setVisibility(View.VISIBLE);
            texttip.setVisibility(View.VISIBLE);
        } else{
            mButtonStartPause.setText("fact ");
        }
        mEndTime = System.currentTimeMillis() + mTimeLeftInMillis;
        mCountDownTimer = new CountDownTimer(mTimeLeftInMillis, 1000) {
            @Override
            public void onTick(long millisUntilFinished) {
                mTimeLeftInMillis = millisUntilFinished;
                updateCountDownText();
            }

            @Override
            public void onFinish() {
                mTimerRunning= false;
                updateButtons();
            }
        }.start();

        mTimerRunning = true;
        updateButtons();

    }

    private void updateCountDownText() {
        int minutes = (int) (mTimeLeftInMillis / 1000) / 60;
        int seconds = (int) (mTimeLeftInMillis / 1000) % 60;

        String timeLeftFormatted = String.format(Locale.getDefault(), "%02d:%02d", minutes, seconds);
        mTextViewCountDown.setText(timeLeftFormatted);

    }

    private void updateButtons() {
        if(mTimerRunning){

            mButtonStartPause.setText("fact");
        }else {
            mButtonStartPause.setText("fact");

            if (mTimeLeftInMillis < 1000) {
                mButtonStartPause.setVisibility(View.VISIBLE);
            } else {
                mButtonStartPause.setVisibility(View.VISIBLE);
            }

        }
    }

    @Override
    protected void onStop() {
        super.onStop();

        SharedPreferences prefs = getSharedPreferences("prefs", MODE_PRIVATE);
        SharedPreferences.Editor editor = prefs.edit();

        editor.putLong("millisLeft", mTimeLeftInMillis);
        editor.putBoolean("timerRunning", mTimerRunning);
        editor.putLong("endTime", mEndTime);

        editor.apply();
    }

    @Override
    protected void onStart() {
        super.onStart();

        SharedPreferences prefs = getSharedPreferences("prefs", MODE_PRIVATE);

        mTimeLeftInMillis = prefs.getLong("millisLeft", START_TIME_IN_MILLIS);
        mTimerRunning = prefs.getBoolean("timerRunning", false);

        updateCountDownText();
        updateButtons();

        if (mTimerRunning) {
            mEndTime = prefs.getLong("endTime", 0);
            mTimeLeftInMillis = mEndTime - System.currentTimeMillis();

            if (mTimeLeftInMillis < 0) {
                mTimeLeftInMillis = 0;
                mTimerRunning = false;
                updateCountDownText();
                updateButtons();
            } else{
                startTimer();
            }
        }
    }

}

I tried making two timers and the other timer  will save it because i know how to do shared preferences on timers but not on stuff like that but it didn't work also because errors started coming!
I wanted the timing thing to save.


text:
Q: Is "X is a risk of substance abuse" an ambiguous statement? I recently happened upon a health assessment quiz with the following question:

*

*Which is not a risk of substance abuse?

*

*Bullying

*Death from Heart Failure

*Lack of Coping Skills

*Addiction

The correct answer is "Death from Heart Failure." It was explained to me that this question is asking, "Which of the following will not lead to substance abuse?"
Does this seem like a good question in terms of wording?

A: This question is badly written, to the extent that I also could not understand what it was asking when I first read it. I disagree with Zebrafish's comment saying

If this is a quiz given to anyone in the field of health (either student or otherwise), it would be entirely clear, I believe. In this context "Risk of substance abuse" always means "something that puts you at risk of abusing substances", not "a possible result of abusing substances."

Here are two examples of "is a risk of substance abuse" being used to mean "is a potential negative result of substance abuse":

*

*
Alcohol and drugs affect your judgment and can lead to dangerous behavior that puts you at risk for:

*

*[...]

*Unwanted pregnancy. For the same reasons that alcohol and other drugs put people at greater risk for STDs, it also makes pregnancy a risk of substance abuse.

–"Drug and Alcohol Abuse Awareness", Porter and Chester Institute (Porter and Chester Institute is a technical school)

*
Suicide is a Hidden Risk of Substance Abuse

–National Screening Centers blog, 2018
I would expect "risk of substance abuse" to be used in the following ways when describing some thing "X" that contributes to substance abuse:

*

*X carries a risk of substance abuse

*X increases the risk of substance abuse

*X is linked to increased risk of substance abuse


text:
Q: Создание нескольких лейблов программно Добрый вечер, нужно вывести количество элементов в очередях на разные лейблы. При нажатии кнопки печатается только количество элементов в первой очереди,найдите ошибку, пожалуйста. Заранее спасибо.
private void button1_Click_1(object sender, EventArgs e)
{
    M = int.Parse(textBox1.Text); //Количество очередей
    QArray = new Queue<int> [M];
    for (int i=0;i< M; i++)
    {
        QArray[i] = new Queue<int>();
        Random rnd = new Random();
        int count = rnd.Next(1, 8); //Количество элементов в очереди
        for (int j=0;j< count; j++)
        {
            QArray[i].Enqueue(rnd.Next(1, 30));
        }
        Label label = new Label();
        label.Location = new Point(100+10*i, 100);
        label.Text = QArray[i].Count.ToString();
        this.Controls.Add(label);
    }
}

A: В Вашем коде нет ошибки, просто Ваши элементы перекрывают друг друга. Попробуйте внести следующее изменение:
label.Location = new Point(100 + 100 * i, 100);

Измените, к примеру 10 * i на 100 * i тогда уведите все элементы.


text: Q: How to hide files on USB [Python] The goal is to prevent unauthorized copying from USB Drive. I need to block visibility of selected files on other devices (upon USB insertion) not using attribute "Hidden". Is there a way to do that theoretically?


text:
Q: How to extract part of a polygon in R? I would like to create a map of Europe in R to plot some of my data. I have modified the code below (taken from: http://www.r-bloggers.com/provincial-map-using-gadm/) to give me a map of Europe. All is great except that the sliver of Russia along the Baltic disappears.
How can I extract that portion of the Russia polygon to maintain a true map of Europe?
library(sp)
library(raster)
## Download Map of the World ##
WorldMap <- getData('countries')

## Subset world map to European countries ##
EuropeMap <- (WorldMap[WorldMap$CONTINENT=="Europe" & WorldMap$COUNTRY != "Russia",])

## Plot map ##
plot(EuropeMap, bg = "dodgerblue", axes = T)
plot(EuropeMap, lwd = 10, border = "skyblue", add = T)
plot(EuropeMap, col ="green4", add = T)
grid()
box()
invisible(text(getSpPPolygonsLabptSlots(EuropeMap), labels = as.character(EuropeMap$COUNTRY), cex = 0.5, col = "white", font = 2))
mtext(side = 3, line = 1, "Map of Europe", cex = 2)
mtext(side = 1, "Longtiude", line = 2.5, cex = 1.1)
mtext(side = 2, "Latitude", line = 2.5, cex = 1.1)
text(40,30, "Projection: Geographic\nCoordinate System: WGS 1984\nData Source: GADM.org\nCreated by: Keith Larson", adj = c(0,0), cex = 0.7, col = "grey20")
text(-35, 75, "Calopteryx splendens", col="white", font=3, cex=1.5)

A: it is very simple to extract that portion of the Russia polygon,just like choose the data that conform to our condtions. For example:
datamapSliver <- datamap[datamap$Sliver==1,]
plot(datamapSliver)


text:
Q: firebase deploy: Error: path-to-file/firestore.indexes.json does not exist I added the functions folder for firebase cloud functions. But now I can not deploy my Angular project. When I deploy only the function with firebase deploy --only functions it works fine but when I try to deploy my project by running firebase deploy, I get this error:

Error: desktop/projects/my-angular-project/firestore.indexes.json does not exist

my firebase.json file :
{
  "hosting": {
    "public": "public",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**",
      "**/functions/**"
    ],
    "rewrites": [
      {
        "source": "**",
        "destination": "/index.html"
      }
    ]
  },
  "firestore": {
    "rules": "firestore.rules",
    "indexes": "firestore.indexes.json"
  },
  "functions": {
    "predeploy": [
      "npm --prefix \"$RESOURCE_DIR\" run lint",
      "npm --prefix \"$RESOURCE_DIR\" run build"
    ]
  }
}

How do I fix this?

A: Your firebase.json files has an instruction to deploy security rules and predefined indexes to Firestore here:
  "firestore": {
    "rules": "firestore.rules",
    "indexes": "firestore.indexes.json"
  },

If you don't want either of these to happen, remove that line from the firebase.json.

A: I solved it by reinitializing the firebase project firebase init. This time two files were generated in the root directory firebase.rules and firebase.indexes.json which were not there for some reason and the problem was solved.


text:
Q: What Ubuntu is better for an i5 CPU? 32 or 64 Bit? I want to install Ubuntu 64 Bit on a i5 CPU, but I'm not sure how the 64 Bit version performs now.
How good is the application support for it? Are there any issues to be aware of?
In general, is it better to go with a 32 Bit or 64 Bit operating system?

A: Short answer : 64 bit.
If you want a longer explanation and some documentation about the topic, see ubuntu-64-bit-vs-32-bit.

A: I use 64 bit Ubuntu/Kubuntu/Mint/Arch for years. 64 bit version has become good enough and as people already said you can install 32bit library's easely:
sudo apt-get install ia32-libs

Another clue that could convince you is that from next release Ubuntu will no longer recommend 32-bit versions when you click on "Download Ubuntu" because the assumption is that most people have hardware that is capable of 64 bit computing. You are ready now (I hope you don't have less RAM than 2Gb with such processor).

A: I haven't encountered any 32-bit problems with my 64-bit OS for a few years now. I would definetily go with 64-bit so that I don't need to migrate later.


text:
Q: Merge-Sort(array, first, last): Can first ever exceed last? MERGE-SORT(a[], first, last)
{
     if first >= last
         return

     mid = first + (last - first) / 2
     MERGE-SORT(a, first, mid)
     MERGE-SORT(a, mid + 1, last)
     MERGE(a, first, mid, last)
}

Is there a case where the first will ever be bigger than the last? If not, then the '>' in the if statement got no use I guess, right?


text:
Q: AWS SES Missing final '@domain' PHP SDK Here's a tidbit so you don't have to spend two hours nearly tearing out your hair like I just did.
I was receiving the following error message:
 Fatal error: Uncaught Aws\Ses\Exception\SesException: AWS Error Code: InvalidParameterValue, Status Code: 400, AWS Request ID: [Removed for stackoverflow], AWS Error Type: client, AWS Error Message: Missing final '@domain', User-Agent: aws-sdk-php2/2.6.6 Guzzle/3.9.1 curl/7.36.0 PHP/5.5.12
Earlier errors had shown validation taking place, (e.g. ToAddresses must be an array), so I assumed the data was validated. To a degree, I was wrong.

A: Despite the name, this is an error indicating that SES doesn't like one of your parameters.  In my case, I had used the code on this page from the PHP SDK documentation to build up the parameter for sendEmail() and I had left Source as 'string'.
Try building your parameter for sendEmail() as $msg and using echo "sendSES msg: ".print_r($msg, true); to see exactly what's going to SES.
Postfix users may have the issue that the email address is not matching the ec2 domain name.  It is a different issue, but similar in that it is SES rejecting the semantics of the data.


text:
Q: Is it possible to listen to different ports in the same domain name? I am a newbie in server hosting and i have the code source of several applications that i can run on localhost and i want to host them in the same website
So let's say that i am running the first one which is written with JavaScript frameworks in port 8080: https://localhost:8080
and the second one which is written in Java is running in port 3000; https://localhost:3000
What i want to do is to host the first one as www.example.com/first and the second one as  www.example.com/second, is that possible? Thank you!

A: Yes, you'll want to use something like ProxyPass for Apache's httpd or proxy_pass for nginx.


text:
Q: Should I use the FQN in PHPDoc if I'm importing the class with use? Let's say I have a UserController class and I'm importing the App\User class with use. Inside, there is a show() method that receieves an instance of User.
namespace App\Http\Controllers;

use App\User;

class UserController extends Controller
{
    /**
     * Show user info
     *
     * @param  User $user
     * @return Illuminate\Http\JsonResponse
     */
    public function show(User $user)
    {
        // Do something...
    }
}

Is it recommended to add the fully qualified name of User in PHPDoc even if I'm importing the class with use?

A: Use FQN if there are no use statement, as it would be recognized as a different class, in Your case as \JsonResponse which is not imported.
As for User class, use short name.
It is more convenient to import class with use statement and write short name in docblock.
Also class aliases can be used, for instance:
namespace App\Http\Controllers;

use App\User;
use Illuminate\Http\JsonResponse as Response;

class UserController extends Controller
{
    /**
     * Show user info
     *
     * @param  User $user
     * @return Response
     */
    public function show(User $user)
    {
        // Do something...
    }

}


text:
Q: Setup web server copying response from another server with nginx I would like to configure a nginx server which will be continously connected to another web server - with mjpeg stream. My new web server should copy the response it gets and send it to any client connected to it (to the new server). I cannot just connect clients to the original web server providing mjpg stream as it gets blocked on first connection, I am trying to bypass it somehow. I tried reverse proxy, but its still blocking the original server after first connection.

A: You won't be able to do this purely with Nginx.  You need something that can take the stream, buffer, and output streams that start in the right place.
There are a couple ways to handle this.  One is to create a custom server with Node.js or something that does what you need.  Another is to transcode this MJPEG stream to something else, such as an HLS stream.  This will be more efficient, can be served with Nginx, but will increase latency a bit.


text:
Q: What is the Cameron-Martin norm associated to $X(t)=\int_0^t B(s) ds+B(t)$? The process $X(t)=\int_0^t B(s) ds+B(t)$ is a centered continuous Gaussian process. Therefore it defines a Gaussian measure on $C[0,T]$. Therefore there is a Cameron-Martin space with Cameron-Martin norm. I can compute the covariance and get some complicated expression.
Is there a clean expression for the Cameron-Martin norm associated to $X$?

A: I will show that for $x\in\mathcal C^1$, $x$ is in the Cameron-Martin space $\mathcal H$ and
$$ |x|_\mathcal{H}^2 = \int_0^T\left(x'(t)-\int_0^t\mathbf e^{-(t-s)}x'(s)\mathrm ds\right)^2\mathrm dt. $$
Expanding the product and using Fubini's theorem, it can be rewritten as
$$ |x|_\mathcal{H}^2 = \int_0^T|x'(t)|^2\mathrm dt + \int_0^T\int_0^Tk(s,t)x'(s)x'(t)\mathrm ds\mathrm dt $$
for some explicit kernel $k$. I claim that with slightly more effort, one can show that $\mathcal H=\mathrm H^1$ as vector spaces, and that the above expression stays true for $x'\in\mathrm L^2$ the weak derivative. Hopefully this is clean enough for your purposes.
The Cameron-Martin space.
Define $\overline F:\mathcal C\to\mathcal C$ as the continuous map sending $B$ to $X$; formally, $F(b):t\mapsto\int_0^tb_sds + b_t$. Set $i_B:\mathrm H^1\to\mathcal C$ the usual Cameron-Martin inclusion for Brownian motion.¹ The important observation is that the continuous map $\overline F\circ i_B:\mathrm H^1\to\mathcal C$ is injective. Let us postpone the proof to the end of the answer.
Define $\mathcal H$ as the image of $\mathrm H^1$ under $\overline F\circ i_B$, together with the inner product coming from $\mathrm H^1$ (we use the injectivity here). In other words, $\mathcal H$ is the set of all $\overline F\circ i_B(b)$ for $b\in\mathrm H^1$, and $|\overline F\circ i_B(b)|_\mathcal{H}^2=|b|_{\mathrm H^1}^2$.  It is obviously canonically isomorphic to $\mathrm H^1$, through some $F:\mathrm H^1\to\mathcal H$.
I claim that the inclusion $i_X:\mathcal H\hookrightarrow\mathcal C$ is the Cameron-Martin space of $X$. Indeed, for any $\phi,\psi\in\mathcal C^*$, and noting that $\overline F\circ i_B=i_X\circ F$,
$$ \begin{align*}
   \mathbb E[\phi(X)\psi(X)]
&= \mathbb E[\phi\circ\overline F(B)\psi\circ\overline F(B)] \\
&= \big\langle\phi\circ\overline F\circ i_B,\psi\circ\overline F\circ i_B\big\rangle_{(\mathrm H^1)^*} \\
&= \big\langle\phi\circ i_X\circ F,\psi\circ i_X\circ F\big\rangle_{(\mathrm H^1)^*} \\
&= \big\langle\phi\circ i_X,\psi\circ i_X\big\rangle_\mathcal{H^*}.
   \end{align*} $$
Expression for the norm.
Suppose $x\in\mathcal C$ is actually of class $\mathcal C^1$, and define
$$ b:t\mapsto
   \int_0^t\mathbf e^{-(t-s)}x'(s)\mathrm ds
 = \mathbf e^{-t}\int_0^t\mathbf e^sx'(s)\mathrm ds. $$
Then $b$ is clearly in $\mathrm H^1$, and in fact we will show $x=F(b)$, so $x\in\mathcal H$ and $|x|_\mathcal{H}=|b|_{\mathrm H^1}$ and we have the expected expression for the Cameron-Martin norm.
The fact that $x=F(b)$ follows from computing derivatives:
$$ \frac{\mathrm d}{\mathrm dt}\big(F(b)(t)-x(t)\big)
 = b(t) + b'(t) - x'(t)
 = 0. $$
Injectivity of the transform.
Since $i_B$ is injective, we need only show that $\overline F$ is injective. Choose $b\in\mathcal C$ such that $\overline F(b)=0$. This means precisely that
$$ 0=\overline F(b)(t)=\int_0^tb(s)\mathrm ds + b(t) $$
for all $t$. Then the function
$$ t\mapsto\mathbf e^t\int_0^tb(s)\mathrm dt $$
is $\mathcal C^1$ with vanishing derivative hence always zero, and using the relation again,
$$ b(t) = -\int_0^tb(s)\mathrm ds = -\mathbf e^{-t}\cdot0 = 0. $$

¹ $\mathrm H^1$ is the Sobolev space of functions $b$ that can be written as the integral of a function $\dot b\in\mathrm L^2$.


text:
Q: How to locate the icon of the extension that opened in new tab I m trying to find xpath of button:

<svg width="24" height="24" fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" class="sc-hXvPvl cOJGAW"><path d="M10.125 0h3.75C14.498 0 15 .502 15 1.125V9h4.11c.835 0 1.253 1.008.662 1.598l-7.13 7.135a.908.908 0 0 1-1.28 0l-7.139-7.135C3.633 10.008 4.05 9 4.884 9H9V1.125C9 .502 9.502 0 10.125 0ZM24 17.625v5.25c0 .623-.502 1.125-1.125 1.125H1.125A1.122 1.122 0 0 1 0 22.875v-5.25c0-.623.502-1.125 1.125-1.125h6.877l2.296 2.297a2.402 2.402 0 0 0 3.404 0l2.296-2.297h6.877c.623 0 1.125.502 1.125 1.125Zm-5.813 4.125a.94.94 0 0 0-.937-.938.94.94 0 0 0-.938.938.94.94 0 0 0 .938.938.94.94 0 0 0 .938-.938Zm3 0a.94.94 0 0 0-.937-.938.94.94 0 0 0-.938.938.94.94 0 0 0 .938.938.94.94 0 0 0 .938-.938Z"></path></svg>

Snapshot of the element:

A: To locate the element you can use either of the following locator strategies:

*

*Using css_selector:
element = driver.find_element(By.CSS_SELECTOR, "div[data-testid='xray-export-csv']")

*Using xpath:
element = driver.find_element(By.XPATH, "//div[@data-testid='xray-export-csv']")


text:
Q: int *array = new int[n]; what is this function actually doing? I am confused about how to create a dynamic defined array:
 int *array = new int[n];

I have no idea what this is doing.  I can tell it's creating a pointer named array that's pointing to a new object/array int?  Would someone care to explain?

A: new allocates an amount of memory needed to store the object/array that you request. In this case n numbers of int.
The pointer will then store the address to this block of memory.
But be careful, this allocated block of memory will not be freed until you tell it so by writing
delete [] array;

A: It allocates space on the heap equal to an integer array of size N,
and returns a pointer to it, which is assigned to int* type pointer called "array"

A: int *array = new int[n];

It declares a pointer to a dynamic array of type int and size n.
A little more detailed answer: new allocates memory of size equal to sizeof(int) * n bytes  and return the memory which is stored by the variable array. Also, since the memory is dynamically allocated using new, you should deallocate it manually by writing (when you don't need anymore, of course):
delete []array;

Otherwise, your program will leak memory of at least sizeof(int) * n bytes (possibly more, depending on the allocation strategy used by the implementation).

A: The statement basically does the following:

*

*Creates a integer array of 'n' elements

*Allocates the memory in HEAP memory of the process as you are using new operator to create the pointer

*Returns a valid address (if the memory allocation for the required size if available at the  point of execution of this statement)

A: It allocates that much space according to the value of n and pointer will point to the array i.e the 1st element of array
int *array = new int[n];

A: The new operator is allocating space for a block of n integers and assigning the memory address of that block to the int* variable array.
The general form of new as it applies to one-dimensional arrays appears as follows:
array_var = new Type[desired_size];

A: In C/C++, pointers and arrays are (almost) equivalent.
int *a; a[0]; will return *a, and a[1]; will return *(a + 1)
But array can't change the pointer it points to while pointer can.
new int[n] will allocate some spaces for the "array"

A: As of C++11, the memory-safe way to do this (still using a similar construction) is with std::unique_ptr:
std::unique_ptr<int[]> array(new int[n]);

This creates a smart pointer to a memory block large enough for n integers that automatically deletes itself when it goes out of scope. This automatic clean-up is important because it avoids the scenario where your code quits early and never reaches your delete [] array; statement.
Another (probably preferred) option would be to use std::vector if you need an array capable of dynamic resizing. This is good when you need an unknown amount of space, but it has some disadvantages (non-constant time to add/delete an element). You could create an array and add elements to it with something like:
std::vector<int> array;
array.push_back(1);  // adds 1 to end of array
array.push_back(2);  // adds 2 to end of array
// array now contains elements [1, 2]


text:
Q: Changing YYYY-MM-DD to three different columns I am struggling to find information on changing a singe date into three columns.
Current Data:
      Date
2018-06-07
2017-03-01
2015-11-30

Desired Result
Year  Month  Day
2018     06   07
2017     03   01
2015     11   30

A: 1) chron Since the input was not specified reproducibly we assume this:
Dates <- c("2018-06-07", "2017-03-01", "2015-11-30")

in which case this would work -- you can omit the [...] part if column order does not matter:
library(chron)
do.call("cbind", month.day.year(Dates)[c("year", "month", "day")])

giving this matrix (use data.frame in place of cbind if you want a data frame):
     year month day
[1,] 2018     6   7
[2,] 2017     3   1
[3,] 2015    11  30

The above code will also work if Dates is of "Date" class.
2) format (base)
DatestoNum <- function(fmt) as.numeric(format(as.Date(Dates), fmt))
sapply(c(year = "%Y", month = "%m", day = "%d"), DatestoNum)

giving the same result.  This will also work if Dates is of "Date" class. In that case you can optionally remove the as.Date.  Use as.data.frame on the result if you prefer a data frame result.
2a) Alternately write it out:
cbind(year = DatestoNum("%Y"), month = DatestoNum("%m"), day = DatestoNum("%d"))

3) lubridate
library(lubridate)

cbind(year = year(Dates), month = month(Dates), day = day(Dates))

4) read.table (base)
read.table(text = format(Dates), sep = "-", col.names = c("year", "month", "day"))

If Dates is already character you could optionally omit format.

A:  Dates <- c("2018-06-07", "2017-03-01", "2015-11-30")
> scan(text=Dates, what=list(Year="",Month="",Day=""), sep="-")
Read 3 records
$Year
[1] "2018" "2017" "2015"

$Month
[1] "06" "03" "11"

$Day
[1] "07" "01" "30"

So that's in a "dataframe" arrangement:
data.frame( scan(text=Dates, what=list(Year="",Month="",Day=""),
                 sep="-", quiet=TRUE) )
#-------
  Year Month Day
1 2018    06  07
2 2017    03  01
3 2015    11  30

If those values were already Date- (or factor-) classed variables in a dataframe or list, then you would need as.character to coerce the Date column for this to succeed.

A: It seems the user is just keeping the dates as strings which need to be split on a separator character. In this case, using tidyr::separate is the easiest solution:
library(tidyverse)
Dates <- data.frame(id = c('a', 'b', 'c'),
                    date = c("2018-06-07", "2017-03-01", "2015-11-30"))
Dates %>%
    separate(date, c("Year","Month","Day"))

  id Year Month Day
1  a 2018    06  07
2  b 2017    03  01
3  c 2015    11  30

The safer solution is probably to store the dates as some kind of date object. In that case you would want to use the solutions posted by @G.Grothendieck.


text:
Q: expected expression on else if condition I have the following code to determine if the game should move to the next level. The last else if and else condition cause and two errors. "expected expression" and "expected identifier. If I comment those conditions out the code compiles just fine. Not sure what I'm missing. Any help would be appreciated.
- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
    for (UITouch *touch in touches) {
        SKNode *n = [self nodeAtPoint: [touch locationInNode:self]];
        if (n !=self && [n.name isEqual:@"restartLabel"] && _gameLevel == 0){
            [[self childNodeWithName:@"restartLabel"] removeFromParent];
            [[self childNodeWithName:@"winLoseLabel"] removeFromParent];
            SKTransition *reveal = [SKTransition flipHorizontalWithDuration:0.5];
            SKScene * myScene = [[MyScene alloc] initWithSize:self.size];
            [self.view presentScene:myScene transition: reveal];
            return;
        }
    else if (n !=self && [n.name isEqual:@"nextLevelLabel"] && _gameLevel == 1)
        {
            [[self childNodeWithName:@"nextLevelLabel"] removeFromParent];
            [[self childNodeWithName:@"winLoseLabel"] removeFromParent];
            SKTransition *reveal = [SKTransition flipHorizontalWithDuration:0.5];
            SKScene * myScene2 = [[MyScene2 alloc] initWithSize:self.size];
            [self.view presentScene:myScene2 transition: reveal];
            return;
        }
    }
    else if (n !=self && [n.name isEqual:@"nextLevelLabel"] && _gameLevel == 2)
        {
            [[self childNodeWithName:@"nextLevelLabel"] removeFromParent];
            [[self childNodeWithName:@"winLoseLabel"] removeFromParent];
            SKTransition *reveal = [SKTransition flipHorizontalWithDuration:0.5];
            SKScene * myScene3 = [[MyScene3 alloc] initWithSize:self.size];
            [self.view presentScene:myScene3 transition: reveal];
            return;
        }
}
    else
        {            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"End of the Road" message:@"You reached the end of the game. More levels coming soon!" delegate:self cancelButtonTitle:@"Ok"  nil]
            [alert show];
        }
    @end

A: The 2nd else if and the last else are after the closing curly brace of the for loop.
May I suggest you work on curly brace consistency and the following layout to avoid such a problem.
for (...) {
    if (...) {
    } else if (...) {
    } else if (...) {
    } else {
    }
}

Doing it this way makes it readable and easy to spot mistakes.
You may prefer curly braces on their own lines and that is fine. Pick a style and use it every where. The code you posted is used two different styles. That just leads to problems.

A: else if (n !=self && [n.name isEqual:@"nextLevelLabel"] && _gameLevel == 1)
    {
        [[self childNodeWithName:@"nextLevelLabel"] removeFromParent];
        [[self childNodeWithName:@"winLoseLabel"] removeFromParent];
        SKTransition *reveal = [SKTransition flipHorizontalWithDuration:0.5];
        SKScene * myScene2 = [[MyScene2 alloc] initWithSize:self.size];
        [self.view presentScene:myScene2 transition: reveal];
        return;
    }
}   <--- remove this


text:
Q: HTML Form Value = Javascript variable I want to display "something" on the HTML forms textbox
this value should be a javascript variable

var paramvalue = "something"
document.getElementById("client_id").value = paramvalue
<form action="login.php" method="post">
       <input type="hidden" name="clientID" id="client_id" value="" />
       <button>Login</button>
</form>

A: You have to put the script after the HTML, since when it is run, the input field doesn't exist yet, so it will return an error.
<form action="login.php" method="post">
    <input type="hidden" name="clientID" id="client_id" value="" />
    <button>Login</button>
</form>
<script type="text/javascript">
    var paramvalue = "something";
    document.getElementById("client_id").value = paramvalue;
</script>

A: var textbox = document.getElementById('client_id');,

then
textbox.value = paramvalue;

will work.
Your issue is you have type='hidden' where it should be type='text' because hidden will not be visible. You also need to change it to run onload so you replace the value on page load.
<script type="text/javascript">
   function init(){
      var paramvalue = "something"
      document.getElementById("client_id").value = paramvalue
   }
   body.addEventListener("load", init);
</script>

  <form action="login.php" method="post">
           <input type="text" name="clientID" id="client_id" value="" />
           <button>Login</button>
  </form>

Alternatively, you can keep your code, change input type = "text" and just move your script below your HTML code/ Form, negating the need for the JS function and the event listener
The user could also do :
<input type="text" name="clientID" id="client_id" value="" onload="init()" />


text:
Q: Google In app billing always failing and not consuming Im trying to add in app billing that will allow the user to make a purchase as many times as they like (no limit). Therefore it must be consumed. The first time I run the code on a new device it works fine and the test purchase is made successfully. However it fails to be consumed and doesnt let me make another purchase. The problem seems to be in this method, as it always ends up with result.isFailure() thus, the purchase is not consumed (and can only be made once).
IabHelper.OnIabPurchaseFinishedListener mPurchaseFinishedListener = new IabHelper.OnIabPurchaseFinishedListener() {
    public void onIabPurchaseFinished(IabResult result, Purchase purchase)
    {
        if (result.isFailure()) {
            Toast.makeText(getApplicationContext(), "Failed to make purchase.", Toast.LENGTH_LONG).show();
            return;
        }
        else if (purchase.getSku().equals(ITEM_SKU)) {
            consumeItem();
        }

    }
};

Does anyone know how I can fix the problem?
Here is the rest of the code:
    Preference removeAds = (Preference) findPreference("inAppBilling");
        removeAds.setOnPreferenceClickListener(new OnPreferenceClickListener() {
            public boolean onPreferenceClick(Preference preference) {

                mHelper.launchPurchaseFlow(About.this, ITEM_SKU, 10001, mPurchaseFinishedListener, "mypurchasetoken");

                return true;
            }
    });

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data)
    {
        if (!mHelper.handleActivityResult(requestCode, resultCode, data)) {
            super.onActivityResult(requestCode, resultCode, data);
        }
    }

    IabHelper.OnIabPurchaseFinishedListener mPurchaseFinishedListener = new IabHelper.OnIabPurchaseFinishedListener() {
        public void onIabPurchaseFinished(IabResult result, Purchase purchase)
        {
            if (result.isFailure()) {
                Toast.makeText(getApplicationContext(), "Failed to make purchase.", Toast.LENGTH_LONG).show();
                return;
            }
            else if (purchase.getSku().equals(ITEM_SKU)) {
                consumeItem();
            }

        }
    };

    public void consumeItem() {
        mHelper.queryInventoryAsync(mReceivedInventoryListener);
    }

    IabHelper.QueryInventoryFinishedListener mReceivedInventoryListener = new IabHelper.QueryInventoryFinishedListener() {
        public void onQueryInventoryFinished(IabResult result, Inventory inventory) {
            if (result.isFailure()) {
                // Handle failure
            } else {
                mHelper.consumeAsync(inventory.getPurchase(ITEM_SKU), mConsumeFinishedListener);
            }
        }
    };

    IabHelper.OnConsumeFinishedListener mConsumeFinishedListener = new IabHelper.OnConsumeFinishedListener() {
        public void onConsumeFinished(Purchase purchase, IabResult result) {
            if (result.isSuccess()) {
                CustomAlerts.showBasicAlert("Thanks", "We appreciate your support.", About.this);
            } else {
                // handle error
            }
        }
    };

    @Override
    public void onDestroy() {
        super.onDestroy();
        if (mHelper != null) mHelper.dispose();
        mHelper = null;
    }

A: You need to query the users inventory on app start. If there are any purchased but not yet redeemed products in it, you can just redeem them at this point. Here's the docu for retrieving it.


text:
Q: Vis.js timline not rendering in Meteor.js application I'm trying to include the vis.js library into my Meteor application. I have the library included and I'm rendering the page without errors, however, the vis.js timeline is rendering with only horizontal lines, and no objects.
I am definitely populating my dataset as I have confirmed it via console.
Here is my code.
Template.events_timeline.rendered = function () {
  drawTimeline();
};

function drawTimeline(){
  var container = document.getElementById('timeline');
  var event = Events.find();

  if (event.count() === 0) {
    console.log('found no events');
    return;
  }
  data = new vis.DataSet({
    type: { start: 'ISODate', end: 'ISODate' }
  });

  var i = 1;
  event.forEach(function (ev) {
    data.add([{id: i, content: ev.content, start: ev.startDate, end: ev.endDate}]);
    i++;
  });

  // Configuration for the Timeline
  var options = {};

  // Create a Timeline
  var timeline = new vis.Timeline(container, data, options);
}

My template is as follows. Very basic.
<template name="events_timeline">

</template>

Result.
http://i.imgur.com/k2HyQb5.jpg
I was able to get the graph to render with data on it's own with the above code and some changes to the router, but I cannot seem to get the chart to work when embedding the chart template in, for example, a layout template.
The following router changes renders the chart correctly, with data from the Events collection.
this.route('events_timeline', {
    path: '/timeline',
    waitOn: function() {
      return Meteor.subscribe('events');
    },
    notFoundTemplate:'data_not_found',
    action: function() {
      if(this.ready()) {
        this.setLayout('events_timeline');
        this.render();
      } else {
        this.setLayout('loading');
        this.render('loading');
      }
    }
  });

If I replace ...
this.setLayout('events_timeline');

... With ...
this.setLayout('layout');

... Then I still get the blank chart.
I think I'm missing something with how to correctly waitOn the data for a specific template.


text:
Q: Jmeter - running the exact number of requests within an hour with the highest defined concurrency I have a task to run the exact number of requests within an hour, with a given maximum number of concurrency, how do i design that with Jmeter?
For example:
Total number of request: 1000
Run time: 60 mins
Max Concurrency: 15

Meaning my script needs to reach the maximum of 15 requests at the same time at least once, and the rest can be distributed unevenly throughout an hour, and it needs to finish 1000 requests within an hour.
Thank you

A: *

*You can set the hard limit on the number of requests which JMeter will execute by using Throughput Controller in "Total Executions" mode

*You can slow down JMeter's number of requests per minute by using Constant Throughput Timer. If you need to execute 1000 requests in 60 minutes you need to run 16.6 requests per minute, in this case they will be evenly distributed.

If your workload patterns are more complex consider using Throughput Shaping Timer


text:
Q: Embedding app.config: working only in release, not in debug In order to have neater app distribution I have made app.config file to be embedded resource, since it only contains default values. However, the app now cannot be debugged, it throws an exception (ConfigurationErrorException). But when released, the app runs fine. Is there any way how to get it working in the debug time too? Thanks

A: I hope you are aware of the fact that this is not the intended behaviour? How do you extract the app.config at runtime? How do you get the values from the settings? The app.config file is not distributed as "app.config", but as "yourprogramname.exe.config". Which one do you embed?
If you embed the config file, you have no way of changing values. Why do you use the config file instead of hardcoding the values?
When you say that the app runs fine when you release-build it: I'm pretty sure that the values are not taken from the config file, but from the default values of the Settings class.
To make a long story short: I doubt that your approach will work.


text:
Q: PHP taking a long time to resolve hostnames we're seeing a very odd issue with PHP taking a very long to resolve any hostname, which happens randomly every 5-10 attempts. We have used the following script to check it out...
<?php

$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$starttime = $mtime;

$host = "google.com";
echo "looking up ".$host."
";
$ip = gethostbyname($host)
//$ip = rtrim(`/usr/bin/dig $host A +short | /usr/bin/tail -1`);
echo "IP = " . $ip . "
";

$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$endtime = $mtime;
$totaltime = ($endtime - $starttime);
echo "
Total Time: ".$totaltime." seconds";

?>

To look up google.com is mostly taking milliseconds, but one in 5-10 attempts it will take 10-15 seconds! We see the same behaviour for any domain name. The commented out line uses dig from the command line to resolve, when this is used instead we see no issue. This is all very weird as they are using the same resolver. We have run this PHP script from the command line to take apache out of the equation too - same result, so it seems to be purely a PHP issue.
The PHP docs say the gethostbyname() function can take up to 4 seconds - we're seeing considerably longer than this. We don't actually use this function - the real problem we have is with cURL calls timing out due to not being able to resolve the hostname. The script above is purely to assess whether we have a resolving problem in PHP, which we do!
At a total loss atm - googling has turned up very little. Even pointers to where we might start the investigation would be greatly appreciated.
Thanks.

A: I would start with looking at where your DNS is resolving, where is the DNS currently pointed on your server?  Maybe try changing it to one of the public DNS servers (8.8.8.8 or 4.2.2.2) and see if you experience the same issues.


text:
Q: Cannot get Ubuntu 22.04 to connect Canon Pixma G3501 printer The printer worked well with Ubuntu 21.10 but the same settings do not work with Ubuntu 22.04.
I have tried to compile the Canon driver for Linux 64bit but the make command gives the following error "/usr/bin/ld: cannot find -lcnbpcnclapicom2: No such file or directory".
Can anyone help?


text:
Q: Why isn't my Minecraft detect command working when executed by a command block? I now have this command:

/execute @a ~ ~ ~ detect ~ ~-1 ~ minecraft:sandstone 0 effect @a[c=1] minecraft:slowness 2 1

When I run this from the chat it works fine, it gives me slowness when I stand on sandstone and no slowness when I don't. but when I run this from a command block, it says

Failed to execute 'detect' as [my name]

Why is this? Why won't my command work when executed by a command block?

A: As Fabian commented, use @s target selector, instead of the @a[c=1].  This target selector selects the entity executing the command.  You are using the execute command so this would select the player that has sandstone beneath them.

This 'error' is indicating that the detect portion did not detect sandstone below the player.
It will say this every time it executes and it does not detect sandstone, I am standing on stone here:
Exact same command while standing on sandstone, no error and I have slowness:


text:
Q: DataGridComboBoxColumn binding issues in WPF MVVM application I have a custom WPF MVVM (Prism) application I'm developing and am having some trouble with ComboBox bindings within a DataGrid.  I have seen others with similar problems, but nothing quite the same and I cannot get any of the answers to work 100% for my situation.
For this particular view, I am representing a parent-child relationship.  When displaying the form, I am displaying the parent info on top in a basic Grid and those bindings work fine.  Below that is a DataGrid with 1:many items related to that parent record.  It's pretty simple - just a TextBox representing Display Order, then a ComboBox holding a Statistic Type value.  The ComboBox is bound to an ObservableCollection and I can get it to display those values properly; however, I am not able to get it to select the correct value for the given record.  I am able to display the correct value in a TextBox, so I know the values are correct, I just can't get the right bindings on the ComboBox.
Here's the pertinent code:
View:
<DataGrid AutoGenerateColumns="false" Name="DataGridStatistics" Width="900"
          ItemsSource="{Binding Path=DspTemplateStats, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
                  >
    <DataGrid.Columns>
        <DataGridTextColumn Header="Display Order" Width="100"
                            Binding="{Binding Path=DisplayOrder, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" />
        <!-- This is where the issue is.  It is displaying the StatisticTypeName properly in the combobox, but it is not connecting the StatisticId
        from the DspTemplateStats collection to the StatisticTypes collection -->
        <DataGridComboBoxColumn Header="Statistic Type 2"
                                SelectedValueBinding="{Binding RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}, Path=DataContext.StatisticId}"
                                SelectedValuePath="StatisticId"
                                DisplayMemberPath="StatisticTypeName"
                                >
             <DataGridComboBoxColumn.ElementStyle>
                 <Style TargetType="ComboBox">
                     <Setter Property="ItemsSource" Value="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DataGrid}}, Path=DataContext.StatisticTypes}"/>
                 </Style>
             </DataGridComboBoxColumn.ElementStyle>
             <DataGridComboBoxColumn.EditingElementStyle>
                 <Style TargetType="ComboBox">
                     <Setter Property="ItemsSource" Value="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DataGrid}}, Path=DataContext.StatisticTypes}"/>
                     </Style>
             </DataGridComboBoxColumn.EditingElementStyle>
         </DataGridComboBoxColumn>
         <!-- This is temporary to test the binding.  It displays the correct value -->
         <DataGridTextColumn Header="Statistic" Width="*" Binding="{Binding Path=StatisticTypeName, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" />
     </DataGrid.Columns>
 </DataGrid>

ViewModel
// This is how DspTemplateStats is defined, populated from Stored Procedure
// I pass it the ProejctTemplateId and it retrieves all the Statistics associated with it
private ObservableCollection<ProjectTemplateStat> dspTemplateStats;
public ObservableCollection<ProjectTemplateStat> DspTemplateStats
{
    get { return dspTemplateStats; }
    set
    {
        dspTemplateStats = value;
        OnPropertyChanged("DspTemplateStats");
    }
}

// This is how StatisticTypes is defined, populated from Stored Procedure
// It pulls back all StatisticTypes defined in the database
private ObservableCollection<StatisticType> statisticTypes;
public ObservableCollection<StatisticType> StatisticTypes
{
    get { return statisticTypes; }
    set
    {
        statisticTypes = value;
        OnPropertyChanged("StatisticTypes");
    }
}

And the key Models
public class ProjectTemplateStat
{
    public int ProjectTemplateId { get; set; }
    public int TemplateStatId { get; set; }
    public int StatisticId { get; set; }
    public string TemplateName { get; set; }
    public string StatisticTypeName { get; set; }
    public int DisplayOrder { get; set; }
}

// The match should between StatisticType.StatisticTypeId and ProjectTemplateStat.StatisticId
public class StatisticType
{
    public int StatisticTypeId { get; set; }
    public int UOMId { get; set; }
    public string UOMValue { get; set; }
    public int DatatypeId { get; set; }
    ...
}

I feel like the issue is on the DataGridComboBoxColumn bindings, but cannot seem to figure out what I'm missing.  Thanks for any insight.

A: Property used for SelectedValueBinding would be a custom property(place-holder) to get the value chosen by the user. You are using same property for SelectedValuePath and SelectedValueBinding, which is meaningless.


text:
Q: Different emails for different firebase users Flutter I have 2 kinds of users.

*

*Admin.

*User.

And there are 2 registrations.
After registration, you will receive a confirmation email. How to make a different email structure for different users?
For example:
Hello Admin, please confirm your email.
and for the user:
Hi User, please verify your email.

A: The built-in email verification feature if Firebase Authentication uses a single email template for all users and doesn't allow customization of the content of the email.
If you want to send different emails to different types of users, you'll have to take control of the entire verification process. Once you've verified the email address, you can use the Admin SDK to set the emailVerified flag of the user.


text:
Q: how to restrict user to uninstall application from android mobile I want to develop an application which will not uninstall from mobile without authentication  if there is any solution regarding this feature please give me any solution.
Waiting for reply.

A: You need to push your apk to /system/app.
To do that you need to root your device.
Just have a look: http://www.addictivetips.com/mobile/how-to-install-any-app-as-system-app-on-android/

A: You can't do that. If you could it would be a security breach.


text:
Q: Tools to Swap Equations in Code I know this might be trivial to some but when programming say in c# and you have a very large data structure. I usually do assignment via equation for setting value in control and then later do it the reverse way.
Control1.Text = data.value1;
Control2.SelectedValue = data.value2;

Reverse:
data.value1 = Control1.Text;
data.value2 = Control2.SelectedValue;

I was wondering if there is a tool to do this quickly. This is to assume that you have a very large set of values.

A: ReSharper 4.5 supports this; select the lines, hit Alt+Enter, and choose Reverse assignments.

A: You could use Visual Studio Find & Replace to perform the swap. Here's a regular expression pair that will perform the replacement automatically:
Find: ^{:b*}{([^=]+)} += +{([^=]+)};
Replace: \1\3 = \2;
Remember to turn on regular expressions. This will do exactly what you are asking for. This can also be encapsulated into a macro. Here's an example Macro that I put together:
Sub SwapAssignments()
    DTE.Find.Action = vsFindAction.vsFindActionReplaceAll
    DTE.Find.FindWhat = "^{:b*}{([^=]+)} += +{([^=]+)};"
    DTE.Find.ReplaceWith = "\1\3 = \2;"
    DTE.Find.Target = vsFindTarget.vsFindTargetCurrentDocumentFunction
    DTE.Find.MatchCase = False
    DTE.Find.MatchWholeWord = False
    DTE.Find.MatchInHiddenText = True
    DTE.Find.PatternSyntax = vsFindPatternSyntax.vsFindPatternSyntaxRegExpr
    DTE.Find.ResultsLocation = vsFindResultsLocation.vsFindResultsNone
    If (DTE.Find.Execute() = vsFindResult.vsFindResultNotFound) Then
        Throw New System.Exception("vsFindResultNotFound")
    End If
    DTE.Windows.Item("{CF2DDC32-8CAD-11D2-9302-005345000000}").Close()
End Sub

...This will simply swap assignments in the current block.

A: Good old excel comes to rescue.
Paste the statement into cell A1.
Goto cell B1 & paste this formula -
=MID(A1,1,SEARCH(";",A1) - 1)
Goto cell C1 & paste this formula -
=CONCATENATE(TRIM(MID(B1,SEARCH("=",B1)+1, 100)),
   " = ",
   TRIM(LEFT(B1,SEARCH("=",B1)-1)),
   ";")

Paste each of your statement in a separate cell.
cell A1: textBox1.Value = textBox2.Value;
cell A2: textBox2.Value = textBox4.Value;

It relies on a the assumption that the statement ends with semicolon.
At least, it gets you what you need.

A: Found this too: another example, and explanation on how to install it:
http://www.switchonthecode.com/tutorials/how-to-configure-and-use-visual-studio-macros

A: I also saw a tool named MZTools that has a swap assignment in the screenshot.

(source: mztools.com)


text:
Q: Child service data access to other services with Apollo Federation configuration We've been using Apollo Federation for about 1.5 years as our main api. Behind the federation gateway are 6 child graphql services which are all combined at the gateway. This configuration really works excellent when you have a result set of data which spans the different services. E.g. A list of tickets which references the user who purchased and event it is associated with it, etc.
One place we have experienced this breaking down is when a pre-set of data is needed which is already defined in another child service (or across other child services) (resolver/path). There is no way (that has been discovered by us) to query the federation from a child service to get a federated set of data for use by a resolver to work with that data.
For example, say we have a graphql query defined which queries all tickets for an event, and through federation returns the purchaser's data, the event's data and the products data. If I need this data set from a resolver, I would need to make all those queries again myself duplicating dataSource logic and having to match up the data in code.
One crazy thought which came up is to setup apollo-datasource-rest dataSource to make queries against our gateway end point as a dataSource for our resolvers. This way we can request the data we need and let Apollo Federation stitch all the data together as it is designed to do. So instead of the resolver querying the database for all the different pieces of data and then matching them up, we would request the data from our graphql gateway where this query is already defined.
What we are trying to avoid by doing this is having a repeated set of queries in child services to get the details which are already available in (or across) other services.
The question
Is this a really bad idea?
Is it a plausible idea?
Has anyone tried something like this before?

Yes we would have to ensure that there aren't circular dependencies on the resolvers. In our case I see the "dataSource accessing the gateway" utilized in gathering initial data in mutations.

Example of a federated query. In this query, event, allocatedTo, purchasedBy, and product are all types in other services. event is an Event type, allocatedTo and purchasedBy are a Profile type, and product is a Product type. This query provides me with all the data I would use to say, send an email notification to the people in the result set. Though to get this data from a resolver in a mutation to queue up those emails means I need to make many queries and align all the data through code myself instead of using the Gateway/federation which does this already with the already established query. The thought around using apollo-datasource-rest to query our own gateway is get at this data in this form. Not through separate queries and code to align id's etc.
query getRegisteredUsers($eventId: ID!) {
  communications {
    event(eventId: $eventId) {
      registered {
        event {
          name
        }
        isAllocated,
        hasCheckedIn,
        lastUpdatedAt,
        allocatedTo {
          firstName
          lastName
          email
        }
        purchasedBy {
          id
          firstName
          lastName
        }
        product {
          __typename
          ...on Ticket {
            id
            name
          }
        }
      }
    }
  }
}

A: FYI, I didn't quite understand the question until I looked at your edits, which had some examples.

Is this a really bad idea?

In my experience, yes. Not as an idea, as you're in good company with other very smart people who have done this.

Is it a plausible idea?

Absolutely it's plausible, but I don't recommend it.

Has anyone tried something like this before?

Yes, but I hope you don't.

Your Question
Having resolvers make requests back to the Gateway:
I do not recommend this. I've seen this happen, and I've personally worked to help companies out of the mess this takes you into. Circular dependencies are going to happen. Latency is just going to skyrocket as you have more and more hops, TLS handshakes, etc. Do orchestration instead. It feels weird to introduce non-GraphQL, but IMO in the end it's way simpler, faster, and more maintainable than where "just talk to the gateway" takes you.

What then?
When you're dealing with some mutations which require data from across multiple data sources to be able to process a single thing (like sending a transaction email to a person), you have some choices. Something that helped me figure this out was the question "how would I have done this before GraphQL?"

*

*Orchestration: you have a single "orchestration service", which takes the mutation and makes calls (preferably non-GraphQL, so REST, gRPC, Lambda?) to the owner services to collect the data. The orchestration layer does NOT own data, but it can speak with the other services. It's like Federation, but for sending the data into the request, instead of into the response.

*Choreography: you trigger roughly the same thing, but via an event stream. (doesn't work as well with the request / response model of GraphQL)

*CQRS (projections): Copies of database data, used for things like reporting. CQRS is basically "the way you read data doesn't have to be the same as the way you write it", and it allows for things like event-sourced data. If all of your data sources actually share the same database, you don't even need "projections" as much as you would just want a read replica. If you're not at enough scale to do replicas, just skip it and promise never to write data that your current domain doesn't own.

What I Do
Where I work, I have gotten us to:
Queries

*

*queries always start with "one database call".

*if the "one database call" goes to one domain of data (most often true), that query goes into one service, and Federation fills in the leaves of your tree. If you really follow CQRS, this could go the same way as #3, but we don't.

*if your "one database call" needs data from across domains (e.g. get all orders with Product X in it, but sorted by the customer's first name), you need a database projection. Preferably this can be handled by a "reporting service": it doesn't OWN any data, but it READS all data.

Mutations

*

*if your top-level mutation modifies acts only within one domain, the mutation goes in a service, it can use database transactions, and Federation fills in the leaves

*if your mutation is required to write across multiple domains and requires immediate consistency (placing an order with inventory, payments, etc), we chose orchestration to write across multiple services (and roll-back when necessary, since we don't have database transactions to do it for us).

*if your mutation requires data from many places to send further into the request (like sending an email), we chose orchestration to pull from the multiple services and to push that data down. This feels very much like Federation, but in reverse.


text:
Q: How can I find the temporal complexity of this algorithm? fun xpto(n: Int, m: Int): Int {
    return if (n / m == 0) 0 else 1 + xpto(n / m, m)
}

How does m influence the temporal complexity? My first thought was O(n), but I wasn't sure.

A: This function divides the first argument by the second, and uses that quotient again as the first argument for a next call, for as long as this quotient is non-zero. For positive integers, the number of times a recursive call is made is thus equal to the greatest power  such that
       /  >= 1, or
       >=
Hence the number of recursive calls  is
       = ⌊log⌋
This is also the value that the function will return, as with each recursive call 1 is added to the result coming back from recursion.
Time Complexity
Assuming that we can consider division as a constant-time operation, we thus have a time complexity of O(log). The value of  (i.e. the base of the logarithm) is not relevant in big O notation, as it provides an upper bound. Note how for a given value of , an increasing (absolute) value of  will not inccrease the time spent on the algorithm.
However, there are categories of large  and  where where we can lower the asymptotic upper bound. For instance, in the category where  < , the complexity is O(1). For other categories it could be anything else between O(1) and O(log). So for all categories together, we have O(log) as upper bound.
All of the following time complexity expressions are true for the algorithm:

*

*Asymptotic upper bound: O(log)

*Asymptotic lower bound: Ω(1)

*Asymptotic tight bound: ϴ(log)
Negative input
The sign of the arguments is not of influence as the number of recursive calls only depends on the absolute value of both arguments.
If at least one of the arguments is negative we must also assume that integer division (in the actual programming language) will round towards zero, as otherwise the algorithm may get into infinite recursion, always producing a quotient of -1.
Restrictions

*

* should be non-zero, as otherwise there will be a division by zero exception.

*abs() should not be 1, as this will lead to infinite recursion when  is non-zero. See log base 1 of 1 for a related discussion.


text:
Q: Ruby setters and method with parameters I hope you are doing well. I am new with Ruby and I don't really get what is the difference between a setter method and a method with a parameter. For example, let's say I have the following code:
module Popy

  def self.friend
    @friend
  end

  def self.friend=(new_friend)
    @friend = new_friend
  end

end

I understand that with the setter method called friend I set the @friend of Popy. But what is the difference if I put this method?
def self.friend!(new_friend)
  @friend = new_friend
end

I have tried to search this on internet but can't find an answer. Thank you in advance! Have a great day.

A: There is not much difference; the = char is part of the method-name just like the !. Readability is one issue - an exclamation mark is often used to draw attention to the method: "Watch out, something potentially risky is about to happen." I would be disappointed and a bit confused if friend! turned out to be just a setter. Also , the = allows Ruby to throw in some convenience methods like:
Popy.friend = "Ana"
Popy.friend += " maria"
p Popy.friend # => "Ana maria"

A: From a semantic standpoint, there is no difference between a method named foo, a method named bar, a method named friend, a method named friend!, or a method named friend=.
From a syntactic standpoint, though, a method whose name ends with = can be called in a way that looks like assignment. In other words, the difference is in the syntax that can be used to call the methods:
Popy.friend = the_new_friend

Popy.friend!(the_new_friend)

But that is the only difference.
Note that your method named friend! is not idiomatic Ruby: method names ending in a bang (!) are only used when there is a pair of methods with the same name that do "roughly the same thing". In that case, the "more surprising" method of the pair of methods gets the bang.
In your case, you have a pair of methods with the same name (friend). And the one which assigns the instance variable is surely the more surprising. But the thing is: those two methods don't do "roughly the same thing". In fact, they do the exact opposite of each other: one gets a value, the other sets a value.
Therefore, they should be named in a way that it makes it clear that they are opposites.
In a language like Java, the common idiom would be to name them getFriend and setFriend.
But in Ruby, the common idiom is to name them friend and friend=.
Note that Ruby has methods for generating such trivial writers and readers:

*

*Module#attr_reader generates a reader method,

*Module#attr_writer generates a writer method, and

*Module#attr_accessor generates a both a reader and a writer method.

So, the code in your question would most idiomatically be written just as
class << Popy
  attr_accessor :friend
end


text:
Q: How to setup connection via VPN to private AKS I am trying to setup a private AKS cluster which I want to manage from a user laptop using kubectl. I have tried to create a simple setup with one vNET, Azure VPN gateway with OpenVPN configuration, where the VPN Gateway is attached to one subnet of the vNET and AKS is configured via Azure CNI to live in another subnet of the same vNET. I have expected that this is all I would need to get manage the cluster as long as I am connected to the VPN (I understood that all subnets on a vNET are routed by default). But when I try to use kubectl I get Unable to connect to the server: dial tcp: lookup : no such host My network knowledge does not go too deep unfortunately, but should this just work? I mean it all lives within the same vNET. Thank you.

A: My setup is very similar and I ran into the same situation. This was a DNS issue for me.
If you have a private DNS zone with your private AKS cluster (should be in the resource group which was created for the AKS private cluster), go find the DNS record and IP address for the API server. Put that IP address into your hosts file (/etc/hosts if on linux or WSL) with the fully qualified domain name, then try your kubectl commands again.


text:
Q: Part of a proof recurrence relation I'm reading this survey by Carl Offner about digit computation of the number $\pi$.
In page 7 there's a step that I didn't understand:
suppose
$$\alpha_{n+1}=\frac{\alpha_n \beta_n}{\alpha_n + \beta_n}$$
$$\beta_{n+1}=\sqrt{\frac{ \beta_n  \alpha_{n+1}}{2}}$$
and
$$a_n=6\cdot 2^n \alpha_n$$
$$b_n=6\cdot 2^n \beta_n$$
Why it "follows easily" then, that
$$a_{n+1}=\frac{2a_nb_n}{a_n+b_n}$$
$$b_{n+1}=\sqrt{b_na_{n+1}}$$
I've tried computing
$$a_{n+1}=6\cdot 2^{n+1}\alpha_{n+1}$$
and then plugging the expression for $\alpha_{n+1}$ but it doesn't really help.
Thanks for your help!

A: Write $\alpha_n = \frac{a_n}{6\cdot 2^n}$ and $\beta_n = \frac{b_n}{6\cdot 2^n}.$ Then plug them into
$$\alpha_{n+1}=\frac{\alpha_n \beta_n}{\alpha_n + \beta_n}$$
Get
$$\frac{a_{n+1}}{6\cdot 2^{n+1}}=\frac{\frac{a_n}{6\cdot 2^n} \frac{b_n}{6\cdot 2^n}}{\frac{a_n}{6\cdot 2^n} + \frac{b_n}{6\cdot 2^n}} = \frac{a_n b_n }{a_n+b_n} / 6\cdot 2^n$$
So
$$a_{n+1}=\frac{2a_nb_n}{a_n+b_n}.$$
Same thing for the second equation.


text:
Q: Плавная прокрутка блоков новостей, нужно сделать плавное прокручивание новостей вправо, 3 новости в ряд.

Как это организовать ?

              <?php foreach ($countries as $country): ?>

                      <?= $country->title ?>

                    <p1>

                        <?= $country->text ?>

                    </p1>

                  <?= Html::a('Читать далее',
                                            ['country/info', 'id' => $country->id]); ?>

28.11.2018

              <?php endforeach; ?>

A: Вам нужно смотреть в сторону carousel, например как тут - https://bootsnipp.com/snippets/featured/carousel-product-cart-slider, и уже адаптировать под свои потребности.
Можно, конечно, изобретать велосипед, но зачем?


text:
Q: hide and show button when check box clicked i want code en eclipse android when i clicked checkbox i want to show hidden button
i'm beginner in android so please help me :(
this is my xml code :
<CheckBox
    android:id="@+id/CB1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:layout_marginTop="19dp"
    android:fontFamily="Segoe UI"
    android:text="I Want To Select A Favorite Station And Receive Notification."
    android:textStyle="bold" />

A: CheckBox checkBox = (CheckBox)findViewById(R.id.CB1);
checkbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {

btn.setVisibility(View.GONE);//TO HIDE THE BUTTON
btn.setVisibility(View.VISIBLE);//TO SHOW THE BUTTON
    }
});

where btn is your button.

A: Reference the checkbox in your Activity and set an OnCheckedChangeListener:
CheckBox checkBox = (CheckBox)findViewById(R.id.CB1);
checkbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {

    // do whatever

    }
});


text:
Q: "[Error] pointer value used where a floating point value was expected" How to solve this error? my code is Below
I want convert Fahrenheit to degree Celsius in the following code but i am getting error does anybody know how to tackle with this error ?
#include <stdio.h>
int main()
{
    int frnhet[]={0,20,40,60,80,100,120,140,160,180,200,220,240,260,280,300};
    double celcius;
    int i;
    for(i=0;i<16;i++)
        {
      celcius = ((float)(5/9) + (float)(frnhet-32));
        printf("celcius = %f",celcius);
       }
     return 0;
 }

A: Your error is here:
celcius = ((float)(5/9) + (float)(frnhet-32));

it must be frnhet[i] since frnhet is an array
celcius = ((float)(5 / 9) + (float)(frnhet[i] - 32));

A: You missed index to frnhet in code. Please refer following code -
#include <stdio.h>

    int main()
    {
        int frnhet[]={0,20,40,60,80,100,120,140,160,180,200,220,240,260,280,300};
        double celcius;
        int i;
        for(i=0;i<16;i++)
            {
          celcius = ((float)(5/9) + (float)(frnhet[i]-32));
            printf("celcius = %f",celcius);
           }
         return 0;
     }

A: frnhet is an array and in the expression frnhet-32 it will convert to pointer to its first element. Change frnhet-32 to frnhet[i]-32.
celcius = (5.0/9 + frnhet[i]-32);

A: Please change line
celcius = ((float)(5/9) + (float)(frnhet-32));

To
celcius = ((float)(5/9) + (float)(frnhet[i]-32));

you missed the index to access frnht array

A: #include <stdio.h>
int main()
{
    int frnhet[]={0,20,40,60,80,100,120,140,160,180,200,220,240,260,280,300};
    double celcius;
    int i;
    for(i=0;i<16;i++)
        {
      celcius = ((float)(5/9) + (float)(frnhet[i]-32));
        printf("celcius = %f",celcius);
       }
     return 0;
 }

In celcius = ((float)(5/9) + (float)(frnhet-32)); you are passing pointer where it is excepting float value. for passing value use celcius = ((float)(5/9) + (float)(frnhet[i]-32));


text:
Q: Java sticky instances of class com.mysql.jdbc.Field aggregating I recently noticed (via jmap+jhat) that my App was leaking storing many instances com.mysql.jdbc.Field class
- I double checked my code to make sure I was closing all PreparedStatements, find a few missing but it didn't change the outcome.
- Some PreparedStatement are created and closed right away
- Several others are created at start up and reused many times
- I am using org.apache.tomcat.jdbc.pool.DataSource as connection pool

What can cause this type of behavior?

A: Are you closing all of your preparedstatements / result sets using:
PreparedStatement stmt (possible assignment here);
try
{
 // do all work with prepared statement
 ResultSet rs;
 try
 {
   while (rs.next()) ...
   // process results
 }
 finally
 {
   rs.close();
 }
}
finally
{
  stmt.close();
}

So that you guarantee all result sets are closed when finished (regardless of exceptions) and all statements are closed (regardless of exceptions)? Obviously there are other ways to write that, but the idea is the same.
If you're doing all of that properly, then unless you have so many references that it's taking up an inordinate amount of memory, it's almost certainly OK and nothing needs to be done about it.


text:
Q: Should Publish work with MassTransit's Mediator? The Send method works with Mediator, but not the Publish method. Nothing is received by consumers.
Is that on purpose? Is it expected in a later version?

A: Publish should work, but I just realized that it throws a NullReferenceException if there isn't a pipe specified. That's a bug, I've found and fixed it. Issue


text:
Q: undefined local variable or method (NameError) This code:
def convert(temp)
  new_temp = (temp - 32) * 5/9
  return new_temp
end

fahrenheit_temp = gets.to_i
celsius_temp = convert(fahrenheit_temp)
puts celsius_temp

raises:
C:/Users/Asd/Documents/Aptana Studio 3 Workspace/test/test.rb:3:in `convert': undefined local variable or method `new_temp' for main:Object (NameError)
from C:/Users/Asd/Documents/Aptana Studio 3 Workspace/test/test.rb:7:in `<main>

Is there any help? I don't understand why the return method causes this problem.

A: It work fine for me. I use this command line:
ruby test.rb

You can try again ?


text:
Q: Python 2.5 fails on a datetime.strptime format I have seen several questions with people asking about the same problem but none of the answers are helping me.
I'm receiving this error:
    pydev debugger: starting
Traceback (most recent call last):
>>>
  File "/usr/local/zend/apache2/htdocs/pyth/src/conn.py", line 23, in <module>
    userConnDate = datetime.strptime(data[1] + ' ' + data[2], "%y-%m-%d %H:%M:%S")
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/_strptime.py", line 330, in strptime
    (data_string, format))
ValueError: time data did not match format:  data=2010-03-11 08:35:25  fmt=%y-%m-%d %H:%M:%S

It looks fine to me, what is python seeing that I don't?
Thanks for you time.

A: you are using %y (which matches a 2 digit year).
try with %Y, which matches a 4 digit year (like your 2010)

A: Try using the a capital Y - '%Y' to match a 4-digit year.