问:
Disable Thread.sleep()
I want to disable possibility of using Thread.sleep() in a java project and use my own method instead:

```<code>sleep(int time, String info)
</code>```

That will wait for given amount of time, and print info why is waiting necessary here.

Is disabling Thread.sleep() possible?

If yes, what's best method to do so?

答:
The best method would be to have hook on some static code analysis tool to mark build as failed if there are any invocations of Thread.Sleep().

You could probably configure SonarCube to do this.

Title: Disable Thread.sleep()

Body:
I want to disable possibility of using Thread.sleep() in a java project and use my own method instead:

sleep(int time, String info)

That will wait for given amount of time, and print info why is waiting necessary here.

Is disabling Thread.sleep() possible?

If yes, what's best method to do so?


来源: stackexchange

问:
How to convert a column of a dataframe from char to ascii integers? [Pandas]
I have a dataframe in which one columns called 'label' holds values like 'b', 'm', 'n' etc.

I want 'label' to instead hold the ascii equivalent of the letter.
How do I do it?

答:
e.g. "a"=97 in ascii}
write print(ord("a"))

print(ord("a"))

answer would be 97

ContentLicense: CC BY-SA 3.0


问:
AS3 UILoader External Image Loop
I am looping a code where n images are loaded in n UILoader components on the stage using a dynamic XML.

```<code>    var aLoader: UILoader = new UILoader();
MovieClip(parent).box1_mc.match1_mc.flag1_mc.source = "C:\\Saverio\\Scoreboard\\Flags\\Squared\\" + country01 + ".png";
aLoader.scaleContent = false;
addChild(aLoader);
</code>```

However this loop keeps reloading the image, generating a blinking effect on the image that I don't want to show.

This basic function was running smooth when in AS2 I was using the loader.contentPath command.

I need to produce an AS3 project, and NOT an Air app.

Thank you

答:
I solved this way:</p>

```<code>var aLoader01: UILoader = new UILoader();
aLoader01.source = "C:\\Saverio\\Scoreboard\\Flags\\Squared\\" + MovieClip(root).country + ".png";
aLoader01.width = 330;
aLoader01.height = 220;
flag_mc.addChild(aLoader01);
</code>```

Title: AS3 UILoader External Image Loop

Body:
I am looping a code where n images are loaded in n UILoader components on the stage using a dynamic XML.

    var aLoader: UILoader = new UILoader();
MovieClip(parent).box1_mc.match1_mc.flag1_mc.source = "C:\\Saverio\\Scoreboard\\Flags\\Squared\\" + country01 + ".png";
aLoader.scaleContent = false;
addChild(aLoader);

However this loop keeps reloading the image, generating a blinking effect on the image that I don't want to show.

This basic function was running smooth when in AS2 I was using the loader.contentPath command.

I need to produce an AS3 project, and NOT an Air app.

Thank you

Body:
I solved this way:

var aLoader01: UILoader = new UILoader();
aLoader01.source = "C:\\Saverio\\Scoreboard\\Flags\\Squared\\" + MovieClip(root).country + ".png";
aLoader01.width = 330;
aLoader01.height = 220;
flag_mc.addChild(aLoader01);


问:
How do you version your home? I would like some info about subrepos
I've started to put some files in version control in mercurial. It started with .vim, and then with .bashrc, and now I realized a lot of other files could be versioned as well (such as .zshrc, .task directory created by taskwarrior, etc)

Fact is I would like to know which approachs are available and how people here in SO do it.

Versioning home is not a good idea since I would need to edit my .hgignore, and each time a new folder I don't want versioned is added I would need to edit .hgignore as well.

So I think of 2 approaches:

Create a "dotfiles" repo with everything inside it (vim, bash, screenrc), clone it in home and create symbolic links in home to them;

Create a "dotfiles" repo and a repo for each configuration (vim, bash, screenrc, cvsrc, etc). This "dotfiles" repo will just have the other repositories as submodules, but creation of symbolic links in home is still needed.

Do you think it's overkill to create a repository for each configuration in the second approach? Do you have another suggestions? I would like to use this approach on linux/mac. I use vim on windows as well, that's why I tought of making different repositories with submodules - in windows I would just clone the vim repo: the home repo would have vim as a submodule.

