问:
GROUP BY + CASE statement
I have a working query that is grouping data by hardware model and a result, but the problem is there are many "results".  I have tried to reduce that down to "if result = 0  then keep as 0, else set it to 1".  This generally works, but I end up having:

```<code>    day     |      name      | type | case | count
------------+----------------+------+------+-------
 2013-11-06 | modelA         |    1 |    0 |   972
 2013-11-06 | modelA         |    1 |    1 |    42
 2013-11-06 | modelA         |    1 |    1 |     2
 2013-11-06 | modelA         |    1 |    1 |    11
 2013-11-06 | modelB         |    1 |    0 |   456
 2013-11-06 | modelB         |    1 |    1 |    16
 2013-11-06 | modelB         |    1 |    1 |     8
 2013-11-06 | modelB         |    3 |    0 | 21518
 2013-11-06 | modelB         |    3 |    1 |     5
 2013-11-06 | modelB         |    3 |    1 |     7
 2013-11-06 | modelB         |    3 |    1 |   563
</code>```

Instead of the aggregate I am trying to achieve, where only 1 row per type/case combo.

```<code>    day     |      name      | type | case | count
------------+----------------+------+------+-------
 2013-11-06 | modelA         |    1 |    0 |   972
 2013-11-06 | modelA         |    1 |    1 |    55
 2013-11-06 | modelB         |    1 |    0 |   456
 2013-11-06 | modelB         |    1 |    1 |    24
 2013-11-06 | modelB         |    3 |    0 | 21518
 2013-11-06 | modelB         |    3 |    1 |   575
</code>```

Here is my query:

```<code>select CURRENT_DATE-1 AS day, model.name, attempt.type,
       CASE WHEN attempt.result = 0 THEN 0 ELSE 1 END,
       count(*)
from attempt attempt, prod_hw_id prod_hw_id, model model
where time >= '2013-11-06 00:00:00'
AND time < '2013-11-07 00:00:00'
AND attempt.hard_id = prod_hw_id.hard_id
AND prod_hw_id.model_id = model.model_id
group by model.name, attempt.type, attempt.result
order by model.name, attempt.type, attempt.result;
</code>```

Any tips on how I can achieve this would be awesome.

Day will always be defined in the WHERE clause, so it will not vary. name, type, result(case) and count will vary. In short, for any given model I want only 1 row per "type + case" combo. As you can see in the first result set I have 3 rows for modelA that have type=1 and case=1 (because there are many "result" values that I have turned into 0=0 and anything else=1). I want that to be represented as 1 row with the count aggregated as in example data set 2.

答:
For TSQL I like to encapsulate case statements in an outer apply. This prevents me from having to have the case statement written twice, allows reference to the case statement by alias in future joins and avoids the need for positional references.</p>

```<code>select oa.day,
model.name,
attempt.type,
oa.result
COUNT(*) MyCount
FROM attempt attempt, prod_hw_id prod_hw_id, model model
WHERE time >= '2013-11-06 00:00:00'
AND time < '2013-11-07 00:00:00'
AND attempt.hard_id = prod_hw_id.hard_id
AND prod_hw_id.model_id = model.model_id
OUTER APPLY (
    SELECT CURRENT_DATE-1 AS day,
     CASE WHEN attempt.result = 0 THEN 0 ELSE 1 END result
    ) oa
group by oa.day,
model.name,
attempt.type,
oa.result
order by model.name, attempt.type, oa.result;
</code>```

Title: GROUP BY + CASE statement

Body:
I have a working query that is grouping data by hardware model and a result, but the problem is there are many "results".  I have tried to reduce that down to "if result = 0  then keep as 0, else set it to 1".  This generally works, but I end up having:

    day     |      name      | type | case | count
------------+----------------+------+------+-------
 2013-11-06 | modelA         |    1 |    0 |   972
 2013-11-06 | modelA         |    1 |    1 |    42
 2013-11-06 | modelA         |    1 |    1 |     2
 2013-11-06 | modelA         |    1 |    1 |    11
 2013-11-06 | modelB         |    1 |    0 |   456
 2013-11-06 | modelB         |    1 |    1 |    16
 2013-11-06 | modelB         |    1 |    1 |     8
 2013-11-06 | modelB         |    3 |    0 | 21518
 2013-11-06 | modelB         |    3 |    1 |     5
 2013-11-06 | modelB         |    3 |    1 |     7
 2013-11-06 | modelB         |    3 |    1 |   563

Instead of the aggregate I am trying to achieve, where only 1 row per type/case combo.

    day     |      name      | type | case | count
------------+----------------+------+------+-------
 2013-11-06 | modelA         |    1 |    0 |   972
 2013-11-06 | modelA         |    1 |    1 |    55
 2013-11-06 | modelB         |    1 |    0 |   456
 2013-11-06 | modelB         |    1 |    1 |    24
 2013-11-06 | modelB         |    3 |    0 | 21518
 2013-11-06 | modelB         |    3 |    1 |   575

Here is my query:

select CURRENT_DATE-1 AS day, model.name, attempt.type,
       CASE WHEN attempt.result = 0 THEN 0 ELSE 1 END,
       count(*)
from attempt attempt, prod_hw_id prod_hw_id, model model
where time >= '2013-11-06 00:00:00'
AND time < '2013-11-07 00:00:00'
AND attempt.hard_id = prod_hw_id.hard_id
AND prod_hw_id.model_id = model.model_id
group by model.name, attempt.type, attempt.result
order by model.name, attempt.type, attempt.result;

Any tips on how I can achieve this would be awesome.

Day will always be defined in the WHERE clause, so it will not vary. name, type, result(case) and count will vary. In short, for any given model I want only 1 row per "type + case" combo. As you can see in the first result set I have 3 rows for modelA that have type=1 and case=1 (because there are many "result" values that I have turned into 0=0 and anything else=1). I want that to be represented as 1 row with the count aggregated as in example data set 2.

Body:
For TSQL I like to encapsulate case statements in an outer apply. This prevents me from having to have the case statement written twice, allows reference to the case statement by alias in future joins and avoids the need for positional references.

select oa.day,
model.name,
attempt.type,
oa.result
COUNT(*) MyCount
FROM attempt attempt, prod_hw_id prod_hw_id, model model
WHERE time >= '2013-11-06 00:00:00'
AND time < '2013-11-07 00:00:00'
AND attempt.hard_id = prod_hw_id.hard_id
AND prod_hw_id.model_id = model.model_id
OUTER APPLY (
    SELECT CURRENT_DATE-1 AS day,
     CASE WHEN attempt.result = 0 THEN 0 ELSE 1 END result
    ) oa
group by oa.day,
model.name,
attempt.type,
oa.result
order by model.name, attempt.type, oa.result;


来源: stackexchange

问:
Write a c++ program that finds the number of vowels used in an string
Write a c++ program that finds the number of vowels used in an string.

For the above problem I written a program as follows:

```<code>int main()
{
    char x[10];
    int n,i,s=0;
    cout<<"Enter any string\n";
    cin>>x;
    n=strlen(x);
    for(i=0;i<n;++i)
    {
        if(x[i]=='a'||x[i]=='e'||x[i]=='i'||x[i]=='o'||x[i]=='u')
        {
            s=s+1;
       }
    }
    cout<<s;
    return 0;
}
</code>```

Output of the program is as:

Enter any string
 elephant
 3

Here in 'elephant' at three places vowels are used but the total number of vowels used is 2(e and a) not 3

I am asking to improve the program so that it counts the total number of vowels and print the total number.(e.g. in case of elephant it must give 2)

答:
C++ Code Snippet :

```<code>#include <bits/stdc++.h>
using namespace std;

int main()
{
    char s[100];
    int cnt;

    cnt=0;
    cin>>s;
    for(int i=0;s[i];i++)
    {
      char c =s[i];
      if(s[i]=='A' || s[i] =='E' || s[i]=='I' ||s[i]=='O'|| s[i]=='U')   cnt++;
      else if(s[i]=='a' || s[i] =='e' || s[i]=='i'||s[i]=='o' || s[i]=='u')  cnt++;
    }
    cout<<cnt<<endl;

    return 0;
}
</code>```

ContentLicense: CC BY-SA 3.0

Body:
Write a c++ program that finds the number of vowels used in an string.

For the above problem I written a program as follows:

int main()
{
    char x[10];
    int n,i,s=0;
    cout<<"Enter any string\n";
    cin>>x;
    n=strlen(x);
    for(i=0;i<n;++i)
    {
        if(x[i]=='a'||x[i]=='e'||x[i]=='i'||x[i]=='o'||x[i]=='u')
        {
            s=s+1;
       }
    }
    cout<<s;
    return 0;
}

Output of the program is as:

Enter any string
 elephant
 3

Here in 'elephant' at three places vowels are used but the total number of vowels used is 2(e and a) not 3

I am asking to improve the program so that it counts the total number of vowels and print the total number.(e.g. in case of elephant it must give 2)

Body:
C++ Code Snippet :

#include <bits/stdc++.h>
using namespace std;

int main()
{
    char s[100];
    int cnt;

    cnt=0;
    cin>>s;
    for(int i=0;s[i];i++)
    {
      char c =s[i];
      if(s[i]=='A' || s[i] =='E' || s[i]=='I' ||s[i]=='O'|| s[i]=='U')   cnt++;
      else if(s[i]=='a' || s[i] =='e' || s[i]=='i'||s[i]=='o' || s[i]=='u')  cnt++;
    }
    cout<<cnt<<endl;

    return 0;
}


问:
How do I run the Visual Studio (2017) Installer?
It's probably really obvious once you know the answer, but I can't find it anywhere.

I'm not talking about making an installer, I'm talking about running the installer that lets me modify which features of Visual Studio 2017 are installed.

The main screen looks like this:

the screen I need is this one:

In Visual Studio 2017, there is a menu entry for "Extensions and Updates" under the Tool menu that doesn't take me to this application.
There is also a "NuGet Package Manager" which isn't even close.

In my Windows 10 start menu, I see Visual Studio 2017 itself, and a folder named "Visual Studio 2017" that contains a couple of command prompts and a "Debuggable Package Manager".

In the Control Panel - Programs and Features, I see Microsoft Visual Studio 2017 but right-click only gives me "Uninstall".

答:
The screenshots you show are the VS 2017 installer. This allows you to select from the large number of optional components that can be included in the VS install. Run by running the downloaded installed file you started the original install with.

Tools | Extensions and Updates is used to extend and service VS.

Extensions are (usually third party) components to extend and enhance VS.

Servicing: just a prompt that there is an update available, this takes you to the Visual Studio installer.

NuGet: is a package manager for projects built with VS. Adding a component that the software you are writing uses. Soemthing like jQuery in a web app. This does not change VS itself.


问:
Unable to receive pushNotifications from Firebase connected through application server
I created a new project in firebase console for apple APNs pushNotifications. I followed all the instructions in firebase documentation like generating SSl certificate and uploading p12 certificates(development and production) to firebase and also the provisioning profile. And also added the whole required code in Appdelegate. And also activated pushNotifications in capabilities and also in Entitlement file APNs enviroment set as development.

When I'm sending a sample message from firebase notification messageing, my iPhone(6) able to receive the notification(send through both FCM token and also with bundelId able to receive notification). But from my application server with same FCM token I'm unable to receive notifications, but my server side getting reply as notification sent Ok with 200 code from firebase.

