问:
How can I resolve the WooCommerce 'Error' and 'Warning: Illegal Characters' message within the WooCommerce files?
I am currently working on a WordPress website, with WooCommerce functionality.  The website has not gone live yet, as undergoing some testing.

I have just tested the Checkout process, and on the Checkout page, I see the following error message:

```<code>Error found in: /var/www/vhosts/example.com/httpdocs/wp-content/plugins/woocommerce/includes/libraries/class-wc-eval-math.php, nfx, 117
Warning: illegal character '�' in /var/www/vhosts/example.com/httpdocs/wp-content/plugins/woocommerce/includes/libraries/class-wc-eval-math.php on line 289
</code>```

These files have not been edited by myself and and I installed the WooCommerce directly from WooCommerce.

Anyone have any ideas on what this is and how I can resolve this?  I have not come across this error message before.

I am not sure if the issue is connected but the PayPal/Delivery section, on the Checkout page,generates the loading spinner, which stays on the page and does not load anything.

EDIT:
When making a purchase from within the UK, the 'Proceed to PayPal' button works fine.  It is only when I change the country, within the drop down menu,that the Spinner loads continually.  Thus preventing any progress.  I have looked at the 'Console' feature within Google Chrome and it highlights the following error message:

```<code>Failed to load resource: the server responded with a status of 404 (Not Found)    http://www.example.com/wp-content/themes/theme_name/css/custom-stylesheet.css?ver=1.0
jquery-migrate.min.js:2 JQMIGRATE: Migrate is installed, version 1.4.1    http://www.example.com/wp-includes/js/jquery/jquery-migrate.min.js?ver=1.4.1
Failed to load resource: the server responded with a status of 404 (Not Found)    custom-stylesheet.css
</code>```

I then went into the Page Source but could see that the above files had loaded.  Could the issue lie within this?

答:
Problem resolved!

I had placed the '£' in the 'Cost Field', when setting shipping costs.  I removed the '£' and the problem was resolved!

Body:
I am currently working on a WordPress website, with WooCommerce functionality.  The website has not gone live yet, as undergoing some testing.

I have just tested the Checkout process, and on the Checkout page, I see the following error message:

Error found in: /var/www/vhosts/example.com/httpdocs/wp-content/plugins/woocommerce/includes/libraries/class-wc-eval-math.php, nfx, 117
Warning: illegal character '�' in /var/www/vhosts/example.com/httpdocs/wp-content/plugins/woocommerce/includes/libraries/class-wc-eval-math.php on line 289

These files have not been edited by myself and and I installed the WooCommerce directly from WooCommerce.

Anyone have any ideas on what this is and how I can resolve this?  I have not come across this error message before.

I am not sure if the issue is connected but the PayPal/Delivery section, on the Checkout page,generates the loading spinner, which stays on the page and does not load anything.

EDIT:
When making a purchase from within the UK, the 'Proceed to PayPal' button works fine.  It is only when I change the country, within the drop down menu,that the Spinner loads continually.  Thus preventing any progress.  I have looked at the 'Console' feature within Google Chrome and it highlights the following error message:

Failed to load resource: the server responded with a status of 404 (Not Found)    http://www.example.com/wp-content/themes/theme_name/css/custom-stylesheet.css?ver=1.0
jquery-migrate.min.js:2 JQMIGRATE: Migrate is installed, version 1.4.1    http://www.example.com/wp-includes/js/jquery/jquery-migrate.min.js?ver=1.4.1
Failed to load resource: the server responded with a status of 404 (Not Found)    custom-stylesheet.css

I then went into the Page Source but could see that the above files had loaded.  Could the issue lie within this?


来源: stackexchange

问:
MySQL: index a field that contains only distinct values?
Is it useful for SELECT performance to set an index on a field that contains only distinct values?

eg:

```<code>order_id
--------
98317490
10928343
82931376
93438473
...
</code>```

答:
Is it useful for SELECT performance to set an index on a field that contains only distinct values?

That depends. An index is useful if you often search on this column:

WHERE column=value

WHERE column BETWEEN a AND b

The usefulness of an index is determined by its selectivity. For example, if your column contains a boolean, which is:

false in 99.9% of rows

true in 0.1% of rows

Then you can easily guess that using an index to find "true" values will be a huge boost relative to reading the entire table to search for them.

On the other hand, searching for "false" using an index will be slower than not using an index, since you're gonna read the whole table anyway, you might as well not bother to also process the index.

If values are all distinct, then selectivity is maximum, and index will be very useful. That is, assuming you actually search on that column!

An index that is never used only slows down updates.

ContentLicense: CC BY-SA 3.0

Body:
Is it useful for SELECT performance to set an index on a field that contains only distinct values?

eg:

order_id
--------
98317490
10928343
82931376
93438473
...


