问:
if checkbox check but input empty disable another checkbox
i have one chekbox and one textfield

```<code><input type="checkbox" id="vehicle1" name="vehicle1" value="Bike">

<input class="form-control" type="text" id="usr_zipcode" maxlength="10" name="usr_zipcode" required="required">
</code>```

how to make jquery, when vehiche1 is check but usr_zipcode is empty or no value, it disable another checkbox , name checkme :

```<code><input type="checkbox" id="checkme">
</code>```

i try to use below code but not working

```<code>$('#vehicle1').change(function () {

    var input1 = $('#usr_zipcode');

    input1.change( function() {
       var empty = ( input1.val() == '' );
       $("#checkme").prop('checked', false);
       $("#checkme").attr('disabled','disabled');
    });
}).change();
</code>```

答:
create a separate function to check or disable another checkbox like below</p>

```<code>function checkOrDisableAnotherCheckBox() {
  if($('#vehicle1').is(':checked') && $('#usr_zipcode').val() == ''){
    $("#checkme").attr('disabled', true);
  } else {
    $("#checkme").removeAttr('disabled');
  }
}

$('#vehicle1').change(function () {
  checkOrDisableAnotherCheckBox();
});

$('#usr_zipcode').keyup(function () {
  checkOrDisableAnotherCheckBox();

});
</code>```

Body:
i have one chekbox and one textfield

<input type="checkbox" id="vehicle1" name="vehicle1" value="Bike">

<input class="form-control" type="text" id="usr_zipcode" maxlength="10" name="usr_zipcode" required="required">

how to make jquery, when vehiche1 is check but usr_zipcode is empty or no value, it disable another checkbox , name checkme :

<input type="checkbox" id="checkme">

i try to use below code but not working

$('#vehicle1').change(function () {

    var input1 = $('#usr_zipcode');

    input1.change( function() {
       var empty = ( input1.val() == '' );
       $("#checkme").prop('checked', false);
       $("#checkme").attr('disabled','disabled');
    });
}).change();

Body:
create a separate function to check or disable another checkbox like below

function checkOrDisableAnotherCheckBox() {
  if($('#vehicle1').is(':checked') && $('#usr_zipcode').val() == ''){
    $("#checkme").attr('disabled', true);
  } else {
    $("#checkme").removeAttr('disabled');
  }
}

$('#vehicle1').change(function () {
  checkOrDisableAnotherCheckBox();
});

$('#usr_zipcode').keyup(function () {
  checkOrDisableAnotherCheckBox();

});


来源: stackexchange

问:
Azure Function Blob Storage connection: The format of value '*' is invalid
I am writing a v2 Azure Function in which I will access Azure Blob Storage. Because I was having trouble, I reduced it down to this minimal example.

```<code>namespace Test
{
    public static class Function1
    {
        [FunctionName("Function1")]
        public static async Task<IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "test")] HttpRequest req,
            ILogger log)
        {
            var azureStorage = CloudStorageAccount.Parse("UseDevelopmentStorage=true");
            var blobClient = azureStorage.CreateCloudBlobClient();
            var container = blobClient.GetContainerReference("migrated-load-sets-localhost");
            var blobReference = container.GetBlockBlobReference("11016093-2f6e-4631-97c1-04f8acfb2370");
            var memoryStream = new MemoryStream();
            var accessCondition = AccessCondition.GenerateIfExistsCondition();
            var blobRequestOptions = new BlobRequestOptions();
            await blobReference.DownloadToStreamAsync(memoryStream, accessCondition, blobRequestOptions, null);
            var text = System.Text.Encoding.UTF8.GetString(memoryStream.ToArray());
            return new OkObjectResult(text);
        }
    }
}
</code>```

When I run and hit this, I get the error

System.Private.CoreLib: Exception while executing function: Function1. Microsoft.WindowsAzure.Storage: The format of value '*' is invalid. System.Net.Http: The format of value '*' is invalid.

If I change

```<code>var accessCondition = AccessCondition.GenerateIfExistsCondition();
</code>```

to be

```<code>var accessCondition = AccessCondition.GenerateEmptyCondition();
</code>```

it works.

I have observed in debugging that accessCondition.IfMatchETag equals "*", so it seems like that might be the culprit.

Am I doing something wrong when I use AccessCondition.GenerateIfExistsCondition(), or is there a bug in the library?

答:
In case if you need to check if the blob is present before downloading the file , all you need is </p>

```<code>if(blobReference.ExistsAsync())
{
   //Download
}
</code>```

ContentLicense: CC BY-SA 4.0

Body:
I am writing a v2 Azure Function in which I will access Azure Blob Storage. Because I was having trouble, I reduced it down to this minimal example.

namespace Test
{
    public static class Function1
    {
        [FunctionName("Function1")]
        public static async Task<IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "test")] HttpRequest req,
            ILogger log)
        {
            var azureStorage = CloudStorageAccount.Parse("UseDevelopmentStorage=true");
            var blobClient = azureStorage.CreateCloudBlobClient();
            var container = blobClient.GetContainerReference("migrated-load-sets-localhost");
            var blobReference = container.GetBlockBlobReference("11016093-2f6e-4631-97c1-04f8acfb2370");
            var memoryStream = new MemoryStream();
            var accessCondition = AccessCondition.GenerateIfExistsCondition();
            var blobRequestOptions = new BlobRequestOptions();
            await blobReference.DownloadToStreamAsync(memoryStream, accessCondition, blobRequestOptions, null);
            var text = System.Text.Encoding.UTF8.GetString(memoryStream.ToArray());
            return new OkObjectResult(text);
        }
    }
}

When I run and hit this, I get the error

System.Private.CoreLib: Exception while executing function: Function1. Microsoft.WindowsAzure.Storage: The format of value '*' is invalid. System.Net.Http: The format of value '*' is invalid.

If I change

var accessCondition = AccessCondition.GenerateIfExistsCondition();

to be

var accessCondition = AccessCondition.GenerateEmptyCondition();

it works.

I have observed in debugging that accessCondition.IfMatchETag equals "*", so it seems like that might be the culprit.

Am I doing something wrong when I use AccessCondition.GenerateIfExistsCondition(), or is there a bug in the library?

Body:
In case if you need to check if the blob is present before downloading the file , all you need is

if(blobReference.ExistsAsync())
{
   //Download
}


问:
Regex to find words with specific character
How to find all words which contain a specific letter in it?

For example, if my string is

```<code>This is a Station called South Yarra
</code>```

then I want to extract all words with the letter 'a' in them. The matches will be

```<code>"a", "Station", "called", "Yarra"
</code>```

So far I have tried

```<code>Regex regex = new Regex(@"\w[a]\w");

Regex regex = new Regex(@"\s[a*]\s");
</code>```

答:
Depending on how you want to handle punctuation such as hyphenation, consider using just \w*a\w*.

FYI: \w matches a word character.

Body:
How to find all words which contain a specific letter in it?

For example, if my string is

This is a Station called South Yarra

then I want to extract all words with the letter 'a' in them. The matches will be

"a", "Station", "called", "Yarra"

So far I have tried

Regex regex = new Regex(@"\w[a]\w");

Regex regex = new Regex(@"\s[a*]\s");


问:
Get HTML Element Based on Style in C#
I have HTML in a string and need to use C# to extract a particular node based on its CSS style.  In the past, I've parsed HTML using HtmlAgilityPack.  This parses the HTML very well, and gives me all the elements in an organized fashion.  And I can even filter or query by attributes.  The problem is that it doesn't "understand" how the CSS hierarchy works.  CSS can be inline, at the beginning of the file, or in a parent node.  The browser is intelligent enough to know what the final rendering of an element should be.  HtmlAgilityPack can give me the attributes of a particular element, but I don't see a way for it to tell me what the ultimate style of the element would be.  For example, an element might not have any attributes, but yet have a particular style based on the more complex CSS logic (style from a parent node, etc.)

How can I query the in-memory HTML, without using a headless browser, to find elements whose final rendering (were they to be rendered in a browser) would have a particular style?  (Similar to how jQuery does it, eg: $('[color="#0000ff"]')

I don't want a lot of complicated regexs or similiar.

Thanks,

答:
CSS (Cascading Style Sheet) use for the butterfly layout web application it's a one client site. A web page multiple CSS examples External, Internal, Inline use as user needed. Every CSS works the same goals but it maintains order. the higher order is the Inline CSS then Internal CSS and then external CSS we get it external file. Every CSS selector is not the same example id, class, adjoin, parent, sibling and others selectors. read this article https://css-tricks.com/precedence-css-order-css-matters/.

jQuery selector and CSS Selector are the same but jquery is work different way every jQuery CSS contain in Inline CSS. from your ask $('[color="#0000ff"]') is an a attribute selector. this html example are
content
 but it's not seticesfy W3C. it's also an custom attribute of an html element the W3C are recomended for custom attribute prefix data- example
content
 you got it http://html5doctor.com/html5-custom-data-attributes/.

--Thanks --

Title: Get HTML Element Based on Style in C#

Body:
CSS (Cascading Style Sheet) use for the butterfly layout web application it's a one client site. A web page multiple CSS examples External, Internal, Inline use as user needed. Every CSS works the same goals but it maintains order. the higher order is the Inline CSS then Internal CSS and then external CSS we get it external file. Every CSS selector is not the same example id, class, adjoin, parent, sibling and others selectors. read this article https://css-tricks.com/precedence-css-order-css-matters/.

jQuery selector and CSS Selector are the same but jquery is work different way every jQuery CSS contain in Inline CSS. from your ask $('[color="#0000ff"]') is an a attribute selector. this html example are <div color="#0000ff">content</div> but it's not seticesfy W3C. it's also an custom attribute of an html element the W3C are recomended for custom attribute prefix data- example <div data-color="#0000ff">content</div> you got it http://html5doctor.com/html5-custom-data-attributes/.

--Thanks --


问:
How to generate some feasible solutions in CPLEX-PYTHON (Not docplex)?
I am working on my thesis about a variant form of Vehicle routing problem (VRP) using a linear mathematical programming approach. I have a well-tested model that I formulated but this model is solved in an acceptable computational time for at most 30 nodes, so I need to implement some metaheuristics to find good feasible solutions for bigger instances, so here is the question. I know that I can generate some solutions using a python-cplex command solution_pool (something like that) so I would like help to know how to generate and access to these solutions (objective function value, decision variables values, etc) my model is a cplex object Model. I know that this is possible if you could help me it would be great. Thanks in advance and greetings from Chile.</p>

答:
The solution in the solution pool are available in the Cplex.solution.pool attribute, see the reference documentation here.

CPLEX by default saves any feasible solution it finds in the solution pool, so you don't have to do anything specific to create those solutions. However, since you are not after proving optimality but want to see good solutions fast, you may want to play with some parameters:

Setting Cplex.parameters.emphasis to 4 may produce better solutions faster

There are some more ideas in the manual in the chapter about filling the solution pool. You may want to look at the polishing procedure and/or at Cplex.populate_solution_pool().


问:
UI View before camera picker view
I want to be able to display a UIAlertView and/or an actionsheet before the Camera Picker view. Is it possible and can you tell me how. Thanks in advance,</p>

答:
This tutorial explains it: http://www.musicalgeometry.com/?p=821

Just add a UIAlertview in the overlay view .. if you follow this tutorial, you can do it

ContentLicense: CC BY-SA 3.0

Title: UI View before camera picker view


问:
How to find the placement of a List within another List?
I am working with two lists. The first contains a large sequence of strings. The second contains a smaller list of strings. I need to find where the second list exists in the first list.

I worked with enumeration, and due to the large size of the data, this is very slow, I was hoping for a faster way.

```<code>    List<string> first = new List<string>() { "AAA","BBB","CCC","DDD","EEE","FFF" };

    List<string> second = new List<string>() { "CCC","DDD","EEE" };

int x = SomeMagic(first,second);
</code>```

And I would need x to = 2.

答:
you can use intersect extension method using the namepace System.Linq

```<code>var CommonList = Listfirst.Intersect(Listsecond)
</code>```

Body:
I am working with two lists. The first contains a large sequence of strings. The second contains a smaller list of strings. I need to find where the second list exists in the first list.

I worked with enumeration, and due to the large size of the data, this is very slow, I was hoping for a faster way.

    List<string> first = new List<string>() { "AAA","BBB","CCC","DDD","EEE","FFF" };

    List<string> second = new List<string>() { "CCC","DDD","EEE" };

int x = SomeMagic(first,second);

And I would need x to = 2.

Body:
you can use intersect extension method using the namepace System.Linq

var CommonList = Listfirst.Intersect(Listsecond)


问:
sendto takes much time
I'm trying communicate client-server without tcp's payload. I'm just using tcp's header as payload field which is 20 byte in default. I just realized cpu usage is very high for transfer big files I tried put some timer to every part of code. (I used rdtsc for it.) Result is I build packet's everything in 1000~ tick (I don't touch ipv4 checksum since kernel calculates it automatically); then I looked sendto time, it takes 100000~ tick (100x more than to build the packet). Is there any faster way to send raw tcp packet without sendto or a way to make sendto faster?

