问:
Blinking cursor after text in SearchView without showing soft keyboard
I am trying to imitate the style of how search is handled by the gmail app which looks as follows:

As shown above there is a (blue) blinking cursor after the search query in the searchView.

My respective code looks like this:

SearchReslutActivity.class

```<code>@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu, menu);

    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView();
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setQuery(getIntent().getStringExtra(SearchManager.QUERY), false);
    searchView.setIconified(false);
    searchView.clearFocus();

    return true;
}
</code>```

menu/search_menu.xml

```<code><menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<item
    android:id="@+id/search"
    android:title="@string/search_title"
    app:actionViewClass="android.support.v7.widget.SearchView"
    app:showAsAction="always" /> </menu>
</code>```

xml/searchable.xml

```<code><searchable xmlns:android="http://schemas.android.com/apk/res/android"
android:hint="@string/hint"
android:includeInGlobalSearch="true"
android:inputType="textCapWords"
android:label="@string/app_name"
android:searchSuggestAuthority="com.webaddress.myproject.data.Provider"
android:searchSuggestIntentAction="android.intent.action.VIEW"
android:searchSuggestIntentData="content://com.webaddress.myproject.data.Provider/table"
android:searchSuggestSelection=" ?"
android:searchSuggestThreshold="1" />
</code>```

The above code achieves the same look as what is displayed in the gmail app except for having a blinking cursor. How can I add such a blinking cursor without requesting focus on the searchView (which in turn will make the soft keyboard pop up again)?

Thanks!

答:
Thanks to @Azizbekian's answer (which did not work on its own for me) I finally got it working with the following code (in an empty project - support libs 25.3.0):

java/MainActivity

```<code>package com.yourwebpage.yourapplication;

import android.app.SearchManager;
import android.os.Bundle;
import android.support.v4.view.MenuItemCompat;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.SearchView;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;

public class MainActivity extends AppCompatActivity {

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    @Override
    public boolean onCreateOptionsMenu(final Menu menu) {
        getMenuInflater().inflate(R.menu.search_menu, menu);
        return true;
    }

    @Override
    public boolean onPrepareOptionsMenu(final Menu menu) {
        MenuItem menuItem = menu.findItem(R.id.search);
        SearchView searchView = (SearchView) MenuItemCompat.getActionView(menuItem);
        searchView.setQuery(getIntent().getStringExtra(SearchManager.QUERY), false);
        searchView.setIconified(false);
        SearchView.SearchAutoComplete searchAutoComplete =
                (SearchView.SearchAutoComplete) searchView.findViewById(R.id.search_src_text);
        searchAutoComplete.setOnFocusChangeListener(new View.OnFocusChangeListener() {
            @Override
            public void onFocusChange(final View v, final boolean hasFocus) {
                v.requestFocus();
            }
        });
        searchView.clearFocus();
        return super.onPrepareOptionsMenu(menu);
    }
}
</code>```

res/layout/activity_main.xml

```<code><?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
    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"
    tools:context="com.yourwebpage.yourapplication.MainActivity">
</android.support.constraint.ConstraintLayout>
</code>```

res/menu/search_menu.xml

```<code><?xml version="1.0" encoding="utf-8"?>
<menu
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">
    <item
        android:id="@+id/search"
        android:title="Search"
        app:actionViewClass="android.support.v7.widget.SearchView"
        app:showAsAction="always"/>
</menu>
</code>```

manifests/AndroidManifest.xml

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

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

</manifest>
</code>```

I am posting this rather comprehensive solution in the hope of making it reproducible thereby.

Body:
I am trying to imitate the style of how search is handled by the gmail app which looks as follows:

As shown above there is a (blue) blinking cursor after the search query in the searchView.

My respective code looks like this:

SearchReslutActivity.class

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu, menu);

    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView();
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setQuery(getIntent().getStringExtra(SearchManager.QUERY), false);
    searchView.setIconified(false);
    searchView.clearFocus();

    return true;
}

menu/search_menu.xml

<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<item
    android:id="@+id/search"
    android:title="@string/search_title"
    app:actionViewClass="android.support.v7.widget.SearchView"
    app:showAsAction="always" /> </menu>

xml/searchable.xml

<searchable xmlns:android="http://schemas.android.com/apk/res/android"
android:hint="@string/hint"
android:includeInGlobalSearch="true"
android:inputType="textCapWords"
android:label="@string/app_name"
android:searchSuggestAuthority="com.webaddress.myproject.data.Provider"
android:searchSuggestIntentAction="android.intent.action.VIEW"
android:searchSuggestIntentData="content://com.webaddress.myproject.data.Provider/table"
android:searchSuggestSelection=" ?"
android:searchSuggestThreshold="1" />

The above code achieves the same look as what is displayed in the gmail app except for having a blinking cursor. How can I add such a blinking cursor without requesting focus on the searchView (which in turn will make the soft keyboard pop up again)?

Thanks!

Body:
Thanks to @Azizbekian's answer (which did not work on its own for me) I finally got it working with the following code (in an empty project - support libs 25.3.0):

java/MainActivity

package com.yourwebpage.yourapplication;

import android.app.SearchManager;
import android.os.Bundle;
import android.support.v4.view.MenuItemCompat;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.SearchView;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;

public class MainActivity extends AppCompatActivity {

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    @Override
    public boolean onCreateOptionsMenu(final Menu menu) {
        getMenuInflater().inflate(R.menu.search_menu, menu);
        return true;
    }

    @Override
    public boolean onPrepareOptionsMenu(final Menu menu) {
        MenuItem menuItem = menu.findItem(R.id.search);
        SearchView searchView = (SearchView) MenuItemCompat.getActionView(menuItem);
        searchView.setQuery(getIntent().getStringExtra(SearchManager.QUERY), false);
        searchView.setIconified(false);
        SearchView.SearchAutoComplete searchAutoComplete =
                (SearchView.SearchAutoComplete) searchView.findViewById(R.id.search_src_text);
        searchAutoComplete.setOnFocusChangeListener(new View.OnFocusChangeListener() {
            @Override
            public void onFocusChange(final View v, final boolean hasFocus) {
                v.requestFocus();
            }
        });
        searchView.clearFocus();
        return super.onPrepareOptionsMenu(menu);
    }
}

res/layout/activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
    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"
    tools:context="com.yourwebpage.yourapplication.MainActivity">
</android.support.constraint.ConstraintLayout>

res/menu/search_menu.xml

<?xml version="1.0" encoding="utf-8"?>
<menu
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">
    <item
        android:id="@+id/search"
        android:title="Search"
        app:actionViewClass="android.support.v7.widget.SearchView"
        app:showAsAction="always"/>
</menu>

manifests/AndroidManifest.xml

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

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

</manifest>

I am posting this rather comprehensive solution in the hope of making it reproducible thereby.


来源: stackexchange

问:
Is there any way to determine the type of a mountpoint?
I've got a bash script that deals with files in Mac OS X 10.5 & 10.6. It now needs to determine whether the files are on a local volume or a remote AFP volume. All mountpoints are in /Volumes on Mac OS X, but I cannot see any difference between local & remote volumes, at least with ls -al (except for the boot volume, which is a symlink to /).

Is there a way to programatically, esp. something that can be easily called from a bash script (I really don't want to rewrite this in C/Obj-C with OS X-specific APIs, unless absolutely necessary), to determine the source or type of a mountpoint? Even what device a volume maps to (assuming volumes mounted with mount_afp, mount_smbfs, mount_webdav, etc., won't point back to a device in /dev) so I have some way of guessing whether it's local or not?

答:
Does the plain

```<code>$ mount
</code>```

command without any additional args tell you what you need?

ContentLicense: CC BY-SA 2.5

Body:
Does the plain

$ mount

command without any additional args tell you what you need?


问:
How to embed Telegram chat views in Ionic app
I am building an Ionic application and want to integrate Telegram's web client(Webogram) into my application.
Currently I am redirecting from my ionic application to webogram using:

```<code>window.location.href ="signin.html#/";
</code>```

Now I want to embed the view of webogram chat into a div in my view.
Is there any way of accomplishing this?

Webogram link : https://github.com/zhukov/webogram

答:
The appropriate way is inserting an IFRAME tag inside the DIV tag that you want to display the desired web page.</p>

```<code><DIV class="..." id="..." style="...">
<IFRAME src="..."></IFRAME>
</DIV>
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I am building an Ionic application and want to integrate Telegram's web client(Webogram) into my application.
Currently I am redirecting from my ionic application to webogram using:

window.location.href ="signin.html#/";

Now I want to embed the view of webogram chat into a div in my view.
Is there any way of accomplishing this?

Webogram link : https://github.com/zhukov/webogram

Body:
The appropriate way is inserting an IFRAME tag inside the DIV tag that you want to display the desired web page.

<DIV class="..." id="..." style="...">
<IFRAME src="..."></IFRAME>
</DIV>


问:
SQL query using code igniter
How can I write this query to a code igniter query?

```<code>WHERE
  SmallVersion.ID =
  (
    SELECT ChildSmallVersionID AS ID FROM SmallVersion
    WHERE ID = $id
  )
</code>```

this is how is looks so far:

```<code>         ->where('SmallVersion.ID', ("SELECT `ChildSmallVersionID` AS ID
                  FROM `SmallVersion` WHERE ID = $id"));
</code>```

答:
Mateusz Wojtula's answer looks ok but you can protect your query</p>

```<code>$strSubQuery = $this->db
    ->select("ChildSmallVersionID AS ID")
    ->from("SmallVersion")
    ->where("ID",$id)
    ->get_compiled_select();

$where = "SmallVersion.ID = (".$strSubQuery.")";
$this->db->where($where, NULL, FALSE);
</code>```

Title: SQL query using code igniter

Body:
How can I write this query to a code igniter query?

WHERE
  SmallVersion.ID =
  (
    SELECT ChildSmallVersionID AS ID FROM SmallVersion
    WHERE ID = $id
  )

this is how is looks so far:

         ->where('SmallVersion.ID', ("SELECT `ChildSmallVersionID` AS ID
                  FROM `SmallVersion` WHERE ID = $id"));

Body:
Mateusz Wojtula's answer looks ok but you can protect your query

$strSubQuery = $this->db
    ->select("ChildSmallVersionID AS ID")
    ->from("SmallVersion")
    ->where("ID",$id)
    ->get_compiled_select();

$where = "SmallVersion.ID = (".$strSubQuery.")";
$this->db->where($where, NULL, FALSE);


问:
How to bind the RUN action to correct NodeJS version in Cloud9?

Background

I have a very sinmple nodejs app that uses the Object Destructur Operator of ECMA6

```<code>"use strict";

function bananas(){
    return {
        type: "fruit",
        color: "yellow"
    };
}

function eat(){
    var {
        type,
        color
    } = bananas();

    return `I eat ${type} colored ${color}`;
}

console.log(eat());
</code>```

Problem

When I click the run button of index.js (or when you go right-click index.js and then select "Run this file")

I get the following error:

```<code>Debugger listening on [::]:15454
/home/ubuntu/workspace/server/index.js:16
    var {
        ^

SyntaxError: Unexpected token {
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:373:25)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.runMain [as _onTimeout] (module.js:441:10)
    at Timer.listOnTimeout (timers.js:92:15)
</code>```

However, if I type in the bash command line node index.js I get the expected output:

I eat fruit colored yellow

Furthermore, typing node -v outputs:

v7.8.0

Question

It is my strong believe that the run option is not picking up the correct version of node.
How can I fix that?

Notes

To update node I used nvm install 7.

答:
Answer

My identification of the issue was correct. To fix it one needs to run the following command:

```<code>nvm alias default 7
</code>```

Credits

Kudos++ to Harutyun for the answer.

Body:
Background

I have a very sinmple nodejs app that uses the Object Destructur Operator of ECMA6

"use strict";

function bananas(){
    return {
        type: "fruit",
        color: "yellow"
    };
}

function eat(){
    var {
        type,
        color
    } = bananas();

    return `I eat ${type} colored ${color}`;
}

console.log(eat());

Problem

When I click the run button of index.js (or when you go right-click index.js and then select "Run this file")

I get the following error:

Debugger listening on [::]:15454
/home/ubuntu/workspace/server/index.js:16
    var {
        ^

SyntaxError: Unexpected token {
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:373:25)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.runMain [as _onTimeout] (module.js:441:10)
    at Timer.listOnTimeout (timers.js:92:15)

However, if I type in the bash command line node index.js I get the expected output:

I eat fruit colored yellow

Furthermore, typing node -v outputs:

v7.8.0

Question

It is my strong believe that the run option is not picking up the correct version of node.
How can I fix that?

Notes

To update node I used nvm install 7.

Body:
Answer

My identification of the issue was correct. To fix it one needs to run the following command:

nvm alias default 7

Credits

Kudos++ to Harutyun for the answer.


问:
Android 5.0 - ProgressBar cannot be displayed over a Button
I think the title is pretty explicit about my problem... So here is my layout :

```<code>            <RelativeLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content">

                <Button
                    android:id="@+id/button_action"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="Login" />

                <ProgressBar
                    android:id="@+id/progress_bar"
                    android:layout_width="50dp"
                    android:layout_height="50dp"
                    android:layout_centerInParent="true"/>

            </RelativeLayout>
</code>```

On android SDKs < 21, no problem, the ProgressBar is correctly displayed over the Button and centered in the Button. But on Android 5.0, the ProgressBar is displayed behind the Button.

So you can see it's correctly positionned it when you activate the option "Show layout bounds" in Developer Options settings, but you can't see anything on the screen without that option.

Would anybody know how to fix this? I guess it's a matter of elevation recently introduced, but I really don't know how to take care of it.
For the record, I'm using the recently released Theme.AppCompat style from the support.v7.

EDIT:

I also tried to apply setElevation(0) and setTranslationY(0) to the Button programmatically but it didn't change anything. So I wonder if it has to deal with the elevation.

答:
Same issue here, my simple "hack" was too wrap the Button into another FrameLayout.
This way I don't care about the api version and other elevation issue ;)</p>

```<code><FrameLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center" >

        <FrameLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content">
                <Button
                    android:id="@+id/button_action"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="Login" />
        </FrameLayout>

        <ProgressBar
            android:id="@+id/progress_bar"
            android:layout_width="50dp"
            android:layout_height="50dp" />
</FrameLayout>
</code>```

ContentLicense: CC BY-SA 4.0

Body:
I think the title is pretty explicit about my problem... So here is my layout :

            <RelativeLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content">

                <Button
                    android:id="@+id/button_action"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="Login" />

                <ProgressBar
                    android:id="@+id/progress_bar"
                    android:layout_width="50dp"
                    android:layout_height="50dp"
                    android:layout_centerInParent="true"/>

            </RelativeLayout>

On android SDKs < 21, no problem, the ProgressBar is correctly displayed over the Button and centered in the Button. But on Android 5.0, the ProgressBar is displayed behind the Button.

So you can see it's correctly positionned it when you activate the option "Show layout bounds" in Developer Options settings, but you can't see anything on the screen without that option.

Would anybody know how to fix this? I guess it's a matter of elevation recently introduced, but I really don't know how to take care of it.
For the record, I'm using the recently released Theme.AppCompat style from the support.v7.

EDIT:

I also tried to apply setElevation(0) and setTranslationY(0) to the Button programmatically but it didn't change anything. So I wonder if it has to deal with the elevation.

Body:
Same issue here, my simple "hack" was too wrap the Button into another FrameLayout.
This way I don't care about the api version and other elevation issue ;)

<FrameLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center" >

        <FrameLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content">
                <Button
                    android:id="@+id/button_action"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="Login" />
        </FrameLayout>

        <ProgressBar
            android:id="@+id/progress_bar"
            android:layout_width="50dp"
            android:layout_height="50dp" />
</FrameLayout>


问:
How to extract all alphabetical characters from a string and store as a 1-dim array?
I have a variable $var = "My name's Ankit". I want to store all the English alphabet characters of $var into an array $charvar. I know that I can use a simple for loop over the entire length of $var and array_push the characters if they are English characters else ignore. However, I wanted to know if PHP provides some function which can do this.
What I want in $charvar is:

```<code>Array
(
        [0] => M
        [1] => y
        [2] => n
        [3] => a
        [4] => m
        [5] => e
        [6] => s
        [7] => A
        [8] => n
        [9] => k
        [10] => i
        [11] => t
)
</code>```

Body:
I have a variable $var = "My name's Ankit". I want to store all the English alphabet characters of $var into an array $charvar. I know that I can use a simple for loop over the entire length of $var and array_push the characters if they are English characters else ignore. However, I wanted to know if PHP provides some function which can do this.
What I want in $charvar is:

Array
(
        [0] => M
        [1] => y
        [2] => n
        [3] => a
        [4] => m
        [5] => e
        [6] => s
        [7] => A
        [8] => n
        [9] => k
        [10] => i
        [11] => t
)

Body:
PHP code demo

preg_match_all("![a-zA-Z0-9]!", "My name's Ankit",$matches);
print_r($matches);

Output:

Array
(
    [0] => Array
        (
            [0] => M
            [1] => y
            [2] => n
            [3] => a
            [4] => m
            [5] => e
            [6] => s
            [7] => A
            [8] => n
            [9] => k
            [10] => i
            [11] => t
        )

)


问:
Different width and height from DisplayMetrics and $(window).width() in WebView
Inside an Android app, I tried using the following way to obtain the screen width and height:

```<code>DisplayMetrics metrics = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(metrics);
        final int screenWidth = metrics.widthPixels;
        final int screenHeight = metrics.heightPixels;
</code>```

This reports 1080 and 1920 respectively for my phone, which matches the specs.

However, inside a webview, when I used:

```<code>var screenWidth = $(window).width();
</code>```

This reports only 360.

From this what I understand, both are using pixel as unit, so why are the values different?

答:
I figured out that the dpi of your device belongs to xxhdpi

Where 300 dpi can be converted as 1080 pixels width.

and 640 dpi can be converted as 1920 pixels.

also you can include;

```<code> private int convertDpToPixel(int dp) {
    Resources r = getResources();
    float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp,
r.getDisplayMetrics());
    return (int) px;
}
</code>```

Body:
Inside an Android app, I tried using the following way to obtain the screen width and height:

DisplayMetrics metrics = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(metrics);
        final int screenWidth = metrics.widthPixels;
        final int screenHeight = metrics.heightPixels;

This reports 1080 and 1920 respectively for my phone, which matches the specs.

However, inside a webview, when I used:

var screenWidth = $(window).width();

This reports only 360.

From this what I understand, both are using pixel as unit, so why are the values different?

Body:
I figured out that the dpi of your device belongs to xxhdpi

Where 300 dpi can be converted as 1080 pixels width.

and 640 dpi can be converted as 1920 pixels.

also you can include;

 private int convertDpToPixel(int dp) {
    Resources r = getResources();
    float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp,
r.getDisplayMetrics());
    return (int) px;
}


问:
How to install the Sun Java JDK on Ubuntu 10.10 (Maverick Meerkat)?
I've tried to add the Canonical Partner repository, but I still can't find the sun-java6-jdk package. What is the right way to install the Oracle Sun JDK instead of OpenJDK on Ubuntu 10.10 (Maverick Meerkat)?

答:
```<code>sudo add-apt-repository ppa:sun-java-community-team/sun-java6

sudo apt-get update

sudo apt-get install sun-java6-jre sun-java6-bin sun-java6-jdk
</code>```


问:
Set up Firebase and the Dynamic Links SDK IOS
I've followed the steps described in Firebase Dynamic Links doc for setting up dynamic links for iOS, but when I check

```<code>https://my_app_code.app.goo.gl/apple-app-site-association
</code>```

the details node is always empty.

Did anyone had this issue? Thanks.

答: Maybe It is a little bit late for you but for those with the same problem, it takes some minutes since you introduce all the fields in Dynamic Links Setup.</p>

Body:
I've followed the steps described in Firebase Dynamic Links doc for setting up dynamic links for iOS, but when I check

https://my_app_code.app.goo.gl/apple-app-site-association

the details node is always empty.

Did anyone had this issue? Thanks.


问:
writing a json object to buffer in nodejs
I am trying to use amqplib a AMQP 0-9-1 library and client for Node.JS

and I have a question about buffers. How can I write a JSON object to them.

The channel.publish requires content in the form of a buffer.

And after I publish the message, when I consume them in the worker, how can I extract the message again from the buffer to get the JavaScript object back.

The message object passed to the consumer is of the form

```<code>{
  content: Buffer,
  fields: Object,
  properties: Object
}
</code>```

where content is the content we passed to the publisher

答:
```<code>JSON.parse(message.content)
</code>```

Should work

Body:
I am trying to use amqplib a AMQP 0-9-1 library and client for Node.JS

and I have a question about buffers. How can I write a JSON object to them.

The channel.publish requires content in the form of a buffer.

And after I publish the message, when I consume them in the worker, how can I extract the message again from the buffer to get the JavaScript object back.

The message object passed to the consumer is of the form

{
  content: Buffer,
  fields: Object,
  properties: Object
}

where content is the content we passed to the publisher

Body:
JSON.parse(message.content)

Should work


问:
Start the activity when receiving a message from the service FCM?
today I needed solving, how to automatically start the activity when receiving a message from the service FCM.

I've made a function call activity and only managed to get called when the user opens the application only. But could not be called when the smartphone is in a state of lock screen, home screen or the user is opening another application.

This is part of my code:

```<code>public class MyFirebaseMessagingService extends FirebaseMessagingService {

     private static final String TAG = "MyFirebaseMsgService";

     @Override
     public void onMessageReceived (RemoteMessage remoteMessage) {
         Bundle args = new Bundle ();
         Intent intent = new Intent (this, ProgressOrderActivity.class);
         intent.setFlags (Intent.FLAG_ACTIVITY_NEW_TASK);
         intent.putExtras (args);
         startActivity (intent);
     }

}
</code>```

SO how to solve it ?

答:
This is my MyFirebaseMessagingService class you can use it

```<code>public class MyFirebaseMessagingService extends FirebaseMessagingService {

    private static final String TAG = MyFirebaseMessagingService.class.getSimpleName();

    private NotificationUtils notificationUtils;

    @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {
        Log.e(TAG, "From: " + remoteMessage.getFrom());

        if (remoteMessage == null)
            return;

        // Check if message contains a notification payload.
        if (remoteMessage.getNotification() != null) {
            Log.e(TAG, "Notification Body: " + remoteMessage.getNotification().getBody());
            handleNotification(remoteMessage.getNotification().getBody());
        }

        // Check if message contains a data payload.
        if (remoteMessage.getData().size() > 0) {
            Log.e(TAG, "Data Payload: " + remoteMessage.getData().toString());

            try {
                JSONObject json = new JSONObject(remoteMessage.getData().toString());
                handleDataMessage(json);
            } catch (Exception e) {
                Log.e(TAG, "Exception: " + e.getMessage());
            }
        }
    }

    private void handleNotification(String message) {
        if (!NotificationUtils.isAppIsInBackground(getApplicationContext())) {
            // app is in foreground, broadcast the push message
            Intent pushNotification = new Intent("pushNotification");
            pushNotification.putExtra("message", message);
            LocalBroadcastManager.getInstance(this).sendBroadcast(pushNotification);

            // play notification sound
            NotificationUtils notificationUtils = new NotificationUtils(getApplicationContext());
            notificationUtils.playNotificationSound();
        }else{
            // If the app is in background, firebase itself handles the notification
        }
    }

    private void handleDataMessage(JSONObject json) {
        Log.e(TAG, "push json: " + json.toString());

        try {
            JSONObject data = json.getJSONObject("data");

            String title = data.getString("title");
            String message = data.getString("message");
            boolean isBackground = data.getBoolean("is_background");
            String imageUrl = data.getString("image");
            String timestamp = data.getString("timestamp");
            JSONObject payload = data.getJSONObject("payload");

            Log.e(TAG, "title: " + title);
            Log.e(TAG, "message: " + message);
            Log.e(TAG, "isBackground: " + isBackground);
            Log.e(TAG, "payload: " + payload.toString());
            Log.e(TAG, "imageUrl: " + imageUrl);
            Log.e(TAG, "timestamp: " + timestamp);

            if (!NotificationUtils.isAppIsInBackground(getApplicationContext())) {
                // app is in foreground, broadcast the push message
                Intent pushNotification = new Intent(""pushNotification);
                pushNotification.putExtra("message", message);
                LocalBroadcastManager.getInstance(this).sendBroadcast(pushNotification);

                // play notification sound
                NotificationUtils notificationUtils = new NotificationUtils(getApplicationContext());
                notificationUtils.playNotificationSound();
            } else {
                // app is in background, show the notification in notification tray
                Intent resultIntent = new Intent(getApplicationContext(), YourActivity.class);
                resultIntent.putExtra("message", message);

                // check for image attachment
                if (TextUtils.isEmpty(imageUrl)) {
                    showNotificationMessage(getApplicationContext(), title, message, timestamp, resultIntent);
                } else {
                    // image is present, show notification with image
                    showNotificationMessageWithBigImage(getApplicationContext(), title, message, timestamp, resultIntent, imageUrl);
                }
            }
        } catch (JSONException e) {
            Log.e(TAG, "Json Exception: " + e.getMessage());
        } catch (Exception e) {
            Log.e(TAG, "Exception: " + e.getMessage());
        }
    }

    /**
     * Showing notification with text only
     */
    private void showNotificationMessage(Context context, String title, String message, String timeStamp, Intent intent) {
        notificationUtils = new NotificationUtils(context);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
        notificationUtils.showNotificationMessage(title, message, timeStamp, intent);
    }

    /**
     * Showing notification with text and image
     */
    private void showNotificationMessageWithBigImage(Context context, String title, String message, String timeStamp, Intent intent, String imageUrl) {
        notificationUtils = new NotificationUtils(context);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
        notificationUtils.showNotificationMessage(title, message, timeStamp, intent, imageUrl);
    }
}
</code>```

use this code if still problem then inform me@Amay

Body:
today I needed solving, how to automatically start the activity when receiving a message from the service FCM.

I've made a function call activity and only managed to get called when the user opens the application only. But could not be called when the smartphone is in a state of lock screen, home screen or the user is opening another application.

This is part of my code:

public class MyFirebaseMessagingService extends FirebaseMessagingService {

     private static final String TAG = "MyFirebaseMsgService";

     @Override
     public void onMessageReceived (RemoteMessage remoteMessage) {
         Bundle args = new Bundle ();
         Intent intent = new Intent (this, ProgressOrderActivity.class);
         intent.setFlags (Intent.FLAG_ACTIVITY_NEW_TASK);
         intent.putExtras (args);
         startActivity (intent);
     }

}

SO how to solve it ?

Body:
This is my MyFirebaseMessagingService class you can use it

public class MyFirebaseMessagingService extends FirebaseMessagingService {

    private static final String TAG = MyFirebaseMessagingService.class.getSimpleName();

    private NotificationUtils notificationUtils;

    @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {
        Log.e(TAG, "From: " + remoteMessage.getFrom());

        if (remoteMessage == null)
            return;

        // Check if message contains a notification payload.
        if (remoteMessage.getNotification() != null) {
            Log.e(TAG, "Notification Body: " + remoteMessage.getNotification().getBody());
            handleNotification(remoteMessage.getNotification().getBody());
        }

        // Check if message contains a data payload.
        if (remoteMessage.getData().size() > 0) {
            Log.e(TAG, "Data Payload: " + remoteMessage.getData().toString());

            try {
                JSONObject json = new JSONObject(remoteMessage.getData().toString());
                handleDataMessage(json);
            } catch (Exception e) {
                Log.e(TAG, "Exception: " + e.getMessage());
            }
        }
    }

    private void handleNotification(String message) {
        if (!NotificationUtils.isAppIsInBackground(getApplicationContext())) {
            // app is in foreground, broadcast the push message
            Intent pushNotification = new Intent("pushNotification");
            pushNotification.putExtra("message", message);
            LocalBroadcastManager.getInstance(this).sendBroadcast(pushNotification);

            // play notification sound
            NotificationUtils notificationUtils = new NotificationUtils(getApplicationContext());
            notificationUtils.playNotificationSound();
        }else{
            // If the app is in background, firebase itself handles the notification
        }
    }

    private void handleDataMessage(JSONObject json) {
        Log.e(TAG, "push json: " + json.toString());

        try {
            JSONObject data = json.getJSONObject("data");

            String title = data.getString("title");
            String message = data.getString("message");
            boolean isBackground = data.getBoolean("is_background");
            String imageUrl = data.getString("image");
            String timestamp = data.getString("timestamp");
            JSONObject payload = data.getJSONObject("payload");

            Log.e(TAG, "title: " + title);
            Log.e(TAG, "message: " + message);
            Log.e(TAG, "isBackground: " + isBackground);
            Log.e(TAG, "payload: " + payload.toString());
            Log.e(TAG, "imageUrl: " + imageUrl);
            Log.e(TAG, "timestamp: " + timestamp);

            if (!NotificationUtils.isAppIsInBackground(getApplicationContext())) {
                // app is in foreground, broadcast the push message
                Intent pushNotification = new Intent(""pushNotification);
                pushNotification.putExtra("message", message);
                LocalBroadcastManager.getInstance(this).sendBroadcast(pushNotification);

                // play notification sound
                NotificationUtils notificationUtils = new NotificationUtils(getApplicationContext());
                notificationUtils.playNotificationSound();
            } else {
                // app is in background, show the notification in notification tray
                Intent resultIntent = new Intent(getApplicationContext(), YourActivity.class);
                resultIntent.putExtra("message", message);

                // check for image attachment
                if (TextUtils.isEmpty(imageUrl)) {
                    showNotificationMessage(getApplicationContext(), title, message, timestamp, resultIntent);
                } else {
                    // image is present, show notification with image
                    showNotificationMessageWithBigImage(getApplicationContext(), title, message, timestamp, resultIntent, imageUrl);
                }
            }
        } catch (JSONException e) {
            Log.e(TAG, "Json Exception: " + e.getMessage());
        } catch (Exception e) {
            Log.e(TAG, "Exception: " + e.getMessage());
        }
    }

    /**
     * Showing notification with text only
     */
    private void showNotificationMessage(Context context, String title, String message, String timeStamp, Intent intent) {
        notificationUtils = new NotificationUtils(context);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
        notificationUtils.showNotificationMessage(title, message, timeStamp, intent);
    }

    /**
     * Showing notification with text and image
     */
    private void showNotificationMessageWithBigImage(Context context, String title, String message, String timeStamp, Intent intent, String imageUrl) {
        notificationUtils = new NotificationUtils(context);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
        notificationUtils.showNotificationMessage(title, message, timeStamp, intent, imageUrl);
    }
}

use this code if still problem then inform me@Amay


问:
Sort php array based on current time
I am currently using the following json data. (The key is a time hh:mm)

```<code> "chart": {
    "23:20": 11,
    "23:30": 11,
    "23:40": 11,
    "23:50": 16,
    "00:00": 16,
    "00:10": 14,
    "00:20": 11,
    "00:30": 12,
    "00:40": 14,
    "00:50": 10,
    "01:00": 8,
    "01:10": 12,
    "01:20": 15,
    "01:30": 13,
    "01:40": 11,
    "01:50": 8,
    "02:00": 8
 }
</code>```

https://pastebin.com/cp16Rr9w

I am then moving the data to a php array. I would like to sort the array, so it starts at the current server time and goes on from there.

At the moment i am using the following php (unsorted)

```<code>  <?php
    foreach ($data['chart'] as $key => $value){
        echo 'Time: '.$key.'Data: '.$value;
    }
  ?>
</code>```

答:
The easiest approach perhaps would be to filter out all "too old" entries first with array_filter() and then sort the resulting array using ksort():

```<code><?php

function getFilter($server_time) {
    return function($item) use($server_time) {
       return (strtotime($item) >= $server_time);
    };
}

$data = '{"chart": {
          "23:20": 11,"23:30": 11,"23:40": 11,"23:50": 16,"00:00": 16,
          "00:10": 14,"00:20": 11,"00:30": 12,"00:40": 14,"00:50": 10,
          "01:00": 8,"01:10": 12,"01:20": 15,"01:30": 13,"01:40": 11,
          "01:50": 8,"02:00": 8
}}';

$json = json_decode($data, true);
$src = $json['chart'];

$server_time = strtotime("now");

$filtered = array_filter($src, getFilter($server_time), ARRAY_FILTER_USE_KEY);
ksort($filtered);

print_r($filtered);
</code>```

Live test case: https://3v4l.org/M3RLm

Title: Sort php array based on current time

Body:
I am currently using the following json data. (The key is a time hh:mm)

 "chart": {
    "23:20": 11,
    "23:30": 11,
    "23:40": 11,
    "23:50": 16,
    "00:00": 16,
    "00:10": 14,
    "00:20": 11,
    "00:30": 12,
    "00:40": 14,
    "00:50": 10,
    "01:00": 8,
    "01:10": 12,
    "01:20": 15,
    "01:30": 13,
    "01:40": 11,
    "01:50": 8,
    "02:00": 8
 }

https://pastebin.com/cp16Rr9w

I am then moving the data to a php array. I would like to sort the array, so it starts at the current server time and goes on from there.

At the moment i am using the following php (unsorted)

  <?php
    foreach ($data['chart'] as $key => $value){
        echo 'Time: '.$key.'Data: '.$value;
    }
  ?>

Body:
The easiest approach perhaps would be to filter out all "too old" entries first with array_filter() and then sort the resulting array using ksort():

<?php

function getFilter($server_time) {
    return function($item) use($server_time) {
       return (strtotime($item) >= $server_time);
    };
}

$data = '{"chart": {
          "23:20": 11,"23:30": 11,"23:40": 11,"23:50": 16,"00:00": 16,
          "00:10": 14,"00:20": 11,"00:30": 12,"00:40": 14,"00:50": 10,
          "01:00": 8,"01:10": 12,"01:20": 15,"01:30": 13,"01:40": 11,
          "01:50": 8,"02:00": 8
}}';