I am unable to get the solution from last week and also not getting where is issue from mobile side or from server side.

Thanks in Advance....

答:
I got a solution for my problem.

```<code>- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
kGCMMessageIDKey = @"gcm.message_id";
if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_7_1) {
    // iOS 7.1 or earlier. Disable the deprecation warnings.
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
    UIRemoteNotificationType allNotificationTypes =
    (UIRemoteNotificationTypeSound |
     UIRemoteNotificationTypeAlert |
     UIRemoteNotificationTypeBadge);
    [application registerForRemoteNotificationTypes:allNotificationTypes];
#pragma clang diagnostic pop
} else {
    // iOS 8 or later
    // [START register_for_notifications]
    if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_9_x_Max) {
        UIUserNotificationType allNotificationTypes =
        (UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge);
        UIUserNotificationSettings *settings =
        [UIUserNotificationSettings settingsForTypes:allNotificationTypes categories:nil];
        [[UIApplication sharedApplication] registerUserNotificationSettings:settings];
    } else {
        // iOS 10 or later
#if defined(__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
        // For iOS 10 display notification (sent via APNS)
        [UNUserNotificationCenter currentNotificationCenter].delegate = self;
        UNAuthorizationOptions authOptions =
        UNAuthorizationOptionAlert
        | UNAuthorizationOptionSound
        | UNAuthorizationOptionBadge;
        [[UNUserNotificationCenter currentNotificationCenter] requestAuthorizationWithOptions:authOptions completionHandler:^(BOOL granted, NSError * _Nullable error) {
        }];

        // For iOS 10 data message (sent via FCM)
        [FIRMessaging messaging].remoteMessageDelegate = self;
#endif
    }

    [[UIApplication sharedApplication] registerForRemoteNotifications];
    // [END register_for_notifications]
}

[UIApplication sharedApplication].applicationIconBadgeNumber = 0;

[FIRApp configure];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(tokenRefreshNotification:)
                                             name:kFIRInstanceIDTokenRefreshNotification object:nil];
return YES;
}
</code>```

in my above code I not written

```<code>[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(tokenRefreshNotification:)
                                             name:kFIRInstanceIDTokenRefreshNotification object:nil];
</code>```

this line,actually which is not in firebase direct documentation.

And also check whether may get notifications which will print in console by using this method

```<code>- (void)applicationReceivedRemoteMessage:(FIRMessagingRemoteMessage *)remoteMessage {
// Print full message
NSLog(@"Notification :%@", remoteMessage.appData);
}
</code>```

But notification may not be appear on notifications screen,because the apns formate is

```<code>{"aps":{"alert":"Testing.. (0)","badge":1,"sound":"default"}}
</code>```

but from server side it may be a different format.

Body:
I got a solution for my problem.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
kGCMMessageIDKey = @"gcm.message_id";
if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_7_1) {
    // iOS 7.1 or earlier. Disable the deprecation warnings.
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
    UIRemoteNotificationType allNotificationTypes =
    (UIRemoteNotificationTypeSound |
     UIRemoteNotificationTypeAlert |
     UIRemoteNotificationTypeBadge);
    [application registerForRemoteNotificationTypes:allNotificationTypes];
#pragma clang diagnostic pop
} else {
    // iOS 8 or later
    // [START register_for_notifications]
    if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_9_x_Max) {
        UIUserNotificationType allNotificationTypes =
        (UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge);
        UIUserNotificationSettings *settings =
        [UIUserNotificationSettings settingsForTypes:allNotificationTypes categories:nil];
        [[UIApplication sharedApplication] registerUserNotificationSettings:settings];
    } else {
        // iOS 10 or later
#if defined(__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
        // For iOS 10 display notification (sent via APNS)
        [UNUserNotificationCenter currentNotificationCenter].delegate = self;
        UNAuthorizationOptions authOptions =
        UNAuthorizationOptionAlert
        | UNAuthorizationOptionSound
        | UNAuthorizationOptionBadge;
        [[UNUserNotificationCenter currentNotificationCenter] requestAuthorizationWithOptions:authOptions completionHandler:^(BOOL granted, NSError * _Nullable error) {
        }];

        // For iOS 10 data message (sent via FCM)
        [FIRMessaging messaging].remoteMessageDelegate = self;
#endif
    }

    [[UIApplication sharedApplication] registerForRemoteNotifications];
    // [END register_for_notifications]
}

[UIApplication sharedApplication].applicationIconBadgeNumber = 0;

[FIRApp configure];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(tokenRefreshNotification:)
                                             name:kFIRInstanceIDTokenRefreshNotification object:nil];
return YES;
}

in my above code I not written

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(tokenRefreshNotification:)
                                             name:kFIRInstanceIDTokenRefreshNotification object:nil];

this line,actually which is not in firebase direct documentation.

And also check whether may get notifications which will print in console by using this method

- (void)applicationReceivedRemoteMessage:(FIRMessagingRemoteMessage *)remoteMessage {
// Print full message
NSLog(@"Notification :%@", remoteMessage.appData);
}

But notification may not be appear on notifications screen,because the apns formate is

{"aps":{"alert":"Testing.. (0)","badge":1,"sound":"default"}}

but from server side it may be a different format.


问:
jquery get first text element attribute from selected dropdown
both simple and complicate question:
I have my dropdown item created programmatically from ajax request and that is ok. So i serve name and surname for convenient aestetic way, but i need to send an ajax post with only surname and value is needed for other purposes.

```<code>$('#dropDocente').append('<option value="'+value.idDocente+'"">' + value.surname   + ' ' + value.name  +'</option>');
</code>```

what i would achieve is:

```<code>var testd = $("#dropDocente option:selected").text();
console.log("Surname is : "+testd);
desired output == Surname is : Doe
</code>```

so, in other hand, i would like get only first element of text in selected dropbox.

I can help me to understand how to reach my goal?

答:
You could just split full name on select change.

Something like this:

```<code>$('select').on('change', function(){
    var id = $(this).val();
    var fullName = $('select option:selected').text();
    var surname = fullName.split(" ", 1);
});
</code>```

Full example here: https://jsfiddle.net/1aj06Lw6/1/

Body:
both simple and complicate question:
I have my dropdown item created programmatically from ajax request and that is ok. So i serve name and surname for convenient aestetic way, but i need to send an ajax post with only surname and value is needed for other purposes.

$('#dropDocente').append('<option value="'+value.idDocente+'"">' + value.surname   + ' ' + value.name  +'</option>');

what i would achieve is:

var testd = $("#dropDocente option:selected").text();
console.log("Surname is : "+testd);
desired output == Surname is : Doe

so, in other hand, i would like get only first element of text in selected dropbox.

I can help me to understand how to reach my goal?

Body:
You could just split full name on select change.

Something like this:

$('select').on('change', function(){
    var id = $(this).val();
    var fullName = $('select option:selected').text();
    var surname = fullName.split(" ", 1);
});

Full example here: https://jsfiddle.net/1aj06Lw6/1/


问:
Which is a better way to query in Django (Raw query vs ORM)?
I am using MySQL, I have two schemas and I have to perform a join over multiple schemas, which as you might know is not supported with the Django ORM.

So, this is most simplified SQL query for this scenario

```<code>SELECT * FROM db1.a AS a
JOIN db2.b AS b
ON b.some_id = a.id
WHERE a.name = 'localhost'
</code>```

DJANGO ORM

Now, if I use Django ORM, I will have to do something like

```<code>a_obj = ModelA.objects.filter(name='localhost')
ModelB.objects.filter(some_id__in=a_obj)
</code>```

DJANGO RAW SQL / CONNECTION

```<code>from django.db import connection

sql = 'SELECT * FROM db1.a AS a
       JOIN db2.b AS b
       ON b.some_id = a.id
       WHERE a.name = %s'
cursor = connection.cursor()
try:
      cursor.execute(sql, ['localhost'])
      row = cursor.fetchall()
except Exception as e:
      cursor.close
</code>```

Now, I understand that both of them are going to give me the required result. But, why use one over the other? From what I see, the Django ORM will have to hit the database twice to get the required info, while the raw query can get it with a single hit, here in my opinion the raw query wins. Again, the raw query prevents from sql injection attacks by using parameterised query, which escapes the variable, thus preventing the attack.

A lot of people have suggested using Django ORM, over the raw query, but, in these scenarios, I don't see Django ORM doing any better than Raw query, it not worse.

So, which one should I use, keeping in mind database performance and security? And Why?

答:
Here's my generic, perhaps unpopular, opinion on ORM vs RAW SQL in Django.

In short, it depends.

The ORM is a common conversion point among the majority of developers who work with Django. Most Django developers are going to have a comfort level with the Django orm. Most tutorials, plugins, and examples leverage the orm to interface with the database. I've even seen some junior devs who don't even know SQL queries and only know how to use the ORM.

RAW SQL will be more efficient in a lot of cases, however you then bypass the abstraction benefits the ORM provides.

If you truly care about optimizing then RAW SQL will be inevitable, but if you care more about (depending on the team) consistency and leveraging the abstraction then stick with the ORM.

My personal strategy is to stick with the ORM as much as I can even in cases when it's less efficient. I don't use Django much anymore, but when I do use Django I'm using it solely to use its batteries, packages, plugins, and extensions to increase developer efficiency. If I really cared about performance and optimization I wouldn't be using Django in the first place.

Body:
I am using MySQL, I have two schemas and I have to perform a join over multiple schemas, which as you might know is not supported with the Django ORM.

So, this is most simplified SQL query for this scenario

SELECT * FROM db1.a AS a
JOIN db2.b AS b
ON b.some_id = a.id
WHERE a.name = 'localhost'

DJANGO ORM

Now, if I use Django ORM, I will have to do something like

a_obj = ModelA.objects.filter(name='localhost')
ModelB.objects.filter(some_id__in=a_obj)

DJANGO RAW SQL / CONNECTION

from django.db import connection

sql = 'SELECT * FROM db1.a AS a
       JOIN db2.b AS b
       ON b.some_id = a.id
       WHERE a.name = %s'
cursor = connection.cursor()
try:
      cursor.execute(sql, ['localhost'])
      row = cursor.fetchall()
except Exception as e:
      cursor.close

Now, I understand that both of them are going to give me the required result. But, why use one over the other? From what I see, the Django ORM will have to hit the database twice to get the required info, while the raw query can get it with a single hit, here in my opinion the raw query wins. Again, the raw query prevents from sql injection attacks by using parameterised query, which escapes the variable, thus preventing the attack.

A lot of people have suggested using Django ORM, over the raw query, but, in these scenarios, I don't see Django ORM doing any better than Raw query, it not worse.

So, which one should I use, keeping in mind database performance and security? And Why?


问:
How to both type and have a drop down list in Ruby form?
Right now, my drop down list is pulling values from a database file. However, there are too many values (150+ values) and searching them is a pain. Is there any way I can type the values as well?

While I type, the corresponding list values can be highlighted. This will help the user to find and select the value he/she requires.

答:
You'd be best off using a js library like chosen, which is easily integrated with rails if needed via chosen-rails, or just use it standalone!

No need to reinvent the wheel.


