问:
Time slider to move automatically using setInterval()
I am trying to make a Mapbox map that would show data chronologically for a given year, and I am trying to make the year be specified automatically in sequence.

However, I am having a problem using setInterval to move the time slider in the following script automatically, and it gives me a [object HTMLLabelElement] without the slider moving.

Am I setting the setInterval to the wrong function?

```<code><!DOCTYPE html>
<html>
<head>
    <meta charset='utf-8' />
    <title></title>
    <meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
    <script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.29.0/mapbox-gl.js'></script>
    <link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.29.0/mapbox-gl.css' rel='stylesheet' />
    <style>
        body { margin:0; padding:0; }
        #map { position:absolute; top:0; bottom:0; width:100%; }
    </style>
</head>
<body>

<style>
.map-overlay {
    font: 12px/20px 'Helvetica Neue', Arial, Helvetica, sans-serif;
    position: absolute;
    width: 25%;
    top: 0;
    left: 0;
    padding: 10px;
}

.map-overlay .map-overlay-inner {
    background-color: #fff;
    box-shadow:0 1px 2px rgba(0, 0, 0, 0.20);
    border-radius: 3px;
    padding: 10px;
    margin-bottom: 10px;
}

.map-overlay h2 {
    line-height: 24px;
    display: block;
    margin: 0 0 10px;
}

.map-overlay input {
    background-color: transparent;
    display: inline-block;
    width: 100%;
    position: relative;
    margin: 0;
    cursor: ew-resize;
}
</style>

<div id='map'></div>

<div class='map-overlay top'>
    <div class='map-overlay-inner'>
        <h2>Tel-Aviv Cinemas 1914-2016</h2>
        <label id='Year'></label>
        <input id='slider' type='range' min='0' max='102' step='1' value='0' />
    </div>
    <div class='map-overlay-inner'></div>
</div>

<script src="https://d3js.org/d3.v4.js"></script>

<script>
mapboxgl.accessToken = 'pk.eyJ1Ijoia3Z5YiIsImEiOiJjaXUwMHEwcmgwMDAxMnlvM3NzMm0xbGozIn0.JL_eeNZL_lDoJxijNqFPoA';
var map = new mapboxgl.Map({
    container: 'map',
    style: 'mapbox://styles/mapbox/dark-v9',
    center: [34.775981, 32.081287],
    zoom: 11
});

var Years = ['1914', '1915', '1916', '1917', '1918', '1919', '1920', '1921', '1922', '1923', '1924', '1925', '1926', '1927', '1928', '1929', '1930', '1931', '1932', '1933', '1934', '1935', '1936', '1937', '1938', '1939', '1940', '1941', '1942', '1943', '1944', '1945', '1946', '1947', '1948', '1949', '1950', '1951', '1952', '1953', '1954', '1955', '1956', '1957', '1958', '1959', '1960', '1961', '1962', '1963', '1964', '1965', '1966', '1967', '1968', '1969', '1970', '1971', '1972', '1973', '1974', '1975', '1976', '1977', '1978', '1979', '1980', '1981', '1982', '1983', '1984', '1985', '1986', '1987', '1988', '1989', '1990', '1991', '1992', '1993', '1994', '1995', '1996', '1997', '1998', '1999', '2000', '2001', '2002', '2003', '2004', '2005', '2006', '2007', '2008', '2009', '2010', '2011', '2012', '2013', '2014', '2015', '2016'];

function filterBy(Year) {
    var filters = ['==', 'Year', Year];
    map.setFilter('cinema-circles', filters);
    map.setFilter('cinema-labels', filters);

    // Set the label to the Year
    document.getElementById('Year').textContent = Year;
}

map.on('load', function() {

    // Data courtesy of https://earthquake.usgs.gov/
    // Query for significant earthquakes in 2015 URL request looked like this:
    // https://earthquake.usgs.gov/fdsnws/event/1/query
    //    ?format=geojson
    //    &starttime=2015-01-01
    //    &endtime=2015-12-31
    //    &minmagnitude=6'
    //
    // Here we're using d3 to help us make the ajax request but you can use
    // Any request method (library or otherwise) you wish.
    d3.json('https://cldex.net/visual/cinema_telaviv.geojson', function(err, data) {
        if (err) throw err;

        // Create a Year property value based on time
        // used to filter against.
        data.features = data.features.map(function(d) {
        return d;
        });

        map.addSource('cinemas', {
            'type': 'geojson',
            'data': data
        });

        map.addLayer({
            'id': 'cinema-circles',
            'type': 'circle',
            'source': 'cinemas',
            'paint': {
                'circle-color': {
            property: 'sqrt',
            stops: [
                [0, '#f1f075'],
                [1500, '#e55e5e']
                ]
                },
                'circle-opacity': 0.75,
                'circle-radius': 20
            }
        });

        map.addLayer({
            'id': 'cinema-labels',
            'type': 'symbol',
            'source': 'cinemas',
            'layout': {
                'text-field': '{Cinema}',
                'text-font': ['Open Sans Bold', 'Arial Unicode MS Bold'],
                'text-size': 12
            },
            'paint': {
                'text-color': 'rgba(0,0,0,0.5)'
            }
        });

        // Set filter to first Year of the Year
        // 0 = 1914
        filterBy(1914);
        document.getElementById('slider').addEventListener('input', function(e) {
              var Year = window.setInterval(function() { parseInt(Years[e.target.value]) }, 1000);
            filterBy(Year);
        });
        // Create a popup, but don't add it to the map yet.
        var popup = new mapboxgl.Popup({
            closeButton: false,
            closeOnClick: false
});

map.on('mousemove', function(e) {
    var features = map.queryRenderedFeatures(e.point, { layers: ['cinema-circles'] });
    // Change the cursor style as a UI indicator.
    map.getCanvas().style.cursor = (features.length) ? 'pointer' : '';

    if (!features.length) {
        popup.remove();
        return;
    }

    var feature = features[0];

    // Populate the popup and set its coordinates
    // based on the feature found.
    popup.setLngLat(feature.geometry.coordinates)
        .setHTML(feature.properties.Cinema+'<b> Cinema Information</b>'+'<br><b>Number: </b>'+feature.properties.Number+'<br><b>Number of Screens: </b>'+feature.properties.Screens+'<br><b>Number of Seats: </b>'+feature.properties.Seatss)
        .addTo(map);
});
});
});
</script>

</body>
</html>
</code>```

My Data can be found in a geojson: https://cldex.net/visual/cinema_telaviv.geojson

答:
@Wakeuphate, this is an awesome solution (up-voted accordingly). I was able to implement quickly for my project.

It seems the missing item was moving the slider as well. I was able to achieve this by simply adding the following line:

```<code>    document.getElementById('slider').value = currentYear;
</code>```

So that the full function looks like:

```<code>var cycleYears = window.setInterval(function() {
        var currentYear = advanceYear();
        filterBy(parseInt(currentYear));
        document.getElementById('slider').value = currentYear;
    }, 1000);
</code>```

Body:
I am trying to make a Mapbox map that would show data chronologically for a given year, and I am trying to make the year be specified automatically in sequence.

However, I am having a problem using setInterval to move the time slider in the following script automatically, and it gives me a [object HTMLLabelElement] without the slider moving.

Am I setting the setInterval to the wrong function?

<!DOCTYPE html>

    <meta charset='utf-8' />
    <title></title>
    <meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />

    <link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.29.0/mapbox-gl.css' rel='stylesheet' />

Tel-Aviv Cinemas 1914-2016

        <input id='slider' type='range' min='0' max='102' step='1' value='0' />

My Data can be found in a geojson: https://cldex.net/visual/cinema_telaviv.geojson

Body:
@Wakeuphate, this is an awesome solution (up-voted accordingly). I was able to implement quickly for my project.

It seems the missing item was moving the slider as well. I was able to achieve this by simply adding the following line:

    document.getElementById('slider').value = currentYear;

So that the full function looks like:

var cycleYears = window.setInterval(function() {
        var currentYear = advanceYear();
        filterBy(parseInt(currentYear));
        document.getElementById('slider').value = currentYear;
    }, 1000);


来源: stackexchange

问:
How do I use radio buttons in c# to change a displayed image?
I've got three images saved in my project, 1.jpg 2.jpg and 3.jpg and a picture box that currently displays nothing. I also have three radio buttons. What I'm trying to do is when I click radio button one, the picture box displays 1.jpg, when I click radio button 2, 2.jpg displays and so on.

I'm trying to get some code that looks something like this ..

```<code>private void imageOne_CheckedChanged(object sender, EventArgs e)
        {
            imageContainer.Image = "1.jgp";
        }
</code>```

But I get an error saying I can't convert a string to a System.Drawing.Image

What is the correct way of approaching this?

答:
Import the images to resource folder
Then load the picture from Resouce

```<code> PictureBox.Image = Properties.Resources._2;
</code>```

In your code file,

```<code>private void imageOne_CheckedChanged(object sender, EventArgs e)
        {
            imageContainer.Image = Properties.Resources._2;
        }
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I've got three images saved in my project, 1.jpg 2.jpg and 3.jpg and a picture box that currently displays nothing. I also have three radio buttons. What I'm trying to do is when I click radio button one, the picture box displays 1.jpg, when I click radio button 2, 2.jpg displays and so on.

I'm trying to get some code that looks something like this ..

private void imageOne_CheckedChanged(object sender, EventArgs e)
        {
            imageContainer.Image = "1.jgp";
        }

But I get an error saying I can't convert a string to a System.Drawing.Image

What is the correct way of approaching this?

Body:
Import the images to resource folder
Then load the picture from Resouce

 PictureBox.Image = Properties.Resources._2;

In your code file,

private void imageOne_CheckedChanged(object sender, EventArgs e)
        {
            imageContainer.Image = Properties.Resources._2;
        }


问:
How to remove first character from C-string?
Can anyone please help me? I need to remove the first character from a char * in C.

For example,  char * contents contains a '\n' character as the first character in the array.  I need to detect and eliminate this character, modifying the original variable after its been "sanitized".

Can anyone help me with the code? I'm completely new to C, and just can't seem to figure it out.

答:
It sounds as if you're under the impression that a char* "contains" characters. It does not. It merely points at a byte. The rest of the string is implied to consist of the subsequent byte in memory up until the next null byte. (You should also be aware that although the 'char' data type is a byte, by definition, it is not really a character - please be aware of Unicode - and nor is a byte necessarily an octet.)

The char* is not an array, either, although there may exist an array of characters such that the pointer is pointing to the beginning of that array.

ContentLicense: CC BY-SA 2.5


问:
react-intl: Missing locale data for locale: "undefined". Using default locale: "en" as fallback
I'm using React v15.4, react-intl v2.2.3

In my /lang/en.json :

```<code>{
  "greeting": "Hello, World!"
}
</code>```

And my /pages/about.js :

```<code>import React from 'react'
import {FormattedMessage} from 'react-intl'
import pageWithIntl from '../components/PageWithIntl'
import Layout from '../components/Layout'

export default pageWithIntl(({intl}) => (
  <Layout>
    <h1 className="page-title">About Page</h1>
    <p>
      <FormattedMessage id='greeting' defaultMessage='Hello, World!' />
    </p>
  </Layout>
))
</code>```

When I load the page the "Hello, World!" - Text is correctly displayed.
But in the console I'm getting

[React Intl] Missing locale data for locale: "undefined". Using
  default locale: "en" as fallback.

When I reload the page. How can I add the missing locale data?

答:
You should wrap you main component (usually it named <App/ >) into <IntlProvider> middleware and set locale prop.

```<code><IntlProvider locale='en'>
   <App/ >