问:
deploy war to nexus repository or not
This question was raised since our main war file is about 40 Mb size (and it's not a single war file in whole project). And all the rest jar files is about 20 Mb thus every release takes 3 times bigger space then if we will not deploy wars.

So maybe there is an option to not deploy whole war files but only resources so then deploy team could build it from Nexus? If I skip deploy for module where we build war file then deployment team cannot be able to build it without access to source code.

Is it common practice to deploy war files in company local repository?

答:
```<code><maven.deploy.skip>true</maven.deploy.skip>
</code>```

set this properties maven pom file can fix this problem

The maven deploy plugin has a skip property: http://maven.apache.org/plugins/maven-deploy-plugin/deploy-mojo.html

Title: deploy war to nexus repository or not

Body:
<maven.deploy.skip>true</maven.deploy.skip>

set this properties maven pom file can fix this problem

The maven deploy plugin has a skip property: http://maven.apache.org/plugins/maven-deploy-plugin/deploy-mojo.html


问:
how to create an app tour/walkthrough in cordova?

I want to create an app tour/walkthrough for my cordova project.  I
  have tried bootstrap tour ,but it is not like native android
  tour/walkthrough .

答:
Your question is not clear, but if I get it correctly you can use this codepen

angular.module('ionicApp', ['ionic'])

.config(function($stateProvider, $urlRouterProvider) {

  $stateProvider
  .state('intro', {
    url: '/',
    templateUrl: 'templates/intro.html',
    controller: 'IntroCtrl'
  })
  .state('main', {
    url: '/main',
    templateUrl: 'templates/main.html',
    controller: 'MainCtrl'
  });

  $urlRouterProvider.otherwise("/");

})

.controller('IntroCtrl', function($scope, $state, $ionicSlideBoxDelegate) {

  // Called to navigate to the main app
  $scope.startApp = function() {
    $state.go('main');
  };
  $scope.next = function() {
    $ionicSlideBoxDelegate.next();
  };
  $scope.previous = function() {
    $ionicSlideBoxDelegate.previous();
  };

  // Called each time the slide changes
  $scope.slideChanged = function(index) {
    $scope.slideIndex = index;
  };
})

.controller('MainCtrl', function($scope, $state) {
  console.log('MainCtrl');

  $scope.toIntro = function(){
    $state.go('intro');
  }
});```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body {
  cursor: url('http://ionicframework.com/img/finger.png'), auto;
}
.slider {
  height: 100%;
}
.slider-slide {
  padding-top: 80px;
  color: #000;
  background-color: #fff;
  text-align: center;

  font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
  font-weight: 300;
}

#logo {
  margin: 30px 0px;
}

#list {
  width: 170px;
  margin: 30px auto;
  font-size: 20px;
}
#list ol {
  margin-top: 30px;
}
#list ol li {
  text-align: left;
  list-style: decimal;
  margin: 10px 0px;
}

.button.ng-hide{
  display:none;
}</code>```

    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
    <title>Ionic App</title>

    <link href="//code.ionicframework.com/nightly/css/ionic.css" rel="stylesheet">

    <ion-nav-bar class="bar-light">
        <ion-nav-back-button>
        </ion-nav-back-button>
    </ion-nav-bar>

    <ion-nav-view></ion-nav-view>

```

Body:
Your question is not clear, but if I get it correctly you can use this codepen

angular.module('ionicApp', ['ionic'])

.config(function($stateProvider, $urlRouterProvider) {

  $stateProvider
  .state('intro', {
    url: '/',
    templateUrl: 'templates/intro.html',
    controller: 'IntroCtrl'
  })
  .state('main', {
    url: '/main',
    templateUrl: 'templates/main.html',
    controller: 'MainCtrl'
  });

  $urlRouterProvider.otherwise("/");

})

.controller('IntroCtrl', function($scope, $state, $ionicSlideBoxDelegate) {

  // Called to navigate to the main app
  $scope.startApp = function() {
    $state.go('main');
  };
  $scope.next = function() {
    $ionicSlideBoxDelegate.next();
  };
  $scope.previous = function() {
    $ionicSlideBoxDelegate.previous();
  };

  // Called each time the slide changes
  $scope.slideChanged = function(index) {
    $scope.slideIndex = index;
  };
})

.controller('MainCtrl', function($scope, $state) {
  console.log('MainCtrl');

  $scope.toIntro = function(){
    $state.go('intro');
  }
});

body {
  cursor: url('http://ionicframework.com/img/finger.png'), auto;
}
.slider {
  height: 100%;
}
.slider-slide {
  padding-top: 80px;
  color: #000;
  background-color: #fff;
  text-align: center;

  font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
  font-weight: 300;
}

#logo {
  margin: 30px 0px;
}

#list {
  width: 170px;
  margin: 30px auto;
  font-size: 20px;
}
#list ol {
  margin-top: 30px;
}
#list ol li {
  text-align: left;
  list-style: decimal;
  margin: 10px 0px;
}

.button.ng-hide{
  display:none;
}

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
    <title>Ionic App</title>

    <link href="//code.ionicframework.com/nightly/css/ionic.css" rel="stylesheet">
    <script src="//code.ionicframework.com/nightly/js/ionic.bundle.js"></script>
  </head>

  <body ng-app="ionicApp">

    <ion-nav-bar class="bar-light">
        <ion-nav-back-button>
        </ion-nav-back-button>
    </ion-nav-bar>

    <ion-nav-view></ion-nav-view>

    <script id="templates/intro.html" type="text/ng-template">
      <ion-view view-title="Intro">
        <ion-nav-buttons side="left">
          <button class="button button-positive button-clear no-animation"
                  ng-click="startApp()" ng-show="!slideIndex">
            Skip Intro
          </button>
          <button class="button button-positive button-clear no-animation"
                  ng-click="previous()" ng-show="slideIndex > 0">
            Previous Slide
          </button>
        </ion-nav-buttons>
        <ion-nav-buttons side="right">
          <button class="button button-positive button-clear no-animation"
                  ng-click="next()" ng-show="slideIndex != 2">
            Next
          </button>
          <button class="button button-positive button-clear no-animation"
                  ng-click="startApp()" ng-show="slideIndex == 2">
            Start using MyApp
          </button>
        </ion-nav-buttons>
        <ion-slide-box on-slide-changed="slideChanged(index)">
          <ion-slide>
            <h3>Thank you for choosing the Awesome App!</h3>
            <div id="logo">
              <img src="http://code.ionicframework.com/assets/img/app_icon.png">
            </div>
            <p>
              We've worked super hard to make you happy.
            </p>
            <p>
              But if you are angry, too bad.
            </p>
          </ion-slide>
          <ion-slide>
            <h3>Using Awesome</h3>

            <div id="list">
              <h5>Just three steps:</h5>
              <ol>
                <li>Be awesome</li>
                <li>Stay awesome</li>
                <li>There is no step 3</li>
              </ol>
            </div>
          </ion-slide>
          <ion-slide>
            <h3>Any questions?</h3>
            <p>
              Too bad!
            </p>
          </ion-slide>
        </ion-slide-box>
      </ion-view>
    </script>

    <script id="templates/main.html" type="text/ng-template">
      <ion-view hide-back-button="true" view-title="Awesome">
        <ion-content class="padding">
          <h1>Main app here</h1>
          <button class="button" ng-click="toIntro()">Do Tutorial Again</button>
        </ion-content>
      </ion-view>
    </script>

  </body>
</html>


问:
Confluence Insert (better Insert Jira Issue) Keyboard Shortcut
What's the keyboard shortcut in Atlassian Confluence to activate the 'menu bar'?

Better still - what's the keyboard shortcut to activate the 'Insert' option on the menu?

Better still - what's the keyboard shortcut to activate the 'Insert Jira Issue/Filter' option on the Insert menu?

答:
To insert a JIRA issue. (Opens the Insert JIRA Issue dialog.): Ctrl+Shift+J

Look at Keyboard Shortcuts in Atlassian documentation.


问:
Error importing data with FoxPro OLEDB driver
I am importing some data from a FoxPro database to a Sql Server database using the FoxPro OLE-DB driver.  The approach I am taking is to loop through the FoxPro tables, select all records into a DataTable and then use SqlBulkCopy to insert that table into Sql Server.  This works fine except for a few instances where I get the following error:

```<code>System.InvalidOperationException: The provider could not determine the Decimal value. For example, the row was just created, the default for the Decimal column was not available, and the consumer had not yet set a new Decimal value.
</code>```

I have investigated this and logged which rows it appears with and the issue is that the FoxPro table has a fixed width for a numeric value.  1 is stored as 1.00 however 10 is stored as 10.0 and it is the single digit after the decimal point which is causing the issues.  Having now found the issue I am struggling to fix it though.  The following function is what I am using to convert an OLEDBReader to a DataTable:

```<code>    private DataTable FPReaderToDataTable(OleDbDataReader dr, string TableName)
    {
        DataTable dt = new DataTable();

        //get datareader schema
        DataTable SchemaTable = dr.GetSchemaTable();
        List<DataColumn> cols = new List<DataColumn>();
        if (SchemaTable != null)
        {
            foreach (DataRow drow in SchemaTable.Rows)
            {
                string columnName = drow["ColumnName"].ToString();
                DataColumn col = new DataColumn(columnName, (Type)(drow["DataType"]));
                col.Unique = (bool)drow["IsUnique"];
                col.AllowDBNull = (bool)drow["AllowDBNull"];
                col.AutoIncrement = (bool)drow["IsAutoIncrement"];
                cols.Add(col);
                dt.Columns.Add(col);
            }
        }

        //populate data
        int RowCount = 1;
        while (dr.Read())
        {
            DataRow row = dt.NewRow();

            for (int i = 0; i < cols.Count; i++)
            {
                try
                {
                    row[((DataColumn)cols[i])] = dr[i];
                }
                catch (Exception ex) {
                    if (i > 0)
                    {
                        LogImportError(TableName, cols[i].ColumnName, RowCount, ex.ToString(), dr[0].ToString());
                    }
                    else
                    {
                        LogImportError(TableName, cols[i].ColumnName, RowCount, ex.ToString(), "");
                    }
                }
            }
            RowCount++;
            dt.Rows.Add(row);
        }
        return dt;
    }
</code>```

What I would like to do is check for values that have the 1 decimal place issue but I am unable to read from the datareader at all in these cases.  I would have thought that I could have used dr.GetString(i) on the offending rows however this then returns the following error:

```<code>The provider could not determine the String value. For example, the row was just created, the default for the String column was not available, and the consumer had not yet set a new String value.
</code>```

I am unable to update the FoxPro data as the column does not allow this, how can I read the record from the DataReader and fix it?  I have tried all combinations of casting / dr.GetValue / dr.GetData and all give variations on the same error.

The structure of the FoxPro table is as follows:

```<code>Number of data records:       1664
Date of last update:          11/15/10
 Code Page:                   1252
                Field        Field Name                                                            Type                                                                                Width                           Dec                   Index   Collate                                            Nulls                               Next                               Step
                    1        AV_KEY                                                                Numeric                                                                                6                                                   Asc   Machine                                               No
                    2        AV_TEAM                                                               Numeric                                                                                6                                                                                No
                    3        AV_DATE                                                               Date                                                                                8                                                                                No
                    4        AV_CYCLE                                                              Numeric                                                                                2                                                                                No
                    5        AV_DAY                                                                Numeric                                                                                1                                                                                No
                    6        AV_START                                                              Character                                                                                8                                                                                No
                    7        AV_END                                                                Character                                                                                8                                                                                No
                    8        AV_SERVICE                                                            Numeric                                                                                6                                                                                No
                    9        AV_SYS                                                                Character                                                                                1                                                                                No
                   10        AV_LENGTH                                                             Numeric                                                                                4                             2                                                                                No
                   11        AV_CWEEKS                                                             Numeric                                                                                2                                                                                No
                   12        AV_CSTART                                                             Date                                                                                8                                                                                No
** Total **                                                                                61
</code>```

It is the av_length column which is causing the problem

答:
From your listed structure of the table, that IS CORRECT what it is doing.  In VFP for the table structure listed, the AV_LENGTH is of type numeric, length of 4, 2 being allocated for decimal positons.  So it will at MOST have a value of "9.99".  VFP forces the input of the numeric field to a maximum of 2 decimal positions, 1 for decimal point and the rest as whole number portion.

The rest of the numeric based fields are Numeric with a length, but NO decimal positions which indicates they are all WHOLE numbers with no decimal position hence would qualify as integer data types.  Numeric with decimal should go into a float or double column type.

That being said, I don't know HOW you are even getting a 10.0 value in a numeric 4, 2 decimal.  This is the FIRST time I've ever seen forcing a number larger than the allocated intent of the structure being saved actually be stored in the field like this.

ContentLicense: CC BY-SA 2.5

Body:
I am importing some data from a FoxPro database to a Sql Server database using the FoxPro OLE-DB driver.  The approach I am taking is to loop through the FoxPro tables, select all records into a DataTable and then use SqlBulkCopy to insert that table into Sql Server.  This works fine except for a few instances where I get the following error:

System.InvalidOperationException: The provider could not determine the Decimal value. For example, the row was just created, the default for the Decimal column was not available, and the consumer had not yet set a new Decimal value.

I have investigated this and logged which rows it appears with and the issue is that the FoxPro table has a fixed width for a numeric value.  1 is stored as 1.00 however 10 is stored as 10.0 and it is the single digit after the decimal point which is causing the issues.  Having now found the issue I am struggling to fix it though.  The following function is what I am using to convert an OLEDBReader to a DataTable:

    private DataTable FPReaderToDataTable(OleDbDataReader dr, string TableName)
    {
        DataTable dt = new DataTable();

        //get datareader schema
        DataTable SchemaTable = dr.GetSchemaTable();
        List<DataColumn> cols = new List<DataColumn>();
        if (SchemaTable != null)
        {
            foreach (DataRow drow in SchemaTable.Rows)
            {
                string columnName = drow["ColumnName"].ToString();
                DataColumn col = new DataColumn(columnName, (Type)(drow["DataType"]));
                col.Unique = (bool)drow["IsUnique"];
                col.AllowDBNull = (bool)drow["AllowDBNull"];
                col.AutoIncrement = (bool)drow["IsAutoIncrement"];
                cols.Add(col);
                dt.Columns.Add(col);
            }
        }

        //populate data
        int RowCount = 1;
        while (dr.Read())
        {
            DataRow row = dt.NewRow();

            for (int i = 0; i < cols.Count; i++)
            {
                try
                {
                    row[((DataColumn)cols[i])] = dr[i];
                }
                catch (Exception ex) {
                    if (i > 0)
                    {
                        LogImportError(TableName, cols[i].ColumnName, RowCount, ex.ToString(), dr[0].ToString());
                    }
                    else
                    {
                        LogImportError(TableName, cols[i].ColumnName, RowCount, ex.ToString(), "");
                    }
                }
            }
            RowCount++;
            dt.Rows.Add(row);
        }
        return dt;
    }

What I would like to do is check for values that have the 1 decimal place issue but I am unable to read from the datareader at all in these cases.  I would have thought that I could have used dr.GetString(i) on the offending rows however this then returns the following error:

The provider could not determine the String value. For example, the row was just created, the default for the String column was not available, and the consumer had not yet set a new String value.

I am unable to update the FoxPro data as the column does not allow this, how can I read the record from the DataReader and fix it?  I have tried all combinations of casting / dr.GetValue / dr.GetData and all give variations on the same error.

The structure of the FoxPro table is as follows:

Number of data records:       1664
Date of last update:          11/15/10
 Code Page:                   1252
                Field        Field Name                                                            Type                                                                                Width                           Dec                   Index   Collate                                            Nulls                               Next                               Step
                    1        AV_KEY                                                                Numeric                                                                                6                                                   Asc   Machine                                               No
                    2        AV_TEAM                                                               Numeric                                                                                6                                                                                No
                    3        AV_DATE                                                               Date                                                                                8                                                                                No
                    4        AV_CYCLE                                                              Numeric                                                                                2                                                                                No
                    5        AV_DAY                                                                Numeric                                                                                1                                                                                No
                    6        AV_START                                                              Character                                                                                8                                                                                No
                    7        AV_END                                                                Character                                                                                8                                                                                No
                    8        AV_SERVICE                                                            Numeric                                                                                6                                                                                No
                    9        AV_SYS                                                                Character                                                                                1                                                                                No
                   10        AV_LENGTH                                                             Numeric                                                                                4                             2                                                                                No
                   11        AV_CWEEKS                                                             Numeric                                                                                2                                                                                No
                   12        AV_CSTART                                                             Date                                                                                8                                                                                No
** Total **                                                                                61

It is the av_length column which is causing the problem


问:
What does this Xamarin Profiler value mean?
I'm using the Xamarin Profiler for the first time. I want to check how much memory is used by my application(iOS). What does "Max 49 MB" mean? Is this the memory that my application is using right now? What is the difference between memory allocated(5,8 MB) and "Max 49 MB"?

In addition, the value(49 MB) slowly increases every few seconds. But my application is not changing its state, my application just draws one sprite all the time. Why is the value increasing all the time?
I'm testing the application on my iPhone device.

Profiler screenshot: Profiler

答:
"Memory allocated" includes allocations size that may not be in use (but that they have been) during all profiler session.Max value refers to Working set: "working set" basically is the current physical memory being used, it may include non managed memory. working set is a perf counter. therefore, the working set includes the memory allocated + native memory -currently used-

cheers


问:
Gave nobody user owner ship of directory, now missing. Can I revert back by just doing the opposite command?
I upgraded my server from easy apache 3 to 4 and gained some permission issues, I ran:

chown -R nobody /home/myuser/public_html

in the server, which corrected this, now that directory is no where to be seen on cpanel but the site is still live.

Can I put the directory back but simply using:

chown -R myuser /home/nobody/public_html when ssh'd in as root?

Self managed server so my host won't help me.

Thanks Brad

答:
Yes, you can change the permission using below command.

chown -R myuser /home/myuser/public_html


问:
Is there a way to disable UpdateProgress for certain async postbacks?
I have an UpdateProgress control, that shows as an overlay (using CSS) for all async events for an update panel. Now, for certain EXPAND/COLLAPSE row command events, i just dont want to show that updateprogress.

Is there a way?

答:
I found this works for me where a Response.Redirect prevents the original page being reloaded & therefore the UpdateProgress does not get turned off..

On the offending control add

```<code>OnClientClick="disableProgress()"
</code>```

and then put this javascript on the page

```<code><script type="text/javascript">

function disableProgress() {

var updateProgress = $get('<%=UpdateProgress1.ClientID%>');
var originalID = updateProgress.control._associatedUpdatePanelId;
updateProgress.control._associatedUpdatePanelId = 'dummyId';

setTimeout(function () { updateProgress.control._associatedUpdatePanelId = originalID; }, 1000);

}
</script>
</code>```

This temporarily disables the UpdateProgress control and then asynchronously reactivates it client-side after 1 second.

Body:
I found this works for me where a Response.Redirect prevents the original page being reloaded & therefore the UpdateProgress does not get turned off..

On the offending control add

OnClientClick="disableProgress()"

and then put this javascript on the page

<script type="text/javascript">

function disableProgress() {

var updateProgress = $get('<%=UpdateProgress1.ClientID%>');
var originalID = updateProgress.control._associatedUpdatePanelId;
updateProgress.control._associatedUpdatePanelId = 'dummyId';

setTimeout(function () { updateProgress.control._associatedUpdatePanelId = originalID; }, 1000);

}
</script>

This temporarily disables the UpdateProgress control and then asynchronously reactivates it client-side after 1 second.


问:
Install packages locally with npm
I am new with Node and npm, and when I try to install packages locally, all of the dependencies for that specific package gets installed in the main nodule_modules folder.

It looks like this

LOCALLY

And if I install them globally it looks like this

GLOBALLY

I think I should mention the fact that the folder where I try to install locally is on Desktop.

答:
If you need to install specific dependancies for a project you are working on then do it locally:

```<code>npm install <packagename>
</code>```

If you need something that you can run from the commandline such as grunt or phantomjs (etc..) then install it globally:

```<code>npm install -g <packagename>
</code>```

Title: Install packages locally with npm

Body:
If you need to install specific dependancies for a project you are working on then do it locally:

npm install <packagename>

If you need something that you can run from the commandline such as grunt or phantomjs (etc..) then install it globally:

npm install -g <packagename>


问:
Error establishing a database connection on wordpress
i have a blog with wordpress but sometimes i have problem with that

i got blow error

Error establishing a database connection
This either means that the username and password information in your wp-config.php file is incorrect or we can't contact the database server at %s. This could mean your host's database server is down.

Are you sure you have the correct username and password?
Are you sure that you have typed the correct hostname?
Are you sure that the database server is running?
If you're unsure what these terms mean you should probably contact your host. If you still need help you can always visit the WordPress Support Forums

and this is my config file

```<code>define('WP_HOME','http://www.mysite.com');
define('WP_SITEURL','http://www.mysite.come');
define('DB_NAME', 'mydbname');

/** MySQL database username */
define('DB_USER', 'dbusername');

/** MySQL database password */
define('DB_PASSWORD', 'dbpassword');

/** MySQL hostname */
define('DB_HOST', 'mysite.com');
</code>```

why i got this error sometimes what do you think about this problem?

i contact with my admins server and they said "we dont have any problem with server and mysql service"

does my server have problem or my config have problem?

答: If you get it 'sometimes' then it means the PHP Scrpt wasn't able to connect to the database. One of the various reasons could be database server down for a while.

Body:
i have a blog with wordpress but sometimes i have problem with that

i got blow error

Error establishing a database connection
This either means that the username and password information in your wp-config.php file is incorrect or we can't contact the database server at %s. This could mean your host's database server is down.

Are you sure you have the correct username and password?
Are you sure that you have typed the correct hostname?
Are you sure that the database server is running?
If you're unsure what these terms mean you should probably contact your host. If you still need help you can always visit the WordPress Support Forums

and this is my config file

define('WP_HOME','http://www.mysite.com');
define('WP_SITEURL','http://www.mysite.come');
define('DB_NAME', 'mydbname');

/** MySQL database username */
define('DB_USER', 'dbusername');

/** MySQL database password */
define('DB_PASSWORD', 'dbpassword');

/** MySQL hostname */
define('DB_HOST', 'mysite.com');

why i got this error sometimes what do you think about this problem?

i contact with my admins server and they said "we dont have any problem with server and mysql service"

does my server have problem or my config have problem?


问:
HttpClient HttpResponseMessage LastModified date of file
I am using the C# HttpClient to simulate a request to download a CSV file from a server.  I need to check the LastModified dateof the file against the LastModified date of the previous file I downloaded to check if the file has changed.

HttpClient gets a HttpResponseMessage when I make the request, but every time I check

```<code>response.Headers.Date.Value
</code>```

I get the current Date/Time that the request was made.  I understand that if the page I'm requesting the file from is generated by a DB or by some other dynamic method, the LastModified value will be the time that the request was made.

However, I have tried the same process using the older HttpWebRequest/Response and I found that

```<code>response.Headers[HttpResponseHeader.LastModified]
</code>```

Will return the date that the file was last changed, e.g. the 2 different methods return different dates, HttpWebResponse gives a date of 1/12/2017, and HttpResponseMessage gives a date of 3/30/2017.

How can I get the file change date using HttpWebResponse?

答:
From https://social.msdn.microsoft.com/Forums/windowsapps/en-US/c830971a-e60f-4759-ba2a-42638b0afad0/uwp-lastmodifiedheader-invalid?forum=wpdevelop

"The Last-Modified HTTP header is treated as part of the HTTP response content rather than the HTTP response itself,"

I was able to pull the LastModified date by accessing the Content of the response headers, not the headers themselves

```<code>DateTime lastModified = result.Content.Headers.LastModified;
</code>```

Body:
I am using the C# HttpClient to simulate a request to download a CSV file from a server.  I need to check the LastModified dateof the file against the LastModified date of the previous file I downloaded to check if the file has changed.

HttpClient gets a HttpResponseMessage when I make the request, but every time I check

response.Headers.Date.Value

I get the current Date/Time that the request was made.  I understand that if the page I'm requesting the file from is generated by a DB or by some other dynamic method, the LastModified value will be the time that the request was made.

However, I have tried the same process using the older HttpWebRequest/Response and I found that

response.Headers[HttpResponseHeader.LastModified]

Will return the date that the file was last changed, e.g. the 2 different methods return different dates, HttpWebResponse gives a date of 1/12/2017, and HttpResponseMessage gives a date of 3/30/2017.

How can I get the file change date using HttpWebResponse?

Body:
From https://social.msdn.microsoft.com/Forums/windowsapps/en-US/c830971a-e60f-4759-ba2a-42638b0afad0/uwp-lastmodifiedheader-invalid?forum=wpdevelop

"The Last-Modified HTTP header is treated as part of the HTTP response content rather than the HTTP response itself,"

I was able to pull the LastModified date by accessing the Content of the response headers, not the headers themselves

DateTime lastModified = result.Content.Headers.LastModified;


问:
Datatable Methods not working after adding Row with append
Ive got a problem to solve. With .append() I do add new rows which have input fields. But the problem is, that after appending new rows no methods work on them. No methods like search, responsive button etc.

I tried a lot but I couldnt figure it out...After clicking on a button a new Row gets added to the #table.

```<code>var poAddRowTable = $('#table').DataTable();
$('button').on('click', function () {
    addRowFunc(true)
});

addRowFunc = function () {
    var previousRow = $('#table tr:last');
    var newRow = $(previousRow).clone(true, true);

    $('#table tbody').append(newRow);
    $("html, body").scrollTop($(document).height());
}
</code>```

答:
You should consider to use DataTable.row.add() for adding a new row to the data table.

Your addRowFunc should be updated like this

```<code>addRowFunc = function () {

    // Clone data from last row
    var lastRow = $('#table tr:last');
    var newRowdata = [];
    $('#table tr:last').find('td').each(function() {
        newRowdata.push($(this).text());
    });

    // Add new row to table
    poAddRowTable.row.add(newRowdata).draw();

    $("html, body").scrollTop($(document).height());
}
</code>```

Body:
Ive got a problem to solve. With .append() I do add new rows which have input fields. But the problem is, that after appending new rows no methods work on them. No methods like search, responsive button etc.

I tried a lot but I couldnt figure it out...After clicking on a button a new Row gets added to the #table.

var poAddRowTable = $('#table').DataTable();
$('button').on('click', function () {
    addRowFunc(true)
});

addRowFunc = function () {
    var previousRow = $('#table tr:last');
    var newRow = $(previousRow).clone(true, true);

    $('#table tbody').append(newRow);
    $("html, body").scrollTop($(document).height());
}

Body:
You should consider to use DataTable.row.add() for adding a new row to the data table.

Your addRowFunc should be updated like this

addRowFunc = function () {

    // Clone data from last row
    var lastRow = $('#table tr:last');
    var newRowdata = [];
    $('#table tr:last').find('td').each(function() {
        newRowdata.push($(this).text());
    });

    // Add new row to table
    poAddRowTable.row.add(newRowdata).draw();

    $("html, body").scrollTop($(document).height());
}


问:
How to extract multiple array & insert data to database
How to extract below array & insert 3 data & 2 query

Extract this array & give me 2 row & 3 columns

```<code>Array
(
    [name] => Array
        (
            [0] => AAAAA
            [1] => BBBBB
        )

    [number] => Array
        (
            [0] => 7878787878
            [1] => 9898989898
        )

    [email] => Array
        (
            [0] => a@gmail.com
            [1] => b@gmail.com
        )

)
</code>```

We need Below query by foreach loop

```<code>INSERT INTO `contact_person` SET customer_id='131',cp_name='AAAAA',cp_phone='7878787878',cp_email='a@gmail.com

INSERT INTO `contact_person` SET customer_id='131',cp_name='BBBBB',cp_phone='9898989898',cp_email='b@gmail.com'
</code>```

答:
consider a for loop like so:

```<code>$length = count($yourarray['name']);
$queries = new array();
for(i = 0; i < $length; i++) {
    $queries[] = "INSERT INTO `contact_person` SET customer_id='131',
                 cp_name='" . $yourarray['name'][i] . "',
                 cp_phone='" . $yourarray['number'][i] . "',
                 cp_email='" . $yourarray['email'][i] " . "'";
}
</code>```

This will create all the insert queries and put them in an array named $queries

NOTE: This code assumes you always have the same amount of names, numbers and emails

Body:
How to extract below array & insert 3 data & 2 query

Extract this array & give me 2 row & 3 columns

Array
(
    [name] => Array
        (
            [0] => AAAAA
            [1] => BBBBB
        )

    [number] => Array
        (
            [0] => 7878787878
            [1] => 9898989898
        )

    [email] => Array
        (
            [0] => a@gmail.com
            [1] => b@gmail.com
        )

)

We need Below query by foreach loop

INSERT INTO `contact_person` SET customer_id='131',cp_name='AAAAA',cp_phone='7878787878',cp_email='a@gmail.com

INSERT INTO `contact_person` SET customer_id='131',cp_name='BBBBB',cp_phone='9898989898',cp_email='b@gmail.com'

Body:
consider a for loop like so:

$length = count($yourarray['name']);
$queries = new array();
for(i = 0; i < $length; i++) {
    $queries[] = "INSERT INTO `contact_person` SET customer_id='131',
                 cp_name='" . $yourarray['name'][i] . "',
                 cp_phone='" . $yourarray['number'][i] . "',
                 cp_email='" . $yourarray['email'][i] " . "'";
}

This will create all the insert queries and put them in an array named $queries

NOTE: This code assumes you always have the same amount of names, numbers and emails


问:
Angular2 NgFor only supports binding to Iterables such as Arrays error
I have a model:

```<code>export class CoreGoalModel {
  constructor(

    public title: string,
    public image: string,

    ){}
}
</code>```

My service:

```<code>  getGoals(): Observable<CoreGoalModel[]> {

    let headers = new Headers({ 'Access-Control-Allow-Origin': '*' });
    let options = new RequestOptions({ headers: headers });

    return this.http.get(this.base_url + 'coregoal', options)
    .map(this.extractData)
    .catch(this.handleError);
  }

  private extractData(res: Response) {
    let body = res.json();
    return body.data || { };
  }
</code>```

And then in my component:

```<code>ngOnInit() {

    this.homeService.getGoals()
    .subscribe(
                 goals => this.coreGoals = goals,
                 error =>  this.errorMessage = <any>error);

}
</code>```

I then am binding this in my template as:

```<code><ul>
    <li *ngFor="let goal of coreGoals">
        {{goal.title}}
    </li>
</ul>
</code>```

My actual response from server:

```<code>[{"coreGoalId":1,"title":"Core goal 1","infrastructure":"Sample Infrastructure","audience":"People","subGoals":null,"benefits":[{"benefitId":1,"what":"string","coreGoalId":1}],"effects":null,"steps":null,"images":[{"imagelId":1,"base64":"/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcU\nFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/2wBDAQcHBwoIChMKChMoGhYaKCgoKCgo\nKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCj/wgARCAIWAe4DASIA\nAhEBAxEB/8QAHAABAAIDAQEB"}]}]
</code>```

This throws me error Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays.

What am I doing wrong? I simply would like to iterate over coreGoals properties and also access it's children and their properties.

答:
Your error is here:

private extractData(res: Response) {
  let body = res.json();
  return body.data || { }; // error
}
```

<p>Your response has no object named <code>data</code>, so remove <code>data</code> and it should work:</p>

<pre class="lang-ts prettyprint-override"><code>private extractData(res: Response) {
  let body = res.json();
  return body || { }; // here
}
</code>```

Body:
I have a model:

export class CoreGoalModel {
  constructor(

    public title: string,
    public image: string,

    ){}
}

My service:

  getGoals(): Observable<CoreGoalModel[]> {

    let headers = new Headers({ 'Access-Control-Allow-Origin': '*' });
    let options = new RequestOptions({ headers: headers });

    return this.http.get(this.base_url + 'coregoal', options)
    .map(this.extractData)
    .catch(this.handleError);
  }

  private extractData(res: Response) {
    let body = res.json();
    return body.data || { };
  }

And then in my component:

ngOnInit() {

    this.homeService.getGoals()
    .subscribe(
                 goals => this.coreGoals = goals,
                 error =>  this.errorMessage = <any>error);

}

I then am binding this in my template as:

        {{goal.title}}

My actual response from server:

[{"coreGoalId":1,"title":"Core goal 1","infrastructure":"Sample Infrastructure","audience":"People","subGoals":null,"benefits":[{"benefitId":1,"what":"string","coreGoalId":1}],"effects":null,"steps":null,"images":[{"imagelId":1,"base64":"/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcU\nFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/2wBDAQcHBwoIChMKChMoGhYaKCgoKCgo\nKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCj/wgARCAIWAe4DASIA\nAhEBAxEB/8QAHAABAAIDAQEB"}]}]

This throws me error Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays.

What am I doing wrong? I simply would like to iterate over coreGoals properties and also access it's children and their properties.

Body:
Your error is here:

private extractData(res: Response) {
  let body = res.json();
  return body.data || { }; // error
}

Your response has no object named data, so remove data and it should work:

private extractData(res: Response) {
  let body = res.json();
  return body || { }; // here
}


问:
Why it didn't print?
simple asm for  ptint the string "/bin/sh" and then exit

```<code>    global _start:
_start:
    jmp what
are:
    mov rbx,0x68732f6e69622fff
    shr rbx,0x8
    push rbx
    mov rsi,rsp
    mov dl,0x8
    xor rax,rax
    mov al,1
    syscall
    xor rax,rax
    mov al,0x3c
    syscall
what:
    call are
</code>```

nasm -f elf64 test.asm
ld -o test test.o

Run as expected .

but use in shellcode :

```<code>const char shellcode[] = "\x48\xbb\xff\x2f\x62\x69\x6e\x2f\x73\x68\x48\xc1\xeb\x08\x53\x48\x89\xe6\xb2\x08\x48\x31\xc0\xb0\x01\x0f\x05\x48\x31\xc0\xb0\x3c\x0f\x05";

int main(){
    ( (void (*)(void))&shellcode )();
    return 0;
}
</code>```

gcc -fno-stack-protector -z execstack -o test2 test.c

it prints nothing.

答:
Your code assumes rdi == 0, 1, or 2, and that 56 high bits of rdx are zero. This happens to be true at the start of the process. It just isn't true at the point where you call your shellcode.

To fix, you need to set rdi to 1 (if you want the output to be to standard output) or 2 (for output to go to standard error), and set rdx 8.

The syscall ABI in Linux on x86-64 is

syscall number in rax

char, short, int, long, and pointer parameters in rdi, rsi, rdx, r10, r8, and r9 registers, respectively

return value will be in rax; most syscalls return -errno if an error occurs

(the actual errno variable is a C library construct, and the kernel does not know anything about it)

rcx and r11 are clobbered (may be modified by the syscall); all other registers are preserved

Thus, for write (SYS_write == __NR_write == 1) you set rax == 1; rdi == descriptor number (STDOUT_FILENO == 1 for standard output, STDERR_FILENO == 2 for standard error); rsi == pointer to the data to be written, and rdx == the number of chars to be written.

Title: Why it didn't print?

Body:
simple asm for  ptint the string "/bin/sh" and then exit

    global _start:
_start:
    jmp what
are:
    mov rbx,0x68732f6e69622fff
    shr rbx,0x8
    push rbx
    mov rsi,rsp
    mov dl,0x8
    xor rax,rax
    mov al,1
    syscall
    xor rax,rax
    mov al,0x3c
    syscall
what:
    call are

nasm -f elf64 test.asm
ld -o test test.o

Run as expected .

but use in shellcode :

const char shellcode[] = "\x48\xbb\xff\x2f\x62\x69\x6e\x2f\x73\x68\x48\xc1\xeb\x08\x53\x48\x89\xe6\xb2\x08\x48\x31\xc0\xb0\x01\x0f\x05\x48\x31\xc0\xb0\x3c\x0f\x05";

int main(){
    ( (void (*)(void))&shellcode )();
    return 0;
}

gcc -fno-stack-protector -z execstack -o test2 test.c

it prints nothing.


问:
Iterator and printing details
Hey all. I've been asked to create a method that uses an iterator to print details of 'lots'. I'm able to create an iterator that prints all of the details, however, for any lots that haven't been bought, a message should print out this fact and I'm unsure how I can add that code in. It is the public void close method I'm focusing on. This is what I have so far. Help is greatly appreciated.</p>

```<code>public class Auction{

    // The list of Lots in this auction.
    private final ArrayList<Lot> lots;
    // The number that will be given to the next lot entered
    // into this auction.
    private int nextLotNumber;

    /**
     * Create a new auction.
     */
    public Auction(){
        lots = new ArrayList<Lot>();
        nextLotNumber = 1;
    }

    /**
     * Enter a new lot into the auction.
     *
     * @param description
     *            A description of the lot.
     */
    public void enterLot(final String description){
        lots.add(new Lot(nextLotNumber, description));
        nextLotNumber++;
    }

    /**
     * Show the full list of lots in this auction.
     */
    public void showLots(){
        for(final Lot lot : lots){
            System.out.println(lot.toString());
        }
    }

    public void close(){
        final Iterator<Lot> it = lots.iterator();
        while(it.hasNext()){

        }
    }

    /**
     * Bid for a lot. A message indicating whether the bid is
     * successful or not is printed.
     *
     * @param number
     *            The lot number being bid for.
     * @param bidder
     *            The person bidding for the lot.
     * @param value
     *            The value of the bid.
     */
    public void bidFor(final int lotNumber,
        final Person bidder,
        final long value){
        final Lot selectedLot = getLot(lotNumber);
        if(selectedLot != null){
            final boolean successful =
                selectedLot.bidFor(new Bid(bidder, value));
            if(successful){
                System.out.println("The bid for lot number " + lotNumber
                    + " was successful.");
            } else{
                // Report which bid is higher.
                final Bid highestBid = selectedLot.getHighestBid();
                System.out.println("Lot number: " + lotNumber
                    + " already has a bid of: " + highestBid.getValue());
            }
        }
    }

}
</code>```

答:
Does the Lot class have a flag indicating if it's purchased or not?  If so then

```<code>for(final Lot lot : lots){
   if (!lot.purchased) {
     System.out.println("not bought");
   }
}
</code>```

BTW - I noticed you're using the pre for-each style iterator in the close method. There's no reason to do this since you'll have access to individual Lot instances in the for-each also.

Title: Iterator and printing details

Body:
Hey all. I've been asked to create a method that uses an iterator to print details of 'lots'. I'm able to create an iterator that prints all of the details, however, for any lots that haven't been bought, a message should print out this fact and I'm unsure how I can add that code in. It is the public void close method I'm focusing on. This is what I have so far. Help is greatly appreciated.

public class Auction{

    // The list of Lots in this auction.
    private final ArrayList<Lot> lots;
    // The number that will be given to the next lot entered
    // into this auction.
    private int nextLotNumber;

    /**
     * Create a new auction.
     */
    public Auction(){
        lots = new ArrayList<Lot>();
        nextLotNumber = 1;
    }

    /**
     * Enter a new lot into the auction.
     *
     * @param description
     *            A description of the lot.
     */
    public void enterLot(final String description){
        lots.add(new Lot(nextLotNumber, description));
        nextLotNumber++;
    }

    /**
     * Show the full list of lots in this auction.
     */
    public void showLots(){
        for(final Lot lot : lots){
            System.out.println(lot.toString());
        }
    }

    public void close(){
        final Iterator<Lot> it = lots.iterator();
        while(it.hasNext()){

        }
    }

    /**
     * Bid for a lot. A message indicating whether the bid is
     * successful or not is printed.
     *
     * @param number
     *            The lot number being bid for.
     * @param bidder
     *            The person bidding for the lot.
     * @param value
     *            The value of the bid.
     */
    public void bidFor(final int lotNumber,
        final Person bidder,
        final long value){
        final Lot selectedLot = getLot(lotNumber);
        if(selectedLot != null){
            final boolean successful =
                selectedLot.bidFor(new Bid(bidder, value));
            if(successful){
                System.out.println("The bid for lot number " + lotNumber
                    + " was successful.");
            } else{
                // Report which bid is higher.
                final Bid highestBid = selectedLot.getHighestBid();
                System.out.println("Lot number: " + lotNumber
                    + " already has a bid of: " + highestBid.getValue());
            }
        }
    }

}

Body:
Does the Lot class have a flag indicating if it's purchased or not?  If so then

for(final Lot lot : lots){
   if (!lot.purchased) {
     System.out.println("not bought");
   }
}

BTW - I noticed you're using the pre for-each style iterator in the close method. There's no reason to do this since you'll have access to individual Lot instances in the for-each also.


问:
Store byte value in char*
I've got byte value like 0x1F and i would like to store this hexa value in a char* like char*="1F"
this is my code:</p>

```<code>uint8_t *pBlockAddr=0x1F;
printf("%02X", pBlockAddr); //Print 1F
</code>```

答:
You probably want this:</p>

```<code>char mystring[3];
snprintf(mystring, sizeof(mystring), "%02X", 0x1f);

printf("%s\n", mystring);
</code>```

Title: Store byte value in char*

Body:
I've got byte value like 0x1F and i would like to store this hexa value in a char* like char*="1F"
this is my code:

uint8_t *pBlockAddr=0x1F;
printf("%02X", pBlockAddr); //Print 1F

Body:
You probably want this:

char mystring[3];
snprintf(mystring, sizeof(mystring), "%02X", 0x1f);

printf("%s\n", mystring);


问:
Change label value in UICollectionView without reload data?
I'm using swift 2.2 and i have a collectionview inside cell ia hve a label.I want to change a label text value in UICollection view on a button click without using reloading whole uiCollection view.
I can't use collectionView.reloadData() for my scenario. I want a do it without using it. Just to update one label in a particular item in collectionview.
Any help??</p>

答:
You can do it by this way:

```<code>let indexPath = NSIndexPath(forRow: row, inSection: 0)
tableView.reloadRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)
</code>```

It will not reload your complete UICollectionView.

Body:
You can do it by this way:

let indexPath = NSIndexPath(forRow: row, inSection: 0)
tableView.reloadRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)

It will not reload your complete UICollectionView.


问:
Can't install StarUML in Ubuntu 16.04
I’m using ubuntu 16.04 - 64 bit. I tried to install Start UML with .deb file and got this message from Ubuntu Software:

```<code>This software comes from a 3rd party and may contain non-free components
</code>```

Then I trying to install with dpkg, and got this:

```<code>$ sudo dpkg -i StarUML-v2.7.0-64-bit.deb
Selecting previously unselected package staruml.
(Reading database ... 212003 files and directories currently installed.)
Preparing to unpack StarUML-v2.7.0-64-bit.deb ...
Unpacking staruml (2.7.0) ...
dpkg: dependency problems prevent configuration of staruml:
 staruml depends on libgcrypt11 (>= 1.4.5); however:
  Package libgcrypt11 is not installed.