问:
Test Which folder project is running from in C#
I have code that tests which folder a project is running from to determine if it is the testing version or production version.  I know there is a way to do this with the difference between debug version and released (which I want to do in the future but I don't know how yet).  So for now, this is a workaround to get me what I need. This code works correctly when I run from Visual Studio but not when my scheduled task runs the compiled version.

```<code>string projectPath = System.IO.Directory.GetCurrentDirectory();
var TestVersion = true;
if (projectPath == @"H:\Automation\RefreshData\RefreshData\bin\Debug" || projectPath == @"\\atlelz1fs03.atalanta.local\USERS\Automation\RefreshData\RefreshData\bin\Debug" || projectPath == @"H:\Automation\RefreshData" || projectPath == @"\\atlelz1fs03.atalanta.local\USERS\Automation\RefreshData")
{
    TestVersion = false;
}
</code>```

Which folder should I be looking at for the compiled version? or is there a better way for me to determine this?

答:
Use precompiler statements:

```<code>#if DEBUG
    var TestVersion = true;
#endif
#if !DEBUG
    var TestVersion = false;
#endif
</code>```

then when in debug mode run with debug selected in visual studio (as normal) when you release this change it to Release:

this will set TestVersion to false in your released code only. (BTW I have lots of configuration options, just ignore these, you will likely have Debug and Release only)

This works even better if you use continuous integration to compile your code for you, you can then configure this to do this, so you don't forget.

Body:
I have code that tests which folder a project is running from to determine if it is the testing version or production version.  I know there is a way to do this with the difference between debug version and released (which I want to do in the future but I don't know how yet).  So for now, this is a workaround to get me what I need. This code works correctly when I run from Visual Studio but not when my scheduled task runs the compiled version.

string projectPath = System.IO.Directory.GetCurrentDirectory();
var TestVersion = true;
if (projectPath == @"H:\Automation\RefreshData\RefreshData\bin\Debug" || projectPath == @"\\atlelz1fs03.atalanta.local\USERS\Automation\RefreshData\RefreshData\bin\Debug" || projectPath == @"H:\Automation\RefreshData" || projectPath == @"\\atlelz1fs03.atalanta.local\USERS\Automation\RefreshData")
{
    TestVersion = false;
}

Which folder should I be looking at for the compiled version? or is there a better way for me to determine this?

Body:
Use precompiler statements:

#if DEBUG
    var TestVersion = true;
#endif
#if !DEBUG
    var TestVersion = false;
#endif

then when in debug mode run with debug selected in visual studio (as normal) when you release this change it to Release:

this will set TestVersion to false in your released code only. (BTW I have lots of configuration options, just ignore these, you will likely have Debug and Release only)

This works even better if you use continuous integration to compile your code for you, you can then configure this to do this, so you don't forget.


问:
shutdownguest vmware ansible
I am trying to shutdown a guest in ansible using vmware_guest

Nothing I do is working.

Can anyone help?

What is the yml code to just initiate guest shutdown?

Many Thanks

Chris

答:
I've never used vmware_guest, but take a look at the documentation on https://docs.ansible.com/ansible/vmware_guest_module.html . It seems pretty easy, something like:</p>

```<code>- hosts: vmwaremaster
  tasks:
    - name: shutdown myguest
      vmware_guest:
        hostname: ip_of_vcenter
        password: pwassword_of_vcenter
        username: username_of_vcenter
        name: myguest
        state: shutdownguest
</code>```

Title: shutdownguest vmware ansible

Body:
I've never used vmware_guest, but take a look at the documentation on https://docs.ansible.com/ansible/vmware_guest_module.html . It seems pretty easy, something like:

- hosts: vmwaremaster
  tasks:
    - name: shutdown myguest
      vmware_guest:
        hostname: ip_of_vcenter
        password: pwassword_of_vcenter
        username: username_of_vcenter
        name: myguest
        state: shutdownguest


问:
pgadmin4 query tool always comes back not connected
Q: How can I diagnose and correct problems with the Query tool connection.

Using pgAdmin4 1.0-rc1 to connect to a local host "PostgreSQL 9.5.3, compiled by Visual C++ build 18..."

I can connect and drill down to my schema. I use the context menu to select 'Query tool'. The editor shows the correct database@host:port in the editor header bar.

When I execute a simple query, or any query
  select 1 as first;

I get the message
"Not conencted to the server or the connection to the server has been closed.

instead of the expected results.

The editor alwa

答:
This issue has been resolved now,
Upgrade pgAdmin4 to version 1.3. https://www.pgadmin.org/download/</p>


问:
Parse json file in U-SQL
I'm trying to parse below Json file using USQL but keep getting error.

```<code>Json file@

{"dimBetType_SKey":1,"BetType_BKey":1,"BetTypeName":"Test1"}
{"dimBetType_SKey":2,"BetType_BKey":2,"BetTypeName":"Test2"}
{"dimBetType_SKey":3,"BetType_BKey":3,"BetTypeName":"Test3"}
</code>```

Below is the USQL script, I'm trying to extract the data from above file.

```<code>    REFERENCE ASSEMBLY [Newtonsoft.Json];
    REFERENCE ASSEMBLY [Microsoft.Analytics.Samples.Formats];

DECLARE @Full_Path string =
"adl://xxxx.azuredatalakestore.net/2017/03/28/00_0_66ffdd26541742fab57139e95080e704.json";

DECLARE @Output_Path = "adl://xxxx.azuredatalakestore.net/Output/Output.csv";

@logSchema =
EXTRACT dimBetType_SKey int
FROM @Full_Path
USING new Microsoft.Analytics.Samples.Formats.Json.JsonExtractor();

OUTPUT @logSchema
TO @Output_Path
USING Outputters.Csv();
</code>```

But the USQL is keep failing with Vertex error

Any help?

答:
This is probably because you have new JSON blocks on each new line of the file. This means you need to parse it slightly differently rather than in being a straight JSON file.

Try just using a text extractor first to bring in each JSON element with a new line delimiter. Like this...

```<code>DECLARE @Full_Path string = "etc"

@RawExtract =
    EXTRACT
        [RawString] string,
        [FileName] string //optional, see below
    FROM
        @Full_Path
    USING
        Extractors.Text(delimiter:'\b', quoting : false);
</code>```

Then shred the JSON with the assembly you've referenced, but using the JSON tuple method. Like this...

```<code>REFERENCE ASSEMBLY [Newtonsoft.Json];
REFERENCE ASSEMBLY [Microsoft.Analytics.Samples.Formats];

@ParsedJSONLines =
    SELECT
        Microsoft.Analytics.Samples.Formats.Json.JsonFunctions.JsonTuple([RawString]) AS JSONLine,
        [FileName]
    FROM
        @RawExtract
</code>```

Next, get the values out. Like this...

```<code>@StagedData =
    SELECT
        JSONLine["dimBetType_SKey"] AS dimBetType_SKey,
        JSONLine["BetType_BKey"] AS BetType_BKey,
        JSONLine["BetTypeName"] AS BetTypeName
        [FileName]
    FROM
        @ParsedJSONLines;
</code>```

Finally, do your output to CSV, or whatever.

```<code>DECLARE @Output_Path string = "etc"

OUTPUT @StagedData
TO @Output_Path
USING Outputters.Csv();
</code>```

As a side note, you don't need to reference the complete data lake store path. The analytics engine knows where the root to the storage is so you can probably replace your variables with just this...

```<code>DECLARE @Full_Path string = "/2017/03/28/{FileName}";
</code>```

Hope this helps sort your issue.

Title: Parse json file in U-SQL

Body:
I'm trying to parse below Json file using USQL but keep getting error.

Json file@

{"dimBetType_SKey":1,"BetType_BKey":1,"BetTypeName":"Test1"}
{"dimBetType_SKey":2,"BetType_BKey":2,"BetTypeName":"Test2"}
{"dimBetType_SKey":3,"BetType_BKey":3,"BetTypeName":"Test3"}

Below is the USQL script, I'm trying to extract the data from above file.

    REFERENCE ASSEMBLY [Newtonsoft.Json];
    REFERENCE ASSEMBLY [Microsoft.Analytics.Samples.Formats];

DECLARE @Full_Path string =
"adl://xxxx.azuredatalakestore.net/2017/03/28/00_0_66ffdd26541742fab57139e95080e704.json";

DECLARE @Output_Path = "adl://xxxx.azuredatalakestore.net/Output/Output.csv";

@logSchema =
EXTRACT dimBetType_SKey int
FROM @Full_Path
USING new Microsoft.Analytics.Samples.Formats.Json.JsonExtractor();

OUTPUT @logSchema
TO @Output_Path
USING Outputters.Csv();

But the USQL is keep failing with Vertex error

Any help?

Body:
This is probably because you have new JSON blocks on each new line of the file. This means you need to parse it slightly differently rather than in being a straight JSON file.

Try just using a text extractor first to bring in each JSON element with a new line delimiter. Like this...

DECLARE @Full_Path string = "etc"

@RawExtract =
    EXTRACT
        [RawString] string,
        [FileName] string //optional, see below
    FROM
        @Full_Path
    USING
        Extractors.Text(delimiter:'\b', quoting : false);

Then shred the JSON with the assembly you've referenced, but using the JSON tuple method. Like this...

REFERENCE ASSEMBLY [Newtonsoft.Json];
REFERENCE ASSEMBLY [Microsoft.Analytics.Samples.Formats];

@ParsedJSONLines =
    SELECT
        Microsoft.Analytics.Samples.Formats.Json.JsonFunctions.JsonTuple([RawString]) AS JSONLine,
        [FileName]
    FROM
        @RawExtract

Next, get the values out. Like this...

@StagedData =
    SELECT
        JSONLine["dimBetType_SKey"] AS dimBetType_SKey,
        JSONLine["BetType_BKey"] AS BetType_BKey,
        JSONLine["BetTypeName"] AS BetTypeName
        [FileName]
    FROM
        @ParsedJSONLines;

Finally, do your output to CSV, or whatever.

DECLARE @Output_Path string = "etc"

OUTPUT @StagedData
TO @Output_Path
USING Outputters.Csv();

As a side note, you don't need to reference the complete data lake store path. The analytics engine knows where the root to the storage is so you can probably replace your variables with just this...

DECLARE @Full_Path string = "/2017/03/28/{FileName}";

Hope this helps sort your issue.


问:
Extract video from streaming
Imagine a live video being streamed from a HD Camera to a computer. I would like to place markers at various moment on this stream in order to extract the content between markers to a file.

I am familiar with Scala but I could considere looking at any other technology do to the job.

Any idea on how to get started with this crazy idea ? :D

Thanks!

答:
Not sure what you're trying to do..

Try maybe use NodeJs - create readStream and mark the data on the fly. Or maybe save it to a temp file and mess with it in offline mode.

There is an npm package that expose the ffmpeg api to nodejs (https://github.com/fluent-ffmpeg/node-fluent-ffmpeg) so you could use ffmpeg functions on your stream.

Title: Extract video from streaming


问:
visible button in grid
my gridpane is :

```<code><?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>

<AnchorPane id="AnchorPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="569.0" prefWidth="794.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/2.2" fx:controller="com.controller.test">
  <children>
    <GridPane layoutX="10.0" layoutY="270.0" prefWidth="775.0" rotate="0.0">
      <children>
        <Button fx:id="btn1" mnemonicParsing="false" prefWidth="67.0" rotate="0.0" text="btn1" GridPane.columnIndex="0" GridPane.rowIndex="0" />
        <Button fx:id="btn2" mnemonicParsing="false" prefWidth="67.0" rotate="0.0" text="btn2" GridPane.columnIndex="1" GridPane.rowIndex="0" />
        <Button fx:id="btn3" mnemonicParsing="false" prefWidth="67.0" rotate="0.0" text="btn3" GridPane.columnIndex="2" GridPane.rowIndex="0" />
        <Button fx:id="btn4" mnemonicParsing="false" prefWidth="67.0" rotate="0.0" text="btn4" GridPane.columnIndex="3" GridPane.rowIndex="0" />
      </children>
      <columnConstraints>
        <ColumnConstraints maxWidth="594.0" minWidth="10.0" prefWidth="69.0" />
        <ColumnConstraints maxWidth="594.0" minWidth="10.0" prefWidth="69.0" />
        <ColumnConstraints maxWidth="558.0" minWidth="10.0" prefWidth="67.0" />
        <ColumnConstraints maxWidth="507.0" minWidth="10.0" prefWidth="507.0" />
      </columnConstraints>
      <rowConstraints>
        <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
      </rowConstraints>
    </GridPane>
  </children>
</AnchorPane>
</code>```

i need the result like below image when visible(false) for btn1,btn2

i use scene builder. thanks

答: In addition to making the components invisible by setting the visible property to false ('visible="false"'), you have set the managed property to false (managed="false").But with explicit 'ColumnConstraints' in your fxml, 'managed=false' will not have effect. So you may want to avoid using ColumnConstraints  and instead use GridPane child component's properties to set dimensions.</p>

Title: visible button in grid

Body:
my gridpane is :

<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>

<AnchorPane id="AnchorPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="569.0" prefWidth="794.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/2.2" fx:controller="com.controller.test">
  <children>
    <GridPane layoutX="10.0" layoutY="270.0" prefWidth="775.0" rotate="0.0">
      <children>
        <Button fx:id="btn1" mnemonicParsing="false" prefWidth="67.0" rotate="0.0" text="btn1" GridPane.columnIndex="0" GridPane.rowIndex="0" />
        <Button fx:id="btn2" mnemonicParsing="false" prefWidth="67.0" rotate="0.0" text="btn2" GridPane.columnIndex="1" GridPane.rowIndex="0" />
        <Button fx:id="btn3" mnemonicParsing="false" prefWidth="67.0" rotate="0.0" text="btn3" GridPane.columnIndex="2" GridPane.rowIndex="0" />
        <Button fx:id="btn4" mnemonicParsing="false" prefWidth="67.0" rotate="0.0" text="btn4" GridPane.columnIndex="3" GridPane.rowIndex="0" />
      </children>
      <columnConstraints>
        <ColumnConstraints maxWidth="594.0" minWidth="10.0" prefWidth="69.0" />
        <ColumnConstraints maxWidth="594.0" minWidth="10.0" prefWidth="69.0" />
        <ColumnConstraints maxWidth="558.0" minWidth="10.0" prefWidth="67.0" />
        <ColumnConstraints maxWidth="507.0" minWidth="10.0" prefWidth="507.0" />
      </columnConstraints>
      <rowConstraints>
        <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
      </rowConstraints>
    </GridPane>
  </children>
</AnchorPane>

i need the result like below image when visible(false) for btn1,btn2

i use scene builder. thanks


问:
One ImageButton works, the others crash app
I have 6 ImageButtons in one activity, the first one works without any issues but the others when clicked on the device crash the app.
I have used the same code for the rest of the ImageButtons - am I missing something?

```<code><LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="#FF54561E"
    android:orientation="vertical"
    android:textAlignment="center">

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="120dp"
        android:layout_margin="8dp"
        android:layout_weight="1"
        android:contentDescription="@string/Logo"
        android:src="@drawable/idailment"
        android:textAlignment="center"

        />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="15dp"
        android:layout_weight="1"
        android:text="@string/IdDisease"
        android:textAlignment="center"
        android:textColor="#FFFFFF"
        android:textSize="16sp"
        android:textStyle="italic" />

    <TextView
        android:layout_width="300dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_margin="10dp"
        android:gravity="center"
        android:text="@string/BlackRotButton"
        android:textColor="#FFFFFF"
        android:textSize="20sp"
        android:textStyle="bold" />

    <ImageButton
        android:id="@+id/BlackRotAnim"
        android:layout_width="300dp"
        android:layout_height="300dp"
        android:layout_gravity="center"
        android:layout_marginBottom="20dp"
        android:layout_weight="1"
        android:background="@drawable/black_rot_anim"
        android:contentDescription="@string/BlackRotButton"
        android:gravity="center"
        android:onClick="goToDiseaseBlackRot"
        android:scaleType="centerCrop" />

    <TextView
        android:layout_width="300dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_margin="10dp"
        android:gravity="center"
        android:text="@string/BacterialBrownSpotButton"
        android:textColor="#FFFFFF"
        android:textSize="20sp"
        android:textStyle="bold" />

    <ImageButton
        android:id="@+id/BacterialBrownSpotAnim"
        android:layout_width="300dp"
        android:layout_height="300dp"
        android:layout_gravity="center"
        android:layout_marginBottom="20dp"
        android:layout_weight="1"
        android:background="@drawable/bacterial_brown_spot_anim"
        android:contentDescription="@string/BacterialBrownSpotButton"
        android:gravity="center"
        android:onClick="goToDiseaseBacterialBrownSpot"
        android:scaleType="centerCrop" />

    <TextView
        android:layout_width="300dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_margin="10dp"
        android:gravity="center"
        android:text="@string/BudBlastButton"
        android:textColor="#FFFFFF"
        android:textSize="20sp"
        android:textStyle="bold" />

    <ImageButton
        android:id="@+id/BudBlastAnim"
        android:layout_width="300dp"
        android:layout_height="300dp"
        android:layout_gravity="center"
        android:layout_marginBottom="20dp"
        android:layout_weight="1"
        android:background="@drawable/bud_blast_anim"
        android:contentDescription="@string/BudBlastButton"
        android:gravity="center"
        android:onClick="goToDiseaseBudBlast"
        android:scaleType="centerCrop" />

    <TextView
        android:layout_width="300dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_margin="10dp"
        android:gravity="center"
        android:text="@string/RotButton"
        android:textColor="#FFFFFF"
        android:textSize="20sp"
        android:textStyle="bold" />

    <ImageButton
        android:id="@+id/RotAnim"
        android:layout_width="300dp"
        android:layout_height="300dp"
        android:layout_gravity="center"
        android:layout_marginBottom="20dp"
        android:layout_weight="1"
        android:background="@drawable/rot_anim"
        android:contentDescription="@string/RotButton"
        android:gravity="center"
        android:onClick="goToDiseaseRot"
        android:scaleType="centerCrop" />

    <TextView
        android:layout_width="300dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_margin="10dp"
        android:gravity="center"
        android:text="@string/SunBurnButton"
        android:textColor="#FFFFFF"
        android:textSize="20sp"
        android:textStyle="bold" />

    <ImageButton
        android:id="@+id/SunBurnAnim"
        android:layout_width="300dp"
        android:layout_height="300dp"
        android:layout_gravity="center"
        android:layout_marginBottom="20dp"
        android:layout_weight="1"
        android:background="@drawable/sun_burn_anim"
        android:contentDescription="@string/SunBurnButton"
        android:gravity="center"
        android:onClick="goToDiseaseSunBurn"
        android:scaleType="centerCrop" />

    <TextView
        android:layout_width="300dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_margin="10dp"
        android:gravity="center"
        android:text="@string/VirusButton"
        android:textColor="#FFFFFF"
        android:textSize="20sp"
        android:textStyle="bold" />

    <ImageButton
        android:id="@+id/VirusAnim"
        android:layout_width="300dp"
        android:layout_height="300dp"
        android:layout_gravity="center"
        android:layout_marginBottom="20dp"
        android:layout_weight="1"
        android:background="@drawable/virus_anim"
        android:contentDescription="@string/VirusButton"
        android:gravity="center"
        android:onClick="goToDiseaseVirus"
        android:scaleType="centerCrop" />

</LinearLayout>
</code>```

And

```<code>    // Load the ImageView that will host the animation and
    // set its background to our AnimationDrawable XML resource.
    ImageView blackRotButton = (ImageView)findViewById(BlackRotAnim);
    blackRotButton.setBackgroundResource(R.drawable.black_rot_anim);

    // Get the background, which has been compiled to an AnimationDrawable object.
    AnimationDrawable diseaseButton1Animation = (AnimationDrawable) blackRotButton.getBackground();

    // Start the animation (looped playback by default).
    diseaseButton1Animation.start();

    // Load the ImageView that will host the animation and
    // set its background to our AnimationDrawable XML resource.
    ImageView bacterialBrownSpotButton = (ImageView)findViewById(BacterialBrownSpotAnim);
    bacterialBrownSpotButton.setBackgroundResource(R.drawable.bacterial_brown_spot_anim);

    // Get the background, which has been compiled to an AnimationDrawable object.
    AnimationDrawable diseaseButton2Animation = (AnimationDrawable) bacterialBrownSpotButton.getBackground();

    // Start the animation (looped playback by default).
    diseaseButton2Animation.start();

    // Load the ImageView that will host the animation and
    // set its background to our AnimationDrawable XML resource.
    ImageView budBlasttButton = (ImageView)findViewById(BudBlastAnim);
    budBlasttButton.setBackgroundResource(R.drawable.bud_blast_anim);

    // Get the background, which has been compiled to an AnimationDrawable object.
    AnimationDrawable diseaseButton3Animation = (AnimationDrawable) budBlasttButton.getBackground();

    // Start the animation (looped playback by default).
    diseaseButton3Animation.start();

    // Load the ImageView that will host the animation and
    // set its background to our AnimationDrawable XML resource.
    ImageView rotButton = (ImageView)findViewById(RotAnim);
    rotButton.setBackgroundResource(R.drawable.rot_anim);

    // Get the background, which has been compiled to an AnimationDrawable object.
    AnimationDrawable diseaseButton4Animation = (AnimationDrawable) rotButton.getBackground();

    // Start the animation (looped playback by default).
    diseaseButton4Animation.start();

    // Load the ImageView that will host the animation and
    // set its background to our AnimationDrawable XML resource.
    ImageView sunBurnButton = (ImageView)findViewById(SunBurnAnim);
    sunBurnButton.setBackgroundResource(R.drawable.sun_burn_anim);

    // Get the background, which has been compiled to an AnimationDrawable object.
    AnimationDrawable diseaseButton5Animation = (AnimationDrawable) sunBurnButton.getBackground();

    // Start the animation (looped playback by default).
    diseaseButton5Animation.start();

    // Load the ImageView that will host the animation and
    // set its background to our AnimationDrawable XML resource.
    ImageView virusButton = (ImageView)findViewById(VirusAnim);
    virusButton.setBackgroundResource(R.drawable.virus_anim);

    // Get the background, which has been compiled to an AnimationDrawable object.
    AnimationDrawable diseaseButton6Animation = (AnimationDrawable) virusButton.getBackground();

    // Start the animation (looped playback by default).
    diseaseButton6Animation.start();}

/**
 * This method is called when BlackRot button is clicked.
 */
public void goToDiseaseBlackRot (View view){
    Intent intent = new Intent (this, DiseaseBlackRot.class);
    startActivity(intent);}
/**
 * This method is called when BlackRot button is clicked.
 */
public void goToDiseaseBacterialBrownSpot (View view){
    Intent intent = new Intent (this, DiseaseBacterialBrownSpot.class);
    startActivity(intent);}
/**
 * This method is called when BlackRot button is clicked.
 */
public void goToDiseaseRot (View view){
    Intent intent = new Intent (this, DiseaseRot.class);
    startActivity(intent);}
/**
 * This method is called when BlackRot button is clicked.
 */
public void goToDiseaseVirus (View view){
    Intent intent = new Intent (this, DiseaseVirus.class);
    startActivity(intent);}
/**
 * This method is called when BlackRot button is clicked.
 */
public void goToDiseaseSunBurn (View view){
    Intent intent = new Intent (this, DiseaseSunBurn.class);
    startActivity(intent);}
/**
 * This method is called when BlackRot button is clicked.
 */
public void goToDiseaseBudBlast (View view){
    Intent intent = new Intent (this, DiseaseBudBlast.class);
    startActivity(intent);}}
</code>```

First few logcat errors are these actually
Thank you so much for all your effort!

04-03 18:50:46.461 140-10698/? W/SocketClient: write error (Broken pipe)
W/ADB_SERVICES: terminating JDWP 9676 connection: I/O error

答:
The layout file seems perfect. Use this code. I Have used R.id:</p>

```<code>// Load the ImageView that will host the animation and
// set its background to our AnimationDrawable XML resource.
ImageView blackRotButton = (ImageView)findViewById(R.id.BlackRotAnim);
blackRotButton.setBackgroundResource(R.drawable.black_rot_anim);

// Get the background, which has been compiled to an AnimationDrawable object.
AnimationDrawable diseaseButton1Animation = (AnimationDrawable) blackRotButton.getBackground();

// Start the animation (looped playback by default).
diseaseButton1Animation.start();

// Load the ImageView that will host the animation and
// set its background to our AnimationDrawable XML resource.
ImageView bacterialBrownSpotButton = (ImageView)findViewById(R.id.BacterialBrownSpotAnim);
bacterialBrownSpotButton.setBackgroundResource(R.drawable.bacterial_brown_spot_anim);

// Get the background, which has been compiled to an AnimationDrawable object.
AnimationDrawable diseaseButton2Animation = (AnimationDrawable) bacterialBrownSpotButton.getBackground();

// Start the animation (looped playback by default).
diseaseButton2Animation.start();

// Load the ImageView that will host the animation and
// set its background to our AnimationDrawable XML resource.
ImageView budBlasttButton = (ImageView)findViewById(R.id.BudBlastAnim);
budBlasttButton.setBackgroundResource(R.drawable.bud_blast_anim);

// Get the background, which has been compiled to an AnimationDrawable object.
AnimationDrawable diseaseButton3Animation = (AnimationDrawable) budBlasttButton.getBackground();

// Start the animation (looped playback by default).
diseaseButton3Animation.start();

// Load the ImageView that will host the animation and
// set its background to our AnimationDrawable XML resource.
ImageView rotButton = (ImageView)findViewById(R.id.RotAnim);
rotButton.setBackgroundResource(R.drawable.rot_anim);

// Get the background, which has been compiled to an AnimationDrawable object.
AnimationDrawable diseaseButton4Animation = (AnimationDrawable) rotButton.getBackground();

// Start the animation (looped playback by default).
diseaseButton4Animation.start();

// Load the ImageView that will host the animation and
// set its background to our AnimationDrawable XML resource.
ImageView sunBurnButton = (ImageView)findViewById(R.id.SunBurnAnim);
sunBurnButton.setBackgroundResource(R.drawable.sun_burn_anim);

// Get the background, which has been compiled to an AnimationDrawable object.
AnimationDrawable diseaseButton5Animation = (AnimationDrawable) sunBurnButton.getBackground();

// Start the animation (looped playback by default).
diseaseButton5Animation.start();

// Load the ImageView that will host the animation and
// set its background to our AnimationDrawable XML resource.
ImageView virusButton = (ImageView)findViewById(R.id.VirusAnim);
virusButton.setBackgroundResource(R.drawable.virus_anim);

// Get the background, which has been compiled to an AnimationDrawable object.
AnimationDrawable diseaseButton6Animation = (AnimationDrawable) virusButton.getBackground();

// Start the animation (looped playback by default).
diseaseButton6Animation.start();}

 /**
 * This method is called when BlackRot button is clicked.
 */
public void goToDiseaseBlackRot (View view){
    Intent intent = new Intent (this, DiseaseBlackRot.class);
    startActivity(intent);}
/**
 * This method is called when BlackRot button is clicked.
 */
 public void goToDiseaseBacterialBrownSpot (View view){
    Intent intent = new Intent (this, DiseaseBacterialBrownSpot.class);
    startActivity(intent);}
 /**
  * This method is called when BlackRot button is clicked.
 */
 public void goToDiseaseRot (View view){
    Intent intent = new Intent (this, DiseaseRot.class);
   startActivity(intent);}
 /**
  * This method is called when BlackRot button is clicked.
*/
 public void goToDiseaseVirus (View view){
     Intent intent = new Intent (this, DiseaseVirus.class);
     startActivity(intent);}
 /**
  * This method is called when BlackRot button is clicked.
 */
 public void goToDiseaseSunBurn (View view){
     Intent intent = new Intent (this, DiseaseSunBurn.class);
     startActivity(intent);}
 /**
  * This method is called when BlackRot button is clicked.
 */
 public void goToDiseaseBudBlast (View view){
 Intent intent = new Intent (this, DiseaseBudBlast.class);
 startActivity(intent);}}
</code>```

Body:
I have 6 ImageButtons in one activity, the first one works without any issues but the others when clicked on the device crash the app.
I have used the same code for the rest of the ImageButtons - am I missing something?

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="#FF54561E"
    android:orientation="vertical"
    android:textAlignment="center">

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="120dp"
        android:layout_margin="8dp"
        android:layout_weight="1"
        android:contentDescription="@string/Logo"
        android:src="@drawable/idailment"
        android:textAlignment="center"

        />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="15dp"
        android:layout_weight="1"
        android:text="@string/IdDisease"
        android:textAlignment="center"
        android:textColor="#FFFFFF"
        android:textSize="16sp"
        android:textStyle="italic" />

    <TextView
        android:layout_width="300dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_margin="10dp"
        android:gravity="center"
        android:text="@string/BlackRotButton"
        android:textColor="#FFFFFF"
        android:textSize="20sp"
        android:textStyle="bold" />

    <ImageButton
        android:id="@+id/BlackRotAnim"
        android:layout_width="300dp"
        android:layout_height="300dp"
        android:layout_gravity="center"
        android:layout_marginBottom="20dp"
        android:layout_weight="1"
        android:background="@drawable/black_rot_anim"
        android:contentDescription="@string/BlackRotButton"
        android:gravity="center"
        android:onClick="goToDiseaseBlackRot"
        android:scaleType="centerCrop" />

    <TextView
        android:layout_width="300dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_margin="10dp"
        android:gravity="center"
        android:text="@string/BacterialBrownSpotButton"
        android:textColor="#FFFFFF"
        android:textSize="20sp"
        android:textStyle="bold" />

    <ImageButton
        android:id="@+id/BacterialBrownSpotAnim"
        android:layout_width="300dp"
        android:layout_height="300dp"
        android:layout_gravity="center"
        android:layout_marginBottom="20dp"
        android:layout_weight="1"
        android:background="@drawable/bacterial_brown_spot_anim"
        android:contentDescription="@string/BacterialBrownSpotButton"
        android:gravity="center"
        android:onClick="goToDiseaseBacterialBrownSpot"
        android:scaleType="centerCrop" />

    <TextView
        android:layout_width="300dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_margin="10dp"
        android:gravity="center"
        android:text="@string/BudBlastButton"
        android:textColor="#FFFFFF"
        android:textSize="20sp"
        android:textStyle="bold" />

    <ImageButton
        android:id="@+id/BudBlastAnim"
        android:layout_width="300dp"
        android:layout_height="300dp"
        android:layout_gravity="center"
        android:layout_marginBottom="20dp"
        android:layout_weight="1"
        android:background="@drawable/bud_blast_anim"
        android:contentDescription="@string/BudBlastButton"
        android:gravity="center"
        android:onClick="goToDiseaseBudBlast"
        android:scaleType="centerCrop" />

    <TextView
        android:layout_width="300dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_margin="10dp"
        android:gravity="center"
        android:text="@string/RotButton"
        android:textColor="#FFFFFF"
        android:textSize="20sp"
        android:textStyle="bold" />

    <ImageButton
        android:id="@+id/RotAnim"
        android:layout_width="300dp"
        android:layout_height="300dp"
        android:layout_gravity="center"
        android:layout_marginBottom="20dp"
        android:layout_weight="1"
        android:background="@drawable/rot_anim"
        android:contentDescription="@string/RotButton"
        android:gravity="center"
        android:onClick="goToDiseaseRot"
        android:scaleType="centerCrop" />

    <TextView
        android:layout_width="300dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_margin="10dp"
        android:gravity="center"
        android:text="@string/SunBurnButton"
        android:textColor="#FFFFFF"
        android:textSize="20sp"
        android:textStyle="bold" />

    <ImageButton
        android:id="@+id/SunBurnAnim"
        android:layout_width="300dp"
        android:layout_height="300dp"
        android:layout_gravity="center"
        android:layout_marginBottom="20dp"
        android:layout_weight="1"
        android:background="@drawable/sun_burn_anim"
        android:contentDescription="@string/SunBurnButton"
        android:gravity="center"
        android:onClick="goToDiseaseSunBurn"
        android:scaleType="centerCrop" />

    <TextView
        android:layout_width="300dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_margin="10dp"
        android:gravity="center"
        android:text="@string/VirusButton"
        android:textColor="#FFFFFF"
        android:textSize="20sp"
        android:textStyle="bold" />

    <ImageButton
        android:id="@+id/VirusAnim"
        android:layout_width="300dp"
        android:layout_height="300dp"
        android:layout_gravity="center"
        android:layout_marginBottom="20dp"
        android:layout_weight="1"
        android:background="@drawable/virus_anim"
        android:contentDescription="@string/VirusButton"
        android:gravity="center"
        android:onClick="goToDiseaseVirus"
        android:scaleType="centerCrop" />

</LinearLayout>

And

    // Load the ImageView that will host the animation and
    // set its background to our AnimationDrawable XML resource.
    ImageView blackRotButton = (ImageView)findViewById(BlackRotAnim);
    blackRotButton.setBackgroundResource(R.drawable.black_rot_anim);

    // Get the background, which has been compiled to an AnimationDrawable object.
    AnimationDrawable diseaseButton1Animation = (AnimationDrawable) blackRotButton.getBackground();

    // Start the animation (looped playback by default).
    diseaseButton1Animation.start();

    // Load the ImageView that will host the animation and
    // set its background to our AnimationDrawable XML resource.
    ImageView bacterialBrownSpotButton = (ImageView)findViewById(BacterialBrownSpotAnim);
    bacterialBrownSpotButton.setBackgroundResource(R.drawable.bacterial_brown_spot_anim);

    // Get the background, which has been compiled to an AnimationDrawable object.
    AnimationDrawable diseaseButton2Animation = (AnimationDrawable) bacterialBrownSpotButton.getBackground();

    // Start the animation (looped playback by default).
    diseaseButton2Animation.start();

    // Load the ImageView that will host the animation and
    // set its background to our AnimationDrawable XML resource.
    ImageView budBlasttButton = (ImageView)findViewById(BudBlastAnim);
    budBlasttButton.setBackgroundResource(R.drawable.bud_blast_anim);

    // Get the background, which has been compiled to an AnimationDrawable object.
    AnimationDrawable diseaseButton3Animation = (AnimationDrawable) budBlasttButton.getBackground();

    // Start the animation (looped playback by default).
    diseaseButton3Animation.start();

    // Load the ImageView that will host the animation and
    // set its background to our AnimationDrawable XML resource.
    ImageView rotButton = (ImageView)findViewById(RotAnim);
    rotButton.setBackgroundResource(R.drawable.rot_anim);

    // Get the background, which has been compiled to an AnimationDrawable object.
    AnimationDrawable diseaseButton4Animation = (AnimationDrawable) rotButton.getBackground();

    // Start the animation (looped playback by default).
    diseaseButton4Animation.start();

    // Load the ImageView that will host the animation and
    // set its background to our AnimationDrawable XML resource.
    ImageView sunBurnButton = (ImageView)findViewById(SunBurnAnim);
    sunBurnButton.setBackgroundResource(R.drawable.sun_burn_anim);

    // Get the background, which has been compiled to an AnimationDrawable object.
    AnimationDrawable diseaseButton5Animation = (AnimationDrawable) sunBurnButton.getBackground();

    // Start the animation (looped playback by default).
    diseaseButton5Animation.start();

    // Load the ImageView that will host the animation and
    // set its background to our AnimationDrawable XML resource.
    ImageView virusButton = (ImageView)findViewById(VirusAnim);
    virusButton.setBackgroundResource(R.drawable.virus_anim);

    // Get the background, which has been compiled to an AnimationDrawable object.
    AnimationDrawable diseaseButton6Animation = (AnimationDrawable) virusButton.getBackground();

    // Start the animation (looped playback by default).
    diseaseButton6Animation.start();}

/**
 * This method is called when BlackRot button is clicked.
 */
public void goToDiseaseBlackRot (View view){
    Intent intent = new Intent (this, DiseaseBlackRot.class);
    startActivity(intent);}
/**
 * This method is called when BlackRot button is clicked.
 */
public void goToDiseaseBacterialBrownSpot (View view){
    Intent intent = new Intent (this, DiseaseBacterialBrownSpot.class);
    startActivity(intent);}
/**
 * This method is called when BlackRot button is clicked.
 */
public void goToDiseaseRot (View view){
    Intent intent = new Intent (this, DiseaseRot.class);
    startActivity(intent);}
/**
 * This method is called when BlackRot button is clicked.
 */
public void goToDiseaseVirus (View view){
    Intent intent = new Intent (this, DiseaseVirus.class);
    startActivity(intent);}
/**
 * This method is called when BlackRot button is clicked.
 */
public void goToDiseaseSunBurn (View view){
    Intent intent = new Intent (this, DiseaseSunBurn.class);
    startActivity(intent);}
/**
 * This method is called when BlackRot button is clicked.
 */
public void goToDiseaseBudBlast (View view){
    Intent intent = new Intent (this, DiseaseBudBlast.class);
    startActivity(intent);}}

First few logcat errors are these actually
Thank you so much for all your effort!

04-03 18:50:46.461 140-10698/? W/SocketClient: write error (Broken pipe)
W/ADB_SERVICES: terminating JDWP 9676 connection: I/O error

Body:
The layout file seems perfect. Use this code. I Have used R.id:

// Load the ImageView that will host the animation and
// set its background to our AnimationDrawable XML resource.
ImageView blackRotButton = (ImageView)findViewById(R.id.BlackRotAnim);
blackRotButton.setBackgroundResource(R.drawable.black_rot_anim);

// Get the background, which has been compiled to an AnimationDrawable object.
AnimationDrawable diseaseButton1Animation = (AnimationDrawable) blackRotButton.getBackground();

// Start the animation (looped playback by default).
diseaseButton1Animation.start();

// Load the ImageView that will host the animation and
// set its background to our AnimationDrawable XML resource.
ImageView bacterialBrownSpotButton = (ImageView)findViewById(R.id.BacterialBrownSpotAnim);
bacterialBrownSpotButton.setBackgroundResource(R.drawable.bacterial_brown_spot_anim);

// Get the background, which has been compiled to an AnimationDrawable object.
AnimationDrawable diseaseButton2Animation = (AnimationDrawable) bacterialBrownSpotButton.getBackground();

// Start the animation (looped playback by default).
diseaseButton2Animation.start();

// Load the ImageView that will host the animation and
// set its background to our AnimationDrawable XML resource.
ImageView budBlasttButton = (ImageView)findViewById(R.id.BudBlastAnim);
budBlasttButton.setBackgroundResource(R.drawable.bud_blast_anim);

// Get the background, which has been compiled to an AnimationDrawable object.
AnimationDrawable diseaseButton3Animation = (AnimationDrawable) budBlasttButton.getBackground();

// Start the animation (looped playback by default).
diseaseButton3Animation.start();

// Load the ImageView that will host the animation and
// set its background to our AnimationDrawable XML resource.
ImageView rotButton = (ImageView)findViewById(R.id.RotAnim);
rotButton.setBackgroundResource(R.drawable.rot_anim);

// Get the background, which has been compiled to an AnimationDrawable object.
AnimationDrawable diseaseButton4Animation = (AnimationDrawable) rotButton.getBackground();

// Start the animation (looped playback by default).
diseaseButton4Animation.start();

// Load the ImageView that will host the animation and
// set its background to our AnimationDrawable XML resource.
ImageView sunBurnButton = (ImageView)findViewById(R.id.SunBurnAnim);
sunBurnButton.setBackgroundResource(R.drawable.sun_burn_anim);

// Get the background, which has been compiled to an AnimationDrawable object.
AnimationDrawable diseaseButton5Animation = (AnimationDrawable) sunBurnButton.getBackground();

// Start the animation (looped playback by default).
diseaseButton5Animation.start();

// Load the ImageView that will host the animation and
// set its background to our AnimationDrawable XML resource.
ImageView virusButton = (ImageView)findViewById(R.id.VirusAnim);
virusButton.setBackgroundResource(R.drawable.virus_anim);

// Get the background, which has been compiled to an AnimationDrawable object.
AnimationDrawable diseaseButton6Animation = (AnimationDrawable) virusButton.getBackground();

// Start the animation (looped playback by default).
diseaseButton6Animation.start();}

 /**
 * This method is called when BlackRot button is clicked.
 */