I measure sendto time like this:

```<code>timefirst = rdtsc()
sendto()
timesecond = rdtsc()
print timesecond - timefirst
</code>```

I create my send socket with:

```<code>int mysocket = socket(PF_INET, SOCK_RAW, IPPROTO_TCP);
int one = 1;
const int *val = &one;
setsockopt(mysocket, IPPROTO_IP, IP_HDRINCL, val, sizeof(one));
</code>```

Note: I'm talking about packet's time only on my side (sender program and kernel). It's not about about how slow it goes through wire, isp and routers.

答:
Are you encountering Nagle's algorithm: https://en.wikipedia.org/wiki/Nagle%27s_algorithm ?

If so, you can try setting a socket option of TCP_NODELAY which might address data being sent more slowly than you expect.

Title: sendto takes much time

Body:
I'm trying communicate client-server without tcp's payload. I'm just using tcp's header as payload field which is 20 byte in default. I just realized cpu usage is very high for transfer big files I tried put some timer to every part of code. (I used rdtsc for it.) Result is I build packet's everything in 1000~ tick (I don't touch ipv4 checksum since kernel calculates it automatically); then I looked sendto time, it takes 100000~ tick (100x more than to build the packet). Is there any faster way to send raw tcp packet without sendto or a way to make sendto faster?

I measure sendto time like this:

timefirst = rdtsc()
sendto()
timesecond = rdtsc()
print timesecond - timefirst

I create my send socket with:

int mysocket = socket(PF_INET, SOCK_RAW, IPPROTO_TCP);
int one = 1;
const int *val = &one;
setsockopt(mysocket, IPPROTO_IP, IP_HDRINCL, val, sizeof(one));

Note: I'm talking about packet's time only on my side (sender program and kernel). It's not about about how slow it goes through wire, isp and routers.


问:
Docker compose cannot find build path
I'm trying to run docker-compose but I'm thrown an "Build path does not exist..." error although as shown in the second last statement in the image below I am in the correct directory with the relevant files all inside.

How do I fix this?

I'm using docker toolbox if it makes any difference.

答:
You could try the same command, but from a CMD session, instead of a git bash session.

That way, a path like C:\... would be recognized by docker compose, from Docker Toolbox for Windows.

Title: Docker compose cannot find build path


问:
Laravel belongsToMany relationship with only one result
I have a relationship between two tables with a join table that only has one result.

When I define a Laravel belongsToMany relationship, instead of returning a collection with only one element I would like to have it return that item alone.

Is there a way to model this in Laravel?

Thanks in advance.

[EDIT]

I'll try to explain what I want using the classic Users/Roles example. Besides de users and roles tables, we'll have a users_roles pivot table which will store all the roles the user has had. A user can, at any given time, have only one active role (identified by the active attribute being true).

class User {
    function role() {
        return $this->belongsToMany('App\Role')->wherePivot('active', 'true');
    }
}
```

With this relationship definition, when I access $user->role I get a collection (with only one element) of Roles. What I would like is to have that Role instance directly.

答:
I faced the exactly same issue, let me show you how I managed it.

In my case a have a belongsToMany relationship between materials and customer_types, the pivot table contains the material price for specific customer types, therefore there are as many records (prices) in the pivot table as customer_types are.

What I expected: when a price is requested for a specific customer_type I want to get the scoped price for that specific customer_type as a nested element.

What I got: a collection with only 1 element.

This is what I had at the beginning in my Model:

```<code>class Material extends Model
{
    public function customer_types(){
        return $this->belongsToMany('App\CustomerType', 'customertype_material', 'material_id', 'customertype_id')->withPivot('price');
    }
}
</code>```

Of course, when I requested the customer_types for a specific customer_type the result wasn't the expected one:

```<code>$resources = Material::with(['customer_types' => function($query) use ($customer_type_id){
                        $query->where('customertype_id', $customer_type_id);
                       }])->get();
</code>```

It was returning a Material model with a customer_types nested collection with 1 element on it, forcing me to use first() or loop over 1 element.

The solution: Create a Model that extends the pivot table and add a relationship to it.

Created a new model that extends the pivot:

```<code>use Illuminate\Database\Eloquent\Relations\Pivot;

class CustomertypeMaterial extends Pivot
{
    protected $table    = 'customertype_material';
    protected $fillable = ['price', 'customertype_id', 'material_id'];
}
</code>```

Now, added a relationship pointing to this new model in my Material Model:

```<code>public function scoped_price(){
    return $this->belongsTo('App\CustomertypeMaterial', 'id','material_id');
}
</code>```

Finally the query loading this new relationship:

```<code>$resources = Material::with(['scoped_price' => function($query) use ($customer_type_id){
                        $query->where('customertype_id', $customer_type_id);
                       }])->get();
</code>```

The result is a Material model with a scoped_price element nested on it and filtered by a customer_type_id

I'm not sure if it's the right way to do this, but it's working for me.

Hope it helps!

Body:
I have a relationship between two tables with a join table that only has one result.

When I define a Laravel belongsToMany relationship, instead of returning a collection with only one element I would like to have it return that item alone.

Is there a way to model this in Laravel?

Thanks in advance.

[EDIT]

I'll try to explain what I want using the classic Users/Roles example. Besides de users and roles tables, we'll have a users_roles pivot table which will store all the roles the user has had. A user can, at any given time, have only one active role (identified by the active attribute being true).

class User {
    function role() {
        return $this->belongsToMany('App\Role')->wherePivot('active', 'true');
    }
}

With this relationship definition, when I access $user->role I get a collection (with only one element) of Roles. What I would like is to have that Role instance directly.

Body:
I faced the exactly same issue, let me show you how I managed it.

In my case a have a belongsToMany relationship between materials and customer_types, the pivot table contains the material price for specific customer types, therefore there are as many records (prices) in the pivot table as customer_types are.

What I expected: when a price is requested for a specific customer_type I want to get the scoped price for that specific customer_type as a nested element.

What I got: a collection with only 1 element.

This is what I had at the beginning in my Model:

class Material extends Model
{
    public function customer_types(){
        return $this->belongsToMany('App\CustomerType', 'customertype_material', 'material_id', 'customertype_id')->withPivot('price');
    }
}

Of course, when I requested the customer_types for a specific customer_type the result wasn't the expected one:

$resources = Material::with(['customer_types' => function($query) use ($customer_type_id){
                        $query->where('customertype_id', $customer_type_id);
                       }])->get();

It was returning a Material model with a customer_types nested collection with 1 element on it, forcing me to use first() or loop over 1 element.

The solution: Create a Model that extends the pivot table and add a relationship to it.

Created a new model that extends the pivot:

use Illuminate\Database\Eloquent\Relations\Pivot;

class CustomertypeMaterial extends Pivot
{
    protected $table    = 'customertype_material';
    protected $fillable = ['price', 'customertype_id', 'material_id'];
}

Now, added a relationship pointing to this new model in my Material Model:

public function scoped_price(){
    return $this->belongsTo('App\CustomertypeMaterial', 'id','material_id');
}

Finally the query loading this new relationship:

$resources = Material::with(['scoped_price' => function($query) use ($customer_type_id){
                        $query->where('customertype_id', $customer_type_id);
                       }])->get();

The result is a Material model with a scoped_price element nested on it and filtered by a customer_type_id

I'm not sure if it's the right way to do this, but it's working for me.

Hope it helps!


问:
Count a foreach loop and create new element in php
I'm working on a Mega Menu for WooCommerce Product Category. I'm able to get the list of all Subcategories using the code below;

```<code>$parent_id = 37; //ID of the Parent Category
$subCat_of_parent = get_terms('product_cat',array('child_of' => $parent_id));
</code>```

Then used in a html structure as below;

```<code><div class="row">
    <div class="col-md-6">
        <ul>
        <?php
        foreach ($subCat_of_parent as $subcat) {
            ?>
            <li>
                <a href="<?php echo get_category_link($subcat->term_id); ?>"><?php echo $subcat->name; ?></a>
            </li>
            <?php
        }
         ?>
        </ul>
    </div>
</div>
</code>```

This worked by getting all the list of subcategory of the parent category in this format;

```<code><div class="row">
    <div class="col-md-6">
        <ul>
           <li><a>1st subcategory</a></li>
           <li><a>2nd subcategory</a></li>
           <li><a>3rd subcategory</a></li>
           <li><a>4th subcategory</a></li>
           <li><a>5th subcategory</a></li>
           <li><a>6th subcategory</a></li>
        </ul>
    <div>
