问:
Inflate Exception in Google Map Fragment in ViewPager with TabLayout
I made an app in which I have displayed a Google Map with GPS location marker on my location. This map is on the 1st tab, and I also have two other tabs as shown in picture below

Now I am facing an issue i.e. when I move from tab 1 to tab 2 and then to tab 1 it works perfectly, but when I move to tab 3 and then move back to tab 1 or tab 2, the app crashes and giving the following exception in LogCat:

```<code>01-27 18:35:26.190 9414-9414/com.example.accurat.faisal E/AndroidRuntime: FATAL EXCEPTION: main
  Process: com.example.accurat.faisal, PID: 9414
  android.view.InflateException: Binary XML file line #26: Binary XML file line #26: Error inflating class fragment
      at android.view.LayoutInflater.inflate(LayoutInflater.java:551)
      at android.view.LayoutInflater.inflate(LayoutInflater.java:429)
      at com.example.accurat.faisal.MyLocation.onCreateView(MyLocation.java:62)
      at android.support.v4.app.Fragment.performCreateView(Fragment.java:2184)
      at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1298)
      at android.support.v4.app.FragmentManagerImpl.moveFragmentsToInvisible(FragmentManager.java:2323)
      at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2136)
      at android.support.v4.app.FragmentManagerImpl.optimizeAndExecuteOps(FragmentManager.java:2092)
      at android.support.v4.app.FragmentManagerImpl.execSingleAction(FragmentManager.java:1969)
      at android.support.v4.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:620)
      at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:143)
      at android.support.v4.view.ViewPager.populate(ViewPager.java:1268)
      at android.support.v4.view.ViewPager.populate(ViewPager.java:1116)
      at android.support.v4.view.ViewPager$3.run(ViewPager.java:273)
      at android.view.Choreographer$CallbackRecord.run(Choreographer.java:911)
      at android.view.Choreographer.doCallbacks(Choreographer.java:686)
      at android.view.Choreographer.doFrame(Choreographer.java:619)
      at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897)
      at android.os.Handler.handleCallback(Handler.java:739)
      at android.os.Handler.dispatchMessage(Handler.java:95)
      at android.os.Looper.loop(Looper.java:148)
      at android.app.ActivityThread.main(ActivityThread.java:7325)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
   Caused by: android.view.InflateException: Binary XML file line #26: Error inflating class fragment
      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:794)
      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:716)
      at android.view.LayoutInflater.rInflate(LayoutInflater.java:847)
      at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810)
      at android.view.LayoutInflater.inflate(LayoutInflater.java:527)
      at android.view.LayoutInflater.inflate(LayoutInflater.java:429)
      at com.example.accurat.faisal.MyLocation.onCreateView(MyLocation.java:62)
      at android.support.v4.app.Fragment.performCreateView(Fragment.java:2184)
      at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1298)
      at android.support.v4.app.FragmentManagerImpl.moveFragmentsToInvisible(FragmentManager.java:2323)
      at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2136)
      at android.support.v4.app.FragmentManagerImpl.optimizeAndExecuteOps(FragmentManager.java:2092)
      at android.support.v4.app.FragmentManagerImpl.execSingleAction(FragmentManager.java:1969)
      at android.support.v4.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:620)
      at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:143)
      at android.support.v4.view.ViewPager.populate(ViewPager.java:1268)
      at android.support.v4.view.ViewPager.populate(ViewPager.java:1116)
      at android.support.v4.view.ViewPager$3.run(ViewPager.java:273)
      at android.view.Choreographer$CallbackRecord.run(Choreographer.java:911)
      at android.view.Choreographer.doCallbacks(Choreographer.java:686)
      at android.view.Choreographer.doFrame(Choreographer.java:619)
      at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897)
      at android.os.Handler.handleCallback(Handler.java:739)
      at android.os.Handler.dispatchMessage(Handler.java:95)
      at android.os.Looper.loop(Looper.java:148)
      at android.app.ActivityThread.main(ActivityThread.java:7325)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
   Caused by: java.lang.IllegalArgumentException: Binary XML file line #26: Duplicate id 0x7f10010d, tag null, or parent id 0xffffffff with another fragment for com.google.android.gms.maps.SupportMapFragment
      at android.support.v4.app.FragmentManagerImpl.onCreateView(FragmentManager.java:3364)
      at android.support.v4.view.LayoutInflaterCompatHC$FactoryWrapperHC.onCreateView(LayoutInflaterCompatHC.java:47)
      at android.view.LayoutInflater$FactoryMerger.onCreateView(LayoutInflater.java:192)
      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:758)
      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:716)
      at android.view.LayoutInflater.rInflate(LayoutInflater.java:847)
      at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810)
      at android.view.LayoutInflater.inflate(LayoutInflater.java:527)
      at android.view.LayoutInflater.inflate(LayoutInflater.java:429)
      at com.example.accurat.faisal.MyLocation.onCreateView(MyLocation.java:62)
      at android.support.v4.app.Fragment.performCreateView(Fragment.java:2184)
      at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1298)
      at android.support.v4.app.FragmentManagerImpl.moveFragmentsToInvisible(FragmentManager.java:2323)
      at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2136)
      at android.support.v4.app.FragmentManagerImpl.optimizeAndExecuteOps(FragmentManager.java:2092)
      at android.support.v4.app.FragmentManagerImpl.execSingleAction(FragmentManager.java:1969)
      at android.support.v4.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:620)
      at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:143)
      at android.support.v4.view.ViewPager.populate(ViewPager.java:1268)
      at android.support.v4.view.ViewPager.populate(ViewPager.java:1116)
      at android.support.v4.view.ViewPager$3.run(ViewPager.java:273)
      at android.view.Choreographer$CallbackRecord.run(Choreographer.java:911)
      at android.view.Choreographer.doCallbacks(Choreographer.java:686)
      at android.view.Choreographer.doFrame(Choreographer.java:619)
      at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897)
      at android.os.Handler.handleCallback(Handler.java:739)
      at android.os.Handler.dispatchMessage(Handler.java:95)
      at android.os.Looper.loop(Looper.java:148)
      at android.app.ActivityThread.main(ActivityThread.java:7325)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) at
    com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
</code>```

It shows error at below point:

```<code>// inflat and return the layout
    View rootView = inflater.inflate(R.layout.my_location, container, false);
</code>```

Whether I choose any tab it always shows me an error on the above line, i.e. when I go to my pictures tab and came back to the camera or my location tab it always shows me the error on the above line.

Below is my layout

```<code><manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.accurat.faisal">

<permission android:name="com.example.accurat.faisal.permission.MAPS_RECEIVE"
    android:protectionLevel="signature"/>

<uses-permission android:name="com.example.accurat.faisal.permission.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>

<uses-feature
    android:glEsVersion="0x00020000"
    android:required="true"
    />

<application
    android:name=""
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <meta-data
        android:name="com.google.android.geo.API_KEY"
        android:value="MY_KEY"
        />

    <meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />
    <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:theme="@style/AppTheme.NoActionBar">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>
</code>```

Below is my layout code

```<code><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.accurat.faisal.MyLocation$PlaceholderFragment">

<TextView
    android:id="@+id/section_label"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBottom="@+id/section_label"
    android:id="@+id/textView"
    android:layout_alignParentRight="true"
    android:layout_alignParentEnd="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:textAppearance="@style/TextAppearance.AppCompat.Body2" />

<fragment xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/map"
    tools:context="com.example.app.MyLocation"
    android:name="com.google.android.gms.maps.SupportMapFragment"
    android:layout_below="@+id/section_label" />
</code>```

I have searched and found many answers on them (1, 2, 3), but couldn't able to find any help on it

I am stuck to it, Any help would be appreciated

答:
I respect all the answers but i found this one liner solution:
If n Is the Number of tabs then:

mViewPager.setOffscreenPageLimit(n);

Example:
In case mentioned :

mViewPager.setOffscreenPageLimit(2);

View pager implements a queue so, you don't have to let it remove that fragment. onCreateView is called only once.

Body:
I made an app in which I have displayed a Google Map with GPS location marker on my location. This map is on the 1st tab, and I also have two other tabs as shown in picture below

Now I am facing an issue i.e. when I move from tab 1 to tab 2 and then to tab 1 it works perfectly, but when I move to tab 3 and then move back to tab 1 or tab 2, the app crashes and giving the following exception in LogCat:

01-27 18:35:26.190 9414-9414/com.example.accurat.faisal E/AndroidRuntime: FATAL EXCEPTION: main
  Process: com.example.accurat.faisal, PID: 9414
  android.view.InflateException: Binary XML file line #26: Binary XML file line #26: Error inflating class fragment
      at android.view.LayoutInflater.inflate(LayoutInflater.java:551)
      at android.view.LayoutInflater.inflate(LayoutInflater.java:429)
      at com.example.accurat.faisal.MyLocation.onCreateView(MyLocation.java:62)
      at android.support.v4.app.Fragment.performCreateView(Fragment.java:2184)
      at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1298)
      at android.support.v4.app.FragmentManagerImpl.moveFragmentsToInvisible(FragmentManager.java:2323)
      at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2136)
      at android.support.v4.app.FragmentManagerImpl.optimizeAndExecuteOps(FragmentManager.java:2092)
      at android.support.v4.app.FragmentManagerImpl.execSingleAction(FragmentManager.java:1969)
      at android.support.v4.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:620)
      at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:143)
      at android.support.v4.view.ViewPager.populate(ViewPager.java:1268)
      at android.support.v4.view.ViewPager.populate(ViewPager.java:1116)
      at android.support.v4.view.ViewPager$3.run(ViewPager.java:273)
      at android.view.Choreographer$CallbackRecord.run(Choreographer.java:911)
      at android.view.Choreographer.doCallbacks(Choreographer.java:686)
      at android.view.Choreographer.doFrame(Choreographer.java:619)
      at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897)
      at android.os.Handler.handleCallback(Handler.java:739)
      at android.os.Handler.dispatchMessage(Handler.java:95)
      at android.os.Looper.loop(Looper.java:148)
      at android.app.ActivityThread.main(ActivityThread.java:7325)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
   Caused by: android.view.InflateException: Binary XML file line #26: Error inflating class fragment
      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:794)
      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:716)
      at android.view.LayoutInflater.rInflate(LayoutInflater.java:847)
      at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810)
      at android.view.LayoutInflater.inflate(LayoutInflater.java:527)
      at android.view.LayoutInflater.inflate(LayoutInflater.java:429)
      at com.example.accurat.faisal.MyLocation.onCreateView(MyLocation.java:62)
      at android.support.v4.app.Fragment.performCreateView(Fragment.java:2184)
      at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1298)
      at android.support.v4.app.FragmentManagerImpl.moveFragmentsToInvisible(FragmentManager.java:2323)
      at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2136)
      at android.support.v4.app.FragmentManagerImpl.optimizeAndExecuteOps(FragmentManager.java:2092)
      at android.support.v4.app.FragmentManagerImpl.execSingleAction(FragmentManager.java:1969)
      at android.support.v4.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:620)
      at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:143)
      at android.support.v4.view.ViewPager.populate(ViewPager.java:1268)
      at android.support.v4.view.ViewPager.populate(ViewPager.java:1116)
      at android.support.v4.view.ViewPager$3.run(ViewPager.java:273)
      at android.view.Choreographer$CallbackRecord.run(Choreographer.java:911)
      at android.view.Choreographer.doCallbacks(Choreographer.java:686)
      at android.view.Choreographer.doFrame(Choreographer.java:619)
      at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897)
      at android.os.Handler.handleCallback(Handler.java:739)
      at android.os.Handler.dispatchMessage(Handler.java:95)
      at android.os.Looper.loop(Looper.java:148)
      at android.app.ActivityThread.main(ActivityThread.java:7325)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
   Caused by: java.lang.IllegalArgumentException: Binary XML file line #26: Duplicate id 0x7f10010d, tag null, or parent id 0xffffffff with another fragment for com.google.android.gms.maps.SupportMapFragment
      at android.support.v4.app.FragmentManagerImpl.onCreateView(FragmentManager.java:3364)
      at android.support.v4.view.LayoutInflaterCompatHC$FactoryWrapperHC.onCreateView(LayoutInflaterCompatHC.java:47)
      at android.view.LayoutInflater$FactoryMerger.onCreateView(LayoutInflater.java:192)
      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:758)
      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:716)
      at android.view.LayoutInflater.rInflate(LayoutInflater.java:847)
      at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810)
      at android.view.LayoutInflater.inflate(LayoutInflater.java:527)
      at android.view.LayoutInflater.inflate(LayoutInflater.java:429)
      at com.example.accurat.faisal.MyLocation.onCreateView(MyLocation.java:62)
      at android.support.v4.app.Fragment.performCreateView(Fragment.java:2184)
      at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1298)
      at android.support.v4.app.FragmentManagerImpl.moveFragmentsToInvisible(FragmentManager.java:2323)
      at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2136)
      at android.support.v4.app.FragmentManagerImpl.optimizeAndExecuteOps(FragmentManager.java:2092)
      at android.support.v4.app.FragmentManagerImpl.execSingleAction(FragmentManager.java:1969)
      at android.support.v4.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:620)
      at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:143)
      at android.support.v4.view.ViewPager.populate(ViewPager.java:1268)
      at android.support.v4.view.ViewPager.populate(ViewPager.java:1116)
      at android.support.v4.view.ViewPager$3.run(ViewPager.java:273)
      at android.view.Choreographer$CallbackRecord.run(Choreographer.java:911)
      at android.view.Choreographer.doCallbacks(Choreographer.java:686)
      at android.view.Choreographer.doFrame(Choreographer.java:619)
      at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897)
      at android.os.Handler.handleCallback(Handler.java:739)
      at android.os.Handler.dispatchMessage(Handler.java:95)
      at android.os.Looper.loop(Looper.java:148)
      at android.app.ActivityThread.main(ActivityThread.java:7325)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) at
    com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

It shows error at below point:

// inflat and return the layout
    View rootView = inflater.inflate(R.layout.my_location, container, false);

Whether I choose any tab it always shows me an error on the above line, i.e. when I go to my pictures tab and came back to the camera or my location tab it always shows me the error on the above line.

Below is my layout

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.accurat.faisal">

<permission android:name="com.example.accurat.faisal.permission.MAPS_RECEIVE"
    android:protectionLevel="signature"/>

<uses-permission android:name="com.example.accurat.faisal.permission.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>

<uses-feature
    android:glEsVersion="0x00020000"
    android:required="true"
    />

<application
    android:name=""
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <meta-data
        android:name="com.google.android.geo.API_KEY"
        android:value="MY_KEY"
        />

    <meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />
    <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:theme="@style/AppTheme.NoActionBar">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

Below is my layout code

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.accurat.faisal.MyLocation$PlaceholderFragment">

<TextView
    android:id="@+id/section_label"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBottom="@+id/section_label"
    android:id="@+id/textView"
    android:layout_alignParentRight="true"
    android:layout_alignParentEnd="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:textAppearance="@style/TextAppearance.AppCompat.Body2" />

<fragment xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/map"
    tools:context="com.example.app.MyLocation"
    android:name="com.google.android.gms.maps.SupportMapFragment"
    android:layout_below="@+id/section_label" />

I have searched and found many answers on them (1, 2, 3), but couldn't able to find any help on it

I am stuck to it, Any help would be appreciated


来源: stackexchange

问:
Combine multiple atom/electron apps
Is there a way to load an electron app inside another electron app?
I would like to have the effect of an host electron app and multiple electron apps inside iframes.
The concept is to have multiple electron apps as widgets installable through a main electron app. For example I want to have one window where
you can see a twitter client app and facebook messenger app as tabs of a main window. It doesn't matter if size of the app gets big.</p>

答:
You can use windows 'cause at the end you just need html,css and some js to do widgets like show twitter, so prepare a function to pass the html directory of the page dynamically.

Otherwise if you prefer call exactly another app you can make a function for call the path of the app that you want  using childprocess

ContentLicense: CC BY-SA 3.0

Title: Combine multiple atom/electron apps


问:
when opening Main.axml in visual studio it is showing the below error CreateSession failed due to an internal error?

I have installed xamarin for visual studio manually,and path for sdk,ndk,jdk has been configured correctly but still iam getting this error

No indirect rendering available
java.lang.NoClassDefFoundError: Could not initialize class com.android.sdklib.repository.targets.SystemImage

at com.android.sdklib.repository.legacy.local.LocalSysImgPkgInfo.extractTagFromProps(LocalSysImgPkgInfo.java:88)
    at com.android.sdklib.repository.legacy.local.LocalSdk.scanSysImages(LocalSdk.java:1035)
    at com.android.sdklib.repository.legacy.local.LocalSdk.getPkgsInfos(LocalSdk.java:552)
    at com.android.sdklib.repository.legacy.LegacyLocalRepoLoader.parseLegacyLocalPackage(LegacyLocalRepoLoader.java:100)
    at com.android.repository.impl.manager.LocalRepoLoaderImpl.parsePackages(LocalRepoLoaderImpl.java:176)
    at com.android.repository.impl.manager.LocalRepoLoaderImpl.getPackages(LocalRepoLoaderImpl.java:154)
    at com.android.repository.impl.manager.RepoManagerImpl$LoadTask.run(RepoManagerImpl.java:653)
    at com.android.repository.api.RepoManager$DummyProgressRunner.runSyncWithProgress(RepoManager.java:398)
    at com.android.repository.impl.manager.RepoManagerImpl.load(RepoManagerImpl.java:387)
    at com.android.repository.api.RepoManager.loadSynchronously(RepoManager.java:290)
    at com.android.sdklib.repository.AndroidSdkHandler$RepoConfig.createRepoManager(AndroidSdkHandler.java:695)
    at com.android.sdklib.repository.AndroidSdkHandler.getSdkManager(AndroidSdkHandler.java:269)
    at com.android.sdklib.repository.AndroidSdkHandler.getAndroidTargetManager(AndroidSdkHandler.java:307)
    at mono.android.AndroidDesignerHost.getAndroidTarget(AndroidDesignerHost.java:86)
    at mono.android.DesignerSession.initialize(DesignerSession.java:114)
    at mono.android.Project.createSession(Project.java:383)
    at mono.android.Project.processMessage(Project.java:414)
    at mono.android.MessageListener.executeMessage(MessageListener.java:88)
    at mono.android.MessageListener$Runner.run(MessageListener.java:44)
    at java.lang.Thread.run(Thread.java:745)

 please see here for the  photo snipet of the error

答: after a big headmarch of approx 15 days it all solved just by changing the system default language to English. (my system default language was Hindi) .</p>


问:
webpack standard-loader, problems with jsx?
Getting this error when compiling with webpack.  Using standard-loader as a preloader.  The readme, specifies this configuration for webpack 2: https://www.npmjs.com/package/standard-loader.  There is jsx included in the test, so I'm confused why there is a problem parsing jsx.

Note that everything compiled fine, until I added the standard-loader for eslinting.