(I'm using a bitbucket private account. Is it possible to have submodules in there? And one more thing: is it possible to have git submodules inside a mercurial repository as submodules as well? How?)

Thanks!

答: I would suggest making one repository, and hard linking all of your dotfiles there. This way, you will only be managing one repository, but you don't have to have a .hgignore with every file in your home directory. I do this with Dropbox instead of Mercurial, and it works quite well.</p>

ContentLicense: CC BY-SA 2.5


问:
how to send form data with fileupload image in php using ajax
I am trying to send form data with attachment to php via ajax.

My code is :

```<code>var company_name = $('#companyname').val();
    var company_type = $('#companytype').val();
    var industry_sector = $('#industrysector').val();
    var email = $('#email').val();
    var mobile = $('#mobile').val();
    var logo = $("#logo").prop("files")[0];
    var company_description = $('#company_description').val();
    var password = $('#password').val();
    var rePassword = $('#rePassword').val();

    var data = {
        company_name: company_name,
        company_type: company_type,
        industry_sector: industry_sector,
        email: email,
        mobile: mobile,
        logo: logo,
        company_description: company_description,
        password: password
    }

    $.ajax({
        type: "POST",
        async: false,
        data: {companyregister: data},
        url: "ajax/loginvia.php",
        processData: false,  // tell jQuery not to process the data
        contentType: false,
        beforeSend:function(){

        },
</code>```

i am getting empty data to php controller. i tried in many ways, im unable to resolve the issue.

答:
```<code>    $.ajax({
    url: "ajax_php_file.php", // Url to which the request is send
    type: "POST",             // Type of request to be send, called as method
    data: new FormData(this), // Data sent to server, a set of key/value pairs (i.e. form fields and values)
    contentType: false,       // The content type used when sending data to the server.
    cache: false,             // To unable request pages to be cached
    processData:false,        // To send DOMDocument or non processed data file it is set to false
    success: function(data)   // A function to be called if request succeeds
    {
    $('#loading').hide();
    $("#message").html(data);
    }
    });

$sourcePath = $_FILES['file']['tmp_name'];       // Storing source path of the file in a variable
$targetPath = "upload/".$_FILES['file']['name']; // Target path where file is to be stored
move_uploaded_file($sourcePath,$targetPath) ;    // Moving Uploaded file
</code>```

Body:
I am trying to send form data with attachment to php via ajax.

My code is :

var company_name = $('#companyname').val();
    var company_type = $('#companytype').val();
    var industry_sector = $('#industrysector').val();
    var email = $('#email').val();
    var mobile = $('#mobile').val();
    var logo = $("#logo").prop("files")[0];
    var company_description = $('#company_description').val();
    var password = $('#password').val();
    var rePassword = $('#rePassword').val();

    var data = {
        company_name: company_name,
        company_type: company_type,
        industry_sector: industry_sector,
        email: email,
        mobile: mobile,
        logo: logo,
        company_description: company_description,
        password: password
    }

    $.ajax({
        type: "POST",
        async: false,
        data: {companyregister: data},
        url: "ajax/loginvia.php",
        processData: false,  // tell jQuery not to process the data
        contentType: false,
        beforeSend:function(){

        },

i am getting empty data to php controller. i tried in many ways, im unable to resolve the issue.


问:
Between query in cakephp 3.3
THE QUERY IS WORKING

Want to write the query below by using cakephp 3.3

```<code>SELECT
</code>```

Books.id AS Books__id,
  Books.title AS Books__title,
  Books.for_min_age AS Books__for_min_age,
  Books.for_max_age AS Books__for_max_age,
  Books.for_min_grade AS Books__for_min_grade,
  Books.for_max_grade AS Books__for_max_grade
FROM
  books Books
WHERE
    4 BETWEEN Books.for_min_age AND Books.for_max_age
    OR
    2 BETWEEN Books.for_min_grade AND Books.for_max_grade

答:
I wonder if you even tried to find the answer. If that was the case you would have found out that BETWEEN won’t work the way you described here. Afaik.

The following code works in CakePHP assuming your Models are set up correctly.

```<code>$age = 4;
$grade = 2;

$query = TableRegistry::get('Books')->find('all')
    ->select([
        'id',
        'title',
        'for_min_age',
        'for_max_age',
        'for_min_grade',
        'for_max_grade'
    ]);

$query->where(function ($exp) use ($age, $grade) {
    $ageExp = $exp->and_(function ($and) use ($age) {
        return $and
            ->lte('for_min_age', $age)
            ->gte('for_max_age', $age);
    });

    $gradeExp = $exp->and_(function ($and) use ($grade) {
        return $and
            ->lte('for_min_grade', $grade)
            ->gte('for_max_grade', $grade);
    });

    return $exp->add(['OR' => [$ageExp, $gradeExp]]);
});

$data = $query->execute();
</code>```

Which will result in:

```<code>SELECT
  Books.id AS `Books__id`,
  Books.title AS `Books__title`,
  Books. for_min_age AS `Books__for_min_age`,
  Books. for_max_age AS `Books__for_max_age`,
  Books. for_min_grade AS `Books__for_min_grade`,
  Books. for_max_grade AS `Books__for_max_grade`
FROM
  books Books
WHERE
  (
    (
      for_min_age <= 4
      AND for_max_age >= 4
    )
    OR (
      for_min_grade <= 2
      AND for_max_grade >= 2
    )
  )
</code>```

EDIT

You could theoretically do it this way, but CakePHP will cast number and number2 as string, which will not work.

```<code>$query->where(function ($exp) use ($age, $grade) {
    return $exp->or_(function ($or) use ($age) {
        return $or->between($age, 'for_min_age', 'for_max_age');
    })->between($grade, 'for_min_grade', 'for_max_grade');
});
</code>```

Title: Between query in cakephp 3.3

Body:
THE QUERY IS WORKING

Want to write the query below by using cakephp 3.3

SELECT

Books.id AS Books__id,
  Books.title AS Books__title,
  Books.for_min_age AS Books__for_min_age,
  Books.for_max_age AS Books__for_max_age,
  Books.for_min_grade AS Books__for_min_grade,
  Books.for_max_grade AS Books__for_max_grade
FROM
  books Books
WHERE
    4 BETWEEN Books.for_min_age AND Books.for_max_age
    OR
    2 BETWEEN Books.for_min_grade AND Books.for_max_grade

Body:
I wonder if you even tried to find the answer. If that was the case you would have found out that BETWEEN won’t work the way you described here. Afaik.

The following code works in CakePHP assuming your Models are set up correctly.

$age = 4;
$grade = 2;

$query = TableRegistry::get('Books')->find('all')
    ->select([
        'id',
        'title',
        'for_min_age',
        'for_max_age',
        'for_min_grade',
        'for_max_grade'
    ]);

$query->where(function ($exp) use ($age, $grade) {
    $ageExp = $exp->and_(function ($and) use ($age) {
        return $and
            ->lte('for_min_age', $age)
            ->gte('for_max_age', $age);
    });

    $gradeExp = $exp->and_(function ($and) use ($grade) {
        return $and
            ->lte('for_min_grade', $grade)
            ->gte('for_max_grade', $grade);
    });

    return $exp->add(['OR' => [$ageExp, $gradeExp]]);
});

$data = $query->execute();

Which will result in:

SELECT
  Books.id AS `Books__id`,
  Books.title AS `Books__title`,
  Books. for_min_age AS `Books__for_min_age`,
  Books. for_max_age AS `Books__for_max_age`,
  Books. for_min_grade AS `Books__for_min_grade`,
  Books. for_max_grade AS `Books__for_max_grade`
FROM
  books Books
WHERE
  (
    (
      for_min_age <= 4
      AND for_max_age >= 4
    )
    OR (
      for_min_grade <= 2
      AND for_max_grade >= 2
    )
  )

EDIT

You could theoretically do it this way, but CakePHP will cast number and number2 as string, which will not work.

$query->where(function ($exp) use ($age, $grade) {
    return $exp->or_(function ($or) use ($age) {
        return $or->between($age, 'for_min_age', 'for_max_age');
    })->between($grade, 'for_min_grade', 'for_max_grade');
});


问:
Typesafe config: encryption/obfuscation of sensitive values in memory
I have an Akka project that needs several passwords to work: to access a datastore, a distributed filesystem connection string...

Those values are not hardcoded in the configuration file, but rather pulled from a key vault at run time during app startup and then stored in memory in a typesafe config object as the thirdparty are using this configuration to get the password and open the connections.

I am just wondering if somehow this is risky, as I am guessing the strings would be in clear in memory. Is there a way to transparently obfuscate/encrypt the values ? Or do I need to implement it on my side, and update the thirdparties so that they transform the string before actually opening the connections.

答: In my opinion that is, in almost every application, a security risk you should not be concerned of. Since Scala runs on the JVM please refer to: Sensitive Data In Memory. </p>


问:
WCF works ONLY Asynchronously
I have a WCF “MWManageSession” service inside my WebApplication so I don’t have any service reference.
The problem is that seems to work  only asynchronously instead of synchronously.

public interface IMWManageSession{

```<code>[OperationContract]
[WebInvoke(Method = "POST",
BodyStyle = WebMessageBodyStyle.WrappedRequest,
ResponseFormat = WebMessageFormat.Json)]
string SetIdSelezionato_SessionData(String[] pvalori, SessionNavigation pSN, long varpChangingAzienda);
</code>```

}

I consume the wcf on a client function using

```<code>$.ajax({
    type: "POST",
    url: webMethod,
    data: jsonText,
    processData: false,
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function (msg) {
        ServiceSucceeded(msg, ptoPopup, DatixWCF, myvar);
    },
    error: ServiceFailed
});

function ServiceSucceeded(result, ptoPopup, DatixWCF, myvar) {
console.log("ServiceSucceeded: " + result);
</code>```

}

I get execute code that I put on “OnServiceSucceed” while the wcf is steel working…

How can I make the wcf works ONLY synchronously?
Thanks in advance !

答:
Maybe you can try to add to your ajax post  async: false

Something like this:

```<code>$.ajax({
    type: "POST",
    url: webMethod,
    data: jsonText,
    processData: false,
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    async: false,
    success: function (msg) {
        ServiceSucceeded(msg, ptoPopup, DatixWCF, myvar);
    },
    error: ServiceFailed
});
</code>```

Title: WCF works ONLY Asynchronously

Body:
I have a WCF “MWManageSession” service inside my WebApplication so I don’t have any service reference.
The problem is that seems to work  only asynchronously instead of synchronously.

public interface IMWManageSession{

[OperationContract]
[WebInvoke(Method = "POST",
BodyStyle = WebMessageBodyStyle.WrappedRequest,
ResponseFormat = WebMessageFormat.Json)]
string SetIdSelezionato_SessionData(String[] pvalori, SessionNavigation pSN, long varpChangingAzienda);

}

I consume the wcf on a client function using

$.ajax({
    type: "POST",
    url: webMethod,
    data: jsonText,
    processData: false,
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function (msg) {
        ServiceSucceeded(msg, ptoPopup, DatixWCF, myvar);
    },
    error: ServiceFailed
});

function ServiceSucceeded(result, ptoPopup, DatixWCF, myvar) {
console.log("ServiceSucceeded: " + result);

}

I get execute code that I put on “OnServiceSucceed” while the wcf is steel working…

How can I make the wcf works ONLY synchronously?
Thanks in advance !

Body:
Maybe you can try to add to your ajax post  async: false

Something like this:

$.ajax({
    type: "POST",
    url: webMethod,
    data: jsonText,
    processData: false,
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    async: false,
    success: function (msg) {
        ServiceSucceeded(msg, ptoPopup, DatixWCF, myvar);
    },
    error: ServiceFailed
});


问:
How to clean up folders efficiently using shell script
I am using a directory structure with various folders. There are new files created daily in some of them.

I have created some programs to clean up the directories, but I would like to use a shell script to make it more efficient.

Therefore I would like to store an "archiving.properties" file in every folder that needs to be cleaned up. The properties file should contain the following variables

```<code>file_pattern="*.xml"
days_to_keep=2
</code>```

Now my clean up routine should:

find all properties files

delete all files that match the file name pattern (file_pattern) and that are older then the defined number of days (days_to_keep) in the directory where the properties file was found.

So my question is how can I do this in the most efficient way?

```<code>find . -type f -name "archiving.properties"  -print
find . -type f -name "<file_pattern>"  -mtime +<days_to_keep> -delete
</code>```

currently I was trying the following in a single folder. It prints out the command correctly, but it is not executed.

```<code>#!/bin/bash
. archiving.properties
find . -type f -name "*.xml"  -mtime +1 -exec rm -rf {} \;
echo "    find . -type f -name \"${file_pattern}\"  -mtime +${days_to_keep} -exec rm -rf {} \;"

Result is:    find . -type f -name "*.xml"  -mtime +1 -exec rm -rf {} \;
</code>```

Thanks for your help in advance.

答:
I got a final result</p>

```<code>echo "start deleting files in " $(pwd) " ... "

#filename of the properties
properties="clean_up.properties"

#find all properties files
for prop in $(find . -type f -name $properties);do
        #init variables
        file_pattern="*._html"
        days_to_keep=14

        #load the variables from the properties file
        . "$prop"

        #define the folder of the properties file
        folder=${prop%?$properties}

        #remove all files matching the parameters in the folder where the properties were found
        echo ">>>   find $folder -type f -name \"${file_pattern}\" -mtime +${days_to_keep} -exec rm -f {} \;"
                    find $folder -type f -name "${file_pattern}"   -mtime +${days_to_keep} -exec rm -f {} \;
done
echo "... done"
</code>```

Body:
I am using a directory structure with various folders. There are new files created daily in some of them.

I have created some programs to clean up the directories, but I would like to use a shell script to make it more efficient.

Therefore I would like to store an "archiving.properties" file in every folder that needs to be cleaned up. The properties file should contain the following variables

file_pattern="*.xml"
days_to_keep=2

Now my clean up routine should:

find all properties files

delete all files that match the file name pattern (file_pattern) and that are older then the defined number of days (days_to_keep) in the directory where the properties file was found.

So my question is how can I do this in the most efficient way?

find . -type f -name "archiving.properties"  -print
find . -type f -name "<file_pattern>"  -mtime +<days_to_keep> -delete

currently I was trying the following in a single folder. It prints out the command correctly, but it is not executed.

#!/bin/bash
. archiving.properties
find . -type f -name "*.xml"  -mtime +1 -exec rm -rf {} \;
echo "    find . -type f -name \"${file_pattern}\"  -mtime +${days_to_keep} -exec rm -rf {} \;"

Result is:    find . -type f -name "*.xml"  -mtime +1 -exec rm -rf {} \;

Thanks for your help in advance.

Body:
I got a final result

echo "start deleting files in " $(pwd) " ... "

#filename of the properties
properties="clean_up.properties"

#find all properties files
for prop in $(find . -type f -name $properties);do
        #init variables
        file_pattern="*._html"
        days_to_keep=14

        #load the variables from the properties file
        . "$prop"

        #define the folder of the properties file
        folder=${prop%?$properties}

        #remove all files matching the parameters in the folder where the properties were found
        echo ">>>   find $folder -type f -name \"${file_pattern}\" -mtime +${days_to_keep} -exec rm -f {} \;"
                    find $folder -type f -name "${file_pattern}"   -mtime +${days_to_keep} -exec rm -f {} \;
done
echo "... done"


问:
How to conditionally insert a record in table B during insert into table A in PostgreSQL?
Given the following structure:

Table A (aliases):

```<code>user_id | alias
---------------
   1      john
   2      peter
</code>```

user_id references id in users.

Table B (users):

```<code>  id | password_hash | ...
---------------------------
   1        ...        ...
   2        ...        ...
</code>```

(the idea is that users can have multiple aliases all of which point to the same main user account record)

I would like to do the following operation: given an alias, password, ... record:

if alias exists in aliases, update the corresponding password in users

if alias does not exist, create a new user in users with the given password and insert a row into aliases pointing to this new record.

How can I do that in a single query in Postgres?

Something along the lines of

```<code>WITH (
  INSERT INTO users(id, password, ...) VALUES(DEFAULT, password, ...) RETURNING id
)
INSERT INTO aliases(user_id, alias) VALUES(id, alias)
  ON CONFLICT {delete the temp row in users and update the one with the
               known user_id instead}
</code>```

答:
This assumes that users_id_seq is the sequence used for users.id and that there is a UNIQUE constraint on aliases.alias:

```<code>WITH a AS (INSERT INTO aliases (user_id, alias)
              VALUES (nextval('users_id_seq'), p_alias)
           ON CONFLICT (alias)
              /* this does nothing, but is needed for RETURNING */
              DO UPDATE
                 SET user_id = aliases.user_id
           RETURNING user_id
          )
INSERT INTO users (id, password_hash, ...)
   SELECT user_id, p_password, ...
      FROM a
ON CONFLICT (id)
   DO UPDATE
      SET password_hash = EXCLUDED.password_hash;
</code>```

Body:
Given the following structure:

Table A (aliases):

user_id | alias
---------------
   1      john
   2      peter

user_id references id in users.

Table B (users):

  id | password_hash | ...
---------------------------
   1        ...        ...
   2        ...        ...

(the idea is that users can have multiple aliases all of which point to the same main user account record)

I would like to do the following operation: given an alias, password, ... record:

if alias exists in aliases, update the corresponding password in users

if alias does not exist, create a new user in users with the given password and insert a row into aliases pointing to this new record.

How can I do that in a single query in Postgres?

Something along the lines of

WITH (
  INSERT INTO users(id, password, ...) VALUES(DEFAULT, password, ...) RETURNING id
)
INSERT INTO aliases(user_id, alias) VALUES(id, alias)
  ON CONFLICT {delete the temp row in users and update the one with the
               known user_id instead}

Body:
This assumes that users_id_seq is the sequence used for users.id and that there is a UNIQUE constraint on aliases.alias:

WITH a AS (INSERT INTO aliases (user_id, alias)
              VALUES (nextval('users_id_seq'), p_alias)
           ON CONFLICT (alias)
              /* this does nothing, but is needed for RETURNING */
              DO UPDATE
                 SET user_id = aliases.user_id
           RETURNING user_id
          )
INSERT INTO users (id, password_hash, ...)
   SELECT user_id, p_password, ...
      FROM a
ON CONFLICT (id)
   DO UPDATE
      SET password_hash = EXCLUDED.password_hash;


问:
Set report date for date other than today in SQL reporting
I have a report that I have been asked to produce. The first column of data is total time entered from the first of the year to the end of the previous month. The next column of data is total time from beginning of "current" month to the end of "current" month.

For example. If this report was being run for March then the first column would be total time for Jan and Feb and the second column would be total time for March. If I were to run it in April then the first column would be total time for Jan/Feb/Mar and the second column total time for April etc.

I am using various expressions to get first date of the year, last date of previous month, first date of this month, last date of this month. All working fine and it runs like a dream if you run the report in the current month (i.e. March) but if you want to run the report in April for March's data it won't do it as it's reading the date on the computer and using that to calculate the prev month.

In Crystal reports you can set a report date. Is there something similar in SQL reporting? I'm assuming you DECLARE the report date in your initial query but I haven't yet found the right combination of functions.

This report is for an external bit of software that we run.

The only parameters I can use are @FromDate and @ToDate and these are set as text rather than date

I was planning on using the @ToDate to set the report date but would obviously have to convert it from text first

Any guidance very much appreciated

答:
Try this.  You could actually do it without all the declare statements, I just did those to break it down to be easy to read.</p>

```<code>declare @date_entered datetime = '2/7/2017'
declare @start_of_year datetime =  DATEADD(yy, DATEDIFF(yy, 0, @date_entered), 0)
declare @start_of_month datetime = DATEADD(month, DATEDIFF(month, 0, @date_entered), 0)
declare @end_of_month datetime = DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,@date_entered)+1,0))
declare @end_of_last_month datetime = DATEADD(day,-1,@start_of_month)
-- Now remove weekends from days found
declare @amount_of_days_previous tinyint = datediff(day,@start_of_year,@end_of_last_month) - (datediff(wk, @start_of_year, @end_of_last_month) * 2)
declare @amount_of_days_this tinyint = DATEDIFF(day,@start_of_month,@end_of_month) - (datediff(wk, @start_of_month, @end_of_month) * 2)

select  @amount_of_days_previous * 8 as WorkHoursinDaysPrevious,
    @amount_of_days_this * 8 as WorkHoursinDaysThis
</code>```

Body:
Try this.  You could actually do it without all the declare statements, I just did those to break it down to be easy to read.

declare @date_entered datetime = '2/7/2017'
declare @start_of_year datetime =  DATEADD(yy, DATEDIFF(yy, 0, @date_entered), 0)
declare @start_of_month datetime = DATEADD(month, DATEDIFF(month, 0, @date_entered), 0)
declare @end_of_month datetime = DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,@date_entered)+1,0))
declare @end_of_last_month datetime = DATEADD(day,-1,@start_of_month)
-- Now remove weekends from days found
declare @amount_of_days_previous tinyint = datediff(day,@start_of_year,@end_of_last_month) - (datediff(wk, @start_of_year, @end_of_last_month) * 2)
declare @amount_of_days_this tinyint = DATEDIFF(day,@start_of_month,@end_of_month) - (datediff(wk, @start_of_month, @end_of_month) * 2)