</div>
</code>```

what i want to achieve is after the 3rd subcategory, it should break and continue on a new column, so that i can get something like this;

```<code><div class="row">
    <div class="col-md-6">
        <ul>
           <li><a>1st subcategory</a></li>
           <li><a>2nd subcategory</a></li>
           <li><a>3rd subcategory</a></li>
        </ul>
    <div>

    <div class="col-md-6">
        <ul>
           <li><a>4th subcategory</a></li>
           <li><a>5th subcategory</a></li>
           <li><a>6th subcategory</a></li>
        </ul>
    <div>
</div>
</code>```

How can i achieve this? Thanks for your help in advance

答:
You can use array_chunk() to divide the array into groups of 3.</p>

```<code><div class="row">

<?php

    $chunks = array_chunk($subCat_of_parent, 3);

    foreach ($chunks as $group) {
        print '<div class="col-md-6">';
        print '<ul>';

        foreach ($group as $subcat) {
            print '<li>';
                //to-do
            print '</li>';
        }

        print '</ul>';
        print '</div>';
    }

?>

</div>
</code>```

Body:
I'm working on a Mega Menu for WooCommerce Product Category. I'm able to get the list of all Subcategories using the code below;

$parent_id = 37; //ID of the Parent Category
$subCat_of_parent = get_terms('product_cat',array('child_of' => $parent_id));

Then used in a html structure as below;

        <?php
        foreach ($subCat_of_parent as $subcat) {
            ?>

                <a href="<?php echo get_category_link($subcat->term_id); ?>"><?php echo $subcat->name; ?>

            <?php
        }
         ?>

This worked by getting all the list of subcategory of the parent category in this format;

1st subcategory

2nd subcategory

3rd subcategory

4th subcategory

5th subcategory

6th subcategory

what i want to achieve is after the 3rd subcategory, it should break and continue on a new column, so that i can get something like this;

1st subcategory

2nd subcategory

3rd subcategory

4th subcategory

5th subcategory

6th subcategory

How can i achieve this? Thanks for your help in advance

Body:
You can use array_chunk() to divide the array into groups of 3.

<div class="row">

<?php

    $chunks = array_chunk($subCat_of_parent, 3);

    foreach ($chunks as $group) {
        print '<div class="col-md-6">';
        print '<ul>';

        foreach ($group as $subcat) {
            print '<li>';
                //to-do
            print '</li>';
        }

        print '</ul>';
        print '</div>';
    }

?>

</div>


答:
You can try my code:

```<code>$('#vehicle1').change(function () {
   checkEmpty();
});

function checkEmpty(){

  var empty = ( $('#vehicle1').prop('checked') && $('#usr_zipcode').val() == '' );
  if (empty) {
    $("#checkme").prop('checked', false);
    $("#checkme").attr('disabled','disabled');
  }else {
    $("#checkme").removeAttr("disabled");
  }
}
</code>```

This is a demo: https://codepen.io/phuongnm153/pen/zQavrN

Title: if checkbox check but input empty disable another checkbox

Body:
You can try my code:

$('#vehicle1').change(function () {
   checkEmpty();
});

function checkEmpty(){

  var empty = ( $('#vehicle1').prop('checked') && $('#usr_zipcode').val() == '' );
  if (empty) {
    $("#checkme").prop('checked', false);
    $("#checkme").attr('disabled','disabled');
  }else {
    $("#checkme").removeAttr("disabled");
  }
}

This is a demo: https://codepen.io/phuongnm153/pen/zQavrN


问:
snippet for creating object from destructured array
For example, I had an array with 3 numbers:

```<code>var arr = [124, -50, 24];
</code>```

and I need to convert this array to the object:

```<code>{
   x: 124,
   y: -50,
   z: 24
}
</code>```

I don`t want to use "old-style" syntax for this, for example:

```<code>{
  x: arr[0],
  y: arr[1],
  z: arr[2]
}
</code>```

so for now, I`m using that syntax:

```<code>const [x, y, z] = [...arr];
const obj = {x, y, z};
</code>```

But, is there is any way to do this with a straight dectructuring array to object without need of temporary variables?

答:
As it was already mentioned in the comment you can use an Immediately Invoked Function Expression (IIFE) to create the object in a single step, but it's less readable then multiple steps.

const arr = [124, -50, 24];
const obj = (([x, y, z]) => ({ x, y, z }))(arr);

console.log(obj);```

Body:
For example, I had an array with 3 numbers:

var arr = [124, -50, 24];

and I need to convert this array to the object:

{
   x: 124,
   y: -50,
   z: 24
}

I don`t want to use "old-style" syntax for this, for example:

{
  x: arr[0],
  y: arr[1],
  z: arr[2]
}

so for now, I`m using that syntax:

const [x, y, z] = [...arr];
const obj = {x, y, z};

But, is there is any way to do this with a straight dectructuring array to object without need of temporary variables?


问:
Mootools - Fx.Tween vs Fx.Morph
I'm fairly new to MooTools. I notice that the Morph effect is similar to the Tween effect.

Is the only difference that tween is for one attribute and morph is for multiple.

Can some one please tell me what the effects are best used for, i.e two scenarios where one effect is suited more than the other.

Thanks!

答:
Fx.Tween would be more performant than Fx.Morph when animating only one property, ie:

```<code>el.tween('height', 100);
</code>```

Versus

```<code>el.morph({
    height: 100
});
</code>```

What you don't want to do, ever, is:

```<code>el.tween('height', 100);
el.tween('width', 100);
</code>```

Instead of:

```<code>el.morph({
    height: 100,
    width: 1000
});
</code>```

OwnerDisplayName: Paul Mason

Title: Mootools - Fx.Tween vs Fx.Morph

Body:
Fx.Tween would be more performant than Fx.Morph when animating only one property, ie:

el.tween('height', 100);

Versus

el.morph({
    height: 100
});

What you don't want to do, ever, is:

el.tween('height', 100);
el.tween('width', 100);

Instead of:

el.morph({
    height: 100,
    width: 1000
});


问:
rdlc report grouping data sort by numeric column
I'm using rdlc report in C#. Inside rdlc report I had added one parent group and report shows data as I expected, Only problem is that I want to sort data by RowId Column This RowId is an int type(DataSet Column). Sort Order shows option A to Z and  Z to A. Reference image is attached here.

Suppose I have Row Id 1, 2,3,4 ....40. This report will sort data like 1,11, 12,13...., 2, 21,.......
How to sort this data in order of 1,2,3,4.....40

I'm using visual studio 2015.
Is there any other way to sort data?

答:
Finally I got solution to this problem, I use expression for converting existing value to int. Expression used is as below,</p>

```<code> =CInt(Fields!RowId.Value)
</code>```

Body:
Finally I got solution to this problem, I use expression for converting existing value to int. Expression used is as below,

 =CInt(Fields!RowId.Value)


问:
Error due to unexpected value in module when use command "ionic cordova build android --release --prod"
I tried to do ionic cordova build android --release --prod but this error come out.

ERROR in : Unexpected value 'ServicePage in C:/Users/User/Ionic project/PLUMS/src/app/service/service.page.ts' declared by the module 'ServicePageModule in C:/Users/User/Ionic project/PLUMS/src/app/service/service.module.ts'. Please add a @Pipe/@Directive/@Component annotation.
[ERROR] An error occurred while running subprocess ng.

What should I do to solve the error?

```<code>**code for service.module.ts**
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { Routes, RouterModule } from '@angular/router';
import { IonicModule } from '@ionic/angular';
import { ServicePage } from './service.page';

const routes: Routes = [
  {
    path: '',
    component: ServicePage
  }
];

@NgModule({
  imports: [
    CommonModule,
    FormsModule,
    IonicModule,
    RouterModule.forChild(routes)
  ],
  declarations: [ServicePage]
})
export class ServicePageModule {}
</code>```

```<code>**code for service.page.ts**
import { Component, OnInit } from '@angular/core';
import { Injectable } from '@angular/core';
import { AngularFirestore } from '@angular/fire/firestore';

@Injectable({
  providedIn: 'root'
})

@Component({
  selector: 'app-service',
  templateUrl: './service.page.html',
  styleUrls: ['./service.page.scss'],
})

export class ServicePage {
  constructor(private firestore: AngularFirestore) { }
}
</code>```

答:
remove this :

```<code>@Injectable({
 providedIn: 'root'
})
</code>```

this is for injecting service/providers .And you are showing page

Body:
I tried to do ionic cordova build android --release --prod but this error come out.

ERROR in : Unexpected value 'ServicePage in C:/Users/User/Ionic project/PLUMS/src/app/service/service.page.ts' declared by the module 'ServicePageModule in C:/Users/User/Ionic project/PLUMS/src/app/service/service.module.ts'. Please add a @Pipe/@Directive/@Component annotation.
[ERROR] An error occurred while running subprocess ng.

What should I do to solve the error?

**code for service.module.ts**
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { Routes, RouterModule } from '@angular/router';
import { IonicModule } from '@ionic/angular';
import { ServicePage } from './service.page';

const routes: Routes = [
  {
    path: '',
    component: ServicePage
  }
];

@NgModule({
  imports: [
    CommonModule,
    FormsModule,
    IonicModule,
    RouterModule.forChild(routes)
  ],
  declarations: [ServicePage]
})
export class ServicePageModule {}

**code for service.page.ts**
import { Component, OnInit } from '@angular/core';
import { Injectable } from '@angular/core';
import { AngularFirestore } from '@angular/fire/firestore';

@Injectable({
  providedIn: 'root'
})

@Component({
  selector: 'app-service',
  templateUrl: './service.page.html',
  styleUrls: ['./service.page.scss'],
})

export class ServicePage {
  constructor(private firestore: AngularFirestore) { }
}

Body:
remove this :

@Injectable({
 providedIn: 'root'
})

this is for injecting service/providers .And you are showing page


问:
How to perform an async operation on exit
I've been trying to perform an asynchronous operation before my process is terminated.

Saying 'terminated' I mean every possibility of termination:

ctrl+c

Uncaught exception

Crashes

End of code

Anything..

To my knowledge the exit event does that but for synchronous operations.

Reading the Nodejs docs i found the beforeExit event is for the async operations BUT :

The 'beforeExit' event is not emitted for conditions causing explicit termination, such as calling process.exit() or uncaught exceptions.

The 'beforeExit' should not be used as an alternative to the 'exit' event unless the intention is to schedule additional work.

Any suggestions?

答:
Using beforeExit hook

The 'beforeExit' event is emitted when Node.js empties its event loop and has no additional work to schedule. Normally, the Node.js process will exit when there is no work scheduled, but a listener registered on the 'beforeExit' event can make asynchronous calls, and thereby cause the Node.js process to continue.

