Why is there no 4-player pre-made group on Flex Queue?

Question: In the current season, there is a 'Flex Queue' which allows you to queue to a ranked game with 1, 2, 3 or 5 player pre-made groups. Why is a 4-player pre-made group not available?
Comment: That's a question only the developers can answer.
Comment: If only a developer can answer a question, we don't allow it. Whether they actually *have* answered it is immaterial.
Comment: @DanmakuGrazer FYI, there used to be a 4-player premade which was removed this season. I am looking for past announcements which might have touched up on the subject.
Comment: You're saying yourself that it's a question only the developers can answer.
Comment: I am saying there would have been some communication when a feature in the game was removed in a later update. I am looking for this communication, if there was any.
Comment: Looking at the answer given, it seems like people other than devs can answer using logic.
Comment: It's a shame that this question was marked as off-topic, as it is not. It's a very simple to answer question, it's a group ranked mode, if groups of 4 existed, there would be a solo player, which isn't group mode anymore.
Answer: Four-man premades are disabled in Flex queue because a solo-player would have to fill the last position. The 4-man group would have peer-pressure and would be able to bully the solo player into picking a role they may not want. Because the solo player is the odd man out, they usually also end up as a scapegoat if things start going wrong in game, and the 4-man group harasses the solo player in retribution.
Another reason is that Flex queue is meant to be played in groups of more than one person. If 4-man groups were allowed, that would implicitly encourage solo-players to join Flex queue in order to fill those extra slots.


Can't find a way to approximate $R_n(x)$ of this series of functions.

