text:
Q: Android and Eclipse - Exporting local jars through SVN How do I 'include' a jar inside an android project, instead of just referencing it? For example, below is a picture of my tree view for a project.

This is fine if I want to test this app on this machine, and it even works when I deploy, however if I try to check out the project through SVN, I get a message saying "The project cannot be built until build path errors are resolved". Also missing lib messages such as:
...is missing required library: C:\Users\Dane\Desktop\commons-math-2.2.jar
etc.
I've checked the build path and checked all jars in the 'Order and Export', but it does not do what I think it does apparently.
How does one 'package' jars so they are transportable, and not left behind?

A: You can copy the jar to your project(copy the jar, click on your android project and paste)
You'll see your jar inside the project,
then reference it once it's there.


text:
Q: Tela de login - não consigo logar um usuario,admin ou user tabela usuários;
create table usuario(
usuario_nome varchar(15) not null,
usuario_senha varchar(15) not null,
primary key (usuario_nome)
);

tabela permissão;
create table permissao(
usuario_nome varchar(15) not null,
usuario_permissao varchar(15) not null,
primary key (usuario_nome, usuario_permissao),
foreign key (usuario_nome) references usuario(usuario_nome)
);

Inserts;
insert into usuario values('matheus','maithe');
insert into usuario values('maithe','matheus');
insert into permissao values('matheus','administrador');
insert into permissao values('maithe','usuario');

bean
@ManagedBean
public class UsuarioBean {

    private String usuario_nome;
    private String usuario_senha;

    public String login() {
        HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();

        try {
            request.login(this.usuario_nome, this.usuario_senha);
            return "dados?.redrect-true";
        } catch (ServletException ex) {

            return null;
        }

    }

    /**
     * @return the usuario_nome
     */
    public String getUsuario_nome() {
        return usuario_nome;
    }

    /**
     * @param usuario_nome the usuario_nome to set
     */
    public void setUsuario_nome(String usuario_nome) {
        this.usuario_nome = usuario_nome;
    }

    /**
     * @return the usuario_senha
     */
    public String getUsuario_senha() {
        return usuario_senha;
    }

    /**
     * @param usuario_senha the usuario_senha to set
     */
    public void setUsuario_senha(String usuario_senha) {
        this.usuario_senha = usuario_senha;
    }

}

web.xml
<login-config>
        <auth-method>FORM</auth-method>
        <form-login-config>
            <form-login-page>/TelaDeLogin.xhtml</form-login-page>
            <form-error-page>/TelaDeLogin.xhtml</form-error-page>
        </form-login-config>
    </login-config>

    <security-role>
        <role-name>usuario</role-name>
    </security-role>

    <security-role>
        <role-name>administrador</role-name>
    </security-role>

    <security-constraint>
        <web-resource-collection>
            <web-resource-name>Tela Usuario</web-resource-name>
            <url-pattern>/telausuario_1.xhtml</url-pattern>
        </web-resource-collection>
        <auth-constraint>
            <role-name>usuario</role-name>
        </auth-constraint>
    </security-constraint>

    <security-constraint>
        <web-resource-collection>
            <web-resource-name>Administrador</web-resource-name>
            <url-pattern>/dados.xhtml</url-pattern>
        </web-resource-collection>
        <auth-constraint>
            <role-name>administrador</role-name>
        </auth-constraint>
    </security-constraint>

context.xml

<?xml version="1.0" encoding="UTF-8"?>
<Context path="/ProjetoGrandeRecife" >
    <Realm className="org.apache.catalina.realm.JDBCRealm"
           driverName="com.mysql.jdbc.Driver"
           connectionURL="jdbc:mysql://localhost/dp"
           connectionName="root" connectionPassword="root"
           userTable="usuario" userNameCol="usuario_nome" userCredCol="usuario_senha"
           userRoleTable="permissao" roleNameCol="usuario_permissao"/>
</Context>

tela de login

<h:head>
        <title>Teste</title>

    </h:head>
    <h:body>

                    <h:graphicImage library="imagens" name="logo.png" width="1060" height="85"/>

                    GRANDE RECIFE CONSORCIO DE TRANSPORTE

                    Identifique-se por favor para utilizar
                    o sistema.

                <h:panelGrid columns="2">

                    <h:outputLabel value="Nome:" for="nome" style="background-color: navajowhite"/>
                    <h:inputText id="nome" style="background-color: #dddddd" label="Nome" value="#{usuarioBean.usuario_nome}"  required="true" />
                    <h:outputLabel value="Senha:" for="senha" style="background-color: navajowhite"/>
                    <h:inputSecret id="senha" style="background-color: #dddddd" label="Senha" value="#{usuarioBean.usuario_senha}" required="true" />
                </h:panelGrid>

                <h:commandButton action="#{usuarioBean.login()}" value="Entrar" style="position: relative;left: 78px;"/>

    </h:body>

Resultado

Message from lcosta,       Thursday, 13:34 28-Jul-2016 13:39:09.356
  INFO [http-apr-8080-exec-32]
  org.apache.catalina.util.LifecycleBase.start The start() method was
  called on component
  [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/ProjetoGrandeRecife]]
  after start() had already been called. The second call will be
  ignored.

A: Não tenho certeza se é isso mas,
Não use underline (_) em nomes de variáveis, você sempre começa com letra minúscula e qualquer outro nome que apareça depois você começa com letra maiúscula. Exemplo: nomeUsuario
De modo que isso talvez gere confusão com os nomes dos métodos getUsuario_nome() se tornaria usuarioNome, getUsuarioNome() e setUsuarioNome().  Faça estes ajustes e veja se o problema persiste.
EDIT:
Complementando a resposta, a mensagem que você está recebendo não é um ERROR mas sim um INFO.

This exception at shutdown happens only if examples webapp was correct
  when Tomcat started, but was broken afterwards. If it was already
  broken at startup time, nothing happens.
https://issues.apache.org/bugzilla/show_bug.cgi?id=51610 -maybe it
  help.

Esta exceção só acontece se o webapp estava correto no startup do Tomcat mas foi corrompido depois. Se ele estivesse corrompido já de início nada aconteceria.
Cheque o link

redpajama_set_name: RedPajamaStackExchange


text:
Q: conditional jquery validation based on radio value in form I'm using validation plugin.
I want to validate certain fields IN THE SAME form, when radio value is other than "REGULAR",
<form id="registerform">
<input type="radio" name="role" value="REGULAR" checked="checked" id="role">Regular

<input type="radio" name="role" value="AGENT" id="role">Agent

<input type="radio" name="role" value="ORGANIZATION" id="role">Organization

<input type="text" name="phone"  id="phone">

<input type="text" name="password" id="password">

<input type="text" name="work_area" id="work_area" value="">

<input type="text" name="work_phone" id="work_phone" value="">

<input type="text" name="org_name" id="org_name">

<input type="text" name="org_phone" id="org_phone">

</form>