dpkg: error processing package staruml (--install):
 dependency problems - leaving unconfigured
Processing triggers for hicolor-icon-theme (0.15-0ubuntu1) ...
Errors were encountered while processing:
 staruml
</code>```

Could you help me to resolve this issue?

答:
Download

```<code>wget http://security.ubuntu.com/ubuntu/pool/main/libg/libgcrypt11/libgcrypt11_1.5.3-2ubuntu4_amd64.deb
</code>```

Install lib with dpkg

```<code>sudo dpkg -i libgcrypt11_1.5.3-2ubuntu4_amd64.deb
</code>```

Install StarUML with dpkg

```<code>sudo dpkg -i StarUML-v2.8.0-64-bit.deb
</code>```

Title: Can't install StarUML in Ubuntu 16.04

Body:
I’m using ubuntu 16.04 - 64 bit. I tried to install Start UML with .deb file and got this message from Ubuntu Software:

This software comes from a 3rd party and may contain non-free components

Then I trying to install with dpkg, and got this:

$ sudo dpkg -i StarUML-v2.7.0-64-bit.deb
Selecting previously unselected package staruml.
(Reading database ... 212003 files and directories currently installed.)
Preparing to unpack StarUML-v2.7.0-64-bit.deb ...
Unpacking staruml (2.7.0) ...
dpkg: dependency problems prevent configuration of staruml:
 staruml depends on libgcrypt11 (>= 1.4.5); however:
  Package libgcrypt11 is not installed.

dpkg: error processing package staruml (--install):
 dependency problems - leaving unconfigured
Processing triggers for hicolor-icon-theme (0.15-0ubuntu1) ...
Errors were encountered while processing:
 staruml

Could you help me to resolve this issue?

Body:
Download

wget http://security.ubuntu.com/ubuntu/pool/main/libg/libgcrypt11/libgcrypt11_1.5.3-2ubuntu4_amd64.deb

Install lib with dpkg

sudo dpkg -i libgcrypt11_1.5.3-2ubuntu4_amd64.deb

Install StarUML with dpkg

sudo dpkg -i StarUML-v2.8.0-64-bit.deb


问:
How does BinaryFormatter.Deserialize create new objects?
When BinaryFormatter deserializes a stream into objects, it appears to create new objects without calling constructors.

How is it doing this? And why? Is there anything else in .NET that does this?

Here's a demo:

```<code>[Serializable]
public class Car
{
    public static int constructionCount = 0;