</ IntlProvider>
</code>```

or React automatically set locale: 'en' and throw you warning

[React Intl] Missing locale data for locale: "undefined". Using
  default locale: "en" as fallback.

Body:
I'm using React v15.4, react-intl v2.2.3

In my /lang/en.json :

{
  "greeting": "Hello, World!"
}

And my /pages/about.js :

import React from 'react'
import {FormattedMessage} from 'react-intl'
import pageWithIntl from '../components/PageWithIntl'
import Layout from '../components/Layout'

export default pageWithIntl(({intl}) => (
  <Layout>

About Page

      <FormattedMessage id='greeting' defaultMessage='Hello, World!' />

  </Layout>
))

When I load the page the "Hello, World!" - Text is correctly displayed.
But in the console I'm getting

[React Intl] Missing locale data for locale: "undefined". Using
  default locale: "en" as fallback.

When I reload the page. How can I add the missing locale data?

Body:
You should wrap you main component (usually it named <App/ >) into <IntlProvider> middleware and set locale prop.

<IntlProvider locale='en'>
   <App/ >
</ IntlProvider>

or React automatically set locale: 'en' and throw you warning

[React Intl] Missing locale data for locale: "undefined". Using
  default locale: "en" as fallback.


问:
com.jcraft.jsch.JSchException: Algorithm negotiation fail + mulesoft
I am executing following mulesoft code for FTP to File transfer.
Got source code from here :
read file from SFTP and dump to local folder using mulesoft

```<code><mule xmlns="http://www.mulesoft.org/schema/mule/core"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:sftp="http://www.mulesoft.org/schema/mule/sftp"
  xmlns:file="http://www.mulesoft.org/schema/mule/file"
  xmlns:spring="http://www.springframework.org/schema/beans"
  xsi:schemaLocation="
      http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
      http://www.mulesoft.org/schema/mule/sftp http://www.mulesoft.org/schema/mule/sftp/current/mule-sftp.xsd
      http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
      http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd">

<!-- This placeholder bean lets you import the properties from the sftp.properties file. -->
<spring:bean id="property-placeholder" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <spring:property name="location" value="classpath:sftp.properties"/>
</spring:bean>

<flow name="sftp2file">
    <sftp:inbound-endpoint host="${sftp.host}" port="${sftp.port}" path="/home/test/sftp-files" user="${sftp.user}" password="${sftp.password}">
                <file:filename-wildcard-filter pattern="*.txt,*.xml"/>
            </sftp:inbound-endpoint>
    <file:outbound-endpoint path="/tmp/incoming" outputPattern="#[message.inboundProperties.originalFilename]"/>
</flow>
</code>```

But I am getting following error :

```<code>    INFO  2017-03-29 18:43:20,877 [main] org.mule.transport.sftp.SftpConnector: Registering listener: sftp2file on endpointUri: sftp://{user}:****@{host}:22/incoming/test
INFO  2017-03-29 18:43:20,940 [main] org.mule.lifecycle.AbstractLifecycleManager: Initialising: 'null'. Object is: SftpMessageReceiver
INFO  2017-03-29 18:43:20,942 [main] org.mule.transport.sftp.SftpMessageReceiver: Connecting clusterizable message receiver
ERROR 2017-03-29 18:43:21,965 [main] org.mule.transport.sftp.SftpClient: Error during login to {user}@{host}
com.jcraft.jsch.JSchException: Algorithm negotiation fail
    at com.jcraft.jsch.Session.receive_kexinit(Session.java:583) ~[jsch-0.1.51.jar:?]
    at com.jcraft.jsch.Session.connect(Session.java:320) ~[jsch-0.1.51.jar:?]
    at com.jcraft.jsch.Session.connect(Session.java:183) ~[jsch-0.1.51.jar:?]
    at org.mule.transport.sftp.SftpClient.login(SftpClient.java:147) ~[mule-transport-sftp-3.8.3.jar:3.8.3]
    at org.mule.transport.sftp.SftpConnectionFactory.createClient(SftpConnectionFactory.java:116) ~[mule-transport-sftp-3.8.3.jar:3.8.3]
    at org.mule.transport.sftp.SftpConnector.createSftpClient(SftpConnector.java:195) ~[mule-transport-sftp-3.8.3.jar:3.8.3]
    at org.mule.transport.sftp.SftpConnector.createSftpClient(SftpConnector.java:178) ~[mule-transport-sftp-3.8.3.jar:3.8.3]
    at org.mule.transport.sftp.SftpReceiverRequesterUtil.getAvailableFiles(SftpReceiverRequesterUtil.java:72) ~[mule-transport-sftp-3.8.3.jar:3.8.3]
    at org.mule.transport.sftp.SftpMessageReceiver$2.doWork(SftpMessageReceiver.java:291) ~[mule-transport-sftp-3.8.3.jar:3.8.3]
    at org.mule.retry.policies.AbstractPolicyTemplate.execute(AbstractPolicyTemplate.java:63) ~[mule-core-3.8.3.jar:3.8.3]
    at org.mule.transport.sftp.SftpMessageReceiver.doConnect(SftpMessageReceiver.java:280) ~[mule-transport-sftp-3.8.3.jar:3.8.3]
    at org.mule.transport.AbstractMessageReceiver.connectHandler(AbstractMessageReceiver.java:448) ~[mule-core-3.8.3.jar:3.8.3]
    at org.mule.transport.AbstractTransportMessageHandler.connect(AbstractTransportMessageHandler.java:217) ~[mule-core-3.8.3.jar:3.8.3]
    at org.mule.transport.AbstractConnector.registerListener(AbstractConnector.java:1299) ~[mule-core-3.8.3.jar:3.8.3]
    at org.mule.endpoint.DefaultInboundEndpoint.start(DefaultInboundEndpoint.java:105) ~[mule-core-3.8.3.jar:3.8.3]
    at org.mule.api.lifecycle.LifecycleUtils.startIfNeeded(LifecycleUtils.java:92) ~[mule-core-3.8.3.jar:3.8.3]
    at org.mule.DefaultMuleContext.startMessageSource(DefaultMuleContext.java:381) ~[mule-core-3.8.3.jar:3.8.3]
    at org.mule.DefaultMuleContext.startPipelineMessageSources(DefaultMuleContext.java:372) ~[mule-core-3.8.3.jar:3.8.3]
    at org.mule.DefaultMuleContext.startMessageSources(DefaultMuleContext.java:335) ~[mule-core-3.8.3.jar:3.8.3]
    at org.mule.DefaultMuleContext.start(DefaultMuleContext.java:320) ~[mule-core-3.8.3.jar:3.8.3]
    at org.mule.module.launcher.application.DefaultMuleApplication.start(DefaultMuleApplication.java:139) ~[mule-module-launcher-3.8.3.jar:3.8.3]
    at org.mule.module.launcher.artifact.ArtifactWrapper$4.execute(ArtifactWrapper.java:105) ~[mule-module-launcher-3.8.3.jar:3.8.3]
    at org.mule.module.launcher.artifact.ArtifactWrapper.executeWithinArtifactClassLoader(ArtifactWrapper.java:136) ~[mule-module-launcher-3.8.3.jar:3.8.3]
    at org.mule.module.launcher.artifact.ArtifactWrapper.start(ArtifactWrapper.java:100) ~[mule-module-launcher-3.8.3.jar:3.8.3]
    at org.mule.module.launcher.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:26) ~[mule-module-launcher-3.8.3.jar:3.8.3]
    at org.mule.module.launcher.DefaultArchiveDeployer.deployArtifact(DefaultArchiveDeployer.java:309) ~[mule-module-launcher-3.8.3.jar:3.8.3]
    at org.mule.module.launcher.DefaultArchiveDeployer.deployPackagedArtifact(DefaultArchiveDeployer.java:164) ~[mule-module-launcher-3.8.3.jar:3.8.3]
    at org.mule.module.launcher.DefaultArchiveDeployer.deployPackagedArtifact(DefaultArchiveDeployer.java:253) ~[mule-module-launcher-3.8.3.jar:3.8.3]
    at org.mule.module.launcher.DefaultArchiveDeployer.deployPackagedArtifact(DefaultArchiveDeployer.java:75) ~[mule-module-launcher-3.8.3.jar:3.8.3]
    at org.mule.module.launcher.DeploymentDirectoryWatcher.deployPackedApps(DeploymentDirectoryWatcher.java:278) ~[mule-module-launcher-3.8.3.jar:3.8.3]
    at org.mule.module.launcher.DeploymentDirectoryWatcher.start(DeploymentDirectoryWatcher.java:150) ~[mule-module-launcher-3.8.3.jar:3.8.3]
    at org.mule.module.launcher.MuleDeploymentService.start(MuleDeploymentService.java:134) ~[mule-module-launcher-3.8.3.jar:3.8.3]
    at org.mule.module.launcher.MuleContainer.start(MuleContainer.java:172) ~[mule-module-launcher-3.8.3.jar:3.8.3]
    at org.mule.tooling.server.application.ApplicationDeployer.main(ApplicationDeployer.java:15) ~[tooling-support-3.8.3.jar:?]