ERROR in ./src/index.jsx
Module parse failed: /Users/kwokbk/Desktop/Apps/redux/react-redux-boiler/node_modules/standard-react-loader/index.js??ref--0!/Users/kwokbk/Desktop/Apps/redux/react-redux-boiler/src/index.jsx Unexpected token (11:2)
You may need an appropriate loader to handle this file type.
|
| render(
|   <Provider store={store}>
|     <App />
|   </Provider>,
 @ multi webpack-hot-middleware/client ./src/
webpack: Failed to compile.```
</div>
</div>
</p>

<p>index.jsx</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>import React from 'react'
import { render } from 'react-dom'
import { Provider } from 'react-redux'
import { createStore } from 'redux'
import App from './components/App'
import reducer from './reducers'

const store = createStore(reducer)

render(
  <Provider store={store}>
    <App />
  </Provider>,
  document.getElementById('react-root')
)</code>```

webpack.config

```<code>const CONFIG = require('./webpack.base.js');
const webpack = require('webpack');

const { CLIENT_ENTRY, CLIENT_OUTPUT } = CONFIG;

module.exports = {
    entry: {
        main: [
            'webpack-hot-middleware/client',
            CLIENT_ENTRY
        ],
        vendor: [
            'react',
            'react-dom',
            'redux',
            'react-redux'
        ]
    },
    output: {
        path: CLIENT_OUTPUT,
        publicPath: CLIENT_OUTPUT,
        chunkFilename: '[name].chunk.js',
        filename: '[name].js'
    },
    resolve: {
        extensions: ['.js', '.jsx']
    },
    module: {
        rules: [
            {
                enforce: 'pre',
                test: /\.jsx?$/,
                loader: 'standard-loader',
                exclude: /(node_modules)/,
                options: {
                    parser: 'babel-eslint'
                }
            }
        ],
        loaders: [
            {
                test: /\.jsx?$/,
                exclude: /(node_modules|server)/,
                loader: 'babel-loader'
            }
        ]
    },
    plugins: [
        new webpack.HotModuleReplacementPlugin(),
        new webpack.optimize.CommonsChunkPlugin({name: 'vendor', filename: 'vendor.js', minChunks: 2})
    ]
}
</code>```

package.json

```<code>{
  "name": "react-redux-boiler",
  "version": "1.0.0",
  "description": "React Redux Boiler with webpack dev middleware, hot reloading, mocha-enzyme testing ",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "cross-env NODE_ENV=development nodemon -r 'babel-register' src/server"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/bkkwok/react-redux-boiler.git"
  },
  "author": "Benjamin Kwok",
  "license": "ISC",
  "bugs": {
    "url": "https://github.com/bkkwok/react-redux-boiler/issues"
  },
  "homepage": "https://github.com/bkkwok/react-redux-boiler#readme",
  "dependencies": {
    "cross-env": "^4.0.0",
    "express": "^4.15.2",
    "react": "^15.4.2",
    "react-dom": "^15.4.2",
    "react-redux": "^5.0.3",
    "redux": "^3.6.0"
  },
  "devDependencies": {
    "babel-core": "^6.24.0",
    "babel-eslint": "^7.2.1",
    "babel-loader": "^6.4.1",
    "babel-preset-airbnb": "^2.2.3",
    "babel-preset-es2015": "^6.24.0",
    "babel-preset-react": "^6.23.0",
    "babel-register": "^6.23.0",
    "chai": "^3.5.0",
    "enzyme": "^2.8.0",
    "eslint-config-standard": "^7.1.0",
    "eslint-loader": "^1.7.1",
    "eslint-plugin-react": "^6.10.3",
    "mocha": "^3.2.0",
    "nodemon": "^1.11.0",
    "sinon": "^2.1.0",
    "standard": "^9.0.2",
    "standard-loader": "^6.0.1",
    "standard-react-loader": "^1.0.0",
    "webpack": "^2.3.2",
    "webpack-dev-middleware": "^1.10.1",
    "webpack-hot-middleware": "^2.17.1"
  },
  "standard": {
    "parser": ["babel-eslint", "eslint-plugin-react"]
  }
}
</code>```

.babelrc

```<code>{
    presets: ['es2015', 'react']
}
</code>```

答:
In webpack 2, the loaders have to reside under rules, so change to:

```<code>module: {
        rules: [
            {
                enforce: 'pre',
                test: /\.jsx?$/,
                loader: 'standard-loader',
                exclude: /(node_modules)/,
                options: {
                    parser: 'babel-eslint'
                }
            },
            {
                test: /\.jsx?$/,
                exclude: /(node_modules|server)/,
                loader: 'babel-loader'
            }
        ]
    },
</code>```

Body:
Getting this error when compiling with webpack.  Using standard-loader as a preloader.  The readme, specifies this configuration for webpack 2: https://www.npmjs.com/package/standard-loader.  There is jsx included in the test, so I'm confused why there is a problem parsing jsx.

Note that everything compiled fine, until I added the standard-loader for eslinting.

ERROR in ./src/index.jsx
Module parse failed: /Users/kwokbk/Desktop/Apps/redux/react-redux-boiler/node_modules/standard-react-loader/index.js??ref--0!/Users/kwokbk/Desktop/Apps/redux/react-redux-boiler/src/index.jsx Unexpected token (11:2)
You may need an appropriate loader to handle this file type.
|
| render(
|   <Provider store={store}>
|     <App />
|   </Provider>,
 @ multi webpack-hot-middleware/client ./src/
webpack: Failed to compile.

index.jsx

import React from 'react'
import { render } from 'react-dom'
import { Provider } from 'react-redux'
import { createStore } from 'redux'
import App from './components/App'
import reducer from './reducers'

const store = createStore(reducer)

render(
  <Provider store={store}>
    <App />
  </Provider>,
  document.getElementById('react-root')
)

webpack.config

const CONFIG = require('./webpack.base.js');
const webpack = require('webpack');

const { CLIENT_ENTRY, CLIENT_OUTPUT } = CONFIG;

module.exports = {
    entry: {
        main: [
            'webpack-hot-middleware/client',
            CLIENT_ENTRY
        ],
        vendor: [
            'react',
            'react-dom',
            'redux',
            'react-redux'
        ]
    },
    output: {
        path: CLIENT_OUTPUT,
        publicPath: CLIENT_OUTPUT,
        chunkFilename: '[name].chunk.js',
        filename: '[name].js'
    },
    resolve: {
        extensions: ['.js', '.jsx']
    },
    module: {
        rules: [
            {
                enforce: 'pre',
                test: /\.jsx?$/,
                loader: 'standard-loader',
                exclude: /(node_modules)/,
                options: {
                    parser: 'babel-eslint'
                }
            }
        ],
        loaders: [
            {
                test: /\.jsx?$/,
                exclude: /(node_modules|server)/,
                loader: 'babel-loader'
            }
        ]
    },
    plugins: [
        new webpack.HotModuleReplacementPlugin(),
        new webpack.optimize.CommonsChunkPlugin({name: 'vendor', filename: 'vendor.js', minChunks: 2})
    ]
}

package.json

{
  "name": "react-redux-boiler",
  "version": "1.0.0",
  "description": "React Redux Boiler with webpack dev middleware, hot reloading, mocha-enzyme testing ",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "cross-env NODE_ENV=development nodemon -r 'babel-register' src/server"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/bkkwok/react-redux-boiler.git"
  },
  "author": "Benjamin Kwok",
  "license": "ISC",
  "bugs": {
    "url": "https://github.com/bkkwok/react-redux-boiler/issues"
  },
  "homepage": "https://github.com/bkkwok/react-redux-boiler#readme",
  "dependencies": {
    "cross-env": "^4.0.0",
    "express": "^4.15.2",
    "react": "^15.4.2",
    "react-dom": "^15.4.2",
    "react-redux": "^5.0.3",
    "redux": "^3.6.0"
  },
  "devDependencies": {
    "babel-core": "^6.24.0",
    "babel-eslint": "^7.2.1",
    "babel-loader": "^6.4.1",
    "babel-preset-airbnb": "^2.2.3",
    "babel-preset-es2015": "^6.24.0",
    "babel-preset-react": "^6.23.0",
    "babel-register": "^6.23.0",
    "chai": "^3.5.0",
    "enzyme": "^2.8.0",
    "eslint-config-standard": "^7.1.0",
    "eslint-loader": "^1.7.1",
    "eslint-plugin-react": "^6.10.3",
    "mocha": "^3.2.0",
    "nodemon": "^1.11.0",
    "sinon": "^2.1.0",
    "standard": "^9.0.2",
    "standard-loader": "^6.0.1",
    "standard-react-loader": "^1.0.0",
    "webpack": "^2.3.2",
    "webpack-dev-middleware": "^1.10.1",
    "webpack-hot-middleware": "^2.17.1"
  },
  "standard": {
    "parser": ["babel-eslint", "eslint-plugin-react"]
  }
}

.babelrc

{
    presets: ['es2015', 'react']
}

Body:
In webpack 2, the loaders have to reside under rules, so change to:

module: {
        rules: [
            {
                enforce: 'pre',
                test: /\.jsx?$/,
                loader: 'standard-loader',
                exclude: /(node_modules)/,
                options: {
                    parser: 'babel-eslint'
                }
            },
            {
                test: /\.jsx?$/,
                exclude: /(node_modules|server)/,
                loader: 'babel-loader'
            }
        ]
    },


问:
Get last entered record for each item from mysql
how to join t_detail and t_header mysql, by group by item, by taking the last data record ?

```<code>id | doc | item | price
1  | 002 | asz  | 1200
2  | 002 | aqw  | 3000
3  | 002 | qwe  | 1300
4  | 005 | qwe  | 1000
5  | 005 | aqw  | 2000
</code>```

output

```<code>id | doc | item | price
1  | 002 | asz  | 1200
4  | 005 | qwe  | 1000
5  | 005 | aqw  | 2000
</code>```

答:
```<code>Use GROUP BY and JOIN :

SELECT id,doc,item,price
FROM Table1
JOIN
(
  SELECT MAX(Id) _Id,item
  FROM Table1
  GROUP BY item
) A ON A._Id = id
</code>```

Body:
how to join t_detail and t_header mysql, by group by item, by taking the last data record ?

id | doc | item | price
1  | 002 | asz  | 1200
2  | 002 | aqw  | 3000
3  | 002 | qwe  | 1300
4  | 005 | qwe  | 1000
5  | 005 | aqw  | 2000

output

id | doc | item | price
1  | 002 | asz  | 1200
4  | 005 | qwe  | 1000
5  | 005 | aqw  | 2000


问:
WebApi Soln with multiple projects each having different windowsAzure.Storage version reference
I have web api solution which has say two projects.  Each of these project are refering to different versions of Microsoft.WindowsAzure.Storage assembly.  And solution has another version of storage referenced.

When I deploy the solution there is only one version of storage assembly (that referenced by soln) in the soln\bin directory.

Hence I am getting following error at runtime.

```<code>System.IO.FileLoadException: Could not load file or assembly 'Microsoft.WindowsAzure.Storage, Version=8.1.1.0
</code>```

Any help really appreciated.

答:
As far as I know, we couldn’t add different version of reference in same project.
So the only way to solve the different version of reference in same project is using the “Redirecting Assembly Versions”.
By using this way, you could make all different version of reference all redirect to the same version assembly.

You could set it in your webconfig files.

Like below:

```<code><dependentAssembly>
        <assemblyIdentity name="Microsoft.WindowsAzure.Storage" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-8.1.1.0" newVersion="7.1.2.0" />
      </dependentAssembly>
</code>```

This means make all Microsoft.WindowsAzure.Storage redirect to the 7.1.2.0(Which is installed in your web api project).

Besides, there are some differences between the different version of the azurestorage SDK.
For example, one method have been removed in the new version.

So normally, we will use the same version of all the project, if we want to use them.
I suggest you could check your codes and use the same version of the azure storage SDK in all three project.

Body:
I have web api solution which has say two projects.  Each of these project are refering to different versions of Microsoft.WindowsAzure.Storage assembly.  And solution has another version of storage referenced.

When I deploy the solution there is only one version of storage assembly (that referenced by soln) in the soln\bin directory.

Hence I am getting following error at runtime.

System.IO.FileLoadException: Could not load file or assembly 'Microsoft.WindowsAzure.Storage, Version=8.1.1.0

Any help really appreciated.

Body:
As far as I know, we couldn’t add different version of reference in same project.
So the only way to solve the different version of reference in same project is using the “Redirecting Assembly Versions”.
By using this way, you could make all different version of reference all redirect to the same version assembly.

You could set it in your webconfig files.

Like below:

<dependentAssembly>
        <assemblyIdentity name="Microsoft.WindowsAzure.Storage" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-8.1.1.0" newVersion="7.1.2.0" />
      </dependentAssembly>

This means make all Microsoft.WindowsAzure.Storage redirect to the 7.1.2.0(Which is installed in your web api project).

Besides, there are some differences between the different version of the azurestorage SDK.
For example, one method have been removed in the new version.

So normally, we will use the same version of all the project, if we want to use them.
I suggest you could check your codes and use the same version of the azure storage SDK in all three project.


问:
Visual Studio 'packages' element is not declared warning
So in Visual Studio 2017, I get the following warning in the auto-generated packages.config file:

The 'packages' element is not declared.

It is the same issue as here: The 'packages' element is not declared

And here: nuget 'packages' element is not declared warning

The consensus seems to be that this warning can be safely ignored.  Moreover, some of the comments suggest that attempts at fixing this can cause other issues and/or be hard to maintain.

For example, one contributor said:

None of the answers will solve your problem permanently. If you go to the path of adding XSD (From Xml menu, select "Create schema"), you will end up having problems with the package manager as it will clean up your packages.config file when you add a new package.

However, the most recent contributor suggested simply changing <packages> to <packages xmlns="urn:packages">.  Doing this makes the error go away and I saw no OBVIOUS problem (my experience here is very limited).

However, I don't want to risk causing Nuget problems over a warning that does not need to be addressed. On the other hand, every project created in VS, I'm guessing, will have this error by default, so an easy, safe, and easily maintainable fix would be good to have.

So my bottom line question is: what exactly does changing <packages> to <packages xmlns="urn:packages"> in the packages.config file do, and are there any risks or downsides to doing this?

答:
what exactly does changing <packages> to <packages xmlns="urn:packages"> in the packages.config file do, and are there any risks or downsides to doing this?

Using <packages xmlns="urn:packages"> in the packages.config file adds the schema to the file. The xmlns (namespace) declaration is nothing more than a string in the form of a uniform resource identifier (URI) and this declaration is not required. NuGet uses the <packages> node in packages.config to restore project dependencies as is described in the Schema section of the packages.config reference.  This is why Microsoft used <packages> instead of <packages xmlns="urn:packages">.

The packages.config file is auto-generated and can be used by NuGet as-is.  There is no need to change the file and there no risks or downsides associated with ignoring the warning.

ContentLicense: CC BY-SA 4.0


问:
Transition from SQL Server to MySQL (no data migration) - what's the difference?
I've written my website using ASP.NET MVC and SQL Server (used a SQL Server instance which ran locally on my machine).

I'm about to upload my site to a hosting provider. However, his DB works under MySQL. I don't care about the data already in the DB itself. It's mostly mock data and a few tables which I don't mind rewriting. But how do I go about the transition from SQL Server to MySQL? How does this influence my queries inside my code? is it the same code syntax? Will I have to recreate the table definitions? In my project I used LINQ to SQL.

Am I forced to look for a host with SQL Server capabilities (i.e. licenses)? (I hope not...)

Thanks!

答: LINQ to SQL works with MS SQL Server only...so if you want to keep using it, you need to find a host with a MSSQL database.</p>

ContentLicense: CC BY-SA 2.5


问:
Why isn't _mm_div_epi64/_mm_div_epu64 defined?
I've noticed that _mm_div_epi64/_mm_div_epu64 isn't defined in the headers for simd intrinsics and I don't get why it wouldn't. If it was multiplication it would make sense since 64bit * 64bit = 128bit, which would overflow but 64bit / 64bit = 64bit.

Unless there's some unforeseen issue with 64bit division for xmm registers.

Note: I am using Visual Studio 2017

答: Which header are you looking in?  According to the Intel Intrinsics Guide, both of those instructions are defined in "immintrin.h".</p>


问:
automake: substitute bin_PROGRAMS in DATA bash file
Is there any way to use the list of programs to build from a Makefile.am and put it in a bash script (autotools substitution, variables, ...)?

Something like below :

Example

Makefile.am

```<code>bin_PROGRAMS = prog1 prog2 prog3
[...]
</code>```

script.sh

```<code>#!/bin/bash
EXEC=@bin_PROGRAMS@ # something like this
</code>```

The goal is to give this script the list of programs being built

答:
No, because substitution happens at configure time, while the Makefile stuff happens at make time.

However, you can ensure that both lists are defined at configure time:

configure.ac

```<code>AC_SUBST([PROGRAMS], [prog1 prog2 prog3])
</code>```

Makefile.am

```<code>bin_PROGRAMS = @PROGRAMS@
</code>```

script.sh

```<code>EXEC=@PROGRAMS@
</code>```

Body:
Is there any way to use the list of programs to build from a Makefile.am and put it in a bash script (autotools substitution, variables, ...)?

Something like below :

Example

Makefile.am

bin_PROGRAMS = prog1 prog2 prog3
[...]

script.sh

#!/bin/bash
EXEC=@bin_PROGRAMS@ # something like this

The goal is to give this script the list of programs being built

Body:
No, because substitution happens at configure time, while the Makefile stuff happens at make time.

However, you can ensure that both lists are defined at configure time:

configure.ac

AC_SUBST([PROGRAMS], [prog1 prog2 prog3])

Makefile.am

bin_PROGRAMS = @PROGRAMS@

script.sh

EXEC=@PROGRAMS@


问:
Should I create different git repository for different AWS lambda functions?
There are some cons for using single repository for all my lambda functions of a project like:-

Size of deployment package becomes huge. So, when only 1 lambda is changed, entire package is recreated and deployed to AWS.

Also, different repositories for different lambdas can give us privilege of changing lambda code without affecting other lambdas, but it has its own cons.

So, what is the best design for coding in the AWS lambdas?

答:
After some research, I found out.

You need to group relevant lambda functions for e.g 4 lambda functions for CRUD operations corresponding to a single resource should be in a single repository.

Lambda functions concerning with different resource or irrelevant functions should be in a different repository.

Reference: Serverless framework documentation.


问:
HTMLEntities and URLencode in Laravel link
So I'm creating my own password reset system on my Laravel app, and when I email the user the recovery link, shown here:

```<code><a href='{{ url("forgotpassword/reset?email={$user->email}&recovery={$recoveryString}") }}'>click this link and reset your password!</a>
</code>```

the ampersand becomes "&".

I tried doing things likes

```<code>{{ url("forgotpassword/reset?email={$user->email} }}<?php echo urlencode('&'); ?>{{ recovery={$recoveryString}") }}'>click this link and reset your password!</a> }}
</code>```

but that doesn't work.

How could I write this?

答:
You can Try this

```<code><a href='{{ route("forgetpassword",array( "email@email.com","recoveryString")) }}'>click this link and reset your password!</a>
</code>```

and in your route file

```<code>Route::get('user/forgetpassword/{email}/{recoveryString}', [
'as' => 'forgetpassword', 'uses' => 'UserController@forgetPassword'
]);
</code>```

you can pass required parameter as array in .blade.php

Body:
So I'm creating my own password reset system on my Laravel app, and when I email the user the recovery link, shown here:

email}&recovery={$recoveryString}") }}'>click this link and reset your password!

