问:
How can I fix the "No certificates found - The app Chrome has requested a certificate" Android / Google Chrome issue

The issue

Some of our website users are encountering an issue when accessing secure areas of our website, on Android devices, in Google Chrome.

It looks like this;

I've been able to replicate the issue on the following devices using Browserstack's physical device testing;

Samsung Galaxy S6, Samsung Galaxy S5, Samsung Galaxy S4 (Android v5 and v4.4)

Nexus 6 (Android v6, v5 and v4.4)

Moto X 2nd Gen (Android v6 and v5)

My research

All the articles, forums and questions that I've read online (and there aren't many, unless I'm searching for the wrong thing) point to server and / or SSL certificate setup and configuration, and that the issue being experienced is by design.

Suggested fix 1

The most useful article I've found so far is Issue 268055 "No Certificates Found" on the chromium issue tracker.

Comment 18 suggests changing SSL settings in IIS;

I can fix the issue if you have access to IIS. Basically you need to go to SSL Settings and make sure Require SSL is unchecked and that "Ignore" is selected for Client Certificates.

Comment 28 backs it up;

For the non-Googler case, this error message only occurs when you encounter a site that requests a client certificate. There's nothing that Chrome can do here - the site has requested a client certificate, and to even know if a client certificate is valid, Chrome for Android has to ask the OS. That's the prompt you're seeing - it's controlled by Android and all apps (Google or otherwise) are required to go through that flow.

This will occur with any site configured to request client certificates, so to resolve this, either don't request client certificates, or configure your Android devices to have client certificates (e.g. via a device management application or via installing a PKCS#12 file).

kamakshi: This is all "By Design" behaviour, but requires server operators to change, so I'm not sure what to do with this bug.

As does comment 43;

I don't think people on this bug would know much about configuring IIS. You'd want to talk with Microsoft about that. From searching around, "Ignore Client Certificate" seems to be the option you want.

We've done that but it doesn't seem to have made a difference.

Suggested fix 2

Another question here on Stack ("certificate trusted on pc but not in android") suggests that an intermediate certificate might be missing;

You might be missing an intermediate certificate in your cert file. If you have already visited another website which has the same certificate seller, the intermediate certificate is remembered in your browser. This might not - or even better - will not be the case with every visitor to your website. To solve a missing intermediate certificate in the SSL connection, you will need to add the intermediate certificate to your own certificate file.

I've checked and we have a domain certificate (which isn't a wildcard certificate), an intermediate certificate and a root certificate, so I don't think that's the issue either. I've also run a site checker test on the Networking4all website, and an SSL test on the Qualys SSL website and they both path without errors or warnings.

My question

Has anyone else encountered this issue? Are there any other solutions that we can try to fix it? I'm out of ideas at this point so any advice would be hugely appreciated.

Some extra details just in case

The server the website is on is running Windows Server 2008 R2 and IIS 7.5, and our SSL certificate provider is Thawte.

Thanks in advance!

答:
Having just resolved this exact same issue, here's what I found...

Server Specs (essentially the same as O.P)

Windows Server 2008 r2

IIS 7.5

SSL Provider: GeoTrust RapidSSL

First Issue: Out of Date Cryptographic Policies

Several articles pointed out the server may have out of date cryptographic policies. A bit of research revealed everything must be configured using registry settings. See the MS Support article How to restrict the use of certain cryptographic algorithms and protocols in Schannel.dll for detailed information.

Not sure if your sever is up to date? SSL Labs' Server Test is a great tool for validating your site's cryptographic policies.

Manually Edit the Registry?

The MS Support article details editing the registry keys. Aack! A bit more research and I found a great utility called IIS Crypto by Nartac Software that will update all the registry keys in a single click. FYI: a reboot is required as well.

From the Nartac Software site:

IIS Crypto is a free tool that gives administrators the ability to
enable or disable protocols, ciphers, hashes and key exchange
algorithms on Windows Server 2008, 2012 and 2016. It also lets you
reorder SSL/TLS cipher suites offered by IIS, implement best practices
with a single click, create custom templates and test your website.

Second Issue: Incorrect IIS SSL Site Settings

The root of this issue due to the default of IIS setting the SSL Settings to "Accept" Client certificates. There is no need to accept client certs, so simply set the setting as "Ignore" (from the O.P.'s suggested fix #1 image).

Note: The image shows "Require SSL" is unchecked; for this discussion, whether it is checked is not relevant. All that matters is the site can connect using https.

Wrap Up

Once the server has the cryptographic policies reconfigured and the IIS SSL Settings have been set to ignore client certs, the "No certificates found" error will be resolved.


来源: stackexchange

问:
iPhone - wont let compile apps from the Xcode
I updated the iPhone 7 OS and now i cant submit my apps in iPhone 7 from my Xcode, constantly failing. How do i fix it?

Before updating my OSX and iPhone 7, all was working but since i updated the OSX and iPhone 7, now Xcode is failing with my stable app which was working before updates.

EDIT: after Xcode update, throwing new warning / build error

答: You need Xcode 8.3 (just download via App Store). Xcode 8.2.1 is not compatible with iOS 10.3 on your phone.</p>

ContentLicense: CC BY-SA 3.0


问:
restart terminated emr cluster
I terminated an existing cluster to not incur costs. Can I somehow restart this cluster. Is cloning = restart? Thanks and sorry about my ignorance.</p>

答:
No, cloning is not restarting.

If you fully automated your cluster with, i.e., bootstrap actions and cluster steps, then cloning will be the exact same. It takes the configuration and re-launches that. But if you SSH'd in and executed manual commands, you will not be able to get that back..

One of the key things with EMR is that it is ephemeral

Title: restart terminated emr cluster


问:
FFMPEG: FFPLAY binary not getting generated on compilation
I have downloaded FFMPEG with FFPLAY enabled code from: https://github.com/cus/ffplay

I use the following command to configure and make the package:

```<code>./configure --enable-ffplay
make
</code>```

Here it shows that:
SDL support               no
as one of the outputs. But i have sdl packages installed in my system.

However, the packages created are:

```<code>ffmpeg
ffmpeg_g
ffserver
ffserver_g
ffprobe
ffprobe_g
</code>```

I have referred this post : http://ffmpeg-users.933282.n4.nabble.com/Compiling-FFMPEG-with-ffplay-support-td3414041.html But this didn't help out.

I checked my config.log, it has the below lines:

```<code>ffplay='yes'
ffplay_deps='avcodec avformat swscale swresample sdl'
ffplay_select='rdft crop_filter'
</code>```

I have the sdl packages installed in my system. What is the issue actually. Could anyone please guide me through this.

答:
I was spent 2 weeks to install newest version ffmpeg 2.8.11. This version is used for Ubuntu 16.04. I advise you should install this version. I tested on Ubuntu 12.04 and Ubuntu 14.04 and it worked well. You can install libav-tools like directions above but you will have a problem about compatibility. Because libav-tools and ffmpeg now was developed by two different group.
Following my directions. If you have any problem can sent me via an email: hohaidang.khtn@gmail.com

```<code>$ sudo apt-get update
$ sudo apt-get -y install build-essential checkinstall git libfaac-dev libgpac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev librtmp-dev libtheora-dev libvorbis-dev pkg-config texi2html yasm zlib1g-dev  libavcodec-extra-53
$ sudo apt-get -y install autoconf automake build-essential libass-dev libfreetype6-dev libtool libva-dev libvdpau-dev libvorbis-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev pkg-config texinfo zlib1g-dev
$ sudo apt-get install libdc1394-22 libdc1394-22-dev libgsm1 libgsm1-dev libopenjpeg-dev libschroedinger-1.0-0 libschroedinger-dev libschroedinger-doc libspeex-dev libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libsdl1.2-dev libtheora-dev libvorbis-dev libx11-dev libxfixes-dev libxvidcore-dev libx264-dev
$ wget https://www.ffmpeg.org/releases/ffmpeg-2.8.11.tar.xz
$ tar xf ffmpeg-2.8.11.tar.xz
$ cd ffmpeg-2.8.11/
./configure --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-x11grab --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libdc1394 --enable-libfaac --enable-libgsm --enable-libmp3lame --enable-libopenjpeg --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --disable-yasm // disable yasm if you are using Ubuntu 12.04, if not --enable-yasm
$ make
$ sudo make install
</code>```

Check ffmpeg, ffserver, ffplay, ffprobe in terminal.
Good luck

Body:
I have downloaded FFMPEG with FFPLAY enabled code from: https://github.com/cus/ffplay

I use the following command to configure and make the package:

./configure --enable-ffplay
make

Here it shows that:
SDL support               no
as one of the outputs. But i have sdl packages installed in my system.

However, the packages created are:

ffmpeg
ffmpeg_g
ffserver
ffserver_g
ffprobe
ffprobe_g

I have referred this post : http://ffmpeg-users.933282.n4.nabble.com/Compiling-FFMPEG-with-ffplay-support-td3414041.html But this didn't help out.

I checked my config.log, it has the below lines:

ffplay='yes'
ffplay_deps='avcodec avformat swscale swresample sdl'
ffplay_select='rdft crop_filter'

I have the sdl packages installed in my system. What is the issue actually. Could anyone please guide me through this.

Body:
I was spent 2 weeks to install newest version ffmpeg 2.8.11. This version is used for Ubuntu 16.04. I advise you should install this version. I tested on Ubuntu 12.04 and Ubuntu 14.04 and it worked well. You can install libav-tools like directions above but you will have a problem about compatibility. Because libav-tools and ffmpeg now was developed by two different group.
Following my directions. If you have any problem can sent me via an email: hohaidang.khtn@gmail.com

$ sudo apt-get update
$ sudo apt-get -y install build-essential checkinstall git libfaac-dev libgpac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev librtmp-dev libtheora-dev libvorbis-dev pkg-config texi2html yasm zlib1g-dev  libavcodec-extra-53
$ sudo apt-get -y install autoconf automake build-essential libass-dev libfreetype6-dev libtool libva-dev libvdpau-dev libvorbis-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev pkg-config texinfo zlib1g-dev
$ sudo apt-get install libdc1394-22 libdc1394-22-dev libgsm1 libgsm1-dev libopenjpeg-dev libschroedinger-1.0-0 libschroedinger-dev libschroedinger-doc libspeex-dev libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libsdl1.2-dev libtheora-dev libvorbis-dev libx11-dev libxfixes-dev libxvidcore-dev libx264-dev
$ wget https://www.ffmpeg.org/releases/ffmpeg-2.8.11.tar.xz
$ tar xf ffmpeg-2.8.11.tar.xz
$ cd ffmpeg-2.8.11/
./configure --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-x11grab --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libdc1394 --enable-libfaac --enable-libgsm --enable-libmp3lame --enable-libopenjpeg --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --disable-yasm // disable yasm if you are using Ubuntu 12.04, if not --enable-yasm
$ make
$ sudo make install

Check ffmpeg, ffserver, ffplay, ffprobe in terminal.
Good luck


问:
Getting exception while using JAX-RS response class to return the entity
When I use the below code I get the exception. It looked to be jar issue, to conform it I uncommented the commented code and it worked fine.

Message class is annotated with @XmlRootElement, so that should not be an issue as well.

getting exception - org.glassfish.jersey.message.internal.MessageBodyProviderNotFoundException: MessageBodyWriter not found for media type=application/json, type=class java.util.ArrayList, genericType=class java.util.ArrayList.

```<code>@Path("/messages")
@Singleton
public class MessageResource {

MessageService service = new MessageService();

@GET
@Produces(MediaType.APPLICATION_JSON)
public Response getMessages(@BeanParam MessageBean bean) {

    List<Message> messages;

    if (bean.getYear() > 0)
        messages = service.getMessagesForYearById(bean.getYear());
    messages = service.getMessages();

    return Response.ok().entity(messages).build();
}

// @GET
// @Produces(MediaType.APPLICATION_JSON)
// public List<Message> getMessages(@BeanParam MessageBean bean) {
//
// List<Message> messages;
//
// if (bean.getYear() > 0)
// messages = service.getMessagesForYearById(bean.getYear());
// messages = service.getMessages();
//
//
// return messages;
// }
</code>```

}