ERROR 2017-03-29 18:43:21,969 [main] org.mule.retry.notifiers.ConnectNotifier: Failed to connect/reconnect: Trying to reconnect to SFTP server sftp://{user}:****@{host}:22/incoming/test. Root Exception was: Error during login to {user}@{host}: Algorithm negotiation fail. Type: class java.io.IOException
ERROR 2017-03-29 18:43:21,971 [main] org.mule.module.launcher.application.DefaultMuleApplication: Failed to start inbound endpoint "endpoint.sftp.{host}.22.incoming.test"
INFO  2017-03-29 18:43:21,978 [main] org.mule.module.launcher.application.DefaultMuleApplication:
</code>```

Is there a way to configure inbound SFTP which will handle SSH issues?

答:
have you read this answer to your other question?

SFTP component uses jsch under the hood. The documentation for jsch states following:

JSch is in pure Java, but it depends on JavaTM Cryptography Extension
  (JCE)

here is a short description on how to install JCE.

Body:
I am executing following mulesoft code for FTP to File transfer.
Got source code from here :
read file from SFTP and dump to local folder using mulesoft

<mule xmlns="http://www.mulesoft.org/schema/mule/core"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:sftp="http://www.mulesoft.org/schema/mule/sftp"
  xmlns:file="http://www.mulesoft.org/schema/mule/file"
  xmlns:spring="http://www.springframework.org/schema/beans"
  xsi:schemaLocation="
      http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
      http://www.mulesoft.org/schema/mule/sftp http://www.mulesoft.org/schema/mule/sftp/current/mule-sftp.xsd
      http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
      http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd">

<spring:bean id="property-placeholder" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <spring:property name="location" value="classpath:sftp.properties"/>
</spring:bean>

<flow name="sftp2file">
    <sftp:inbound-endpoint host="${sftp.host}" port="${sftp.port}" path="/home/test/sftp-files" user="${sftp.user}" password="${sftp.password}">
                <file:filename-wildcard-filter pattern="*.txt,*.xml"/>
            </sftp:inbound-endpoint>
    <file:outbound-endpoint path="/tmp/incoming" outputPattern="#[message.inboundProperties.originalFilename]"/>
</flow>

But I am getting following error :

    INFO  2017-03-29 18:43:20,877 [main] org.mule.transport.sftp.SftpConnector: Registering listener: sftp2file on endpointUri: sftp://{user}:****@{host}:22/incoming/test
INFO  2017-03-29 18:43:20,940 [main] org.mule.lifecycle.AbstractLifecycleManager: Initialising: 'null'. Object is: SftpMessageReceiver
INFO  2017-03-29 18:43:20,942 [main] org.mule.transport.sftp.SftpMessageReceiver: Connecting clusterizable message receiver
ERROR 2017-03-29 18:43:21,965 [main] org.mule.transport.sftp.SftpClient: Error during login to {user}@{host}
com.jcraft.jsch.JSchException: Algorithm negotiation fail
    at com.jcraft.jsch.Session.receive_kexinit(Session.java:583) ~[jsch-0.1.51.jar:?]
    at com.jcraft.jsch.Session.connect(Session.java:320) ~[jsch-0.1.51.jar:?]
    at com.jcraft.jsch.Session.connect(Session.java:183) ~[jsch-0.1.51.jar:?]
    at org.mule.transport.sftp.SftpClient.login(SftpClient.java:147) ~[mule-transport-sftp-3.8.3.jar:3.8.3]
    at org.mule.transport.sftp.SftpConnectionFactory.createClient(SftpConnectionFactory.java:116) ~[mule-transport-sftp-3.8.3.jar:3.8.3]
    at org.mule.transport.sftp.SftpConnector.createSftpClient(SftpConnector.java:195) ~[mule-transport-sftp-3.8.3.jar:3.8.3]
    at org.mule.transport.sftp.SftpConnector.createSftpClient(SftpConnector.java:178) ~[mule-transport-sftp-3.8.3.jar:3.8.3]
    at org.mule.transport.sftp.SftpReceiverRequesterUtil.getAvailableFiles(SftpReceiverRequesterUtil.java:72) ~[mule-transport-sftp-3.8.3.jar:3.8.3]
    at org.mule.transport.sftp.SftpMessageReceiver$2.doWork(SftpMessageReceiver.java:291) ~[mule-transport-sftp-3.8.3.jar:3.8.3]
    at org.mule.retry.policies.AbstractPolicyTemplate.execute(AbstractPolicyTemplate.java:63) ~[mule-core-3.8.3.jar:3.8.3]
    at org.mule.transport.sftp.SftpMessageReceiver.doConnect(SftpMessageReceiver.java:280) ~[mule-transport-sftp-3.8.3.jar:3.8.3]
    at org.mule.transport.AbstractMessageReceiver.connectHandler(AbstractMessageReceiver.java:448) ~[mule-core-3.8.3.jar:3.8.3]
    at org.mule.transport.AbstractTransportMessageHandler.connect(AbstractTransportMessageHandler.java:217) ~[mule-core-3.8.3.jar:3.8.3]
    at org.mule.transport.AbstractConnector.registerListener(AbstractConnector.java:1299) ~[mule-core-3.8.3.jar:3.8.3]
    at org.mule.endpoint.DefaultInboundEndpoint.start(DefaultInboundEndpoint.java:105) ~[mule-core-3.8.3.jar:3.8.3]
    at org.mule.api.lifecycle.LifecycleUtils.startIfNeeded(LifecycleUtils.java:92) ~[mule-core-3.8.3.jar:3.8.3]
    at org.mule.DefaultMuleContext.startMessageSource(DefaultMuleContext.java:381) ~[mule-core-3.8.3.jar:3.8.3]
    at org.mule.DefaultMuleContext.startPipelineMessageSources(DefaultMuleContext.java:372) ~[mule-core-3.8.3.jar:3.8.3]
    at org.mule.DefaultMuleContext.startMessageSources(DefaultMuleContext.java:335) ~[mule-core-3.8.3.jar:3.8.3]
    at org.mule.DefaultMuleContext.start(DefaultMuleContext.java:320) ~[mule-core-3.8.3.jar:3.8.3]
    at org.mule.module.launcher.application.DefaultMuleApplication.start(DefaultMuleApplication.java:139) ~[mule-module-launcher-3.8.3.jar:3.8.3]
    at org.mule.module.launcher.artifact.ArtifactWrapper$4.execute(ArtifactWrapper.java:105) ~[mule-module-launcher-3.8.3.jar:3.8.3]
    at org.mule.module.launcher.artifact.ArtifactWrapper.executeWithinArtifactClassLoader(ArtifactWrapper.java:136) ~[mule-module-launcher-3.8.3.jar:3.8.3]
    at org.mule.module.launcher.artifact.ArtifactWrapper.start(ArtifactWrapper.java:100) ~[mule-module-launcher-3.8.3.jar:3.8.3]
    at org.mule.module.launcher.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:26) ~[mule-module-launcher-3.8.3.jar:3.8.3]
    at org.mule.module.launcher.DefaultArchiveDeployer.deployArtifact(DefaultArchiveDeployer.java:309) ~[mule-module-launcher-3.8.3.jar:3.8.3]
    at org.mule.module.launcher.DefaultArchiveDeployer.deployPackagedArtifact(DefaultArchiveDeployer.java:164) ~[mule-module-launcher-3.8.3.jar:3.8.3]
    at org.mule.module.launcher.DefaultArchiveDeployer.deployPackagedArtifact(DefaultArchiveDeployer.java:253) ~[mule-module-launcher-3.8.3.jar:3.8.3]
    at org.mule.module.launcher.DefaultArchiveDeployer.deployPackagedArtifact(DefaultArchiveDeployer.java:75) ~[mule-module-launcher-3.8.3.jar:3.8.3]
    at org.mule.module.launcher.DeploymentDirectoryWatcher.deployPackedApps(DeploymentDirectoryWatcher.java:278) ~[mule-module-launcher-3.8.3.jar:3.8.3]
    at org.mule.module.launcher.DeploymentDirectoryWatcher.start(DeploymentDirectoryWatcher.java:150) ~[mule-module-launcher-3.8.3.jar:3.8.3]
    at org.mule.module.launcher.MuleDeploymentService.start(MuleDeploymentService.java:134) ~[mule-module-launcher-3.8.3.jar:3.8.3]
    at org.mule.module.launcher.MuleContainer.start(MuleContainer.java:172) ~[mule-module-launcher-3.8.3.jar:3.8.3]
    at org.mule.tooling.server.application.ApplicationDeployer.main(ApplicationDeployer.java:15) ~[tooling-support-3.8.3.jar:?]
ERROR 2017-03-29 18:43:21,969 [main] org.mule.retry.notifiers.ConnectNotifier: Failed to connect/reconnect: Trying to reconnect to SFTP server sftp://{user}:****@{host}:22/incoming/test. Root Exception was: Error during login to {user}@{host}: Algorithm negotiation fail. Type: class java.io.IOException
ERROR 2017-03-29 18:43:21,971 [main] org.mule.module.launcher.application.DefaultMuleApplication: Failed to start inbound endpoint "endpoint.sftp.{host}.22.incoming.test"
INFO  2017-03-29 18:43:21,978 [main] org.mule.module.launcher.application.DefaultMuleApplication:

Is there a way to configure inbound SFTP which will handle SSH issues?


问:
Jsoup is not Correctly Working
Hello guys i have an problem by Jsoup it is not working and i have no idea to figured it out here is the Code

```<code>    private void getWebsite() {
    Document doc = null;
    try {
        doc = Jsoup.connect("http://www.jean-clermont-schule.de/seite/90384/vertretungsplan.html").get();
        Elements newsHeadlines = doc.select("content");
    } catch (IOException e) {
        e.printStackTrace();
    }
}
</code>```

And here is an Picture

答:
I am unable to add comment above.

I think that the code line Elements newsHeadlines = doc.select("content"); is wrong because content isn't tag for this link.

You must provide tag name with attribute and value being optional while using .select("");

You may try Elements newsHeadlines = doc.select("div[id=content]");

Title: Jsoup is not Correctly Working

Body:
Hello guys i have an problem by Jsoup it is not working and i have no idea to figured it out here is the Code

    private void getWebsite() {
    Document doc = null;
    try {
        doc = Jsoup.connect("http://www.jean-clermont-schule.de/seite/90384/vertretungsplan.html").get();
        Elements newsHeadlines = doc.select("content");
    } catch (IOException e) {
        e.printStackTrace();
    }
}

And here is an Picture


问:
UE4 Enabling Mouse During Play?
I'm extremely new to UE, and doing a few easy tutorials to get started, so I don't exactly know the correct terminology to use to help me find what I am looking for... Anyway, whenever I hit play and the game starts, my mouse disappears and I am only able to use the input that I set up; so my question is, even though I do not need mouse input for movement, as I am using WASD, how do I keep my mouse unlocked and available to move around without being locked to the camera?</p>

答:
When you hit play and the game starts, your mouse gets captured by the game to control the camera.  If your play button is set to play in the viewport, you can release the mouse from the viewport by pressing Shift-F1.  The game will still be running, but input (including from the keyboard) will be suspended and you can interact with the editor.

You can also change the default behavior of how the mouse is captured and it if is constrained to the viewport boundaries.  To see these options, go into the project settings (settings button above main viewport/project settings...).  On the left side of the project settings window, select 'Input' under the Engine heading.  On the right side will be some mouse preferences that can change its behavior.

For instance, to allow the mouse to travel outside the viewport, change 'Default Viewport Mouse Lock Mode' to 'Do Not Lock'.  I don't recommend this, but you might experiment with these to get a feel for what they do.  Also, you might look up these settings in the Unreal documentation for more detail.

Title: UE4 Enabling Mouse During Play?


问:
Filtering text in NSTableView
I have an NSTableView in which I need to be able to intercept keyboard events within an editable cell and replace the cell with strings.  For example, press "a" and have the "a" intercepted and the value "Alpha" assigned when the table reloads.  The actual situation is a bit more complex in that I'm also handling HID devices, but that's a whole other story.  Suffice it to say, I just want to be able to go into edit mode and stop the keyboard-generated values from being displayed.

The latter part of this (displaying "Alpha") is easy, but I can't figure out the first part of the problem.  If I subclass the table and make it first responder, I can receive the keyDown: event, but once the user double-clicks on a cell and starts typing, this goes silent.

Since none of the other NSTableView components (NSCell, NSTextFieldCell, etc) derive from NSResponder, I'm assuming there is an NSTextField buried in there somewhere.

So, what's the best way to filter text once the user goes into cell edit mode?

答:
As always happens: after working on this for eight hours, reading all the docs five times, and then resorting to the net, I find the answer five minutes later:

```<code>- (BOOL)textShouldBeginEditing:(NSText *)textObject.
</code>```

Sorry to consume bandwidth.

Title: Filtering text in NSTableView

Body:
As always happens: after working on this for eight hours, reading all the docs five times, and then resorting to the net, I find the answer five minutes later:

- (BOOL)textShouldBeginEditing:(NSText *)textObject.

Sorry to consume bandwidth.


问:
How to group similar GTFS trips
I need to group GTFS trips to human understandable "route variants". As one route can have run different trips based on day/time etc.

Is there any preferred way to group similar trips? Trip shape_id looks promising, but is there any guarantee that all similar trips has same shape_id?

My GTFS data is imported my sql database and the database structure is the same as GTFS txt files.

UPDATE
Im not looking sql query example, im looking high level example how to group similar trips to user friendly "route variants".

Many route planning apps (like Moovit) use GTFS data as source and they display different route variants to users.

答:
There is no official way to do this. The best way is probably to group by the ordered list of stops on each trip, sometimes known as the "stopping pattern" of the trip. The idea is discussed at a conceptual level here by Mapzen.

In practice, I have created concatenated strings of all stops on a given trip (from stop_times), and grouped by that to define similar trips. E.g., if the stops on a given trip are A, B, C, D, and E, create a string A-B-C-D-E or A_B_C_D_E and group trips on that string. This functionality is not part of the SQL spec, although MySQL implements it as GROUP_CONCAT and PostgreSQL uses arrays and array_to_string. You may also want to add route_id and shape_id into the grouping as well, to handle some corner cases.

Title: How to group similar GTFS trips


问:
matplotlib negative numbers on tick labels displayed as boxes
I'm using matplotlib to generate plots for a report and specifying my own style sheet to specify text formatting to comply with a specified document style for a report. In my .mplstyle stylesheet I'm specifying the font family as follows:

font.family : Tw Cen MT

This works fine so far for everything except when I have tick labels with negative numbers. For negative numbers on the tick labels the minus sign gets displayed as a box with this font. With the default font family it works correctly, but I need to use the Tw Cen MT font family.

Is there a way to use the Tw Cen MT font family in a way that correctly displays negative numbers?

Alternatively, is there a way to specify a different font just for the tick labels.

In my Python script I'm setting the ticks as follows:
ax2.set_yticks([-3, -2, -1, 0, 1, 2, 3], minor=False)

答:
The font you are using possibly does not have the unicode minus sign implemented.

While i would strongly recomment not to use a font without basic unicode signs, you may get around this problem by using a normal hyphen instead.

In your mplstyle file add the line

```<code>axes.unicode_minus  : False
</code>```

or use

```<code>plt.rcParams['axes.unicode_minus'] = False
</code>```

as in the linked example.

Body:
The font you are using possibly does not have the unicode minus sign implemented.

While i would strongly recomment not to use a font without basic unicode signs, you may get around this problem by using a normal hyphen instead.

In your mplstyle file add the line

axes.unicode_minus  : False

or use

plt.rcParams['axes.unicode_minus'] = False

as in the linked example.


问:
Combine two mysql queries with uneven columns
I have two mysql queries that I'd like to combine. I'm shame-posting here as I've tried many combinations to make it work but can't figure it out. I guess I've hit a ceiling in my query writing abilities. :(

Query #1

```<code>        SELECT
        time_clock.id AS clock_id,
        employees.first_name, employees.last_name, employees.nick_name, employees.pay_schedule, time_clock.comments,
        employees.id AS employee_id, time_clock.punch_in,
        UNIX_TIMESTAMP(time_clock.punch_in) AS punch_in_unix,
        UNIX_TIMESTAMP(time_clock.punch_out) AS punch_out_unix,
        TIMESTAMPDIFF(MINUTE, time_clock.punch_in, time_clock.punch_out) AS time_spent
        FROM time_clock
        JOIN employees ON employees.id = time_clock.employee_id
        WHERE time_clock.id IN
            (
            SELECT MAX(time_clock.id)
            FROM time_clock
            WHERE employees.pay_schedule='hourly'
            GROUP BY employee_id
            )
        ORDER BY last_name, first_name ASC
