问:
How to validate date in laravel
In validate method I have following :

```<code>$this->validate($request, ['test_date' => 'required|unique:test_db']);
</code>```

The test_date in test_db is stored as unix time.
On submission of form, I get $request->get('test_date') in mm/dd/Y

The unique validation does not work because I get date in mm/dd/Y which is different from db (unix time).

How to make it unique in this validation?

答:
You can try this:

```<code>//get date from request
$date = $request->get('test_date');

//add the converted date to request
$request->request->add(['new_date_field'=> DateTime::createFromFormat('m/d/Y', $date)->getTimestamp()]);

//validate the updated date field
$this->validate($request, ['new_date_field' => 'required|unique:test_db']);
</code>```

Adding fields to the request : Laravel is there a way to add values to a request array

UPDATE :
You can update existing field using offsetSet method:

```<code>    //get date from request
    $date = $request->get('test_date');

    //update date in request
    $request->offsetSet('test_date', DateTime::createFromFormat('m/d/Y', $date)->getTimestamp());

    //validate the updated date field
    $this->validate($request, ['test_date' => 'required|unique:test_db']);
</code>```

Updating request fields :
Modify request field value before saving in Laravel 5

Title: How to validate date in laravel

Body:
In validate method I have following :

$this->validate($request, ['test_date' => 'required|unique:test_db']);

The test_date in test_db is stored as unix time.
On submission of form, I get $request->get('test_date') in mm/dd/Y

The unique validation does not work because I get date in mm/dd/Y which is different from db (unix time).

How to make it unique in this validation?

Body:
You can try this:

//get date from request
$date = $request->get('test_date');

//add the converted date to request
$request->request->add(['new_date_field'=> DateTime::createFromFormat('m/d/Y', $date)->getTimestamp()]);

//validate the updated date field
$this->validate($request, ['new_date_field' => 'required|unique:test_db']);

Adding fields to the request : Laravel is there a way to add values to a request array

UPDATE :
You can update existing field using offsetSet method:

    //get date from request
    $date = $request->get('test_date');

    //update date in request
    $request->offsetSet('test_date', DateTime::createFromFormat('m/d/Y', $date)->getTimestamp());

    //validate the updated date field
    $this->validate($request, ['test_date' => 'required|unique:test_db']);

Updating request fields :
Modify request field value before saving in Laravel 5


来源: stackexchange

问:
ionic 3 App unable to display data fetch from firebase database
I am novice in ionic and angular and creating login/profile module in my society management website.I wanted to display logged in user data on profile page.I have fetch the data and I have used ngModel to display the data which is retrieved from firebase database.But it is not displaying, instead, I can get my data in console window.And also i wanted to edit the profile data.So input field will become editable after i have click on edit button,before it will remain read only.

My Question is about how to display that data on profile page which is retrieved by the database? can anybody tell me how to display the data?

Profile.html

```<code> <form [formGroup]="authForm" (ngSubmit)="onSubmit(authForm.value)">
    <ion-item [ngClass]="{'error-border':!authForm.controls.username.valid && authForm.controls.username.touched}">
        <ion-label floating>Username</ion-label>
        <ion-input formControlName="username" type="text" [(ngModel)]="username"></ion-input>
    </ion-item>
    <ion-item *ngIf="authForm.controls.username.hasError('required') && authForm.controls.username.touched">
        <p>Sorry, field username is required!</p>
    </ion-item>
    <ion-item [ngClass]="{'error-border':!authForm.controls.flatno.valid && authForm.controls.flatno.touched}">
        <ion-label floating>Flat No</ion-label>
        <ion-input formControlName="flatno" type="text" [(ngModel)]="flatno"></ion-input>
    </ion-item>
    <ion-item *ngIf="authForm.controls.flatno.hasError('required') && authForm.controls.flatno.touched">
        <p>Sorry, field is required!</p>
    </ion-item>

    <ion-item [ngClass]="{'error-border':!authForm.controls.email.valid && authForm.controls.email.touched}">
        <ion-label floating>Email</ion-label>
        <ion-input formControlName="email" type="text" [(ngModel)]="email"></ion-input>
    </ion-item>
    <ion-item [ngClass]="{'error-border':!authForm.controls.password.valid && authForm.controls.password.touched}">
        <ion-label floating>Password</ion-label>
        <ion-input formControlName="password" type="password" [(ngModel)]="password"></ion-input>
    </ion-item>
    <ion-item [ngClass]="{'error-border':!authForm.controls.family.valid && authForm.controls.family.touched}">
        <ion-label floating>Total Family Member</ion-label>
        <ion-input formControlName="family" type="text" [(ngModel)]="family"></ion-input>
    </ion-item>
    <ion-item [ngClass]="{'error-border':!authForm.controls.vehicles.valid && authForm.controls.vehicles.touched}">
        <ion-label floating>Total Vehicles</ion-label>
        <ion-input formControlName="vehicles" type="text" [(ngModel)]="vehicles"></ion-input>
    </ion-item>
    <button ion-button full color="button"  style="margin-top: 20px;" type="submit">Save</button>
</form>
</code>```

profile.ts

```<code>  ref.on('value', this.gotData,this.errData);
  gotData(data){
   console.log('data');

   var users = data.val();
   var keys = Object.keys(users);

  for(i=0; i < keys.length;i++){

     var k = keys[i];
     var sessionUser =sessionStorage.getItem("Sessioneml");

    if(users[k].email == sessionUser){
        console.log('true');
        var email = users[k].email;
        var Id = users[k].ID;
        var username = users[k].username;
        var flatno = users[k].flatno;
        var family = users[k].familyMember;
        var vehicles= users[k].parking_slot;

        console.log('user data ='+Id, username,flatno,family,vehicles);
    }
  }
}
</code>```

答:
You need to declare global variable for that. Please have a look at this.

```<code>    export class YOUR_PAGE_NAME{

      email: string = "";
      Id: string = "";
      username: string = "";
      flatno: string = "";
      family: string = "";
      vehicles: string = "";

    //Your constructor and other code

        let self = this;
        ref.on('value', function (data) {
        console.log('data');

        var users = data.val();
        var keys = Object.keys(users);

         for (i = 0; i < keys.length; i++) {
           var k = keys[i];
           var sessionUser = sessionStorage.getItem("Sessioneml");
           if (users[k].email == sessionUser) {
            console.log('true');
            self.email = users[k].email;
            self.Id = users[k].ID;
            self.username = users[k].username;
            self.flatno = users[k].flatno;
            self.family = users[k].familyMember;
            self.vehicles = users[k].parking_slot;
           }
         }
        }, function (error) {
              //Error code goes here
        });
}
</code>```

Please let me know if it worked!

ContentLicense: CC BY-SA 3.0

Body:
I am novice in ionic and angular and creating login/profile module in my society management website.I wanted to display logged in user data on profile page.I have fetch the data and I have used ngModel to display the data which is retrieved from firebase database.But it is not displaying, instead, I can get my data in console window.And also i wanted to edit the profile data.So input field will become editable after i have click on edit button,before it will remain read only.

My Question is about how to display that data on profile page which is retrieved by the database? can anybody tell me how to display the data?

Profile.html

 <form [formGroup]="authForm" (ngSubmit)="onSubmit(authForm.value)">
    <ion-item [ngClass]="{'error-border':!authForm.controls.username.valid && authForm.controls.username.touched}">
        <ion-label floating>Username</ion-label>
        <ion-input formControlName="username" type="text" [(ngModel)]="username"></ion-input>
    </ion-item>
    <ion-item *ngIf="authForm.controls.username.hasError('required') && authForm.controls.username.touched">

Sorry, field username is required!

    </ion-item>
    <ion-item [ngClass]="{'error-border':!authForm.controls.flatno.valid && authForm.controls.flatno.touched}">
        <ion-label floating>Flat No</ion-label>
        <ion-input formControlName="flatno" type="text" [(ngModel)]="flatno"></ion-input>
    </ion-item>
    <ion-item *ngIf="authForm.controls.flatno.hasError('required') && authForm.controls.flatno.touched">

Sorry, field is required!

    </ion-item>

    <ion-item [ngClass]="{'error-border':!authForm.controls.email.valid && authForm.controls.email.touched}">
        <ion-label floating>Email</ion-label>
        <ion-input formControlName="email" type="text" [(ngModel)]="email"></ion-input>
    </ion-item>
    <ion-item [ngClass]="{'error-border':!authForm.controls.password.valid && authForm.controls.password.touched}">
        <ion-label floating>Password</ion-label>
        <ion-input formControlName="password" type="password" [(ngModel)]="password"></ion-input>
    </ion-item>
    <ion-item [ngClass]="{'error-border':!authForm.controls.family.valid && authForm.controls.family.touched}">
        <ion-label floating>Total Family Member</ion-label>
        <ion-input formControlName="family" type="text" [(ngModel)]="family"></ion-input>
    </ion-item>
    <ion-item [ngClass]="{'error-border':!authForm.controls.vehicles.valid && authForm.controls.vehicles.touched}">
        <ion-label floating>Total Vehicles</ion-label>
        <ion-input formControlName="vehicles" type="text" [(ngModel)]="vehicles"></ion-input>
    </ion-item>
    <button ion-button full color="button"  style="margin-top: 20px;" type="submit">Save</button>
</form>

profile.ts

  ref.on('value', this.gotData,this.errData);
  gotData(data){
   console.log('data');

   var users = data.val();
   var keys = Object.keys(users);

  for(i=0; i < keys.length;i++){

     var k = keys[i];
     var sessionUser =sessionStorage.getItem("Sessioneml");

    if(users[k].email == sessionUser){
        console.log('true');
        var email = users[k].email;
        var Id = users[k].ID;
        var username = users[k].username;
        var flatno = users[k].flatno;
        var family = users[k].familyMember;
        var vehicles= users[k].parking_slot;

        console.log('user data ='+Id, username,flatno,family,vehicles);
    }
  }
}

Body:
You need to declare global variable for that. Please have a look at this.

    export class YOUR_PAGE_NAME{

      email: string = "";
      Id: string = "";
      username: string = "";
      flatno: string = "";
      family: string = "";
      vehicles: string = "";

    //Your constructor and other code

        let self = this;
        ref.on('value', function (data) {
        console.log('data');

        var users = data.val();
        var keys = Object.keys(users);

         for (i = 0; i < keys.length; i++) {
           var k = keys[i];
           var sessionUser = sessionStorage.getItem("Sessioneml");
           if (users[k].email == sessionUser) {
            console.log('true');
            self.email = users[k].email;
            self.Id = users[k].ID;
            self.username = users[k].username;
            self.flatno = users[k].flatno;
            self.family = users[k].familyMember;
            self.vehicles = users[k].parking_slot;
           }
         }
        }, function (error) {
              //Error code goes here
        });
}