$json = json_decode($data, true);
$src = $json['chart'];

$server_time = strtotime("now");

$filtered = array_filter($src, getFilter($server_time), ARRAY_FILTER_USE_KEY);
ksort($filtered);

print_r($filtered);

Live test case: https://3v4l.org/M3RLm


问:
How to display attached images on single.php file in wordpress
Maybe someone solved this problem sorry if I am asking again this question. I have one post displaying on front page now this post has one feature Image along with other images and gallery.

What I want when user click on post so it will go on single.php to show full post view. I want to display on this single.php view an image and some text as well as a custom gallery images but not the feature image.

how can I achieve this I wrote one code but it did not work.

```<code>function displayPostImages() {

global $post; function

$attachments = get_children(array('post_parent' => $post->ID, 'order' => 'ASC', 'orderby' => 'menu_order', 'post_type' => 'attachment', 'post_mime_type' => 'image' ));

$image =  get_post_thumbnail_id( $post->ID); // featured_image ID
$featured_image = wp_get_attachment_image_src($image);

if ($attachments) { // if there are images attached to posting, start the flexslider markup
    foreach ( $attachments as $attachment_id => $attachment ) {

    if($attachment->ID != $image && $featured_image ){

    $img_source = wp_get_attachment_image_src( $attachment_id, 'full' )[0];

    //print_r($img_source);
?>

// here will be HTML to display TOP images text and gallery images.

<?php
             }
         }
     }
 }
displayPostImages();
?>
</code>```