</code>```

Query #2

```<code>        SELECT
        employees.first_name, employees.last_name,
        employees.id AS employee_id,
        SUM(TIME_TO_SEC(time_clock.punch_out) - TIME_TO_SEC(time_clock.punch_in)) AS summed_seconds
        FROM time_clock
        JOIN employees ON employees.id = time_clock.employee_id
        WHERE YEAR(punch_in + interval 4 day) = YEAR(CURDATE()) AND
        WEEK(punch_in + interval 4 day) = WEEK(CURDATE())
        GROUP BY employee_id
</code>```

Each query functions fine on its own. The first query selects the latest time event for each employee. The second query sums the recorded time for each employee in the last pay period (weekly, from Wed. to Tues.).

I'd love to have one query do both: Select the latest time event for each employee and sum the time for those with time recorded in the last pay period. (I'm doing this to present an interface for keeping track of which employees are on overtime.)

Any help I can get would be fantastic. I've also been exploring combining the results as arrays in php to get what I want but that presents its own set of problems for me and I suspect isn't as efficient.

The output of Query #1 is like so:

The output of Query #2 looks like:

And this is essentially the output I'd like to be able to have:

Thank you for any help you can offer. My forehead is denting faster than the desk I'm banging it on.

-Matt

PS - One of my attempts to combine them is below. It seems to produce the most sane error out of all my attempts ("The used SELECT statements have a different number of columns"), so I don't know how close it really is.

```<code>SELECT
        time_clock.id AS clock_id,
        employees.first_name, employees.last_name, employees.nick_name, employees.pay_schedule, time_clock.comments,
        employees.id AS employee_id, time_clock.punch_in,
        UNIX_TIMESTAMP(time_clock.punch_in) AS punch_in_unix,
        UNIX_TIMESTAMP(time_clock.punch_out) AS punch_out_unix,
        TIMESTAMPDIFF(MINUTE, time_clock.punch_in, time_clock.punch_out) AS time_spent
        FROM (
            SELECT *
            FROM time_clock
            LEFT JOIN employees ON employees.id = time_clock.employee_id
            WHERE time_clock.id IN
                (
                SELECT MAX(time_clock.id)
                FROM time_clock
                WHERE employees.pay_schedule='hourly'
                GROUP BY employee_id
                )

            UNION ALL

            SELECT
                employees.first_name, employees.last_name,
                employees.id AS employee_id,
                SUM(TIME_TO_SEC(time_clock.punch_out) - TIME_TO_SEC(time_clock.punch_in)) AS summed_seconds
                FROM time_clock
                LEFT JOIN employees ON employees.id = time_clock.employee_id
                WHERE YEAR(punch_in + interval 4 day) = YEAR(CURDATE()) AND
                      WEEK(punch_in + interval 4 day) = WEEK(CURDATE())
                GROUP BY employee_id
                ) as thing_one
        JOIN employees ON employees.id = time_clock.employee_id
        ORDER BY last_name, first_name ASC
</code>```

答:
Just join both the queries using employee_id</p>

```<code>SELECT clock_id,
table1.first_name,
table1.last_name,
nick_name,
pay_schedule,
comments,
table1.employee_id,
punch_in,
punch_in_unix,
punch_out_unix,
time_spent,
summed_seconds
(SELECT
        time_clock.id AS clock_id,
        employees.first_name, employees.last_name, employees.nick_name, employees.pay_schedule, time_clock.comments,
        employees.id AS employee_id, time_clock.punch_in,
        UNIX_TIMESTAMP(time_clock.punch_in) AS punch_in_unix,
        UNIX_TIMESTAMP(time_clock.punch_out) AS punch_out_unix,
        TIMESTAMPDIFF(MINUTE, time_clock.punch_in, time_clock.punch_out) AS time_spent
        FROM time_clock
        JOIN employees ON employees.id = time_clock.employee_id
        WHERE time_clock.id IN
            (
            SELECT MAX(time_clock.id)
            FROM time_clock
            WHERE employees.pay_schedule='hourly'
            GROUP BY employee_id
            )) as table1,

(SELECT
        employees.first_name, employees.last_name,
        employees.id AS employee_id,
        SUM(TIME_TO_SEC(time_clock.punch_out) - TIME_TO_SEC(time_clock.punch_in)) AS summed_seconds
        FROM time_clock
        JOIN employees ON employees.id = time_clock.employee_id
        WHERE YEAR(punch_in + interval 4 day) = YEAR(CURDATE()) AND
        WEEK(punch_in + interval 4 day) = WEEK(CURDATE())
        GROUP BY employee_id
) as table2
WHERE table1.employee_id = table2.employee_id
</code>```

Body:
I have two mysql queries that I'd like to combine. I'm shame-posting here as I've tried many combinations to make it work but can't figure it out. I guess I've hit a ceiling in my query writing abilities. :(

Query #1

        SELECT
        time_clock.id AS clock_id,
        employees.first_name, employees.last_name, employees.nick_name, employees.pay_schedule, time_clock.comments,
        employees.id AS employee_id, time_clock.punch_in,
        UNIX_TIMESTAMP(time_clock.punch_in) AS punch_in_unix,
        UNIX_TIMESTAMP(time_clock.punch_out) AS punch_out_unix,
        TIMESTAMPDIFF(MINUTE, time_clock.punch_in, time_clock.punch_out) AS time_spent
        FROM time_clock
        JOIN employees ON employees.id = time_clock.employee_id
        WHERE time_clock.id IN
            (
            SELECT MAX(time_clock.id)
            FROM time_clock
            WHERE employees.pay_schedule='hourly'
            GROUP BY employee_id
            )
        ORDER BY last_name, first_name ASC

Query #2

        SELECT
        employees.first_name, employees.last_name,
        employees.id AS employee_id,
        SUM(TIME_TO_SEC(time_clock.punch_out) - TIME_TO_SEC(time_clock.punch_in)) AS summed_seconds
        FROM time_clock
        JOIN employees ON employees.id = time_clock.employee_id
        WHERE YEAR(punch_in + interval 4 day) = YEAR(CURDATE()) AND
        WEEK(punch_in + interval 4 day) = WEEK(CURDATE())
        GROUP BY employee_id

Each query functions fine on its own. The first query selects the latest time event for each employee. The second query sums the recorded time for each employee in the last pay period (weekly, from Wed. to Tues.).

I'd love to have one query do both: Select the latest time event for each employee and sum the time for those with time recorded in the last pay period. (I'm doing this to present an interface for keeping track of which employees are on overtime.)

Any help I can get would be fantastic. I've also been exploring combining the results as arrays in php to get what I want but that presents its own set of problems for me and I suspect isn't as efficient.

The output of Query #1 is like so:

The output of Query #2 looks like:

And this is essentially the output I'd like to be able to have:

Thank you for any help you can offer. My forehead is denting faster than the desk I'm banging it on.

-Matt

PS - One of my attempts to combine them is below. It seems to produce the most sane error out of all my attempts ("The used SELECT statements have a different number of columns"), so I don't know how close it really is.

SELECT
        time_clock.id AS clock_id,
        employees.first_name, employees.last_name, employees.nick_name, employees.pay_schedule, time_clock.comments,
        employees.id AS employee_id, time_clock.punch_in,
        UNIX_TIMESTAMP(time_clock.punch_in) AS punch_in_unix,
        UNIX_TIMESTAMP(time_clock.punch_out) AS punch_out_unix,
        TIMESTAMPDIFF(MINUTE, time_clock.punch_in, time_clock.punch_out) AS time_spent
        FROM (
            SELECT *
            FROM time_clock
            LEFT JOIN employees ON employees.id = time_clock.employee_id
            WHERE time_clock.id IN
                (
                SELECT MAX(time_clock.id)
                FROM time_clock
                WHERE employees.pay_schedule='hourly'
                GROUP BY employee_id
                )

            UNION ALL

            SELECT
                employees.first_name, employees.last_name,
                employees.id AS employee_id,
                SUM(TIME_TO_SEC(time_clock.punch_out) - TIME_TO_SEC(time_clock.punch_in)) AS summed_seconds
                FROM time_clock
                LEFT JOIN employees ON employees.id = time_clock.employee_id
                WHERE YEAR(punch_in + interval 4 day) = YEAR(CURDATE()) AND
                      WEEK(punch_in + interval 4 day) = WEEK(CURDATE())
                GROUP BY employee_id
                ) as thing_one
        JOIN employees ON employees.id = time_clock.employee_id
        ORDER BY last_name, first_name ASC

Body:
Just join both the queries using employee_id

SELECT clock_id,
table1.first_name,
table1.last_name,
nick_name,
pay_schedule,
comments,
table1.employee_id,
punch_in,
punch_in_unix,
punch_out_unix,
time_spent,
summed_seconds
(SELECT
        time_clock.id AS clock_id,
        employees.first_name, employees.last_name, employees.nick_name, employees.pay_schedule, time_clock.comments,
        employees.id AS employee_id, time_clock.punch_in,
        UNIX_TIMESTAMP(time_clock.punch_in) AS punch_in_unix,
        UNIX_TIMESTAMP(time_clock.punch_out) AS punch_out_unix,
        TIMESTAMPDIFF(MINUTE, time_clock.punch_in, time_clock.punch_out) AS time_spent
        FROM time_clock
        JOIN employees ON employees.id = time_clock.employee_id
        WHERE time_clock.id IN
            (
            SELECT MAX(time_clock.id)
            FROM time_clock
            WHERE employees.pay_schedule='hourly'
            GROUP BY employee_id
            )) as table1,

(SELECT
        employees.first_name, employees.last_name,
        employees.id AS employee_id,
        SUM(TIME_TO_SEC(time_clock.punch_out) - TIME_TO_SEC(time_clock.punch_in)) AS summed_seconds
        FROM time_clock
        JOIN employees ON employees.id = time_clock.employee_id
        WHERE YEAR(punch_in + interval 4 day) = YEAR(CURDATE()) AND
        WEEK(punch_in + interval 4 day) = WEEK(CURDATE())
        GROUP BY employee_id
) as table2
WHERE table1.employee_id = table2.employee_id


问:
How should I define non-entity repositories with Spring Data MongoDB?
On my domain I have the usual entities (User, Company, etc) and also "entities" that doesn't change, I mean they are fixed values but stored on data base. My backend is Mongo so I make use of MongoRepository. I'm also using Spring Data Rest.

Let's say I have defined Sector as entity, which is nothing more than a String wrapped on a Java object.

So this is how I define the repository.

```<code>@RepositoryRestResource
public interface SectorRepo extends MongoRepository<Sector,String>{

}
</code>```

The thing is that this seems to be inappropriate, as I should not define an object that only wraps an string and treat it as an entity, it isn't. The only purpose for Sector collection is to be loaded on a combo box, nothing more.
The problem gets serious when you have more and more of these non-entities objects.

How I should approach this situation so I can still use MongoRepository + Spring Data Rest?

答:
This is similar to couple of other questions. Please see my answers for both. Hope it helps

Spring Data MongoDB eliminate POJO's

Storing a JSON schema in mongodb with spring

Body:
On my domain I have the usual entities (User, Company, etc) and also "entities" that doesn't change, I mean they are fixed values but stored on data base. My backend is Mongo so I make use of MongoRepository. I'm also using Spring Data Rest.

Let's say I have defined Sector as entity, which is nothing more than a String wrapped on a Java object.

So this is how I define the repository.

@RepositoryRestResource
public interface SectorRepo extends MongoRepository<Sector,String>{

}

The thing is that this seems to be inappropriate, as I should not define an object that only wraps an string and treat it as an entity, it isn't. The only purpose for Sector collection is to be loaded on a combo box, nothing more.
The problem gets serious when you have more and more of these non-entities objects.

How I should approach this situation so I can still use MongoRepository + Spring Data Rest?


问:
I'm getting NoSuchElement exception error
I have shared the below code please let me know the correction

```<code>import org.openqa.selenium.By;
import org.openqa.selenium.ie.InternetExplorerDriver;

