问:
Doesn't Working MICountry picker's dial_code in swift
I'm trying to use MICountrypicker for country code (Mobile number code). I referred this link. But its not working well. It just showing (-) Symbol

Screen shot

My source code:

@IBAction func codet(_ sender: Any) {

```<code>    let picker = MICountryPicker { (name, code) -> () in
        print(code)
    }

    // Optional: To pick from custom countries list
    picker.customCountriesCode = ["EG", "US", "AF", "AQ", "AX", "IN","AL","DZ","AS","AD","AO","AI","AG","AR","AM","AW","AU","AT","AZ","BS","BH","BD","BB","BY","BE","BZ","BJ","BM","BT","BO","BA","BW","BR","IO","BN","BG","BF","BI","KH","CM","CA","CV","KY","CF","TD","CL","CN","CX","CC","CO","KM","CG","CD","CK","CR","CI","HR","CU","CY","CZ","DK","DJ","DM","DO","EC","EG","SV","GQ","ER","EE","ET","FK","FO","FJ","FI","FR","GF","PF","GA","GM","GE","DE","GH","GI","GR","GL","GD","GP","GU","GT","GG","GN","GW","GY","HT","VA","HN","HK","HU","IS","ID","IR","IQ","IE","IM","IL","IT","JM","JP","JE","JO","KZ","KE","KI","KP","KR","KW","KG","LA","LV","LB","LS","LR","LY","LI","LT","LU","MO","MK","MG","MW","MY","MV","ML","MT","MH","MQ","MR","MU","YT","MX","FM","MD","MC","MN","ME","MS","MA","MZ","MM","NA","NR","NP","NL","AN","NC","NZ","NI","NE","NZ","NU","NF","MP","NO","OM","PK","PW","PS","PA","PG","PY","PE","PH","PN","PL","PT","PR","QA","RO","RU","RW","RE","BL","SH","KN","LC","MF","PM","VC","WS","SM","ST","SA","SN","RS","SC","SL","SG","SK","SI","SB","SO","ZA","SS","GS","ES","LK","SD","SR","SJ","SZ","SE","CH","SY","TW","TJ","TZ","TH","TL","TG","TK","TO","TT","TN","TR","TM","TC","TV","UG","UA","AE","GB","US","UY","UZ","VU","VE","VN","VG","VI","WF","YE","ZM","ZW"]

    // delegate
    picker.delegate = self

    // Display calling codes
    picker.showCallingCodes = true

    // or closure
    picker.didSelectCountryClosure = { name, code in

        //      picker.navigationController?.popToRootViewController(animated: true)

        //  picker.navigationController?.popViewController(animated: true)

        print(code)
    }

    picker.didSelectCountryWithCallingCodeClosure = { name, code, dialCode in
        print(dialCode)
    }
    //   self.navigationController?.setNavigationBarHidden(false, animated: true)
    navigationController?.pushViewController(picker, animated: true)

    }
</code>```

If any one know answer, Ping me ... ;)

答: Add this line, picker.showCallingCodes = true

Body:
I'm trying to use MICountrypicker for country code (Mobile number code). I referred this link. But its not working well. It just showing (-) Symbol

Screen shot

My source code:

@IBAction func codet(_ sender: Any) {

    let picker = MICountryPicker { (name, code) -> () in
        print(code)
    }

    // Optional: To pick from custom countries list
    picker.customCountriesCode = ["EG", "US", "AF", "AQ", "AX", "IN","AL","DZ","AS","AD","AO","AI","AG","AR","AM","AW","AU","AT","AZ","BS","BH","BD","BB","BY","BE","BZ","BJ","BM","BT","BO","BA","BW","BR","IO","BN","BG","BF","BI","KH","CM","CA","CV","KY","CF","TD","CL","CN","CX","CC","CO","KM","CG","CD","CK","CR","CI","HR","CU","CY","CZ","DK","DJ","DM","DO","EC","EG","SV","GQ","ER","EE","ET","FK","FO","FJ","FI","FR","GF","PF","GA","GM","GE","DE","GH","GI","GR","GL","GD","GP","GU","GT","GG","GN","GW","GY","HT","VA","HN","HK","HU","IS","ID","IR","IQ","IE","IM","IL","IT","JM","JP","JE","JO","KZ","KE","KI","KP","KR","KW","KG","LA","LV","LB","LS","LR","LY","LI","LT","LU","MO","MK","MG","MW","MY","MV","ML","MT","MH","MQ","MR","MU","YT","MX","FM","MD","MC","MN","ME","MS","MA","MZ","MM","NA","NR","NP","NL","AN","NC","NZ","NI","NE","NZ","NU","NF","MP","NO","OM","PK","PW","PS","PA","PG","PY","PE","PH","PN","PL","PT","PR","QA","RO","RU","RW","RE","BL","SH","KN","LC","MF","PM","VC","WS","SM","ST","SA","SN","RS","SC","SL","SG","SK","SI","SB","SO","ZA","SS","GS","ES","LK","SD","SR","SJ","SZ","SE","CH","SY","TW","TJ","TZ","TH","TL","TG","TK","TO","TT","TN","TR","TM","TC","TV","UG","UA","AE","GB","US","UY","UZ","VU","VE","VN","VG","VI","WF","YE","ZM","ZW"]

    // delegate
    picker.delegate = self

    // Display calling codes
    picker.showCallingCodes = true

    // or closure
    picker.didSelectCountryClosure = { name, code in

        //      picker.navigationController?.popToRootViewController(animated: true)

        //  picker.navigationController?.popViewController(animated: true)

        print(code)
    }

    picker.didSelectCountryWithCallingCodeClosure = { name, code, dialCode in
        print(dialCode)
    }
    //   self.navigationController?.setNavigationBarHidden(false, animated: true)
    navigationController?.pushViewController(picker, animated: true)

    }

If any one know answer, Ping me ... ;)


来源: stackexchange

问:
How to calculate moving sum with reset based on condition in teradata SQL?
I have this data and I want to sum the field USAGE_FLAG but reset when it drops to 0 or moves to a new ID keeping the dataset ordered by SU_ID and WEEK:

```<code>SU_ID   WEEK    USAGE_FLAG
100        1    0
100        2    7
100        3    7
100        4    0
101        1    0
101        2    7
101        3    0
101        4    7
102        1    7
102        2    7
102        3    7
102        4    0
</code>```

So I want to create this table:

```<code>SU_ID   WEEK    USAGE_FLAG    SUM
100        1    0             0
100        2    7             7
100        3    7             14
100        4    0             0
101        1    0             0
101        2    7             7
101        3    0             0
101        4    7             7
102        1    7             7
102        2    7             14
102        3    7             21
102        4    0             0
</code>```

I have tried the MSUM() function using GROUP BY but it won't keep the order I want above. It groups the 7's and the week numbers together which I don't want.

Anyone know if this is possible to do? I'm using teradata

答:
Please try below SQL:

```<code>select su_id,
       week,
       usage_flag,
       SUM(usage_flag) OVER (PARTITION BY su_id ORDER BY week
        RESET WHEN usage_flag = 0
        ROWS UNBOUNDED PRECEDING
   )
from emp_su;
</code>```

Here RESET WHEN usage_flag = 0 will reset sum whenever sum usage_flag drops to 0

ContentLicense: CC BY-SA 3.0

Body:
I have this data and I want to sum the field USAGE_FLAG but reset when it drops to 0 or moves to a new ID keeping the dataset ordered by SU_ID and WEEK:

SU_ID   WEEK    USAGE_FLAG
100        1    0
100        2    7
100        3    7
100        4    0
101        1    0
101        2    7
101        3    0
101        4    7
102        1    7
102        2    7
102        3    7
102        4    0

So I want to create this table:

SU_ID   WEEK    USAGE_FLAG    SUM
100        1    0             0
100        2    7             7
100        3    7             14
100        4    0             0
101        1    0             0
101        2    7             7
101        3    0             0
101        4    7             7
102        1    7             7
102        2    7             14
102        3    7             21
102        4    0             0

I have tried the MSUM() function using GROUP BY but it won't keep the order I want above. It groups the 7's and the week numbers together which I don't want.

Anyone know if this is possible to do? I'm using teradata

Body:
Please try below SQL:

select su_id,
       week,
       usage_flag,
       SUM(usage_flag) OVER (PARTITION BY su_id ORDER BY week
        RESET WHEN usage_flag = 0
        ROWS UNBOUNDED PRECEDING
   )
from emp_su;

Here RESET WHEN usage_flag = 0 will reset sum whenever sum usage_flag drops to 0


问:
Nearby Connections NullPointerException
I've tried to use Nearby Connections, but I keep getting the dialog "Google Play Services" has crashed. The logcat shows a stack trace like this:

