How to render edges as cylinders?

Question: I've loaded an OBJ polyhedron and I've used EdgesGeometry() to extract its edges:
var edges = new THREE.LineSegments(new THREE.EdgesGeometry(child.geometry), new THREE.LineBasicMaterial( {color: 0x000000}) );

But I would like to render each edge as a cylinder with configurable radius. Something like this:

Comment: **1)** Welcome to StackOverflow! Please take a moment to read [How To Ask A Good Question](https://stackoverflow.com/help/how-to-ask), and consider adding a [Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve) to your post. **2)** What have you tried so far? What you want requires understanding what `EdgesGeometry` is returning, and converting that into a collection of cylinders and spheres. If you can tell us what specific problem you're encountering doing that, we'll be able to better help you.
Comment: Possible solution: https://stackoverflow.com/questions/15316127/three-js-line-vector-to-cylinder
Answer:
A customizable solutuion, which you can start from:
var edgesGeom = new THREE.EdgesGeometry(dodecahedronGeom); //EdgesGeometry is a BufferGeometry

var thickness = 0.25; // radius of a cylinder

for (var i = 0; i < edgesGeom.attributes.position.count - 1; i+=2){

  // when you know that it's BufferGeometry, you can find vertices in this way
  var startPoint = new THREE.Vector3(
    edgesGeom.attributes.position.array[i * 3 + 0],
    edgesGeom.attributes.position.array[i * 3 + 1],
    edgesGeom.attributes.position.array[i * 3 + 2]
  );
    var endPoint = new THREE.Vector3(
    edgesGeom.attributes.position.array[i * 3 + 3],
    edgesGeom.attributes.position.array[i * 3 + 4],
    edgesGeom.attributes.position.array[i * 3 + 5]
  );

  var cylLength = new THREE.Vector3().subVectors(endPoint, startPoint).length(); // find the length of a cylinder
  var cylGeom = new THREE.CylinderBufferGeometry(thickness, thickness, cylLength, 16);
  cylGeom.translate(0, cylLength / 2, 0);
  cylGeom.rotateX(Math.PI / 2);
  var cyl = new THREE.Mesh(cylGeom, new THREE.MeshLambertMaterial({color: "blue"}));
  cyl.position.copy(startPoint);
  cyl.lookAt(endPoint);  // and do the trick with orienation
  scene.add(cyl);
}

jsfiddle example
Comment: This still works. Note that `CylinderBufferGeometry` seems to have been renamed to `CylinderGeometry`.
Comment: Oh, man! This is a crazy solution! Thank you!
Answer: Here's a version of @prisoner849's excellent answer which returns a merged BufferGeometry for just the cylinders:
/** Convert an edges geometry to a set of cylinders w/ the given thickness. */
function edgesToCylinders(edgesGeometry, thickness) {
  const {position} = edgesGeometry.attributes;
  const {array, count} = position;
  const r = thickness / 2;
  const geoms = [];
  for (let i = 0; i < count * 3 - 1; i += 6) {
    const a = new THREE.Vector3(array[i], array[i + 1], array[i + 2]);
    const b = new THREE.Vector3(array[i + 3], array[i + 4], array[i + 5]);

    const vec = new THREE.Vector3().subVectors(b, a);
    const len = vec.length();
    const geom = new THREE.CylinderBufferGeometry(r, r, len, 8);
    geom.translate(0, len / 2, 0);
    geom.rotateX(Math.PI / 2);
    geom.lookAt(vec);
    geom.translate(a.x, a.y, a.z);
    geoms.push(geom);
  }
  return THREE.BufferGeometryUtils.mergeBufferGeometries(geoms);
}

Usage:
const edgesGeom = new THREE.EdgesGeometry(dodecahedronGeom);
const cylindersGeom = edgesToCylinders(edgesGeom, 0.25);
const cylinders = new THREE.Mesh(
  cylindersGeom,
  new THREE.MeshLambertMaterial({color: "blue"})
);
scene.add(cylinders);

See updated fiddle.

How to render edges as cylinders?


Hovertemplate does not recognize the text vector I pass to it

Question: I create the bar chart below using plotly but while I give values to text it is not recognized in my hovertemplate.
library(plotly)
    "Country(s)"<-c("United Kingdom", "Brazil", "United States Of America", "India",
      "Russian Federation")
    "Number of cases"<-c(1032990, 1264637, 5905072, 618694, 735681)
    "lab"<-c("1.0M", "1.3M", "5.9M", "618.7K", "735.7K")
    cm4d<-data.frame(`Country(s)`,`Number of cases`,lab)

    fig1 <- plot_ly(cm4d, x = ~`Country(s)`, y = ~`Number of cases`,text=~lab,
                    type = 'bar',
                    hovertemplate = paste('%{x}', '
Number of cases: %{text}
<extra></extra>'),
                    colors = c("#60ab3d","#6bbabf","#c4d436","#3e5b84","#028c75"),
                    color = ~`Country(s)`)
    fig1

while this works
library(plotly)
library(dplyr)

full_data<-data.frame("Name"=c("Q1","Q2","Q3","Q1","Q2","Q3"),"Values"=c(245645,866556,26440,65046,641131,463265),
                      "Week"=c("a","b","c","d","e","f"))
desc <- full_data %>%
  group_by(Name,Week) %>%
  summarise(values = sum(Values)) %>%
  mutate(lab = scales::label_number_si(accuracy = 0.1)(values))

fig1 <- plot_ly(desc, x = ~`Name`, y = ~values,text = ~lab,
                type = 'bar',
                hovertemplate = paste('%{x}', '
Number of cases: %{text}
<extra></extra>'),
                colors = c("#60ab3d","#6bbabf","#c4d436"),
                color = ~Name)
fig1

Answer: Not sure that this is an "answer". I think you ran into a bug! It seems like {plotly} expects a "stacked" bar chart.
You can quickly make your working solution "fail" when you limit the desc dataframe to single rows only.
fig2 <- plot_ly(desc[c(1,3,5), ]
               , x = ~`Name`, y = ~values,text = ~lab
               , type = 'bar'
               , hovertemplate = paste('%{x}', '
Number of cases: %{text}
<extra></extra>'),
                colors = c("#60ab3d","#6bbabf","#c4d436"),
                color = ~Name)
fig2

With such a "single key element" dataframe, fig2 shows the annoying %text in the hovertext!
I have not yet found a way to circumnavigate this.
Comment: thanks this may be an issue that plotly devs should  look at
Comment: I think so. If you file a bug report, provide a link to this post and/or your story/experience


How to print only the numbers greater than the average?

Question: I'm new to java and i'm trying to print my only numbers greater than the average from my file.
   3.2
   7.5
   1.11
   9.4

Average:4.8525
double x;

 Scanner inputStream = null;

 try { // place file in project folder, not src;
     inputStream = new Scanner( new File("Data.txt") );
 } catch( FileNotFoundException e ) {
     System.out.println("Error opening file");
     System.exit(1);
 }

 while(inputStream.hasNextDouble()){
     x = inputStream.nextDouble();
     System.out.println(x);
 }

 inputStream.close();

Comment: Have you started writing code even ? Whats wring with a If condition before printing ?
Comment: read the values into a list. calculate the average based on the values in the list. print the items in the list, only if they are greater than the average.
Answer:
At first you need to store data at ArrayList, if you don't know the size of data.
List<Double> list=new ArrayList<>();
while(inputStream.hasNextDouble()){
 list.add(inputStream.nextDouble());
}

Calculate the sum of values.
 double sum=0.0;
 for(Double val: list){
   sum+= val;
 }

Iterate over list and print the value, which are greater than average.
 for(Double val: list){
  if(val> sum/list.size()){
  System.out.println(val);
  }
 }

Answer: while( inputStream.hasNextDouble() ){
 x = inputStream.nextDouble();
  if(x > 4.8525){
    System.out.println(x);
   }
 }

Comment: i think the purpose of the exercise is to store all values, calculate the average, then print only those greater than the calculated average. (or read the file twice - but that would suck)


External furnace fan switch energizes AC

Question: 2010 house and thermostat. White Rogers 1F80-361 controlling a lennox furnace. We have a fan switch located above our Tstat that will turn the furnace blower on and will also energize a make up air fan tied into the cold air return. The issue is that we had AC installed and now turning this switch energizes the AC unit as well. Fan switch is wired into G but looking at the wiring diagram it looks like when I energize the G contact it's running through the board and energizes the Y contact. Is there a way around this easily as if I run the furnace fan with the Tstat options it doesn't energize the make up air?

Update: looks like the tstat auto position and the y share a home. I was able
To switch the fan mode to on which obviously runs the furnace fan but I could then use the external switch which also energizes the make up air without the ac turning on. As soon as the tstat switch goes back to auto the ac contractor pulls in.
Furnace model is g43uf-48c-090-08
ADDED MATERIAL FROM ANSWER BOX
enter image description hereSo fan only mode will operate the fan as it should. Using my fan switch will turn on the ac if it's in heat or cool mode. It looks like the fan switch of the thermostat can be on power or cool according the the above schematic. What I think is happening is energizing G separately is also energizing Y as that's where the switch is sitting when in auto mode.
AC is on y and C
My external switch goes through a 120/24V contact and then comes into the furnace and is on R and G
I'll try get a picture of the terminations but I'll have to try shrink the file size.
Added the switch and make up setup. There is 120V going to the switch above the Tstat. It comes back down to the yellow hoyme box and gets swapped to 24V. From there out to the furnace and is terminated on R and G for fan.
I assume it's what was mentioned and the tstat only has an auto or on for the fan. Being in auto means it's common with the Y terminal.
Comment: Looking at the schematic, it does not show the G and C are connected. G is always for Fan Only function. You mentioned to have a switch. Show me. I believe the AC installer messed up
Comment: hang in there, reading
Comment: Can you post the model number of your furnace please?
Answer: If the room thermostat is in Cool mode, it will activate the Fan (normal function)
However if you activate the Fan only mode, only the Fan will run.
It looks like the AC installer messed up.
Answer: Most HVAC systems have "bang-bang" controls, meaning at a setpoint BANG they turn on and run full blast until they hit the desired setpoint then BANG they turn off.   In these systems, the furnace does not know about the A/C unit and they don't talk to each other.
To control the furnace, the thermostat

shunts R(h) to W to "call for heat". The furnace takes the fan under local control, running it when the heat exchanger is warm enough.
shunts R(h) to G to "call for fan". This overrides the furnace's automatic fan control and runs the fan alone.

The A/C evaporator is installed in the furnace's air handling stack, so the furnace's blower is needed to circulate the cold air.  Again in these bang-bang systems, the furnace has no idea the A/C unit even exists.  So when the thermostat wants the A/C to run, it must simultaneously

shunt R(c) to Y to call for A/C compressor to run, and
shunt R(h) to G to call for fan.

It's common for this to be physically wired as a 4-wire (Red White Green Yellow) thermostat cable from furnace to thermostat with wire functions on the same letter as the first letter of the color name.... and then a 2-wire thermostat cable (Red White) carrying  C and Y to the A/C unit.  (thus, the A/C uses the furnace's 24V transformer).
Sometimes the A/C has its own transformer, that's why there is R(h) and R(c), in which case the A/C can run direct to the thermostat with R(c) and Y.  Probably on a 2-wire cable that is red and white.
When people retrofit smart thermostats, they typically need a 5th wire, "C". (typically on the Cyan wire or blue).  Often the thermostat was run on 4-wire cable and compromises must be made. Typically the "fan only" functionality is deleted, so G is empty on the thermostat... and  Y on the thermostat is wired to both G on the furnace and Y on the A/C unit.


Jerry rig a common wire from another zone?

Question: It appears as if my zone 1 doesn't have a c terminal for a common wire or it's not very obvious. The relay is a White Rodgers 829A-845, wiring diagram here: https://www.manualslib.com/manual/539220/White-Rodgers-829a-845.html
If true, Is there some way to pigtail to my zone 2 c terminal to "complete the circuit"?
Comment: What thermostat are you trying to install? How many spare wires are in zone 1's thermostat cable?
Comment: Ecobee 3 lite. There are two spare wire for zone 1, blue and green. You can see them right above the red circle in the picture wrapped around the cable casing.
Comment: Very clever solution. Thank you very much.
Answer: You just can't get what you want...
Unfortunately, each zone relay has its own independent 24VAC transformer, so trying to "poach" a C wire connection from another zone's relay simply won't work at all.  No sense continuing down that dead end!
However, you just might be able to get what you need
The good news is that there is a way out of your situation, since the Ecobee model you have supports two-transformer systems.  You'll need:

a faceplate mount or knockout mount 24VAC Class 2 transformer (if you're using the latter, you'll need a suitable faceplate for the box)
a few feet of 18/2 thermostat wire
a few feet of 12/2 armored cable with matching bushings ("redheads") and cable clamps
Crimp spade lugs suitable for 12AWG wire
Wirenuts
Mounting screws
A suitable tool for crimping the spade lugs on
And a 4" square metal junction box

We first start by turning the HVAC system breaker off and mounting our 4" square box somewhere convenient near the existing zone relays, then running the 12/2 armored cable over to said 4" square box from the top of the leftmost zone relay using the "redhead" anti-short bushings and cableclamps.  Once that's done, we can wirenut the transformer's 120V leads to the black and white wires on the armored cable, then mount the transformer.  At the other end of the AC run, we crimp spade lugs onto the white and black wires then land them on the appropriate terminal screws on the zone relay board.  Once those terminal screws are retightened, then we can move onto the secondary side of the transformer.  The 18/2 cable attaches to the two terminal screws on the transformer at one end, and gets wirenutted to the green and blue wires on Zone 1's thermostat cable at the other end.
Now that we're done at the zone relays, we can tackle installing the new thermostat for zone 1.  Green and blue go to Rc and C respectively, while red and white go to Rh and W/W1.  This way, the Ecobee will draw power from the 24VAC transformer you just installed, while controlling the heat by connecting Rh to W to activate the zone relay by bridging the T-T terminals on said relay.


Linux kernel module development buildroot

Question: I have build a Linux kernel for the beaglebone black using buildroot. Now I would like to develop a hello world Linux kernel module application:
#include <linux/init.h>
#include <linux/module.h>

MODULE_LICENSE("Dual BSD/GPL");

static int hello_init(void)
{
    printk(KERN_ALERT "Hello, world\n");
    return 0;
}

static void hello_exit(void)
{
    printk(KERN_ALERT "Goodbye, cruel world\n");
}

module_init(hello_init);
module_exit(hello_exit);

The problem is I still keep missing some header files. After finally gathering them all, I get an error that the code is not compilable (many errors, I don't want to paste them all). What I was wondering is either I am really including the right files?
At the moment I have:
/home/lukasz/brl/Machine/beaglebone/build/linux-headers-a75d8e93056181d512f6c818e8627bd4554aaf92/include
/home/lukasz/brl/Machine/beaglebone/build/uboot-2018.01/arch/x86/include
/home/lukasz/brl/Machine/beaglebone/build/linux-headers-a75d8e93056181d512f6c818e8627bd4554aaf92/arch/arm/include/generated
/home/lukasz/brl/Machine/beaglebone/build/linux-headers-a75d8e93056181d512f6c818e8627bd4554aaf92/arch/arm/include
/home/lukasz/brl/Machine/beaglebone/build/linux-a75d8e93056181d512f6c818e8627bd4554aaf92/include

Its a bit odd to me that the C include files and asm files are so scattered around within the directory. Are there some mistakes in my understanding of the topic here?
My Linux version:
# uname -a
Linux buildroot 4.9.59 #1 SMP Fri Oct 5 11:55:54 CEST 2018 armv7l GNU/Linux

Comment: which toolchain are you using to compile the module? are you compiling the code directly on the beagle or the host device? if you wish to compile the module on the beagle than you need to make sure you build buildroot with gcc and dev directories.
if you wish to compile on the host make sure that you build the buildroot toolchain and use it to compile the module
usually when such an error occurs it points to a wrong toolchain
Comment: Thanks for ansfer. At first I wanted to build on the target, but wasnt able to make the gcc "appear" in my build. So i xcompile using the toolchain created by buildroot
Comment: Btw, a regular hello world c application compiles on host and runs on target correctly
Answer: To compile a kernel module, you need the real kernel sources, not just the kernel header files. You have to build from the kernel source directory with M= pointing to the source of your modules. And together with your module source, you of course also need a working Makefile. These steps are explained in any of the dozens of how-to-write-a-kernel-module guides, e.g. this one.
For cross-compilation, you also need to pass the appropriate arguments so that the kernel knows for which architecture to build and which cross-compiler to use. At the very least, this means you have to give the ARCH= and CROSS_COMPILE= options when building. Sometimes you need additional options (e.g. to point to the appropriate depmod tool).
To simplify this, Buildroot offers kernel module infrastructure. In the simplest case, you can just create a Config.in file containing
config BR2_PACKAGE_HELLOMOD
        bool "hellomod"
        depends on BR2_LINUX_KERNEL

and a hellomod.mk file containing
HELLOMOD_SITE = /path/to/hellomod/source

$(eval $(kernel-module))
$(eval $(generic-package))

You also have to source the Config.in from package/Config.in in the Buildroot tree. Or better yet, use an external tree so you don't have to modify Buildroot itself.
Comment: I am not sure if kernel sources are a prerequisite, I have got stuff to work with out the sources and just the appropriate headers.
Comment: Well, you indeed don't need the full sources. But the uapi headers are definitely not enough. You need at least `include/`, `arch/xxx/asm`, top-level `Makefile`, part of `scripts/`, ...
Comment: Hello, thank you for answer. At this point I dont want to compile my module into the kernel at kernel build time, but just compile it separately and try to load it in runtime. The things you mention seem to be higher level stuff that I would need to settle, but once everything is working. I am not certain either my headers dirs are correct. Is there any reference how to crosscompile a module using the tools provided by buildroot (and which files to include)?
Comment: On my host device I was able to build a test module using provided tutorial: http://devarea.com/linux-kernel-development-and-writing-a-simple-kernel-module/ . I think my problem with xcompiling is that I dont have the build directory in the lib/modules dir. Is there any specific way to build those?
Comment: As written in the answer: once the module compiles correctly natively following e.g. the devarea.com guide, you can include it in Buildroot as a cross-compiled module by using the kernel-module infrastructure. Documentation of that is referenced in the answer, and summarized as well. What more do you need?
Comment: But thats the end way of providing modules- compiling them statically. I am trying to cross compile the module and add it using insmod during runtime. Also, I cannot compile it natively, since the host is x86 and the target is Arm.
Comment: It is not possible to compile external modules (that are not part of the Linux tree) statically into the kernel. The instructions are for compiling them as modules, which you load with modprobe or insmod.


Your app couldn't be released because the following APKs use sensitive permissions that haven't been declared : 56

Question: Error
Your app couldn't be released because the following APKs use sensitive permissions that haven't been declared : 56. If you're attempting a staged roll-out, do a full roll-out instead.
I am not able to move the update apk from Alpha version to production due to above error. I removed all the sensitive permissions in the previous versions itself.What is the meaning of "sensitive permissions that haven't been declared : 56".
I tried doing full roll-out also but still not allowed to release the updated version.
Comment: when had you uploaded apk over alpha channel? It must be long time back
Comment: what permissions are you now asking for? post a list of those so people can help
Comment: If you for example are asking for the geo location you also have to declare this in the content rating form in the Google Play console
Comment: @PareshMayani I have uploaded APK to Alpha yesterday
Comment: @Kushan No new permissions i am asking and I kept to remove these permission in the manifest if they are using in merged manifest.
Answer: What 3rd party libraries are you using? My guess is, at least one of them asks for permissions you did not declare in your manifest. Also, if you are using flavours, make sure to check the auto-generated, merged manifest. Hope that helps!
Answer: This Reference solved the issue. We have to RETAIN the previous version which we presented the inline permission declaration form. Hope it will help someone to resolve the issue.


Touch event is not working

Question: I am developng one app for touch and type phone. Now in one screen of the application, there is 3 buttons.
Here if i touch in the three buttons, it is working. But if i touch outside the buttons, means in the top bar or in the bottom bar, then also touch event is working. Suppose in the below, Add More button is focused. So if i am touching in the bottom bar, then also button touch is working. To resolve this problem, i wrote the below code:
protected boolean touchEvent(TouchEvent event) {
    try {

        int touchXPos = event.getX(1);
        int touchYPos = event.getY(1);
        int addBtnXPos = btnAddMore.getLeft();
        int saveBtnXPos = btnSave.getLeft();
        int helpBtnXpos = btnHelp.getLeft();

        int vfmTitleTouch = m_vfmTitle.getHeight();
if(event.getEvent() == TouchEvent.CLICK)
      {
        if ((touchXPos >= addBtnXPos + 40) && (touchXPos <= (addBtnXPos + btnAddMore.getWidth() + 40)) && (touchYPos <= screenHeight -10) && (touchYPos >= (screenHeight -10 - btnAddMore.getHeight())) /*&& (touchYPos < (screenHeight-gmYPos)) */) {
            Logger.out("touchEvent", "------------------------------1");
            showPopUp();

        } else if ((touchXPos >= saveBtnXPos + 40) && (touchXPos <= (saveBtnXPos + 40 + btnSave.getWidth())) && (touchYPos <= screenHeight -10) && (touchYPos >= (screenHeight -10 - btnSave.getHeight())) /* && (touchYPos < (screenHeight-gmYPos))*/) {
            Logger.out("touchEvent", "------------------------------2");
            saveToDb();

        } else if ((touchXPos >= helpBtnXpos) && (touchXPos <= (helpBtnXpos + btnHelp.getWidth())) && (touchYPos <= (btnHelp.getTop() + btnHelp.getHeight())) && (touchYPos >= btnHelp.getTop()) /* && (touchYPos < (screenHeight-gmYPos))*/ ) {
            Logger.out("touchEvent", "------------------------------3");
            UiApplication.getUiApplication().pushScreen(new HelpScreen());

        } else if ((touchYPos <= screenHeight - hfmBtn.getHeight()) && (touchYPos >= (vfmTitleTouch))) {
            Logger.out("touchEvent", "------------------------------4");
            //Logger.out("touchEvent", "touchY::::" +touchYPos  + "Vfm Title::::" +vfmTitleTouch  + "  "+"GM Y Pos"+  gmYPos);

        }
            return true;
        }
    } catch (Exception e) {
    }

    return super.touchEvent(event);
}

But it is not working..Can any one help me out??
And touch event should work in the middle of the screens like for check boxes also..
Thanks..
Answer: Check the answers of the question BlackBerry touchEvent outside Field triggers fieldChanged provided by Paul Sylliboy and Arhimed.
I have pasted those links on comment first, but later removed it from there to share the code snippet for killing unwanted touch events, which I found very useful.
protected boolean touchEvent(TouchEvent message) {
    int event = message.getEvent();
    // you can add other events
    if (event == TouchEvent.CLICK || event == TouchEvent.UNCLICK) {
        // Kill all click events that happen outside any fields
        if (getFieldAtLocation(message.getX(1), message.getY(1)) == -1)
            return true;
    }

    return super.touchEvent(message);
}

// The regular getFieldAtLocation returns wrong values in
// open spaces in complex managers, so we override it
public int getFieldAtLocation(int x, int y) {
    XYRect rect = new XYRect();
    int index = getFieldCount() - 1;
    while (index >= 0) {
        getField(index).getExtent(rect);
        if (rect.contains(x, y))
            break;
        --index;
    }

    return index;
}

Comment: Thanks Rupak. I also made some changes in the code. But it is somehow working. Now when i am clicking outside the button, it is not executing the code related to button, but focus is only coming to the button. It means when i ma touching outside the save button, focus is coming to the save button.
Comment: I have a simple query. Did you set any `FieldChangeListener` for those `ButtonField`s? If yes then you dont't have to do anything in `touchEvent(..)` except killing unwanted events. And I'm not sure about what may cause the focus problem. You can follow the strategy described in the answer link provided above.
Comment: So you mean i should not use both: FieldChangeListeer and touchevent()?
Comment: Yes, because normally the parent Field/Manager/Screen handles all the touch events and It will eventually pass the event to the `fieldChanged(...)` method.
Comment: if i will write your code that you posted, then also it is giving the same problem...

Touch event is not working


Logical issues with the weak law of large numbers and its interpretation

Question: In several probability textbooks I have found what amounts to the following argument:

Let A be an event in some probabilistic experiment. Let p=P(A) be the
  probability of this event occurring in n trials. Let $M$ be the
  fraction of time $A$ occurs in $n$ trials:
$M = \frac{X_1+...+X_n}{n}$
where $X_i$ is 1 whenever A occurs, and 0 otherwise; in particular
  $E[X_i]=p$. From simple properties of expectation and variance:
$E[M] = \frac{E[X_1+...+X_n]}{n} = \frac{E[X_1]+...+E[X_n]}{n} =
 \frac{np}{n} = p$ $Var[M] = \frac{Var[X_1+...+X_n]}{n^2} = \frac{Var[X_1]+...+Var[X_n]}{n^2} = \frac{n\sigma^2}{n^2} =
\frac{\sigma^2}{n}$
So using Chebyshev's inequality:
$P(|M-p|>\epsilon) \le \frac{\sigma^2}{n\epsilon^2}$
And so:
$\lim_{n \to \infty} P(|M-p|) = 0$

It is often claimed that this derivation links the mathematical theory of probability with the concept of frequency, but I think is not true and the derivation is either pointless or tautological, for consider the following: if you proceed purely from mathematical axioms, the result holds true in an abstract sense, but there is no logical reason for the particular quantities to have the interpretations we give to them intuitively, e.g. one can not interpret M as a frequency of occurrence without adding an additional axiom specifying what P(A) is, at least this is how it seems to me.
On the other hand, if you choose the frequency interpretation of probability, the moment you say "let p=P(A) be the probability of A" the very same moment you make an assumption of  existence of a single number p that is the limit of the relative frequency of occurrence of the event A, so what amounts to placing:
$\lim_{n \to \infty} P(|M-p|) = 0$
among the axioms.
Ideally I would like to know what someone familiar with mathematical logic or research in foundations of mathematics where such issues are examined thinks about this, while in areas like set theory there are volumes written about issues of this kind, in probability theory, while there are plenty of philosophical books about various ways of interpreting probability, I have not found a single work on the mathematical logic of the subject, besides Kolmogorov's Grundbegriffe. My questions are the following:
Is my reasoning correct?
Is there any reason I miss for this derivation to be important or interesting in some sense?
Are there any works that examine probability theory from the standpoint of mathematical logic, where issues of this kind are made more clear?
For reference, textbooks are either very mysterious about this, or altogether avoid motivating or interpreting the result. Jim Pitman's "Probability", page 101 this is called a "mathematical confirmation of our intuitive idea of probability as a limit of long-run sequences". In Bertsekas and Tsitskilis, page 270, M is called the empirical frequency, and it is said that "Loosely speaking, this allows us to conclude that empirical frequencies are faithful estimates of p. Alternatively, this is a step towards interpreting the probability p as the frequency of occurrence of A.". Mark Kac in "Probability and related topics in the physical sciences", page 4, writes:

Actually, the theorem says disappointingly little. All it says, in
  fact, is the following: If the probability of a certain event was
  calculated in accordance with certain assumptions and rules, then the
  probability (again calculated, according to the same assumptions and
  rules) that the frequency with which the event will occur in a large
  assembly of trials will differ significantly form the calculated
  probability is low.

In the notes for a probability theory course by Rota and Baclawski, the interpretation seems more similar to what I have written above:

This is essentially just a psychological theorem, for it does not
  provide the information necessary for concrete applications. The
  Central Limit Theorem is far more useful and in fact the law of large
  numbers is a consequence of the Central Limit Theorem. We leave the
  proof as an exercise.
In any case the law of large numbers is a purely mathematical theorem.
  In order for it to make sense we must already have the concepts of
  probability, random variables, means, variances, etc. We cannot use
  this as a definition of probability. But we cannot even use the law of
  large numbers as a justification of the frequentist point of view.
  This point of view says that probabilities represent a physically
  measurable quantity (at least in principle). But there is no concept
  of a physical "measurement" corresponding to the mathematical concept
  of the limit:
lim n->inf of (X_1+...+X_n)/n
The relationship between physical experiments and the theory of
  probability is much more subtle than the frequentist point of view
  would have one belive.

Finally, Grinstead and Snell write what seems also very reasonable, but not very precise:

The Law of Large Numbers, which is a theorem proved about the
  mathematical model of probability, shows that this model is consistent
  with the frequency interpretation of probability.
Comment: Please don't [crosspost](http://mathoverflow.net/questions/164884/logical-issues-with-the-weak-law-of-large-numbers-and-its-interpretation).
Comment: Sorry, I am just looking for a satisfying answer, and I thought those were two completely distinct communities.
Comment: You can take a look at Jan von Plato, *Creating Modern Probability Its Mathematics Physics and Philosophy in Historical Perspective* (1994).
Comment: Please delete this question, it was initially framed too vaguely to produce meaningful answers, and I made it more concrete here: http://math.stackexchange.com/questions/777493/do-the-kolmogorovs-axioms-permit-speaking-of-frequencies-of-occurence-in-any-me

Sorry for a partial repost, but apparently I wasn't able to phrase my issue clearly enough here, and having seen the attempted answers and having thought more, I think I am able to formulate it in a way allowing a proper answer.
Answer: As the link provided by the previous poster also states, the LLN is a result relating the axiomatic concept of probability to the statistical concept of frequency. Probability theory per se does not deal with the physical meaning of probability.
From a philosophical perspective, you can either be a frequentist which implies that probability is only meaningful as a frequency derived from repeating your experiment; or you can be a naturalist (aka Bayesian) which implies that probability is a measure of the uncertainty in inherent nature and that frequency is a way to assess that uncertainty. And that is the main philosophical contribution of the LLN and Glivenko-Cantelli lemma.
I use the word naturalist because physicists were thinking about probability this way long before statisticians and their frequentist interpretation muddied the waters. Frequentism denies meaning to statements like the probability of rain tomorrow is 45% and also all of quantum mechanics.
I would suggest Cox's seminal paper Probability, Frequency, and Reasonable Expectation in American Journal of Physics 14:1-13 (1946)
Comment: The very point it that I think that the LLN **can not** relate the axiomatic concept of probability to the statistical concept of frequency, for in the purely mathematical framework, while the theorem is true, nothing in the axioms allows to talk of p or M as frequencies.
Comment: I think what is called the "empirical mean" can not from the logical point of view be thought of as a relative frequency if only the Kolmogorov axioms are assumed, IMO the LLN by itself does not establish any connection at all within the mathematical theory between frequency and probability, it only **appears** to make such connection because the concepts have such forceful intuitive interpretations. In other words, people who claim that LLN connects probability to frequency, make a tacit assumption about what the various variables represent, but nothing of the sort follows from the axioms.
Comment: Could you clarify what you mean by the statement : "in the purely mathematical framework, while the theorem is true, nothing in the axioms allows to talk of p or M as frequencies" ?
Comment: Could you clarify what you mean by the statement : "in the purely mathematical framework, while the theorem is true, nothing in the axioms allows to talk of p or M as frequencies" ?. Starting with P([X<x] ) as axiomatic, we define E[X] purely through measure-theoretic axioms.  So far - no appeal to frequency is made. It's only when we get to the LLN (Glivenko-Cantelli) that we make the relation between the limit of empirical mean (frequency) to the expectation (probability).  So I'm not sure why we would want frequency / empirical-mean as an axiomatic concept in the definition of P(X) ?
Comment: Think about the meaning of E[X_1+...+X_n] if p is not up front known to be the relative frequency in the limit of infinite number of trials.
Comment: Basically M is not the number of successes in n trials if p is not already assumed to be a relative frequency.
Answer: I finally found a particularly clear example in the book "A Treatise of Probability" by Keynes, that I think shows beyond any doubt that if p is anything but a number defined a priori to precisely satisfy $\lim_{n \to \infty} P(|M-p|) = 0$, the WLLN ceases to be interpretable as a valid statement about frequencies:

The following example from Czuber will be
  sufficient for the purpose of illustration. Czuber's argument is as
  follows: In the period 1866–1877 there were registered in Austria
m = 4,311,076 male births
n = 4,052,193 female births
s = 8,363,269
for the succeeding period, 1877–1899, we are given only
m' = 6,533,961 male births;
what conclusion can we draw as to the number n of female births? We
  can conclude, according to Czuber, that the most probable value
n' = nm'/m = 6,141,587
and that there is a probability P = .9999779 that n will lie between
  the limits 6,118,361 and 6,164,813. It seems in plain opposition to
  good sense that on such evidence we should be able with practical
  certainty P = .9999779 = 1 − 1/45250 to estimate the number of female
  births within such narrow limits. And we see that the conditions laid
  down in § 11 have been flagrantly neglected. The number of cases, over
  which the prediction based on Bernoulli's Theorem is to extend,
  actually exceeds the number of cases upon which the à priori
  probability has been based. It may be added that for the period,
  1877–1894, the actual value of n did lie between the estimated limits,
  but that for the period, 1895–1905, it lay outside limits to which the
  same method had attributed practical certainty.

Maybe this is something obvious in retrospect, that additional assumptions might be needed to interpret probabilities and that those assumptions might overlap theorems of abstract probability theory, but I have browsed through literally dozens of textbooks and they all either do not provide any interpretation or motivation for this result, or say something false or "not even false" - too vague to even have any meaning. Richer with this insight I actually found the following statement in Kolmogorov's Grundbegriffe, in section 2 of chapter 1, "The Relation to Experimental Data":

We apply the theory of probability to the actual world of experiment
  in the following manner:
...
4) Under certain conditions, which we shall not discuss here, we may
  assume that the event A which may or may not occur under conditions S,
  is assigned a real number P(A) which has the following
  characteristics:
a) One can be practically certain that if the complex of conditions S
  is repeated a large number of times, n, then if m be the number of
  occurrences of event A, the ratio m/n will differ very slightly from
  P(A).

As far as I understand, this is Kolmogorov essentially saying the WLLN becomes an additional axiom if any attempts are made to give interpretation to his very general theory, at least in the particular interpretation he envisioned. Unless this is done, there is no ground for treating M as a relative frequency, it is a term of unknown interpretation, just as a line is an entity of unknown interpretation from within the axiomatic framework of geometry. WLLN is the very assumption that allows interpreting M as a relative frequency. This actually contradicts statements of the kind claimed in one of the answers and stated in some textbooks:

LLN is a result relating the axiomatic concept of probability to the
  statistical concept of frequency.

It is either a theorem that has nothing to do with frequency, or an assumption or additional axiom.
Answer: I believe my answer here might be what you're looking for. I'm also assuming the question asked there is close to what you're asking here.
Comment: I have seen this thread before asking the question, it is a variation on the some topic, I however do realize the difference between probability as a mathematical theory and its real world models, and I think my question still stands with that out of the way.
Comment: @JarosławRzeszótko: I'm not entirely sure what you're asking for then. When you say "$p$ is not defined" this is ambiguous. In probability theory $p$ is very well defined, it's whatever $P(A)$ is. Whereas as a frequentist, you *define* $p$ through something like the strong law of large numbers.
Comment: @JarosławRzeszótko: so for example, if you encounter a coin, then mathematically you can define it as a random variable with $p=0.50$. In the real world you'd have to confirm that fact somehow, perhaps by flipping it many times and then looking at the average.
Comment: @JarosławRzeszótko: The key is that rather than saying you are sure that $p=0.50$ in the example above, you can reasonsably discredit statements such as $p=0.51$ with enough trials. Naturally, there's no infinite accuracy that would allow you to conclude that $p=0.50$ but even with a few hundred throws, you can conclude say, $0.40<p<0.60$.
Comment: "not defined" is sloppy wording on my side, I meant it does not allow for an interpretation as a frequency. My question is about the overall significance of the result shown, and about the confusing comments in the textbooks, as in the comment above, many authors seem to state something to the effect that this law connects probabilities to frequencies, I think that you cannot conclude anything of the sort purely from the mathematical derivation of the law, and would like to have some confirmation on this.
Answer: This became rather long for a comment.
I think we have here a model which was designed to be a good model of real-life problems. The real decision which is being made when using the ideas of probability is that this is a good model. And if there is reason to believe it is a good model, then we believe that the consequences we derive from the model apply to our real life situation.
Here this is not just that the limit is $p$ but also that the variation in outcomes is insufficient to prevent there being a limit. How would we measure probability in the real world without such a limit existing, you ask. Well a priori it is conceivable that our situation is wholly symmetrical between outcomes, with no reason to believe that one is preferred to another, yet the inherent variability of the process is so great that no limit exists. If our model applies, this cannot happen. And the model does apply, and constrains our ability to think what the world might be like if it didn't.
If the model didn't work so well, we'd be using a different model.
Answer: Take a look at Burdzy's book,
The Search for Certainty: On the Clash of Science and Philosophy of Probability.
Comment: The book is titled "The Search for Certainty: On the Clash of Science and Philosophy of Probability" (for further reference)
Answer: As my answer on the other question, in a sense you are correct.
You are correct because obviously the mathematical axioms include the derivation of the LLN or WLLN (i presume this is what one could call a "weak" tautology), however it is a question if the other way follows too (meaning assuming LLN or WLLN, derive the axioms of probability) which can be answered in the negative (since the simple axioms of probability hold in other cases except LLN or WLLN).


IIS authentication UNC folder error

Question: I have a problem creating a website over a network folder
The network admin give me a domain user that can access the network resources:

Then i create a website pointing to that network folder:

Change the option "Connect as..." and set a custom user (the one that network admin give to me)

Click on "Test Configuration" and give me this error:

Also tried changing Application Pool Identity and th error still there.
Funy things:

The user HAS write and read access on the network folder
When configuring the web site, IIS creates and modify a web.config file on network folder but then when running website it said cannot read the web.config

Any suggestions would be appreciated
Answer: I've run into this issue. Previously I've changed the permissions to give full access to the folder for the user and it's fixed this issue.
Comment: Thank you, in this case the user already has full access to the folder, may be is because one of the servers is on domain and the iis server is not?
Answer: Late answer. It's was a problem with the domain account. The iis was not in domain. So, in other server wich was on domain, try the connection and it was succesful.

IIS authentication UNC folder error


Use the divergent theorem to verify the volume of a circular cone

Question:
Let $T$ be a region with boundary surface $S$ such that $T$ has volume
$$V=\frac{1}{3} \iint_S (x dydz +ydzdx+zdxdy)$$
use this equation to verify the volume of a circular cone with height $h$ and radius of base $a$ is $V = \pi a^2 \frac{h}{3}$

Here is what I got so far
Since
$$V=\frac{1}{3} \iint_S (x dydz +ydzdx+zdxdy)$$
$$V= \iint_S x dydz =\iint_S y dxdz=\iint_S z dxdy$$
Since this is a cone so I can have $r(w,\theta)=[w\cos(\theta),w\sin(\theta),w]$  with $0\leq w\leq a$ and $0 \leq \theta \leq 2\pi$ as the parametrization.
Now I'm stuck. I wonder if any one can give me a hint. Please.
Comment: Div grad curl and all that, problem in Chap-1, II-26 , b.ii
Answer: Thinking geometrically can save a whole bunch of time here. Split the surface integral over the cone into two integrals, an integral over the circular base (call this surface $B$) and integral over the curved part of the cone's surface connecting base to apex (call this surface $C$).
Consider the surface integral over $C$ first. Note that the vector field whose surface integral we're evaluating is simply a scalar multiple of the radius vector. But since we placed the cone's apex at the origin, any radius vector from the origin to a point on the surface $C$ will also be a tangent vector to surface $C$ at that point. It follows that this surface integral vanishes, since the dot product of a surface tangent vector with the surface normal vector is zero at each point:
$$\iint_{C}\vec{F}\cdot\hat{n}\,\mathbb{d}S=\frac13\iint_{C}\vec{r}\cdot\hat{n}\,\mathbb{d}S=0.$$
Now for the other part of the surface integral, $\iint_{B}\vec{F}\cdot\hat{n}\,\mathbb{d}S$. Again, $\vec{F}=\frac13\vec{r}$, and since we've oriented the cone so that its axis of symmetry coincides with the $z$-axis we can immediately see that the unit normal vector to this part of the cone's surface is simply the Cartesian unit vector
$$\hat{n}=\hat{z}=\langle0,0,1\rangle$$. Parametrizing this surface is also straightforward:
$$\vec{r}(\rho,\phi)=\langle\rho\cos{\phi},\rho\sin{\phi},h\rangle,~~~\text{where }0\leq\rho \leq a,0\leq\phi\leq 2\pi.$$
Hence,
$$\vec{F}\cdot\hat{n}=\frac13 h\\
\implies \iint_{B}\vec{F}\cdot\hat{n}\,\mathbb{d}S = \frac{h}{3}\iint_{B}\,\mathbb{d}S = \frac{h}{3}(\pi a^2).~~~QED$$


How can can I repair peeling shower drain coating?

Question: There is some kind of plastic coating over my drain that is peeling and needs replacing. I can't work out what kind of product I would need to use to recover it to protect the plug and would appreciate any advice!
Comment: I'd be replacing the assembly with a shiny new chrome one. They're not expensive, and assuming you have access they're not usually complicated.
Answer: This white coating isn't actually sealant. The seal to keep water from leaking is either some plumber's putty under the rim of the drain or a foam or rubber gasket (and yours is probably plumber's putty). So long as the drain isn't actually leaking water, there is no technical reason for that white layer to be there. It appears to be purely aesthetic.
Generally, in the US at least, that part of the drain is either plastic or metal and chromed, though some are white plastic. It appears to me that yours is actually metal and that someone in the past may have painted it white to hide the scratching and pitting in the part.
Should you not like the look of the pitted metal underneath (and it does look rough), you could either replace the drain*, or you could remove it then recoat it with either paint (which may not last a terribly long time), white epoxy (which should last a very long time) or possibly a white rubberized coating like PlastiDip™ (which should also last a long time).
Any recoating would require proper preparation which would include making sure that the part is dry, scraping off the old coat, giving it a good sanding to ensure any rust and corrosion are removed and that the surface is smooth. Then, follow any extra instructions for the product you choose.

*Replacement is very much within the realm of DIY, and replacement parts should be rather inexpensive - probably less than what I've seen some people spend at McDonald's for lunch...
Comment: Replacement of the drain can be outside the skill level of some DIYers. Especially since the possibility of leaks, if the job isn't done well, can cause some serious and expensive issues.  Not advised for someone new to doing their home repairs. After having some problem solving experiences, then sure maybe a try.
Comment: Fair point, @RMDman. A few _good_ YouTube* videos should be sufficient to learn the skills. Of course, asking here (after searching first, of course) should also help. *NOTE: YT is _notorious_ for _bad_ teaching, so watching several and trusting gut instinct as to "this gal's got it right" and "that guy's an idiot", as well as several confirming the "this is right" instinct is always recommended.
Comment: I've gotten the "this person's got it right" and "this person's an idiot" vibe from actual "professionals" I've paid to do the work for me as well.  Sometimes YouTube imitates life...
Answer: That is starting to corrode. The factory applied paint is peeling off. You could sand it and tape off around it and apply an epoxy primer and paint. However if it is corroded on top it may be corroded underneath and can start leaking, giving you more problems. Most of the time these things are replaced. Especially if the tub gets everyday use. If you are up for trying a replacement, ask the question of how. If not, it may be time to call a plumber.
Comment: That ain't factory-applied :D


The set of real numbers and the set of Real valued functions are not similar (equinumerous)

Question: We need to show that the set of real numbers and the set of Real valued functions whose domain is $\mathbb R$ are not similar (equinumerous).
Let $\mathbb R$ denote the set of real numbers and $S$ denote the set of real valued functions whose domain is $\mathbb R$.
Suppose $\mathbb R$ and $S$ are equinumerous. Then, $~\exists ~$ a one-one onto function $f :\mathbb R \rightarrow S $ such that $f( \mathbb R) = S$.
Let $a \in \mathbb R$, then let $g_a$ be the associated real valued function with $a$. Thus :
$f(a) = g_a$.
To bring a contradiction, I think we should show that $f$ is either not one-one or onto.
How do I move forward?
Thank you for your help.
Comment: Trying to show that $f$ is not one-one is not a promising approach because there are at least as many real functions as there are numbers. For instance, what if $g_a$ is just the constant function $a$? So the way forward is to try and show that $f$ is not onto, which means, find a real function which is different from every $g_a$.
Comment: I doubt it. To show that $f$ is not onto, you have to construct a function $h:\mathbb R\to\mathbb R$ such that $h\ne g_a$ for each $a\in\mathbb R$. That means that, for each $a$, there is some $x$ such that $h(x)\ne g_a(x)$. The simplest way is to take $x=a$, that is, define a function $h$ so that $h(a)\ne g_a(a)$ for each $a$. For instance, $h(a)=g_a(a)+17$.
Comment: Suppose $f(a) = g_a$ , then $1 + g_a = f(b)$ for some $b \in \mathbb R \implies 1 + f(a) = f(b) \implies f(b) - f(a) = 1$. Am I on the correct path?
Comment: I get it now. Thank you very much :-)
Answer: Don't move forward. As often happens, you need to move sideways, backwards, different sideways, forward, sideways, sideways, backwards, sideways, forward in order to actually move forward.
Note that the set of functions from $\Bbb R$ into $\{0,1\}$ is a subset of all real-valued functions, and remember Cantor's theorem.
Comment: (In general, the best way to move is by doing two quarter-circles forward, and then all three punch keys. HADOUKEN!)
Answer: Suppose $F$ is a function from $\mathbb{R}$ to $\mathbb{R}^{\mathbb{R}}$ (the latter is the set of real-valued functions on the reals). We show that $F$ is not onto:
For every $x \in \mathbb{R}$, define $f(x) = F(x)(x)+1$. This well-defined, because $F(x)$ is some function on $\mathbb{R}$ that we can evaluate at $x$, we get a real number and add 1 to it.
Suppose that there exists some $p \in \mathbb{R}$ such that $F(p) = f$. Then $f(p) = F(p)(p) + 1$ (by definition of $f$) $ = f(p) + 1$ as $F(p) = f$. So $f(p) = f(p)  +1$, which cannot be (or we'd have $0 = 1$).  So no such $p$ can exist. So our $f$ shows that $F$ is not surjective.
As the map that sends each $x \in \mathbb{R}$ to the constant function $f_x$ with value $x$ is clearly injective, we have an injection from $\mathbb{R}$ into $\mathbb{R}^{\mathbb{R}}$ but we cannot have a bijection, so $|\mathbb{R}| < |\mathbb{R}^{\mathbb{R}}|$.
Answer: It should be obvious that an injection from $\mathbb R$ to S is possible, given by assigning each real number $r$ to the constant function $g(x)=r$.  In fact, we have a bijection between $\mathbb R$  and the set of all constant functions.  Now your problem is to show that there is strictly 'more' functions than constant functions.   Assume you have a bijection, and work from there for a contradiction
Comment: Oh okay .. So, since, there exist a lot more functions than the constant function $g_a(x)=a$ such as $g(x) = ax$, then the mapping $f$ should not be onto. Am I correct .. Is that it?
Comment: Correct,  but that "should be" needs to be proved, as often times in set theory things that you think "should be" more actually aren't.
Comment: Okay .. Our aim is to prove that there are a lot more functions than the set of real numbers.Let $f : \mathbb R \rightarrow S$ be a bijection. I am not able to formally write down what I am thinking .. uhmm, since, there are many more functions other than constant functions , so ... ? Could you give me a hint?


How do I write raw bytes to a sound-device?

Question: In the olden days, you used to be able to open /dev/dsp for reading and writing, now, with PulseAudio this doesn't work anymore.
I thought you could do it with padsp, but this code doesn't run:
import ossaudiodev

f = ossaudiodev.open("w")
fmt, channels, rate = dsp.setparameters(fmt, channels, rate)

(running it via padsp python script.py)
The error I get is No such file or directory: '/dev/dsp'.
What am I missing? How do I read and write raw bytes from and to a sound device, and how do I select which one I want to use?
Answer: This script is a thin wrapper around PulseAudio's Simple API. It allows you to write samples to the default output:
#!/usr/bin/env python3

import random
import ctypes
import struct

class NoiseMaker (object):

    PA_SAMPLE_U8 = 0
    PA_STREAM_PLAYBACK = 1

    def __init__(self, rate, channels):
        pat_sample_spec = ctypes.c_buffer(struct.pack("LLB",
            self.PA_SAMPLE_U8, rate, channels))
        self.pa = ctypes.cdll.LoadLibrary("libpulse-simple.so.0")
        self.s = self.pa.pa_simple_new(0, "App", self.PA_STREAM_PLAYBACK,
            0, "App Noise", ctypes.byref(pat_sample_spec), 0, 0,0)

    def write(self, data):
        self.pa.pa_simple_write(self.s, data, len(data), 0)

    def __del__(self):
        self.pa.pa_simple_free(self.s)

one_second_noise = bytes(random.randint(0, 255) for i in range(44100*2))
NoiseMaker(44100, 2).write(one_second_noise)

The rate (44100) defines how many samples there are in a second of real time. It expects bytes in the range of 0-255 inclusive, which is defined by PA_SAMPLE_U8 (equivalent to 'Unsigned 8-Bit' as shown by Audacity, for example). If you have more than one channel, it expects alternating samples for each of them. So, one second of noise has 44100 samples per channel = 88200 samples, where the (modulo 2 = 0) ones are for the left channel.
Please note that this script runs only on Python 3
Comment: As an side note, if you're interested in using sound manipulation with the terminal, you can write or read raw audio using the `pacat` tool.


Only four specialisation skills?

Question: So i'm new to World of Warcraft and now that i've hit level 10 with my Warlock i'm wondering, are there only 4 specialisation skills or are the others hidden?
Comment: i mean like the specialisation from a mage to fire, ice and arcan.
Comment: What do you mean by specialisation skill?
Answer: There are 3 or 4 specializations available for each class. Each specialization is focused on a particular playstyle, and will come with its own abilities. To answer your question, no there are no "hidden" specializations, and no more specializations are later unlocked.
Starting at level 15, you get to choose your Talents. Each "tier" has 3 available talents to choose from, and you may choose 1 of the 3 from a given tier. More tiers are further unlocked at levels 30, 45, 60, 75, 90, and 100. Most of the talents are the same regardless of your class specialization, however some can change depending on your specialization.
When you hit level 30, you get Dual Talent Specialization. This means that you can switch between two specializations depending on what you would prefer to do. You'll likely maintain separate gear for each specialization, since gear that is good for one specialization might not be good for another. Though for your Warlock, this is less of an issue. I would be more concerned with someone trying to tank or heal in gear designed for damage.
If you would like to try out a different specialization, you do have the option of respeccing:

Changing a character's talent build is called respeccing or is referred to as a respec. Characters can unlearn all of their talents (becoming untalented) at their respective class trainers, at a cost. Unlearning talents scales up the more times it is done: 1 gold, 5 gold, 10 gold, 15 gold, etc., up to 50 gold.
The cost to unlearn talents decays over time. This cost will be reduced by a rate of 5 gold per month to a minimum of 10 gold.

Finally, it's worth noting that the system can always change. It used to be that every class had only 3 specializations. Back in WotLK, the "specialization" was never a thing, and each class could freely assign talent points (51 points at level 80) across their 3 talent trees. It is always possible that Blizzard will change the system as time goes on.
Comment: @deutschZuid I know at least Druids now have 4 specs. I haven't checked other classes though.
Comment: @Thebluefish Ah yes.. guardian and feral. Of course. Thanks. Well done on the answer.
Comment: Sure thing. I just got back into WoW a week ago in anticipation for WoD, so I'll be answering more WoW-related questions from now on.
Comment: 3 to 4 specialisations? Which class has 4 specialisations? I haven't played the game for a year, but I don't think that much has changed.

Only four specialisation skills?


Render custom menu filter icon

Question: Is there a way to render a custom icon for the column filter menu? I found the prop renderMenuTool (https://reactdatagrid.io/docs/api-reference#props-renderMenuTool) to render a custom column context menu icon, but I need a similar one for the filter menu icon.
I tried with prop renderColumnFilterContextMenu, but this one is just to customize the popup menu, not the Icon.
Answer: Yes it is: columns.filterEditorProps.renderSettings.
See: https://reactdatagrid.io/docs/api-reference#props-columns-filterEditorProps-renderSettings

Render custom menu filter icon


Can I use a list of functions, as input, for a different function in Haskell?

Question: I am struggling to figure out how to make a function that takes a list of functions as input to generate some output. For example,
let's say that I make a type synonym called Func10 like so:
type Func10 = Int -> Int

I can create a set of functions that add, subtract, divide or multiply a value to 10 like so:
add10 :: Func10
add10 input = 10 + input

subtract10 :: Func10
subtract10 input = 10 - input

times10 :: Func10
times10 input = 10 * input

divide10 :: Func10
divide10 input = 10 `div` input

Now let's say that I want to make a function that will take a list of 4 values and a list of functions that I want to apply to them: add10, subtract10, multiply10 and divide10.
Initially I thought that I could give the function in the list input the integer argument when I need it, like so:
test_function :: [Func10] -> [Int] -> Int
test_function function input = function[0] (input[1])

main = do
    print("print 5 add 10")
    print(test_function [add10, subtract10] [3,5,7,9])

This resulted in the following error:
function_lists2.hs:17:32: error:
    * Couldn't match expected type `[Integer] -> t0 -> Int'
                  with actual type `[Func10]'
    * The function `function' is applied to two arguments,
      but its type `[Func10]' has none
      In the expression: function [0] (input [1])
      In an equation for `test_function':
          test_function function input = function [0] (input [1])
   |
17 | test_function function input = function[0] (input[1])
   |                                ^^^^^^^^^^^^^^^^^^^^^^

function_lists2.hs:17:45: error:
    * Couldn't match expected type `[Integer] -> t0'
                  with actual type `[Int]'
    * The function `input' is applied to one argument,
      but its type `[Int]' has none
      In the second argument of `function', namely `(input [1])'
      In the expression: function [0] (input [1])
   |
17 | test_function function input = function[0] (input[1])
   |                                             ^^^^^^^^

I thought that this could be because test_function needs the integer input as part of calling test_function, like so:
test_function :: [Func10] -> Int
test_function function = function[0]

main = do
    print("print 5 add 10")
    print(test_function ([add10, subtract10] 5))

However, this resulted in a similar error:
function_lists2.hs:26:26: error:
    * Couldn't match expected type `[Integer] -> Int'
                  with actual type `[Func10]'
    * The function `function' is applied to one argument,
      but its type `[Func10]' has none
      In the expression: function [0]
      In an equation for `test_function':
          test_function function = function [0]
   |
26 | test_function function = function[0]
   |                          ^^^^^^^^^^^

function_lists2.hs:30:30: error:
    * Couldn't match expected type `Integer -> [Func10]'
                  with actual type `[Func10]'
    * The function `[add10, subtract10]' is applied to one argument,
      but its type `[Func10]' has none
      In the first argument of `test_function', namely
        `([add10, subtract10] 5)'
      In the first argument of `print', namely
        `(test_function ([add10, subtract10] 5))'
   |
30 |         print(test_function ([add10, subtract10] 5))
   |                              ^^^^^^^^^^^^^^^^^^^^^

What would be the correct way of doing this? I am trying to take a list of functions and apply them to some other values but it's hard to find information on this topic online. Thanks.
Comment: To take an item from a list you need to use `!!`. Your first function would be written like `testfunction function input = (function !! 0) (input !! 1)` but generally manually taking items from lists is a bad idea, you should pattern match or loop through the list
Comment: why are you using list in this way... i never had the need to index a list, so what are you trying to do here...
Comment: Ah yes, @Zpalmtree you're right. I completely forgot that to call an nth index form a list you use !!. That solves the error.

HuStmpHrrr I was trying to create some AI "players" and I needed to use the list of players in a functioni that would calculate the next state of the program.
Comment: What result exactly you want `test_function [add10, subtract10] [3,5,7,9]` to return?
Answer: Like Zpalmtree said in the comments, the error was not using !! to call indexes. The correct way to write the code was to have it written out like so:
test_function :: [Func10] -> [Int] -> Int
test_function function input = (function !! 0) (input !! 1)

main = do
    print("print 5 add 10")
    print(test_function [add10, subtract10] [3,5,7,9])

Comment: or `(function <*> input) !! (0*4 + 1)`.


Can we use MSBuild 16 on an Azure Web App?

Question: I'm using Visual Studio 2019, which is using MSBuild 16. On Azure, a web app seems to be using MSBuild 14 by default. Looking at this question, How do you get KUDU to use MSBuild 15, it seems we can force the Azure web app to use MSBuild 15. Do Azure web apps support MSBuild 16 yet? And how can we tell if this is so using the command line in Kudu, or some other direct method? (I can't even find any announcements about this.)
Answer: Thanks for raising the issue. This is currently not supported. Are you using .NET core by any chance?
Comment: No, but I'd like to migrate some projects over if it's easy enough.


Python 3.x Broken variables when using ' def ' method

Question: My code is a text based adventure program however, when i am running it and it tries to use variables it breaks since the variables are not getting added to the def as python defines things before it does anything else.
This is my code and the program breaks when you go north twice and open window and enter window and up or east
    import time
reset = "yes"
def print_slow(str):
    for letter in str:
        print(letter),
        time.sleep(.3)

def game():
    #This sets the commands to be used
    inv_command = ["inv", "inventory", "i"]
    west = ["west", "w", "go west", "walk west"]
    east = ["east", "e", "go east", "walk east"]
    north = ["north", "n", "go north", "walk north"]
    south = ["south", "s", "go south", "walk south"]
    northeast = ["northeast", "ne", "go northeast", "walk northeast"]
    northwest = ["northwest", "nw", "go northwest", "walk northwest"]
    southeast = ["southeast", "se", "go southeast", "walk southeast"]
    southwest = ["southwest", "sw", "go southwest", "walk southwest"]
    up = ["up", "u", "go up", "go up stairs", "go up ladder", "up stairs", "up ladder"]
    down = ["down", "d", "go down", "go down stairs", "go down ladder", "down stairs", "down ladder"]
    take = ["take", "t"]
    die = ["die","suicide", "kill myself","kill"]
    #This sets the objects
    mailbox = 1
    house_window = 0
    house_bag = 0
    knife = 0
    lamp = 0
    carpet = 0
    rug = 0
    light = 0
    trapdoor =0
    #This sets the inventory
    class Item(object):
        def __init__(self, name, attack, armour):
            self.name = name
            self.attack = attack
            self.armour = armour

    class Inventory(object):
        def __init__(self):
            self.items = {}

        def add_item(self, item):
            self.items[item.name] = item

        def contain_item(self, item):
            self.items["Leaflet"] = item

        def print_items(self):
            print('\t'.join(['Name', 'Atk', 'Arm']))
            for item in self.items.values():
                print('\t'.join([str(x) for x in [item.name, item.attack, item.armour]]))
            time.sleep(1)
    inventory = Inventory()
    class death():
        def kill():
            print("You killed yourself")
            reset()
    game = 1
    still_running = 1
    while game is still_running:
        #This is the spawn area
        def spawn():
            while game is still_running:
                inp = input("You wake up in a field surrounded by trees. The only pathway is going north \n>")
                if inp in north:
                    front_house()
                if inp in die:
                    game.reset()
                elif inp in inv_command:
                    inventory.print_items()
                else:
                    print("<You can't do that>")

            #This is the front of the house
        def front_house():
            while game is still_running:
                inp = input("You face the front of a house. The windows are boarded up and the door is closed. In front there is a mailbox, and pathways leading west and further north\n>")
                if inp in south:
                    spawn()
                elif inp in inv_command:
                    inventory.print_items()
                elif inp in north:
                    back_house()
                elif inp in west:
                    west_forest_entrance()
                elif inp in "open door":
                    print("<The door is locked>")
                elif inp in "open window":
                    print("<The windows can't be opened. They seem to be nailed shut>")
                elif inp in "read leaflet":
                    if inventory.contain_item:
                        print("<Welcome to the text based adventure!>")
                        print("<When typing commands, please don't use capital letters.>")
                        print("<have fun!>")
                    else:
                        print("<You don't have a leaflet>")
                elif inp in "open mailbox":
                    if mailbox == 1:
                        print("<The mailbox contains a leaflet>")
                    else:
                        print("<The mailbox is empty>")
                elif inp in "take leaflet":
                    if mailbox == 1:
                        inventory.add_item(Item('Leaflet', 0, 0))
                        mailbox = 0
                        print("<You have taken the leaflet>")
                    else:
                        print("<There's no leaflet in the mailbox>")
                else:
                    print("<You can't do that>")

        #This is the back of the house
        def back_house():
            while game is still_running:
                inp = input("You face the back of the house, which has nothing except one ajar window. There is another pathway heading east \n>")
                if inp in inv_command:
                    inventory.print_items()
                if inp in south:
                    front_house()
                if inp == "open window":
                    house_window = 1
                    print("<You opened the window enough for you to enter through>")
                if inp == "enter window":
                    if house_window == 1:
                        kitchen()
                    else:
                        print("<The window isn't opened enough to fit through>")
                else:
                    print("<You can't do that>")

        #This is the kitchen
        def kitchen():
            while game is still_running:
                inp = input("You are inside the kitchen of the house. On the table there is a bag, there is a staircase leading up stairs and to the east there is a living room \n>")
                if inp in inv_command:
                    inventory.print_items()
                elif inp in "read manual":
                    if inventory.contain_item:
                        print("<Commands - inventory, take, open, attack>")
                        print("<Moving commands - go north, go south, go northeast, go northwest, go southeast, go southwest, up, down.>")
                        print("<Good luck!>")
                elif inp in up:
                    attic()
                elif inp in east:
                    living_room()
                elif inp in "exit window":
                    back_house()
                elif inp == "open bag":
                    print("<The bag contains a manual>")
                elif inp == "take bag":
                    print("<You would much rather take what's inside the bag then the bag itself>")
                elif inp == "take manual":
                    if house_bag == 0:
                        print("<You took the manual>")
                        house_bag = 1
                        inventory.add_item(Item('manual', 0, 0))
                    else:
                        print("<You have already taken the manual>")
                else:
                    print("<You can't do that>")

        #This is the Attic of the house
        def attic():
            while game is still_running:
                if knife == 0:
                    if lamp == 0:
                        inp = input("You are in the attic, you can see a lamp and a knife. You see blood stains and stairs downwards \n>")
                    else:
                        inp = input("You are in the attic, you can see a knife. You see blood stains and stairs downwards \n>")
                elif knife == 1:
                    if lamp == 0:
                        inp = input("You are in the attic, you can see a lamp. You see blood stains and stairs downwards \n>")
                    else:
                        inp = input("You are in the attic. You see blood stains and stairs downwards \n>")
                if inp in inv_command:
                    inventory.print_items()
                elif inp in down:
                    kitchen()
                elif inp in "take knife":
                    if knife == 0:
                        print("You pulled the knife out from the wall and put it in your pocket")
                        print("<You have obtain a knife>")
                        knife = 1
                        inventory.add_item(Item('knife', 3, 0))
                    else:
                        print("<You have already taken the knife>")
                elif inp in "take lamp":
                    if lamp == 0:
                        print("<You have taken the lamp>")
                        lamp = 1
                        inventory.add_item(Item('lamp', 0,0))
                    else:
                        print("<You have already taken the lamp>")
                else:
                    print("<You can't do that>")
        #This is the living room
        def living_room():
            while game is still_running:
                if rug == 0:
                    inp = input("You are in the living room and you see a rug on the floor.\n>" )
                if rug == 1:
                    inp = input("You are in the living room and you can see a trap door.\n>")
                if inp == "move rug":
                    rug = 1
                    print("<You have found a trap door to the basement>")
                if trapdoor == 1:
                    if inp in down:
                        underground_entrance()
                if inp in inv_command:
                    inventory.print_items()
            else:
                print("<You can't do that>")
        #This is the underground entrance
        def underground_entrance():
            while game is still_running:
                if lamp == 1:
                    if light == 0:
                        inp = input("It is dark, you can't see anything.\n>")
                        if inp in up:
                            living_room()
                        if inp in inv_command:
                            inventory.print_items()
                        if inp == "turn on lamp" or "turn lamp on":
                            print("<You turned on the lamp>")
                            light = 1
                        else:
                            print("<You can't do that>")
                    if light == 1:
                        inp = input("You are below the living room, where you can see a entrance to a underground tunnel north of you.\n>")
                        if inp in up:
                            living_room()
                        if inp in inv_command:
                            inventory.print_items()
                        if inp in north:
                            loop = 12
                    else:
                        print("<You can't do that>")
                if lamp == 0:
                    inp = input("It is dark, you can't see anything you need to find a lamp.\n>")
                    if inp in up:
                        living_room()
                    if inp in inv_command:
                        inventory.print_items()
                else:
                    print("<You can't do that>")

                #This is the west forest entrance
                def west_forest_entrance():
                    while game is still_running:
                        inp = input("You are now in a dense forest. There is a fork in the road going NorthWest and SouthWest \n>")
                        if inp in inv_command:
                            inventory.print_items()
                        elif inp in east:
                            loop = 2
                        elif inp in northwest:
                            loop = 6
                        elif inp in southwest:
                            loop = 7
                        else:
                            print("<You can't do that>")
        spawn()
def reset():
    if reset == "yes":
        print_slow("Resetting...")
        print_slow("Loading...")
        time.sleep(5)
        game()
game()

Comment: You have an un-needed tab at the very first line. Otherwise, would be nice to know what is the problem. What do you mean by break? At which line?
Comment: The way you are using functions doesn't make a lot of sense.  You should start with the basics (maybe the [Python tutorial](https://docs.python.org/3/tutorial/)).
Answer: Many of your defs are nested inside the game() function. You appear to be trying to use the local variables of game as quasi-global variables.
If you are going to do that, you need to declare the variables you wish to use as nonlocal in the nested functions.
For example:  See this answer for an example of nonlocal.
Alternatively, you may wish to move the variables to be truly global, put the definitions at the outermost scope, and declare the ones you wish to modify in functions with the global statement.
For example: See this answer for an example of 'global'.
Or, you might make all those functions methods on a class, and use self.mailbox and self.window instead of mailbox or window.
For example:
class Game:
    def __init__(self):
        self.mailbox_full = True

    def take_leaflet(self):
        if self.location != FRONT_HOUSE:
            self.bogus()
            return

        if self.mailbox_full:
            self.inventory.add_item(Item('Leaflet', 0, 0))
            self.mailbox_full = False
            self.msg('You take the leaflet')
        else:
            self.msg('There is no leaflet in the mailbox.')

Comment: thank you however, what would be the best place to put it in my code and can you also give me an example.
Comment: I've added an example and some links. The "best place to put it" depends on what "it" is - there's three choices.


Why attack wards?

Question: In League of Legends, you can attack wards for a short window of time when they're put down by the opposing team (discounting the use of other methods of finding wards).
Often, a quick autoattack at the beginning of the match can only take out one segment of health on a ward, and since I can't find a definite consequence of wards losing health, I was wondering if there's a benefit to attacking wards if you can't take it out entirely at once.
Comment: The ward has less health allowing you to kill it faster in the future.
Answer: This is a tricky question, as the answer is HIGHLY situational. Wards tend to be used as bait, beyond their uses for vision. Overall, you generally want to remove enemy wards as quickly as you can, without risking yourself or teammates. Denying the enemy vision is extremely important, but so is not dying. Basically, if you can't destroy a ward, attacking it is a good idea, unless it risks your safety. Let's go over some example situations.
You're in lane, and see one of the opponents drop a ward. If your basic attack is ranged, go for a shot on it, or if you happen to be standing right next to it. Again, if there are clear risks, don't go for it. The benefits you are getting in exchange for that one hit, is that it is easier for your support or jungler to clear. That extra second or two that it takes to hit a ward 3 times as opposed to just twice, can be the difference between clearing and not clearing a ward, or clearing it in time to get out safely. This is especially true when the support is the one clearing the ward, as they generally don't ever have an attack speed of more than once per second.
A second situation to consider is when destroying wards is true sight. If your team has true sight in the area, not granted by a pink ward (Although, this situation may apply if you know for a fact they know the pink ward is there). If an enemy places a ward in an area that they KNOW you have true sight, then there is a 99% chance that the ward is a bait of some sort. So what do you do? Simple, steer clear until someone on your team can disable it with a sweeping lens, the kill it. You want to disable the ward FIRST to deny the enemy vision of your team moving to kill it. Attempting to kill a ward they know you can see without disabling it, will likely result in a Blitzcrank Rocket Grab Q, a Lee Sin jumping to you with his Sonic Wave Q into Resonating Strike  Q combo, a Nidalee Javelin Toss Q to the face, or some other equally nasty surprise.
Next there's the Inhibitor Tower Siege, Over the Base Wall ward. Do NOT under any circumstances try to destroy these. I guarantee that there is an enemy waiting for you to get close to hit you with something nasty. The best way to deal with this is to counter ward, by placing your own ward over the wall as well. This way, you can watch what they are doing, and you spend much less time in the danger zone than if you are attempting to destroy it. The only exception is again, if an ally disables the ward with a sweeping lens. Be wary though, your opponents are much more likely to attempt a blind skill shot in this situation than in the above. You will, however, be safe from targeted spells such as Talon's Cutthroat E.
The last is that random ward an enemy tossed down as a team fight broke out. Leave it, but memorize it's spot. It's not important enough to stop focusing on the enemy damage dealers to kill the ward as fast as possible, but you do want to be able to have an ally hit it with a sweeping lens once the action calms down.
TL;DR? There are lots of benefits to getting that one free shot off on a ward, but in most situations, the potential risk is not worth the one hit on the ward.
Answer: Yes, it is worth hitting the ward.  Sometimes if there are 2 of you there, you may manage to actually kill it.  You or someone on your team might reveal it later and requiring to hit it less keeps them safer.
As long as it doesn't put you in danger, it is always worth hitting the ward.
Answer: You attack wards as a general principle.

If you have enough teammates around you will destroy the ward.
When the ward is revealed by using a pink or trinket it will be faster to kill.
You train your conditional reflex to attack all wards that are suddenly revealed, increasing as a team the chances of killing wards faster.

Unless attacking the ward will put you in a hard position there's no reason why you shouldn't attack it, really.
Answer: Well, there is no point on attacking a ward if you can't destroy it. There is no benefit at all. But there are select champions who can hit wards three times in quick succession. Leona for example, she can do an autoattack-Q-autoattack combo and right timing to destroy a ward just before it goes invisible. This is one of her strong points, denying enemy vision. I think Garen can do this as well.
Comment: Pretty much any champ with an auto attack reset can. The only problem is the ward has to be placed right next to you for you to even have time to react to it in time.
Comment: Yeah that's right. You have to be aware of your enemy's movement and predict when and where they'll place the ward. Sometimes I manage to deny wards placed on short distances just in the nick of time.
Comment: You can also use Jayce's Cannon W attack speed buff to kill a ward that's placed down right away.
Answer: The only real benefit to attacking a ward that you cannot kill in 1 sitting, is if you are planning on revealing the ward later and killing it. For example, using the new reveal trinket, you can hit it once, and then reveal and only have to hit it twice more. It might not seem like much, but for example, you might be putting yourself in danger by revealing and destroying the ward, and killing it in 2 auto attacks is a lot faster than with 3.
Answer: When should I spend my auto-attacks on the enemy wards?

You and your lane partner (or any other ally) are close by and probably will hit it too.
You have Attack reset skills (attack -> skill -> attack).
You are gonna revel that ward with your trinket or pink-ward.
An ally will revel that ward with his trinket or pink-ward.

Is it worth to just hit a couple of times even none of the criteria above fits?
If you don't have nothing else to do, go for it. Besides passing time and put yourself at enemy range/risk. NO isn't worth at all.

Worth to mention notes:

Depending on the attack speed. 2 champions can take down one ward with just auto-attack.
Every time you go for a ward, you put yourself at the enemy mercy, so be careful!
Sometimes is worth hit the ward just for bait, but be aware, the enemy may use the same strategy

TL;DR;
Don't hit it if you are not going to destroy it. Be careful!

Why attack wards?


Can I use Git, or any derivatives such as Git-Annex etc, as a two way sync framework?

Question: Can I use Git, or any derivatives such as Git-Annex etc, as a two way sync framework?
What would be the pros and cons of this framework?
Would the syncs be done through merging diffs?
Comment: Have you considered Unison - https://en.wikipedia.org/wiki/Unison_%28file_synchronizer%29 ?
Comment: Seen http://git-annex.branchable.com/assistant/?
Comment: If there is a central repo and you are merging in that from both sides... weren't it be ok?
Comment: I have; do you have any experience with it?
Answer: You haven't really elaborated on your usecase. If you want something dropbox-like, then git-annex assistant should be what you're looking for. SparkleShare is also built on git. Seafile also seems to be similar.
Comment: Use cause is a two way sync framework to be used for Pair Programming. I am examining the different options out there. Basically though, a host opens a project, a client connects, downloads the project to /tmp, and then changes to either the host or clients version of the "Project" are synced between the two in realtime. (Every character input would trigger a save.) Does that make sense?
Comment: Sounds like you should be using something like etherpad or google docs instead to get the realtime sync you seem to want.
Comment: Its for a specific IDE, and so html apps are not an appropriate solution. I could try something with the GData API, but as useful as that is, I find it quite slow.


json remove unneserry timestamp with milliseconds and seconds

Question: I am developing service that returning json only needs to show date time and minutes, but it shows everything on time stamp. How to get rid of milliseconds and seconds ?
My model below;
private LocalDateTime processStartDate;

My RowMapper bewlow;
taskList.setProcessStartDate(rs.getTimeStamp("PROCESS_START_DATE").toLocalDateTime());

My Response
private LocalDateTime processStartDate;

My Json Response Using Postman below;
"taskResponseList": [
 {
   "processStartDate" : "2020-02-14T17:30:23.00Z"
 }
]

Comment: see: https://stackoverflow.com/questions/22463062/how-to-parse-format-dates-with-localdatetime-java-8
Comment: I have already saw that, not working
Comment: Add the code where you try using it to the question
Answer: you can remove the milliseconds by using the following line of code.
taskList.setProcessStartDate(rs.getTimeStamp("PROCESS_START_DATE").toLocalDateTime()).withNano(0);

To remove both seconds and milliseconds from the time, you can just use the chorounit to truncate the date:
taskList.setProcessStartDate(rs.getTimeStamp("PROCESS_START_DATE").toLocalDateTime()).truncatedTo(ChronoUnit.MINUTES);

Edited:
Convert it into into the date format by using new Date()
 Date date=new Date(rs.getTimeStamp("PROCESS_START_DATE").toLocalDateTime()).truncatedTo(ChronoUnit.MINUTES);
taskList.setProcessStartDate(date)

And then use any method to remove the seconds and miliseconds from date
Comment: Hello, still same
Comment: I have used this approached before, unfortunately nothing changed
Comment: Hey, I guess you are getting the string type value from the rs. So try to convert it from string to date first
Comment: can you please tell me how to do it on mapper
Comment: yes thank you. But can you please write on mapper how to do it ?
Comment: I  have no idea where to write on mapper. Can you combine your solution with my mapper
Comment: date(long) can not applied localDateTime
Comment: You can just remove localDateTime for instance and check if it works fine.
Answer: You could also format the way JSON is returned by adding the following to your Response Object :
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd:HH:mm")
private LocalDateTime processStartDate;


Do I use the Siemens Type Q Breaker in ITE Blueline Loadcenter panel?

Question: I'm looking for compatible breakers for my old ITE Blueline Loadcenter main panel.  I believe ITE was bought by Siemens.  Would the Siemens 100A 2 Pole 120/240V Type Q Breaker (https://www.homedepot.ca/product/siemens-100a-2-pole-120-240v-type-q-breaker/1000436969) be compatible for supplying 100A sub-panel?
Update:
I noticed one newer Siemens breaker in the panel! It's labelled type BL.  Can I assume all type BL breakers will be compatible with my ITE Blueline Loadcenter panel?
Update:
Photos added.
Photos:
Comment: Can you post photos of the labeling on the inside of your panel's door please?
Comment: well unfortunately there is no labeling on the inside of the panel's door... or anywhere else on the panel
Comment: ah but I did just notice one newer Siemens breaker in the panel! Its type BL.
Comment: Can you post whatever photos of the panel you have please then?
Comment: I posted photos
Answer: You are looking for a Siemens BL2 (not to be confused with a Siemens BL)
ITE Blue Line loadcenters appear to use a special style of "thin" breaker instead of the more "typical" QP (EQ-P) breaker.  Unfortunately, the ITE Blue Line (not to be confused with the other type BL breaker, which is the bolt-down version of the QP and thus no use to you), only is available in 1 pole up to 50A and 2 pole up to 40A, as per the current Siemens Canada catalog.  So, you'll either need to run a smaller feeder to your subpanel, or have your main panel replaced outright.
Comment: @jpx -- yea, that'd go with 8/3...
Comment: ouff... I was hoping to future proof for possible solar (I think I need at least 60A 2 pole for that) but I guess that's a future problem.  The 40A is more than enough more my current needs.  Pun not intended.
Comment: follow up:  the BL2-040 is the 2 pole 40A breaker.  So I need the 8/3 wire for that?


Find duplicates in SQL Server database where one of the columns must differ

Question: I'm trying to write a SQL query to find duplicates. What I can't manage to do is to make my query only select duplicates where one of the columns value must differ. So, I want to find all the duplicates where all the columns are the same, but one of the values must differ.
What I've got at the moment:
SELECT
    a.1, underlag.1, f.1, f.2, f.3, f.4, f.5,  f.6, f.7, f.8,
    COUNT(*) TotalCount
FROM
    f
JOIN
    a ON a.Id = f.Id
JOIN
    underlag ON underlag.Id = f.Id
GROUP BY
    a.1, underlag.1, f.1, f.2, f.3, f.4, f.5,  f.6, f.7, f.8
HAVING
    COUNT(*) > 1
ORDER BY
    underlag.1

The column that I want to differ is f.9 but I've no clue on how to do this. Any help or pointers in the right direction would be great!
Comment: many "find duplicate questions" asked on SO....
Comment: having count(distinct f.9) > 1?
Comment: Yes, I know. But I can't seem to find where someone needs one of the column values to differ.
Answer: SELECT *
FROM (
    SELECT
          a1 = a.[1]
        , underlag1 = underlag.[1]
        , f.[1], f.[2], f.[3], f.[4], f.[5], f.[6], f.[7], f.[8], f.[9]
        , val = SUM(1) OVER (PARTITION BY CHECKSUM(f.[1], f.[2], f.[3], f.[4], f.[5], f.[6], f.[7], f.[8]))
    FROM f
    JOIN a on a.Id = f.Id
    JOIN underlag on underlag.Id = f.Id
) t
WHERE t.val > 1
ORDER BY underlag1


Wordpress: Error in get post by met_key

Question: I have this code,
    $type = get_the_ID();
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $units3 = new wp_query( array(  'post_type' => 'units' ,
                                    'posts_per_page'=> 6 ,
                                    'paged' => $paged  ,
                                    'meta_key' => 'unittype',
                                    'meta_value' => $type ) );
    while ($units3->have_posts()) : $units3->the_post();

Its must get me all post from unit That is in the unit type that id = $type
But the query is get me all post.
It must get me only all post from unit post type that in unit type post type,
Where is error
Comment: Have you tried to use `get_posts()` or `new WP_Query` instead of `new wp_query`. I think you have a writing issue here.
More information on http://codex.wordpress.org/Template_Tags/get_posts or http://codex.wordpress.org/Class_Reference/WP_Query.
Also are you sure get_the_ID() Method is right for your $type variable
Comment: Nice:) but how can check if have post or not ??
Comment: you could write `var_dump( $units3 );` so you can see if your query returns any posts. By the way, `new wp_query` doesn't exist in Wordpress.
Comment: Ok, but can i check more than meta_key, i need to get all post tha in unit type and has sale :), So i need to use 2 meta_key
Comment: Should be possible. Look at https://wordpress.org/support/topic/query-for-multiple-meta-keys-and-values
Answer: Meta key is for using meta_value_num in order parameter,
You need to use meta_query for querying specific meta data
Test your query first until you get the correct data
$data = query_posts( array(
                'post_type' => 'your_custom_post_type',
                'orderby' => 'meta_value_num',
                'meta_key' => 'your_order_meta_key',
                'posts_per_page'=> 5,
                'meta_query' => array(
                    array(
                        'key'     => 'key_to_only_display_if_exist',
                        'value'   => array( 3, 4 ),
                        'compare' => 'IN',
                        )
                    )
                )
            );
var_dump($data);

Then Use query_post
query_posts( array(
                'post_type' => 'your_custom_post_type',
                'orderby' => 'meta_value_num',
                'meta_key' => 'your_order_meta_key',
                'posts_per_page'=> 5,
                'meta_query' => array(
                    array(
                        'key'     => 'key_to_only_display_if_exist',
                        'value'   => array( 3, 4 ),
                        'compare' => 'IN',
                        )
                    )
                )
            );
      if (have_posts()) :
          while (have_posts()) : the_post();
              echo '
';
              echo '
' . get_the_title() . '
';
              echo '
'. apply_filters('the_content',get_the_content('Read More')).'
';
              echo '
';
          endwhile;
      endif;
wp_reset_query();

Wordpress: Error in get post by met_key


How to iteratively nest a nested function

Question: I have an array arr_multi_dim which is multi-dimensional. Every time when I increase a parameter n, there will be more entries created in the array results and the array will get larger.
With each increase in n, I need to perform the function np.concatenate() on the array arr_multi_dim, in such a way that there will be more np.concatenate() function nested every time n increases.
For eg.,
when n=2:
arr_multi_dim = np.concatenate(np.concatenate(arr_multi_dim, axis=1), axis=1)

when n=3:
arr_multi_dim = np.concatenate(np.concatenate(
                np.concatenate(np.concatenate(arr_multi_dim, axis=1), axis=1), axis=1), axis=1)

when n=4:
arr_multi_dim = np.concatenate(np.concatenate(
                np.concatenate(np.concatenate(
                np.concatenate(np.concatenate(arr_multi_dim, axis=1), axis=1), axis=1), axis=1), axis=1), axis=1)

etc.
where at each increment of n, a pair of np.concatenate() (ie. two) gets added into the function.
How do I write a function, loops (or something similar), so that when I specify any values for n, the appropriate np.concatenate() function will be used?
Many thanks in advance.
Edit:
This is the full code that I have written which uses the above np.concatenate() function.
from itertools import product
from joblib import Parallel, delayed
from functools import reduce
from operator import mul
import numpy as np

lst = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
arr = np.array(lst)
n = 2

def test1(arr, n):
    flat = np.ravel(arr).tolist()
    gen = (list(a) for a in product(flat, repeat=n))

    results = Parallel(n_jobs=-1)(delayed(reduce)(mul, x) for (x) in gen)

    nrows = arr.shape[0]
    ncols = arr.shape[1]

    arr_multi_dim = np.array(results).reshape((nrows, ncols)*n)
    arr_final = np.concatenate(np.concatenate(arr_multi_dim, axis=1), axis=1)  # need to generalise this

    return arr_final

The above code only works for n=2. I am trying to generalize the np.concatenate part of the code so that it would work for any n as mentioned above.
Comment: can you provide an example of input/output you want? like your result and n and the output you want, I think there must be a much simpler way than calling concatenate multiple times
Comment: can you show a dummy of how `results` looks like?
Comment: Hi @S.Mohsensh, I have updated my question above as requested. This code is doing a self-Kronecker product (ie, Kronecker product of it's own matrix). I am experimenting if I could write my own code for this and parallelize this. Many thanks in advance.
Comment: Hi @dzang, I have updated my question above as requested. This code is doing a self-Kronecker product (ie, Kronecker product of it's own matrix with `n` representing how many times the Kronecker product is performed). I am experimenting if I could write my own code for this and parallelize this. Many thanks.
Comment: @Leockl thanks, can you also add the imports to the needed function to reproduce your example?
Comment: Hi @dzang, apologies. Added thanks.
Answer: If i understood you correctly its pretty simple:
arr_multi_dim = results
for i in range(n):
  if i < 2:
    arr_multi_dim = np.concatenate(arr_multi_dim , axis=1)
  else:
    arr_multi_dim = np.concatenate(np.concatenate(arr_multi_dim , axis=1), axis=1)

becase the first two iteration only add a single layer while the rest add two layers
Comment: @Leockl I updated my answer with what i think are the correct counters in your situation
Comment: Many thanks @Nullman. I feel so dumb right now as I wasn't able to see this.
Comment: Thank heaps @Nullman for pointing to the right direction. Working out now what values of the counters in the for loop should take.