    public Car()
    {
        constructionCount++;
    }
}

public class Test
{
    public static void Main(string[] args)
    {
        // Construct a car
        Car car1 = new Car();

        // Serialize and then deserialize to create a second, identical car
        MemoryStream stream = new MemoryStream();
        BinaryFormatter formatter = new BinaryFormatter();
        formatter.Serialize(stream, car1);
        stream.Seek(0, SeekOrigin.Begin);
        Car car2 = (Car)formatter.Deserialize(stream);

        // Wait, what happened?
        Console.WriteLine("Cars constructed: " + Car.constructionCount);
        if (car2 != null && car2 != car1)
        {
            Console.WriteLine("But there are actually two.");
        }
    }
}
</code>```

Output:

Cars constructed: 1

But there are actually two.

答:
There are two things calling a constructor does (or at least should do).

One is to set aside a certain amount of memory for the object and does all the housekeeping necessary for it to be an object to the rest of the .NET world (note certain amount of handwaving in this explanation).

The other is to put the object into a valid initial state, perhaps based on parameters - this is what the actual code in the constructor will do.

Deserialisation does much the same thing as the first step by calling FormatterServices.GetUninitializedObject, and then does much the same thing as the second step by setting the values for fields to be equivalent to those that were recorded during serialisation (which may require deserialising other objects to be said values).

Now, the state that deserialisation is putting the object into may not correspond to that possible by any constructor. At best it will be wasteful (all values set by the constructor will be overwritten) and at worse it could be dangerous (constructor has some side-effect). It could also just be impossible (only constructor is one that takes parameters - serialisation has no way of knowing what arguments to use).

You could look at it as a special sort of constructor only used by deserialisation (OO purists will - and should - shudder at the idea of a constructor that doesn't construct, I mean this as an analogy only, if you know C++ think of the way overriding new works as far as memory goes and you've an even better analogy, though still just an analogy).

Now, this can be a problem in some cases - maybe we have readonly fields that can only be set by a constructor, or maybe we have side-effects that we want to happen.

A solution to both is to override serialisation behaviour with ISerializable. This will serialise based on a call to ISerializable.GetObjectData and then call a particular constructor with SerializationInfo and StreamingContext fields to deserialise (said constructor can even be private - meaning most other code won't even see it). Hence if we can deserialise readonly fields and have any side-effects we want (we can also do all manner of things to control just what is serialised and how).

If we just care about ensuring some side-effect happens on deserialisation that would happen on construction, we can implement IDeserializationCallback and we will have IDeserializationCallback.OnDeserialization called when deserialisation is complete.

As for other things that do the same thing as this, there are other forms of serialisation in .NET but that's all I know of. It is possible to call FormatterServices.GetUninitializedObject yourself but barring a case where you have a strong guarantee that subsequent code will put the object produced into a valid state (i.e. precisely the sort of situation you are in when deserialising an object from data produced by serialising the same sort of object) doing such is fraught and a good way to produce a really hard to diagnose bug.

Body:
When BinaryFormatter deserializes a stream into objects, it appears to create new objects without calling constructors.

How is it doing this? And why? Is there anything else in .NET that does this?

Here's a demo:

[Serializable]
public class Car
{
    public static int constructionCount = 0;

    public Car()
    {
        constructionCount++;
    }
}

public class Test
{
    public static void Main(string[] args)
    {
        // Construct a car
        Car car1 = new Car();

        // Serialize and then deserialize to create a second, identical car
        MemoryStream stream = new MemoryStream();
        BinaryFormatter formatter = new BinaryFormatter();
        formatter.Serialize(stream, car1);
        stream.Seek(0, SeekOrigin.Begin);
        Car car2 = (Car)formatter.Deserialize(stream);

        // Wait, what happened?
        Console.WriteLine("Cars constructed: " + Car.constructionCount);
        if (car2 != null && car2 != car1)
        {
            Console.WriteLine("But there are actually two.");
        }
    }
}

Output:

Cars constructed: 1

But there are actually two.


问:
Get a 4 bytes hex string with stringWithFormat
Until now, I have this code :

```<code>NSString *hex = [NSString stringWithFormat:@"%lX", crc32Result];
</code>```

Which formats an int value into a hex (string) value.

But now, I would like to always get a 4 bytes hex with "stringWithFormat". I mean, when the result is, for example : "DFF241", then I would like it to output "00DFF241" instead. If it is "F241", I would like the output to be "0000F241".

Is it possible with "stringWithFormat"?

答:
Yes, it is:

```<code>NSString *hex = [NSString stringWithFormat:@"%08lX", crc32Result];
</code>```

About the 0 flag:

For d, i, o, u, x, X, a, A, e, E, f, F, g, and G conversion specifiers, leading zeros (following any indication of sign or base) are used to pad to the field width; no space padding is performed.

Body:
Until now, I have this code :

NSString *hex = [NSString stringWithFormat:@"%lX", crc32Result];

Which formats an int value into a hex (string) value.

But now, I would like to always get a 4 bytes hex with "stringWithFormat". I mean, when the result is, for example : "DFF241", then I would like it to output "00DFF241" instead. If it is "F241", I would like the output to be "0000F241".

Is it possible with "stringWithFormat"?

Body:
Yes, it is:

NSString *hex = [NSString stringWithFormat:@"%08lX", crc32Result];

About the 0 flag:

For d, i, o, u, x, X, a, A, e, E, f, F, g, and G conversion specifiers, leading zeros (following any indication of sign or base) are used to pad to the field width; no space padding is performed.


问:
how can I split a string and store it in a temporary variable
I have a data, which is nothing but a string b'365,7,7675962680, 4040.I want to split this data and want to store only 7675962680 to any temporary variable.I don not know, how to split and pick that particular data in python. I have a small code, please help me to solve these issue

manage.py

```<code>def data(self, data):
    data1 = data # b'365,7,7675962680, 4040
    # want to split these and store 7675962680 in a variable