public class MyClass {

    public static void main(String[] args) throws InterruptedException {
        // TODO Auto-generated method stub
        /*System.setProperty("webdriver.ie.driver","D:\\Backup\\Documents\\Automation\\drivers\\IEDriverServer.exe");
        InternetExplorerDriver driver = new InternetExplorerDriver();
        driver.get("https://www.google.com");

        WebDriverWait driverWait = new WebDriverWait(driver,50);

        driverWait.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@id='lst-ib']"))).click();
        driver.findElementByXPath("//*[@id='lst-ib']").sendKeys("Make My Trip");
        driver.findElementById("_fZl").click();
        driverWait.until(ExpectedConditions.elementToBeClickable(By.linkText("MakeMyTrip, India's No 1 Travel Site | Book Hotels, Flights, Holiday ..."))).click();
        Screenshot S1 = new Screenshot();
        S1.Takescreen();*/
        String username = null;
        String password = null;
        MyClass C1 = new MyClass();
        C1.URLs(username, password);
    }

    public void URLs  (String username, String password) throws InterruptedException
    {

        System.setProperty("webdriver.ie.driver","D:\\Backup\\Documents\\Automation\\drivers\\IEDriverServer.exe");
        InternetExplorerDriver driver = new InternetExplorerDriver();
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        driver.get("https://google.com");
        driver.findElement(By.className("lst lst-tbb sbibps")).sendKeys("irctc");
        driver.findElement(By.id("_fZl")).click();
        Thread.sleep(10000);
        driver.findElement(By.linkText("IRCTC Next Generation eTicketing System")).click();
        username = driver.findElement(By.id("usernameId")).getTagName();
        password = driver.findElement(By.className("loginPassword")).getTagName();
        System.out.println(username);
        System.out.println(password);
    }
}
</code>```

Error :

Exception in thread "main" org.openqa.selenium.NoSuchElementException:
  Unable to find element with class name == lst lst-tbb sbibps (WARNING:
  The server did not provide any stacktrace information) Command
  duration or timeout: 10.45 seconds

答:
Try below code it will work in your case(I tested it in my machine).

```<code>import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.ie.InternetExplorerDriver;

public class MyClass {

public static void main(String[] args) throws InterruptedException {
    String username = null;
    String password = null;
    MyClass C1 = new MyClass();
    C1.URLs(username, password);
}

public void URLs  (String username, String password) throws InterruptedException
{
    System.setProperty("webdriver.ie.driver","D:\\Backup\\Documents\\Automation\\drivers\\IEDriverServer.exe");
    InternetExplorerDriver driver = new InternetExplorerDriver();
    InternetExplorerDriver driver = new InternetExplorerDriver();
    driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
    driver.get("https://google.com");
    driver.findElement(By.id("lst-ib")).sendKeys("irctc");
    driver.findElement(By.id("_fZl")).click();
    Thread.sleep(10000);
    driver.findElement(By.linkText("IRCTC Next Generation eTicketing System")).click();
    username = driver.findElement(By.id("usernameId")).getTagName();
    password = driver.findElement(By.className("loginPassword")).getTagName();
    System.out.println(username);
    System.out.println(password);
}
}
</code>```

Let me know if it works for you.

Body:
I have shared the below code please let me know the correction

import org.openqa.selenium.By;
import org.openqa.selenium.ie.InternetExplorerDriver;

public class MyClass {

    public static void main(String[] args) throws InterruptedException {
        // TODO Auto-generated method stub
        /*System.setProperty("webdriver.ie.driver","D:\\Backup\\Documents\\Automation\\drivers\\IEDriverServer.exe");
        InternetExplorerDriver driver = new InternetExplorerDriver();
        driver.get("https://www.google.com");

        WebDriverWait driverWait = new WebDriverWait(driver,50);

        driverWait.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@id='lst-ib']"))).click();
        driver.findElementByXPath("//*[@id='lst-ib']").sendKeys("Make My Trip");
        driver.findElementById("_fZl").click();
        driverWait.until(ExpectedConditions.elementToBeClickable(By.linkText("MakeMyTrip, India's No 1 Travel Site | Book Hotels, Flights, Holiday ..."))).click();
        Screenshot S1 = new Screenshot();
        S1.Takescreen();*/
        String username = null;
        String password = null;
        MyClass C1 = new MyClass();
        C1.URLs(username, password);
    }

    public void URLs  (String username, String password) throws InterruptedException
    {

        System.setProperty("webdriver.ie.driver","D:\\Backup\\Documents\\Automation\\drivers\\IEDriverServer.exe");
        InternetExplorerDriver driver = new InternetExplorerDriver();
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        driver.get("https://google.com");
        driver.findElement(By.className("lst lst-tbb sbibps")).sendKeys("irctc");
        driver.findElement(By.id("_fZl")).click();
        Thread.sleep(10000);
        driver.findElement(By.linkText("IRCTC Next Generation eTicketing System")).click();
        username = driver.findElement(By.id("usernameId")).getTagName();
        password = driver.findElement(By.className("loginPassword")).getTagName();
        System.out.println(username);
        System.out.println(password);
    }
}

Error :

Exception in thread "main" org.openqa.selenium.NoSuchElementException:
  Unable to find element with class name == lst lst-tbb sbibps (WARNING:
  The server did not provide any stacktrace information) Command
  duration or timeout: 10.45 seconds

Body:
Try below code it will work in your case(I tested it in my machine).

import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.ie.InternetExplorerDriver;

public class MyClass {

public static void main(String[] args) throws InterruptedException {
    String username = null;
    String password = null;
    MyClass C1 = new MyClass();
    C1.URLs(username, password);
}

public void URLs  (String username, String password) throws InterruptedException
{
    System.setProperty("webdriver.ie.driver","D:\\Backup\\Documents\\Automation\\drivers\\IEDriverServer.exe");
    InternetExplorerDriver driver = new InternetExplorerDriver();
    InternetExplorerDriver driver = new InternetExplorerDriver();
    driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
    driver.get("https://google.com");
    driver.findElement(By.id("lst-ib")).sendKeys("irctc");
    driver.findElement(By.id("_fZl")).click();
    Thread.sleep(10000);
    driver.findElement(By.linkText("IRCTC Next Generation eTicketing System")).click();
    username = driver.findElement(By.id("usernameId")).getTagName();
    password = driver.findElement(By.className("loginPassword")).getTagName();
    System.out.println(username);
    System.out.println(password);
}
}

Let me know if it works for you.


问:
Mark multi location in database and compare distance them using GoogleMap?
I have hybrid app (Ionic 1) and contains some locations in my database , i want to check some locations near this my positons now ( GPS ) radius < 10km .help me solution to solve it ? using Google Map ? </p>

答: you need to do this in your back-end or server side by passing your current position details like lat and lang.check this  for a guideline how to do that.In this they used PHP as a back-end technology so you need to try in your technology.check this also</p>


问:
XREF-ing the same table in MySql
I need to create a MySql relational DB with the following simple requirements:

A CLIENT can have many SUBSCRIBERs which themselves are CLIENTs

A CLIENT can have many CONTACTs which themselves are CLIENTs

It looks like I need two XREF tables, however they are xreferencing the same table (CLIENT)!

So far, the only way I seem to be able to design this is as follows:

Which seems impractical since both CONTACT and SUBSCRIBER are just referencing a CLIENT.

I sense I'm missing something obvious here...

* EDIT *

Based on the first comment below, I derived the following simplified table ...

Title: XREF-ing the same table in MySql

Body:
You can define your clients has many subscribers and contacts as like -

TABLE : clients

+----+-------------+----------------------+
| id | name        | email                |
+----+-------------+----------------------+
| 1  | A           | email@example.com    |
+----+-------------+----------------------+

Note : id is the Primary Key

TABLE : subscribers

+----+-------------+----------------------+
| id | client_id   | status               |
+----+-------------+----------------------+
| 1  | 1           | Y                    |
+----+-------------+----------------------+
| 2  | 3           | Y                    |
+----+-------------+----------------------+

Note : id is the Primary Key and client_id is the Foreign Key of clients table

TABLE : contacts

+----+-------------+----------------------+
| id | client_id   | status               |
+----+-------------+----------------------+
| 1  | 1           | Y                    |
+----+-------------+----------------------+
| 2  | 3           | Y                    |
+----+-------------+----------------------+

Note : id is the Primary Key and client_id is the Foreign Key of clients table


问:
PHP : Regex to extract data from web url
I am receiving URL from an application as post data.

The URL has a signature : //abc.com/name?q=123456.

I want to extract name from the URL using regex ( Regular Expression )
How do I do that?

答:
Best method is parsing url, but if you need regex to extract name :

```<code>/.+\/([^\?]+?)(\?|$)/gm
</code>```

Demo

Note: this regex pattern match whole url, but captures name that you want in Group 1.

Body:
Best method is parsing url, but if you need regex to extract name :

/.+\/([^\?]+?)(\?|$)/gm

Demo

Note: this regex pattern match whole url, but captures name that you want in Group 1.


问:
Good piece of software for practicing SQL on Windows?
I brought 31 queries down to 3 for a certain page in my application by using a single join (provided by Django's ORM). Up until that very moment I thought of SQL optimization as something I didn't need to worry about. I instantly realized that there are probably so many areas that run slow which could use some SQL tomFOOlery (SQL FOO is for professionals).

Now I'm looking for a piece of open source software that will allow me to quickly create databases, and tables with a GUI, so I can quickly add data and experiment with queries. Is Access good for this (aside from not being free or open source)? Or, does Access use it's own SQL syntax?

答:
SQuirreL SQL is a nice and free software that supports many databases.

I'm not sure if you can create tables visually, but from my experience, it's faster to just write the DDL and then execute it since it's a one time job.

As for data generation, I've found http://www.generatedata.com/ to be a nice online site where you can generate dummy data.


问:
How to set the tab bar badge with swift?
How to set the tab bar badge with swift ? for example when I get new message  showing number 1 on the message icon !
Do I have to use the UITabBarItem.swift and write the code in it !
I'm not really sure how I can do it

Thank you !

答:
If you got the reference to the tabBarController (e.g. from the UIViewController) you can do the following:

```<code>if let tabItems = tabBarController?.tabBar.items {
    // In this case we want to modify the badge number of the third tab:
    let tabItem = tabItems[2]
    tabItem.badgeValue = "1"
}
</code>```

From a UITabBarController it would be tabBar.items instead of tabBarController?.tabBar.items

and to delete the badge:

```<code>tabItem.badgeValue = nil
</code>```

Body:
If you got the reference to the tabBarController (e.g. from the UIViewController) you can do the following:

if let tabItems = tabBarController?.tabBar.items {
    // In this case we want to modify the badge number of the third tab:
    let tabItem = tabItems[2]
    tabItem.badgeValue = "1"
}

From a UITabBarController it would be tabBar.items instead of tabBarController?.tabBar.items

and to delete the badge:

tabItem.badgeValue = nil

ContentLicense: CC BY-SA 4.0


问:
Remove Collection view bounce issue when using pull to refresh
I have one collection view configured as follow

```<code>        superCollectionView!.alwaysBounceHorizontal = false
        superCollectionView!.alwaysBounceVertical = false

        if #available(iOS 10.0, *) {
            superCollectionView!.refreshControl = refreshControl
        } else {
            superCollectionView!.backgroundView = refreshControl
        }