select  @amount_of_days_previous * 8 as WorkHoursinDaysPrevious,
    @amount_of_days_this * 8 as WorkHoursinDaysThis


问:
MySQL - How to search for exact word match in a column of sentence?
I have a MySQL table with a list of sentences such as:

```<code>id | Sentence
---+---------------------------------------------------------------
 1 | Come On Boys, You Can do it my boy.
 2 | Everything is possible, impossible itself says I am possible.
 3 | Boys I know possible solutions are good!
 4 | Possible solutions are all failed its also possible
</code>```

I have to search on Sentence column exact word like possible.

There are some condition :

Searching word can't be prefix or suffix of any word.

Searching word possible , impossible is incorrect.

Punctuation mark can be before or after the word.Ex: !boy or boy,

No case sensitive means for possible Possible is correct.

I try a query but it is not working

```<code>mysql_query("SELECT * FROM products WHERE Sentence LIKE '%".$search."%'");
</code>```

Possible punctuation mark are ,.!?;-

I need a working solution. Thanks in advance !

答:
Use REGEXP:

```<code>SELECT *
FROM products
WHERE Sentence REGEXP '[^\\d\\w]possible[^\\d\\w]'
</code>```

This takes every word possible surrounded by any word or number.

Be carefull with case sensitivity.

Body:
I have a MySQL table with a list of sentences such as:

id | Sentence
---+---------------------------------------------------------------
 1 | Come On Boys, You Can do it my boy.
 2 | Everything is possible, impossible itself says I am possible.
 3 | Boys I know possible solutions are good!
 4 | Possible solutions are all failed its also possible

I have to search on Sentence column exact word like possible.

There are some condition :

Searching word can't be prefix or suffix of any word.

Searching word possible , impossible is incorrect.

Punctuation mark can be before or after the word.Ex: !boy or boy,

No case sensitive means for possible Possible is correct.

I try a query but it is not working

mysql_query("SELECT * FROM products WHERE Sentence LIKE '%".$search."%'");

Possible punctuation mark are ,.!?;-

I need a working solution. Thanks in advance !

Body:
Use REGEXP:

SELECT *
FROM products
WHERE Sentence REGEXP '[^\\d\\w]possible[^\\d\\w]'

This takes every word possible surrounded by any word or number.

Be carefull with case sensitivity.


问:
How to define a List bean in Spring?
I'm using Spring to define stages in my application. It's configured that the necessary class (here called Configurator) is injected with the stages.

Now I need the List of Stages in another class, named LoginBean. The Configurator doesn't offer access to his List of Stages.

I cannot change the class Configurator.

My Idea:

Define a new bean called Stages and inject it to Configurator and LoginBean.
My problem with this idea is that I don't know how to transform this property:

<property ...>
  <list>
    <bean ... >...</bean>
    <bean ... >...</bean>
    <bean ... >...</bean>
  </list>
</property>
```

<p>into a bean.</p>

<p>Something like this does not work:</p>

<pre class="lang-xml prettyprint-override"><code><bean id="stages" class="java.util.ArrayList">
</code>```

Can anybody help me with this?

答:
And this is how to inject set in some property in Spring:</p>

```<code><bean id="process"
      class="biz.bsoft.processing">
    <property name="stages">
        <set value-type="biz.bsoft.AbstractStage">
            <ref bean="stageReady"/>
            <ref bean="stageSteady"/>
            <ref bean="stageGo"/>
        </set>
    </property>
</bean>
</code>```

Title: How to define a List bean in Spring?

Body:
I'm using Spring to define stages in my application. It's configured that the necessary class (here called Configurator) is injected with the stages.

Now I need the List of Stages in another class, named LoginBean. The Configurator doesn't offer access to his List of Stages.

I cannot change the class Configurator.

My Idea:

Define a new bean called Stages and inject it to Configurator and LoginBean.
My problem with this idea is that I don't know how to transform this property:

<property ...>
  <list>
    <bean ... >...</bean>
    <bean ... >...</bean>
    <bean ... >...</bean>
  </list>
</property>

into a bean.

Something like this does not work:

<bean id="stages" class="java.util.ArrayList">

Can anybody help me with this?

Body:
And this is how to inject set in some property in Spring:

<bean id="process"
      class="biz.bsoft.processing">
    <property name="stages">
        <set value-type="biz.bsoft.AbstractStage">
            <ref bean="stageReady"/>
            <ref bean="stageSteady"/>
            <ref bean="stageGo"/>
        </set>
    </property>
</bean>


问:
Floating of labels not working in yii2
i have created a form in yii2 basic and used material design to enable floating labels but its labels are not floating above when i click the input field. Here is my code for form.
     </p>

```<code>    <?php
    $form = ActiveForm::begin([
                'action' => ['index'],
                'method' => 'get',
    ]);
    ?>

    <div class="panel-body container-fluid">

        <div class="row">
            <div class="col-md-12">
                <div class="col-xs-6 col-lg-6">

                    <div class="form-group form-material floating" data-plugin="formMaterial">
                        <?= $form->field($model, 'corporation_name',[  'labelOptions' => [ 'class' => 'floating-label' ]])->textInput(['maxlength' => true, 'class' => 'form-control'])->label('Corporation Name') ?>
                    </div>

                    <div class="form-group form-material floating" data-plugin="formMaterial">
                        <?= $form->field($model, 'user_first_name',[  'labelOptions' => [ 'class' => 'floating-label' ]])->textinput(['class' => 'form-control'])->label('Corporation Admin'); ?>
                    </div>
                </div>
                <div class="col-xs-6 col-lg-6">
                    <div class="form-group form-material floating" data-plugin="formMaterial">
                        <div class="example"> <b role="presentation"></b>
                            <?= $form->field($model, 'corporation_status')->dropDownList(Yii::$app->appstatues->status, ['prompt' => 'Status'])->label(false); ?>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-md-12">
                <div class="form-group form-material floating m-t-27" data-plugin="formMaterial">
                    <?= Html::submitButton('Search', ['class' => 'btn-primary btn waves-effect waves-light   waves-effect']) ?>
                    <?= Html::resetButton('Reset', ['class' => 'btn-primary btn waves-effect waves-light   waves-effect', 'onclick' => 'location.href = "/admin/corporations";']) ?>

                </div>
            </div>
        </div>

    </div>
    <?php ActiveForm::end(); ?>

</div>
</code>```

<p>can anybody tell what am i doing wrong? </p>

答:
Have you look in inspect element?

If I understand you well...

Try to remove divs around input form. When you bind form for model you already have divs around input. Try this...

```<code><?= $form->field($model, 'ime',['options'=>['class'=>'form-group form-material floating', 'data-plugin'=> 'formMaterial'], 'labelOptions' => [ 'class' => 'floating-label' ]])->textInput(['maxlength' => true, 'class' => 'form-control'])->label('Corporation Name') ?>
</code>```

Title: Floating of labels not working in yii2

Body:
i have created a form in yii2 basic and used material design to enable floating labels but its labels are not floating above when i click the input field. Here is my code for form.

    <?php
    $form = ActiveForm::begin([
                'action' => ['index'],
                'method' => 'get',
    ]);
    ?>

                        <?= $form->field($model, 'corporation_name',[  'labelOptions' => [ 'class' => 'floating-label' ]])->textInput(['maxlength' => true, 'class' => 'form-control'])->label('Corporation Name') ?>

                        <?= $form->field($model, 'user_first_name',[  'labelOptions' => [ 'class' => 'floating-label' ]])->textinput(['class' => 'form-control'])->label('Corporation Admin'); ?>

                            <?= $form->field($model, 'corporation_status')->dropDownList(Yii::$app->appstatues->status, ['prompt' => 'Status'])->label(false); ?>

                    <?= Html::submitButton('Search', ['class' => 'btn-primary btn waves-effect waves-light   waves-effect']) ?>
                    <?= Html::resetButton('Reset', ['class' => 'btn-primary btn waves-effect waves-light   waves-effect', 'onclick' => 'location.href = "/admin/corporations";']) ?>

    <?php ActiveForm::end(); ?>

can anybody tell what am i doing wrong?

Body:
Have you look in inspect element?

If I understand you well...

Try to remove divs around input form. When you bind form for model you already have divs around input. Try this...

<?= $form->field($model, 'ime',['options'=>['class'=>'form-group form-material floating', 'data-plugin'=> 'formMaterial'], 'labelOptions' => [ 'class' => 'floating-label' ]])->textInput(['maxlength' => true, 'class' => 'form-control'])->label('Corporation Name') ?>


问:
android ssl certificate
Assuming, my application need to access my web server using server certificate that is not supported by Nexus One (or other android devices), for example.

is it possible to 'embedded' the client certificate in the application? is this the same as signing the app with the client certificate?

Thanks

答:
Yes, it is possible to embed the server certificate in the application.

Look at my blog article. I posted a detailed description how you can achieve this with creating your own keystore.

Title: android ssl certificate


问:
How to add
 with  link into a textarea as simple text?
I would like to be able to add links with an  tag based on user input.

HTML

```<code><div id="linkRef">
  <button type="button" class="btn btn-default link-list">Aggiungi un link</button>
  <ul class="main_ul">
  </ul>
</div>

<div id="linkData">
  <textarea></textarea>
</div>
</code>```

JS

```<code>$('body').on('click', 'button.link-list', function() {
  $("#linkRef").on("DOMSubtreeModified", updateTree);
  $('.main_ul').append(
    $('<li><div class="form-group"><input  placeholder="Dai un nome al link...." class="link_name form-control" type="text"></div><div class="form-group"><input placeholder="inserisci il link..." class="form-control" type="text"></div></li>')
  );
});

function updateTree() {
   var myLinks = $("#linkRef ul");
   $("#linkData textarea").val(myLinks.html() + "\n");
 }

$("#linkRef").on("DOMSubtreeModified", updateTree);
$("#linkRef").on('keyup', '.form-group input', updateTree);
</code>```

The above inserts the added list but it inserts the inputs and buttons and all the html in it too, yet not the actual values, i didn't insert the  code as i was trying to work out the basic first.

The output within the textarea that I am expecting would be:

```<code><ul>
   <li>
     <a href="www.example.com">Example</a>
   </li>
   <li>
     <a href="www.example2.com">Example2</a>
   </li>
</ul>
</code>```

I made a JsFiddle playground

And this is another JsFiddle for another case I had and I was trying to work this new question out based on that but i didn't manage it

答:
I think your html is look like this according to your requirments