</code>```

答:
You can use something like this:    </p>

```<code>def get_data(data):
    data = data.decode()
    data_list = data.split(',')
    return data_list[2]

a = get_data(b'365,7,7675962680, 4040')
print(a)
>> 7675962680
</code>```

Body:
I have a data, which is nothing but a string b'365,7,7675962680, 4040.I want to split this data and want to store only 7675962680 to any temporary variable.I don not know, how to split and pick that particular data in python. I have a small code, please help me to solve these issue

manage.py

def data(self, data):
    data1 = data # b'365,7,7675962680, 4040
    # want to split these and store 7675962680 in a variable

Body:
You can use something like this:

def get_data(data):
    data = data.decode()
    data_list = data.split(',')
    return data_list[2]

a = get_data(b'365,7,7675962680, 4040')
print(a)
>> 7675962680


Title: how can I split a string and store it in a temporary variable

Body:
assuming,

s ="365,7,7675962680, 4040"
s.split(',')[2]
'7675962680'


问:
how to login using facebook in codeigniter?
I'm trying to login using facebook php sdk 5.0 in codeigniter but an error occurs:

Facebook class not found.

This is file structure and library file to use faceboojk sdk

答:
facebook api does not work on localhost..
watch this tutorial</p>


问:
Eloquent join table with two conditions
I have two tables:

A: id | user_id | phonenumber | status | ...

B: id | user_id | phonenumber | name | ...

I would like to list all elements in table A but I have to left join the elements to table B.

I can do it with DB:

```<code>DB::table('A')
  ->leftJoin('B', function ($join) {
    $join->on('A.phonenumber', '=', 'B.phonenumber')
         ->on('A.user_id', '=', 'B.user_id');
  })
  ->select(...)
  ->where('A.user_id', '=', $userId)
  ->get();
