问:
AlarmManager not invoking the task?
I want to execute a auto-logout after 10 PM everyday in my application, for that that I have implemented a AlarmManager task but it is not invoking .For testing purpose I have given the other timing .(e.g

```<code>calendar.set(Calendar.HOUR_OF_DAY,15);
                    calendar.set(Calendar.MINUTE,59);
                    calendar.set(Calendar.SECOND,30);
</code>```

)
AlarmManager Code:

```<code> sign_in_button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                hideKeyboard(LoginActivity.this);
                //implementation of auto logout
                checkSuiteSession = new CheckSuiteSession(getApplicationContext());
                checkSuiteSession.check_attendance_flag("true");
                Calendar calendar = Calendar.getInstance();
                calendar.set(Calendar.HOUR_OF_DAY,15);
                calendar.set(Calendar.MINUTE,59);
                calendar.set(Calendar.SECOND,30);
                Intent autoLogoutIntent = new Intent(getApplicationContext(),AutoLogoutRecevier.class);
                PendingIntent pendingIntent =
                        PendingIntent.getBroadcast(getApplicationContext(),100,autoLogoutIntent,PendingIntent.FLAG_UPDATE_CURRENT);

                AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
                alarmManager.setRepeating(AlarmManager.RTC_WAKEUP,calendar.getTimeInMillis(),AlarmManager.INTERVAL_DAY,pendingIntent);
</code>```

My broadcast receiver class :

```<code>public class AutoLogoutRecevier extends BroadcastReceiver {
    CheckSuiteSession checkSuiteSession;
    @Override
    public void onReceive(Context context, Intent intent) {
        checkSuiteSession = new CheckSuiteSession(context);
        //calling logout function
        checkSuiteSession.logoutUser();
        Log.d("LOGOUT","auto logout executed");
        checkSuiteSession.check_attendance_flag("false");

    }
}
</code>```

My manifest file (I have added the following permission) :

```<code><?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.fresherguru.checksuite">

    <!-- To auto-complete the email text field in the login form with the user's emails -->
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="android.permission.READ_PROFILE" />
    <uses-permission android:name="android.permission.READ_CONTACTS" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="com.android.alarm.permission.SET_ALARM"/>
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
    <uses-permission android:name="android.permission.WAKE_LOCK"/>

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name"
            android:theme="@style/AppTheme.NoActionBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <service
            android:name=".fcm.MyFirebaseMessagingService">
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT"/>
            </intent-filter>
        </service>
        <service android:name=".fcm.MyFirebaseInstanceIDService">
            <intent-filter>
                <action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
            </intent-filter>
        </service>

        <receiver android:name=".autoLogoutReceiver.AutoLogoutRecevier">
        <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED"/>
        </intent-filter>
        </receiver>

        <receiver android:name=".autoLogoutReceiver.ActivateLogin">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED"/>
            </intent-filter>
        </receiver>

        <receiver android:name=".autoLogoutReceiver.ChangeDialogStatus"
            android:process=":remote"/>
        <receiver android:name=".autoLogoutReceiver.ScreenUnlockReceiver">
            <intent-filter>
                <action android:name="android.intent.action.USER_PRESENT" />
                <!--<action android:name="android.intent.action.ACTION_SHUTDOWN" />-->
            </intent-filter>
            </receiver>

        <receiver android:name=".autoLogoutReceiver.DeviceBootReceiver"
            android:enabled="false">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED"/>
                <action android:name="android.intent.action.REBOOT"/>
            </intent-filter>
        </receiver>
        <service android:name=".service.CallHandleAlarmService"
            android:enabled="true"/>

        <activity
            android:name=".home.LoginActivity"
            android:theme="@style/AppTheme.NoActionBar" />
        <activity
            android:name=".home.HomeActivity"
            android:theme="@style/AppTheme.NoActionBar" />

        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />

        <activity
            android:name=".home.CheckSuiteForm"
            />
    </application>

</manifest>
</code>```

答:
Did you put

<receiver android:name=".AutoLogoutRecevier" />

in your manifest?

Title: AlarmManager not invoking the task?

Body:
I want to execute a auto-logout after 10 PM everyday in my application, for that that I have implemented a AlarmManager task but it is not invoking .For testing purpose I have given the other timing .(e.g

calendar.set(Calendar.HOUR_OF_DAY,15);
                    calendar.set(Calendar.MINUTE,59);
                    calendar.set(Calendar.SECOND,30);

)
AlarmManager Code:

 sign_in_button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                hideKeyboard(LoginActivity.this);
                //implementation of auto logout
                checkSuiteSession = new CheckSuiteSession(getApplicationContext());
                checkSuiteSession.check_attendance_flag("true");
                Calendar calendar = Calendar.getInstance();
                calendar.set(Calendar.HOUR_OF_DAY,15);
                calendar.set(Calendar.MINUTE,59);
                calendar.set(Calendar.SECOND,30);
                Intent autoLogoutIntent = new Intent(getApplicationContext(),AutoLogoutRecevier.class);
                PendingIntent pendingIntent =
                        PendingIntent.getBroadcast(getApplicationContext(),100,autoLogoutIntent,PendingIntent.FLAG_UPDATE_CURRENT);

                AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
                alarmManager.setRepeating(AlarmManager.RTC_WAKEUP,calendar.getTimeInMillis(),AlarmManager.INTERVAL_DAY,pendingIntent);

My broadcast receiver class :

public class AutoLogoutRecevier extends BroadcastReceiver {
    CheckSuiteSession checkSuiteSession;
    @Override
    public void onReceive(Context context, Intent intent) {
        checkSuiteSession = new CheckSuiteSession(context);
        //calling logout function
        checkSuiteSession.logoutUser();
        Log.d("LOGOUT","auto logout executed");
        checkSuiteSession.check_attendance_flag("false");

    }
}

My manifest file (I have added the following permission) :

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.fresherguru.checksuite">

    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="android.permission.READ_PROFILE" />
    <uses-permission android:name="android.permission.READ_CONTACTS" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="com.android.alarm.permission.SET_ALARM"/>
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
    <uses-permission android:name="android.permission.WAKE_LOCK"/>

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name"
            android:theme="@style/AppTheme.NoActionBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <service
            android:name=".fcm.MyFirebaseMessagingService">
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT"/>
            </intent-filter>
        </service>
        <service android:name=".fcm.MyFirebaseInstanceIDService">
            <intent-filter>
                <action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
            </intent-filter>
        </service>

        <receiver android:name=".autoLogoutReceiver.AutoLogoutRecevier">
        <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED"/>
        </intent-filter>
        </receiver>

        <receiver android:name=".autoLogoutReceiver.ActivateLogin">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED"/>
            </intent-filter>
        </receiver>

        <receiver android:name=".autoLogoutReceiver.ChangeDialogStatus"
            android:process=":remote"/>
        <receiver android:name=".autoLogoutReceiver.ScreenUnlockReceiver">
            <intent-filter>
                <action android:name="android.intent.action.USER_PRESENT" />

            </intent-filter>
            </receiver>

        <receiver android:name=".autoLogoutReceiver.DeviceBootReceiver"
            android:enabled="false">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED"/>
                <action android:name="android.intent.action.REBOOT"/>
            </intent-filter>
        </receiver>
        <service android:name=".service.CallHandleAlarmService"
            android:enabled="true"/>

        <activity
            android:name=".home.LoginActivity"
            android:theme="@style/AppTheme.NoActionBar" />
        <activity
            android:name=".home.HomeActivity"
            android:theme="@style/AppTheme.NoActionBar" />

        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />

        <activity
            android:name=".home.CheckSuiteForm"
            />
    </application>

</manifest>


来源: stackexchange

问:
Class Not Found Exception when running JUnit test
I am getting this error when running JUnit test in Eclipse:

```<code>Class not found com.myproject.server.MyTest
java.lang.ClassNotFoundException: com.myproject.server.MyTest
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClass(RemoteTestRunner.java:693)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClasses(RemoteTestRunner.java:429)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
</code>```

I've tried adding JUnit library in the classpath although I'm using maven, and the JUnit library is in the POM dependency.

I already have tried cleaning the project and created a new JUnit test case using the JUnit plugin for Eclipse, still getting the same error.

答: Check if your project is opened as a Maven project and not just a regular Java project. Actually a no-brainer, but that is exactly the same reason why you might miss it.</p>

ContentLicense: CC BY-SA 3.0

Body:
I am getting this error when running JUnit test in Eclipse:

Class not found com.myproject.server.MyTest
java.lang.ClassNotFoundException: com.myproject.server.MyTest
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClass(RemoteTestRunner.java:693)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClasses(RemoteTestRunner.java:429)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)

I've tried adding JUnit library in the classpath although I'm using maven, and the JUnit library is in the POM dependency.

I already have tried cleaning the project and created a new JUnit test case using the JUnit plugin for Eclipse, still getting the same error.


问:
scale_x_date on other column or using hour as well as date
I have a data frame where I've added the hour onto the end of my date

Data:

```<code> structure(list(date = c("2016-01-30 11", "2016-01-30 13", "2016-01-30 16",
    "2016-01-30 18", "2016-01-30 21", "2016-01-31 2", "2016-01-31 5",
    "2016-01-31 7", "2016-01-31 13", "2016-01-31 13"), Obs = c(9L,
    15L, 15L, 16L, 15L, 16L, 15L, 16L, 14L, 9L), score = structure(c(3L,
    1L, 3L, 1L, 3L, 1L, 3L, 1L, 3L, 2L), .Label = c("1", "1.5", "2"
    ), class = "factor"), date2_1 = c("2016-01-30", "2016-01-30",
    "2016-01-30", "2016-01-30", "2016-01-30", "2016-01-31", "2016-01-31",
    "2016-01-31", "2016-01-31", "2016-01-31"), date2_2 = c(11L, 13L,
    16L, 18L, 21L, 2L, 5L, 7L, 13L, 13L)), .Names = c("date", "Obs",
    "score", "date2_1", "date2_2"), class = c("data.table", "data.frame"
    ), row.names = c(NA, -10L), .internal.selfref = <pointer: 0x00000000001f0788>)
</code>```

My plot is:

```<code>ggplot(data = tt, aes(date2_1, Obs, colour=score)) +
       geom_point() +
       scale_colour_discrete(drop=TRUE, limits = levels(t$score))
</code>```

