问:
RESTORE DATABASE RDS - MS SQL - 0% complete
Im trying to restore/create a MS SQL database from a .bak file of another MS SQL database (versions 2014), however from SQL benchmark I can see that my task is never done.

I followed this documentation and the one from AWS:

https://trailheadtechnology.com/blog/restoring-a-sql-server-backup-to-amazon-rds

http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/SQLServer.Procedural.Importing.html#SQLServer.Procedural.Importing.Native.Using

Steps:

Create the db with permissions to S3 for data restoring.

Install SQL benchmark Linux and Driver

Connect to the database

Upload data to S3

RESTORE:

```<code>exec msdb.dbo.rds_restore_database
    @restore_db_name='DB_test',
    @s3_arn_to_restore_from='arn:aws:s3:::bucket/backup.bak';
</code>```

Then it creates the TASK and hangs there..I had wait for 30 min and the status is always 0% complete...no errors

PD. My user is the creator of the database, the one given to AWS at the creation through the console.

答:
I had the same problem recently trying to restore a .bak dump from S3 into an RDS SQL Server 2008 R2 using SQL Workbench/J (did not try SSMS)

I finally made it work by using the Microsoft JDBC Driver 6.0 for SQL Server with support for the JDBC 4.2 API (included in the Sqljdbc42.jar which requires a JRE of 8 and supports the JDBC 4.2 API)

AWS docs are unfortunately inaccurate in this subject as they propose to use Microsoft JDBC Drivers 4.1 (Preview) or 4.0 for SQL Server with SQL Workbench/J
http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_ConnectToMicrosoftSQLServerInstance.html

Body:
Im trying to restore/create a MS SQL database from a .bak file of another MS SQL database (versions 2014), however from SQL benchmark I can see that my task is never done.

I followed this documentation and the one from AWS:

https://trailheadtechnology.com/blog/restoring-a-sql-server-backup-to-amazon-rds

http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/SQLServer.Procedural.Importing.html#SQLServer.Procedural.Importing.Native.Using

Steps:

Create the db with permissions to S3 for data restoring.

Install SQL benchmark Linux and Driver

Connect to the database

Upload data to S3

RESTORE:

exec msdb.dbo.rds_restore_database
    @restore_db_name='DB_test',
    @s3_arn_to_restore_from='arn:aws:s3:::bucket/backup.bak';

Then it creates the TASK and hangs there..I had wait for 30 min and the status is always 0% complete...no errors

PD. My user is the creator of the database, the one given to AWS at the creation through the console.


来源: stackexchange

问:
Prettify numbers to their closest number with zeros at the end in javascript
I have some chunks as following example:

```<code>// lowest and highest values of chunk arrays
[
    [0, 945710.3843175517],
    [945710.3843175517, 2268727.9557668166],
    [2268727.9557668166, 14965451.25314727],
    [14965451.25314727, 17890252.39415521],
    [17890252.39415521, 3501296406.880383]
]
</code>```

what I want to get from these chunks is something like this:

```<code>< 1.000.000
1.000.000 - 3.000.000
3.000.000 - 15.000.000
15.000.000 - 18.000.000
> 10.000.000
</code>```

I will use these new numbers as a legend of an informative map.

I use a function to achieve this goal named as roundClosestLegendNumber for each value.

All numbers are positive numbers and there is no maximum limitation.

```<code>roundClosestLegendNumber(5) \\ should give 10
roundClosestLegendNumber(94) \\ should give 100
roundClosestLegendNumber(125) \\ should give 200
roundClosestLegendNumber(945710.3843175517) \\ should give 1000000
roundClosestLegendNumber(14965451.25314727) \\ should give 15000000
roundClosestLegendNumber(17890252.39415521) \\ should give 18000000
// and so on
</code>```