Please let me know if it worked!


问:
SQL Server 2008 - Keyboard Shortcut Key to do SQL Query Formatting
Do you know the Keyboard shortcut key in SQL Server 2008 Management Studio to do SQL Query Formatting?</p>

答:
Their is no shortcut keys in sql server 2008,2010,2014,2015...

The simple way visit http://www.sql-format.com/ and format.


问:
None of the plugins can be loaded in Cordova/PhoneGap Android hybrid mobile app. How to solve?
I have followed the instructions here to the dot. (https://documentation.onesignal.com/v3.0/docs/phonegap-sdk-setup)

My goal is to send Push Notifications from a server (Firebase or OneSignal) to my Android device which I am testing on Chrome browser or PhoneGap test app.

I have added the following code to my onDeviceReady function and it runs;

```<code>console.log("OneSignal is here!");
var notificationOpenedCallback = function(jsonData) {
  console.log('notificationOpenedCallback: ' + JSON.stringify(jsonData));
  alert("Received my notification");
};

// c02be63f-e777-4b99-8775-dec62efxxxxx is my APP ID
window.plugins.OneSignal
  .startInit("c02be63f-e777-4b99-8775-dec62efxxxxx")
  .handleNotificationOpened(notificationOpenedCallback)
  .endInit();

window.plugins.OneSignal.setSubscription (true);

window.plugins.OneSignal.enableNotificationWhenActive(true);
</code>```

However, after running, I get the following errors. Can someone please explain what this error means?

```<code>Error: exec proxy not found for :: StatusBar :: _ready
(index):365 OneSignal is here!
(index):365 Error: exec proxy not found for :: OneSignalPush :: setNotificationReceivedHandler
(index):365 Error: exec proxy not found for :: OneSignalPush :: setNotificationOpenedHandler
(index):365 Error: exec proxy not found for :: OneSignalPush :: init
(index):365 Error: exec proxy not found for :: OneSignalPush :: setSubscription
</code>```

I have noticed the same error for every other new plugin I tried. This means something is wrong.

Here is my config.xml

```<code><?xml version='1.0' encoding='utf-8'?>
<widget id="com.upen.testing" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0">
    <name>Testing</name>
    <description>
        A blank PhoneGap app.
    </description>
    <author email="support@phonegap.com" href="http://phonegap.com">
        PhoneGap Team
    </author>
    <content src="index.html" />
    <access origin="*" />
    <gap:plugin name="onesignal-cordova-plugin" source="npm" spec="^2.2.4" />
    <preference name="phonegap-version" value="cli-7.1.1" />
    <preference name="android-build-tool" value="gradle" />
    <preference name="android-minSdkVersion" value="15" />
    <engine name="browser" spec="~5.0.1" />
    <plugin name="cordova-plugin-whitelist" spec="~1.3.3" />
    <plugin name="onesignal-cordova-plugin" spec="~2.2.4" />
    <plugin name="cordova-plugin-statusbar" spec="~2.3.0" />
    <plugin name="cordova-plugin-fcm" spec="^2.1.2" />
    <engine name="android" spec="~6.3.0" />
</widget>
</code>```

答:
This is the key

which I am testing on Chrome browser or PhoneGap test app.

If you test on Chrome, the Cordova plugins don't work there

If you test on the Phonegap test app, the Phonegap developer app is a Cordova app, and it has been built with some Cordova plugins, but it doesn't include the onesignal plugin, so you can't use the plugin when you test there.

So, what you have to do is to compile and run your app directly in your phone (without Chrome or Phonegap app)

I don't use Phonegap, so I'm not sure about the exact command you need. You can try

phonegap run android --device

or

phonegap cordova run android --device

or

cordova run android --device (this might require to install the Cordova CLI npm install -g cordova)

You will need to install the Android SDK to make previous commands to work.

Body:
I have followed the instructions here to the dot. (https://documentation.onesignal.com/v3.0/docs/phonegap-sdk-setup)

My goal is to send Push Notifications from a server (Firebase or OneSignal) to my Android device which I am testing on Chrome browser or PhoneGap test app.

I have added the following code to my onDeviceReady function and it runs;

console.log("OneSignal is here!");
var notificationOpenedCallback = function(jsonData) {
  console.log('notificationOpenedCallback: ' + JSON.stringify(jsonData));
  alert("Received my notification");
};

// c02be63f-e777-4b99-8775-dec62efxxxxx is my APP ID
window.plugins.OneSignal
  .startInit("c02be63f-e777-4b99-8775-dec62efxxxxx")
  .handleNotificationOpened(notificationOpenedCallback)
  .endInit();

window.plugins.OneSignal.setSubscription (true);

window.plugins.OneSignal.enableNotificationWhenActive(true);

However, after running, I get the following errors. Can someone please explain what this error means?

Error: exec proxy not found for :: StatusBar :: _ready
(index):365 OneSignal is here!
(index):365 Error: exec proxy not found for :: OneSignalPush :: setNotificationReceivedHandler
(index):365 Error: exec proxy not found for :: OneSignalPush :: setNotificationOpenedHandler
(index):365 Error: exec proxy not found for :: OneSignalPush :: init
(index):365 Error: exec proxy not found for :: OneSignalPush :: setSubscription

I have noticed the same error for every other new plugin I tried. This means something is wrong.

Here is my config.xml

<?xml version='1.0' encoding='utf-8'?>
<widget id="com.upen.testing" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0">
    <name>Testing</name>
    <description>
        A blank PhoneGap app.
    </description>
    <author email="support@phonegap.com" href="http://phonegap.com">
        PhoneGap Team
    </author>
    <content src="index.html" />
    <access origin="*" />
    <gap:plugin name="onesignal-cordova-plugin" source="npm" spec="^2.2.4" />
    <preference name="phonegap-version" value="cli-7.1.1" />
    <preference name="android-build-tool" value="gradle" />
    <preference name="android-minSdkVersion" value="15" />
    <engine name="browser" spec="~5.0.1" />
    <plugin name="cordova-plugin-whitelist" spec="~1.3.3" />
    <plugin name="onesignal-cordova-plugin" spec="~2.2.4" />
    <plugin name="cordova-plugin-statusbar" spec="~2.3.0" />
    <plugin name="cordova-plugin-fcm" spec="^2.1.2" />
    <engine name="android" spec="~6.3.0" />
</widget>


问:
When does a RDD lineage is created? How to find lineage graph?
I am learning Apache Spark and trying to get the lineage graph of the RDDs.
But i could not find when does a particular lineage is created?
Also, where to find the lineage of an RDD?</p>

答:
RDD Lineage is the logical execution plan of a distributed computation that is created and expanded every time you apply a transformation on any RDD.

Note the part "logical" not "physical" that happens after you've executed an action.

Quoting Mastering Apache Spark 2 gitbook:

RDD Lineage (aka RDD operator graph or RDD dependency graph) is a graph of all the parent RDDs of a RDD. It is built as a result of applying transformations to the RDD and creates a logical execution plan.

A RDD lineage graph is hence a graph of what transformations need to be executed after an action has been called.

Any RDD has a RDD lineage even if that means that the RDD lineage is just a single node, i.e. the RDD itself. That's because an RDD may or may not be a result of a series of transformations (and no transformations is a "zero-effect" transformation :))

You can check out the RDD lineage of an RDD using RDD.toDebugString:

toDebugString: String A description of this RDD and its recursive dependencies for debugging.

```<code>val nums = sc.parallelize(0 to 9)
scala> nums.toDebugString
res0: String = (8) ParallelCollectionRDD[0] at parallelize at <console>:24 []

val doubles = nums.map(_ * 2)
scala> doubles.toDebugString
res1: String =
(8) MapPartitionsRDD[1] at map at <console>:25 []
 |  ParallelCollectionRDD[0] at parallelize at <console>:24 []

val groups = doubles.groupBy(_ < 10)
scala> groups.toDebugString
res2: String =
(8) ShuffledRDD[3] at groupBy at <console>:25 []
 +-(8) MapPartitionsRDD[2] at groupBy at <console>:25 []
    |  MapPartitionsRDD[1] at map at <console>:25 []
    |  ParallelCollectionRDD[0] at parallelize at <console>:24 []
</code>```

Body:
RDD Lineage is the logical execution plan of a distributed computation that is created and expanded every time you apply a transformation on any RDD.

Note the part "logical" not "physical" that happens after you've executed an action.

Quoting Mastering Apache Spark 2 gitbook:

RDD Lineage (aka RDD operator graph or RDD dependency graph) is a graph of all the parent RDDs of a RDD. It is built as a result of applying transformations to the RDD and creates a logical execution plan.

A RDD lineage graph is hence a graph of what transformations need to be executed after an action has been called.

Any RDD has a RDD lineage even if that means that the RDD lineage is just a single node, i.e. the RDD itself. That's because an RDD may or may not be a result of a series of transformations (and no transformations is a "zero-effect" transformation :))

You can check out the RDD lineage of an RDD using RDD.toDebugString:

toDebugString: String A description of this RDD and its recursive dependencies for debugging.

val nums = sc.parallelize(0 to 9)
scala> nums.toDebugString
res0: String = (8) ParallelCollectionRDD[0] at parallelize at <console>:24 []

val doubles = nums.map(_ * 2)
scala> doubles.toDebugString
res1: String =
(8) MapPartitionsRDD[1] at map at <console>:25 []
 |  ParallelCollectionRDD[0] at parallelize at <console>:24 []

val groups = doubles.groupBy(_ < 10)
scala> groups.toDebugString
res2: String =
(8) ShuffledRDD[3] at groupBy at <console>:25 []
 +-(8) MapPartitionsRDD[2] at groupBy at <console>:25 []
    |  MapPartitionsRDD[1] at map at <console>:25 []
    |  ParallelCollectionRDD[0] at parallelize at <console>:24 []


问:
sql fetch one record per date from table
I have a table like:

```<code>o_id  order_no   date        etc....
 4     1         2017-02-01
 4     2         2017-02-01
 4     3         2017-02-01
</code>```

what i want is only one(highest order no) record per date should be fetched.
For example for only order_no 3 for o_id 4 should be fetched

Output:

```<code>o_id       order_no      date
4          3             2017-02-01
2          1             .........so on
</code>```

答:
The canonical method is to use the ANSI-standard ROW_NUMBER() function:

```<code>select t.*
from (select t.*,
             row_number() over (partition by o_id order by order_no desc) as seqnum
      from t
     ) t
where seqnum = 1;
</code>```

Body:
I have a table like:

o_id  order_no   date        etc....
 4     1         2017-02-01
 4     2         2017-02-01
 4     3         2017-02-01

what i want is only one(highest order no) record per date should be fetched.
For example for only order_no 3 for o_id 4 should be fetched

Output:

o_id       order_no      date
4          3             2017-02-01
2          1             .........so on

Body:
The canonical method is to use the ANSI-standard ROW_NUMBER() function:

select t.*
from (select t.*,
             row_number() over (partition by o_id order by order_no desc) as seqnum
      from t
     ) t
where seqnum = 1;


问:
SQL right join between tables
I have three tables where I want to perform a join between them.

1st table looks like (named users)

```<code>id      column1
1       1
2       2
3       3
</code>```

2nd table looks like (named transactions) here we have some transactions of users

```<code>user_id      transaction_date      transaction_expire
1            2017-03-31            2017-05-16
1            2017-02-28            2017-04-16
</code>```

3rd table looks like (named user_logs) we have logs of the users based on days

```<code>user_id      date          some_log_data
1            2017-03-07    1505
1            2017-03-03    1201
1            2017-03-22    942
1            2017-03-31    1490
1            2017-04-05    1490
</code>```

I want to know the sum of every user based on transactions something like:

```<code>user_id     transaction_date    transaction_expire    log
1           2017-03-31          2017-05-16            2980
1           2017-02-28          2017-04-16            6628
</code>```

So this is the result which I want to achieve for every use get the SUM of their log in all transactions.

By doing this query between transaction_date and transaction_expire I get some result but when I try to do the summation the result are for all of them:

```<code>SELECT t.transaction_date, t.transaction_expire, ul.log
FROM user_logs as ul
    RIGHT JOIN transactions as t ON ul.user_id= t.user_id
WHERE ul.date BETWEEN t.transaction_date AND t.transaction_expire
</code>```

This query gives me 7 rows which is correct but now I want to find only the sum of the logs in these two different transactions.

答:
How about this

```<code>SELECT t.user_id, t.transaction_date, t.transaction_expire, SUM(IFNULL(ul.log, 0))
FROM user_logs as ul
    LEFT JOIN transactions as t ON (ul.user_id= t.user_id AND
           ul.date BETWEEN t.transaction_date AND t.transaction_expire)
GROUP BY t.user_id, t.transaction_date, t.transaction_expire;
</code>```

Your expected result contains user_id. So, I included that. If a user doesnt have a log, this will return a 0 for the SUM. I assume this is what you wanted

Title: SQL right join between tables

Body:
I have three tables where I want to perform a join between them.

1st table looks like (named users)

id      column1
1       1
2       2
3       3

2nd table looks like (named transactions) here we have some transactions of users

user_id      transaction_date      transaction_expire
1            2017-03-31            2017-05-16
1            2017-02-28            2017-04-16

3rd table looks like (named user_logs) we have logs of the users based on days

user_id      date          some_log_data
1            2017-03-07    1505
1            2017-03-03    1201
1            2017-03-22    942
1            2017-03-31    1490
1            2017-04-05    1490

I want to know the sum of every user based on transactions something like:

user_id     transaction_date    transaction_expire    log
1           2017-03-31          2017-05-16            2980
1           2017-02-28          2017-04-16            6628

So this is the result which I want to achieve for every use get the SUM of their log in all transactions.

By doing this query between transaction_date and transaction_expire I get some result but when I try to do the summation the result are for all of them:

SELECT t.transaction_date, t.transaction_expire, ul.log
FROM user_logs as ul
    RIGHT JOIN transactions as t ON ul.user_id= t.user_id
WHERE ul.date BETWEEN t.transaction_date AND t.transaction_expire

This query gives me 7 rows which is correct but now I want to find only the sum of the logs in these two different transactions.

Body:
How about this

SELECT t.user_id, t.transaction_date, t.transaction_expire, SUM(IFNULL(ul.log, 0))
FROM user_logs as ul
    LEFT JOIN transactions as t ON (ul.user_id= t.user_id AND
           ul.date BETWEEN t.transaction_date AND t.transaction_expire)
GROUP BY t.user_id, t.transaction_date, t.transaction_expire;

Your expected result contains user_id. So, I included that. If a user doesnt have a log, this will return a 0 for the SUM. I assume this is what you wanted


问:
Java Game - Pick up Item and Look around Function
I have been creating a java text game but I am stuck trying to figure out on how to implement the last 2 methods. I want it to print out the items in the room and the name of the npc thats in the room (A sort of a Look function). I am not sure on how to go on about it. Any help would be appriciated.

```<code>Room[] place = new Room[]{station, UC, Ollies, lounge, palace, AT301};
Sword sword = new Sword();
Thing heal = new HealthPotion();
Thing armour = new Armour();
Thing trap = new Trap();
</code>```

and for the NPC (Mike, Jake, Evil, Carl)

```<code>public abstract class Player{

//abstract attributes
private String name;
private int currentHealth;
private int maxHealth;
private int damage;
private Room currentRoom;
private int stack;
private int effect;

//Constructor for player
public Player(String name, int currentHealth, int maxHealth, int damage, int effect, int stack){
    this.name = name;
    this.currentHealth = currentHealth;
    this.maxHealth = maxHealth;
    this.damage = damage;
    this.effect = effect;
    this.stack = stack;
}

//getters
public String getName(){ return name;}
public int  getCurrentHealth(){ return currentHealth;}
public int getMaxHealth(){ return maxHealth;}
public int getDamage(){ return damage;}
public Room getCurrentRoom(){ return currentRoom;}
public int getEffect(){ return effect;}
public int getStack(){ return stack;}

//setters
public void setCurrentHealth(int currentHealth){this.currentHealth = currentHealth;}
public void setMaxHealth(int maxHealth){this.maxHealth = maxHealth;}
public void setDamage(int damage){ this.damage = damage;}
public void setCurrentRoom(Room room){this.currentRoom = room;}
public void setEffect(int effect){ this.effect = effect;}
public void setStack(int stack){ this.stack = stack;}
public void enter(Room room){ this.currentRoom = room;}

//abstract method because each player has a different attack;

public void takeDamage(int damage){ setCurrentHealth(this.currentHealth-damage);}

public boolean isDead(){
    if(this.currentHealth<=0){ return true;}
    return false;
}
</code>```

}

I was able to make everything functional except the Look function for the player. I can't figure out how to go on about it.

答: I would recommend you first of all creating a class Npc with attribute name and add it to the room.

Body:
I have been creating a java text game but I am stuck trying to figure out on how to implement the last 2 methods. I want it to print out the items in the room and the name of the npc thats in the room (A sort of a Look function). I am not sure on how to go on about it. Any help would be appriciated.

Room[] place = new Room[]{station, UC, Ollies, lounge, palace, AT301};
Sword sword = new Sword();
Thing heal = new HealthPotion();
Thing armour = new Armour();
Thing trap = new Trap();

and for the NPC (Mike, Jake, Evil, Carl)

public abstract class Player{

//abstract attributes
private String name;
private int currentHealth;
private int maxHealth;
private int damage;
private Room currentRoom;
private int stack;
private int effect;

//Constructor for player
public Player(String name, int currentHealth, int maxHealth, int damage, int effect, int stack){
    this.name = name;
    this.currentHealth = currentHealth;
    this.maxHealth = maxHealth;
    this.damage = damage;
    this.effect = effect;
    this.stack = stack;
}

//getters
public String getName(){ return name;}
public int  getCurrentHealth(){ return currentHealth;}
public int getMaxHealth(){ return maxHealth;}
public int getDamage(){ return damage;}
public Room getCurrentRoom(){ return currentRoom;}
public int getEffect(){ return effect;}
public int getStack(){ return stack;}

//setters
public void setCurrentHealth(int currentHealth){this.currentHealth = currentHealth;}
public void setMaxHealth(int maxHealth){this.maxHealth = maxHealth;}
public void setDamage(int damage){ this.damage = damage;}
public void setCurrentRoom(Room room){this.currentRoom = room;}
public void setEffect(int effect){ this.effect = effect;}
public void setStack(int stack){ this.stack = stack;}
public void enter(Room room){ this.currentRoom = room;}

//abstract method because each player has a different attack;

public void takeDamage(int damage){ setCurrentHealth(this.currentHealth-damage);}

public boolean isDead(){
    if(this.currentHealth<=0){ return true;}
    return false;
}

}

I was able to make everything functional except the Look function for the player. I can't figure out how to go on about it.


问:
regex to ignore lines with specific symbol
I'm trying to get a regex to set change relative paths to absolute with an alias, and ignore any lines with alias already indicated with the @ symbol to prevent folder/file name matches.  I've got as far as the replace and match , but I can't do the ignore lines with @ bit.  I would also like it to match  the /foldername/ forward slashes either side when selecting.

https://regex101.com/r/vRUegE/1/

I would have expected the lines with @ to be ignored

Here is the correct response thanks to Wiktor:

Working example

Using a combination of WinGrep and these regex's it was easy to refactor hundreds of paths in hundreds of files in minutes!

答:
You may add a negative lookahead (?!@) after the positive lookbehind:

```<code>(?<=from..)(?!@)(.*)(?=module)(.*)(module)
           ^^^^^
</code>```

See this regex demo. The (?!@) will fail the match once @ is found right after from and any 2 chars immediately to the right of it.

Note that the regex might need further adjusting as (?=module) does not make much sense here. You might as well use (?<=from..)(?!@)(.*)(module).

Body:
You may add a negative lookahead (?!@) after the positive lookbehind:

(?<=from..)(?!@)(.*)(?=module)(.*)(module)
           ^^^^^

See this regex demo. The (?!@) will fail the match once @ is found right after from and any 2 chars immediately to the right of it.

Note that the regex might need further adjusting as (?=module) does not make much sense here. You might as well use (?<=from..)(?!@)(.*)(module).


问:
Oracle SQL: Trying to exclude rows based on a combination of column values
I have a table with a list of IDs that I need to exclude rows from. For each row, an ID can have one value in the comment_code column. I need to exclude IDs from my results that have a combination of two specific values and keep IDs that have only one of those two values. Sorry if this isn't clear.

Table example:

```<code>ID     SEQUENCE     FUNCTION     COMMENT_CODE
---------------------------------------------------------------
1        1             tree          apple
1        2             bush          orange
2        1             tree          apple
2        2             tree          banana
3        1             bush          strawberry
</code>```

Output needed:

```<code>ID     SEQUENCE     FUNCTION     COMMENT_CODE
---------------------------------------------------------------
2        1             tree          apple
</code>```

Basically, if an ID has a row with 'apple' as the comment_code and a row with 'orange' as the comment code, I don't want to see that ID in my results. If an ID has a row with 'apple' as a comment code, I want to see them in my results regardless of any other comment_code they may have as long as they don't have the orange comment code.

Any help would be greatly appreciated. I've tried using a combination of exists and not exists clauses as well as listagg to group the comment_code values together for each ID, but I'm not getting the expected result.

答:
select *

  from table t

 where exists (select 1 from dual

                where t.function = 'tree'
                  and t.comment_code = 'apple')

Body:
I have a table with a list of IDs that I need to exclude rows from. For each row, an ID can have one value in the comment_code column. I need to exclude IDs from my results that have a combination of two specific values and keep IDs that have only one of those two values. Sorry if this isn't clear.

Table example:

ID     SEQUENCE     FUNCTION     COMMENT_CODE
---------------------------------------------------------------
1        1             tree          apple
1        2             bush          orange
2        1             tree          apple
2        2             tree          banana
3        1             bush          strawberry

Output needed:

ID     SEQUENCE     FUNCTION     COMMENT_CODE
---------------------------------------------------------------
2        1             tree          apple

Basically, if an ID has a row with 'apple' as the comment_code and a row with 'orange' as the comment code, I don't want to see that ID in my results. If an ID has a row with 'apple' as a comment code, I want to see them in my results regardless of any other comment_code they may have as long as they don't have the orange comment code.

Any help would be greatly appreciated. I've tried using a combination of exists and not exists clauses as well as listagg to group the comment_code values together for each ID, but I'm not getting the expected result.


问:
Haskell: accessing lists from back
Today I started learning Haskell. I'm kind of new with functional languages, and I'm enjoying Haskell a lot.

However I've got a question about its design which is bugging me: from what I understood so far it looks like accessing an element to the back of a list is a lot more complicated that accessing the element to the front (something like xs:x where xs::[a] and x::a doesn't seem to be possible).