public void goToDiseaseBlackRot (View view){
    Intent intent = new Intent (this, DiseaseBlackRot.class);
    startActivity(intent);}
/**
 * This method is called when BlackRot button is clicked.
 */
 public void goToDiseaseBacterialBrownSpot (View view){
    Intent intent = new Intent (this, DiseaseBacterialBrownSpot.class);
    startActivity(intent);}
 /**
  * This method is called when BlackRot button is clicked.
 */
 public void goToDiseaseRot (View view){
    Intent intent = new Intent (this, DiseaseRot.class);
   startActivity(intent);}
 /**
  * This method is called when BlackRot button is clicked.
*/
 public void goToDiseaseVirus (View view){
     Intent intent = new Intent (this, DiseaseVirus.class);
     startActivity(intent);}
 /**
  * This method is called when BlackRot button is clicked.
 */
 public void goToDiseaseSunBurn (View view){
     Intent intent = new Intent (this, DiseaseSunBurn.class);
     startActivity(intent);}
 /**
  * This method is called when BlackRot button is clicked.
 */
 public void goToDiseaseBudBlast (View view){
 Intent intent = new Intent (this, DiseaseBudBlast.class);
 startActivity(intent);}}


问:
JQuery script problem in Internet Explorer (2)
I made a script which works in all browsers, except for SOME Internet Explorer's. I cannot seem to figure out why some Internet Explorer's work, and others don't. At the office, 4 Internet Explorer 8's @ version 8.0.6001.18702 work perfectly while 4 others Internet Explorer's 8 @ version 8.0.6001.18702 (so completely the same browsers) are not working. We all have Windows XP and all the latest updates.

