Copy Object array values in textarea field

Question: I have multiple object arrays in js and i want to insert them into Textarea elements accordingly
I have provided a code snipped below to see what im trying to do
and the problem im haven is when you click the Paste button it only inserts the last values of the array.
How do i make the button to copy paste all the array values into the textarea?

var darkmode = {
    '1': {
    '--primary_button': '#000','--primary_button_font': '#ffffff'
    },
    '2': {
    '--primary_button': '#ffffff','--primary_button_font': '#000'
    }
};
    $('.tButton').on('click', function (event) {
      var val = $(this).attr('data-value'); //returns 1,2
        for (var i in darkmode[val]) {
          if (val === '1') {
              $('#scheme1 textarea').text([i] + ": " + darkmode[val][i]);

          }else if (val === '2') {
             $('#scheme2 textarea').text([i] + ": " + darkmode[val][i]);
          };

      };
    });

  <textarea name="theme"></textarea>
  <button class="tButton " data-value="1">Paste</button>

  <textarea name="theme"></textarea>
  <button class="tButton " data-value="2">Paste</button>

The snipped
Answer: Firstly, what is happening here is that every time you insert a value into the textarea, it is getting replaced with the latest value inserted and hence you get to see the last value only.
Instead of using text(), use append() which actually concats the inserted values to the element instead of replacing it.

var darkmode = {
    '1': {
    '--primary_button': '#000','--primary_button_font': '#ffffff'
    },
    '2': {
    '--primary_button': '#ffffff','--primary_button_font': '#000'
    }
};
    $('.tButton').on('click', function (event) {
      var val = $(this).attr('data-value'); //returns 1,2
        for (var i in darkmode[val]) {
          if (Number(val) === 1) {
              $('#scheme1 textarea').append([i] + ": " + darkmode[val][i]);

          }else if (Number(val) === 2) {
             $('#scheme2 textarea').append([i] + ": " + darkmode[val][i]);
          };

      };
    });

  <textarea name="theme"></textarea>
  <button class="tButton " data-value="1">Paste</button>

  <textarea name="theme"></textarea>
  <button class="tButton " data-value="2">Paste</button>

Answer:

var darkmode = {
  '1': {
    '--primary_button': '#000',
    '--primary_button_font': '#ffffff'
  },
  '2': {
    '--primary_button': '#ffffff',
    '--primary_button_font': '#000'
  },
  '3': {
    '--primary_button': '#fdfdfd',
    '--primary_button_font': '#fff'
  }
};
$('.tButton').on('click', function(event) {
  var getClickedElement = event.target.getAttribute('data-value')
  var val = $(this).attr('data-value');
  for (var i in darkmode[val]) {
    if (Number(val) == getClickedElement) {
      $('#scheme' + getClickedElement + ' textarea ').append([i] + ": " + darkmode[val][i]);
    }
  };
});

  <textarea name="theme"></textarea>
  <button class="tButton " data-value="1">Paste</button>

  <textarea name="theme"></textarea>
  <button class="tButton " data-value="2">Paste</button>

  <textarea name="theme"></textarea>
  <button class="tButton " data-value="3">Paste</button>

Note:- This will be the dynamic solution for multiple values...


Which Android Chart library I should Chose

Question: I just make a Pie Chart like below in Android System.
But i don't know which Chart library I should choose.
I try AchartEngine.But it not work.It can't do lots of things
I need the library can set X cordinate Unit,Y cordinate Unit.Like Day 1,Day 2;But AChartEngine can't do that.
I need draw a 3d Chart Engine below.

j4lChartAndroid can do that ?or anything else can do that?
Answer: For 3D charts I can suggest Orson Charts for Android (commercial, not free).
Answer: check this
http://steema.com/entry/60
and following
Java related charts
J4L charts
artful bits charts
steema charts
afreecharts
android plot
achart engine charts
Using Javascript charts are build . Below i have mentioned them
mcharts
opengl
fusion charts ... like this you can have many more building charts using javascript


Passing Vue data to php

Question: I want to pass a data from vue props to php code. My code looks something like this:<input type="text" value="" @{{props.correct}} class="d-none" name="correct">
Comment: Vue is javascript and javascript talks with php by ajax
Comment: please specify the php code? controller or blade or something else?
Comment: i used the blade
Comment: actually, i just want to put the value of the props.question as the value of the input element
Comment: i see. are they on othe same file ?  bind the value if not then u need to pass the variable to your parent component until it reaches where you put your vue on your blade then call like that. i assume since you use blade they are on the same blade/file all?
Answer: You can pass vue (input) data to PHP by using AJAX Request (e.g. you can sending them as json to your server)
Answer: Have you tried binding property with attribute name?
<input type="text" value="" :attribute-name="props.correct" class="d-none" name="correct">

Comment: my bad, it should be like this
Comment: Yeah, you can use v-bind with any attribute, like value also.

Passing Vue data to php


Efficient countByValue of each column Spark Streaming

Question: I want to find countByValues of each column in my data. I can find countByValue() for each column (e.g. 2 columns now) in basic batch RDD as fallows:
scala> val double = sc.textFile("double.csv")
scala> val counts = sc.parallelize((0 to 1).map(index => {
     double.map(x=> { val token = x.split(",")
     (math.round(token(index).toDouble))
     }).countByValue()
     }))
scala> counts.take(2)
res20: Array[scala.collection.Map[Long,Long]] = Array(Map(2 -> 5, 1 -> 5), Map(4 -> 5, 5 -> 5))

Now I want to perform same with DStreams. I have windowedDStream and want to countByValue on each column. My data has 50 columns. I have done it as fallows:
val windowedDStream = myDStream.window(Seconds(2), Seconds(2)).cache()
ssc.sparkContext.parallelize((0 to 49).map(index=> {
val counts = windowedDStream.map(x=> { val token = x.split(",")
                                (math.round(token(index).toDouble))
                                }).countByValue()
counts.print()
}))
val topCounts = counts.map . . . .  will not work

I get correct results with this, the only issue is that I want to apply more operations on counts and it's not available outside map.
Comment: Why do you do `parallelize`? What good does a 2 (or 50) element RDD do?
Comment: I am doing parallelize to process all the columns in parallel. I can use a simple loop, but then i believe it will be less efficient. There are 50 column and each column is independent. I can do topCounts() just after .countByValue but it makes the application slow. Format is like Time, sensor1, sensor2 . . . . . . sensor50. This is not real stream but file read as DStream. I dont need on time so we can do it from 1 to 49.
Comment: Why do you use streams if the input is not a stream?
Comment: yes a good question. I use streams because it has applications in real life problem. Actually my data is eeg data. Although it is in csv file format now but later the work can be used to process eeg data at real time.
Answer: You misunderstand what parallelize does. You think when you give it a Seq of two elements, those two elements will be calculated in parallel. That it not the case and it would be impossible for it to be the case.
What parallelize actually does is it creates an RDD from the Seq that you provided.
To try to illuminate this, consider that this:
val countsRDD = sc.parallelize((0 to 1).map { index =>
  double.map { x =>
    val token = x.split(",")
    math.round(token(index).toDouble)
  }.countByValue()
})

Is equal to this:
val counts = (0 to 1).map { index =>
  double.map { x =>
    val token = x.split(",")
    math.round(token(index).toDouble)
  }.countByValue()
}
val countsRDD = sc.parallelize(counts)

By the time parallelize runs, the work has already been performed. parallelize cannot retroactively make it so that the calculation happened in parallel.
The solution to your problem is to not use parallelize. It is entirely pointless.
Comment: Just do the simple loop. There is nothing to be gained by parallelizing the loop. Even if you process one column at a time, that column is broken up and the pieces processed in parallel. So you don't need to parallelize the loop to use all the available cores.
Comment: Thanks @Daniel I go it. But is there a way to apply same operations on multiple columns of RDD. I know one can use DataFrames but if I don't want to use DataFrames, what are other options.


bringing local storage page to page not working

Question: I have a select element that changes the theme of my website. In it, I use local storage to change the theme on every page, even though the changer is just on the home page. It sets the local storage key, but I can't get it to pull up on the other pages. It works on the home page, though. My code to retrieve the local storage is
function setTheme() {
theme = window.localStorage.getItem('theme');
document.getElementById('themepicker').setAttribute('href', theme);
document.getElementById(theme).setAttribute('selected', 'selected');
}

The code that changes it is
        function changeTheme(theme) {
        sltr = document.getElementById('themepicker');
        theme = theme + '.css';
        sltr.setAttribute('href', theme);
        window.localStorage.setItem('theme', theme);
    }

The function is run when the page is loaded.
Comment: is it possible your homepage has a different domain name than your other site pages?  even if it's something simple like one uses a `www.` and the others don't?
Comment: where are you running `window.localStorage.setItem('theme', theme);`?
Comment: The Homepage of the site
Comment: can you either post the full code for both set and load, or make an online demo?
Comment: I just updated it
Comment: No, unless using github pages counts
Answer: The problem is you are only resetting theme to theme instead change the theme to the new theme and theme was never defined or set to the new theme.
Comment: Could you explain that again. I don't get it when there are 6 themes in one sentence


Flex wrap items at larger breakpoint, while overflow scrolling at smallest

Question: I am trying to accommodate a responsive design that has horizontally-scrolling rows of a varying number of items at the mobile breakpoint, but that dumps all items into one big wrapping row on desktop (aligned left, no overflow or scrolling). I've got mobile working as I intend, but am struggling with desktop.
/*SCSS*/
$spacer: 8px;
$border: 1px solid #c3c1c0;

.category-flex-outer-container {
  margin: ($spacer*2) (-$spacer*4) ($spacer*2) (-$spacer*4);

    h3 {
      margin: $spacer*2 $spacer*4;
      position: absolute;
      }
}

/* testing only */
.category-flex-item {
  border: $border;
  display: flex;
  margin: $spacer*2;
  padding: $spacer*2;
  text-align: center;
  width: 220px;
}

/* END testing only */

.category-flex-inner-container {
  background: #fff;
  padding: $spacer*6 $spacer*2 $spacer*2;

  /* testing only */
  &.one {
    .category-flex-item {
      background: #d14124;
    }
  }

  &.two {
    .category-flex-item {
      background: #44a705;
    }
  }

  &.three {
    .category-flex-item {
      background: #008eaa;
    }
  }

  &.four {
    .category-flex-item {
      background: #ebbc4e;
    }
  }

  /* END testing only */
}

@media (max-width: 768px) {
  .category-flex-inner-container {
    display: inline-flex;
  }

  .category-flex-outer-container {
    overflow: scroll;
  }
}

@media (min-width: 768px) {
  .category-flex-wrapper {
    display: flex;
    justify-content: space-around;
  }

  .category-flex-outer-container {
    width: 20%;

    h3 {
      display: none;
    }
  }

  .category-flex-item {
    width: 100%;
  }
}

Heading 1

                 1

                 2

                 3

Heading 2

               4

            5

            6

Heading 3

            7

            8

            9

            10

Heading 4

            11

            12

            13

https://jsfiddle.net/Razzle/5hmdLgba/19/
Desired desktop design
Comment: I don't get much of the logic in this case on why you would want the `10` to be below `3` instead of putting it above `11` and push `13` down below `3`. You would most likely need to use js to add any "left-over" per column (when over 3 items) to the next "set" (after the first 12 items from 4 different categories)
Comment: Yeah, fair point re: the numbers. That was more for me to understand the flex direction. Thank you for the response.
Comment: Would you need js to put 10 above 11 and push 13 down below 3?
Comment: yes and no, it depends on your logic and what you are wanting to achieve here. Is there a reason you want it to go from top to bottom up to 3 rows before you fill the next set of 3 by 4 instead of just filling the page left to right, row by row?
Comment: Nope, I just want it to fill the page left to right, row by row.
Answer: If you just want it to fill ltr and row by row, then this should do it.