(From what I understood) it's possible to append a list to another one (xs++[a]), but it'll cost more at run time (it requires to traverse the whole list) and it cannot be used for pattern matching.

Why is Haskell missing such operation?

答:
The list datatype

```<code>data [a] = [] | a : [a]
</code>```

is defined like above.  There's only two patterns you can match: [] and x : xs, where x is the head and xs is the tail.

Prepending to a list

```<code>a = 1 : 2 : []
b = 0 : a
</code>```

```
 (:) <-- b
 / \
0  (:)  <-- a
   / \
  1  (:)
     / \
    2   []
```

simply adds a new cons cell and reuses the original list as the tail.

However, keep in mind that Haskell data structures are immutable.  Appending to the tail of a list

```<code>a = 1 : 2 : []
b = a ++ [3]
</code>```

```
 (:) <-- a      (:) <-- b
 / \            / \
1  (:)         1  (:)
   / \            / \
  2   []         2  (:)
                    / \
                   3   []
```

requires building an entirely new list, because no part of the original structure can be reused.

In fact, consider

```<code>a = 0 : a
b = 0 : [ x+1 | x <- b ]
</code>```

```
 (:) <-- a         (:) <-- b
 / \               / \
0  (:) <-- a      0  (:) <-- [ x+1 | x <- b ]
   / \               / \
  0  (:) <-- a      1  (:) <-- [ x+1 | x <- [ x+1 | x <- b ] ]
     ...               ...
```