When role == "REGULAR", validate phone, password
When role == "AGENT", validate phone, password, work_area, work_phone
When role == "ORGANIZATION", validate phone, password, org_name, org_phone
How to achieve this elegantly ?
I don't want to divide it into different forms!
My false code :
$(document).ready(function() {
var rule_options =
{
    "phone": "required"
    ,"password": "required"
};

var role = $("#registerform").find("input[name=role]:checked").val();
if(role ==  "AGENT") {
    $.extend(true, rule_options,
        {
            "work_area": "required"
            ,"work_phone": "required"
        }
    );
}

if(role ==  "ORGANIZATION") {
    $.extend(true, rule_options,
        {
            "org_area": "required"
            ,"org_phone": "required"
        }
    );
}
jform.validate({
            errorClass : "err_label",
            rules: rule_options,
            ignore: "",

Above code won't work since its run only once after document.ready.
I must be missing something, some syntax..~ Idea ?

A: jquery validation rules

I got what I really needed from above link. What need to be solved here really is how to make the jQuery validator plugin behave DYNAMICALLY BASED on radio value for each input. I don't even use jQuery.change() method.
function getRole() {
    return $("#registerform").find("input[name=role]:checked").val();
}

$(document).ready(function() {
    var jform = $("#registerform");
    jform.validate({
            errorClass : "err_label",
            rules:
                "phone": "required"
                ,"password": "required"
                ,"work_area": {
                    required: function(element) {
                        return (getRole() == 'AGENT');
                    }
                }
                ,"work_phone": {
                    required: function(element) {
                        return (getRole() == 'AGENT');
                    }
                }
                ,"org_name": {
                    required: function(element) {
                        return (getRole() == 'ORGANIZATION');
                    }
                }
                ,"org_phone": {
                    required: function(element) {
                        return (getRole() == 'ORGANIZATION');
                    }
                }

If exist other idea, please let me know.

A: Use ignore option. Sorry if there is any syntax error as I don't have access to my development tools and jsfiddle is not working from my computer.
EDIT: I am assuming all fields are required.
$("form").validate({ignore: ".ignore"});

var role = {
    "REGULAR": ["work_area", "work_phone", "org_name", "org_phone"],
    "AGENT": ["org_name", "org_phone"],
    "ORGANIZATION": ["org_name", "org_phone"]
};

$("input[name=role]").click(function () {
    //reset ignore
    $("#work_area,#work_phone,#org_name,#org_phone").removeClass("ignore");

    for (var i in role[$(this).val()])
    {
        $(i).addClass("ignore");
    }
});

A: $("input[@name='role']").change(function(){
    // Rest of your code here.
});

Insted of using the onload event, bind the function to the radiobuttons.

A: You can update the validation rules, every time the user clicks on the form or presses a key on it.
function updateRules() {
  // Your code here
}

$('#registerform').click(function() {
  updateRules();
});

$('#registerform').keyUp(function() {
  updateRules();
});

A: The problem is that you are doing:
var role = $("#registerform").find("input[name=role]:checked").val();

and its working, but only once since you need to attach this to an event (maybe the change event is suitable), so every time the radiobuttons somehow changes, the validation setting should change:
$("input[@name='role']").change(function(){
    if( $(this).is(":checked") ){ // check if the radio is checked
        var val = $(this).val(); // retrieve the value
        if(role ==  "AGENT") {
           $.extend(true, rule_options, {
              "work_area": "required"
             ,"work_phone": "required"});
        }
        if(role ==  "ORGANIZATION") {
           $.extend(true, rule_options, {
              "org_area": "required"
             ,"org_phone": "required"});
        }
    }
});


text:
Q: How to set focus on inputfield in react.js? How do I set focus on the last added inputfield?
I found a few examples at the www, but all with class-component, not hook.
I did try useref, but I cant make it work.
import React, { useState } from 'react';

const About = () => {
    const [list, setList] = useState([
        { id: 1, txt: 'text 1' },
        { id: 2, txt: 'text 2' }
    ]);

    return (

About

            {list.map((elm) => (
                <input key={elm.id} type="text" defaultValue={elm.txt} />
            ))}

            <button value="ADD" onClick={e => {
                e.preventDefault();
                setList(oldList => ([
                    ...oldList, { id: 3, txt: 'text 3', active: true }
                ]));
            }}>ADD</button>

    )
}

export default About;

A: Callback seems to do it.
import React, { useState, useCallback } from 'react';

const About = () => {
    const [list, setList] = useState([
        { id: 1, txt: 'text 1' },
        { id: 2, txt: 'text 2' }
    ]);

    const callbackRef = useCallback(inputElement => {
        if (inputElement) {
            inputElement.focus();
        }
    }, []);

    return (

About

            {list.map((elm) => (
                elm.active ? <input key={elm.id} type="text" defaultValue={elm.txt} ref={callbackRef} />
                    : <input key={elm.id} type="text" defaultValue={elm.txt} />
            ))}

            <button value="ADD" onClick={e => {
                e.preventDefault();
                setList(oldList => ([
                    ...oldList, { id: 3, txt: 'text 3', active: true }
                ]));
            }}>ADD</button>

    )
}

export default About;


text:
Q: Animated toggle columns I have an HTML page containing a table, in which i have three columns with display:none and visibility:hidden. When clicking a cell in the adjacent column, the attributes change to table-cell and visible respectively, showing the three columns. Another click at the cell of said adjacent column resets the values to none and hidden.
The only problem is that, of course, it's not pleasant to see. I would like to include an animation so that i can see the other columns shrink in order to let the hidden columns slide in the middle and an animation when i can do the opposite thing.
What should I use? I'm asking for help because I'm relatively new to web designing and I have no idea about where to look for guidance.

A: The tables themselves are not animated. Perhaps this option may suit you. (Google translate.)

$('.show').on('click', function(){
 $('.table').find('.td').each(function(){
   if($(this).css('display') === 'none'){
     $(this).show().addClass('animate');
    }
  });
});
.table{
  display: flex;
  flex-direction: column;
}

.td{
  border: 1px solid #999;
  border-collapse: collapse;
}

.tr{
  display: flex;
}

.td{
  padding: 10px;
}
.td:nth-of-type(2){
  display: none;
}
*{
  transition: all 0.3s ease;
}
button{
  margin-top: 20px;
}
.animate{
  animation: show 1s ease forwards;
}
@keyframes show{
  from{
    transform: translateX(-100%);
    display: block;
  }
  to{
    transform: translateX(0%);
  }
}

1

2

3

1

2

3

1

2

3

<button class="show">Show</button>

A: Just as I finished posting the question, a friend of mine introduced me to the fadeToggle function available using JQuery. This is precisely what I was looking for.


text:
Q: I am getting a "Fatal Client error; Disconnecting" I am having trouble with this error when attempting to connect to perforce client
Fatal client error; disconnecting! write: ...: No space left on device
I have tried looking into the contents of this "..." folder but there is not much there.

A: The machine which runs your Perforce server is probably out of disk space.
Do you have an administrator who runs your server? Contact them, and ask them to have a look at the server machine to see if disk space can be freed up.


text:
Q: Problema de cálculo javascript Me gustaría hacer un cálculo en javascript en el cual si un autobus tiene 25 plazas introduzcas el número de pasajeros mediante un prompt y te calcule el número de viajes que ha de hacer para llevar a todos a su destino
let pasajeros = parseInt(prompt("numero de pasajeros"));
let bus= [];

A: Para hacer el cálculo que requieres deberás utilizar lo siguiente
let bus= 25; //declaras el numero de plazas del bus
let pasajeros = parseInt(prompt("numero de pasajeros")); //pides la entrada de pasajeros al usuario
console.log("el número de viajes que ha de hacer son: "+pasajeros/bus);//realizas el cálculo y lo muestras por pantalla


text:
Q: redirect after few second on click jquery i have a small issue, i want to redirect page on click using jquery
here is my code
$('#submit').click(function(){
   window.location.href='index.php';
})

Now is there any way to delay redirect for 5 second.. i mean when click on button user wait  at least 5 second on same page and then redirect to index.php  i also tried this but it's not working
$('#submit').click(function(){
       window.location.href='index.php';
    } 5000)

A: Try this:
$('#submit').click(function()
{
    setTimeout(function(){ window.location.href='index.php'; }, 5000);
});

A: Use setTimeout function.

$('#submit').click(function(){
  setTimeout(function(){
       window.location.href='index.php';
  },5000);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<button type="button" id="submit">Submit</button>

A: $('#submit').click(function(){
    var delay = 1000; //Your delay in milliseconds
    setTimeout(function(){ window.location = URL; }, delay);
});


text:
Q: How to convert Buffer array to hex? I am getting a Buffer array back in a JSON object when I call one of my API endpoints. I would like to convert this array to a more "usable" form (hex?) so I can compare them, etc. Here is what the object currently looks like:
"hash": {
  "type": "Buffer",
  "data": [
    151,
    14,
    51,
    26,
    46,
    52,
    5,
    151,
    99,
    107,
    38,
    188,
    138,
    180,
    76,
    56,
    108,
    214,
    135,
    213,
    125,
    134,
    105,
    139,
    129,
    236,
    206,
    157,
    67,
    1,
    12,
    12
  ]
}

How would I go about converting this array to a hex (or string, etc.) so that I can compare hashes?

A: You can just create a new buffer and convert it into the format you need.
var o = {"hash": {
"type": "Buffer",
"data": [
  151,
  14,
  51,
  26,
  46,
  52,
  5,
  151,
  99,
  107,
  38,
  188,
  138,
  180,
  76,
  56,
  108,
  214,
  135,
  213,
  125,
  134,
  105,
  139,
  129,
  236,
  206,
  157,
  67,
  1,
  12,
  12
  ]
 }
}

console.log(new Buffer(o.hash,'hex').toString('hex'));
// 970e331a2e340597636b26bc8ab44c386cd687d57d86698b81ecce9d43010c0c

A: If you have an existing Buffer object, you can represent it as hex via:
myBuffer.toString('hex')
// '970e331a2e340597636b26bc8ab44c386cd687d57d86698b81ecce9d43010c0c'

A: Use Number.prototype.toString:

var json = '{"hash": {"type": "Buffer","data": [151,14,51]}}';
var parsed = JSON.parse(json);
document.write("data: " + JSON.stringify(parsed.hash.data) + "<br>");
document.write("hex: ");
parsed.hash.data.forEach(function(b) { document.write(("00" + b.toString(16)).substr(-2)); });


text:
Q: Python @property Mapper 'mapped class User->user' has no property 'member_groups Context: For my work, I'm running a script populate.py where we populate a database. It fails at a certain advanced stage (let's just say step 9) as I'm trying to add a new many to many association table.
I made some changes to correspond to a similar entity that works. Specifically I added some @property and @x.setter methods because I thought that would solve it or at least be good practice. Now I get a failure at an earlier stage that was working before (let's say step 4).
I'm not looking for a solution to either of these issues but an understanding of how there could be such an error as logged with respect to how python is designed to work.
The error is:
`sqlalchemy.exc.InvalidRequestError: Mapper 'mapped class User->user' has no property 'member_groups'`

I did change a class attribute from
member_groups

to
_member_groups

But I also added the following code
@property
def member_groups(self) -> List[MemberGroup]:
    return self._member_groups

@member_groups.setter
def member_groups(self, new_member_groups):
    '''
    Now, what do we do with you?
    '''
    self._member_groups = new_member_groups

I thought the whole point of the @property decorator in python was for this very use case- that I could call the class attribute _foobar as long as I had the decorator grabbing and setting it correctly..
@property
def member_groups(self):
    return self._foobar

..and that it shouldn't make any difference what the class attribute is called as long as we give what we want the user to access it through the property descriptor. I thought that was the whole purpose or at least a major point of this pythonic api, specifically to create pseudo private variables and not have it make a difference or be breaking with existing code, but it shows that mapped class has no property.
I just want the theory, not a code solution per se, although I'll take ideas if you have them. I just want to understand Python better.


text:
Q: Execute Spacebar or Backspace with function in Javascript this is my code in JavaScript:
document.addEventListener('keypress', event => {
  event.code === 'Space';
})

I want to execute my keyboard with a function of javascript. Thank you for answering me

A: let element = document.querySelector('input');
element.onkeydown = e => alert(e.key);
element.dispatchEvent(new KeyboardEvent('keydown', {
'key': 'a'
}))


text:
Q: How can I make a shared account in Exchange 2013 that let's me add new users to that account in Active Directory I'm new to Active Directory and Exchange Server 2013. I'm looking for a way to simplify shared accounts in Exchange. At the moment, whenever we get a new user who wants access to a shared email account we have to manually add them in Exchange 2013. Then, when the user leaves our company we have to remove them from both Active Directory and the shared email in Exchange.
It would be nice to make the shared account in Exchange 2013 and simply add them to that shared account in Active Directory. That way when we remove them from Active Directory when they leave, they will automatically be removed from the shared account. Here's what I've tried so far.

*

*Created a shared account named "TestZach" in Exchange admin center 2013 and selected the location to store it our OU named "Shared Accounts" in ADUC

*Went to ADUC and created a Universal Security Group named "Test" in the "Shared Accounts" OU

*On our exchange server started Exchange Management Shell and ran this command: "Enable-DistributionGroup -Identity Test" in order to mail enable my universal security group in Exchange 2013.

*Added the Universal group "Test" as member of owner in Exchange admin center

*Added myself and my boss to be members of the "Test" Universal Security Group in ADUC
At this point I expected to see the inbox "TestZach" show up in Outlook 2013 but no such luck even after waiting overnight with a restart. I did a bit more research and found that I may need to add permissions to "TestZach" through the Exchange Management Shell in our exchange server. So I added the following step

*Ran command "Add-MailboxPermission -id TestZach -User Test -AccessRights Fullaccess" in Exchange Management Shell to give the Test Security group full access to mailbox TestZach.
However it still hasn't seemed to work as TestZach still isn't showing up in Outlook 2013.
I realize I may be attempting something that doesn't work in Exchange 2013 or I may be going about it all wrong.

A: Your approach to create a Shared Mailbox (disabled taskuser & Active Directory group) is quite common, because you can grant somebody rights to manage the access group, but that user do not need Exchange Admin rights.
However (as mentioned in my comment) the "auto map" function works only if the user is directly added to the mailbox. It isn´t working when you are using groups (see: it is important to understand that this auto-mapping process does not work if the Full Access Permission is assigned via membership of a group.).


text:
Q: SQL Server 2008R2 Transaction Replication Stop and Restart but continue log backups In a database that is currently being replicated I want to stop the replication (stop the log reader process) for a period of time though I want to continue to take log backups on that same database.
Does the log backup free up the log for reuse or does it remain intact for the log reader task to perform the replication to copy the transactions to the distribution database?  All of this assumes that the space for the log is available for the log growth.  I am thinking that whatever is remaining in the transaction log that is marked for replication that has not been distributed will not be overwritten but I wanted to verify this.
If so, when I restart the log reader process the transactions are written to the distribution database then the log would then continue to be handled as it was in the past and shrink appropriately.

A: The log backup will not free up the log for reuse.  Transactions in the transaction log in the publication database that have been marked for replication will not be unmarked until they have been written successfully to the distribution database.  Only then can that portion of the log be marked for reuse.
From the moment you stop the Log Reader Agent you will most likely notice some transaction log growth with log_reuse_wait_desc being REPLICATION.
For example:
SELECT name, log_reuse_wait_desc FROM sys.databases

At first the log_reuse_wait_desc might be LOG_BACKUP, but after a log backup is performed, if the Log Reader Agent is not running, log_reuse_wait_desc will be REPLICATION.


text:
Q: Prevent vcpkg project-wide and user-wide integration from clashing I have C++ source in source-control that uses vcpkg through project-wide integration (the .props and .targets files from vcpkg are imported).
That works great, but a developer in the team already has vcpkg installed on their system a different folder. They used `vcpkg integrate install' to use it with Visual Studio projects.
That results in many build warnings for them that look like this:
C:\Users\<username>\AppData\Local\vcpkg\vcpkg.user.props(3,3): warning MSB4011: "D:\vcpkg\scripts\buildsystems\msbuild\vcpkg.props" cannot be imported again. It was already imported at "D:\MyApp\Directory.Build.props". This is most likely a build authoring error. This subsequent import will be ignored.

I thought a Condition on the import might work, but I think the condition
<Import Condition="'$(VcpkgPropsImported)'!='true'" would need to be on the Import in vcpkg.user.props created by the vcpkg integrate install. And that is outside my app's source code, so a future vcpkg integrate install would break again.
Is there a work-around that can be used?


text:
Q: Clickhouse shared dictionaries Is there any way to "share" or "replicate" a dictionary among multiple machine in the same shared and/or cluster using clickhouse.
Currently I have ~10 files for external dictionaries that clickhouse loads up (and a few csvs where the data is loaded from). All the dictionaries are quite small and critical for a lot of queries, so I'd like to find a way to distribute them instead of having to maintain up to date copies on every cluster.
Is there any way to do this ?

A: you can try use configuration managament tools like a puppet, ansible for rollup your dictionaries over multiple nodes together clickhouse configs
or just use rsync or NFS share and run service clickhouse reload  as neccessary


text:
Q: Management of State in React How is the initial state preserved when you you route to another component?
Say you have an e-commerce site, where you have information about a user's cart when the user is in checkout. Now the user decided to go to the main page. How will the cart information passed so that it is not lost?

A: Hi I guess the main page is the parent component and card page is the child component. It it is then you can pass the function reference from parent to child and pass child information to the parent by calling that function. here is the example:
Parent Component
import React, {useEffect, useState} from 'react';
import Child from "./Child";

function CParent(props) {

    const [status, setStatus] = useState(false);

    function setOpeningValue(status) {
        console.log(status);
        setStatus(status);
    }
    return (

            <Child setOpeningValue={setOpeningValue}/>

    );
}
export default CParent;

Child Component
import React, {useEffect, useState} from 'react';

// Child to Parent communication
function Child(props) {
    const {setOpeningValue} = props;
    const [isOpen, setOpen] = useState(false);

    function clickHandler() {
        setOpen(!isOpen);
        setOpeningValue(`changes is ${!isOpen}`);
    }
    return (

            <button onClick={clickHandler}>Open</button>

    );
}
export default Child;


text:
Q: Undefined is not a function with dataTable.js I have the following javascript code (JQuery and datatable) which gives the error Uncaught Type error: undefined is not a function.

function checkTransaction(tableName, url, columns){
var columnList = [];
for (var i = 0; i < columns.length; i++){
    columnList.push({
        "data": columns[i]
    });
}

for (var i = 0; i < 1; i++){
    columnList.push({
        "data": "id"
    });
}

$(document).ready(function(){
    var firstname = $("#firstname").val();
    var lastname = $("#lastname").val();
    var startDate = $("#startdate").val();
    var endDate = $("#enddate").val();
    searchTable = $(tableName).dataTable({
        "ordering": false,
        "columns": columnList,
        "columnDefs": [
            {
                "targets": columns.length,
              }
        ],
        "pagingType": "full_numbers",
        "ajax": {
            "url": url,
            type: "POST",
            data: {firstname: firstname, lastname: lastname, startDate: startDate, endDate: endDate},
            "dataSrc": "",
            error: function(xhr, error) {
                if (xhr.status == 400) {
                    alert('Bad Request. [400]');
                }
                else if (xhr.status == 401) {
                    alert('User Unauthorized To Access Resource. [401]');
                }
                else if (xhr.status == 403) {
                    alert('Access To Resource Forbidden [403]');
                }
                else if (xhr.status == 404) {
                    alert('Requested Resource Not Found [404].');
                } else if (xhr.status == 500) {
                    alert('Internal Server Error [500].');
                }
                else if (xhr.status == 503) {
                    alert('Service Unavailable [503].');
                }
                else if (error === 'parsererror') {
                    alert('Requested JSON parsing failed.');
                }
                else if (error === 'timeout') {
                    alert('Time out error.');
                }
                else if (error === 'abort') {
                    alert('Ajax request aborted.');
                }
                else {
                    alert('Uncaught Error.\n' + xhr.responseText);
                }
            },
        }
    });

}); }

Chrome points to this "searchTable = $(tableName).dataTable({" as the source of the error
and but it looks ok to me (i have limited knowledge of Javascript)
I'd appreciate it if someone can explain why the cause of this error.
PS: I've made sure jquery is first loaded and only one jquery library is loaded, i've made sure that the datatable library is also load.
Thanks.

A: Referencing a local copy of the DataTable library solved the problem but i'm puzzled as to why the code doesn't work when i use the DataTable CDN.


text:
Q: Codename one - checkbox option in overflow menu I have a form with a basic overflow menu, that is supposed to offer options of manipulating a list of items of that form. One part is sorting the list by various means (which works well), the other part is providing a filtering of the list. E.g. having a simple shopping list of items that can be checked and I want the filter to show only "open" items, yet unchecked to focus on.
Can I add a previously assembled component to the overflow menu? Its just a dialog spawning in that location, so it should be able to house any component for that matter. However, the options "add(Material)CommandToOverflowMenu" only allow to add commands directly or a string, icon, listener combination.
If a custom component is not possible, I could still use the icon to show an empty checkbox first, and then update to an checked checkbox icon, once pressed. However, how to manipulate an existing overflow item, after it was added? I dont even see a way to remove previously added overflow items, as the "getOverflowCommands" returns an Iterable, which is not supposed to be used for manipulation of the list.
Is there a way to do this, I do I have to setup my own, custom, overflow menu like dialog?
Thanks and best regards
EDIT WITH SOLUTION
I created a new class to solve my problem:
public class ToggleCommand extends Command {

    private boolean selected;

    private static Image selectedImage = FontImage.createMaterial(FontImage.MATERIAL_RADIO_BUTTON_CHECKED,
            new Label().getUnselectedStyle());
    private static Image unSelectedImage = FontImage.createMaterial(FontImage.MATERIAL_RADIO_BUTTON_UNCHECKED,
            new Label().getUnselectedStyle());

    public ToggleCommand(String command) {
        this(command, selectedImage);
    }

    public ToggleCommand(String command, Image icon) {
        super(command, icon);
        selected = true;
    }

    public boolean isSelected() {
        return selected;
    }

    public void setSelected(boolean selected) {
        this.selected = selected;
        if (selected) {
            this.setIcon(selectedImage);
        } else {
            this.setIcon(unSelectedImage);
        }
    }
}

which you can use like this:
filterDoneCommand = new ToggleCommand("Show closed?") {
        @Override
        public void actionPerformed(ActionEvent evt) {
            filterDoneCommand.setSelected(!filterDoneCommand.isSelected());
            // do your other stuff
        }
    };
    getToolbar().addCommandToOverflowMenu(filterDoneCommand);

A: The overflow menu wasn't built well and should probably be rewritten. We don't have builtin support for checkbox options there and making a change to add it would be pretty cumbersome.
The best workaround I can think of is to add a command with a checkbox as an icon. Then checking/unchecking when the command is invoked. The addMaterialCommandToOverflowMenu and similar command methods return a Command instance which you need to save for future reference in this case.
If you want to go "all out" you can just add a button to the right side toolbar and use that to show a completely customized overflow menu. That might be easier in some regards.


text:
Q: For quick Web Animations, Javascript/jQuery or CSS3? jQuery animations seem to have better browser support, but the CSS3 Keyframes appear to be really fast and smooth yet not very good browser support.
I'd like to here people's opinion about jQuery or CSS3 in terms of:
Canvas Gaming:
I have seen a few CSS3 games which where pretty nice. Then again, when we are gaming with the Canvas we are already using Javascript and to do some quick and dirty stuff we might also include the jQuery Javacsript Library.
Or would we use both for Canvas Gaming? Not sure.
Websites:
For normal websites delivering content, not gaming: what would be a decent approach for animations on a regular Web Page?

I also hear stuff such as: CSS3 Animations slows down some jQuery Animations and other scripts on the page...hm.
To clear things up, I would just someone to explain some of the advantages of using CSS3 Animations or a jQuery Animation.
Any opinions would be nice, thanks!

A: The Mozilla developer documentation raises some interesting points regarding CSS3 animation:

Letting the browser control the animation sequence lets the browser
  optimize performance and efficiency by, for example, reducing the
  update frequency of animations running in tabs that aren't currently
  visible.

WebKit also makes use of hardware accelerated compositing, which can have a much greater effect on performance than anything Javascript can do at this time. (I think this will change very soon though as more functions are added to manage calculations) This is because it will take advantage of dedicated hardware if it available to perform the calculations, rather than making it happen through a translated language like Javascript.
It stands to reason browser vendors will only increase their support for this in the name of competition, and because the CSS3 standard is getting closer to completion.
My only concern would be the manageability of the code, although this could easily be managed with a decent translation layer. There are some excellent animation engines available in Javascript, although I haven't used or researched one recently to give an accurate estimate of performance.

A: For the part of your question Re: "Websites: For normal websites delivering content", you are going to want to interact with a server for some of that content.  That interaction is going to be via ajax and, based on your question, jquery-based.  Then consider some of your animations will be based on the exact data returned.
jQuery makes that kind of content-dependent animation so easy.   In a "normal website delivering content" you would, logically, have much less animation than in a game - so performance / resource hogging is less of an issue.


text:
Q: Add a SQL XOR Constraint between two nullable FK's I'd like to define a constraint between two nullable FK's in a table where if one is null the other needs a value, but both can't be null and both can't have values. Logic is the derived table inherits data from the either of the FK tables to determine its type. Also, for fun bonus points, is this a bad idea?

A: One way to achieve it is to simply write down what "exclusive OR" actually means:
CHECK (
    (FK1 IS NOT NULL AND FK2 IS NULL)
    OR (FK1 IS NULL AND FK2 IS NOT NULL)
)

However, if you have many FKs, the above method can quickly become unwieldy, in which case you can do something like this:
CHECK (
    1 = (
        (CASE WHEN FK1 IS NULL THEN 0 ELSE 1 END)
        + (CASE WHEN FK2 IS NULL THEN 0 ELSE 1 END)
        + (CASE WHEN FK3 IS NULL THEN 0 ELSE 1 END)
        + (CASE WHEN FK4 IS NULL THEN 0 ELSE 1 END)
        ...
    )
)

BTW, there are legitimate uses for that pattern, for example this one (albeit not applicable to MS SQL Server due to the lack of deferred constraints). Whether it is legitimate in your particular case, I can't judge based on the information you provided so far.

A: You can use check constraint:
create table #t (
   a int,
   b int);

alter table #t add constraint c1
check ( coalesce(a, b) is not null and a*b is null );

insert into #t values ( 1,null);

insert into #t values ( null ,null);

Running:
The INSERT statement conflicted with the CHECK constraint "c1".

A: Alternate way is to define this check constraint in a procedure. Before you insert a record in the derived table, the constraint should be satisfied. Else insert fails or returns an error.


text:
Q: How do I plot a function a=a(r, theta) in cylindrical coordinates in MATLAB? a is a 100x100 matrix containing the numerical solution of a differential equation.The function a(r, theta) does not have an explicit form in terms of r and theta.I have tried creating a mesh for r and theta using meshgrid and then converting the problem to the cartesian frame using pol2cart. But this does not work as a cannot be expressed in terms of r and theta.
[R, Theta]=meshgrid(r,theta);
[x,y,A]=pol2cart(Theta,r,a);
contourf(x,y,A,50,'linecolor','none');

A: It looks like the error may just be a matter of capitalization. 'r' -> 'R' produced a polar contour plot in my test implementation.
% Setting up the plotting ranges
r = 0:99;
theta = linspace(0,2*pi,100);
[R, Theta]=meshgrid(r,theta);

a = R + Theta; % Your numerical solution goes here

[x,y,A]=pol2cart(Theta,R,a); % <- Your error is here?
contourf(x,y,A,50,'linecolor','none');

The arguments for the pol2cart function should have the same size.


text:
Q: Can One Public Key be Used to Encrypt and Decrypt Data during the SSL Handshake? When a server sends a Certificate message to a client, the public key in the server's certificate will be used to verify server's identity(decryption with the public key).
The server follows its Certificate message with a ServerKeyExchange message, the session key information is signed using the same public key contained in the server's certificate (encryption with the public key).
So I feel a Public key can be used to encrypt and decrypt data as well, am I right?
If yes, I wonder why text book just states one key(e.g. public key) is used to encrypt , and the other one(private key) is used to decrypt, rather than mention that a key can be used to both encrypt and decrypt?
[UPDATE2]
Really thanks for Bruno's help.
After reading Bruno's replies and RFC4346(section7.4.2 and 7.4.3) again and again, I suddenly felt I grasp the main points. :)
However, I am not sure I am right, and hope someone can confirm my following understanding. Thanks.
1.Server Certificate
SSL and TLS Essential section 3.6.1:
(SSL and TLS Essential: Securing the Web   Author: Stephen A. Thomas)

...the public key in the server's certificate will only be used to verify its(server) identity.

Bruno wrote,

The public key in the server certificate isn't used to verify the server's identity itself.

I agree Bruno's viewpoint now, because a certificate is only a private-key-signed(encrypted) message that also contains someone else's(e.g., a client ) public key, so a client should use its trusted copy of the server's public key (usually, web browsers include dozens of these certificates in advance), instead of the public key in the server certificate, to verify the server's identity.
Is it right?
2.Server Key Exchange
SSL and TLS Essential section 3.6.2:

...the key information is signed using the public key contained in the server's certificate.

Bruno wrote,

Similarly, you don't really sign something with a public key. You only need one of the keys to sign, and that's the private key. You verify the signature with the matching public key.
...
"signing with a public key" is an unusual and misleading expression.

I think Bruno is right. The reasons are as follows,
RFC4346 section 7.4.2. Server Certificate

It MUST contain a key that matches the key exchange method, as follows.
Key Exchange Algorithm           Certificate Key Type

     RSA                     RSA public key; the certificate MUST
                             allow the key to be used for encryption.

     DHE_DSS                 DSS public key.

     DHE_RSA                 RSA public key that can be used for signing.

     DH_DSS                  Diffie-Hellman key. The algorithm used
                             to sign the certificate MUST be DSS.

     DH_RSA                  Diffie-Hellman key. The algorithm used
                             to sign the certificate MUST be RSA.

So the server sends one of 6 public key types in a certificate first.

RFC4346 section [7.4.3 Server Key Exchange Message][2]
>The server key exchange message is sent by the server.
>...
>This is true for the following key exchange methods:
>
   DHE_DSS
   DHE_RSA
   DH_anon
>...
>This message conveys cryptographic information to allow the client to communicate the premaster secret.
The server chooses one of 3 key exchange methods, and uses its private key to sign(encrypt) cryptographic information.
When the client receives the encrypted cryptographic information, it will use the public key in ServerCertificate message to verify(decrypt) and get the plain-text cryptographic information.
Is it right?

A: In a PPK algorithm like RSA, you have two different communication channels. Information encrypted using the public key is only readable to the possessor of the private key, and information encrypted using the private key is only readable to the possessor of the public key.
In fact, the selection of which half of the pair is "public" is completely arbitrary.
Now, in practice this doesn't much matter; the whole world has access to the public key, so encrypting something with the private part wouldn't do anything to secure it. But you can use this for authentication: since only one holder has the private key, if a message is validly encrypted using it, then the private-key holder must have been the author.
That's why your book doesn't say that the private key is used for encryption: because it's used for integrity, not for confidentiality, as any message sealed using it would be readable to anyone possessing the non-secret public half. While the integrity validation mechanism is technically encryption (it is encipherment using modular exponentiation), it would be confusing to mention this in a foundations-of-cryptography context as it's not what people think when they hear "encryption" - they think "privacy".

A: In public key cryptography:

*

*The private key is used for signing and deciphering/decrypting.

*The public key is used for verifying signatures and enciphering/encrypting.

See the glossary of the TLS specification:

public key cryptography:
A class of cryptographic techniques employing two-key ciphers.
Messages encrypted with the public key can only be decrypted with
the associated private key.  Conversely, messages signed with the
private key can be verified with the public key.

You cannot encrypt with a private key or decrypt with a public key, not for mathematical reasons, but because it doesn't make sense w.r.t. the definition of encrypt:

To convert ordinary language or other data into code; to hide
the meaning of a message by converting it into a form that
cannot be interpreted without knowing the secret method for
interpretation, called the key; to encode.

In a situation where you "encrypt with the private key", you effectively "scramble" the data indeed, but what's required to turn back the message into its original form is not a secret. Hence, it doesn't make sense to talk about encrypting in this context. Whether the mathematical operations behind it may work one way or the other doesn't matter at this stage.
Similarly, you don't really sign something with a public key. You only need one of the keys to sign, and that's the private key. You verify the signature with the matching public key.
It's quite common (even in the TLS specification) to say "signing with a certificate", when what's really implied is computing the signature with the private key matching the certificate. In many cases, not specifically TLS, the certificate itself is communicated along with the signature (whether-or-not one chooses to trust that certificate is another matter).
Expressions such as "using your certificate to authenticate" or "using your certificate to sign" are generally acceptable, so long as you understand that "certificate" is used there to shorten "certificate and its private key", and that it's in fact the private key that's necessary for those operations.
I don't have the book you're quoting, but this quote sounds misleading or incorrect (perhaps taken out of context here):

...the public key in the server's certificate will only be used to
verify its(server) identity.

The public key in the server certificate isn't used to verify the server's identity itself. What it does is ensuring that only someone/something with the corresponding private key will be able to decipher what you've encrypted with this public key: in this case (authenticated key exchange), the pre-master-secret which the server will prove it knows to the client by producing the correct Finished message, based on the pre-master-master it has managed to decipher.
The identity binding is done by the certificate itself, with is the signed combination of the public key, some identifiers (e.g. Subject DN and Subject Alternative Names) and possibly various other attributes (e.g. key usage, ...).
This side of the identity verification (i.e. checking who this certificate belongs to) is established by verifying the integrity of the certificate and that you trust what it says (usually PKI), and by verifying that the identity it belongs to is indeed the one you wanted to connect to (host name verification). This is done by verifying the certificate signature itself using a Certification Authority (CA) or by an outside mechanism, for example if you have explicitly granted an exception for a given certificate (possibly self-signed) using knowledge you have outside the scope of the PKI to which the certificate belongs. This step is rather independent of the TLS specification, although you'll need all these pieces together to make the communication secure.
There's a similar problem with this quote (again, possibly taken out of context):

...the key information is signed using the public key contained in the
server's certificate.

Although saying "signed with a certificate" is a common expression (as explained above), I'd say "signing using the public key" is definitely confusing, since "public key" is normally used in contrast to "private key", and it's really the private key that's used for signing. While even the TLS specification (Section F.1.1.2) talks about "signing with a certificate" in a few places, "signing with a public key" is an unusual and misleading expression.
I'm not sure whether "(decrypt)" and "(encrypt)" are in the book or your additions:

the public key in the server's certificate can be used to
verify(decrypt) the server's identity and sign(encrypt) the key
information(,then the client will use the key information to encrypt
pre_master_secret)

You actually verify you're talking to the actual server identified by that certificate because it's the only one capable of deciphering what you've encrypted with its public key (in the client key exchange message).
As it's put in the TLS specification Section F.1.1.2:

After verifying the server's certificate, the client encrypts a
pre_master_secret with the server's public key.  By successfully
decoding the pre_master_secret and producing a correct finished
message, the server demonstrates that it knows the private key
corresponding to the server certificate.

What you're asking at the end doesn't completely make sense:

I know the public key can be used to verify server's
identity(Certificate message), but I can't understand the public key
why can be used to sign the key information, because the client
doesn't have the corresponding private key, how does the client verify
the key information?

The public key isn't used to verify the server's identity. You verify that you're talking to the server who has the private key matching the certificate it presented earlier by the fact it was able to decipher the pre-master-key and produce the correct finished message.
EDIT 2:
Following your edit, it seems that you're still using "sign(encrypt)" and "verify(decrypt)" as if encrypting was the same as signing and verifying was the same as decrypting. I would suggest once again that you stop making these associations: these are 4 distinct operations. While the maths may be the same when using RSA, this doesn't work for DSA, which is only a signature algorithm (so signing/verifying only).

When the client receives the encrypted cryptographic information, it
will use the public key in ServerCertificate message to
verify(decrypt) and get the plain-text cryptographic information.

The client doesn't receive any encrypted data during the handshake (only signed data).
For a better general understanding, you should start by trying to understand how Diffie-Hellman and its ephemeral variant (for DHE cipher suites) work.
(In practice, I wouldn't focus too much on non-ephemeral DH_RSA/DH_DSS cipher suites. To be honest, I'm not sure whether they're much used. I haven't seen any example of certificate with the necessary DH attributes, and these cipher suites are not in supported lists by OpenSSL or Java 7. DHE/EDH are much more common, and don't require special attributes in the certificate.)
If you use an RSA key exchange algorithm, the client will encrypt the pre-master-key in the client key exchange message; if it's using one of the DH key exchange algorithms, it will send its DH parameters so that client and server can agree on a pre-master-key (in this case, the client will have checked that the server's DH parameters come from the right server by verifying the signature of the server key exchange message sent beforehand). See description of the Client Key Exchange Message:

With this message, the premaster secret is set, either though
direct transmission of the RSA-encrypted secret or by the
transmission of Diffie-Hellman parameters that will allow each
side to agree upon the same premaster secret.

Regarding the other points:

a certificate is only a private-key-signed(encrypted) message that
also contains someone else's(e.g., a client ) public key, so a client
should use its trusted copy of the server's public key (usually, web
browsers include dozens of these certificates in advance), instead of
the public key in the server certificate, to verify the server's
identity.

Three things happen to verify you're talking to the right server:

*

*The handshake itself, if successful, guarantees that you're talking to the server that has the private key for the certificate it has presented in the server certificate message. If using RSA key exchange, this is guaranteed by the fact it's the only one that can decipher what the client sent in the client key exchange message (since it's encrypted with the public key); if using an EDH key exchange, this is guaranteed because the server signed its DH parameters in the server key exchange message, verifiable with this public key.

*The fact that you can verify the certificate itself. This is rather independent of how TLS works, but it's usually done using a PKI: the client has a pre-set list of trusted CA certificates, the public keys of which can be used to verify the signature in new certificates it doesn't already know about (such as the server certificate). Verifying that signature allows the client to bind that public key to an identifier (Subject DN and/or alt. name). This gives you the identity of the server to which the client is talking.

*The host name verification: it's not good enough to know that you're talking to someone who's presented you a genuine ID that's valid for them, you also need to check that the name matches the server you intended to connect to.

When I said "The public key in the server certificate isn't used to verify the server's identity itself", I meant that the public key wasn't used to verify points 2 and 3. Point 1 guarantees you that you're talking to the server that has the private key matching the certificate it presented, but it doesn't tell you who this is. Verifying the identity of the server is is up to point 2, so as to be able to bind an identifier to that key/cert.

A: I had the same restlessness, since its difficult to ask without falling in technical holes. Quick, easy answer: regardless of the method details, yes, you could reverse engineer and decrypt from one key (is just math at the end) but because of the complexity of the operation, using a long value (you may use ie. a 4096-bit value) would make the reverse operation timeless, so you had to use either a machine so big that still doesnt exists or wait indefinitely, making it inviable... until someone comes up with a quick method to do it.
may want to take a look:
http://www.usna.edu/CS/si110arch/si110AY12F/lec/l29/lec.html


text:
Q: handle bounced email - ActionMailer I have a rails app and I am using ActionMailer to send email but now I need to know if the email is delivered or what?
Do anyone has an idea of how to handle sent emails status(e.g bounced, delivered) ?
thanks.

A: Email service providers use a technique called variable envelope return path.  The idea is to encode a unique key for each message into the (envelope) return address so that when a destination smtp server returns email as a bounce you can tie it to the originating message.
If it sounds complex, it is.  It gets harder if you want to track response rates, which links were clicked, opens, use Domain Keys, etc. Note that it requires you to set up or configure an SMTP server for handling returned mail.
There are a number of services that provide this all to you on a Software As Service basis.  We use socketlabs and are very happy with them.  Industrial strength and all.  I've also heard of people using Postmark in the Ruby community.


text:
Q: PC turns on for a split second then turns off My PC recently stopped working. I turned it on one day and heard a pop then it turned off and when I tried to turn it on it wouldn't.
I assumed it was the PSU so I changed it but then after trying to turn it on again the fans would spin for a split second and the CPU red light would flash then it would all turn off so I thought the CPU shorted so I changed that too.
Tried it again still nothing so changed the motherboard as well but still nothing.
Afterwards I changed the ram sticks and still nothing. When I supply power to the PC and turn it on all it does now is every fan on the case and every fan on the graphics card spins for a split second then nothing happens (cpu fan does not spin either).
I have absolutely no idea what it could be and I've basically built a new pc at this point please help

*

*CPU: Intel i5 96000k

*GPU: Nvidia GeForce RTX 2060

*Motherboard: ASUS Prime z390-p Motherboard

*RAM: 2x LPX Vengeance 8gb RAM sticks

*PSU: 750watts

*Hard Drive: 1TB Hard drive

*SSD: 4TB 850 EVO SSD


text:
Q: codeigniter fatal error using $this not in object context I am beating my head against the wall on this. I have a codeigniter application that I am migrating from one server to another. When migrated, I throws an error (it doesn't in production).
Fatal error: Using $this when not in object context in /SYSTEM_PATH/system/database/DB.php on line 146

It's a stock CI install 2.1.3 as far as the system folder goes.
I've already tried re-uploading/migrating (hoping it was a corrupt file or something), but no luck.

A: This is too big for a comment:
(Are you sure you downloaded a stable version - or did you use the development version of CI?)
In 2.1.3 Line 142 to 156 looks like below, no mention of $this in there
// Instantiate the DB adapter
$driver = 'CI_DB_'.$params['dbdriver'].'_driver';
$DB = new $driver($params);

if ($DB->autoinit == TRUE)
{
    $DB->initialize();
}

if (isset($params['stricton']) && $params['stricton'] == TRUE)
{
    $DB->query('SET SESSION sql_mode="STRICT_ALL_TABLES"');
}

return $DB;

Check here https://github.com/EllisLab/CodeIgniter/blob/2.1.3/system/database/DB.php


text:
Q: On Windows how to get network interface name whether its eth0/eth1/eth2 using batch script? I am working on windows and wanted to get the network interface name whether its eth0, eth1, eth2 etc etc etc. I wrote java program and by passing host/computer name I can find out ip address and thereafter based on an ip address I can find out network interface name. The code is as below:
public static String getNetworkInterface() {
        try {
            String computerHostName = "dummy";
            if(!computerHostName.equals("Unknown Computer")) {
                InetAddress address = InetAddress.getByName(computerHostName);
                return NetworkInterface.getByInetAddress(address).getName();
            }
            else {
                return null;
            }
        }
        catch (SocketException e) {
            e.printStackTrace();
        }
        catch (UnknownHostException e) {
            e.printStackTrace();
        }
        return null;
    }

The above method returns the value something like eth0/eth1/eth2 etc.
Same thing I want to achieve using batch script on windows. I wrote following script which is providing hostname and an ip address. But I don't know as to how to get the network interface name.
for /f "skip=1 delims=" %%A in (
  'wmic computersystem get name'
) do for /f "delims=" %%B in ("%%A") do set "compName=%%A"

echo hostname is %compName%

This scripts gives hostname/computername.
Please help me to get network interface name.
Thanks a lot.
regards,
Yeshwant

A: This should give you the Network Interface Name:
@Echo Off
For /F "Skip=1Delims=" %%a In (
    '"WMIC NIC Where (Not NetConnectionStatus Is Null) Get NetConnectionID"'
) Do For /F "Tokens=*" %%b In ("%%a") Do Echo=%%b
Timeout -1

A: If you want to find the network interface based on a IP-address you can use:
@echo off
SetLocal EnableDelayedExpansion

set ownIP=W.X.Y.Z
set netifc=
FOR /F "tokens=4*" %%G IN ('netsh interface ipv4 show interfaces ^| findstr /I "[^a-zA-Z]connected"') DO (
    REM set /P =interface %%G is connected < nul >> !progress!
    netsh interface ipv4 show addresses "%%H" | findstr /c "%ownIP%" > nul 2>&1
    IF !ERRORLEVEL! EQU 0 (
        set netifc=%%H
    )
)

:outLoop
echo IP-address %ownIP% from interface %netifc%
EndLocal
exit /b 0

I use netsh instead of WMIC because I don't have much experience in WMIC but netsh is sufficient in your case.
Note that the SetLocal EnableDelayedExpansion is very important as this script is based on checking the ERRORLEVEL. The cmd-parser parses every block of commands delimited with () as being one single command as if it was written on one line (in our case FOR ... ( ... ) ). It is thus impossible to use a changing variable with its updated value inside a () unless you use delayed expansion. If you don't, only the value before entering the block can be used. As ERRORLEVEL can change in each iteration (will be 0 if the IP-address has been found by the findstr above it in the addresses of an interface or 1 if it hasn't), we always need the updated value. This is also why I use !ERRORLEVEL! instead of the classic %ERRORLEVEL%.
More info about EnableDelayedExtension can be found here.
Running the script above with set ownIP=127.0.0.1 (don't forget to change to your IP) gives the following result:
>search_interface.bat
IP-address 127.0.0.1 from interface Loopback Pseudo-Interface 1

If you'd like to pass the IP-address as an argument each time you call the script, use set ownIP=%~1 (but don't forget to add a check if an argument has been passed in that case).
Hope it helps.
Good luck!


text:
Q: Scraping the AJAX websites with Scrapy I am searching the answer for my question since last two days but now i am frustrated. I found a lot of stuff about this but nothing helped me in achieving my goal. The purpose of this long paragraph was to aware you that please don't link the previous answers of stackoverflow for reference. Kindly provide me simple & neat solution/answer.
I want to scrape the players data from https://www.premierleague.com/players
but i face ajax while scrolling down the page.
My teammate asked me not to use selenium. He asked me to only use Scrapy for this purpose.
So kindly tell me in easy word if it is possible with Scrapy or not.? & if possible then how.
I will be thankful to you.

A: Its easy
Open Inspect Element or Firebug
Switch to Network tab and then click on XHR
And then start scrolling down the page
You will see they are sending AJAX requests
Just check which URL they are sending requests to, and check what form-data is being sent along
headers = {
    'Referer': 'https://www.premierleague.com/players',
    'Origin': 'https://www.premierleague.com',
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36',
    'DNT': '1',
    'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
}

params = {
    'pageSize': '30',
    'compSeasons': '210',
    'altIds': 'true',
    'page': '0',
    'type': 'player',
    'id': '-1',
    'compSeasonId': '210',
}

yield Request('https://footballapi.pulselive.com/football/players?%s' % (urllib.urlencode(params)), headers=headers)


text:
Q: C++ library for image data acquisition and temporal pixel analysing I am working on a project to monitor if human tissue has been fused with radio frequency during the surgery or not, therefore we are using a very fast camera (1800fps) and also laser illumination on the tissue and a framegrabber (1GB memory).
At the moment we have a software based on C which is only getting the data from the grabber and passes it on the PC also show the images in Screen but I need to add an algorithm to grab all the frames from the framegrabber and analyze them with a mask and also calculate the contrast deviation of temporal images in real time.
I think there must be a framework out there which help me for the image analyzing in C++. What do you suggest? Zhat would be the best option for me to do the processing as fast as possible in real time ? OpenCV? OpenGL? GLPlus?

A: to answer your question I think you should look into OpenCV and ITK, the second one being somehow more popular in the medical imaging community.
That being said, what kind of processing do you intend to do? At these framerates you can only do simple things. I know that some frame grabbers can preprocess images for you and that might be enough for your application. IMO GPU computing is out of the question because of the data transfers and the simplicity of your computation

A: OpenCV Is your buddy for the tasks that you want to achieve. It basically supports lots of image processing functions, supports reading videos via FFMPEG and has camera capture options too. With OpenCV on TBB and GPU enabled primitives, you can definitely harness GPU power for the sake of speed.
Plus tonnes of community contribution is easily available as OpenCV is slowly but surely becoming a MUST know tool for image analysis experts/developers.
You might go for OpenGL. But it would suit 3D graphics type of projects more than just processing videos/image/frames.


text:
Q: How to install Boost.Python on Windows 7 in order to install a python package? I want to install the pyvlfeat package. It requires Boost.Python.
When I run the command
 python.exe setup.py build

I receive the following message:

C:\Users\alex\Anaconda\Scripts\gcc.bat -DMS_WIN64 -mdll -O -Wall -IC:\Users\A
  lexkow\AppData\Roaming\Python\Python27\site-packages\numpy\core\include -Ivlfeat
      / -IC:\Users\alex\Anaconda\include -IC:\Users\alex\Anaconda\PC -c vlfeat/m
      ser/vl_erfill.cpp -o build\temp.win-amd64-2.7\Release\vlfeat\mser\vl_erfill.o -m
      sse2 -O2 -fPIC -w
      In file included from vlfeat/mser/vl_erfill.cpp:7:0:
      vlfeat/mser/../py_vlfeat.h:18:28: fatal error: boost/python.hpp: No such file or
       directory

Which tells me Boost.Python is not installed correctly on my computer, or that I don't launch the python install command correctly.
The package INSTALL instructions are :

Building the Module on a Unix System --
      The C++ wrappers require Boost.Python to be installed:
$ sudo apt-get install boost-python1.35-dev
pyvlfeat uses distutils, so to build the library:
$ python setup.py build

As I am on Windows I can't sudo apt-get, so  I downloaded boost 1.57.0  and extracted it into

C:\Program Files\boost\boost_1_57_0

It did not change the result. And now I don't know what I should do:
When I read the  documentation

*

*The section 3: "No-Install Quick Start" explains how to build an extension module called extending and test it by running a Python script called test_extending.py.  I don't think that is what I want to achieve and it seems outdated because it talks about the bjam build driver.

*The section 4: "Installing Boost.Python on your system" looks more interresting, but it says the information is in the Getting Started Guide, and it is not.
How to install Boost.Python on Windows 7 in order to install a python package ? ?

A: I am looking at the setup.py file. It looks like you can set BOOST_PATH at the top. You should set that to the correct path to the Boost you downloaded, I think.


text:
Q: Formatting a number as a monetary value including separators I need some help with a sql transformation. This part of query that I have been provided with:
'$' + replace(cast((CAST(p.Price1 AS decimal(10,2)) * cast(isnull(p.Multiplier,1) as decimal(10,2))) as varchar), '.0000', '')

Basically, it ends up being a varchar that looks like this: $26980
I need to insert a comma at the thousand and million mark (if applicable). So in this instance, $26,980
What's the easiest way to do that without having to rewrite the whole thing?

A: If you really must do it in TSQL you can use CONVERT(), but this sort of thing really doesn't belong in the database:
declare @m money = 12345678
-- with decimal places
select '$' + convert(varchar, @m, 1)
-- without decimal places
select '$' + replace(convert(varchar, @m, 1), '.00', '')

A: Do it on the client side.  Having said that, this example should show you the way.
with p(price1, multiplier) as (select 1234.5, 10)
select '$' + replace(cast((CAST(p.Price1 AS decimal(10,2)) * cast(isnull(p.Multiplier,1) as decimal(10,2))) as varchar), '.0000', ''),
       '$' + parsename(convert(varchar,cast(p.price1*isnull(p.Multiplier,1) as money),1),2)
from p

The key is in the last expression
'$' + parsename(convert(varchar,cast(p.price1*isnull(p.Multiplier,1) as money),1),2)

Note: if p.price1 is of a higher precision than decimal(10,2), then you may have to cast it in the expression as well to produce a faithful translation since the original CAST(p.Priced1 as decimal(10,2)) will be performing rounding.

A: You could turn this into a function, it only goes 50 characters back.
DECLARE @input VARCHAR(50)
SELECT @input = '123123123.00'
SELECT @input = CASE WHEN CHARINDEX('.', @input) > offset +1
                      THEN STUFF(@input, CHARINDEX('.', @input) - offset, 0, ',')
                      ELSE @input END
FROM (SELECT 3 offset UNION SELECT 7 UNION SELECT 12 UNION SELECT 18 UNION SELECT 25 UNION SELECT 33 UNION SELECT 42) b
PRINT @input

The offset grows by +1 for each position, because it's assuming you've already inserted the commas for the previous positions.


text:
Q: How to redirect 301 this link (https://www.example.com/?lang=en) into this link (https://www.example2.com/en/)? I'm trying to do a redirect 301 from this links in my .htaccess file.
Old url: https://www.example.com/?lang=en
New url: https://www.example2.com/en/
I'll try to use this instruction:
RewriteCond   %{REQUEST_URI}    ^/$

RewriteCond   %{QUERY_STRING}   ^lang=en$

RewriteRule   ^(.*)$   /en/     [R=301,L]

like answer of this question (301 redirect from URL with query string to new domain with different query string), but my result is this: https://www.example2.com/en/?lang=en.
How can i remove the querystring "?lang=en" and obtain the new url?
Now it works with add the flag QSD, but now i've this problem:
I need to redirect this links too :
Old url 2: https://www.example.com/?lang=de
New url 2: https://www.example2.com/de/
And this links:
Old url 3: https://www.example.com/?lang=ru
New url 3: https://www.example2.com/ru/
If i use the instruction above, changing the query string, the redirect doesn't work for all of the language.
RewriteCond   %{REQUEST_URI}    ^/$

RewriteCond   %{QUERY_STRING}   ^lang=en$

RewriteRule   ^(.*)$   /en/     [R=301,L,QSD]

RewriteCond   %{REQUEST_URI}    ^/$

RewriteCond   %{QUERY_STRING}   ^lang=de$

RewriteRule   ^(.*)$   /de/     [R=301,L,QSD]

RewriteCond   %{REQUEST_URI}    ^/$

RewriteCond   %{QUERY_STRING}   ^lang=ru$

RewriteRule   ^(.*)$   /ru/     [R=301,L,QSD]

How can i resolve this new problem?
EDIT 2:
Solution for @QuickBecko
There are two solutions, depending on the Apache version:
First solution
RewriteCond   %{REQUEST_URI}    ^/$
RewriteCond   %{QUERY_STRING}   ^lang=en$
RewriteRule   ^(.*)$   /en/     [R=301,L,QSD]
RewriteCond   %{QUERY_STRING}   ^lang=de$
RewriteRule   ^(.*)$   /de/     [R=301,L,QSD]
RewriteCond   %{REQUEST_URI}    ^/$
RewriteCond   %{QUERY_STRING}   ^lang=ru$
RewriteRule   ^(.*)$   /ru/     [R=301,L,QSD]

Second solution
RewriteCond   %{QUERY_STRING}   ^lang=en$
RewriteRule   ^(.*)$   /en/?     [R=301,L]
RewriteCond   %{QUERY_STRING}   ^lang=de$
RewriteRule   ^(.*)$   /de/?     [R=301,L]
RewriteCond   %{QUERY_STRING}   ^lang=ru$
RewriteRule   ^(.*)$   /ru/?     [R=301,L]

A: This one will do the job:
RewriteCond %{QUERY_STRING} ^lang=en$
RewriteRule ^$ https://www.example2.com/en/?  [R=301,L]

Basically if you add ? at the end it will remove the query from the link.


text:
Q: Sending files as attachment using bash script I have list of excel files in a directory. I'm trying to email those files as attachment. However, when I open the email, I could see only one file as attachment. The below script is not attaching multiple files as attachment.
ls *.xls;
#echo "Test Email" | mailx -s "Testing File Conv" -a *.xls test@testmail.com

Will the above script work?

A: An array can be built to hold all the attachment options for each file like this:
#!/usr/bin/env bash

# Produces no result if no match for pattern
shopt -s nullglob

# Captures recipients from script arguments
recipients=("$@")

# Populates aray with xls file paths
xls_files=(./*.xls)

# If there are xls files
if [ "${#xls_files[@]}" -gt 0 ]; then

  # Declare an array to store mailx attachment options
  attach_option=()

  # Creates an attachment option for each file to be attached
  for file in "${xls_files[@]}"; do
    attach_option+=(-a "$file")
  done

  # Sends mail with all the attachment options
  mailx -s "Testing File Conv" "${attach_option[@]}" "${recipients[@]}"
fi

A: You have to write a script for this. at first create test.txt.
ls *.xls -1 > test.txt

then run this script :
while read line
do
mailx -s "Subject" -a ${line} -s "files" ${mail_from} << EOM

Hi, Sent files

EOM

done<test.txt


text:
Q: When to declare function with 'scope' vs. 'var' in directive? In this plunk I have a directive that is instantiated twice. In each case, the result of the directive (as defined by its template) is displayed correctly.
Question is whether getValue2() needs to be defined as scope.getValue2 or var getValue2. When to use each in the directive?
HTML
    instance 1 =

    instance 2 =

Javascript
var app = angular.module('app', []);

app.controller('myCtl', function($scope) {

});

app.directive('dirx', function () {

    var directive = {};

    directive.restrict = 'EA';

    directive.scope = {
            varx: '='
    };

    directive.template = '{{getValue()}}';

    directive.link = function (scope, element, attrs) {

        scope.getValue = function(){
          return getValue2();
        };

      var getValue2 = function() {
        return scope.varx * 3;
      }

    };

    return directive;

});

A: The only time you need declare something as a property on the $scope object is when it is part of your application state.
Angular 1.x will "dirty check" the $scope and make changes to the DOM. Anything on the $scope object can be watched, so you can observe the variable and trigger functions. This is why Angular searching & filtering can be done with almost no JS code at all. That being said, it's generally good practice to keep the '$scope' free of anything that isn't needed.
So as far as getValue() is concerned, is it being called on render or in a directive in your HTML? if the answer is "no", then it doesn't need to be declared as a property on the $scope object.
Since you're using getValue() in the directive template, it is being rendered in the UI and needs to be in Angular's $scope.
You can also just do:
   directive.template = '{{ varx * 3 }}';
docs: https://docs.angularjs.org/guide/scope

A: The first thing is that the code contains unnecessary nested calls. it can be:
  var getValue2 = function() {
    return scope.varx * 3;
  }

  scope.getValue = getValue2;

The second thing is that getValue2 isn't reused and isn't needed, it can be:
  scope.getValue = function() {
    return scope.varx * 3;
  }

Since getValue is used in template, it should be exposed to scope as scope.getValue. Even if it wouldn't be used in template, it's a good practice to expose functions to scope for testability. So if there's a real need for getValue2, defining and calling it as scope.getValue2 provides small overhead but improves testability.
Notice that the use of link function and direct access to scope object properties is an obsolete practice, while up-to-date approach involves controllerAs and this.


text:
Q: how to subtract previous row value from current row value based on condition in pandas DataFrame? When performing a conditional substraction, where I subtract the previous row value from the current row value for the columns (Jan - AnnualMean) for those rows where the values from the ID column is not equal to 1 or 8.
How to do that? I tried the following, which results in invalid syntax
for index,row in df.iterrows():
    if row["ID"] =! [1,8]:
        row.transform('diff')

input
ID  Jan Feb Mrz Apr Mai Jun Jul Aug Sep Okt Nov Dez AnnualMean
1   14  18  17  45  22  31  30  4   22  26  12  48  24
2   8   35  21  31  50  49  20  29  17  49  17  3   27
3   19  4   8   27  29  37  25  7   2   2   49  28  20
4   3   50  49  20  17  29  35  39  8   42  41  34  31
5   33  2   12  15  49  49  46  25  39  11  42  38  30
6   12  19  14  38  8   42  5   34  36  29  12  50  25
7   16  48  29  14  41  6   9   3   4   33  12  4   18
8   25  24  4   26  7   45  17  2   47  17  19  3   20
9   47  36  34  24  17  45  3   32  27  15  46  49  31
10  50  15  42  45  13  9   31  10  49  1   30  37  28
1   22  26  32  50  22  30  48  27  19  27  44  19  31
2   27  45  43  7   48  13  43  1   45  8   11  4   25
3   24  4   12  5   10  49  24  16  10  42  46  25  22
4   45  32  21  5   30  5   27  23  4   8   21  23  20
5   38  28  4   8   4   20  36  13  11  14  11  11  17
6   42  46  28  42  46  43  7   8   40  30  33  1   31
7   42  11  37  33  16  27  9   23  42  40  29  35  29
8   40  27  45  24  28  34  4   10  28  16  41  27  27
9   4   4   1   6   8   34  43  48  10  10  37  29  20
10  39  17  18  23  27  32  14  15  8   45  28  40  26

desired output:
    ID  Jan Feb Mrz Apr Mai Jun Jul Aug Sep Okt Nov Dez AnnualMean
1   14  18  17  45  22  31  30  4   22  26  12  48  24
2   -6  17  4   -14 28  18  -10 25  -5  23  5   -45 3
3   11  -31 -13 -4  -21 -12 5   -22 -15 -47 32  25  -7
4   -16 46  41  -7  -12 -8  10  32  6   40  -8  6   11
5   30  -48 -37 -5  32  20  11  -14 31  -31 1   4   -1
6   -21 17  2   23  -41 -7  -41 9   -3  18  -30 12  -5
7   4   29  15  -24 33  -36 4   -31 -32 4   0   -46 -7
8   25  24  4   26  7   45  17  2   47  17  19  3   20
9   22  12  30  -2  10  0   -14 30  -20 -2  27  46  11
10  3   -21 8   21  -4  -36 28  -22 22  -14 -16 -12 -3
1   22  26  32  50  22  30  48  27  19  27  44  19  31
2   5   19  11  -43 26  -17 -5  -26 26  -19 -33 -15 -6
3   -3  -41 -31 -2  -38 36  -19 15  -35 34  35  21  -3
4   21  28  9   0   20  -44 3   7   -6  -34 -25 -2  -2
5   -7  -4  -17 3   -26 15  9   -10 7   6   -10 -12 -3
6   4   18  24  34  42  23  -29 -5  29  16  22  -10 14
7   0   -35 9   -9  -30 -16 2   15  2   10  -4  34  -2
8   40  27  45  24  28  34  4   10  28  16  41  27  27
9   -36 -23 -44 -18 -20 0   39  38  -18 -6  -4  2   -7
10  35  13  17  17  19  -2  -29 -33 -2  35  -9  11  6

A: Update
You have to create a group each time ID is 1 or 8 then apply diff per group. Finally, fill values with original data for each ID 1 and 8:
idx = pd.IndexSlice[:, 'Jan':'AnnualMean']
df.loc[idx] = df.loc[idx].groupby(df['ID'].isin([1, 8]).cumsum()) \
                         .diff().fillna(df).astype(int)

Output:
>>> df
    ID  Jan  Feb  Mrz  Apr  Mai  Jun  Jul  Aug  Sep  Okt  Nov  Dez  AnnualMean
0    1   14   18   17   45   22   31   30    4   22   26   12   48          24
1    2   -6   17    4  -14   28   18  -10   25   -5   23    5  -45           3
2    3   11  -31  -13   -4  -21  -12    5  -22  -15  -47   32   25          -7
3    4  -16   46   41   -7  -12   -8   10   32    6   40   -8    6          11
4    5   30  -48  -37   -5   32   20   11  -14   31  -31    1    4          -1
5    6  -21   17    2   23  -41   -7  -41    9   -3   18  -30   12          -5
6    7    4   29   15  -24   33  -36    4  -31  -32    4    0  -46          -7
7    8   25   24    4   26    7   45   17    2   47   17   19    3          20
8    9   22   12   30   -2   10    0  -14   30  -20   -2   27   46          11
9   10    3  -21    8   21   -4  -36   28  -22   22  -14  -16  -12          -3
10   1   22   26   32   50   22   30   48   27   19   27   44   19          31
11   2    5   19   11  -43   26  -17   -5  -26   26  -19  -33  -15          -6
12   3   -3  -41  -31   -2  -38   36  -19   15  -35   34   35   21          -3
13   4   21   28    9    0   20  -44    3    7   -6  -34  -25   -2          -2
14   5   -7   -4  -17    3  -26   15    9  -10    7    6  -10  -12          -3
15   6    4   18   24   34   42   23  -29   -5   29   16   22  -10          14
16   7    0  -35    9   -9  -30  -16    2   15    2   10   -4   34          -2
17   8   40   27   45   24   28   34    4   10   28   16   41   27          27
18   9  -36  -23  -44  -18  -20    0   39   38  -18   -6   -4    2          -7
19  10   35   13   17   17   19   -2  -29  -33   -2   35   -9   11           6

Old answer
Use where:
>>> df.set_index('ID').where(~df['ID'].between(1, 8), other=df.set_index('ID').diff()).reset_index().fillna(df)

    ID   Jan   Feb   Mrz   Apr   Mai   Jun   Jul   Aug   Sep   Okt   Nov   Dez  AnnualMean
0    1  14.0  18.0  17.0  45.0  22.0  31.0  30.0   4.0  22.0  26.0  12.0  48.0        24.0
1    2  -6.0  17.0   4.0 -14.0  28.0  18.0 -10.0  25.0  -5.0  23.0   5.0 -45.0         3.0
2    3  11.0 -31.0 -13.0  -4.0 -21.0 -12.0   5.0 -22.0 -15.0 -47.0  32.0  25.0        -7.0
3    4 -16.0  46.0  41.0  -7.0 -12.0  -8.0  10.0  32.0   6.0  40.0  -8.0   6.0        11.0
4    5  30.0 -48.0 -37.0  -5.0  32.0  20.0  11.0 -14.0  31.0 -31.0   1.0   4.0        -1.0
5    6 -21.0  17.0   2.0  23.0 -41.0  -7.0 -41.0   9.0  -3.0  18.0 -30.0  12.0        -5.0
6    7   4.0  29.0  15.0 -24.0  33.0 -36.0   4.0 -31.0 -32.0   4.0   0.0 -46.0        -7.0
7    8  25.0  24.0   4.0  26.0   7.0  45.0  17.0   2.0  47.0  17.0  19.0   3.0        20.0
8    9  47.0  36.0  34.0  24.0  17.0  45.0   3.0  32.0  27.0  15.0  46.0  49.0        31.0
9   10   3.0 -21.0   8.0  21.0  -4.0 -36.0  28.0 -22.0  22.0 -14.0 -16.0 -12.0        -3.0
10   1 -28.0  11.0 -10.0   5.0   9.0  21.0  17.0  17.0 -30.0  26.0  14.0 -18.0         3.0
11   2   5.0  19.0  11.0 -43.0  26.0 -17.0  -5.0 -26.0  26.0 -19.0 -33.0 -15.0        -6.0
12   3  -3.0 -41.0 -31.0  -2.0 -38.0  36.0 -19.0  15.0 -35.0  34.0  35.0  21.0        -3.0
13   4  21.0  28.0   9.0   0.0  20.0 -44.0   3.0   7.0  -6.0 -34.0 -25.0  -2.0        -2.0
14   5  -7.0  -4.0 -17.0   3.0 -26.0  15.0   9.0 -10.0   7.0   6.0 -10.0 -12.0        -3.0
15   6   4.0  18.0  24.0  34.0  42.0  23.0 -29.0  -5.0  29.0  16.0  22.0 -10.0        14.0
16   7   0.0 -35.0   9.0  -9.0 -30.0 -16.0   2.0  15.0   2.0  10.0  -4.0  34.0        -2.0
17   8  40.0  27.0  45.0  24.0  28.0  34.0   4.0  10.0  28.0  16.0  41.0  27.0        27.0
18   9   4.0   4.0   1.0   6.0   8.0  34.0  43.0  48.0  10.0  10.0  37.0  29.0        20.0
19  10  35.0  13.0  17.0  17.0  19.0  -2.0 -29.0 -33.0  -2.0  35.0  -9.0  11.0         6.0

Update
According to your comment:
idx = pd.IndexSlice[:, 'Jan':'AnnualMean']
df.loc[idx] = df.loc[idx].where(~df['ID'].between(1, 8), other=df.loc[idx]).diff().fillna(df)

A: You can use loc to select only the rows/columns in which to apply the diff:
rows = df['ID'].between(1,8, inclusive='neither')
cols = df.columns!='ID'
df.loc[rows, cols] = df.diff()

output:
    ID   Jan   Feb   Mrz   Apr   Mai   Jun   Jul   Aug   Sep   Okt   Nov   Dez  AnnualMean
0    1  14.0  18.0  17.0  45.0  22.0  31.0  30.0   4.0  22.0  26.0  12.0  48.0        24.0
1    2  -6.0  17.0   4.0 -14.0  28.0  18.0 -10.0  25.0  -5.0  23.0   5.0 -45.0         3.0
2    3  11.0 -31.0 -13.0  -4.0 -21.0 -12.0   5.0 -22.0 -15.0 -47.0  32.0  25.0        -7.0
3    4 -16.0  46.0  41.0  -7.0 -12.0  -8.0  10.0  32.0   6.0  40.0  -8.0   6.0        11.0
4    5  30.0 -48.0 -37.0  -5.0  32.0  20.0  11.0 -14.0  31.0 -31.0   1.0   4.0        -1.0
5    6 -21.0  17.0   2.0  23.0 -41.0  -7.0 -41.0   9.0  -3.0  18.0 -30.0  12.0        -5.0
6    7   4.0  29.0  15.0 -24.0  33.0 -36.0   4.0 -31.0 -32.0   4.0   0.0 -46.0        -7.0
7    8  25.0  24.0   4.0  26.0   7.0  45.0  17.0   2.0  47.0  17.0  19.0   3.0        20.0
8    9  47.0  36.0  34.0  24.0  17.0  45.0   3.0  32.0  27.0  15.0  46.0  49.0        31.0
9   10  50.0  15.0  42.0  45.0  13.0   9.0  31.0  10.0  49.0   1.0  30.0  37.0        28.0
10   1  22.0  26.0  32.0  50.0  22.0  30.0  48.0  27.0  19.0  27.0  44.0  19.0        31.0
11   2   5.0  19.0  11.0 -43.0  26.0 -17.0  -5.0 -26.0  26.0 -19.0 -33.0 -15.0        -6.0
12   3  -3.0 -41.0 -31.0  -2.0 -38.0  36.0 -19.0  15.0 -35.0  34.0  35.0  21.0        -3.0
13   4  21.0  28.0   9.0   0.0  20.0 -44.0   3.0   7.0  -6.0 -34.0 -25.0  -2.0        -2.0
14   5  -7.0  -4.0 -17.0   3.0 -26.0  15.0   9.0 -10.0   7.0   6.0 -10.0 -12.0        -3.0
15   6   4.0  18.0  24.0  34.0  42.0  23.0 -29.0  -5.0  29.0  16.0  22.0 -10.0        14.0
16   7   0.0 -35.0   9.0  -9.0 -30.0 -16.0   2.0  15.0   2.0  10.0  -4.0  34.0        -2.0
17   8  40.0  27.0  45.0  24.0  28.0  34.0   4.0  10.0  28.0  16.0  41.0  27.0        27.0
18   9   4.0   4.0   1.0   6.0   8.0  34.0  43.0  48.0  10.0  10.0  37.0  29.0        20.0
19  10  39.0  17.0  18.0  23.0  27.0  32.0  14.0  15.0   8.0  45.0  28.0  40.0        26.0


text:
Q: How to extract content coming from an Observable and store it in an Array based on a key? I have the following content:
Location:
lat: 43.252967
lng: 5.379856
__proto__: Object
customerId: "5cd430c65304a21b9464a21a"
id: "5d5a99c62a245117794f1276"
siteId: "5d0ce7c4a06b07213a87a758"
__proto__: Object
1:
Location: {lat: 43.249466, lng: 5.392988}
customerId: "5cd430c65304a21b9464a21a"
id: "5d5ab9472a245117794f1277"
siteId: "5d0ce7c4a06b07213a87a753"
__proto__: Object
2:
Location: {lat: 43.245153, lng: 5.395048}
customerId: "5cd430c65304a21b9464a21a"
id: "5d5ab95d2a245117794f1278"
siteId: "5d0ce7c4a06b07213a87a753"
__proto__: Object

I want to extract lat and lng from this content and store them in the same array and stored this array in an array of arrays. This will define an array per site, containing only lat and lng. One array per site stored in an array containing all the arrays per site.
For this, I have the following code:
   this.customerApi.getPoints(this.currentUser.id)
      .subscribe(response => {
        this.sites = response;
        const ok = this.sites.map(s => s.Location);

        ok.forEach((points) => this.pointsArray.push(points));
        console.log(this.pointsArray);

Unfortunately this gives only one tab and not as much as I have siteIDs like this:
0: {lat: 43.252967, lng: 5.379856}
1: {lat: 43.249466, lng: 5.392988}
2: {lat: 43.245153, lng: 5.395048}
3: {lat: 43.239838, lng: 5.383804}
4: {lat: 44.811343, lng: -0.629233}
5: {lat: 44.807202, lng: -0.614642}
6: {lat: 44.796971, lng: -0.620307}
7: {lat: 44.795266, lng: -0.626272}
length: 8

I would like to have an array of 2 Arrays:
1st:
    0: {lat: 43.252967, lng: 5.379856}
    1: {lat: 43.249466, lng: 5.392988}
    2: {lat: 43.245153, lng: 5.395048}
    3: {lat: 43.239838, lng: 5.383804}

2nd:
1: {lat: 44.811343, lng: -0.629233}
2: {lat: 44.807202, lng: -0.614642}
3: {lat: 44.796971, lng: -0.620307}
4: {lat: 44.795266, lng: -0.626272}

Any help would be really precious here.
I thank you in advance for your help,

A: Assuming that all of your data is stored in a single list, it sounds like you want to somehow group by site before returning. Methods to do this are discussed here: Most efficient method to groupby on an array of objects
Once grouped it will be in the format
{
  "site 1": [
    {
      "Location": {
        "lat": 43.252967,
        "lng": 5.379856
      },
      "siteId": "site 1"
    },
    {
      "Location": {
        "lat": 43.252967,
        "lng": 5.379856
      },
      "siteId": "site 1"
    },
    {
      "Location": {
        "lat": 43.252967,
        "lng": 5.379856
      },
      "siteId": "site 1"
    },
    {
      "Location": {
        "lat": 43.252967,
        "lng": 5.379856
      },
      "siteId": "site 1"
    }
  ],
  "site 2": [
    {
      "Location": {
        "lat": 43.252967,
        "lng": 5.379856
      },
      "siteId": "site 2"
    },
    {
      "Location": {
        "lat": 43.252967,
        "lng": 5.379856
      },
      "siteId": "site 2"
    },
    {
      "Location": {
        "lat": 43.252967,
        "lng": 5.379856
      },
      "siteId": "site 2"
    },
    {
      "Location": {
        "lat": 43.252967,
        "lng": 5.379856
      },
      "siteId": "site 2"
    }
  ]
}

So you will have to do some added manipulation after to extract back into 2 arrays
  getPoints(){
    this.customerApi.getPoints(this.currentUser.id)
      .subscribe(response => {
        this.sites = this._groupBy(response,'siteId');
        const siteArray = Object.keys(this.sites).map(key=>this.sites[key])
        this.pointsArray = siteArray.map(siteMeta=>siteMeta.map(site=>site.Location))
        console.log(this.pointsArray)
      })

  }
  _groupBy(xs,key){
    return xs.reduce(function(rv, x) {
    (rv[x[key]] = rv[x[key]] || []).push(x);
    return rv;
  }, {});
  }

Here is a working stackBlitz: https://stackblitz.com/edit/angular-ad17xq


text:
Q: AJAX передает пустой $_POST Всем доброго дня!
Вызываю из success AJAX`а функции call() функцию saving(msg), с передачей результата первой функции(call), а на выходе(success) второй функции(saving()) $_POST пустой
Вызов функций
function saving(msg){
    var res=msg;
    //$('#res').html(res);            <-----Вот тут передаваемые данные еще есть
    $.ajax({
        type: 'POST',
        url: '/wp-content/themes/II/php/saving.php',
        data: res,
        success: function(data){
            $('#res').html(data);   //<-----А вот тут уже нет
        },
        error:  function(xhr, str){
            alert('Возникла ошибка: ' + xhr.responseCode);//Но эта ошибка не вылезает
        }
    });
    }
    function call() {
    var msg   = $('form').serialize();
    $.ajax({
        type: 'POST',
        url: '/wp-content/themes/II/php/res.php',
        data: msg,
        success: function(data) {
            $('#results').html(data);
            saving(data);
        },
        error:  function(xhr, str){
            alert('Возникла ошибка: ' + xhr.responseCode);
        }
    });
}

При чем во вторую функцию, saving, все приходит как надо. Если это важно то туда приходит достаточно большая (250 строчек) HTML разметка.
PHP второй функции:
<?php
echo "
";
    print_r($_POST);
echo "
";
?>

Вывод DOM:

Array
    (
    )

Вот почему вывод из PHP пустой?


text:
Q: Nonabelian group of order $75$ cannot have a cyclic subgroup of order $25$ I am working through the following problem, and would like to know if my proof is mostly correct:

Let $G$ be a nonabelian group of order $75$ and $H$ a $5$-Sylow subgroup
  of $G$. Show that $H$ is not cyclic. (Hint: Show that the conjugation
  action of $G$ on $H$ is not trivial).

Here is my proof:
Let $\mu:G\times H\to H$ be the group action of conjugation on $H$, i.e. $\mu(g,h)=ghg^{-1}$ for $g\in G$ and $h\in H$. We have that $\ker\mu\unlhd G$, so if $\mu$ is trivial, then this implies that $\ker\mu=G$ and so $G\unlhd G$, which contradicts the fact that $G$ is nonabelian. Note that from $\mu$ we have the associated homomorphism $\phi:G\to\operatorname{Aut}(H)$ and we just showed that $\operatorname{ker}\phi\neq G$.
Let $I$ be a $3$-Sylow subgroup of $G$, and we have the associated homomorphism $\psi:I\to \operatorname{Aut}(H)$ when we let $I$ act on $H$ via conjugation. If $H$ were cyclic, then $H\cong\mathbb Z/25\mathbb Z$ and so $|\operatorname{Aut}(H)|=20$. $|I|$ and $|\operatorname{Aut}(H)|$ are coprime, so $\psi$ must be trivial, implying that $I$ commutes with $H$.
Let $J$ denote the subgroup consisting of $g\in G$ such that $g$ commutes with elements in $H$. Then, $I\leq J$ and so $3$ divides $|J|$ and also $H\leq J$ and so 25 divides $|J|$. $J\leq G$ also, so we get that $|J|=75$ and so $J=C_G(H)=G$. But, from above, we showed that $\operatorname{ker}\phi=C_G(H)\neq G$, so we have a contradiction.
It was not obvious to me how the result followed from the hint, so this is the best thing I could come up with. Thank you for any help or feedback!

A: There are some errors in your proof (which I honestly didn't entirely follow), for example the kernel of $\mu$ is not a subgroup of $G$, but there's one part that solves the whole problem.
Note that if $A$ is a Sylow $3$-subgroup then $AH=G$. Since $H$ is normal, $G$ is a semidirect product $H\rtimes A$. If $A$ acted trivially on $H$ by automorphisms, then $G$ would be abelian because it would be the direct product. As you correctly deduced, if $H$ were cyclic then $A$ would act trivially by order considerations. Thus $H$ is not cyclic.

A: Observe from Sylow's theorems that $n_5=1$, so that there is only one Sylow $5$-subgroup and thus it is normal. Let $P$ be that Sylow subgroup. From the $N/C$ theorem, it follows that $N_G(P)/C_G(P) = G/C_G(P)$ is isomorphic to a subgroup of $\mathrm{Aut}(P)$. If $P$ is cyclic then $\mathrm{Aut}(P) \cong C_{20}$. But $P$ is abelian, so $C_G(P) \geq P$, thus the index of $C_G(P)$ in $G$ is either $1$ or $3$. Therefore, if $P$ is cyclic then $P$ is central in $G$.
You should be able to complete this argument.


text:
Q: Using collections with webapi asp.net mvc 5 I'm having some difficulties adding a collection to a webapi controller:
I have a class "Publications":
public class Publications
{
    public int Id { get; set; }
    public string Title { get; set; }
    public string Description { get; set; }
    public double Price { get; set; }
    public int RoomMates { get; set; }
    public string City { get; set; }
    public string Street { get; set; }
    public string HouseNumber { get; set; }
    public DateTime? AddDate { get; set; }
    public virtual ApplicationUser ApplicationUser { get; set; }
    public virtual ICollection<PublicationFilePath> PublicationFilePaths { get; set; }

}

And a class "PublicationFilePath" containing all filepaths linked to the publications from the class mentioned above:
public class PublicationFilePath
{
    public int PublicationFilePathId { get; set; }
    [StringLength(255)]
    public string FileName { get; set; }
    public FileType FileType { get; set; }
    public virtual Publications Publication { get; set; }
}

I created the following DTO's:
 public class PublicationsDTO
{
    public int Id { get; set; }
    public string Title { get; set; }
    public double Price { get; set; }
    public string City { get; set; }
    public DateTime? AddDate { get; set; }
    public ICollection<PublicationFilePath> PublicationFilePaths { get; set; }

}

public class PublicationsDetailDTO
{

    public int Id { get; set; }
    public string Title { get; set; }

    public double Price { get; set; }
    public int RoomMates { get; set; }
    public string City { get; set; }
    public string Street { get; set; }
    public string HouseNumber { get; set; }
    public DateTime? AddDate { get; set; }
    public string UserID { get; set; }
    public string FirstName { get; set; }
    public string LastName { get; set; }
    public ICollection<PublicationFilePath> PublicationFilePaths { get; set; }

}
public class PublicationsFilePathsDTO
{
    public int PublicationFilePathId { get; set; }
    public string FileName { get; set; }
}

At last this is the GET method from my webapi controller using Automapper:
// GET: api/PublicationsAPI
    public IQueryable<PublicationsDTO> GetPublications()
    {
        Mapper.Initialize(cfg => cfg.CreateMap<Publications, PublicationsDTO>());

        var publications = db.Publications.Include(p => p.PublicationFilePaths).ProjectTo<PublicationsDTO>();

        return publications;
    }

However when running the code and requesting the api I get the following error:
<Error>
<Message>An error has occurred.</Message>
<ExceptionMessage>
The 'ObjectContent`1' type failed to serialize the response body for content type 'application/xml; charset=utf-8'.
</ExceptionMessageExceptionMessage>
<ExceptionType>System.InvalidOperationException</ExceptionType>
<StackTrace />
<InnerException>
<Message>An error has occurred.</Message>
<ExceptionMessage>
Type System.Data.Entity.DynamicProxies.PublicationFilePath_A0D9D29395534E1AFC4F8E51FE41FB7B06CBE02E84BBB7D3C75B4E5DE116D45D met gegevenscontractnaam PublicationFilePath_A0D9D29395534E1AFC4F8E51FE41FB7B06CBE02E84BBB7D3C75B4E5DE116D45D:http://schemas.datacontract.org/2004/07/System.Data.Entity.DynamicProxies wordt niet verwacht. U kunt dit probleem omzeilen door DataContractResolver te gebruiken of door typen die niet bekend zijn op statische wijze aan de lijst met bekende typen toe te voegen, bijvoorbeeld door het kenmerk KnownTypeAttribute te gebruiken of door ze toe te voegen aan de lijst met bekende typen die aan DataContractSerializer worden doorgegeven.
</ExceptionMessage>

I think I'm having problem with the Icollection, please advise on how to continue here.

A: I can agree with Ruard it's an Automapper mapping issue.
You're only mapping Publications to PublicationsDTO.
You should also map PublicationFilePath to PublicationFilePathsDTO.
(Also note you pluralised the word Path to Paths in the DTO)
Configuring nested mappings in AutoMapper is explained in their Wiki-section.
Hope this helps you out.
Greetings
William