.text-small{
  font-size:14px;
}
.flex-container {
  padding: 0;
  margin: 0;
  list-style: none;

  display: -webkit-box;
  display: -moz-box;
  display: -ms-flexbox;
  display: -webkit-flex;
  display: flex;

  -webkit-flex-flow: row wrap;
  justify-content: flex-start;
}

.flex-item {
  background: tomato;
  padding: 5px;
  width: calc(25% - 20px);
  height: auto;
  margin: 5px;

  color: white;
  font-weight: bold;
  font-size: 3em;
  text-align: center;
}

@media only screen and (max-width: 600px) {
.flex-item{
  width: 100%;
}
}

1

2

3

4

5

6

7

8

9

10

  Extend Entire Row to the same max height

11

12

13

Comment: Thank you, but I need the items to be broken up by rows that overflow at the mobile breakpoint.


How to calculate compounding frequency for an loan (Using Lambert-W Function)

Question:
A bond will become worth 500 dollars when it becomes due in 5 years. If the bond was purchased today for 450 dollars at 2.13% per year, determine how frequently the interest was compounded.

I tried to solve the question with trial and error, but is there a better way to solve it?
The function looks like this:
$$500 = 450(1 +{0.0213\over x})^{5x}$$
Answer: Consider the more general case of the equation
$$a=\left(1+\frac{b}{x}\right)^{c x}$$ The solution of it is given in terms of Lambert function. I shall skip all intermediate steps and just provide the result; it write
$$x=-\frac{b \log (a)}{\log (a)+b\, c\, W_{-1}(-t)}\qquad \text{where} \qquad t=\frac{ a^{-\frac{1}{b\, c}}}{b \,c}\log (a)$$
Just remember than any equation which can write or rewrite as
$$A+B x+C \log(D+Ex)=0$$ has solution(s) i terms of Lambert function.
For your specific problem, since graphing, you see that the solution is close to $x=1$, you could have done the following : take logarithms of both sides and use Taylor expansion around $x=1$. Working with whole numbers you would get
$$\left(5 \log \left(\frac{10213}{10000}\right)-\log
   \left(\frac{10}{9}\right)\right)+(x-1) \left(5 \log
   \left(\frac{10213}{10000}\right)-\frac{1065}{10213}\right)+O\left((x-1)^2\right)$$ and ignoring the higher order terms, this would give, as an approximation,
$$x=1-\frac{10213 \left(5 \log \left(\frac{10213}{10000}\right)-\log
   \left(\frac{10}{9}\right)\right)}{5 \left(10213 \log
   \left(\frac{10213}{10000}\right)-213\right)}\approx 0.98086$$ while the exact solution is $0.98121$.
Comment: The explanation is really good, wish I could give you an upvote if I am reputation 15
Comment: @KevinXu. You are very welcome ! I upvoted you question because it reveals an intelligent attitude (curiosity). Cheers :-)


pixel error numix

Question: I use Ubuntu 16.04 with the numix-gtk theme from the official repos.
But I see a pixel error how can I solve this?
Answer: This is not an issue with a newer version from Numix official PPA.

Delete the theme you installed from the official repos, and:
<code>sudo add-apt-repository ppa:numix/ppa
sudo apt-get update
sudo apt-get install-numix-gtk-theme
</code>
When you enable the theme for the first time it for some reasons will show white lines near the top border, but after a restart it will all be perfect.

pixel error numix


How do you feed a chicken in Mine Blocks?

Question: I don't know how and need help.
Answer: In mineblocks it's impossible to feed a chicken. Sorry.


What does BST mean?

Question: I played FE Sacred Stones, Blazing Sword and Blinding Blade (until ch13) before playing FE Heroes. I can't wait for Tana to be out on FEH.
Anyways, I've been checking guides on Gamepress on tiers and stuff and they mention that some heroes have "Low BST".
I may not have looked hard enough but I couldn't find any place explaining what it is. I haven't read about it in League of Legends or other games I've played either.
My best guess is "Burst" but I don't think there's much point in removing just 2 letters.
Answer: From what I've read in several pages I guess the BST is some kind of internal value the game assigns to a character to quantify it's potential. Allowing to establish some kind of balance for the Arena and other multiplayer game modes.
This is the link that helped me the most on understanding this. Since I'm not able to find an oficial description of the concept I would suggest to wait for a more accurate answer.
Edit:
Just found out this page where explains how the Arena and some of it's mechanics actually works and mentions the BST:

Once you master winning 7 Advanced battles at max level without any of
  your units dying; the only way to increase your Offense score is by
  using units with a higher stat total. Sometimes called BST (Base Stat
  Total) for short.