Please visit http://www.stardekk.be/voorontwerp/verco/ with Firefox, safari, chrome, ... and afterwards with Internet Explorer (7, 8, doesn't matter).

The problem lays within the top of the website. The thumbs should have an overlay, and when hovered; the overlay should go away and a tooltip should come up.

I hope someone can help me since 50% of the Internet Explorer's work, and 50% don't.

Thank you

```<code>$(window).load(function() {
    $("#gallery div img").after('<div class="overlay"></div>');
    $(".overlay").css({"position":"absolute", "z-index": "30", "background": "url('images/overlay.png')", "top": "0", "left": "0", "width": "241px", "height": "146px"});

    var trans = $.browser.msie ? 0.8 : 1;

    $('.overlay').hover(function() {
        $(this).stop().fadeTo("fast", 0, function() { $(this).css("background", "transparent") });
    },
    function() {
        $(this).stop().css("background", "url('images/overlay.png')").fadeTo("fast", trans);
    });
});
</code>```

答:
Did you try to replace

```<code>$(window).load( ...
</code>```

with

```<code>$(document).ready(...
</code>```

It could come from the connection the window isn't loaded when you tried your script.

ContentLicense: CC BY-SA 2.5

Body:
I made a script which works in all browsers, except for SOME Internet Explorer's. I cannot seem to figure out why some Internet Explorer's work, and others don't. At the office, 4 Internet Explorer 8's @ version 8.0.6001.18702 work perfectly while 4 others Internet Explorer's 8 @ version 8.0.6001.18702 (so completely the same browsers) are not working. We all have Windows XP and all the latest updates.