```<code>04-08 20:01:32.309 8904-11589/? E/AndroidRuntime: FATAL EXCEPTION: highpool[3]
                                                  Process: com.google.android.gms.nearby.connection, PID: 8904
                                                  java.lang.NullPointerException: Attempt to read from field 'java.lang.Object pu.a' on a null object reference
                                                      at vsb.e(:com.google.android.gms:244)
                                                      at vsr.run(:com.google.android.gms:344)
                                                      at lmq.run(:com.google.android.gms:450)
                                                      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
                                                      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
                                                      at lra.run(:com.google.android.gms:17)
                                                      at java.lang.Thread.run(Thread.java:818)
</code>```

Where the specific random letters can change.

After further investigation, it seems to occur when a device is attempting to discover advertising devices and the timeout it specifies ends.

I went to report the issue and found someone already had:

https://code.google.com/p/android/issues/detail?can=1&start=0&num=100&q=nearby%20connections%20nullpointerexception&colspec=ID%20Status%20Priority%20Owner%20Summary%20Stars%20Reporter%20Opened&groupby=&sort=&id=316748

Very few apps seem to use Nearby Connections; I know of none. The official documentation isn't great. Heck, Nearby.Connections.startAdvertising() still wants a AppMetadata parameter, which Google has deprecated.

The official code example, https://github.com/googlesamples/android-nearby , is obsolete and non-functional.

So my question is: how can I work around these issues? Is there a modern, working example of Nearby Connections anywhere? Or is the Nearby Connections API itself simply unused and completely broken?

答: We significantly revamped Nearby Connections in the 11 release of Google Play Services. There's a bunch of new functionally, rewritten docs and new samples on the dev site.</p>

Title: Nearby Connections NullPointerException

Body:
I've tried to use Nearby Connections, but I keep getting the dialog "Google Play Services" has crashed. The logcat shows a stack trace like this:

04-08 20:01:32.309 8904-11589/? E/AndroidRuntime: FATAL EXCEPTION: highpool[3]
                                                  Process: com.google.android.gms.nearby.connection, PID: 8904
                                                  java.lang.NullPointerException: Attempt to read from field 'java.lang.Object pu.a' on a null object reference
                                                      at vsb.e(:com.google.android.gms:244)
                                                      at vsr.run(:com.google.android.gms:344)
                                                      at lmq.run(:com.google.android.gms:450)
                                                      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
                                                      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
                                                      at lra.run(:com.google.android.gms:17)
                                                      at java.lang.Thread.run(Thread.java:818)

Where the specific random letters can change.

After further investigation, it seems to occur when a device is attempting to discover advertising devices and the timeout it specifies ends.

I went to report the issue and found someone already had:

https://code.google.com/p/android/issues/detail?can=1&start=0&num=100&q=nearby%20connections%20nullpointerexception&colspec=ID%20Status%20Priority%20Owner%20Summary%20Stars%20Reporter%20Opened&groupby=&sort=&id=316748

Very few apps seem to use Nearby Connections; I know of none. The official documentation isn't great. Heck, Nearby.Connections.startAdvertising() still wants a AppMetadata parameter, which Google has deprecated.

The official code example, https://github.com/googlesamples/android-nearby , is obsolete and non-functional.

So my question is: how can I work around these issues? Is there a modern, working example of Nearby Connections anywhere? Or is the Nearby Connections API itself simply unused and completely broken?


问:
Can't connect to MySQL server on 'localhost' (10061)
I recently installed MySQL 5 on Windows 2003 and tried configuring an instance. Everything worked fine until I got to "Applying Security settings", at which point it gave me the above error (Can't connect to MySQL server on 'localhost' (10061)).

I do have a port 3306 exception in my firewall for 'MySQL Server'.

答:
English:

press Windows + R

write "services.msc". Then press Enter

search for  MySQL57 and right click

click on  start the service

Français :

Appuyez sur la touche Windows + R

Écrire "services.msc" Puis appuyez sur Entrée

Recherchez MySQL57 et clic droit

Cliquez sur rédémarrer

ContentLicense: CC BY-SA 4.0


问:
error in inflating layout in android studio
I want to add footer in my listview by inflating a different layout.

here is my code ...

```<code>View loadMoreView, loading_img;

loading_img = ((LayoutInflater)this
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE))
                .inflate(R.layout.loading_img, null, false);

loadMoreView = ((LayoutInflater)this
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE))
                .inflate(R.layout.load_more_btn, null, false);
</code>```

Here is xml file loading_img.xml code ....

```<code><?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <pl.droidsonroids.gif.GifImageView
        android:layout_width="match_parent"
        android:layout_height="70dp"
        android:id="@+id/loading_img"
        android:src="@mipmap/progress_bar_default"
        android:background="@color/pd_color1"
        android:layout_marginLeft="20dp"
        android:layout_marginRight="14dp"
        android:layout_marginBottom="10dp"/>

</LinearLayout>
</code>```

but it shows error....

```<code>java.lang.RuntimeException: Unable to start activity ComponentInfo{com.plexusd.plexusd/com.plexusd.plexusd.Notification}: android.view.InflateException: Binary XML file line #8: Binary XML file line #8: Error inflating class <unknown>
                                                                     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2572)
                                                                     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2654)
                                                                     at android.app.ActivityThread.-wrap11(ActivityThread.java)
                                                                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1488)
                                                                     at android.os.Handler.dispatchMessage(Handler.java:111)
                                                                     at android.os.Looper.loop(Looper.java:207)
                                                                     at android.app.ActivityThread.main(ActivityThread.java:5728)
                                                                     at java.lang.reflect.Method.invoke(Native Method)
                                                                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
                                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)
                                                                  Caused by: android.view.InflateException: Binary XML file line #8: Binary XML file line #8: Error inflating class <unknown>
                                                                     at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
                                                                     at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
                                                                     at com.plexusd.plexusd.Notification.onCreate(Notification.java:104)
                                                                     at android.app.Activity.performCreate(Activity.java:6337)
                                                                     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1113)
                                                                     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2519)
                                                                     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2654)
                                                                     at android.app.ActivityThread.-wrap11(ActivityThread.java)
                                                                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1488)
                                                                     at android.os.Handler.dispatchMessage(Handler.java:111)
                                                                     at android.os.Looper.loop(Looper.java:207)
                                                                     at android.app.ActivityThread.main(ActivityThread.java:5728)
                                                                     at java.lang.reflect.Method.invoke(Native Method)
                                                                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
                                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)
                                                                  Caused by: android.view.InflateException: Binary XML file line #8: Error inflating class <unknown>
                                                                     at android.view.LayoutInflater.createView(LayoutInflater.java:645)
                                                                     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764)
                                                                     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
                                                                     at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
                                                                     at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
                                                                     at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
                                                                     at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
                                                                     at com.plexusd.plexusd.Notification.onCreate(Notification.java:104)
                                                                     at android.app.Activity.performCreate(Activity.java:6337)
                                                                     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1113)
                                                                     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2519)
                                                                     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2654)
                                                                     at android.app.ActivityThread.-wrap11(ActivityThread.java)
                                                                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1488)
                                                                     at android.os.Handler.dispatchMessage(Handler.java:111)
                                                                     at android.os.Looper.loop(Looper.java:207)
                                                                     at android.app.ActivityThread.main(ActivityThread.java:5728)
                                                                     at java.lang.reflect.Method.invoke(Native Method)
                                                                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
                                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)
                                                                  Caused by: java.lang.reflect.InvocationTargetException
                                                                     at java.lang.reflect.Constructor.newInstance(Native Method)
                                                                     at android.view.LayoutInflater.createView(LayoutInflater.java:619)
                                                                     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764)
                                                                     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
                                                                     at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
                                                                     at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
                                                                     at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
                                                                     at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
                                                                     at com.plexusd.plexusd.Notification.onCreate(Notification.java:104)
                                                                     at android.app.Activity.performCreate(Activity.java:6337)
                                                                     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1113)
                                                                     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2519)
                                                                     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2654)
                                                                     at android.app.ActivityThread.-wrap11(ActivityThread.java)
                                                                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1488)
                                                                     at android.os.Handler.dispatchMessage(Handler.java:111)
                                                                     at android.os.Looper.loop(Looper.java:207)
                                                                     at android.app.ActivityThread.main(ActivityThread.java:5728)
                                                                     at java.lang.reflect.Method.invoke(Native Method)
                                                                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
                                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)
                                                                  Caused by: java.lang.OutOfMemoryError: Failed to allocate a 3686412 byte allocation with 2971336 free bytes and 2MB until OOM
                                                                     at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
                                                                     at android.graphics.Bitmap.nativeCreate(Native Method)
                                                                     at android.graphics.Bitmap.createBitmap(Bitmap.java:831)
                                                                     at android.graphics.Bitmap.createBitmap(Bitmap.java:808)
                                                                     at android.graphics.Bitmap.createBitmap(Bitmap.java:775)
                                                                     at pl.droidsonroids.gif.GifDrawable.<init>(GifDrawable.java:248)
                                                                     at pl.droidsonroids.gif.GifDrawable.<init>(GifDrawable.java:160)
                                                                     at pl.droidsonroids.gif.GifDrawable.<init>(GifDrawable.java:95)
                                                                     at pl.droidsonroids.gif.GifViewUtils.setResource(GifViewUtils.java:53)
                                                                     at pl.droidsonroids.gif.GifViewUtils.getResourceId(GifViewUtils.java:41)
                                                                     at pl.droidsonroids.gif.GifViewUtils.initImageView(GifViewUtils.java:29)
                                                                     at pl.droidsonroids.gif.GifImageView.<init>(GifImageView.java:41)
                                                                     at java.lang.reflect.Constructor.newInstance(Native Method)
                                                                     at android.view.LayoutInflater.createView(LayoutInflater.java:619)
                                                                     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764)
                                                                     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
                                                                     at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
                                                                     at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
                                                                     at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
                                                                     at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
                                                                     at com.plexusd.plexusd.Notification.onCreate(Notification.java:104)
                                                                     at android.app.Activity.performCreate(Activity.java:6337)
                                                                     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1113)
                                                                     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2519)
                                                                     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2654)
                                                                     at android.app.ActivityThread.-wrap11(ActivityThread.java)
                                                                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1488)
                                                                     at android.os.Handler.dispatchMessage(Handler.java:111)
                                                                     at android.os.Looper.loop(Looper.java:207)
                                                                     at android.app.ActivityThread.main(ActivityThread.java:5728)
                                                                     at java.lang.reflect.Method.invoke(Native Method)
                                                                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
                                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)
</code>```

07-06 00:23:56.956 24424-24424/com.plexusd.plexusd I/Process: Sending signal. PID: 24424 SIG: 9

答:
The cause is shown down at the bottom of stacktrace:

Caused by: java.lang.OutOfMemoryError: Failed to allocate a 3686412 byte allocation with 2971336 free bytes and 2MB until OOM

The suggested ways to deal with OOM are:

If you are working with large-sized GIFs you can subsample them, see: #284 (comment)

You can use tools like MAT, or Memory Monitor in Android Studio to locate potential causes.

You can increase available heap space by using android:largeHeap="true" in AndroidManifest.xml or dividing app to
  separate processes (by adding android:process tags) but those
  workarounds may cause side-effects.

https://github.com/koral--/android-gif-drawable/issues/326

Body:
I want to add footer in my listview by inflating a different layout.

here is my code ...

View loadMoreView, loading_img;

loading_img = ((LayoutInflater)this
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE))
                .inflate(R.layout.loading_img, null, false);