Also in this page is included a link to a list where you can check the BST of each character. The web page appears to be in japanese but it includes the characters portraits.
Comment: @Seiyial `I would suggest to wait for a more accurate answer` I guess we've waited long enough...
Answer: To summarize, a unit's BST (Base Stat Total) in Fire Emblem Heroes is the total value of his/her total stats in the game. For example, Lucina's neutral stats are 43/34/36/25/19, giving her a BST of 157. Keep in mind that the game does not factor in the might of the weapon (in Lucina's case, Falchion with a might of 16) into the total BST.
EDIT:
Last thing, the BST of your four units also affect how many points you recieve when playing an arena match, as mentioned by the user before me.
Answer: Based on the previous answer and the list of levels where the term BST is mentioned. I support the idea that BST is Base State Total, which is no more than an average of the basic statistics of the characters, if you look at the list of levels in which it is set "BST Low", which are usually in intermediate or low levels, Ie they may excel in some aspects (ATK, DEF, SPD ...) or have some good skill, but their set of statistics is not good and ends up being poor in any of these statistics.

What does BST mean?


ExtJS 5 Grid Cell Width Calculation Wrong Using Flex

Question: After upgrading to ExtJS 5 from 4.2.1 I discovered a grid cell width calculation issue or what appears to be an issue.
Here is an example of the columns
columns: [
    { header: 'One', dataIndex: 'one', flex: 2 },
    { header: 'Two', dataIndex: 'two', flex: 2 },
    { header: 'Three', dataIndex: 'three', flex: 3 }
]

The headers fill the grid width as expected but grid cell widths are not equal to the headers in amounts of -5px / -5px / -12 px respectively.
The appearance is as if there is room for a scroll bar but the grid has only one row.
Grids that have enough data to have a scroll bar do not appear to have this issue.
Resizing the grid column puts things back in a proper alignment until new data is loaded and rendered again with the width calculations off. It re-sizes soon after a new data load.
I thought that maybe css was to blame but changing themes did not fix it nor did using ext-all.css rather than the debug css.
Is this a bug or have I missed a new config that will correct the width calculations?

If this is a bug ... any suggestions for a work around?

Help much appreciated.

UPDATE 1:
I used Sencha Cmd to generate a basic app and created a grid view with the columns and a features.
So far it looks like having a grouping feature seems to be the culprit.
However, I do see the behavior on grids without a grouping feature.
Those grids are in a border layout so I'll investigate that next.
Comment: It does seem like a bug, but it will be close to impossible to be definitive about it without a proper test case.
Answer: It looks like bug, however I discovered that wrapping grid with container with auto layout make fixes that issue (at least in my case).
Example: http://jsfiddle.net/nj4nk/3/
In example you can see 2 grids:

first inside panel with fit layout - rows are narrower
second inside panel with auto layout - rows are same as header
Comment: Yes! Thanks so much for the fix. Using layout: 'auto' has corrected the issue. How do I create my own jsfiddle to share?
Comment: Spent so much time trying to fix this. All I had to do is add `layout: 'auto'`. Thanks for the fiddle!
Answer: Using layout:'auto' leaves scrolling broken.
It appears that space is being reserved for the scrollbar, but setting reserveScrollbar:false doesn't help.


Getting error 500 in response code in jmeter

Question: I have recorded a login transaction using Firefox. Now when i run via Jmeter I get Response code:500 and Response message:Internal Server Error. The same works fine when run manually.
I have done the correlation. Dunno where and what to check more?
Attaching the screen shot of the error.
enter image description hereenter image description hereenter image description hereenter image description here
Answer: As per 500 Internal Server Error description:

The HyperText Transfer Protocol (HTTP) 500 Internal Server Error server error response code indicates that the server encountered an unexpected condition that prevented it from fulfilling the request.
This error response is a generic "catch-all" response. Usually, this indicates the server cannot find a better 5xx error code to response. Sometimes, server administrators log error responses like the 500 status code with more details about the request to prevent the error from happening again in the future.

So if you want the reason - you need to check your server logs.
Additionally you might want to check whether your correlation really works, i.e. double check JMeter Variables originating from correlation using Debug Sampler and ensure that they're extracted fully and correctly. In certain cases you need to perform encoding or decoding of the extracted variable


Seemingly simple task of looping for a string in VBA

Question: I am having some trouble getting a loop to work in Excel VBA which searches cell E in each row for a string and then puts that string in cell N of that row.  Code is below:
Dim i As Long
For i = 1 To Rows.Count
Next i
If Cells(i, 5).InStr(1, ActiveSheet.Range("ActiveCell").Value, "Smith") > 0 Then
Cells(i, 14).ActiveCell = "Smith"
End If

Can anyone please give insight as to where I am going wrong?
Comment: See [For](https://www.google.ca/search?rlz=1C1AFAB_enCA478CA535&es_sm=93&q=for+microsoft+loop+vba&oq=for+microsoft+loop+vba&gs_l=serp.3..0i22i30l2.882.1329.0.18188.8.131.52.0.0.0.438.438.4-1.1.0....0...1c.1.51.serp..3.1.438.5yVjo0E7BNo).
Answer: Try:
Dim i As Long
For i = 1 To Rows.Count
    If Cells(i, 5).InStr(1, ActiveSheet.Range("ActiveCell").Value, "Smith") > 0 Then
        Cells(i, 14).ActiveCell = "Smith"
    End If
Next i

You were ending your loop before it even did anything.
I think you also need to replace
Cells(i, 14).ActiveCell = "Smith"

With
Cells(i, 14).Value = "Smith"


Are all Elementary Periodic Functions Trigonometric?

Question: Hypothesis:

Given a non constant differentiable periodic function $f(x),\ \mathbb{R}\to\mathbb{R}$, which has an explicit finite form involving
  only elementary functions. The expression for $f(x)$ must include trigonometric functions, or equivalently, complex exponents.

In other words, we can't construct a periodic function from only roots, real exponents, logarithms and polynomials.
Is there a simple proof or counter example for the above hypothesis?
Comment: It seems like it must be true but I'd imagine it would be quite tedious to prove. You'd want to show that all compositions of $x^n,e^x,\ln(x),\ldots$ are non-periodic but I can't imagine many simple ways of dealing with it other than going through each case. Maybe we could potentially try a set of inductive arguments (for each type of elementary function) that it either explodes or tends to a constant. At the very least, I see this needing about $7$ lemmas for each of $x^n, e^x,\ln(x),\ldots$.
Comment: Also, out of interest, why did you include the stipulation of differentiability? The elementary functions are closed under differentiation, so surely that's redundant?
Comment: @Jam - I'll agree that the elementary functions plus the finite requirement are enough.
Comment: Let $f_0(x)=x$ and for each $n$, $f_n(x) = H_n(f_0(x),\ldots,f_{n-1}(x))$ where $H_n$ is one of the operations allowed in the elementary functions (constant, addition, multiplication, exponentiation, $\log$, differentiation). Your elementary function is $f_N : \Bbb{R} \to \Bbb{R}$. If no $e^z$ appears in the $H_m, m \le n$  or if the imaginary part of the argument of $e^z$ is constant then $f_n$ is constant or $f_n^{-1}(a)$ is finite for every $a\in \Bbb{R}$ so $f_n$ can't be periodic.
Comment: @reuns This seems like a good answer but I'm a bit confused by it. What if we took $f_n=\frac{1}{x^2+1}$? It's neither constant nor has a finite inverse (since $f_n^{-1}(0)=\pm\infty$) but isn't periodic.
Answer: Partial answer.

If $f$ is a composition, then the last composed functions can be ignored if they are injective. Thus, for anything of the form $e^{h},h^{2n+1},\ln h,\ldots$, we need just consider $h(x)$.

Proof: Suppose we were to construct a periodic, composite function $f(x)=g\circ h(x)$, where $g$ is injective and thus aperiodic. Then $h$ must have already been periodic since it is trivially $h=g^{-1}\circ f$.

$f$ cannot be a rational function with an injective function as its variable.

Proof: If $f(x)$ were a periodic polynomial then, for some $x_0$, $f(x)-f(x_0)$ would be a polynomial with infinite roots, $x_0+nP$, where $P$ is a period and $n\in\mathbb{Z}$. This would violate  the fundamental theorem of algebra. This can be generalised to any rational function $r(x)=\frac{a(x)}{b(x)}$ since the polynomial $a(x)-r(x_0)b(x)$ would have infinite roots, $x_0+nP$. We can then generalise it further to $r\circ h(x)$ for any rational function, $r$, with an injective function, $h$, as its variable since it would have at most as many roots as $r(x)$. So all functions of the form $\frac{e^{2x}-3e^x}{e^{2x}+1},\frac{\ln(x)^2+1}{\ln(x)},\ldots$ cannot be periodic.
The question remains for combinations of different elementary functions such as $\frac{e^x+\ln(x)+\ldots}{x+\ldots}$. A difficulty in the problem is that the composition of two aperiodic, elementary functions can form a periodic function. For example, take $g(x)=\cos\sqrt{x}$ and $h(x)=x^2$. So too can the sum or product of two aperiodic, elementary functions. For instance, take $\left(\sin x+e^x\right)+\left(-e^x\right)$ or $\frac{\sin(x)}{e^x}\cdot e^x$.
Comment: An excellent start.
Comment: Notes: We might expect $f$ to be $\mathcal{O}(1)$, like $\sin x$ and $\cos x$ but alas, this wouldn't be the case for discontinuous periodic functions like $\tan x$. At the very least, it's apparent if $f$ tends to $+\infty$, it must do so on a bounded interval, otherwise it would be identically $+\infty$ everywhere. So $f$ also can't be a function explodes to $+\infty$ without discontinuities, e.g. $\frac{e^x}{x^2+1}$.
Comment: The tricky cases are ones like $f=\frac{a(x^2)}{b(x^2)}$ for $a(x)=e^x-3x^2+\frac{1}{x^2+1},\,b(x)=e^x$ since they are $\mathcal{O}(1)$ but it's not immediately obvious how many roots the numerator has - particularly if it's a heavily nested function. Also, we know that $f$ must not have a definable inverse at $\pm\infty$. Lastly, I think the best tactic would be to show that any non-constant function formed by successive addition, multiplication, exp and logs has only finitely many real roots (up to a constant). Despite seeming obvious, I can't think how to prove it.
Comment: On second thoughts, that tactic doesn't work. Take $f=\sqrt{x^2}+\sqrt{\left(x-1\right)^2}-1$, which has infinitely many roots: $x\in[0,1]$.
Answer: Yes. You are right. But I would like to propose a nearly-counterexample (which of course does not count, but still).
If you count the Bernoulli polynomials of negative order, then:
$$B_{-1}(x)+B_{-1}(1-x)=\psi^{(1)}(x)+\psi^{(1)}(1-x)=\pi^2 \csc^2 \pi x$$
This is a periodic function. And elementary. The only problem is, the Bernoulli polynomials of negative order are not polynomials or even elementary functions. But like Bernoulli polynomials of positive order they are cases of Hurwitz Zeta function.
Answer: No. For if you define $f:\mathrm R\to \mathrm R$ by the finite expression $$2x-x^2$$ for $$x\in [0,2]$$ and $$x^2-6x+8$$ for $$x\in [2,4],$$ and elsewhere by $$f(x)=f(x\pm 4),$$ then we see that this function is non-constant, differentiable, and periodic, yet contains no circular functions.
Comment: Nice try, but I don't count an 'if' statement as an elementary function.
Answer: If we consider $[x]$ to be elementary then $x-[x]$ is also periodic with period $=1$
Other than that, Only trigonometric functions are periodic as they are circular functions which repeat after an interval and all periodic functions are composed of trigonometric functions in some form or other.
Comment: Your example is not differentiable. Nor is the rest of the answer a proof.
Comment: The proof can be arrived using fourier series i guess you research it


I cannot move multiple files by drag and drop method

Question: I'm using Ubuntu 20.04.1 LTS.
My problem is when I want to move some files to another place, I'm selecting files then trying to move but the selections disappearing and this way I can move only one file. Or if I try to move with hold on 'ctrl' this time I can move every files except one.
I want to use drag and drop like in Windows OS
How can I solve this problem?
This is problem video, you may want to see:https://drive.google.com/file/d/1NZ5r-q3pp7gE5-HOIfjCSg_977-xckf4/view?usp=sharing
This is the first time I am asking a question in a forum. Sorry if I have any mistakes.
Comment: Restore Drag & Drop in Ubuntu 20.04
hope this link helps:
https://sudofry.com/2020/06/02/restore-drag-drop-in-ubuntu-20-04/
Comment: @eqzhou's solution worked for me
Answer:
click and drag the pointer over all of the files which you would like to select

hold down shift while you drag and drop them into the desired folder
Comment: This may not be a solution to his problem... I believe he rather needs the functionality which may be missing from his operating system.
Comment: As stated by the OP, this does not work. Doing this moves all the file except the one used to drag.


Extract all values in a string that occur after another substring in R

Question: Lets say I have a string:
fgjh=621729_&ioij_fgjh7=twenty-_-One-_-Forty

I want to extract the following substrings from this string:
1. "621729"
2. "twenty"
3. "One"
4. "Forty"

Basically I want to extract anything after the "fgjh=" substring and "fgjh7=" sub strings.
I've found that this formula works in excel:
=TRIM(RIGHT(SUBSTITUTE(A1,"fgjh=",REPT(" ",LEN(A1))),LEN(A1)))

But the excel file is too large and I need to perform the same operation in R
How would I deal with leading characters and trailing characters. Let's say the string was "lmnop_82137_hhgia=77789_pasdk_ikuk_fgjh=621729_&ioij_fgjh7=twenty--One--Forty_dsaoij_882390=lkuk" and I need to extract the data after "fgjh=" i.e 621729 and everything after "fgjh7=" to get only "twenty", "one" and "forty"
Answer: Using sub with regular expression is more flexible than splitting by position:
> sub(".*=(.*)_&.*", "\\1", "fgjh=621729_&ioij_fgjh7=twenty--One--Forty", )
[1] "621729"
> sub(".*=(.*)--.*--.*", "\\1", "fgjh=621729_&ioij_fgjh7=twenty--One--Forty", )
[1] "twenty"
> sub(".*--(.*)--.*", "\\1", "fgjh=621729_&ioij_fgjh7=twenty--One--Forty", )
[1] "One"
> sub(".*--(.*)$", "\\1", "fgjh=621729_&ioij_fgjh7=twenty--One--Forty", )
[1] "Forty"

In one line :
strsplit(sub(".*=(.*)_&.*=(.*)--(.*)--(.*)", "\\1\\|\\2\\|\\3\\|\\4",
  "fgjh=621729_&ioij_fgjh7=twenty--One--Forty" ), split="\\|")[[1]]

[1] "621729" "twenty" "One"    "Forty"

Answer: You could use the package stringr and the function str_match for example to parse out the interesting bits with regular expressions
> library(stringr)
> s <- "fgjh=621729_&ioij_fgjh7=twenty--One--Forty"

> str_match(s, "^fgjh=([0-9]+)_&ioij_fgjh7=(.+)--(.+)--(.+)$")
     [,1]                                         [,2]     [,3]     [,4]  [,5]
[1,] "fgjh=621729_&ioij_fgjh7=twenty--One--Forty" "621729" "twenty" "One" "Forty"

Answer: library(stringr)
unlist(strsplit(str_extract_all(string,'(?<=\\=)([^_]+)')[[1]],'--'))
[1] "621729" "twenty" "One"    "Forty"


jQuery .find need to ensure that both requirements are met before proceeding using tab through

Question: So I'm trying to tab between input fields and select fields in a sliding form. However, with the code that I have it skips over the last input field on the current section of the form or the last select field on the current section of the form, regardless of whether there is a select or input field respectively afterwards. I need the tab to make sure that there are no select fields after the last input field and vice versa. This is the code I have so far:
$(this).find('input:last,select:last').bind('keydown',function(e){

But I need to to function more like this:
$(this).find('input:last && select:last').bind('keydown',function(e){

But the above code is not possible. Any ideas?
Comment: @will The selected answer works for what I was needing. Thanks.
Answer: If I'm following correctly, perhaps jQuery's :input rather than each separately will work?
$(this).find(':input:last').bind('keydown', function(e) {

Answer: Instead of using the :last selector, you need to use the .last() method:
$(this).find('input, select').last().bind('keydown',function(e){

Reference for learning: .last()
Comment: @N +1 for the reference. Thanks for the help!
Answer: Try using the .add() method instead.
var $lastInput = $(this).find('input:last');
$lastInput.add($(this).find('select:last').bind('keydown', function(e) {


What happens to gadgets of players that leave a match

Question: I'd never leave comp nor do I actually play it, I'm asking about a casual game!
Say I'm a kapkan but for whatever reason I need to leave the game after the round has started. I've placed all 5 of my traps, what will happen to those once I've left the match, do they stay up and potentially help my team or do they also disappear with me?
Answer: They stay up. I don't even think grenades you threw that haven't exploded disappear when you leave.
Comment: Grenades are (as of this moment) persistent, I've been in a match where someone Teamkilled everyone and left before the grenade went off.


Possible to automatically reload instance after create or update?

Question: In our Rails 3.2.6 app, we have a model attribute named 'version' that is incremented at the database level whenever an instance is created or updated (via trigger). However, after we do a successful create or update, the new value set by the database is not being returned to our instance, unless we explicitly do an instance.reload.
Does anyone know of a way to have active record automatically reload the instance after persisting to the database?
Background
In our Rails 3.2.6 app, we have a 3 tables that each have a 'version' column. Across all 3 tables, the 'version' integer column needs to be incremented during each insert and update, and the 'version' must never repeat.
Simple solution: we've created a version_sequence in postgres that all 3 tables share. We have a small trigger that updates the version column of any record from these tables with the  nextval('version_sequence') value:
<code>  -- Resource Version Sequence
  CREATE SEQUENCE resource_versions_seq;

  -- Resource Version Trigger
  CREATE FUNCTION update_resource_version() RETURNS trigger AS $update_resource_version$
    BEGIN
      NEW.version := nextval('resource_versions_seq');
      RETURN NEW;
    END;
  $update_resource_version$ LANGUAGE plpgsql;
</code>
However, when we create, save, or update_attributes in active_record, the new 'version' value is not being reloaded after the record is persisted.
Answer: How about using the after_save callback?  In this callback you could fetch just that field and then set it on the model.  Something like this:
<code>class Thing < ActiveRecord::Base
  after_save :refresh_version

  def refresh_version
    self.version = Thing.find(self.id).select(:version)
  end

end
</code>
Comment: Ya, this is very close to what I came up with as well. I'm using an after_commit callback to reload the instance.
Comment: This question was a little bit of a DUH moment


Skip module with Maven enforcer

Question: I'm using enforcer plugin in a multi-node project in the root pom, but I have one testing module, that I don't really care to run the plugin there since it won't create any jar and is only for testing purposes. Is there any way to skip one of the modules in the plugin config?.
Checking the documentation I cannot find anything. Only how to ban some specific dependencies. https://maven.apache.org/enforcer/enforcer-rules/bannedDependencies.html
The solution to put the plugin in each sub-module is possible but it's dangerous, since if I create a new sub-module I might forget to add it there.
Here my plugin config.
      <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-enforcer-plugin</artifactId>
          <version>3.0.0-M3</version>
          <executions>
            <execution>
              <id>enforce-maven-version-and-dependencies</id>
              <goals>
                <goal>enforce</goal>
              </goals>
              <configuration>
                <rules>
                  <requireMavenVersion>
                    <version>3.3.9</version>
                  </requireMavenVersion>
                  <bannedDependencies>
                    <searchTransitive>true</searchTransitive>
                  </bannedDependencies>
                  <dependencyConvergence></dependencyConvergence>
                </rules>
              </configuration>
            </execution>
          </executions>
          <configuration>
            <fail>true</fail>
          </configuration>
        </plugin>

Answer: In the POM of the module, set enforcer.skip to true:
<properties>
  <enforcer.skip>true</enforcer.skip>
</properties>

Answer: Alternatively when building the specific module from command line you can use the following command option.
mvn -Denforcer.skip=true clean install
mvn -Denforcer.skip=true clean package

Comment: The `=true` is not necessary.
Comment: In PowerShell, use double quotes: `mvn clean package "-Denforcer.skip"`

Skip module with Maven enforcer


Why is Ubuntu forcing me to manually partion my drive?

Question: I am attempting to install Ubuntu 17.04 on a Dell XPS 15 via bootable USB drive. I progress through the first few slides in the installation process just fine, but when it comes time to allocate space on the SSD, Ubuntu skips asking me what "installation type" I would prefer, and instead proceeds directly to the "something else" option that involves manually partitioning the drive.
When I quit the installation process, Ubuntu strangely goes to a login screen, where it accepts any username I type in but determines any password to be incorrect. Furthermore, my SSD has four empty partitions of 1.12 GB, 11.94 GB, 450 MB, and 500 MB apiece that I believe were created during separate installation attempts. I am really at a loss, as I have never experienced an installation process like this before. Is there a fixable bug that I am not aware of that could be causing this?
Comment: The login screen you see is the live image. Yes it does not have any specific user that's why it probably accepts anything you type in. Your partition problem is a differen one. It seems your SSD is already partitioned, try manually deleting those and reinstalling. If it still doesn't work just do in manually, don't see the problem. Would recommend `/home` being seperated from `/` and `swap` should be ~2 times your ram (depends strongly on how much ram you have it could also be enough to have 1:1).
Comment: Don't think it is a bug. More likely, the installer detects four primary partitions, in which case it can't create any more partitions, and so, it offers the user to deal with it.
Comment: @Ziazis In 17.04, Ubuntu uses swap files as default, and not swap partitions. https://askubuntu.com/a/910300/179747
Comment: You are right about that mgor, haven't looked into 17.04 too much myself yet. But I prefer using the LTS versions anyway.
Comment: @mikewhatever They appear to be Windows partitions, so I doubt that they would be causing the issue. I assumed they were created by Ubuntu, but that appears to be incorrect.
Answer: An inability to do anything but a manual partitioning ("Something Else") installation is a common complaint when installing a dual-boot with Windows 8 or later. I'm not sure offhand if this is an issue related to EFI/UEFI-mode installation per se or if it's related to the notorious Windows Fast Startup and Hibernate features. These related features turn an ordinary shutdown operation into a suspend-to-disk operation, which leaves filesystems in an inconsistent state that's unsafe for sharing with other OSes. The Ubuntu installer might be detecting this and therefore refusing to provide options to resize the Windows partitions, thus closing off the usual "install alongside" type options.
Thus, one thing you might try is to disable both Fast Startup and Hibernate, as described in the links in the previous paragraph. Note that this is a critical part of a dual-boot installation with Windows 8 or later. Even aside from the installation issues, these features make it unsafe to share data between the two OSes. On EFI-based computers, even the EFI System Partition (ESP; where boot loaders are stored) is likely to be affected, which can produce all sorts of weird boot problems.
If disabling Fast Startup and Hibernate doesn't help, then the only solution is to use the "Something Else" installation option, as described here. Given your description, I recommend using Ubuntu in its "try before installing" mode to launch GParted on the disk to remove any partitions that might be left over from previous installation attempts first. You could optionally create partitions for Ubuntu in GParted at this time, too. Be 100% sure that any partitions you delete really are left over from previous Ubuntu installation attempts, though. Modern Windows installations often have several partitions, most or all of which are important to Windows in one way or another, so you should not delete them! Check the filesystem type in GParted. Ubuntu partitions are likely to use ext4fs or Linux swap. Windows partitions are likely to use FAT, NTFS, or have an unidentified filesystem. If you have any doubts, post a question, showing a GParted screen shot or the output of both sudo parted -l and sudo blkid.
Comment: Thanks for the information. I turned off hibernation mode, and still encountered the same problem. I was going to manually partition the drive, but realized that, for some reason, the installer was failing to recognize/modify my partitions: https://askubuntu.com/questions/932997/why-cannot-the-ubuntu-installer-recognize-my-ssd. If you have any knowledge of what is going on here, it would be greatly appreciated.


Trouble configuring Presto's memory allocation on AWS EMR

Question: I am really hoping to use Presto in an ETL pipeline on AWS EMR, but I am having trouble configuring it to fully utilize the cluster's resources.  This cluster would exist solely for this one query, and nothing more, then die.  Thus, I would like to claim the maximum available memory for each node and the one query by increasing query.max-memory-per-node and query.max-memory.  I can do this when I'm configuring the cluster by adding these settings in the "Edit software settings" box of the cluster creation view in the AWS console.  But the Presto server doesn't start, reporting in the server.log file an IllegalArgumentException, saying that max-memory-per-node exceeds the useable heap space (which, by default, is far too small for my instance type and use case).
I have tried to use the session setting set session resource_overcommit=true, but that only seems to override query.max-memory, not query.max-memory-per-node, because in the Presto UI, I see that very little of the available memory on each node is being used for the query.
Through Google, I've been led to believe that I need to also increase the JVM heap size by changing the -Xmx and -Xms properties in /etc/presto/conf/jvm.config, but it says here (http://docs.aws.amazon.com/emr/latest/ReleaseGuide/emr-presto.html) that it is not possible to alter the JVM settings in the cluster creation phase.
To change these properties after the EMR cluster is active and the Presto server has been started, do I really have to manually ssh into each node and alter jvm.config and config.properties, and restart the Presto server?  While I realize it'd be possible to manually install Presto with a custom configuration on an EMR cluster through a bootstrap script or something, this would really be a deal-breaker.
Is there something I'm missing here?  Is there not an easier way to make Presto allocate all of a cluster to one query?
Answer: As advertised, increasing query.max-memory-per-node, and also by necessity the -Xmx property, indeed cannot be achieved on EMR until after Presto has already started with the default options.  To increase these, the jvm.config and config.properties found in /etc/presto/conf/ have to be changed, and the Presto server restarted on each node (core and coordinator).
One can do this with a bootstrap script using commands like
sudo sed -i "s/query.max-memory-per-node=.*GB/query.max-memory-per-node=20GB/g" /etc/presto/conf/config.properties
sudo restart presto-server

and similarly for /etc/presto/jvm.conf.  The only caveats are that one needs to include the logic in the bootstrap action to execute only after Presto has been installed, and that the server on the coordinating node needs to be restarted last (and possibly with different settings if the master node's instance type is different than the core nodes).
You might also need to change resources.reserved-system-memory from the default by specifying a value for it in config.properties.  By default, this value is .4*(Xmx value), which is how much memory is claimed by Presto for the system pool.  In my case, I was able to safely decrease this value and give more memory to each node for executing the query.
Answer: As a matter of fact, there are configuration classifications available for Presto in EMR. However, please note that these may vary depending on the EMR release version. For a complete list of the available configuration classifications per release version, please visit 1 (make sure to switch between the different tabs according to your desired release version). Specifically regarding to jvm.config properties, you will see in 2 that these are not currently configurable via configuration classifications. That being said, you can always edit the jvm.config file manually per your needs.
Amazon EMR 5.x Release Versions
1
Considerations with Presto on Amazon EMR  - Some Presto Deployment Properties not Configurable:
2


What are electrical rings?

Question: I was mulling buying a powerline adapter, when I read this, from Which magazine.

There's one major caveat, however - powerline adapters won't work if your home electrical circuit is split over more than one ring. If your upstairs wiring is on a different electrical ring to your downstairs wiring, where your router lives, then you won't be able to extend the wi-fi upstairs using powerline adapters.

I'm not sure what this means, but I have a vague idea. The gateway is downstairs, the router I want to connect to is upstairs. They're on separate RCDs, which I assume means that they're on different rings... or does it?
I live in the UK.
Comment: Are you in the UK?   or........... Does your house receive more than one *phase* of electrical power?
Comment: I think the word "ring" is being used as a less technical term for "circuit."
Comment: Yes, I'm in the UK. I don't know what you mean by phase, sorry.
Comment: Why don't these infernal contraptions tx/rx on the neutral or even better, ground lines!  That would get around this uncertainty.
Comment: The Which comment is false. If you have separate consumer units, it would be true. Although powerline adaptors are pretty flakey, anyway. Run some ethernet cable for stability; much cheaper too.
Answer: Rings
Your quotation has a UK source. In the UK a "ring" refers to a ring-main also known as a ring-final circuit. This is the typical way UK houses have provided power to wall-sockets (outlets) since the 1950's.
They are called rings because they are connected in the topological equivalent of a large circle. There are two routes back to the consumer unit (main electrical distribution panel) from each socket.

Source: Wikimedia. CCASA 2.5 firstname.lastname@example.com. This example ring has two spurs.
Usually the ground floor has one ring-main and the upstairs has a separate ring-main. Anything larger than the average 4-bed detached might have more ring-mains.
Note that UK lighting circuits are separate and are not ring-mains, they are radial circuits. There will also be separate dedicated radial circuits for ovens/cookers, boilers and electric-showers.
Newer UK consumer units (main panels) have effectively a split power bus with an RCD for each half. So it is likely that there are RCDs between your downstairs gateway and your upstairs router.

Source: Chase Electrical.  Headings above MCBs are: (downstairs) lights, sockets, cooker ... (upstairs) lights, sockets, shower. This example has a separate RCBO (combined RCD and MCB) for smoke alarms?

Powerline
Across Different Rings
In my house I have an older arrangement that lacks RCDs in the consumer-unit. I use powerline networking between my upstairs router and my downstairs TV (it provides much better throughput and greater reliability than using WiFi in my specific circumstances) - So powerline networking can span rings.
Across RCDs
I don't know how much trouble (if any) your RCDs will cause. Anecdotal evidence suggests you might experience any of

it works but you lose around 20Mbps of 85Mbps bandwidth. or
it doesn't work. or
it trips the RCD.

What to do
I would go to a shop, clearly explain that I want to use the powerline units on separate rings each on a separate RCD. If they sell me some units for that scenario and they don't work, I would promptly return them as not "fit for purpose" under UK law (consumer rights act 2015).

(1)Subsection (3) applies to a contract to supply goods if before the contract is made the consumer makes known to the trader (expressly or by implication) any particular purpose for which the consumer is contracting for the goods.

...

(3) The contract is to be treated as including a term that the goods are reasonably fit for that purpose, whether or not that is a purpose for which goods of that kind are usually supplied.

Footnotes
(for Harper)

Ring final circuit test
Comment: Wait. Suppose the wire you're using in that ring is legal for a 15A radial circuit.... do you breaker it for 15A or 30A?
Comment: @Harpur: See addendum to answer. A UK ring-main is protected by a 32A breaker. The wiring is 2x2.5 mm² (~14AWG?). Breaks in the ring would be a bad thing.

What are electrical rings?


Saving oversampled dataset as csv file in pandas

Question: I am new to Python and apologize in advance, if it is too simple. Cannot find anything and this question did not help.
My code is
# Split data
y = starbucks_smote.iloc[:, -1]
X = starbucks_smote.drop('label', axis = 1)

# Count labels by type
counter = Counter(y)
print(counter)
Counter({0: 9634, 1: 2895})

# Transform the dataset
oversample = SMOTE()
X, y = oversample.fit_resample(X, y)

# Print the oversampled dataset
counter = Counter(y)
print(counter)
Counter({0: 9634, 1: 9634})

How to save the oversampled dataset for future work?
I tried
data_res = np.concatenate((X, y), axis = 1)
data_res.to_csv('sample_smote.csv')

Got an error
ValueError: all the input arrays must have same number of dimensions,
but the array at index 0 has 2 dimension(s) and the array at index 1 has 1 dimension(s)

Appreciate any tips!
Comment: What is result or error after trying to save?
Answer: You may create dataframe:
data_res = pd.DataFrame(X)
data_res['y'] = y

and then save data_res to CSV.
Solution based on concatenation od numpy.arrays is also possible, but np.vstack is needed to make dimensions compliant:
data_res = np.concatenate((X, np.vstack(y)), axis = 1)
data_res = pd.DataFrame(data_res)


Compare integer in attribute source

Question: I have a left arrow that when clicked should decrement the filename so that the previous picture is loaded.
I thought using parseint with a radix would do it (commented out) but in case it turned out to be NAN I used string replace, but it still doesn't work.
Am I missing something here?
$('#lar').on("click", function() {
    /*var num = parseInt( $('#main-img').attr('src'),  10);
    if (num > 0) {*/

    var num = $('#main-img').attr('src').replace(/\d+/, '');

    if (num > 0) {
        $('#main-img').attr('src', $('#main-img').attr('src').replace(/\d+/, function(val) {
            return parseInt(val) - 1;
        }));
    }
});

Thanks guys.
Answer: Problems in your code:

Your regex is incorrect
You need to cast the extracted string to numbers.

You are not extracting the numbers using the regex. Use following regex to extract the numbers from string.
var num = $('#main-img').attr('src').match(/(\d+)/)[1];

You need to parse the string to integer using parseInt. Otherwise, the condition num > 0 will never be satisfied.
var num = parseInt($('#main-img').attr('src').match(/(\d+)/)[1], 10);
//        ^^^^^^^^^                                             ^^^^^

Demo

var str = 'abc123';

var num = str.match(/(\d+)/)[1];

document.write('num= ' + num);
document.write('
');
document.write('
');
document.write(typeof num);
document.write('
');
document.write(typeof parseInt(num, 10));
Comment: Why Downvote? Please add comment here. Can something be improved?
Comment: Thank you tushar (and everyone else for also answering) I was considering using match. I'm going to blame my morning brain. This works perfectly.

Compare integer in attribute source


How to wire a 3-way decora leviton motion sensor switch?

Question: I want to replace one of the two 3-way switch that's in my laundry room. I have the Decora D0S05 model switch: PDF instructions here
The issue though is that the switches beside it is linking up the black wires with it too. My motion sensor has 5 wires:

ground
ground/neutral
black (line/load)
black (line/load)
red/yellow (typically counted as a traveler)

The middle black wire is where the power is coming from, if I disconnect it to the left black wire, the garage light does not turn on.

Closer look with the two switches on either end of the wiring of the first box.

Within the second 3-way switch's box -- there is one other switch that borrows power (it's confirmed because if I turn off the breaker, the 3rd switch can still turn on its set of lights).

I have it to the point where it can periodically have light, but it turns off right away. It does not actually detect motion as it would have this faint red light when motion is detected. Please help...
Comment: The diagram is clearly wrong. Please recheck and update. (It looks like what you were _trying_ to draw is one switch which feeds a three-way pair which then feeds the light, with the second and third being the three-way... but that isn't what you've drawn.)
Comment: The diagram does not make any sense. Do *all* of the other switches besides this Motion Detector/3-way and its remote 3-way work? Based on the diagram, I don't see how that is possible.
Comment: @manassehkatz-Moving2Codidact the diagram are the main wires that I have access to. Everything else in the electrical box is already connected. I updated the photo to provide a clearer picture. Currently from left to right...
#1 works when connected to power
#2 is the new motion sensor switch that's connected to a 3-way switch at another area
#3 is disconnected from power as I want to isolate it till I figure out the motion sensor switch, but it would technically connect to the middle black wire to turn on the driveway light.
Comment: It appears that you've now created two accounts and that's why you couldn't edit your original question without it going into the review queue. Please follow the [instructions here](https://diy.stackexchange.com/help/merging-accounts) to get the accounts merged.
Comment: @ThreePhaseEel the first one from the left of the right wires is the set that goes with the red/white. The second black wire coming out of the blue ish tinted skin leads to the light that I want the motion sensor 3 way switch to control
Comment: Can you provide us with a photo that shows the inside of the box clearly please?
Comment: @keshlam please see the updated photo (not diagram)
Comment: @ThreePhaseEel updated with new photo
Comment: Can you provide photos of the insides of the other boxes involved please for that matter?
Comment: @threephaseeel added the other box
Comment: Can you post a clearer photo of the wiring in the other box without removing the switches please?
Comment: @ThreePhaseEel I added two new photos to show a clearer idea of the switches in the first box and the one in the second as well.
Comment: in the 2nd box, which switch is associated with the light in question?
Comment: @ThreePhaseEel it's the first switch on the left, it's technically the 3-way light switch that would be connected with the motion sensor
Comment: @IanK out of the two black wires on the right side of the first box, which one joins the same cable as the unconnected red/white wires and which one goes off somewhere else?
Comment: @IanK -- I presume the nutted off black pigtail from the right-hand switch in the first box is the incoming hot to that switch, no?
Comment: @ThreePhaseEel that's the wire that needs to connect to power I believe. Otherwise that switch does not get power
Comment: @IanK -- which of the wires going to switch #2 is connected to the differently colored non-grounding screw on said switch?
Comment: @ThreePhaseEel there is another wire on the motion sensor aka the switch #2 that is also green but has the option to be a neutral if one exists.
Comment: @IanK -- sorry, I meant the left switch in box 2 aka the second switch on the motion sensor circuit
Comment: @ThreePhaseEel the black is on black screw, the red is on the gold top screw, the white is on the bottom gold screw
Answer: Switch spurs
The setup you have, where always-hot (power) and switched-hot (the light) are both brought to the same switch box in separate cables, is what I call a three-way switch spur.  As a result of this, you're limited in where your motion sensor can be placed by the fact you only have 3 wires between the two switch boxes.  Fortunately, though, since you're putting the motion sensor at the first switch box, it shouldn't be too much of a challenge wiring this into your 3 way circuit.
To hook it up correctly, as per the instructions:

Remove the green sleeve from the white wire on the motion sensor and connect it in with the bundle of white wires in the first switch box.  Do not separate this bundle!
Connect the green/yellow grounding wire on the motion sensor to the bundle of bare grounding wires in the first switch box.
Connect the red and white wires from the cable over to the second box to the black incoming hot wire, one of the black line/load wires on the motion sensor, and the two black pigtails off to the other two switches in the first box.  This wires up the two same-colored terminals on the switch in the second box.
Connect the black wire in the cable to the second box to the red/yellow traveler wire on the motion sensor.  This wires up the differently-colored terminal on the switch in the second box.
Connect the remaining black wire on the switch to the black load wire off to the light
Button everything up and turn the breaker on
Make sure the light works properly from the pushpad on the motion sensor, then program the motion sensor to work the way you want it as per the instructions.
Comment: I tried this, the motion sensor works but the 3 way switch that it's connected to no longer works
Comment: @IanK read the instructions as the 3 way switch is being basically used as an input to the motion sensor now (toggle once to turn on, toggle twice to turn off)
Comment: Understood. Will test out the toggle once vs twice sometime this week but I am super glad the motion sensor actually works. Much appreciated nonetheless!


How do I determine how many rooms I should build?

Question: My relatively small (24-person) vault seems to have an abundance of power, but a major water and food shortage! I've tried building more water treatment plants and diner/cafeterias (although they're minimally staffed), but my vault continues be in a state of perpetual shortage.
Everyone's miserable! I feel guilty.
I'd appreciate any tips or rules of thumb to determine how many of each type of room I should build...or general advice on how I seem to be messing up.
Comment: I don't think there's any point in having more or larger rooms if they're understaffed. Better upgrade your rooms and make sure they're fully staffed.
Comment: It more cost effective to upgrade merged rooms so it is better to merge first than upgrading before merging.
Comment: Kids seem to use up water and food more than adults, and on top of the fact that they do not work.  You should check how many kids you have and try not to have too many kids pop at the same time.
Comment: FWIW, I'm running a vault with currently 68 dwellers on "single", fully upgraded and staffed triple room of the basic type for both food and water, but I need 3 upgraded triple power rooms to keep the vault going comfortably. Don't expand too fast (ie., build more rooms than you need)!
Answer:
In the beginning (up to about 50 dwellers) you should have about an equal number of each production room type, so one power for each food and water.
When expanding, you should usually build the power room first, so that you have enough power to activate a new food and water room.
Extending a room (i.e. building a new one next to an old one) is more efficient per dweller than placing singles.
Just building a room doesn't make it produce anything, it is actually only a dweller's stat that produces something. For example, in power rooms the production comes from the strength stat. One power room with three strength 3 dwellers will produce the same as one power room with one strength 9 dweller.
Rooms produce depending on the amount of the main stat, not the number of rooms. So for example, one power room with dwellers totalling 10 strength will produce the same per minute as two power rooms of equal size and level as the first room if they contain a combined total of 10 strength. However, using two power rooms instead of one will cost more to build!
To make dwellers happy, keep them in the room they have the strongest stat in (their "talent"). If two stats are equal, the left stat takes precedence (left in the sequence "S-P-E-C-I-A-L"). You will see if a dweller likes a room by the green corners of the room when you move a dweller to it. You can also make dwellers happier by successful rushes (but sadder by failed rushes) or by making them have children (both parents).

The main stat for a dweller includes any outfit bonuses. This means that you can use outfits to change which room a dweller prefers by giving them the right outfit. This is important, since it is more important to keep your production balanced than it is keeping your dwellers happy, but by using outfits you can achieve both!
Answer: There is not really a formula for this. I normally try to get everything in balance. I normally build slowly. Just add one room, and upgrade it to the top. Wait for the result (some minutes) and see if your trend in a stock goes up or down.
Mostly it is more helpful to train your dwellers in the right stats to improve the efficiency of each room and to lower the accident rate for rushes. This is more important than a lot of rooms. By the way, don't let dwellers alone in one room. Their happiness will fall down. If they work with someone else in the same room, they are much happier. But in your case it's just the water/food problem.
You should stuff 2-3 people in each dinner and water supply. If you're still on a shortage, build the next room, upgrade it and stuff it.
Comment: I've noticed there is a 2-person limit to each room, regardless of the level (which doesn't make sense to me - if I can see a diner with 16 tables, why can't I put 16 people in there!?). So for three merged rooms you can only put 6 people in the room.
Comment: Yes this is right. You can merge the rooms to get up to 6. This is good, but mostly not needed 2-3 per room work efficiently enough. I only use the max number for my training rooms.
Comment: More people, faster resources. A room with 6 people with the same stat level will be twice as effective than the same room with only 3.
Answer: What I do, is that I build rooms for the amount of people there are. What I mean by that is if I have, say, 15 dwellers, I would have 6 individual resource rooms. 3 Dwellers would either be two are populating the vault, or going out into the waste land. Add up every resource room you have, and divide it by 3. What you get is how many rooms you should have per category. Any more and you run the risk of wasting your power, any less and your vault is not running at top efficiency, however there are exceptions.
Put the best people into their proper rooms, and it's a generally rule of thumb to combine rooms and then upgrade, as I've noticed that if you upgrade a room and then combine it it (seemingly) loses the upgrades you gave it.
In your situation, you would use seven people, and four rooms per resource category. Three of your people should be bumping uglies or out in the wastes. Give the people in rooms that are understaffed better weapons and better SPECIAL stats, as these people will need a boost, and you will need to rush these people, sometime disregarding the almost-certain probability of failure. That's why they have better guns; almost all of your rushing should be done in those rooms, if not all.
If you need more resources and you have extra people, go ahead. Build more rooms, but make sure you got the caps to upgrade those rooms right away.
That's generally what I do, and it works out well for me. I haven't gotten too far, but my vault never once dropped in the red, so that's great. Happy Surviving!
Answer: I was having a lot of trouble and couldn't get past 10 or so people without everything going to crap.  So what I finally figured out is to built a single unit power, water and food room and staff them adequately with 2 people and send one to the wasteland (checking up on them to make sure they weren't dying).  Once I got my resources up to speed, I added only 1 more living quarters and had one pregnant woman.  I didn't build anything else until my resources were at peak capacity even though I had the money.  I added very slowly to my rooms, making my power room bigger, then my water, and then my diner.  I did this slowly, as I began getting new dwellers so I could adequately staff my rooms.  I didn't build a medbay or a science lab at all until I had a 3-unit power, water and diner with full staff.  You don't really need stimpaks or radaways this early in the game anyway, and if you check up on your explorer regularly you can pull them back before they die.
Now, as far as having kids goes, I never have more than one child at a time, because they utilize water and food without contributing.  I would wait until one baby was born and then have another pregnant woman, so that way I only had one pregnant woman and one child.  The pregnant woman won't fight, so having too many isn't a good idea.  And then once the child is grown (3 hours) they can work in a room.  Since it takes 3 hours to have a baby, this is a cycle than I find works well.  If I don't have room, I don't have a pregnant lady, and I only build as I need so there aren't rooms using energy that aren't being used.
I also made sure to put the people with stats matching the rooms.  And if I got an outfit than increased a stat, I'd put in on the appropriate person so they would decrease the time a room takes to make a resource.
Answer: This guidance applies to Survival mode, so it will also more than cover regular games as it is very conservative:
Basically, getting up to 30 dwellers is critical, as, with 30 dwellers, you have training rooms available for Strength, Perception and Agility and Intellect.
Start your base by concentrating on building exclusively 1 each of a full sized (size 3) Power room, Diner and Water Processing plant - expanding your living quarters as necessary. That covers the first 18 dwellers.
You will need (on Survival) stimpacks, so you also need a size 2 medical room that you will populate with the next 4 dwellers.
With this many dwellers, the training rooms will start to unlock, so a size 1 Weight room, Armory etc, each stocked with 2 dwellers.
At this point your production rooms will NOT be producing enough. Don't panic. Whenever the % chance to fail is near or below 30%, rush the room immediately after collecting. This effectively doubles your production and makes dwellers happy, providing a further boost.
As and when the dwellers in the training rooms level up, drag them over their production room and drop them there if you see a "+1" or more. This automatically swaps the dweller with the dweller with the lowest stat in the room and is thus very effective at minimizing training times and growing the total number of relevant SPECIAL in the room to boost production.
Your (potentially) survival base now has 30 dwellers, all dedicated to principal production (6 in each room) and stimpacks (4), or training up on S,P,I and A (2 in each size 1 room).
As soon as the minimum skill level in each room reaches about 4, production will start to exceed use. Yay!
At this point you can start building more diners, power plants and water processing rooms - that you will leave unstaffed: Use elevators and a zig zag pattern to ensure that disasters in these rooms cannot reach other rooms or your occupied area. These rooms allow your (now) excess production to be stored which act as an excellent buffer to use while you log off / loss due to raids etc.
If you are playing survival, you can now breed 5 more dweller to get the total to 35, an get a fitness training room and train their Endurance.
But with these initial 30 dwellers committed, your power, food and water requirements will be stable and you can (now) take a breather, and start to expand how you choose.


Why this error? Cannot we use format macro inside function parenthesis?

Question: Code:
fltk::frame::Frame::new(0,0, 300, 100, format!("side item {}", i));

Output Error:
the trait `std::convert::From<std::string::String>` is not implemented for `std::option::Option<&'static str>`

Answer: format!() yields a String, while Frame::new expects an (optional) &'static str, i.e. a string slice that will be alive for the entirety of the program's lifecycle.
This pretty much means you can only use string literals. So no, you can not directly use format!(). Seems like FLTK does not intend for dynamically allocated strings to be used in this manner.
There is a hack to get around this using Box::leak. But be aware that it does what it says on the tin - it leaks memory, unless you reclaim it via Box::from_raw() after the widget is destroyed.
let leaked_title = &*Box::leak(format!("abc {}", 1).into_boxed_str())
fltk::frame::Frame::new(0,0, 300, 100, leaked_title);

Answer: The default ::new constructor expects an Into<Option<&'static str>>, so if your &str is not static, you can use with_label() or set_label().
fltk::frame::Frame::new(0,0, 300, 100, None).with_label(&format!("side item {}", i));

or
let mut my_frame = fltk::frame::Frame::new(0,0, 300, 100, None);
my_frame.set_label(&format!("side item {}", i));

Comment: Looks like a way better solution than mine.


Prove or disprove the implication:

Question: Prove or disprove the implication:
$a^2\cdot \tan(B-C)+ b^2\cdot \tan(C-A)+ c^2\cdot \tan(A-B)=0 \implies$
$ ABC$ is an isosceles triangle.
I tried to break down the left hand side in factors, but all efforts were in vain.
Does anyone have a suggestion?
Thank you very much!
Comment: Assuming a unit-diameter circumcircle so that we can make the standard substitution $a = \sin A$, $b = \sin B$, $c = \sin C$, I can manipulate the given condition down to $$(1-\cos 2A-\cos 2B-\cos 2C) \sin(A-B) \sin(B-C) \sin(C-A) = 0$$ but the derivation isn't at all pretty.
Comment: This is a really tough exercise, especially for a homework!
Comment: @medicu, would you mind sharing the source of the problem? I think, the problem can be safely generalized/make more complicated as $$\sum a^n \tan^{2m+1}(B-C)=0$$ where $m,n$ are non-negative integers or  $$\sum a^n \sin^{2m+1}(B-C)=0$$
Comment: @labbhattacharjee, I found the problem in a set of problems for preparation of competitions.
Answer: I will follow the method suggested by Blue in his comment to show that the implication does not hold.
The sides $a$, $b$, $c$ are proportional to $\sin A$, $\sin B$ and $\sin C$, respectively, by the sine law, so the equation is equivalent to $S = 0$, where
$$ S = \sin^2 A \tan(B-C) + \sin^2 B \tan(C-A) + \sin^2 C \tan(A - B).$$
Letting $x = \tan A$, $y = \tan B$, and $z = \tan C$, we can rewrite $S$ in terms of $x$, $y$, $z$; for example, we have $\sin^2 A = x^2/(1 + x^2)$ and $\tan(B - C) = (y-z)/(1 + yz)$. (We will ignore for now the special case where $ABC$ is a right triangle, and one of $x$, $y$, $z$, is correspondingly infinite.) Thus
$$ S = \frac{x^2}{1 + x^2} \frac{y-z}{1 + yz} + \frac{y^2}{1 + y^2} \frac{z-x}{1 + zx} + \frac{z^2}{1 + z^2} \frac{x-y}{1 + xy.}$$
Now we note that $S = 0$ when any two of $x, y, z$ are equal, so we expect the numerator of $S$ to be divisible by $(y-z)(z-x)(x-y)$. This is indeed the case (I used a computer for this part, although it is possible to do long division first by $y-z$, then by $z-x$ and finally by $x-y$):
$$S = \frac{(y-z)(z-x)(x-y)(2x^2 y^2 z^2 + x^2 y^2 + y^2 z^2 + z^2 x^2 - 1)}{(1 + yz)(1 + zx)(1 + xy)(1 + x^2)(1 + y^2)(1 + z^2)}.$$
Now that we have recovered the factors $y-z$, $z-x$ and $x - y$, we can split off factors equal to the tangents that originally appeared in $S$, so that
$$S = \frac{y-z}{1 + yz} \frac{z-x}{1 + zx} \frac{x-y}{1 + xy} T = \tan(B-C)\tan(C-A)\tan(A-B) T,$$
where
$$ T = \frac{2x^2 y^2 z^2 + x^2 y^2 + y^2 z^2 + z^2 x^2 - 1}{(1 + x^2)(1 + y^2)(1 + z^2)}.$$
To simplify $T$, we write $X = 1 + x^2$, $Y = 1 + y^2$, $Z = 1 + z^2$, so that $X = 1 + \tan^2 A = \sec^2 A$, and similarly, $Y = \sec^2 B$, $Z = \sec^2 C$. Then by replacing $x^2$, $y^2$ and $z^2$ with $X-1$, $Y-1$, $Z-1$, respectively, where they appear in $T$, we obtain
$$
\begin{align}
T &= \frac{2(X-1)(Y-1)(Z-1) + (X-1)(Y-1) + (Y-1)(Z-1) + (Z-1)(X-1) - 1}{XYZ} \\
  &= \frac{2XYZ - XY - YZ - ZX}{XYZ} \\
  &= 2 - \frac{1}{X} - \frac{1}{Y} - \frac{1}{Z} \\
  &= 2 - \cos^2 A - \cos^2 B - \cos^2 C.
\end{align}
$$
We therefore have the following identity:
$$S =  \tan(B-C)\tan(C-A)\tan(A-B) (2 - \cos^2 A - \cos^2 B - \cos^2 C),$$
which corresponds more or less to Blue's factorization. Interestingly, we never used the fact that $A$, $B$ and $C$ were the angles of a triangle. The identity extends to the case where one of the angles is a right angle by continuity.
Now the only question becomes whether it is possible to find a scalene triangle for which
$$\cos^2 A + \cos^2 B + \cos^2 C = 2.$$
If we assume that $A < B < C$, then this amounts to showing that the function
$$f(A,B) = \cos^2 A + \cos^2 B + \cos^2 (A + B)$$
takes the value $2$ somewhere in the interior of the triangle $\Delta$ bounded by the lines $A = 0$, $B = A$ and $A + 2B = \pi$. At the vertex $(0,0)$ of $\Delta$, we find $f(0,0) = 3$, so by continuity, at points in the interior of $\Delta$ near $(0,0)$, we must have $f(A,B) \approx 3$. Likewise, at the vertex corresponding to an equilateral triangle we have $f(\pi/3, \pi/3) = 3/4$, so at some points in the interior of $\Delta$, we must have $f(A, B) \approx 3/4$. Since the interior of $\Delta$ is a connected set, by the intermediate value theorem, we must have $f(A, B) = 2$ for some choice of $(A, B)$ in the interior of $\Delta$, which therefore corresponds to a scalene triangle.
Question: Was it predictable somehow, before the factoring step, that the numerator of $T$ would be expressible in terms of $x^2$, $y^2$ and $z^2$? That is what allowed the method to work as smoothly as it did.
Answer: The claim holds if we replace the function $\tan(B-C)$ (and cyclic permutations) with $\tan^*(B-C)=\frac{\sin(B-C)}{\cos(B+C)}$:
Since:
$$\tan^*(B-C)=\frac{\sin B \cos C - \sin C \cos B}{\cos B \cos C - \sin B \sin C}$$
and $2ab\cos(C) = a^2+b^2-c^2, 2R\sin A=a, 2ab\sin C=4\Delta$, we have:
$$2R\tan^*(B-C)= \frac{2abc(a^2+b^2-c^2-a^2-c^2+b^2)}{(a^2+c^2-b^2)(a^2+b^2-c^2)-16\Delta^2},$$
but Heron's formula gives $16\Delta^2 = 4b^2c^2-(b^2+c^2-a^2)^2$, from which
$$2R\tan^*(B-C) = \frac{4abc(b^2-c^2)}{a^4-(b^2-c^2)^2-4b^2c^2+(b^2+c^2-a^2)^2}$$ follows. This gives:
$$2R\tan^*(B-C) = \frac{2abc(b^2-c^2)}{a^2(a^2-b^2-c^2)}=\frac{c^2-b^2}{a \cos A}$$ and:
$$2Ra^2\tan^*(B-C) = \frac{a(c^2-b^2)}{\cos A} = 2R(c^2-b^2)\tan(A),$$
$$ a^2 \tan^*(B-C) = (c^2-b^2)\tan A = (c^2-b^2)\frac{4\Delta}{b^2+c^2-a^2}.\tag{1}$$
So we have, in terms of side lengths,
$$ \sum_{cyc}(c^2-b^2)(a^2+c^2-b^2)(a^2+b^2-c^2) = 0, \tag{2} $$
or:
$$ \sum_{cyc}(c^2-b^2)(a^4-b^4-c^4+2b^2c^2) = 0,$$
$$ \sum_{cyc}\left(b^6-c^6-a^4b^2+a^2b^4+3b^2c^4-3b^4c^2\right)=0, $$
$$ \sum_{cyc}\left(-a^4b^2+a^2b^4+3b^2c^4-3b^4c^2\right)=0, $$
$$ \sum_{cyc}\left(4b^2c^4-4b^4c^2\right)=0,\tag{3} $$
Now it is easy to notice that $a=\pm b,a=\pm c$ or $b=\pm c$ imply that the LHS is zero, so $(a^2-b^2)(b^2-c^2)(c^2-a^2)$ divides the LHS in $(3)$.
$$ \sum_{cyc}\left(4b^2c^4-4b^4c^2\right) = 4(a^2-b^2)(b^2-c^2)(c^2-a^2)\tag{4} $$
proves the (modified) claim.
Comment: In the first line, the denominator should be $+$ not $-$.  Not sure if this is just a typo which has been fixed later or if it is a serious mistake.
Answer: The implication is false: Here is a contour plot of the values of the quantity
$$w = a^2\tan(B-C)+b^2\tan(C-A)+c^2\tan(A-B)$$
where the vertices $B$ and $C$ are fixed at (-1,0) and (1,0), respectively, and the vertex $A$ is allowed to vary through the plane. The green contours are where $w=0$. The two prominent green circles and the green y-axis correspond to isosceles triangles. (The green x-axis corresponds to degenerate triangles.) As you can see though, there is some more green on the map, so there are definitely other zeros.
I'm not sure what the equations for the nontrivial green contours are. But I'll point out some other notable features of the graph. The red curve that appears to be a rectangular hyperbola is indeed the rectangular hyperbola $x^2 - y^2 = 1$: it's the locus of points where $B-C = \pm90^{\circ}$, i.e. $w = \infty$. (Red and blue are supposed to be the contours for $w=1$ and $w=-1$ respectively, but I guess Matlab's plotting doesn't handle the infinity that well, and just plots them in red.) The other "nice" red curves look like they might be cubic curves, and they should correspond to $w = \infty$ where $C-A = \pm90^{\circ}$ and $A-B = \pm90^{\circ}$. I haven't examined the matter closely though.
Here's one concrete example of a scalene triangle where we get $0$: Put vertex $A$ at $(3,\sqrt{-2 + 2\sqrt{17}})$, which makes a triangle with sides $a = 2, b = \sqrt{2 + 2\sqrt{17}}, c = \sqrt{14 + 2\sqrt{17}}.$ You can solve the triangle to verify.

How you can make a plot like this: View the plane as the complex plane, with the position of vertex $A$ as $z=x+iy$. Let $z_a = 2$ be the vector from vertex $B$ to vertex $C$, $z_b = -1 + z$ be the vector from vertex $C$ to vertex $A$, and $z_c = -1 - z$ be the vector from vertex $A$ to vertex $B$. Then $a = |z_a|$, and $B-C = \arg(z_b z_c / z_a^2)$ (can you see why?). In this manner, you can get $w$ as a function of $z$ to input into your software of choice.
Answer: I believe I have an example in which the identity is true but the triangle is not isosceles.  All the algebra in the following was done by Maple.
Let $a=1$ and $b=2$, and take $c^2$ to be a root of the cubic $x^3-5x^2-25x+45$.  The cubic has two roots between $1$ and $9$, either of which will give a valid set of sides $\{a,b,c\}$ for a triangle.
Now $c^2\ne4$ since $4$ is not a root of the cubic; so $c\ne2$; likewise $c\ne1$; so the triangle is not isosceles.  Future forbidden values of $c$ are checked in the same way and will be given without comment.
Now use the cosine rule to find $\cos A$, $\cos B$ and $\cos C$ in terms of $a,b,c$.  Then use the sine rule to write $\sin A$ and $\sin B$ as multiples of $\sin C$.  Check that $\cos C\ne\pm1$ and so $\sin C\ne0$.  Check that $\cos(B-C)$ and so on are not zero, then calculate $\tan(B-C)$ and so on, replacing $\sin^2C$ by $1-\cos^2C$; they all have a factor of $\sin C$.
Form the given expression and cancel $\sin C$; after simplification, Maple gives the numerator of the result as a constant times
$$(c-1)(c-2)(c+1)(c+2)(c^6-5c^4-25c^2+45)\ ,$$
which is zero.
This also fits in with the answer given by @Blue: with the values of $a,b,c$ I have specified, the first factor in his/her product is zero and not the others.
Answer: RTP:$$
a^{2}\tan(B-C)+b^{2}\tan(C-A)+c^{2}\tan(A-B)=0$$ $\implies$ ABC is an isosceles triangle
$$
c^{2}=b^{2}({\frac{\sin C}{\sin B}})^{2} \implies b^{2}=c^{2}({\frac{\sin B}{\sin C}})^{2}
$$
$$                                                                              a^{2}=c^{2}({\frac{\sin(\pi-A)}{\sin C}})^{2}=c^{2}({\frac{\sin A}{\sin C}})^{2}
$$
$$
a^{2}\tan(B-C)+b^{2}\tan(C-A)+c^{2}\tan(A-B)=0
$$
$$
\implies c^{2}[({\frac{\sin A}{\sin C}})^{2}({\frac{\tan B-\tan C}{1+\tan B\tan C}})+({\frac{\sin B}{\sin C}})^{2\
}({\frac{\tan C-\tan A}{1+\tan C\tan A}})+({\frac{\tan A-\tan B}{1+\tan A\tan B}})]=0
$$
$$
\implies [({\frac{\sin A}{\sin C}})^{2}({\frac{\tan B-\tan C}{1+\tan B\tan C}})+({\frac{\sin B}{\sin C}})^{2\
}({\frac{\tan C-\tan A}{1+\tan C\tan A}})+({\frac{\tan A-\tan B}{1+\tan A\tan B}})]=0
$$
Now for any A>B>C the above equation will be false. [It is a conjecture]
Conjecture is a statement which is accepted as to be true/false until any counter example is presented.
So now the above equation is false (for A>B>C) according to conjecture.
Now there are only two possibilities either any two angles be equal or all three angles be equal.
In both the cases the above equation will be true.
and therefore the implication is proved to be right.

Prove or disprove the implication:


Python Construct - How to use a bitwise construct inside a struct

Question: I have this problem that I can't figure out how to solve and was wondering if anyone has a hint for me.
This is a simplified example:
from construct import Struct, Enum, Byte, Switch, this, Flag

one_protocol = Struct(
    "enable" / Flag
)

protocol = Struct(
    "type" / Enum(
        Byte,
        one=0xA2,
        two=0x02,
    ),
    "data" / Switch(
        this.type,
        {
            "one": one_protocol
        }
    ),
)

input_1 = "A201"
input_2 = "A202"
print(protocol.parse(bytes.fromhex(input_1)))
print(protocol.parse(bytes.fromhex(input_2)))

And it works as expected. The output is:
Container:
    type = (enum) one 162
    data = Container:
        enable = True
Container:
    type = (enum) one 162
    data = Container:
        enable = True

The problem is that I want my one_protocol to work in bit level. More specifically, I want the enable field to reflect the value of the first bit and not the whole byte. In other words, I want to get enable = False for input_2.
I know that BitStruct cannot be nested.  But anyway, I have tried replacing the first Struct with Bitstruct and also replace Flag with Bitwise(Flag).
Any idea?
Answer: Construct's author here.
There is no reason why oneprotocol cannot be a BitStruct. You cannot nest Bitwise in another Bitwise but that is not the case here.
You cannot use Bitwise(Flag) because Bitwise will expect all 8 bits (or a multiple of 8 bits) to be consumed while Flag only takes one.
You also cannot make protocol a BitStruct because then enum will not work properly, unless you wrap it with Bytewise or something.
Comment: Thanks @ArekBulski for your answer. I just tried defining `oneprotocol` as a `BitStruct` and it works as expected.


Link mylyn Jira task to Java source code comment in Eclipse

Question: I have pretty much the same question as in the link below except that I'm using the Jira mylyn connector.
I have my Jira Task Repository defined and was just wondering if this is possible.
Link to mylyn task in Java comment (Eclipse)
i.e. Something like <code>//See JIRA-123</code> where the Jira issue number is a clickable link.
Thanks
Simon
Answer: There is no direct connection between JIRA and Eclipse possible. The reason for that is, that JIRA has no access to your local Eclipse installation. But there is a connection possible e.g. between JIRA and Subversion. So if you use Mylyn, and commit on a JIRA ticket in Mylyn, Mylyn will add automatically the active JIRA ticket ID to the commit message of Subversion. JIRA will then later read the commit message from the Subversion repository (if configured to do that), and will then display a backlink from the ticket to the Subversion Change Set (including diffs).
See the following resources for additional information:

TortoiseSVN documentation shows how to link in your Subversion client tool to the JIRA issues.
Integration JIRA with Subversion shows how to link from JIRA to Subversion repository.

You have to have a configuration management system to do that ...
After having read your question again, I think you will need an additional plugin for Mylyn, that interprets your sources and searches there for your JIRA issue ID patterns. But that is a totally different story (and I would not do that ... comments are forgotten, your issues is solved, but the ticket ID remains). Solving a ticket is something that has to do with commits in CM systems.


how to make required true , only if the user is certin value?

Question: hi am making models for my mongodb , and when validating i want the birthday to be required only if the user being added is a student
so i if the user is teacher it is fine if no birthday is provided

const userSchema = mongoose.Schema({
 20
 21         _id: mongoose.Schema.Types.ObjectId,
 22
 23         firstName: {
 24                 type: String,
 25                 required: [true, 'the firstName is missing'],
 26                 validate: [(val) => validator.isAlpha(val, ['fr-FR']), 'not valid first name'],
 27         },
 28         lastName: {
 29                 type: String,
 30                 required: [true, 'the lastName is missing'],
 31                 validate: [(val) => validator.isAlpha(val, ['fr-FR']), 'not valid last name'],
 32         },
 33         birthday: {
 34                 type: Number,
 35                 required: [true, 'birthday is missing']
 36                 validate: [(val) =>
 37         phoneNumber: {
 38                 type: String,
 39                 required: [true, 'the phoneNumber is missing'],
 40                 unique: [true, 'phoneNumber already in use'],
 41                 validate: [(val) => validator.isMobilePhone(val,['ar-DZ']), 'not valid phone number'],
 42         },
 43         email : {
 44                 type: String,
 45                 required: [true, 'the email is missing'],
 46                 unique: [true, 'email already in use'],
 47                 validate: [validator.isEmail, 'not valid email'],
 48         },
 49         password: {
 50                 type: String,
 51                 required: [true, 'the password is missing'],
 52                 minlength: [10, 'error when generating a password for the user'],
 53         },
 54         role: {
 55                 type : String,
 56                 "enum" : ['teacher', 'student'],
 57                 required : [true, 'the user `s role is missing'],
 58         },
Answer: The required property can also accept a function.  For example:
required: [
  function () { return this.role === 'student'; },
  'birthday is missing'
]

Answer: You can create a function to validate the value of the role and use it as a boolean value in required property.
const mongoose = require('mongoose');
const Schema = mongoose.Schema;

var userSchema = new Schema({
    _id: mongoose.Schema.Types.ObjectId,
    firstName: {
        type: String,
        required: [true, 'the firstName is missing'],
        validate: [(val) => validator.isAlpha(val, ['fr-FR']), 'not valid first name'],
    },
    role: {
        type: String,
        enum: ['teacher', 'student'],
        required: [true, 'the user `s role is missing'],
    },
    birthday: { type: Number, required: [isBirthdayRequired, 'the birthday is missing'] },
});

function isBirthdayRequired() {
    if (this.role === 'student') {
        return true;
    }
    return false;
}


Broken snap system after upgrade to Ubuntu 18.10

Question: Please help to install all needed packages to run snap files and integration with Store
Here is my errors:
snap list
2018/12/09 11:36:41.694959 main.go:162: argument "abort"'s "<смена ID>s" should be wrapped in <>s
2018/12/09 11:36:41.695044 main.go:162: argument "ack"'s "<файл подтверждения>s" should be wrapped in <>s
2018/12/09 11:36:41.695158 main.go:162: argument "tasks"'s "<смена ID>s" should be wrapped in <>s
2018/12/09 11:36:41.695197 main.go:162: argument "create-key"'s "<имя ключа>s" should be wrapped in <>s
2018/12/09 11:36:41.695229 main.go:162: argument "create-user"'s "<отослать>s" should be wrapped in <>s
2018/12/09 11:36:41.695245 main.go:162: argument "delete-key"'s "<имя ключа>s" should be wrapped in <>s
2018/12/09 11:36:41.695307 main.go:162: argument "export-key"'s "<имя ключа>s" should be wrapped in <>s
2018/12/09 11:36:41.695351 main.go:162: argument "find"'s "<запрос>s" should be wrapped in <>s
2018/12/09 11:36:41.695383 main.go:162: argument "get"'s "<ключ>s" should be wrapped in <>s
2018/12/09 11:36:41.695463 main.go:162: argument "interface"'s "<интерфейс>s" should be wrapped in <>s
2018/12/09 11:36:41.695506 main.go:162: argument "known"'s "<тип подтверждения>s" should be wrapped in <>s
2018/12/09 11:36:41.695517 main.go:162: argument "known"'s "<фильт заголовков>s" should be wrapped in <>s
2018/12/09 11:36:41.695549 main.go:162: argument "login"'s "<отослать>s" should be wrapped in <>s
2018/12/09 11:36:41.695614 main.go:162: argument "prepare-image"'s "<модель подтверждения>s" should be wrapped in <>s
2018/12/09 11:36:41.695626 main.go:162: argument "prepare-image"'s "<корневая директория>s" should be wrapped in <>s
2018/12/09 11:36:41.695676 main.go:162: argument "services"'s "<сервис>s" should be wrapped in <>s
2018/12/09 11:36:41.695714 main.go:162: argument "logs"'s "<сервис>s" should be wrapped in <>s
2018/12/09 11:36:41.695738 main.go:162: argument "start"'s "<сервис>s" should be wrapped in <>s
2018/12/09 11:36:41.695766 main.go:162: argument "stop"'s "<сервис>s" should be wrapped in <>s
2018/12/09 11:36:41.695789 main.go:162: argument "restart"'s "<сервис>s" should be wrapped in <>s
2018/12/09 11:36:41.695812 main.go:162: argument "set"'s "<конфигурационное значение>s" should be wrapped in <>s
2018/12/09 11:36:41.695856 main.go:162: argument "sign-build"'s "<имя файла>s" should be wrapped in <>s
2018/12/09 11:36:41.696189 main.go:162: argument "wait"'s "<ключ>s" should be wrapped in <>s
2018/12/09 11:36:41.696230 main.go:162: argument "watch"'s "<смена ID>s" should be wrapped in <>s
Name                  Version                    Rev   Tracking  Publisher   Notes
core                  16-2.36.2+git1055.114a76a  6095  edge      canonical✓  core
core18                18                         468   edge      canonical✓  base
gnome-calculator      3.30.1                     260   stable    canonical✓  -
gnome-characters      3.30.0                     139   stable    canonical✓  -
gnome-system-monitor  3.30.0                     57    stable    canonical✓  -
gtk-common-themes     0.1-4-g88bc1b2             818   stable    canonical✓  -

Comment: I'll strongly recommend you to come back to the site after 2 days to mark your answer as accepted. Thanks :-)
Answer: Best way to fix that but is to put locale to /etc/default/locale e.g.:
sudo update-locale LANG=en_US.UTF-8

check changes with cat /etc/default/locale
LANG=en_US.UTF-8
LC_COLLATE=C
LC_MESSAGES=C
LC_ALL=en_US.UTF-8

or edit bash profiale /etc/bash.bashrc:
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8

Answer: Snap seems to be experiencing problems under foreign languages in Ubuntu 18.10. The bug is reported here.
As of now the simple workaround is:
sudo rm /usr/share/locale-langpack/ru/LC_MESSAGES/snappy.mo

or use LANG=C before any snap command


What's causing the sewage smell in my laundry room?

Question: I noticed my laundry room has developed a strong sewage smell over the last two days. I suspect it may have to do with vent blockage, but I ran a garden hose to the vent in the roof last night and had my wife listen near the drain in the laundry room, and she reported hearing a slow trickle of water - so it's not completely blocked up.

I haven't washed anything particularly dirty that might put a lot of debris down the drain pipe recently.
The washer has been used regularly, so the drain pipe trap shouldn't be dry.
I'm on a septic system, if that matters. None of the other bathrooms or sinks in the house have any smell coming from them. I sniffed all the vent pipes while on the roof and could detect a faint level of the same laundry room smell coming from all of them, but I think that's normal.
I checked in the attic and discovered the vent pipe makes a 15-20 foot horizontal run before exiting vertically through the roof.
The slope on the horizontal run actually dips down and back up a few inches over its distance, but the issue just surfaced after living in the house for 7 years. I suppose it's possible it's acting as a trap for venting gas, but I don't know why it would start doing so spontaneously. (The water I ran down the vent from the roof before noticing the lack of proper slope could easily exacerbate this possibility, so I plan ensuring it's drained tonight.)

So my forward plan tonight is as follows:

Snake vent pipe.
Pour water down drain pipe to fill trap if it's empty.
Cut vent pipe in the attic and snake down into drain pipe from there.
Reroute attic vent pipe to have a minimum 1/8" per foot slope at all points.

Any other suggestions for remediation?
Comment: Are there any floor drains that the traps could have dried out?
Comment: No floor drains in the laundry room - just the standard drain pipe on the back wall.
Comment: what do you need us for? sounds like you got this...
Comment: @dandavis Ha! I figured it wouldn't hurt to get another pair of eyes on the plan for a sanity check.
Answer: Well, I'm not sure which of the following actions fixed it, but the smell seems to be dissipating after letting the room sit overnight afterwards:

I cut the vent pipe off in the attic right above where it came out of the ceiling. Then I drained any stagnant water due to the "U-bend" in it.
I snaked down from the roof to the cut location, with no obstructions found.
(Due to more luck than planning, the run was within a few inches of the 25' length of my auger!)
I snaked from the vent cut location in the attic down as far as my auger would reach, and don't think there was anything there, since it came back clean again.
I rerouted the vent pipe in the attic so that any horizontal runs had at least a 1/4" per foot slope upwards so any sewer gasses wouldn't be trapped.
I snaked from the laundry room drain pipe as far as I could reach, once again no obstructions detected.
I borescoped the drain pipe and saw that the trap was full of water as it should be. I added a gallon or so of water anyway, then maybe a cup of vinegar to help with any smell that might be in the pipe itself.

After all that, the smell dissipated overnight. Unfortunately, I didn't find any obstructions, and discovered the trap was full of water. The only thing I really "fixed" was the vent pipe slope, but that's been in that configuration for 7+ years without any trouble, so I still don't know what actually worked!