答:
and what is returned your function?
I don`t see "return" or "echo $someresult";

empty or not this array $attachments = get_children....

Body:
Maybe someone solved this problem sorry if I am asking again this question. I have one post displaying on front page now this post has one feature Image along with other images and gallery.

What I want when user click on post so it will go on single.php to show full post view. I want to display on this single.php view an image and some text as well as a custom gallery images but not the feature image.

how can I achieve this I wrote one code but it did not work.

function displayPostImages() {

global $post; function

$attachments = get_children(array('post_parent' => $post->ID, 'order' => 'ASC', 'orderby' => 'menu_order', 'post_type' => 'attachment', 'post_mime_type' => 'image' ));

$image =  get_post_thumbnail_id( $post->ID); // featured_image ID
$featured_image = wp_get_attachment_image_src($image);

if ($attachments) { // if there are images attached to posting, start the flexslider markup
    foreach ( $attachments as $attachment_id => $attachment ) {

    if($attachment->ID != $image && $featured_image ){

    $img_source = wp_get_attachment_image_src( $attachment_id, 'full' )[0];

    //print_r($img_source);
?>

// here will be HTML to display TOP images text and gallery images.

<?php
             }
         }
     }
 }
displayPostImages();
?>


问:
friend vs member functions in Operator Overloading C++
Previously I learnt about overloading Operators in C++ as member functions as well as friend functions of a class. Although, I know how to overload operators in C++ using both techniques. But I am still confused that ** which one is better** ? A member function or a friend function to overload operators, which one should i use and why?
 Please guide me ! Your response will be appreciated greatly. I shall be glad and thankful for your answers.</p>

答:
Not far from a matter of taste, but some use cases clearly require one of the two ways.

When the operator takes as arguments only members of the class you are designing, encapsulation votes for using a member function. Example: addition of two objects:

```<code>class A {
    ...
    A operator + (const class A& other);   // naturally a member function
    ...
};
</code>```

In the opposite, when the member of the class you are writing is the second argument of the operator, you can only use a friend function

```<code>std::outstream& operator << (std::outstream& out, const class A& a);