```<code> <div id="linkRef">
 <button type="button" class="btn btn-default link-list">Aggiungi un link</button>
 <span class="main_ul">
 </span>
 </div>

<div id="linkData">
<textarea></textarea>
</div>
</code>```

and js is like below to setup textarea

```<code>  $('body').on('click', 'button.link-list', function() {
  $("#linkRef").on("DOMSubtreeModified", updateTree);
  $('.main_ul').append(
  $('<ul><li><a href="www.example.com">Example</a></li><li><a href="www.example2.com">Example2</a></li></ul>')
 );
});

  function updateTree() {
  var myLinks = $("#linkRef span");
 $("#linkData textarea").val(myLinks.html() + "\n");
 }

 $("#linkRef").on("DOMSubtreeModified", updateTree);
  $("#linkRef").on('keyup', '.form-group input', updateTree);
</code>```

Title: How to add <ul> with <a> link into a textarea as simple text?

Body:
I would like to be able to add links with an  tag based on user input.

HTML

  <button type="button" class="btn btn-default link-list">Aggiungi un link</button>

  <textarea></textarea>

JS

$('body').on('click', 'button.link-list', function() {
  $("#linkRef").on("DOMSubtreeModified", updateTree);
  $('.main_ul').append(
    $('

<input  placeholder="Dai un nome al link...." class="link_name form-control" type="text">

<input placeholder="inserisci il link..." class="form-control" type="text">

')
  );
});

function updateTree() {
   var myLinks = $("#linkRef ul");
   $("#linkData textarea").val(myLinks.html() + "\n");
 }

$("#linkRef").on("DOMSubtreeModified", updateTree);
$("#linkRef").on('keyup', '.form-group input', updateTree);

The above inserts the added list but it inserts the inputs and buttons and all the html in it too, yet not the actual values, i didn't insert the  code as i was trying to work out the basic first.

The output within the textarea that I am expecting would be:

     Example

     Example2

I made a JsFiddle playground

And this is another JsFiddle for another case I had and I was trying to work this new question out based on that but i didn't manage it

Body:
I think your html is look like this according to your requirments

 <div id="linkRef">
 <button type="button" class="btn btn-default link-list">Aggiungi un link</button>
 <span class="main_ul">
 </span>
 </div>

<div id="linkData">
<textarea></textarea>
</div>

and js is like below to setup textarea

  $('body').on('click', 'button.link-list', function() {
  $("#linkRef").on("DOMSubtreeModified", updateTree);
  $('.main_ul').append(
  $('<ul><li><a href="www.example.com">Example</a></li><li><a href="www.example2.com">Example2</a></li></ul>')
 );
});

  function updateTree() {
  var myLinks = $("#linkRef span");
 $("#linkData textarea").val(myLinks.html() + "\n");
 }

 $("#linkRef").on("DOMSubtreeModified", updateTree);
  $("#linkRef").on('keyup', '.form-group input', updateTree);


问:
maven test on scala code return successful build but There are no tests to run
I have the problem using mvn test to run the test code in my maven scala code. Here are the settings:

```<code>.
├── pom.xml
├── run
└── src
    ├── main
    │   └── scala
    │       └── com
    │           └── myCompany
    │               └── scala
    │                   └── MaxPrice.scala
    ├── resources
    │   └── JCudaMultiplyBy2.ptx
    └── test
        ├── resources
        │   └── JCudaMultiplyBy2.ptx
        └── scala
            └── MyTest.scala
</code>```

JCudaMultiplyBy2.ptx is the file will be used in MyTest.scala.

Here is my pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.myCompany.scala</groupId>
  <artifactId>sparkExample</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>jar</packaging>
  <properties>
    <scala.version>2.10.5</scala.version>
  </properties>
  <dependencies>
    <dependency>
      <groupId>org.scala-lang</groupId>
      <artifactId>scala-library</artifactId>
      <version>${scala.version}</version>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.4</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.scala-tools</groupId>
      <artifactId>maven-scala-plugin</artifactId>
      <version>2.11</version>
    </dependency>
    <dependency>
      <groupId>org.apache.spark</groupId>
      <artifactId>spark-core_2.10</artifactId>
      <version>1.6.1</version>
    </dependency>
    <dependency>
      <groupId>org.jcuda</groupId>
      <artifactId>jcuda</artifactId>
      <version>0.8.0</version>
    </dependency>
    <dependency>
      <groupId>org.jcuda</groupId>
      <artifactId>jcublas</artifactId>
      <version>0.8.0</version>
    </dependency>
  </dependencies>

  <build>
    <sourceDirectory>src/main/scala</sourceDirectory>
    <testSourceDirectory>src/test/scala</testSourceDirectory>
    <plugins>
      <plugin>
        <groupId>org.scala-tools</groupId>
        <artifactId>maven-scala-plugin</artifactId>
        <executions>
          <execution>
            <goals>
              <goal>compile</goal>
              <goal>testCompile</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <scalaVersion>${scala.version}</scalaVersion>
          <args>

          </args>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.8.1</version>
        <configuration>
                    <includes>
                        <include>**/*Spec.class</include>
                        <include>**/*Test.class</include>
                    </includes>
                </configuration>
      </plugin>
   </plugins>
  </build>
  <reporting>
    <plugins>
      <plugin>
        <groupId>org.scala-tools</groupId>
        <artifactId>maven-scala-plugin</artifactId>
        <configuration>
          <scalaVersion>${scala.version}</scalaVersion>
        </configuration>
      </plugin>
    </plugins>
  </reporting>
</project>
```

<p>The MyTest.scala code is the same as the MaxPrice.scala code, and if I run mvn compile and then run mvn -q scala:run -DmainClass=com.myCompany.scala.MaxPrice -DaddArgs="local[*]", it works perfectly. Now I change the Object name of MaxPrice.scala into MyTest and also its file name into MyTest.scala. Putting MyTest.scala under src/test/scala and run mvn test, it doesn't work and give this results:</p>

<pre class="lang-none prettyprint-override"><code>[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.myCompany.scala:sparkExample:jar:1.0-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.scala-tools:maven-scala-plugin is missing. @ line 48, column 15
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building sparkExample 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ sparkExample ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /home/yuxin/OwensGroup/MavenPract/maven-sparkJcublas/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.2:compile (default-compile) @ sparkExample ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-scala-plugin:2.15.2:compile (default) @ sparkExample ---
[INFO] Checking for multiple versions of scala
[WARNING]  Expected all dependencies to require Scala version: 2.10.5
[WARNING]  com.myCompany.scala:sparkExample:1.0-SNAPSHOT requires scala version: 2.10.5
[WARNING]  com.twitter:chill_2.10:0.5.0 requires scala version: 2.10.4
[WARNING] Multiple versions of scala libraries detected!
[INFO] includes = [**/*.java,**/*.scala,]
[INFO] excludes = []
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ sparkExample ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.2:testCompile (default-testCompile) @ sparkExample ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-scala-plugin:2.15.2:testCompile (default) @ sparkExample ---
[INFO] Checking for multiple versions of scala
[WARNING]  Expected all dependencies to require Scala version: 2.10.5
[WARNING]  com.myCompany.scala:sparkExample:1.0-SNAPSHOT requires scala version: 2.10.5
[WARNING]  com.twitter:chill_2.10:0.5.0 requires scala version: 2.10.4
[WARNING] Multiple versions of scala libraries detected!
[INFO] includes = [**/*.java,**/*.scala,]
[INFO] excludes = []
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.8.1:test (default-test) @ sparkExample ---
[INFO] Surefire report directory: /home/yuxin/OwensGroup/MavenPract/maven-sparkJcublas/target/surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
There are no tests to run.

Results :

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.202 s
[INFO] Finished at: 2017-03-30T14:52:29-07:00
[INFO] Final Memory: 25M/592M
[INFO] ------------------------------------------------------------------------
</code>```

Also if I run mvn test -Dtest=MyTest, it still gives the same result: no tests to run.

Anyone has an idea? I have search a lot but couldn't find the answer, help!

答:
Apparently from the author you should use scala-maven-plugin instead of maven-scala-plugin (see here).

More importantly, to run scala tests, according to the (almighty) documentation, you should disable the surefire plugin:

To use the ScalaTest Maven plugin, you need to disable SureFire and
  enable ScalaTest.

Add in the configuration section of the surefire plugin:

```<code><skipTests>true</skipTests>
</code>```

Body:
I have the problem using mvn test to run the test code in my maven scala code. Here are the settings:

.
├── pom.xml
├── run
└── src
    ├── main
    │   └── scala
    │       └── com
    │           └── myCompany
    │               └── scala
    │                   └── MaxPrice.scala
    ├── resources
    │   └── JCudaMultiplyBy2.ptx
    └── test
        ├── resources
        │   └── JCudaMultiplyBy2.ptx
        └── scala
            └── MyTest.scala

JCudaMultiplyBy2.ptx is the file will be used in MyTest.scala.

Here is my pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.myCompany.scala</groupId>
  <artifactId>sparkExample</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>jar</packaging>
  <properties>
    <scala.version>2.10.5</scala.version>
  </properties>
  <dependencies>
    <dependency>
      <groupId>org.scala-lang</groupId>
      <artifactId>scala-library</artifactId>
      <version>${scala.version}</version>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.4</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.scala-tools</groupId>
      <artifactId>maven-scala-plugin</artifactId>
      <version>2.11</version>
    </dependency>
    <dependency>
      <groupId>org.apache.spark</groupId>
      <artifactId>spark-core_2.10</artifactId>
      <version>1.6.1</version>
    </dependency>
    <dependency>
      <groupId>org.jcuda</groupId>
      <artifactId>jcuda</artifactId>
      <version>0.8.0</version>
    </dependency>
    <dependency>
      <groupId>org.jcuda</groupId>
      <artifactId>jcublas</artifactId>
      <version>0.8.0</version>
    </dependency>
  </dependencies>

  <build>
    <sourceDirectory>src/main/scala</sourceDirectory>
    <testSourceDirectory>src/test/scala</testSourceDirectory>
    <plugins>
      <plugin>
        <groupId>org.scala-tools</groupId>
        <artifactId>maven-scala-plugin</artifactId>
        <executions>
          <execution>
            <goals>
              <goal>compile</goal>
              <goal>testCompile</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <scalaVersion>${scala.version}</scalaVersion>
          <args>

          </args>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.8.1</version>
        <configuration>
                    <includes>
                        <include>**/*Spec.class</include>
                        <include>**/*Test.class</include>
                    </includes>
                </configuration>
      </plugin>
   </plugins>
  </build>
  <reporting>
    <plugins>
      <plugin>
        <groupId>org.scala-tools</groupId>
        <artifactId>maven-scala-plugin</artifactId>
        <configuration>
          <scalaVersion>${scala.version}</scalaVersion>
        </configuration>
      </plugin>
    </plugins>
  </reporting>
</project>

The MyTest.scala code is the same as the MaxPrice.scala code, and if I run mvn compile and then run mvn -q scala:run -DmainClass=com.myCompany.scala.MaxPrice -DaddArgs="local[*]", it works perfectly. Now I change the Object name of MaxPrice.scala into MyTest and also its file name into MyTest.scala. Putting MyTest.scala under src/test/scala and run mvn test, it doesn't work and give this results:

[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.myCompany.scala:sparkExample:jar:1.0-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.scala-tools:maven-scala-plugin is missing. @ line 48, column 15
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building sparkExample 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ sparkExample ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /home/yuxin/OwensGroup/MavenPract/maven-sparkJcublas/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.2:compile (default-compile) @ sparkExample ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-scala-plugin:2.15.2:compile (default) @ sparkExample ---
[INFO] Checking for multiple versions of scala
[WARNING]  Expected all dependencies to require Scala version: 2.10.5
[WARNING]  com.myCompany.scala:sparkExample:1.0-SNAPSHOT requires scala version: 2.10.5
[WARNING]  com.twitter:chill_2.10:0.5.0 requires scala version: 2.10.4
[WARNING] Multiple versions of scala libraries detected!
[INFO] includes = [**/*.java,**/*.scala,]
[INFO] excludes = []
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ sparkExample ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.2:testCompile (default-testCompile) @ sparkExample ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-scala-plugin:2.15.2:testCompile (default) @ sparkExample ---
[INFO] Checking for multiple versions of scala
[WARNING]  Expected all dependencies to require Scala version: 2.10.5
[WARNING]  com.myCompany.scala:sparkExample:1.0-SNAPSHOT requires scala version: 2.10.5
[WARNING]  com.twitter:chill_2.10:0.5.0 requires scala version: 2.10.4
[WARNING] Multiple versions of scala libraries detected!
[INFO] includes = [**/*.java,**/*.scala,]
[INFO] excludes = []
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.8.1:test (default-test) @ sparkExample ---
[INFO] Surefire report directory: /home/yuxin/OwensGroup/MavenPract/maven-sparkJcublas/target/surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
There are no tests to run.

Results :

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.202 s
[INFO] Finished at: 2017-03-30T14:52:29-07:00
[INFO] Final Memory: 25M/592M
[INFO] ------------------------------------------------------------------------

Also if I run mvn test -Dtest=MyTest, it still gives the same result: no tests to run.

Anyone has an idea? I have search a lot but couldn't find the answer, help!

Body:
Apparently from the author you should use scala-maven-plugin instead of maven-scala-plugin (see here).

More importantly, to run scala tests, according to the (almighty) documentation, you should disable the surefire plugin:

To use the ScalaTest Maven plugin, you need to disable SureFire and
  enable ScalaTest.

Add in the configuration section of the surefire plugin:

<skipTests>true</skipTests>


问:
How do I fix the Visual Studio compile error, "mismatch between processor architecture"?
I'm new to project configuration in Visual Studio 2010, but I've done some research and still can't quite figure this issue out. I have a Visual Studio solution with a C++ DLL referencing the C# DLL. The C# DLL references a few other DLLs, some within my project and some external. When I try to compile the C++ DLL, I get this warning:

warning MSB3270: There was a mismatch between the processor architecture of the project being build "MSIL" and the processor architecture of the reference "[internal C# dll]", "x86".

It tells me to go to Configuration Manager to align my architectures. The C# DLL is set up with platform target x86. If I try to change this to something else, like Any CPU, it complains because one of the external DLLs it depends on has platform target x86.

When I look at Configuration Manager it shows the Platform for my C# DLL as x86 and for my C++ project as Win32. This seems like the right setup; surely I don't want the project for my C++ project to have platform set to x64, which is the only other option presented.

What am I doing wrong here?

答:
I had this problem today and just looking the building configurations in Visual Studio wasn't helping because it showed Any CPU for both the project that wasn't building and the referenced project.

I then looked in the csproj of the referenced project and found this:

```<code><PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x64</PlatformTarget>
</code>```

Somehow this PlatformTarget got added in the middle of a config change and the IDE didn't seem to see it.

Removing this line from the referenced project solved my problem.

Body:
I had this problem today and just looking the building configurations in Visual Studio wasn't helping because it showed Any CPU for both the project that wasn't building and the referenced project.

I then looked in the csproj of the referenced project and found this:

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x64</PlatformTarget>

Somehow this PlatformTarget got added in the middle of a config change and the IDE didn't seem to see it.

Removing this line from the referenced project solved my problem.


问:
How to include list of jar in different apk with various versions in Gradle?
My task is to have dailyDebug, dailyRelease, standardDebug and standardRelease apk files as a result of gradle build. Each apk should contain list of common applications with different versions and types e.g dailyDebug should contain jar1 with latest.integration version and with type: debug and the standardRelease with version 01.05.02 and type: release.

In build.gradle I have the following build types:

```<code>buildTypes {
        debug {
            signingConfig null
        }
        debugDaily {
            signingConfig null
        }
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig null
        }
        releaseDaily {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig null
        }
}
</code>```

Here is the jar list that should be included in each apk.

```<code> "jar1:latest.integration:release"
 "jar2:latest.integration:release"
 "jar3:latest.integration:release"
 "jar4:latest.integration:release"
 "jar5:latest.integration:release"
</code>```

One of the simplest solution is to have a lot of copy-pastes like this:

```<code>dependencies {
    debugApk "jar1:01.02:debug"
    debugApk "jar2:02.03:debug"
    debugApk "jar3:05.12:debug"
    debugApk "jar4:01.32:debug"
    debugApk "jar5:02.01:debug"

    releaseApk "jar1:01.02:release"
    releaseApk "jar2:02.03:release"
    releaseApk "jar3:05.12:release"
    releaseApk "jar4:01.32:release"
    releaseApk "jar5:02.01:release"

    debugDailyApk "jar1:latest.integration:debug"
    debugDailyApk "jar2:latest.integration:debug"
    debugDailyApk "jar3:latest.integration:debug"
    debugDailyApk "jar4:latest.integration:debug"
    debugDailyApk "jar5:latest.integration:debug"

    releaseDailyApk "jar1:latest.integration:release"
    releaseDailyApk "jar2:latest.integration:release"
    releaseDailyApk "jar3:latest.integration:release"
    releaseDailyApk "jar4:latest.integration:release"
    releaseDailyApk "jar5:latest.integration:release"
}
</code>```

I am looking for a generic solution, because the list of jars is going  to be larger and larger and in the future it will be very hard to maintain.

Thank you in advance, it's the first post here :)

答:
I found the solution and want to share it with you.
So 2 functions are added in build.gradle:

```<code>def getDailyPackages(type){
         String[] packages = [
                    "jar1:latest.integration:${type}"
                    "jar2:latest.integration:${type}"
                    "jar3:latest.integration:${type}"
                    "jar4:latest.integration:${type}"
                    "jar5:latest.integration:${type}"]
            return packages
        }

def getStandardPackages(type) {
        String[] packages = [
                "jar1:${jar1VersionName}:${type}",
                "jar2:${jar2VersionName}:${type}",
                "jar3:${jar3VersionName}:${type}",
                "jar2:${jar4VersionName}:${type}",
                "jar3:${jar5VersionName}:${type}",]
        return packages
    }
</code>```

Jar version names are declared in ext section:

```<code>ext {
    jar1VersionName = '1.02'
    jar2VersionName = '1.03'
    jar3VersionName = '1.04'
    jar4VersionName = '1.05'
    jar5VersionName = '1.06'
}
</code>```

And finally call them with corresponding types:

```<code>dependencies {
    debugApk(getStandardPackages("debug"))
    releaseApk(getStandardPackages("release"))
    debugDailyApk(getDailyPackages("debug"))
    releaseDailyApk(getDailyPackages("release"))
}
</code>```

I hope this post was helpful :)

Body:
My task is to have dailyDebug, dailyRelease, standardDebug and standardRelease apk files as a result of gradle build. Each apk should contain list of common applications with different versions and types e.g dailyDebug should contain jar1 with latest.integration version and with type: debug and the standardRelease with version 01.05.02 and type: release.

In build.gradle I have the following build types:

buildTypes {
        debug {
            signingConfig null
        }
        debugDaily {
            signingConfig null
        }
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig null
        }
        releaseDaily {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig null
        }
}