Please visit http://www.stardekk.be/voorontwerp/verco/ with Firefox, safari, chrome, ... and afterwards with Internet Explorer (7, 8, doesn't matter).

The problem lays within the top of the website. The thumbs should have an overlay, and when hovered; the overlay should go away and a tooltip should come up.

I hope someone can help me since 50% of the Internet Explorer's work, and 50% don't.

Thank you

$(window).load(function() {
    $("#gallery div img").after('

');
    $(".overlay").css({"position":"absolute", "z-index": "30", "background": "url('images/overlay.png')", "top": "0", "left": "0", "width": "241px", "height": "146px"});

    var trans = $.browser.msie ? 0.8 : 1;

    $('.overlay').hover(function() {
        $(this).stop().fadeTo("fast", 0, function() { $(this).css("background", "transparent") });
    },
    function() {
        $(this).stop().css("background", "url('images/overlay.png')").fadeTo("fast", trans);
    });
});

Body:
Did you try to replace

$(window).load( ...

with

$(document).ready(...

It could come from the connection the window isn't loaded when you tried your script.


问:
How to return variable to *ngFor?
Just started learning ionic2 and Angular. This is what i have inside the member.ts file

```<code>Events (eventData) {
  return this.storage.get('signature').then((val) => {
    this.getDataApi.getEventData(val, function (data) {
      if (data.events.length > 0)  {
          //console.log(data.events);
          eventData = data.events;
          console.log(eventData);
          return eventData;

        }
      })
    })
}
</code>```

inside console.log(eventData) i have [Object, Object, Object, Object, Object, Object] return. Just couldn't display within the "let item of eventData" side.

I am trying to display the payload in member.html. Still very new to this. Anyone

```<code><button ion-item *ngFor="let item of eventData" (click)="gotoEvent($event, name)">
  {{item.name}}
</button>
</code>```

答:
eventData needs to be instance property instead of global variable:

this.getDataApi.getEventData(val, (data) => {
  if (data.events.length > 0)  {
      //console.log(data.events);
      this.eventData = data.events; // <-- use this.eventData = ...
      return eventData;
    }
  })
})
```

Also, note that you should use arrow function so that this has correct reference inside callback.

Title: How to return variable to *ngFor?

Body:
Just started learning ionic2 and Angular. This is what i have inside the member.ts file

Events (eventData) {
  return this.storage.get('signature').then((val) => {
    this.getDataApi.getEventData(val, function (data) {
      if (data.events.length > 0)  {
          //console.log(data.events);
          eventData = data.events;
          console.log(eventData);
          return eventData;

        }
      })
    })
}

inside console.log(eventData) i have [Object, Object, Object, Object, Object, Object] return. Just couldn't display within the "let item of eventData" side.

I am trying to display the payload in member.html. Still very new to this. Anyone

<button ion-item *ngFor="let item of eventData" (click)="gotoEvent($event, name)">
  {{item.name}}
</button>

Body:
eventData needs to be instance property instead of global variable:

this.getDataApi.getEventData(val, (data) => {
  if (data.events.length > 0)  {
      //console.log(data.events);
      this.eventData = data.events; // <-- use this.eventData = ...
      return eventData;
    }
  })
})

Also, note that you should use arrow function so that this has correct reference inside callback.


问:
Vertical Custom Hover( if not click ) CSS tabs with/without javascript
Hi to all the CSS and Javascript gurus out there. I would like to create vertically centered customizable hover tabs (can be buttons of simply created using my own background images). Content for one tab will be displayed when the tab is hovered and the tab's content can be, if possible underlined with yet another custom image. One important this is that the page should remain still. Most examples just pull the page/div back to the top.

Forexample; this has a positioning problem.

First of all: is it possible to achieve this using just CSS and hovering to change (display/hide) content? My content will only be just an image for each tab so if I can just display or hide the div containing that when the tab button is hovered, that would suffice long as I can manipulate its size and position with ease.

If In the end I have to use javascript and buttons to achieve all the above challenges, what is the best way to go about it?

It will also be awesome if I can place the tabs with their content in just one div whose size I can manipulate at will or embed in other html code.

Thanks very much for your advice.

Below is the CSS the above link uses:

```<code>   h1 {
  color: #333;
  font-family: arial, sans-serif;
  margin: 1em auto;
  width: 80%;
}

.tabordion {
  color: #333;
  display: block;
  font-family: arial, sans-serif;
  margin: auto;
  position: relative;
  width: 80%;
}

.tabordion input[name="sections"] {
  left: -9999px;
  position: absolute;
  top: -9999px;
}

.tabordion section {
  display: block;
}

.tabordion section label {
  background: #ccc;
  border:1px solid #fff;
  cursor: pointer;
  display: block;
  font-size: 1.2em;
  font-weight: bold;
  padding: 15px 20px;
  position: relative;
  width: 180px;
  z-index:100;
}

.tabordion section article {
  display: none;
  left: 230px;
  min-width: 300px;
  padding: 0 0 0 21px;
  position: absolute;
  top: 0;
}

.tabordion section article:after {
  background-color: #ccc;
  bottom: 0;
  content: "";
  display: block;
  left:-229px;
  position: absolute;
  top: 0;
  width: 220px;
  z-index:1;
}

.tabordion input[name="sections"]:checked + label {
  background: #eee;
  color: #bbb;
}

.tabordion input[name="sections"]:checked ~ article {
  display: block;
}

@media (max-width: 533px) {

  h1 {
    width: 100%;
  }

  .tabordion {
    width: 100%;
  }

  .tabordion section label {
    font-size: 1em;
    width: 160px;
  }

 .tabordion section article {
    left: 200px;
    min-width: 270px;
  }

  .tabordion section article:after {
    background-color: #ccc;
    bottom: 0;
    content: "";
    display: block;
    left:-199px;
    position: absolute;
    top: 0;
    width: 200px;

  }

}

@media (max-width: 768px) {
  h1 {
    width: 96%;
  }

  .tabordion {
    width: 96%;
  }
}

@media (min-width: 1366px) {
  h1 {
    width: 70%;
  }

  .tabordion {
    width: 70%;
  }
}
</code>```

答:
Something like this?

$(function() {
  $('#tab1').addClass('last');
});

var $tabs = $('.tab');
$tabs.hover(function() {
  $tabs.not($(this)).removeClass('last');
  $(this).addClass('last');
})```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body {
  position: relative;
  width: 50%;
  margin: 10% auto;
}

.tab {
  width: 20%;
  height: 50px;
  background: gray;
  cursor: pointer;
}

.content {
  background: #ccc;
  display: none;
}

.clear {
  clear: both;
  height: 10px;
}

#tab1:hover+#content1,
#tab2:hover+#content2,
#tab3:hover+#content3,
.last+.content {
  display: block;
}

#tab1 {
  position: absolute;
  top: 0;
  left: 0;
}