class A {
    ...
    friend std::outstream& operator << (std::outstream& out, const class A& a); // must be friend here
};
</code>```

At most it could be a member of std::outstream but A class did not exist when std::outstream class was created in the standard C++ library...

Body:
Not far from a matter of taste, but some use cases clearly require one of the two ways.

When the operator takes as arguments only members of the class you are designing, encapsulation votes for using a member function. Example: addition of two objects:

class A {
    ...
    A operator + (const class A& other);   // naturally a member function
    ...
};

In the opposite, when the member of the class you are writing is the second argument of the operator, you can only use a friend function

std::outstream& operator << (std::outstream& out, const class A& a);

class A {
    ...
    friend std::outstream& operator << (std::outstream& out, const class A& a); // must be friend here
};

At most it could be a member of std::outstream but A class did not exist when std::outstream class was created in the standard C++ library...


问:
Deploying a netcoreapp1.1 to Azure
I have netcoreapp1.1 that I am trying to publish to Azure with WebDeploy. I am able to do dotnet publish and deploy the contents to Azure, but the site just says "You do not have permission to view this directory or page.", which suggests the app is not running.

My previous apps have used net461 as target framework and I have noticed that publishing these (with dotnet publish) have caused a web.config file to be created, which explains how IIS is able to run it, but this does not happen when the target framework is netcoreapp1.1.

The command I have been using to publish is this:
dotnet publish --configuration Release --runtime win7-x64 --output .deploy

Here is my project file:

```<code><Project Sdk="FSharp.NET.Sdk;Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp1.1</TargetFramework>
    <RuntimeIdentifiers>win7-x64</RuntimeIdentifiers>
    <OutputType>Exe</OutputType>
  </PropertyGroup>
  <PropertyGroup>
     </PropertyGroup>

  <ItemGroup>
    <Compile Include="Controllers/*.fs" />
    <Compile Include="Startup.fs" />
    <Compile Include="Program.fs" />

    <None Remove="**/*.fs" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="FSharp.Core" Version="4.1.*" />
    <PackageReference Include="FSharp.NET.Sdk" Version="1.0.*" PrivateAssets="All" />
    <PackageReference Include="Microsoft.AspNetCore" Version="1.1.1" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" />
    <PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.1" />
    <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.1" />
  </ItemGroup>

  <ItemGroup>
    <DotNetCliToolReference Include="Microsoft.DotNet.Watcher.Tools" Version="1.0.0" />
  </ItemGroup>

</Project>
</code>```

How am I meant to run a netcoreapp1.1 on Azure? Does it have to be self contained or is it possible to have the Azure App Service run it from dlls?

Edit:

Manually copying a web.config into my publish directory I am able to get the app to run. How can I make dotnet publish create it automatically?
Also, I am still curious about my previous questions.

答:
Add info into you csproj file that you need to copy web.config, like this:

```<code><ItemGroup>
  <Content Update="web.config">
    <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
  </Content>
</ItemGroup>
</code>```

Title: Deploying a netcoreapp1.1 to Azure

Body:
I have netcoreapp1.1 that I am trying to publish to Azure with WebDeploy. I am able to do dotnet publish and deploy the contents to Azure, but the site just says "You do not have permission to view this directory or page.", which suggests the app is not running.

My previous apps have used net461 as target framework and I have noticed that publishing these (with dotnet publish) have caused a web.config file to be created, which explains how IIS is able to run it, but this does not happen when the target framework is netcoreapp1.1.

The command I have been using to publish is this:
dotnet publish --configuration Release --runtime win7-x64 --output .deploy

Here is my project file:

<Project Sdk="FSharp.NET.Sdk;Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp1.1</TargetFramework>
    <RuntimeIdentifiers>win7-x64</RuntimeIdentifiers>
    <OutputType>Exe</OutputType>
  </PropertyGroup>
  <PropertyGroup>
     </PropertyGroup>

  <ItemGroup>
    <Compile Include="Controllers/*.fs" />
    <Compile Include="Startup.fs" />
    <Compile Include="Program.fs" />

    <None Remove="**/*.fs" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="FSharp.Core" Version="4.1.*" />
    <PackageReference Include="FSharp.NET.Sdk" Version="1.0.*" PrivateAssets="All" />
    <PackageReference Include="Microsoft.AspNetCore" Version="1.1.1" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" />
    <PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.1" />
    <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.1" />
  </ItemGroup>

  <ItemGroup>
    <DotNetCliToolReference Include="Microsoft.DotNet.Watcher.Tools" Version="1.0.0" />
  </ItemGroup>

</Project>

How am I meant to run a netcoreapp1.1 on Azure? Does it have to be self contained or is it possible to have the Azure App Service run it from dlls?

Edit:

Manually copying a web.config into my publish directory I am able to get the app to run. How can I make dotnet publish create it automatically?
Also, I am still curious about my previous questions.

Body:
Add info into you csproj file that you need to copy web.config, like this:

<ItemGroup>
  <Content Update="web.config">
    <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
  </Content>
</ItemGroup>


答:
Off the top of my head, I don't believe there's an API for it that's common across platforms. You could, however parse the output of the mount command:

```<code>~$ mount
/dev/disk0s2 on / (hfs, local, journaled)
devfs on /dev (devfs, local, nobrowse)
map -hosts on /net (autofs, nosuid, automounted, nobrowse)
map auto_home on /home (autofs, automounted, nobrowse)
/dev/disk1s2 on /Users/nknight (hfs, local, nodev, nosuid, journaled, nobrowse)
</code>```

mount without arguments has roughly the same effect on most *nix-ish systems, though I don't believe the output format is standardized anywhere.

I would encourage you to rethink your approach, however. The whole point of network filesystems is that applications aren't supposed to care about them. Consider posting another question explaining what you're trying to accomplish by doing this. Someone can probably offer a superior and more generalized solution.

Title: Is there any way to determine the type of a mountpoint?

Body:
I've got a bash script that deals with files in Mac OS X 10.5 & 10.6. It now needs to determine whether the files are on a local volume or a remote AFP volume. All mountpoints are in /Volumes on Mac OS X, but I cannot see any difference between local & remote volumes, at least with ls -al (except for the boot volume, which is a symlink to /).

Is there a way to programatically, esp. something that can be easily called from a bash script (I really don't want to rewrite this in C/Obj-C with OS X-specific APIs, unless absolutely necessary), to determine the source or type of a mountpoint? Even what device a volume maps to (assuming volumes mounted with mount_afp, mount_smbfs, mount_webdav, etc., won't point back to a device in /dev) so I have some way of guessing whether it's local or not?

Body:
Off the top of my head, I don't believe there's an API for it that's common across platforms. You could, however parse the output of the mount command:

~$ mount
/dev/disk0s2 on / (hfs, local, journaled)
devfs on /dev (devfs, local, nobrowse)
map -hosts on /net (autofs, nosuid, automounted, nobrowse)
map auto_home on /home (autofs, automounted, nobrowse)
/dev/disk1s2 on /Users/nknight (hfs, local, nodev, nosuid, journaled, nobrowse)

mount without arguments has roughly the same effect on most *nix-ish systems, though I don't believe the output format is standardized anywhere.

I would encourage you to rethink your approach, however. The whole point of network filesystems is that applications aren't supposed to care about them. Consider posting another question explaining what you're trying to accomplish by doing this. Someone can probably offer a superior and more generalized solution.


问:
Materialize Modal is not opening
Hello I'm using Materialize js and its modal is not opening follwing is my code.Please let me know what wrong with it?

```<code><!-- Modal Structure -->
<div id="modal1" class="modal bottom-sheet">
    <div class="modal-content">
        <h4>
            Modal Header
        </h4>
        <p>
            A bunch of text
        </p>
    </div>
    <div class="modal-footer">
        <a href="#!" class="modal-action modal-close waves-effect waves-green btn-flat">Agree</a>
    </div>