```<code> <servlet>
        <servlet-name>Jersey Web Application</servlet-name>
        <servletclass>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
        <init-param>
            <param-name>jersey.config.server.provider.packages</param-name>
            <param-value>testing.jaxrs.Messages</param-value>
        </init-param>
    </servlet>
    <servlet-mapping>
        <servlet-name>Jersey Web Application</servlet-name>
        <url-pattern>/webapi/*</url-pattern>
    </servlet-mapping>
</code>```

答:
```<code>List<Message> messages
Response.ok().entity(messages)
</code>```

This leads to a type loss carried by the Collection due to type erasure at runtime. Wrap the collection with GenericEntity to preserve its type information:

```<code>GenericEntity generic = new GenericEntity<List<Message>>(messages){};
return Response.ok().entity(generic).build();
</code>```

Body:
When I use the below code I get the exception. It looked to be jar issue, to conform it I uncommented the commented code and it worked fine.

Message class is annotated with @XmlRootElement, so that should not be an issue as well.

getting exception - org.glassfish.jersey.message.internal.MessageBodyProviderNotFoundException: MessageBodyWriter not found for media type=application/json, type=class java.util.ArrayList, genericType=class java.util.ArrayList.

@Path("/messages")
@Singleton
public class MessageResource {

MessageService service = new MessageService();

@GET
@Produces(MediaType.APPLICATION_JSON)
public Response getMessages(@BeanParam MessageBean bean) {

    List<Message> messages;

    if (bean.getYear() > 0)
        messages = service.getMessagesForYearById(bean.getYear());
    messages = service.getMessages();

    return Response.ok().entity(messages).build();
}

// @GET
// @Produces(MediaType.APPLICATION_JSON)
// public List<Message> getMessages(@BeanParam MessageBean bean) {
//
// List<Message> messages;
//
// if (bean.getYear() > 0)
// messages = service.getMessagesForYearById(bean.getYear());
// messages = service.getMessages();
//
//
// return messages;
// }

}

 <servlet>
        <servlet-name>Jersey Web Application</servlet-name>
        <servletclass>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
        <init-param>
            <param-name>jersey.config.server.provider.packages</param-name>
            <param-value>testing.jaxrs.Messages</param-value>
        </init-param>
    </servlet>
    <servlet-mapping>
        <servlet-name>Jersey Web Application</servlet-name>
        <url-pattern>/webapi/*</url-pattern>
    </servlet-mapping>

Body:
List<Message> messages
Response.ok().entity(messages)

This leads to a type loss carried by the Collection due to type erasure at runtime. Wrap the collection with GenericEntity to preserve its type information:

GenericEntity generic = new GenericEntity<List<Message>>(messages){};
return Response.ok().entity(generic).build();


问:
Animate div from bottom to top and back
I have a div element which represents a navigation bar and has the id #navbar. It is positioned absolutely and is set to bottom: 20px;. Now I want it to move to the top, while keeping a 20px distance to the top, on the click of a button. When clicking the button again it should move back to the bottom of the page (again keeping the 20px distance) even if the window has been resized. In general, the resizing of the window should have no effect on the navigation bar. Here is the JavaScript code I have.

```<code>var isUp = false;
function animate() {
    if(!isUp) {
        $("#navbar").animate({top: 20}, 2000);
    } else {
        $("#navbar").animate({bottom: 20}, 2000);
    }
}
</code>```

But it doesn't work and the bar always ends up in the middle of the page. Any help is greatly appreciated.

EDIT:
Here is an example: https://jsfiddle.net/6knLw3a3/

答: I found a solution: Wrap the navbar element in an overlay div. Set this overlay div to lay above all other elements and make it transparent. Position the navbar at the top of the overlay. Now simply set the height of the overlay. </p>

Title: Animate div from bottom to top and back

Body:
I have a div element which represents a navigation bar and has the id #navbar. It is positioned absolutely and is set to bottom: 20px;. Now I want it to move to the top, while keeping a 20px distance to the top, on the click of a button. When clicking the button again it should move back to the bottom of the page (again keeping the 20px distance) even if the window has been resized. In general, the resizing of the window should have no effect on the navigation bar. Here is the JavaScript code I have.

var isUp = false;
function animate() {
    if(!isUp) {
        $("#navbar").animate({top: 20}, 2000);
    } else {
        $("#navbar").animate({bottom: 20}, 2000);
    }
}

But it doesn't work and the bar always ends up in the middle of the page. Any help is greatly appreciated.

EDIT:
Here is an example: https://jsfiddle.net/6knLw3a3/


问:
Give the columnrange different colors
I have built some HighChart and I would like to give the 3 columnrange different colors (And not just blue as the current highChart Please see the jsfiddel link below)  to make it simple for persons to see the difference when taking a look at my HighChart.

https://jsfiddle.net/LLExL/7281/

```<code>Highcharts.chart('container',
 {
     chart: {
         type: 'columnrange',
         inverted: true,
         height: 200,
         spacingLeft: 30
     },
     credits: {
         enabled: false
     },
     title: {
         text: null,
         style: {
             "fontSize": "10px"
         }
     },
     subTitle: {
         text: null
     },
     legend: {
         enabled: false,
     },
     plotOptions: {
         series: {
             pointWidth: 30
         }
     },
     xAxis: {
         min: 1,
         max: 1,
         categories: ['', ''],
         title: {
             text: null
         },
         labels: {
             rotation: 90
         },
         gridLineWidth: 0
     },
     yAxis: {
         type: 'datetime',
         title: {
             text: null
         },
         labels: {
             rotation: -45,
             style: {
                 "fontSize": "10px"
             }
         },
         tickInterval: 1800000,
         gridLineWidth: 1
     },
     series: [{
         data: [
             [1, 1483337940000, 1483338000000],
             [1, 1483338300000, 1483339740000],
             [1, 1483340580000, 1483340640000],
             [1, 1483340640000, 1483340820000],
             [1, 1483340820000, 1483341000000],
             [1, 1483342800000, 1483342860000],
             [1, 1483342860000, 1483342920000],
             [1, 1483342920000, 1483342980000],
             [1, 1483346460000, 1483346520000],
             [1, 1483347120000, 1483347180000],
             [1, 1483347180000, 1483348440000],
             [1, 1483348440000, 1483348620000],
             [1, 1483348620000, 1483348740000],
             [1, 1483350180000, 1483350240000],
             [1, 1483350420000, 1483351380000],
             [1, 1483353300000, 1483353420000],
             [1, 1483355280000, 1483355340000],
             [1, 1483358580000, 1483359780000],
         ]
     }]
 }

);
</code>```

答:
Zones would probably be better for you here. That way the color belongs to the chart not the data. Zone value represents up to next x range.

Here's the example for Highcharts docs:

```<code>Highcharts.chart('container', {
    series: [{
        data: [-10, -5, 0, 5, 10, 15, 10, 10, 5, 0, -5],
        zones: [{
            value: 0,
            color: '#f7a35c'
        }, {
            value: 10,
            color: '#7cb5ec'
        }, {
            color: '#90ed7d'
        }]
    }]
});
</code>```

http://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/series/color-zones-simple/

Also see: http://api.highcharts.com/highcharts/plotOptions.column.zones

Title: Give the columnrange different colors

Body:
I have built some HighChart and I would like to give the 3 columnrange different colors (And not just blue as the current highChart Please see the jsfiddel link below)  to make it simple for persons to see the difference when taking a look at my HighChart.

https://jsfiddle.net/LLExL/7281/

Highcharts.chart('container',
 {
     chart: {
         type: 'columnrange',
         inverted: true,
         height: 200,
         spacingLeft: 30
     },
     credits: {
         enabled: false
     },
     title: {
         text: null,
         style: {
             "fontSize": "10px"
         }
     },
     subTitle: {
         text: null
     },
     legend: {
         enabled: false,
     },
     plotOptions: {
         series: {
             pointWidth: 30
         }
     },
     xAxis: {
         min: 1,
         max: 1,
         categories: ['', ''],
         title: {
             text: null
         },
         labels: {
             rotation: 90
         },
         gridLineWidth: 0
     },
     yAxis: {
         type: 'datetime',
         title: {
             text: null
         },
         labels: {
             rotation: -45,
             style: {
                 "fontSize": "10px"
             }
         },
         tickInterval: 1800000,
         gridLineWidth: 1
     },
     series: [{
         data: [
             [1, 1483337940000, 1483338000000],
             [1, 1483338300000, 1483339740000],
             [1, 1483340580000, 1483340640000],
             [1, 1483340640000, 1483340820000],
             [1, 1483340820000, 1483341000000],
             [1, 1483342800000, 1483342860000],
             [1, 1483342860000, 1483342920000],
             [1, 1483342920000, 1483342980000],
             [1, 1483346460000, 1483346520000],
             [1, 1483347120000, 1483347180000],
             [1, 1483347180000, 1483348440000],
             [1, 1483348440000, 1483348620000],
             [1, 1483348620000, 1483348740000],
             [1, 1483350180000, 1483350240000],
             [1, 1483350420000, 1483351380000],
             [1, 1483353300000, 1483353420000],
             [1, 1483355280000, 1483355340000],
             [1, 1483358580000, 1483359780000],
         ]
     }]
 }

);

Body:
Zones would probably be better for you here. That way the color belongs to the chart not the data. Zone value represents up to next x range.

Here's the example for Highcharts docs:

Highcharts.chart('container', {
    series: [{
        data: [-10, -5, 0, 5, 10, 15, 10, 10, 5, 0, -5],
        zones: [{
            value: 0,
            color: '#f7a35c'
        }, {
            value: 10,
            color: '#7cb5ec'
        }, {
            color: '#90ed7d'
        }]
    }]
});

http://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/series/color-zones-simple/

Also see: http://api.highcharts.com/highcharts/plotOptions.column.zones


问:
Convert text table to pandas dataframe
Many times when I'm trying to answer questions on Stackoverflow, the question contains a table, which I have to convert to a pandas dataframe in order to process. for example, in this question:

```<code>http://stackoverflow.com/questions/43172116/pandas-count-some-value-in-all-columns
</code>```

My question is, is there a faster way to convert it to a dataframe rather than writing:

```<code>df=pd.DataFrame({'graph':[1,2,3,4,5,6],
0:['blue','blue','red','red','blue','blue'],
1:['blue','blue','red','blue','red','blue'],
2:['blue','blue','blue','red','blue','blue'],
3:['blue','blue','blue','red','red','blue'],
4:['blue','blue','red','blue','red','blue']})
</code>```

given that I can copy the text:

```<code>graph   0       1       2       3       4
1       blue    blue    blue    blue    blue
2       blue    blue    blue    blue    blue
3       blue    red     blue    blue    red
4       red     blue    red     red     blue
5       red     red     blue    red     red
6       blue    blue    blue    blue    blue
</code>```

答:
Make sure the desired data set is in clipboard and use pd.read_clipboard() method.

Step by step:

mark desired data set

press Ctrl+C (for MS Windows)

execute: df = pd.read_clipboard()

```<code>In [40]: df = pd.read_clipboard()

In [41]: df
Out[41]:
   graph     0     1     2     3     4
0      1  blue  blue  blue  blue  blue
1      2  blue  blue  blue  blue  blue
2      3  blue   red  blue  blue   red
3      4   red  blue   red   red  blue
4      5   red   red  blue   red   red
5      6  blue  blue  blue  blue  blue
</code>```

Title: Convert text table to pandas dataframe

Body:
Many times when I'm trying to answer questions on Stackoverflow, the question contains a table, which I have to convert to a pandas dataframe in order to process. for example, in this question:

http://stackoverflow.com/questions/43172116/pandas-count-some-value-in-all-columns

My question is, is there a faster way to convert it to a dataframe rather than writing:

df=pd.DataFrame({'graph':[1,2,3,4,5,6],
0:['blue','blue','red','red','blue','blue'],
1:['blue','blue','red','blue','red','blue'],
2:['blue','blue','blue','red','blue','blue'],
3:['blue','blue','blue','red','red','blue'],
4:['blue','blue','red','blue','red','blue']})

given that I can copy the text:

graph   0       1       2       3       4
1       blue    blue    blue    blue    blue
2       blue    blue    blue    blue    blue
3       blue    red     blue    blue    red
4       red     blue    red     red     blue
5       red     red     blue    red     red
6       blue    blue    blue    blue    blue

Body:
Make sure the desired data set is in clipboard and use pd.read_clipboard() method.

Step by step:

mark desired data set

press Ctrl+C (for MS Windows)

execute: df = pd.read_clipboard()

In [40]: df = pd.read_clipboard()

In [41]: df
Out[41]:
   graph     0     1     2     3     4
0      1  blue  blue  blue  blue  blue
1      2  blue  blue  blue  blue  blue
2      3  blue   red  blue  blue   red
3      4   red  blue   red   red  blue
4      5   red   red  blue   red   red
5      6  blue  blue  blue  blue  blue


问:
Android Bitmap Downscaling
What is the best method to downscale a bitmap image on Android using Java if the goal is to preserve the quality of lines/edges, as much as possible? The intent is to use these downscaled images to train a neural network.

Each image will contain a single character (in this case Chinese). The picture below shows the original image produced on a View object, drawn by the user. My goal is to shrink this bitmap image to a resolution of 30 by 30 pixels.

I am currently using the Bitmap createScaledBitmap method at the moment but am wondering if there are any algorithms/methods that optimize for this kind of character downscaling.

```<code>drawView.buildDrawingCache();
Bitmap b = Bitmap.createScaledBitmap(drawView.getDrawingCache(), 30, 30, false);
saveImage(b);  // Saves image to disk.
drawView.destroyDrawingCache();
</code>```

Another factor could be the relation between line width and image size overall. The line width is currently 20f. I've found that at 30f, I start to get large dark clumps and at 10f, I lose a lot of information when I downscale.

Yet another factor could be resulting image size. However, if I go too big, then the amount of computation it takes to train the network might become too large.

Original image.

Here's the processed image - it doesn't look too bad, but I'm worried with other characters, there might not be enough variation for the neural network to learn.

答:
A first solution, coming into my mind was to vectorize this image and then redraw it again. You wrote that image is drawn by a user, so you even don't need to vectorize the image. All you need to do is save user input as a list of points and reproduce (draw) it in the desired scale.

User, drawing a line from (10, 10) to (20, 10) on canvas with size 100 x 100 px, will see line from (3, 3) to (6, 3) on thumbnail with size 30 x 30 px. Then you can also easily apply the line thickness depending on the final image scale.

Of course, for better performance, you should generate and cache some bitmaps instead of drawing them again and again when a user displays them.

Title: Android Bitmap Downscaling

Body:
What is the best method to downscale a bitmap image on Android using Java if the goal is to preserve the quality of lines/edges, as much as possible? The intent is to use these downscaled images to train a neural network.

Each image will contain a single character (in this case Chinese). The picture below shows the original image produced on a View object, drawn by the user. My goal is to shrink this bitmap image to a resolution of 30 by 30 pixels.

I am currently using the Bitmap createScaledBitmap method at the moment but am wondering if there are any algorithms/methods that optimize for this kind of character downscaling.

drawView.buildDrawingCache();
Bitmap b = Bitmap.createScaledBitmap(drawView.getDrawingCache(), 30, 30, false);
saveImage(b);  // Saves image to disk.
drawView.destroyDrawingCache();

Another factor could be the relation between line width and image size overall. The line width is currently 20f. I've found that at 30f, I start to get large dark clumps and at 10f, I lose a lot of information when I downscale.

Yet another factor could be resulting image size. However, if I go too big, then the amount of computation it takes to train the network might become too large.

Original image.

Here's the processed image - it doesn't look too bad, but I'm worried with other characters, there might not be enough variation for the neural network to learn.


问:
Multiplying certain elements within an array
I am coding an nth term of a mathematical sequence generator. I'm just experimenting with the first seven terms for now.

The user enters 1,2,3,4,5,6 and 7 (or any other consecutive values) into the sequence, then the program should multiply the 1st, then every other term entered by 8 (so in this case the 1st, 3rd, 5th and 7th numbers entered).

It should also multiply the 2nd then every other term entered by 2 (so in this case the 2nd, 4th and 6th numbers entered).

Afterwards, I want it to add everything together. Here is what I tried to do:

```<code>x = [0,0,0,0,0,0,0]
for n in range (0,7):
    x[n] = int(input("Input the digits of the sequence one by one:"))
    if x[n] == x[0] or x[2] or x[4] or x[6]:
        x[n] == x[n]*8

    elif x[n] == x[1] or x[3] or x[5]:
        x[n] == x[n]*2

    else:
        break

finalnumber = x[0]+x[1]+x[2]+x[3]+x[4]+x[5]+x[6]
print(finalnumber)
</code>```

I inputted 1,2,3,4,5,6 and 7 and calculated myself that the finalnumber should be 152, however this program for some reason printed 28.

Please tell me what I have done wrong.

I am using Python 3.6.

答:
Instead of x[n] == x[n]*8
You should write

```<code>x[n] = x[n]*8
</code>```

Because double equalmark returns a bool, True or False, it depends on result as mentioned in comments it is used typically with if statements, single equalmark means assigning.
Of course the same situation happens when you want to multiply by 2 in second statement.
I meant:

```<code>x[n] = x[n]*2
</code>```

Body:
I am coding an nth term of a mathematical sequence generator. I'm just experimenting with the first seven terms for now.

The user enters 1,2,3,4,5,6 and 7 (or any other consecutive values) into the sequence, then the program should multiply the 1st, then every other term entered by 8 (so in this case the 1st, 3rd, 5th and 7th numbers entered).

It should also multiply the 2nd then every other term entered by 2 (so in this case the 2nd, 4th and 6th numbers entered).

Afterwards, I want it to add everything together. Here is what I tried to do:

x = [0,0,0,0,0,0,0]
for n in range (0,7):
    x[n] = int(input("Input the digits of the sequence one by one:"))
    if x[n] == x[0] or x[2] or x[4] or x[6]:
        x[n] == x[n]*8

    elif x[n] == x[1] or x[3] or x[5]:
        x[n] == x[n]*2

    else:
        break

finalnumber = x[0]+x[1]+x[2]+x[3]+x[4]+x[5]+x[6]
print(finalnumber)

I inputted 1,2,3,4,5,6 and 7 and calculated myself that the finalnumber should be 152, however this program for some reason printed 28.

Please tell me what I have done wrong.

I am using Python 3.6.

Body:
Instead of x[n] == x[n]*8
You should write

x[n] = x[n]*8

Because double equalmark returns a bool, True or False, it depends on result as mentioned in comments it is used typically with if statements, single equalmark means assigning.
Of course the same situation happens when you want to multiply by 2 in second statement.
I meant:

x[n] = x[n]*2


问:
What is the difference between entropy, energy, mean, skewness, variance, inertia and kurtosis in image processing?
I am reading in Feature Extraction in Medical Imaging field, especially in brain tumor detection, and I had found the above feature extraction and I don't understand the difference between them.</p>

答: The various features that can be calculated from the co-occurrence matrices (C) are inertia (contrast), absolute value, inverse difference, energy, and entropy. Contrast is the element difference moment of order 2, which has a relatively low value when the high values of C are near the main diagonal. Energy value is highest when all values in the co-occurrence matrix are all equal. (Sigma(i) Sigma (j) cij^2). Entropy of the image is the measure of randomness of the image gray levels. ( -1*Sigma(i) Sigma (j) cij^2 * log cij^2 (with base 2))</p>


问:
trigger one MDL dialog with two different buttons
I'm using the Material Design Lite and I want to trigger one dialog using two different buttons.

I have a working example for one button but I'm not sure how to trigger it with the second button.

Any ideas?

(function() {
  'use strict';
  var dialogButton = document.querySelector('.dialog-button');
  var dialog = document.querySelector('#dialog');
  if (!dialog.showModal) {
    dialogPolyfill.registerDialog(dialog);
  }
  dialogButton.addEventListener('click', function() {
    dialog.showModal();
  });
  dialog.querySelector('button:not([disabled])')
    .addEventListener('click', function() {
      dialog.close();
    });
}());```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body {
  padding-top: 20px;
  padding-left: 20px;
  box-sizing: border-box;
}

.mdl-dialog {
  border: none;
  box-shadow: 0 9px 46px 8px rgba(0, 0, 0, 0.14), 0 11px 15px -7px rgba(0, 0, 0, 0.12), 0 24px 38px 3px rgba(0, 0, 0, 0.2);
  width: 280px;
}

.mdl-dialog__title {
  padding: 24px 24px 0;
  margin: 0;
  font-size: 2.5rem;
}

.mdl-dialog__actions {
  padding: 8px 8px 8px 24px;
  display: -webkit-flex;
  display: -ms-flexbox;
  display: flex;
  -webkit-flex-direction: row-reverse;
  -ms-flex-direction: row-reverse;
  flex-direction: row-reverse;
  -webkit-flex-wrap: wrap;
  -ms-flex-wrap: wrap;
  flex-wrap: wrap;
}

.mdl-dialog__actions>* {
  margin-right: 8px;
  height: 36px;
}

.mdl-dialog__actions>*:first-child {
  margin-right: 0;
}

.mdl-dialog__actions--full-width {
  padding: 0 0 8px 0;
}

.mdl-dialog__actions--full-width>* {
  height: 48px;
  -webkit-flex: 0 0 100%;
  -ms-flex: 0 0 100%;
  flex: 0 0 100%;
  padding-right: 16px;
  margin-right: 0;
  text-align: right;
}

.mdl-dialog__content {
  padding: 20px 24px 24px 24px;
  color: rgba(0, 0, 0, 0.54);
}</code>```

<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/dialog-polyfill/0.4.2/dialog-polyfill.min.css" rel="stylesheet">
<link href="https://storage.googleapis.com/code.getmdl.io/1.0.6/material.indigo-pink.min.css" rel="stylesheet">

<button class="mdl-button mdl-button--raised mdl-js-button dialog-button">Show Dialog (working)</button>

<button class="mdl-button mdl-button--raised mdl-js-button dialog-button">Show Dialog (not working)</button>

  Remember that the Dialog component requires the Dialog polyfill in order to function. It takes advantage of the native dialog element to provide the most robust experience possible.

<dialog id="dialog" class="mdl-dialog">

MDL Dialog

      This is an example of the Material Design Lite dialog component. Please use responsibly.

    <button type="button" class="mdl-button">Close</button>

</dialog>

```

答:
Javascript querySelector returns the first one if a query returns multiple results. Because of this, you need to make seperate ID's for each button to bind the action to each button.

(function() {
  'use strict';
  var dialogButton1 = document.querySelector('#dialog-button-1');
  var dialogButton2 = document.querySelector('#dialog-button-2');

  var dialog = document.querySelector('#dialog');
  if (!dialog.showModal) {
    dialogPolyfill.registerDialog(dialog);
  }
  dialogButton1.addEventListener('click', function() {
    dialog.showModal();
  });
  dialogButton2.addEventListener('click', function() {
    dialog.showModal();
  });
  dialog.querySelector('button:not([disabled])')
    .addEventListener('click', function() {
      dialog.close();
    });
}());```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body {
  padding-top: 20px;
  padding-left: 20px;
  box-sizing: border-box;
}

.mdl-dialog {
  border: none;
  box-shadow: 0 9px 46px 8px rgba(0, 0, 0, 0.14), 0 11px 15px -7px rgba(0, 0, 0, 0.12), 0 24px 38px 3px rgba(0, 0, 0, 0.2);
  width: 280px;
}

.mdl-dialog__title {
  padding: 24px 24px 0;
  margin: 0;
  font-size: 2.5rem;
}

.mdl-dialog__actions {
  padding: 8px 8px 8px 24px;
  display: -webkit-flex;
  display: -ms-flexbox;
  display: flex;
  -webkit-flex-direction: row-reverse;
  -ms-flex-direction: row-reverse;
  flex-direction: row-reverse;
  -webkit-flex-wrap: wrap;
  -ms-flex-wrap: wrap;
  flex-wrap: wrap;
}

.mdl-dialog__actions>* {
  margin-right: 8px;
  height: 36px;
}

.mdl-dialog__actions>*:first-child {
  margin-right: 0;
}

.mdl-dialog__actions--full-width {
  padding: 0 0 8px 0;
}

.mdl-dialog__actions--full-width>* {
  height: 48px;
  -webkit-flex: 0 0 100%;
  -ms-flex: 0 0 100%;
  flex: 0 0 100%;
  padding-right: 16px;
  margin-right: 0;
  text-align: right;
}

.mdl-dialog__content {
  padding: 20px 24px 24px 24px;
  color: rgba(0, 0, 0, 0.54);
}</code>```

<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/dialog-polyfill/0.4.2/dialog-polyfill.min.css" rel="stylesheet">
<link href="https://storage.googleapis.com/code.getmdl.io/1.0.6/material.indigo-pink.min.css" rel="stylesheet">

<button class="mdl-button mdl-button--raised mdl-js-button dialog-button" id="dialog-button-1">Show Dialog (working)</button>

<button class="mdl-button mdl-button--raised mdl-js-button dialog-button" id="dialog-button-2">Show Dialog (now working)</button>

  Remember that the Dialog component requires the Dialog polyfill in order to function. It takes advantage of the native dialog element to provide the most robust experience possible.

<dialog id="dialog" class="mdl-dialog">

MDL Dialog

      This is an example of the Material Design Lite dialog component. Please use responsibly.

    <button type="button" class="mdl-button">Close</button>

</dialog>

```

Body:
I'm using the Material Design Lite and I want to trigger one dialog using two different buttons.

I have a working example for one button but I'm not sure how to trigger it with the second button.

Any ideas?

(function() {
  'use strict';
  var dialogButton = document.querySelector('.dialog-button');
  var dialog = document.querySelector('#dialog');
  if (!dialog.showModal) {
    dialogPolyfill.registerDialog(dialog);
  }
  dialogButton.addEventListener('click', function() {
    dialog.showModal();
  });
  dialog.querySelector('button:not([disabled])')
    .addEventListener('click', function() {
      dialog.close();
    });
}());

body {
  padding-top: 20px;
  padding-left: 20px;
  box-sizing: border-box;
}

.mdl-dialog {
  border: none;
  box-shadow: 0 9px 46px 8px rgba(0, 0, 0, 0.14), 0 11px 15px -7px rgba(0, 0, 0, 0.12), 0 24px 38px 3px rgba(0, 0, 0, 0.2);
  width: 280px;
}

.mdl-dialog__title {
  padding: 24px 24px 0;
  margin: 0;
  font-size: 2.5rem;
}

.mdl-dialog__actions {
  padding: 8px 8px 8px 24px;
  display: -webkit-flex;
  display: -ms-flexbox;
  display: flex;
  -webkit-flex-direction: row-reverse;
  -ms-flex-direction: row-reverse;
  flex-direction: row-reverse;
  -webkit-flex-wrap: wrap;
  -ms-flex-wrap: wrap;
  flex-wrap: wrap;
}

.mdl-dialog__actions>* {
  margin-right: 8px;
  height: 36px;
}

.mdl-dialog__actions>*:first-child {
  margin-right: 0;
}

.mdl-dialog__actions--full-width {
  padding: 0 0 8px 0;
}

.mdl-dialog__actions--full-width>* {
  height: 48px;
  -webkit-flex: 0 0 100%;
  -ms-flex: 0 0 100%;
  flex: 0 0 100%;
  padding-right: 16px;
  margin-right: 0;
  text-align: right;
}

.mdl-dialog__content {
  padding: 20px 24px 24px 24px;
  color: rgba(0, 0, 0, 0.54);
}

<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/dialog-polyfill/0.4.2/dialog-polyfill.min.css" rel="stylesheet">
<link href="https://storage.googleapis.com/code.getmdl.io/1.0.6/material.indigo-pink.min.css" rel="stylesheet">

<button class="mdl-button mdl-button--raised mdl-js-button dialog-button">Show Dialog (working)</button>

<button class="mdl-button mdl-button--raised mdl-js-button dialog-button">Show Dialog (not working)</button>

  Remember that the Dialog component requires the Dialog polyfill in order to function. It takes advantage of the native dialog element to provide the most robust experience possible.

<dialog id="dialog" class="mdl-dialog">

MDL Dialog

      This is an example of the Material Design Lite dialog component. Please use responsibly.

    <button type="button" class="mdl-button">Close</button>

</dialog>

Body:
Javascript querySelector returns the first one if a query returns multiple results. Because of this, you need to make seperate ID's for each button to bind the action to each button.

(function() {
  'use strict';
  var dialogButton1 = document.querySelector('#dialog-button-1');
  var dialogButton2 = document.querySelector('#dialog-button-2');

  var dialog = document.querySelector('#dialog');
  if (!dialog.showModal) {
    dialogPolyfill.registerDialog(dialog);
  }
  dialogButton1.addEventListener('click', function() {
    dialog.showModal();
  });
  dialogButton2.addEventListener('click', function() {
    dialog.showModal();
  });
  dialog.querySelector('button:not([disabled])')
    .addEventListener('click', function() {
      dialog.close();
    });
}());

body {
  padding-top: 20px;
  padding-left: 20px;
  box-sizing: border-box;
}

.mdl-dialog {
  border: none;
  box-shadow: 0 9px 46px 8px rgba(0, 0, 0, 0.14), 0 11px 15px -7px rgba(0, 0, 0, 0.12), 0 24px 38px 3px rgba(0, 0, 0, 0.2);
  width: 280px;
}

.mdl-dialog__title {
  padding: 24px 24px 0;
  margin: 0;
  font-size: 2.5rem;
}

.mdl-dialog__actions {
  padding: 8px 8px 8px 24px;
  display: -webkit-flex;
  display: -ms-flexbox;
  display: flex;
  -webkit-flex-direction: row-reverse;
  -ms-flex-direction: row-reverse;
  flex-direction: row-reverse;
  -webkit-flex-wrap: wrap;
  -ms-flex-wrap: wrap;
  flex-wrap: wrap;
}

.mdl-dialog__actions>* {
  margin-right: 8px;
  height: 36px;
}

.mdl-dialog__actions>*:first-child {
  margin-right: 0;
}

.mdl-dialog__actions--full-width {
  padding: 0 0 8px 0;
}

.mdl-dialog__actions--full-width>* {
  height: 48px;
  -webkit-flex: 0 0 100%;
  -ms-flex: 0 0 100%;
  flex: 0 0 100%;
  padding-right: 16px;
  margin-right: 0;
  text-align: right;
}

.mdl-dialog__content {
  padding: 20px 24px 24px 24px;
  color: rgba(0, 0, 0, 0.54);
}

<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/dialog-polyfill/0.4.2/dialog-polyfill.min.css" rel="stylesheet">
<link href="https://storage.googleapis.com/code.getmdl.io/1.0.6/material.indigo-pink.min.css" rel="stylesheet">

<button class="mdl-button mdl-button--raised mdl-js-button dialog-button" id="dialog-button-1">Show Dialog (working)</button>

<br />
<br />

<button class="mdl-button mdl-button--raised mdl-js-button dialog-button" id="dialog-button-2">Show Dialog (now working)</button>

<br />
<br />

<p>
  Remember that the Dialog component requires the <a href="https://github.com/GoogleChrome/dialog-polyfill">Dialog polyfill</a> in order to function. It takes advantage of the native dialog element to provide the most robust experience possible.
</p>

<dialog id="dialog" class="mdl-dialog">
  <h3 class="mdl-dialog__title">MDL Dialog</h3>
  <div class="mdl-dialog__content">
    <p>
      This is an example of the Material Design Lite dialog component. Please use responsibly.
    </p>
  </div>
  <div class="mdl-dialog__actions">
    <button type="button" class="mdl-button">Close</button>
  </div>
</dialog>

<script src="https://cdnjs.cloudflare.com/ajax/libs/dialog-polyfill/0.4.2/dialog-polyfill.min.js"></script>
<script src="https://storage.googleapis.com/code.getmdl.io/1.0.6/material.min.js"></script>


问:
Is this legal ? C++
I have a simple question..
Can i allocate and deallocate memory like this in the operator+ for other object

delete [] p.name;
p.name = new char[strlen(a.name) + 1];

Look at the operator+

```<code>class PlDrustvo{
private:
   char *name;
public:
// Constructors and destructors are implemented.

PlDrustvo operator+(const PlDrustvo &a)
{
    PlDrustvo p(*this);
    if(///////){
        delete [] p.name;
        p.name = new char[strlen(a.name) + 1];
        strcpy(p.name, a.name);
    }

    return p;
}

};
</code>```

答:
Yes, you can do that.  However, it's better to use std::string instead of char*.  If name were a std::string, you could just write p.name = a.name; and it would allocate memory and copy the data automatically.

(std::string also has an operator+ that does string concatenation, so you could join the two names by writing p.name = name + a.name; – I'm guessing that might be what you actually want your operator+ function to do.)

Title: Is this legal ? C++

Body:
I have a simple question..
Can i allocate and deallocate memory like this in the operator+ for other object

delete [] p.name;
p.name = new char[strlen(a.name) + 1];

Look at the operator+

class PlDrustvo{
private:
   char *name;
public:
// Constructors and destructors are implemented.

PlDrustvo operator+(const PlDrustvo &a)
{
    PlDrustvo p(*this);
    if(///////){
        delete [] p.name;
        p.name = new char[strlen(a.name) + 1];
        strcpy(p.name, a.name);
    }

    return p;
}

};


问:
Conditionally Perform difftime in R
I have a data table with devices that are inspected "annually." When the device has an inspection code "AC" (inspection_disposition_cd="AC"), then I need to count the days passed since the inspection record listed in the row directly above it.

The code I am using does the math just fine, however, I am struggling with coding so that ONLY the rows that have the AC code receive this action. Can anyone provide any advice as to how to single out these rows?

This is the working code:

```<code>DispNotClear2$First<-c(0,with(DispNotClear2,difftime(insp_dt[2:length(insp_dt)],insp_dt[1], unit="days")))
DispNotClear2$BETWEEN<-c(0,with(DispNotClear2,diff(insp_dt[1:(length(insp_dt)-1)],unit="days")))}
</code>```

Also, here are 30 rows of sample data from my data table:

```<code>library(data.table)
SampleData <- setDT(structure(list(record_num = c(12354L, 6764L, 9959L, 94L, 16463L,
6859L, 80678L, 87555L, 77980L, 2839L, 4785L, 6082L, 28271L, 54L,
23000L, 2565L, 3507L, 25607L, 106L, 14621L, 33525L, 6335L, 24970L,
4851L, 77057L, 17247L, 14488L, 2754L, 88945L, 2710L), device_num = c("2P4564",
"1P27589", "1P9215", "1P32077", "3P2093", "1P29651", "3P13054",
"1P14559", "3P7242", "1P30282", "1P12286", "1P13149", "3P10127",
"1P18885", "4P5121", "1P14621", "1P6278", "1P35255", "1P28871",
"3P2643", "3P12113", "1P31196", "4P2597", "1W5192", "2P5643",
"3P6750", "3F1928", "1P11978", "1P33505", "1P14572"), year = c(2016,
2011, 2016, 2010, 2011, 2013, 2014, 2015, 2013, 2012, 2015, 2016,
2013, 2015, 2010, 2011, 2011, 2015, 2013, 2012, 2016, 2011, 2015,
2016, 2012, 2016, 2011, 2015, 2010, 2014), inspection_type_cd = c("CATEGORY 1 (1YR)",
"CATEGORY 1 (1YR)", "CATEGORY 1 (1YR)", "CATEGORY 1 (1YR)", "CATEGORY 1 (1YR)",
"CATEGORY 1 (1YR)", "CATEGORY 1 (1YR)", "CATEGORY 1 (1YR)", "CATEGORY 1 (1YR)",
"CATEGORY 1 (1YR)", "CATEGORY 1 (1YR)", "CATEGORY 1 (1YR)", "CATEGORY 1 (1YR)",
"CATEGORY 1 (1YR)", "CATEGORY 1 (1YR)", "CATEGORY 1 (1YR)", "CATEGORY 1 (1YR)",
"CATEGORY 1 (1YR)", "CATEGORY 1 (1YR)", "CATEGORY 1 (1YR)", "CATEGORY 1 (1YR)",
"CATEGORY 1 (1YR)", "CATEGORY 1 (1YR)", "CATEGORY 1 (1YR)", "CATEGORY 1 (1YR)",
"CATEGORY 1 (1YR)", "CATEGORY 1 (1YR)", "CATEGORY 1 (1YR)", "CATEGORY 1 (1YR)",
"CATEGORY 1 (1YR)"), inspection_disposition_cd = c("AC", "AC",
"AC", "AU", "AC", "AC", "AU", "AC", "AC", "AC", "AC", "AU", "AU",
"AU", "AU", "AU", "RD", "AU", "AU", "AC", "AU", "AC", "AU", "AU",
"AC", "AU", "AU", "AC", "AU", "AC"), remarks = c("2015 AFFIRMATION OF CORRECTION",
NA, "2016 AOC", NA, "PENALTY PAID", "2012 AOC", NA, "2015 AFFIRMATION OF CORRECTION",
"2013 AFFIRMATION OF CORRECTION", "2011 CORRECTION", "2015 AFFIRMATION OF CORRECTION",
NA, NA, "2015 CAT1", NA, NA, "AFFIRMATION OF CORRECTION FILED 68 DAYS LATE",
NA, NA, "2012 CORRECTION", "2016 CAT1", "2010 AFFIRMATION OF CORRECTION",
NA, NA, "2012 CORRECTION", "2016 CAT1", NA, "2015 AFFIRMATION OF CORRECTION",
NA, "2013 AOC"), insp_dt = structure(c(16911, 15271, 17060, 14784,
15014, 16009, 16339, 16658, 16044, 15363, 16576, 17151, 16069,
16444, 14714, 15184, 15237, 16631, 16059, 15415, 16979, 14995,
16748, 17137, 15644, 16973, 15211, 16636, 14957, 16087), class = "Date"),
    days_late = c(NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, 68, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA)), .Names = c("record_num", "device_num",
"year", "inspection_type_cd", "inspection_disposition_cd", "remarks",
"insp_dt", "days_late"), class = "data.frame", row.names = c(NA, -30L)))
</code>```

which looks like

```<code>    record_num device_num year inspection_type_cd inspection_disposition_cd                                      remarks    insp_dt days_late
 1:      12354     2P4564 2016   CATEGORY 1 (1YR)                        AC               2015 AFFIRMATION OF CORRECTION 2016-04-20        NA
 2:       6764    1P27589 2011   CATEGORY 1 (1YR)                        AC                                           NA 2011-10-24        NA
 3:       9959     1P9215 2016   CATEGORY 1 (1YR)                        AC                                     2016 AOC 2016-09-16        NA
 4:         94    1P32077 2010   CATEGORY 1 (1YR)                        AU                                           NA 2010-06-24        NA
 5:      16463     3P2093 2011   CATEGORY 1 (1YR)                        AC                                 PENALTY PAID 2011-02-09        NA
 6:       6859    1P29651 2013   CATEGORY 1 (1YR)                        AC                                     2012 AOC 2013-10-31        NA
 7:      80678    3P13054 2014   CATEGORY 1 (1YR)                        AU                                           NA 2014-09-26        NA
 8:      87555    1P14559 2015   CATEGORY 1 (1YR)                        AC               2015 AFFIRMATION OF CORRECTION 2015-08-11        NA
 9:      77980     3P7242 2013   CATEGORY 1 (1YR)                        AC               2013 AFFIRMATION OF CORRECTION 2013-12-05        NA
10:       2839    1P30282 2012   CATEGORY 1 (1YR)                        AC                              2011 CORRECTION 2012-01-24        NA
11:       4785    1P12286 2015   CATEGORY 1 (1YR)                        AC               2015 AFFIRMATION OF CORRECTION 2015-05-21        NA
12:       6082    1P13149 2016   CATEGORY 1 (1YR)                        AU                                           NA 2016-12-16        NA
13:      28271    3P10127 2013   CATEGORY 1 (1YR)                        AU                                           NA 2013-12-30        NA
14:         54    1P18885 2015   CATEGORY 1 (1YR)                        AU                                    2015 CAT1 2015-01-09        NA
15:      23000     4P5121 2010   CATEGORY 1 (1YR)                        AU                                           NA 2010-04-15        NA
16:       2565    1P14621 2011   CATEGORY 1 (1YR)                        AU                                           NA 2011-07-29        NA
17:       3507     1P6278 2011   CATEGORY 1 (1YR)                        RD AFFIRMATION OF CORRECTION FILED 68 DAYS LATE 2011-09-20        68
18:      25607    1P35255 2015   CATEGORY 1 (1YR)                        AU                                           NA 2015-07-15        NA
19:        106    1P28871 2013   CATEGORY 1 (1YR)                        AU                                           NA 2013-12-20        NA
20:      14621     3P2643 2012   CATEGORY 1 (1YR)                        AC                              2012 CORRECTION 2012-03-16        NA
21:      33525    3P12113 2016   CATEGORY 1 (1YR)                        AU                                    2016 CAT1 2016-06-27        NA
22:       6335    1P31196 2011   CATEGORY 1 (1YR)                        AC               2010 AFFIRMATION OF CORRECTION 2011-01-21        NA
23:      24970     4P2597 2015   CATEGORY 1 (1YR)                        AU                                           NA 2015-11-09        NA
24:       4851     1W5192 2016   CATEGORY 1 (1YR)                        AU                                           NA 2016-12-02        NA
25:      77057     2P5643 2012   CATEGORY 1 (1YR)                        AC                              2012 CORRECTION 2012-10-31        NA
26:      17247     3P6750 2016   CATEGORY 1 (1YR)                        AU                                    2016 CAT1 2016-06-21        NA
27:      14488     3F1928 2011   CATEGORY 1 (1YR)                        AU                                           NA 2011-08-25        NA
28:       2754    1P11978 2015   CATEGORY 1 (1YR)                        AC               2015 AFFIRMATION OF CORRECTION 2015-07-20        NA
29:      88945    1P33505 2010   CATEGORY 1 (1YR)                        AU                                           NA 2010-12-14        NA
30:       2710    1P14572 2014   CATEGORY 1 (1YR)                        AC                                     2013 AOC 2014-01-17        NA
    record_num device_num year inspection_type_cd inspection_disposition_cd                                      remarks    insp_dt days_late
</code>```

答:
An alternative solution with dplyr and lubridate:

```<code>library(lubridate)
library(dplyr)
SampleData %>%
        filter(inspection_disposition_cd=="AC") %>%
        mutate(day_passed = today()-insp_dt)
</code>```

Title: Conditionally Perform difftime in R

Body:
I have a data table with devices that are inspected "annually." When the device has an inspection code "AC" (inspection_disposition_cd="AC"), then I need to count the days passed since the inspection record listed in the row directly above it.

The code I am using does the math just fine, however, I am struggling with coding so that ONLY the rows that have the AC code receive this action. Can anyone provide any advice as to how to single out these rows?

This is the working code:

DispNotClear2$First<-c(0,with(DispNotClear2,difftime(insp_dt[2:length(insp_dt)],insp_dt[1], unit="days")))
DispNotClear2$BETWEEN<-c(0,with(DispNotClear2,diff(insp_dt[1:(length(insp_dt)-1)],unit="days")))}

Also, here are 30 rows of sample data from my data table:

library(data.table)
SampleData <- setDT(structure(list(record_num = c(12354L, 6764L, 9959L, 94L, 16463L,
6859L, 80678L, 87555L, 77980L, 2839L, 4785L, 6082L, 28271L, 54L,
23000L, 2565L, 3507L, 25607L, 106L, 14621L, 33525L, 6335L, 24970L,
4851L, 77057L, 17247L, 14488L, 2754L, 88945L, 2710L), device_num = c("2P4564",
"1P27589", "1P9215", "1P32077", "3P2093", "1P29651", "3P13054",
"1P14559", "3P7242", "1P30282", "1P12286", "1P13149", "3P10127",
"1P18885", "4P5121", "1P14621", "1P6278", "1P35255", "1P28871",
"3P2643", "3P12113", "1P31196", "4P2597", "1W5192", "2P5643",
"3P6750", "3F1928", "1P11978", "1P33505", "1P14572"), year = c(2016,
2011, 2016, 2010, 2011, 2013, 2014, 2015, 2013, 2012, 2015, 2016,
2013, 2015, 2010, 2011, 2011, 2015, 2013, 2012, 2016, 2011, 2015,
2016, 2012, 2016, 2011, 2015, 2010, 2014), inspection_type_cd = c("CATEGORY 1 (1YR)",
"CATEGORY 1 (1YR)", "CATEGORY 1 (1YR)", "CATEGORY 1 (1YR)", "CATEGORY 1 (1YR)",
"CATEGORY 1 (1YR)", "CATEGORY 1 (1YR)", "CATEGORY 1 (1YR)", "CATEGORY 1 (1YR)",
"CATEGORY 1 (1YR)", "CATEGORY 1 (1YR)", "CATEGORY 1 (1YR)", "CATEGORY 1 (1YR)",
"CATEGORY 1 (1YR)", "CATEGORY 1 (1YR)", "CATEGORY 1 (1YR)", "CATEGORY 1 (1YR)",
"CATEGORY 1 (1YR)", "CATEGORY 1 (1YR)", "CATEGORY 1 (1YR)", "CATEGORY 1 (1YR)",
"CATEGORY 1 (1YR)", "CATEGORY 1 (1YR)", "CATEGORY 1 (1YR)", "CATEGORY 1 (1YR)",
"CATEGORY 1 (1YR)", "CATEGORY 1 (1YR)", "CATEGORY 1 (1YR)", "CATEGORY 1 (1YR)",
"CATEGORY 1 (1YR)"), inspection_disposition_cd = c("AC", "AC",
"AC", "AU", "AC", "AC", "AU", "AC", "AC", "AC", "AC", "AU", "AU",
"AU", "AU", "AU", "RD", "AU", "AU", "AC", "AU", "AC", "AU", "AU",
"AC", "AU", "AU", "AC", "AU", "AC"), remarks = c("2015 AFFIRMATION OF CORRECTION",
NA, "2016 AOC", NA, "PENALTY PAID", "2012 AOC", NA, "2015 AFFIRMATION OF CORRECTION",
"2013 AFFIRMATION OF CORRECTION", "2011 CORRECTION", "2015 AFFIRMATION OF CORRECTION",
NA, NA, "2015 CAT1", NA, NA, "AFFIRMATION OF CORRECTION FILED 68 DAYS LATE",
NA, NA, "2012 CORRECTION", "2016 CAT1", "2010 AFFIRMATION OF CORRECTION",
NA, NA, "2012 CORRECTION", "2016 CAT1", NA, "2015 AFFIRMATION OF CORRECTION",
NA, "2013 AOC"), insp_dt = structure(c(16911, 15271, 17060, 14784,
15014, 16009, 16339, 16658, 16044, 15363, 16576, 17151, 16069,
16444, 14714, 15184, 15237, 16631, 16059, 15415, 16979, 14995,
16748, 17137, 15644, 16973, 15211, 16636, 14957, 16087), class = "Date"),
    days_late = c(NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, 68, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA)), .Names = c("record_num", "device_num",
"year", "inspection_type_cd", "inspection_disposition_cd", "remarks",
"insp_dt", "days_late"), class = "data.frame", row.names = c(NA, -30L)))

which looks like

    record_num device_num year inspection_type_cd inspection_disposition_cd                                      remarks    insp_dt days_late
 1:      12354     2P4564 2016   CATEGORY 1 (1YR)                        AC               2015 AFFIRMATION OF CORRECTION 2016-04-20        NA
 2:       6764    1P27589 2011   CATEGORY 1 (1YR)                        AC                                           NA 2011-10-24        NA
 3:       9959     1P9215 2016   CATEGORY 1 (1YR)                        AC                                     2016 AOC 2016-09-16        NA
 4:         94    1P32077 2010   CATEGORY 1 (1YR)                        AU                                           NA 2010-06-24        NA
 5:      16463     3P2093 2011   CATEGORY 1 (1YR)                        AC                                 PENALTY PAID 2011-02-09        NA
 6:       6859    1P29651 2013   CATEGORY 1 (1YR)                        AC                                     2012 AOC 2013-10-31        NA
 7:      80678    3P13054 2014   CATEGORY 1 (1YR)                        AU                                           NA 2014-09-26        NA
 8:      87555    1P14559 2015   CATEGORY 1 (1YR)                        AC               2015 AFFIRMATION OF CORRECTION 2015-08-11        NA
 9:      77980     3P7242 2013   CATEGORY 1 (1YR)                        AC               2013 AFFIRMATION OF CORRECTION 2013-12-05        NA
10:       2839    1P30282 2012   CATEGORY 1 (1YR)                        AC                              2011 CORRECTION 2012-01-24        NA
11:       4785    1P12286 2015   CATEGORY 1 (1YR)                        AC               2015 AFFIRMATION OF CORRECTION 2015-05-21        NA
12:       6082    1P13149 2016   CATEGORY 1 (1YR)                        AU                                           NA 2016-12-16        NA
13:      28271    3P10127 2013   CATEGORY 1 (1YR)                        AU                                           NA 2013-12-30        NA
14:         54    1P18885 2015   CATEGORY 1 (1YR)                        AU                                    2015 CAT1 2015-01-09        NA
15:      23000     4P5121 2010   CATEGORY 1 (1YR)                        AU                                           NA 2010-04-15        NA
16:       2565    1P14621 2011   CATEGORY 1 (1YR)                        AU                                           NA 2011-07-29        NA
17:       3507     1P6278 2011   CATEGORY 1 (1YR)                        RD AFFIRMATION OF CORRECTION FILED 68 DAYS LATE 2011-09-20        68
18:      25607    1P35255 2015   CATEGORY 1 (1YR)                        AU                                           NA 2015-07-15        NA
19:        106    1P28871 2013   CATEGORY 1 (1YR)                        AU                                           NA 2013-12-20        NA
20:      14621     3P2643 2012   CATEGORY 1 (1YR)                        AC                              2012 CORRECTION 2012-03-16        NA
21:      33525    3P12113 2016   CATEGORY 1 (1YR)                        AU                                    2016 CAT1 2016-06-27        NA
22:       6335    1P31196 2011   CATEGORY 1 (1YR)                        AC               2010 AFFIRMATION OF CORRECTION 2011-01-21        NA
23:      24970     4P2597 2015   CATEGORY 1 (1YR)                        AU                                           NA 2015-11-09        NA
24:       4851     1W5192 2016   CATEGORY 1 (1YR)                        AU                                           NA 2016-12-02        NA
25:      77057     2P5643 2012   CATEGORY 1 (1YR)                        AC                              2012 CORRECTION 2012-10-31        NA
26:      17247     3P6750 2016   CATEGORY 1 (1YR)                        AU                                    2016 CAT1 2016-06-21        NA
27:      14488     3F1928 2011   CATEGORY 1 (1YR)                        AU                                           NA 2011-08-25        NA
28:       2754    1P11978 2015   CATEGORY 1 (1YR)                        AC               2015 AFFIRMATION OF CORRECTION 2015-07-20        NA
29:      88945    1P33505 2010   CATEGORY 1 (1YR)                        AU                                           NA 2010-12-14        NA
30:       2710    1P14572 2014   CATEGORY 1 (1YR)                        AC                                     2013 AOC 2014-01-17        NA
    record_num device_num year inspection_type_cd inspection_disposition_cd                                      remarks    insp_dt days_late

Body:
An alternative solution with dplyr and lubridate:

library(lubridate)
library(dplyr)
SampleData %>%
        filter(inspection_disposition_cd=="AC") %>%
        mutate(day_passed = today()-insp_dt)


问:
NoClassDefFoundError on an interface, not a class
I have an issue with NoClassDefFoundError. I am using interfaces, and no class definition should be available:

```<code>package code;
public interface Constants {...}
</code>```

The class implementing this interface compiles without any errors, and a JAR file has been built, but at runtime it gives me an error.

```<code>import ...;
import code.*;
public class MultiDoc extends LanguageAnalyser implements Constants{}
</code>```

Constants contains only a list of constants.

I read some posts pointing to CLASSPATH as a cause of this problem, but I have the code package in my CLASSPATH. If I didn't have it, it would produce a compilation error. So, the problem should be something else.

The runtime error is:

```<code>java.lang.NoClassDefFoundError: code/Constants
</code>```

What's the solution?

答:
Any Interface must declared inside class.

```<code>public class Calbacks {
    public interface IBaseFragmentInterface {
        void NotifyMainActivity();
    }
}
</code>```

*I very long find resolution of this problem, but i find resolution independently by the method of scientific poking

Body:
I have an issue with NoClassDefFoundError. I am using interfaces, and no class definition should be available:

package code;
public interface Constants {...}

The class implementing this interface compiles without any errors, and a JAR file has been built, but at runtime it gives me an error.

import ...;
import code.*;
public class MultiDoc extends LanguageAnalyser implements Constants{}

Constants contains only a list of constants.

I read some posts pointing to CLASSPATH as a cause of this problem, but I have the code package in my CLASSPATH. If I didn't have it, it would produce a compilation error. So, the problem should be something else.

The runtime error is:

java.lang.NoClassDefFoundError: code/Constants

What's the solution?

Body:
Any Interface must declared inside class.

public class Calbacks {
    public interface IBaseFragmentInterface {
        void NotifyMainActivity();
    }
}

*I very long find resolution of this problem, but i find resolution independently by the method of scientific poking


问:
Adding CheckBox to DefaultTableModel
I have a DefaultTableModel which is populated with an Object[][] array.

Now I want to add a column with checkBoxes and perform operations accordingly.

When I add the checkbox into the Object[][] array and view it, I get text displayed

'javax.swing.JCheckBox[,0,0,0x0....', how do I get it to show a checkbox and add actions to it?

答:
how do I get it to show a checkbox

See Uhlen's answer

and add actions to it?

Use a TableModelListener. Something like:

```<code>public void tableChanged(TableModelEvent e)
{
    if (e.getType() == TableModelEvent.UPDATE)
    {
        int row = e.getFirstRow();
        int column = e.getColumn();

        if (column == ?)
        {
            TableModel model = (TableModel)e.getSource();
            Boolean value = (Boolean)model.getValueAt(row, column));

            if (value.booleanValue())
                // add your code here
        }
    }
}
</code>```

ContentLicense: CC BY-SA 2.5

Title: Adding CheckBox to DefaultTableModel

Body:
how do I get it to show a checkbox

See Uhlen's answer

and add actions to it?

Use a TableModelListener. Something like:

public void tableChanged(TableModelEvent e)
{
    if (e.getType() == TableModelEvent.UPDATE)
    {
        int row = e.getFirstRow();
        int column = e.getColumn();

        if (column == ?)
        {
            TableModel model = (TableModel)e.getSource();
            Boolean value = (Boolean)model.getValueAt(row, column));

            if (value.booleanValue())
                // add your code here
        }
    }
}


问:
How change zip archive download folder for embedpostgresql?
Here is embedpostgresql library for starting a postgres process via java. The instruction about reusing already extracted postgres from zip archive. But how to change archive directory? By default they store maven to %USER_HOME\.embedpostgresql% I want to change it to maven repository but what is needed to invoke to set such property?

答:
You just have to use the artifactStorePath() method from DownloadConfigBuilder class:

```<code>final FixedPath cachedDir = new FixedPath("/tmp/cacheddir");
final FixedPath artifactStoreDir = new FixedPath("/tmp/artstoredir");
 IRuntimeConfig runtimeConfig = new RuntimeConfigBuilder().defaults(cmd)
 .artifactStore(new CachedArtifactStoreBuilder()
         .defaults(cmd)
         .tempDir(cachedDir)
         .download(new DownloadConfigBuilder()
                 .defaultsForCommand(cmd)
                 .artifactStorePath(artifactStoreDir)
                 .packageResolver(new PackagePaths(cmd, cachedDir))
                 .build()))
 .build();

//starting Postgres
 final PostgresStarter<PostgresExecutable, PostgresProcess> runtime =
 PostgresStarter.getInstance(runtimeConfig);
</code>```

I cloned the git repository, did a 'grep -R embedpostgresql *' and found the first hint in ru.yandex.qatools.embed.postgresql.config.DownloadConfigBuilder class. Then I tested by myself and it works!

Body:
You just have to use the artifactStorePath() method from DownloadConfigBuilder class:

final FixedPath cachedDir = new FixedPath("/tmp/cacheddir");
final FixedPath artifactStoreDir = new FixedPath("/tmp/artstoredir");
 IRuntimeConfig runtimeConfig = new RuntimeConfigBuilder().defaults(cmd)
 .artifactStore(new CachedArtifactStoreBuilder()
         .defaults(cmd)
         .tempDir(cachedDir)
         .download(new DownloadConfigBuilder()
                 .defaultsForCommand(cmd)
                 .artifactStorePath(artifactStoreDir)
                 .packageResolver(new PackagePaths(cmd, cachedDir))
                 .build()))
 .build();

//starting Postgres
 final PostgresStarter<PostgresExecutable, PostgresProcess> runtime =
 PostgresStarter.getInstance(runtimeConfig);

I cloned the git repository, did a 'grep -R embedpostgresql *' and found the first hint in ru.yandex.qatools.embed.postgresql.config.DownloadConfigBuilder class. Then I tested by myself and it works!


问:
How do I run a simple project of Selenium web driver with c#
I am trying to learn Selenium Web driver with c# and I have created a simple project by using code as mentioned in the image

And have already add the references, that use in for selenium, but when I am try to run this piece of code. I am getting error as mentioned below

Kindly let me know, how do I run this piece of code, waiting for reply

Thanks

答:
Use the 'Test Explorer' view to run tests. It is shown on the left side on your screenshot.

Note that using the green 'Start' button in the tool bar only works for projects that create an exectuable program. It does not work for unit testing projects or library projects.


问:
Error installing pg gem after running bundle
I'm on Mac OS X El Capitan (10.11.6):

When trying to run bundle, I get an error after it tries to install pg.

Trying to run gem install pg also fails.

答:
Solution:

Note: Before doing the below steps, make sure you have Xcode installed, and  homebrew.

brew install postgresql

gem uninstall pg - this might not return anything, that's ok.

either bundle install in your application's root or gem install pg


问:
deadlock in a process, Unix command?
I was trying to figure out how to know if the threads of a process have been deadlocked on Unix/Linux machine? Also, is there a command for knowing what stage (or status) a process is in? If you know of any tools, please suggest. Thank you.</p>

答:
Thanks to /proc/<pid>/syscall, this is how I ended up implementing a quick and dirty processes futex(op=FUTEX_WAIT) scanner.

```<code>#!/bin/bash
#
# Find all processes that are executing a futex(2) call with op=FUTEX_WAIT
# In some cases this can be helpful in finding deadlock-ed processes.
#

test ! $UID -eq 0 && echo -e "WARNING: Not running as root, only processes for this user are being scanned\n" >&2;
pids=$(ps -u $UID -opid --no-headers)

for pid in $pids; do
        cat /proc/$pid/syscall |

        awk "{if (\$1 == 202 && \$3 == \"0x0\") {
                print $pid
        }}";

        # $1 is the syscall, we compare to 202 which is the futex call
        # See: /usr/include/asm/unistd.h

        # $2 is the 1st param, $3 is the 2nd param, etc
        # We compare the second param to 0x0 which is FUTEX_WAIT
        # See: /usr/include/linux/futex.h
done
</code>```

Title: deadlock in a process, Unix command?

Body:
Thanks to /proc/<pid>/syscall, this is how I ended up implementing a quick and dirty processes futex(op=FUTEX_WAIT) scanner.

#!/bin/bash
#
# Find all processes that are executing a futex(2) call with op=FUTEX_WAIT
# In some cases this can be helpful in finding deadlock-ed processes.
#

test ! $UID -eq 0 && echo -e "WARNING: Not running as root, only processes for this user are being scanned\n" >&2;
pids=$(ps -u $UID -opid --no-headers)

for pid in $pids; do
        cat /proc/$pid/syscall |

        awk "{if (\$1 == 202 && \$3 == \"0x0\") {
                print $pid
        }}";

        # $1 is the syscall, we compare to 202 which is the futex call
        # See: /usr/include/asm/unistd.h

        # $2 is the 1st param, $3 is the 2nd param, etc
        # We compare the second param to 0x0 which is FUTEX_WAIT
        # See: /usr/include/linux/futex.h
done


问:
Does Informatica Powercenter provide API to access session logs
Question - Does Informatica PowerCenter provide API to access session logs - I believe No but wanted to through in forum to be sure?

Objective -Actually I want to extract session logs and process them through Logstash and perform reactive analytics periodically.

Alternate - The same could be solved using Logstash input plugin for Informatica - but I did not find that either.

Usage - This will be used to determine common causes, analyze usage of cache at session level, throughput, and any performance bottlenecks.

答:
I suppose that the correct answer i 'yes', since there is a command line tool to convert logfiles to txt or even xml format.
The tool for session/workflow logs is called infacmd with the 'getsessionlog' argument. You can look it up in the help section of you powercenter clients or here:
https://kb.informatica.com/proddocs/Product%20Documentation/5/IN_101_CommandReference_en.pdf
That has always been enough for my needs..

But there is more to look into: when you run this commandline tool (which is really a BAT file) a java.exe does the bulk of the processing in a sub-process. The jar files used by this process could potentially be utilized by somebody else directly, but I don't know if it has been documented anywhere publicly available....?

Perhaps someone else knows the answer to that.


问:
Model textBox field passing as null value to controller in MVC
Date TextBox Field passing as null value from View to Controller

Here is my Model class

```<code>public class VehcileMakeModel
    {
        //public VehicleModel VehicleModel { get; set; }
        //public List<VehicleMake> VehcileMakeList { get; set; }

        [Required(ErrorMessage = "...")]
        public string Model { get; set; }

        [Required(ErrorMessage = "...")]
        public DateTime? Year { get; set; }

        [Required(ErrorMessage = "...")]
        [Display(Name = "Make")]
        public int SelectedMake { get; set; }

        public IEnumerable<SelectListItem> MakesList { get; set; }
    }
</code>```

Strongly Typed View:

```<code>@model MvcApplication1.Models.VehcileMakeModel

@{
    ViewBag.Title = "CreateMakeModel";
}

<h2>CreateModel</h2>
@using (Html.BeginForm("SaveModel", "iRateBook"))
{
<table>
    <tr>
        <td>@Html.Label("Select Make")</td>
        <td>@Html.DropDownListFor(m => m.SelectedMake, Model.MakesList)</td>
    </tr>
    <tr>
        <td>Enter Model </td>
        <td>@Html.TextBoxFor(m => m.Model)</td>
    </tr>
    <tr>
        <td>Enter Model Year</td>
        <td>
            @Html.TextBoxFor(m=>m.Year)
        </td>
    </tr>
    <tr><td><input type="submit" value="Save" /> </td></tr>
</table>
}
</code>```

When i click on Save button entered textbox values must pass to controller.

Controller Name

```<code>public ActionResult SaveModel(VehcileMakeModel VMM)
        {
            int ? makeid = VMM.SelectedMake;
            string strModel = VMM.Model.ToString();

            VehicleDataContext obj = new VehicleDataContext();
           // obj.VehicleModels.Add(VMM);

            obj.SaveChanges();

            return View("index");
        }
</code>```

Why Yer field passing as Null value in Controller?

答:
The issue is that you specified Year property as DateTime? and not as int/string.
Default model binder expects dates to be sent in format defined by application culture. For example if you set in web.config

```<code><globalization uiCulture="en-US" culture="en-US" />
</code>```

Model binder will expect MM/dd/yyyy date format (excluding time part.

Since you need only a year, I would simply change Year property to be integer

```<code>public int? Year { get; set; }
</code>```

If you really need a DateTime? property on the model (which I doubt), you can create it it based on Year property:

```<code>public class VehcileMakeModel
{
    [Required(ErrorMessage = "...")]
    public int? Year { get; set; }

    public DateTime? YearDt
    {
         return this.Year.HasValue ? new DateTime(this.Year.Value,1,1) : null;
    }
}
</code>```

Body:
Date TextBox Field passing as null value from View to Controller

Here is my Model class

public class VehcileMakeModel
    {
        //public VehicleModel VehicleModel { get; set; }
        //public List<VehicleMake> VehcileMakeList { get; set; }

        [Required(ErrorMessage = "...")]
        public string Model { get; set; }

        [Required(ErrorMessage = "...")]
        public DateTime? Year { get; set; }

        [Required(ErrorMessage = "...")]
        [Display(Name = "Make")]
        public int SelectedMake { get; set; }

        public IEnumerable<SelectListItem> MakesList { get; set; }
    }

Strongly Typed View:

@model MvcApplication1.Models.VehcileMakeModel

@{
    ViewBag.Title = "CreateMakeModel";
}

CreateModel

@using (Html.BeginForm("SaveModel", "iRateBook"))
{

        @Html.Label("Select Make")
        @Html.DropDownListFor(m => m.SelectedMake, Model.MakesList)

        Enter Model
        @Html.TextBoxFor(m => m.Model)

        Enter Model Year

            @Html.TextBoxFor(m=>m.Year)

<input type="submit" value="Save" />

}

When i click on Save button entered textbox values must pass to controller.

Controller Name

public ActionResult SaveModel(VehcileMakeModel VMM)
        {
            int ? makeid = VMM.SelectedMake;
            string strModel = VMM.Model.ToString();

            VehicleDataContext obj = new VehicleDataContext();
           // obj.VehicleModels.Add(VMM);

            obj.SaveChanges();

            return View("index");
        }

Why Yer field passing as Null value in Controller?

Body:
The issue is that you specified Year property as DateTime? and not as int/string.
Default model binder expects dates to be sent in format defined by application culture. For example if you set in web.config

<globalization uiCulture="en-US" culture="en-US" />

Model binder will expect MM/dd/yyyy date format (excluding time part.

Since you need only a year, I would simply change Year property to be integer

public int? Year { get; set; }

If you really need a DateTime? property on the model (which I doubt), you can create it it based on Year property:

public class VehcileMakeModel
{
    [Required(ErrorMessage = "...")]
    public int? Year { get; set; }

    public DateTime? YearDt
    {
         return this.Year.HasValue ? new DateTime(this.Year.Value,1,1) : null;
    }
}


问:
Reloading page with injected javascript in Browser
So I created a JS script that does something on a page from the browserconsole, but when it is ready, the page needs to be reloaded in order to work properly afterwards, but if I reload the page, the JS will be deleted, because it is only injected by the browsers console.

How do I reload the page, but with my JS-Code already injected, or how do I reload the page, so that the injected JS will not be deleted?

Thanks
Hiro

答:
If you want to save some variables then you should use local or session Storage to save a variable.

```<code>localStorage.setItem("lastname", "Smith");
</code>```

and after refresh you can get it with

```<code>alert(localStorage.lastname); // Smith
</code>```

If you want something more complex you should use Ajax and PHP.

Body:
If you want to save some variables then you should use local or session Storage to save a variable.

localStorage.setItem("lastname", "Smith");

and after refresh you can get it with

alert(localStorage.lastname); // Smith

If you want something more complex you should use Ajax and PHP.


问:
Multiple "sed" actions on previous results
Have this input:

```<code>bar foo
foo ABC/DEF
BAR ABC
ABC foo DEF
foo bar
</code>```

on the above I need do 4 (sequential) actions:

select only lines containing "foo" (lowercase)

on the selected lines, remove everything but UPPERCASE letters

delete empty lines (if some is created by the previous action)

and on the remaining from the above - enclose every char with [x]

I'm able to solve the above, but need two sed invocations piped together. Script:

```<code>#!/bin/bash
data() {
cat <<EOF
bar foo
foo ABC/DEF
BAR ABC
ABC foo DEF
foo bar
EOF
}

echo "Result OK"
data | sed -n '/foo/s/[^A-Z]//gp' | sed '/^\s*$/d;s/./[&]/g'

# in the above it is solved using 2 sed invocations
# trying to solve it using only one invocation,
# but the following doesn't do what i need.. :( :(

echo "Variant 2 - trying to use only ONE invocation of sed"
data | sed -n '/foo/s/[^A-Z]//g;/^\s*$/d;s/./[&]/gp'
</code>```

output from the above:

```<code>Result OK
[A][B][C][D][E][F]
[A][B][C][D][E][F]
Variant 2 - trying to use only ONE invocation of sed
[A][B][C][D][E][F]
[B][A][R][ ][A][B][C]
[A][B][C][D][E][F]
</code>```

The variant 2 should be also only

```<code>[A][B][C][D][E][F]
[A][B][C][D][E][F]
</code>```

It is possible to solve the above using only by one sed invocation?

答:
Alternative sed approach:

```<code>sed '/foo/!d;s/[^A-Z]//g;/./!d;s/./[&]/g' file
</code>```

The output:

```<code>[A][B][C][D][E][F]
[A][B][C][D][E][F]
</code>```

/foo/!d - deletes all lines that don't contain foo

/./!d - deletes all empty lines

Body:
Have this input:

bar foo
foo ABC/DEF
BAR ABC
ABC foo DEF
foo bar

on the above I need do 4 (sequential) actions:

select only lines containing "foo" (lowercase)

on the selected lines, remove everything but UPPERCASE letters

delete empty lines (if some is created by the previous action)

and on the remaining from the above - enclose every char with [x]

I'm able to solve the above, but need two sed invocations piped together. Script:

#!/bin/bash
data() {
cat <<EOF
bar foo
foo ABC/DEF
BAR ABC
ABC foo DEF
foo bar
EOF
}

echo "Result OK"
data | sed -n '/foo/s/[^A-Z]//gp' | sed '/^\s*$/d;s/./[&]/g'

# in the above it is solved using 2 sed invocations
# trying to solve it using only one invocation,
# but the following doesn't do what i need.. :( :(

echo "Variant 2 - trying to use only ONE invocation of sed"
data | sed -n '/foo/s/[^A-Z]//g;/^\s*$/d;s/./[&]/gp'

output from the above:

Result OK
[A][B][C][D][E][F]
[A][B][C][D][E][F]
Variant 2 - trying to use only ONE invocation of sed
[A][B][C][D][E][F]
[B][A][R][ ][A][B][C]
[A][B][C][D][E][F]

The variant 2 should be also only

[A][B][C][D][E][F]
[A][B][C][D][E][F]

It is possible to solve the above using only by one sed invocation?

Body:
Alternative sed approach:

sed '/foo/!d;s/[^A-Z]//g;/./!d;s/./[&]/g' file

The output:

[A][B][C][D][E][F]
[A][B][C][D][E][F]

/foo/!d - deletes all lines that don't contain foo

/./!d - deletes all empty lines


问:
Empty span width in Firefox
I have span with contenteditable property. Most of the time the span is empty so I set fixed width to the span.

It works good in Opera and chrome I can click on the span and edit data. But with Firefox span behaves like there is no span.

E.g. When the span is empty in Firefox it doesn't appear as editable and I cannot click on it. When only one character is there, like space or something, then I can edit it. I tried to fixed that with html character   but nothing.

```<code>$comment = ` `

<span class="edit_notes" contenteditable=true onFocus="clear_input('.$data['ID'].')" style="min-width: 1200px; display: inline-block;display:-moz-inline-box;" id="comment'.$data['ID'].'" onBlur="changeComment('.$data['ID'].')"> '.$comment.' </span>
</code>```

答:
For FF you may use a pseudo element to give it some size or use the :empty pseudo class if there is no white-space in HTML produced by server when there's no data to print.

Example below to test:

span[contenteditable][onFocus]:after, span[contenteditable]:empty {
  content:'';
  padding:0.5em;
  }```
<pre class="snippet-code-html lang-html prettyprint-override"><code><span class="edit_notes" contenteditable=true onFocus="" style="min-width: 1200px; display: inline-block;" id="comment'.$data['ID'].'" onBlur=""> </span>
<hr/>
<span contenteditable=true ></span></code>```

Title: Empty span width in Firefox

Body:
I have span with contenteditable property. Most of the time the span is empty so I set fixed width to the span.

It works good in Opera and chrome I can click on the span and edit data. But with Firefox span behaves like there is no span.

E.g. When the span is empty in Firefox it doesn't appear as editable and I cannot click on it. When only one character is there, like space or something, then I can edit it. I tried to fixed that with html character   but nothing.

$comment = ` `

 '.$comment.'

Body:
For FF you may use a pseudo element to give it some size or use the :empty pseudo class if there is no white-space in HTML produced by server when there's no data to print.

Example below to test:

span[contenteditable][onFocus]:after, span[contenteditable]:empty {
  content:'';
  padding:0.5em;
  }

<span class="edit_notes" contenteditable=true onFocus="" style="min-width: 1200px; display: inline-block;" id="comment'.$data['ID'].'" onBlur=""> </span>
<hr/>
<span contenteditable=true ></span>


问:
Jira Gadgets Development Structure
I need to develop more Gadgets in the same plugin, the gadgets will look pretty the same, what change is the resource they need to access and display. What's the best way to do this?

Do I need to create an xml file for each gadget even if it's the same?

For the Java part can I use a single class with different path for each gadget, like:
@Path("generate-gadget1"), @Path("generate-gadget2")...?

答:
You need a separate XML file for each gadget. You can create multiple REST endpoints within one class by using @Path.

You might get more replies if you ask these questions on the JIRA developers forum at http://forums.atlassian.com/forum.jspa?forumID=100

Title: Jira Gadgets Development Structure


问:
can we submit PDF form without Submit button?
can we submit PDF form without Submit button?
Any javascript code/other alternate is available?
Currently I have PDF form without Submit button.</p>

答:
You will need a trigger to submit.

PDF/Acrobat has a series of possible triggers, such as Button, but you might look at links or bookmarks.


问:
Need assistance with batch variables and substrings
i have issues with %arch:~1,3% showing up correctly
echoing %arch:~1,3% outputs x64 like it should
but when used as a variable it messes everything up

```<code>@echo off
setlocal enabledelayedexpansion
Color 0A
cls
title PORTABLE LASTPASS LAUNCHER

:ARCHCHECK
cls
set arch=
if exist "%PROGRAMFILES(X86)%" set "arch=_x64" & goto LASTPASSCHECK

:LASTPASSCHECK
cls
if not exist .\bin\lastpass\lastapp%arch%.exe goto FILECHECK
if not exist .\bin\lastpass\lastapphook%arch%.dll goto FILECHECK
goto WGETUPDATE

:FILECHECK
cls
if not exist .\extra\lastappinstall%arch%.exe goto DOWNLOADLASTPASS
if not exist .\bin\7-ZipPortable\7-ZipPortable.exe goto 7ZIPINSTALLERCHECK
.\bin\7-ZipPortable\App\7-Zip%arch:~1,3%\7z.exe e .\extra\lastappinstall%arch%.exe lastapp%arch%.exe -o.\bin\lastpass\
.\bin\7-ZipPortable\App\7-Zip%arch:~1,3%\7z.exe e .\extra\lastappinstall%arch%.exe lastapphook%arch%.dll -o.\bin\lastpass\
goto LASTPASSCHECK

:DOWNLOADLASTPASS
cls
if exist lastappinstall%arch%.exe goto MOVELASTPASS
if not exist .\bin\wget.exe call :DOWNLOADWGET
.\bin\wget.exe https://lastpass.com/download/cdn/lastappinstall%arch%.exe

:MOVELASTPASS
cls
move lastappinstall%arch%.exe .\extra\lastappinstall%arch%.exe
goto FILECHECK
</code>```

the output i get when used as a variable is that it thinks it says "ziparcharcharch" somehow :/

答:
fixed it myself
instead of %arch:~1,3% i shouldve put %arch:~2,2% as i want two skip to characters and print the next 2
i.e. instead of _x64 turning into x64 it turns into 64</p>

Body:
i have issues with %arch:~1,3% showing up correctly
echoing %arch:~1,3% outputs x64 like it should
but when used as a variable it messes everything up

@echo off
setlocal enabledelayedexpansion
Color 0A
cls
title PORTABLE LASTPASS LAUNCHER

:ARCHCHECK
cls
set arch=
if exist "%PROGRAMFILES(X86)%" set "arch=_x64" & goto LASTPASSCHECK

:LASTPASSCHECK
cls
if not exist .\bin\lastpass\lastapp%arch%.exe goto FILECHECK
if not exist .\bin\lastpass\lastapphook%arch%.dll goto FILECHECK
goto WGETUPDATE

:FILECHECK
cls
if not exist .\extra\lastappinstall%arch%.exe goto DOWNLOADLASTPASS
if not exist .\bin\7-ZipPortable\7-ZipPortable.exe goto 7ZIPINSTALLERCHECK
.\bin\7-ZipPortable\App\7-Zip%arch:~1,3%\7z.exe e .\extra\lastappinstall%arch%.exe lastapp%arch%.exe -o.\bin\lastpass\
.\bin\7-ZipPortable\App\7-Zip%arch:~1,3%\7z.exe e .\extra\lastappinstall%arch%.exe lastapphook%arch%.dll -o.\bin\lastpass\
goto LASTPASSCHECK

:DOWNLOADLASTPASS
cls
if exist lastappinstall%arch%.exe goto MOVELASTPASS
if not exist .\bin\wget.exe call :DOWNLOADWGET
.\bin\wget.exe https://lastpass.com/download/cdn/lastappinstall%arch%.exe

:MOVELASTPASS
cls
move lastappinstall%arch%.exe .\extra\lastappinstall%arch%.exe
goto FILECHECK

the output i get when used as a variable is that it thinks it says "ziparcharcharch" somehow :/


问:
Kubernetes Jenkins swap space issue
Jenkins is failing to build due to "Free Swap Space" being 0. I don't know how to fix that. The build process keeps hanging. Here part of the output:

When I ssh into the instance and docker info I get a WARNING: No swap limit support.

答:
Your screenshot shows "waiting for next available executor" so try increasing the number of executors in jenkins ("Manage Jenkins" -> "Configure System" -> "# of executors").

Also here the info how to create Swapfile (for avoiding out of memory on building large docker containers etc.). The example creates 4G swapfile at location /myswap :

```<code>sudo dd if=/dev/zero of=/myswap count=4096 bs=1MiB
sudo chmod 600 /myswap
sudo mkswap /myswap
sudo swapon /myswap
</code>```

to check swap is working:

```<code>swapon -s
</code>```

enable swap at boot, add line to fstab file:

```<code>sudo nano /etc/fstab
</code>```

Add this line:

```<code>/myswap   swap    swap    sw  0   0
</code>```

Title: Kubernetes Jenkins swap space issue

Body:
Your screenshot shows "waiting for next available executor" so try increasing the number of executors in jenkins ("Manage Jenkins" -> "Configure System" -> "# of executors").

Also here the info how to create Swapfile (for avoiding out of memory on building large docker containers etc.). The example creates 4G swapfile at location /myswap :

sudo dd if=/dev/zero of=/myswap count=4096 bs=1MiB
sudo chmod 600 /myswap
sudo mkswap /myswap
sudo swapon /myswap

to check swap is working:

swapon -s

enable swap at boot, add line to fstab file:

sudo nano /etc/fstab

Add this line:

/myswap   swap    swap    sw  0   0


问:
Loading data from fixtures to the database ( associations )
I have two models, Project and Todo.

Project stores an array of Todos.

Migration for Project:

```<code>  def up
    create_table :projects do |t|
      t.string :title, null: false
      t.timestamps null: false
    end
  end
</code>```

Migration for Todo:

```<code>  def up
    create_table :todos do |t|
      t.string :text, null: false
      t.boolean :isCompleted, null:false
      t.integer :project_id, null:false
      t.timestamps null: false
    end
  end
</code>```

project.rb

```<code>class Project < ActiveRecord::Base
  has_many :todos
end
</code>```

todo.rb

```<code>class Todo < ActiveRecord::Base
  belongs_to :project
end
</code>```

projects.yml

```<code>family:
  title: 'Семья'

work:
  title: 'Работа'

therest:
  title: 'Прочее'
</code>```

todos.yml

```<code>family_todos:
  text: 'Купить молоко'
  isCompleted: false
  project_id: family

work_todos:
  text: 'Закончить проект'
  isCompleted: false
  project_id: work

therest_todos:
  text: 'Познать бесконечность'
  isCompleted: true
  project_id: therest
</code>```

How can I connect them properly, so when I call a project I can see all the todos inside it? Plus I'm curious how can I add the date via the yml files like an array?

答:
One of the better way to link the association between tables is by using references. You can do this to your todos table

```<code>def up
 create_table :todos do |t|
  t.string :text, null: false
  t.boolean :isCompleted, null:false
  t.references :project, references: :projects, index: true, foreign_key: true
  t.timestamps null: false
 end
end
</code>```

This will create a field called project_id in your todos table. Hence you have a project table with has_many todos.

There are different ways you can preload database. You can use seeds.rb file where you can write your code to read from yml file and load to database.
You can do something like this

```<code>proj = Project.create(title: family)
</code>```

If you have an array of all the family todos, then you can put it in database like this

```<code>##Family todos
loop through
  proj.todos << Todo.create(...fields...)
end
</code>```

Body:
I have two models, Project and Todo.

Project stores an array of Todos.

Migration for Project:

  def up
    create_table :projects do |t|
      t.string :title, null: false
      t.timestamps null: false
    end
  end

Migration for Todo:

  def up
    create_table :todos do |t|
      t.string :text, null: false
      t.boolean :isCompleted, null:false
      t.integer :project_id, null:false
      t.timestamps null: false
    end
  end

project.rb

class Project < ActiveRecord::Base
  has_many :todos
end

todo.rb

class Todo < ActiveRecord::Base
  belongs_to :project
end

projects.yml

family:
  title: 'Семья'

work:
  title: 'Работа'

therest:
  title: 'Прочее'

todos.yml

family_todos:
  text: 'Купить молоко'
  isCompleted: false
  project_id: family

work_todos:
  text: 'Закончить проект'
  isCompleted: false
  project_id: work

therest_todos:
  text: 'Познать бесконечность'
  isCompleted: true
  project_id: therest

How can I connect them properly, so when I call a project I can see all the todos inside it? Plus I'm curious how can I add the date via the yml files like an array?

Body:
One of the better way to link the association between tables is by using references. You can do this to your todos table

def up
 create_table :todos do |t|
  t.string :text, null: false
  t.boolean :isCompleted, null:false
  t.references :project, references: :projects, index: true, foreign_key: true
  t.timestamps null: false
 end
end

This will create a field called project_id in your todos table. Hence you have a project table with has_many todos.

There are different ways you can preload database. You can use seeds.rb file where you can write your code to read from yml file and load to database.
You can do something like this

proj = Project.create(title: family)

If you have an array of all the family todos, then you can put it in database like this

##Family todos
loop through
  proj.todos << Todo.create(...fields...)
end