In another data frame I only have date (which is equiv to date2_1 in this data) and change the class with as.Date such that the following works:

```<code>ggplot(data = t, aes(date, Obs, colour=score)) +
       geom_point() +
       scale_x_date(date_breaks = "1 day", date_labels="%d") +
       scale_colour_discrete(drop=TRUE, limits = levels(t$score))
</code>```

I would like to use scale_x_date(date_breaks = "1 day", date_labels="%d") on the first plot I've shown, but have the scale using date2_1 instead of date.

Extra: Even better would be using the scale to run from date in my sample data, however this isn't of class date as I pasted the hour onto it. This data frame is a subset of another where I do have a datetime column with values like 2016-01-30 11:50:52 which are POSIXct if that helps - in fact I use cSplit and then paste from that to get my date in the sample data. Usingas.POSIXct or strptime I wasn't able to create a date with just the hour, or if I did scale_x_date wouldnt work with it.

Essentially I have a plot with just the date that scales the well, but when using date and hour the datetime is uniformly distributed across the x-axis without taking the date and hour into consideration.

Answers to both options would be appreciated!

答:
It's not really clear what the problem you are encountering is, nor what is it that you want, but hopefully this can at least point you in the right direction.

The first option you ask is to use the day in date2_1 in the x axis, I don't see any problem transforming date2_1 to Date:

```<code>library(ggplot2)

ggplot(df, aes(as.Date(date2_1), Obs, color = score)) +
  geom_point() +
  scale_x_date('Date',
               date_breaks = 'day',
               date_labels = '%d')
</code>```

The second option take the hour in the date column into account, so we have to transform it to a POSIXct, with the right format (note the use of scale_x_datetime instead of scale_x_date):

```<code>library(dplyr)
library(ggplot2)

df %>%
  mutate(date = as.POSIXct(date, format = '%Y-%m-%d %H')) %>%
  ggplot(aes(date, Obs, color = score)) +
  geom_point() +
  scale_x_datetime('Date',
                   date_breaks = '6 hours',
                   date_labels = '%d h:%H')
</code>```

Data:

df <- structure(list(date = c("2016-01-30 11", "2016-01-30 13", "2016-01-30 16",
                              "2016-01-30 18", "2016-01-30 21", "2016-01-31 2", "2016-01-31 5",
                              "2016-01-31 7", "2016-01-31 13", "2016-01-31 13"), Obs = c(9L,
                                                                                15L, 15L, 16L, 15L, 16L, 15L, 16L, 14L, 9L), score = structure(c(3L,
                                                                                1L, 3L, 1L, 3L, 1L, 3L, 1L, 3L, 2L), .Label = c("1", "1.5", "2"
                                                                                ), class = "factor"), date2_1 = c("2016-01-30", "2016-01-30",
                                                                                "2016-01-30", "2016-01-30", "2016-01-30", "2016-01-31", "2016-01-31",
                                                                                "2016-01-31", "2016-01-31", "2016-01-31"), date2_2 = c(11L, 13L,
                                                                                16L, 18L, 21L, 2L, 5L, 7L, 13L, 13L)), .Names = c("date", "Obs",
                                                                                "score", "date2_1", "date2_2"), class = c("data.table", "data.frame"
                                                                                ), row.names = c(NA, -10L))
```

(Note that I had to remove .internal.selfref = <pointer: 0x00000000001f0788> from your dput)

Body:
I have a data frame where I've added the hour onto the end of my date

Data:

 structure(list(date = c("2016-01-30 11", "2016-01-30 13", "2016-01-30 16",
    "2016-01-30 18", "2016-01-30 21", "2016-01-31 2", "2016-01-31 5",
    "2016-01-31 7", "2016-01-31 13", "2016-01-31 13"), Obs = c(9L,
    15L, 15L, 16L, 15L, 16L, 15L, 16L, 14L, 9L), score = structure(c(3L,
    1L, 3L, 1L, 3L, 1L, 3L, 1L, 3L, 2L), .Label = c("1", "1.5", "2"
    ), class = "factor"), date2_1 = c("2016-01-30", "2016-01-30",
    "2016-01-30", "2016-01-30", "2016-01-30", "2016-01-31", "2016-01-31",
    "2016-01-31", "2016-01-31", "2016-01-31"), date2_2 = c(11L, 13L,
    16L, 18L, 21L, 2L, 5L, 7L, 13L, 13L)), .Names = c("date", "Obs",
    "score", "date2_1", "date2_2"), class = c("data.table", "data.frame"
    ), row.names = c(NA, -10L), .internal.selfref = <pointer: 0x00000000001f0788>)

My plot is:

ggplot(data = tt, aes(date2_1, Obs, colour=score)) +
       geom_point() +
       scale_colour_discrete(drop=TRUE, limits = levels(t$score))

In another data frame I only have date (which is equiv to date2_1 in this data) and change the class with as.Date such that the following works:

ggplot(data = t, aes(date, Obs, colour=score)) +
       geom_point() +
       scale_x_date(date_breaks = "1 day", date_labels="%d") +
       scale_colour_discrete(drop=TRUE, limits = levels(t$score))

I would like to use scale_x_date(date_breaks = "1 day", date_labels="%d") on the first plot I've shown, but have the scale using date2_1 instead of date.

Extra: Even better would be using the scale to run from date in my sample data, however this isn't of class date as I pasted the hour onto it. This data frame is a subset of another where I do have a datetime column with values like 2016-01-30 11:50:52 which are POSIXct if that helps - in fact I use cSplit and then paste from that to get my date in the sample data. Usingas.POSIXct or strptime I wasn't able to create a date with just the hour, or if I did scale_x_date wouldnt work with it.

Essentially I have a plot with just the date that scales the well, but when using date and hour the datetime is uniformly distributed across the x-axis without taking the date and hour into consideration.

Answers to both options would be appreciated!

Body:
It's not really clear what the problem you are encountering is, nor what is it that you want, but hopefully this can at least point you in the right direction.

The first option you ask is to use the day in date2_1 in the x axis, I don't see any problem transforming date2_1 to Date:

library(ggplot2)

ggplot(df, aes(as.Date(date2_1), Obs, color = score)) +
  geom_point() +
  scale_x_date('Date',
               date_breaks = 'day',
               date_labels = '%d')

The second option take the hour in the date column into account, so we have to transform it to a POSIXct, with the right format (note the use of scale_x_datetime instead of scale_x_date):

library(dplyr)
library(ggplot2)

df %>%
  mutate(date = as.POSIXct(date, format = '%Y-%m-%d %H')) %>%
  ggplot(aes(date, Obs, color = score)) +
  geom_point() +
  scale_x_datetime('Date',
                   date_breaks = '6 hours',
                   date_labels = '%d h:%H')

Data:

df <- structure(list(date = c("2016-01-30 11", "2016-01-30 13", "2016-01-30 16",
                              "2016-01-30 18", "2016-01-30 21", "2016-01-31 2", "2016-01-31 5",
                              "2016-01-31 7", "2016-01-31 13", "2016-01-31 13"), Obs = c(9L,
                                                                                15L, 15L, 16L, 15L, 16L, 15L, 16L, 14L, 9L), score = structure(c(3L,
                                                                                1L, 3L, 1L, 3L, 1L, 3L, 1L, 3L, 2L), .Label = c("1", "1.5", "2"
                                                                                ), class = "factor"), date2_1 = c("2016-01-30", "2016-01-30",
                                                                                "2016-01-30", "2016-01-30", "2016-01-30", "2016-01-31", "2016-01-31",
                                                                                "2016-01-31", "2016-01-31", "2016-01-31"), date2_2 = c(11L, 13L,
                                                                                16L, 18L, 21L, 2L, 5L, 7L, 13L, 13L)), .Names = c("date", "Obs",
                                                                                "score", "date2_1", "date2_2"), class = c("data.table", "data.frame"
                                                                                ), row.names = c(NA, -10L))

(Note that I had to remove .internal.selfref = <pointer: 0x00000000001f0788> from your dput)


问:
ng-change is not triggering the function
Unable to trigger the function using ng-change. If I select a same option as before initialization even after initializing it to default value through code.
I want ng-change to call my function even the option selected is same after the initialization

Thanks in advance.

答:
```<code>//try angular watch
var selectionWatch = $scope.$watch('yourModelValue', function(newValue, oldValue) {
    //your fn
});

//Destroy watch
$scope.$on('$destroy', selectionWatch);
</code>```


问:
how to iterate elements in reverse order in jquery?
i'm new to jquery.I'd like to know how to iterate form elements in reverse order in jquery using each()?
Any help would be appreciated:)</p>

答:
```<code>$($("input").get().reverse()).each(function() {
   //function body here
});
</code>```

The .get().reverse() returns the reversed array of all your elements
You can then use each() to return each individual element.

Hope this helps.

ContentLicense: CC BY-SA 2.5

Body:
$($("input").get().reverse()).each(function() {
   //function body here
});

The .get().reverse() returns the reversed array of all your elements
You can then use each() to return each individual element.

Hope this helps.


问:
How can I blur the background of my layout?
I have tried most of the solutions from stack overflow, but I don't seem to get a correct implementation of the blurred effect.

Help me out please

答:
layout in which you are adding background add upper layout and set background color with hex transparency you can get it like but not exactly.

```<code><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/splash"
android:orientation="vertical">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#A6FFFFFF"></LinearLayout></LinearLayout>
</code>```

Hex transparency in colors
it is link it would give you transparency code just you have to add hex code before color code. such as your color code is #FFFFF and hex code is A6 than you write like this #A6FFFF.

Body:
layout in which you are adding background add upper layout and set background color with hex transparency you can get it like but not exactly.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/splash"
android:orientation="vertical">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#A6FFFFFF"></LinearLayout></LinearLayout>

Hex transparency in colors
it is link it would give you transparency code just you have to add hex code before color code. such as your color code is #FFFFF and hex code is A6 than you write like this #A6FFFF.


问:
Handling exception on Spring MVC Controller
could you guys share some advices on how to design a good implementation for handling exception in Spring MVC? Here are some of my thoughts after spending some time online trying to figure out the suitable or better implementation in handling exception.

Here is some background on the project I m working on:

The MVC framework used is Spring Boot Web. Similar to other projects using Spring MVC, I have separated my codes into few layers: controller, services, and model.

In the controller, it is mainly to validate the form inputs from the view(front-end) layer and perform some business logic. For form validation, I m using using the Spring validation annotation(JSR 303) and it integrates perfectly fine with the controller.

But, when it comes to the business logic implementation which are distributed across the controller and services layer, I would want to handle some checking which might terminate the execution of the controller/service method block if it fails the check.

So, i think the best would be to use exception for handling this.

There are a few implementation that I found online that share on how to implement a better exception handling framework using Spring existing exception handling mechanism. E.g. controller advice and controller based exception handler, etc.

So, here is my confusion. There are two types of exceptions handling mechanism that I have thought of. Both were implemented using @ControllerAdvice, which separates the exception handling in a separate Java class.

Approach A

A same exception is reused for a particular method in a mvc controller. For example,

public String methodA() throws AException{
 // bla bla bla
}

Then there will be unique AExceptionHandler handling this exception in a separate java file. There could be other method call in methodA() that throws different Exception. But, a try catch block would be implemented to wrap the method throwing other type of Exception and re-throw with AException.

So, it is sort of reusing AException for that methodA. Of cause, there will be some addition attributes for the BaseException class to store the details on return messages(to be displayed on view) and return viewname.

But, this will cause the controller or service layer to be cluttered with return message or return viewname.

Approach B

The other uses unique exceptions in controller or service layer. But, a designated exception handler will be implemented for each exception.

Since the exception is unique, the details(return message and viewname) can be placed at the exception handler, without polluting the controller layer. They will cleaner in this way. But, there will be alot more boilerplate code just for exception handler and many exceptions for different unique cases that I wish to terminate the code execution for a particular method block.

So, these are issues I m facing now. I hope that I'm moving in the correct direction in terms of handling exception for Spring web. Please let me know you thoughts on this. Thanks.

Example:

Lets use the account signup method as example:

```<code>//In the controller class
public String accountSignUp(@Valid AccountSignUpForm form){
    if(bindingResult.hasErrors()){
       return "signupview";
    }
    accountSignUpSvc.validateEmail(form.getEmail);
    accountSignUpSvc.createAccount(form);
}