</div>
<a class="waves-effect waves-light btn" href="#modal1">Modal</a>
</code>```

Fiddle

答:
In the Javascript add this: $('#modal1').modal();
before:  $('#modal1').modal('open');</p>

Title: Materialize Modal is not opening

Body:
Hello I'm using Materialize js and its modal is not opening follwing is my code.Please let me know what wrong with it?

            Modal Header

            A bunch of text

        Agree

Modal

Fiddle


问:
NoClassDefFoundError, FxRobotException, FatalBeanException and ExecutionException while running gradle test
I am trying to run TestFX tests with gradle on offline machine.

With command like

```<code>gradle -Dtest.single=ViewsTest test
</code>```

On one machine it runs well, but on another machine it fails with

```<code>NoClassDefFoundError: org.testfx.api.FxRobotException
</code>```

This probably means double error here. One (unknown) error happens while running test and another error happens, when TestFX tries to generate exception about it.

I am interested in latter one: why doesn't Gradle see this class?

Simultaneously, I wrote test to check if class is available

```<code> @Test
   public void causes_exception_on_unknown_button() {
      try {
         point(new Predicate<Node>() {
            @Override
            public boolean apply(Node input) {
               return false;
            }
         });
      }
      catch (FxRobotException e) {
         System.out.println("Expected exception found");
         return;
      }
      throw new AssertionError("No expected exception found");
   }
</code>```

and it passed, meaning class FxRobotException is available.

Confirming, that the following dependencies are in build.gradle

```<code>testCompile group: 'org.testfx', name: 'testfx-junit', version: '4.0.4-alpha'
testCompile group: 'org.testfx', name: 'testfx-core', version: '4.0.4-alpha'
</code>```

How it can be?

UPDATE

If I run

```<code>gradle -Dtest.single=ViewsTest test -i
</code>```

(with more info)

the following exception occurs:

```<code> java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.NoClassDefFoundError: org.springframework.beans.F
atalBeanException

        Caused by:
        java.util.concurrent.ExecutionException: java.lang.NoClassDefFoundError: org.springframework.beans.FatalBeanException

            Caused by:
            java.lang.NoClassDefFoundError: org.springframework.beans.FatalBeanException

    org.testfx.api.FxRobotException: the query "#menuFile" returned no nodes.
</code>```

It is strange that now we do see actual message from FxRobotException and class-def error now relates to different class of FatalBeanException. Simultaneously, the root cause appears to be execution exception somewhere.

UPDATE 2

build.gradle is follows (note, it is "local"):

```<code>buildscript {
    repositories {
        mavenLocal()
    }

    dependencies {
        classpath "com.github.jengelman.gradle.plugins:shadow:1.2.3"
        classpath 'org.ajoberstar:gradle-git:1.5.1'
    }
}

apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'maven'
apply plugin: "com.github.johnrengelman.shadow"
apply plugin: 'antlr'

ext {

    try {
        revision = org.ajoberstar.grgit.Grgit.open().head().abbreviatedId
    }
    catch(all) {
        revision = 'SNAPSHOT'
    }
}

project.group = 'com.cireca'
version = '0.1.20.' + getDate() + '-' + revision

description = """"""

sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
    mavenLocal()
    flatDir {
        dirs 'lib'
    }

}

dependencies {
    ext.springVersion = '4.2.6.RELEASE'
    ext.junitVersion = '4.12'

    antlr "org.antlr:antlr4:4.5" // use ANTLR version 4

    compile("org.hibernate:hibernate-entitymanager:5.1.0.Final")
    compile("com.opencsv:opencsv:3.7")
    compile("com.cireca.overlaywidget:OverlayWidget:1.0-SNAPSHOT")
    compile("org.springframework:spring-context:$springVersion")
    compile("org.springframework:spring-beans:$springVersion")
    compile("org.springframework:spring-jdbc:$springVersion")
    compile("org.springframework:spring-orm:$springVersion")
    compile('mysql:mysql-connector-java:5.1.38')
    compile('org.apache.commons:commons-dbcp2:2.1.1')
    compile('org.controlsfx:controlsfx:8.40.12')
    compile('org.apache.commons:commons-io:1.3.2')
    compile('org.apache.commons:commons-csv:1.2')
    compile('org.apache.commons:commons-collections4:4.1')
    compile('org.apache.commons:commons-lang3:3.4')
    compile('commons-beanutils:commons-beanutils:1.9.2')
    compile('com.google.guava:guava:19.0')
    compile('org.cache2k:cache2k-core:0.25-BETA')
    compile('it.unimi.dsi:fastutil:7.0.12')
    compile('org.jadira.usertype:usertype.core:5.0.0.GA')
    compile('joda-time:joda-time:2.9.2')
    compile group: 'net.sourceforge.htmlunit', name: 'htmlunit', version: '2.22'
    compile group: 'org.fxmisc.easybind', name: 'easybind', version: '1.0.3'
    compile group: 'io.reactivex', name: 'rxjavafx', version: '2.0.2'
    compile name: 'orsoncharts-1.5'
    compile name: 'fxgraphics2d-1.3'
    compile group: 'com.google.code.gson', name: 'gson', version: '2.7'
    compile group: 'org.eclipse.swt', name: 'org.eclipse.swt.win32.win32.x86', version: '4.6.1'
    compile group: 'org.eclipse.swt', name: 'org.eclipse.swt.win32.win32.x86_64', version: '4.6.1'

    testCompile("org.springframework:spring-test:$springVersion")
    testCompile("junit:junit:$junitVersion")
    testCompile('org.assertj:assertj-core:3.5.2')
    testCompile group: 'org.testfx', name: 'testfx-junit', version: '4.0.4-alpha'
    testCompile group: 'org.testfx', name: 'testfx-core', version: '4.0.4-alpha'

}

sourceSets {
    demo
    attempts {
        compileClasspath += main.output
        runtimeClasspath += main.output
    }
    tools
    antlrGenerated {
        java {

        }
    }
}

jar {
    manifest {
        attributes 'Main-Class': 'com.cireca.Main'
    }

}

attemptsClasses.dependsOn build

task wrapper(type: Wrapper) {
    gradleVersion = '2.9'
}

generateGrammarSource {
    maxHeapSize = "64m"
    arguments += ["-visitor", "-long-messages"]
}

task packageTests(type: Jar) {
    from sourceSets.test.output
}

def getDate() {
    def date = new Date()
    def formattedDate = date.format('yyyyMMddHHmm')
    return formattedDate
}

task zip4BuildServer(type: Zip) {
    classifier = 'src'
    from projectDir
    include 'src/**/*'
    include 'lib/**/*'
    include 'gradle/**/*'
    include 'build.gradle'
    include 'settings.gradle'
    include 'data_source.xml'
    include 'gradlew'
    include 'gradlew.bat'
    archiveName "${baseName}-${getDate()}-${revision}.${extension}"
}

test {
    testLogging {
        // Show that tests are run in the command-line output
        events 'started', 'passed'
    }
}
</code>```

and error trace is following:

```<code>java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.NoClassDefFoundError: org.springframework.beans.FatalBeanException
    at org.testfx.util.WaitForAsyncUtils.waitFor(WaitForAsyncUtils.java:161)
    at org.testfx.api.FxToolkit.waitForSetup(FxToolkit.java:269)
    at org.testfx.api.FxToolkit.setupApplication(FxToolkit.java:175)
    at org.testfx.framework.junit.ApplicationTest.internalBefore(ApplicationTest.java:54)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.runTestClass(JUnitTestClassExecuter.java:105)
    at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.execute(JUnitTestClassExecuter.java:56)
    at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassProcessor.processTestClass(JUnitTestClassProcessor.java:64)
    at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:50)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
    at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
    at org.gradle.messaging.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32)
    at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
    at com.sun.proxy.$Proxy2.processTestClass(Unknown Source)
    at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:106)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
    at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
    at org.gradle.messaging.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:360)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
    at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.util.concurrent.ExecutionException: java.lang.NoClassDefFoundError: org.springframework.beans.FatalBeanException
    at com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:476)
    at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:455)
    at com.google.common.util.concurrent.AbstractFuture$TrustedFuture.get(AbstractFuture.java:79)
    at org.testfx.toolkit.impl.ToolkitServiceImpl.lambda$setupApplication$60(ToolkitServiceImpl.java:144)
    at org.testfx.util.WaitForAsyncUtils.callCallableAndSetFuture(WaitForAsyncUtils.java:363)
    at org.testfx.util.WaitForAsyncUtils.lambda$async$8(WaitForAsyncUtils.java:88)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    ... 3 more