Here is the jar list that should be included in each apk.

 "jar1:latest.integration:release"
 "jar2:latest.integration:release"
 "jar3:latest.integration:release"
 "jar4:latest.integration:release"
 "jar5:latest.integration:release"

One of the simplest solution is to have a lot of copy-pastes like this:

dependencies {
    debugApk "jar1:01.02:debug"
    debugApk "jar2:02.03:debug"
    debugApk "jar3:05.12:debug"
    debugApk "jar4:01.32:debug"
    debugApk "jar5:02.01:debug"

    releaseApk "jar1:01.02:release"
    releaseApk "jar2:02.03:release"
    releaseApk "jar3:05.12:release"
    releaseApk "jar4:01.32:release"
    releaseApk "jar5:02.01:release"

    debugDailyApk "jar1:latest.integration:debug"
    debugDailyApk "jar2:latest.integration:debug"
    debugDailyApk "jar3:latest.integration:debug"
    debugDailyApk "jar4:latest.integration:debug"
    debugDailyApk "jar5:latest.integration:debug"

    releaseDailyApk "jar1:latest.integration:release"
    releaseDailyApk "jar2:latest.integration:release"
    releaseDailyApk "jar3:latest.integration:release"
    releaseDailyApk "jar4:latest.integration:release"
    releaseDailyApk "jar5:latest.integration:release"
}