#tab2 {
  position: absolute;
  top: 60px;
  left: 0;
}

#tab3 {
  position: absolute;
  top: 120px;
  left: 0;
}

#content1 {
  position: absolute;
  top: 0;
  left: 20%;
}

#content2 {
  position: absolute;
  top: 0;
  left: 20%;
}

#content3 {
  position: absolute;
  top: 0;
  left: 20%;
}</code>```

    Tab 1

    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer in ullamcorper nisi. Cras sit amet ligula aliquet justo pellentesque dignissim. Integer ullamcorper felis magna, a porttitor urna molestie vitae. Fusce vitae pharetra tortor. Integer non
    ex quis ex tristique laoreet. Nulla interdum porta sem, eu eleifend felis elementum eu. Integer vehicula nibh metus, id eleifend diam vestibulum ac. Curabitur malesuada mauris nec libero vulputate, id interdum tortor tempor. Cras tincidunt arcu at
    orci ullamcorper faucibus id et metus. Vestibulum semper condimentum volutpat. Nullam a ex ante. Cras laoreet felis dictum lectus elementum, non tempor ex feugiat.

    Tab 2

    Nunc sed felis posuere, consectetur mauris at, gravida augue. Phasellus eget ligula non massa vestibulum placerat. Mauris finibus iaculis lectus, at tincidunt nibh placerat ut. Quisque ut justo eget odio pulvinar imperdiet. Nulla suscipit ultrices eros,
    et feugiat neque blandit eget. Donec fermentum semper efficitur. Sed bibendum, nisl a scelerisque condimentum, nulla augue tincidunt justo, eu varius sapien ipsum luctus nisi. Phasellus leo neque, molestie id nibh ut, eleifend ornare arcu. Ut id odio
    mi. Sed mollis ut est a iaculis. Nunc tempor euismod varius.

    Tab 3

    Suspendisse eget orci molestie, placerat risus posuere, pellentesque velit. Maecenas eu sapien non nisl facilisis fringilla sit amet eu ipsum. Donec vel dui ut augue efficitur aliquam et sit amet nunc. Aliquam ac facilisis ante. Nulla eget ex at metus
    auctor tincidunt. Morbi pellentesque pulvinar nunc, a consectetur quam. Duis id pretium tellus, sit amet bibendum neque. Donec orci tellus, auctor in sapien pellentesque, posuere egestas eros. Fusce metus augue, porttitor in lectus et, sagittis mollis
    lectus. Proin sed lectus egestas lectus fringilla feugiat.

```

Body:
Hi to all the CSS and Javascript gurus out there. I would like to create vertically centered customizable hover tabs (can be buttons of simply created using my own background images). Content for one tab will be displayed when the tab is hovered and the tab's content can be, if possible underlined with yet another custom image. One important this is that the page should remain still. Most examples just pull the page/div back to the top.

Forexample; this has a positioning problem.

First of all: is it possible to achieve this using just CSS and hovering to change (display/hide) content? My content will only be just an image for each tab so if I can just display or hide the div containing that when the tab button is hovered, that would suffice long as I can manipulate its size and position with ease.

If In the end I have to use javascript and buttons to achieve all the above challenges, what is the best way to go about it?

It will also be awesome if I can place the tabs with their content in just one div whose size I can manipulate at will or embed in other html code.

Thanks very much for your advice.

Below is the CSS the above link uses:

   h1 {
  color: #333;
  font-family: arial, sans-serif;
  margin: 1em auto;
  width: 80%;
}

.tabordion {
  color: #333;
  display: block;
  font-family: arial, sans-serif;
  margin: auto;
  position: relative;
  width: 80%;
}

.tabordion input[name="sections"] {
  left: -9999px;
  position: absolute;
  top: -9999px;
}

.tabordion section {
  display: block;
}

.tabordion section label {
  background: #ccc;
  border:1px solid #fff;
  cursor: pointer;
  display: block;
  font-size: 1.2em;
  font-weight: bold;
  padding: 15px 20px;
  position: relative;
  width: 180px;
  z-index:100;
}

.tabordion section article {
  display: none;
  left: 230px;
  min-width: 300px;
  padding: 0 0 0 21px;
  position: absolute;
  top: 0;
}

.tabordion section article:after {
  background-color: #ccc;
  bottom: 0;
  content: "";
  display: block;
  left:-229px;
  position: absolute;
  top: 0;
  width: 220px;
  z-index:1;
}

.tabordion input[name="sections"]:checked + label {
  background: #eee;
  color: #bbb;
}

.tabordion input[name="sections"]:checked ~ article {
  display: block;
}

@media (max-width: 533px) {

  h1 {
    width: 100%;
  }

  .tabordion {
    width: 100%;
  }

  .tabordion section label {
    font-size: 1em;
    width: 160px;
  }

 .tabordion section article {
    left: 200px;
    min-width: 270px;
  }

  .tabordion section article:after {
    background-color: #ccc;
    bottom: 0;
    content: "";
    display: block;
    left:-199px;
    position: absolute;
    top: 0;
    width: 200px;

  }

}

@media (max-width: 768px) {
  h1 {
    width: 96%;
  }

  .tabordion {
    width: 96%;
  }
}

@media (min-width: 1366px) {
  h1 {
    width: 70%;
  }

  .tabordion {
    width: 70%;
  }
}

Body:
Something like this?

$(function() {
  $('#tab1').addClass('last');
});

var $tabs = $('.tab');
$tabs.hover(function() {
  $tabs.not($(this)).removeClass('last');
  $(this).addClass('last');
})

body {
  position: relative;
  width: 50%;
  margin: 10% auto;
}

.tab {
  width: 20%;
  height: 50px;
  background: gray;
  cursor: pointer;
}

.content {
  background: #ccc;
  display: none;
}

.clear {
  clear: both;
  height: 10px;
}

#tab1:hover+#content1,
#tab2:hover+#content2,
#tab3:hover+#content3,
.last+.content {
  display: block;
}

#tab1 {
  position: absolute;
  top: 0;
  left: 0;
}

#tab2 {
  position: absolute;
  top: 60px;
  left: 0;
}