// In the accountSignUpSvc class;
public interface AccountSignUpSvc {
    // Check if email has been used for sign up.
    void validateEmail(String email) throws DuplicateAccountException;
    // Create the account based on the form.
    void createAccount(AccountSignUpForm form) throws AccountCreationException;
}
</code>```

So using approach A:

```<code>//In the controller class
public String accountSignUp(@Valid AccountSignUpForm form){
    if(bindingResult.hasErrors()){
       return "signupview";
    }
    try{
       accountSignUpSvc.validateEmail(form.getEmail);
    } catch ( DuplicateAccountException e){
        // Rethrow with a controller method specific exception
        throw new AccountSignUpException("Returned error message"," Internal error message.",e);
    }
    // Then implement the similar try catch block for the accountSignUpSvc.createAccount method
}

@ControllerAdvice
public class AccountSignUpExceptionHandler{
  @ExceptionHandler(AccountSignUpException.class)
  public ModelAndView handleAccountSignUpException(HttpServletRequest request, AccountSignUpException ex){
    log.error(ex.getInternalError);

    ModelAndView mav = new ModelAndView("signup");
    mav.addObject("returnError", ex.getReturnError());

    return mav;
}
</code>```

Then using approach B:

```<code>//In the controller class
public String accountSignUp(@Valid AccountSignUpForm form){
    if(bindingResult.hasErrors()){
       return "signupview";
    }

    accountSignUpSvc.validateEmail(form.getEmail);

    // Then implement the similar try catch block for the accountSignUpSvc.createAccount method
}

@ControllerAdvice
public class AccountSignUpExceptionHandler{
  @ExceptionHandler(DuplicateAccountException.class)
  public ModelAndView handleDuplicateAccountException(HttpServletRequest request, DuplicateAccountException ex){
    log.error("Error due to error");

    ModelAndView mav = new ModelAndView("signup");
    mav.addObject("returnError", "Return error message: a long error message.");

    return mav;
}
</code>```

The benefit I mentioned is that the exception handler can be specific as only a certain condition would trigger it. So, any long return message that is supposed to be displayed at the html page can be coded in this specific exception handler.

答:
In my opinion it depends on whether these exceptions you are talking about are checked exceptions or not. If they are all checked exceptions being thrown in methodA() then I would be inclined to use Approach A and catch these exceptions and return them as your own app specific exception with a single handler in your @ControllerAdvice class.

If however you are wanting to handle error responses for unchecked exceptions that you might expect to occur in your application then I would use approach B.

Body:
could you guys share some advices on how to design a good implementation for handling exception in Spring MVC? Here are some of my thoughts after spending some time online trying to figure out the suitable or better implementation in handling exception.

Here is some background on the project I m working on:

The MVC framework used is Spring Boot Web. Similar to other projects using Spring MVC, I have separated my codes into few layers: controller, services, and model.

In the controller, it is mainly to validate the form inputs from the view(front-end) layer and perform some business logic. For form validation, I m using using the Spring validation annotation(JSR 303) and it integrates perfectly fine with the controller.

But, when it comes to the business logic implementation which are distributed across the controller and services layer, I would want to handle some checking which might terminate the execution of the controller/service method block if it fails the check.

So, i think the best would be to use exception for handling this.

There are a few implementation that I found online that share on how to implement a better exception handling framework using Spring existing exception handling mechanism. E.g. controller advice and controller based exception handler, etc.

So, here is my confusion. There are two types of exceptions handling mechanism that I have thought of. Both were implemented using @ControllerAdvice, which separates the exception handling in a separate Java class.

Approach A

A same exception is reused for a particular method in a mvc controller. For example,

public String methodA() throws AException{
 // bla bla bla
}

Then there will be unique AExceptionHandler handling this exception in a separate java file. There could be other method call in methodA() that throws different Exception. But, a try catch block would be implemented to wrap the method throwing other type of Exception and re-throw with AException.

So, it is sort of reusing AException for that methodA. Of cause, there will be some addition attributes for the BaseException class to store the details on return messages(to be displayed on view) and return viewname.

But, this will cause the controller or service layer to be cluttered with return message or return viewname.

Approach B

The other uses unique exceptions in controller or service layer. But, a designated exception handler will be implemented for each exception.

Since the exception is unique, the details(return message and viewname) can be placed at the exception handler, without polluting the controller layer. They will cleaner in this way. But, there will be alot more boilerplate code just for exception handler and many exceptions for different unique cases that I wish to terminate the code execution for a particular method block.

So, these are issues I m facing now. I hope that I'm moving in the correct direction in terms of handling exception for Spring web. Please let me know you thoughts on this. Thanks.

Example:

Lets use the account signup method as example:

//In the controller class
public String accountSignUp(@Valid AccountSignUpForm form){
    if(bindingResult.hasErrors()){
       return "signupview";
    }
    accountSignUpSvc.validateEmail(form.getEmail);
    accountSignUpSvc.createAccount(form);
}

// In the accountSignUpSvc class;
public interface AccountSignUpSvc {
    // Check if email has been used for sign up.
    void validateEmail(String email) throws DuplicateAccountException;
    // Create the account based on the form.
    void createAccount(AccountSignUpForm form) throws AccountCreationException;
}

So using approach A:

//In the controller class
public String accountSignUp(@Valid AccountSignUpForm form){
    if(bindingResult.hasErrors()){
       return "signupview";
    }
    try{
       accountSignUpSvc.validateEmail(form.getEmail);
    } catch ( DuplicateAccountException e){
        // Rethrow with a controller method specific exception
        throw new AccountSignUpException("Returned error message"," Internal error message.",e);
    }
    // Then implement the similar try catch block for the accountSignUpSvc.createAccount method
}

@ControllerAdvice
public class AccountSignUpExceptionHandler{
  @ExceptionHandler(AccountSignUpException.class)
  public ModelAndView handleAccountSignUpException(HttpServletRequest request, AccountSignUpException ex){
    log.error(ex.getInternalError);

    ModelAndView mav = new ModelAndView("signup");
    mav.addObject("returnError", ex.getReturnError());

    return mav;
}

Then using approach B:

//In the controller class
public String accountSignUp(@Valid AccountSignUpForm form){
    if(bindingResult.hasErrors()){
       return "signupview";
    }

    accountSignUpSvc.validateEmail(form.getEmail);

    // Then implement the similar try catch block for the accountSignUpSvc.createAccount method
}

@ControllerAdvice
public class AccountSignUpExceptionHandler{
  @ExceptionHandler(DuplicateAccountException.class)
  public ModelAndView handleDuplicateAccountException(HttpServletRequest request, DuplicateAccountException ex){
    log.error("Error due to error");

    ModelAndView mav = new ModelAndView("signup");
    mav.addObject("returnError", "Return error message: a long error message.");

    return mav;
}

The benefit I mentioned is that the exception handler can be specific as only a certain condition would trigger it. So, any long return message that is supposed to be displayed at the html page can be coded in this specific exception handler.


问:
From GDI to WPF: rendering
In GDI you just use System.Drawing.Graphics to manually handle the rendering.

In WPF is DrawingContext the way to go?
https://msdn.microsoft.com/en-us/library/system.windows.media.drawingcontext(v=vs.110).aspx

答:
You could indeed override the OnRender method of a UIElement to define your own rendering instructions but note that this is not an immediate mode rendering API like Windows Forms's OnPaint. In fact there is no such API available in WPF.

The drawing operations of the DrawingContext are not used directly when the OnRender method is invoked. They are instead processed by the rendering thread at a later stage.

So depending on what you are trying to do, overriding the OnRender method may not be your best choice after all. You may want to stick to the "WPF way" of creating composite UI elements.

Title: From GDI to WPF: rendering


问:
Use simulate dates for today in Fluid
TYPO3 has the nice "simulate date" option in the admin panel.

But this doesn't propagate to fluid as in

```<code>{f:format.date(date: 'today' format: 'Y-m-d')}
</code>```

Apparently, this is php at work, not the TYPO3 API.

Is there a simple possibility to simulate a virtual "today" date and pass it to fluid?

答:
You may try to use a typoscript condition to declare a setting.

```<code>[yourcondition]
    plugin.tx_your_ext.settings.dateOverride = 2017-11-11 11:11:11
[global]
</code>```

Then make sure the settings are passed to the view. You can do that in your controller action

```<code>$this->view->assign('settings', $this->settings);
</code>```

And then pass the value to the viewhelper. You can use any value, that can be interpreted by the DateTime constructor.

```<code>{f:format.date(date: settings.dateOverride format: 'Y-m-d')}
</code>```

A list of possible typoscript conditions:

https://docs.typo3.org/typo3cms/TyposcriptReference/Conditions/Reference/Index.html

If you need the date to be set more dynamically, you can use a url parameter and request your page like:

yourpage.com/path/to/your/site?no_cache=1&spoofedDate=2017-11-11T11:11:11Z

I guess you can utilize the DataSubmissionHook to set the value if the simulated date feature of typo3 is used. Maybe that gives you the most comfort.

To access request params in your Controller:

```<code>$this->request->getArgument()
</code>```

Or

```<code>GeneralUtility::_GET()
</code>```

A fancy way of solving that is to overload the DateTime object, so it respects the simulated date Feature.

Title: Use simulate dates for today in Fluid

Body:
TYPO3 has the nice "simulate date" option in the admin panel.

But this doesn't propagate to fluid as in

{f:format.date(date: 'today' format: 'Y-m-d')}

Apparently, this is php at work, not the TYPO3 API.

Is there a simple possibility to simulate a virtual "today" date and pass it to fluid?

Body:
You may try to use a typoscript condition to declare a setting.

[yourcondition]
    plugin.tx_your_ext.settings.dateOverride = 2017-11-11 11:11:11
[global]

Then make sure the settings are passed to the view. You can do that in your controller action

$this->view->assign('settings', $this->settings);

And then pass the value to the viewhelper. You can use any value, that can be interpreted by the DateTime constructor.

{f:format.date(date: settings.dateOverride format: 'Y-m-d')}

A list of possible typoscript conditions:

https://docs.typo3.org/typo3cms/TyposcriptReference/Conditions/Reference/Index.html

If you need the date to be set more dynamically, you can use a url parameter and request your page like:

yourpage.com/path/to/your/site?no_cache=1&spoofedDate=2017-11-11T11:11:11Z

I guess you can utilize the DataSubmissionHook to set the value if the simulated date feature of typo3 is used. Maybe that gives you the most comfort.

To access request params in your Controller:

$this->request->getArgument()

Or

GeneralUtility::_GET()

A fancy way of solving that is to overload the DateTime object, so it respects the simulated date Feature.


问:
Tensorflow:Using a trained model in C++
I have a model build in Python using keras and tensorflow. I want to export the model and use it for training in C++. I am using TF1.2 and used the tf.train.export_metagraph to export my graph. I am not exactly sure on how to proceed in using the model in C++ for training. Thanks :)

答: Why would want to train the model in C++? Tensorflows core libraries are in c++. I think you mean use the trained model in C++? Once you've trained a model and exported it (assuming you have the .pb file) you use the model for predicting .Theres no way to retrain an exported model.</p>

Title: Tensorflow:Using a trained model in C++


答:
Put the view on that view in which you want to blur</p>

```<code> <View
            android:id="@+id/view"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="#CC000000" />
</code>```

Title: How can I blur the background of my layout?

Body:
I have tried most of the solutions from stack overflow, but I don't seem to get a correct implementation of the blurred effect.

Help me out please

Body:
Put the view on that view in which you want to blur

 <View
            android:id="@+id/view"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="#CC000000" />


问:
How to set x axis labels as dates in pandas plot with a dataframe timestamp column
I have a pandas dataframe (Jupyter) with two column, a datetime64[ns] (named day) and int64 (named events).

I want to plot the int64 column, using as x axis labels the datetime64[ns] (properly formatted).

I tried:

events_per_day.plot(kind='line', xticks=events_per_day['day'], ...

but I get:

TypeError: Cannot compare type 'Timestamp' with type 'float'

How to solve this problem?

答:
I think you need parameters x and y in DataFrame.plot, kind='line' can be omit because default value:

```<code>events_per_day.plot(x ='day', y='events')
</code>```

Sample:

```<code>np.random.seed(45)
rng = pd.date_range('2017-04-03', periods=10)
events_per_day = pd.DataFrame({'day': rng, 'events': np.random.randint(10, size=10)})
print (events_per_day)
         day  events
0 2017-04-03       3
1 2017-04-04       0
2 2017-04-05       5
3 2017-04-06       3
4 2017-04-07       4
5 2017-04-08       9
6 2017-04-09       8
7 2017-04-10       1
8 2017-04-11       5
9 2017-04-12       9

events_per_day.plot(x ='day', y='events')
</code>```

Some formating by strftime:

```<code>events_per_day['day'] = events_per_day['day'].dt.strftime('%Y-%m-%d')
events_per_day.plot(x ='day', y='events', rot=45)
</code>```

Body:
I think you need parameters x and y in DataFrame.plot, kind='line' can be omit because default value:

events_per_day.plot(x ='day', y='events')

Sample:

np.random.seed(45)
rng = pd.date_range('2017-04-03', periods=10)
events_per_day = pd.DataFrame({'day': rng, 'events': np.random.randint(10, size=10)})
print (events_per_day)
         day  events
0 2017-04-03       3
1 2017-04-04       0
2 2017-04-05       5
3 2017-04-06       3
4 2017-04-07       4
5 2017-04-08       9
6 2017-04-09       8
7 2017-04-10       1
8 2017-04-11       5
9 2017-04-12       9

events_per_day.plot(x ='day', y='events')

Some formating by strftime:

events_per_day['day'] = events_per_day['day'].dt.strftime('%Y-%m-%d')
events_per_day.plot(x ='day', y='events', rot=45)


问:
how to include external javascript in react
In an html page you can include a javascript file by
How do you get variables from an external path like this in react, if the path is, for example:

Thanks for all your help

答: you can link it in your index.html file just be careful about what you call things when you are doing it as to not re use names in different places</p>


问:
Why does JDO think this detached object is clean?
I am trying to learn JDO (and at the same time its GAE and Spring intricacies) by creating a small web app, and am having trouble getting updated domain objects to persist back to the database. I initially grab the entity from the DB and detach it so that I can show it to the user and allow them to change it. Once the user has made the changes and posts the form back to the app, I again grab the entity from the DB (detached), update its properties, and then call a pm.makePersistent(). The abbreviated code is as follows:

User Domain Object:

```<code>@PersistenceCapable(detachable="true")
public class User extends BaseEntity {
    @Persistent
    private String firstName = "";
    @Persistent
    private String middleInitial = "";
    @Persistent
    private String lastName = "";
}
</code>```

DAO Read Method:

```<code>public User read(Key key) throws DataException {
    PersistenceManager pm = PMF.get().getPersistenceManager();
    User pkg, detached = null;
    try {
        pkg = (User) pm.getObjectById(User.class, key);
        detached = pm.detachCopy(pkg);
        detached.setIsAlreadyInDB(true);
    }
    catch (Exception e) {
        throw new DataException("An error occured trying to read the User object. Details:\n" + e.getMessage());
    }
    finally {
        pm.close();
    }
    return detached;
}
</code>```

DAO Update Method:

```<code>private void update(User pkg) throws DataException {
    PersistenceManager pm = PMF.get().getPersistenceManager();
    Transaction tx = pm.currentTransaction();

    try {
        tx.begin();
        pm.makePersistent(pkg);
        tx.commit();
    }
    finally {
        if (tx.isActive()) tx.rollback();
        pm.close();
    }
}
</code>```

Now when I get down into the update method, I've proven to myself that I'm working with just the same object from my read via inspecting its hashCode(), I've changed a value using the domain object's setter method, I've even printed the changed value to the console to make sure it's getting done, and JDOHelper.isDirty() still returns false, and therefore none of the changes get persisted back to the database.
Any thoughts on what I'm missing or if I'm approaching this from the wrong angle? Thank you for helping out a JDO beginner!

答:
JDOHelper.isDirty is for managed objects. A detached object is not managed. DataNucleus provides a helper method of its own to get the dirty fields while detached since the logic is implementation-specific
String[] dirtyFieldNames = NucleusJDOHelper.getDetachedObjectDirtyFields(obj, pm);</p>

Body:
I am trying to learn JDO (and at the same time its GAE and Spring intricacies) by creating a small web app, and am having trouble getting updated domain objects to persist back to the database. I initially grab the entity from the DB and detach it so that I can show it to the user and allow them to change it. Once the user has made the changes and posts the form back to the app, I again grab the entity from the DB (detached), update its properties, and then call a pm.makePersistent(). The abbreviated code is as follows:

User Domain Object:

@PersistenceCapable(detachable="true")
public class User extends BaseEntity {
    @Persistent
    private String firstName = "";
    @Persistent
    private String middleInitial = "";
    @Persistent
    private String lastName = "";
}

DAO Read Method:

public User read(Key key) throws DataException {
    PersistenceManager pm = PMF.get().getPersistenceManager();
    User pkg, detached = null;
    try {
        pkg = (User) pm.getObjectById(User.class, key);
        detached = pm.detachCopy(pkg);
        detached.setIsAlreadyInDB(true);
    }
    catch (Exception e) {
        throw new DataException("An error occured trying to read the User object. Details:\n" + e.getMessage());
    }
    finally {
        pm.close();
    }
    return detached;
}

DAO Update Method:

private void update(User pkg) throws DataException {
    PersistenceManager pm = PMF.get().getPersistenceManager();
    Transaction tx = pm.currentTransaction();

    try {
        tx.begin();
        pm.makePersistent(pkg);
        tx.commit();
    }
    finally {
        if (tx.isActive()) tx.rollback();
        pm.close();
    }
}

Now when I get down into the update method, I've proven to myself that I'm working with just the same object from my read via inspecting its hashCode(), I've changed a value using the domain object's setter method, I've even printed the changed value to the console to make sure it's getting done, and JDOHelper.isDirty() still returns false, and therefore none of the changes get persisted back to the database.
Any thoughts on what I'm missing or if I'm approaching this from the wrong angle? Thank you for helping out a JDO beginner!


问:
Draw y-axis inside the graph area with chart js
Using chart.js I want to draw the y-axis inside the graph area.

So instead of being left (or right) to the canvas area with the graphs the y-axis values should be drawn inside like this:

答:
You could accomplish that, by setting the mirror property to true for y-axis ticks.

```<code>options: {
   scales: {
      yAxes: [{
         ticks: {
            mirror: true
         }
      }]
   },
   ...
}
</code>```

ᴡᴏʀᴋɪɴɢ ᴇxᴀᴍᴘʟᴇ ⧩

var ctx = c.getContext('2d');
var chart = new Chart(ctx, {
   type: 'line',
   data: {
      labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May'],
      datasets: [{
         label: 'Statistics',
         data: [30, 10, 20, 50, 40],
         backgroundColor: 'rgba(0, 119, 204, 0.1)',
         borderColor: 'rgba(0, 119, 204, 0.8)',
         tension: 0
      }]
   },
   options: {
      scales: {
         yAxes: [{
            ticks: {
               beginAtZero: true,
               mirror: true //<-- set this
            }
         }]
      }
   }
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.6.0/Chart.min.js"></script>
<canvas id="c"></canvas></code>```

Body:
You could accomplish that, by setting the mirror property to true for y-axis ticks.

options: {
   scales: {
      yAxes: [{
         ticks: {
            mirror: true
         }
      }]
   },
   ...
}

ᴡᴏʀᴋɪɴɢ ᴇxᴀᴍᴘʟᴇ ⧩

var ctx = c.getContext('2d');
var chart = new Chart(ctx, {
   type: 'line',
   data: {
      labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May'],
      datasets: [{
         label: 'Statistics',
         data: [30, 10, 20, 50, 40],
         backgroundColor: 'rgba(0, 119, 204, 0.1)',
         borderColor: 'rgba(0, 119, 204, 0.8)',
         tension: 0
      }]
   },
   options: {
      scales: {
         yAxes: [{
            ticks: {
               beginAtZero: true,
               mirror: true //<-- set this
            }
         }]
      }
   }
});

<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.6.0/Chart.min.js"></script>
<canvas id="c"></canvas>


问:
ASP.Net MVC Controller causing Not Found error when deployed to IIS 7
I am developing a website using ASP.Net MVC. I have a method in the Home controller which returns a partial view when called. The issue is when I am calling the controller method using jQuery, I get a 404 Not Found error.

This only happens when the application is deployed on IIS 7. It works fine during development, but after deployement, none of the controller are found when called through jQuery.get method or post.

Thanking you all in advance for helping me.

答:
I had same problem.
solved issue by changing the ajax url.
Just for an example ,
if you are using ajax call to the controller:
have to write url as like this == url: '@Url.Action("actionmethod", "controller")',
instead of ===== url: '/controller/actionmethod',

Thanks

OwnerDisplayName: Jawad


问:
How to replace everything with blank after question mark in a string?
I am trying to replace everything with blank after question mark.

Suppose I have a string like below:

```<code>var str = "/root/Users?SkillId=201;"
</code>```

Now I want to replace everything with blank after ?.

Expected output: "/root/Users"

I tried below solution:

```<code>var str = "/root/Users?SkillId=201;".replace(/[^? ]/g, "");
console.log(str); // output : ?

str = str.split('?')[0] // though worked but not readable
</code>```

I don't want to use for loop for this. Isn't there is any better way to do this?

答:
Match the content before ?

var str = "/root/Users?SkillId=201;"
var a = str.match(/(.*)\?/);

console.log(a[1])```

ContentLicense: CC BY-SA 4.0

Body:
I am trying to replace everything with blank after question mark.

Suppose I have a string like below:

var str = "/root/Users?SkillId=201;"

Now I want to replace everything with blank after ?.

Expected output: "/root/Users"

I tried below solution:

var str = "/root/Users?SkillId=201;".replace(/[^? ]/g, "");
console.log(str); // output : ?

str = str.split('?')[0] // though worked but not readable

I don't want to use for loop for this. Isn't there is any better way to do this?


问:
CSS nth-child(odd) not working
I need to alternate the background color of the class jl-member-info but this doesn’t work. I have this code:

.uk-grid .jl-member-item .jl-member-info:nth-child(odd) {
  position: relative;
  padding: 0 0.9rem;
  background-color: rgba(0, 198, 197, 0.89);
  width: 100%;
  margin-top: -95px;
}

.uk-grid .jl-member-item .jl-member-info:nth-child(even) {
  position: relative;
  padding: 0 0.9rem;
  background-color: #090963;
  width: 100%;
  margin-top: -95px;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="jl-member ">
  <div class=" uk-grid-large uk-grid uk-grid-width-small-1-2 uk-grid-width-medium-1-2 uk-grid-width-large-1-4" data-uk-grid-margin="">
    <div class="jl-member-item default uk-row-first">
      <div class="jl-member-item-img">
        <img class="uk-overlay-spin" src="/templates/g5_helium/custom/images/Alain.jpg?595f26c4">
      </div>
      <div class="jl-member-info">
        <div class="jl-member-name">Alain</div>
        <div class="jl-member-role">Maire</div>
        <div class="jl-member-desc"><span class="cloaked_email">mail@test.fr</span>
        </div>
      </div>
    </div>
    <div class="jl-member-item default">
      <div class="jl-member-item-img">
        <img class="uk-overlay-spin" src="/templates/g5_helium/custom/images/Alain.jpg?595f26c4">
      </div>
      <div class="jl-member-info">
        <div class="jl-member-name">Alain</div>
        <div class="jl-member-role">Maire</div>
        <div class="jl-member-desc"><span class="cloaked_email">mail@test.fr</span>

        </div>
      </div>
    </div>
    <div class="jl-member-item default">
      <div class="jl-member-item-img">
        <img class="uk-overlay-spin" src="/templates/g5_helium/custom/images/Alain.jpg?595f26c4">
      </div>
      <div class="jl-member-info">
        <div class="jl-member-name">Alain</div>
        <div class="jl-member-role">Maire</div>
        <div class="jl-member-desc"><span class="cloaked_email">mail@test.fr</span>
        </div>
      </div>
    </div>
  </div>
</div></code>```

答:
You need to recode like this, because you have only one .jl-member-info in .jl-member-item it will always be odd!

```<code>.uk-grid .jl-member-item .jl-member-info {
    position: relative;
    padding: 0 0.9rem;
    width: 100%;
    margin-top: -95px;
    background-color: #090963;
}

.uk-grid .jl-member-item:nth-child(odd) .jl-member-info {
    background-color: rgba(0, 198, 197, 0.89);
}
</code>```

Title: CSS nth-child(odd) not working

Body:
I need to alternate the background color of the class jl-member-info but this doesn’t work. I have this code:

.uk-grid .jl-member-item .jl-member-info:nth-child(odd) {
  position: relative;
  padding: 0 0.9rem;
  background-color: rgba(0, 198, 197, 0.89);
  width: 100%;
  margin-top: -95px;
}

.uk-grid .jl-member-item .jl-member-info:nth-child(even) {
  position: relative;
  padding: 0 0.9rem;
  background-color: #090963;
  width: 100%;
  margin-top: -95px;
}

Alain

Maire

mail@test.fr

Alain

Maire

mail@test.fr

Alain

Maire

mail@test.fr

Body:
You need to recode like this, because you have only one .jl-member-info in .jl-member-item it will always be odd!

.uk-grid .jl-member-item .jl-member-info {
    position: relative;
    padding: 0 0.9rem;
    width: 100%;
    margin-top: -95px;
    background-color: #090963;
}

.uk-grid .jl-member-item:nth-child(odd) .jl-member-info {
    background-color: rgba(0, 198, 197, 0.89);
}


问:
How to POST Data to another web application (cross domain)
Please consider the following scenario,

There are two web applications App1 & App2. A user would submit his information on App1 though a form. On click of a specific button/link on App1, the same data should be posted to a page on App2 and the user should also be redirected to the same page on App2.

I would like some help in finding out the best way to implement this functionality.

One of the approaches that I have already tried out is by creating a temporary HTML form at runtime, setting the action attribute of the form to the App2 Page and get the form posted by using javascript submit. The data can then be fetched on App2 page by using the response.form object.

This approach works well, but i was still wondering if there is any other way to implement the required functionality.

I would really appriciate if you can give some insights on using RESTful webservices to implement this, or else, using some HttpModule to intercept requests at App1 and modify redirect response to app2 or any other approach that you might find fit for the purpose.

Edit:
Using querystring isnt an option for me.

答:
Note: I'm answering my own question
  just to have a correct answers marked
  against it.  All the suggestions
  provided by various members here are
  correct in their own way, but they
  were not apt for my requirements.
  Hence, I cant accept any of them as
  correct.

The way I have Implemented is by creating a custom control which would have a configurable property containing the URL to post data and another one accepting a dictionary object as the data input to be posted.

This control would internally create a HTML form with action attribute set to the URL specified by the user and have the data feilds created out of the dictionary object. This form would then be posted on the button click event on the page hosting this control.


问:
How can I save below write board(for signature) using core data
I got this problem now. I don't know how to save below write board and and retrieve it.

enter image description here

```<code> override func viewWillDisappear(_ animated: Bool) {
    super.viewWillDisappear(animated)
    if let AppDelegate = (UIApplication.shared.delegate as? AppDelegate)
    {
        let context = AppDelegate.persistentContainer.viewContext
        do{
            let results = try context.fetch(VisitorMO.fetchRequest())
            let signintime = results[lastnumber!] as? VisitorMO
//          signintime?.signinimage = imageView.image
            AppDelegate.saveContext()

        }catch{
            let nserror = error as NSError
            fatalError("Unresolved error \(nserror), \(nserror.userInfo)")
        }
    }

}
</code>```

答:
```<code>import UIKit
import CoreData
class ViewController: UIViewController {

   var logscreen: [NSManagedObject] = []

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.

    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    func saveImage(){
        guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else {
            return
        }
        let managedContext = appDelegate.persistentContainer.viewContext
        do{
            let entity = NSEntityDescription.entity(forEntityName: "CoreImage", in: managedContext)!
            let data = NSManagedObject(entity: entity, insertInto: managedContext)
            data.setValue(imageview.image, forKeyPath: "image")
            try managedContext.save()
            logscreen.append(data)
        } catch let error as NSError {
            // failure
            print(error)
        }
    }
}
</code>```

try this code for saving. also convert image into nsdata instead of imageview.image

Body:
I got this problem now. I don't know how to save below write board and and retrieve it.

enter image description here