How would you ever get the last element of the list, or append to the end?

There are other data structures such as dequeues which are more suited for both front- and back-based access.

ContentLicense: CC BY-SA 2.5

Title: Haskell: accessing lists from back

Body:
The list datatype

data [a] = [] | a : [a]

is defined like above.  There's only two patterns you can match: [] and x : xs, where x is the head and xs is the tail.

Prepending to a list

a = 1 : 2 : []
b = 0 : a

 (:) <-- b
 / \
0  (:)  <-- a
   / \
  1  (:)
     / \
    2   []

simply adds a new cons cell and reuses the original list as the tail.

However, keep in mind that Haskell data structures are immutable.  Appending to the tail of a list

a = 1 : 2 : []
b = a ++ [3]

 (:) <-- a      (:) <-- b
 / \            / \
1  (:)         1  (:)
   / \            / \
  2   []         2  (:)
                    / \
                   3   []

requires building an entirely new list, because no part of the original structure can be reused.

In fact, consider

a = 0 : a
b = 0 : [ x+1 | x <- b ]

 (:) <-- a         (:) <-- b
 / \               / \
0  (:) <-- a      0  (:) <-- [ x+1 | x <- b ]
   / \               / \
  0  (:) <-- a      1  (:) <-- [ x+1 | x <- [ x+1 | x <- b ] ]
     ...               ...

How would you ever get the last element of the list, or append to the end?

There are other data structures such as dequeues which are more suited for both front- and back-based access.