loadMoreView = ((LayoutInflater)this
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE))
                .inflate(R.layout.load_more_btn, null, false);

Here is xml file loading_img.xml code ....

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <pl.droidsonroids.gif.GifImageView
        android:layout_width="match_parent"
        android:layout_height="70dp"
        android:id="@+id/loading_img"
        android:src="@mipmap/progress_bar_default"
        android:background="@color/pd_color1"
        android:layout_marginLeft="20dp"
        android:layout_marginRight="14dp"
        android:layout_marginBottom="10dp"/>

</LinearLayout>

but it shows error....

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.plexusd.plexusd/com.plexusd.plexusd.Notification}: android.view.InflateException: Binary XML file line #8: Binary XML file line #8: Error inflating class <unknown>
                                                                     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2572)
                                                                     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2654)
                                                                     at android.app.ActivityThread.-wrap11(ActivityThread.java)
                                                                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1488)
                                                                     at android.os.Handler.dispatchMessage(Handler.java:111)
                                                                     at android.os.Looper.loop(Looper.java:207)
                                                                     at android.app.ActivityThread.main(ActivityThread.java:5728)
                                                                     at java.lang.reflect.Method.invoke(Native Method)
                                                                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
                                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)
                                                                  Caused by: android.view.InflateException: Binary XML file line #8: Binary XML file line #8: Error inflating class <unknown>
                                                                     at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
                                                                     at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
                                                                     at com.plexusd.plexusd.Notification.onCreate(Notification.java:104)
                                                                     at android.app.Activity.performCreate(Activity.java:6337)
                                                                     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1113)
                                                                     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2519)
                                                                     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2654)
                                                                     at android.app.ActivityThread.-wrap11(ActivityThread.java)
                                                                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1488)
                                                                     at android.os.Handler.dispatchMessage(Handler.java:111)
                                                                     at android.os.Looper.loop(Looper.java:207)
                                                                     at android.app.ActivityThread.main(ActivityThread.java:5728)
                                                                     at java.lang.reflect.Method.invoke(Native Method)
                                                                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
                                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)
                                                                  Caused by: android.view.InflateException: Binary XML file line #8: Error inflating class <unknown>
                                                                     at android.view.LayoutInflater.createView(LayoutInflater.java:645)
                                                                     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764)
                                                                     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
                                                                     at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
                                                                     at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
                                                                     at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
                                                                     at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
                                                                     at com.plexusd.plexusd.Notification.onCreate(Notification.java:104)
                                                                     at android.app.Activity.performCreate(Activity.java:6337)
                                                                     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1113)
                                                                     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2519)
                                                                     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2654)
                                                                     at android.app.ActivityThread.-wrap11(ActivityThread.java)
                                                                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1488)
                                                                     at android.os.Handler.dispatchMessage(Handler.java:111)
                                                                     at android.os.Looper.loop(Looper.java:207)
                                                                     at android.app.ActivityThread.main(ActivityThread.java:5728)
                                                                     at java.lang.reflect.Method.invoke(Native Method)
                                                                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
                                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)
                                                                  Caused by: java.lang.reflect.InvocationTargetException
                                                                     at java.lang.reflect.Constructor.newInstance(Native Method)
                                                                     at android.view.LayoutInflater.createView(LayoutInflater.java:619)
                                                                     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764)
                                                                     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
                                                                     at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
                                                                     at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
                                                                     at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
                                                                     at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
                                                                     at com.plexusd.plexusd.Notification.onCreate(Notification.java:104)
                                                                     at android.app.Activity.performCreate(Activity.java:6337)
                                                                     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1113)
                                                                     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2519)
                                                                     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2654)
                                                                     at android.app.ActivityThread.-wrap11(ActivityThread.java)
                                                                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1488)
                                                                     at android.os.Handler.dispatchMessage(Handler.java:111)
                                                                     at android.os.Looper.loop(Looper.java:207)
                                                                     at android.app.ActivityThread.main(ActivityThread.java:5728)
                                                                     at java.lang.reflect.Method.invoke(Native Method)
                                                                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
                                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)
                                                                  Caused by: java.lang.OutOfMemoryError: Failed to allocate a 3686412 byte allocation with 2971336 free bytes and 2MB until OOM
                                                                     at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
                                                                     at android.graphics.Bitmap.nativeCreate(Native Method)
                                                                     at android.graphics.Bitmap.createBitmap(Bitmap.java:831)
                                                                     at android.graphics.Bitmap.createBitmap(Bitmap.java:808)
                                                                     at android.graphics.Bitmap.createBitmap(Bitmap.java:775)
                                                                     at pl.droidsonroids.gif.GifDrawable.<init>(GifDrawable.java:248)
                                                                     at pl.droidsonroids.gif.GifDrawable.<init>(GifDrawable.java:160)
                                                                     at pl.droidsonroids.gif.GifDrawable.<init>(GifDrawable.java:95)
                                                                     at pl.droidsonroids.gif.GifViewUtils.setResource(GifViewUtils.java:53)
                                                                     at pl.droidsonroids.gif.GifViewUtils.getResourceId(GifViewUtils.java:41)
                                                                     at pl.droidsonroids.gif.GifViewUtils.initImageView(GifViewUtils.java:29)
                                                                     at pl.droidsonroids.gif.GifImageView.<init>(GifImageView.java:41)
                                                                     at java.lang.reflect.Constructor.newInstance(Native Method)
                                                                     at android.view.LayoutInflater.createView(LayoutInflater.java:619)
                                                                     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764)
                                                                     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
                                                                     at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
                                                                     at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
                                                                     at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
                                                                     at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
                                                                     at com.plexusd.plexusd.Notification.onCreate(Notification.java:104)
                                                                     at android.app.Activity.performCreate(Activity.java:6337)
                                                                     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1113)
                                                                     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2519)
                                                                     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2654)
                                                                     at android.app.ActivityThread.-wrap11(ActivityThread.java)
                                                                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1488)
                                                                     at android.os.Handler.dispatchMessage(Handler.java:111)
                                                                     at android.os.Looper.loop(Looper.java:207)
                                                                     at android.app.ActivityThread.main(ActivityThread.java:5728)
                                                                     at java.lang.reflect.Method.invoke(Native Method)
                                                                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
                                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)

07-06 00:23:56.956 24424-24424/com.plexusd.plexusd I/Process: Sending signal. PID: 24424 SIG: 9


问:
Can someone look into a web servers folders?
More a web server security question.

Is it possible for someone to "probe" into a folder on a web server, even if an index file is in place?