 override func viewWillDisappear(_ animated: Bool) {
    super.viewWillDisappear(animated)
    if let AppDelegate = (UIApplication.shared.delegate as? AppDelegate)
    {
        let context = AppDelegate.persistentContainer.viewContext
        do{
            let results = try context.fetch(VisitorMO.fetchRequest())
            let signintime = results[lastnumber!] as? VisitorMO
//          signintime?.signinimage = imageView.image
            AppDelegate.saveContext()

        }catch{
            let nserror = error as NSError
            fatalError("Unresolved error \(nserror), \(nserror.userInfo)")
        }
    }

}

Body:
import UIKit
import CoreData
class ViewController: UIViewController {

   var logscreen: [NSManagedObject] = []

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.

    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    func saveImage(){
        guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else {
            return
        }
        let managedContext = appDelegate.persistentContainer.viewContext
        do{
            let entity = NSEntityDescription.entity(forEntityName: "CoreImage", in: managedContext)!
            let data = NSManagedObject(entity: entity, insertInto: managedContext)
            data.setValue(imageview.image, forKeyPath: "image")
            try managedContext.save()
            logscreen.append(data)
        } catch let error as NSError {
            // failure
            print(error)
        }
    }
}

try this code for saving. also convert image into nsdata instead of imageview.image


问:
SpringBoot + Hibernate + Postgres
I am trying to insert a value(http://localhost:8080/create?name=name1&email=name1@email.com) to Postgres DB using SpringBoot and hibernate but in log it says as it inserts but no records are inserted also no exception is there.Please help me to find the issue.

Postgres Version:

```<code>"PostgreSQL 9.6.3 on x86_64-pc-mingw64, compiled by gcc.exe (Rev5, Built by MSYS2 project) 4.9.2, 64-bit"
</code>```

build.gradle:

```<code>apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'eclipse'

group = 'netgloo'
version = '0.0.1-SNAPSHOT'

description = """spring-boot-mysql-springdatajpa-hibernate"""

sourceCompatibility = 1.8
targetCompatibility = 1.8
tasks.withType(JavaCompile) {
    options.encoding = 'UTF-8'
}
repositories {

     maven { url "http://repo.maven.apache.org/maven2" }
}
dependencies {
    compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version:'1.5.2.RELEASE'
    compile group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa', version:'1.5.2.RELEASE'
    compile group: 'postgres', name: 'postgres', version:'42.1.1.jre6'
}
</code>```

User.java:

```<code>@Entity
@Table(name = "users")
public class User {

  @Id
  @GeneratedValue(strategy = GenerationType.AUTO)
  private long id;
  @NotNull
  private String email;
  @NotNull
  private String name;

  public User() { }

  public User(long id) {
    this.id = id;
  }

  public User(String email, String name) {
    this.email = email;
    this.name = name;
  }

  public long getId() {
    return id;
  }

  public void setId(long value) {
    this.id = value;
  }

  public String getEmail() {
    return email;
  }

  public void setEmail(String value) {
    this.email = value;
  }

  public String getName() {
    return name;
  }

  public void setName(String value) {
    this.name = value;
  }
}
</code>```

Controller:

```<code>@Controller
public class UserController {

  @RequestMapping("/create")
  @ResponseBody
  public String create(String email, String name) {
    User user = null;
    try {
      user = new User(email, name);
      userDao.save(user);
    }
    catch (Exception ex) {
      return "Error creating the user: " + ex.toString();
    }
    return "User succesfully created! (id = " + user.getId() + ")";
  }

  @RequestMapping("/get-by-email")
  @ResponseBody
  public String getByEmail(String email) {
    String userId;
    try {
      User user = userDao.findByEmail(email);
      userId = String.valueOf(user.getId());
    }
    catch (Exception ex) {
      return "User not found";
    }
    return "The user id is: " + userId;
  }
}
</code>```

UserDao:

```<code>@Transactional
public interface UserDao extends CrudRepository<User, Long> {

  public User findByEmail(String email);

} // class UserDao
</code>```

logs:

```<code>  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
[32m :: Spring Boot :: [39m      [2m (v1.5.2.RELEASE)[0;39m

[2m2017-07-07 14:54:59.528[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[           main][0;39m [36mnetgloo.Application                     [0;39m [2m:[0;39m Starting Application on B20GPF2 with PID 17176 (C:\Users\a591470\projects\mylearning\spring-boot-samples-master\spring-boot-mysql-springdatajpa-hibernate\bin started by a591470 in C:\Users\a591470\projects\mylearning\spring-boot-samples-master\spring-boot-mysql-springdatajpa-hibernate)
[2m2017-07-07 14:54:59.533[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[           main][0;39m [36mnetgloo.Application                     [0;39m [2m:[0;39m No active profile set, falling back to default profiles: default
[2m2017-07-07 14:54:59.652[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[           main][0;39m [36mationConfigEmbeddedWebApplicationContext[0;39m [2m:[0;39m Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@4387b79e: startup date [Fri Jul 07 14:54:59 IST 2017]; root of context hierarchy
[2m2017-07-07 14:55:01.391[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[           main][0;39m [36mtrationDelegate$BeanPostProcessorChecker[0;39m [2m:[0;39m Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$61eecdd6] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
[2m2017-07-07 14:55:01.919[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[           main][0;39m [36ms.b.c.e.t.TomcatEmbeddedServletContainer[0;39m [2m:[0;39m Tomcat initialized with port(s): 8080 (http)
[2m2017-07-07 14:55:01.935[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.apache.catalina.core.StandardService  [0;39m [2m:[0;39m Starting service Tomcat
[2m2017-07-07 14:55:01.936[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[           main][0;39m [36morg.apache.catalina.core.StandardEngine [0;39m [2m:[0;39m Starting Servlet Engine: Apache Tomcat/8.5.11
[2m2017-07-07 14:55:02.170[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[ost-startStop-1][0;39m [36mo.a.c.c.C.[Tomcat].[localhost].[/]      [0;39m [2m:[0;39m Initializing Spring embedded WebApplicationContext
[2m2017-07-07 14:55:02.171[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[ost-startStop-1][0;39m [36mo.s.web.context.ContextLoader           [0;39m [2m:[0;39m Root WebApplicationContext: initialization completed in 2525 ms
[2m2017-07-07 14:55:02.466[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[ost-startStop-1][0;39m [36mo.s.b.w.servlet.ServletRegistrationBean [0;39m [2m:[0;39m Mapping servlet: 'dispatcherServlet' to [/]
[2m2017-07-07 14:55:02.472[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[ost-startStop-1][0;39m [36mo.s.b.w.servlet.FilterRegistrationBean  [0;39m [2m:[0;39m Mapping filter: 'characterEncodingFilter' to: [/*]
[2m2017-07-07 14:55:02.472[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[ost-startStop-1][0;39m [36mo.s.b.w.servlet.FilterRegistrationBean  [0;39m [2m:[0;39m Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
[2m2017-07-07 14:55:02.472[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[ost-startStop-1][0;39m [36mo.s.b.w.servlet.FilterRegistrationBean  [0;39m [2m:[0;39m Mapping filter: 'httpPutFormContentFilter' to: [/*]
[2m2017-07-07 14:55:02.472[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[ost-startStop-1][0;39m [36mo.s.b.w.servlet.FilterRegistrationBean  [0;39m [2m:[0;39m Mapping filter: 'requestContextFilter' to: [/*]
[2m2017-07-07 14:55:04.067[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[           main][0;39m [36mj.LocalContainerEntityManagerFactoryBean[0;39m [2m:[0;39m Building JPA container EntityManagerFactory for persistence unit 'default'
[2m2017-07-07 14:55:04.103[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.hibernate.jpa.internal.util.LogHelper [0;39m [2m:[0;39m HHH000204: Processing PersistenceUnitInfo [
    name: default
    ...]
[2m2017-07-07 14:55:04.304[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[           main][0;39m [36morg.hibernate.Version                   [0;39m [2m:[0;39m HHH000412: Hibernate Core {5.0.12.Final}
[2m2017-07-07 14:55:04.306[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[           main][0;39m [36morg.hibernate.cfg.Environment           [0;39m [2m:[0;39m HHH000206: hibernate.properties not found
[2m2017-07-07 14:55:04.309[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[           main][0;39m [36morg.hibernate.cfg.Environment           [0;39m [2m:[0;39m HHH000021: Bytecode provider name : javassist
[2m2017-07-07 14:55:04.388[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.hibernate.annotations.common.Version  [0;39m [2m:[0;39m HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
[2m2017-07-07 14:55:04.602[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[           main][0;39m [36morg.hibernate.dialect.Dialect           [0;39m [2m:[0;39m HHH000400: Using dialect: org.hibernate.dialect.PostgreSQLDialect
[2m2017-07-07 14:55:04.920[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.h.e.j.e.i.LobCreatorBuilderImpl       [0;39m [2m:[0;39m HHH000424: Disabling contextual LOB creation as createClob() method threw error : java.lang.reflect.InvocationTargetException
[2m2017-07-07 14:55:04.923[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[           main][0;39m [36morg.hibernate.type.BasicTypeRegistry    [0;39m [2m:[0;39m HHH000270: Type registration [java.util.UUID] overrides previous : org.hibernate.type.UUIDBinaryType@2f84acf7
[2m2017-07-07 14:55:05.243[0;39m [33m WARN[0;39m [35m17176[0;39m [2m---[0;39m [2m[           main][0;39m [36morg.hibernate.orm.deprecation           [0;39m [2m:[0;39m HHH90000014: Found use of deprecated [org.hibernate.id.SequenceGenerator] sequence-based id generator; use org.hibernate.id.enhanced.SequenceStyleGenerator instead.  See Hibernate Domain Model Mapping Guide for details.
[2m2017-07-07 14:55:05.724[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[           main][0;39m [36morg.hibernate.tool.hbm2ddl.SchemaUpdate [0;39m [2m:[0;39m HHH000228: Running hbm2ddl schema update
[2m2017-07-07 14:55:05.877[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[           main][0;39m [36mj.LocalContainerEntityManagerFactoryBean[0;39m [2m:[0;39m Initialized JPA EntityManagerFactory for persistence unit 'default'
[2m2017-07-07 14:55:06.920[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[           main][0;39m [36ms.w.s.m.m.a.RequestMappingHandlerAdapter[0;39m [2m:[0;39m Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@4387b79e: startup date [Fri Jul 07 14:54:59 IST 2017]; root of context hierarchy
[2m2017-07-07 14:55:07.038[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[           main][0;39m [36ms.w.s.m.m.a.RequestMappingHandlerMapping[0;39m [2m:[0;39m Mapped "{[/]}" onto public java.lang.String netgloo.controllers.MainController.index()
[2m2017-07-07 14:55:07.040[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[           main][0;39m [36ms.w.s.m.m.a.RequestMappingHandlerMapping[0;39m [2m:[0;39m Mapped "{[/delete]}" onto public java.lang.String netgloo.controllers.UserController.delete(long)
[2m2017-07-07 14:55:07.040[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[           main][0;39m [36ms.w.s.m.m.a.RequestMappingHandlerMapping[0;39m [2m:[0;39m Mapped "{[/create]}" onto public java.lang.String netgloo.controllers.UserController.create(java.lang.String,java.lang.String) throws java.lang.Exception
[2m2017-07-07 14:55:07.041[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[           main][0;39m [36ms.w.s.m.m.a.RequestMappingHandlerMapping[0;39m [2m:[0;39m Mapped "{[/update]}" onto public java.lang.String netgloo.controllers.UserController.updateUser(long,java.lang.String,java.lang.String)
[2m2017-07-07 14:55:07.041[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[           main][0;39m [36ms.w.s.m.m.a.RequestMappingHandlerMapping[0;39m [2m:[0;39m Mapped "{[/get-by-email]}" onto public java.lang.String netgloo.controllers.UserController.getByEmail(java.lang.String) throws java.lang.Exception
[2m2017-07-07 14:55:07.044[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[           main][0;39m [36ms.w.s.m.m.a.RequestMappingHandlerMapping[0;39m [2m:[0;39m Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
[2m2017-07-07 14:55:07.045[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[           main][0;39m [36ms.w.s.m.m.a.RequestMappingHandlerMapping[0;39m [2m:[0;39m Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
[2m2017-07-07 14:55:07.113[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.s.w.s.handler.SimpleUrlHandlerMapping [0;39m [2m:[0;39m Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
[2m2017-07-07 14:55:07.113[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.s.w.s.handler.SimpleUrlHandlerMapping [0;39m [2m:[0;39m Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
[2m2017-07-07 14:55:07.172[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.s.w.s.handler.SimpleUrlHandlerMapping [0;39m [2m:[0;39m Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
[2m2017-07-07 14:55:07.557[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.s.j.e.a.AnnotationMBeanExporter       [0;39m [2m:[0;39m Registering beans for JMX exposure on startup
[2m2017-07-07 14:55:08.132[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[           main][0;39m [36ms.b.c.e.t.TomcatEmbeddedServletContainer[0;39m [2m:[0;39m Tomcat started on port(s): 8080 (http)
[2m2017-07-07 14:55:08.138[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[           main][0;39m [36mnetgloo.Application                     [0;39m [2m:[0;39m Started Application in 9.279 seconds (JVM running for 11.078)
[2m2017-07-07 14:55:22.454[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[nio-8080-exec-1][0;39m [36mo.a.c.c.C.[Tomcat].[localhost].[/]      [0;39m [2m:[0;39m Initializing Spring FrameworkServlet 'dispatcherServlet'
[2m2017-07-07 14:55:22.454[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[nio-8080-exec-1][0;39m [36mo.s.web.servlet.DispatcherServlet       [0;39m [2m:[0;39m FrameworkServlet 'dispatcherServlet': initialization started
[2m2017-07-07 14:55:22.692[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[nio-8080-exec-1][0;39m [36mo.s.web.servlet.DispatcherServlet       [0;39m [2m:[0;39m FrameworkServlet 'dispatcherServlet': initialization completed in 237 ms
Hibernate: select nextval ('hibernate_sequence')
Hibernate: insert into users (email, name, id) values (?, ?, ?)
</code>```

答:
When you use a serial or a bigserial field in a Postgre table, it is an auto-increment field for which a sequence is automatically created.

This can cause trouble with the sequence used by hibernate by default (hibernate_sequence) when using GenerationType.AUTO.

To avoid that, you may either rely on the id generator of your serial field :

```<code>@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
</code>```

Or you may find the sequence (1) that the bigserial has generated (let's call it user_id_seq for this example), and specify it in your annotations so that hibernate uses this one directly :

```<code>@Id
@SequenceGenerator(name = "seqUser", sequenceName = "user_id_seq", allocationSize = 1)
@GeneratedValue(generator = "seqUser", strategy = GenerationType.AUTO)
</code>```

(1): in the table script, you probably have something like the following, telling you the name of the sequence used by Postgre for the increment (usually it is like : table name_column name_seq).

```<code>id bigint NOT NULL DEFAULT nextval('user_id_seq'::regclass)
</code>```

Some more information about serial fields can be found in this question : PostgreSQL bigserial & nextval

Ans some information about GenerationType strategies with Postgre : JPA and PostgreSQL with GenerationType.IDENTITY

Title: SpringBoot + Hibernate + Postgres

Body:
I am trying to insert a value(http://localhost:8080/create?name=name1&email=name1@email.com) to Postgres DB using SpringBoot and hibernate but in log it says as it inserts but no records are inserted also no exception is there.Please help me to find the issue.

Postgres Version:

"PostgreSQL 9.6.3 on x86_64-pc-mingw64, compiled by gcc.exe (Rev5, Built by MSYS2 project) 4.9.2, 64-bit"

build.gradle:

apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'eclipse'

group = 'netgloo'
version = '0.0.1-SNAPSHOT'

description = """spring-boot-mysql-springdatajpa-hibernate"""

sourceCompatibility = 1.8
targetCompatibility = 1.8
tasks.withType(JavaCompile) {
    options.encoding = 'UTF-8'
}
repositories {

     maven { url "http://repo.maven.apache.org/maven2" }
}
dependencies {
    compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version:'1.5.2.RELEASE'
    compile group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa', version:'1.5.2.RELEASE'
    compile group: 'postgres', name: 'postgres', version:'42.1.1.jre6'
}

User.java:

@Entity
@Table(name = "users")
public class User {

  @Id
  @GeneratedValue(strategy = GenerationType.AUTO)
  private long id;
  @NotNull
  private String email;
  @NotNull
  private String name;

  public User() { }

  public User(long id) {
    this.id = id;
  }

  public User(String email, String name) {
    this.email = email;
    this.name = name;
  }

  public long getId() {
    return id;
  }

  public void setId(long value) {
    this.id = value;
  }

  public String getEmail() {
    return email;
  }

  public void setEmail(String value) {
    this.email = value;
  }

  public String getName() {
    return name;
  }

  public void setName(String value) {
    this.name = value;
  }
}

Controller:

@Controller
public class UserController {

  @RequestMapping("/create")
  @ResponseBody
  public String create(String email, String name) {
    User user = null;
    try {
      user = new User(email, name);
      userDao.save(user);
    }
    catch (Exception ex) {
      return "Error creating the user: " + ex.toString();
    }
    return "User succesfully created! (id = " + user.getId() + ")";
  }

  @RequestMapping("/get-by-email")
  @ResponseBody
  public String getByEmail(String email) {
    String userId;
    try {
      User user = userDao.findByEmail(email);
      userId = String.valueOf(user.getId());
    }
    catch (Exception ex) {
      return "User not found";
    }
    return "The user id is: " + userId;
  }
}

UserDao:

@Transactional
public interface UserDao extends CrudRepository<User, Long> {

  public User findByEmail(String email);

} // class UserDao

logs:

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
[32m :: Spring Boot :: [39m      [2m (v1.5.2.RELEASE)[0;39m

[2m2017-07-07 14:54:59.528[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[           main][0;39m [36mnetgloo.Application                     [0;39m [2m:[0;39m Starting Application on B20GPF2 with PID 17176 (C:\Users\a591470\projects\mylearning\spring-boot-samples-master\spring-boot-mysql-springdatajpa-hibernate\bin started by a591470 in C:\Users\a591470\projects\mylearning\spring-boot-samples-master\spring-boot-mysql-springdatajpa-hibernate)
[2m2017-07-07 14:54:59.533[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[           main][0;39m [36mnetgloo.Application                     [0;39m [2m:[0;39m No active profile set, falling back to default profiles: default
[2m2017-07-07 14:54:59.652[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[           main][0;39m [36mationConfigEmbeddedWebApplicationContext[0;39m [2m:[0;39m Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@4387b79e: startup date [Fri Jul 07 14:54:59 IST 2017]; root of context hierarchy
[2m2017-07-07 14:55:01.391[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[           main][0;39m [36mtrationDelegate$BeanPostProcessorChecker[0;39m [2m:[0;39m Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$61eecdd6] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
[2m2017-07-07 14:55:01.919[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[           main][0;39m [36ms.b.c.e.t.TomcatEmbeddedServletContainer[0;39m [2m:[0;39m Tomcat initialized with port(s): 8080 (http)
[2m2017-07-07 14:55:01.935[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.apache.catalina.core.StandardService  [0;39m [2m:[0;39m Starting service Tomcat
[2m2017-07-07 14:55:01.936[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[           main][0;39m [36morg.apache.catalina.core.StandardEngine [0;39m [2m:[0;39m Starting Servlet Engine: Apache Tomcat/8.5.11
[2m2017-07-07 14:55:02.170[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[ost-startStop-1][0;39m [36mo.a.c.c.C.[Tomcat].[localhost].[/]      [0;39m [2m:[0;39m Initializing Spring embedded WebApplicationContext
[2m2017-07-07 14:55:02.171[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[ost-startStop-1][0;39m [36mo.s.web.context.ContextLoader           [0;39m [2m:[0;39m Root WebApplicationContext: initialization completed in 2525 ms
[2m2017-07-07 14:55:02.466[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[ost-startStop-1][0;39m [36mo.s.b.w.servlet.ServletRegistrationBean [0;39m [2m:[0;39m Mapping servlet: 'dispatcherServlet' to [/]
[2m2017-07-07 14:55:02.472[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[ost-startStop-1][0;39m [36mo.s.b.w.servlet.FilterRegistrationBean  [0;39m [2m:[0;39m Mapping filter: 'characterEncodingFilter' to: [/*]
[2m2017-07-07 14:55:02.472[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[ost-startStop-1][0;39m [36mo.s.b.w.servlet.FilterRegistrationBean  [0;39m [2m:[0;39m Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
[2m2017-07-07 14:55:02.472[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[ost-startStop-1][0;39m [36mo.s.b.w.servlet.FilterRegistrationBean  [0;39m [2m:[0;39m Mapping filter: 'httpPutFormContentFilter' to: [/*]
[2m2017-07-07 14:55:02.472[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[ost-startStop-1][0;39m [36mo.s.b.w.servlet.FilterRegistrationBean  [0;39m [2m:[0;39m Mapping filter: 'requestContextFilter' to: [/*]
[2m2017-07-07 14:55:04.067[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[           main][0;39m [36mj.LocalContainerEntityManagerFactoryBean[0;39m [2m:[0;39m Building JPA container EntityManagerFactory for persistence unit 'default'
[2m2017-07-07 14:55:04.103[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.hibernate.jpa.internal.util.LogHelper [0;39m [2m:[0;39m HHH000204: Processing PersistenceUnitInfo [
    name: default
    ...]
[2m2017-07-07 14:55:04.304[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[           main][0;39m [36morg.hibernate.Version                   [0;39m [2m:[0;39m HHH000412: Hibernate Core {5.0.12.Final}
[2m2017-07-07 14:55:04.306[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[           main][0;39m [36morg.hibernate.cfg.Environment           [0;39m [2m:[0;39m HHH000206: hibernate.properties not found
[2m2017-07-07 14:55:04.309[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[           main][0;39m [36morg.hibernate.cfg.Environment           [0;39m [2m:[0;39m HHH000021: Bytecode provider name : javassist
[2m2017-07-07 14:55:04.388[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.hibernate.annotations.common.Version  [0;39m [2m:[0;39m HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
[2m2017-07-07 14:55:04.602[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[           main][0;39m [36morg.hibernate.dialect.Dialect           [0;39m [2m:[0;39m HHH000400: Using dialect: org.hibernate.dialect.PostgreSQLDialect
[2m2017-07-07 14:55:04.920[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.h.e.j.e.i.LobCreatorBuilderImpl       [0;39m [2m:[0;39m HHH000424: Disabling contextual LOB creation as createClob() method threw error : java.lang.reflect.InvocationTargetException
[2m2017-07-07 14:55:04.923[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[           main][0;39m [36morg.hibernate.type.BasicTypeRegistry    [0;39m [2m:[0;39m HHH000270: Type registration [java.util.UUID] overrides previous : org.hibernate.type.UUIDBinaryType@2f84acf7
[2m2017-07-07 14:55:05.243[0;39m [33m WARN[0;39m [35m17176[0;39m [2m---[0;39m [2m[           main][0;39m [36morg.hibernate.orm.deprecation           [0;39m [2m:[0;39m HHH90000014: Found use of deprecated [org.hibernate.id.SequenceGenerator] sequence-based id generator; use org.hibernate.id.enhanced.SequenceStyleGenerator instead.  See Hibernate Domain Model Mapping Guide for details.
[2m2017-07-07 14:55:05.724[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[           main][0;39m [36morg.hibernate.tool.hbm2ddl.SchemaUpdate [0;39m [2m:[0;39m HHH000228: Running hbm2ddl schema update
[2m2017-07-07 14:55:05.877[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[           main][0;39m [36mj.LocalContainerEntityManagerFactoryBean[0;39m [2m:[0;39m Initialized JPA EntityManagerFactory for persistence unit 'default'
[2m2017-07-07 14:55:06.920[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[           main][0;39m [36ms.w.s.m.m.a.RequestMappingHandlerAdapter[0;39m [2m:[0;39m Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@4387b79e: startup date [Fri Jul 07 14:54:59 IST 2017]; root of context hierarchy
[2m2017-07-07 14:55:07.038[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[           main][0;39m [36ms.w.s.m.m.a.RequestMappingHandlerMapping[0;39m [2m:[0;39m Mapped "{[/]}" onto public java.lang.String netgloo.controllers.MainController.index()
[2m2017-07-07 14:55:07.040[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[           main][0;39m [36ms.w.s.m.m.a.RequestMappingHandlerMapping[0;39m [2m:[0;39m Mapped "{[/delete]}" onto public java.lang.String netgloo.controllers.UserController.delete(long)
[2m2017-07-07 14:55:07.040[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[           main][0;39m [36ms.w.s.m.m.a.RequestMappingHandlerMapping[0;39m [2m:[0;39m Mapped "{[/create]}" onto public java.lang.String netgloo.controllers.UserController.create(java.lang.String,java.lang.String) throws java.lang.Exception
[2m2017-07-07 14:55:07.041[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[           main][0;39m [36ms.w.s.m.m.a.RequestMappingHandlerMapping[0;39m [2m:[0;39m Mapped "{[/update]}" onto public java.lang.String netgloo.controllers.UserController.updateUser(long,java.lang.String,java.lang.String)
[2m2017-07-07 14:55:07.041[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[           main][0;39m [36ms.w.s.m.m.a.RequestMappingHandlerMapping[0;39m [2m:[0;39m Mapped "{[/get-by-email]}" onto public java.lang.String netgloo.controllers.UserController.getByEmail(java.lang.String) throws java.lang.Exception
[2m2017-07-07 14:55:07.044[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[           main][0;39m [36ms.w.s.m.m.a.RequestMappingHandlerMapping[0;39m [2m:[0;39m Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
[2m2017-07-07 14:55:07.045[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[           main][0;39m [36ms.w.s.m.m.a.RequestMappingHandlerMapping[0;39m [2m:[0;39m Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
[2m2017-07-07 14:55:07.113[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.s.w.s.handler.SimpleUrlHandlerMapping [0;39m [2m:[0;39m Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
[2m2017-07-07 14:55:07.113[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.s.w.s.handler.SimpleUrlHandlerMapping [0;39m [2m:[0;39m Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
[2m2017-07-07 14:55:07.172[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.s.w.s.handler.SimpleUrlHandlerMapping [0;39m [2m:[0;39m Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
[2m2017-07-07 14:55:07.557[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.s.j.e.a.AnnotationMBeanExporter       [0;39m [2m:[0;39m Registering beans for JMX exposure on startup
[2m2017-07-07 14:55:08.132[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[           main][0;39m [36ms.b.c.e.t.TomcatEmbeddedServletContainer[0;39m [2m:[0;39m Tomcat started on port(s): 8080 (http)
[2m2017-07-07 14:55:08.138[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[           main][0;39m [36mnetgloo.Application                     [0;39m [2m:[0;39m Started Application in 9.279 seconds (JVM running for 11.078)
[2m2017-07-07 14:55:22.454[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[nio-8080-exec-1][0;39m [36mo.a.c.c.C.[Tomcat].[localhost].[/]      [0;39m [2m:[0;39m Initializing Spring FrameworkServlet 'dispatcherServlet'
[2m2017-07-07 14:55:22.454[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[nio-8080-exec-1][0;39m [36mo.s.web.servlet.DispatcherServlet       [0;39m [2m:[0;39m FrameworkServlet 'dispatcherServlet': initialization started
[2m2017-07-07 14:55:22.692[0;39m [32m INFO[0;39m [35m17176[0;39m [2m---[0;39m [2m[nio-8080-exec-1][0;39m [36mo.s.web.servlet.DispatcherServlet       [0;39m [2m:[0;39m FrameworkServlet 'dispatcherServlet': initialization completed in 237 ms
Hibernate: select nextval ('hibernate_sequence')
Hibernate: insert into users (email, name, id) values (?, ?, ?)

Body:
When you use a serial or a bigserial field in a Postgre table, it is an auto-increment field for which a sequence is automatically created.

This can cause trouble with the sequence used by hibernate by default (hibernate_sequence) when using GenerationType.AUTO.

To avoid that, you may either rely on the id generator of your serial field :

@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)

Or you may find the sequence (1) that the bigserial has generated (let's call it user_id_seq for this example), and specify it in your annotations so that hibernate uses this one directly :

@Id
@SequenceGenerator(name = "seqUser", sequenceName = "user_id_seq", allocationSize = 1)
@GeneratedValue(generator = "seqUser", strategy = GenerationType.AUTO)

(1): in the table script, you probably have something like the following, telling you the name of the sequence used by Postgre for the increment (usually it is like : table name_column name_seq).

id bigint NOT NULL DEFAULT nextval('user_id_seq'::regclass)

Some more information about serial fields can be found in this question : PostgreSQL bigserial & nextval

Ans some information about GenerationType strategies with Postgre : JPA and PostgreSQL with GenerationType.IDENTITY


Title: How to get partial sum of column and finds which rows has partial sum in mysql

Body:
+----------------------------------------+
|        Here is my sample table         |
+----------------------------------------+
| Date       Person    Column_1    Column_2 |
| 15-03-13    A       100         NULL   |
| 15-03-13    B       NULL         100   |
| 16-03-13    A       100           50   |
| 16-03-13    B       NULL         NULL  |
| 17-03-13    A       100           50   |
| 17-03-13    B       20            30   |
+----------------------------------------+

Now i wanted to do sum(column_1) by date. But i also need to which sum of row includes NULL data.
here is the output result I wanted to achieve

+---------------------------------+
| Date       SUM  includesNullval |
+---------------------------------+
| 15-03-13   100   true           |
| 16-03-13   100   true           |
| 17-03-13   120   false          |
+---------------------------------+

I don't know to achieve above output. Can anybody give me any idea or solution of this problem?

Body:
Note both the form and content of the answer.

DROP TABLE IF EXISTS my_table;

CREATE TABLE my_table
(date DATE NOT NULL
,person CHAR(1) NOT NULL
,column_1 INT NULL
,column_2 INT NULL
,PRIMARY KEY(date,person)
);

INSERT INTO my_table VALUES
('2013-03-15','A', 100, NULL),
('2013-03-15','B',NULL,  100),
('2013-03-16','A', 100,   50),
('2013-03-16','B',NULL, NULL),
('2013-03-17','A', 100,   50),
('2013-03-17','B',  20,   30);

SELECT date, SUM(column_1), MAX(column_2 IS NULL) incnull FROM my_table GROUP BY date;
+------------+---------------+---------+
| date       | SUM(column_1) | incnull |
+------------+---------------+---------+
| 2013-03-15 |           100 |       1 |
| 2013-03-16 |           100 |       1 |
| 2013-03-17 |           120 |       0 |
+------------+---------------+---------+


答:
try this </p>

```<code>$($("input").get().reverse()).each(function() { /* ... */ });
</code>```

Title: how to iterate elements in reverse order in jquery?

Body:
i'm new to jquery.I'd like to know how to iterate form elements in reverse order in jquery using each()?
Any help would be appreciated:)

Body:
try this

$($("input").get().reverse()).each(function() { /* ... */ });