</code>```

but bounce effect is still there.
I want to remove bounce from bottom...

答:
If you want to remove bouncing only from the bottom (For letting the refreshControl to be available), I'd suggest to handle it in scrollViewDidScroll: method to check if the scroll view contentOffset.y has been reached to bottom of the scroll view (logically, it is the content size of the scroll view minus the height of the visible frame of the scroll view), as follows:

Solution:

```<code>func scrollViewDidScroll(_ scrollView: UIScrollView) {
    if scrollView.contentOffset.y >= scrollView.contentSize.height - scrollView.frame.size.height {
        scrollView.setContentOffset(CGPoint(x: scrollView.contentOffset.x, y: scrollView.contentSize.height - scrollView.frame.size.height), animated: false)
    }
}
</code>```

Output:

After implementing scrollViewDidScroll as mentioned above, it should be behaves like:

Also:

What about achieving the opposite?

Referring to the above description, preventing the top bouncing would be:

```<code>func scrollViewDidScroll(_ scrollView: UIScrollView) {
    if scrollView.contentOffset.y < 0 {
        scrollView.setContentOffset(CGPoint(x: scrollView.contentOffset.x, y: 0), animated: false)
    }
}
</code>```

Body:
I have one collection view configured as follow

        superCollectionView!.alwaysBounceHorizontal = false
        superCollectionView!.alwaysBounceVertical = false

        if #available(iOS 10.0, *) {
            superCollectionView!.refreshControl = refreshControl
        } else {
            superCollectionView!.backgroundView = refreshControl
        }

but bounce effect is still there.
I want to remove bounce from bottom...

Body:
If you want to remove bouncing only from the bottom (For letting the refreshControl to be available), I'd suggest to handle it in scrollViewDidScroll: method to check if the scroll view contentOffset.y has been reached to bottom of the scroll view (logically, it is the content size of the scroll view minus the height of the visible frame of the scroll view), as follows:

Solution:

func scrollViewDidScroll(_ scrollView: UIScrollView) {
    if scrollView.contentOffset.y >= scrollView.contentSize.height - scrollView.frame.size.height {
        scrollView.setContentOffset(CGPoint(x: scrollView.contentOffset.x, y: scrollView.contentSize.height - scrollView.frame.size.height), animated: false)
    }
}

Output:

After implementing scrollViewDidScroll as mentioned above, it should be behaves like:

Also:

What about achieving the opposite?

Referring to the above description, preventing the top bouncing would be:

func scrollViewDidScroll(_ scrollView: UIScrollView) {
    if scrollView.contentOffset.y < 0 {
        scrollView.setContentOffset(CGPoint(x: scrollView.contentOffset.x, y: 0), animated: false)
    }
}


问:
What is the purpose and duration of this cookie __utmli used by Google Analytics?
We are researching on the Cookies rendered by GA on our website which are generated on user's machine.

I found the description of almost all cookies from https://developers.google.com/analytics/devguides/collection/analyticsjs/cookie-usage

But one cookie in specific is not menitioned anywhere. "__utmli".

Could anyone here please provide some information like description/purpose and duration of this cookie?

Thanks,
Praful Memane

答:
The cookie is part of the Enhanced Link Attribution feature that (tries to) distinguish clicks on links to the same destination in the in-page analyses.

If I recall correctly it expires pretty quickly (I think 30 seconds or thereabout) and contains the id (if any) of the clicked link (or its parent) to be read on the next page, so in-page analyses can tell where on the page the clicked link was located.

It seems however that this refers to ga.js exclusively, and that the corresponding cookie for analytics.js is called "_gali" as per https://developers.google.com/analytics/devguides/collection/analyticsjs/enhanced-link-attribution.


问:
What is the use of % symbol in unix
Example.sh :

```<code>SERVICE="${0##*/}";
SERVICE="${SERVICE%.sh}"
echo $SERVICE
</code>```

The above script provides Shellscript name as the output.But, how exactly it works ?
What is the purpose of line 1 and 2 ?
Can anyone help me ?

答:
SERVICE="${0##*/}";

${x} where x is a number returns the command line parameter value identified by index x. If x is 0, it returns the scriptname itself, including the path.
The operation ##*/ strips the path from that value.

After this operation, SERVICE contains the scriptname + extension but without the path.

SERVICE="${SERVICE%.sh}"

When the percent sign (%) is used in the pattern ${variable%substring}, it will return the content of the variable with the shortest occurrence of substring deleted from the back of the variable.

So after this operation .sh will be stripped from the value in the ${SERVICE} variable. Now SERVICE contains the scriptname without path and without extension.

Title: What is the use of % symbol in unix

Body:
Example.sh :

SERVICE="${0##*/}";
SERVICE="${SERVICE%.sh}"
echo $SERVICE

The above script provides Shellscript name as the output.But, how exactly it works ?
What is the purpose of line 1 and 2 ?
Can anyone help me ?


问:
Update selectbox options and save to database
I've to select boxes:

```<code><select name="select1" id="select1" multiple="multiple">
<option value="8">Civics</option>
<option value="9">English</option>
<option value="10">Economics</option>
</select>

<select id="select2" size="4" multiple="multiple" name="select2[]">
<option value="1">Maths</option>
<option value="2">Physics</option>
<option value="3">Chemistry</option>
<option value="4">Biology</option>
<option value="5">History</option>
<option value="7">Social Studies</option>
<option value="11">Geography</option>
</select>
</code>```

The data for both the boxes is fetched from the db on page load.
The idea is to either add/delete options from the select2 and save it to a table in the db. I delete the existing data in the table before updating it.

The issue I'm facing is while saving the data, only the new options which are added to the select2 are getting saved and if I remove any options, I'm getting an index out of bounds error. How do I make sure that the values which are already there in the select2 on page load are read as well?

The php code is as follows:

```<code><?php
if(isset($_POST['save']))
{
    $qry = 'delete * from table_sel2';
    $exec = mysqli_query($conn,$qry);

    foreach ($_POST['select2'] as $sel_val)
    {
        echo $sel_val;
        $sql = "insert into table_sel2 (select2,status_id) values (".$sel_val.",1)";
        $result = mysqli_query($conn,$sql);
    }
    $message = "Done!";
}
?>
</code>```

Jquery code to move data between the selectboxes:

```<code>$('#add').click(
            function(e)
            {
                $('#select1 > option:selected').appendTo('#select2');

            });

            $('#remove').click(
            function(e)
            {
                $('#select2 > option:selected').appendTo('#select1');

            });
</code>```

答:
Select all options from select2 upon form submission like this - </p>

```<code>    submit_bttn.click(function () {
      $('#select2 option').each(function () {
          $(this).attr('selected', true);
      });
    });