process.on('beforeExit', async () => {
    await something()
    process.exit(0) // if you don't close yourself this will run forever
});
```


问:
Decode json PHP find output only arrays containing POST string value
Im trying to make a simple JSON retriever.

So here is what im trying to do.
When i type for example
Japan. and i post the data to php.
I want it to load the json it has and search arrays for values containing this country Japan

Sending a smaller cut down json array containing only results containing this value back to the page.

The key is Country,
Example json

{
"1": {
        "country": "America",
        "Name": "Harry",
        "Age": "41"
    },
"2": {
        "country": "America",
        "Name": "ben",
        "Age": "40"
    },
"3": {
        "country": "Japan",
        "Name": "taka",
        "Age": "48"
    },
"4": {
        "country": "Japan",
        "Name": "John",
        "Age": "41"
    },
"5": {
        "country": "America",
        "Name": "Ted",
        "Age": "41"
    },
"6": {
        "country": "America",
        "Name": "Simon",
        "Age": "41"
    }
}```
</div>
</div>
</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>var country = $(".country").val();
$.ajax ({
      url: json.php,
      type: 'POST',
      data: {
          'find': country,
      },
      success: function (results) {
          console.log(results);
      },
      fail: function(data) {
          console.log( data.responseText );
          console.log( 'Request Failed' + data.statusText );
      }
  })</code>```

<input name="country" class="country" type="text" placeholder="type country"></input>```
</div>
</div>
</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code><?php
header('content-type: application/json; charset=utf-8');
header("access-control-allow-origin: *");
$jsonurl = "data.json";
$json = file_get_contents($jsonurl);
$find = $_POST["find"];
$decode = json_decode($json, true);

$results = array_filter($decode[''], function($country) {
  return $country['country'] == $find;
});

var_dump($results);</code>```

Any help would be appreciated...

答:
Here is the code sample using which you can achieve your requirement.</p>

```<code>$my_json = '{
           "1": {"country": "America","Name": "Harry","Age": "41"},
           "2": {"country": "America","Name": "ben","Age": "40"},
           "3": {"country": "Japan","Name": "taka","Age": "48"},
           "4": {"country": "Japan","Name": "John","Age": "41"},
           "5": {"country": "America","Name": "Ted","Age": "41"},
           "6": {"country": "America","Name": "Simon","Age": "41"}
        }';
    $json_arr =  json_decode($my_json);
    $item = array();
    foreach($j as $k=>$struct) {
        if ('Japan' == $struct->country) {
            $item[$k] = $struct;
        }
    }
    echo 'Object Array form::';
    echo '---------------------------';
    print_r(array_values($item));
    echo 'Json form::';
    echo '---------------------------';
    echo json_encode(array_values($item));
</code>```

Body:
Im trying to make a simple JSON retriever.

So here is what im trying to do.
When i type for example
Japan. and i post the data to php.
I want it to load the json it has and search arrays for values containing this country Japan

Sending a smaller cut down json array containing only results containing this value back to the page.

The key is Country,
Example json

{
"1": {
        "country": "America",
        "Name": "Harry",
        "Age": "41"
    },
"2": {
        "country": "America",
        "Name": "ben",
        "Age": "40"
    },
"3": {
        "country": "Japan",
        "Name": "taka",
        "Age": "48"
    },
"4": {
        "country": "Japan",
        "Name": "John",
        "Age": "41"
    },
"5": {
        "country": "America",
        "Name": "Ted",
        "Age": "41"
    },
"6": {
        "country": "America",
        "Name": "Simon",
        "Age": "41"
    }
}

var country = $(".country").val();
$.ajax ({
      url: json.php,
      type: 'POST',
      data: {
          'find': country,
      },
      success: function (results) {
          console.log(results);
      },
      fail: function(data) {
          console.log( data.responseText );
          console.log( 'Request Failed' + data.statusText );
      }
  })

<input name="country" class="country" type="text" placeholder="type country"></input>

<?php
header('content-type: application/json; charset=utf-8');
header("access-control-allow-origin: *");
$jsonurl = "data.json";
$json = file_get_contents($jsonurl);
$find = $_POST["find"];
$decode = json_decode($json, true);

$results = array_filter($decode[''], function($country) {
  return $country['country'] == $find;
});

var_dump($results);

Any help would be appreciated...

Body:
Here is the code sample using which you can achieve your requirement.

$my_json = '{
           "1": {"country": "America","Name": "Harry","Age": "41"},
           "2": {"country": "America","Name": "ben","Age": "40"},
           "3": {"country": "Japan","Name": "taka","Age": "48"},
           "4": {"country": "Japan","Name": "John","Age": "41"},
           "5": {"country": "America","Name": "Ted","Age": "41"},
           "6": {"country": "America","Name": "Simon","Age": "41"}
        }';
    $json_arr =  json_decode($my_json);
    $item = array();
    foreach($j as $k=>$struct) {
        if ('Japan' == $struct->country) {
            $item[$k] = $struct;
        }
    }
    echo 'Object Array form::';
    echo '---------------------------';
    print_r(array_values($item));
    echo 'Json form::';
    echo '---------------------------';
    echo json_encode(array_values($item));


问:
google dynamic marker of maps
what i want to do is:

when i select on combo box item, get items from database and show all marker where i have select . but it doesn't work.
Here are my code:

index.php

```<code><?php
    session_start();
    $_SESSION['sum']=0;
        include("database/connect_conf.php");
        if(!connection()){
            echo 'Not connect: '.mysql_error();
            }else{
                connection();
                }
        if(!db_select()){
            echo 'Not connect to Dabatase: '.mysql_error();

            }else{
                db_select();
                }

            $string="SELECT count(province_id) AS c FROM tbl_cep_forum";
            $get_result=mysql_query($string);
                if($get_result){
                    $j=1;
                    while($value=mysql_fetch_array($get_result)){
                        $_SESSION['sum']=$_SESSION['sum']+$value['c'];
                        $j++;
                        }
                    }

    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
        <title>Google Maps AJAX + mySQL/PHP Example</title>
        <script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAR0TWf73rulOP_SnETQPFKxRj5djmSsmVAgDaRb1psFcJlThRhxSjxifqM96NjrBsBn2XrZWSE-QQqQ"
           type="text/javascript"></script>
            <link rel="stylesheet" type="text/css" href="includes/style_map.css" />
            <script type="text/javascript" src="includes/jquery-1.5.min.js"></script>
            <script type="text/javascript" src="includes/interactive_map.js"></script>
            <script type="text/javascript" src="includes/js_map.js"></script>
            <script type="text/ecmascript" src="includes/ajax_google.js"></script>
        <script type="text/javascript">
        //<![CDATA[

        var iconRed = new GIcon();
        iconRed.image = 'http://labs.google.com/ridefinder/images/mm_20_red.png';
        iconRed.shadow = 'http://labs.google.com/ridefinder/images/mm_20_shadow.png';
        iconRed.iconSize = new GSize(12, 20);
        iconRed.shadowSize = new GSize(22, 20);
        iconRed.iconAnchor = new GPoint(6, 20);
        iconRed.infoWindowAnchor = new GPoint(5, 1);

           var customIcons= iconRed;

        function load() {
          if (GBrowserIsCompatible()) {
            var map = new GMap2(document.getElementById("map"));
            map.addControl(new GSmallMapControl());
            map.addControl(new GMapTypeControl());
            map.setCenter(new GLatLng(12.5, 104.98386), 7);

            // Change this depending on the name of your PHP file
            GDownloadUrl("phpsqlajax_genxml.php", function(data) {
              var xml = GXml.parse(data);
              var markers = xml.documentElement.getElementsByTagName("marker");
              for (var i = 0; i < markers.length; i++) {
    //          var pro_id=markers[i].getAttribute("id");

                var name = markers[i].getAttribute("name");
                var type = markers[i].getAttribute("type");
                var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")),
                                        parseFloat(markers[i].getAttribute("lng")));
                var address = markers[i].getAttribute("address");
                var description = markers[i].getAttribute("description");
                var marker = createMarker(point, name, address, type,name,description);
    //          marker.url='http://www.jaukjey.com';
                map.addOverlay(marker);
              }
            });
          }
    }

        function createMarker(point, name, address, type,id,description) {
          var marker = new GMarker(point, customIcons);
          var html_a = "<b>" + name + "</b> <br/>"+ type;
    //      var html = "<b>" + name + "</b> <br/>" + type;

          GEvent.addListener(marker, 'click', function() {
    //          window.location.href = marker.url;
                var imag_info='<img class="city_photo" src="images/cities/sydney.jpg" alt="sydney" width="75" height="75" />';
                var sideHtml='<div class="city_info"><div id="'+name+'" class="dot" continent="'+name+'">'+imag_info+'<br><b>Addres:</b></br><h2>Province Name:....</h2><br></br>'+description+'</div></div>';
            $('.detail_container').fadeOut(500,function(){

                $('.detail_container .city_detail').html(sideHtml);
                $(".detail_container").fadeIn(500);
                                                            })
    //          $(".city_detail").html(sideHtml);
                var div=document.getElementById(id);
                marker.openInfoWindowHtml(html_a);
          });
          return marker;

        }
    /*function Get marker by province*/
    function phpajax_get_Province(){
        $('#t2').load('phpajax_get_uniq_province.php').show();
                        var get_name=$('#continent').val();
                        $.post('phpajax_get_uniq_province.php', { continent: get_name },
                               function(return_data){

                                   $('#t2').html(return_data).show();
                                   });
                        alert('Province name is: '+ get_name);
          if (GBrowserIsCompatible()) {
            var map = new GMap2(document.getElementById("map"));
            map.addControl(new GSmallMapControl());
            map.addControl(new GMapTypeControl());
            map.setCenter(new GLatLng(12.5, 104.98386), 7);

            // Change this depending on the name of your PHP file
            GDownloadUrl("phpajax_get_uniq_province.php", function(data) {
              var xml = GXml.parse(data);
              var markers = xml.documentElement.getElementsByTagName("marker");
              for (var i = 0; i < markers.length; i++) {
    //          var pro_id=markers[i].getAttribute("id");

                var name = markers[i].getAttribute("name");
                var type = markers[i].getAttribute("type");
                var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")),
                                        parseFloat(markers[i].getAttribute("lng")));
                var address = markers[i].getAttribute("address");
                var description = markers[i].getAttribute("description");
                var marker = createMarker(point, name, address, type,name,description);
                map.addOverlay(marker);
          //alert('Has reloded!'+ name+"<br></br>"+ type);
              }
            });

          }
                }

    </script>

      </head>
      <body onload="load()" onunload="GUnload()" bgcolor="#99b3cc">
        <div id="menu_title"><a href="">Forum</a><a href="">Training</a></div>
        <div class="map_contianer">
        <div id="map" style="width: 600px; height: 500px;"></div>
                    <!-- Form -->
          <form id="mapForm" name="mapForm" class="form_continent" method="post" action="">

              <select name="continent" id="continent" onchange="javascript:phpajax_get_Province();">
    <?php
    $str="select * from tbl_cep_province";
    $result=mysql_query($str);
        if($result){
            $i=1;
            while($value=mysql_fetch_array($result)){
            ?>
        <option value="<?php echo $value['id'];?>">
        <?php echo $value['name'];?>
    </option>
        <?php       }
            $i++;
    }else{echo 'Can not select table number.';}?>
        <option value="ALL" selected="selected">Show all provinces</option>
        </select>
    </form>
            <table class="collape_main_contianer" border="0">
            <tr><td class="list_event_province">
            <div style="background-color:#00F; padding-left:5px; font-size:18px; font-weight:bold;">All Medias</div>
            <ul>
            <li><a href="">Download Video</a></li>
            <li><a href="">Download Audio</a></li>
            </ul>
            <div style="background-color:#00F; padding-left:5px; font-size:18px; font-weight:bold;">Total All Forum: <?php echo $_SESSION['sum'];?></div>
            </td></tr>

            <tr><td>

            <div class="detail_container">
            <!-- City details -->
                <div class="city_detail">
                  <!-- City -->
                      <h3>Choose a province</h3>
                      <p>Pellentesque nibh felis, eleifend id, commodo in, interdum vitae, leo. Praesent eu elit. Ut eu ligula.</p>
                      <p>Curabitur fringilla. Nunc est ipsum, pretium quis, dapibus sed, varius non, lectus. Proin a quam.</p>
                      <p>Pellentesque nibh felis, eleifend id, commodo in, interdum vitae, leo. Praesent eu elit. Ut eu ligula.</p>
                      <p>Curabitur fringilla. Nunc est ipsum, pretium quis, dapibus sed, varius non, lectus. Proin a quam.</p>
                      <p>Pellentesque nibh felis, eleifend id, commodo in, interdum vitae, leo. Praesent eu elit. Ut eu ligula.</p>
                      <p>Curabitur fringilla. Nunc est ipsum, pretium quis, dapibus sed, varius non, lectus. Proin a quam.</p>
                      </div>
    </div>

            </td></tr>
            </table>

          </div>
            <div id="t2">return value here</div>
      <div id="left_content"><p class="grey" align="justify">
            <?php
            $str="SELECT tbl_cep_province.id,tbl_cep_province.name FROM tbl_cep_province";
            $result=mysql_query($str);
            if($result){
                $i=1;
                while($get_values=mysql_fetch_array($result)){
                //$_SESSION['name_province']=$values['id'];
                $string="SELECT tbl_cep_province.name,count(province_id) AS c
                    FROM tbl_cep_forum
                    INNER JOIN tbl_cep_province ON tbl_cep_province.id = tbl_cep_forum.province_id
                    WHERE tbl_cep_forum.province_id='".$get_values['id']."'";

                $get_result=mysql_query($string);
                if($get_result){
                    $j=1;
                    while($value=mysql_fetch_array($get_result)){?>
                    <table cellpadding="0" cellspacing="1">
            <tr bgcolor="#ECECEC" onMouseOver="this.style.backgroundColor='transparent'" onMouseOut="this.style.backgroundColor='#ECECEC'">
                    <td style="width:150px; float:left; padding-left:10px;"><?php echo $value['name'];?></td><td style="padding-left:10px; width:30px; float:left;"><?php echo $value['c'];?></td></tr>
                    </table>
                        <?php
                        $j++;
                        }
                    }
                    $i++;
                    }
                }
            ?>
            </p>
        </div>
            <div class="city_detail_container">
                <!-- City -->
                <div class="city_detail" id="sydney">
                    <img class="city_photo" src="images/cities/sydney.jpg" alt="sydney" width="75" height="75" />
                    <div class="city_info">
                        <h2>Sydney 123</h2>
                        <h3>Australia</h3>
                        <p>Pellentesque nibh felis, eleifend id, commodo in, interdum vitae, leo. Praesent eu elit. Ut eu ligula. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos commodo in interdum vitae leo.</p>
                    </div>
                </div>
                    <div class="clear_both"></div>
            </div><!--close city_detail_container-->
       </div><!--Close map_container-->
      </body>
    </html>