I am looking for a generic solution, because the list of jars is going  to be larger and larger and in the future it will be very hard to maintain.

Thank you in advance, it's the first post here :)

Body:
I found the solution and want to share it with you.
So 2 functions are added in build.gradle:

def getDailyPackages(type){
         String[] packages = [
                    "jar1:latest.integration:${type}"
                    "jar2:latest.integration:${type}"
                    "jar3:latest.integration:${type}"
                    "jar4:latest.integration:${type}"
                    "jar5:latest.integration:${type}"]
            return packages
        }

def getStandardPackages(type) {
        String[] packages = [
                "jar1:${jar1VersionName}:${type}",
                "jar2:${jar2VersionName}:${type}",
                "jar3:${jar3VersionName}:${type}",
                "jar2:${jar4VersionName}:${type}",
                "jar3:${jar5VersionName}:${type}",]
        return packages
    }

Jar version names are declared in ext section:

ext {
    jar1VersionName = '1.02'
    jar2VersionName = '1.03'
    jar3VersionName = '1.04'
    jar4VersionName = '1.05'
    jar5VersionName = '1.06'
}

And finally call them with corresponding types:

dependencies {
    debugApk(getStandardPackages("debug"))
    releaseApk(getStandardPackages("release"))
    debugDailyApk(getDailyPackages("debug"))
    releaseDailyApk(getDailyPackages("release"))
}

I hope this post was helpful :)


问:
Playing a Facebook video in WPF
My application is making API calls to Facebook and returning video URLs, for example:

https://video.xx.fbcdn.net/v/t43.1792-2/17641656_1853451031583994_2664925858824716288_n.mp4?efg=eyJybHIiOjI1OTIsInJsYSI6MTAyNCwidmVuY29kZV90YWciOiJzdmVfaGQifQ%3D%3D&rl=2592&vabr=1728&oh=d503ccbcfe165a8cfc0436fb0a07078e&oe=58E04780

The video uses the H.264 codec.

Is there a way I can get this video to play from the URL in WPF without having to download the video locally?

答: Yes you use MediaElement to display videos without downloading. Please check this url  http://www.wpf-tutorial.com/audio-video/playing-video/</p>

Title: Playing a Facebook video in WPF


问:
Creating a Mutex throws a DirectoryNotFoundException
I'm trying to create a named mutex, but when I call the constructor I get a DirectoryNotFoundException! Why is a mutex trying to access the filesystem, and how do I know what is a valid path? Is there any particular directory the mutex should be placed in, and how does that correspond to the name?

EDIT: I'm using the Mutex(bool, string) overload, and the exception is:

```<code>System.IO.DirectoryNotFoundException: Could not find a part of the path '<mutex name>'.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.Threading.Mutex.<>c__DisplayClass3.<.ctor>b__0(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.Mutex..ctor(Boolean initiallyOwned, String name, Boolean& createdNew, MutexSecurity mutexSecurity)
at System.Threading.Mutex..ctor(Boolean initiallyOwned, String name)
</code>```

答:
Ah, found what the problem was. My mutex name had \ in it, which windows was interpreting as a path character. Running:

```<code>mutexName = mutexName.Replace(Path.DirectorySeparatorChar, '_');
</code>```

fixes the problem

Body:
I'm trying to create a named mutex, but when I call the constructor I get a DirectoryNotFoundException! Why is a mutex trying to access the filesystem, and how do I know what is a valid path? Is there any particular directory the mutex should be placed in, and how does that correspond to the name?

EDIT: I'm using the Mutex(bool, string) overload, and the exception is:

System.IO.DirectoryNotFoundException: Could not find a part of the path '<mutex name>'.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.Threading.Mutex.<>c__DisplayClass3.<.ctor>b__0(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.Mutex..ctor(Boolean initiallyOwned, String name, Boolean& createdNew, MutexSecurity mutexSecurity)
at System.Threading.Mutex..ctor(Boolean initiallyOwned, String name)

Body:
Ah, found what the problem was. My mutex name had \ in it, which windows was interpreting as a path character. Running:

mutexName = mutexName.Replace(Path.DirectorySeparatorChar, '_');

fixes the problem


问:
Auto-hided Toolbar does not reappear on new Fragment
I have a single-activity application that implements (so far) three different fragments:

MainActivity - takes care of switching between fragments

HomeFragment - home screen for application

TasksFragment - includes RecyclerView with CardView and autohiding of Toolbar on vertical scrolling
AssesmentFragment -

The (main) issue:

In TasksFragment, when Toolbar is hidden after scrolling to bottom of RecyclerView, Button on CardView is pressed and AssessmentFragment is created and slides in.

toolbar is now hidden in new AssessmentFragment (because of auto-hidden toolbar in RecyclerView)

after quickfix (see below) backbutton is unpressable!

My terrible quickfix:

```<code>public class TasksAdapter extends
    RecyclerView.Adapter<TasksAdapter.ViewHolder> {

    (... details omitted ...)

    viewHolder.messageButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            switch (position) {
                case 0:
                    //http://stackandroid.com/tutorial/custom-dialog-with-user-input/
                    Log.i("Press", "" + position);
                    break;
                case 1:
                    Log.i("Press", "" + position);
                    break;
                case 2:
                    Log.i("Press", "" + position);

                    MainActivity mainActivity = (MainActivity) mContext;
                    mainActivity.moveToolbarUp();
                    mainActivity.taskToAssessment();
                break;
            }
    });
}
</code>```

MainActivity

```<code>public void moveToolbarUp() {
    TranslateAnimation anim = new TranslateAnimation(0, 0, -50, 122);
    anim.setDuration(400);
    toolbar.startAnimation(anim);
    anim.setFillAfter(true);
    //toolbar.setTranslationY(0);
}

public void taskToAssessment() {
    FragmentManager fm = getSupportFragmentManager();
    FragmentTransaction ft = fm.beginTransaction();
    ft.setCustomAnimations(R.anim.left_in, R.anim.left_out);
    AssessmentFragment af = new AssessmentFragment();
    ft.replace(R.id.mainFragment, af);
    ft.addToBackStack(null);
    ft.commit();
}
</code>```

Which looks like this:

That looks okay at first, but as you can see the backbutton is not pressable in the new Fragment, and also when going back to previous Fragment the toolbar is now in all wrong position.

Does anyone have ideas on how to improve on this? I would like to: have the toolbar accessible at all times, and reappear when its hidden. There has got to be a better way to do this. I would like to see some alternative way to deal with toolbar hidden on scrolling from recyclerview, when changing to new fragment. Surely someone will have had similar issue!

I will of course provide more code snippets if needed! Thanks.

答:
Fixed by adding

```<code>toolbar.animate().translationY(toolbar.getTop()).setInterpolator(new AccelerateInterpolator()).start();
</code>```

at MainActivity's taskToAssessment():

```<code>public void taskToAssessment() {
    toolbar.animate().translationY(toolbar.getTop()).setInterpolator(new AccelerateInterpolator()).start();
    FragmentManager fm = getSupportFragmentManager();
    FragmentTransaction ft = fm.beginTransaction();
    ft.setCustomAnimations(R.anim.left_in, R.anim.left_out);
    AssessmentFragment af = new AssessmentFragment();
    ft.replace(R.id.mainFragment, af);
    ft.addToBackStack(null);
    ft.commit();
}
</code>```

Body:
I have a single-activity application that implements (so far) three different fragments:

MainActivity - takes care of switching between fragments

HomeFragment - home screen for application

TasksFragment - includes RecyclerView with CardView and autohiding of Toolbar on vertical scrolling
AssesmentFragment -

The (main) issue:

In TasksFragment, when Toolbar is hidden after scrolling to bottom of RecyclerView, Button on CardView is pressed and AssessmentFragment is created and slides in.

toolbar is now hidden in new AssessmentFragment (because of auto-hidden toolbar in RecyclerView)

after quickfix (see below) backbutton is unpressable!

My terrible quickfix:

public class TasksAdapter extends
    RecyclerView.Adapter<TasksAdapter.ViewHolder> {

    (... details omitted ...)

    viewHolder.messageButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            switch (position) {
                case 0:
                    //http://stackandroid.com/tutorial/custom-dialog-with-user-input/
                    Log.i("Press", "" + position);
                    break;
                case 1:
                    Log.i("Press", "" + position);
                    break;
                case 2:
                    Log.i("Press", "" + position);

                    MainActivity mainActivity = (MainActivity) mContext;
                    mainActivity.moveToolbarUp();
                    mainActivity.taskToAssessment();
                break;
            }
    });
}