</code>```

Body:
I've to select boxes:

<select name="select1" id="select1" multiple="multiple">
<option value="8">Civics</option>
<option value="9">English</option>
<option value="10">Economics</option>
</select>

<select id="select2" size="4" multiple="multiple" name="select2[]">
<option value="1">Maths</option>
<option value="2">Physics</option>
<option value="3">Chemistry</option>
<option value="4">Biology</option>
<option value="5">History</option>
<option value="7">Social Studies</option>
<option value="11">Geography</option>
</select>

The data for both the boxes is fetched from the db on page load.
The idea is to either add/delete options from the select2 and save it to a table in the db. I delete the existing data in the table before updating it.

The issue I'm facing is while saving the data, only the new options which are added to the select2 are getting saved and if I remove any options, I'm getting an index out of bounds error. How do I make sure that the values which are already there in the select2 on page load are read as well?

The php code is as follows:

<?php
if(isset($_POST['save']))
{
    $qry = 'delete * from table_sel2';
    $exec = mysqli_query($conn,$qry);

    foreach ($_POST['select2'] as $sel_val)
    {
        echo $sel_val;
        $sql = "insert into table_sel2 (select2,status_id) values (".$sel_val.",1)";
        $result = mysqli_query($conn,$sql);
    }
    $message = "Done!";
}
?>

Jquery code to move data between the selectboxes:

$('#add').click(
            function(e)
            {
                $('#select1 > option:selected').appendTo('#select2');

            });

            $('#remove').click(
            function(e)
            {
                $('#select2 > option:selected').appendTo('#select1');

            });

Body:
Select all options from select2 upon form submission like this -

    submit_bttn.click(function () {
      $('#select2 option').each(function () {
          $(this).attr('selected', true);
      });
    });


问:
How to Select TFS History based on System.ID
The script below allows me to get changeset history from TFS.  How can I get the history based on a PBI number or System.ID?

```<code>Get-TfsItemHistory $locationToSearch -Recurse -Version $dateRange |
Sort CreationDate | Select ChangeSetId,Committer,Comment,CreationDate |  Format-Table ChangeSetId,CreationDate,Committer,Comment -Auto -Wrap  |
out-file "C:\full.txt"
</code>```

答:
Get-TfsItemHistory is a commandlet  in tfspowertools. It's not able to get what you want. You could use TFS Client API to achieve it, please refer the code sample from AlexanderM's answer:

```<code>private static void GetChangesForWorkItem()
{
    var configurationServer = TfsConfigurationServerFactory.GetConfigurationServer(new Uri(@"http://myserver:8080/tfs"));
    var tpcService = configurationServer.GetService<ITeamProjectCollectionService>();
    var collectionNodes = configurationServer.CatalogNode.QueryChildren(
           new[] { CatalogResourceTypes.ProjectCollection },
           false, CatalogQueryOptions.None);

    var collectionNode = collectionNodes.First(x => x.Resource.DisplayName == "<collection name>");

    // Use the InstanceId property to get the team project collection
    Guid collectionId = new Guid(collectionNode.Resource.Properties["InstanceId"]);
    TfsTeamProjectCollection collection = configurationServer.GetTeamProjectCollection(collectionId);
    var vcs = collection.GetService<VersionControlServer>();
    var store = new WorkItemStore(collection);
    var workItems = new List<WorkItem>()
    {
        store.GetWorkItem(1123),
        store.GetWorkItem(1145),
    };

    var associatedChangesets = new List<Changeset>();

    foreach (var workItem in workItems)
    {
        foreach (var link in workItem.Links)
        {
            if((link==null) || !(link is ExternalLink))
            continue;

            string externalLink = ((ExternalLink)link).LinkedArtifactUri;
            var artifact =LinkingUtilities.DecodeUri(externalLink);

            if (artifact.ArtifactType == "Changeset")
                associatedChangesets.Add(vcs.ArtifactProvider.GetChangeset(new Uri(externalLink)));
        }
    }

    Console.WriteLine(associatedChangesets.Select(x=>x.ChangesetId).OrderBy(x => x));
}
</code>```

Another way is using TFS RSET API and then filter out "relations" array with rel == "ArtifactLink"

```<code>   Get  https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/wit/workitems?ids=297,299,300&$expand=all&api-version=1.0
</code>```

Body:
The script below allows me to get changeset history from TFS.  How can I get the history based on a PBI number or System.ID?

Get-TfsItemHistory $locationToSearch -Recurse -Version $dateRange |
Sort CreationDate | Select ChangeSetId,Committer,Comment,CreationDate |  Format-Table ChangeSetId,CreationDate,Committer,Comment -Auto -Wrap  |
out-file "C:\full.txt"

Body:
Get-TfsItemHistory is a commandlet  in tfspowertools. It's not able to get what you want. You could use TFS Client API to achieve it, please refer the code sample from AlexanderM's answer:

private static void GetChangesForWorkItem()
{
    var configurationServer = TfsConfigurationServerFactory.GetConfigurationServer(new Uri(@"http://myserver:8080/tfs"));
    var tpcService = configurationServer.GetService<ITeamProjectCollectionService>();
    var collectionNodes = configurationServer.CatalogNode.QueryChildren(
           new[] { CatalogResourceTypes.ProjectCollection },
           false, CatalogQueryOptions.None);

    var collectionNode = collectionNodes.First(x => x.Resource.DisplayName == "<collection name>");

    // Use the InstanceId property to get the team project collection
    Guid collectionId = new Guid(collectionNode.Resource.Properties["InstanceId"]);
    TfsTeamProjectCollection collection = configurationServer.GetTeamProjectCollection(collectionId);
    var vcs = collection.GetService<VersionControlServer>();
    var store = new WorkItemStore(collection);
    var workItems = new List<WorkItem>()
    {
        store.GetWorkItem(1123),
        store.GetWorkItem(1145),
    };

    var associatedChangesets = new List<Changeset>();

    foreach (var workItem in workItems)
    {
        foreach (var link in workItem.Links)
        {
            if((link==null) || !(link is ExternalLink))
            continue;

            string externalLink = ((ExternalLink)link).LinkedArtifactUri;
            var artifact =LinkingUtilities.DecodeUri(externalLink);

            if (artifact.ArtifactType == "Changeset")
                associatedChangesets.Add(vcs.ArtifactProvider.GetChangeset(new Uri(externalLink)));
        }
    }

    Console.WriteLine(associatedChangesets.Select(x=>x.ChangesetId).OrderBy(x => x));
}

Another way is using TFS RSET API and then filter out "relations" array with rel == "ArtifactLink"

   Get  https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/wit/workitems?ids=297,299,300&$expand=all&api-version=1.0


问:
Excel Macro to pick values from one table/array to another
I have the following "table" in an Excel sheet. I would like to do the following change:

Each time when there is a "x" I would like to report on another sheet the corresponding value of the first row and corresponding value of the first column:

"Original Table"

```<code>    a1      a2      a3      a7      a8      a9
    main    main    main    main    main    main
u1  X       X        X
u2          X        X
u3
u4
u5  X
u6                   X
</code>```

"Transformed Table":

```<code>  u1 a1
  u1 a2
  u1 a3
  u2 a2
  u2 a3
  u5 a1
  u6 a3
</code>```

Could you please tell me what is the Excel macro that will do this ?

Thank you in advance.

答:
This assumes that sheet(2) exists (ie doesn't check).  It will populate sheet(2) with the row and column headers as you've given in your example:

```<code>Sub ReportOnAllXs()
  Dim r As Integer, c As Integer, r2 As Integer
  r2 = 1
  With Sheets(1)
    For r = 3 To .Cells(.Rows.Count, "A").End(xlUp).row
      For c = 2 To .Cells(1, .Columns.Count).End(xlToLeft).Column
        If .Cells(r, c).Value = "X" Then
          Sheets(2).Cells(r2, 1).Value = .Cells(r, 1).Value
          Sheets(2).Cells(r2, 2).Value = .Cells(1, c).Value
          r2 = r2 + 1
        End If
      Next
    Next
  End With
End Sub
</code>```

I'm also assuming that you want the resulting row and column values in separate cells on sheet(2).

Body:
I have the following "table" in an Excel sheet. I would like to do the following change:

Each time when there is a "x" I would like to report on another sheet the corresponding value of the first row and corresponding value of the first column:

"Original Table"

    a1      a2      a3      a7      a8      a9
    main    main    main    main    main    main
u1  X       X        X
u2          X        X
u3
u4
u5  X
u6                   X

"Transformed Table":

  u1 a1
  u1 a2
  u1 a3
  u2 a2
  u2 a3
  u5 a1
  u6 a3

Could you please tell me what is the Excel macro that will do this ?

Thank you in advance.

Body:
This assumes that sheet(2) exists (ie doesn't check).  It will populate sheet(2) with the row and column headers as you've given in your example:

Sub ReportOnAllXs()
  Dim r As Integer, c As Integer, r2 As Integer
  r2 = 1
  With Sheets(1)
    For r = 3 To .Cells(.Rows.Count, "A").End(xlUp).row
      For c = 2 To .Cells(1, .Columns.Count).End(xlToLeft).Column
        If .Cells(r, c).Value = "X" Then
          Sheets(2).Cells(r2, 1).Value = .Cells(r, 1).Value
          Sheets(2).Cells(r2, 2).Value = .Cells(1, c).Value
          r2 = r2 + 1
        End If
      Next
    Next
  End With
End Sub

I'm also assuming that you want the resulting row and column values in separate cells on sheet(2).


问:
Overlay effect working on iframe in Chrome but not in IE11
I have a Document viewer with .less file having:

```<code>div.document-previewer-container {
//height: 400px;
//width: 300px;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
//padding: 5px 2px;
> div.document-preview {
    height: 88%;
    //width: 100%;
    position: relative;

    .document-container, .text-container, video, iframe, pre {
        height: 100%;
        width: 100%;
        position: relative;
    }

    .document-container > img {
        max-height: 100%;
        max-width: 100%;
    }

    .text-container pre {
        margin: 0;
        padding: 0;
    }

    .doc-overlay {
        width: 95%;
        height: 95%;
        position: absolute;
        cursor: pointer;
        top: 0;

        p {
            padding: 2px;
        }
    }
}
}
</code>```

My html is

```<code><div class="document-previewer-container">
<div class="document-preview">
    <h3 ng-click="vm.openPDF()">yu</h3> <----- THIS CLICK IS WORKING
    <div class="document-container">
        <!-- PDF show in iframe -->
    </div>
    <div class="doc-overlay" ng-click="vm.openPDF()"> <---- THIS CLICK ISN'T becuse if is hidden by iframe
        <!-- any content is shown on the top of PDF file in chrome only, not in IE -->
    </div>
</div>
</div>
</div>
</code>```

My click event is working on  tag but not when clicked on div with css class 'doc-overlay'.

How to handle it

I am using Foxit Reader plugin for IE11

Update1

I found this question which I think is happening with me. The iframe is overlapping .doc-overlay and hence the click isn't working.
Any suggestions for this please

答:
Actually this is a CSS issue. You have used SCSS format that is why DOM is unable to find class "doc-overlay".

You can use this CSS, it will work fine.

div.document-previewer-container {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
div.document-previewer-container> div.document-preview {
    height: 88%;
    position: relative;
}
    div.document-previewer-container> div.document-preview .document-container, .text-container, video, iframe, pre {
        height: 100%;
        width: 100%;
        position: relative;
    }

    div.document-previewer-container> div.document-preview .document-container > img {
        max-height: 100%;
        max-width: 100%;
    }

   div.document-previewer-container> div.document-preview .text-container pre {
        margin: 0;
        padding: 0;
    }

   div.document-previewer-container> div.document-preview .doc-overlay {
        width: 95%;
        height: 95%;
        position: absolute;
        cursor: pointer;
        top: 0;
}
div.document-previewer-container> div.document-preview  .doc-overlay p {
       padding: 2px;
}```

Body:
I have a Document viewer with .less file having:

div.document-previewer-container {
//height: 400px;
//width: 300px;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
//padding: 5px 2px;
> div.document-preview {
    height: 88%;
    //width: 100%;
    position: relative;

    .document-container, .text-container, video, iframe, pre {
        height: 100%;
        width: 100%;
        position: relative;
    }

    .document-container > img {
        max-height: 100%;
        max-width: 100%;
    }

    .text-container pre {
        margin: 0;
        padding: 0;
    }

    .doc-overlay {
        width: 95%;
        height: 95%;
        position: absolute;
        cursor: pointer;
        top: 0;

        p {
            padding: 2px;
        }
    }
}
}

My html is

yu
 <----- THIS CLICK IS WORKING

 <---- THIS CLICK ISN'T becuse if is hidden by iframe

My click event is working on  tag but not when clicked on div with css class 'doc-overlay'.

How to handle it

I am using Foxit Reader plugin for IE11

Update1

I found this question which I think is happening with me. The iframe is overlapping .doc-overlay and hence the click isn't working.
Any suggestions for this please


问:
how to do SSH with -t option using paramiko
I am trying to login to some remote servers and trying to fetch the system info. During that process I have faced an issued in some of the servers, where the password is not really required to execute commands as SUDO. To overcome this issue and make the script generic came up with option like this "sudo -k udisksctl status", i.e providing -k option so that everytime it requests for a password.

Now a different problem has occured : When trying to login to some of the servers the following error is occuring "sorry you must have a tty to run sudo centos". When googled out came to know about the option of doing ssh with -t option from here

So my Question is how to do SSH with -t option using paramiko ? Or How to overcome this problem ?

```<code>import paramiko
import pprint

ip_list = [
["192.168.11.44", "root", "aaa", "aaa"],
["192.168.11.6", "root", "bbb", "bbb"]
]
os_check_list = ["DISTRIB_DESCRIPTION"]
os = None

ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())

for ip in ip_list:
    ssh.connect(ip[0], username = ip[1], password = ip[2])

    stdin, stdout, stderr = ssh.exec_command("sudo -k udisksctl status")
    stdin.write(ip[3]+"\n")
</code>```

答:
You can use the get_pty parameter:

```<code>stdin, stdout, stderr = ssh.exec_command("sudo -k udisksctl status", get_pty=True)
</code>```

There's some side effect though. With get_pty=True, all output will be sent to stdout and so you cannot get data from stderr any more.

Body:
I am trying to login to some remote servers and trying to fetch the system info. During that process I have faced an issued in some of the servers, where the password is not really required to execute commands as SUDO. To overcome this issue and make the script generic came up with option like this "sudo -k udisksctl status", i.e providing -k option so that everytime it requests for a password.

Now a different problem has occured : When trying to login to some of the servers the following error is occuring "sorry you must have a tty to run sudo centos". When googled out came to know about the option of doing ssh with -t option from here

So my Question is how to do SSH with -t option using paramiko ? Or How to overcome this problem ?

import paramiko
import pprint

ip_list = [
["192.168.11.44", "root", "aaa", "aaa"],
["192.168.11.6", "root", "bbb", "bbb"]
]
os_check_list = ["DISTRIB_DESCRIPTION"]
os = None

ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())

for ip in ip_list:
    ssh.connect(ip[0], username = ip[1], password = ip[2])

    stdin, stdout, stderr = ssh.exec_command("sudo -k udisksctl status")
    stdin.write(ip[3]+"\n")

Body:
You can use the get_pty parameter:

stdin, stdout, stderr = ssh.exec_command("sudo -k udisksctl status", get_pty=True)

There's some side effect though. With get_pty=True, all output will be sent to stdout and so you cannot get data from stderr any more.


问:
jquery if checkbox checked add value true
How to make jquery click function if checkBox checked then status value set to 'true', if not cheked value set to 'false'?

if I check checkbox 1 , then status 1 set to true
if I check checkbox 2 , then status 2 set to true
if I check checkbox 3 , then status 3 set to true

  <input name="checkBox[]" type="checkbox" value="1"> Checkbox 1
   <input name="status[]" type="text" value="">

   <input name="checkBox[]" type="checkbox" value="2"> Checkbox 2
   <input name="status[]" type="text" value="">

  <input name="checkBox[]" type="checkbox" value="3"> Checkbox 3
   <input name="status[]" type="text" value="">

```

答:
 $('input[type="checkbox"]').change(function () {
            if ($(this).prop('checked')) {  $(this).closest('label').next('input[type="text"]').val('true');
            } else {
                $(this).closest('label').next('input[type="text"]').val('false');
            }
        });```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<div class="form-group">
  <label><input name="checkBox[]" type="checkbox" value="1"> Checkbox 1</label>
   <input name="status[]" type="text" value="">
</div>
<div class="form-group">
   <label><input name="checkBox[]" type="checkbox" value="2"> Checkbox 2</label>
   <input name="status[]" type="text" value="">
</div>
<div class="form-group">
  <label><input name="checkBox[]" type="checkbox" value="3"> Checkbox 3</label>
   <input name="status[]" type="text" value="">
</div></code>```

Body:
 $('input[type="checkbox"]').change(function () {
            if ($(this).prop('checked')) {  $(this).closest('label').next('input[type="text"]').val('true');
            } else {
                $(this).closest('label').next('input[type="text"]').val('false');
            }
        });

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<div class="form-group">
  <label><input name="checkBox[]" type="checkbox" value="1"> Checkbox 1</label>
   <input name="status[]" type="text" value="">
</div>
<div class="form-group">
   <label><input name="checkBox[]" type="checkbox" value="2"> Checkbox 2</label>
   <input name="status[]" type="text" value="">
</div>
<div class="form-group">
  <label><input name="checkBox[]" type="checkbox" value="3"> Checkbox 3</label>
   <input name="status[]" type="text" value="">
</div>


答:
As your input is within <lable>, use parent().next() to set the value.

Here is the working example.

$(function() {
  $('.form-group input[type="checkbox"]').change(function() {
    if ($(this).is(":checked")) {
      $(this).parent().next().val('true')
    } else
      $(this).parent().next().val('false');
  });
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="form-group">
  <label><input name="checkBox[]" type="checkbox" value="1"> Checkbox 1</label>
  <input name="status[]" type="text" value="">
</div>
<div class="form-group">
  <label><input name="checkBox[]" type="checkbox" value="2"> Checkbox 2</label>
  <input name="status[]" type="text" value="">
</div>
<div class="form-group">
  <label><input name="checkBox[]" type="checkbox" value="3"> Checkbox 3</label>
  <input name="status[]" type="text" value="">
</div></code>```

Title: jquery if checkbox checked add value true

Body:
How to make jquery click function if checkBox checked then status value set to 'true', if not cheked value set to 'false'?

if I check checkbox 1 , then status 1 set to true
if I check checkbox 2 , then status 2 set to true
if I check checkbox 3 , then status 3 set to true

  <input name="checkBox[]" type="checkbox" value="1"> Checkbox 1
   <input name="status[]" type="text" value="">

   <input name="checkBox[]" type="checkbox" value="2"> Checkbox 2
   <input name="status[]" type="text" value="">

  <input name="checkBox[]" type="checkbox" value="3"> Checkbox 3
   <input name="status[]" type="text" value="">

Body:
As your input is within <lable>, use parent().next() to set the value.

Here is the working example.

$(function() {
  $('.form-group input[type="checkbox"]').change(function() {
    if ($(this).is(":checked")) {
      $(this).parent().next().val('true')
    } else
      $(this).parent().next().val('false');
  });
});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="form-group">
  <label><input name="checkBox[]" type="checkbox" value="1"> Checkbox 1</label>
  <input name="status[]" type="text" value="">
</div>
<div class="form-group">
  <label><input name="checkBox[]" type="checkbox" value="2"> Checkbox 2</label>
  <input name="status[]" type="text" value="">
</div>
<div class="form-group">
  <label><input name="checkBox[]" type="checkbox" value="3"> Checkbox 3</label>
  <input name="status[]" type="text" value="">
</div>


问:
Smallest Sum Algorithm
I feel like I may not have been clear enough about the requirements so let me try to make things more clear.

You are provided a dictionary that contains keys that are either single letters or multiple letters. Each key has an associated value. Given an input, you must find the keys that contain the input letters. Return the lowest key values that satisfy this requirement.

Here are a few examples:

Input Dictionary

Key -> Value

a -> 4

b -> 6

e -> 5

abc -> 8

Input: 'a'
Output: 4

Input: 'c'
Output: 8

Input: 'ab'
Output: 8

Input: 'ac'
Output: 8

Input: 'ce'
Output: 13

Input: 'd'
Output: null

Note on the third example, the input is ab. So here, we can either get the letter 'a' from the key 'a' or the key 'abc'. We can either get the letter 'b' from the key 'b' or the key 'abc'. In order to get both keys with the lowest total value, 'abc' with a value of 8 is the correct output.

Note on the fifth example, the input is ce. The letter 'c' is only available in the key 'abc'. The letter 'e' is only available in the key 'e'. The correct output in this situation is 13.

UPDATE: I was able to solve this recursively by starting off with the first letter in the input sequence, finding all keys that contain that letter, and for each key, building a list of all the possible combinations. I was able to track the lowest sum by recursively moving through one letter of the input sequence at a time.

答:
You can and probably should do recursion. Always grab the next letter of the string you are searching for, and continue building all the possibilities. For each branch, keep just the smallest value and the string it is associated to.

Starting with letter a, you have 2 options - either [4, a] or [8, abc]. Now you continue to the next letter, for a you now have [6, b] or [8, abc]. As this is the end of the list, and b is smaller than abc, you end up with [10, ab] here. Now the other, abc branch, can skip b - it already has it. So, you compare [8, abc] vs [10, ab] and abc is smaller, so it gets returned. And is the final solution already.

Title: Smallest Sum Algorithm


问:
Mysql delete query using zend
i'm developing an application where there is a function (correctly called) that receive an id an should delete records from a table where the id is present.

This is my code:

```<code>public function deleteAction($id) {
        if ($id) {
            $where[] = $this->_db->quoteInto('transazione = ?', $id);
            $this->_db->delete($this->_name, $where);
        }
    }
</code>```

The function is correctly called but i receive this error:

```<code>An error occurred

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ')' at line 1
</code>```

How can i solve this?

答:
try</p>

```<code>   $n = $this->_db->delete('tablename', "column_id = $id");
        /*or*/
   $q = $this->_db->quoteInto('DELETE * FROM bugs WHERE reported_by = ?', $id);
   $this->_db->query($q);
</code>```

Title: Mysql delete query using zend

Body:
i'm developing an application where there is a function (correctly called) that receive an id an should delete records from a table where the id is present.

This is my code:

public function deleteAction($id) {
        if ($id) {
            $where[] = $this->_db->quoteInto('transazione = ?', $id);
            $this->_db->delete($this->_name, $where);
        }
    }

The function is correctly called but i receive this error:

An error occurred

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ')' at line 1

How can i solve this?

Body:
try

   $n = $this->_db->delete('tablename', "column_id = $id");
        /*or*/
   $q = $this->_db->quoteInto('DELETE * FROM bugs WHERE reported_by = ?', $id);
   $this->_db->query($q);


问:
curl: (48) An unknown option was passed in to libcurl
This is really frustrating. I keep getting this error when trying to run a standard curl command:

```<code>curl --url https://install.meteor.com | sh
curl: (48) An unknown option was passed in to libcurl
</code>```

Anyone know how to fix it?

答: On Ubuntu 16.04 LTS I just added /usr/local/lib to the LD_LIBRARY_PATH in /etc/profile (LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH)</p>

Body:
This is really frustrating. I keep getting this error when trying to run a standard curl command:

curl --url https://install.meteor.com | sh
curl: (48) An unknown option was passed in to libcurl

Anyone know how to fix it?


问:
Why not mongodb?
I recently used MongoDB for the first time and found it exceptionally easy to use and high-performing. Which leads to my question - why not MongoDB?

Lets say I am implementing a Q & A app. My approach would be to implement the User data in a MySQL database and then use MongoDB for the question and answer storage - one collection storing a question and all responses.

Is there anything wrong with this approach?

答:
While deciding the database for my project I heard that mongoDB is free then I thought why not mongoDB?

Well, Just to be more sure I called the MongoDB Customer Support Team.
There are three different version of MongoDB as per now.

Community Server

Professional

Enterprise

Actually Community server is free and other 2 are paid software.

I asked the guy-

Where can I use Community Server of mongodb?

Below the response I received through Email-

Community Server's Suggested use is for development environment. For production purpose
  Enterprise offering is required.

Please be sure before using the version.

Hoping this will help you :)

Title: Why not mongodb?


答:
I know this is Excel VBA question and it cannot be done with built-in formulae. In Google Sheets, you can do achieve this with built-in functions only. When 'a1' is on B1 and 'u1' is on A3, you can get the table with just one formula. Sample sheet is here.

```<code>=transpose(
  split(
   concatenate(
    arrayformula(
     if(B3:G8="x", "u"&(row(B3:G8)-row($A$3)+1)&" a"&(column(B3:G8)-column($B$1)+1)&char(10), "")
    )
   ), char(10)
  )
 )
</code>```

Title: Excel Macro to pick values from one table/array to another

Body:
I know this is Excel VBA question and it cannot be done with built-in formulae. In Google Sheets, you can do achieve this with built-in functions only. When 'a1' is on B1 and 'u1' is on A3, you can get the table with just one formula. Sample sheet is here.

=transpose(
  split(
   concatenate(
    arrayformula(
     if(B3:G8="x", "u"&(row(B3:G8)-row($A$3)+1)&" a"&(column(B3:G8)-column($B$1)+1)&char(10), "")
    )
   ), char(10)
  )
 )