</code>```

phpajax_get_uniq_province.php

```<code>    <?php
require("database/connect_conf.php");
    if(!connection()){
        echo 'Not connect: '.mysql_error();
        }else{
            connection();
            }
    if(!db_select()){
        echo 'Not connect to Dabatase: '.mysql_error();

        }else{
            db_select();
            }

if (isset($_POST['continent'])){
    $name=$_POST['continent'];
        ?>
    <script type="text/javascript">alert('The post name is set!');</script>
    <?php

function parseToXML($htmlStr)
{
$xmlStr=str_replace('<','<',$htmlStr);
$xmlStr=str_replace('>','>',$xmlStr);
$xmlStr=str_replace('"','"',$xmlStr);
$xmlStr=str_replace("'",''',$xmlStr);
$xmlStr=str_replace("&",'&',$xmlStr);
return $xmlStr;
}
// Opens a connection to a MySQL server
    //include("images/template/dots.png");
// Select all the rows in the markers table
$query = "SELECT * FROM markers WHERE name='$name'";
$result = mysql_query($query);
if (!$result) {
  die('Invalid query: ' . mysql_error());
}

header("Content-type: text/xml");

// Start XML file, echo parent node
echo '<markers>';

// Iterate through the rows, printing XML nodes for each
while ($row = @mysql_fetch_assoc($result)){
  // ADD TO XML DOCUMENT NODE
  echo '<marker ';
  echo 'name="' . parseToXML($row['name']) . '" ';
  echo 'address="' . parseToXML($row['address']) . '" ';
  echo 'description="' . parseToXML($row['description']) . '" ';
  echo 'lat="' . $row['lat'] . '" ';
  echo 'lng="' . $row['lng'] . '" ';
  echo 'type="' . $row['type'] . '" ';
  echo '/>';
}

// End XML file
echo '</markers>';

}else{
    ?>
    <script type="text/javascript">alert('Can not get post');</script>
    <?php
    }

?>
</code>```

phpsqlajax_genxml.php

```<code>    <?php
    require("database/connect_conf.php");

    function parseToXML($htmlStr)
    {
    $xmlStr=str_replace('<','<',$htmlStr);
    $xmlStr=str_replace('>','>',$xmlStr);
    $xmlStr=str_replace('"','"',$xmlStr);
    $xmlStr=str_replace("'",''',$xmlStr);
    $xmlStr=str_replace("&",'&',$xmlStr);
    return $xmlStr;
    }

    // Opens a connection to a MySQL server
        //include("images/template/dots.png");
        if(!connection()){
            echo 'Not connect: '.mysql_error();
            }else{
                connection();
                }
        if(!db_select()){
            echo 'Not connect to Dabatase: '.mysql_error();

            }else{
                db_select();
                }

    // Select all the rows in the markers table
    $query = "SELECT * FROM markers WHERE 1";
    $result = mysql_query($query);
    if (!$result) {
      die('Invalid query: ' . mysql_error());
    }

    header("Content-type: text/xml");

    // Start XML file, echo parent node
    echo '<markers>';

    // Iterate through the rows, printing XML nodes for each
    while ($row = @mysql_fetch_assoc($result)){
      // ADD TO XML DOCUMENT NODE
      echo '<marker ';
      echo 'name="' . parseToXML($row['name']) . '" ';
      echo 'address="' . parseToXML($row['address']) . '" ';
      echo 'description="' . parseToXML($row['description']) . '" ';
      echo 'lat="' . $row['lat'] . '" ';
      echo 'lng="' . $row['lng'] . '" ';
      echo 'type="' . $row['type'] . '" ';
      echo '/>';
    }

    // End XML file
    echo '</markers>';

    ?>
</code>```

答:
Your first drama may be that you are calling the same PHP script, through jQuery, using the $.load() function and the $.post() function:

```<code>$('#t2').load('phpajax_get_uniq_province.php').show();
var get_name=$('#continent').val();
$.post('phpajax_get_uniq_province.php', { continent: get_name },
</code>```

I have little doubt that is the first of many issues. You really do need to cut the code into pieces, run them independently, using Firebug or similar to view the interactions, and then combine it as you prove each segment as error-free.

Title: google dynamic marker of maps

Body:
what i want to do is:

when i select on combo box item, get items from database and show all marker where i have select . but it doesn't work.
Here are my code:

index.php

<?php
    session_start();
    $_SESSION['sum']=0;
        include("database/connect_conf.php");
        if(!connection()){
            echo 'Not connect: '.mysql_error();
            }else{
                connection();
                }
        if(!db_select()){
            echo 'Not connect to Dabatase: '.mysql_error();

            }else{
                db_select();
                }

            $string="SELECT count(province_id) AS c FROM tbl_cep_forum";
            $get_result=mysql_query($string);
                if($get_result){
                    $j=1;
                    while($value=mysql_fetch_array($get_result)){
                        $_SESSION['sum']=$_SESSION['sum']+$value['c'];
                        $j++;
                        }
                    }

    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

        <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
        <title>Google Maps AJAX + mySQL/PHP Example</title>

            <link rel="stylesheet" type="text/css" href="includes/style_map.css" />

ForumTraining

          <form id="mapForm" name="mapForm" class="form_continent" method="post" action="">

              <select name="continent" id="continent" onchange="javascript:phpajax_get_Province();">
    <?php
    $str="select * from tbl_cep_province";
    $result=mysql_query($str);
        if($result){
            $i=1;
            while($value=mysql_fetch_array($result)){
            ?>
        <option value="<?php echo $value['id'];?>">
        <?php echo $value['name'];?>
    </option>
        <?php       }
            $i++;
    }else{echo 'Can not select table number.';}?>
        <option value="ALL" selected="selected">Show all provinces</option>
        </select>
    </form>

All Medias

Download Video

Download Audio

Total All Forum: <?php echo $_SESSION['sum'];?>

Choose a province

Pellentesque nibh felis, eleifend id, commodo in, interdum vitae, leo. Praesent eu elit. Ut eu ligula.

Curabitur fringilla. Nunc est ipsum, pretium quis, dapibus sed, varius non, lectus. Proin a quam.

Pellentesque nibh felis, eleifend id, commodo in, interdum vitae, leo. Praesent eu elit. Ut eu ligula.

Curabitur fringilla. Nunc est ipsum, pretium quis, dapibus sed, varius non, lectus. Proin a quam.

Pellentesque nibh felis, eleifend id, commodo in, interdum vitae, leo. Praesent eu elit. Ut eu ligula.

Curabitur fringilla. Nunc est ipsum, pretium quis, dapibus sed, varius non, lectus. Proin a quam.

return value here

            <?php
            $str="SELECT tbl_cep_province.id,tbl_cep_province.name FROM tbl_cep_province";
            $result=mysql_query($str);
            if($result){
                $i=1;
                while($get_values=mysql_fetch_array($result)){
                //$_SESSION['name_province']=$values['id'];
                $string="SELECT tbl_cep_province.name,count(province_id) AS c
                    FROM tbl_cep_forum
                    INNER JOIN tbl_cep_province ON tbl_cep_province.id = tbl_cep_forum.province_id
                    WHERE tbl_cep_forum.province_id='".$get_values['id']."'";

                $get_result=mysql_query($string);
                if($get_result){
                    $j=1;
                    while($value=mysql_fetch_array($get_result)){?>

                    <?php echo $value['name'];?>	<?php echo $value['c'];?>

                        <?php
                        $j++;
                        }
                    }
                    $i++;
                    }
                }
            ?>

Sydney 123

Australia

Pellentesque nibh felis, eleifend id, commodo in, interdum vitae, leo. Praesent eu elit. Ut eu ligula. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos commodo in interdum vitae leo.

phpajax_get_uniq_province.php

    <?php
require("database/connect_conf.php");
    if(!connection()){
        echo 'Not connect: '.mysql_error();
        }else{
            connection();
            }
    if(!db_select()){
        echo 'Not connect to Dabatase: '.mysql_error();

        }else{
            db_select();
            }

if (isset($_POST['continent'])){
    $name=$_POST['continent'];
        ?>

    <?php

function parseToXML($htmlStr)
{
$xmlStr=str_replace('<','<',$htmlStr);
$xmlStr=str_replace('>','>',$xmlStr);
$xmlStr=str_replace('"','"',$xmlStr);
$xmlStr=str_replace("'",''',$xmlStr);
$xmlStr=str_replace("&",'&',$xmlStr);
return $xmlStr;
}
// Opens a connection to a MySQL server
    //include("images/template/dots.png");
// Select all the rows in the markers table
$query = "SELECT * FROM markers WHERE name='$name'";
$result = mysql_query($query);
if (!$result) {
  die('Invalid query: ' . mysql_error());
}

header("Content-type: text/xml");

// Start XML file, echo parent node
echo '<markers>';

// Iterate through the rows, printing XML nodes for each
while ($row = @mysql_fetch_assoc($result)){
  // ADD TO XML DOCUMENT NODE
  echo '<marker ';
  echo 'name="' . parseToXML($row['name']) . '" ';
  echo 'address="' . parseToXML($row['address']) . '" ';
  echo 'description="' . parseToXML($row['description']) . '" ';
  echo 'lat="' . $row['lat'] . '" ';
  echo 'lng="' . $row['lng'] . '" ';
  echo 'type="' . $row['type'] . '" ';
  echo '/>';
}

// End XML file
echo '</markers>';

}else{
    ?>

    <?php
    }

?>

phpsqlajax_genxml.php

    <?php
    require("database/connect_conf.php");

    function parseToXML($htmlStr)
    {
    $xmlStr=str_replace('<','<',$htmlStr);
    $xmlStr=str_replace('>','>',$xmlStr);
    $xmlStr=str_replace('"','"',$xmlStr);
    $xmlStr=str_replace("'",''',$xmlStr);
    $xmlStr=str_replace("&",'&',$xmlStr);
    return $xmlStr;
    }

    // Opens a connection to a MySQL server
        //include("images/template/dots.png");
        if(!connection()){
            echo 'Not connect: '.mysql_error();
            }else{
                connection();
                }
        if(!db_select()){
            echo 'Not connect to Dabatase: '.mysql_error();

            }else{
                db_select();
                }

    // Select all the rows in the markers table
    $query = "SELECT * FROM markers WHERE 1";
    $result = mysql_query($query);
    if (!$result) {
      die('Invalid query: ' . mysql_error());
    }

    header("Content-type: text/xml");

    // Start XML file, echo parent node
    echo '<markers>';

    // Iterate through the rows, printing XML nodes for each
    while ($row = @mysql_fetch_assoc($result)){
      // ADD TO XML DOCUMENT NODE
      echo '<marker ';
      echo 'name="' . parseToXML($row['name']) . '" ';
      echo 'address="' . parseToXML($row['address']) . '" ';
      echo 'description="' . parseToXML($row['description']) . '" ';
      echo 'lat="' . $row['lat'] . '" ';
      echo 'lng="' . $row['lng'] . '" ';
      echo 'type="' . $row['type'] . '" ';
      echo '/>';
    }

    // End XML file
    echo '</markers>';

    ?>

Body:
Your first drama may be that you are calling the same PHP script, through jQuery, using the $.load() function and the $.post() function:

$('#t2').load('phpajax_get_uniq_province.php').show();
var get_name=$('#continent').val();
$.post('phpajax_get_uniq_province.php', { continent: get_name },

I have little doubt that is the first of many issues. You really do need to cut the code into pieces, run them independently, using Firebug or similar to view the interactions, and then combine it as you prove each segment as error-free.


问:
How to show warning message when back button is pressed in fragments
I want application to show warning message when user press back button and if user select Yes it will go back. And i am in navigation graph fragment.

I have searched many time in stack Overflow and tried:

```<code>@Override
public void onBackPressed() {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

    builder.setTitle("Save Or Not");
    builder.setMessage("Do you want to save this? ");
    builder.setPositiveButton("Save", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            /*Go back:-I dont know how*/
        }
    });
    builder.setNegativeButton("Discard",null);
    builder.show();
}
</code>```

But it is showing giver error:
Method does not override method from its superclass

Edit:
I want to set onBackPressedListener(Mobiles back button) in Navigation graphs fragment

答:
Add this line in button clicklistner MainActivity.super.onBackPressed();
Replace your Activity name insted of MainActivity

```<code> builder.setPositiveButton("Save", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
          dialog.dismiss();
          MainActivity.super.onBackPressed();
         //Replace your Activity name insted of MainActivity
        }
    });