</code>```

Is it possible to solve it with eloquent somehow?

答:
You can use eloquent, one way is to change it to

```<code>A::leftJoin('B', function ($join) {
  $join->on('A.phonenumber', '=', 'B.phonenumber')
     ->on('A.user_id', '=', 'B.user_id');
 })
->select(...)
->where('A.user_id', '=', $userId)
->get();
</code>```

And with using pure eloquent

You would have to do adjustment to your A model. We would define two model functions.

```<code>public function phoneNumber()
{
    return $this->hasMany(B::class, "phonenumber", "phonenumber");
}

public function userId()
{
    return $this->hasMany(B::class, "user_id", "user_id");
}
</code>```

Now we will change our query to

```<code>A::with("phonenumber")->has("phonenumber")
   ->with("userId")->has("userId")
   ->where("user_id","=",$userId)
   ->get();
</code>```

This should work for you.

** Updated ***

if you want all the record in A then simply do

```<code>A::with("phonenumber","userId")
   ->where("user_id","=",$userId)
   ->get();
</code>```

Title: Eloquent join table with two conditions

Body:
I have two tables:

A: id | user_id | phonenumber | status | ...

B: id | user_id | phonenumber | name | ...

I would like to list all elements in table A but I have to left join the elements to table B.

I can do it with DB:

DB::table('A')
  ->leftJoin('B', function ($join) {
    $join->on('A.phonenumber', '=', 'B.phonenumber')
         ->on('A.user_id', '=', 'B.user_id');
  })
  ->select(...)
  ->where('A.user_id', '=', $userId)
  ->get();

Is it possible to solve it with eloquent somehow?

Body:
You can use eloquent, one way is to change it to

A::leftJoin('B', function ($join) {
  $join->on('A.phonenumber', '=', 'B.phonenumber')
     ->on('A.user_id', '=', 'B.user_id');
 })
->select(...)
->where('A.user_id', '=', $userId)
->get();

And with using pure eloquent

You would have to do adjustment to your A model. We would define two model functions.

public function phoneNumber()
{
    return $this->hasMany(B::class, "phonenumber", "phonenumber");
}

public function userId()
{
    return $this->hasMany(B::class, "user_id", "user_id");
}

Now we will change our query to

A::with("phonenumber")->has("phonenumber")
   ->with("userId")->has("userId")
   ->where("user_id","=",$userId)
   ->get();

This should work for you.

** Updated ***

if you want all the record in A then simply do

A::with("phonenumber","userId")
   ->where("user_id","=",$userId)
   ->get();


答:
```<code>def data(self, data):
    # data = b'365,7,7675962680, 4040
    # data MUST be converted to str before splitting it
    data1 = data.decode('utf8').split(',')[2]
    print(data1)  # 7675962680
    print(type(data1))  # str