I assume they can't, but if I wanted to store .pdf applications as random names (93fe3509edif094.pdf) I want to make sure there's no way to list all the pdfs in the folder.

Thank you.

答:
Web servers have a setting that controls whether or not the directory listing can be browsed.  Apache's is called Options Indexes:

Indexes
If a URL which maps to a directory is requested, and the there is no DirectoryIndex (e.g., index.html) in that directory, then the server will return a formatted listing of the directory.

However, if anyone knows the URL in advance, or can easily guess the filename, they can still load the pdf.

ContentLicense: CC BY-SA 2.5


问:
BIRT Viewer randomly fails to open report
I'm running birt 3.7.2 using the Birt Web Viewer and have recently been encountering an error when opening my reports / changing the report parameters.

The error is as follows:

An error occurred while getting report parameters. The specified report: /$$$Transient/acfile20.rptdocument was not found. The report may have expired or may not have been generated.

It also throws a "Get page count failed." error message too. I'm sure it's related to the message above.

It's not happening on all of the different instances of BIRT that I'm using. I've checked what I think is the Transient folder and it is not generating these files, yet sometimes, if I refresh the report, it will run.

What might be causing this?

答: If you are using either a dynamic parameter or computed column, try disabling either.  For example if there is a dynamic parameter make it static, if there is a computed column try removing it.</p>


问:
angular2-Highcharts not working in angular-cli project
I have created a new project using angular-cli
I followed all the steps that are suggested at the page
https://www.npmjs.com/package/angular2-highcharts

npm install angular2-highcharts --save
import { ChartModule } from 'angular2-highcharts';
ChartModule.forRoot(require('highcharts')

When I run the app, it says cannot find name 'require'
Do I need to follow any other steps.

答:
Try to add this dclaration on your component : declare var require: any;

I had the same problem.
I didn't have much time to resolve the problem. So i used ng2-highchart (an alternative for angular2-highcharts).

-you can follow instruction for installation by there

-You will find the github project for more informations.

-With an example on Angular-Cli .


问:
Ajax call to passport does not run the authenticate middleware
This is the client side code to request authentication

```<code>    $("form#login-form").on("click", "#submit", function (e) {
      e.preventDefault();
      $.ajax({
        url: "/login",
        type: "POST",
        data: JSON.stringify({ email: $("#email").val(), password: $("#password").val() }),
        contentType: "application/json; charset=utf-8",
        dataType: "json",
      }).done(function (response, textStatus, jqXHR) {

        utils.clearErrors();
        location.reload();
      }).fail(function (jqXHR, textStatus, errorThrown) {

        // handle the error
        utils.handleError(jqXHR, textStatus, errorThrown);
      })
    });
</code>```

Below is the node API for passport authentication

```<code>    app.post('/login', passport.authenticate('local-login'), (req, res, next) => {
      return res.json({ user: req.user });
    });
</code>```

Passport.authenticate function does not call the middleware function in case of ajax call but if page is submitted using form then it works perfectly.

答:
the function you are u calling to authenticate is

```<code>passport.authenticate('local');
</code>```

It aslo depends the module you have included.
Please check the code here on https://github.com/rupalipemare/Mongoose-Demo, wherein there is complete example demonstrating passport authentication. Hope this helps

Body:
This is the client side code to request authentication

    $("form#login-form").on("click", "#submit", function (e) {
      e.preventDefault();
      $.ajax({
        url: "/login",
        type: "POST",
        data: JSON.stringify({ email: $("#email").val(), password: $("#password").val() }),
        contentType: "application/json; charset=utf-8",
        dataType: "json",
      }).done(function (response, textStatus, jqXHR) {

        utils.clearErrors();
        location.reload();
      }).fail(function (jqXHR, textStatus, errorThrown) {

        // handle the error
        utils.handleError(jqXHR, textStatus, errorThrown);
      })
    });

Below is the node API for passport authentication

    app.post('/login', passport.authenticate('local-login'), (req, res, next) => {
      return res.json({ user: req.user });
    });

Passport.authenticate function does not call the middleware function in case of ajax call but if page is submitted using form then it works perfectly.

Body:
the function you are u calling to authenticate is

passport.authenticate('local');

It aslo depends the module you have included.
Please check the code here on https://github.com/rupalipemare/Mongoose-Demo, wherein there is complete example demonstrating passport authentication. Hope this helps


问:
Jquery - fadeIn - jerky fadein
I've made a simple image switcher that fades different logos in and out. Example and full source code at http://bit.ly/ewrSgp . I fadeout the image, then queue a src attribute change, then fade back in. It seems to work smoothly for a while but after 20 seconds or so it starts to fade the image back in before changing the src, which then changes instantly and  looks ugly. Am I doing this right?

The code that runs the change is:

```<code>// fadeout old image, change to new and fadeback in.
// Call function changeimage again.
$(imToChange).fadeOut(600).queue(function (n) {
    jQuery(this).attr('src', newimageSrc);
    n();
}).fadeIn(1000, function () {
    setTimeout(function () {
        //recall image change function
        changeImage(indexToChange);
    }, o.delay);
});
</code>```

Thanks in advance.

答:
I saw some flickers, but not many. I noticed that it happened on a particular logo, I think the first time I saw it, but not the next time, which makes me think that once it's loaded, it's fine. Some thoughts:

Does this happen if the images are all local (and hence load very quickly)?

Have you tried preloading the images?

If preloading works, what do you think about putting them all in a sprite? Only one http request to make.

Title: Jquery - fadeIn - jerky fadein

Body:
I've made a simple image switcher that fades different logos in and out. Example and full source code at http://bit.ly/ewrSgp . I fadeout the image, then queue a src attribute change, then fade back in. It seems to work smoothly for a while but after 20 seconds or so it starts to fade the image back in before changing the src, which then changes instantly and  looks ugly. Am I doing this right?

The code that runs the change is:

// fadeout old image, change to new and fadeback in.
// Call function changeimage again.
$(imToChange).fadeOut(600).queue(function (n) {
    jQuery(this).attr('src', newimageSrc);
    n();
}).fadeIn(1000, function () {
    setTimeout(function () {
        //recall image change function
        changeImage(indexToChange);
    }, o.delay);
});

Thanks in advance.


问:
Cannot use smartcard reader with protocol type T=CL using pcsc-sharp
I recently acquired an ACS ACR122U card reader for use in an upcoming project. The only trouble is that I cannot send APDU commands to it using pcsc-sharp - I just get an PCSC.InvalidProtocolException every time I try, no matter what protocol I select as the argument when constructing the CommandApdu object. The reader uses a T=CL protocol according to the ACR122UTool included in the SDK. Is there any way I can use it from pcsc-sharp, or do I have to do it another way?

答: According to the source code, pcsc-sharp only supports the protocols T=0, T=1, T=15 and raw.</p>


问:
CSS trouble to place buttom border under logos top right of the page
I'm trying to put a border under my  logos at the top of the page right.

Before I'm adding position:absolute; to the div, my 2 logos are placed where I want them to be under the contact me top right. But the border on the left side of the page, when I put position:absolute; it moves but the logos jump down the page.

css #para {
  margin-right: 1.66%;
  float: right;
  font-family: indie flower;
  position: absolute;
  top: 0px;
  right: 0px;
}

.fb {
  width: 27px;
  float: right;
  right: 5px;
  position: absolute;
  margin-top: 3px;
  top: 35px;
}

#in {
  margin-top: 4px;
  width: 25px;
  float: right;
  position: absolute;
  right: 40px;
  top: 35px;
}