</code>```

Body:
I want application to show warning message when user press back button and if user select Yes it will go back. And i am in navigation graph fragment.

I have searched many time in stack Overflow and tried:

@Override
public void onBackPressed() {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

    builder.setTitle("Save Or Not");
    builder.setMessage("Do you want to save this? ");
    builder.setPositiveButton("Save", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            /*Go back:-I dont know how*/
        }
    });
    builder.setNegativeButton("Discard",null);
    builder.show();
}

But it is showing giver error:
Method does not override method from its superclass

Edit:
I want to set onBackPressedListener(Mobiles back button) in Navigation graphs fragment

Body:
Add this line in button clicklistner MainActivity.super.onBackPressed();
Replace your Activity name insted of MainActivity

 builder.setPositiveButton("Save", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
          dialog.dismiss();
          MainActivity.super.onBackPressed();
         //Replace your Activity name insted of MainActivity
        }
    });


问:
How to make sure only one Instances is putting data into Redis Caching server during pre-load process
I am using CacheManager for Redis connections.

Right now, I have multiple instances running same application and connect to same Redis server.

At 8:00, application will be scheduled to do preload method to load data by using put into Redis server.

How do I make sure only one of them is writing to Redis?

Do I use lock or something else able to make that happen?

答: You can use Redis String as a distribute lock. see more in: https://redis.io/topics/distlock</p>


问:
Milliseconds in Lap Time Average dropping the Zero in Tenths place
I am using code I found on this site to average lap times in MM:SS.mmm (Averaging Times using Javascript)

It works great until the result has a zero in the tenths place. For example, the result should be 01:00.096 however, the zero is dropped and the answer is 01:00.96

I have simplified the input of 'times' to highlight the problem.

I have looked at different formatting issues, tried converting the strings to numbers and I've looked at the offsetify function thinking it was somehow interpreting the milliseconds incorrectly.

I am a novice at JavaScript with no formal training but enjoy hobby-programming.  I have learned a lot from the examples on this site for use in my own little apps.

```<code>var times = ['01:00.096'];
var date = 0
var result = '';

function offsetify(t)
{
    return t < 10 ? '0' + t : t;
}

for(var x = 0; x < times.length; x++ ) {
    var tarr = times[x].split(':');
    date += new Date(0, 0, 0, 0, tarr[0], tarr[1].split('.')[0], tarr[1].split('.')[1]).getTime();
}
var avg = new Date(date/times.length);
result = offsetify(avg.getMinutes()) + ':' + offsetify(avg.getSeconds()) + '.' + offsetify(avg.getMilliseconds());
</code>```

答:
Your function offsetify(t) appends a 0 in case your minutes/seconds is only single-digit - however milliseconds should be 3 digits!

You could create a new function that appends 0 if it is already 2 digits (less than 100), and 00 if it is only single-digit (less than 10) and just returns the result if it is already 3 digits.

```<code>function offsetifyMilliseconds(t)
{
  return t < 10 ? '00' + t : t < 100 ? '0' + t : t;
}
</code>```

and then do

```<code>result = offsetify(avg.getMinutes()) + ':' + offsetify(avg.getSeconds()) + '.' + offsetifyMilliseconds(avg.getMilliseconds());
</code>```

However recent versions of Javascript (from ES2017) has access to the .padStart() function on any string:

The padStart() method pads the current string with another string (multiple times, if needed) until the resulting string reaches the given length. The padding is applied from the start (left) of the current string.

-- String.prototype.padStart() - MDN

Using this would make your code much more readable (although you'd have to convert the numeric result to a string first). You could even change your offsetify function to use this method, and prevent code duplication!

In the example below I have defined 2 as the default padding length for the method, but you can pass an additional parameter to the function when you want to use it for milliseconds:

var times = ['01:00.096'];
var date = 0
var result = '';

function offsetify(t, len = 2)
{
    return t.toString().padStart(len, '0');
}

for(var x = 0; x < times.length; x++ ) {
    var tarr = times[x].split(':');
    date += new Date(0, 0, 0, 0, tarr[0], tarr[1].split('.')[0], tarr[1].split('.')[1]).getTime();
}
var avg = new Date(date/times.length);

var minutes = offsetify(avg.getMinutes());
var seconds = offsetify(avg.getSeconds());
var milliseconds = offsetify(avg.getMilliseconds(), 3);

result = minutes + ':' + seconds + ':' + milliseconds;

console.log(result);```

Body:
I am using code I found on this site to average lap times in MM:SS.mmm (Averaging Times using Javascript)

It works great until the result has a zero in the tenths place. For example, the result should be 01:00.096 however, the zero is dropped and the answer is 01:00.96

I have simplified the input of 'times' to highlight the problem.

I have looked at different formatting issues, tried converting the strings to numbers and I've looked at the offsetify function thinking it was somehow interpreting the milliseconds incorrectly.

I am a novice at JavaScript with no formal training but enjoy hobby-programming.  I have learned a lot from the examples on this site for use in my own little apps.

var times = ['01:00.096'];
var date = 0
var result = '';

function offsetify(t)
{
    return t < 10 ? '0' + t : t;
}

for(var x = 0; x < times.length; x++ ) {
    var tarr = times[x].split(':');
    date += new Date(0, 0, 0, 0, tarr[0], tarr[1].split('.')[0], tarr[1].split('.')[1]).getTime();
}
var avg = new Date(date/times.length);
result = offsetify(avg.getMinutes()) + ':' + offsetify(avg.getSeconds()) + '.' + offsetify(avg.getMilliseconds());