the ampersand becomes "&".

I tried doing things likes

{{ url("forgotpassword/reset?email={$user->email} }}<?php echo urlencode('&'); ?>{{ recovery={$recoveryString}") }}'>click this link and reset your password! }}

but that doesn't work.

How could I write this?

Body:
You can Try this

<a href='{{ route("forgetpassword",array( "email@email.com","recoveryString")) }}'>click this link and reset your password!</a>

and in your route file

Route::get('user/forgetpassword/{email}/{recoveryString}', [
'as' => 'forgetpassword', 'uses' => 'UserController@forgetPassword'
]);

you can pass required parameter as array in .blade.php


问:
How to achieve this effect? its about borders/lines
https://codepen.io/anon/pen/NpoevM

http://imgur.com/a/OQ3cu

I want to have the small lines to separate the boxes. I was thinking about how to make the lines like in the picture. I was thinking using borders or span but having trouble

#third {
  height: 55%;
  width: 40%;
  display: flex;
  flex-direction: column;
  float: right;
}
.t-row {
  height: 100%;
  display: flex;
}
.tbox {
  width: 50%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}
.fa {
  font-size: 5em !important;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><section id="third">
  <div class="hr-lines">
    <hr class="icon-sep">
  </div>
  <div class="t-row">
    <div class="tbox tb-one">
      <i class="fa fa-home" aria-hidden="true"></i>
      <h1 class="t-text">Home</h1>
    </div>
    <div class="tbox tb-two">
      <i class="fa fa-info-circle" aria-hidden="true"></i>
      <h1 class="t-text">About</h1>
    </div>
  </div>
  <div class="t-row">
    <div class="tbox tb-three">
      <i class="fa fa-book" aria-hidden="true"></i>
      <h1 class="t-text">Work</h1>
    </div>
    <div class="tbox tb-four">
      <i class="fa fa-envelope" aria-hidden="true"></i>
      <h1 class="t-text">Hire</h1>
    </div>
  </div>
</section></code>```

答:
check below snippet. I have used :after for all four div and used border to create the + sign.

#third {
    height: 55%;
    width: 40%;
    display: flex;
    flex-direction: column;
    float: right;
}

.t-row {
    height: 100%;
    display: flex;
}

.tbox {
    width: 50%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.fa {
    font-size: 5em !important;
}

.tb-one,
.tb-two,
.tb-three,
.tb-four {
    position: relative;
}

.tb-one:after,
.tb-two:after,
.tb-three:after,
.tb-four:after {
    position: absolute;
    content: " ";
    border: 1px solid #000;
    width: 20px;
    height: 20px;
    display: block;
}

.tb-one:after {
    bottom: 0;
    right: 0;
    border-top: none;
    border-left: none
}

.tb-two:after {
    bottom: 0;
    left: 0;
    border-top: none;
    border-right: none
}

.tb-three:after {
    top: 0;
    right: 0;
    border-bottom: none;
    border-left: none
}

.tb-four:after {
    top: 0;
    left: 0;
    border-bottom: none;
    border-right: none
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><section id="third">
    <div class="hr-lines">
        <hr class="icon-sep">
    </div>
    <div class="t-row">
        <div class="tbox tb-one">
           <i class="fa fa-home" aria-hidden="true"></i>
           <h1 class="t-text">Home</h1>
        </div>
        <div class="tbox tb-two">
           <i class="fa fa-info-circle" aria-hidden="true"></i>
           <h1 class="t-text">About</h1>
        </div>
    </div>
    <div class="t-row">
        <div class="tbox tb-three">
           <i class="fa fa-book" aria-hidden="true"></i>
           <h1 class="t-text">Work</h1>
        </div>
        <div class="tbox tb-four">
            <i class="fa fa-envelope" aria-hidden="true"></i>
            <h1 class="t-text">Hire</h1>
        </div>
    </div>
</section></code>```

Body:
https://codepen.io/anon/pen/NpoevM

http://imgur.com/a/OQ3cu

I want to have the small lines to separate the boxes. I was thinking about how to make the lines like in the picture. I was thinking using borders or span but having trouble

#third {
  height: 55%;
  width: 40%;
  display: flex;
  flex-direction: column;
  float: right;
}
.t-row {
  height: 100%;
  display: flex;
}
.tbox {
  width: 50%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}