Caused by: java.lang.NoClassDefFoundError: org.springframework.beans.FatalBeanException
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1123)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1018)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
    at com.cireca.filterwidget.javafx.spring.SpringFX.initializeSpringContext(SpringFX.java:65)
    at com.cireca.filterwidget.javafx.spring.SpringFX.initialize(SpringFX.java:123)
    at com.cireca.filterwidget.javafx.spring.SpringFX.init(SpringFX.java:73)
    at com.cireca.testfx.TestFXUtils.startLDT(TestFXUtils.java:38)
    at com.cireca.testfx.MainUITest.start(MainUITest.java:37)
    at org.testfx.framework.junit.ApplicationAdapter.start(ApplicationAdapter.java:54)
    at org.testfx.toolkit.impl.ApplicationServiceImpl.lambda$start$61(ApplicationServiceImpl.java:62)
    at org.testfx.util.WaitForAsyncUtils.callCallableAndSetFuture(WaitForAsyncUtils.java:363)
    at org.testfx.util.WaitForAsyncUtils.lambda$asyncFx$9(WaitForAsyncUtils.java:115)
    at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
    ... 1 more
</code>```

UPDATE 3

results of dependencies check

```<code>>gradle dependencyInsight --dependency spring-beans --configuration testRuntime
:dependencyInsight
org.springframework:spring-beans:4.2.6.RELEASE
+--- testRuntime
+--- org.springframework:spring-aop:4.2.6.RELEASE
|    \--- org.springframework:spring-context:4.2.6.RELEASE
|         \--- testRuntime
+--- org.springframework:spring-context:4.2.6.RELEASE (*)
+--- org.springframework:spring-jdbc:4.2.6.RELEASE
|    +--- testRuntime
|    \--- org.springframework:spring-orm:4.2.6.RELEASE
|         \--- testRuntime
+--- org.springframework:spring-orm:4.2.6.RELEASE (*)
\--- org.springframework:spring-tx:4.2.6.RELEASE
     +--- org.springframework:spring-jdbc:4.2.6.RELEASE (*)
     \--- org.springframework:spring-orm:4.2.6.RELEASE (*)

(*) - dependencies omitted (listed previously)

BUILD SUCCESSFUL

Total time: 5.694 secs

>gradle dependencyInsight --dependency spring-core --configuration testRuntime
:dependencyInsight
org.springframework:spring-core:4.2.6.RELEASE
+--- org.springframework:spring-aop:4.2.6.RELEASE
|    \--- org.springframework:spring-context:4.2.6.RELEASE
|         \--- testRuntime
+--- org.springframework:spring-beans:4.2.6.RELEASE
|    +--- testRuntime
|    +--- org.springframework:spring-context:4.2.6.RELEASE (*)
|    +--- org.springframework:spring-jdbc:4.2.6.RELEASE
|    |    +--- testRuntime
|    |    \--- org.springframework:spring-orm:4.2.6.RELEASE
|    |         \--- testRuntime
|    +--- org.springframework:spring-orm:4.2.6.RELEASE (*)
|    +--- org.springframework:spring-aop:4.2.6.RELEASE (*)
|    \--- org.springframework:spring-tx:4.2.6.RELEASE
|         +--- org.springframework:spring-jdbc:4.2.6.RELEASE (*)
|         \--- org.springframework:spring-orm:4.2.6.RELEASE (*)
+--- org.springframework:spring-context:4.2.6.RELEASE (*)
+--- org.springframework:spring-expression:4.2.6.RELEASE
|    \--- org.springframework:spring-context:4.2.6.RELEASE (*)
+--- org.springframework:spring-jdbc:4.2.6.RELEASE (*)
+--- org.springframework:spring-orm:4.2.6.RELEASE (*)
+--- org.springframework:spring-test:4.2.6.RELEASE
|    \--- testRuntime
\--- org.springframework:spring-tx:4.2.6.RELEASE (*)

(*) - dependencies omitted (listed previously)

BUILD SUCCESSFUL