答:
You could use significant figures, set sf (I've set mine to 3) then only the first 3 numbers are displayed.

function sigFigure(v) {
  let sf = 3;
  if (v >= Math.pow(10,sf)) {
    let number = v.toPrecision(sf);
    let numbers = number.split("e+")
    return parseInt((numbers[0]*Math.pow(10,numbers[1])).toFixed(0));
  } else {
    return v
  }
}

var array = [0, 945710.38431755, 2268727.9557668166, 14965451.25314727, 17890252.39415521, 3501296406.880383];

console.log(array.map(sigFigure));```

ContentLicense: CC BY-SA 3.0

Body:
I have some chunks as following example:

// lowest and highest values of chunk arrays
[
    [0, 945710.3843175517],
    [945710.3843175517, 2268727.9557668166],
    [2268727.9557668166, 14965451.25314727],
    [14965451.25314727, 17890252.39415521],
    [17890252.39415521, 3501296406.880383]
]

what I want to get from these chunks is something like this:

< 1.000.000
1.000.000 - 3.000.000
3.000.000 - 15.000.000
15.000.000 - 18.000.000
> 10.000.000

I will use these new numbers as a legend of an informative map.

I use a function to achieve this goal named as roundClosestLegendNumber for each value.

All numbers are positive numbers and there is no maximum limitation.

roundClosestLegendNumber(5) \\ should give 10
roundClosestLegendNumber(94) \\ should give 100
roundClosestLegendNumber(125) \\ should give 200
roundClosestLegendNumber(945710.3843175517) \\ should give 1000000
roundClosestLegendNumber(14965451.25314727) \\ should give 15000000
roundClosestLegendNumber(17890252.39415521) \\ should give 18000000
// and so on


问:
Conditionally create an object in c++
I am writing a program that has the option to visualize the output of an algorithm I am working on - this is done by changing a const bool VISUALIZE_OUTPUT variable defined in a header file. In the main file, I want to have this kind of pattern:

```<code>if(VISUALIZE_OUTPUT) {
    VisualizerObject vis_object;
}
...
if(VISUALIZE_OUTPUT) {
    vis_object.initscene(objects_here);
}
...
if(VISUALIZE_OUTPUT) {
    vis_object.drawScene(objects_here);
}
</code>```

However, this clearly won't compile since vis_object goes out of scope. I don't want to declare the object before the condition since it is a big object and it needs to available for multiple points in the code (I can't just have one conditional statement where everything is done).

What is the preferred way of doing this?

Declare the object on the heap and refer to it by using a pointer (or
unique_ptr)?

Declare the object on the heap and make a reference to it
since it won't ever change?

Some other alternative?

答:
I would use Null_object_pattern:

```<code>struct IVisualizerObject
{
    virtual ~IVisualizerObject() = default;
    virtual void initscene(Object&) = 0;
    virtual void drawScene(Object&) = 0;
    // ...
};

struct NullVisualizerObject : IVisualizerObject
{
    void initscene(Object&) override { /* Empty */ }
    void drawScene(Object&) override { /* Empty */}
    // ...
};

struct VisualizerObject : IVisualizerObject
{
    void initscene(Object& o) override { /*Implementation*/}
    void drawScene(Object& o) override { /*Implementation*/}
    // ...
};
</code>```

And finally:

```<code>std::unique_ptr<IVisualizerObject> vis_object;
if (VISUALIZE_OUTPUT) {
    vis_object = std::make_unique<VisualizerObject>();
} else {
    vis_object = std::make_unique<NullVisualizer>();
}

// ...
vis_object->initscene(objects_here);

//...

vis_object->drawScene(objects_here);
</code>```

Title: Conditionally create an object in c++

Body:
I am writing a program that has the option to visualize the output of an algorithm I am working on - this is done by changing a const bool VISUALIZE_OUTPUT variable defined in a header file. In the main file, I want to have this kind of pattern:

if(VISUALIZE_OUTPUT) {
    VisualizerObject vis_object;
}
...
if(VISUALIZE_OUTPUT) {
    vis_object.initscene(objects_here);
}
...
if(VISUALIZE_OUTPUT) {
    vis_object.drawScene(objects_here);
}

However, this clearly won't compile since vis_object goes out of scope. I don't want to declare the object before the condition since it is a big object and it needs to available for multiple points in the code (I can't just have one conditional statement where everything is done).

What is the preferred way of doing this?

Declare the object on the heap and refer to it by using a pointer (or
unique_ptr)?

Declare the object on the heap and make a reference to it
since it won't ever change?

Some other alternative?

Body:
I would use Null_object_pattern:

struct IVisualizerObject
{
    virtual ~IVisualizerObject() = default;
    virtual void initscene(Object&) = 0;
    virtual void drawScene(Object&) = 0;
    // ...
};

struct NullVisualizerObject : IVisualizerObject
{
    void initscene(Object&) override { /* Empty */ }
    void drawScene(Object&) override { /* Empty */}
    // ...
};

struct VisualizerObject : IVisualizerObject
{
    void initscene(Object& o) override { /*Implementation*/}
    void drawScene(Object& o) override { /*Implementation*/}
    // ...
};

And finally:

std::unique_ptr<IVisualizerObject> vis_object;
if (VISUALIZE_OUTPUT) {
    vis_object = std::make_unique<VisualizerObject>();
} else {
    vis_object = std::make_unique<NullVisualizer>();
}

// ...
vis_object->initscene(objects_here);

//...

vis_object->drawScene(objects_here);


问:
In javascript, when creating properties, which is the right way or better syntax?
properties(keys) can be accessed and set using the dot notation as well as the square brackets. any advice when to use dot prototype syntax</p>

```<code>var myObj = {};
myObj.myProp1 = 'value1'; //works, an expando property
myObj[myProp2] = 'value2'; // FAILS, myProp2 is undefined
myObj["myProp2"] = 'value2'; // works, an expando property
myObj[2010]= 'value'; //note the key is number, still works, an expando property??
myObj.2010 = 'value'; // FAILS. to use dot notation, key must be a string

myObj.prototype.myProp3 = 'value3' // whats the advantage?
</code>```

答:
```<code>var myObj = function () {

};
myObj.prototype.myProp3 = 'value3' // whats the advantage?
</code>```

This should be used if you want to use the myObj as a construct to create multiple objects. ie .

```<code>var obj1 = new myObj();
</code>```

then obj1 will also get the myProp3 property

edit: edited the above example . to use myObj as a constructor, it should be declared as a function

ContentLicense: CC BY-SA 2.5

Body:
properties(keys) can be accessed and set using the dot notation as well as the square brackets. any advice when to use dot prototype syntax

var myObj = {};
myObj.myProp1 = 'value1'; //works, an expando property
myObj[myProp2] = 'value2'; // FAILS, myProp2 is undefined
myObj["myProp2"] = 'value2'; // works, an expando property
myObj[2010]= 'value'; //note the key is number, still works, an expando property??
myObj.2010 = 'value'; // FAILS. to use dot notation, key must be a string

myObj.prototype.myProp3 = 'value3' // whats the advantage?

Body:
var myObj = function () {

};
myObj.prototype.myProp3 = 'value3' // whats the advantage?

This should be used if you want to use the myObj as a construct to create multiple objects. ie .

var obj1 = new myObj();

then obj1 will also get the myProp3 property

edit: edited the above example . to use myObj as a constructor, it should be declared as a function


问:
Sending a post method to server undefined - error
My form is in JADE and it look like this.

```<code>  form(action='/test/about', method='post')
          .form-group
            label(for='nameFormControlInput1') Name
            input#nameFormControlInput1.form-control(type='text', placeholder='name')
  .form-group
          input(type='submit', value='Add')
</code>```

In my app.js I have a POST method defined as follows:

```<code>var express = require('express')
  , stylus = require('stylus')
  , nib = require('nib')

var app = express()

function compile(str, path) {
  return stylus(str)
    .set('filename', path)
    .use(nib());
}

app.set('views', __dirname + '/views')
app.set('view engine', 'jade')
app.use(express.logger('dev'))
app.use(stylus.middleware(
  { src: __dirname + '/public'
  , compile: compile
  }
))
app.use(express.static(__dirname + '/public'))

app.get('/', function (req, res) {
  res.render('index',
  { title : 'Home' }
  )
})

app.post('/test/about', function (req, res) {
  console.log(req.body);
  res.render('index',
  { title : 'Home' }
  )
})

app.listen(3000)
</code>```

However, I have added console.log(req.body) and It now prints as undefined
How can I solve this ?

答:
Ok first of all you need to add name attribute to your input element and use the body-parser

```<code>    var express = require('express')
        , stylus = require('stylus')
        , nib = require('nib')
        , bodyParser = require('body-parser');

    var app = express()
    function compile(str, path) {
        return stylus(str)
            .set('filename', path)
            .use(nib());
    }

    app.use(bodyParser.urlencoded({ extended: false }));

   app.set('views', __dirname + '/views')
   app.set('view engine', 'jade')
    // app.use(express.logger('dev'))
    app.use(stylus.middleware(
        {
            src: __dirname + '/public'
            , compile: compile
        }
    ))
    app.use(express.static(__dirname + '/public'))

    app.get('/', function (req, res) {
        res.render('index',
            { title: 'Home' }
        )
    })

    app.post('/test/about', function (req, res) {
        console.log(req.body);

        res.render('formresult',
            {
                title: 'Form Result',
                name: req.body.nameFormControlInput1
            }
        )
    })

    app.listen(3000)
</code>```

after data posted, you can acces it using req.body.nameFormControlInput1

And I create a another jade file to display posted data.

formresult.jade

```<code>- if(name)
 h1=name
- else
 h1 No data
</code>```

index.jade

add name="nameFormControlInput1" to input field

```<code>form(action='/test/about', method='post')
 .form-group
  label(for='nameFormControlInput1') Name
  input#nameFormControlInput1.form-control(type='text', placeholder='name', name="nameFormControlInput1")
  .form-group
   input(type='submit', value='Add')
</code>```

Body:
My form is in JADE and it look like this.

  form(action='/test/about', method='post')
          .form-group
            label(for='nameFormControlInput1') Name
            input#nameFormControlInput1.form-control(type='text', placeholder='name')
  .form-group
          input(type='submit', value='Add')

In my app.js I have a POST method defined as follows:

var express = require('express')
  , stylus = require('stylus')
  , nib = require('nib')

var app = express()

function compile(str, path) {
  return stylus(str)
    .set('filename', path)
    .use(nib());
}

app.set('views', __dirname + '/views')
app.set('view engine', 'jade')
app.use(express.logger('dev'))
app.use(stylus.middleware(
  { src: __dirname + '/public'
  , compile: compile
  }
))
app.use(express.static(__dirname + '/public'))

app.get('/', function (req, res) {
  res.render('index',
  { title : 'Home' }
  )
})

app.post('/test/about', function (req, res) {
  console.log(req.body);
  res.render('index',
  { title : 'Home' }
  )
})

app.listen(3000)

However, I have added console.log(req.body) and It now prints as undefined
How can I solve this ?

Body:
Ok first of all you need to add name attribute to your input element and use the body-parser

    var express = require('express')
        , stylus = require('stylus')
        , nib = require('nib')
        , bodyParser = require('body-parser');

    var app = express()
    function compile(str, path) {
        return stylus(str)
            .set('filename', path)
            .use(nib());
    }

    app.use(bodyParser.urlencoded({ extended: false }));

   app.set('views', __dirname + '/views')
   app.set('view engine', 'jade')
    // app.use(express.logger('dev'))
    app.use(stylus.middleware(
        {
            src: __dirname + '/public'
            , compile: compile
        }
    ))
    app.use(express.static(__dirname + '/public'))

    app.get('/', function (req, res) {
        res.render('index',
            { title: 'Home' }
        )
    })

    app.post('/test/about', function (req, res) {
        console.log(req.body);

        res.render('formresult',
            {
                title: 'Form Result',
                name: req.body.nameFormControlInput1
            }
        )
    })

    app.listen(3000)

after data posted, you can acces it using req.body.nameFormControlInput1

And I create a another jade file to display posted data.

formresult.jade

- if(name)
 h1=name
- else
 h1 No data

index.jade

add name="nameFormControlInput1" to input field

form(action='/test/about', method='post')
 .form-group
  label(for='nameFormControlInput1') Name
  input#nameFormControlInput1.form-control(type='text', placeholder='name', name="nameFormControlInput1")
  .form-group
   input(type='submit', value='Add')


问:
Laravel 5.5 eloquent request in blade and many sql queries
I need output user payments history. With payment method detail. Like card or paypall data for each payment

```<code><table border="1">
        <tr>
        <th>
        </th>
        <th>
            summ
        </th>
        <th>
            date
        </th>
        <th>
            payment method
        </th>
        <th>
            subscription
        </th>
        <th></th>
        </tr>
    @foreach($user -> payments()->get() as $payment)
        <tr>
            <td>
            {{$payment->type}}
            </td>
            <td>
            {{$payment->amount}}$
            </td>
            <td>
            {{$payment->created_at}}
            </td>
            <td>
                   @if($payment -> payment_method()->first()->type == PaymentMethod::PAYPAL_ACCOUNT)
                        <div><strong>Paypal: </strong> {{ $payment -> payment_method() -> first() -> paypal_email }}</div>
                    @else
                        <div><strong>Card: </strong>{{ $payment -> payment_method() -> first() -> card_brand }} **** **** **** {{ $payment -> payment_method() -> first() -> card_last_four }}</div>
                    @endif
            </td>
            <td>
                <div><strong>plan:</strong> {{ $payment->subscription->plan->name }}</div>
                <div><strong>period:</strong> {{ $payment->period_start->format('d.m.Y')}} - {{ $payment->period_end->format('d.m.Y') }}</div>
            </td>
            <td>
                @if (!empty($payment -> void_at))
                    <div>void {{ $payment -> void_at }}</div>
                @elseif (!empty($payment->refund_at))
                    <div>refunded {{ $payment->refund_at }} </div>
                @elseif(!empty($payment->refunded_transaction_id ))
                     <div>refund</div>
                @endif
            </td>
        </tr>
    @endforeach
</table>
</code>```

This code generates many sql request's in each cycle iteration:

```<code>select * from `payment_method` where `payment_method`.`id` = '3' and `payment_method`.`deleted_at` is null limit 1

select * from `payment_method` where `payment_method`.`id` = '3' and `payment_method`.`deleted_at` is null limit 1
</code>```

My models:

User class. With realation to payment one to many

```<code>class User extends Authenticatable
{

    public function payments()
    {
        return $this->hasMany(Payment::class, $this->getForeignKey())->orderBy('created_at', 'desc');
    }

}
</code>```

Payment class with relation to payment method one to one

```<code>class Payment extends Model
{

    public function payment_method()
    {
        return $this->belongsTo(PaymentMethod::class, 'payment_method_id', 'id');
    }
</code>```

How change my code for avoid this

答:
i do Eeager loading two relation</p>

```<code>class User
....
public function paymentWithMethod()
{
    return $this->payments()->with('payment_method', 'subscription.plan')->get();
}
</code>```

Body:
I need output user payments history. With payment method detail. Like card or paypall data for each payment

            summ

            date

            payment method

            subscription

    @foreach($user -> payments()->get() as $payment)

            {{$payment->type}}

            {{$payment->amount}}$

            {{$payment->created_at}}

                   @if($payment -> payment_method()->first()->type == PaymentMethod::PAYPAL_ACCOUNT)

Paypal:  {{ $payment -> payment_method() -> first() -> paypal_email }}

                    @else

Card: {{ $payment -> payment_method() -> first() -> card_brand }} **** **** **** {{ $payment -> payment_method() -> first() -> card_last_four }}

                    @endif

plan: {{ $payment->subscription->plan->name }}

period: {{ $payment->period_start->format('d.m.Y')}} - {{ $payment->period_end->format('d.m.Y') }}

                @if (!empty($payment -> void_at))

void {{ $payment -> void_at }}

                @elseif (!empty($payment->refund_at))

refunded {{ $payment->refund_at }}

                @elseif(!empty($payment->refunded_transaction_id ))

refund

                @endif

    @endforeach

This code generates many sql request's in each cycle iteration:

select * from `payment_method` where `payment_method`.`id` = '3' and `payment_method`.`deleted_at` is null limit 1

select * from `payment_method` where `payment_method`.`id` = '3' and `payment_method`.`deleted_at` is null limit 1

My models:

User class. With realation to payment one to many

class User extends Authenticatable
{

    public function payments()
    {
        return $this->hasMany(Payment::class, $this->getForeignKey())->orderBy('created_at', 'desc');
    }

}

Payment class with relation to payment method one to one

class Payment extends Model
{

    public function payment_method()
    {
        return $this->belongsTo(PaymentMethod::class, 'payment_method_id', 'id');
    }

How change my code for avoid this

Body:
i do Eeager loading two relation

class User
....
public function paymentWithMethod()
{
    return $this->payments()->with('payment_method', 'subscription.plan')->get();
}


问:
Span class getText() using Selenium WebDriver with Java
Its a table inside one of the row contains the below td available, I want to get the span class value in separate string (its dynamic n number of span may available),
means 1111 FRANKLIN STREET OAKLAND, CALIFORNIA 94607-5200:

HTML

```<code><td colspan="5">
    <p class="caption">Assignee</p>
    <a class="ng-binding ng-scope" alt="View assignment(s)" ui-sref="search.resultAssignee(goToAssignee(assignee))" ng-repeat-start="assignee in abstract.patAssigneeName track by $index" href="#assigneeName=THE%20REGENTS%20OF%20THE%20UNIVERSITY%20OF%20CALIFORNIA">UNIVERSITY OF CALIFORNIA</a>
    <p class="ng-scope">
        <span class="ng-binding ng-scope" ng-if="abstract.patAssigneeAddress1[$index] !== ''">1111 FRANKLIN STREET<br></span>
        <span class="ng-binding ng-scope" ng-if="abstract.patAssigneeCity[$index] !== '' && abstract.patAssigneeState[$index] !== ''">OAKLAND, CALIFORNIA 94607-5200<br></span>
        <span class="ng-binding"> </span>
    </p>
    <br class="ng-scope" ng-repeat-end="">
</td>
</code>```

I getting the assignee name easily with below XPath (iterate with table):

```<code>String recAssignee = driver.findElement(By.xpath(" //*[@id='printable-area']/table[" + r + "]/tbody/tr[4]/td/a")).getText().replace("Assignee", "");
</code>```

Please help to get the span class value.

答:
First get all span elements and keep them on a WebElement list. Then get the element using getText() in the loop. You can use like below:

```<code>List<WebElement> allSpanElements = driver.findElements(By.xpath(" //*[@id='printable-area']/table[" + r + "]/tbody/tr[4]/td/p[2]/span"));
for (WebElement elem : allSpanElements) {
    String address = elem.getText();
    //System.out.println(address);
}
</code>```

You can use to keep the value in the String array.

You can also try using the class name instead of xpath like -

```<code>By.className("ng-binding ng-scope");
</code>```

Body:
Its a table inside one of the row contains the below td available, I want to get the span class value in separate string (its dynamic n number of span may available),
means 1111 FRANKLIN STREET OAKLAND, CALIFORNIA 94607-5200:

HTML

Assignee

    UNIVERSITY OF CALIFORNIA

        1111 FRANKLIN STREET

        OAKLAND, CALIFORNIA 94607-5200

I getting the assignee name easily with below XPath (iterate with table):

String recAssignee = driver.findElement(By.xpath(" //*[@id='printable-area']/table[" + r + "]/tbody/tr[4]/td/a")).getText().replace("Assignee", "");

Please help to get the span class value.

Body:
First get all span elements and keep them on a WebElement list. Then get the element using getText() in the loop. You can use like below:

List<WebElement> allSpanElements = driver.findElements(By.xpath(" //*[@id='printable-area']/table[" + r + "]/tbody/tr[4]/td/p[2]/span"));
for (WebElement elem : allSpanElements) {
    String address = elem.getText();
    //System.out.println(address);
}

You can use to keep the value in the String array.

You can also try using the class name instead of xpath like -

By.className("ng-binding ng-scope");


问:
Apache - RewriteRule removes url arguments
I try to add a default parameter when using a particular domain name without any additional infos like ht tp:// www.mydomain.com[NOTHINGHERE]

apache keeps removing the parameter, doing some weird split and discarding it although I try many options SDI,QSA,L...

here is the quiet simple rule :

```<code>RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{QUERY_STRING} "^$"
RewriteRule ^(.*)$ ?s=somehashvalue [QSA,L]
</code>```

here is the log :

```<code>init rewrite engine with requested uri /
pass through /
[perdir /somedironmyserver/] strip per-dir prefix: /somedironmyserver/ ->
[perdir /somedironmyserver/] applying pattern '^(.*)$' to uri ''
[perdir /somedironmyserver/] RewriteCond: input='/somedironmyserver/' pattern='!-f' => matched
[perdir /somedironmyserver/] RewriteCond: input='' pattern='^$' => matched
[perdir /somedironmyserver/] rewrite '' -> '?s=somehashvalue'
split uri=?s=somehashvalue-> uri=, args=s=somehashvalue
[perdir /somedironmyserver/] add per-dir prefix:  -> /somedironmyserver/
[perdir /somedironmyserver/] initial URL equal rewritten URL: /somedironmyserver/ [IGNORING REWRITE]

init rewrite engine with requested uri /index.html
pass through /index.html
[perdir /somedironmyserver/] strip per-dir prefix: /somedironmyserver/index.html -> index.html
[perdir /somedironmyserver/] applying pattern '^(.*)$' to uri 'index.html'
[perdir /somedironmyserver/] RewriteCond: input='/somedironmyserver/index.html' pattern='!-f' => not-matched
[perdir /somedironmyserver/] pass through /somedironmyserver/index.html
</code>```

答:
Try adding the flag R to the rewrite rule. R signifies Redirect and instructs the server to redirect.

```<code>            RewriteEngine On
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteCond %{QUERY_STRING} "^$"
            RewriteBase /
            RewriteRule ^(.*)$ ?s=hashvalue [QSA,L,R]
</code>```

You can find more about flags on the Apache site:

https://httpd.apache.org/docs/2.4/rewrite/flags.html

Body:
I try to add a default parameter when using a particular domain name without any additional infos like ht tp:// www.mydomain.com[NOTHINGHERE]

apache keeps removing the parameter, doing some weird split and discarding it although I try many options SDI,QSA,L...

here is the quiet simple rule :

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{QUERY_STRING} "^$"
RewriteRule ^(.*)$ ?s=somehashvalue [QSA,L]

here is the log :

init rewrite engine with requested uri /
pass through /
[perdir /somedironmyserver/] strip per-dir prefix: /somedironmyserver/ ->
[perdir /somedironmyserver/] applying pattern '^(.*)$' to uri ''
[perdir /somedironmyserver/] RewriteCond: input='/somedironmyserver/' pattern='!-f' => matched
[perdir /somedironmyserver/] RewriteCond: input='' pattern='^$' => matched
[perdir /somedironmyserver/] rewrite '' -> '?s=somehashvalue'
split uri=?s=somehashvalue-> uri=, args=s=somehashvalue
[perdir /somedironmyserver/] add per-dir prefix:  -> /somedironmyserver/
[perdir /somedironmyserver/] initial URL equal rewritten URL: /somedironmyserver/ [IGNORING REWRITE]

init rewrite engine with requested uri /index.html
pass through /index.html
[perdir /somedironmyserver/] strip per-dir prefix: /somedironmyserver/index.html -> index.html
[perdir /somedironmyserver/] applying pattern '^(.*)$' to uri 'index.html'
[perdir /somedironmyserver/] RewriteCond: input='/somedironmyserver/index.html' pattern='!-f' => not-matched
[perdir /somedironmyserver/] pass through /somedironmyserver/index.html

Body:
Try adding the flag R to the rewrite rule. R signifies Redirect and instructs the server to redirect.

            RewriteEngine On
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteCond %{QUERY_STRING} "^$"
            RewriteBase /
            RewriteRule ^(.*)$ ?s=hashvalue [QSA,L,R]

You can find more about flags on the Apache site:

https://httpd.apache.org/docs/2.4/rewrite/flags.html


问:
gem install rb-appscript on macos fails / Alfred todo workflow
I'd like to install rb-appscript on my macbook pro running high sierra but it fails for reasons I can't tell

```<code>sa@mbp: ~ sudo gem install rb-appscript
Password:
Building native extensions.  This could take a while...
ERROR:  Error installing rb-appscript:
    ERROR: Failed to build gem native extension.

    current directory: /usr/local/lib/ruby/gems/2.4.0/gems/rb-appscript-0.6.1
/usr/local/opt/ruby/bin/ruby -r ./siteconf20171117-38586-zi3axn.rb extconf.rb
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
    --with-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/usr/local/Cellar/ruby/2.4.2_1/bin/$(RUBY_BASE_NAME)
extconf.rb:44:in `<main>': uninitialized constant Config (NameError)
Did you mean?  RbConfig
               CONFIG

extconf failed, exit code 1

Gem files will remain installed in /usr/local/lib/ruby/gems/2.4.0/gems/rb-appscript-0.6.1 for inspection.
Results logged to /usr/local/lib/ruby/gems/2.4.0/extensions/x86_64-darwin-17/2.4.0/rb-appscript-0.6.1/gem_make.out
sa@mbp: ~ uname -a
Darwin mbp.home 17.2.0 Darwin Kernel Version 17.2.0: Fri Sep 29 18:27:05 PDT 2017; root:xnu-4570.20.62~3/RELEASE_X86_64 x86_64
sa@mbp: ~ ruby -v
ruby 2.3.3p222 (2016-11-21 revision 56859) [universal.x86_64-darwin17]
sa@mbp: ~ xcode-select -p
/Library/Developer/CommandLineTools
sa@mbp: ~ gcc -v
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 9.0.0 (clang-900.0.38)
Target: x86_64-apple-darwin17.2.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
sa@mbp: ~ make -v
GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for i386-apple-darwin11.3.0
sa@mbp: ~
</code>```

Any clues on what the issue is and how to resolve it?

What I actually want to achieve is installing a workflow for alfred that seems to require 'rb-appscript' https://github.com/dv/alfred-omnifocus-workflow

答:
I ran into this problem recently too. The issue is that the rb-appscript gem is very out of date; it's last update was in 2011. It does not work with modern Mac OS. There's a modern replacement for it called rb-scpt. At the time of this post, it was last updated 9 days ago. I am using it in an app that is running at this very moment in Sierra, so I can confirm that it works.

https://github.com/BrendanThompson/rb-scpt

Body:
I'd like to install rb-appscript on my macbook pro running high sierra but it fails for reasons I can't tell

sa@mbp: ~ sudo gem install rb-appscript
Password:
Building native extensions.  This could take a while...
ERROR:  Error installing rb-appscript:
    ERROR: Failed to build gem native extension.

    current directory: /usr/local/lib/ruby/gems/2.4.0/gems/rb-appscript-0.6.1
/usr/local/opt/ruby/bin/ruby -r ./siteconf20171117-38586-zi3axn.rb extconf.rb
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
    --with-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/usr/local/Cellar/ruby/2.4.2_1/bin/$(RUBY_BASE_NAME)
extconf.rb:44:in `': uninitialized constant Config (NameError)
Did you mean?  RbConfig
               CONFIG

extconf failed, exit code 1

Gem files will remain installed in /usr/local/lib/ruby/gems/2.4.0/gems/rb-appscript-0.6.1 for inspection.
Results logged to /usr/local/lib/ruby/gems/2.4.0/extensions/x86_64-darwin-17/2.4.0/rb-appscript-0.6.1/gem_make.out
sa@mbp: ~ uname -a
Darwin mbp.home 17.2.0 Darwin Kernel Version 17.2.0: Fri Sep 29 18:27:05 PDT 2017; root:xnu-4570.20.62~3/RELEASE_X86_64 x86_64
sa@mbp: ~ ruby -v
ruby 2.3.3p222 (2016-11-21 revision 56859) [universal.x86_64-darwin17]
sa@mbp: ~ xcode-select -p
/Library/Developer/CommandLineTools
sa@mbp: ~ gcc -v
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 9.0.0 (clang-900.0.38)
Target: x86_64-apple-darwin17.2.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
sa@mbp: ~ make -v
GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for i386-apple-darwin11.3.0
sa@mbp: ~

Any clues on what the issue is and how to resolve it?

What I actually want to achieve is installing a workflow for alfred that seems to require 'rb-appscript' https://github.com/dv/alfred-omnifocus-workflow


问:
Getting linux command syntax with escaped quotes correct from R
I am trying to build a linux sendemail command in R using paste from a bunch of values from a contact form.  The message portion will have single and/or double quotes in it.  Based on this post (How to escape double quote inside a double quote?) I have determined that I need to  finish already opened one ('), placing escaped one (\'), then opening another one (').

For example, this works when run directly from linux command line (when using actual email addresses):

```<code>sendemail -f mary@test.com -t bob@test.com -u 'Subject here' -m 'My message'\''s text has single quote or maybe "double quotes".' -s smtp.gmail.com:587 -o tls=yes -xu from@mail.com -xp xxxxxx
</code>```

The message portion is coming from a contact form and I want to email that message to our team.  I've tried using gsub to replace a single quote with  '\'' so sendemail will send the message successfully but I have not found the correct gsub syntax.  I've tried various gyrations of this type of thing:

```<code>gsub("'", "'\''", message)

gsub("\'", "'\\''", message)
</code>```

and so on...  I've tried using fixed, perl, etc.  I cannot seem to get the needed syntax.

I get either no backslashes or 2 backslashes and sendemail wants only one backslash.

Certainly,  I can just remove the single and double quotes from the message and it will work.  I would prefer to preserve the message "as is" if possible, though.

Is this even possible with gsub and paste?

Here is a code snippet of what I'm doing:

```<code> message = gsub("\'", "\\\'", input$mailAndStoreModalText)
 message = gsub("\"", "\\\"", message)
 print( message)
</code>```

If my input is - This's the "best" music - the gsubs above just result in the same exact thing with 0 backslashes.  Then this fails:

```<code>team.email = paste0("sendemail -f ", user.email,
                   " -t ", distr.list,
                   " -u 'Contact Form Submitted' -m",
                   " 'Priority: ", priority," ", message,
                   "' -s smtp.gmail.com:587 -o tls=yes -xu sender@test.com -xp xxxxx")

 t <- try(system(team.email, intern = TRUE))
</code>```

答:
If you chain the gsubs, you should pass message variable the second time. However, you may use it like this:

```<code>message <- gsub("\"", "\\\"", gsub("\'", "\\\'", input$mailAndStoreModalText, fixed=TRUE), fixed=TRUE)
</code>```

Or a regex based replacement:

```<code>message <- gsub("([\"'])", "\\\\\\1", input$mailAndStoreModalText)
</code>```

Both will output This\'s the \"best\" music as output.

See the R demo online. Note that cat(message, "\n") command shows you the literal string that message holds, not the string literal that you get when trying to just print message.

Also, the ([\"']) regex matches and captures into Group 1 either a " or ' and the "\\\\\\1" replacement pattern replaces the whole match with \ (that is defined with 4 backslashes) and then the value inside Group 1 (\\1).

Body:
I am trying to build a linux sendemail command in R using paste from a bunch of values from a contact form.  The message portion will have single and/or double quotes in it.  Based on this post (How to escape double quote inside a double quote?) I have determined that I need to  finish already opened one ('), placing escaped one (\'), then opening another one (').

For example, this works when run directly from linux command line (when using actual email addresses):

sendemail -f mary@test.com -t bob@test.com -u 'Subject here' -m 'My message'\''s text has single quote or maybe "double quotes".' -s smtp.gmail.com:587 -o tls=yes -xu from@mail.com -xp xxxxxx

The message portion is coming from a contact form and I want to email that message to our team.  I've tried using gsub to replace a single quote with  '\'' so sendemail will send the message successfully but I have not found the correct gsub syntax.  I've tried various gyrations of this type of thing:

gsub("'", "'\''", message)

gsub("\'", "'\\''", message)

and so on...  I've tried using fixed, perl, etc.  I cannot seem to get the needed syntax.

I get either no backslashes or 2 backslashes and sendemail wants only one backslash.

Certainly,  I can just remove the single and double quotes from the message and it will work.  I would prefer to preserve the message "as is" if possible, though.

Is this even possible with gsub and paste?

Here is a code snippet of what I'm doing:

 message = gsub("\'", "\\\'", input$mailAndStoreModalText)
 message = gsub("\"", "\\\"", message)
 print( message)

If my input is - This's the "best" music - the gsubs above just result in the same exact thing with 0 backslashes.  Then this fails:

team.email = paste0("sendemail -f ", user.email,
                   " -t ", distr.list,
                   " -u 'Contact Form Submitted' -m",
                   " 'Priority: ", priority," ", message,
                   "' -s smtp.gmail.com:587 -o tls=yes -xu sender@test.com -xp xxxxx")

 t <- try(system(team.email, intern = TRUE))

Body:
If you chain the gsubs, you should pass message variable the second time. However, you may use it like this:

message <- gsub("\"", "\\\"", gsub("\'", "\\\'", input$mailAndStoreModalText, fixed=TRUE), fixed=TRUE)

Or a regex based replacement:

message <- gsub("([\"'])", "\\\\\\1", input$mailAndStoreModalText)

Both will output This\'s the \"best\" music as output.

See the R demo online. Note that cat(message, "\n") command shows you the literal string that message holds, not the string literal that you get when trying to just print message.

Also, the ([\"']) regex matches and captures into Group 1 either a " or ' and the "\\\\\\1" replacement pattern replaces the whole match with \ (that is defined with 4 backslashes) and then the value inside Group 1 (\\1).


问:
Kotlin collections map causing a 'Type Checking Has Run Into A Recursive In Kotlin' error
I have 2 classes lets call them A and B, I also have a function that converts an instance of A to an instance of B.

My code that is causing issues is basically:

```<code>fun fromAtoB(a: A) = B (fb1 = a.fa1, fb2 = a.fa2,  fb3 = a.fa3)

val listOfA: List<A> = ...
val listOfB: listOfA.map { fromAtoB(it) }
</code>```

This won't build due to the line:

```<code>fromAtoB(it)
</code>```

With the error:

Due to the error Type checking has run into a recursive problem. Easiest workaround: specify types of your declarations explicitly

I Have no clue what I can do to fix this, Google had provided no results that seem to apply to my issue...

Thanks in advance for any help!

EDIT:

Here are the actual source files:

TenantEntity.kt - https://pastebin.com/mdSWiA1Y (Line 51 of this file
is the issue)

TenantDto.kt - https://pastebin.com/83UP9Cwe

ReceiptEntity.kt - https://pastebin.com/BjP2ikg9

ReceiptDto.kt - https://pastebin.com/Kpt9dSAp

答:
This type of problem means that the compiler can't infer what the type of listOfB should be, because you have a recursive call somewhere in its definition. That's curious as I can't see any in your example code, but maybe you left out the offending code inadvertently. Anyways, this problem is usually resolved by doing what the error message suggests, manually specifying the return type like so:

```<code>val listOfB: List<B> = listOfA.map { fromAtoB(it) }
</code>```

Edit:
After trying the real code, I just went after a hunch and changed line 45 in TenantEntity.kt from this:

```<code>fun fromDto(dto: TenantDto) = TenantEntity (
</code>```

to this:

```<code>fun fromDto(dto: TenantDto): TenantEntity = TenantEntity (
</code>```

and the error was gone. I'm not really sure why, but it should compile now.

Second edit:
Upon further inspection, you're going to run into a StackOverflowException with this code, which is ultimately why the compiler couldn't resolve the type. When you call TenantEntity.fromDto(...), that will call ReceiptEntity.fromDto(...), which will in turn call TenantEntity.fromDto(...), and back again, into eternity (or the stack limit). That's not going to work, you'll need to fix your logic there.

Body:
I have 2 classes lets call them A and B, I also have a function that converts an instance of A to an instance of B.

My code that is causing issues is basically:

fun fromAtoB(a: A) = B (fb1 = a.fa1, fb2 = a.fa2,  fb3 = a.fa3)

val listOfA: List = ...
val listOfB: listOfA.map { fromAtoB(it) }

This won't build due to the line:

fromAtoB(it)

With the error:

Due to the error Type checking has run into a recursive problem. Easiest workaround: specify types of your declarations explicitly

I Have no clue what I can do to fix this, Google had provided no results that seem to apply to my issue...

Thanks in advance for any help!

EDIT:

Here are the actual source files:

TenantEntity.kt - https://pastebin.com/mdSWiA1Y (Line 51 of this file
is the issue)

TenantDto.kt - https://pastebin.com/83UP9Cwe

ReceiptEntity.kt - https://pastebin.com/BjP2ikg9

ReceiptDto.kt - https://pastebin.com/Kpt9dSAp

Body:
This type of problem means that the compiler can't infer what the type of listOfB should be, because you have a recursive call somewhere in its definition. That's curious as I can't see any in your example code, but maybe you left out the offending code inadvertently. Anyways, this problem is usually resolved by doing what the error message suggests, manually specifying the return type like so:

val listOfB: List<B> = listOfA.map { fromAtoB(it) }

Edit:
After trying the real code, I just went after a hunch and changed line 45 in TenantEntity.kt from this:

fun fromDto(dto: TenantDto) = TenantEntity (

to this:

fun fromDto(dto: TenantDto): TenantEntity = TenantEntity (

and the error was gone. I'm not really sure why, but it should compile now.

Second edit:
Upon further inspection, you're going to run into a StackOverflowException with this code, which is ultimately why the compiler couldn't resolve the type. When you call TenantEntity.fromDto(...), that will call ReceiptEntity.fromDto(...), which will in turn call TenantEntity.fromDto(...), and back again, into eternity (or the stack limit). That's not going to work, you'll need to fix your logic there.


问:
How do you get the duration of a .gif file in c#?
How do i get the duration of a .gif file in c#?

I would like to perform an action during the duration of time an animated gif file is playing, but for some reason i cannot find out how to get the length of time the gif will play.

答:
You can use this code:

```<code>public static class GifExtension
    {
        public static TimeSpan? GetGifDuration(this Image image, int fps = 60)
        {
            var minimumFrameDelay = (1000.0/fps);
            if (!image.RawFormat.Equals(ImageFormat.Gif)) return null;
            if (!ImageAnimator.CanAnimate(image)) return null;

            var frameDimension = new FrameDimension(image.FrameDimensionsList[0]);

            var frameCount = image.GetFrameCount(frameDimension);
            var totalDuration = 0;

            for (var f = 0; f < frameCount; f++)
            {
                var delayPropertyBytes = image.GetPropertyItem(20736).Value;
                var frameDelay = BitConverter.ToInt32(delayPropertyBytes, f * 4) * 10;
                // Minimum delay is 16 ms. It's 1/60 sec i.e. 60 fps
                totalDuration += (frameDelay < minimumFrameDelay ? (int) minimumFrameDelay : frameDelay);
            }

            return TimeSpan.FromMilliseconds(totalDuration);
        }
    }
</code>```

EDIT:
If you are sure, that all frames have the same duration – you can take only delay the first one.

Body:
You can use this code:

public static class GifExtension
    {
        public static TimeSpan? GetGifDuration(this Image image, int fps = 60)
        {
            var minimumFrameDelay = (1000.0/fps);
            if (!image.RawFormat.Equals(ImageFormat.Gif)) return null;
            if (!ImageAnimator.CanAnimate(image)) return null;

            var frameDimension = new FrameDimension(image.FrameDimensionsList[0]);

            var frameCount = image.GetFrameCount(frameDimension);
            var totalDuration = 0;

            for (var f = 0; f < frameCount; f++)
            {
                var delayPropertyBytes = image.GetPropertyItem(20736).Value;
                var frameDelay = BitConverter.ToInt32(delayPropertyBytes, f * 4) * 10;
                // Minimum delay is 16 ms. It's 1/60 sec i.e. 60 fps
                totalDuration += (frameDelay < minimumFrameDelay ? (int) minimumFrameDelay : frameDelay);
            }

            return TimeSpan.FromMilliseconds(totalDuration);
        }
    }

EDIT:
If you are sure, that all frames have the same duration – you can take only delay the first one.


问:
Vue Router Child, Trailing slash
Is is it normal behavior for Vue to add a trailing slash to the default child subroute?

For example:

URL

```<code>Result:
/#/user/test/
</code>```

Link

```<code><router-link :to="{ name: 'user', params: { username: 'test' } }">Test User Overview</router-link>
</code>```

Routes

```<code>routes: [
     {
        path: '/user/:username',
        component: User,
        children: [
            {
                path: '',
                name: 'user',
                component: UserOverview
            },
            {
                path: 'stats',
                name: 'user.stats',
                component: UserStats
            }
        ]
    }
]
</code>```

I would expect the user link to have the path specified by its parent, meaning without a trailing slash. Like this: /#/user/test. If its normal behavior, can I somehow prevent it?

答:
Yes, it is. And do not try to prevent this behaviour, it is preferred and recommended.

Read more in this article - it is older, but not outdated: https://webmasters.googleblog.com/2010/04/to-slash-or-not-to-slash.html?m=1

Title: Vue Router Child, Trailing slash

Body:
Is is it normal behavior for Vue to add a trailing slash to the default child subroute?

For example:

URL

Result:
/#/user/test/

Link

<router-link :to="{ name: 'user', params: { username: 'test' } }">Test User Overview</router-link>

Routes

routes: [
     {
        path: '/user/:username',
        component: User,
        children: [
            {
                path: '',
                name: 'user',
                component: UserOverview
            },
            {
                path: 'stats',
                name: 'user.stats',
                component: UserStats
            }
        ]
    }
]

I would expect the user link to have the path specified by its parent, meaning without a trailing slash. Like this: /#/user/test. If its normal behavior, can I somehow prevent it?


问:
Disown a function from a script?
I'm not sure this is really possible, but maybe someone has some suggestion on how I can do something similar to this:

```<code>#!/bin/bash

dissed() {
    for i in {1..10}
    do
        sleep 5
        echo "$(date)"
    done
}

/usr/bin/screen -S disowned -d -m dissed & disown -h;

screen -ls

echo "done."
</code>```

Of course this doesn't work, since I assume the function gets killed when the script ends. I know it works when I substitute an actual .sh file where the "dissed" function gets called, but this is what I want to avoid.

Is there some way to disown a function or subscript located in the parent?

答:
To detach a process from a bash script:

nohup ./process &
If you stop your bash script with SIGINT for instance, the process won't be bothered and will continue to execute normally. stdout & stderr will be redirected to a file: nohup.out.

If you wish to execute a detached command while being able to see the output in the terminal, then use tail:

TEMP_LOG_FILE=tmp.log

"$TEMP_LOG_FILE"
  nohup ./process &> "$TEMP_LOG_FILE" & tail -f "$TEMP_LOG_FILE" &

Title: Disown a function from a script?

Body:
I'm not sure this is really possible, but maybe someone has some suggestion on how I can do something similar to this:

#!/bin/bash

dissed() {
    for i in {1..10}
    do
        sleep 5
        echo "$(date)"
    done
}

/usr/bin/screen -S disowned -d -m dissed & disown -h;

screen -ls

echo "done."

Of course this doesn't work, since I assume the function gets killed when the script ends. I know it works when I substitute an actual .sh file where the "dissed" function gets called, but this is what I want to avoid.

Is there some way to disown a function or subscript located in the parent?


问:
Python style question: Support class as inner class?
I like to use the structures built into the language to organize my code. But there is one situation where I can't stay consistent, simply because I don't see a definitive best way of doing it. It's regarding support classes, that is, classes that are exclusively used internally by another class: Do I make them inner classes, or separate classes.

Inner classes:

```<code>class Complicated:
    class Utility1:
        pass
    class Utility2:
        pass
    pass
</code>```

Separate classes:

```<code>class Complicated:
    pass

class Utility1:
    pass

class Utility2:
    pass
</code>```

Inner classes has the advantage of being scoped inside the only class that uses them. But the problem is that I get less space to write code due to indentation.

Outer classes have neither the advantage nor the disadvantage. I am tired of always spending some mental energy whenever I write support classes, wondering about this silly issue.

My question is whether anyone with a substantial python experience on their back can advise as to whether there is a best practice regarding this? Even if the answer is that "it depends", it is appreciated if it comes with someone more experienced than myself.

答:
I use the single underscore as a prefix to classes that are internal to a python packages. I think this is a common python pattern:</p>

```<code>class Complicated:
    pass

class _Utility1:
    pass

class _Utility2:
    pass
</code>```

Body:
I like to use the structures built into the language to organize my code. But there is one situation where I can't stay consistent, simply because I don't see a definitive best way of doing it. It's regarding support classes, that is, classes that are exclusively used internally by another class: Do I make them inner classes, or separate classes.

Inner classes:

class Complicated:
    class Utility1:
        pass
    class Utility2:
        pass
    pass

Separate classes:

class Complicated:
    pass

class Utility1:
    pass

class Utility2:
    pass

Inner classes has the advantage of being scoped inside the only class that uses them. But the problem is that I get less space to write code due to indentation.

Outer classes have neither the advantage nor the disadvantage. I am tired of always spending some mental energy whenever I write support classes, wondering about this silly issue.

My question is whether anyone with a substantial python experience on their back can advise as to whether there is a best practice regarding this? Even if the answer is that "it depends", it is appreciated if it comes with someone more experienced than myself.

Body:
I use the single underscore as a prefix to classes that are internal to a python packages. I think this is a common python pattern:

class Complicated:
    pass

class _Utility1:
    pass

class _Utility2:
    pass


问:
Reading all files in two directories at the same time
I have a problem with task. I have two path to directories. I can read all files from first path in argv[1] but can't open files from second folder from argv[2]. Quantity of files is equal.  The way at the begining to write name of fales in array is failed because their is about a few hundred.I have an example how I try reading files. Need help. Thanks!</p>

```<code>#include "stdafx.h"
#include "windows.h"

int main(int argc, char* argv[])
{
    FILE   *fp = 0;
    uchar  tmpl1[BUFFER_SIZE] = { 0 };
    uchar tmpl2[BUFFER_SIZE] = { 0 };
    size_t size;
    size_t n;
    FILE   *Fl = 0;

    if (argc != 3 || argv[1] == NULL || argv[2] == NULL)
    {
        printf("Error", argv[0]);
        return -1;
    }

    char            Fn[255];
    HANDLE          hFind;
    WIN32_FIND_DATA ff;

    char            Fn1[255];
    HANDLE          hFind1;
    WIN32_FIND_DATA ff1;

    sprintf_s(Fn, 255, "%s\\*", argv[1]);
    sprintf_s(Fn1, 255, "%s\\*", argv[2]);

    if ((hFind = FindFirstFile(Fn, &ff)) != INVALID_HANDLE_VALUE)
    {
                if ((hFind1 = FindFirstFile(Fn1, &ff1)) != INVALID_HANDLE_VALUE)
        {
            do
            {
                if (ff.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue;
                ff1.dwFileAttributes;
                sprintf_s(Fn, "%s\\%s", argv[1], ff.cFileName);
                sprintf_s(Fn1, "%s\\%s", argv[2], ff1.cFileName);
                // here I can't read file's name from second folder
                printf(Fn, "%s\\%s", argv[1], ff.cFileName);
                                printf(Fn1, "%s\\%s", argv[2], ff1.cFileName);

                if (fopen_s(&fp, Fn, "rb") != 0)
                {
                    printf("Error reading\nUsage: %s <tmpl1>\n", argv[1]);
                    return -1;
                }
                size = _filelength(_fileno(fp));
                n = fread(tmpl1, size, 1, fp);
                fclose(fp);
                fp = 0;

            } while (FindNextFile(hFind, &ff));
            // also I have a problem how read next file in second directory
            FindClose(hFind);
        }
    }
    return 0;
}
</code>```

答:
I didn't read why you want to scan two directories concurrently.

When I saw "at the same time" in the title I thought "concurrently". Afterwards, I saw the presented code and realized it shall be done rather  "interleaved" instead of "concurrently" but that's not essential.

I assume you want to associate the file names in the first directory somehow to the file names in the second directory. This might be comparing the file names, read data from a file of first directory and read other data from an associated file of second directory, or may be something completely different.

However, based on this assumption, you have to consider that:

You should not assume to get file names in any useful order when scanning with FindFirstFile()/FindNextFile(). These functions return the files in its "physical order" i.e. how they are listed internally. (At best, you get . and .. always as first entries but I even wouldn't count on this.)

Considering this, I would recommend the following procedure:

read file names from first directory and store them in an array names1

read file names from second directory and store them in an array names2

sort arrays names1 and names2 with an appropriate criterion (e.g. lexicographically)

process the arrays names1 and names2.

As you see, the "read file names from directory and store them in an array" could be implemented as function and re-used as well as the sorting.

This said, finally, the answer for how to interleave two directory scans:

```<code>HANDLE hFind1 = FindFirstFile(Fn1, &ff1);
HANDLE hFind2 = FindFirstFile(Fn2, &ff2);
while (hFind1 != INVALID_HANDLE_VALUE || hFind2 != INVALID_HANDLE_VALUE) {
  if (hFind1 != INVALID_HANDLE_VALUE) {
    /** @todo process ff1 somehow */
  }
  if (hFind2 != INVALID_HANDLE_VALUE) {
    /** @todo process ff2 somehow */
  }
  /* iterate: */
  if (!FindNextFile(hFind1, &ff1)) {
    FindClose(hFind1); hFind1 = INVALID_HANDLE_VALUE;
  }
  if (!FindNextFile(hFind2, &ff2)) {
    FindClose(hFind2); hFind2 = INVALID_HANDLE_VALUE;
  }
}
</code>```

Please, note that I "abuse" the handles hFind1 and hFind2 itself for loop repetition. Thus, I do not need the extra ifs. (I like things like that.)

Btw. this loop iterates until both directories are scanned completely (even if they don't contain the same number of entries).

If you want to iterate instead until at least one directory is scanned completely you may achieve this by simply changing the while condition to:

```<code>while (hFind1 != INVALID_HANDLE_VALUE && hFind2 != INVALID_HANDLE_VALUE) {
</code>```

if the loop shall be terminated as soon as at least one directory scan fails.

At last, a little story out of my own past (where I learnt a useful lesson regarding this):

I just had finished my study (of computer science) and was working at home on a rather fresh installed Windows NT when I started to copy a large directory from a CD drive to harddisk. The estimated time was round-about 1 hour and I thought: 'Hey. It does multi-tasking!' Thus, I started a second File Manager to copy another directory from this CD drive concurrently. When I hit the OK button, the prompt noises of the CD drive alerted me as well as the estimated time which "exploded" to multiple hours. After that, I behaved like to expect: tapped on my forehead and mumbled something like "unshareable resources"... (and, of course, stopped the second copying and went for a coffee instead.)

Body:
I have a problem with task. I have two path to directories. I can read all files from first path in argv[1] but can't open files from second folder from argv[2]. Quantity of files is equal.  The way at the begining to write name of fales in array is failed because their is about a few hundred.I have an example how I try reading files. Need help. Thanks!

#include "stdafx.h"
#include "windows.h"

int main(int argc, char* argv[])
{
    FILE   *fp = 0;
    uchar  tmpl1[BUFFER_SIZE] = { 0 };
    uchar tmpl2[BUFFER_SIZE] = { 0 };
    size_t size;
    size_t n;
    FILE   *Fl = 0;

    if (argc != 3 || argv[1] == NULL || argv[2] == NULL)
    {
        printf("Error", argv[0]);
        return -1;
    }

    char            Fn[255];
    HANDLE          hFind;
    WIN32_FIND_DATA ff;

    char            Fn1[255];
    HANDLE          hFind1;
    WIN32_FIND_DATA ff1;

    sprintf_s(Fn, 255, "%s\\*", argv[1]);
    sprintf_s(Fn1, 255, "%s\\*", argv[2]);

    if ((hFind = FindFirstFile(Fn, &ff)) != INVALID_HANDLE_VALUE)
    {
                if ((hFind1 = FindFirstFile(Fn1, &ff1)) != INVALID_HANDLE_VALUE)
        {
            do
            {
                if (ff.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue;
                ff1.dwFileAttributes;
                sprintf_s(Fn, "%s\\%s", argv[1], ff.cFileName);
                sprintf_s(Fn1, "%s\\%s", argv[2], ff1.cFileName);
                // here I can't read file's name from second folder
                printf(Fn, "%s\\%s", argv[1], ff.cFileName);
                                printf(Fn1, "%s\\%s", argv[2], ff1.cFileName);

                if (fopen_s(&fp, Fn, "rb") != 0)
                {
                    printf("Error reading\nUsage: %s <tmpl1>\n", argv[1]);
                    return -1;
                }
                size = _filelength(_fileno(fp));
                n = fread(tmpl1, size, 1, fp);
                fclose(fp);
                fp = 0;

            } while (FindNextFile(hFind, &ff));
            // also I have a problem how read next file in second directory
            FindClose(hFind);
        }
    }
    return 0;
}

Body:
I didn't read why you want to scan two directories concurrently.

When I saw "at the same time" in the title I thought "concurrently". Afterwards, I saw the presented code and realized it shall be done rather  "interleaved" instead of "concurrently" but that's not essential.

I assume you want to associate the file names in the first directory somehow to the file names in the second directory. This might be comparing the file names, read data from a file of first directory and read other data from an associated file of second directory, or may be something completely different.

However, based on this assumption, you have to consider that:

You should not assume to get file names in any useful order when scanning with FindFirstFile()/FindNextFile(). These functions return the files in its "physical order" i.e. how they are listed internally. (At best, you get . and .. always as first entries but I even wouldn't count on this.)

Considering this, I would recommend the following procedure:

read file names from first directory and store them in an array names1

read file names from second directory and store them in an array names2

sort arrays names1 and names2 with an appropriate criterion (e.g. lexicographically)

process the arrays names1 and names2.

As you see, the "read file names from directory and store them in an array" could be implemented as function and re-used as well as the sorting.

This said, finally, the answer for how to interleave two directory scans:

HANDLE hFind1 = FindFirstFile(Fn1, &ff1);
HANDLE hFind2 = FindFirstFile(Fn2, &ff2);
while (hFind1 != INVALID_HANDLE_VALUE || hFind2 != INVALID_HANDLE_VALUE) {
  if (hFind1 != INVALID_HANDLE_VALUE) {
    /** @todo process ff1 somehow */
  }
  if (hFind2 != INVALID_HANDLE_VALUE) {
    /** @todo process ff2 somehow */
  }
  /* iterate: */
  if (!FindNextFile(hFind1, &ff1)) {
    FindClose(hFind1); hFind1 = INVALID_HANDLE_VALUE;
  }
  if (!FindNextFile(hFind2, &ff2)) {
    FindClose(hFind2); hFind2 = INVALID_HANDLE_VALUE;
  }
}

Please, note that I "abuse" the handles hFind1 and hFind2 itself for loop repetition. Thus, I do not need the extra ifs. (I like things like that.)

Btw. this loop iterates until both directories are scanned completely (even if they don't contain the same number of entries).

If you want to iterate instead until at least one directory is scanned completely you may achieve this by simply changing the while condition to:

while (hFind1 != INVALID_HANDLE_VALUE && hFind2 != INVALID_HANDLE_VALUE) {

if the loop shall be terminated as soon as at least one directory scan fails.

At last, a little story out of my own past (where I learnt a useful lesson regarding this):

I just had finished my study (of computer science) and was working at home on a rather fresh installed Windows NT when I started to copy a large directory from a CD drive to harddisk. The estimated time was round-about 1 hour and I thought: 'Hey. It does multi-tasking!' Thus, I started a second File Manager to copy another directory from this CD drive concurrently. When I hit the OK button, the prompt noises of the CD drive alerted me as well as the estimated time which "exploded" to multiple hours. After that, I behaved like to expect: tapped on my forehead and mumbled something like "unshareable resources"... (and, of course, stopped the second copying and went for a coffee instead.)


问:
bootstrap active class background color
I have this HTML for navbar and I need to change the background color for the .active class.

```<code><nav class="navbar navbar-inverse">
  <div class="container-fluid">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" id="white" href="#">TableMailerMM</a>
    </div>
    <div class="collapse navbar-collapse" id="myNavbar">
      <ul class="nav navbar-nav">
        <li class="active"><a href="#">Home</a></li>
        <li><a href="#">About</a></li>
        <li><a href="#">Projects</a></li>
        <li><a href="#">Contact</a></li>
      </ul>
      <!--<ul class="nav navbar-nav navbar-right">
        <li><a href="#"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>
      </ul>-->
    </div>
  </div>
</nav>
</code>```

What I have tried is,

```<code>.nav.navbar-nav li:active{
   background-color: #ff812c;
}
</code>```

but it doesn't work, any ideas?

答:
Try using

```<code>.nav.navbar-nav li.active a{
   background-color: red;
}
</code>```

.nav.navbar-nav li.active a {
      background-color: #ff812c;
  }```
<pre class="snippet-code-html lang-html prettyprint-override"><code><link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<nav class="navbar navbar-inverse">
    <div class="container-fluid">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            TableMailerMM
        </div>
        <div class="collapse navbar-collapse" id="myNavbar">
            <ul class="nav navbar-nav">
                <li class="active">Home</li>
                <li>About</li>
                <li>Projects</li>
                <li>Contact</li>
            </ul>
        </div>
    </div>
</nav></code>```

Title: bootstrap active class background color

Body:
I have this HTML for navbar and I need to change the background color for the .active class.

      <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">

      </button>
      TableMailerMM

Home

About

Projects

Contact

What I have tried is,

.nav.navbar-nav li:active{
   background-color: #ff812c;
}

but it doesn't work, any ideas?

Body:
Try using

.nav.navbar-nav li.active a{
   background-color: red;
}

.nav.navbar-nav li.active a {
      background-color: #ff812c;
  }

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<nav class="navbar navbar-inverse">
    <div class="container-fluid">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" id="white" href="#">TableMailerMM</a>
        </div>
        <div class="collapse navbar-collapse" id="myNavbar">
            <ul class="nav navbar-nav">
                <li class="active"><a href="#">Home</a></li>
                <li><a href="#">About</a></li>
                <li><a href="#">Projects</a></li>
                <li><a href="#">Contact</a></li>
            </ul>
        </div>
    </div>
</nav>


问:
RPG timestamp validation, is this best practice?
For RPG timestamp validation, is this best practice?  It seem that there should be a way to test using TEST opcode?</p>

```<code>d DateTimeST      S               Z
d Value           S             26A
d*---------------------------------------------------------------------------
c                   Eval      Value = '2017-11-16-09.54.40.840586'
c                   Eval      DateTimeST = %timestamp(Value)
c                   If        %Error
c                   EXSR      DoSometing
c                   ENDIF
c*-------------------------------------------------------------------
c     DoSometing    BEGSR
c                   ENDSR
c*-------------------------------------------------------------------
c                   Eval         *inlr = *on
c                   return
</code>```

答:
Mustapha,

You can test a timestamp using the TEST(ZE) opcode. The Z extender specifies you're testing a timestamp and the E extender sets the %Error on if the test fails.

As Mike mentioned, you can also wrap it in a monitor group and use the On-Error opcode to run your subroutine.

Sample code for both methods is below.

```<code> d DateTimeST      S               Z
 d Value           S             26A
 d*---------------------------------------------------------------------------
 c                   Eval      Value = '2017-11-16-09.54.40.840586'
 c
 c* Method #1 - use monitor group
 c                   Monitor
 c                   Eval      DateTimeST = %timestamp(Value:*ISO)
 c                   On-Error
 c                   EXSR      DoSometing
 c                   Endmon
 c
 c* Method #2 - use Test(ZE)
 c     *ISO          Test(ZE)                Value
 c                   If        %Error
 c                   EXSR      DoSometing
 c                   Else
 c                   Eval      DateTimeST = %timestamp(Value:*ISO)
 c                   Endif
 c
 c                   Eval         *inlr = *on
 c                   return
 c*-------------------------------------------------------------------
 c     DoSometing    BEGSR
 c                   ENDSR
 c*-------------------------------------------------------------------
</code>```

Body:
For RPG timestamp validation, is this best practice?  It seem that there should be a way to test using TEST opcode?

d DateTimeST      S               Z
d Value           S             26A
d*---------------------------------------------------------------------------
c                   Eval      Value = '2017-11-16-09.54.40.840586'
c                   Eval      DateTimeST = %timestamp(Value)
c                   If        %Error
c                   EXSR      DoSometing
c                   ENDIF
c*-------------------------------------------------------------------
c     DoSometing    BEGSR
c                   ENDSR
c*-------------------------------------------------------------------
c                   Eval         *inlr = *on
c                   return

Body:
Mustapha,

You can test a timestamp using the TEST(ZE) opcode. The Z extender specifies you're testing a timestamp and the E extender sets the %Error on if the test fails.

As Mike mentioned, you can also wrap it in a monitor group and use the On-Error opcode to run your subroutine.

Sample code for both methods is below.

 d DateTimeST      S               Z
 d Value           S             26A
 d*---------------------------------------------------------------------------
 c                   Eval      Value = '2017-11-16-09.54.40.840586'
 c
 c* Method #1 - use monitor group
 c                   Monitor
 c                   Eval      DateTimeST = %timestamp(Value:*ISO)
 c                   On-Error
 c                   EXSR      DoSometing
 c                   Endmon
 c
 c* Method #2 - use Test(ZE)
 c     *ISO          Test(ZE)                Value
 c                   If        %Error
 c                   EXSR      DoSometing
 c                   Else
 c                   Eval      DateTimeST = %timestamp(Value:*ISO)
 c                   Endif
 c
 c                   Eval         *inlr = *on
 c                   return
 c*-------------------------------------------------------------------
 c     DoSometing    BEGSR
 c                   ENDSR
 c*-------------------------------------------------------------------


答:
I think this could be done using some of your algorithm, except at the ProjectNo granularity:

```<code>SELECT ProjectNo
      ,SUM(ChargedHours*PayPerHour) [TotalPayPerProject]
FROM ProjectDetails
GROUP BY ProjectNo
</code>```

This gives output:

```<code>ProjectNo   TotalPayPerProject
100         13475
101         5250
103         2406.25
</code>```

This is different from your expected output, for some reason.

Here's a SQL fiddle: http://sqlfiddle.com/#!6/21a33/2/0

Title: Query for computing a column using other computed columns

Body:
Table: Project Details

+-----+------------------+------------+--------------+------------+
| GPN | EmployeePosition | Project.No | ChargedHours | PayPerHour |
+-----+------------------+------------+--------------+------------+
|   2 | B                |        101 |           50 |         57 |
|   3 | C                |        100 |           75 |         44 |
|   4 | D                |        100 |          100 |      24.75 |
|   5 | E                |        103 |          125 |      19.25 |
|   6 | F                |        101 |          150 |         16 |
|   7 | C                |        100 |          175 |         44 |
+-----+------------------+------------+--------------+------------+

I need to find out total pay of each Project. So first I have to find out Total pay per employee and group it by Project.No.

The table below shows the Total pay per Employee which is created using other 2 existing columns

+-----+-------------+---------+------------+----------+----------------+
| GPN | EmpPosition | Proj.No | ChargedHrs | PayPerHr | TotalPayPerEmp |
+-----+-------------+---------+------------+----------+----------------+
|   2 | B           |     101 |         50 |       57 |         993.75 |
|   3 | C           |     100 |         75 |       44 |           2850 |
|   4 | D           |     100 |        100 |    24.75 |           3300 |
|   5 | E           |     103 |        125 |    19.25 |        2406.25 |
|   6 | F           |     101 |        150 |       16 |           2400 |
|   7 | C           |     100 |        175 |       44 |           7700 |
+-----+-------------+---------+------------+----------+----------------+

My Query:

 Select EngNumber, SUM([CharHrs])[SumOfChargedHours], Levell, CostPH,
SUM([CharHrs])*CostPH [TotalPayPerEmployee]
FROM data1.dbo.PayedPerHour
GROUP BY EngNumber, Levell, TotalPayPerEmployee, CostPH
ORDER BY EngNumber;

Update data1.dbo.PayedPerHour
SET CostPH = CASE Levell
                      WHEN 'Associate Director' THEN '79.75'
                      WHEN 'Senior Manager' THEN '57'
                      WHEN 'Manager' THEN '44'
                      WHEN 'Senior' THEN '24.75'
                      WHEN 'Staff 2, 3 & 4' THEN '19.25'
                      WHEN 'Staff 1' THEN '16'
                      ELSE 'NULL'
                      END
 WHERE Levell IN('Associate Director', 'Senior Manager','Manager', 'Senior',
'Staff 2, 3 & 4', 'Staff 1');

I want to group the TotalPayPerEmp by Proj.No but i cant accomplish it.
I would have made silly mistakes in the query since I'm very new to sql so please regret them

Expected table:

+---------+--------------------+
| Proj.No | TotalPayPerProject |
+---------+--------------------+
|     100 |           14093.75 |
|     101 |               5250 |
|     103 |            4881.25 |
+---------+--------------------+

Body:
I think this could be done using some of your algorithm, except at the ProjectNo granularity:

SELECT ProjectNo
      ,SUM(ChargedHours*PayPerHour) [TotalPayPerProject]
FROM ProjectDetails
GROUP BY ProjectNo

This gives output:

ProjectNo   TotalPayPerProject
100         13475
101         5250
103         2406.25

This is different from your expected output, for some reason.

Here's a SQL fiddle: http://sqlfiddle.com/#!6/21a33/2/0


问:
Ionic 2 Error while trying to add platform
My ionic 2 project is running properly when I am doing ionic serve --lab but I am getting the error while I am trying to add Platform in my Ionic 2 Project.

Error While Trying to add iOS

```<code>sudipta$ ionic cordova platform add ios
cordova platform add ios --save

You have been opted out of telemetry. To change this, run: cordova telemetry on.
Using cordova-fetch for cordova-ios@^4.4.0

Error: Failed to fetch platform cordova-ios@^4.4.0
Probably this is either a connection problem, or platform spec is incorrect.
Check your connection and platform name/version/URL.
Error: npm: Command failed with exit code 1 Error output:
npm ERR! Darwin 17.2.0
npm ERR! argv "/usr/local/bin/node" "/Users/sudipta/musicapp/node_modules/.bin/npm" "install" "cordova-ios@^4.4.0" "--production" "--save-exact"
npm ERR! node v6.10.3
npm ERR! npm  v2.15.12
npm ERR! code EPEERINVALID

npm ERR! peerinvalid The package @ionic-native/core@3.10.2 does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer @ionic-native/device@3.14.0 wants @ionic-native/core@^3.6.0
npm ERR! peerinvalid Peer @ionic-native/email-composer@4.4.0 wants @ionic-native/core@^4.2.0
npm ERR! peerinvalid Peer @ionic-native/facebook@3.14.0 wants @ionic-native/core@^3.6.0
npm ERR! peerinvalid Peer @ionic-native/file@3.14.0 wants @ionic-native/core@^3.6.0
npm ERR! peerinvalid Peer @ionic-native/media@3.14.0 wants @ionic-native/core@^3.6.0
npm ERR! peerinvalid Peer @ionic-native/native-audio@3.14.0 wants @ionic-native/core@^3.6.0
npm ERR! peerinvalid Peer @ionic-native/splash-screen@3.10.2 wants @ionic-native/core@^3.6.0
npm ERR! peerinvalid Peer @ionic-native/status-bar@3.10.2 wants @ionic-native/core@^3.6.0
npm ERR! peerinvalid Peer @ionic-native/toast@3.14.0 wants @ionic-native/core@^3.6.0
npm ERR! peerinvalid Peer @ionic-native/transfer@3.14.0 wants @ionic-native/core@^3.6.0

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/sudipta/musicapp/npm-debug.log

[ERROR] Exception:
sudipta$
</code>```

Error while trying to add Android

```<code>sudipta$ ionic cordova platform add android
> cordova platform add android --save
Using cordova-fetch for cordova-android@6.2.3

Error: Failed to fetch platform cordova-android@6.2.3
Probably this is either a connection problem, or platform spec is incorrect.
Check your connection and platform name/version/URL.
Error: npm: Command failed with exit code 1 Error output:
npm ERR! Darwin 17.2.0
npm ERR! argv "/usr/local/bin/node" "/Users/sudipta/musicapp/node_modules/.bin/npm" "install" "cordova-android@6.2.3" "--production" "--save-exact"
npm ERR! node v6.10.3
npm ERR! npm  v2.15.12
npm ERR! code EPEERINVALID

npm ERR! peerinvalid The package @ionic-native/core@3.10.2 does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer @ionic-native/device@3.14.0 wants @ionic-native/core@^3.6.0
npm ERR! peerinvalid Peer @ionic-native/email-composer@4.4.0 wants @ionic-native/core@^4.2.0
npm ERR! peerinvalid Peer @ionic-native/facebook@3.14.0 wants @ionic-native/core@^3.6.0
npm ERR! peerinvalid Peer @ionic-native/file@3.14.0 wants @ionic-native/core@^3.6.0
npm ERR! peerinvalid Peer @ionic-native/media@3.14.0 wants @ionic-native/core@^3.6.0
npm ERR! peerinvalid Peer @ionic-native/native-audio@3.14.0 wants @ionic-native/core@^3.6.0
npm ERR! peerinvalid Peer @ionic-native/splash-screen@3.10.2 wants @ionic-native/core@^3.6.0
npm ERR! peerinvalid Peer @ionic-native/status-bar@3.10.2 wants @ionic-native/core@^3.6.0
npm ERR! peerinvalid Peer @ionic-native/toast@3.14.0 wants @ionic-native/core@^3.6.0
npm ERR! peerinvalid Peer @ionic-native/transfer@3.14.0 wants @ionic-native/core@^3.6.0

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/sudipta/musicapp/npm-debug.log

[ERROR] Exception:
sudipta$
</code>```

Error While Trying to browser

```<code>sudipta$ ionic cordova platform add browser
> cordova platform add browser --save
Using cordova-fetch for cordova-browser@^4.1.0

Error: Failed to fetch platform cordova-browser@^4.1.0
Probably this is either a connection problem, or platform spec is incorrect.
Check your connection and platform name/version/URL.
Error: npm: Command failed with exit code 1 Error output:
npm ERR! Darwin 17.2.0
npm ERR! argv "/usr/local/bin/node" "/Users/sudipta/musicapp/node_modules/.bin/npm" "install" "cordova-browser@^4.1.0" "--production" "--save-exact"
npm ERR! node v6.10.3
npm ERR! npm  v2.15.12
npm ERR! code EPEERINVALID

npm ERR! peerinvalid The package @ionic-native/core@3.10.2 does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer @ionic-native/device@3.14.0 wants @ionic-native/core@^3.6.0
npm ERR! peerinvalid Peer @ionic-native/email-composer@4.4.0 wants @ionic-native/core@^4.2.0
npm ERR! peerinvalid Peer @ionic-native/facebook@3.14.0 wants @ionic-native/core@^3.6.0
npm ERR! peerinvalid Peer @ionic-native/file@3.14.0 wants @ionic-native/core@^3.6.0
npm ERR! peerinvalid Peer @ionic-native/media@3.14.0 wants @ionic-native/core@^3.6.0
npm ERR! peerinvalid Peer @ionic-native/native-audio@3.14.0 wants @ionic-native/core@^3.6.0
npm ERR! peerinvalid Peer @ionic-native/splash-screen@3.10.2 wants @ionic-native/core@^3.6.0
npm ERR! peerinvalid Peer @ionic-native/status-bar@3.10.2 wants @ionic-native/core@^3.6.0
npm ERR! peerinvalid Peer @ionic-native/toast@3.14.0 wants @ionic-native/core@^3.6.0
npm ERR! peerinvalid Peer @ionic-native/transfer@3.14.0 wants @ionic-native/core@^3.6.0

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/sudipta/musicapp/npm-debug.log

[ERROR] Exception:
sudipta$
</code>```

I am using following versions

```<code>sudipta$ ionic -version
3.18.0
sudipta$ node -v
v6.10.3
sudipta$ npm -v
5.5.1
sudipta$ cordova -version
7.1.0
sudipta$
</code>```

my package.json (Updated)

```<code>{
"name": "xxxxxxxxxxx",
"version": "1.0.0",
"author": "Ionic Framework",
"homepage": "http://ionicframework.com/",
"private": true,
"scripts": {
    "clean": "ionic-app-scripts clean",
    "build": "ionic-app-scripts build",
    "lint": "ionic-app-scripts lint",
    "ionic:build": "ionic-app-scripts build",
    "ionic:serve": "ionic-app-scripts serve"
},
"dependencies": {
    "@angular/common": "^5.0.2",
    "@angular/compiler": "^5.0.2",
    "@angular/compiler-cli": "^5.0.2",
    "@angular/core": "^5.0.2",
    "@angular/forms": "^5.0.2",
    "@angular/http": "^5.0.2",
    "@angular/platform-browser": "^5.0.2",
    "@angular/platform-browser-dynamic": "^5.0.2",
    "@angular/tsc-wrapped": "^4.4.6",
    "@ionic-native/core": "^4.4.2",
    "@ionic-native/device": "^4.4.2",
    "@ionic-native/email-composer": "^4.4.2",
    "@ionic-native/facebook": "^4.4.2",
    "@ionic-native/file": "^4.4.2",
    "@ionic-native/media": "^4.4.2",
    "@ionic-native/native-audio": "^4.4.2",
    "@ionic-native/splash-screen": "^4.4.2",
    "@ionic-native/status-bar": "^4.4.2",
    "@ionic-native/toast": "^4.4.2",
    "@ionic-native/transfer": "^3.12.1",
    "@ionic/cloud-angular": "^0.12.0",
    "@ionic/pro": "^1.0.16",
    "@ionic/storage": "^2.1.3",
    "angularfire2": "^5.0.0-rc.3",
    "cordova": "^7.0.1",
    "cordova-android": "^6.4.0",
    "cordova-browser": "^5.0.1",
    "cordova-fabric-plugin": "git+https://github.com/sarriaroman/FabricPlugin.git",
    "cordova-ios": "^4.4.0",
    "cordova-plugin-add-swift-support": "^1.7.0",
    "cordova-plugin-compat": "^1.1.0",
    "cordova-plugin-device": "^1.1.7",
    "cordova-plugin-email-composer": "^0.8.7",
    "cordova-plugin-facebook4": "^1.9.1",
    "cordova-plugin-file": "^5.0.0",
    "cordova-plugin-file-transfer": "^1.7.0",
    "cordova-plugin-ionic": "^2.0.3",
    "cordova-plugin-media": "^4.0.0",
    "cordova-plugin-nativeaudio": "^3.0.9",
    "cordova-plugin-splashscreen": "^4.1.0",
    "cordova-plugin-statusbar": "^2.3.0",
    "cordova-plugin-whitelist": "^1.3.3",
    "cordova-plugin-x-toast": "^2.6.0",
    "emulator": "^0.1.0",
    "firebase": "^4.5.0",
    "ionic-angular": "^3.9.2",
    "ionic-plugin-deploy": "^0.6.7",
    "ionic-plugin-keyboard": "^2.2.1",
    "ionicons": "3.0.0",
    "phonegap-plugin-push": "^2.1.0",
    "promise-polyfill": "^6.0.2",
    "react-native": "^0.50.3",
    "rxjs": "^5.5.2",
    "superagent": "^3.8.0",
    "sw-toolbox": "3.6.0",
    "zone.js": "^0.8.18"
},
"devDependencies": {
    "@ionic/app-scripts": "^3.1.2",
    "ionic": "3.18.0",
    "typescript": "^2.6.1"
},
"description": "An Ionic project",
"cordova": {
    "plugins": {
        "cordova-plugin-x-toast": {},
        "cordova-plugin-file-transfer": {},
        "cordova-plugin-file": {},
        "cordova-plugin-console": {},
        "cordova-plugin-device": {},
        "cordova-plugin-splashscreen": {},
        "cordova-plugin-statusbar": {},
        "cordova-plugin-whitelist": {},
        "ionic-plugin-keyboard": {},
        "cordova-plugin-nativeaudio": {},
        "cordova-plugin-facebook4": {
            "APP_ID": "xxxxxxxxxxx",
            "APP_NAME": "MusicApp"
        },
        "cordova-plugin-media": {
            "MICROPHONE_USAGE_DESCRIPTION": " "
        },
        "ionic-plugin-deploy": {},
        "cordova-fabric-plugin": {
            "FABRIC_API_KEY": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
            "FABRIC_API_SECRET": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
        },
        "cordova-plugin-email-composer": {},
        "cordova-plugin-ionic": {
            "APP_ID": "xxxxxxxxxxx",
            "CHANNEL_NAME": "Master",
            "UPDATE_METHOD": "auto",
            "UPDATE_API": "https://api.ionicjs.com",
            "MAX_STORE": "2"
        }
    },
    "platforms": [
        "android",
        "browser",
        "ios"
    ]
}
}
</code>```

Output of ionic info

```<code>sudipta$ ionic info

cli packages: (/Users/sudipta/musicapp/node_modules)

    @ionic/cli-utils  : 1.18.0
    ionic (Ionic CLI) : 3.18.0

global packages:

    cordova (Cordova CLI) : 7.1.0

local packages:

    @ionic/app-scripts : 3.1.2
    Cordova Platforms  : none
    Ionic Framework    : ionic-angular 3.9.2

System:

    Node  : v6.10.3
    npm   : 5.5.1
    OS    : macOS High Sierra
    Xcode : Xcode 8.3.1 Build version 8E1000a

Environment Variables:

    ANDROID_HOME : not set

Misc:

    backend : pro

sudipta$
</code>```

So, I am not able to build the app.
Thanks in advance for your help.

答:
Would you give a try to reinstall cleanly your libs?

```<code>rm package-lock.json
rm -r node_modules
npm install
</code>```

You've got all native libs set to 4.4.2 in your package.json but 3.14.0 and 3.10.2 seems to be use when you add your platform

P.S.: Except one lib, respectively @ionic-native/transfer which is set to 3.12.1 in your package.json, maybe set it to 4.4.2 like the others too

Body:
My ionic 2 project is running properly when I am doing ionic serve --lab but I am getting the error while I am trying to add Platform in my Ionic 2 Project.

Error While Trying to add iOS

sudipta$ ionic cordova platform add ios
cordova platform add ios --save

You have been opted out of telemetry. To change this, run: cordova telemetry on.
Using cordova-fetch for cordova-ios@^4.4.0

Error: Failed to fetch platform cordova-ios@^4.4.0
Probably this is either a connection problem, or platform spec is incorrect.
Check your connection and platform name/version/URL.
Error: npm: Command failed with exit code 1 Error output:
npm ERR! Darwin 17.2.0
npm ERR! argv "/usr/local/bin/node" "/Users/sudipta/musicapp/node_modules/.bin/npm" "install" "cordova-ios@^4.4.0" "--production" "--save-exact"
npm ERR! node v6.10.3
npm ERR! npm  v2.15.12
npm ERR! code EPEERINVALID

npm ERR! peerinvalid The package @ionic-native/core@3.10.2 does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer @ionic-native/device@3.14.0 wants @ionic-native/core@^3.6.0
npm ERR! peerinvalid Peer @ionic-native/email-composer@4.4.0 wants @ionic-native/core@^4.2.0
npm ERR! peerinvalid Peer @ionic-native/facebook@3.14.0 wants @ionic-native/core@^3.6.0
npm ERR! peerinvalid Peer @ionic-native/file@3.14.0 wants @ionic-native/core@^3.6.0
npm ERR! peerinvalid Peer @ionic-native/media@3.14.0 wants @ionic-native/core@^3.6.0
npm ERR! peerinvalid Peer @ionic-native/native-audio@3.14.0 wants @ionic-native/core@^3.6.0
npm ERR! peerinvalid Peer @ionic-native/splash-screen@3.10.2 wants @ionic-native/core@^3.6.0
npm ERR! peerinvalid Peer @ionic-native/status-bar@3.10.2 wants @ionic-native/core@^3.6.0
npm ERR! peerinvalid Peer @ionic-native/toast@3.14.0 wants @ionic-native/core@^3.6.0
npm ERR! peerinvalid Peer @ionic-native/transfer@3.14.0 wants @ionic-native/core@^3.6.0

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/sudipta/musicapp/npm-debug.log

[ERROR] Exception:
sudipta$

Error while trying to add Android

sudipta$ ionic cordova platform add android
> cordova platform add android --save
Using cordova-fetch for cordova-android@6.2.3

Error: Failed to fetch platform cordova-android@6.2.3
Probably this is either a connection problem, or platform spec is incorrect.
Check your connection and platform name/version/URL.
Error: npm: Command failed with exit code 1 Error output:
npm ERR! Darwin 17.2.0
npm ERR! argv "/usr/local/bin/node" "/Users/sudipta/musicapp/node_modules/.bin/npm" "install" "cordova-android@6.2.3" "--production" "--save-exact"
npm ERR! node v6.10.3
npm ERR! npm  v2.15.12
npm ERR! code EPEERINVALID

npm ERR! peerinvalid The package @ionic-native/core@3.10.2 does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer @ionic-native/device@3.14.0 wants @ionic-native/core@^3.6.0
npm ERR! peerinvalid Peer @ionic-native/email-composer@4.4.0 wants @ionic-native/core@^4.2.0
npm ERR! peerinvalid Peer @ionic-native/facebook@3.14.0 wants @ionic-native/core@^3.6.0
npm ERR! peerinvalid Peer @ionic-native/file@3.14.0 wants @ionic-native/core@^3.6.0
npm ERR! peerinvalid Peer @ionic-native/media@3.14.0 wants @ionic-native/core@^3.6.0
npm ERR! peerinvalid Peer @ionic-native/native-audio@3.14.0 wants @ionic-native/core@^3.6.0
npm ERR! peerinvalid Peer @ionic-native/splash-screen@3.10.2 wants @ionic-native/core@^3.6.0
npm ERR! peerinvalid Peer @ionic-native/status-bar@3.10.2 wants @ionic-native/core@^3.6.0
npm ERR! peerinvalid Peer @ionic-native/toast@3.14.0 wants @ionic-native/core@^3.6.0
npm ERR! peerinvalid Peer @ionic-native/transfer@3.14.0 wants @ionic-native/core@^3.6.0

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/sudipta/musicapp/npm-debug.log

[ERROR] Exception:
sudipta$

Error While Trying to browser

sudipta$ ionic cordova platform add browser
> cordova platform add browser --save
Using cordova-fetch for cordova-browser@^4.1.0

Error: Failed to fetch platform cordova-browser@^4.1.0
Probably this is either a connection problem, or platform spec is incorrect.
Check your connection and platform name/version/URL.
Error: npm: Command failed with exit code 1 Error output:
npm ERR! Darwin 17.2.0
npm ERR! argv "/usr/local/bin/node" "/Users/sudipta/musicapp/node_modules/.bin/npm" "install" "cordova-browser@^4.1.0" "--production" "--save-exact"
npm ERR! node v6.10.3
npm ERR! npm  v2.15.12
npm ERR! code EPEERINVALID

npm ERR! peerinvalid The package @ionic-native/core@3.10.2 does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer @ionic-native/device@3.14.0 wants @ionic-native/core@^3.6.0
npm ERR! peerinvalid Peer @ionic-native/email-composer@4.4.0 wants @ionic-native/core@^4.2.0
npm ERR! peerinvalid Peer @ionic-native/facebook@3.14.0 wants @ionic-native/core@^3.6.0
npm ERR! peerinvalid Peer @ionic-native/file@3.14.0 wants @ionic-native/core@^3.6.0
npm ERR! peerinvalid Peer @ionic-native/media@3.14.0 wants @ionic-native/core@^3.6.0
npm ERR! peerinvalid Peer @ionic-native/native-audio@3.14.0 wants @ionic-native/core@^3.6.0
npm ERR! peerinvalid Peer @ionic-native/splash-screen@3.10.2 wants @ionic-native/core@^3.6.0
npm ERR! peerinvalid Peer @ionic-native/status-bar@3.10.2 wants @ionic-native/core@^3.6.0
npm ERR! peerinvalid Peer @ionic-native/toast@3.14.0 wants @ionic-native/core@^3.6.0
npm ERR! peerinvalid Peer @ionic-native/transfer@3.14.0 wants @ionic-native/core@^3.6.0

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/sudipta/musicapp/npm-debug.log

[ERROR] Exception:
sudipta$

I am using following versions

sudipta$ ionic -version
3.18.0
sudipta$ node -v
v6.10.3
sudipta$ npm -v
5.5.1
sudipta$ cordova -version
7.1.0
sudipta$

my package.json (Updated)

{
"name": "xxxxxxxxxxx",
"version": "1.0.0",
"author": "Ionic Framework",
"homepage": "http://ionicframework.com/",
"private": true,
"scripts": {
    "clean": "ionic-app-scripts clean",
    "build": "ionic-app-scripts build",
    "lint": "ionic-app-scripts lint",
    "ionic:build": "ionic-app-scripts build",
    "ionic:serve": "ionic-app-scripts serve"
},
"dependencies": {
    "@angular/common": "^5.0.2",
    "@angular/compiler": "^5.0.2",
    "@angular/compiler-cli": "^5.0.2",
    "@angular/core": "^5.0.2",
    "@angular/forms": "^5.0.2",
    "@angular/http": "^5.0.2",
    "@angular/platform-browser": "^5.0.2",
    "@angular/platform-browser-dynamic": "^5.0.2",
    "@angular/tsc-wrapped": "^4.4.6",
    "@ionic-native/core": "^4.4.2",
    "@ionic-native/device": "^4.4.2",
    "@ionic-native/email-composer": "^4.4.2",
    "@ionic-native/facebook": "^4.4.2",
    "@ionic-native/file": "^4.4.2",
    "@ionic-native/media": "^4.4.2",
    "@ionic-native/native-audio": "^4.4.2",
    "@ionic-native/splash-screen": "^4.4.2",
    "@ionic-native/status-bar": "^4.4.2",
    "@ionic-native/toast": "^4.4.2",
    "@ionic-native/transfer": "^3.12.1",
    "@ionic/cloud-angular": "^0.12.0",
    "@ionic/pro": "^1.0.16",
    "@ionic/storage": "^2.1.3",
    "angularfire2": "^5.0.0-rc.3",
    "cordova": "^7.0.1",
    "cordova-android": "^6.4.0",
    "cordova-browser": "^5.0.1",
    "cordova-fabric-plugin": "git+https://github.com/sarriaroman/FabricPlugin.git",
    "cordova-ios": "^4.4.0",
    "cordova-plugin-add-swift-support": "^1.7.0",
    "cordova-plugin-compat": "^1.1.0",
    "cordova-plugin-device": "^1.1.7",
    "cordova-plugin-email-composer": "^0.8.7",
    "cordova-plugin-facebook4": "^1.9.1",
    "cordova-plugin-file": "^5.0.0",
    "cordova-plugin-file-transfer": "^1.7.0",
    "cordova-plugin-ionic": "^2.0.3",
    "cordova-plugin-media": "^4.0.0",
    "cordova-plugin-nativeaudio": "^3.0.9",
    "cordova-plugin-splashscreen": "^4.1.0",
    "cordova-plugin-statusbar": "^2.3.0",
    "cordova-plugin-whitelist": "^1.3.3",
    "cordova-plugin-x-toast": "^2.6.0",
    "emulator": "^0.1.0",
    "firebase": "^4.5.0",
    "ionic-angular": "^3.9.2",
    "ionic-plugin-deploy": "^0.6.7",
    "ionic-plugin-keyboard": "^2.2.1",
    "ionicons": "3.0.0",
    "phonegap-plugin-push": "^2.1.0",
    "promise-polyfill": "^6.0.2",
    "react-native": "^0.50.3",
    "rxjs": "^5.5.2",
    "superagent": "^3.8.0",
    "sw-toolbox": "3.6.0",
    "zone.js": "^0.8.18"
},
"devDependencies": {
    "@ionic/app-scripts": "^3.1.2",
    "ionic": "3.18.0",
    "typescript": "^2.6.1"
},
"description": "An Ionic project",
"cordova": {
    "plugins": {
        "cordova-plugin-x-toast": {},
        "cordova-plugin-file-transfer": {},
        "cordova-plugin-file": {},
        "cordova-plugin-console": {},
        "cordova-plugin-device": {},
        "cordova-plugin-splashscreen": {},
        "cordova-plugin-statusbar": {},
        "cordova-plugin-whitelist": {},
        "ionic-plugin-keyboard": {},
        "cordova-plugin-nativeaudio": {},
        "cordova-plugin-facebook4": {
            "APP_ID": "xxxxxxxxxxx",
            "APP_NAME": "MusicApp"
        },
        "cordova-plugin-media": {
            "MICROPHONE_USAGE_DESCRIPTION": " "
        },
        "ionic-plugin-deploy": {},
        "cordova-fabric-plugin": {
            "FABRIC_API_KEY": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
            "FABRIC_API_SECRET": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
        },
        "cordova-plugin-email-composer": {},
        "cordova-plugin-ionic": {
            "APP_ID": "xxxxxxxxxxx",
            "CHANNEL_NAME": "Master",
            "UPDATE_METHOD": "auto",
            "UPDATE_API": "https://api.ionicjs.com",
            "MAX_STORE": "2"
        }
    },
    "platforms": [
        "android",
        "browser",
        "ios"
    ]
}
}

Output of ionic info

sudipta$ ionic info

cli packages: (/Users/sudipta/musicapp/node_modules)

    @ionic/cli-utils  : 1.18.0
    ionic (Ionic CLI) : 3.18.0

global packages:

    cordova (Cordova CLI) : 7.1.0

local packages:

    @ionic/app-scripts : 3.1.2
    Cordova Platforms  : none
    Ionic Framework    : ionic-angular 3.9.2

System:

    Node  : v6.10.3
    npm   : 5.5.1
    OS    : macOS High Sierra
    Xcode : Xcode 8.3.1 Build version 8E1000a

Environment Variables:

    ANDROID_HOME : not set

Misc:

    backend : pro

sudipta$

So, I am not able to build the app.
Thanks in advance for your help.

Body:
Would you give a try to reinstall cleanly your libs?

rm package-lock.json
rm -r node_modules
npm install

You've got all native libs set to 4.4.2 in your package.json but 3.14.0 and 3.10.2 seems to be use when you add your platform

P.S.: Except one lib, respectively @ionic-native/transfer which is set to 3.12.1 in your package.json, maybe set it to 4.4.2 like the others too