div {
  border-bottom: 1.5px solid red;
  width: 60px;
  right: 5px;
  position: absolute;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><p id="para">Contact me </p>
<div>
  <img class="fb" width="10" src="https://cdn3.iconfinder.com/data/icons/picons-social/57/46-facebook-512.png">
  <img id="in" width="25" src="https://image.flaticon.com/icons/png/512/69/69366.png">
</div></code>```

答:
Check This out. And one thing style elements by class not id

#left {
 margin-right: 1.66%;
 float: left;
 font-family: indie flower;
 top: 0px;
 right: 0px;
    }

.fb {
 width: 27px;
    }

#in {
 width: 25px;
    }

#right {
 float: right;
 text-align: center;
 border-bottom: 1.5px solid red;
 right: 5px;
    }```
<pre class="snippet-code-html lang-html prettyprint-override"><code><!DOCTYPE html>
<html>
<head>
<title>question reality.</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>

<body>
 <div id="right">
  <p>Contact me </p>
  <img id="in" width="25" src="https://image.flaticon.com/icons/png/512/69/69366.png">
  <img class="fb" width="10" src="https://cdn3.iconfinder.com/data/icons/picons-social/57/46-facebook-512.png">
 </div>
</body>
</html></code>```

Body:
I'm trying to put a border under my  logos at the top of the page right.

Before I'm adding position:absolute; to the div, my 2 logos are placed where I want them to be under the contact me top right. But the border on the left side of the page, when I put position:absolute; it moves but the logos jump down the page.

css #para {
  margin-right: 1.66%;
  float: right;
  font-family: indie flower;
  position: absolute;
  top: 0px;
  right: 0px;
}

.fb {
  width: 27px;
  float: right;
  right: 5px;
  position: absolute;
  margin-top: 3px;
  top: 35px;
}

#in {
  margin-top: 4px;
  width: 25px;
  float: right;
  position: absolute;
  right: 40px;
  top: 35px;
}

div {
  border-bottom: 1.5px solid red;
  width: 60px;
  right: 5px;
  position: absolute;
}

Contact me

Body:
Check This out. And one thing style elements by class not id

#left {
 margin-right: 1.66%;
 float: left;
 font-family: indie flower;
 top: 0px;
 right: 0px;
    }

.fb {
 width: 27px;
    }

#in {
 width: 25px;
    }

#right {
 float: right;
 text-align: center;
 border-bottom: 1.5px solid red;
 right: 5px;
    }

<!DOCTYPE html>
<html>
<head>
<title>question reality.</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>

<body>
 <div id="right">
  <p>Contact me </p>
  <img id="in" width="25" src="https://image.flaticon.com/icons/png/512/69/69366.png">
  <img class="fb" width="10" src="https://cdn3.iconfinder.com/data/icons/picons-social/57/46-facebook-512.png">
 </div>
</body>
</html>


问:
Azure AD and Spring Security with Oauth 2
We are trying to implement a SSO scheme using Azure AD and Spring security.
We found a few leads:

https://github.com/spring-guides/tut-spring-boot-oauth2

https://github.com/Pytry/azure-b2c-oauth2

But none of these tell the full story.
In fact we can't get passed the access token parsing, Spring has a different idea of what the JWT token should be.

Ideally we wouldn't want to write an SSO filter from scratch but override the Token Services to implement custom filtering for starters.

Has anyone successfully implemented this?
Any help would be appreciated.

答:
Update: I found an easier method. Just add a resource parameter after the userAuthorizationUri.

```<code>security:
  oauth2:
    client:
      ...
      userAuthorizationUri: https://login.microsoftonline.com/<<tenantId>>/oauth2/authorize?resource=https://graph.windows.net
      ...
</code>```

https://stackoverflow.com/a/45828135/2231168

Original answer

At my office we found a foreign blog post which lead us to the final implementation http://statemachine.hatenablog.com/entry/2016/04/19/155920

As a workaround, you had to add two classes to capture OAuth2RestTemplate and request enhancers. It works with spring boot 1.3.8 which contains spring 4.2.8, we couldn't make it work with higher version.

application.yml:

```<code>azure:
  resource: https://graph.windows.net
security:
  oauth2:
    client:
      clientId: <<your client id>>
      clientSecret: <<your client secret>>
      accessTokenUri: https://login.microsoftonline.com/<<tenantId>>/oauth2/token
      userAuthorizationUri: https://login.microsoftonline.com/<<tenantId>>/oauth2/authorize
      clientAuthenticationScheme: form
      scope: openid
    resource:
      userInfoUri: https://graph.windows.net/me?api-version=1.6
</code>```

AzureRequestEnhancer:

```<code>@Component
public class AzureRequestEnhancer implements RequestEnhancer {
    @Value("${azure.resource:null}")
    private String aadResource;

    @Override
    public void enhance(AccessTokenRequest request, OAuth2ProtectedResourceDetails resource, MultiValueMap<String, String> form, HttpHeaders headers) {
        if (!StringUtils.isEmpty(resource)) {
            form.set("resource", aadResource);
        }
    }
}
</code>```

AzureRequestEnhancerCustomizer:

```<code>@Component
public class AzureRequestEnhancerCustomizer {
    @Autowired
    private OAuth2RestTemplate userInfoRestTemplate;

    @Autowired
    private AzureRequestEnhancer azureRequestEnhancer;

    @PostConstruct
    public void testWiring() {
        AuthorizationCodeAccessTokenProvider authorizationCodeAccessTokenProvider = new AuthorizationCodeAccessTokenProvider();
        authorizationCodeAccessTokenProvider.setTokenRequestEnhancer(azureRequestEnhancer);
        userInfoRestTemplate.setAccessTokenProvider(authorizationCodeAccessTokenProvider);
    }
}
</code>```

The PostConstruct annotation is used on a method that needs to be executed after dependency injection is done to perform any initialization.

I hope this helps you with the implementation.

Body:
Update: I found an easier method. Just add a resource parameter after the userAuthorizationUri.

security:
  oauth2:
    client:
      ...
      userAuthorizationUri: https://login.microsoftonline.com/<<tenantId>>/oauth2/authorize?resource=https://graph.windows.net
      ...

https://stackoverflow.com/a/45828135/2231168

Original answer

At my office we found a foreign blog post which lead us to the final implementation http://statemachine.hatenablog.com/entry/2016/04/19/155920

As a workaround, you had to add two classes to capture OAuth2RestTemplate and request enhancers. It works with spring boot 1.3.8 which contains spring 4.2.8, we couldn't make it work with higher version.

application.yml:

azure:
  resource: https://graph.windows.net
security:
  oauth2:
    client:
      clientId: <<your client id>>
      clientSecret: <<your client secret>>
      accessTokenUri: https://login.microsoftonline.com/<<tenantId>>/oauth2/token
      userAuthorizationUri: https://login.microsoftonline.com/<<tenantId>>/oauth2/authorize
      clientAuthenticationScheme: form
      scope: openid
    resource:
      userInfoUri: https://graph.windows.net/me?api-version=1.6

AzureRequestEnhancer:

@Component
public class AzureRequestEnhancer implements RequestEnhancer {
    @Value("${azure.resource:null}")
    private String aadResource;

    @Override
    public void enhance(AccessTokenRequest request, OAuth2ProtectedResourceDetails resource, MultiValueMap<String, String> form, HttpHeaders headers) {
        if (!StringUtils.isEmpty(resource)) {
            form.set("resource", aadResource);
        }
    }
}

AzureRequestEnhancerCustomizer:

@Component
public class AzureRequestEnhancerCustomizer {
    @Autowired
    private OAuth2RestTemplate userInfoRestTemplate;

    @Autowired
    private AzureRequestEnhancer azureRequestEnhancer;

    @PostConstruct
    public void testWiring() {
        AuthorizationCodeAccessTokenProvider authorizationCodeAccessTokenProvider = new AuthorizationCodeAccessTokenProvider();
        authorizationCodeAccessTokenProvider.setTokenRequestEnhancer(azureRequestEnhancer);
        userInfoRestTemplate.setAccessTokenProvider(authorizationCodeAccessTokenProvider);
    }
}

The PostConstruct annotation is used on a method that needs to be executed after dependency injection is done to perform any initialization.

I hope this helps you with the implementation.


问:
Not asking admin to enter password for password protected pages
I am using the password protection feature from WordPress

https://codex.wordpress.org/Using_Password_Protection

to protect my pages with password.

So now when I see the page in front-end it asks for password no matter who is logged in. I was wondering if there is any way so that, admin can directly view the website on front-end without having to enter the password. But other users must.

I guess this is not possible. But still I want to be sure about it. So kindly let me know.

答:
```<code>add_filter( 'post_password_required', 'remove_password_requirement_for_admins', 0 );
function remove_password_requirement_for_admins( $required ) {
    if ( current_user_can( 'manage_options' ) ) {
        $required = false;
    }

    return $required;
}
</code>```

Add this to your theme's functions.php.

Body:
add_filter( 'post_password_required', 'remove_password_requirement_for_admins', 0 );
function remove_password_requirement_for_admins( $required ) {
    if ( current_user_can( 'manage_options' ) ) {
        $required = false;
    }

    return $required;
}

Add this to your theme's functions.php.


问:
BIRT: How to share reports to end user
I am new to BIRT. I created a report which has pie chart and a tabular report which has drill down. I run the report locally as "View report as HTML" option it works fine. When I save the report from browser as html format, and send the link to end user. He is not able to do a drill down on the report. How does end user see the report completely ? What are the steps to be taken ? Also how do I run the report from command line ?</p>

答: Check the URLs that you are using for the drill down to see if they are available from the remote machine.</p>

Title: BIRT: How to share reports to end user


问:
OpenAL Vs. AVAudioPlayer/AVAudioRecorder on iPhone
What is the difference between OpenAL and AVAudioPlayer on the iPhone? It seems that both can be used for playing/recording audio. When would you use either? What advantages/features does each provide?

Thanks!
-MT

答: OpenAL provides more control if you want to change the audio parameters like distance related, patter-based playback. AVAudioPlayer is a pretty basic one, but you can achieve similar with AudioQueues and AudioUnit using low level api's. In a nutshell, OpenAL does few things with snap of finger but then again it needs what you are looking at? Hope this helps.</p>


问:
Is there a possibility to redirect from my ionic2 app to an external app?
I want to create a button, which when is clicked, an external application is opened. For example: https://play.google.com/store/apps/details?id=com.fitbit.FitbitMobile&hl=fr

Is there a way to do that?

答:
You need to use a InAppBrowser plugin from Apache Cordova. Its explained here in detail : https://www.thepolyglotdeveloper.com/2014/07/launch-external-urls-ionicframework/.

Hope this will help.


问:
Angularjs Page Load always return to page 1
When I chosen a page number, localStorage store this page number. But I redirect to other page, then I reback this page. It always return to page 1. Because function vm.loadAll recall again after page load init().

```<code>(function() {
'use strict';

angular
    .module('eTransportApp')
    .controller('ImprestBillController', ImprestBillController);

ImprestBillController.$inject = ['$state', 'ImprestBill', 'ParseLinks', 'AlertService', '$scope', 'eTransportAppConstants', '$localStorage', 'DateUtils'];

function ImprestBillController($state, ImprestBill, ParseLinks, AlertService, $scope, eTransportAppConstants, $localStorage, DateUtils) {

    var vm = this;

    vm.predicate = 'id';
    vm.reverse = true;
    vm.itemsPerPage = eTransportAppConstants.itemsPerPage;
    vm.page = 1;

    vm.loadAll = function() {

        ImprestBill.query({
            page: vm.page > 0? vm.page - 1: vm.page,
            size: vm.itemsPerPage,
            sort: sort(),
            fromDate: DateUtils.convertLocalDateToServer($localStorage.searchForImprestBill.fromDate),
            toDate: DateUtils.convertLocalDateToServer($localStorage.searchForImprestBill.toDate),
            fromCost: $localStorage.searchForImprestBill.fromCost,
            toCost: $localStorage.searchForImprestBill.toCost,
            status: $localStorage.searchForImprestBill.status,
            clientId: $localStorage.searchForImprestBill.clientId
        }, onSuccess, onError);
        function sort() {
            return [vm.predicate + ',' + (vm.reverse ? 'desc' : 'asc')];
        }
        function onSuccess(data, headers) {
            vm.links = ParseLinks.parse(headers('link'));
            vm.totalItems = headers('X-Total-Count');
            vm.queryCount = vm.totalItems;
            vm.imprestBills = data;
            $localStorage.pageForImprestBill.page = vm.page;
            $localStorage.pageForImprestBill.predicate = vm.predicate;
            $localStorage.pageForImprestBill.reverse = vm.reverse
        }
        function onError(error) {
            AlertService.error(error.data.message);
        }
    }

    vm.clear = function() {
        $localStorage.searchForImprestBill = {};
        $localStorage.pageForImprestBill.page = 1;
        $localStorage.pageForImprestBill.reverse = true;
        $localStorage.pageForImprestBill.predicate = 'id';
        vm.reverse = true;
        vm.predicate = 'id';
        vm.loadAll();
    }

    /*$scope.$on(eTransportAppConstants.EVT_LOAD_RESULT_IMPREST_BILL, function(event){
        vm.loadAll();
    });*/

    function init() {
        if (!$localStorage.searchForImprestBill) {
            $localStorage.searchForImprestBill = {};
        }
        if (!$localStorage.pageForImprestBill) {
            $localStorage.pageForImprestBill = {};
        }
        vm.predicate = $localStorage.pageForImprestBill.predicate? $localStorage.pageForImprestBill.predicate: 'id';
        vm.reverse = $localStorage.pageForImprestBill.reverse? $localStorage.pageForImprestBill.reverse: true;
        vm.page = $localStorage.pageForImprestBill.page? $localStorage.pageForImprestBill.page: 1;
        vm.loadAll();
    }

    vm.showClearBtn = function() {
         return ($localStorage.searchForImprestBill && JSON.stringify($localStorage.searchForImprestBill) !== '{}');
    }

    init();
}
</code>```

})();

```<code><div>
<h2 data-translate="eTransportApp.imprestBill.home.title">Imprest Bills</h2>
<jhi-alert></jhi-alert>
<div class="container-fluid">
    <div class="row">
        <div class="col-xs-12 no-padding-right no-padding-left">
            <div class="input-group no-padding-left">
                <button class="btn btn-info" ui-sref="imprest-bill.search" >
                    <span class="glyphicon glyphicon-search"></span>
                    <span  data-translate="eTransportApp.imprestBill.home.searchLabel">
                        Search new Imprest Bill
                    </span>
                </button>
                    <button class="btn btn-info " ng-click="vm.clear()" ng-if="vm.showClearBtn()">
                        <span class="glyphicon glyphicon-trash"></span>
                    </button>
            </div>
        </div>
    </div>

    <div class="row">
        <div class="col-xs-12 no-padding-left">
            <button class="btn btn-primary" ui-sref="imprest-bill.new" >
                <span class="glyphicon glyphicon-plus"></span>
                <span  data-translate="eTransportApp.imprestBill.home.createLabel">
                    Create new Imprest Bill
                </span>
            </button>
        </div>
    </div>
</div>
<br/>
<div class="table-responsive">
    <table class="jh-table table table-striped">
        <thead>
            <tr jh-sort="vm.predicate" ascending="vm.reverse" callback="vm.loadAll()">
                <th jh-sort-by="id"><span data-translate="global.field.id">ID</span> <span class="glyphicon glyphicon-sort"></span></th>
                <th jh-sort-by="date"><span data-translate="eTransportApp.imprestBill.date">Date</span> <span class="glyphicon glyphicon-sort"></span></th>
                <th jh-sort-by="totalCost"><span data-translate="eTransportApp.imprestBill.totalCost">Total Cost</span> <span class="glyphicon glyphicon-sort"></span></th>
                <th jh-sort-by="status"><span data-translate="eTransportApp.imprestBill.status">Status</span> <span class="glyphicon glyphicon-sort"></span></th>
                <th jh-sort-by="paidDate"><span data-translate="eTransportApp.imprestBill.paidDate">Paid Date</span> <span class="glyphicon glyphicon-sort"></span></th>
                <th jh-sort-by="note"><span data-translate="eTransportApp.imprestBill.note">Note</span> <span class="glyphicon glyphicon-sort"></span></th>
                <th jh-sort-by="client.name"><span data-translate="eTransportApp.imprestBill.client">Client</span> <span class="glyphicon glyphicon-sort"></span></th>
                <th></th>
            </tr>
        </thead>
        <tbody>
            <tr ng-repeat="imprestBill in vm.imprestBills track by imprestBill.id">
                <td><a ui-sref="imprest-bill.edit({id:imprestBill.id})">{{imprestBill.id}}</a></td>
                    <td>{{imprestBill.date | date:'dd/MM/yyyy'}}</td>
                <td>{{imprestBill.totalCost | number}}</td>
                <td data-translate="{{'eTransportApp.ImprestBillStatus.' + imprestBill.status}}">{{imprestBill.status}}</td>
                <td>{{imprestBill.paidDate | date:'dd/MM/yyyy'}}</td>
                <td>{{imprestBill.note}}</td>
                <td>
                    <a ui-sref="client-detail({id:imprestBill.client.id})">{{imprestBill.client.nickName}}</a>
                </td>
                <td class="text-right">
                    <div class="btn-group flex-btn-group-container">
                        <button type="submit"
                                ui-sref="imprest-bill.edit({id:imprestBill.id})"
                                class="btn btn-primary btn-sm">
                            <span class="glyphicon glyphicon-pencil"></span>
                            <span class="hidden-sm-down" data-translate="entity.action.edit"></span>
                        </button>
                        <button type="submit"
                                ui-sref="imprest-bill.delete({id:imprestBill.id})"
                                class="btn btn-danger btn-sm">
                            <span class="glyphicon glyphicon-remove-circle"></span>
                            <span class="hidden-sm-down" data-translate="entity.action.delete"></span>
                        </button>
                    </div>
                </td>
            </tr>
        </tbody>
    </table>
</div>
<div class="text-center">
    <uib-pagination boundary-links="true"
        class="pagination-sm"
        total-items="vm.totalItems"
        ng-model="vm.page"
        items-per-page="vm.itemsPerPage"
        max-size="20"
        rotate="false"
        ng-change="vm.loadAll()">
    </uib-pagination>
</div>
</code>```

答:
```<code><div class="text-center" ng-if="vm.totalItems">
    <uib-pagination boundary-links="true"
        class="pagination-sm"
        total-items="vm.totalItems"
        ng-model="vm.page"
        items-per-page="vm.itemsPerPage"
        max-size="20"
        rotate="false"
        ng-change="vm.loadAll()">
    </uib-pagination>
</div>
</code>```

Body:
When I chosen a page number, localStorage store this page number. But I redirect to other page, then I reback this page. It always return to page 1. Because function vm.loadAll recall again after page load init().

(function() {
'use strict';

angular
    .module('eTransportApp')
    .controller('ImprestBillController', ImprestBillController);

ImprestBillController.$inject = ['$state', 'ImprestBill', 'ParseLinks', 'AlertService', '$scope', 'eTransportAppConstants', '$localStorage', 'DateUtils'];

function ImprestBillController($state, ImprestBill, ParseLinks, AlertService, $scope, eTransportAppConstants, $localStorage, DateUtils) {

    var vm = this;

    vm.predicate = 'id';
    vm.reverse = true;
    vm.itemsPerPage = eTransportAppConstants.itemsPerPage;
    vm.page = 1;

    vm.loadAll = function() {

        ImprestBill.query({
            page: vm.page > 0? vm.page - 1: vm.page,
            size: vm.itemsPerPage,
            sort: sort(),
            fromDate: DateUtils.convertLocalDateToServer($localStorage.searchForImprestBill.fromDate),
            toDate: DateUtils.convertLocalDateToServer($localStorage.searchForImprestBill.toDate),
            fromCost: $localStorage.searchForImprestBill.fromCost,
            toCost: $localStorage.searchForImprestBill.toCost,
            status: $localStorage.searchForImprestBill.status,
            clientId: $localStorage.searchForImprestBill.clientId
        }, onSuccess, onError);
        function sort() {
            return [vm.predicate + ',' + (vm.reverse ? 'desc' : 'asc')];
        }
        function onSuccess(data, headers) {
            vm.links = ParseLinks.parse(headers('link'));
            vm.totalItems = headers('X-Total-Count');
            vm.queryCount = vm.totalItems;
            vm.imprestBills = data;
            $localStorage.pageForImprestBill.page = vm.page;
            $localStorage.pageForImprestBill.predicate = vm.predicate;
            $localStorage.pageForImprestBill.reverse = vm.reverse
        }
        function onError(error) {
            AlertService.error(error.data.message);
        }
    }

    vm.clear = function() {
        $localStorage.searchForImprestBill = {};
        $localStorage.pageForImprestBill.page = 1;
        $localStorage.pageForImprestBill.reverse = true;
        $localStorage.pageForImprestBill.predicate = 'id';
        vm.reverse = true;
        vm.predicate = 'id';
        vm.loadAll();
    }

    /*$scope.$on(eTransportAppConstants.EVT_LOAD_RESULT_IMPREST_BILL, function(event){
        vm.loadAll();
    });*/

    function init() {
        if (!$localStorage.searchForImprestBill) {
            $localStorage.searchForImprestBill = {};
        }
        if (!$localStorage.pageForImprestBill) {
            $localStorage.pageForImprestBill = {};
        }
        vm.predicate = $localStorage.pageForImprestBill.predicate? $localStorage.pageForImprestBill.predicate: 'id';
        vm.reverse = $localStorage.pageForImprestBill.reverse? $localStorage.pageForImprestBill.reverse: true;
        vm.page = $localStorage.pageForImprestBill.page? $localStorage.pageForImprestBill.page: 1;
        vm.loadAll();
    }

    vm.showClearBtn = function() {
         return ($localStorage.searchForImprestBill && JSON.stringify($localStorage.searchForImprestBill) !== '{}');
    }

    init();
}

})();

Imprest Bills

<jhi-alert></jhi-alert>

                <button class="btn btn-info" ui-sref="imprest-bill.search" >

                        Search new Imprest Bill

                </button>
                    <button class="btn btn-info " ng-click="vm.clear()" ng-if="vm.showClearBtn()">

                    </button>

            <button class="btn btn-primary" ui-sref="imprest-bill.new" >

                    Create new Imprest Bill

            </button>

                ID
                Date
                Total Cost
                Status
                Paid Date
                Note
                Client

                {{imprestBill.id}}
                    {{imprestBill.date | date:'dd/MM/yyyy'}}
                {{imprestBill.totalCost | number}}
                {{imprestBill.status}}
                {{imprestBill.paidDate | date:'dd/MM/yyyy'}}
                {{imprestBill.note}}

                    {{imprestBill.client.nickName}}

                        <button type="submit"
                                ui-sref="imprest-bill.edit({id:imprestBill.id})"
                                class="btn btn-primary btn-sm">

                        </button>
                        <button type="submit"
                                ui-sref="imprest-bill.delete({id:imprestBill.id})"
                                class="btn btn-danger btn-sm">

                        </button>

    <uib-pagination boundary-links="true"
        class="pagination-sm"
        total-items="vm.totalItems"
        ng-model="vm.page"
        items-per-page="vm.itemsPerPage"
        max-size="20"
        rotate="false"
        ng-change="vm.loadAll()">
    </uib-pagination>


问:
How to access a row in a data frame by using first column values in R
```<code>    intercatedData                 n

1 Completed Degree in 2 Years.0    2
2  Retained to Midyear Year 2.0    1
3 Retained to Start of Year 2.0    1
4  Retained to Midyear Year 2.1    1
5 Retained to Start of Year 2.1    1
</code>```

Here is the data frame(mydf) that i am using.

Now i want access first row value (that is 2) by its name (Completed Degree in 2 Years.0). I am able to access the value by using print(mydf$n[1]) but  right I would like to access the value by name instead of by index 1.

How can I access the value by name instead of by index ?

答:
```<code>mydf[ mydf$intercatedData == 'Completed Degree in 2 Years.0', ]
</code>```

A DATA record in a dataframe has a row AND column and so can be referred as so

mydf[2,3] will give me record in 2nd row and 3rd column for dataframe named mydf

mydf[2,] will give me record in 2nd row and all columns for that for dataframe named mydf

mydf[,3] will give me records in 3rd column for dataframe named mydf

This dataframe property can now be used for conditional selection

```<code>mydf[ mydf$intercatedData == 'Completed Degree in 2 Years.0', ]
</code>```

Says give me all rows where the value for mydf$intercatedData is 'Completed Degree in 2 Years.0' and all columns

Body:
    intercatedData                 n

1 Completed Degree in 2 Years.0    2
2  Retained to Midyear Year 2.0    1
3 Retained to Start of Year 2.0    1
4  Retained to Midyear Year 2.1    1
5 Retained to Start of Year 2.1    1

Here is the data frame(mydf) that i am using.

Now i want access first row value (that is 2) by its name (Completed Degree in 2 Years.0). I am able to access the value by using print(mydf$n[1]) but  right I would like to access the value by name instead of by index 1.

How can I access the value by name instead of by index ?

Body:
mydf[ mydf$intercatedData == 'Completed Degree in 2 Years.0', ]

A DATA record in a dataframe has a row AND column and so can be referred as so

mydf[2,3] will give me record in 2nd row and 3rd column for dataframe named mydf

mydf[2,] will give me record in 2nd row and all columns for that for dataframe named mydf

mydf[,3] will give me records in 3rd column for dataframe named mydf

This dataframe property can now be used for conditional selection

mydf[ mydf$intercatedData == 'Completed Degree in 2 Years.0', ]

Says give me all rows where the value for mydf$intercatedData is 'Completed Degree in 2 Years.0' and all columns


问:
What message causes a button to send a WM_COMMAND message
I know that a Button, when clicked, sends the WM_COMMAND message to it's parent, but what message does it receive that makes it send this message? I am overriding the default WndProc of a button and the button does not receive the WM_COMMAND message, so I need to know what message causes a button to send the WM_COMMAND message so I can replicate that functionality.</p>

答: I seem to recall it's WM_LBUTTONUP, but use a Spy program to find out for sure.</p>


问:
detecting KEY_BACKSPACE in ncurses
I am writing a ncurses program, and I need to detect KEY_BACKSPACE. I have test the program under 2 linux distros.

Under suse, it runs OK. But under archlinux, KEY_BACKSPACE is 263, but what I print from program got 127.

For suse, they're both 263.

I am using int ch = wgetch(somw_window) to get the keypress.

答:
It depends: whether Backspace sends ASCII BS (8) or ASCII DEL (127) is configurable with many terminal emulators, such as xterm.  The terminal description (selected by the TERM environment variable) has to be consistent with the terminal's configuration, otherwise curses will not see that the kbs capability (backspace-key) matches what your keyboard actually sends, and you'll just get the 8/127 value.

Some terminals send only one or the other (but most of the hard-coded ones which you'll encounter, use ASCII DEL).

Further reading (xterm FAQ):

Why doesn't my delete key work?

Why did my delete key stop working?

Well, how can I set my delete key?

Title: detecting KEY_BACKSPACE in ncurses


问:
How to make client open save file dialog when downloading a file
I want the browser to show or open a file save dialog box to save the file I send when user clicks on the download file button.

My server side code for download:

```<code>func Download(w http.ResponseWriter, r *http.Request) {
    url := "http://upload.wikimedia.org/wikipedia/en/b/bc/Wiki.png"

    timeout := time.Duration(5) * time.Second
    transport := &http.Transport{
        ResponseHeaderTimeout: timeout,
        Dial: func(network, addr string) (net.Conn, error) {
            return net.DialTimeout(network, addr, timeout)
        },
        DisableKeepAlives: true,
    }
    client := &http.Client{
        Transport: transport,
    }
    resp, err := client.Get(url)
    if err != nil {
        fmt.Println(err)
    }
    defer resp.Body.Close()

    //copy the relevant headers. If you want to preserve the downloaded file name, extract it with go's url parser.
    w.Header().Set("Content-Disposition", "form-data; filename=Wiki.png")
    w.Header().Set("Content-Type", r.Header.Get("Content-Type"))
    w.Header().Set("Content-Length", r.Header.Get("Content-Length"))
    //dialog.File().Filter("XML files", "xml").Title("Export to XML").Save()
    //stream the body to the client without fully loading it into memory
    io.Copy(w, resp.Body)
}
</code>```

答:
If you intend the response to be saved at the client side, use the "attachment" content disposition type. This is detailed in rfc2183, section 2.2:

2.2  The Attachment Disposition Type

Bodyparts can be designated `attachment' to indicate that they are
     separate from the main body of the mail message, and that their
     display should not be automatic, but contingent upon some further
     action of the user.  The MUA might instead present the user of a
     bitmap terminal with an iconic representation of the attachments, or,
     on character terminals, with a list of attachments from which the
     user could select for viewing or storage.

So set it like this:

```<code>w.Header().Set("Content-Disposition", "attachment; filename=Wiki.png")
</code>```

Also when setting headers of your response writer w, copy the fields from the response you make, not from the incoming request:

```<code>w.Header().Set("Content-Type", resp.Header.Get("Content-Type"))
w.Header().Set("Content-Length", resp.Header.Get("Content-Length"))
</code>```

Also note that the headers are more like a "proposal" to the browser. That's one thing you suggest the response is a file to be saved, but from the server side you can't force the browser to really save the response to a file and not display it.

See related question: Golang beego output to csv file dumps the data to browser but not dump to file

Body:
I want the browser to show or open a file save dialog box to save the file I send when user clicks on the download file button.

My server side code for download:

func Download(w http.ResponseWriter, r *http.Request) {
    url := "http://upload.wikimedia.org/wikipedia/en/b/bc/Wiki.png"

    timeout := time.Duration(5) * time.Second
    transport := &http.Transport{
        ResponseHeaderTimeout: timeout,
        Dial: func(network, addr string) (net.Conn, error) {
            return net.DialTimeout(network, addr, timeout)
        },
        DisableKeepAlives: true,
    }
    client := &http.Client{
        Transport: transport,
    }
    resp, err := client.Get(url)
    if err != nil {
        fmt.Println(err)
    }
    defer resp.Body.Close()

    //copy the relevant headers. If you want to preserve the downloaded file name, extract it with go's url parser.
    w.Header().Set("Content-Disposition", "form-data; filename=Wiki.png")
    w.Header().Set("Content-Type", r.Header.Get("Content-Type"))
    w.Header().Set("Content-Length", r.Header.Get("Content-Length"))
    //dialog.File().Filter("XML files", "xml").Title("Export to XML").Save()
    //stream the body to the client without fully loading it into memory
    io.Copy(w, resp.Body)
}

Body:
If you intend the response to be saved at the client side, use the "attachment" content disposition type. This is detailed in rfc2183, section 2.2:

2.2  The Attachment Disposition Type

Bodyparts can be designated `attachment' to indicate that they are
     separate from the main body of the mail message, and that their
     display should not be automatic, but contingent upon some further
     action of the user.  The MUA might instead present the user of a
     bitmap terminal with an iconic representation of the attachments, or,
     on character terminals, with a list of attachments from which the
     user could select for viewing or storage.

So set it like this:

w.Header().Set("Content-Disposition", "attachment; filename=Wiki.png")

Also when setting headers of your response writer w, copy the fields from the response you make, not from the incoming request:

w.Header().Set("Content-Type", resp.Header.Get("Content-Type"))
w.Header().Set("Content-Length", resp.Header.Get("Content-Length"))

Also note that the headers are more like a "proposal" to the browser. That's one thing you suggest the response is a file to be saved, but from the server side you can't force the browser to really save the response to a file and not display it.

See related question: Golang beego output to csv file dumps the data to browser but not dump to file


问:
Styling "page-break-after" works on Firefox, but neither in Chrome or Internet Explorer
We have this page that the client uses for printing out some data onto paper. It loops through a list of MVC models, and every new iteration should be printed on a new page.

In cshtml I have built this (simplified):

```<code>@foreach (var header in Model.ReportHeaders)
{
    <div style="page-break-after:always">
        <div>
            <img src="Logo-image-url" />
            <h2>Misc Logo stuff</h2>
        </div>

        <div>Report header information</div>

        <div>
            <table>
                <thead>
                    <th>Column headers</th>
                    <th>Column headers</th>
                    <th>Column headers</th>
                </thead>
                <tbody>
                    @foreach (var details in header.ReportDetails)
                    {
                        <td>All the data here</td>
                        <td>All the data here</td>
                        <td>All the data here</td>
                    }
                </tbody>
            </table>
        </div>
    </div>
}
</code>```

But somehow, however I try to rearrange the page-break-after styling neither Chrome or IE wants to start on a new page when printing it. Am I using it incorrectly, or why doesn't it work as intended?

答: This whole page was indeed, as samAlvin commented on my question, inheriting a layout page where both a div with class "page" and another div with the ID "main" had the styling float:left. I temporarily removed the float styling on these two divs just before the print function and then re-added it afterwards. The page has a small hickup during that millisecond, but at least the print now works correctly in all browsers. Thanks for the quick help!</p>

Body:
We have this page that the client uses for printing out some data onto paper. It loops through a list of MVC models, and every new iteration should be printed on a new page.

In cshtml I have built this (simplified):

@foreach (var header in Model.ReportHeaders)
{

Misc Logo stuff

Report header information

                    Column headers
                    Column headers
                    Column headers

                    @foreach (var details in header.ReportDetails)
                    {
                        All the data here
                        All the data here
                        All the data here
                    }

}

But somehow, however I try to rearrange the page-break-after styling neither Chrome or IE wants to start on a new page when printing it. Am I using it incorrectly, or why doesn't it work as intended?


问:
SQL Insert command throwing errors

```<code> System.Data.SqlClient.SqlException occurred   HResult=0x80131904   Message=Cannot insert explicit value for identity column in table 'DriversDetailsTable' when IDENTITY_INSERT is set to OFF.   Source=.Net SqlClient Data Provider   StackTrace: <Cannot evaluate the exception stack trace>
</code>```

I keep getting the above error when i run my code, not sure why. Here is my code:

```<code>SqlConnection conn = new SqlConnection(@"Data Source = ComputerName\SQLEXPRESS;Initial Catalog = Drivers;Trusted_Connection=True;");
        conn.Open();

        SqlDataAdapter adapter = new SqlDataAdapter();

        SqlCommand command = new SqlCommand($@"INSERT INTO DriversDetailsTable (name, Id, DateJoined) VALUES ('Driver4', 1, '2017-07-06')", conn);
        command.ExecuteNonQuery();

        conn.Close();
</code>```

答:
If you do want to be able to insert the id for some reason you need to set IDENTITY_INSERT to ON like so:

```<code>Set Identity_Insert DriverDetailsTable ON;
</code>```

This can be done just for that particular command like so:

```<code>SqlCommand command = new SqlCommand($@"
Set Identity_Insert DriverDetailsTable ON;
INSERT INTO DriversDetailsTable (name, Id, DateJoined) VALUES ('Driver4', 1, '2017-07-06');
Set Identity_Insert DriverDetailsTable OFF;", conn);
</code>```

Title: SQL Insert command throwing errors

Body:
 System.Data.SqlClient.SqlException occurred   HResult=0x80131904   Message=Cannot insert explicit value for identity column in table 'DriversDetailsTable' when IDENTITY_INSERT is set to OFF.   Source=.Net SqlClient Data Provider   StackTrace: <Cannot evaluate the exception stack trace>

I keep getting the above error when i run my code, not sure why. Here is my code:

SqlConnection conn = new SqlConnection(@"Data Source = ComputerName\SQLEXPRESS;Initial Catalog = Drivers;Trusted_Connection=True;");
        conn.Open();

        SqlDataAdapter adapter = new SqlDataAdapter();

        SqlCommand command = new SqlCommand($@"INSERT INTO DriversDetailsTable (name, Id, DateJoined) VALUES ('Driver4', 1, '2017-07-06')", conn);
        command.ExecuteNonQuery();

        conn.Close();

Body:
If you do want to be able to insert the id for some reason you need to set IDENTITY_INSERT to ON like so:

Set Identity_Insert DriverDetailsTable ON;

This can be done just for that particular command like so:

SqlCommand command = new SqlCommand($@"
Set Identity_Insert DriverDetailsTable ON;
INSERT INTO DriversDetailsTable (name, Id, DateJoined) VALUES ('Driver4', 1, '2017-07-06');
Set Identity_Insert DriverDetailsTable OFF;", conn);