Body:
Your function offsetify(t) appends a 0 in case your minutes/seconds is only single-digit - however milliseconds should be 3 digits!

You could create a new function that appends 0 if it is already 2 digits (less than 100), and 00 if it is only single-digit (less than 10) and just returns the result if it is already 3 digits.

function offsetifyMilliseconds(t)
{
  return t < 10 ? '00' + t : t < 100 ? '0' + t : t;
}

and then do

result = offsetify(avg.getMinutes()) + ':' + offsetify(avg.getSeconds()) + '.' + offsetifyMilliseconds(avg.getMilliseconds());

However recent versions of Javascript (from ES2017) has access to the .padStart() function on any string:

The padStart() method pads the current string with another string (multiple times, if needed) until the resulting string reaches the given length. The padding is applied from the start (left) of the current string.

-- String.prototype.padStart() - MDN

Using this would make your code much more readable (although you'd have to convert the numeric result to a string first). You could even change your offsetify function to use this method, and prevent code duplication!

In the example below I have defined 2 as the default padding length for the method, but you can pass an additional parameter to the function when you want to use it for milliseconds:

var times = ['01:00.096'];
var date = 0
var result = '';

function offsetify(t, len = 2)
{
    return t.toString().padStart(len, '0');
}

for(var x = 0; x < times.length; x++ ) {
    var tarr = times[x].split(':');
    date += new Date(0, 0, 0, 0, tarr[0], tarr[1].split('.')[0], tarr[1].split('.')[1]).getTime();
}
var avg = new Date(date/times.length);

var minutes = offsetify(avg.getMinutes());
var seconds = offsetify(avg.getSeconds());
var milliseconds = offsetify(avg.getMilliseconds(), 3);

result = minutes + ':' + seconds + ':' + milliseconds;

console.log(result);


问:
How to preview files before uploaded to server by using file-upload component of vue.js & element-ui?
I'm using vue.js & element-ui to upload files and preview files. I want to preview file(.pdf/.docx/.jpg...) before uploaded to server.

 <el-upload
          ref="uploadFile"
          :on-change="onUploadChange"
          :on-preview="handlePreview"
          :on-remove="handleRemove"
          :before-remove="beforeRemove"
          :file-list="fileList"
          :http-request="handleUpload"
          :data="extendData"
          :auto-upload="false"
          class="upload-demo"
          drag
          action="uploadUrl"
          multiple>

drag here, or click to upload

 </el-upload>
```

Only the on-change function can get the content of the file, while the on-preview function only get the meta message. How to get the file content and preview that before which is uploaded to server?

答:
It's not the meta, it's the file. So you need to use a FileReader on the file:

```<code>handlePreview(file) {
  const reader = new FileReader()

  reader.onload = e => console.log(e.target.result) // here is the result you can work with.

  reader.readAsText(file)
}
</code>```

Body:
I'm using vue.js & element-ui to upload files and preview files. I want to preview file(.pdf/.docx/.jpg...) before uploaded to server.

 <el-upload
          ref="uploadFile"
          :on-change="onUploadChange"
          :on-preview="handlePreview"
          :on-remove="handleRemove"
          :before-remove="beforeRemove"
          :file-list="fileList"
          :http-request="handleUpload"
          :data="extendData"
          :auto-upload="false"
          class="upload-demo"
          drag
          action="uploadUrl"
          multiple>

drag here, or click to upload

 </el-upload>

Only the on-change function can get the content of the file, while the on-preview function only get the meta message. How to get the file content and preview that before which is uploaded to server?

Body:
It's not the meta, it's the file. So you need to use a FileReader on the file:

handlePreview(file) {
  const reader = new FileReader()

  reader.onload = e => console.log(e.target.result) // here is the result you can work with.

  reader.readAsText(file)
}


问:
How to ignore events in Observable if condition does not match?
I want to place a condition such that I want to ignore the action event if the condition is not met in the nested pipe condition.

If I just return ignoreElements it is causing an error that the return value does not stream.

```<code>export const getDataEpic: (action$, state$,
    { apolloClient, services }: { apolloClient: ApolloClient<any>, services: any }) => any
    = (action$, state$, { apolloClient, services }) =>
        action$.pipe(ofType('TEST)).pipe(map(x => x))
            .pipe(
                switchMap((action) =>
                    of([true, false, true]))
                        .pipe(
                            map(settings => ({ action, config: settings})), // true or false
                            switchMap(value=> {
                                if(value.config)
                                  return of([1])
                                } else {
                                   // if condition not met then don't emit anything
                                    return ignoreElements();
                                }
                            }),
                        ),

                ),
                groupBy(value => value.action.payload.model.resource),
                mergeMap(ngroup => ngroup

</code>```

答:
The error is because you're returning an operator function instead of an observable. You should return EMPTY if you need an observable that emits no items.

import { EMPTY } from 'rxjs'

...
switchMap(value => {
  if (value.config)
    return of([1])
  } else {
    // if condition not met then don't emit anything
    return EMPTY
  }
})
...
```

Body:
I want to place a condition such that I want to ignore the action event if the condition is not met in the nested pipe condition.

If I just return ignoreElements it is causing an error that the return value does not stream.

export const getDataEpic: (action$, state$,
    { apolloClient, services }: { apolloClient: ApolloClient<any>, services: any }) => any
    = (action$, state$, { apolloClient, services }) =>
        action$.pipe(ofType('TEST)).pipe(map(x => x))
            .pipe(
                switchMap((action) =>
                    of([true, false, true]))
                        .pipe(
                            map(settings => ({ action, config: settings})), // true or false
                            switchMap(value=> {
                                if(value.config)
                                  return of([1])
                                } else {
                                   // if condition not met then don't emit anything
                                    return ignoreElements();
                                }
                            }),
                        ),

                ),
                groupBy(value => value.action.payload.model.resource),
                mergeMap(ngroup => ngroup


问:
Render javascript file with inline javascript
I am having the following *.js file:

```<code>var text = `
This is a test ${Company.Name}.
`

module.exports = {
    text
};
</code>```

My main file looks like the following:

```<code>const Company = {}
Company.Name = "Apple"
</code>```

Basically, I would like to "render" the text and fill it with my predefined variable.

Any suggestions what is the best way to "load" the text file in the main file?

I appreciate your replies!

答:
Just import it:</p>

```<code>const { text } = require("./*");
</code>```

Body:
I am having the following *.js file:

var text = `
This is a test ${Company.Name}.
`

module.exports = {
    text
};

My main file looks like the following:

const Company = {}
Company.Name = "Apple"

Basically, I would like to "render" the text and fill it with my predefined variable.

Any suggestions what is the best way to "load" the text file in the main file?

I appreciate your replies!

Body:
Just import it:

const { text } = require("./*");


问:
Ionic 4, ion-slides vertical scrolling not working
I have a component inside of ion-slide and its is the scroll not working

here is my code :

      {{tab}}

```<code><ion-slide style="height:100%">
  <main-search></main-search>
</ion-slide>

<ion-slide>

    <div style="height:100%">Page 2 </div>

</ion-slide>
</code>```

答:
Please try following code:

.html

```<code><ion-slides [options]="slideOpts"
                pager="true">
      <ion-slide>
        <ion-list>
          <ion-item>
            <h2>Some title1</h2>
          </ion-item>
          <ion-item>
            <h2>Some title2</h2>
          </ion-item>
          <ion-item>
            <h2>Some title3</h2>
          </ion-item>
          <ion-item>
            <h2>Some title4</h2>
          </ion-item>
          <ion-item>
            <h2>Some title5</h2>
          </ion-item>
          <ion-item>
            <h2>Some title45</h2>
          </ion-item>
          <ion-item>
            <h2>Some title46</h2>
          </ion-item>
        </ion-list>
      </ion-slide>

      <ion-slide>
        <ion-list>
          <ion-item>
            <h2>Some title1</h2>
          </ion-item>
          <ion-item>
            <h2>Some title2</h2>
          </ion-item>
          <ion-item>
            <h2>Some title3</h2>
          </ion-item>
          <ion-item>
            <h2>Some title4</h2>
          </ion-item>
          <ion-item>
            <h2>Some title5</h2>
          </ion-item>
          <ion-item>
            <h2>Some title45</h2>
          </ion-item>
          <ion-item>
            <h2>Some title46</h2>
          </ion-item>
          <ion-item>
            <h2>Some title1</h2>
          </ion-item>
          <ion-item>
            <h2>Some title2</h2>
          </ion-item>
          <ion-item>
            <h2>Some title3</h2>
          </ion-item>
          <ion-item>
            <h2>Some title4</h2>
          </ion-item>
          <ion-item>
            <h2>Some title5</h2>
          </ion-item>
          <ion-item>
            <h2>Some title45</h2>
          </ion-item>
          <ion-item>
            <h2>Some title46</h2>
          </ion-item>
        </ion-list>
      </ion-slide>
    </ion-slides>
</code>```

.ts

```<code>  slideOpts = {
      initialSlide: 0,
      speed: 500
  };
</code>```

.scss

For vertical scrolling

```<code>ion-slides{
  overflow-y: scroll;
}
</code>```

For horizontal scrolling

```<code>ion-slides{
  overflow-x: scroll;
}
</code>```

Body:
I have a component inside of ion-slide and its is the scroll not working

here is my code :

      {{tab}}

<ion-slide style="height:100%">

</ion-slide>

<ion-slide>

Page 2

</ion-slide>

Body:
Please try following code:

.html

<ion-slides [options]="slideOpts"
                pager="true">
      <ion-slide>
        <ion-list>
          <ion-item>
            <h2>Some title1</h2>
          </ion-item>
          <ion-item>
            <h2>Some title2</h2>
          </ion-item>
          <ion-item>
            <h2>Some title3</h2>
          </ion-item>
          <ion-item>
            <h2>Some title4</h2>
          </ion-item>
          <ion-item>
            <h2>Some title5</h2>
          </ion-item>
          <ion-item>
            <h2>Some title45</h2>
          </ion-item>
          <ion-item>
            <h2>Some title46</h2>
          </ion-item>
        </ion-list>
      </ion-slide>

      <ion-slide>
        <ion-list>
          <ion-item>
            <h2>Some title1</h2>
          </ion-item>
          <ion-item>
            <h2>Some title2</h2>
          </ion-item>
          <ion-item>
            <h2>Some title3</h2>
          </ion-item>
          <ion-item>
            <h2>Some title4</h2>
          </ion-item>
          <ion-item>
            <h2>Some title5</h2>
          </ion-item>
          <ion-item>
            <h2>Some title45</h2>
          </ion-item>
          <ion-item>
            <h2>Some title46</h2>
          </ion-item>
          <ion-item>
            <h2>Some title1</h2>
          </ion-item>
          <ion-item>
            <h2>Some title2</h2>
          </ion-item>
          <ion-item>
            <h2>Some title3</h2>
          </ion-item>
          <ion-item>
            <h2>Some title4</h2>
          </ion-item>
          <ion-item>
            <h2>Some title5</h2>
          </ion-item>
          <ion-item>
            <h2>Some title45</h2>
          </ion-item>
          <ion-item>
            <h2>Some title46</h2>
          </ion-item>
        </ion-list>
      </ion-slide>
    </ion-slides>

.ts

  slideOpts = {
      initialSlide: 0,
      speed: 500
  };

.scss

For vertical scrolling

ion-slides{
  overflow-y: scroll;
}

For horizontal scrolling

ion-slides{
  overflow-x: scroll;
}


问:
Is HTTPServerUtility.Transfer is more userful  than Response.Redirect in performance of website in asp.net?
Right now I am reading about .net website performance and scalability.

I read many blog posts and microsoft book about performance and scalability.

In last blog, linked here.

In this blog poing no.6 talking about
 "Use HTTPServerUtility.Transfer instead of Response.Redirect"..

Is it more useful in performance of website and to the point as in the blog that,

"They should only be used when you are transferring people to another physical web server.  For any transfers within your server, use .transfer!  You will save a lot of needless HTTP requests."

Anyone help me how it is more useful in performance than response.redirect?

答:
Yeah Server.Transfer eliminate Http Request; however, its not best suited in all scenarios. You should know what each do.

Response.Redierct

Browser request for a page.

Server process request then Response.Redirect sends response with new URL to load having Response code 302 Moved.

Browser receives 302 status code, and request new url.

Server receive new url and process.

Server.Transfer

Browser request for a page.

Server process request then do Server.Transfer <s>sends response with new URL to load having Response code 302 Moved.</s>

<s>Browser receives 302 status code, and request new url.</s>

Server process request on new page then send response back.

So in short you save one round trip with Server.Transfer. But the browser could not get new URL.

Conclusion: If you want to index your URLs by search engines or want your users to bookmark URLs then Server.Transfer will not help you.

Server.Transfer: will only help you to hide URL from user or browser or search engines.


问:
Azure web app deployment failure: access denied for NuGet package
I'm attempting to deploy a .NET Core web app in Azure on Linux from GitHub using Kudu. I get this error during deployment:

```<code>Command: "/home/site/deployments/tools/deploy.sh"
Handling ASP.NET Core Web Application deployment.
  Restoring packages for /home/site/repository/myproject.csproj...
  Installing NuGet.Frameworks 4.7.0.
/opt/dotnet/2.2.104/sdk/2.2.104/NuGet.targets(114,5): error : Access to the path '/var/nuget/nuget.frameworks/4.7.0' is denied. [/home/site/repository/myproject.csproj]
/opt/dotnet/2.2.104/sdk/2.2.104/NuGet.targets(114,5): error :   Permission denied [/home/site/repository/myproject.csproj]
An error has occurred during web site deployment.
dotnet restore failed
\n/opt/Kudu/Scripts/starter.sh "/home/site/deployments/tools/deploy.sh"
</code>```

NuGet.Frameworks is not a library I use in my project. How can I get my project to successfully deploy?

答: Remove the package Microsoft.VisualStudio.Web.CodeGeneration.Design from the project. It has many dependencies, including NuGet.Frameworks, and doesn't seem to play nice with Azure (at least on Linux).

Body:
I'm attempting to deploy a .NET Core web app in Azure on Linux from GitHub using Kudu. I get this error during deployment:

Command: "/home/site/deployments/tools/deploy.sh"
Handling ASP.NET Core Web Application deployment.
  Restoring packages for /home/site/repository/myproject.csproj...
  Installing NuGet.Frameworks 4.7.0.
/opt/dotnet/2.2.104/sdk/2.2.104/NuGet.targets(114,5): error : Access to the path '/var/nuget/nuget.frameworks/4.7.0' is denied. [/home/site/repository/myproject.csproj]
/opt/dotnet/2.2.104/sdk/2.2.104/NuGet.targets(114,5): error :   Permission denied [/home/site/repository/myproject.csproj]
An error has occurred during web site deployment.
dotnet restore failed
\n/opt/Kudu/Scripts/starter.sh "/home/site/deployments/tools/deploy.sh"

NuGet.Frameworks is not a library I use in my project. How can I get my project to successfully deploy?


问:
Which is better vue-native or nativescript-vue?
I would like to start a mobile app with VueJS. Can anyone please suggest which Framework I can choose between vue-native or nativescript-vue?

答:
As @Manoj mentioned about the biggest advantage of using Nativescript is : You can access all the native elements and apis from Javascript.

I think another plus is the ability to create a code-sharing project. New Vue CLI plugin enables code sharing between web and mobile.There’s nothing quite as awesome as watching your web, iOS and Android app all spinning up at once with the same codebase.

You can further read on nativescript blog and here is the sample project.


问:
read csv but occur java.io.FileNotFoundException: (No such file or directory)
my code is

public float modelPredict(String StationNM, int day, int hour, int minute) {
    int[] model = new int[0];
    try {
        File csvfile = new File(Environment.getExternalStorageDirectory() + "/" + StationNM + ".csv");
        CSVReader reader = new CSVReader(new FileReader(csvfile));
        //            CSVReader reader = new CSVReader(new FileReader(StationNM+".csv"));
        String[] nextLine;
        while ((nextLine = reader.readNext()) != null) {
            // nextLine[] is an array of values from the line
            System.out.println(nextLine[0] + nextLine[1] + "etc...");
        }
        model = new int[nextLine.length];
        for (int i = 0; i < nextLine.length; i++) {
            model[i] = Integer.parseInt(nextLine[i]);
        }
    } catch (Exception e) {
        e.printStackTrace();
        //Toast.makeText(this, "The specified file was not found", T oast.LENGTH_SHORT).show();
    }
}
```

<p>and error is </p>

<pre class="lang-none prettyprint-override"><code>java.io.FileNotFoundException: /storage/emulated/0/이대.csv (No such file or directory)
</code>```

my .java file path is

C:\Users\Mir\Python\capstone\SC\MySubwayProject\app\src\main\java\com\example\mysubwayproject

and .csv file path is

C:\Users\Mir\Python\capstone\SC\MySubwayProject\app\src\main\assets\아현.csv

AndroidManifest.xml is (added user-permission)

```<code><?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.mysubwayproject">
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <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=".Main2Activity"
            android:label="@string/title_activity_main2"
            android:theme="@style/AppTheme.NoActionBar"></activity>
        <activity android:name=".TimeSetter" />
        <activity android:name=".ResultView" />
        <activity android:name=".StartStation" />
        <activity android:name=".EndStation" />
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

</manifest>
</code>```

how can I import  .csv files in assets path?

and my Repository is
https://github.com/Lay4U/CapstOne/tree/master/SC/MySubwayProject

答:
I have updated your method. USe it in your code

```<code>public float modelPredict(String StationNM, int day, int hour, int minute) {
    int[] model = new int[0];
    try {
        //File csvfile = new File(Environment.getExternalStorageDirectory() + //"/"+StationNM+".csv");
        File dir = Environment.getExternalStorageDirectory();
        File yourFile = new File(dir, "path/to/the/file/inside/the/sdcard.ext");
        CSVReader reader = new CSVReader(new FileReader(yourFile));
        //            CSVReader reader = new CSVReader(new FileReader(StationNM+".csv"));
        String[] nextLine;
        while ((nextLine = reader.readNext()) != null) {
            // nextLine[] is an array of values from the line
            System.out.println(nextLine[0] + nextLine[1] + "etc...");
        }
        model = new int[nextLine.length];
        for (int i = 0; i < nextLine.length; i++) {
            model[i] = Integer.parseInt(nextLine[i]);
        }
    } catch (Exception e) {
        e.printStackTrace();
        //Toast.makeText(this, "The specified file was not found", T oast.LENGTH_SHORT).show();
    }
}
</code>```

Body:
my code is

public float modelPredict(String StationNM, int day, int hour, int minute) {
    int[] model = new int[0];
    try {
        File csvfile = new File(Environment.getExternalStorageDirectory() + "/" + StationNM + ".csv");
        CSVReader reader = new CSVReader(new FileReader(csvfile));
        //            CSVReader reader = new CSVReader(new FileReader(StationNM+".csv"));
        String[] nextLine;
        while ((nextLine = reader.readNext()) != null) {
            // nextLine[] is an array of values from the line
            System.out.println(nextLine[0] + nextLine[1] + "etc...");
        }
        model = new int[nextLine.length];
        for (int i = 0; i < nextLine.length; i++) {
            model[i] = Integer.parseInt(nextLine[i]);
        }
    } catch (Exception e) {
        e.printStackTrace();
        //Toast.makeText(this, "The specified file was not found", T oast.LENGTH_SHORT).show();
    }
}

and error is

java.io.FileNotFoundException: /storage/emulated/0/이대.csv (No such file or directory)

my .java file path is

C:\Users\Mir\Python\capstone\SC\MySubwayProject\app\src\main\java\com\example\mysubwayproject

and .csv file path is

C:\Users\Mir\Python\capstone\SC\MySubwayProject\app\src\main\assets\아현.csv

AndroidManifest.xml is (added user-permission)

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.mysubwayproject">
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <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=".Main2Activity"
            android:label="@string/title_activity_main2"
            android:theme="@style/AppTheme.NoActionBar"></activity>
        <activity android:name=".TimeSetter" />
        <activity android:name=".ResultView" />
        <activity android:name=".StartStation" />
        <activity android:name=".EndStation" />
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

</manifest>

how can I import  .csv files in assets path?

and my Repository is
https://github.com/Lay4U/CapstOne/tree/master/SC/MySubwayProject

Body:
I have updated your method. USe it in your code

public float modelPredict(String StationNM, int day, int hour, int minute) {
    int[] model = new int[0];
    try {
        //File csvfile = new File(Environment.getExternalStorageDirectory() + //"/"+StationNM+".csv");
        File dir = Environment.getExternalStorageDirectory();
        File yourFile = new File(dir, "path/to/the/file/inside/the/sdcard.ext");
        CSVReader reader = new CSVReader(new FileReader(yourFile));
        //            CSVReader reader = new CSVReader(new FileReader(StationNM+".csv"));
        String[] nextLine;
        while ((nextLine = reader.readNext()) != null) {
            // nextLine[] is an array of values from the line
            System.out.println(nextLine[0] + nextLine[1] + "etc...");
        }
        model = new int[nextLine.length];
        for (int i = 0; i < nextLine.length; i++) {
            model[i] = Integer.parseInt(nextLine[i]);
        }
    } catch (Exception e) {
        e.printStackTrace();
        //Toast.makeText(this, "The specified file was not found", T oast.LENGTH_SHORT).show();
    }
}