.fa {
  font-size: 5em !important;
}

Home

About

Work

Hire

Body:
check below snippet. I have used :after for all four div and used border to create the + sign.

#third {
    height: 55%;
    width: 40%;
    display: flex;
    flex-direction: column;
    float: right;
}

.t-row {
    height: 100%;
    display: flex;
}

.tbox {
    width: 50%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.fa {
    font-size: 5em !important;
}

.tb-one,
.tb-two,
.tb-three,
.tb-four {
    position: relative;
}

.tb-one:after,
.tb-two:after,
.tb-three:after,
.tb-four:after {
    position: absolute;
    content: " ";
    border: 1px solid #000;
    width: 20px;
    height: 20px;
    display: block;
}

.tb-one:after {
    bottom: 0;
    right: 0;
    border-top: none;
    border-left: none
}

.tb-two:after {
    bottom: 0;
    left: 0;
    border-top: none;
    border-right: none
}

.tb-three:after {
    top: 0;
    right: 0;
    border-bottom: none;
    border-left: none
}

.tb-four:after {
    top: 0;
    left: 0;
    border-bottom: none;
    border-right: none
}

<section id="third">
    <div class="hr-lines">
        <hr class="icon-sep">
    </div>
    <div class="t-row">
        <div class="tbox tb-one">
           <i class="fa fa-home" aria-hidden="true"></i>
           <h1 class="t-text">Home</h1>
        </div>
        <div class="tbox tb-two">
           <i class="fa fa-info-circle" aria-hidden="true"></i>
           <h1 class="t-text">About</h1>
        </div>
    </div>
    <div class="t-row">
        <div class="tbox tb-three">
           <i class="fa fa-book" aria-hidden="true"></i>
           <h1 class="t-text">Work</h1>
        </div>
        <div class="tbox tb-four">
            <i class="fa fa-envelope" aria-hidden="true"></i>
            <h1 class="t-text">Hire</h1>
        </div>
    </div>
</section>


问:
C/C++ preprocessor single quote?

Possible Duplicate:

  How to single-quote an argument in a macro?

How can it do the following:

```<code>#define MACRO(X) ...
MACRO(a) // should give 'a'
</code>```

答:
Like this:

```<code>#include <string>

std::string Macro(const std::string& s)
{
  std::string ret = "'";
  ret += s;
  ret += "'";
  return ret;
}
</code>```

EDIT:

I posted this answer before it was revealed that this was needed for metaprogramming.  I don not know of a way to accomplish this for metaprogramming, but metaprogramming is not my forte.

Also, as for why I am effectively saying "don't use the preprocessor" in the first place, read the comments below.  But in short, I believe that almost everything that is commonly done using the preprocessor can and should be done using first-level constructs instead.  Using the preprocessor skirts the C++ type system and reduces safety.  Macros are difficult to debug, difficult to extend.  Extensively using macros will result in code that isn't familiar to the programmers who didn't create the macro, resulting in a kind of "secret language" only 1 person knows, decreasing maintainability of not only the macros, but the functions where they are used.

OK, I guess that wasn't so short, but there it is.

Title: C/C++ preprocessor single quote?

Body:
Possible Duplicate:

  How to single-quote an argument in a macro?

How can it do the following:

#define MACRO(X) ...
MACRO(a) // should give 'a'

Body:
Like this:

#include <string>

std::string Macro(const std::string& s)
{
  std::string ret = "'";
  ret += s;
  ret += "'";
  return ret;
}

EDIT:

I posted this answer before it was revealed that this was needed for metaprogramming.  I don not know of a way to accomplish this for metaprogramming, but metaprogramming is not my forte.

Also, as for why I am effectively saying "don't use the preprocessor" in the first place, read the comments below.  But in short, I believe that almost everything that is commonly done using the preprocessor can and should be done using first-level constructs instead.  Using the preprocessor skirts the C++ type system and reduces safety.  Macros are difficult to debug, difficult to extend.  Extensively using macros will result in code that isn't familiar to the programmers who didn't create the macro, resulting in a kind of "secret language" only 1 person knows, decreasing maintainability of not only the macros, but the functions where they are used.

OK, I guess that wasn't so short, but there it is.


问:
Font Awesome handshake icon did n't work
I had tried to use handshake icons but it doesn't work, below included us the code which I have tried:

```<code><i class="fa fa-handshake-o"></i>
</code>```

Please help me

答:
Try Your code in w3 school tryit editor

It is link for that https://www.w3schools.com/icons/fontawesome_icons_intro.asp

I think that You are not include the css for font-awesome so include that 'font-awesome.min.css'

This is the sample screen from try it editor

Body:
I had tried to use handshake icons but it doesn't work, below included us the code which I have tried:

Please help me


答:
In your code add four classes with border property of div.</p>

```<code>    <style>
#third {
    height: 55%;
    width: 40%;
    display: flex;
    flex-direction: column;
    float: right;
}

.t-row {
    height: 100%;
    display: flex;
}

.tbox {
    width: 50%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.fa {
    font-size: 5em !important;
}
.left-border{ border-left : 1px solid;}
.right-border{ border-right : 1px solid;}
.bottom-border{ border-bottom : 1px solid;}
.top-border{ border-top: 1px solid;}
</style>
<section id="third">
    <div class="hr-lines">
        <hr class="icon-sep">
    </div>
    <div class="t-row">
        <div class="tbox tb-one  right-border bottom-border">
            <i class="fa fa-home" aria-hidden="true"></i>
            <h1 class="t-text">Home</h1>
        </div>
        <div class="tbox tb-two left-border bottom-border">
            <i class="fa fa-info-circle" aria-hidden="true"></i>
            <h1 class="t-text">About</h1>
        </div>
    </div>
    <div class="t-row">
        <div class="tbox tb-three top-border right-border">
            <i class="fa fa-book" aria-hidden="true"></i>
            <h1 class="t-text">Work</h1>
        </div>
        <div class="tbox tb-four top-border left-border">
            <i class="fa fa-envelope" aria-hidden="true"></i>
            <h1 class="t-text">Hire</h1>
        </div>
    </div>
</section>
</code>```

Title: How to achieve this effect? its about borders/lines

Body:
In your code add four classes with border property of div.

    <style>
#third {
    height: 55%;
    width: 40%;
    display: flex;
    flex-direction: column;
    float: right;
}

.t-row {
    height: 100%;
    display: flex;
}