问:
How to join summary statistics as new variables for each statistics back to original dataframe
need help to create a function so that this function can produce summary statistics joined back to the original but named after the column (with a prefix (i.e. cyl_event_pct, cyl_distn_events for each variable with values to the corresponding variable in the data frame. The function will require input parameters both the dataframe, and the independent variable. in the example below, the independent variable will be mtcars$am

```<code>df <- mtcars %>%
  select(cyl,gear,vs,am)

df %>%
  gather(variable,value, -ncol(df)) %>%
  group_by(variable, value) %>%
  summarise (n = n(),
             n_events = sum(am),
             event_pct = round(mean(am),4)
  ) %>%
  mutate(distn_events = round(n_events/sum(n_events),4))
</code>```

Would like to add event_pct and distn_events as new variable to original df.

```<code>   # A tibble: 8 x 6
# Groups:   variable [3]
  variable value     n n_events event_pct distn_events
     <chr> <dbl> <int>    <dbl>     <dbl>        <dbl>
1      cyl     4    11        8    0.7273       0.6154
2      cyl     6     7        3    0.4286       0.2308
3      cyl     8    14        2    0.1429       0.1538
4     gear     3    15        0    0.0000       0.0000
5     gear     4    12        8    0.6667       0.6154
6     gear     5     5        5    1.0000       0.3846
7       vs     0    18        6    0.3333       0.4615
8       vs     1    14        7    0.5000       0.5385
</code>```

hope to see a dataframe after with additional columns added as cyl_event_pct, cyl_distn_events, gear_event_pct, gear_distn_events to the below table with values to the corresponding variable in the data frame(excluding the independent variable of am)

```<code>df
                    cyl gear vs am
Mazda RX4             6    4  0  1
Mazda RX4 Wag         6    4  0  1
Datsun 710            4    4  1  1
Hornet 4 Drive        6    3  1  0
Hornet Sportabout     8    3  0  0
Valiant               6    3  1  0
Duster 360            8    3  0  0
Merc 240D             4    4  1  0
Merc 230              4    4  1  0
Merc 280              6    4  1  0
Merc 280C             6    4  1  0
</code>```

Thank you in advanced you masters of the universe!
JT

Body:
need help to create a function so that this function can produce summary statistics joined back to the original but named after the column (with a prefix (i.e. cyl_event_pct, cyl_distn_events for each variable with values to the corresponding variable in the data frame. The function will require input parameters both the dataframe, and the independent variable. in the example below, the independent variable will be mtcars$am

df <- mtcars %>%
  select(cyl,gear,vs,am)

df %>%
  gather(variable,value, -ncol(df)) %>%
  group_by(variable, value) %>%
  summarise (n = n(),
             n_events = sum(am),
             event_pct = round(mean(am),4)
  ) %>%
  mutate(distn_events = round(n_events/sum(n_events),4))

Would like to add event_pct and distn_events as new variable to original df.

   # A tibble: 8 x 6
# Groups:   variable [3]
  variable value     n n_events event_pct distn_events
     <chr> <dbl> <int>    <dbl>     <dbl>        <dbl>
1      cyl     4    11        8    0.7273       0.6154
2      cyl     6     7        3    0.4286       0.2308
3      cyl     8    14        2    0.1429       0.1538
4     gear     3    15        0    0.0000       0.0000
5     gear     4    12        8    0.6667       0.6154
6     gear     5     5        5    1.0000       0.3846
7       vs     0    18        6    0.3333       0.4615
8       vs     1    14        7    0.5000       0.5385

hope to see a dataframe after with additional columns added as cyl_event_pct, cyl_distn_events, gear_event_pct, gear_distn_events to the below table with values to the corresponding variable in the data frame(excluding the independent variable of am)

df
                    cyl gear vs am
Mazda RX4             6    4  0  1
Mazda RX4 Wag         6    4  0  1
Datsun 710            4    4  1  1
Hornet 4 Drive        6    3  1  0
Hornet Sportabout     8    3  0  0
Valiant               6    3  1  0
Duster 360            8    3  0  0
Merc 240D             4    4  1  0
Merc 230              4    4  1  0
Merc 280              6    4  1  0
Merc 280C             6    4  1  0

Thank you in advanced you masters of the universe!
JT

Body:
You could use

cols <- c("cyl", "gear", "vs")
df[paste0(cols,"_event_pct")] <- lapply(cols, function(x) df_stat[df_stat$variable==x,"event_pct"][match(df[[x]], df_stat[df_stat$variable==x,"value"])])
df[paste0(cols,"_distn_events")] <- lapply(cols, function(x) df_stat[df_stat$variable==x,"distn_events"][match(df[[x]], df_stat[df_stat$variable==x,"value"])])
df

Output is:

                  cyl gear vs am cyl_event_pct gear_event_pct vs_event_pct cyl_distn_events gear_distn_events vs_distn_events
Mazda RX4           6    4  0  1        0.4286         0.6667       0.3333           0.2308            0.6154          0.4615
Mazda RX4 Wag       6    4  0  1        0.4286         0.6667       0.3333           0.2308            0.6154          0.4615
Datsun 710          4    4  1  1        0.7273         0.6667       0.5000           0.6154            0.6154          0.5385
Hornet 4 Drive      6    3  1  0        0.4286         0.0000       0.5000           0.2308            0.0000          0.5385
Hornet Sportabout   8    3  0  0        0.1429         0.0000       0.3333           0.1538            0.0000          0.4615
Valiant             6    3  1  0        0.4286         0.0000       0.5000           0.2308            0.0000          0.5385
Duster 360          8    3  0  0        0.1429         0.0000       0.3333           0.1538            0.0000          0.4615
Merc 240D           4    4  1  0        0.7273         0.6667       0.5000           0.6154            0.6154          0.5385
Merc 230            4    4  1  0        0.7273         0.6667       0.5000           0.6154            0.6154          0.5385
Merc 280            6    4  1  0        0.4286         0.6667       0.5000           0.2308            0.6154          0.5385
Merc 280C           6    4  1  0        0.4286         0.6667       0.5000           0.2308            0.6154          0.5385

#sample data
> dput(df)
structure(list(cyl = c(6L, 6L, 4L, 6L, 8L, 6L, 8L, 4L, 4L, 6L,
6L), gear = c(4L, 4L, 4L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L), vs = c(0L,
0L, 1L, 1L, 0L, 1L, 0L, 1L, 1L, 1L, 1L), am = c(1L, 1L, 1L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L)), .Names = c("cyl", "gear", "vs",
"am"), class = "data.frame", row.names = c("Mazda RX4", "Mazda RX4 Wag",
"Datsun 710", "Hornet 4 Drive", "Hornet Sportabout", "Valiant",
"Duster 360", "Merc 240D", "Merc 230", "Merc 280", "Merc 280C"
))
> dput(df_stat)
structure(list(variable = structure(c(1L, 1L, 1L, 2L, 2L, 2L,
3L, 3L), .Label = c("cyl", "gear", "vs"), class = "factor"),
    value = c(4L, 6L, 8L, 3L, 4L, 5L, 0L, 1L), n = c(11L, 7L,
    14L, 15L, 12L, 5L, 18L, 14L), n_events = c(8L, 3L, 2L, 0L,
    8L, 5L, 6L, 7L), event_pct = c(0.7273, 0.4286, 0.1429, 0,
    0.6667, 1, 0.3333, 0.5), distn_events = c(0.6154, 0.2308,
    0.1538, 0, 0.6154, 0.3846, 0.4615, 0.5385)), .Names = c("variable",
"value", "n", "n_events", "event_pct", "distn_events"), class = "data.frame", row.names = c("1",
"2", "3", "4", "5", "6", "7", "8"))


问:
How can I pass parameters using request Header with aspnet boilerplate?
Following this question, now I want to pass the username in the headers of the redirection request. The code is this:

```<code>return Json(new AjaxResponse { TargetUrl = returnUrl });
</code>```

Is there some way to do that using this AjaxResponse or something like that?

答: I followed the sugestion of tienguyen and I used HttpContext.Current.Response.AppendHeader(headerkey, value); and it works fine!

Body:
Following this question, now I want to pass the username in the headers of the redirection request. The code is this:

return Json(new AjaxResponse { TargetUrl = returnUrl });

Is there some way to do that using this AjaxResponse or something like that?


问:
How can I give my right div margin top property here?

Hi,

I want the right div with red background some margin top property but still stay the same in the blue box. How can I achieve this? If I give margin top to the div now, it moves the whole blue div.

    left

    right

```

答:
Just Add float: left; and remove margin-left in red div

    left

    right

```

Body:
Just Add float: left; and remove margin-left in red div

<div id="wrapper" style="width: 100%;height: 100px; background-color: blue">
  <div id="left" style="background-color: green; height: 50px; width: 50px;  display: inline-block; float: left">
    left
  </div>
  <div id="right" style="background-color: red; height: 50px; width: 50px; float: left; margin-top: 10px;">
    right
  </div>
</div>


问:
Grunt build is breaking my compiled javascript
I've got a project that wasn't mine from the beginning and the whole deployment was incomplete. I have the freaking grunt ignoring overrides specified here and now i've discovered that when he generates the vendor.js with all the dependencies it simply doesn't work. The browser prints:

```<code>    Uncaught TypeError: Cannot read property 'Item' of undefined(anonymous function) @ vendor.js:14(anonymous function) @ vendor.js:14
vendor.js:4 Uncaught Error: [$injector:nomod] Module 'gettext' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
http://errors.angularjs.org/1.2.14/$injector/nomod?p0=gettext(anonymous function) @ vendor.js:4(anonymous function) @ vendor.js:4b @ vendor.js:4l.bootstrap @ vendor.js:4(anonymous function) @ scripts.js:1
VM47 vendor.js:4 Uncaught Error: [$injector:modulerr] Failed to instantiate module trepeatApp due to:
Error: [$injector:modulerr] Failed to instantiate module angularPayments due to:
Error: [$injector:nomod] Module 'angularPayments' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
</code>```

When i'm using just the grunt serve task it works fine but if i grunt build something in these tasks bellow just breaks the freaking script

```<code>    'concat',
    'ngmin',
    'copy:dist',
    'cdnify',
    'cssmin',
    'uglify',
    'usemin',
    'htmlmin',
</code>```

Can someone help me? I'm getting quite desperate

[UPDATE - 24/08/2015]
I've read the link the @RobSchmuecker comment and changed some stuff on gettext config and one of the errors was solved.

```<code>Uncaught Error: [$injector:modulerr] Failed to instantiate module trepeatApp due to:
Error: [$injector:modulerr] Failed to instantiate module angularPayments due to:
Error: [$injector:nomod] Module 'angularPayments' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
http://errors.angularjs.org/1.4.4/$injector/nomod?p0=angularPayments
    at http://mylocaldev.com:3000/scripts/vendor.js:4:15152
    at http://mylocaldev.com:3000/scripts/vendor.js:4:24650
    at b (http://mylocaldev.com:3000/scripts/vendor.js:4:24123)
    at http://mylocaldev.com:3000/scripts/vendor.js:4:24435
    at http://mylocaldev.com:3000/scripts/vendor.js:5:1222
    at f (http://mylocaldev.com:3000/scripts/vendor.js:4:15559)
    at n (http://mylocaldev.com:3000/scripts/vendor.js:5:1000)
    at http://mylocaldev.com:3000/scripts/vendor.js:5:1169
    at f (http://mylocaldev.com:3000/scripts/vendor.js:4:15559)
    at n (http://mylocaldev.com:3000/scripts/vendor.js:5:1000)
http://errors.angularjs.org/1.4.4/$injector/modulerr?p0=angularPayments&p1=…20n%20(http%3A%2F%2Fmylocaldev.com%3A3000%2Fscripts%2Fvendor.js%3A5%3A1000)
    at http://mylocaldev.com:3000/scripts/vendor.js:4:15152
    at http://mylocaldev.com:3000/scripts/vendor.js:5:1428
    at f (http://mylocaldev.com:3000/scripts/vendor.js:4:15559)
    at n (http://mylocaldev.com:3000/scripts/vendor.js:5:1000)
    at http://mylocaldev.com:3000/scripts/vendor.js:5:1169
    at f (http://mylocaldev.com:3000/scripts/vendor.js:4:15559)
    at n (http://mylocaldev.com:3000/scripts/vendor.js:5:1000)
    at $a (http://mylocaldev.com:3000/scripts/vendor.js:5:2690)
    at h (http://mylocaldev.com:3000/scripts/vendor.js:4:22195)
    at ga (http://mylocaldev.com:3000/scripts/vendor.js:4:22505)
http://errors.angularjs.org/1.4.4/$injector/modulerr?p0=trepeatApp&p1=Error…ga%20(http%3A%2F%2Fmylocaldev.com%3A3000%2Fscripts%2Fvendor.js%3A4%3A22505)
</code>```

答:
As jesus.jackson.sena correctly states, this error can be caused by Outlayer. But in contrast to him, overrides works well for me. So as a reference for those who need it, that's how to set the override correctly in bower.json:

```<code>"overrides": {
  "outlayer": {
    "main": [
      "item.js",
      "outlayer.js"
    ]
  }
}
</code>```

For those interested in the reason for this behaviour:
outlayer.js has the following initialization code:

```<code>window.Outlayer = factory(
  window,
  window.EvEmitter,
  window.getSize,
  window.fizzyUIUtils,
  window.Outlayer.Item
);
</code>```

For window.Outlayer.Item to be defined, Outlayer's item.js has to be called first, which defines it as follows:

```<code>window.Outlayer = {};
window.Outlayer.Item = factory(
  window.EvEmitter,
  window.getSize
);
</code>```

Body:
I've got a project that wasn't mine from the beginning and the whole deployment was incomplete. I have the freaking grunt ignoring overrides specified here and now i've discovered that when he generates the vendor.js with all the dependencies it simply doesn't work. The browser prints:

    Uncaught TypeError: Cannot read property 'Item' of undefined(anonymous function) @ vendor.js:14(anonymous function) @ vendor.js:14
vendor.js:4 Uncaught Error: [$injector:nomod] Module 'gettext' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
http://errors.angularjs.org/1.2.14/$injector/nomod?p0=gettext(anonymous function) @ vendor.js:4(anonymous function) @ vendor.js:4b @ vendor.js:4l.bootstrap @ vendor.js:4(anonymous function) @ scripts.js:1
VM47 vendor.js:4 Uncaught Error: [$injector:modulerr] Failed to instantiate module trepeatApp due to:
Error: [$injector:modulerr] Failed to instantiate module angularPayments due to:
Error: [$injector:nomod] Module 'angularPayments' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.

When i'm using just the grunt serve task it works fine but if i grunt build something in these tasks bellow just breaks the freaking script

    'concat',
    'ngmin',
    'copy:dist',
    'cdnify',
    'cssmin',
    'uglify',
    'usemin',
    'htmlmin',

Can someone help me? I'm getting quite desperate

[UPDATE - 24/08/2015]
I've read the link the @RobSchmuecker comment and changed some stuff on gettext config and one of the errors was solved.

Uncaught Error: [$injector:modulerr] Failed to instantiate module trepeatApp due to:
Error: [$injector:modulerr] Failed to instantiate module angularPayments due to:
Error: [$injector:nomod] Module 'angularPayments' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
http://errors.angularjs.org/1.4.4/$injector/nomod?p0=angularPayments
    at http://mylocaldev.com:3000/scripts/vendor.js:4:15152
    at http://mylocaldev.com:3000/scripts/vendor.js:4:24650
    at b (http://mylocaldev.com:3000/scripts/vendor.js:4:24123)
    at http://mylocaldev.com:3000/scripts/vendor.js:4:24435
    at http://mylocaldev.com:3000/scripts/vendor.js:5:1222
    at f (http://mylocaldev.com:3000/scripts/vendor.js:4:15559)
    at n (http://mylocaldev.com:3000/scripts/vendor.js:5:1000)
    at http://mylocaldev.com:3000/scripts/vendor.js:5:1169
    at f (http://mylocaldev.com:3000/scripts/vendor.js:4:15559)
    at n (http://mylocaldev.com:3000/scripts/vendor.js:5:1000)
http://errors.angularjs.org/1.4.4/$injector/modulerr?p0=angularPayments&p1=…20n%20(http%3A%2F%2Fmylocaldev.com%3A3000%2Fscripts%2Fvendor.js%3A5%3A1000)
    at http://mylocaldev.com:3000/scripts/vendor.js:4:15152
    at http://mylocaldev.com:3000/scripts/vendor.js:5:1428
    at f (http://mylocaldev.com:3000/scripts/vendor.js:4:15559)
    at n (http://mylocaldev.com:3000/scripts/vendor.js:5:1000)
    at http://mylocaldev.com:3000/scripts/vendor.js:5:1169
    at f (http://mylocaldev.com:3000/scripts/vendor.js:4:15559)
    at n (http://mylocaldev.com:3000/scripts/vendor.js:5:1000)
    at $a (http://mylocaldev.com:3000/scripts/vendor.js:5:2690)
    at h (http://mylocaldev.com:3000/scripts/vendor.js:4:22195)
    at ga (http://mylocaldev.com:3000/scripts/vendor.js:4:22505)
http://errors.angularjs.org/1.4.4/$injector/modulerr?p0=trepeatApp&p1=Error…ga%20(http%3A%2F%2Fmylocaldev.com%3A3000%2Fscripts%2Fvendor.js%3A4%3A22505)

Body:
As jesus.jackson.sena correctly states, this error can be caused by Outlayer. But in contrast to him, overrides works well for me. So as a reference for those who need it, that's how to set the override correctly in bower.json:

"overrides": {
  "outlayer": {
    "main": [
      "item.js",
      "outlayer.js"
    ]
  }
}

For those interested in the reason for this behaviour:
outlayer.js has the following initialization code:

window.Outlayer = factory(
  window,
  window.EvEmitter,
  window.getSize,
  window.fizzyUIUtils,
  window.Outlayer.Item
);

For window.Outlayer.Item to be defined, Outlayer's item.js has to be called first, which defines it as follows:

window.Outlayer = {};
window.Outlayer.Item = factory(
  window.EvEmitter,
  window.getSize
);


问:
Vertically center text in a table header
I'm new to CSS and HTML and I'm trying to vertically center some text in a table header. At the moment the text is aligned with the top of the table cell. I was unsuccessful with vertical-align: middle;, and the only solution seems to be to add padding-top to match the space underneath the text. However this is not the best solution because I would like to have the text fit snugly within the table cell. Any ideas are appreciated.

body {
    font-size: 18px;
    font-family: 'Open Sans', sans-serif;
    text-align: center;
    color: black;
    background-size: 100%;
    padding:0;
}

.mytable {
  border: solid 1px #DDEEEE;
  border-collapse: collapse;
  border-spacing: 0;
  width: 80%;
}

.mytable thead th {
  background-color: #DDEFEF;
  border: solid 1px #DDEEEE;
  color: #336B6B;
  /*padding: 30px;*/
  text-align: center;
  vertical-align: middle;
}

.mytable tbody td {
  border: solid 1px #DDEEEE;
  color: #333;
  padding: 30px;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div id="myWebPage" style="display:block">
  <br><br><br><br>
  <h3>Page title here</h3><br><br><br>

  <table class="mytable" align="center">
    <thead>
      <tr>
        <th><u>Resource</u><br><br><br></th>
        <th><u>Contact</u><br><br><br></th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <th align="left">Resource 1<br><br></th>
        <th align="left" width=35%;>999-999-9999<br> <br></th>
      </tr>
      <tr>
        <th align="left">Resource 2<br><br></th>
        <th align="left">888-888-8888<br><br></th>
      </tr>
      <tr>
        <th align="left">Resource 3<br><br></th>
        <th align="left" width=35%;>777-777-7777<br> <br></th>
      </tr>
    </tbody>
  </table>
</div></code>```

答:
You have done it right in your CSS, just remove your
 tags. E.g.

```<code><th><u>Resource</u></th>
</code>```

The vertical alignment won't work whilst you're manually inserting lines under your headings.

Full example

body {
    font-size: 18px;
    font-family: 'Open Sans', sans-serif;
    text-align: center;
    color: black;
    background-size: 100%;
    padding:0;
}

.mytable {
  border: solid 1px #DDEEEE;
  border-collapse: collapse;
  border-spacing: 0;
  width: 80%;
}

.mytable thead th {
  background-color: #DDEFEF;
  border: solid 1px #DDEEEE;
  color: #336B6B;
  /*padding: 30px;*/
  text-align: center;
  vertical-align: middle;
}

.mytable tbody td {
  border: solid 1px #DDEEEE;
  color: #333;
  padding: 30px;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div id="myWebPage" style="display:block">
  <br><br><br><br>
  <h3>Page title here</h3><br><br><br>

  <table class="mytable" align="center">
    <thead>
      <tr>
        <th><u>Resource</u></th>
        <th><u>Contact</u></th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td align="left">Resource 1<br><br></td>
        <td align="left" width=35%;>999-999-9999<br> <br></td>
      </tr>
      <tr>
        <td align="left">Resource 2<br><br></td>
        <td align="left">888-888-8888<br><br></td>
      </tr>
      <tr>
        <td align="left">Resource 3<br><br></td>
        <td align="left" width=35%;>777-777-7777<br> <br></td>
      </tr>
    </tbody>
  </table>
</div></code>```

Body:
I'm new to CSS and HTML and I'm trying to vertically center some text in a table header. At the moment the text is aligned with the top of the table cell. I was unsuccessful with vertical-align: middle;, and the only solution seems to be to add padding-top to match the space underneath the text. However this is not the best solution because I would like to have the text fit snugly within the table cell. Any ideas are appreciated.

body {
    font-size: 18px;
    font-family: 'Open Sans', sans-serif;
    text-align: center;
    color: black;
    background-size: 100%;
    padding:0;
}

.mytable {
  border: solid 1px #DDEEEE;
  border-collapse: collapse;
  border-spacing: 0;
  width: 80%;
}

.mytable thead th {
  background-color: #DDEFEF;
  border: solid 1px #DDEEEE;
  color: #336B6B;
  /*padding: 30px;*/
  text-align: center;
  vertical-align: middle;
}

.mytable tbody td {
  border: solid 1px #DDEEEE;
  color: #333;
  padding: 30px;
}

Page title here

        Resource

        Contact

        Resource 1

        999-999-9999

        Resource 2

        888-888-8888

        Resource 3

        777-777-7777

Body:
You have done it right in your CSS, just remove your <br> tags. E.g.

<th><u>Resource</u></th>

The vertical alignment won't work whilst you're manually inserting lines under your headings.

Full example

body {
    font-size: 18px;
    font-family: 'Open Sans', sans-serif;
    text-align: center;
    color: black;
    background-size: 100%;
    padding:0;
}

.mytable {
  border: solid 1px #DDEEEE;
  border-collapse: collapse;
  border-spacing: 0;
  width: 80%;
}

.mytable thead th {
  background-color: #DDEFEF;
  border: solid 1px #DDEEEE;
  color: #336B6B;
  /*padding: 30px;*/
  text-align: center;
  vertical-align: middle;
}

.mytable tbody td {
  border: solid 1px #DDEEEE;
  color: #333;
  padding: 30px;
}

<div id="myWebPage" style="display:block">
  <br><br><br><br>
  <h3>Page title here</h3><br><br><br>

  <table class="mytable" align="center">
    <thead>
      <tr>
        <th><u>Resource</u></th>
        <th><u>Contact</u></th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td align="left">Resource 1<br><br></td>
        <td align="left" width=35%;>999-999-9999<br> <br></td>
      </tr>
      <tr>
        <td align="left">Resource 2<br><br></td>
        <td align="left">888-888-8888<br><br></td>
      </tr>
      <tr>
        <td align="left">Resource 3<br><br></td>
        <td align="left" width=35%;>777-777-7777<br> <br></td>
      </tr>
    </tbody>
  </table>
</div>


问:
How can I enable strict sql_mode in MySQL?
How can I enable strict sql_mode in MySQL?

I want to fetch data from SQL and process the same in strict mode.

My current sql_mode is:

```<code>mysql> SELECT @@sql_mode;
+------------------------+
| @@sql_mode             |
+------------------------+
| NO_ENGINE_SUBSTITUTION |
+------------------------+
</code>```

答:
You basically have two ways of doing it, using SQL command or changing configuration file. If you set it using SQL command - it will change back after the server is restarted.

Doing it in SQL:

SET GLOBAL sql_mode='STRICT_TRANS_TABLES';

Doing it in config file:

[mysqld]
sql_mode="STRICT_TRANS_TABLES"

File location varies depending on your operating system, more on where to find it here: https://dev.mysql.com/doc/refman/5.7/en/option-files.html

Important to note, that you can have multiple modes specified:

sql_mode="STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION"

this is especially important when using SQL statement, since it could override your whole mode string.

More stuff about SQL modes here: https://dev.mysql.com/doc/refman/5.7/en/sql-mode.html

ContentLicense: CC BY-SA 4.0

Body:
How can I enable strict sql_mode in MySQL?

I want to fetch data from SQL and process the same in strict mode.

My current sql_mode is:

mysql> SELECT @@sql_mode;
+------------------------+
| @@sql_mode             |
+------------------------+
| NO_ENGINE_SUBSTITUTION |
+------------------------+


问:
Protractor Help: Admin Error Issues on a client machine
I am an automation tester that is developing tests using a laptop given to me by the client. With the client laptop there are certain security restrictions that will not allow me to add certain software, plugins, or browser extensions.  For my protractor tests, I was able to get ChromeDriver working (and run my test), but only after disabling the automation extension to bypass the security restriction.

Are there any implications of having that extension disabled and if it will affect any automation capability going forward.  Here is a similar thread on the chrome extension Chrome extension thread

答:
I don't think so, I'm not using any automation extension and my tests work. </p>

<p>Protractor tests does not depend on any chrome extension. They work just with appropriate chrome driver. </p>

Body:
I don't think so, I'm not using any automation extension and my tests work.

Protractor tests does not depend on any chrome extension. They work just with appropriate chrome driver.


问:
RecyclerView addInArray error when adding
When I add in List<OrderList> any item in loadOrdersData(), it throws this:

D/ViewGroup: addInArray been called, this = android.support.v7.widget.RecyclerView {41cab8f0 VFED.... .F....ID 0,0-480,770 #7f0c0073 app:id/rv}call stack = java.lang.Throwable: addInArray at android.view.ViewGroup.addInArray(ViewGroup.java:3786) at android.view.ViewGroup.addViewInner(ViewGroup.java:3740) at android.view.ViewGroup.addView(ViewGroup.java:3564) at android.view.ViewGroup.addView(ViewGroup.java:3509) at android.support.v7.widget.RecyclerView$5.addView(RecyclerView.java:649) at android.support.v7.widget.ChildHelper.addView(ChildHelper.java:107) at android.support.v7.widget.RecyclerView$LayoutManager.addViewInt(RecyclerView.java:7115) at android.support.v7.widget.RecyclerView$LayoutManager.addView(RecyclerView.java:7073) at android.support.v7.widget.RecyclerView$LayoutManager.addView(RecyclerView.java:7061) at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1428) at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1377) at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:578) at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3315) at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3124)  at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3568) at android.view.View.layout(View.java:15125) at android.view.ViewGroup.layout(ViewGroup.java:4862) at android.support.v4.widget.DrawerLayout.onLayout(DrawerLayout.java:1197) at android.view.View.layout(View.java:15125) at android.view.ViewGroup.layout(ViewGroup.java:4862) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:515) at android.widget.FrameLayout.onLayout(FrameLayout.java:450) at android.view.View.layout(View.java:15125) at android.view.ViewGroup.layout(ViewGroup.java:4862) at android.support.v7.widget.ActionBarOverlayLayout.onLayout(ActionBarOverlayLayout.java:433) at android.view.View.layout(View.java:15125) at android.view.ViewGroup.layout(ViewGroup.java:4862) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:515) at android.widget.FrameLayout.onLayout(FrameLayout.java:450) at android.view.View.layout(View.java:15125) at android.view.ViewGroup.layout(ViewGroup.java:4862) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1888) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1742) at android.widget.LinearLayout.onLayout(LinearLayout.java:1651) at android.view.View.layout(View.java:15125) at android.view.ViewGroup.layout(ViewGroup.java:4862) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:515) at android.widget.FrameLayout.onLayout(FrameLayout.java:450) at android.view.View.layout(View.java:15125) at android.view.ViewGroup.layout(ViewGroup.java:4862) at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2323) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2029) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1192) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6231) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:788) at android.view.Choreographer.doCallbacks(Choreographer.java:591) at android.view.Choreographer.doFrame(Choreographer.java:560) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:774) at android.os.Handler.handleCallback(Handler.java:808) at android.os.Handler.dispatchMessage(Handler.java:103) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:5305) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:824) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640) at dalvik.system.NativeStart.main(Native Method)

I tried adding: adapter.notifyDataSetChanged(); before setAdapter() in loadOrdersData() but it makes no sense. Does anyone see what it is caused by?

Here's the code:

MainActivity:

```<code>public class CourierActivity extends AppCompatActivity {
    private TableLayout orderTable;
    private RecyclerView recyclerView;
    private RecycleAdapter adapter;
    private List<OrderListItem> listItems;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.courier_main);

        recyclerView = (RecyclerView) findViewById(R.id.rv);
        recyclerView.setHasFixedSize(true);
        recyclerView.setLayoutManager(new LinearLayoutManager(CourierActivity.this));
        adapter = new RecycleAdapter(listItems, getApplicationContext());
        recyclerView.setAdapter(adapter);
        loadOrdersData();
    }

    private void loadOrdersData() {
        RequestQueue queue = Volley.newRequestQueue(this);
        StringRequest sr = new StringRequest(Request.Method.GET, URL, new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {
                listItems = new ArrayList<>();

                try {
                    String rsp = new String(response.getBytes("ISO-8859-1"), "UTF-8");
                    JSONArray orders = new JSONArray(rsp);

                    for (int i = 0; i < orders.length(); i++) {
                        OrderListItem listItem = new OrderListItem(
                                // ..
                        );

                        listItems.add(listItem);
                    }

                    adapter = new RecycleAdapter(listItems, getApplicationContext());
                    recyclerView.setAdapter(adapter);
                } catch (JSONException | UnsupportedEncodingException e) {
                    e.printStackTrace();
                }
            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                Toast.makeText(getApplicationContext(), error.getMessage(), Toast.LENGTH_SHORT);
            }
        }) {

            @Override
            public Map<String, String> getHeaders() throws AuthFailureError {
                Map<String, String> params = new HashMap<String, String>();
                return params;
            }
        };

        queue.add(sr);
    }
}
</code>```

OrderListItem:

```<code>public class OrderListItem {
    private String name;
    private String status;
    private String price;
    private String courier;

    public OrderListItem(String name, String status, String price, String courier) {
        this.name = name;
        this.status = status;
        this.price = price;
        this.courier = courier;
    }

    public String getName() { return name; }

    public String getStatus() { return status;}

    public String getPrice() { return price; }

    public String getCourier() { return courier; }
}
</code>```

RecycleAdapter:

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

    private List<OrderListItem> listItems;
    private Context context;

    public RecycleAdapter(List<OrderListItem> listItems, Context context) {
        this.listItems = listItems;
        this.context = context;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View v = LayoutInflater.from(parent.getContext())
                .inflate(R.layout.rv_item, parent, false);

        return new ViewHolder(v);
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        OrderListItem listItem = listItems.get(position);

        holder.TextViewName.setText(listItem.getName());
        holder.TextViewStatus.setText(listItem.getStatus());
        holder.TextViewPrice.setText(listItem.getPrice());
        holder.TextViewCourier.setText(listItem.getCourier());
    }

    @Override
    public int getItemCount() {
        int count = 0;

        if (listItems != null && !listItems.isEmpty()) {
            count = listItems.size();
        }

        return count;
    }

    public class ViewHolder extends RecyclerView.ViewHolder {

        public TextView TextViewName;
        public TextView TextViewStatus;
        public TextView TextViewPrice;
        public TextView TextViewCourier;

        public ViewHolder(View itemView) {
            super(itemView);

            TextViewName = (TextView) itemView.findViewById(R.id.orderListName);
            TextViewStatus = (TextView) itemView.findViewById(R.id.orderListStatus);
            TextViewPrice = (TextView) itemView.findViewById(R.id.orderListPrice);
            TextViewCourier = (TextView) itemView.findViewById(R.id.orderListCourier);
        }
    }

}
</code>```

@layout/rv_item.xml:

```<code><?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
        android:layout_margin="@dimen/activity_horizontal_margin"
        android:layout_height="wrap_content"
        android:layout_width="match_parent">

        <LinearLayout
            android:padding="@dimen/activity_horizontal_margin"
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <TextView
                android:id="@+id/orderListName"
                android:text="Order name"
                android:textAppearance="@style/Base.TextAppearance.AppCompat.Large"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" />

            <TextView
                android:id="@+id/orderListStatus"
                android:text="Status"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" />

            <TextView
                android:id="@+id/orderListPrice"
                android:text="Price"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" />

            <TextView
                android:id="@+id/orderListCourier"
                android:text="Courier"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" />
        </LinearLayout>

    </android.support.v7.widget.CardView>

</LinearLayout>
</code>```

@layout/main.xml:

```<code><?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    tools:context="com.example.seether.myapplication.CourierActivity"
    android:background="#fff"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/drawerLayout">

    <android.support.v7.widget.RecyclerView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/rv"/>

</android.support.v4.widget.DrawerLayout>
</code>```

EDIT. Works perfect without log's warnings if I enter custom data into listItems.

答:
Volley seems to get the data asynchronously, so the most reasonable way to manage the RecyclerView is setting the adapter at first with an empty (but not null) List and the Activity context (e.g. Mainactivity.this).

When Volley has finally got all the elements, you add all of them (instead of for(int i = 0; i < orders.length(); i++) you could use for(OrderListItem listItem : orders);), you can call adapter.notifyDataSetChanged()

Body:
When I add in List<OrderList> any item in loadOrdersData(), it throws this:

D/ViewGroup: addInArray been called, this = android.support.v7.widget.RecyclerView {41cab8f0 VFED.... .F....ID 0,0-480,770 #7f0c0073 app:id/rv}call stack = java.lang.Throwable: addInArray at android.view.ViewGroup.addInArray(ViewGroup.java:3786) at android.view.ViewGroup.addViewInner(ViewGroup.java:3740) at android.view.ViewGroup.addView(ViewGroup.java:3564) at android.view.ViewGroup.addView(ViewGroup.java:3509) at android.support.v7.widget.RecyclerView$5.addView(RecyclerView.java:649) at android.support.v7.widget.ChildHelper.addView(ChildHelper.java:107) at android.support.v7.widget.RecyclerView$LayoutManager.addViewInt(RecyclerView.java:7115) at android.support.v7.widget.RecyclerView$LayoutManager.addView(RecyclerView.java:7073) at android.support.v7.widget.RecyclerView$LayoutManager.addView(RecyclerView.java:7061) at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1428) at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1377) at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:578) at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3315) at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3124)  at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3568) at android.view.View.layout(View.java:15125) at android.view.ViewGroup.layout(ViewGroup.java:4862) at android.support.v4.widget.DrawerLayout.onLayout(DrawerLayout.java:1197) at android.view.View.layout(View.java:15125) at android.view.ViewGroup.layout(ViewGroup.java:4862) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:515) at android.widget.FrameLayout.onLayout(FrameLayout.java:450) at android.view.View.layout(View.java:15125) at android.view.ViewGroup.layout(ViewGroup.java:4862) at android.support.v7.widget.ActionBarOverlayLayout.onLayout(ActionBarOverlayLayout.java:433) at android.view.View.layout(View.java:15125) at android.view.ViewGroup.layout(ViewGroup.java:4862) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:515) at android.widget.FrameLayout.onLayout(FrameLayout.java:450) at android.view.View.layout(View.java:15125) at android.view.ViewGroup.layout(ViewGroup.java:4862) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1888) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1742) at android.widget.LinearLayout.onLayout(LinearLayout.java:1651) at android.view.View.layout(View.java:15125) at android.view.ViewGroup.layout(ViewGroup.java:4862) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:515) at android.widget.FrameLayout.onLayout(FrameLayout.java:450) at android.view.View.layout(View.java:15125) at android.view.ViewGroup.layout(ViewGroup.java:4862) at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2323) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2029) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1192) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6231) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:788) at android.view.Choreographer.doCallbacks(Choreographer.java:591) at android.view.Choreographer.doFrame(Choreographer.java:560) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:774) at android.os.Handler.handleCallback(Handler.java:808) at android.os.Handler.dispatchMessage(Handler.java:103) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:5305) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:824) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640) at dalvik.system.NativeStart.main(Native Method)

I tried adding: adapter.notifyDataSetChanged(); before setAdapter() in loadOrdersData() but it makes no sense. Does anyone see what it is caused by?

Here's the code:

MainActivity:

public class CourierActivity extends AppCompatActivity {
    private TableLayout orderTable;
    private RecyclerView recyclerView;
    private RecycleAdapter adapter;
    private List<OrderListItem> listItems;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.courier_main);

        recyclerView = (RecyclerView) findViewById(R.id.rv);
        recyclerView.setHasFixedSize(true);
        recyclerView.setLayoutManager(new LinearLayoutManager(CourierActivity.this));
        adapter = new RecycleAdapter(listItems, getApplicationContext());
        recyclerView.setAdapter(adapter);
        loadOrdersData();
    }

    private void loadOrdersData() {
        RequestQueue queue = Volley.newRequestQueue(this);
        StringRequest sr = new StringRequest(Request.Method.GET, URL, new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {
                listItems = new ArrayList<>();

                try {
                    String rsp = new String(response.getBytes("ISO-8859-1"), "UTF-8");
                    JSONArray orders = new JSONArray(rsp);

                    for (int i = 0; i < orders.length(); i++) {
                        OrderListItem listItem = new OrderListItem(
                                // ..
                        );

                        listItems.add(listItem);
                    }

                    adapter = new RecycleAdapter(listItems, getApplicationContext());
                    recyclerView.setAdapter(adapter);
                } catch (JSONException | UnsupportedEncodingException e) {
                    e.printStackTrace();
                }
            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                Toast.makeText(getApplicationContext(), error.getMessage(), Toast.LENGTH_SHORT);
            }
        }) {

            @Override
            public Map<String, String> getHeaders() throws AuthFailureError {
                Map<String, String> params = new HashMap<String, String>();
                return params;
            }
        };

        queue.add(sr);
    }
}

OrderListItem:

public class OrderListItem {
    private String name;
    private String status;
    private String price;
    private String courier;

    public OrderListItem(String name, String status, String price, String courier) {
        this.name = name;
        this.status = status;
        this.price = price;
        this.courier = courier;
    }

    public String getName() { return name; }

    public String getStatus() { return status;}

    public String getPrice() { return price; }

    public String getCourier() { return courier; }
}

RecycleAdapter:

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

    private List<OrderListItem> listItems;
    private Context context;

    public RecycleAdapter(List<OrderListItem> listItems, Context context) {
        this.listItems = listItems;
        this.context = context;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View v = LayoutInflater.from(parent.getContext())
                .inflate(R.layout.rv_item, parent, false);

        return new ViewHolder(v);
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        OrderListItem listItem = listItems.get(position);

        holder.TextViewName.setText(listItem.getName());
        holder.TextViewStatus.setText(listItem.getStatus());
        holder.TextViewPrice.setText(listItem.getPrice());
        holder.TextViewCourier.setText(listItem.getCourier());
    }

    @Override
    public int getItemCount() {
        int count = 0;

        if (listItems != null && !listItems.isEmpty()) {
            count = listItems.size();
        }

        return count;
    }

    public class ViewHolder extends RecyclerView.ViewHolder {

        public TextView TextViewName;
        public TextView TextViewStatus;
        public TextView TextViewPrice;
        public TextView TextViewCourier;

        public ViewHolder(View itemView) {
            super(itemView);

            TextViewName = (TextView) itemView.findViewById(R.id.orderListName);
            TextViewStatus = (TextView) itemView.findViewById(R.id.orderListStatus);
            TextViewPrice = (TextView) itemView.findViewById(R.id.orderListPrice);
            TextViewCourier = (TextView) itemView.findViewById(R.id.orderListCourier);
        }
    }

}

@layout/rv_item.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
        android:layout_margin="@dimen/activity_horizontal_margin"
        android:layout_height="wrap_content"
        android:layout_width="match_parent">

        <LinearLayout
            android:padding="@dimen/activity_horizontal_margin"
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <TextView
                android:id="@+id/orderListName"
                android:text="Order name"
                android:textAppearance="@style/Base.TextAppearance.AppCompat.Large"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" />

            <TextView
                android:id="@+id/orderListStatus"
                android:text="Status"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" />

            <TextView
                android:id="@+id/orderListPrice"
                android:text="Price"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" />

            <TextView
                android:id="@+id/orderListCourier"
                android:text="Courier"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" />
        </LinearLayout>

    </android.support.v7.widget.CardView>

</LinearLayout>

@layout/main.xml:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    tools:context="com.example.seether.myapplication.CourierActivity"
    android:background="#fff"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/drawerLayout">

    <android.support.v7.widget.RecyclerView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/rv"/>

</android.support.v4.widget.DrawerLayout>

EDIT. Works perfect without log's warnings if I enter custom data into listItems.


问:
Unprotect workbook without password
I have a popular VBA code to unprotect a worksheet, but I am still running into the issue that the Workbook is protected. </p>

```<code>Sub PasswordBreaker()
'Breaks worksheet password protection.

    Dim i As Integer, j As Integer, k As Integer
    Dim l As Integer, m As Integer, n As Integer
    Dim i1 As Integer, i2 As Integer, i3 As Integer
    Dim i4 As Integer, i5 As Integer, i6 As Integer
    On Error Resume Next
    For i = 65 To 66: For j = 65 To 66: For k = 65 To 66
    For l = 65 To 66: For m = 65 To 66: For i1 = 65 To 66
    For i2 = 65 To 66: For i3 = 65 To 66: For i4 = 65 To 66
    For i5 = 65 To 66: For i6 = 65 To 66: For n = 32 To 126
    ActiveSheet.Unprotect Chr(i) & Chr(j) & Chr(k) & _
        Chr(l) & Chr(m) & Chr(i1) & Chr(i2) & Chr(i3) & _
        Chr(i4) & Chr(i5) & Chr(i6) & Chr(n)
    If ActiveSheet.ProtectContents = False Then
        MsgBox "One usable password is " & Chr(i) & Chr(j) & _
            Chr(k) & Chr(l) & Chr(m) & Chr(i1) & Chr(i2) & _
            Chr(i3) & Chr(i4) & Chr(i5) & Chr(i6) & Chr(n)
         Exit Sub
    End If
    Next: Next: Next: Next: Next: Next
    Next: Next: Next: Next: Next: Next
End Sub
</code>```

答: No longer works for spreadsheets Protected with Excel 2013 or later -- they improved the pw hash.  So now need to unzip .xlsx and hack the internals.

Title: Unprotect workbook without password

Body:
I have a popular VBA code to unprotect a worksheet, but I am still running into the issue that the Workbook is protected.

Sub PasswordBreaker()
'Breaks worksheet password protection.

    Dim i As Integer, j As Integer, k As Integer
    Dim l As Integer, m As Integer, n As Integer
    Dim i1 As Integer, i2 As Integer, i3 As Integer
    Dim i4 As Integer, i5 As Integer, i6 As Integer
    On Error Resume Next
    For i = 65 To 66: For j = 65 To 66: For k = 65 To 66
    For l = 65 To 66: For m = 65 To 66: For i1 = 65 To 66
    For i2 = 65 To 66: For i3 = 65 To 66: For i4 = 65 To 66
    For i5 = 65 To 66: For i6 = 65 To 66: For n = 32 To 126
    ActiveSheet.Unprotect Chr(i) & Chr(j) & Chr(k) & _
        Chr(l) & Chr(m) & Chr(i1) & Chr(i2) & Chr(i3) & _
        Chr(i4) & Chr(i5) & Chr(i6) & Chr(n)
    If ActiveSheet.ProtectContents = False Then
        MsgBox "One usable password is " & Chr(i) & Chr(j) & _
            Chr(k) & Chr(l) & Chr(m) & Chr(i1) & Chr(i2) & _
            Chr(i3) & Chr(i4) & Chr(i5) & Chr(i6) & Chr(n)
         Exit Sub
    End If
    Next: Next: Next: Next: Next: Next
    Next: Next: Next: Next: Next: Next
End Sub


问:
How to display image in a UIAlertController
I only need to display DELETE and CANCEL button as alert, no alert title or a message, and add action to DELETE button. Tried to modify following code but couldn't succeeded.
And additionally, I want to make UIVIEW bit darker when DELETE and CANCEL buttons displayed. What is the best way to do this ?

DELETE and CANCEL Button

```<code> let refreshAlert = UIAlertController(title: "Alert", message: "Are you sure ?", preferredStyle: UIAlertControllerStyle.Alert)

    var imageView = UIImageView(frame: CGRectMake(220, 10, 40, 40))
    let yourImage = UIImage(named: "delete")
    imageView.image = yourImage

    refreshAlert.view.addSubview(imageView)

    refreshAlert.addAction(UIAlertAction(title: "Ok", style: .Default, handler: { (action: UIAlertAction!) in ...
</code>```

答:
Some emojis have images , you can use these, This can be helpful for you if your image have standard emoji. please check LOCK emoji in example,> </p>

```<code>UIAlertAction* HDQuality = [UIAlertAction
                                actionWithTitle:@" lockk Action"
                                style:UIAlertActionStyleDefault
                                handler:^(UIAlertAction * action)
                                {
                                    [alert dismissViewControllerAnimated:YES completion:nil];

                                }];

[alert addAction:HDQuality];
</code>```

Body:
I only need to display DELETE and CANCEL button as alert, no alert title or a message, and add action to DELETE button. Tried to modify following code but couldn't succeeded.
And additionally, I want to make UIVIEW bit darker when DELETE and CANCEL buttons displayed. What is the best way to do this ?

DELETE and CANCEL Button

 let refreshAlert = UIAlertController(title: "Alert", message: "Are you sure ?", preferredStyle: UIAlertControllerStyle.Alert)

    var imageView = UIImageView(frame: CGRectMake(220, 10, 40, 40))
    let yourImage = UIImage(named: "delete")
    imageView.image = yourImage

    refreshAlert.view.addSubview(imageView)

    refreshAlert.addAction(UIAlertAction(title: "Ok", style: .Default, handler: { (action: UIAlertAction!) in ...

Body:
Some emojis have images , you can use these, This can be helpful for you if your image have standard emoji. please check LOCK emoji in example,>

UIAlertAction* HDQuality = [UIAlertAction
                                actionWithTitle:@" lockk Action"
                                style:UIAlertActionStyleDefault
                                handler:^(UIAlertAction * action)
                                {
                                    [alert dismissViewControllerAnimated:YES completion:nil];

                                }];

[alert addAction:HDQuality];