</code>```


问:
Pass data from activity to dialogFragment in android
This is the method that I send the data from activity to dialog fragment

```<code> MultipleColorFragment multipleColorFragment = new MultipleColorFragment();//Get Fragment Instance
  Bundle data = new Bundle();//Use bundle to pass data
  for(int i = 0;i<product_data_two.getColor().size();i++) {
  data.putStringArrayList(i + "", product_data_two.getColor().get(i));
  Log.d(TAG + " send fragment data",data.toString());
                            }
   data.putInt("size", product_data_two.getColor().size());
    multipleColorFragment.setArguments(data);//Finally set argument bundle to fragment

   final FragmentManager fm=getFragmentManager();
    multipleColorFragment.show(fm,"Color Set");
</code>```

This is the method that I get back the data.

```<code>RecyclerView rv;
ArrayList<ArrayList<String>> getArgument;

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View rootView = inflater.inflate(R.layout.multiple_color_fragment_layout, container);

    //RECYCER
    rv = (RecyclerView) rootView.findViewById(R.id.multiple_color_recyclerview);
    rv.setLayoutManager(new LinearLayoutManager(this.getActivity()));
    rv.setLayoutManager(new GridLayoutManager(getActivity(), 6));
    rv.setAdapter(new MultipleColorAdapter());

    int size = getArguments().getInt("size");

    Log.d( " size : " + size ,"");

    for (int i = 0; i < size; i++)
        getArgument.add(getArguments().getStringArrayList(i + ""));

    this.getDialog().setTitle("Color Set");

    return rootView;
}
</code>```

I find that the data that I pass is right. However, I cannot get back the data in the fragment. Can anyoun help me to figure out the problem? Thank you very much.

Update:

ProductTypeTwo.java

```<code>public class ProductTypeTwo {

private String productName;
private String brandID;
private String description;
private String productImage;
private Long colorNo;
private String category;
private String uid;
private ArrayList<ArrayList<String>> color;

public ProductTypeTwo(String productName, String brandID, String description, String productImage, Long colorNo, String category, String uid, ArrayList<ArrayList<String>> color) {
    this.productName = productName;
    this.brandID = brandID;
    this.description = description;
    this.productImage = productImage;
    this.colorNo = colorNo;
    this.category = category;
    this.uid = uid;
    this.color = color;
}

public ProductTypeTwo()
{

}

public String getProductName() {
    return productName;
}

public void setProductName(String productName) {
    this.productName = productName;
}

public String getBrandID() {
    return brandID;
}

public void setBrandID(String brandID) {
    this.brandID = brandID;
}

public String getDescription() {
    return description;
}

public void setDescription(String description) {
    this.description = description;
}

public String getProductImage() {
    return productImage;
}

public void setProductImage(String productImage) {
    this.productImage = productImage;
}

public Long getColorNo() {
    return colorNo;
}

public void setColorNo(Long colorNo) {
    this.colorNo = colorNo;
}

public String getCategory() {
    return category;
}

public void setCategory(String category) {
    this.category = category;
}

public String getUid() {
    return uid;
}

public void setUid(String uid) {
    this.uid = uid;
}

public ArrayList<ArrayList<String>> getColor() {
    return color;
}

public void setColor(ArrayList<ArrayList<String>> color) {
    this.color = color;
}

}
</code>```

message from my logcat:

D/MultipleColorFragment color set size: 0

    java.lang.NullPointerException: Attempt to invoke virtual method 'boolean >     >   java.util.ArrayList.add(java.lang.Object)' on a null object reference

答:
Since product_data_two.getColor() returns an ArrayList<ArrayList<String>> , you can add it to bundle like this:

```<code>bundle.putSerializable("SOME_KEY",product_data_two.getColor());
</code>```

And in your Fragment, get it like this:

```<code>getArgument = (ArrayList<ArrayList<String>>) bundle.getSerializable("SOME_KEY");
</code>```

read more: Bundle

Body:
This is the method that I send the data from activity to dialog fragment

 MultipleColorFragment multipleColorFragment = new MultipleColorFragment();//Get Fragment Instance
  Bundle data = new Bundle();//Use bundle to pass data
  for(int i = 0;i<product_data_two.getColor().size();i++) {
  data.putStringArrayList(i + "", product_data_two.getColor().get(i));
  Log.d(TAG + " send fragment data",data.toString());
                            }
   data.putInt("size", product_data_two.getColor().size());
    multipleColorFragment.setArguments(data);//Finally set argument bundle to fragment

   final FragmentManager fm=getFragmentManager();
    multipleColorFragment.show(fm,"Color Set");

This is the method that I get back the data.

RecyclerView rv;
ArrayList<ArrayList<String>> getArgument;

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View rootView = inflater.inflate(R.layout.multiple_color_fragment_layout, container);

    //RECYCER
    rv = (RecyclerView) rootView.findViewById(R.id.multiple_color_recyclerview);
    rv.setLayoutManager(new LinearLayoutManager(this.getActivity()));
    rv.setLayoutManager(new GridLayoutManager(getActivity(), 6));
    rv.setAdapter(new MultipleColorAdapter());

    int size = getArguments().getInt("size");

    Log.d( " size : " + size ,"");

    for (int i = 0; i < size; i++)
        getArgument.add(getArguments().getStringArrayList(i + ""));

    this.getDialog().setTitle("Color Set");

    return rootView;
}

I find that the data that I pass is right. However, I cannot get back the data in the fragment. Can anyoun help me to figure out the problem? Thank you very much.

Update:

ProductTypeTwo.java

public class ProductTypeTwo {

private String productName;
private String brandID;
private String description;
private String productImage;
private Long colorNo;
private String category;
private String uid;
private ArrayList<ArrayList<String>> color;

public ProductTypeTwo(String productName, String brandID, String description, String productImage, Long colorNo, String category, String uid, ArrayList<ArrayList<String>> color) {
    this.productName = productName;
    this.brandID = brandID;
    this.description = description;
    this.productImage = productImage;
    this.colorNo = colorNo;
    this.category = category;
    this.uid = uid;
    this.color = color;
}

public ProductTypeTwo()
{

}

public String getProductName() {
    return productName;
}

public void setProductName(String productName) {
    this.productName = productName;
}

public String getBrandID() {
    return brandID;
}

public void setBrandID(String brandID) {
    this.brandID = brandID;
}

public String getDescription() {
    return description;
}

public void setDescription(String description) {
    this.description = description;
}

public String getProductImage() {
    return productImage;
}

public void setProductImage(String productImage) {
    this.productImage = productImage;
}

public Long getColorNo() {
    return colorNo;
}

public void setColorNo(Long colorNo) {
    this.colorNo = colorNo;
}

public String getCategory() {
    return category;
}

public void setCategory(String category) {
    this.category = category;
}

public String getUid() {
    return uid;
}

public void setUid(String uid) {
    this.uid = uid;
}

public ArrayList<ArrayList<String>> getColor() {
    return color;
}

public void setColor(ArrayList<ArrayList<String>> color) {
    this.color = color;
}

}

message from my logcat:

D/MultipleColorFragment color set size: 0

    java.lang.NullPointerException: Attempt to invoke virtual method 'boolean >     >   java.util.ArrayList.add(java.lang.Object)' on a null object reference

Body:
Since product_data_two.getColor() returns an ArrayList<ArrayList<String>> , you can add it to bundle like this:

bundle.putSerializable("SOME_KEY",product_data_two.getColor());

And in your Fragment, get it like this:

getArgument = (ArrayList<ArrayList<String>>) bundle.getSerializable("SOME_KEY");

read more: Bundle


问:
Show Text on ProgressBar in StatusStrip
I am new in windows programming. In C# I was working with using Visual Studio 2017. Now, Im stuck with a problem. The Problem is that, I am trying to display some text (the progress value) in ProgressBar in the StatusStrip but can't find a proper working way to do that. :-(

Can anyone please provide me some ideas or solution to this problem? I shall be glad and thankful to you !
 Your answers will be appreciated greatly. :-)

答:
```<code>  progressBar1.CreateGraphics().DrawString(progressBar1.Value.ToString(), new Font("Arial", (float)8.25, FontStyle.Regular), Brushes.Black, new PointF(progressBar1.Width / 2 - 10, progressBar1.Height / 2 - 7));
</code>```

I had the same question just a jew days ago an ran into this little piece of code that does the job perfectly :)

Got the code and explanation from this Website

Title: Show Text on ProgressBar in StatusStrip

Body:
  progressBar1.CreateGraphics().DrawString(progressBar1.Value.ToString(), new Font("Arial", (float)8.25, FontStyle.Regular), Brushes.Black, new PointF(progressBar1.Width / 2 - 10, progressBar1.Height / 2 - 7));

I had the same question just a jew days ago an ran into this little piece of code that does the job perfectly :)

Got the code and explanation from this Website


问:
Use an android player with download button when clicking mp3 links on WebView
I'm new to this site and new to android programming and I need help. I have a webview where the webpage loaded has particular links and those links are mp3 playable files. What code(s) should I use to make it play(stream) and/or download within my android app instead of opening up browsers to play it? Thanks!

EDIT:
I have tried this:

```<code>myWebView.setWebViewClient(new WebViewClient());
myWebView.setWebChromeClient(new WebChromeClient());
</code>```

which now plays the mp3 links but it only allows me to play and pause the audio file, and I'm stuck right now, is there a way for me to add something like a download button also a seek bar. Still, any help would be appreciated.

答:
You want to play audio? If it is complex page with HTML5 content, you can use crosswalk library and XWalkView instead of WebView. But this library will strongly increase your apk size.

To download file go through this tutorial:

http://androidtrainningcenter.blogspot.in/2013/11/download-file-videoaudiotext-through.html

Body:
I'm new to this site and new to android programming and I need help. I have a webview where the webpage loaded has particular links and those links are mp3 playable files. What code(s) should I use to make it play(stream) and/or download within my android app instead of opening up browsers to play it? Thanks!

EDIT:
I have tried this:

myWebView.setWebViewClient(new WebViewClient());
myWebView.setWebChromeClient(new WebChromeClient());

which now plays the mp3 links but it only allows me to play and pause the audio file, and I'm stuck right now, is there a way for me to add something like a download button also a seek bar. Still, any help would be appreciated.


问:
EditText with DatePicker dialog not showing error text when date is not selected
i am working in a app that triggers local notification. for that i have coded to display a date in Edittext, such that when a user clicks on edit text, a date picker dialog opens.

In a case, if edittext is null, i have to show a error to the user and i have coded the below for that.

```<code>  btn_save.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
       if (et_reminderDate.getText().toString().trim().length() == 0) {
                        et_reminderDate.requestFocus();
                        et_reminderDate.setError(getResources().getString(R.string.reminder_selectDate));
                    } else if (et_reminderTime.getText().toString().trim().length() == 0) {
                        et_reminderTime.requestFocus();
                        et_reminderTime.setError(getResources().getString(R.string.reminder_time));
                    } else if (et_dateDue.getText().toString().toString().length() != 0) {
                        et_dateDue.setError(null);
                        et_dateDue.clearFocus();
                    } else if (et_reminderDate.getText().toString().toString().length() != 0) {
                        et_reminderDate.setError(null);
                        et_reminderDate.clearFocus();
                    }else{
My project coding goes here!
}
                            }