Total time: 5.557 secs
</code>```

答:
Taking a quick search on Maven Central I found that org.springframework.beans.FatalBeanException is in spring-beans and spring-core dependencies.

You might want to use the dependencyInsight to see what's happening with these two dependencies.

eg: Type the following at command line

```<code>gradle dependencyInsight --dependency spring-beans --configuration testRuntime
gradle dependencyInsight --dependency spring-core --configuration testRuntime
</code>```

I suspect that somewhere on your classpath one of your dependencies expects a certain version of spring-beans or spring-core but Gradle is resolving with another version

Body:
I am trying to run TestFX tests with gradle on offline machine.

With command like

gradle -Dtest.single=ViewsTest test

On one machine it runs well, but on another machine it fails with

NoClassDefFoundError: org.testfx.api.FxRobotException

This probably means double error here. One (unknown) error happens while running test and another error happens, when TestFX tries to generate exception about it.

I am interested in latter one: why doesn't Gradle see this class?

Simultaneously, I wrote test to check if class is available

 @Test
   public void causes_exception_on_unknown_button() {
      try {
         point(new Predicate<Node>() {
            @Override
            public boolean apply(Node input) {
               return false;
            }
         });
      }
      catch (FxRobotException e) {
         System.out.println("Expected exception found");
         return;
      }
      throw new AssertionError("No expected exception found");
   }

and it passed, meaning class FxRobotException is available.

Confirming, that the following dependencies are in build.gradle

testCompile group: 'org.testfx', name: 'testfx-junit', version: '4.0.4-alpha'
testCompile group: 'org.testfx', name: 'testfx-core', version: '4.0.4-alpha'

How it can be?

UPDATE

If I run

gradle -Dtest.single=ViewsTest test -i

(with more info)

the following exception occurs:

 java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.NoClassDefFoundError: org.springframework.beans.F
atalBeanException

        Caused by:
        java.util.concurrent.ExecutionException: java.lang.NoClassDefFoundError: org.springframework.beans.FatalBeanException

            Caused by:
            java.lang.NoClassDefFoundError: org.springframework.beans.FatalBeanException

    org.testfx.api.FxRobotException: the query "#menuFile" returned no nodes.

It is strange that now we do see actual message from FxRobotException and class-def error now relates to different class of FatalBeanException. Simultaneously, the root cause appears to be execution exception somewhere.

UPDATE 2

build.gradle is follows (note, it is "local"):

buildscript {
    repositories {
        mavenLocal()
    }

    dependencies {
        classpath "com.github.jengelman.gradle.plugins:shadow:1.2.3"
        classpath 'org.ajoberstar:gradle-git:1.5.1'
    }
}

apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'maven'
apply plugin: "com.github.johnrengelman.shadow"
apply plugin: 'antlr'

ext {

    try {
        revision = org.ajoberstar.grgit.Grgit.open().head().abbreviatedId
    }
    catch(all) {
        revision = 'SNAPSHOT'
    }
}

project.group = 'com.cireca'
version = '0.1.20.' + getDate() + '-' + revision

description = """"""

sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
    mavenLocal()
    flatDir {
        dirs 'lib'
    }

}

dependencies {
    ext.springVersion = '4.2.6.RELEASE'
    ext.junitVersion = '4.12'

    antlr "org.antlr:antlr4:4.5" // use ANTLR version 4

    compile("org.hibernate:hibernate-entitymanager:5.1.0.Final")
    compile("com.opencsv:opencsv:3.7")
    compile("com.cireca.overlaywidget:OverlayWidget:1.0-SNAPSHOT")
    compile("org.springframework:spring-context:$springVersion")
    compile("org.springframework:spring-beans:$springVersion")
    compile("org.springframework:spring-jdbc:$springVersion")
    compile("org.springframework:spring-orm:$springVersion")
    compile('mysql:mysql-connector-java:5.1.38')
    compile('org.apache.commons:commons-dbcp2:2.1.1')
    compile('org.controlsfx:controlsfx:8.40.12')
    compile('org.apache.commons:commons-io:1.3.2')
    compile('org.apache.commons:commons-csv:1.2')
    compile('org.apache.commons:commons-collections4:4.1')
    compile('org.apache.commons:commons-lang3:3.4')
    compile('commons-beanutils:commons-beanutils:1.9.2')
    compile('com.google.guava:guava:19.0')
    compile('org.cache2k:cache2k-core:0.25-BETA')
    compile('it.unimi.dsi:fastutil:7.0.12')
    compile('org.jadira.usertype:usertype.core:5.0.0.GA')
    compile('joda-time:joda-time:2.9.2')
    compile group: 'net.sourceforge.htmlunit', name: 'htmlunit', version: '2.22'
    compile group: 'org.fxmisc.easybind', name: 'easybind', version: '1.0.3'
    compile group: 'io.reactivex', name: 'rxjavafx', version: '2.0.2'
    compile name: 'orsoncharts-1.5'
    compile name: 'fxgraphics2d-1.3'
    compile group: 'com.google.code.gson', name: 'gson', version: '2.7'
    compile group: 'org.eclipse.swt', name: 'org.eclipse.swt.win32.win32.x86', version: '4.6.1'
    compile group: 'org.eclipse.swt', name: 'org.eclipse.swt.win32.win32.x86_64', version: '4.6.1'

    testCompile("org.springframework:spring-test:$springVersion")
    testCompile("junit:junit:$junitVersion")
    testCompile('org.assertj:assertj-core:3.5.2')
    testCompile group: 'org.testfx', name: 'testfx-junit', version: '4.0.4-alpha'
    testCompile group: 'org.testfx', name: 'testfx-core', version: '4.0.4-alpha'

}

sourceSets {
    demo
    attempts {
        compileClasspath += main.output
        runtimeClasspath += main.output
    }
    tools
    antlrGenerated {
        java {

        }
    }
}

jar {
    manifest {
        attributes 'Main-Class': 'com.cireca.Main'
    }

}

attemptsClasses.dependsOn build

task wrapper(type: Wrapper) {
    gradleVersion = '2.9'
}

generateGrammarSource {
    maxHeapSize = "64m"
    arguments += ["-visitor", "-long-messages"]
}

task packageTests(type: Jar) {
    from sourceSets.test.output
}

def getDate() {
    def date = new Date()
    def formattedDate = date.format('yyyyMMddHHmm')
    return formattedDate
}

task zip4BuildServer(type: Zip) {
    classifier = 'src'
    from projectDir
    include 'src/**/*'
    include 'lib/**/*'
    include 'gradle/**/*'
    include 'build.gradle'
    include 'settings.gradle'
    include 'data_source.xml'
    include 'gradlew'
    include 'gradlew.bat'
    archiveName "${baseName}-${getDate()}-${revision}.${extension}"
}

test {
    testLogging {
        // Show that tests are run in the command-line output
        events 'started', 'passed'
    }
}

and error trace is following:

java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.NoClassDefFoundError: org.springframework.beans.FatalBeanException
    at org.testfx.util.WaitForAsyncUtils.waitFor(WaitForAsyncUtils.java:161)
    at org.testfx.api.FxToolkit.waitForSetup(FxToolkit.java:269)
    at org.testfx.api.FxToolkit.setupApplication(FxToolkit.java:175)
    at org.testfx.framework.junit.ApplicationTest.internalBefore(ApplicationTest.java:54)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.runTestClass(JUnitTestClassExecuter.java:105)
    at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.execute(JUnitTestClassExecuter.java:56)
    at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassProcessor.processTestClass(JUnitTestClassProcessor.java:64)
    at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:50)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
    at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
    at org.gradle.messaging.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32)
    at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
    at com.sun.proxy.$Proxy2.processTestClass(Unknown Source)
    at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:106)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
    at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
    at org.gradle.messaging.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:360)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
    at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.util.concurrent.ExecutionException: java.lang.NoClassDefFoundError: org.springframework.beans.FatalBeanException
    at com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:476)
    at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:455)
    at com.google.common.util.concurrent.AbstractFuture$TrustedFuture.get(AbstractFuture.java:79)
    at org.testfx.toolkit.impl.ToolkitServiceImpl.lambda$setupApplication$60(ToolkitServiceImpl.java:144)
    at org.testfx.util.WaitForAsyncUtils.callCallableAndSetFuture(WaitForAsyncUtils.java:363)
    at org.testfx.util.WaitForAsyncUtils.lambda$async$8(WaitForAsyncUtils.java:88)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    ... 3 more
Caused by: java.lang.NoClassDefFoundError: org.springframework.beans.FatalBeanException
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1123)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1018)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
    at com.cireca.filterwidget.javafx.spring.SpringFX.initializeSpringContext(SpringFX.java:65)
    at com.cireca.filterwidget.javafx.spring.SpringFX.initialize(SpringFX.java:123)
    at com.cireca.filterwidget.javafx.spring.SpringFX.init(SpringFX.java:73)
    at com.cireca.testfx.TestFXUtils.startLDT(TestFXUtils.java:38)
    at com.cireca.testfx.MainUITest.start(MainUITest.java:37)
    at org.testfx.framework.junit.ApplicationAdapter.start(ApplicationAdapter.java:54)
    at org.testfx.toolkit.impl.ApplicationServiceImpl.lambda$start$61(ApplicationServiceImpl.java:62)
    at org.testfx.util.WaitForAsyncUtils.callCallableAndSetFuture(WaitForAsyncUtils.java:363)
    at org.testfx.util.WaitForAsyncUtils.lambda$asyncFx$9(WaitForAsyncUtils.java:115)
    at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
    ... 1 more

UPDATE 3

results of dependencies check

>gradle dependencyInsight --dependency spring-beans --configuration testRuntime
:dependencyInsight
org.springframework:spring-beans:4.2.6.RELEASE
+--- testRuntime
+--- org.springframework:spring-aop:4.2.6.RELEASE
|    \--- org.springframework:spring-context:4.2.6.RELEASE
|         \--- testRuntime
+--- org.springframework:spring-context:4.2.6.RELEASE (*)
+--- org.springframework:spring-jdbc:4.2.6.RELEASE
|    +--- testRuntime
|    \--- org.springframework:spring-orm:4.2.6.RELEASE
|         \--- testRuntime
+--- org.springframework:spring-orm:4.2.6.RELEASE (*)
\--- org.springframework:spring-tx:4.2.6.RELEASE
     +--- org.springframework:spring-jdbc:4.2.6.RELEASE (*)
     \--- org.springframework:spring-orm:4.2.6.RELEASE (*)

(*) - dependencies omitted (listed previously)

BUILD SUCCESSFUL

Total time: 5.694 secs

>gradle dependencyInsight --dependency spring-core --configuration testRuntime
:dependencyInsight
org.springframework:spring-core:4.2.6.RELEASE
+--- org.springframework:spring-aop:4.2.6.RELEASE
|    \--- org.springframework:spring-context:4.2.6.RELEASE
|         \--- testRuntime
+--- org.springframework:spring-beans:4.2.6.RELEASE
|    +--- testRuntime
|    +--- org.springframework:spring-context:4.2.6.RELEASE (*)
|    +--- org.springframework:spring-jdbc:4.2.6.RELEASE
|    |    +--- testRuntime
|    |    \--- org.springframework:spring-orm:4.2.6.RELEASE
|    |         \--- testRuntime
|    +--- org.springframework:spring-orm:4.2.6.RELEASE (*)
|    +--- org.springframework:spring-aop:4.2.6.RELEASE (*)
|    \--- org.springframework:spring-tx:4.2.6.RELEASE
|         +--- org.springframework:spring-jdbc:4.2.6.RELEASE (*)
|         \--- org.springframework:spring-orm:4.2.6.RELEASE (*)
+--- org.springframework:spring-context:4.2.6.RELEASE (*)
+--- org.springframework:spring-expression:4.2.6.RELEASE
|    \--- org.springframework:spring-context:4.2.6.RELEASE (*)
+--- org.springframework:spring-jdbc:4.2.6.RELEASE (*)
+--- org.springframework:spring-orm:4.2.6.RELEASE (*)
+--- org.springframework:spring-test:4.2.6.RELEASE
|    \--- testRuntime
\--- org.springframework:spring-tx:4.2.6.RELEASE (*)

(*) - dependencies omitted (listed previously)

BUILD SUCCESSFUL

Total time: 5.557 secs

Body:
Taking a quick search on Maven Central I found that org.springframework.beans.FatalBeanException is in spring-beans and spring-core dependencies.

You might want to use the dependencyInsight to see what's happening with these two dependencies.

eg: Type the following at command line

gradle dependencyInsight --dependency spring-beans --configuration testRuntime
gradle dependencyInsight --dependency spring-core --configuration testRuntime

I suspect that somewhere on your classpath one of your dependencies expects a certain version of spring-beans or spring-core but Gradle is resolving with another version


问:
xlwt on ubuntu installs but does not import
xlwt installs in the following path:

```<code>/usr/local/lib/python2.7/dist-packages
</code>```

successfully with pip or apt-get or easy_install.

However, when I try to import, it gives an error no module named xlwt.

All the relevant answers on this site say to pip install, but xlwt is already installed. As a workaround, I added the dist packages to my python path. Why is it not searching in dist packages?

I'm using ubuntu 16.04 and python 2.7

答:
set-up eclipse to look in virtualenv (import errors in eclipse)
modules installed in dist packages, ubuntu (ex. xlwt)

create virtualenv as answered by Abijith Mg,
BUT add

    (see below)

```<code>virtualenv my_env--use-site-package

source my_env/bin/activate

pip install xlwt
</code>```

(so you can set-up eclipse and only need to add new modules to virtualenv)

go to window menu in eclipse
   preferences
   pyDev on the left
   interpreters
   python interpreter

new folder

select your virtualenv path to point to site-packages
   apply

Body:
xlwt installs in the following path:

/usr/local/lib/python2.7/dist-packages

successfully with pip or apt-get or easy_install.

However, when I try to import, it gives an error no module named xlwt.

All the relevant answers on this site say to pip install, but xlwt is already installed. As a workaround, I added the dist packages to my python path. Why is it not searching in dist packages?

I'm using ubuntu 16.04 and python 2.7

Body:
set-up eclipse to look in virtualenv (import errors in eclipse)
modules installed in dist packages, ubuntu (ex. xlwt)

create virtualenv as answered by Abijith Mg,
BUT add

    (see below)

virtualenv my_env--use-site-package

source my_env/bin/activate

pip install xlwt

(so you can set-up eclipse and only need to add new modules to virtualenv)

go to window menu in eclipse
   preferences
   pyDev on the left
   interpreters
   python interpreter

new folder

select your virtualenv path to point to site-packages
   apply