MainActivity

public void moveToolbarUp() {
    TranslateAnimation anim = new TranslateAnimation(0, 0, -50, 122);
    anim.setDuration(400);
    toolbar.startAnimation(anim);
    anim.setFillAfter(true);
    //toolbar.setTranslationY(0);
}

public void taskToAssessment() {
    FragmentManager fm = getSupportFragmentManager();
    FragmentTransaction ft = fm.beginTransaction();
    ft.setCustomAnimations(R.anim.left_in, R.anim.left_out);
    AssessmentFragment af = new AssessmentFragment();
    ft.replace(R.id.mainFragment, af);
    ft.addToBackStack(null);
    ft.commit();
}

Which looks like this:

That looks okay at first, but as you can see the backbutton is not pressable in the new Fragment, and also when going back to previous Fragment the toolbar is now in all wrong position.

Does anyone have ideas on how to improve on this? I would like to: have the toolbar accessible at all times, and reappear when its hidden. There has got to be a better way to do this. I would like to see some alternative way to deal with toolbar hidden on scrolling from recyclerview, when changing to new fragment. Surely someone will have had similar issue!

I will of course provide more code snippets if needed! Thanks.

Body:
Fixed by adding

toolbar.animate().translationY(toolbar.getTop()).setInterpolator(new AccelerateInterpolator()).start();

at MainActivity's taskToAssessment():

public void taskToAssessment() {
    toolbar.animate().translationY(toolbar.getTop()).setInterpolator(new AccelerateInterpolator()).start();
    FragmentManager fm = getSupportFragmentManager();
    FragmentTransaction ft = fm.beginTransaction();
    ft.setCustomAnimations(R.anim.left_in, R.anim.left_out);
    AssessmentFragment af = new AssessmentFragment();
    ft.replace(R.id.mainFragment, af);
    ft.addToBackStack(null);
    ft.commit();
}


问:
i have use two dropdown components in single page but only first of them is showing data not second one in nativescript ios
i have used dropdown components in nativescript ios but only one component is loading the data not second one </p>

```<code>//this is my code where i have used dropdown

<StackLayout orientation="horizontal" width="100%" class="padding">
      <StackLayout orientation="horizontal" horizontalAlignment="left" width="50%">
        <GridLayout rows="auto, auto, *" columns="auto, *" class="newstack">
          <TextField [(ngModel)]="userRegister.langauge" class="noline"></TextField>
          <DropDown #Langauge hint="Langauge" class="Nopadding" backgroundcolor="transparent" [items]=ArrayLangauge [selectedIndex]="selectedIndex"
            (selectedIndexChange)="onchangeLanguage(Langauge.selectedIndex)" row="0" colSpan="1"></DropDown>
        </GridLayout>
      </StackLayout>

      <StackLayout orientation="horizontal" textWrap="true" horizontalAlignment="right" width="50%">
        <GridLayout rows="auto, auto, *" columns="auto, *" class="newstack" horizontalAlignment="center">
          <TextField [(ngModel)]="userRegister.state" class="noline"></TextField>
          <DropDown #State hint="State" class="Nopadding" backgroundcolor="transparent" [items]="ArrayState" [selectedIndex]="selectedIndex"
            (selectedIndexChange)="onchangeState(State.selectedIndex)" row="0" colSpan="1"></DropDown>
        </GridLayout>
      </StackLayout>
    </StackLayout>
</code>```

答:
At first glance, you have syntax mistake when passing the items in your first drop down control (missing quotes).
this [items]=ArrayLangauge should become

```<code>[items]="ArrayLangauge"
</code>```

Here you can find basic project demonstrating usage of two drop-downs at one page

Body:
i have used dropdown components in nativescript ios but only one component is loading the data not second one

//this is my code where i have used dropdown

<StackLayout orientation="horizontal" width="100%" class="padding">
      <StackLayout orientation="horizontal" horizontalAlignment="left" width="50%">
        <GridLayout rows="auto, auto, *" columns="auto, *" class="newstack">
          <TextField [(ngModel)]="userRegister.langauge" class="noline"></TextField>
          <DropDown #Langauge hint="Langauge" class="Nopadding" backgroundcolor="transparent" [items]=ArrayLangauge [selectedIndex]="selectedIndex"
            (selectedIndexChange)="onchangeLanguage(Langauge.selectedIndex)" row="0" colSpan="1"></DropDown>
        </GridLayout>
      </StackLayout>

      <StackLayout orientation="horizontal" textWrap="true" horizontalAlignment="right" width="50%">
        <GridLayout rows="auto, auto, *" columns="auto, *" class="newstack" horizontalAlignment="center">
          <TextField [(ngModel)]="userRegister.state" class="noline"></TextField>
          <DropDown #State hint="State" class="Nopadding" backgroundcolor="transparent" [items]="ArrayState" [selectedIndex]="selectedIndex"
            (selectedIndexChange)="onchangeState(State.selectedIndex)" row="0" colSpan="1"></DropDown>
        </GridLayout>
      </StackLayout>
    </StackLayout>

Body:
At first glance, you have syntax mistake when passing the items in your first drop down control (missing quotes).
this [items]=ArrayLangauge should become

[items]="ArrayLangauge"

Here you can find basic project demonstrating usage of two drop-downs at one page


问:
How to compare 2 dates in SPARQL
I'm studying non-temporal SPARQL Queries and I'm a bit confused about the concept of RDF triples..

Say, I want to find all employees that cancelled a job and then later chose to complete the same job that they cancelled. So how can I store the date that they cancelled the job and the date they chose to do the same job?

Would the following work?

SELECT ?emp
    WHERE
    {
      ?emp :cancelledJob ?job
      ?emp :dateCancelled ?date1
      ?emp :selectedJob ?job
      ?emp :dateSelectedJob ?date2
      FILTER(?date1 < ?date2)
    }
```

答:
Your query will work if the values of ?date1 and ?date2 are such that they comparable with < as defined in the standard, or if the specific implementation that you're using extends the < operator to handle them. The operator mapping for SPARQL is given in the standard, at 17.3 Operator Mapping. The datatypes that the standard dictates, along with their mappings are:

```<code>numeric         op:numeric-less-than(A, B)
simple literal  op:numeric-equal(fn:compare(A, B), -1)
xsd:string      op:numeric-equal(fn:compare(STR(A), STR(B)), -1)
xsd:boolean     op:boolean-less-than(A, B)
xsd:dateTime    op:dateTime-less-than(A, B)
</code>```

So, if your dates are any of those types, your query will work. Some implementations might handle additional types, too.

Title: How to compare 2 dates in SPARQL

Body:
Your query will work if the values of ?date1 and ?date2 are such that they comparable with < as defined in the standard, or if the specific implementation that you're using extends the < operator to handle them. The operator mapping for SPARQL is given in the standard, at 17.3 Operator Mapping. The datatypes that the standard dictates, along with their mappings are:

numeric         op:numeric-less-than(A, B)
simple literal  op:numeric-equal(fn:compare(A, B), -1)
xsd:string      op:numeric-equal(fn:compare(STR(A), STR(B)), -1)
xsd:boolean     op:boolean-less-than(A, B)
xsd:dateTime    op:dateTime-less-than(A, B)

So, if your dates are any of those types, your query will work. Some implementations might handle additional types, too.