#tab3 {
  position: absolute;
  top: 120px;
  left: 0;
}

#content1 {
  position: absolute;
  top: 0;
  left: 20%;
}

#content2 {
  position: absolute;
  top: 0;
  left: 20%;
}

#content3 {
  position: absolute;
  top: 0;
  left: 20%;
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<body>
  <div id="tab1" class="tab">
    Tab 1
  </div>
  <div id="content1" class="content">
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer in ullamcorper nisi. Cras sit amet ligula aliquet justo pellentesque dignissim. Integer ullamcorper felis magna, a porttitor urna molestie vitae. Fusce vitae pharetra tortor. Integer non
    ex quis ex tristique laoreet. Nulla interdum porta sem, eu eleifend felis elementum eu. Integer vehicula nibh metus, id eleifend diam vestibulum ac. Curabitur malesuada mauris nec libero vulputate, id interdum tortor tempor. Cras tincidunt arcu at
    orci ullamcorper faucibus id et metus. Vestibulum semper condimentum volutpat. Nullam a ex ante. Cras laoreet felis dictum lectus elementum, non tempor ex feugiat.
  </div>
  <div id="tab2" class="tab">
    Tab 2
  </div>
  <div id="content2" class="content">
    Nunc sed felis posuere, consectetur mauris at, gravida augue. Phasellus eget ligula non massa vestibulum placerat. Mauris finibus iaculis lectus, at tincidunt nibh placerat ut. Quisque ut justo eget odio pulvinar imperdiet. Nulla suscipit ultrices eros,
    et feugiat neque blandit eget. Donec fermentum semper efficitur. Sed bibendum, nisl a scelerisque condimentum, nulla augue tincidunt justo, eu varius sapien ipsum luctus nisi. Phasellus leo neque, molestie id nibh ut, eleifend ornare arcu. Ut id odio
    mi. Sed mollis ut est a iaculis. Nunc tempor euismod varius.
  </div>
  <div id="tab3" class="tab">
    Tab 3
  </div>
  <div id="content3" class="content">
    Suspendisse eget orci molestie, placerat risus posuere, pellentesque velit. Maecenas eu sapien non nisl facilisis fringilla sit amet eu ipsum. Donec vel dui ut augue efficitur aliquam et sit amet nunc. Aliquam ac facilisis ante. Nulla eget ex at metus
    auctor tincidunt. Morbi pellentesque pulvinar nunc, a consectetur quam. Duis id pretium tellus, sit amet bibendum neque. Donec orci tellus, auctor in sapien pellentesque, posuere egestas eros. Fusce metus augue, porttitor in lectus et, sagittis mollis
    lectus. Proin sed lectus egestas lectus fringilla feugiat.
  </div>
</body>


问:
JIRA- How to immigrate data from an issue to another?
Currently I am working on a Jira project and in that project I have built a workflow. The workflow runs with a single issue and runs successfully.

This workflow mainly consists of 2 parts. In the 1st part, the authorizations are set and approved. In the 2nd part some assignments are being conducted according to the authorizations that have been set in the first part.

This workflow works well but I have been asked to implement this project with 2 different workflows which will be run by 2 different issues.

So my question is, how can I migrate data from the first issue to the second issue? Somehow I need to transfer the authorization info to the second issue so that the second workflow will be able to run.

Thanks a lot.

答: Once the authorization is complete you could change the issue type to a type which uses the second workflow. If you want to retain the authorization record, you could clone the first issue and then change the issue type of the clone.</p>

ContentLicense: CC BY-SA 4.0


问:
Using JsonSerializer and DeflateStream to return compressed stream in WCF
Right now I'm using JSON.net JsonSerializer to return data as stream in from my WCF services. The code is something like this:

```<code>[OperationContract]
[WebGet(ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare)]
public Stream GetJSON()
{
    Dictionary<string, string> resultDict = new Dictionary<string, string>();
    WebOperationContext.Current.OutgoingResponse.ContentType = "application/json; charset=utf-8";
    return SerializeToJSON(resultDict);
}

public static Stream SerializeToJSON(object value)
{
    MemoryStream stream = new MemoryStream();
    StreamWriter writer = new StreamWriter(stream);
    JsonTextWriter jsonWriter = new JsonTextWriter(writer);
    JsonSerializer ser = new JsonSerializer();

    ser.Formatting = Formatting.None;
    ser.Serialize(jsonWriter, value);
    jsonWriter.Flush();
    stream.Position = 0;
    return stream;
}
</code>```

I was wondering if it's possible to add the DeflateStream somewhere and return compressed data.

Adding it directly to SerializeToJSON method don't work because I cannot dispose streams or WCF close them before returning data to clients.

any suggestions?

答:
I've found a solution and reworked my code to better dispose streams.
From my understanding the returned stream can't be disposed because they are needed by WCF to handle returned data</p>

```<code>[OperationContract]
[WebGet(ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare)]
public Stream GetJSON()
{
    WebOperationContext.Current.OutgoingResponse.ContentType = "application/json; charset=utf-8";
    WebOperationContext.Current.OutgoingResponse.Headers["Content-Encoding"] = "gzip";
    Dictionary<string, string> resultDict = new Dictionary<string, string>();
    return Compress(SerializeToJSON(resultDict));
}

public static Stream SerializeToJSON(object value)
{
    var resultStream = new MemoryStream();
    using (var jsonStream = new MemoryStream())
    using (var writer = new StreamWriter(jsonStream))
    using (var jsonWriter = new JsonTextWriter(writer))
    {
        var jsonSer = new JsonSerializer();
        jsonSer.Formatting = Formatting.None;
        jsonSer.Serialize(jsonWriter, value);
        jsonWriter.Flush();
        resultStream = new MemoryStream(jsonStream.ToArray());
    }
    return resultStream;
}

public static Stream Compress(Stream plainStream)
{
    var resultStream = new MemoryStream();
    using (var compressedStream = new MemoryStream())
    using (var compressor = new GZipStream(compressedStream, CompressionMode.Compress))
    {
        plainStream.CopyTo(compressor);
        compressor.Close();
        resultStream = new MemoryStream(compressedStream.ToArray());
    }
    return resultStream;
}
</code>```

Body:
Right now I'm using JSON.net JsonSerializer to return data as stream in from my WCF services. The code is something like this:

[OperationContract]
[WebGet(ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare)]
public Stream GetJSON()
{
    Dictionary<string, string> resultDict = new Dictionary<string, string>();
    WebOperationContext.Current.OutgoingResponse.ContentType = "application/json; charset=utf-8";
    return SerializeToJSON(resultDict);
}

public static Stream SerializeToJSON(object value)
{
    MemoryStream stream = new MemoryStream();
    StreamWriter writer = new StreamWriter(stream);
    JsonTextWriter jsonWriter = new JsonTextWriter(writer);
    JsonSerializer ser = new JsonSerializer();

    ser.Formatting = Formatting.None;
    ser.Serialize(jsonWriter, value);
    jsonWriter.Flush();
    stream.Position = 0;
    return stream;
}

I was wondering if it's possible to add the DeflateStream somewhere and return compressed data.

Adding it directly to SerializeToJSON method don't work because I cannot dispose streams or WCF close them before returning data to clients.

any suggestions?

Body:
I've found a solution and reworked my code to better dispose streams.
From my understanding the returned stream can't be disposed because they are needed by WCF to handle returned data

[OperationContract]
[WebGet(ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare)]
public Stream GetJSON()
{
    WebOperationContext.Current.OutgoingResponse.ContentType = "application/json; charset=utf-8";
    WebOperationContext.Current.OutgoingResponse.Headers["Content-Encoding"] = "gzip";
    Dictionary<string, string> resultDict = new Dictionary<string, string>();
    return Compress(SerializeToJSON(resultDict));
}

public static Stream SerializeToJSON(object value)
{
    var resultStream = new MemoryStream();
    using (var jsonStream = new MemoryStream())
    using (var writer = new StreamWriter(jsonStream))
    using (var jsonWriter = new JsonTextWriter(writer))
    {
        var jsonSer = new JsonSerializer();
        jsonSer.Formatting = Formatting.None;
        jsonSer.Serialize(jsonWriter, value);
        jsonWriter.Flush();
        resultStream = new MemoryStream(jsonStream.ToArray());
    }
    return resultStream;
}

public static Stream Compress(Stream plainStream)
{
    var resultStream = new MemoryStream();
    using (var compressedStream = new MemoryStream())
    using (var compressor = new GZipStream(compressedStream, CompressionMode.Compress))
    {
        plainStream.CopyTo(compressor);
        compressor.Close();
        resultStream = new MemoryStream(compressedStream.ToArray());
    }
    return resultStream;
}


问:
How to Prevent access from a certain folder?
I want to lock a certain folder and unlock it using a password, any ideeas ?

PS I am a delphi coder!

答:
There exist several approaches:

block access to the folder to any
application until it's unlocked. The
files remain unchanged.

encrypt all
files in the folder and decrypt them
on-the-fly.

move the files to
encrypted storage and mount this
storage as a virtual folder.

The first approach is flawed as it lets the user reboot the system in safe mode or just take the HDD to other computer and gain access to the folder.

Second approach is possible using file system filter driver. You can write your own or you can use our CallbackFilter product (which includes Encrypt sample for this particular purpose).

Third approach is also possible using our products. You can mount a virtual storage as a disk or as a folder on NTFS disk using Callback File System (see VMounter sample).

There exists also Pismo File Mount product on the market and it would work for you out of the box if it had Delphi API. That product mounts a container as a folder on the disk using FS Filter driver. Personally I am not fond of this approach, though -- FS filter drivers are trickier than file system drivers and more prone to conflicts with third-party filters.


问:
How can I combine elements from different arrays in java?
Suppose a={1,2,3} and b={4,5,6} and I want to return an array containing the middle elements of a and b, i.e., {2,5}. I tried to use "merge":

```<code>public int[] middleValueArray(int[] a, int[] b) {
 int[] both=merge(a[1],b[1]);
 return both;
}
</code>```

This does not seem to work. Is there a simple way to approach this? Thanks!

答:
More general solution would be to convert it to list and then add list one by one..for example.. </p>

```<code> import java.util.ArrayList;
    import java.util.Arrays;
    import java.util.List;

    public class Main {
       public static void main(String args[]) {
          String a[] = { "A", "E", "I" };
          String b[] = { "O", "U" };
          List list = new ArrayList(Arrays.asList(a));
          list.addAll(Arrays.asList(b));
          Object[] c = list.toArray();
          System.out.println(Arrays.toString(c));
       }
    }
</code>```

Body:
Suppose a={1,2,3} and b={4,5,6} and I want to return an array containing the middle elements of a and b, i.e., {2,5}. I tried to use "merge":

public int[] middleValueArray(int[] a, int[] b) {
 int[] both=merge(a[1],b[1]);
 return both;
}

This does not seem to work. Is there a simple way to approach this? Thanks!

Body:
More general solution would be to convert it to list and then add list one by one..for example..

 import java.util.ArrayList;
    import java.util.Arrays;
    import java.util.List;

    public class Main {
       public static void main(String args[]) {
          String a[] = { "A", "E", "I" };
          String b[] = { "O", "U" };
          List list = new ArrayList(Arrays.asList(a));
          list.addAll(Arrays.asList(b));
          Object[] c = list.toArray();
          System.out.println(Arrays.toString(c));
       }
    }