</code>```

But i am just getting the error icon. The error text is not shown.
As of my assumption, i have validated for text in edittext. Is that i have to validate for date in Edittext to find whether the date is null?

Note: In the same code, i am getting error message for edittext with text values. For example, edittext where user can enter name. Only for
Edittext with date picker i am not getting the error message!

Any help thanks!

答:
Altough I cannot see the full code, I assume the problem is with else ifstatement.

I think they should be handled as seperate if statements.

Like this:

```<code>            if (et_reminderTime.getText().toString().trim().length() == 0) {
                et_reminderTime.requestFocus();
                et_reminderTime.setError(getResources().getString(R.string.reminder_time));
            }
            if(et_dateDue.getText().toString().length()!=0) {
                et_dateDue.requestFocus();
                et_dateDue.setError(null);
            }
</code>```

Body:
i am working in a app that triggers local notification. for that i have coded to display a date in Edittext, such that when a user clicks on edit text, a date picker dialog opens.

In a case, if edittext is null, i have to show a error to the user and i have coded the below for that.

  btn_save.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
       if (et_reminderDate.getText().toString().trim().length() == 0) {
                        et_reminderDate.requestFocus();
                        et_reminderDate.setError(getResources().getString(R.string.reminder_selectDate));
                    } else if (et_reminderTime.getText().toString().trim().length() == 0) {
                        et_reminderTime.requestFocus();
                        et_reminderTime.setError(getResources().getString(R.string.reminder_time));
                    } else if (et_dateDue.getText().toString().toString().length() != 0) {
                        et_dateDue.setError(null);
                        et_dateDue.clearFocus();
                    } else if (et_reminderDate.getText().toString().toString().length() != 0) {
                        et_reminderDate.setError(null);
                        et_reminderDate.clearFocus();
                    }else{
My project coding goes here!
}
                            }

But i am just getting the error icon. The error text is not shown.
As of my assumption, i have validated for text in edittext. Is that i have to validate for date in Edittext to find whether the date is null?

Note: In the same code, i am getting error message for edittext with text values. For example, edittext where user can enter name. Only for
Edittext with date picker i am not getting the error message!

Any help thanks!

Body:
Altough I cannot see the full code, I assume the problem is with else ifstatement.

I think they should be handled as seperate if statements.

Like this:

            if (et_reminderTime.getText().toString().trim().length() == 0) {
                et_reminderTime.requestFocus();
                et_reminderTime.setError(getResources().getString(R.string.reminder_time));
            }
            if(et_dateDue.getText().toString().length()!=0) {
                et_dateDue.requestFocus();
                et_dateDue.setError(null);
            }


问:
Why is my custom module not available after YUILoader.onSuccess event fires?
Trying to write better JavaScript, woohoo!

First step for me: YUILoader dependency loader so all of my custom code is available to use at a reliable point in time.

My current environment:

YUI (2.8.1) library path: C:\wamp\www\lib\js\yui\2\build\ (http://localhost/lib/js/yui/2/build/)

All YUI min, debug and raw files located in above location

Custom library path: C:\wamp\www\lib\js\ (http://localhost/lib/js/)

Custom Module 'fln-min.js' located in above location

Testing in Chrome

Notes:

Below is my example HTML page, my custom module follows the HTML code. No CSS or anything funky yet, I just want to get this working as a proof of concept. If you run my code, you'll see that both onSuccess events fire, but in the nested callback data is null, and my custom module seems to be unavailable. I've tried a few things, like the path concatenation, hence 'base' in the first YUILoader instance, and the commented out 2nd 'fullpath' in the 2nd YUILoader instance.

Demo HTML page:

```<code><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
 <head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>External file Loader</title>
  <script src="/lib/js/yui/2/build/yuiloader/yuiloader-min.js"></script>
  <script>
   new YAHOO.util.YUILoader({

    base: '/lib/js/yui/2/build/',
    require: ['yahoo-dom-event'],
//    require: ['yahoo-dom-event','reset-fonts-grids','container'],
//    allowRollup: true,
//    combine: true,

    onSuccess: function() {

     alert('YAHOO: '+YAHOO);

     var loader = new YAHOO.util.YUILoader();
     //
     loader.addModule({
      name:'FLN',
//      varName:'FLN',
      type:'js',
      fullpath:'/lib/js/fln-min.js'
//      fullpath:'../../../fln-min.js'
     });
     loader.onSuccess = function(o) {
      //
      alert('o.data: '+YAHOO.lang.dump(o.data));
      alert('FLN: '+FLN);
      //
     };
     loader.onFailure = function(o) {
      //
      alert('Error: '+YAHOO.lang.dump(o));
      //
     };
     loader.insert();
    }

   }).insert();
  </script>
 </head>
 <body>
  <div id="output"></div>
 </body>
</html>
</code>```

Custom module (fln-min.js):

```<code>var FLN = function(){

 var _debug = false ;
 var _masterDebug = false ;

 return {
  loaded: function(){ return true; }
    }

}();
alert('...');
</code>```

答: The correct answer was: new Loader() #1's config object was missing the custom module key name FLN from its requires array.

Body:
Trying to write better JavaScript, woohoo!

First step for me: YUILoader dependency loader so all of my custom code is available to use at a reliable point in time.

My current environment:

YUI (2.8.1) library path: C:\wamp\www\lib\js\yui\2\build\ (http://localhost/lib/js/yui/2/build/)

All YUI min, debug and raw files located in above location

Custom library path: C:\wamp\www\lib\js\ (http://localhost/lib/js/)

Custom Module 'fln-min.js' located in above location

Testing in Chrome

Notes:

Below is my example HTML page, my custom module follows the HTML code. No CSS or anything funky yet, I just want to get this working as a proof of concept. If you run my code, you'll see that both onSuccess events fire, but in the nested callback data is null, and my custom module seems to be unavailable. I've tried a few things, like the path concatenation, hence 'base' in the first YUILoader instance, and the commented out 2nd 'fullpath' in the 2nd YUILoader instance.

Demo HTML page:

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

  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>External file Loader</title>

Custom module (fln-min.js):

var FLN = function(){

 var _debug = false ;
 var _masterDebug = false ;

 return {
  loaded: function(){ return true; }
    }

}();
alert('...');


问:
Writing the titles of a podcast xml file into a text file matching the item GUID (linux)
I'd like to take a web-hosted xml podcast file and loop through, putting all the titles into a txt file matching the guid, ie abcd.mp3.txt (or abcd.txt) will contain This is the title

```<code><rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">
<channel>
    <item>
    <title>This is the title</title>
    <enclosure url="http://www.example.com/abcd.mp3" length="402024" type="audio/mpeg"/>
    <guid>http://www.example.com/abcd.mp3</guid>
</code>```

I've SO'd the question and looked at xmlstarlet, xmlgrep, xmlsh. And then there's things like Osmosis which looks powerful but requires node and is lacking practical documentation. Ideally using as few external dependencies as possible (although Python 3.6 is installed).

After a morning at this I'm starting to wonder if I'm over-thinking/complicating things. Any pointers appreciated.

答:
OK, after much messing with stylesheets, I stumbled upon BeautifulSoup.

And the answer is as simple as this (HT to this guide)

```<code>pip install bs4
pip install lxml
</code>```

and then

```<code>#! /usr/bin/env python3
from bs4 import BeautifulSoup
import requests
url = 'http://www.example.com/somepodcast.xml'
content = requests.get(url).content
soup = BeautifulSoup(content,'lxml') # choose lxml parser
titles = soup.find_all('title')
for title in titles:
    print(title) # or do whatever.
</code>```

Thanks for the other suggestions, but this works for me as far as not messing with xpaths, regex etc.

Body:
I'd like to take a web-hosted xml podcast file and loop through, putting all the titles into a txt file matching the guid, ie abcd.mp3.txt (or abcd.txt) will contain This is the title

<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">
<channel>
    <item>
    <title>This is the title</title>
    <enclosure url="http://www.example.com/abcd.mp3" length="402024" type="audio/mpeg"/>
    <guid>http://www.example.com/abcd.mp3</guid>

I've SO'd the question and looked at xmlstarlet, xmlgrep, xmlsh. And then there's things like Osmosis which looks powerful but requires node and is lacking practical documentation. Ideally using as few external dependencies as possible (although Python 3.6 is installed).

After a morning at this I'm starting to wonder if I'm over-thinking/complicating things. Any pointers appreciated.

Body:
OK, after much messing with stylesheets, I stumbled upon BeautifulSoup.

And the answer is as simple as this (HT to this guide)

pip install bs4
pip install lxml

and then

#! /usr/bin/env python3
from bs4 import BeautifulSoup
import requests
url = 'http://www.example.com/somepodcast.xml'
content = requests.get(url).content
soup = BeautifulSoup(content,'lxml') # choose lxml parser
titles = soup.find_all('title')
for title in titles:
    print(title) # or do whatever.

Thanks for the other suggestions, but this works for me as far as not messing with xpaths, regex etc.