.tbox {
    width: 50%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.fa {
    font-size: 5em !important;
}
.left-border{ border-left : 1px solid;}
.right-border{ border-right : 1px solid;}
.bottom-border{ border-bottom : 1px solid;}
.top-border{ border-top: 1px solid;}
</style>
<section id="third">
    <div class="hr-lines">
        <hr class="icon-sep">
    </div>
    <div class="t-row">
        <div class="tbox tb-one  right-border bottom-border">
            <i class="fa fa-home" aria-hidden="true"></i>
            <h1 class="t-text">Home</h1>
        </div>
        <div class="tbox tb-two left-border bottom-border">
            <i class="fa fa-info-circle" aria-hidden="true"></i>
            <h1 class="t-text">About</h1>
        </div>
    </div>
    <div class="t-row">
        <div class="tbox tb-three top-border right-border">
            <i class="fa fa-book" aria-hidden="true"></i>
            <h1 class="t-text">Work</h1>
        </div>
        <div class="tbox tb-four top-border left-border">
            <i class="fa fa-envelope" aria-hidden="true"></i>
            <h1 class="t-text">Hire</h1>
        </div>
    </div>
</section>


问:
No arguments Provided! - PHP Contact form
When I hit Send Message on my contact form it takes me to a mysite.com/mail.php and give me the error No arguments Provided!

Here is my HTML

```<code><form id="myForm" method="post" action="../mail.php">

            <div class="row">
                    <div class="medium-6 columns">
                        <input type="text" name="name" value="" placeholder="Your Name">
                    </div>
                    <div class="medium-6 columns">
                        <input type="text" name="website" value="" placeholder="Website">
                    </div>
                    <div class="medium-6 columns">
                        <input type="email" name="email" value="" placeholder="Email">
                    </div>
                    <div class="medium-6 columns">
                        <input type="text" name="service" value="" placeholder="Service Needed">
                    </div>
            </div>

            <div class="row">
                <div class="columns">
                    <label for="textarea">
                        <textarea name="message" rows="8" cols="80" placeholder="Tell me about your project"></textarea>
                    </label>
                </div>
            </div>

        <div class="row">
            <div class="columns">
                <input name="Submit" type="submit" class="button" value="Send Message">
            </div>
        </div>

        </form>
</code>```

Here is the PHP

```<code><?php
if(empty($_POST['name'])        ||
   empty($_POST['email'])       ||
   empty($_POST['website'])     ||
     empty($_POST['service'])   ||
   empty($_POST['message'])   ||
   !filter_var($_POST['email'],FILTER_VALIDATE_EMAIL))
   {
    echo "No arguments Provided!";
    return false;
   }

$name = $_POST['name'];
$email_address = $_POST['email'];
$message = $_POST['message'];

// Create the email and send the message
$to = 'myemail@gmail.comm';
$email_subject = "Website Contact Form SRC:  $name";
$email_body = "You have received a new message from your website contact form.\n\n"."Here are the details:\n\nName: $name\n\nEmail: $email_address\n\nPhone: $phone\n\nMessage:\n$message";
$headers = "From: myemail@gmail.comm\n";
$headers .= "Reply-To: $email_address";
mail($to,$email_subject,$email_body,$headers);
return true;
?>
</code>```

答: Use name="website" instead of name="webiste"

Body:
When I hit Send Message on my contact form it takes me to a mysite.com/mail.php and give me the error No arguments Provided!

Here is my HTML

<form id="myForm" method="post" action="../mail.php">

                        <input type="text" name="name" value="" placeholder="Your Name">

                        <input type="text" name="website" value="" placeholder="Website">

                        <input type="email" name="email" value="" placeholder="Email">

                        <input type="text" name="service" value="" placeholder="Service Needed">

                        <textarea name="message" rows="8" cols="80" placeholder="Tell me about your project"></textarea>

                <input name="Submit" type="submit" class="button" value="Send Message">

        </form>

Here is the PHP

<?php
if(empty($_POST['name'])        ||
   empty($_POST['email'])       ||
   empty($_POST['website'])     ||
     empty($_POST['service'])   ||
   empty($_POST['message'])   ||
   !filter_var($_POST['email'],FILTER_VALIDATE_EMAIL))
   {
    echo "No arguments Provided!";
    return false;
   }

$name = $_POST['name'];
$email_address = $_POST['email'];
$message = $_POST['message'];

// Create the email and send the message
$to = 'myemail@gmail.comm';
$email_subject = "Website Contact Form SRC:  $name";
$email_body = "You have received a new message from your website contact form.\n\n"."Here are the details:\n\nName: $name\n\nEmail: $email_address\n\nPhone: $phone\n\nMessage:\n$message";
$headers = "From: myemail@gmail.comm\n";
$headers .= "Reply-To: $email_address";
mail($to,$email_subject,$email_body,$headers);
return true;
?>


问:
Java comparing two arrays and checking if the First array is consecutive of the Second
Long story short beginner programer here practicing with java. Right now I'm taking two arrays and I want to find out if int arrayA (7,14,21,28) is consecutive to int ArrayB meaning does arrayB have (7,14,21,28) consecutively within the array. If it is the boolean returns true if not it shall simply return false. Here is an example of my code.</p>

```<code> public class Harrison7aTest
 {
 public static void main(String [] args)
 {
  int[] arrayA = {7,14,21,28};
  int[] arrayB = {1,3,5,7,14,21,28,32};

 boolean result = false;

  for(int A = 0; A < arrayA.length - 1; A++)
  {
     for(int B = 0; B < arrayB.length - 1; B++)
     {

     }

  }

}
}
</code>```

答:
You can convert them to string and make use of str.contains() method

```<code>String strArrA = Arrays.toString(arrayA);
String strArrB = Arrays.toString(arrayB);

//to strip square brackets that's comes with Arrays.toString
//for ex: Arrays.toString(arrayA); returns "[7, 14, 21, 28]"
//we want to convert it to "7, 14, 21, 28"
strArrA = strArrA.substring(1, strArrA.length()-1);

if (strArrB.contains(strArrA)) {
    System.out.println("true");
} else {
    System.out.println("false");
}
</code>```

DEMO

Body:
Long story short beginner programer here practicing with java. Right now I'm taking two arrays and I want to find out if int arrayA (7,14,21,28) is consecutive to int ArrayB meaning does arrayB have (7,14,21,28) consecutively within the array. If it is the boolean returns true if not it shall simply return false. Here is an example of my code.

 public class Harrison7aTest
 {
 public static void main(String [] args)
 {
  int[] arrayA = {7,14,21,28};
  int[] arrayB = {1,3,5,7,14,21,28,32};

 boolean result = false;

  for(int A = 0; A < arrayA.length - 1; A++)
  {
     for(int B = 0; B < arrayB.length - 1; B++)
     {

     }

  }

}
}

Body:
You can convert them to string and make use of str.contains() method

String strArrA = Arrays.toString(arrayA);
String strArrB = Arrays.toString(arrayB);

//to strip square brackets that's comes with Arrays.toString
//for ex: Arrays.toString(arrayA); returns "[7, 14, 21, 28]"
//we want to convert it to "7, 14, 21, 28"
strArrA = strArrA.substring(1, strArrA.length()-1);

if (strArrB.contains(strArrA)) {
    System.out.println("true");
} else {
    System.out.println("false");
}

DEMO


答:
for more performance :

```<code>SELECT
    d.*
FROM
   t_detail d INNER JOIN
            (
               SELECT
                  MAX(id) as 'id'
               FROM t_detail
            GROUP BY item
            ) dmax on d.id = dmax.id ;
</code>```

this way the query is executed only one time .

Title: Get last entered record for each item from mysql

Body:
for more performance :

SELECT
    d.*
FROM
   t_detail d INNER JOIN
            (
               SELECT
                  MAX(id) as 'id'
               FROM t_detail
            GROUP BY item
            ) dmax on d.id = dmax.id ;

this way the query is executed only one time .


问:
Can't figure out how to print a list in this correct order
Basically I have an arraylist of objects which have a name and startDate and they are in a similar initial order to :

Frank 10/20/1990

Bill 1/2/1990

Frank 2/2/1990

John 9/8/1990

Bill 4/4/1990

Frank 5/1/1990

I'm trying to print them in order of the first names declared and then by date, eg, the final printing should print :

Frank 1/1/1990

Frank 5/1/1990

Frank 10/20/1990

Bill 1/2/1990

Bill 4/4/1990

John 9/8/1990

答:
Assuming you object class looks like this:

```<code>private static class MyObject {

  private final String name;
  private final Date date;

  private MyObject(String name, Date date) {
    this.name = name;
    this.date = date;
  }

  public String getName() {
    return name;
  }

  public Date getDate() {
    return date;
  }
}
</code>```

You could print your objects using the following method:

```<code>@Test
public void printInOrder() {
  List<MyObject> list = new ArrayList<>(); // List containing your objects
  list.add(new MyObject("Frank", Date.from(LocalDate.of(1990, 10, 20).atStartOfDay(ZoneId.systemDefault()).toInstant())));
  list.add(new MyObject("Bill", Date.from(LocalDate.of(1990, 1, 2).atStartOfDay(ZoneId.systemDefault()).toInstant())));
  list.add(new MyObject("Frank", Date.from(LocalDate.of(1990, 2, 2).atStartOfDay(ZoneId.systemDefault()).toInstant())));
  list.add(new MyObject("John", Date.from(LocalDate.of(1990, 9, 8).atStartOfDay(ZoneId.systemDefault()).toInstant())));
  list.add(new MyObject("Bill", Date.from(LocalDate.of(1990, 4, 4).atStartOfDay(ZoneId.systemDefault()).toInstant())));
  list.add(new MyObject("Frank", Date.from(LocalDate.of(1990, 5, 1).atStartOfDay(ZoneId.systemDefault()).toInstant())));

  list.stream()
      .sorted(Comparator.comparing(MyObject::getName)
                        .thenComparing(Comparator.comparing(MyObject::getDate)))
      .map(obj -> obj.getName() + " " + obj.getDate())
      .forEach(System.out::println);
}
</code>```

Output:

Bill Tue Jan 02 00:00:00 CET 1990

  Bill Wed Apr 04 00:00:00 CEST 1990

  Frank Fri Feb 02 00:00:00 CET 1990

  Frank Tue May 01 00:00:00 CEST 1990

  Frank Sat Oct 20 00:00:00 CET 1990

  John Sat Sep 08 00:00:00 CEST 1990

This uses Java 8 streams and a comparator chain to sort your objects. The comparators compare by a given attribute, the thenComparing is used to chain them.

UPDATE:

As I am not sure if I possibly misunderstood you, here is a second version for the following case:

You want to sort by name, but in the order the names are appearing in the original list, so names first appearing will be first.

In this case you will have to remember the order of the names in a separate, temporary list (only containing the unique names in the original order) that can be used inside the comparator afterwards.

This list is produced by transforming the original list into a set (so have only the unique names) and then transforming this set back into a list (to be able to use indexOf inside the comparator).

```<code>@Test
public void printInOrder() {
  List<MyObject> list = new ArrayList<>();
  list.add(new MyObject("Frank", Date.from(LocalDate.of(1990, 10, 20).atStartOfDay(ZoneId.systemDefault()).toInstant())));
  list.add(new MyObject("Bill", Date.from(LocalDate.of(1990, 1, 2).atStartOfDay(ZoneId.systemDefault()).toInstant())));
  list.add(new MyObject("Frank", Date.from(LocalDate.of(1990, 2, 2).atStartOfDay(ZoneId.systemDefault()).toInstant())));
  list.add(new MyObject("John", Date.from(LocalDate.of(1990, 9, 8).atStartOfDay(ZoneId.systemDefault()).toInstant())));
  list.add(new MyObject("Bill", Date.from(LocalDate.of(1990, 4, 4).atStartOfDay(ZoneId.systemDefault()).toInstant())));
  list.add(new MyObject("Frank", Date.from(LocalDate.of(1990, 5, 1).atStartOfDay(ZoneId.systemDefault()).toInstant())));

  List<String> declaredNameOrder = new ArrayList<>(list.stream()
                                      .map(MyObject::getName)
                                      .collect(Collectors.toCollection(LinkedHashSet::new)));

  list.stream()
      .sorted(Comparator.<MyObject>comparingInt(o -> declaredNameOrder.indexOf(o.getName()))
                  .thenComparing(Comparator.comparing(MyObject::getDate)))
      .map(obj -> obj.getName() + " " + obj.getDate())
      .forEach(System.out::println);
}
</code>```

Output:

Frank Fri Feb 02 00:00:00 CET 1990

  Frank Tue May 01 00:00:00 CEST 1990

  Frank Sat Oct 20 00:00:00 CET 1990

  Bill Tue Jan 02 00:00:00 CET 1990

  Bill Wed Apr 04 00:00:00 CEST 1990

  John Sat Sep 08 00:00:00 CEST 1990

Body:
Assuming you object class looks like this:

private static class MyObject {

  private final String name;
  private final Date date;

  private MyObject(String name, Date date) {
    this.name = name;
    this.date = date;
  }

  public String getName() {
    return name;
  }

  public Date getDate() {
    return date;
  }
}

You could print your objects using the following method:

@Test
public void printInOrder() {
  List<MyObject> list = new ArrayList<>(); // List containing your objects
  list.add(new MyObject("Frank", Date.from(LocalDate.of(1990, 10, 20).atStartOfDay(ZoneId.systemDefault()).toInstant())));
  list.add(new MyObject("Bill", Date.from(LocalDate.of(1990, 1, 2).atStartOfDay(ZoneId.systemDefault()).toInstant())));
  list.add(new MyObject("Frank", Date.from(LocalDate.of(1990, 2, 2).atStartOfDay(ZoneId.systemDefault()).toInstant())));
  list.add(new MyObject("John", Date.from(LocalDate.of(1990, 9, 8).atStartOfDay(ZoneId.systemDefault()).toInstant())));
  list.add(new MyObject("Bill", Date.from(LocalDate.of(1990, 4, 4).atStartOfDay(ZoneId.systemDefault()).toInstant())));
  list.add(new MyObject("Frank", Date.from(LocalDate.of(1990, 5, 1).atStartOfDay(ZoneId.systemDefault()).toInstant())));

  list.stream()
      .sorted(Comparator.comparing(MyObject::getName)
                        .thenComparing(Comparator.comparing(MyObject::getDate)))
      .map(obj -> obj.getName() + " " + obj.getDate())
      .forEach(System.out::println);
}

Output:

Bill Tue Jan 02 00:00:00 CET 1990

  Bill Wed Apr 04 00:00:00 CEST 1990

  Frank Fri Feb 02 00:00:00 CET 1990

  Frank Tue May 01 00:00:00 CEST 1990

  Frank Sat Oct 20 00:00:00 CET 1990

  John Sat Sep 08 00:00:00 CEST 1990

This uses Java 8 streams and a comparator chain to sort your objects. The comparators compare by a given attribute, the thenComparing is used to chain them.

UPDATE:

As I am not sure if I possibly misunderstood you, here is a second version for the following case:

You want to sort by name, but in the order the names are appearing in the original list, so names first appearing will be first.

In this case you will have to remember the order of the names in a separate, temporary list (only containing the unique names in the original order) that can be used inside the comparator afterwards.

This list is produced by transforming the original list into a set (so have only the unique names) and then transforming this set back into a list (to be able to use indexOf inside the comparator).

@Test
public void printInOrder() {
  List<MyObject> list = new ArrayList<>();
  list.add(new MyObject("Frank", Date.from(LocalDate.of(1990, 10, 20).atStartOfDay(ZoneId.systemDefault()).toInstant())));
  list.add(new MyObject("Bill", Date.from(LocalDate.of(1990, 1, 2).atStartOfDay(ZoneId.systemDefault()).toInstant())));
  list.add(new MyObject("Frank", Date.from(LocalDate.of(1990, 2, 2).atStartOfDay(ZoneId.systemDefault()).toInstant())));
  list.add(new MyObject("John", Date.from(LocalDate.of(1990, 9, 8).atStartOfDay(ZoneId.systemDefault()).toInstant())));
  list.add(new MyObject("Bill", Date.from(LocalDate.of(1990, 4, 4).atStartOfDay(ZoneId.systemDefault()).toInstant())));
  list.add(new MyObject("Frank", Date.from(LocalDate.of(1990, 5, 1).atStartOfDay(ZoneId.systemDefault()).toInstant())));

  List<String> declaredNameOrder = new ArrayList<>(list.stream()
                                      .map(MyObject::getName)
                                      .collect(Collectors.toCollection(LinkedHashSet::new)));

  list.stream()
      .sorted(Comparator.<MyObject>comparingInt(o -> declaredNameOrder.indexOf(o.getName()))
                  .thenComparing(Comparator.comparing(MyObject::getDate)))
      .map(obj -> obj.getName() + " " + obj.getDate())
      .forEach(System.out::println);
}

Output:

Frank Fri Feb 02 00:00:00 CET 1990

  Frank Tue May 01 00:00:00 CEST 1990

  Frank Sat Oct 20 00:00:00 CET 1990

  Bill Tue Jan 02 00:00:00 CET 1990

  Bill Wed Apr 04 00:00:00 CEST 1990

  John Sat Sep 08 00:00:00 CEST 1990


问:
not looping through all the data
I have created a script to get data within the html element there is a div with an id ticker and I wanted to get all the data within the divs present in the ticker div I am only getting the first one in my console log not getting the rest of them please can anyone help me out </p>

```<code>$(document).ready(function() {
var table = $("#ticker");
var calls = [];
table.each(function (i) {
    var $tds = $(this).find('div'),
    url = $tds.eq(0).text(),
    Company_name = $tds.eq(1).text(),
    open = $tds.eq(2).text();
    high = $tds.eq(3).text();
    var row_id = (i + 1);
    console.log(url);
});
});
</code>```

<p>This is my html </p>

```<code><div id="ticker" style="height:18px;font-family:Arial;font-size:12px;font-weight:bold;padding-top:3px;width:6000px;">

<div style="width:180px;float:left;text-align:center;">
    <font color="#f6c644">tag 1</font>
      52.24 / 1.33M
    <font color="#4eff00"> 0.16</font>
    </div>
    <div style="width:180px;float:left;text-align:center;">
    <font color="#f6c644">tag 2</font>  93.5 / 1.07M
    <font color="#4eff00"> 1.4</font>
    </div>
    <div style="width:180px;float:left;text-align:center;">
    <font color="#f6c644">tag 3</font>  74.2 / 0.84M
    <font color="#ff0000"> -0.47</font>
    </div>
</div>
</code>```

答:
var table = $("#ticker");
var calls = [];
table.find('div').each(function(i,item) {
    var $tds = $(this);
    var url = $tds.eq(0).text();
    var Company_name = $tds.eq(1).text();
    var open = $tds.eq(2).text();
    var high = $tds.eq(3).text();
    var row_id = (i + 1);
    console.log(url);
}); ```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="ticker" style="height:18px;font-family:Arial;font-size:12px;font-weight:bold;padding-top:3px;width:6000px;">

<div style="width:180px;float:left;text-align:center;">
    <font color="#f6c644">tag 1</font>
      52.24 / 1.33M
    <font color="#4eff00"> 0.16</font>
    </div>
    <div style="width:180px;float:left;text-align:center;">
    <font color="#f6c644">tag 2</font>  93.5 / 1.07M
    <font color="#4eff00"> 1.4</font>
    </div>
    <div style="width:180px;float:left;text-align:center;">
    <font color="#f6c644">tag 3</font>  74.2 / 0.84M
    <font color="#ff0000"> -0.47</font>
    </div>
</div></code>```

Title: not looping through all the data

Body:
I have created a script to get data within the html element there is a div with an id ticker and I wanted to get all the data within the divs present in the ticker div I am only getting the first one in my console log not getting the rest of them please can anyone help me out

$(document).ready(function() {
var table = $("#ticker");
var calls = [];
table.each(function (i) {
    var $tds = $(this).find('div'),
    url = $tds.eq(0).text(),
    Company_name = $tds.eq(1).text(),
    open = $tds.eq(2).text();
    high = $tds.eq(3).text();
    var row_id = (i + 1);
    console.log(url);
});
});

This is my html

    tag 1
      52.24 / 1.33M
     0.16

    tag 2  93.5 / 1.07M
     1.4

    tag 3  74.2 / 0.84M
     -0.47

Body:
var table = $("#ticker");
var calls = [];
table.find('div').each(function(i,item) {
    var $tds = $(this);
    var url = $tds.eq(0).text();
    var Company_name = $tds.eq(1).text();
    var open = $tds.eq(2).text();
    var high = $tds.eq(3).text();
    var row_id = (i + 1);
    console.log(url);
});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="ticker" style="height:18px;font-family:Arial;font-size:12px;font-weight:bold;padding-top:3px;width:6000px;">

<div style="width:180px;float:left;text-align:center;">
    <font color="#f6c644">tag 1</font>
    &nbsp;&nbsp;52.24&nbsp;/&nbsp;1.33M&nbsp;
    <font color="#4eff00">&nbsp;0.16</font>
    </div>
    <div style="width:180px;float:left;text-align:center;">
    <font color="#f6c644">tag 2</font>&nbsp;&nbsp;93.5&nbsp;/&nbsp;1.07M&nbsp;
    <font color="#4eff00">&nbsp;1.4</font>
    </div>
    <div style="width:180px;float:left;text-align:center;">
    <font color="#f6c644">tag 3</font>&nbsp;&nbsp;74.2&nbsp;/&nbsp;0.84M&nbsp;
    <font color="#ff0000">&nbsp;-0.47</font>
    </div>
</div>


问:
How can I convert the output from a ostream_iterator to a string?
I am implementing a toString method in C++ primarily using the ostream_iterator.

```<code>std::ostream_iterator<int> output(std::cout, " ");
</code>```

After printing to the console, however, I wish to return the output of the ostream_iterator as a string. Is this direct conversion possible?

答:
Is this direct conversion possible?

I think, no, because ostream_iterator is used to send data to stream one way, so if the destination is std::cout you cannot use ostream_iterator to get data back.

But you can use some other destination, e.g. ostringstream object, and then use it for both output through cout and use again as you like.

Consider simple example:

    std::stringstream buff;
    std::ostream_iterator<int> output(buff, " ");
    std::istringstream str("10 3 ABC 7 1");
    // just copy only first integer values from str (stop on the first non-integer)
    std::copy(std::istream_iterator<int>(str), std::istream_iterator<int>(), output);
    // output as a string to std output
    std::cout << buff.str() << std::endl;
    // do something else
    buff.seekp(0, std::ios::end);
    std::cout << "String size is " << buff.tellp() << std::endl;
```

Body:
I am implementing a toString method in C++ primarily using the ostream_iterator.

std::ostream_iterator<int> output(std::cout, " ");

After printing to the console, however, I wish to return the output of the ostream_iterator as a string. Is this direct conversion possible?


问:
How do I split a list of array?
Here is the list array:

```<code>{"things":{"1":"1_4","3":"3_13","4":"4_18","5":"5_25","6":"6_28","7":"7_32"}}
</code>```

here is the code:

```<code>var t = things;
string aa = t[0].ToString();
</code>```

How do I split the above array in , separator and _ .
from the above array i want only 1_4,3_13...this column and save in two different var.

when I am using

```<code>string[] ss = aa.Split(new char[] { ',', '|', }, System.StringSplitOptions.RemoveEmptyEntries);
</code>```

the problem is that in first list {"things":{"1":"1_4".
comes

so how to remove {"things"??

答:
Instead of string manipulation, you should use JSON library like Json.Net. Simply, because you are working with string in JSON format and it will be easier to work with that information if you deserialize it into proper object or JObject.

Example with JObject:

```<code>string json = @"{""things"":{""1"":""1_4"",""3"":""3_13"",""4"":""4_18"",""5"":""5_25"",""6"":""6_28"",""7"":""7_32""}}";
var jObj = Newtonsoft.Json.Linq.JObject.Parse(json);
var prop1 = jObj.GetValue("things").GetPropertyValue("1").ConvertTo<string>();
var prop4 = jObj.GetValue("things").GetPropertyValue("4").ConvertTo<string>();
</code>```

Note: You can create classes which will represent your JSON structure, if you want to have strongly typed object structure.

Title: How do I split a list of array?

Body:
Here is the list array:

{"things":{"1":"1_4","3":"3_13","4":"4_18","5":"5_25","6":"6_28","7":"7_32"}}

here is the code:

var t = things;
string aa = t[0].ToString();

How do I split the above array in , separator and _ .
from the above array i want only 1_4,3_13...this column and save in two different var.

when I am using

string[] ss = aa.Split(new char[] { ',', '|', }, System.StringSplitOptions.RemoveEmptyEntries);

the problem is that in first list {"things":{"1":"1_4".
comes

so how to remove {"things"??

Body:
Instead of string manipulation, you should use JSON library like Json.Net. Simply, because you are working with string in JSON format and it will be easier to work with that information if you deserialize it into proper object or JObject.

Example with JObject:

string json = @"{""things"":{""1"":""1_4"",""3"":""3_13"",""4"":""4_18"",""5"":""5_25"",""6"":""6_28"",""7"":""7_32""}}";
var jObj = Newtonsoft.Json.Linq.JObject.Parse(json);
var prop1 = jObj.GetValue("things").GetPropertyValue("1").ConvertTo<string>();
var prop4 = jObj.GetValue("things").GetPropertyValue("4").ConvertTo<string>();

Note: You can create classes which will represent your JSON structure, if you want to have strongly typed object structure.


问:
Why can my synchronized methods lock on different objects?
I am learning Java concurrency right now. I came across a piece of code like this:

```<code>package pac1;

import java.util.*;
import java.util.concurrent.*;

class A1 {
    public void f() {
        synchronized (this) {
            for (int i = 0; i < 5; i++)
                System.out.println("f()");
        }
    }
}

class B1 {
    public void g() {
        synchronized (this) {
            for (int i = 0; i < 5; i++)
                System.out.println("g()");
        }
    }
}

class C1 {
    public void p() {
        synchronized (this) {
            for (int i = 0; i < 5; i++)
                System.out.println("p()");
        }
    }

}

public class V {
    public static void main(String[] args) {
        A1 a = new A1();
        B1 b = new B1();
        C1 c = new C1();
        new Thread() {
            public void run() {
                a.f();
            }
        }.start();
        new Thread() {
            public void run() {
                c.p();
            }
        }.start();
        b.g();
    }

}
</code>```

Since this code uses different objects to call synchronized methods,  I supposed that it would not prevent them from interfering with each other. However, the result is as follows:

```<code>f()
f()
f()
f()
f()
g()
g()
g()
g()
g()
p()
p()
p()
p()
p()
</code>```

BTW, the result is the same using Lock:

```<code>package pac1;

import java.util.*;
import java.util.concurrent.*;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

class A {
    Lock lock = new ReentrantLock();

    public void f() {
        lock.lock();
        try {
            for (int i = 0; i < 5; i++)
                System.out.println("f()");
        } finally {
            lock.unlock();
        }
    }
}

class B {
    Lock lock = new ReentrantLock();

    public void g() {
        lock.lock();
        try {
            for (int i = 0; i < 5; i++)
                System.out.println("g()");
        } finally {
            lock.unlock();
        }
    }
}

class C {
    Lock lock = new ReentrantLock();

    public void p() {
        lock.lock();
        try {
            for (int i = 0; i < 5; i++)
                System.out.println("p()");
        } finally {
            lock.unlock();
        }
    }
}

public class Ex16 {

    public static void main(String[] args) {
        A a = new A();
        B b = new B();
        C c = new C();
        new Thread() {
            public void run() {
                a.f();
            }
        }.start();
        new Thread() {
            public void run() {
                c.p();
            }
        }.start();
        b.g();
    }

}
</code>```

答:
You don't need a lock or synchronized here. Sychronized is used to lock access to shared mutable state. You don't have any shared mutable state to begin with. </p>

<p>You have 3 threads here and nobody can predict the order in which those threads run because of context switching. I don't see a problem. </p>

Body:
I am learning Java concurrency right now. I came across a piece of code like this:

package pac1;

import java.util.*;
import java.util.concurrent.*;

class A1 {
    public void f() {
        synchronized (this) {
            for (int i = 0; i < 5; i++)
                System.out.println("f()");
        }
    }
}

class B1 {
    public void g() {
        synchronized (this) {
            for (int i = 0; i < 5; i++)
                System.out.println("g()");
        }
    }
}

class C1 {
    public void p() {
        synchronized (this) {
            for (int i = 0; i < 5; i++)
                System.out.println("p()");
        }
    }

}

public class V {
    public static void main(String[] args) {
        A1 a = new A1();
        B1 b = new B1();
        C1 c = new C1();
        new Thread() {
            public void run() {
                a.f();
            }
        }.start();
        new Thread() {
            public void run() {
                c.p();
            }
        }.start();
        b.g();
    }

}

Since this code uses different objects to call synchronized methods,  I supposed that it would not prevent them from interfering with each other. However, the result is as follows:

f()
f()
f()
f()
f()
g()
g()
g()
g()
g()
p()
p()
p()
p()
p()

BTW, the result is the same using Lock:

package pac1;

import java.util.*;
import java.util.concurrent.*;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

class A {
    Lock lock = new ReentrantLock();

    public void f() {
        lock.lock();
        try {
            for (int i = 0; i < 5; i++)
                System.out.println("f()");
        } finally {
            lock.unlock();
        }
    }
}

class B {
    Lock lock = new ReentrantLock();

    public void g() {
        lock.lock();
        try {
            for (int i = 0; i < 5; i++)
                System.out.println("g()");
        } finally {
            lock.unlock();
        }
    }
}

class C {
    Lock lock = new ReentrantLock();

    public void p() {
        lock.lock();
        try {
            for (int i = 0; i < 5; i++)
                System.out.println("p()");
        } finally {
            lock.unlock();
        }
    }
}

public class Ex16 {

    public static void main(String[] args) {
        A a = new A();
        B b = new B();
        C c = new C();
        new Thread() {
            public void run() {
                a.f();
            }
        }.start();
        new Thread() {
            public void run() {
                c.p();
            }
        }.start();
        b.g();
    }

}

Body:
You don't need a lock or synchronized here. Sychronized is used to lock access to shared mutable state. You don't have any shared mutable state to begin with.

You have 3 threads here and nobody can predict the order in which those threads run because of context switching. I don't see a problem.


问:
Codeigniter Htaccess didn't work on win 64-bit
My .htaccess file that worked in my Windows 32-bit XAMPP did not work when  moving my directory to a 64-bit Windows.

This URL works in my 32-bit windows but not on my 64-bit setup for which I get "object not found":

```<code>localhost/folder/controller
</code>```

But this URL does work:

```<code>localhost/folder/index.php/controller
</code>```

Here is my .htaccess file:

```<code>RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php?/$0 [PT,L]
</code>```

答:
please add .htaccess to the root of codeigniter in .htaccess just add this .. and you are good to go..
**

```<code>DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php?/$1 [L,QSA]
</code>```

**

Body:
My .htaccess file that worked in my Windows 32-bit XAMPP did not work when  moving my directory to a 64-bit Windows.

This URL works in my 32-bit windows but not on my 64-bit setup for which I get "object not found":

localhost/folder/controller

But this URL does work:

localhost/folder/index.php/controller

Here is my .htaccess file:

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php?/$0 [PT,L]

Body:
please add .htaccess to the root of codeigniter in .htaccess just add this .. and you are good to go..
**

DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php?/$1 [L,QSA]

**