text:
Q: Spivak, Ch 2 Prologue, Problem 13: how to prove $\sqrt{3}$ is irrational using fact that $k^2$ divisible by 3 means k is also divisible by 3? Problem 13 in Spivak's chapter 2 Prologue is to prove $\sqrt{3}$, $\sqrt{5}$, and $\sqrt{6}$ are irrational with the hint that to treat $\sqrt{3}$ you can use the fact that every integer can be written in the form $3n$, $3n+1$, or $3n+2$.
Let's just consider the $\sqrt{3}$ case, because the other two are analogous. The question here is simply about one step in the proof, namely the part with divisibility by three explained below.
The solution at the back of Spivak for $\sqrt{3}$ is as follows:
$(3n+1)^2 = 9n^2+6n+1 = 3(3n^2+2n) + 1$
$(3n+2)^2 = 9n^2+12n+4 = 3(3n^2+4n + 1) + 1$
From the above, it follows that if $k^2$ is divisible by 3, then $k$ is divisible by 3. Main question: why does this follow?
Assume $\sqrt{3}$ is rational. $\sqrt{3} = p/q$ where $p$ and $q$ have no common factor.
$$p^2=3q^2$$
So $p^2$ is divisible by 3, and therefore $p$ is too. $$p=3p'$$ for some natural number $p'$ (shouldn't it be some integer $p'$?)
Consequently,
$$(3p')^2=3q^2$$
$$q^2=3p'^2$$
Therefore, $q$ is divisible by 3, a contradiction since this means $p$ and $q$ have a common factor.

A: If a number $k$ is not a multiple of $3$, then it is of the form $3n+1$ or $3n+2$ for some integer $n$, but then those computations show that $k^2$ is a multiple of $3$ plus $1$; therefore, $k^2$ is not a multiple of $3$.
Concerning your other question, if $\sqrt3$ was rational, it could be written as $\frac pq$, with $p,q\in\Bbb N$. And, if $3\mid p$, then $\frac p3(=p')$ would also be a natural number.

A: *

*It follows because we have shown that $(3n+1)^2$ is of the form $3k+1$, meaning that it cannot be of the form $3k$ (i.e. it cannot be divisible by $3$). The same reasoning applies for $(3n+2)^2$.

*Notice that we are assuming that $p,q$ are positive, and since $\frac{p}{3}$ is positive, so is $p'$. It follows because  the natural numbers are the set of positive integers.


text: Q: Inclusions between $L^p$ continuous functions and Triebel-Lizorkin spaces Working in $\mathbb{R}^{d}$, consider on the one hand the space of continuous $L^{p}$ functions (let's use $V$ to denote this space), and on the other the family $\{ F_ {\alpha}^{p, q} \}_{\alpha, q}$ of Triebel-Lizorkin spaces. Since $F_{0}^{p, 2} = L^{p}$, we have $V \subseteq F_{0}^{p, 2}$; and I think (although I don't have a reference handy to check this) that $F_{d/p + \varepsilon}^{p, q} \subseteq V$ for any $\varepsilon > 0$ and any $q$ (or maybe there are restrictions on $q$, but I think it's something along these lines that's true). I'm wondering if there are any other inclusions that hold, aside from ones that would follow from combining the two above with the standard inclusions/embeddings between Triebel-Lizorkin spaces.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Deploy power-apps portal customization & configuration from Development to Production environment? We are developing one power-apps portal. We have custom Web Pages, Web Forms, Page Templates, Custom CSS, JavaScript & Image files in the portal. Also having some portal configuration like, Website settings, Entity permissions, Web Roles, Bindings.
I wanted to know about, how to deploy all these portal files, customization & configuration from development environment to production environment?
This MSDN article  is related to migrating portal configurations but I want to know about entire portal deployment.
Any help will be appreciated


text:
Q: how to fetch file informations and md5 checksum using 1 command in linux I want to fetch all the file information viz: "permission","hardlink","owner","group","fsize","month","date","time","filename"
and
MD5 Sum information in one line command. How can I do this?
currently I get the 1st one by running ls -latr /home/asimon
and 2nd 1 by md5sum /home/asimon/filename.sh (it fetches me info for only 1 file) but instead i want all the information  like below
drwxr-xr-x  2 asimon support   4096 Sep 27 11:59 lib de1d8cd98f00b204e9800998ecf842qw
-rwxrwxrwx  1 asimon support    924 Sep 27 12:00 run.sh dqtd8cd98f00b204e9800998ecf84a7a
drwxr-xr-x  6 asimon support   4096 Sep 27 18:13 plugins d41d8cd98f00b204e9800998ecf8427s
-rw-r--r--  1 asimon support   2572 Sep 28 10:06 servicesFramework.log d51d8cd98f00b204e9800998ecf8427f

A: you can do it with find very easily:
find . -printf "%m %n %u %g %s  %t" -exec md5sum \{\} \;

Instead of the printf and the options you could also do a -ls but that would print the file name twice (and the ouput from md5sum delimited with a newline char)

A: Looks rather clumsy, but here you go:
ls -lAtr /home/asimon |grep -v total|awk '{printf($ARGV[1]);printf(" ");system("md5sum $9");}'|tr -d "-"
[EDIT]
note the upper case A in the ls command
[EDIT2 and 3]
Upated command, not spoiling the '-' characters in file names:
ls -lAtr /home/asimon|egrep -v "^d|total"|awk '{printf($ARGV[1]);printf(" ");system("md5sum $9");}'|awk '{$11="";print $ARGV[1]}'

A: One of the many ways would be to use a for loop as follows:
for ls_entry in `ls`;do [ -f $ls_entry ] && ls_out=`ls -alth $ls_entry` && md5_out=`md5sum $ls_entry|awk '{print $1}'` && echo "$ls_out $md5_out"; done

Hope this helps!

A: try: ls -latr /home/asimon; md5sum /home/asimon/*
the semicolon lets you do two commands on one line, and the * will run md5sum for everything in that directory.


text:
Q: File moving according to substring derived from file name Ihave started a simple script in order to move files of a certain prefix to a folder of the same name eg: W100_11.jpg W100_12.jpg in to folder W100.
Thanks to help from the answers below I have progressed and have a successful loop which can iterate through the file sin the folder, I am having issues with the -filter switch and when trying to use the move-item cmdlet I am getting errors
The current code is:
$sourceDir = read-host "Please enter source Dir:"
$format = read-host "Format to look for with .  :"
#$length = read-host "length of folder name:"

gci -Path $sourceDir | % {
    If( -not $_.PSIsContainer)
    {
        $path = $sourceDir + "\" + $_.Name.substring(0, 3)
        $_
        if(-not (Test-Path $path))
        {
            mkdir $path

        }
        move $_.fullname $path

    }
}

I am still having issues when using the -filter switch. This is a partial solution to the issue

A: The code below shortens your for loop and shows an example of using substrings on file names. You get a FileInfo object from the Get-ChildItem (gci) call, so you need to use it's property Name to do substrings. See MSDN for more info on FileInfo.
$sourceDir = read-host Please enter source Dir
$format = read-host Format to look for with .

gci -Path $sourceDir -filter $format | % {
    If( -not $_.PSIsContainer)
    {
        $path = $sourceDir + "\" + $_.Name.substring(0, 3)
        if(-not (Test-Path $path))
        {
            mkdir $path
        }
        move $_ $path
    }
}

A: If files names are always with this prefix "W100" you can easily take a substring in this way:
$a = "w100_12.ps1"
$a.Substring(0,4) # give W100

if prefix is not fix give more sample to help you solve it.

A: When piping use the built-in variable $_ to refer to the piped object, the '%' sign is an alias for 'for each':
get-childitem -Path $sourceDir -Filter $format -Recurse | % {If ($_.extension -eq ".ps1"){Write-Host $_.fullname}}

Answers above refer to substring, here is the MS Technet page that explains Powershell substring usage:
http://technet.microsoft.com/en-us/library/ee692804.aspx


text:
Q: Electric Circuits - tikz circuits library How to show loop current direction and Labels of resistor I am struggling to find these in tikz documentation.
How to label resistor (R above it and 3Ohm below).
How to indicate loop current and indicate its direction as shown in the snapshot.
\documentclass{memoir}

\usepackage{tikz}
\usetikzlibrary{circuits.ee.IEC}
\usetikzlibrary{shapes,fit,arrows}

\begin{document}

    \begin{figure}
        \centering
    \begin{tikzpicture}[circuit ee IEC, x=3cm,y=4cm,
    thick,
    every info/.style={font=\footnotesize},
    set resistor graphic=var resistor IEC graphic,
    set diode graphic=var diode IEC graphic,
    set make contact graphic= var make contact IEC graphic]

        \draw (0,0)  to [voltage source={direction info={volt=20}}] ++(0,1);
        \draw (0,1)  to [resistor={info={$R$},ohm=3}]  (2,1);
        \draw (2,1)  to [voltage source ={direction info={volt=10}}]
(2,0);
        \draw (2,0)  to [resistor={info=$R$}] (0,0);

    \end{tikzpicture}
    \caption{What is current in shown direction}
    \end{figure}

\end{document}

I would like to show loop current as show below

A: Suffixing ' to some of the circuit keys (e.g., info', ohm' see the manual for details), places the annotation on the other side of the component.
For the arc in the middle, I think drawing it manually is probably the best approach, but here I illustrate the use of a custom annotation with a node:
\documentclass[tikz,border=5]{standalone}
\usetikzlibrary{circuits.ee.IEC,calc}
\begin{document}
\begin{tikzpicture}[circuit ee IEC, x=3cm, y=4cm, thick,
  every info/.style={font=\footnotesize},
  set resistor graphic=var resistor IEC graphic,
  set diode graphic=var diode IEC graphic,
  set make contact graphic= var make contact IEC graphic,
  circuit declare annotation={circular annotation}{0}
    { (270:3/16) edge [to path={ arc (270:0:1/8) } ] () }]

\draw (0,0)  to [voltage source={direction info={volt=20}}] ++(0,1);
\draw (0,1)  to [resistor={info={$R$},ohm'=3}]  (2,1);
\draw (2,1)  to [voltage source ={direction info={volt=10}}] (2,0);
\draw (2,0)  to [resistor={info=$R$}] (0,0);
\node at (1,1/2) [circular annotation] {$I_1$};
\end{tikzpicture}
\end{document}


text:
Q: What are some fast outlier detection methods for big data in R? I have a large dataset (300,000 rows) for which there are clear outliers.  Box plots of two of the DVs of interest reveal the presence of large numbers of outliers by the Tukey outlier detection rule (1.5 * IQR).  See image below:
  [1]: https://i.stack.imgur.com/k8O2y.png
  [2]: https://i.stack.imgur.com/31cJp.png

I don't feel comfortable eliminating such a large number of outliers, and yet conceptually a large number of the variables are clear errors (e.g. it doesn't make sense that people spend 24 hours a day sleeping).
I'm wondering two questions:
(1) What is the 'state of the art' outlier detection on big datasets?  I've come across six methods implemented in R ("HDo", "PCS", "BAC", "adjOut", "DDC", "MCD") all of which seem to yield very different results as to what constitutes an outlier (with little consensus across methods).
(2) If the answer is along the lines "you shouldn't be automatically detecting outliers... they need to be evaluated on a case by case basis", what are some clear diagnostics and visualization that one should do to justify eliminating outliers?


text:
Q: Correct parameter type for moving object into vector Suppose I have an object that holds some data:
struct Object
{
   std::vector<float> data;
}

And a struct that holds some objects:
struct Holder
{
   private:
   std::vector<Object> objects_;
}

Calling code wants to build an Object and add it to a Holder without creating copies as Object may contain millions of elements. My initial thought was to let Holder handle the move:
struct Holder
{
   void addObject(Object& object)
   {
      objects_.push_back(std::move(object));
   }
   private:
   std::vector<Object> objects_;
}

However, other programmers may not be aware that the object it passed to Holder::addObject will leave it in an unspecified state and continue to work on it. Thus, I leave it to calling code to explicitly move the object into a copy, else a copy is constructed:
struct Holder
{
   void addObject(Object object)
   {
      objects_.push_back(std::move(object));
   }
   private:
   std::vector<Object> objects_;
}

Calling code then looks like:
Holder h;
Object o;
// populate c

h.addObject(std::move(o))

Is the use of std::move in this context correct? Is there an alternative, more correct and obvious way of handling this?

A: You could emplace the construction of your objects into the holder's vector. This also allows for passing a rvalue (which can be moved from).
template<typename... Args>
void emplaceObject (Args... && args) {
  objects_.emplace_back(std::forward<Args>(args)...);
}

std::forward  forwards the value category of the parameters, that is if you called your function with an rvalue, then the std::vector:: emplace_back() will also get an rvalue.
So h.emplaceObject(std::move(o)) would call the move constructor of Object once.
Btw, this is called perfect forwarding.


text:
Q: QT Creator - Parsing through CSV file OK, so I am using QT Creator for C++ and I am making a function that allows me to parse through the CSV file that I have named getExcelFile. Everything else is working fine but my code will not enter my while loop for some reason which is driving me crazy. Some suggestions would be helpful! Thanks.
void Widget::getExcelFile(){
    //Name of the Qfile object.
    //filename is the directory of the file once it has been selected in prompt
    QFile thefile(filename);
    //If the file isn't successfully open
    if (thefile.open(QIODevice::ReadOnly | QIODevice::Text)){
        qDebug() << "File opened successfully";
        //Converts text file to stream
        QTextStream in(&thefile);
        fileContent=in.readAll();
        QString line;
        while (!in.atEnd()){
            //line = textStream.readLine();//reads line from file
            //Will not enter this loop for some odd reason.
            qDebug() << "This text does not print out";
        }
    }

    qDebug() << "This prints out successfully";
    ui->textEdit->setPlainText(fileContent);
}

A: You did in.readAll(), after that call in.atEnd() will return true. Either remove in.readlAll() or while loop, why do you need both?


text:
Q: Covariant return types and static classes Please have a look at the function below:
Public Function Test(ByVal i As Integer) As Animal
        If i = 1 Then
            Return New Dog
        Else
            Return New Cat
        End If

    End Function

A dog or a cat is returned by the function depending on whether the value of the integer is 1 or not.  How is this approached if Dog and Cat are Static classes? i.e. you cannot create an instance of a static class.  I have read a few webpages on the MSDN website this afternoon talking about static classes, but I have not found an answer to my specific question.

A:
How is this approached if Dog and Cat are Static classes?

This isn't.  You can't "return a static class" - you need to always return an object.  You could use a static/shared method on a class to generate or operate on the object.  For example, if you had a factory creation method on the types, you could do something like:
Public Function Test(ByVal i As Integer) As Animal
    If i = 1 Then
        Return Dog.Create(i)
    Else
        Return Cat.Create(i)
    End If

End Function

A: The term "static class" is a C# concept, it doesn't exist in VB.NET.  So, no, this isn't possible.
It isn't possible in C# either, a static class can only derive from Object.  The closest VB.NET equivalent of a static class is Module.  Quite unsuitable.
You can certainly return a static instance of a class.  Declare the variable in a Module or use the Shared keyword if you want to declare it inside a class.
Class Example
    Private Shared theDog As Dog
    Private Shared theCat As Cat

    Public Shared Function Test(ByVal i As Integer) As Animal
        If i = 1 Then Return theDog Else Return theCat
    End Function
End Class


text:
Q: What's a bash string manipulation substitution for this? I do the following in my scripts:
~/tmp$ cat quick.sh
#!/bin/bash
TEXT="Hello World"
KEY=$(echo ${TEXT} | sed -r "s/(^[^ \t]+).+/\1/")
echo ${TEXT}
echo ${KEY}
~/tmp$ ./quick.sh
Hello World
Hello

How can I extract the first word from a string just with tools BASH provides?

A: Using the ${param%%word} Parameter Expansion
$ var="Hello World" ; echo "${var%% *}"
Hello

A: You can also use an array or the positional parameters as temporary placeholders
TEXT='Hello World'
tmp=($TEXT)         # must not quote the variable here
first=${tmp[0]}
second=${tmp[1]}

or
set -- $TEXT        # must not quote the variable here
first=$1
second=$2


text:
Q: Modifying CSS to produce 6 circle sectors I found some code here: https://stackoverflow.com/a/29007874/3042018 which makes 12 circle sectors using rotate and skew CSS (e.g.transform: rotate(30deg) skewY(-60deg); ).
I want to modify the code to have 6 sectors instead of 12. I thought it should be simple. I've done my due diligence and had a good go, but I'm stumped. I deleted the last six list elements and the css rules for these, then modified the angles to what I though would give me what I want, but now there are gaps in my circle.
Can someone please explain how to have six even-sized sectors filling the whole circle, based on the existing code?

.circle {
    position: relative;
    border: 1px solid black;
    padding: 0;
    margin: 1em auto;
    width: 20em;
    height: 20em;
    border-radius: 50%;
    list-style: none;
    overflow: hidden;
}
li {
    overflow: hidden;
    position: absolute;
    top: 0; right: 0;
    width: 50%; height: 50%;
    transform-origin: 0% 100%;
}
.text {
    position: absolute;
    left: -100%;
    width: 200%; height: 200%;
    text-align: center;
    -webkit-transform: skewY(60deg) rotate(15deg);
    -ms-transform: skewY(60deg) rotate(15deg);
    transform: skewY(60deg) rotate(15deg);
    padding-top: 20px;
}

li:first-child {
    -webkit-transform: rotate(0deg) skewY(-60deg);
    -ms-transform: rotate(0deg) skewY(-60deg);
    transform: rotate(0deg) skewY(-60deg);
}
li:nth-child(2) {
    -webkit-transform: rotate(60deg) skewY(-60deg);
    -ms-transform: rotate(60deg) skewY(-60deg);
    transform: rotate(60deg) skewY(-60deg);
}
li:nth-child(3) {
    -webkit-transform: rotate(120deg) skewY(-60deg);
    -ms-transform: rotate(120deg) skewY(-60deg);
    transform: rotate(120deg) skewY(-60deg);
}
li:nth-child(4) {
    -webkit-transform: rotate(180deg) skewY(-60deg);
    -ms-transform: rotate(180deg) skewY(-60deg);
    transform: rotate(180deg) skewY(-60deg);
}
li:nth-child(5) {
    -webkit-transform: rotate(240deg) skewY(-60deg);
    -ms-transform: rotate(240deg) skewY(-60deg);
    transform: rotate(240deg) skewY(-60deg);
}
li:nth-child(6) {
    -webkit-transform: rotate(300deg) skewY(-60deg);
    -ms-transform: rotate(300deg) skewY(-60deg);
    transform: rotate(300deg) skewY(-60deg);
}

li:first-child .text {
    background: green;
}
li:nth-child(2) .text {
    background: tomato;
}
li:nth-child(3) .text {
    background: aqua;
}
li:nth-child(4) .text {
    background: yellow;
}
li:nth-child(5) .text {
    background: orange;
}
li:nth-child(6) .text {
    background: purple;
}

1

2

3

4

5

6

A: skewY on the li elements controls the angle of the wedge. skewY(-30deg) makes it the correct size for six wedges.
li:first-child {
  transform: rotate(0deg) skewY(-30deg);
}
li:nth-child(2) {
  transform: rotate(60deg) skewY(-30deg);
}
li:nth-child(3) {
  transform: rotate(120deg) skewY(-30deg);
}
li:nth-child(4) {
  transform: rotate(180deg) skewY(-30deg);
}
li:nth-child(5) {
  transform: rotate(240deg) skewY(-30deg);
}
li:nth-child(6) {
  transform: rotate(300deg) skewY(-30deg);
}

transform and padding-top on .text counters the container's skew and controls the orientation and position of the text. So adjust it as follows:
.text {
  transform: skewY(30deg) rotate(30deg);
  padding-top: 15px;
}

You will, of course, need to update -webkit-transform and -ms-transform as well.

A: I just followed the instructions of the post.

.circle {
    position: relative;
    border: 1px solid black;
    padding: 0;
    margin: 1em auto;
    width: 20em;
    height: 20em;
    border-radius: 50%;
    list-style: none;
    overflow: hidden;
}
li {
    overflow: hidden;
    position: absolute;
    top: 0; right: 0;
    width: 50%; height: 50%;
    transform-origin: 0% 100%;
}
.text {
    position: absolute;
    left: -100%;
    width: 200%; height: 200%;
    text-align: center;
    -webkit-transform: skewY(30deg) rotate(15deg);
    -ms-transform: skewY(30deg) rotate(15deg);
    transform: skewY(30deg) rotate(15deg);
    padding-top: 20px;
}

li:first-child {
    -webkit-transform: rotate(0deg) skewY(-30deg);
    -ms-transform: rotate(0deg) skewY(-30deg);
    transform: rotate(0deg) skewY(-30deg);
}
li:nth-child(2) {
    -webkit-transform: rotate(60deg) skewY(-30deg);
    -ms-transform: rotate(60deg) skewY(-30deg);
    transform: rotate(60deg) skewY(-30deg);
}
li:nth-child(3) {
    -webkit-transform: rotate(120deg) skewY(-30deg);
    -ms-transform: rotate(120deg) skewY(-30deg);
    transform: rotate(120deg) skewY(-30deg);
}
li:nth-child(4) {
    -webkit-transform: rotate(180deg) skewY(-30deg);
    -ms-transform: rotate(180deg) skewY(-30deg);
    transform: rotate(180deg) skewY(-30deg);
}
li:nth-child(5) {
    -webkit-transform: rotate(240deg) skewY(-30deg);
    -ms-transform: rotate(240deg) skewY(-30deg);
    transform: rotate(240deg) skewY(-30deg);
}
li:nth-child(6) {
    -webkit-transform: rotate(300deg) skewY(-30deg);
    -ms-transform: rotate(300deg) skewY(-30deg);
    transform: rotate(300deg) skewY(-30deg);
}

li:first-child .text {
    background: green;
}
li:nth-child(2) .text {
    background: tomato;
}
li:nth-child(3) .text {
    background: aqua;
}
li:nth-child(4) .text {
    background: yellow;
}
li:nth-child(5) .text {
    background: orange;
}
li:nth-child(6) .text {
    background: purple;
}

1

2

3

4

5

6


text:
Q: What is the maximum voltage that silicon can handle? Today, in a race for efficiency, we have moved from transformers to switching power supplies. Almost all PSUs were designed for single-phase low-voltage operation (220Vac/310Vdc in my country). I've never ever seen 380V 3-phase 3+ kW ATX PSUs for PCs despite their efficiency and lower ripple noise. They would be very useful for stacks of GPUs. I think that it is mainly because electrolytic capacitors cannot survive rectified 660Vdc.
And it could be even better to rectify a 10kV medium voltage line, as it usually comes to the village transformer. But what is the voltage limit silicon devices (MOSFETs) can survive without breaking down?

A:
But what is voltage limit silicon keys (mosfets) can survive without breaking through?

There's virtually no limit; if your voltage exceeds the breakdown voltage of a component, well, put two in series.
There's silicon semiconductor-based rectifiers for high voltage DC power transfer. These work around 800 kV or higher.
Still, it'd be stupidly expensive to try to use multiple kV as input to a power supply that in the end generates voltage three orders of magnitude smaller. Also, it's incredibly dangerous to handle multiple kV within home installations, to plain impossible (isolation can easily get thicker than cable openings).

A: You can get 8 kV rated (at several thousand amps) thyristors for use in HVDC converters. The gate is optically coupled for the obvious reasons and also because, when used in tandem on HVDC links, the gate driving speed differences between series connected thyristors is important and optical is a little bit more clear cut speed-wise: -

Stack a few together in a tray with the various extras you need to control them safely (snubbers etc) and you get one of these: -

Then you build a monument to the gods of Megavolt by stacking the trays like so: -

Notice the little guy at the bottom.
Regarding power I've read that it takes 40 grams of silicon to control 20 MW of power and a lot of these installations are literally a thousand MW or more.

And it could be even better to rectify 10kV medium voltage line, as it
  usually come to village transformer.

Ah but you don't get safe isolation that is reliable - one breakdown and 10 kV in your house wiring is not good. Plus, the break-even point on a HVDC link versus a regular AC link is many, many miles.

Where are 3-phase 380v to 12V PSUs?

Well there is a technical snag that is inherent to the circuit used for many years in the "standard" 3 phase rectifier circuit: -

The problem is how they switch and power factor correction. In the good old days nobody cared but these days PF and supply cleanliness is paramount in many countries. And this is the problem with the standard 3 phase rectifier - it cannot be PF corrected because diodes can't conduct from 0 volts through to 0 volts (throughout one-half cycle) because of the blocking effect of the other phases and their diodes. The pulsing current taken from the 3 phase supply is really bad.
The solution is to use three single phase (and PF corrected) supplies all contributing power to a common DC bus. So, the modern 3 phase switching supply is in fact three single phase supplies.
How do the HVDC thyristors do it you might ask? They use filters as big as small houses to quench the harmonics generated.

Notice the relative size of the harmonic filters compared to the "valve hall" where all the thyristor "valves" are. All manner of double and single tuned filters are used just to remove those harmonics and, if the same technique were used on more ordinary standard 3 phase switching supplies (the ones that will never meet modern legislation) then guess what; the cost of the filtering is more than the added cost of individual supplies with PF correction built in.

Could you provide a link to model name, or at least name the product
  series?

Infineon thyristor discs rated at up to 8 kV and 4800 amps.

A: Mitsubishi IGBT hybrids with FET input BJT outputs can now switch Megawatts and very high voltage 15kV and are also used in smart power inverters and 600V GTI's in arrays for redundancy to smaller GTI's such as Huawei's 2000S 50kW units.
Below is a Mitsubishi hybrid IGBT which has many patents for exceptionally high switching energy and extremely low internal driver ESL and ESR. (inductance and resistance) I believe they working on their 8th generation now.

TI also has great design info on their IGBT's

A: They are actually building solid state transformers with greater efficiency and control, these run at 7.2kV

The workhorse switch of power electronics, the silicon-based
  insulated-gate bipolar transistor (IGBT) is a better fit. These
  devices have been used to build SSTs for rail applications in Europe.
  And they are certainly faster. But the most rigorous commercial
  devices can withstand voltages up to only about 6.5 kilovolts. While
  this breakdown voltage is perfectly fine for a range of power
  applications, it isn't sufficient to handle the electricity that flows
  through distribution transformers; in the United States, a typical
  voltage at the low end of the spectrum is 7.2 kV.

They are using silicon carbide which has a bigger bandgap and is more tolerant to heating problems also:

Fortunately, silicon is not the only option. In the last 10 years,
  great strides have been made in the development of switches based on
  compound semiconductors—silicon carbide in particular. Silicon carbide
  has a range of attractive properties that stem from its large
  bandgap—the energy hurdle that must be overcome to switch from
  insulator to conductor. Silicon carbide's bandgap is 3.26 electron
  volts to silicon's 1.1 eV, which means the material can be exposed to
  significantly higher electric fields and temperatures than silicon can
  without breaking down. And because this compound semiconductor can
  withstand much higher voltages, power transistors built from it can be
  made more compact, which in turn allows them to switch much faster
  than their silicon-based counterparts. A faster switching speed also
  cuts down on energy loss, so silicon carbide transistors can carry
  more current for a given thermal budget.

Sources: https://spectrum.ieee.org/energy/renewables/smart-transformers-will-make-the-grid-cleaner-and-more-flexible


text:
Q: "Invalid block tag on line 14: 'empty', expected 'endblock'. Did you forget to register or load this tag?" I'm receiving the following error in Django:
"Invalid block tag on line 14: 'empty', expected 'endblock'. Did you forget to register or load this tag?"
topic.html Template:
{% extends 'learning_logs/base.html' %}

{% block content %}

Topic: {{ topic }}

Entries:

        <% for entry in entries %>

{{ entry.date_added|date:'M d, Y H:i' }}

{{ entry.text|linebreaks }}

        {% empty %}

There are no entries for this topic yet.

        {% endfor %}

{% endblock content %}

A: The problem occurs at the <% for entry in entries %> template tag, or well what should be a template tag. In Django, template tags are surrounded with {% … %} (note the curly brackets instead of the angle brackets). You thus should rewrite the for template tag:
{% for entry in entries %}

{{ entry.date_added|date:'M d, Y H:i' }}

{{ entry.text|linebreaks }}

{% empty %}

There are no entries for this topic yet.

{% endfor %}


text:
Q: Copy single file using robocopy I'm writing on a batch file to copy a certain file to a samba-share.
I've already read robocopy transfer file and not folder
and thought I would be good using
robocopy "E:\Some\Path\with spaces" "\\sambaServer\some\path\with spaces" "myFile.rar" /z /MIR

But I keep seeing
Source: E:\Some\Path\with spaces\
Destination: \\sambaServer\Some\path\with spaces" myFile.rar \Z \MIR\

Files: *.*

And ofcourse I get an error

ERROR 123 (0x0000007B) Accessing Destination folder \\sambaServer\Some\path\with spaces" myFile.rar \Z \MIR\
  The syntax for file name, folder name or the volume label is incorrect.

So apparently robocopy takes the whole second part - the destination folder, the file and the parameters - together as the destination folder.
Why is this not working? What am I doing wrong?

It worked when I copy the whole folder instead using
robocopy "E:\Some\Path\with spaces" "\\sambaServer\some\path\with spaces" /z /MIR

A: Huh, I'm not sure, but it looks like it can be permissions issue, see here        http://blogs.technet.com/filecab/archive/2008/07/31/robocopy-mir-switch-mirroring-file-permissions.aspx
For me robocopy works fine:

robocopy "D:\test" "\share-name\folder-name\test test" "11.rar" /z /MIR

A: Please note that there is a defect in ROBOCOPY, which fails if a single file is specified even though the documentation indicates that should be valid. Just add a wildcard (*) to the end of the filename and it will be copied. (Of course, if the wildcard hits more than one file, all hit files will be copied, so this is not an ideal circumvention of the defect. )
Ferdie documented this circumvention back in 2016 at https://minglemangleofmymind.wordpress.com/2014/11/21/robocopy-error-2-accessing-destination-directory-and-the-system-cannot-find-the-file-specified/
By the way, I don't have enough reputation points to post the same circumvention at robocopy transfer file and not folder


text:
Q: How do I switch to Classic controller control scheme? I've started playing Hyrule Warriors, and I'm trying to switch the control schemes.  It recognizes the Wiimote + Nunchuck combo just fine, but when I unplug it, and plug in the Classic controller, it doesn't light up like the gamepad or nunchuck options do.  Looking on the back of the packaging, the classic controller icon is there, but it doesn't work.  Do I have to do something special to make the Classic controller work?

A: The classic controller is not supported in Hyrule Warriors. You can use the Wii U Gamepad, Wii Remote + Nunchuck, or the Wii U Pro Controller.
Source

A: you need the Wii U pro controller, classic controller doesn't work

A: Go to options and check your controller settings. It could require a restart of the system to recognize properly.

A: Restart the game, and dont touch anything on the gamepad. when the title screen comes up, press a button on your controller FIRST. If that doesn't work, then I'm guessing that the classic controller is unsupported, but I have to follow those steps to get my pro contoller to work.


text:
Q: making a template priority queue with vectors The following is a program to implement a priority queue.  I am using vectors to create the queue.  For this program, I want to be able to add any type of data using a template.  All of the code compiles correctly until I try to test the code by adding to the main function.  Can anyone catch what is going wrong here? below i have also indicated the line of code that gives me the error(down at the bottom in main).  Without it, the program runs fine.

PQ.h:
#ifndef PQ_H
#define PQ_H
#include <vector>
using namespace std;

template <typename T> struct vec//allows template vectors
    {
        std::vector<T> vec0;
        std::vector<T> vec1;
        std::vector<T> vec2;
        std::vector<T> vec3;
        std::vector<T> vec4;
        std::vector<T> vec5;
        std::vector<T> vec6;
        std::vector<T> vec7;
        std::vector<T> vec8;
        std::vector<T> vec9;
    };

template <class T>
void add(T item, int r);//adds to template queue
template<class T>
void remove();//removes from highest priority vector
template<class T>
bool empty();//check empty
template<class T>
bool empty(int r);//check if specific rank is empty

endif

PQFunction.cpp
#include <iostream>
#include <vector>
#include "PQ.h"
using namespace std;

template <class T>
void add(T item, int r)
{
        if (r==0)
    {
        vec0.push_back(item);
}
    if (r==1)
    {
        vec1.push_back(item);
    }
    if (r==2)
    {
        vec2.push_back(item);
    }
    if (r==3)
    {
        vec3.push_back(item);
    }
    if (r==4)
{
        vec4.push_back(item);
    }
    if (r==5)
    {
        vec5.push_back(item);
    }
    if (r==6)
    {
        vec6.push_back(item);
    }
    if (r==7)
        {
        vec7.push_back(item);
        }
    if (r==8)
{
    vec8.push_back(item);
    }
    if (r==9)
    {
        vec9.push_back(item);
    }
    if (r > 9 || r < 0)
    {
    cout<<"Rank is invalid"<<endl;
    }
}
template <class T>
void remove()
{
    if (!empty())
{
        if (!empty(0))
    {
        vec0.erase(vec0.begin);
        }
        else if(!empty(1))
        {
            vec1.erase(vec1.begin());
        }
        else if(!empty(2))
        {
            vec2.erase(vec2.begin());
        }
    else if(!empty(3))
        {
        vec3.erase(vec3.begin());
        }
        else if(!empty(4))
        {
        vec4.erase(vec4.begin());
        }
    else if(!empty(5))
        {
            vec5.erase(vec5.begin());
        }
        else if(!empty(6))
    {
            vec6.erase(vec6.begin());
    }
        else if(!empty(7))
    {
            vec7.erase(vec7.begin());
    }
    else if(!empty(8))
        {
        vec8.erase(vec8.begin());
        }
        else if(!empty(9))
    {
            vec9.erase(vec9.begin());
    }
}
    else
{
        cout<<"Nothing to remove"<<endl;
}
}
    template <class T>
    bool empty()
    {
        if (
        vec0.empty()&&
        vec1.empty()&&
        vec2.empty()&&
        vec3.empty()&&
        vec4.empty()&&
        vec5.empty()&&
        vec6.empty()&&
        vec7.empty()&&
        vec8.empty()&&
        vec9.empty())
        return true;

}

    template <class T>
    bool empty(int r)
    {
        if (r == 0)
    {
        return vec0.empty();
}
if (r==1)
{
        return vec1.empty();
}
    if (r==2)
{
        return vec2.empty();
}
    if (r==3)
{
        return vec3.empty();
}
    if (r==4)
{
        return vec4.empty();
}
    if (r==5)
{
        return vec5.empty();
}
    if (r==6)
{
        return vec6.empty();
}
    if (r==7)
{
        return vec7.empty();
}
        if (r==8)
{
        return vec8.empty();
}
    if(r==9)
{
        return.vec9.empty();
}

}

PQueue.cpp
#include <iostream>
#include <cstdlib>
#include <vector>
#include "PQ.h"
using namespace std;

int main()

{
**add(1,0);//this single line of code gives me the lnk error but when removed, the program compiles fine**

return(0);
}


text:
Q: Conditional validation in a JavaScript web form I am working on a web form using JavaScript for validation.  This is only one section of a much larger form.
The form has a question that asks the user if they have a Social Security Number. (SocialSecurity field)  It has two radio buttons, one yes and one no.  IF the user answers yes, then another field (SSN) becomes visible.  Otherwise, it stays hidden.   This part is actually working. (the show/hide of the SSN field)
The JS needs to do two things.  IF the user answers yes, then the SSN field becomes required, and must validate that it has 9 integers.   BUT, if the user answers no, then SSN field, which will stay hidden must no longer be required.
What I am having difficulty with, is getting the SSN to be required only if the user answers yes, and validate it correctly under that circumstance.
Online Demo
Here is the code:

Do you have a Social Security Number?

<input id="p_lt_ctl03_pageplaceholder_p_lt_ctl00_On_lineForm_viewBiz_SocialSecurity_list_0" type="radio" name="p$lt$ctl03$pageplaceholder$p$lt$ctl00$On_lineForm$viewBiz$SocialSecurity$list" value="As a U.S. Citizen, permanent resident, or temporary working resident, I have a Social Security Number." />
As a U.S. Citizen, permanent resident, or temporary working resident, I have a Social Security Number.

<input id="p_lt_ctl03_pageplaceholder_p_lt_ctl00_On_lineForm_viewBiz_SocialSecurity_list_1" type="radio" name="p$lt$ctl03$pageplaceholder$p$lt$ctl00$On_lineForm$viewBiz$SocialSecurity$list" value="Due to my international student status, my residency status, or my specific visa type, I do not have a Social Security Number." />
Due to my international student status, my residency status, or my specific visa type, I do not have a Social Security Number.

Social Security Number

<input name="p$lt$ctl03$pageplaceholder$p$lt$ctl00$On_lineForm$viewBiz$SSN$txtText" type="text" maxlength="9" id="p_lt_ctl03_pageplaceholder_p_lt_ctl00_On_lineForm_viewBiz_SSN_txtText" class="form-control" />

$('.field.SocialSecurity input[type=radio]').on("change", function() {
  switch ($(this).val()) {
    case 'As a U.S. Citizen, permanent resident, or temporary working resident, I have a Social Security Number.':
      $('.field.SSN').show();
      $('.field.SSN input').focus();
      break;

    case 'Due to my international student status, my residency status, or my specific visa type, I do not have a Social Security Number.':
      $('.field.SSN').hide();
      break;
  }
});

//Here is the SS format validation section

function validateSSN() {
  if (!validateRequiredTextField('SSN', 'Social Security Number'))
    return false;

  var value = $('.field.SSN input').val();

  if (!isInteger(value) ||
    (value.length != 9) ||
    (value == '000000000') ||
    (value == '111111111') ||
    (value == '222222222') ||
    (value == '333333333') ||
    (value == '444444444') ||
    (value == '555555555') ||
    (value == '666666666') ||
    (value == '777777777') ||
    (value == '888888888') ||
    (value == '999999999') ||
    (value == '123456789')) {
    $('.field.SSN input').focus();
    alert("Invalid: Social Security Number");
    return false;
  }

  return true;
}

//overall form validation - section on SSN
function validateForm()

if (!validateSSN())
  return false;

A: Update your validateform() function as below
function validateForm()
{
if($("#p_lt_ctl03_pageplaceholder_p_lt_ctl00_On_lineForm_viewBiz_SocialSecurity_list_0").is(':checked'))
{
    if($(".field.SSN input").val().trim() == "")
    {
        alert("You must provide SSN!");
        // Instead of alert, you can also apply some style to textBox e.g. red borders
        return false;
    }
    else if (!validateSSN())
    {
        return false;
    }
}
}

A: Your sample code is way to messy to work with. I've created this demo to show you the basics of how I think you should go about this. Note that I have simplified your code and changed both field names and classnames for the purpose of this demo. If you choose to implement a solution such as this you will need to update code to use your own values accordingly. (see second snippet.)
Solution:

*

*Use the browser's native validation by adding required and pattern attributes to the fields. A simple Rx pattern=[0-9]{9} will take care of your 9 integer validation requirement. Remember to re-validate server-side after the form has been submitted.

*Using JavaScript (/jQuery) listen for changes on the SocialSecurity field then set the SSN field's disabled attribute to true or false to enable or disable it depending on the chosen SocialSecurity value. If you don't want the disabled SSN field to be visible you can have the JS hide its parent container. Note that so long as the field is given the disabled property it won't be validated or submitted regardless of whether its visible or not.

Woking demo:

$(function() {
  var $ssn = $(".SSN");
  //add and enable and disable custom event:
  $ssn.on("enable", function() {
    $(this).show().find("input").attr("disabled", false);
  }).on("disable", function() {
    $(this).hide().find("input").attr("disabled", true);
  })
  //set initial state to disabled:
  $ssn.trigger("disable");
  //listen for changes and change the $ssn state accordingly
  $("input[name='havessn']").on("change", function() {
    var val = $(this).val();
    if (val === 'nope') {
      $(".SSN").trigger("disable");
    } else {
      $(".SSN").trigger("enable");
    }
  })
});
input:required:valid {
  border: green solid 3px;
}

<form>

    Do you have a Social Security Number?

      <input type="radio" name="havessn" value="yup" required="required" />As a U.S. Citizen, permanent resident, or temporary working resident, I have a Social Security Number.

      <input type="radio" name="havessn" value="nope" required="required" />Due to my international student status, my residency status, or my specific visa type, I do not have a Social Security Number.

      Social Security Number <input name="ssn" type="text" required="required" length="9" pattern="[0-9]{9}" title="Please provide a 9 digit SSN" />

    <input type="submit" />
</form>

Demo for your specific use-case with unwieldy classnames intact:

$(function() {
  var $ssn = $(".SSN");
  //add and enable and disable custom event:
  $ssn.on("enable", function() {
    $(this).show().find("input").attr("disabled", false);
  }).on("disable", function() {
    $(this).hide().find("input").attr("disabled", true);
  })
  //set initial state to disabled:
  $ssn.trigger("disable");
  //listen for changes and change the $ssn state accordingly
  $("input[name='p$lt$ctl03$pageplaceholder$p$lt$ctl00$On_lineForm$viewBiz$SocialSecurity$list']").on("change", function() {
    var val = $(this).val();
    if (val === "Due to my international student status, my residency status, or my specific visa type, I do not have a Social Security Number.") {
      $(".SSN").trigger("disable");
    } else {
      $(".SSN").trigger("enable");
    }
  })
});
input:required:valid {
  border: green solid 3px;
}

Do you have a Social Security Number?

<input id="p_lt_ctl03_pageplaceholder_p_lt_ctl00_On_lineForm_viewBiz_SocialSecurity_list_0" type="radio" name="p$lt$ctl03$pageplaceholder$p$lt$ctl00$On_lineForm$viewBiz$SocialSecurity$list" required="required" value="As a U.S. Citizen, permanent resident, or temporary working resident, I have a Social Security Number." />
As a U.S. Citizen, permanent resident, or temporary working resident, I have a Social Security Number.

<input id="p_lt_ctl03_pageplaceholder_p_lt_ctl00_On_lineForm_viewBiz_SocialSecurity_list_1" type="radio" name="p$lt$ctl03$pageplaceholder$p$lt$ctl00$On_lineForm$viewBiz$SocialSecurity$list" required="required" value="Due to my international student status, my residency status, or my specific visa type, I do not have a Social Security Number." />
Due to my international student status, my residency status, or my specific visa type, I do not have a Social Security Number.

Social Security Number

<input name="p$lt$ctl03$pageplaceholder$p$lt$ctl00$On_lineForm$viewBiz$SSN$txtText" type="text" required="required" length="9" pattern="[0-9]{9}" title="Please provide a 9 digit SSN" id="p_lt_ctl03_pageplaceholder_p_lt_ctl00_On_lineForm_viewBiz_SSN_txtText" class="form-control" />

A: you should create a boolean that is true only if the user have a SSN. And then call your validation function only if the boolean is true.


text:
Q: In SWT how can I bring one button infront of another How can I bring "NewButton"  in front of "Button" in SWT? Please refer to the below image: In other words, how to send "Button" to the back of "NewButton"?

A:
    public static void main(String[] args) {

    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setBounds(10,10,300,300);
    Button b =new Button(shell, SWT.NONE);
    b.setText("Button");
    b.setBounds(60,60,80,80);
    Button button = new Button(shell, SWT.PUSH);
    button.setText("NewButton");

    button.setBounds(120,120,90,90);
    button.moveAbove(b); shell.open();

    while (!shell.isDisposed()) {
    if (!display.readAndDispatch()) display.sleep();
    }
    display.dispose();
    }


text:
Q: What is the purpose of the Jarl's map in the Dragonreach? In the Jarl's quarters in Dragonreach (in Whiterun) is a map on a table with red and blue flags marking areas held by the Imperials and Stormcloaks.
I'm still early in the game, so is this map used for some purpose other than the ability to add those locations to your map, perhaps after choosing a side? Currently, clicking on a flag will add the location to your world map.

A: As Raven said, this show the progress of the war. As a side effect, you can use (I mean the "Use" action) the pin points to update your map with the most important strongholds and city.

A: There are a bunch of these maps around Skyrim. They're basically marking the current territories of the Stormcloaks vs. the Imperial Legion. As you progress in the civil war questline, these flags will change color as regions are captured.
They're basically are a visual representation of who's "winning" the civil war.


text:
Q: how to use dir() as default argument within a function I can't figure out what I'm doing wrong. It seems I'm not able to use dir() as the default argument to a function's input
def print_all_vars(arg=dir()):
    for i in arg:
        print(i)

foo=1

If I use
print_all_vars()

gives the output
__builtins__
__cached__
__doc__
__file__
__loader__
__name__
__package__
__spec__

but
print_all_vars(dir())

outputs
__builtins__
foo
print_all_vars

A: So - first, what is going on -
The line containing the  def statement is run only once, when the module containing the function is first imported (or on the interactive prompt) - anyway, any expressions used as default parameter values are evaluated a single time, and their resulting object is kept as the default value for that parameter.
So, your dir() call is executed, and the resulting list - a dir on the namespace of the module containing your example function is saved.  (The most common related error for Python beginners is to try to put an empty list or dictionary ( [] or  {}) as a paramter default: the same list or dictionary will be reused for the lifetime of the function).
That explains why you see in the output some values that won't show up if you call it with a dir from the interactive prompt, like  __package__ or __spec__.
Now, your real question is:

... I am actually trying to create an analog of MATLAB's save function
  that saves all existing variables to an external file that can be
  recalled later –

So, even if your dir() would be lazily executed, when the function is called only, that would still fail:  it would still retrieve the variable names from the module where the function is defined, not on the callers.
The coding pattern for doing that would be:
def print_all_vars(arg=None):
    if arg is None:
        arg = dir()
    ...

(And this is the most common way to enforce empty lists of dictionaries as default parameters on the function body)
But even this, or if you pass your own list of variable names explicitly to the function, you will still have just a list of strings - not Python objects that need you will want to save.
And - if you want to retrieve the variables from the caller by default, you have a problem in common with having this list of strings: you need to be able to access the namespace of the caller code, in order to either retrieve the variable names existing there, and later to retrieve their contents in order to be saved.
The way to know "who've called your function" in Python is an advanced thing, and I am not even sure it is guarantee to work across all Python implementations - but it will certainly work on the most common (cPython, Pypy, Jython) and even some considered smaller ones (such as Brython):
You call sys._getframe() to retrieve the frame object of the code currently being executed (that is the code in your function itself) - and this frame object will have a f_back attribute, which points to the frame object of the code which called your function. The frame object, on its side, has reference to the globals and locals variables of the code being run as plain dictionaries as  f_globals and f_locals respectively.
You can them "save" and "restore" as  you want the contents of the global variables on the caller code - but you can't update - using pure Python code - the local variables.
So, just to list by default the global variables on the caller code - you can do:
import sys

def print_all_vars(arg=None):
    if arg is None:
        arg = list(sys.get_frame.f_back.f_globals.keys())
    print (arg)

Being able to properly saving and restoring those variables is another question  - as you can see in the comments, you can use pickle to serialize a lot of Python objects - but the caller namespace will have module names (such as mathnp`, etc...) which can't be ordinarily pickled - so you will have to come with an strategy to detect, annotate the used modules, and restoring them, by using further introspection on all objects retrieved.
Anyway, experimenting with the information here should put you on the track for what you want.


text:
Q: How to install Python, VSCode, and flake8 correctly on Win10 I greatly apologize for the newbie question. I am trying to correctly download and integrate a Python 3.7 installation with VSCode and using flake8 as a linter. I want to get set up for developing custom scripts for Blender. I'm on Win10 x64.

*

*I downloaded the "python-3.7.8-amd64.exe" installation package, and installed it.

*I made sure to select the checkbox that adds python to the PATH environment variable in the installer.

*I pointed VSCode to the newly installed interpreter and was then prompted to install a linter.

*Someone recommended flake8, so I selected that in VSCode and installed.

*During the installation I get the following warnings:

WARNING: The script pyflakes.exe is installed in 'C:\Users\futur\AppData\Roaming\Python\Python37\Scripts' which is not on PATH.  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
WARNING: The script pycodestyle.exe is installed in 'C:\Users\futur\AppData\Roaming\Python\Python37\Scripts' which is not on PATH.       Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
WARNING: The script flake8.exe is installed in 'C:\Users\futur\AppData\Roaming\Python\Python37\Scripts' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed flake8-3.8.3 importlib-metadata-1.7.0 mccabe-0.6.1 pycodestyle-2.6.0 pyflakes-2.2.0 zipp-3.1.0
I checked my environment variables and this is what shows up:

What I don't understand is why I have two Python directories in %APPDATA%. There is:
C:\Users\futur\AppData\Local\Programs\Python\Python37\Scripts
As well as:
C:\Users\futur\AppData\Roaming\Python\Python37\Scripts
flake8 installed in the Roaming folder, while my main Python installation is in
C:\Users\futur\AppData\Local\Programs\Python\Python37
So to conclude, these are my questions:

*

*Did flake8 install in the wrong directory?

*Should I add C:\Users\futur\AppData\Roaming\Python\Python37\Scripts to my USER PATH environment variable, or to my SYSTEM PATH environment variable?

*Why are there two Python directories in %appdata%? (Roaming and Local)

Any guidance on how to properly set everything up correctly would be an ENORMOUS help and greatly appreciated.
Edit 1
Thank so much for all the answers. I want to emphasize that I would prefer to get this issue sorted out without just installing Anaconda.
Edit 2
I made some progress here. Instead of installing flake8 through VSCode, I just ran python -m pip install flake8 and everything seems good now.

A: According to your description, I successfully installed flake8.
I think there is a problem with your installation path of flake8.
Its default path will not be in roaming.
The default path will only have: C:\Users\futur\AppData\Local\Programs\Python\Python37\Scripts    and C:\Users\futur\AppData\Local\Programs\Python\Python37;
The default is local, which usually stores executable programs and other large capacity files;
It is recommended that you could install python again and check the version and location of the pip (use "pip -- version").

A: You could use an environment tool to resolve all these.
Download anaconda and create a environment with your intended python version and install flake8 inside your conda env. VScode works well with anaconda env.

A: Download Anaconda it will auto-resolve all the problems which you are facing related to environment setup.

A: *

*I don't think it is wrong. My new modules are also installed at same directory as yours.

*For me, it only works when I add to SYSTEM PATH.

*I also have Python in both Roaming and Local. But after checking my folders, it seem Local one is from my previous installation of Python.

As a side note, I also have to add env path for Python after installing Python installer. But, I remember clearly that in previous Python installers, I didn't have to add path manually. I wonder if there is any changes regarding path in new Python installer.

A: What I think happened is you used a global install of Python to install flake8 and the Python extension does a user install to help prevent you from breaking your Python installation (python -m pip install -u). So one path is to Python itself and the other is your user install of packages for a specific version of Python. That's why there's two separate locations.
The best way to manage this is to create a virtual environment and install into that (you don't need to switch to conda for isolation). That global install you did using python -m pip install flake8 is a bit risky as that could clash with other things you install in the future.


text:
Q: Clone SQL Server database I have two computers, one is the main used by people and the other is the backup in case the main stops working. They are both running SQL Server and at the moment whenever I want to sync their data I backup the main computer and restore the backup computer.
Is there an option to clone and on realtime if it's possible an sql server database on another computer running also SQL Server?
After a search I found about Transactional Replication is it what I'm looking for?

A: Currently, you have 3 options:

*

*AlwaysOn

*Database mirroring

*Log shipping

Database mirroing is going to be deprecated in the future versions of SQL Server so perhaps you should choose between AlwaysOn and Log Shipping. Depends on what are your actual needs, you can read about differences and options here: https://msdn.microsoft.com/en-us/library/ms190202.aspx


text:
Q: prepareForValidation does not work Laravel I want to make a whitelist of id that can be created, but for some reason it doesn't work
    protected function prepareForValidation(){
        $WhiteListes = WhiteList::all();

        foreach ($WhiteListes as $WhiteList){
            if ($WhiteList->server_id == $this->id) {
                $this->merge(['id' => $this->id]);
            } else {
                $this->merge(['id' => null]);
            }
        }

    }

This returns null. Although it should return an $this->id
I've already tried doing this
        foreach ($WhiteListes as $WhiteList){
            $test = $WhiteList->server_id == $this->id;
            dd($test);
        }

This returns True to me
Why does it work so crookedly? And how do I do it right


text:
Q: How to flash(hide/clear/delete) the previously appended values on every new click? Whenever I click, the new value  is appended but the previous value is also shown. How can I clear the previously appended values on every new click?
Here goes the onclick used in php function
echo "$name
";  // suppose this dispalyes a,b,c

Here is jquery function to append this value.
function chat_com(name) {
    $('#appendto').append(name);
}

Here is the HTML div where value is appended.

On first click a is shown, on second click a,b is shown instead just b.

A: $("#appendto").empty().append(name);

A: use this
function chat_com(name) {
$("#appento").html("")

$('#appendto').append(name);

   }

or
  $('#appendto').empty().append(name);

A: Instead of append use html. this will automatically flush older html.
$('#appendto').html(name);


text:
Q: Angular translate with ajax request i am working on an application and i want to translate some data in my page. I am using the following angular libraries:
angular-translate and angular-translate-loader-static-files.
i have write these config method:
myApp.config(['$translateProvider', function($translateProvider) {
    $translateProvider.useStaticFilesLoader({
        prefix: appdifConst.context + '/messages/messages_',
        suffix: '.json'
    });

    $translateProvider.preferredLanguage('en');
}]);

As it seem i get all the json files from /message/messages_*.json when my application starts.
What i want, is to configure this method above in a way that, when my application start to load, only one of the files (for example english which is the predefined) to loaded and when i click on a link (for example fr) the appi to make a post ajax request and brings the messages_fr.json back.
How is that possible?

A: Actually, what you want is exactly what angular-translate does. It only loads the language that is currently requested (in your case 'en'). What version do you use?

A: This sounds like a bug on your side to me, because there's one thing I don't understand..
You say that angular translate downloads ALL the json files.
How does it KNOW which translations exist???
My guess is that there is code with $translationProvider.use(key) on every language you have.
Perhaps someone thought this is mandatory as part of the setup or something? otherwise it just doesn't make sense that translate will know which translations you have and download them.


text:
Q: Gradle - Copy jars of all changed modules in a multi-module project build I have a multi-module build with approx 100 modules. Is there a way to create jar files for only the changed modules and copy them to somewhere?
The task should be a standalone task without modifying existing jar tasks

A: Assuming you have all your task inputs and outputs setup correctly, gradle supports up to date checking and task skipping out of the box. See up to date checks (aka incremental build)
For the copying, you could use a Sync task which will only copy (or delete) jars that are different from the target directory.
Eg
task syncJars(type: Sync) {
    allprojects { p ->
        from p.tasks.withType(Jar)
    }
    into 'path/to/target/dir'
}

A: So, assuming all your modules are simple java modules, all your modules will have a jar task (of type Jar) that build the JAR file of the respective module. Each jar task will only be executed, if the contents changed in any way (e.g. new files were compiled), thanks to Gradle incremental build feature.
You can simply add a doLast closure to each of these tasks, which copies the created file to your directory, because the closure will only be executed if and only if the task was executed:
Example for a single task:
jar {
    doLast {
        project.copy {
            from archivePath
            into 'path/to/my/location'
        }
    }
}

If this works for a single module, we can try a similar approach as what @lance-java did:
allprojects { project ->
    project.tasks.withType(Jar).all { jar ->
        jar.doLast {
            project.copy {
                from jar.archivePath
                into 'path/to/my/location'
            }
        }
    }
}


text:
Q: How to close iframe using 'end chat' button? I have placed the Live Chat into an iFrame and the chat functionality works.
Unfortunately, when I click the 'cancel chat' button, the chat ends, but the iFrame is still visible.
Is there a way to make 'cancel chat' button close the iFrame, as it does when the chat is in a pop up?

A: "Closing" the current iFrame is not possible but you can tell the parent to manipulate the dom and make it invisible.
In IFrame:
parent.closeIFrame(); //Call this method onclick on Close Chat button

In parent:
function closeIFrame(){
     $('#youriframeid').remove();
 }


text:
Q: Redirect without showing default action index - Yii I want to know if is possible using $this->redirect() statement ,to redirect to a different controller but without showing the action , I mean, if i want to redirect to controller Person by default yii goes to Person/index, I want to redirect to Person (don't want to show the action Person == Person/index)
I know that with $this->redirect() I can use $this->redirect(array(controller/action)), but is always showing the index action.

A: In your main.php, you should have these default rules in urlManager section:
'<controller:\w+>/<id:\d+>' => '<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
'<controller:\w+>/<action:\w+>' => '<controller>/<action>',

Simply add this above the existing rules:
'<controller:\w+>/' => '<controller>/index',


text:
Q: Symfony2 include form on error page (404) I created a custom error template
app/Resources/TwigBundle/views/Exception/error404.html.twig
and
app/Resources/TwigBundle/views/Exception/exception_full.html.twig
for development to change the layout to what ever I want to. This works fine. But, as soon as I add a form (e.g. my search or a contact form) using
{{ include ('MyCoreBundle:Default/forms:myCustomForm.html.twig' ) }}
or enter the code directly it shows a ResourceNotFoundException and a NotFoundHttpException instead of the 404 page.
Is there any way to display a form on the error templates?

A: What about using an embedded controller?
Here's the short example taken from Symfony's documentation page.
You have a controller that returns and renders some output:
// src/Acme/ArticleBundle/Controller/ArticleController.php
class ArticleController extends Controller
{
    public function recentArticlesAction($max = 3)
    {
        // make a database call or other logic
        // to get the "$max" most recent articles
        $articles = ...;

        return $this->render(
            'AcmeArticleBundle:Article:recentList.html.twig',
            array('articles' => $articles)
        );
    }
}

In this example, it renders a view:
{# src/Acme/ArticleBundle/Resources/views/Article/recentList.html.twig #}
{% for article in articles %}

        {{ article.title }}

{% endfor %}

and in the view you'd like to embed controller's action:
{# app/Resources/views/base.html.twig #}

{# ... #}

    {{ render(controller('AcmeArticleBundle:Article:recentArticles', {
        'max': 3
    })) }}

The docs page also says that you should use and embedded controllers when you need data that you don't have access to in a template. From my point of view, it's perfect for creating widgets, some statistics and so on.
Hope this helps.
Edit
To make this answer more accurate to your issue, here's the solution I'd use:

*

*You'll need a controller, let's call it SearchController

*In the controller's renderForm() method, you need to create a form and pass it to the view

*Form's action attribute should point to resultAction() method where you can fetch the results from your data storage and display result to the end user.


text:
Q: How to Take Input Data from Arduino to HTML and Log File? I have found a code to make output data from HTML to Arduino by using Johnny Five. Now, I need your help to explain, how to take and save input data from Arduino to HTML and Log file (it could be plain text, xml, or another type). So that, i can processing the variable.
This is my output data maker
<html>
<head>
  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
  <script src="/socket.io/socket.io.js"></script>
  <script>
    $(document).ready(function() {
      var socket = io.connect('http://localhost:8080');
      $('#button').click(function(e){
        socket.emit('click');
        e.preventDefault();
      });
    });
  </script>
</head>
<body>
  <button id="button" href="#">LED ON/OFF</button>
</body>
</html>

JavaScript
var app = require('http').createServer(handler),
     io = require('socket.io').listen(app),
     fs = require('fs'),
   five = require('johnny-five');

app.listen(8080);

function handler (req, res) {
  fs.readFile(__dirname + '/index.html',
  function (err, data) {
    if (err) {
      res.writeHead(500);
      return res.end('Error loading index.html');
    }

    res.writeHead(200);
    res.end(data);
  });
}

board = new five.Board();

board.on("ready", function() {
  led = new five.Led(13);

  io.sockets.on('connection', function (socket) {
    socket.on('click', function () {
      led.toggle();
    });
  });
});

Now, I need your help to show some code and explain how it work


text:
Q: Compile JSP & Java on browser refresh - Tomcat Is there any way to setup Tomcat server so whenever I make changes to Java class or JSP page the change is visible on browser refresh.
 I'm bored stopping and starting Tomcat. I want to configure Tomcat like the way WAMP works [where you can see the PHP code change upon browser refresh]

A: If it's for development mode that's ok. Don't use it for production stuff.

*

*You don't have to restart the server. You can restart the app through the Tomcat Manager.

*You can even do this directly as: http://[hostname]:[port]/manager/reload?path=[/path/to/your/webapp]
or

*

*Define your context as reloadable

Be careful: It is NOT recommended to place  elements directly in the server.xml file
Check out the Tomcat configuration guide
For java classes: reloadable

Set to true if you want Catalina to monitor classes in /WEB-INF/classes/ and /WEB-INF/lib for changes, and automatically reload the web application if a change is detected. This feature is very useful during application development, but it requires significant runtime overhead and is not recommended for use on deployed production applications. You can use the Manager web application, however, to trigger reloads of deployed applications on demand.
NOTE - The value for this property will be inherited from the reloadable attribute you set on the surrounding Context component, and any value you explicitly set here will be replaced.
  (http://tomcat.apache.org/tomcat-7.0-doc/config/loader.html)

For JSP: development ($CATALINA_BASE/conf/web.xml)

development - Is Jasper used in development mode? If true, the frequency at which JSPs are checked for modification may be specified via the modificationTestInterval parameter.true or false, default true.

Hope this helps


text:
Q: C# Clickonce Publishing DLL issues with gMap I have an application that has been in use for a long time now.  I recently added some new functionality including gMap.  My application works great when I debug or build it out and test.  The issue occurs when I publish as a clickonce and then install on my same machine.  The app installs and when it tries to run I get the error "WMS Toolbox has stopped working".  Looking at the event viewer I see that it is obviously missing dll files related to gMap.
--Event Viewer Fault1--

 Description: The process was terminated due to an unhandled exception.

 Exception Info: System.DllNotFoundException
    at System.Data.SQLite.UnsafeNativeMethods.sqlite3_libversion()
    at GMap.NET.CacheProviders.SQLitePureImageCache.Ping()
    at GMap.NET.GMaps.SQLitePing()
    at GMap.NET.WindowsForms.GMapControl..cctor()

 Exception Info: System.TypeInitializationException
    at GMap.NET.WindowsForms.GMapControl..ctor()
    at wmsToolBox.wmsToolBox.InitializeComponent()
    at wmsToolBox.wmsToolBox..ctor()
    at wmsToolBox.Program.Main()

--Event Viewer Fault2--

 Faulting application name: wmsToolBox.exe, version: 1.0.0.0, time stamp:
 0x5d70eddb
 Faulting module name: KERNELBASE.dll, version: 10.0.15063.1836, time
 stamp: 0xbb572fa7
 Exception code: 0xe0434352
 Fault offset: 0x000f18e2
 Faulting process id: 0x3a8
 Faulting application start time: 0x01d563db00e3051a
 Faulting module path: C:\windows\System32\KERNELBASE.dll
 Report Id: 0bc8cd8f-c137-4cd8-a8d8-880ce20add89
 Faulting package full name:
 Faulting package-relative application ID:

I have noted that this seems to be a know issue with applications dependent on sqlite.dlls.

Taking suggestions from other posts, here is what I have tried:

*

*Removing all references from the application and adding them back, making sure they are all updated

*I have tried creating x86 and x64 folders in my app and providing the SQLite.Interop.dll to both folders (This made no changes in the performance of the app)

*I have downloaded the precompiled .net and then placed the System.Data.SQLite.dll near my exe (this caused install errors stating that the dll file already existed in the folder and wouldn't install)

*I have tried adding dll files to the clickonce installation folder and running the app again.  (this caused the following error:

         Exception Info: System.BadImageFormatException
            at GMap.NET.CacheProviders.SQLitePureImageCache.Ping()
            at GMap.NET.GMaps.SQLitePing()
            at GMap.NET.WindowsForms.GMapControl..cctor())

Sources I have referenced

How to Publish a Winforms App with SQLite using ClickOnce
I also referenced the suggestions at the following site.  They are largely the same as the post on SO.
https://github.com/oysteinkrog/SQLite.Net-PCL/issues/158

A: I was finally able to resolve this issue.  As elwood472 stated, it is very similar to the notes he provided.  I have a few subtle additions to offer to be even more concise.  This assumes that you have added the references to your application.

*

*Determine the target framework of your app, mine is 4.5.1

*Create the x86 and x64 folders in your project

*Navigate to the project folder solution/packages/System.Data.SQLite.Core.1.0.111.0/build/$target framework version$.  You will see a x64 and x86 folder here, HOPEFULLY!

*Under the x64 folder, copy the SQLite.Interop.dll file to your project under the x64 folder

*Under the x86 folder, copy the SQLite.Interop.dll file to your project under the x86 folder

*Set the properties of both files to Build Action: content; Copy to output directory: Copy if newer

Publish the application and it finally worked for me.  I think I had been getting incorrect framework versions by searching for the file.  Elwood472 offered to use the directory: \Solution Name\packages\System.Data.SQLite.Core.1.0.111.0\lib\net46\ which can be incorrect per the framework you are building your app for.  I'm not sure if there is a difference in the x86 and x64 files but I copied them to their respective folders and it worked fine.
If you have the wrong framework version you will likely get an error in Event Viewer that says Exception Info: System.BadImageFormatException
If you are missing the dll files all together you will likely get an error in Event Viewer that says Exception Info: System.DllNotFoundException

A: Unfortunately, I am having the same issue.  I'm hoping you have a solution...
I have seen some of those solutions, but not tried any.  One solution I found was to download the GMAP sources and compile it as an AnyCode version, but I don't know how to do that.
https://stackoverflow.com/a/43886479/4114838

A: I have resolved this for myself using known solutions.  I'll be specific since if it had been explained to me this way I would have gotten it done much quicker.  It involves creating the x64 and x86 folders.
In Visual Studio, look at your Solution Explorer.  Under the root of your project, add a folder for x64 and another for x86.
For each folder, right-click, select Add and then choose existing item.  Add the file SQLite.Interop.dll to it.  When you're done you MUST be able to see the folder and file in the Solution explorer.
In Solution Explorer, select the file SQLite.Interop.dll.  In the properties, set Copy to Output Directory to "Copy if Newer".  Do this for each folder (x86 and x64).
That's it.  When you publish your project it should now work.


text:
Q: In OOP reading from text file should be a Independent class method? I have a class that only have main which read in some txt and do the algorithms.
my class is look like:
class doThejob{
     public static void main(String args[]){
            //*****start part A******
           //do the reading from text file, and tokenize it
           // process into the form I need,
           //about 10-30 lines of codes
           //******End of part A*****

           //then run the algorithms
           algorithm alg=new aglorithm();
           Object output = alg.x(input);

           //****Part B**** output to txt, about 10~40 lines

     }
}

class algorithm{
      private void  a(Object x){
             //do something
           return (Object)result;
      }

}

Can anyone tell me should I extract those part A and part B to a new class ,and then setup them as a public method .like below
class Io{
    public Object readFromTxt(String path){
    }
    public void outputToTxt(String path){
    }

}

And if I setup them , and then use it like below, is that more OOP?
class doThejob{
     public static void main(String args[]){
           Io dataProcess= new Io();

           Object input = dataProcess.readFromTxt(args[0]);
           algorithm alg=new aglorithm();
           Object output =alg.x(input);

           dataProcess.readFromTxt(args[1],output);

     }
}

class algorithm{
      private Object  a(Object x){
             //do something
      }

}

A: Do it the way you fill is more readable.
Separating this in another class is according to the Single Responsability Principle. It will help making the code more readable and easy to change later on.
If you want to expand more on this, you could create an interface (eg.: IIO) for input and output. This way you can implement this interface in the IO class, renaming it to FileIO. Anytime you want to create another form of IO, like database access, you just have to create a DatabaseIO class that implements this interface and change the instance in the main method for this new type:
public interface IIO
{
    string Read();
    void Write(string text);
}

public class FileIO : IIO
{
     string path;

     public FileIO(string filePath)
     {
         path = filePath;
     }

     public string Read()
     {
         // read from file and return contents
     }

     public void Write(string text)
     {
         // write to file
     }
}

public class SqlServerIO : IIO
{
    SqlConnection conn;

    public SqlServerIO(string connectionStringName)
    {
        // create the connection
    }

    public string Read()
    {
        // read from database
    }

    public void Write(string text)
    {
        // write to database
    }
}

Extracting interfaces makes the code more maintenable by alowing to switch implementations anytime without messing with working code. It also facilitates unit testing.


text:
Q: How to redefine a symbol/character to be interpreted as a """ (triple quotes) symbol in Scala code? For example, suppose I wanted to redefine the bang symbol to mean the same thing as triple quotes in Scala for a DSL.
Then I would want
!Hello world!
to mean the same thing as
"""Hello world"""
in Scala source code. (Essentially, this might be similar to a #DEFINE in C.)

A: Because the behavior of """ is a built-in feature of the language (see section 1.3.5 of the spec) and any alias for it would require support in the lexical parser, I don't think this is possible using normal means.  Even the macro processor doesn't work at that low a level.


text:
Q: simulation of logistic regression sensitivity to prior probability: Brier score vs accuracy I wrote a simulation in R that compares performance of a logistic regression as I vary the prior probability of the two classes.
The gist is that I do a simulation of data that generates nearly balanced classes and then fit a logistic regression.
Then I generate a new response variable, with the original predictors.
Next, I take only a fraction of the new data, according to the specified class imbalance, which ranges from $5\%$ being in class $0$ to $95\%$ being in class $0$.
I use my original logistic regression model, trained on balanced classes, to predict both the accuracy (threshold of $0.5$) and the Brier score, which is a proper scoring rule.
My stance is that the proper scoring rule should be much less sensitive to the class imbalance, and the results show this.

However, this feels like cheating! Are these even on the same scale, or have I done something like compare the variance of human heights in feet and dog heights in miles? At the same time, there are no units on either accuracy or Brier score
What would be the right way to make this comparison about variability in order to show the lack of sensitivity the proper scoring rule has to the prior probability?
(I eventually want to do something like this with a more sophisticated machine learning model, but logistic regression is easy to simulate.)
# Taken from: https://stats.stackexchange.com/a/46525/247274
set.seed(2020)
N <- 1000
x1 <- rnorm(N)           # some continuous variables
x2 <- rnorm(N)
z <- 0.6*x1 + 1.7*x2     # linear combination
pr <- 1/(1+exp(-z))      # pass through an inv-logit function
y <- rbinom(N ,1,pr)     # bernoulli response variable

#now feed it to glm:
df <- data.frame(y=y,x1=x1,x2=x2)
G <- glm(y~x1+x2,data=df,family="binomial")

probs <- seq(0.05, 0.95, 0.01) # prior probabilities

acc <- pro <- rep(NA, length(probs))

for (i in 1:length(probs)){

    y <- rbinom(N, 1, pr)     # bernoulli response variable

    df_i <- data.frame(y=y,x1=x1,x2=x2)

    idx0 <- which(df_i$y == 0)
idx1 <- which(df_i$y == 1)

    # Subset
    #
    select0 <- sample(idx0, 100*probs, replace=F)
    select1 <- sample(idx1, 100*(1-probs), replace=F)

    df0 <- df_i[select0,]
    df1 <- df_i[select1,]

    df_test <- rbind(df0, df1)
    preds <- predict(G, df_test[,c(2,3)])
    prob_preds <- 1/(1+exp(-preds))
    pro[i] <- mean((prob_preds - y)^2)
    acc[i] <- mean((round(prob_preds)-1)^2)
}


text:
Q: Create multidimensional array from table where duplicative IDs have the same parent Key I have a table like this:
--primary id---office id----
|----1-------|---10--------|
|----2-------|---10--------|
|----3-------|---20--------|
|----4-------|---10--------|
|----5-------|---20--------|
----------------------------

I want an object/array like this:
Array = array(
  "10" => array(
      "Primary ID" => 1,
      "Primary ID" => 2,
      "Primary ID" => 4
   ),
  "20" => array(
      "Primary ID" => 3,
      "Primary ID" => 5
   )
)

My query would be:
SELECT * FROM table ORDER BY office id

Is there a better query for this case?
Is there a simple and small method for creating an Array like that above?
EDIT: I am using SQL Server for this... so sadly no GROUP_CONCAT etc... ):
Thanks!

A: Its better to use LISTAGG function .
i.e.
SELECT office id, LISTAGG(primary id, ', ')
FROM table
GROUP BY office id
ORDER BY office id

once you get the result of above sql, we can tokenise each row by delimiter ',' and put the tokenised data in array.

A: You can use the following query:
SELECT primary id, GROUP_CONCAT(office id) as office_id
FROM table
GROUP BY primary_id;

This will return the results as:
primary_id   office_id
---------------------------
10           1,2,4
20           3,5

This would make it easier for you to process it and store it in array.


text:
Q: Keep only one element of each group of elements who match each other Suppose I have an object of the structure:
class Obj:
  def match(other):
    return check_match(self, other)

For example, check_match could check for overlap or for equality or for "is friend".
Now I'll have a list of those objects:
objList = create_random_list_of_Obj()

Now, for each element which matches other elements, I d like to keep only one of those mutually matching elements.
Remark and clarification:
So far, the task is ambiguous: If A and B match, and B and C match, but A and C do not match, then we could keep A and C or we could keep B. It's not important, which decision the algorithm will take. The important thing is, that there are no matching elements in the final list.
Two questions:

*

*What is the pythonic way to do so?

*Does this problem have a name?

A: Regarding: What is the pythonic way to do so?
The pythonic way is to rename your match method to __eq__.
Then you can do things like element in list with your custom object.
A very pythonic way to make a list contain unique items is then:
uniques = list(set(list_with_duplicates))

Edit: __ne__ is not needed and will default to not __eq__()
Does this problem have a name?
One could look for "equivalence classes".
Some references:

*

*implementing __eq__ in your own class: Elegant ways to support equivalence ("equality") in Python classes

*stdlib docs on __eq__: https://docs.python.org/3/reference/datamodel.html#object.eq

*how element in list works behind the scenes: https://docs.python.org/3/reference/expressions.html#membership-test-details

A: Python has a type of contains method that works with the following syntax: if x in y: Use it to determine if a list contains an obj
a = ["a", "b", "c", "d", "d"]
b = ["c", "c", "d", "e", "f"]
c = []

for member in a:
  if member in b and member not in c:
    c.append(member)

Should result in c = ["c", "d"]


text:
Q: Taking derivative for RNN back propogation I am trying to understand the derivation of backpropagation for recurrent neural networks (RNNs) from this source:
https://github.com/go2carter/nn-learn/blob/master/grad-deriv-tex/rnn-grad-deriv.pdf
I am stuck in understanding the below-given equation:
$\frac{\partial}{V_{ij}}(V_{lm}s_{m}) = \delta _{il} \delta _{jm}s_{m}$
I dont understand where these two Kronecker deltas come from.

A: I am answering my own question:
From matrix calculus cookbook, I got this equality:
$\frac{\partial X_{kl}}{\partial X_{ij}} =  \delta_{ik} \delta_{lj}$ (I could not find the proof for this)
Therefore:
$\frac{\partial V_{lm}}{\partial V_{ij}} =  \delta_{il} \delta_{mj}$
Because all the indexes are free indexes (in einstein notation), one can change them so that $s_m$ can be incorporated (This statement needs validation from someone who knows einstein notation well). The result is given below.
$\frac{\partial V_{lm}s_m}{\partial V_{ij}} =  \delta_{il} \delta_{jm} s_m$


text:
Q: Publishing a Windows Form with Local Database We have a windows form application with a local .mdf database. It has all its required functionality, but it wont work without connecting to the associated database. This is probably an incredibly simple solution, but we cannot figure out WHAT needs to be installed on the target PC for this to work. For reference, our connection string is as follows
    const string connectionString = "Data Source = (LocalDB)\MSSQLLocalDB; AttachDbFilename = |DataDirectory|ourDataBaseName.mdf; Integrated Security = True";

The problem is, this, and the published program version, works fine on OUR computers, but with our test computer, we cannot for the life of us get this thing working. My questions then  are the following

*

*Do we need to change the connection string?

*What needs to be installed on the target PC to make it connect to the database? We've tried many of the offered prerequisites that are in visual studio, but none seem to work.

For reference, the database and program were made in visual studio 2015, and does not integrate with any other applications, and is intended for use on a single pc. Aside from installation, it shouldn't need connection to the internet to function.
Any help or direction to helpful resources would be greatly appreciated.
Thanks

A: I had exactly the same problem, I had an application with a local database, which was created in sql server 2017, and when I published it, it only worked on my PC and nobody elses. After struggling a long time to solve this I found out that I needed to install both SQL Server Express 2017 AND the localdb version on the target device.
Keep in mind that even after installation and rebooting the machine, MSSQL Service has a tendency to not be running and you'll face the same error, you'll have to start it manually.


text:
Q: Imgur upload using servlet in jsp I have trying to create a simple upload ui for an image. On the click of the button upload it using the imgur API. And return the image url and display the image.
I have tried to follow this: https://kodejava.org/how-do-i-create-a-web-based-file-upload/ but this is for server upload..
Also tried to follow: Simple Java Imgur Upload
It would be really helpful if someone could show a simple example.


text:
Q: Rails Helper If statement I am trying to write a helper that will read an integer and set the string that goes with it and also the class. I thought it would be something like this...
def credit_status(customer)
if customer.stop_flag == 0
  Active

elsif customer.stop_flag == 1
  Closed

elsif customer.stop_flag == 2
  Hard Stop

elsif customer.stop_flag == 3
  Closed
end
end

But I get this error
/home/ec2-user/environment/rialto-crm/app/helpers/application_helper.rb:55: syntax error, unexpected '<'  {
    class: 'success',
    label: 'Active'
  },
  '1' => {
    class: 'warning',
    label: 'Closed'
  },
  '2' => {
    class: 'warning',
    label: 'Hard Stop'
  },
  '3' => {
    class: 'danger',
    label: 'Closed'
  }
}

def credit_status(customer)
  content_tag(
    :span,
    STOP_FLAG_MAPPINGS[customer.stop_flag.to_s][:label],
    class: "badge badge-#{STOP_FLAG_MAPPINGS[customer.stop_flag.to_s][:class]}"
  )
end


text:
Q: How to get Data of a UI Component Admin Form and use it in Controller? So i'm creating a UI Component Admin Form with a few fields, and one of them is a Dropdown field.
I want to get the value that user selects, using a custom controller that i made.
I tried this comands:
$this->getRequest()->getParams(); but only returns ID and KEY. What can i don to get all data of the form?
$this->getRequest()->getPostValue(); i tried this one too, but don't works.
Well, but when i use those commandson the Save Controller it works, however thats not functional for me, because i want this to works when i call the DeleteHeader Controller. Why on the Save Controller works? thats because this tag <submitUrl> on the Form.xml: ?
<settings>
      <submitUrl path="api/data/save"/>
</settings>


text:
Q: FromsAuthenticationTicket.UserData is always empty and authentication cookie does not retain value I have the following code in the Login(username, password)
if (hasher.Compare(password, person.Hash))
                {
                    FormsAuthentication.SetAuthCookie(userId, true);
                    OpenAccount(person);

                    var principle = new GenericPrincipal( new GenericIdentity($"{person.FirstName} {person.LastName}"), new string[] {"All"});
                    var data = Konstants.Serialize(principle);
                    var ticket = new FormsAuthenticationTicket(1, principle.Identity.Name, DateTime.Now, DateTime.Now.AddMinutes(30), true, data);
                    var encryptedTicket = FormsAuthentication.Encrypt(ticket);

                    FormsAuthentication.SetAuthCookie(principle.Identity.Name, false);
                    var cookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);
                    Response.SetCookie(cookie);
                    Response.RedirectToRoute("Default");
                }

Then in the Global.asax I have the following code:
protected void Application_AuthenticateRequest(Object sender, EventArgs e)
{
    var  authCookie = Request.Cookies[FormsAuthentication.FormsCookieName];
    try
    {
        if (authCookie != null)
        {
            FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(authCookie.Value);
            if (!string.IsNullOrEmpty(ticket.UserData))
            {
                var principle = Konstants.Deserialize<GenericPrincipal>(ticket.UserData);
                HttpContext.Current.User = principle;
            }
        }
    }
    catch
    {

    }
}

But in the AutheticateRequest the ticket.UserData is always empty. In fact  the cookie value I get is the one that was before authentication not the one that I stored. What am I doing wrong here.
Update: The Serialize and Deserialize code is as follows:
   public static string Serialize<T>(T obj)
    {
        var ret = string.Empty;
        using(var ms = new MemoryStream())
        {
            var bf = new BinaryFormatter();
            bf.Serialize(ms, obj);
            ret= Convert.ToBase64String(ms.GetBuffer());
        }
        return ret;
    }

public static T Deserialize<T>(string text)
{
    var obj = default(T);
    var data = Convert.FromBase64String(text);
    using(var ms = new MemoryStream(data, false))
    {
        var bf = new BinaryFormatter();
        obj = (T)bf.Deserialize(ms);
    }
    return obj;
}

A: You've got two calls to SetAuthCookie in that first code block, but you don't need either if you're creating a custom ticket. I think this should do the trick:
OpenAccount(person);

var principle = new GenericPrincipal( new GenericIdentity($"{person.FirstName} {person.LastName}"), new string[] {"All"});
var data = Konstants.Serialize(principle);
var ticket = new FormsAuthenticationTicket(1, principle.Identity.Name, DateTime.Now, DateTime.Now.AddMinutes(30), true, data);
var encryptedTicket = FormsAuthentication.Encrypt(ticket);

var cookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);
Response.SetCookie(cookie);
Response.RedirectToRoute("Default");

Edit: I also just noticed that you're not passing your serialized data into the userData field of the new ticket, is that the intention?


text:
Q: ObjectA.Signal.connect(ObjectB.Slot) not working. is my understanding correct? This is my understanding of Signal and Slot, is it correct?
When clicked, emitting a data(QModelIndex) to setRootIndex().

if correct. then why this code not working?
treeView.clicked.connect(listView.setRootIndex)

this is my ui:

code:
... ...
# model
treeModel=QtWidgets.QFileSystemModel()
listModel=QtWidgets.QFileSystemModel()
treeModel.setRootPath(PATH1)
listModel.setRootPath(PATH2)

# fill data
treeView.setModel(treeModel)
treeView.setRootIndex(treeModel.index(PATH1))
listView.setModel(listModel)
listView.setRootIndex(listModel.index(PATH2))

# connect
treeView.clicked.connect(listView.setRootIndex)

# show window
... ..

A: When you execute your code you get the following message:
QAbstractItemView::setRootIndex failed : index must be from the currently set model

And that message gives us an important clue, a QModelIndex belongs to a model so although it has the same data from another QModelIndex of another model they are not the same.
There are 2 possible solutions:

*

*Use only one model

import os
from PyQt5 import QtCore, QtGui, QtWidgets

if __name__ == "__main__":
    import sys

    app = QtWidgets.QApplication(sys.argv)

    model = QtWidgets.QFileSystemModel()
    model.setRootPath(QtCore.QDir.rootPath())

    treeView = QtWidgets.QTreeView()
    treeView.setModel(model)
    treeView.setRootIndex(model.index(QtCore.QDir.homePath()))

    listView = QtWidgets.QListView()
    listView.setModel(model)
    listView.setRootIndex(model.index(QtCore.QDir.homePath()))

    treeView.clicked.connect(listView.setRootIndex)

    w = QtWidgets.QWidget()
    hlay = QtWidgets.QHBoxLayout(w)
    hlay.addWidget(treeView)
    hlay.addWidget(listView)
    w.show()

    sys.exit(app.exec_())

*

*Obtain the QModelIndex of the other model using the QModelIndex information of the initial model:

import os
from PyQt5 import QtCore, QtGui, QtWidgets

if __name__ == "__main__":
    import sys

    app = QtWidgets.QApplication(sys.argv)

    dirModel = QtWidgets.QFileSystemModel()
    dirModel.setRootPath(QtCore.QDir.rootPath())
    dirModel.setFilter(QtCore.QDir.NoDotAndDotDot | QtCore.QDir.Dirs)

    listModel = QtWidgets.QFileSystemModel()
    listModel.setRootPath(QtCore.QDir.rootPath())

    treeView = QtWidgets.QTreeView()
    treeView.setModel(dirModel)
    treeView.setRootIndex(dirModel.index(QtCore.QDir.homePath()))

    listView = QtWidgets.QListView()
    listView.setModel(listModel)
    listView.setRootIndex(listModel.index(QtCore.QDir.homePath()))

    treeView.clicked.connect(
        lambda ix: listView.setRootIndex(
            listModel.index(ix.data(QtWidgets.QFileSystemModel.FilePathRole))
        )
    )

    w = QtWidgets.QWidget()
    hlay = QtWidgets.QHBoxLayout(w)
    hlay.addWidget(treeView)
    hlay.addWidget(listView)
    w.show()

    sys.exit(app.exec_())


text:
Q: How to supply an external tool in Eclipse with multiple selected resources? There are variables:

*

*${selected_resource_loc}, ${selected_resource_name}, ${selected_resource_path}
but none in plural:

*

*${selected_resources_locs}, ${selected_resources_names}, ${selected_resources_paths}
If you select more than one resource and run your external tool the former variables resolve to the first resource only.
The variables available to me:


text:
Q: How to split quantities in separate columns and lines Details
These are my tables and data:
create table orders (
  id int not null,
  item varchar(10),
  quantity int
 );

 insert into orders (id, item, quantity) values
 (1, 'Item 1', 10);

 create table orders_picked (
  id int not null,
  orderId int,
  quantity int
 );

  insert into orders_picked (id, orderId, quantity) values
 (1, 1, 4),
 (2, 1, 1);

To get a count of picked Items, I run this query:
select item, sum(op.quantity) as quantity from orders o left join orders_picked op on o.id = op.orderId group by item
And this is the output:

Question
Because the table orders has 5 remaining items to be picked. How can I display the remaining items in separate lines, with an extra column to identify whether it's "picked" or "remaining"? Like so:

A: Use a CTE to join the tables and to aggregate and then use UNION ALL to get separate rows for picked and remaining:
WITH cte AS (
  SELECT o.item,
         o.quantity,
         TOTAL(op.quantity) AS picked_quantity
  FROM orders o LEFT JOIN orders_picked op
  ON op.orderId = o.id
)
SELECT item, picked_quantity AS quantity, 'Picked' AS Type
FROM cte
UNION ALL
SELECT item, quantity - picked_quantity, 'Remaining'
FROM cte;

See the demo.


text:
Q: Why looping through all div's childs + removing them starts working only after X uses? why this code is not removing all nodes after first use, but it does after e.g 2 or 3 times?
function remove()
{
    var nodes = document.getElementById("test").childNodes;

    for (var i=0; i<nodes.length; i++)
    {
      nodes[i].parentNode.removeChild(nodes[i]);
    }
}

Use button a few times:
https://jsfiddle.net/ekbadocs/

A: because you forgot some node when deleting
first call
var nodes = document.getElementById("test").childNodes;
console.log(nodes)// NodeList(5) [ #text, div.red, #text, div.green, #text ]

// here's what append in for loop
// i | nodes[i]  | nodes
// 0 | #text     | #text, div.red, #text, div.green, #text
// 1 | #text     | div.red, #text, div.green, #text
// 2 | #text     | div.red, div.green, #text
// 3 | undefined | div.red, div.green
// 4 | undefined | div.red, div.green
for (var i=0; i<nodes.length; i++)
{
    nodes[i].parentNode.removeChild(nodes[i]);
}

second call
var nodes = document.getElementById("test").childNodes;
console.log(nodes)// NodeList(5) [ div.red, div.green ]

// here's what append in for loop
// i | nodes[i]  | nodes
// 0 | div.red   | div.red, div.green
// 1 | undefined | div.green
for (var i=0; i<nodes.length; i++)
{
    nodes[i].parentNode.removeChild(nodes[i]);
}

third call
var nodes = document.getElementById("test").childNodes;
console.log(nodes)// NodeList(5) [ div.green ]

// here's what append in for loop
// i | nodes[i]  | nodes
// 0 | div.green | div.green
for (var i=0; i<nodes.length; i++)
{
    nodes[i].parentNode.removeChild(nodes[i]);
}

so it delete only node on odd index in your list each time, because the loop goes one forward while your list change and the values in it "goes one index backward" filling for the position that was emptied

use
let last; while (last = node.lastChild) node.removeChild(last);

to remove every childs of a node, it goes backward to prevent this problem
or keeping your logic, delete only the first value since the element are one index backward at each itération
for (var i=0; i<nodes.length; i++)
{
    nodes[0].parentNode.removeChild(nodes[0]);
}

A: because as soon as you remove one node, the whole list is not the same anymore, so the other delete objects doesn't exist anymore.
This is much easier and does the trick:
function remove() {
  document.getElementById("test").innerHTML = '';
}

Working example:

  function remove() {
    document.getElementById("test").innerHTML = '';
  }
button
{
  height: 50px;
  width: 150px;
}

.red
{
  background-color: red;
  width: 250px;
}

.green
{
  background-color: green;
  width: 250px;
}

    a

    b

<button onClick="remove();">clickme
</button>