Question: In this question, the solver depended on a way I didn't use to solve in.
I thought of finding a bound for $|R_n(x)|$ that's going to $0$ in order to prove the uniform convergence. But I always find a problem dealing with $(-1)^n$. I think of using the fact that in alternating convergent series, the first term dominates.
$|R_n(x)| = |\sum_{k=n+1}^\infty (-1)^k\frac{x^2 + k}{k^2}| \leq |(-1)^{n+1}\frac{x^2+n+1}{(n+1)^2}|= \frac{x^2+n+1}{(n+1)^2}$ but then,
$|R_n(n)| \leq  \frac{n^2+n+1}{(n+1)^2} \longrightarrow 1$ not $0$. So for sure I'm doing mistakes in estimating, since the answer is "uniformly convergent".
Guys, I'm just a beginner, you can call me a self learner. Please help me as I feel I won't be good at such problems :(
Answer: We observe that $S:=\displaystyle\sum_{k=1}^{\infty} (-1)^k\frac{x^2 + k}{k^2}$ is an alternating series.
We put
$\displaystyle\ S_n(x)=\sum_{k=1}^{n} (-1)^k\frac{x^2 + k}{k^2},$ and
$b_n=\frac{x^2 + n}{n^2}.$
We have:
(i) $\left\{b_n\right\}$ is a decreasing sequence.
$S_{2n+1}<S_{2n}, S_{2n+2}=S_{2n}+b_{2n+1}-b_{2n}<S_{2n}$, and
$S_{2n+3}=S_{2n+1}+b_{2n+2}-b_{2n+3}>S_{2n+1}.$
Therefore, $S_{2n+1}<S<S_{2n}.$
$|R_{2n+1}(x)|<S_{2n}(x)-S_{2n+1}(x)=\frac{x^2 + (2n+1)}{(2n+1)^2}.$
Similarly, we obtain an evaluation for $|R_{2n+1}(x)|.$


How to show mounted partition in devices list

Question: How to show the mounted disk in devices list, my disk is mounted on /media
Here is the screen shot.
Comment: why not edit /etc/fstab... make sure you use UUID instead of /dev/sda sdb if you have multiple hdds.
Comment: where should I put UUID, can you please put the exact entry
Comment: Which mounted partitions doesn't show there? Could you give us the output of mounted partitions? Use `lsblk` or `df` (friendler thand `findmnt`, `mount` or `cat /proc/mounts`)
Answer: First you need to make folder in /media ex. /media/Data then you can mount it to folder you've created before by using command :
<code># mount /dev/sda /media/Data
</code>
Now your mounted disk should appear in device list.
Comment: Maybe you mean `/media/$USER/...`, where `$USER` is your username? BTW, there are [better ways to mount](https://askubuntu.com/questions/342188/how-to-auto-mount-from-command-line)


Show that $\det(xA+yB+zI_{n})=\det(yA+xB+zI_{n})$

Question: We have $A$ and $B$ $(n×n)$ matrices with complex entries. We know that $A-B=AB-BA$. Show that $$\det(xA+yB+zI_{n})=\det(yA+xB+zI_{n})$$
for every $x,y,z$ complex numbers with $x+y≠0$.
We can see that $\operatorname{Tr}(A)=\operatorname{Tr}(B)$. I tried to suppose $A$ or $B$ are invertible and try changing $A-B=AB-BA$ somehow, but I dont know if that helps. We can also see that $$\operatorname{Tr}(xA+yB)=\operatorname{Tr}(yA+xB)=(x+y)\operatorname{Tr}(A).$$ The conclusion looks like we need to show that $f(x,y)=f(y,x)$. Maybe some calculus and we can use the continuity of polynomial functions? I also minded calculating the determinants using polynomial forms.
Comment: I think this question had been asked before, but I cannot find the duplicate. Essentially, if you put $N=A-B$, then $N=[N,B]$. Therefore $[N,B]$ is nilpotent, by Jacobson's lemma. Hence $N$ is nilpotent. Then it should be possible to use a subspace chain argument to show that $N$ and $B$ are simultaneously triangulable. Therefore $\det((x+y)B+tN+zI)$ does not depend on $t$ and the result follows immediately.
Comment: Another approach: by proposition 1.5 of Gerald Bourgeois, *Pair of matrices, one of which commutes with their commutator*, Electronic J. Lin. Alg., vol. 22, pp.593-597, June 2011, if $[X,[X,Y]]=0$, then the pair of matrices $Y$ and $[X,Y]$ has Taussky's property L. In your case, by putting $X=N$ and $Y=B$, we see that $(N,B)$ has property L. Hence the result.
Comment: You can use characteristic polynom (with $z$ instead of $-z$ it changes nothing) :

$$ \det(xA+yB+zI_n)=\chi_{xA+yB}(z)$$
Comment: @user1551 do I need to prove the propriety L in contest conditions?
Comment: @user1551 Yes. Another thing about this problem: can we show that xA+yB and yB+xA are similar?
Comment: If this is a contest question, I think the contestants are not even expected to *know* property L, let alone to *prove* it or to prove that some pairs of matrices satisfy it.
Answer: From the given condition, we get $N=[N,B]$ where $N=A-B$. Therefore $[N,B]$ is nilpotent, by Jacobson's lemma. Hence $N$ is nilpotent, because it is equal to $[N,B]$. (One may also use prove this result without Jacobson's lemma. See Aphelli's comment below.) Now rewrite $N=[N,B]$ as
$$
NB=(B+I)N.
$$
It follows that $NB\ker(N)=(B+I)N\ker(N)=0$. That is, $B\ker(N)\subseteq\ker(N)$. We may then prove by mathematical induction that $B\ker(N^k)\subseteq\ker(N^k)$ for every $k\ge1$:
$$
\begin{aligned}
N^{k+1}B\ker(N^{k+1})
&=N^kNB\ker(N^{k+1})\\
&=N^k(B+I)N\ker(N^{k+1})\\
&\subseteq N^k(B+I)\ker(N^k)\\
&\subseteq N^kB\ker(N^k)+N^k\ker(N^k)\\
&\subseteq N^k\ker(N^k)+N^k\ker(N^k)\\
&=0.
\end{aligned}
$$
Let $m$ be the index of nilpotence of $N$. Then $\ker(N)\subseteq\ker(N^2)\subseteq\cdots\subseteq\ker(N^{m-1})=\mathbb C^n$. Let $n_k=\operatorname{nullity}(N^k)$. Extend a basis $\{v_1,v_2,\ldots,v_{n_1}\}$ of $\ker(N)$ to a basis of $\{v_1,v_2,\ldots,v_{n_2}\}$ of $\ker(N^2)$ and so on until we obtain a basis $\mathscr B=\{v_1,v_2,\ldots,v_n\}$ of $\mathbb C^n$ such that $\{v_1,v_2,\ldots,v_{n_k}\}$ is a basis of $\ker(N^k)$ for each $k\in\{1,2,\ldots,m-1\}$.
If we change the basis from the standard basis to $\mathscr B$, $B$ becomes a block triangular matrix and $N$ becomes a strictly block-upper triangular matrix. So, if we further triangularise each diagonal sub-block of $B$ (which leaves the corresponding diagonal sub-block of $N$ unchanged because it is zero), then $B$ and $N$ become simultaneously triangularised. Therefore $\det(sB+tN+zI)$ does not depend on $t$. In particular, we have $\det((x+y)B+xN+zI)=\det((x+y)B+yN+zI)$, i.e., $\det(xA+yB+zI)=\det(yA+xB+zI)$.
Comment: @StefanSolomon: so what you want to show is that, given that $YX-XY=Y$, $\det(aX+bY+zI)$ is an even function of $b$. So it's enough (up to adding a multiple of the identity to $X$, and using continuity) to show that $\det(aX+bY)=\det(aX-bY)$ assuming $X$ is invertible. But $\det(aX+bY)=b^n\det(X)\det(a/b\cdot I_n+X^{-1}Y)$. So we need to show that the characteristic polynomial of $X^{-1}Y$ has the same parity as that of $n$, so it's enough to show that $X^{-1}Y$ is nilpotent. Well, $(X^{-1}Y)X-X(X^{-1}Y)=X^{-1}(YX)-X^{-1}(XY)=X^{-1}Y$, which concludes.
Comment: You're assuming the conclusion to prove that $N$ is nilpotent, though, if I'm not mistaken. This part of the argument can be rescued by noting that since $N=NB-BN$, by induction $kN^k=N^kB-BN^k$, so that if $N$ isn't nilpotent, $X \longmapsto XB-BX$ has infinitely many eigenvalues (or every power of $N$ has trace zero, therefore $N$ is nilpotent).
Comment: x+y≠0 so we cant put x=1 and y=-1 no?
Comment: @Aphelli Oh, I see what you meant now. Yes, you are absolutely right.
Comment: @StefanSolomon As mentioned by Aphelli, I should not have substituted anything into $x$ and $y$, as the statement determinant is what we want to prove rather than a given condition. But your question was posted long ago and I had not re-read your question carefully when I wrote my answer an hour ago. Anyway, whether $x+y=0$ is unimportant, as determinant is continuous in matrix entries. If equality holds for a dense set of $(x,y)$, it holds for all $(x,y)$.
Comment: @user1551 If I write $A=X+Y$ and $B=X-Y$ then $Y=YX-XY$ so $Y$ and $YX-XY$ are nilpotent. So $det(xA+yB+zI)=det((x+y)X+(x-y)Y+zI)$ and $det(yA+xB+zI)=det((x+y)X+(y-x)Y+zI)$. Now let $C=(x+y)X$ and $D=(x-y)Y$. We will need now to prove that $det(C+D+zI)=det(C-D+zI)$. I think this is an alternate way to do this problem but I dont really know how to finish. And the condition $x+y≠0$ tells us that $C$ is non-zero matrix if $X$ is non zero. How I can show that using the fact that $Y=YX-XY$ ?
Comment: @StefanSolomon Sorry, I have no idea.
Comment: @Aphelli I dont really understand the part when you assume that $X$ is invertible. Can't we take $X$ as a limit of a sequence of invertible matrices?
Comment: That's exactly what I'm doing. If the result is true for invertible $X$, then for any $X$, we can take a sequence of invertible matrices converging to $X$. The result holds for every matrix in the sequence, so holds for the limit.
Comment: @Aphelli sorry, can you explain showing $det(aX+bY)=det(aX-bY)$ implies $det(aX+bY+zI)=det(aX-bY+zI)$?
Answer: I'm making this an answer to flesh out the approach hinted by the post author and that I completed.
Write $A=X+Y$, $B=X-Y$, then $2(YX-XY)=AB-BA=2Y$ so $Y=YX-XY$.
Moreover, for any $x,y,z \in \mathbb{C}$, $xA+yB+zI_n=(x+y)X+(x-y)Y+zI_n$. Thus the problem is solved if we can prove that $\det(aX+bY+cI_n)$ is an even function of $b$.
Note that it's enough to show, by continuity of the determinant, that for any $a \neq 0$ and any $c$ such that $X'=X+c/a I_n$ is invertible, that the function $b \longmapsto \det(aX+bY+cI_n)$ is even.
But for such $a,c$, $\det(aX+bY+cI_n)=\det(aX'+bY)=\det(X')\det(aI_n+b(X')^{-1}Y)$. This is an even function of $b$ (constant, in fact) as long as $Z=(X')^{-1}Y$ is nilpotent.
Now, note that $YX'-X'Y=Y$: this implies (formally) that $ZX'-X'Z=Z$.
It is then standard to show that $Z$ is nilpotent. For instance, you can show by induction on $k$ that $Z^kX'-X'Z^k=kZ^k$: in particular, if $Z$ is not nilpotent, every $k \geq 1$ is an eigenvalue of the endomorphism $T \longmapsto TX'-X'T$, which is impossible since we're in finite dimension.
Comment: Please accept user1551's answer instead, it was the earlier one and I wouldn't have found this if it weren't for their solution.


Can anyone help me how to access a data from an fla file to another fla file?

Question: Can anyone help me how to access a data from an fla file to another fla file?
I have a starting fla file called "savescore.fla" which is connected to the class called "score.as".I have a "btnAdd" button that if clicked, it will add by one to the variable "scoring" in the class "score.as". I have also a movieclip "btnSave" that would save the score. Lastly, I have a "next_btn" button that would go directly to my another fla file
which is "finalscore.fla". I wanted the "finalscore.fla" to show the current "scoring" variable from the "score.as" class but the problem is that it will only show 0/zero as the score. I think that as "savescore.fla" saves and edits the variable in the "score.as", it will only make changes to itself and not to the "score.as" that's why I still got 0 as the final score because it comes from the "score.as" and not from "savescore.fla". So I was thinking if I could just access the score from the "savescore.fla", it would solve the problem. But I have no idea what codes to put...or can you give me another way?
Here are the codes: (Btw, I am using actionscript 3.0)
savescore.fla:
var lol:score = new score();

var saveDataObject:SharedObject;
//var currentScore:int;

init(); // this line goes directly beneath the variables

function init():void{ // call once to set everything up

     saveDataObject = SharedObject.getLocal("test"); // give the save data a location

     btnAdd.addEventListener(MouseEvent.CLICK, addScore); // clicking on +1
     btnSave.addEventListener(MouseEvent.CLICK, saveData); // clicking on Save
 next_btn.addEventListener(MouseEvent.CLICK, sunod); // clicking on +1

 if(saveDataObject.data.savedScore == null){ // checks if there is save data
      trace("No saved data yet."); // if there isn't any data on the computer...
      saveDataObject.data.savedScore = lol.scoring; // ...set the savedScore to 0

 } else {
      trace("Save data found."); // if we did find data...
      loadData(); // ...load the data
 }

 }

function addScore(e:MouseEvent):void{
     lol.scoring+=1; // add 1 to the score
}

function saveData(e:MouseEvent):void{
     saveDataObject.data.savedScore = lol.scoring; // set the saved score to the current      score
 trace("Data Saved!");
 saveDataObject.flush(); // immediately save to the local drive

 trace(saveDataObject.size); // this will show the size of the save file, in bytes
 trace(lol.GetFullScore());
}

function loadData():void{
     lol.scoring = saveDataObject.data.savedScore; // set the current score to the saved score

 trace("Data Loaded!");
}

function sunod(event:MouseEvent):void{

var ldr:Loader=new Loader();
ldr.load(new URLRequest("finalscore.swf"));
addChild(ldr);
}

score.as:
package{

public class score{

    public var scoring:int;

    function score()
    {

    }

public function SetScore(val:int):void
{
  scoring = val;
}

public function GetFullScore():int
{
  return scoring;
  trace(scoring);
}

    }
}

finalscore.fla:
var lol1:score = new score();

txtScore.text = ("Score: " + lol1.GetFullScore()); // set the text property of the    txtScore

trace(lol1.GetFullScore());

Comment: so are you wanting to send variables from one swf to another?
Comment: Yes..That's exactly what I wanted to do since I can't save the changes in my "score.as" class..
Answer: Once you have loaded an external swf you can grab a reference to it in an onLoadedHandler. So in savescore:
var myReference:Object;

function loadComplete(event:Event):void {

    myReference= event.target.content;

        myReference.lol1.GetFullScore();
... or...
       var myScore = event.target.lol1.GetFullScore();
 etc...

}

you'll want to make sure the reference exists before you use it
EDIT
in your Child SWF create a variable and method to store the parent:
var parentSWF:MovieClip;

function setParent(myParent:MovieClip):void{
    parentSWF = myParent;
}

then in the parent send the child a reference :
function loadComplete(event:Event):void {

    myReference= event.target.content;

        // use the reference to child to call
        // any variables or functions in it
        myReference.lol1.GetFullScore();

        // set the reference in child with the following
        // so that the child can call the parent
        myReference.setParent(this);

}

then in child you can use lol :
 parentSWF.lol;

If you had to go this way you would ideally create measures to check the objects/methods etc exist before they are used
FINAL EDIT
For a start, move
var ldr:Loader=new Loader();

out of the sunod function and put it at the top with the other declaration so that loadcomplete can use it. You need to set up a listener for the loadComplete handler. Put this after your other listeners
ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);

in your loadcomplete handler in savescore add
   myReference.doThisWhenLoaded();

in finalscore put
function doThisWhenLoaded():void{
    txtScore.text = ("Score: " + parentSWF.lol);

}

This just seems complete overkill and I'm sure I've overcomplicated your over complications(!). My advice would be to do away with the second swf and just create a finalscore.as object in savescore. This would be so much easier. At the moment I can't see why you want to have another swf floating around. I've never been a fan of multiple swfs though so someone else may well jump in and correct this.
Comment: Thanks for the reply...but what do I put in "finalscore.fla" in order to access the data from "savescore.fla"?
Comment: What you are trying to do seems quite akward. Why don't you create a class instead of a new swf? If you want to do it with multiple swfs you can pass a reference of the parent to the child..see my edit
Comment: I just tried your "EDIT"..(I decided to use multiple swfs) but I get an error in my "finalscore.fla" saying "cannot access a null object reference...etc." and I think it's because of the parentSWF.lol...am I using the codes properly? sorry for the trouble...I'm really good in actionscript..
Comment: These are my codes with few changes..I just added your code..I didn't make any changes in "score.as"
Comment: Sorry for my comment above: I really meant "I'm not really good in actionscript"..
Comment: Since I can't type all my codes,I'll just tell you what I've done: in "savescore.fla", I added this:    `function loadComplete(event:Event):void {     myReference= event.target.content;     myReference.lol1.GetFullScore();     myReference.setParent(this); }` in my "finalscore.fla", these are my codes:     `var lol1:score = new score();     var parentSWF:MovieClip;     function setParent(myParent:MovieClip):void{     parentSWF = myParent; }     txtScore.text = ("Score: " + parentSWF.lol); // set the text property of the txtScore`
Comment: if you can post the whole thing somewhere I'll have a look. That error occurs when you try and reference somethng that doesn't exist yet.
Comment: I can't type all the codes in the comment box...Can you teach me how to do it just like what you did in your comment above where you were able to comment your codes?
Comment: By the way, I just add your function "loadComplete" into my "savescore.fla" and the variable "parentSWF" & function "setParent" into my "finalscore.fla"...then I replaced my:    `txtScore.text = ("Score: " + lol1.GetFullScore()); ` with `txtScore.text = ("Score: " + parentSWF.lol);`
Comment: I just meant find a file sharing service where I can download all the files you're using. You can also edit your first post
Comment: Thanks..I really appreciate your reply..if I can't pull this through, I'll be giving up this method and maybe start by using your advise..
Comment: I am trying to make an educational game which composed of multiple games..I am planning to have an swf for every game that's why I came up with the idea which may not be a good idea after all..any possible method to this one?
Comment: If you do it with multiple SWFs it would be a good idea to read up on using multiple swfs. I would google it and really get your head around it. I would start with help from Adobe http://helpx.adobe.com/flash/kb/load-external-swf-swf.html then move on to some other resources. Plan it out on paper how each swf will need to talk to the other. If each of your child SWFs need to talk to the parent. I would make each SWF standalone then create a globalScore object in your parent and pass a reference to it to each child SWF that each child can then access/read/amend.
Answer: Here's the changes of my code:
savescore.fla:
var lol:score = new score();

var saveDataObject:SharedObject;

init(); // this line goes directly beneath the variables

function init():void{ // call once to set everything up

 saveDataObject = SharedObject.getLocal("test"); // give the save data a location

 btnAdd.addEventListener(MouseEvent.CLICK, addScore); // clicking on +1
 btnSave.addEventListener(MouseEvent.CLICK, saveData); // clicking on Save
 next_btn.addEventListener(MouseEvent.CLICK, sunod); // clicking on +1

 if(saveDataObject.data.savedScore == null){ // checks if there is save data
      trace("No saved data yet."); // if there isn't any data on the computer...
      saveDataObject.data.savedScore = lol.scoring; // ...set the savedScore to 0

 } else {
      trace("Save data found."); // if we did find data...
      loadData(); // ...load the data
 }

}

function addScore(e:MouseEvent):void{
     lol.scoring+=1; // add 1 to the score
}

function saveData(e:MouseEvent):void{
     saveDataObject.data.savedScore = lol.scoring; // set the saved score to the current      score
     trace("Data Saved!");
     saveDataObject.flush(); // immediately save to the local drive

     trace(saveDataObject.size); // this will show the size of the save file, in bytes
     trace(lol.GetFullScore());
}

function loadData():void{
     lol.scoring = saveDataObject.data.savedScore; // set the current score to the saved score
     trace("Data Loaded!");
}

function sunod(event:MouseEvent):void{

var ldr:Loader=new Loader();
ldr.load(new URLRequest("finalscore.swf"));
addChild(ldr);
}

var myReference:Object;

function loadComplete(event:Event):void {

    myReference= event.target.content;

    myReference.lol1.GetFullScore();

    myReference.setParent(this);

}

finalscore.fla:
var lol1:score = new score();
var parentSWF:MovieClip;

txtScore.text = ("Score: " + parentSWF.lol); // this line has the error because of parentSWF.lol

trace(lol1.GetFullScore());

function setParent(myParent:MovieClip):void{
    parentSWF = myParent;
}

score.as:
package{

public class score{

    public var scoring:int;

    function score()
    {

    }

public function SetScore(val:int):void
{
  scoring = val;
}

public function GetFullScore():int
{
  return scoring;
  trace(scoring);
}

 }
}


Is there a command to merge data sets based on observations of a variable?

Question: I'm trying to merge two data sets, depending on the observations of the data sets.
In other words, I have two data sets both containing year and state.
However, the two data sets
consists each of one additional variable, X1 for df1 and X2 for df2. That is, I'm trying to merge the two dataset if a state is observed to a have minimum of 5 observation for both X1 and X2, such that the all observations for that state is included, even when both X1 and X2 are NA values.
Is there a way to merge the data sets to only merge states in which both X1 and X2 has minimum 5 observations?
Such that, the new dataset has observations for all the years of the states that both X1 and X5 has a minimum of 5 observations in. While rest are excluded.
I have tried to use experiment with inner_join(df1,df2) with no success, as it only merges the year and state that both specific dataset has individual observations.
An reproducible example of the merge effect (for simplicity, I have used if 2 observations are non NA, the state is included)
df1 = read.table(
  text =
    "State Year X1
A 1 NA
A 2 NA
A 3 5
A 4 NA
B 1 NA
B 2 NA
B 3 4
B 4 3", header = TRUE)

df2 = read.table(
  text =
    "State Year X2
A 1 NA
A 2 5
A 3 7
A 4 NA
B 1 NA
B 2 2
B 3 5
B 4 7", header = TRUE)

newdf = read.table(
  text =
    "State Year X1 X2
B 1 NA NA
B 2 NA 2
B 3 4 5
B 4 3 7", header = TRUE)

Here, newdf neglect the state A as the df1 only have one observation for that state, while all years are included for the state B (even the first year when both X1 and X2 are NA) as both X1 and X2 has minimum of 2 non-NA observations for that state. (recall, for simplicity here the minimum observation is 2 not 5)
Comment: Please share a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) including a small example of your data used.
Comment: I will try to make a reproducible example and upload it to the original question, but it might be difficult to visualize.
Comment: Updated the original text to include an example, if anything is still unclear, please dont hesitate to ask.
Comment: Perhaps you need `dplyr`s `full_join` instead of an `inner_join`? `full_join(df1, df2, by = c("State", "Year"))`.
Comment: I've tried the full_join command aswell but there is no sortation to the minimum observations. The full_join merges all the observation for all years.
Answer: You need to do further filtering after merging.
library(dplyr)

inner_join(df1, df2, by = c("State", "Year")) %>%
  group_by(State) %>%
  filter(if_all(X1:X2, ~ sum(!is.na(.x)) >= 2)) %>%
  ungroup()

# # A tibble: 4 × 4
#   State  Year X1    X2
#   <chr> <int> <chr> <chr>
# 1 B         1 NA    NA
# 2 B         2 NA    2
# 3 B         3 4     5
# 4 B         4 3     7

Comment: Your coding of sortation did the trick.
 If anyone else has similar struggles instead of using the inner_join code, use the full_join as to merge all observations and then sort afterwards.


Process.Start returns null

Question: I'm writing a program that launches a random file in s directory. the file can be of any type, but mostly video or image files.
Each time I launch a file I want to close the previous opened one.
Code :
string FolderSelected = "";
string FileName = "";
Process proc;

List<string> FilesDisplayed = new List<string>();

private void button2_Click(object sender, EventArgs e)
{
    if (FolderSelected == string.Empty)
        FolderSelected = Properties.Settings.Default.FilesDefaultFolder;

    if (proc != null)
    {
        proc.CloseMainWindow();
        proc.Close();
    }
    FileName = FetchRandomFile();
    proc = Process.Start(FileName);
}

Problem is, that I keep getting proc = null (the file is launched properly) and I cannot fetch the previously opened process in order to close it. I know that .NET reuses processes and that's why it returns Null but I need to override this behavior.
Answer: EDIT: Thanks to leppie's comment, I suspect I know the answer: my guess is that you're "starting" something like an image, and it's reusing an existing process to open the document instead of creating a new one.
I've reproduced this with this simple test app:
using System;
using System.Diagnostics;

public class Test
{
    static void Main()
    {
        Process proc = Process.Start("image.tif");
        Console.WriteLine(proc == null);
    }
}

This prints "true" because it's using dllhost.exe to host the Windows Image Viewer, rather than creating a new process.
Comment: `static Process Start(ProcessStartInfo startInfo)` can return `null`, if the process didn't start (or is already started).
Comment: @gash25: I don't *think* you can. You can use a `ProcessStartInfo` with `UseShellExecute` set to false, but I suspect that'll just make it fail to start. If you know which process should be used, you could explicitly start that executable.
Comment: I need to override this behavior, because i want to close the last opened file before opening a new one.
how can i do this?
Comment: thanks,
But finding out which process is too much of a overhead.
i just need a simple random open and close file program.
Answer: To fix this problem, you have to set UseShellExecute to false to bypass the shell.
Instead of
Process.Start("filename", "args")

use
Process.Start(new ProcessStartInfo() {
    FileName = "filename",
    Arguments = "args",
    UseShellExecute = false
});

Comment: It doesn't work in my case. I'm getting exception which says that the file is not a correct Win32 application (in my case it's a video file). This works only with executables.
Comment: This will not solve the problem in case `UseShellExecute` will mainly assist to find the application to use the wanted file (like image/pdf/doc/...). If it works with `UseShellExecute = false` it even will also work with `UseShellExecute = true` and respond with a valid process.
Answer: You are declaring 'proc' at method scope, so of course it will always be null when checked at the top of that method.  If you want the reference to live beyond the function, declare it is a class level variable.
You are spawning a process each time (probably), Process.Start is not returning null, but you simply lose the reference to it when i goes out of scope.
Answer: That won't even compile (definite assignment). As a method variable, proc is local only to the declaring method(/scope) - i.e. button2_Click, which explains why you can't retain values. If proc is meant to persist between calls, promote it to a field (per-instance variable):
Process proc;
private void button2_Click(object sender, EventArgs e)
{
    if (proc != null)
    ...

Process.Start returns null


Vim,omnicomplete and python documentation

Question: I started to learn Python, and I tried to setup my vim for it. I have vim 126.96.36.199, it has omnicompletion and I downloaded pyflakes. I read this article
and it says that omnicompletion should also display some documentation (there is also an image with string.atoi and some documentation), but when I try something like this:
import string
string.

and do CTRL-xCTRL-o I get the proper listing, but I don't get any documentation.
Should I install other plugins or change some configuration file?
EDIT:
I needed to install supertabs to get the effect I wanted.
Comment: you should apply patch to fix a bug which can't complete with "from xxx import yyy": https://groups.google.com/d/topic/vim_dev/Dnb4OcDriJ0/discussion
Answer: To enable code(omni) completion, add this line to your vimrc ($HOME/vimrc):
autocmd FileType python set omnifunc=pythoncomplete#Complete

If it doesn't work then, you'll need this plugin.
Comment: I tried it and I still don't have the window with documentation, I tried to get something like this: http://blog.dispatched.ch/wp-content/uploads/2009/05/omnicompletion.png As I said, I get the listing(Formatter,Template,atof etc.) but I want to get this small window that shows documentation also.
Comment: please check this: http://www.mohdshakir.net/2007/12/27/enable-vim-code-python-auto-complete too! It describes how to do this by using the pydiciton plugin that you can download it from here: http://www.vim.org/scripts/script.php?script_id=850
Comment: Sorry, I have to downvote now. You don't seem to understand the question.
Answer: Check my plugin: https://github.com/klen/python-mode
Rope omnicompletion from the box. Also many others features.
Answer: Omni completion i_CTRL-X_CTRL-O works in Vim without installing plugins, but only if you satisfy these three conditions:

Vim is compiled with +python3
Python3 is installed
for the Python packages you want to omni-complete:

the package is installed
the script you are editing has an import statement for the Python package
if doing import numpy as np, you are doing i_CTRL-X_CTRL-O after typing np., not numpy.

The Python3 omni completion is defined in the python3complete.vim that comes with Vim.
:new
:set filetype=python
:echo &omnifunc
python3complete#Complete

I found this in my Vim installation here:
/usr/share/vim/vim81/autoload/python3complete.vim

Details
1. Vim compiled with +python3
:ve to check Vim version and enabled features. Here is the relevant output when I run :ve
VIM - Vi IMproved 8.1 (2018 May 18, compiled Jul 28 2019 15:01:57)
...
Huge version without GUI.  Features included (+) or not (-):
...
+python3/dyn
...

2. Python installation
This is easy to confuse when there are multiple Python installations.
For example, I have a Windows Python3 installation:

Windows Python3 runs from PowerShell

PS> python
Python 3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 23:11:46) [MSC v.1916 64 bit (AMD64)] on win32

Windows Python3 runs from Cygwin bash

$ python.exe
Python 3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 23:11:46) [MSC v.1916 64 bit (AMD64)] on win32

Windows Python3 does not run from the Cygwin Vim command line
:python3

of course I can use :!python.exe for Vim to run python.exe in bash

:!python.exe
Python 3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 23:11:46) [MSC v.1916 64 bit (AMD64)] on win32

but that does not help omni completion
for omni completion Vim needs to be able to Python3 directly from the Vim command line

Test Vim can call Python3:
:py3 print("hey")
hey

I had to install Python with the Cygwin package manager to get the output hey.
3. Python package installation
If you have the mutliple Python installation problem, then also install another copy of the Python packages you want to omni-complete for.
For example, I installed the Python packages with the Cygwin package manager.
If the Python package is not available through your package manager, clone a copy of the package repository at the path identified by site.USER_SITE. This is part of the package search path, so omni completion searches in this path as well.
Find out the USER_SITE path from Vim:
: py3 import site; print(site.getusersitepackages())

The path should look something like this:
/home/myname/.local/lib/python3.7/site-packages

Alternatively, check from bash:
$ python3.7 -m site --user-site
/home/myname/.local/lib/python3.7/site-packages

Note the path is defined even it is does not exist. You need to create the path if this is the first time putting a package there.
With the above conditions satisfied, omni completion works. Start a .py file (or just open a new buffer and :set filetype=python), then try typing the following:
import numpy as np
np.CTRL-X_CTRL-O

The omni-complete window pops-up for cycling through with CTRL-N (next) CTRL-P (previous).
There is additional confusion because python3complete does not use a tags file like ccomplete does. Please see my solution to this post: Vim's Omnicompletion with Python just doesn't work


Hierarchical tables with vuejs

Question: I need to display some tree structures on an application I'm working on. The sample data would be something like this:
<code>Category 1
       - Subcategory 1.1
                - Subcategory 1.1.1:     5 items
                - Subcategory 1.1.2:     6 items
       - Subcategory 1.2
                - Subcategory 1.2.1:     2 items
Category 2
       - Subcategory 2.1
                - Subcategory 2.2.1:     5 items
                - Subcategory 2.2.2:     6 items
                - Subcategory 2.2.3:     5 items
                - Subcategory 2.2.4:     6 items
</code>
So I need to put this on a table for which i need to alter the rowspan on the parent groups. The thing is that I have no idea how to do that with Vuejs. I tried with v-for structures on the three levels, but I'm seriously lost. Has anyone done something similar with Vue?
Comment: It's not clear how you would draw such a table. Can you make a sample table in ASCII? Using something like Monodraw or ASCIIflow?
Comment: You can check out this example: http://vuejs.org/examples/tree-view.html
Comment: On a table, even with nested data, I encountered problems with opening and closing of the tags and the v-for. So it might not be possible to do this with a table. Other structures might be possible (where each level uses a different tag, div, span, etc).
Comment: https://www.npmjs.com/package/vue-hierarchy
Answer: Consider using CSS Grid to build the table.  You could conditionally assign CSS rules ( :class ) to progressively indent.  For example .level__2 { margin-left: 24px;}

Hierarchical tables with vuejs


Prove almost sure convergence series of independent variables

Question: Given $X_i$ i.i.d random variables, $|X_i| \leq l$ for some $l>0$, $p_k = P(X_i = k) > 0 \ \forall k$.
Let $N_n(k) = \sum_{i=1}^{n}1_{X_i = k}$ and let $\prod_n = \prod_{k=1}^l (p_k)^{(N_n(k))}$.
Prove the sequence $\frac{1}{n}\log \prod_n $ converges almost surely and compute the limit.
I try this using the 3 Series theorem but I am unsure how to define the sequence to prove a.s. convergence using the 3 series theorem.  Breaking down the sequence I arrive at the following:
$$A_n = \frac{1}{n}\sum_{k=1}^{l}\sum_{i=1}^n 1_{X_i = k}\log(p(X_1 = k)) $$
I'm not sure how to create the sequence though to prove the 3 criteria of the 3 series theorem if that is what is required for the proof.
Comment: $N_n(k))$ is the # of times the Xis = k so the bound would be n given the indicator function, how are you getting $l(l+1)$?
Comment: By $|X_i| < l$ for some $l$ You mean that $X_i$ are bounded by $l$ ? If yes, what is the probability that $P(X_i = l+1)$?
Comment: It would be 0, the $X_i$s are basically discrete I think based on the definition
Answer: In the proof I assumed that $X_i > 0.$
Firstly, by boundness of $X_i$ there exists $m \leq l$ such that
$$ P(X_i = m) > 0,~~P(X_i = m+1) =0.$$
Let's denote
$$ \prod_n = p_1^{N_n(1)}\dots p_m^{N_n(m)}, $$
now by property of $\log$
\begin{align}
\frac{1}{n} \log ( \prod_n ) &=  \log ( p_1^{N_n(1)/n}\dots p_m^{N_n(m)/n} ) \\&= \sum_{i=1}^m \log( p_i^{N_n(i)/n} ).
\end{align}
For each $i \in \{1,2,\dots,m\}$
\begin{align}
&\lim_{n \rightarrow \infty}  \log( p_i^{N_n(i)/n } ) \\&= \log( p_i^{  \lim_{n \rightarrow \infty} N_n(i)/n} ).
\end{align}
By strong law of large numbers
\begin{align}
& \lim_{n \rightarrow \infty} N_n(i)/n \\ &= \lim_{n \rightarrow \infty} \frac{\sum_{k=1}^n 1_{\{X_k = p_i \}} }{ n } = p_i, ~~~~\text{a.s}.
\end{align}
Hence
$$ \lim_{n \rightarrow \infty} \frac{1}{n} \log ( \prod_n ) = \log ( p_1^{p_1}\dots p_m^{p_m} ).$$
Comment: Yes they are. We have $P(f(X_i) \in A) = P(X_i \in f^{-1}(A))$ , here $f^{-1}$ is invers image of $f$. So if $X_1, X_2$ are i.i.d then $f(X_1), f(X_2)$ also
Comment: I agree we need SLLN argument here for the $N_n(k)$ but can't we simply set each $X_i = 1_{X_i=k}$ and thus $E|X_i| \le \inf$ and where each $X_i$ is i.i.d as stated and so by SLLN $N_n(k) / n $ = $S_n/n$ = $E(S_n)/n$ = $np_k/n$ = $p_k$ and then we're done since the log sum is a finite sum of bounded terms?
Comment: Your idead is also fine. We can firstly show that $N_n(k)/n \rightarrow p_k$ so then $p_k^{N_n(k)/n} \rightarrow p_k^{p_k}$. And since we have finite number of $p_k$'s by laws of limit we can conclude that our limit is equal to the product of $p_k^{p_k}$'s
Comment: My only lasting question here is on the notion of identical distribution, if two r.v.s are i.i.d say X1, X2 then f(X1) and f(X2) are independent but are they also ident distributed, f:borel -> borel? I think that's correct but I haven't yet proved it but wanted to confirm
Comment: You do You mean by f:borel -> borel?. So in general if $X_1, X_2$ are independent borel measurable random variables then for any borel measurable funcion $f$, $f(X_1), f(X_2)$ are also independent random variables .
Comment: correct but are they identical in distribution too, f(X1) and f(X2) iff X1 and X2 are i.i.d?


How to overscroll using gsap Draggable with scrollTop?

Question: import {gsap} from "gsap";
import Draggable from "gsap/Draggable";
import { InertiaPlugin } from "./libs/gsap/InertiaPlugin";
import { ScrollToPlugin } from "./libs/gsap/ScrollToPlugin";

gsap.registerPlugin(Draggable)
gsap.registerPlugin(InertiaPlugin);
gsap.registerPlugin(ScrollToPlugin);

Draggable.create(scrollContainer, {
    type: 'scrollTop',
    inertia: true,
});

This simple example works nice for making a vertical scroll/throw effect for desktop browsers.
When flick scrolling back to top, the inertia plugin makes the content overscroll and bounce back to starting point. This is good.
However, the overscroll does not happen when just dragging, ie. like on an iPad. Is it possible to make Draggable overshoot/overscroll while dragging and bounce back when dragging ends?
Edit:
Here is codepen with example:
https://codepen.io/Agint/pen/LYZMyYR
(I could not find cdn version of the newest gsap InertiaPlugin, so this version is with older version. The behaviour and problem are exactly the same regardless of version. Locally, I have the the newest gsap version with bonus files that includes InertiaPlugin from greensock.)
Answer: This is exactly what the edgeResistance is for:
Draggable.create("#scrollContainer", {
  type: "scrollTop",
  inertia: true,
  edgeResistance: 0.9
});

Demo
Comment: It works very nice when overscrolling to the top, but at the bottom it is a bit funky. Change the resistance to 0.5 to make it more obvious. It might be how I have set up the divs, will look more into it.
Comment: Yes, I believe it has to do with your CSS. Removing the unnecessary `position` and `float` properties it works fine for me.


Ending Webview and going back to VIew Controller when URL changes

Question: I have a edit photo php script that i want to load in my iOS app. I am calling it through WebView "www.example/com/myTool". When the edit task is complete the webView is moving to homepage of the website. I want when the Edit task is complete then instead of redirecting url to www.example.com/home the webView closes and it moves back to View Controller.
What i can think of solution is - when the URL of webView changes then the webView should close and move back to view controller .. But i don't know how to apply it in code.
import UIKit

class AddPostVC: UIViewController {

@IBOutlet weak var addPost: UIWebView!

override func viewDidLoad() {
    super.viewDidLoad()
    addPost.loadRequest(URLRequest(url: URL(string: "https://new.example.com/pentool")!))

}
}

Answer: You need to implement UIWebViewDelegate methods.
Before loading a URL, UIWebView will call, (webView: shouldStartLoadWith request) delegate method.
Compare the URL in request property with your home page URL. If yes, close the web view.
Hope this helps :)
Comment: @KeshuRai I created a sample application with UIWebView and delegates for your reference.  https://github.com/mcabasheer/webview-reload pls check and let me know if you have any queries.
Comment: thnx buddy .. but actually you have just stopped the webview from loading any other link .. what i want is when someone has ended editing the image then when he clicks on post button in php script , then after image being posted successfully the url should not redirect to www.example.com/home as the php script does, instead it should go back to home view controller.
Comment: @KeshuRai yes... returning false in that method will not redirect the webview to home page. and you can dismiss the view controller in that same block.
Comment: How would i tell my webview that the task that i wanted has been completed and now we can dismiss webview ?
Comment: You don't have to tell webview. Just pop navigation view controller and go back to previous screen.
Comment: M not getting it ... it wud b helpful if u can update your code and show it .
Comment: @KeshuRai  I have updated the github project with navigation example. Check for NSURL host property to get the domain name.   https://github.com/mcabasheer/webview-reload
Answer: You could do this
NSString *currentURL = [webView stringByEvaluatingJavaScriptFromString:@"window.location"];

This will get you the url of the current page. Or this
currentURL = currentWebView.request.URL.absoluteString
Credit to https://stackoverflow.com/questions/2491410/get-current-url-of-uiwebview/3654403#3654403
Comment: can you explain it in swift please ?
Comment: Yup - so `currentURL = currentWebView.request.URL.absoluteString` actually is swift. Basically, it just gets the current url of the webview, where currentWebView is your webview. So in your case, you would go `if currentURL == urlYouWantToMatch { move back to view controller.}
Comment: Check out the link I posted, they go into all the detail you will need.
Comment: i tried your way. not working. url is not getting stored in currentUrl. Also the syntax has changed little bit .         let currentURL = addPost.request?.url?.absoluteString


How to include a css file using R code in the yaml header?

Question: How to include a css file using R code in the yaml header?
I have the following directory tree
./
./include/
./include/css/
./include/css/style.css
./docs
./docs/report/
./docs/report/report.Rmd

and I have tried
css: "`r library(here); here('include/css/style.css')`"

but it didn't work and gives the following error

File r here::here('include/css/style.css') not found in resource
path Error: pandoc document conversion failed with error 99
Comment: Did you examine the output HTML to check what CSS path gets inserted? Also, instead of `library(here); here(…)` I suggest using `here::here(…)`. It's more concise and there's no need to attach the package.
Comment: @KonradRudolph
"File `r here::here('include/css/style.css')` not found in resource path
Error: pandoc document conversion failed with error 99"
Answer: I am new, so can't comment on your post yet.
I use this example for my bookdown documents:
https://bookdown.org/yihui/rmarkdown-cookbook/html-css.html
This works well, but I put all my css files on the same directory along with markdown and yml files.
If you want to use your directory structure, maybe a relative path might work.
Here is an example I found:
https://github.com/fletcher/MultiMarkdown/issues/47
Good luck!


Dismissing Anko Dialog in onClickListener

Question: I would like to dismiss Anko Dialog when pressing the button defined in my customLayout
val dialog = alert {
   val view = layoutInflater.inflate(R.layout.match_stats, null)
   val closeButton = view.findViewById<ImageButton>(R.id.closeButton)
   closeButton.setOnClickListener { _ -> dialog.dismiss()}
   customView = view
}
dialog.show()

I tried above code, unfortunately, I can't get a reference to dialog in my onClickListener. Do you have any idea how to solve it?
Answer: You could declare variable before and assign null:
var dialog: DialogInterface? = null
dialog = alert {
   val view = layoutInflater.inflate(R.layout.match_stats, null)
   val closeButton = view.findViewById<ImageButton>(R.id.closeButton)
   closeButton.setOnClickListener { _ -> dialog?.dismiss()}
   customView = view
}.show()

Of course now your dialog variable is muttable and optional.
Comment: Ofc mutable and optional sucks, but I haven't found a better solution. Thanks!


MAMP Pro, 403 forbidden unless typing https://

Question: I have recently started switching all my sites to SSL, locally using Mamp Pro virtual hosts and self-sign certificates.
All works fine with one exception:
if I type local.domainname.co.uk in a browser I get a 403 error, unless I type the full https:// first, then it works fine. On the live site it all works as expected; type domainname.co.uk and the browser fills in the https:// for me.
These are drupal sites using htaccess module to force the ssl - but since it works live but not local I'm assuming its a mamp issue?
Comment: Possible duplicate of [Mamp Pro 4 HTTP and HTTPS](http://stackoverflow.com/questions/40077934/mamp-pro-4-http-and-https)
Comment: Don't think it's a duplicate - I didn't want mixed http and https, I wanted pure https. Just had to have http in order to redirect to https
Comment: The answers are the same, I think it might be a duplicate because even if you don't really need both for your application, you actually need them to redirect one to another. They highlight the same issue, and the answer is the same. I'll a let a moderator decide wether it is or not a duplicate, nothing personal ;)
Answer: Solved this - I needed to set up a non-SSL host in MAMP with the same name and settings as the SSL host (with SSL unchecked obviously) - although I want the site all https, there still needs to be an http host so it can re-direct to ssl (until browsers default to https at some point in the future?). MAMP instructions.
Or don't bother if you can live with typing https:// every time!


Add a dot to the string in the form of a name, if there are characters in the name string

Question: I want to create a function that can correct invalid string names. Sample case:

"ThOMas m aEro" will be "Thomas M. Aero"
"T M aEro" will become "T.M. Aero"
"thomas M. e." will become "Thomas M.E."

Here is the code that I have created using PHP:
function fixName($name){

    $step1 = str_replace('.', ' ', $name);
    $step2 = ucwords(strtolower($step1));

    $step3 = explode(" ", $step2);
    $step4 = "";
    foreach ($step3 as $part3) {
      $partName = trim($part3);
      if(!$partName) continue;
      if(strlen($partName) == 1){
        $step4 .= $partName . ".";
      }elseif($step3[0] == $partName){
        $step4 .= $partName . " ";
      }else{
        $step4 .= " " . $partName;
      }
    }
    return $step4;
}

Any better code suggestions for this problem?
Answer: Here is a fairly concise version of your function which relies mainly on regex replacements to get the job done:
function fixName($name) {
    $output = preg_replace_callback(
    "/\b\w+\b/", function($m) {
        return strtoupper($m[0][0]) . strtolower(substr($m[0], 1));
    },
    $name);
    $output = preg_replace("/\b(\w)(?=[^.\w])/", "$1.", $output);
    $output = preg_replace("/\b(\w\.)\s*(?!\w{2,})/", "$1", $output);
    return $output;
}

$input = array("ThOMas m aEro", "T M aEro", "thomas M. e.");
foreach ($input as $inp) {
    echo $inp . " => " . fixName($inp) . "\n";
}

This prints:
ThOMas m aEro => Thomas M. Aero
T M aEro => T.M. Aero
thomas M. e. => Thomas M.E.

For an explanation, there are 3 replacement steps used above.  The first puts all words into camel case, with the first character being capitalized, and all subsequent characters in lowercase.  Next, we add a trailing dot to all single characters.  Finally, we remove whitespace in between clusters of single letter initials.  Here are the steps as applied to one of your test inputs:
T M aEro    original input
T M Aero    camel cased
T. M. Aero  add dots after single letter intials
T.M. Aero   trim whitespace between clusters of initials

Comment: Thank you for your great answer. I was so motivated to learn more about regex


PHP : Function - Return 2 variables (Boolean + $variable)

Question: Issue Resolved : Here is the solution :
function testCoreq()
    {
        $coreqTest = makeCoreq();

        if(empty($coreqTest))
        {
            return array(true);
            break;
        }
        else
        {
            foreach ($coreqTest as $ctest)
            {
                if($ctest['value'] == "true")
                {
                    return array(true);
                    break;
                }
                else
                {
                    return array(false,$ctest['coreqID']);
                }
            }
        }

    }

if(testCoreq()[0])
{
  //do something
}
else
{
  return testCoreq()[1]
}

I'm doing a school project and hit kind of a bump.
I created a function and i want it to either return "true" (boolean) or "false" (boolean) + a variable.
I searched the net quite a bit but wan't able to find a simple way to do this .
Is there any way to this this ?     //Thanks
The function is working properly but when it is returning the variable - it is also assuming that the function is returning "true" when i want it to return false + the value like :
else
                {
                    return $ctest['coreqID'];
                    return false;
                }

Here is the code :
function testCoreq()
    {
        $coreqTest = makeCoreq();

        if(empty($coreqTest))
        {
            return true;
            break;
        }
        else
        {
            foreach ($coreqTest as $ctest)
            {
                if($ctest['value'] == "true")
                {
                    return true;
                    break;
                }
                else
                {
                    return $ctest['coreqID'];
                }
            }
        }

    }

I am using it like this:
if (testCoreq())
{
 // do something
}
else
{
 // return the variable
}

but even if the first statement is false , then it is returning the variable - it is assuming the function is true.
Comment: Return an `array(true, $value);` or pass 2 values [by reference](http://www.php.net/manual/en/language.references.pass.php)
Comment: u cant return 2 values in one return however u can enclose the values in an array and then return.
Comment: thanks - how do i check the first value & return the second one ?
Comment: You can not use `return` to return two variables. As other said, you can use array in the `return` to do it.
Comment: yep i already updated my code - but when i check the function - how i can use the first value of the array to test the boolean like : if (testCoreq[0])
Comment: Why do you use a `foreach` loop and in the first iteration you stop the function?
Comment: if even one of the value is true , then the function works & should return true instead of going on
Answer: You can try to return -1 on true and other for false to decrease amount of returning values. Next option is to return array of values. The other option would be to pass reference variable in the function.
Comment: thx - how do i check the first value & if false - return the second array value : if (testCoreq())
{
 // do something
}
else
{
 // return the variable
}
Comment: You can save the results to the variable, and then check it, or do it immadiately with `if(testCoreq()[0])` if you are returning array like `array(true, $value);`
Comment: Thanks - got it working . Posting the working code above


HBITMAP *Bitmap to .net Bitmap

Question: I have a Dll and the header file for it, and I'm trying to create a COM wrapper in C++ to use in C#.
For most of functions it was very simple since they were returning int or string.
I have this struct in the header file.
virtual HRESULT STDMETHODCALLTYPE GetBMP(
            int Width,
            int Height,
            HBITMAP *Bitmap) = 0;

My problem is that since I'm way out of my league with C++ I don't know how to convert the HBITMAP to something more appropriated to .net style
Thanks in advance, and please forgive me if wrote stupid things
UPDATE:
I tried something like this :
HBITMAP GetBMP(int Width, int Height)
{

    HBITMAP bm = 0;
    m_piHelper->GetBMP(Width,Height,&bm);
    return bm ;

}

The problem obviously is after that in c# how convert from 'HBITMAP__*' to 'System.IntPtr to use it with bitmap.fromHbitmap
Comment: The `[DllImport]` C# declaration for `GetBMP` is the place where you declare the third parameter as `out IntPtr`.
Comment: no im not importing the dll in c# im trying to write c++ wrapper
Comment: Then you confused all us. "Managed wrapper" is something you write in C#. If you are writing a C++ wrapper, that might be a COM wrapper. I have edited your question to reflect this. Please feel free to amend the edit as appropriate. (Maybe you *are* using managed C++?)
Answer: The parameter should be out IntPtr.
Then you can create an additional function that will call GetBMP and then call Bitmap.FromHbitmap to return a bitmap. Such function must then DeleteObject the original hbitmap.
Answer: You should perhaps try System.IntPtr.

HBITMAP *Bitmap to .net Bitmap


How to set items on left and right to center align image

Question: I have really basic question for most of HTML and CSS guy. I am trying to align list to center aligned image but not able to set list left or right to the image.
That what my code look like right now

 Web Development

 Application Development

 Website Design

 UI/UX Design

 SEO Service

But i want my screen to look like this. Please guide me to get it done in right way.
Comment: Note that the `align` attribute has been [obsolete for several years](https://html.spec.whatwg.org/dev/obsolete.html#obsolete).
Comment: add your full code with the css here other wise no one can easily help you.
Comment: It's inline css. Please check
Comment: but not get same layout as you put in screenshot.
Comment: Please check updated image
Comment: are you using any css framework like bootstrap etc?
Comment: its a template which i am editing in Dreamweaver. Yes it contains bootstrap.css file
Answer: Hope this help you.
Please try below css.

.mobile_container{
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
     align-items: center;
     -ms-flex-pack: distribute;justify-content: space-around;
}

 Web Development

 Application Development

 Website Design

 UI/UX Design

 SEO Service

 Web Development

 Application Development

 Website Design

 UI/UX Design

 SEO Service

Comment: Thanks for the solutions. Let me check and get back to you
Comment: yes sure. please let me know if you still need any kind of help. Thanks
Comment: Not getting output as need. gets same output as i mentioned in question
Answer: You need something like this?
Result:
Codepen

.features-title {
  margin-bottom: 50px;
  text-align: center;
}

.features-col li {
  position: relative;
  padding-left: 80px;
}

.features-col li::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  transform: translateY(-50%);
  width: 50px;
  height: 50px;
  background-position: center;
  background-size: cover;
  border-radius: 50%;
}

.item-1::before {
  background-image: url("https://picsum.photos/id/70/300/300");
}

.item-2::before {
  background-image: url("https://picsum.photos/id/71/300/300");
}

.item-3::before {
  background-image: url("https://picsum.photos/id/72/300/300");
}

.item-4::before {
  background-image: url("https://picsum.photos/id/73/300/300");
}

.item-5::before {
  background-image: url("https://picsum.photos/id/74/300/300");
}

.item-6::before {
  background-image: url("https://picsum.photos/id/75/300/300");
}

.features-col {
  flex-grow: 1;
  list-style: none;
}

.features-col--center img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.features-inner {
  display: flex;
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
}

.features-col--center {
  flex-basis: 25%;
  flex-grow: 0;
}

.features-col--left,
.features-col--right {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  align-items: center;
}

Lorem ipsum dolor sit amet consectetur.

Lorem ipsum dolor sit.

Lorem ipsum dolor sit.

Lorem ipsum dolor sit.

Lorem ipsum dolor sit.

Lorem ipsum dolor sit.

Lorem ipsum dolor sit.

Comment: To replace the gray fill with a picture, simply add the `url()` value to `background` property. Updated codepen in stackoverflow code for example: https://take.ms/8P4eT
Comment: This can be done, for example, by adding a unique class to each element. Updated code
Comment: I tried to but not able to put `li:before` as inline code. Can you please tell me how to use it as inline
Comment: As i already have li and ui in css template. So i can't touch it, how can i achieve it without messing up my whole css with unique classes name in css.
Comment: @androidXP, I updated the code in the answer and on CodePen, replacing the tags with classes in CSS. I hope there are no such classes in your code.
Comment: One more question. How can i change that gray dot into some image for each li element?
Comment: It's my pleasure
Comment: How we can set different background for different elements cuz as you setting same for all. How to set different background for each `li` elements
Answer: try this code and you will get the same layout as you want.

*{box-sizing: border-box;}
.left_box,
.center_box,
.right_box{
  float: left;
  width: 33.33%;
  padding: 30px;
}
.center_box{
  text-align: center;
}

 Web Development

 Application Development

 Website Design

 UI/UX Design

 SEO Service

 Web Development

 Application Development

 Website Design

 UI/UX Design

 SEO Service

Comment: Thanks for the solutions. Let me check and get back to you
Comment: not working as required. Image is not aligned in center
Comment: ya but as per your provided code this my code is perfect to set image in center its working properly i think you need to post Question with all Css library you are using.
Answer: You can split the ul items using jquery and then apply css.

 Web Development

 Application Development

 Website Design

 UI/UX Design

 SEO Service

Comment: running loop for no reason could be expensive. Here we can avoid loop. Nice use of JS, this is actually a hack not a perfect solution.


Run RMI Hello world in Mac OS X Lion Failed

Question: I've been trying to execute the commands to run the RMI Hello world example but I Failed!
My execution steps are taken from here: http://docs.oracle.com/javase/1.5.0/docs/guide/rmi/hello/hello-world.html
The commands are:

javac: works fine and I get the class files
rmiregistry &: I get something like [1] 17122
java -Djava.rmi.server.codebase=file:/users/ha/RMI/ example.hello.Server:

Gives me an error message

Exception in thread "main" java.lang.NoClassDefFoundError:
  example/hello/Server Caused by: java.lang.ClassNotFoundException:
  example.hello.Server  at
  java.net.URLClassLoader$1.run(URLClassLoader.java:202)    at
  java.security.AccessController.doPrivileged(Native Method)    at
  java.net.URLClassLoader.findClass(URLClassLoader.java:190)    at
  java.lang.ClassLoader.loadClass(ClassLoader.java:306)     at
  sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)     at
  java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Comment: I used to edit the class path in windows, but here in mac I didn't do that, is it necessary?
Answer: I did solve this problem by running each command on a new terminal window.
First I started with javac for the .java files, then run the command rmiregistry &.
Second I opened a new terminal window and run the command java for the Server class.
Third I opened a new terminal window and run the command java for the Client class.
and it works with me!
Answer: On the Mac, the Users directory in the root directory is written with a capital letter.
You wrote:

file:/users/ha/RMI/

file:/Users/ha/RMI/ would be correct. This applies only to file systems that have been setup explicitly to setup to ignore case (Case-insensitive). At least that is what the comments below are saying. I cannot verify this myself.
A classpath is also needed under many circumstances. It depends on your dependencies. But if you needed the classpath in windows, you will need a similar one on Mac.
Depending on where you .class files are, I would add the classpath to your invocation.
java -Djava.rmi.server.codebase=file:/users/ha/RMI/ -cp=/Users/ha/RMI example.hello.Server

This assumes, of course, that the class files are under /Users/ha/RMI/example/hello
Just look inside of the directory to verify that the class files are there. It should be the directory that you designated after the javac command and -d argument.
Comment: MacOS file system is case insensitive so should not matter
Comment: edit it to: java -classpath /Users/ha/RMI/ -Djava.rmi.server.codebase=file:/Users/ha/RMI/ example.hello.Server, but still getting the same error message
Comment: My MacOS file system was set intentionally to case sensitive. Mac OS Extended (Case-sensitive, journaled). This is a much more reliable setting for iPhone Development. For XIB files using ~ipad or ~iPad (or ~iphone/~iPhone) you wouldn't have a problem in the simulator, but the device will show the wrong results in one of the cases (iPad won't work on a device). It is a valid statement to verify that this isn't a problem first.
Comment: The problem should be your classpath then.
Comment: Make sure you are targeting the directory where the class files are living and not the java files.
Comment: @Terry Dye how can I do that in mac?
Comment: If you're using Terminal, you can just use the 'ls'-Command. For example: ls /Users/ha/RMI/example/hello Or go to your Finder and look in the directory. I would look in /Users/ha/RMI/example/hello directory.
Comment: @Evanescence did the last comment help you? Have you had success with your tests?
Comment: @Terry Dye Thanx for asking, yes I did.
Answer: I used three terminal windows for execution of a rmiregistry program.
1.Use this terminal window to compile all your files (javac filename.java) and use the command "rmiregistry &" this is the windows equivalent command for "start rmiregistry". (Note:'start' command doesn't work on the macOS)
2.Use this to run the java file ie. Server file (ie. java RMI_Server)
3.Use this to run the client file ie. Client file (ie. java RMI_Client 127.0.0.1)
And yeah it worked for me. (Note: The Directory should be set properly in the terminal)


Stuck on handling common scroll gestures

Question: I have a screen where users can switch between tabs via swiping back and forth. In each tab, it has a list of items. Recently I implemented a gesture handler for that list (so list can have more optons, but hidden initailly) and now it's a lack in user experience since both, top navigation (tabs) and the list has the same gesture behaviours. Please refer to the image for more info.
So I am stuck in this and seeking help from you guys. If you have any advices, let me know.
Comment: I just see one problem, that the user does not know that they can swipe on the tabs. Is that the problem you're describing? Or is it something else?
Comment: @NielsBrinch basically they can switch between tabs via swiping the whole screen. The problem is I recently added a swipe feature to the list, So now if the user does a swipe on a list item it will now show more options instead of moving from one tab to another.
Answer: I think the solution is to understand that although the gesture is the same, the functionality is different. The first is a Swipeable Menu with hidden tabs and the second is a Swipeable List with hidden options.
In other words, the first one is a Carousel and the second a list with a swipe functionality.
While in the list it's easily deductible for the user that the number of options is minimal, in the menu the number of items is unpredictable, it can be 3 or n-items.
Adding a dot indicator at the menu can solve several of these problems:

Knowing the total number of items
Knowing the position of the selected item
Understand that it's a menu with a swipe interaction


For German code, what is the correct fuse amperage, per phase, for a 3-phase service line?

Question: This website provides convenient tables for fused amperage given conductor cross-section area (mm^2), number of conductors, and temperature.
The cable in question is a 5 conductor (L1,L2,L3,N,PE) 10 mm^2.  20 meters long, connecting the main panel to a secondary panel.  It is currently using 16 A fuses (Hager FS MBN116A).  It is installed "in the air", i.e. in the walls but not buried in concrete or plaster.
I want to upgrade it's fuses with an appropriate amperage rating.  Considering this is a domestic residence, and the subpanel will feed yet another subpanel in the garage, which is expected to run large amperage single-phase power tools occasionally.
From the first table, first column, I get 10 mm^2 -> 73 A.
From the second table, given normal ambient temperature of 30 C -> 1.0 factor -> 73 A.
From the third table, 5 conductors -> 0.75 factor -> 54.75 A.
The remaining tables seem not applicable.
I have very little background knowledge on this topic.  Is 54.5 A per phase a reasonable value?  I plan on fusing each phase 32 A (Hager MBN332A).
Thank you.
A similar, simpler table here
Comment: There may be some confusion in or caused by the use of the terms "fuse" (a thin piece of wire in a non-conducting glass or ceramic capsule, the wire melts under overcurrent conditions) and "breaker" (a device in an electrical panel which usually includes both thermal and magnetic sensors to break overcurrents on one or multiple line conductors)
Comment: @RedGrittyBrick.  Right, my bad on the poor terminology.  Should have said breaker.  They are "FS" in German, whatever that means.
Comment: Honestly, the links you are providing aren't a lot of help to English speakers. Take America - I can show you tables that'll authorize anything from 25A to 40A on a 12AWG wire (3.31mm2), but for building wiring there's a *statutory* rule of 20A, *end of subject*.  So it's just a matter of finding the right table - or rather, the wrong one.
Comment: @Harper.  I'm an American living in Germany.  I recognize those VDE references as "building code".  I've yet to find a German-language equivalent to stackexchange; just crummy forums with pages of no-reputation advice.
Answer: I suggest you not to use fuses on 3-phase, just go for a magnato-termic breaker (L1,L2,L3 + N). Fuses have to be in fixture that if a single phase breaks, all 4 wires have to go out of power (if you have PE separated from neutral = both green-yellow and blue), or onlt 2 wires if you have a single PEN conductor.
Note that in tables usually they consider only 'active' conductors -> 5 wire cable is '4 poles' wire as PE isn't an 'active' conductor
PE = green yellow
N = blue
PEN = usually blue marked with green-yellow tape at ends and in accessible boxes
Comment: does it help that the [Hager MBN332A](https://www.hager.de/modulargeraete/leitungsschutzschalter/ls-schalter-6-ka/mbn332/954889.htm) does indeed bind all three phases to a single phase tripped?
Comment: @TysonHilmer -- yeah, common trip is the norm for such a breaker.
Comment: It's 32A per phase (for a perfectly evened circuit it's 96A in total). Also amperages are given for single wire, not for the 'composed' cord
Comment: **Thermal derates also disregard neutrals* in multi-phase arrangements.  That is because *if balanced*, neutral is 0.  *If imbalanced*, it's cooler still.  Heat is proportional to amperage *squared*, so two wires handling 2 and 13 amps will always be cooler than the same wires with 15 and 0 amps.


Wrapping normals around a sphere

Question: I'm using a vertex shader to effectively wrap vertices on a sphere. Starting with world_position already after multiplying the vertex by the model transform matrix to get the coordinates in world space, I calculate the new position via an inverse Mercator projection:
float theta = 2.0 * PI * world_position.x / world_radius;
float phi = 2.0 * atan(exp(world_position.y / world_radius)) - PI / 2.0;
float radius = world_position.z

gl_Position = vec4(radius * vec3(sin(theta)*cos(phi), sin(phi), cos(theta)*cos(phi)), 1.0);

What I now need to do is take these angles, $\theta$ and $\varphi$, and use them to transform the normals as well. I've tried creating a rotation matrix to represent rotation first around the Y axis (for $\theta$) and then around the X axis (for $\varphi$), and multiplying that by the vertex's normal (after multiplying the normal by the model matrix's inverse transpose), but that didn't give the results I expected.
How do I use the angles to rotate the normals so they match the rotations of the vertices?
Answer: Turns out I needed to be looking at the former normal as a unit vector $(\hat{r}, \hat{\theta},\hat{\varphi})$, and then use a rotation matrix as outlined here to find $(\hat{x},\hat{y},\hat{z})$.

Wrapping normals around a sphere


How do I configure jupyter notebook for having a pre loaded cell with certain imports without using ipython?

Question: I want to import certain libraries and define certain functions in my first cell of the notebook every time it starts. In my case, I am using a Docker container for this purpose. After going through several links and answers(https://vivekbharadwaj.github.io/data%20science/jumpstart-your-Jupyter-notebook-analysis-with-pre-loaded-cells/), I am unable to set the notebook up as I have certain errors.
These are the commands:
# Python3 Kernel for JuPyter notebooks
RUN     python3 -m pip install ipykernel
RUN     python3 -m ipykernel install --user
RUN     python3 -m pip install jupyter_contrib_nbextensions
RUN     mkdir -p /usr/local/airflow/.local/share/jupyter/preload_import_code
RUN     echo "define([ 'base/js/namespace' ], function( Jupyter ) { function load_ipython_extension() { if (Jupyter.notebook.get_cells().length===1){ //change this piece of code to what you want Jupyter.notebook.insert_cell_above('code', 0).set_text(\"import os, sys;\"); } } return { load_ipython_extension: load_ipython_extension }; });" >> /usr/local/airflow/.local/share/jupyter/preload_import_code/main.js
RUN     jupyter nbextension enable --sys-prefix preload_import_code/main

With the current similar answers and questions, I am unable to have my configuration either due to error or because ipython is used.
While running, I get the following error on this step:
Step 36/41 : RUN     jupyter nbextension enable --sys-prefix preload_import_code/main
 ---> Running in c56e28731e36
Enabling notebook extension preload_import_code/main...
      - Validating: problems found:
        - require?  X preload_import_code/main
Removing intermediate container c56e28731e36
 ---> ea0c6505dd57

Answer: I used a different approach, specific to ipython in here(https://stackoverflow.com/a/56216780/10834788).


Missing files in /home directory after boot crash during software update

Question: I'm using Ubuntu 14.04; during a routine software update the PC crash for some reason. Here is the situation now:

Looping during desktop log-in: each time I try to log-in via the desktop it loops back to the same screen.
ctrl + alt + F1 and SSH log-ins work and I can browse the file directory.
Problem ->  /home directory is missing all the files and folders! There are indications that files are still on the hard drive (i.e. disk usage ~17GB data on it etc.)
Used "TestDisk" to make an image and PhotoRec to extract whatever I can. There are snippets of my files here and there but all scattered.

Any suggestions or help would be greatly appreciated.
Update: This message shows up too: "No directory logging in with home=/"
Update: Running "lsblk" outputs
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 931.5G  0 disk
sda1   8:1    0   100M  0 part
sda2   8:2    0   600G  0 part
sda3   8:3    0     1K  0 part
sda5   8:5    0   3.7G  0 part [SWAP]
sda6   8:6    0 327.7G  0 part /
sdb      8:16   0 238.5G  0 disk
sdb1   8:17   0   128M  0 part
sdb2   8:18   0 238.4G  0 part

Running df -h outputs
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda6       323G   17G  290G   6% /
none            4.0K     0  4.0K   0% /sys/fs/cgroup
udev             16G  4.0K   16G   1% /dev
tmpfs           3.2G  1.3M  3.2G   1% /run
none            5.0M     0  5.0M   0% /run/lock
none             16G  144K   16G   1% /run/shm
none            100M   40K  100M   1% /run/user

Update: Running ls -la outputs:
total 116
drwxr-xr-x  26 root root  4096 Sep 17 21:37 .
drwxr-xr-x  26 root root  4096 Sep 17 21:37 ..
drwxr-xr-x   2 root root  4096 Sep 14 15:53 bin
drwxr-xr-x   3 root root  4096 Sep 14 16:14 boot
drwx------   3 root root  4096 Sep 14 15:33 .cache
drwxrwxr-x   2 root root  4096 May 23 17:50 cdrom
drwxr-xr-x  15 root root  4180 Sep 18 11:52 dev
drwxr-xr-x 135 root root 12288 Sep 18 11:52 etc
drwxr-xr-x   2 root root  4096 Sep 14 15:20 home
lrwxrwxrwx   1 root root    33 Sep 14 14:59 initrd.img -> boot/initrd.img-3.13.0-35-generic
lrwxrwxrwx   1 root root    33 Aug 27 10:33 initrd.img.old -> boot/initrd.img-3.13.0-34-generic
drwxr-xr-x  24 root root  4096 Sep 14 16:14 lib
drwxr-xr-x   2 root root  4096 Sep 14 14:56 lib32
drwxr-xr-x   2 root root  4096 Sep 14 14:56 lib64
drwx------   2 root root 16384 May 23 17:48 lost+found
drwxr-xr-x   3 root root  4096 May 23 18:02 media
drwxr-xr-x   4 root root  4096 May 23 19:45 mnt
drwxr-xr-x   3 root root  4096 May 24 18:31 opt
dr-xr-xr-x 166 root root     0 Sep 18 04:52 proc
drwx------  10 root root  4096 Sep 14 17:02 root
drwxr-xr-x   2 root root  4096 Jul  6 08:41 .rpmdb
drwxr-xr-x  22 root root   760 Sep 18 11:54 run
drwxr-xr-x   2 root root 12288 Sep 14 16:14 sbin
drwxr-xr-x   2 root root  4096 Apr 16 18:21 srv
dr-xr-xr-x  13 root root     0 Sep 18 04:52 sys
drwxrwxrwt   4 root root  4096 Sep 18 11:54 tmp
drwxr-xr-x  11 root root  4096 May 24 18:15 usr
drwxr-xr-x  13 root root  4096 Apr 16 18:29 var
lrwxrwxrwx   1 root root    30 Sep 14 14:59 vmlinuz -> boot/vmlinuz-3.13.0-35-generic
lrwxrwxrwx   1 root root    30 Aug 27 10:33 vmlinuz.old -> boot/vmlinuz-3.13.0-34-generic

ls -la /home output:
total 8
drwxr-xr-x  2 root root 4096 Sep 14 15:20 .
drwxr-xr-x 26 root root 4096 Sep 17 21:37 ..

Comment: Does [this](http://askubuntu.com/questions/300682/what-represent-xauthority-file) help?
Comment: Thanks! I haven't tried this yet.  The bigger problem is why the /home directory is empty! Any suggestions?
Comment: /home was a folder or a mount point?
If /home was a mount point, try to mount this partition
Comment: Could you pls give me '$ lsblk' and '$ df -h' output?
Comment: @Sprite8bit: /home was a folder. see update in post for command outputs
Comment: Where was your HOME directory before the crash, on sda6 or sda2 (which seems to be a large (data?) partition?
Comment: It wad on sda6.
Comment: AHA, could you run `ls -la /`? What is your main goal: saving the files or reparing the system?
Comment: ls -la / outputs a whole bunch of stuff. Is there something specific I can post? Goal is to recover and saved files which appear to be on the system, but not showing up
Comment: I assume it still is, but it is either renamed, invisible, moved etc. The `ls -la` could/should give us a hunch of where to look. BTW, could you use @(myname) to ping me, else I would have to keep the window open all the time :)
Comment: @JacobVlijm, thanks for the note. Ls -la output has been added the original post.
Comment: There appears to be a `/home` directory. If you run `ls la /home` is there a subdirectory that *could* be a renamed version of your original home folder? (and if so, `ls -la` again in that folder to see if you recognize anything)
Comment: @JacobVlijm: right /home exists, but it appears to be empty and that is where all the files were stored. See post.
Comment: silly question, I am a bit lost, but are you sure your /home was not on sda2? There seems no sign of a previous HOME folder. I will look around, I remember something that could be realated.
Comment: @JacobVlijm, no it is on sda6. Thanks, any help is appreciated! I know, it is an odd situation.
Comment: One more: could you run *sudo* `ls -la /home`? does that make a difference?
Comment: @JacobVlijm, I'm logged in as root. The output is still the same.
Comment: Ah, should have read your post better, you already mentioned /home was empty :(
Comment: got the same problem, did you manage to solve it?
Answer: Try to use sudo ecryptfs-mount-private.


How do I change textbox font back to default and clear default text when click or tabbed to?

Question: In a C# Windows Form App, how do I programatically make it to when a user clicks (or tabs) on/(to) a textbox,  the default text is cleared and reverts the font styling back to windows default?
I am just doing a basic form for testing.  I am not going to include the code that I am using that fails, because I've tried so many different things.  I sort of need to get help filling in the blanks.  I will have the text in the textBox grey and italicized.  When the textbox is tabbed to or clicked the text needs to disappear and the font style and color need to be set back to windows default.  I have spent all day messing with this, and I know it should be simple but I cannot, for the life of me, figure it out.  SOS!  Most information I see on the web has ASP, HTML, and Java, but I cannot seem to stumble on a C# example.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication5
{
public partial class Form1 : Form
{

    public Form1()
    {
        InitializeComponent();
    }

    private void textBox1_Click(object sender, EventArgs e)
    {

    }

    private void Form1_Load(object sender, EventArgs e)
    {

    }

    private void button1_Click(object sender, EventArgs e)
    {

    }

}
}

I have searched the extensively and cannot find a good example written in C#.  I ran accross a page several days ago, but wasn't yet on the market for this, so I paid no attention to it and now I cannot find it again. I tried several methods and now I am all confused.
Answer: You need to store a value to indicate that the text has been changed. I would consider creating a derived TextBox like the following:
///
/// Represents a Windows TextBox control that displays placeholder text when the
/// control is empty.
///
public class PlaceholderTextBox : TextBox
{
    private bool _set;
    private Color _valueForeColor;
    private Color _valueBackColor;
    private Font _valueFont;
    private Color? _PlaceholderForeColor;
    private Color? _PlaceholderBackColor;
    private Font _PlaceholderFont;

    ///
    /// Gets or sets the text that is shown when the <see cref="TextBox"/> is empty.
    ///
    [Browsable(true)]
    [Category("Appearance")]
    [Description ("The text that is shown when the TextBox is empty.")]
    [DefaultValue("")]
    public string PlaceholderText { get; set; }

    ///
    /// Gets or sets the <see cref="Color"/> of the placeholder text.
    ///
    [Browsable(true)]
    [Category("Appearance")]
    [Description("The color of the placeholder text.")]
    public Color PlaceholderForeColor
    {
        get { return _PlaceholderForeColor ?? _valueForeColor; }
        set
        {
            if (value == _valueForeColor)
                _PlaceholderForeColor = null;
            else
                _PlaceholderForeColor = value;
        }
    }

    ///
    /// Gets or sets the <see cref="Color"/> of the background when displaying placeholder text.
    ///
    [Browsable(true)]
    [Category("Appearance")]
    [Description("The color of the background when displaying placeholder text.")]
    public Color PlaceholderBackColor
    {
        get { return _PlaceholderBackColor ?? _valueBackColor; }
        set
        {
            if (value == _valueBackColor)
                _PlaceholderBackColor = null;
            else
                _PlaceholderBackColor = value;
        }
    }

    ///
    /// Gets or sets the <see cref="Font"/> used by the control when displaying placeholder text.
    ///
    [Browsable(true)]
    [Category("Appearance")]
    [Description("the Font used by the control when displaying placeholder text.")]
    public Font PlaceholderFont
    {
        get { return _PlaceholderFont ?? Font; }
        set { _PlaceholderFont = value.Equals(Font) ? null : value; }
    }

    ///
    /// Gets or sets the foreground color of the control.
    ///
    /// <returns>
    /// A <see cref="Color"/> that represents the control's foreground color.
    /// </returns>
    public override Color ForeColor
    {
        get { return _valueForeColor; }
        set
        {
            _valueForeColor = value;
            if(_set)
                base.ForeColor = value;
        }
    }

    ///
    /// Gets or sets the background color of the control.
    ///
    /// <returns>
    /// A <see cref="Color"/> that represents the background of the control.
    /// </returns>
    public override Color BackColor
    {
        get { return _valueBackColor; }
        set
        {
            _valueBackColor = value;
            if(_set)
                base.BackColor = value;
        }
    }

    ///
    /// Gets or sets the font of the text displayed by the control.
    ///
    /// <returns>
    /// The <see cref="Font"/> to apply to the text displayed by the control.
    /// The default is the value of the <see cref="Control.DefaultFont"/> property.
    /// </returns>
    public override Font Font
    {
        get { return _valueFont; }
        set
        {
            _valueFont = value;
            if(_set)
                base.Font = value;
        }
    }

    public PlaceholderTextBox()
    {
        _valueForeColor = base.ForeColor;
        _valueBackColor = base.BackColor;
        _valueFont = base.Font;
    }

    ///
    /// Raises the <see cref="E:System.Windows.Forms.Control.GotFocus"/> event.
    ///
    /// <param name="e">An <see cref="T:System.EventArgs"/> that contains the event data.</param>
    protected override void OnGotFocus(EventArgs e)
    {
        if (!_set)
        {
            Text = String.Empty;
            base.ForeColor = _valueForeColor;
            base.BackColor = _valueBackColor;
            base.Font = _valueFont;
            _set = true;
        }

        base.OnGotFocus(e);
    }

    ///
    /// Raises the <see cref="E:System.Windows.Forms.Control.LostFocus"/> event.
    ///
    /// <param name="e">An <see cref="T:System.EventArgs"/> that contains the event data. </param>
    protected override void OnLostFocus(EventArgs e)
    {
        if (Text == String.Empty)
        {
            Text = PlaceholderText;
            base.ForeColor = PlaceholderForeColor;
            base.BackColor = PlaceholderBackColor;
            base.Font = PlaceholderFont;
            _set = false;
        }

        base.OnLostFocus(e);
    }
}

Comment: I really think the OP knows how to set the placeholder text and just needs to know that the `GotFocus` event exists. However, this is an elegant, total solution that the OP should definitely consider.
Comment: I was lying in bed last night reading this post.  This looks to be exactly like what i need.  I am at wqork now today.  i am not a programmer.  I took a little bit of C++ in college several years ago.  i can piece working C# together by the skin of my teeth with the help of you guys here on StackOverflow, and Google.  I have been reading through  some beginner tutorials for C# and i slightly understand many of the concepts.  I am just lost about where the placement of this code will go, and how to apply this class to my textbox.  i need someone to hold my hand on this a little more.  SOS!
Comment: @HoustoneD: I actually wrote a complete implementation of this class because it's really pretty useful. Please check out the update code in the answer. **To use**: Copy the entire class into a new file in your project and recompile the solution. Now open up the designer toolbox, and you should see a new section titled " Components" with the PlaceholderTextBox control in it. You can now use the control just like a normal textbox, but you will have four additional properties in the Appearance section that let you control the placeholder text and appearance.
Comment: Awesome!  Thank you sir.  I'll be giving this a shot soon.  I have a had a few drinks tonight and don't have the capacity to implement this at the moment.  I will probably wait until i am on on the clock monday to do this.  You are the man! thanks again.  i'll let you know if i have any problems.
Answer: Might the GotFocus event work for you?


How React Redux Reselect manages previous arguments?

Question: How does React Redux Reselect manages the previous arguments and where and that will be compared with the current arguments?
Answer: It looks like the previous arguments are encapsulated within their own memoization code. If you need to access a previous state of your application, it may be worthwhile looking into a separate middleware like this: https://github.com/omnidan/redux-undo


Need help in solving integral

Question: $$\int\frac{dx}{(z^{2}+x^{2})^{3/2}}$$
I arrived at this after a substitution $t=x/z$:
$$\frac{1}{z^{2}}\int\frac{dt}{(1+t^{2})^{3/2}}$$
but now stuck with that 3/2 in the exponent.
Comment: Try the standard substitution $x=z \tan(t)$.
Comment: Try a trigonometric substitution: construct a right triangle with catheti $z$ and $x$, and see what happens...
Answer: Let us substitute $x = z \tan(t)$. Differentiating we get
$ dx = \frac{z\, dt}{\cos^2(t)}$. Now,
$$ \int \frac{z\,dt}{\cos^2(t) z^3 (1+\tan^2(t))^{3/2}}=$$
$$ \frac{1}{z^2} \int \frac{dt}{\cos^2(t) (\frac{1}{\cos^2(t)})^{3/2}}=$$
$$ \frac{1}{z^2} \int \cos(t) \,dt=  \frac{1}{z^2} \sin(t) + C = $$
$$ \frac{1}{z^2} \frac{x}{\sqrt{z^2+x^2}} + C,$$
where the back-substitution is done (as in the above remark by Matemáticos Chibchas) by constructing a right triangle.
Comment: Hi Teddy, in 2nd passage shouldn't it be $\int|\cos t|dt$ ?
Comment: Formally you're right. However, $x$ runs over all real values as $t\in (-\pi/2, \pi /2)$, and in this last interval, $\cos(t)>0$.
Comment: Oh, I've missed it. Then it is perfectly fair to omit the |.|.
Answer: You can also try a hyperbolic substitution:
$$\frac{x}{z}=\sinh u\Longrightarrow dx=z\cosh u$$
$$\int\frac{dx}{(z^2+x^2)^{3/2}}=\frac{1}{z^3}\int z\cosh u\; du\frac{1}{(1+\sinh^2u)^{3/2}}=\frac{1}{z^2}\int\frac{du}{\cosh^2 u}=$$
$$=\frac{2}{z^2}\int\frac{e^udu}{e^{2u}+1}=\frac{2}{z^2}\arctan e^u+C\ldots$$

Need help in solving integral


My flash player not autoplaying in Chrome version 45

Question: With Chrome version 45, "Chrome Now Automatically Pauses Flash Content That Isn't 'Central' To A Web Page".
How does chrome determine 'Central' content?
On my web page there is only one player on top left. This is flash based. The business requirement is to auto play the content whenever the page loads but it seems chrome latest version does not allow to autoplay the content and instead displays a Play icon on it. How does Chrome determines Central content? I tried to put the focus on the player but still it does not autoplay.
Is there a way we can overwrite chrome setting through UI to "Run all plugin content" under content settings?
Is there any other alternative that i can try. Any inputs will be appreciated.
Thank You!
Regards,
Hakim
Answer: Ok, I got the solution for my issue.
Chrome requires minimum height, width, aspect ratio for it to consider the player as central/important content of the page. In my case the height of the player was 267px and for chrome the min needed is 298 (see below link). I changed it to 298px and it worked :)
Please see below link/code if you need more details:
https://code.google.com/p/chromium/codesearch/#chromium/src/content/renderer/peripheral_content_heuristic.cc


What is the program "Additional Drivers" (jockey-gtk) talking me about?

Question: The program says:
<code>"No proprietary drivers are in use on this system"
</code>
But it doesn't say if it is talking about graphical drivers only or what.
Then, it lists two drivers:
<code>NVIDIA accelerated graphics driver (version 173).
NVIDIA accelerated graphics driver (version current) [recomended]
</code>
Both have exactly the same description. What is the difference between them, then??. Moreover,

When I select the 1st one, it says: "This driver is not activated",and there's a button to "activate" it.
When I select the 2nd one, it says: "This driver is activated but it is not currently in use", and the button is to "remove".

So, which one is in use?. Why, or what for, should I have one activated (enabled) but not in use? If a driver is in use it means it is activated? (as I see it can be activated but not in use).
What is the difference between deactivate and remove?, and what is the relationship between: installed, activated, in use, and enabled; and between: removed, disabled, inactive and not-installed?
Why can I activate the inactivated and remove (but not deactivate) the activated that is not in use?
All this is very puzzling...
What other drivers can I use for an Apple MacBook pro 3,1 and how? I see that there's a nouveau and I heard that there was going to be a new open source even better.
<code>> -display
>        description: VGA compatible controller
>        product: G84 [GeForce 8600M GT]
>        vendor: nVidia Corporation
</code>
PLEASE STOP DELETING THIS:
1.As I have written several times, the system is Natty, and the questions remain the same.
2. The package nvidia-current is installed.
Answer: The difference between each proprietary driver is explained in my answer here: https://askubuntu.com/a/218181/7035
Since you are a Geforce 8600M GT then in my answer you can find which one to install.
Along with that, the "No proprietary drivers are in use on this system" message appears since there could be other proprietary drivers apart from the video card. There are other proprietary drivers that the Additional Drivers checks when looking for proprietary drivers, some are:

Video Drivers (Most common reason to use Proprietary Drivers)
Wireless Drivers (Like Broadcom. Second most used Proprietary Driver)
Modem Drivers
Others (Most can be found here: http://archive.ubuntu.com/ubuntu/pool/restricted/)

So the message simply states that it could not find any proprietary drivers IN USE in your system. Which means you have not yet installed any proprietary drivers.
For the mouthful of words when you asked: "What is the difference between activate and remove? and what is the relationship between installed, activated, in use, enabled and removed, disabled, inactive and not-installed?" all I can say is:
Active - When you are using a proprietary driver at that moment
Remove - Remove
Installed - You installed this proprietary driver but you are no using it at the moment.
Since you are asking that part I suggest you read on some proprietary driver installation problems from this question: https://askubuntu.com/a/194628/7035 also as yo mention, you are using 11.04. Going back to 11.04 and checking it out, I figure that, in that time, there was a version difference between both options (Version 173 and Version Current), but since Natty was still receiving updates (Ended on October of this year), both got to a point of having the same version, same description and basically installing the same one, but jockey on the other hand, did not update this so this could mean that:

Bug in Jockey that they forgot to remove the (Version 173) and leave the recommended
Both packages actually install the same package (But this still confuses the end user, since a single option should be made)

For both cases I really suggest upgrading the system, here are the reasons, specifically for your question:

Between 11.10, 12.04 and 12.10 there were many MANY bugs fixed in regards to jockey, so much so that jockey is not used as seen in 11.04 but rather a more friendly approach to installing and configuring proprietary driver.
Jockey is known to have some driver confusion from time to time and it was becoming hard to work with it (Examples like this) so some work was done to simplify jockey into the Update Manager and Software Sources.

My guess is that you are using 11.04 because of Gnome 2, which actually leaves me with little answers if you do not want to upgrade because of Unity/Gnome3 and performance penalties. My suggestion is, since you found a bug, publish it in Launchpad describing this same problem (Because if it confuses you, imagine how many other people will be confused by it also) and to install any of the 2 drivers, or simply go to the terminal and install the nvidia-current package.
Comment: It is really VERY confusing that after saying that there are NO proprietary drivers in use, then lists two: one is active (?) the other not, but non in use(?). Only two. Only video drivers are mentioned. Why those? A normal user cannot know why those two and why only those two. And the others?... you have to go and look somewhere else or what? Lack of information in an information system.
Comment: "Active - When you are using a proprietary driver at that moment"?? As I said, jockey says that I have an active driver, an inactive driver, and **non** of them is **in use**. The difference between remove and deactivate is not clear, either. I am going to check the links you suggest, thank you.
Comment: You should add to your question what version of Ubuntu you are talking about and if you updated that version.
Comment: Your first link is very informative, but it doesn't explain the difference between the two drivers that jockey-gtk lists in my case, and that have exactly the same descriptions. I'm using Natty in an Apple macbook-pro 3,1 (it is a pity my profile is disabled (or I don't know what, every week)), now but probably reinstall Pangolin here as soon as I know how to install properly grub so that I can boot from usb in this Apple with dual boot.
Comment: Updated answer since the explanation is too big to be in the comments.
Comment: 173 are the legacy drivers for old software, the recommended ones are the recent version. As Luis says, there was a bug with Nvidia and Jokey where the driver was installed but jokey complained it was not in use. That was fixed later on but you need to let us know what version from Ubuntu you are using.


Compute Quantile Function that uses an Indicator function

Question: I have to calculate the Quantile Function,
$$
F^{-1}_{L}(1-0.05),
$$
where the distribution is given by $L=-(1-\textbf{1})$. Here $\textbf{1}$ is the indicator function with $P(\textbf{1}=1)=0.02$. Thus, inserting this we get,
$$
F^{-1}_{L}(1-0.05)=F^{-1}_{-(1-\textbf{1})}(0.95) = F^{-1}_{(\textbf{1}-1)}(0.95).
$$
Using the fact that $F^{-1}_{g(X)}(p)=g(F^{-1}_{X}(p))$ should yield that $F^{-1}_{(\textbf{1}-1)}(0.95)=F^{-1}_{\textbf{1}}(0.95)-1.$
Because the distribution function $F_{\textbf{1}}(1)=P(\textbf{1}\leq1)=1$, due to the indicator function only taking values $1$ or $0$, we get $F^{-1}_{\textbf{1}}(0.95)=1$. Thus,
$$
F^{-1}_{L}(1-0.05)=F^{-1}_{\textbf{1}}(0.95)-1=1-1=0.
$$
However, the short solution that I have says that $F^{-1}_{L}(1-0.05)=-1$. Could someone please show me how they arrived to that? What am I doing wrong?
Comment: Because your random variable takes on the value $0$ with probability $0.02$ and $-1$ with probability $0.98$. The quantile function evaluated at some $p$ gives you back the smallest value $x$ with $P(X \leq x) \geq p$. To put it another way, your whole computation was correct until you wrote $F_{\mathbf{1}}^{-1}(0.95)=1$, that's actually zero.
Comment: Is this $1$ just the constant number 1? Thus your random variable takes on the value $0$ with probability $0.02$ and $-1$ with probability $0.98$?
Comment: Are you talking about the "other" 1? In that case yes, it's just the constant number 1, i.e. $(1-\textbf{1})$ is "1 minus Indicator function". But how would this make the Quantile Function = -1?
Comment: Ah! Thank you @Ian! Would you want to give this as an answer? If so I would be more than happy to mark this question as answered
Answer: Your steps were correct all the way up until $F_{\mathbf{1}}^{-1}(0.95)=1$. This is actually $0$, since $P(\mathbf{1} \leq 0) = 0.98 \geq 0.95$, while $P(\mathbf{1} \leq a)=0$ for all $a<0$. Making this change gives the expected result.