问:
select more than one checkbox to execute condition
I want a text file to show contents in memo1 once I have selected 2 checkboxes.
How would I do this?

I tried the code below but I can't seem to get it right.

```<code>if CheckBox1.Checked and CheckBox2.Checked then
begin
memo1.lines.LoadFromFile('files\RS.txt');
end;
</code>```

I also want to be able to select the checkboxes individually Like:
(pointing this out in case combining them prevents checking them individually)

Checkbox1:

```<code>procedure TForm1.CheckBox1Change(Sender: TObject);
begin
   memo1.lines.LoadFromFile('files\R.txt');
end;
</code>```

Checkbox2:

```<code>procedure TForm1.CheckBox2Change(Sender: TObject);
begin
   memo1.lines.LoadFromFile('files\S.txt');
end;
</code>```

Any suggestions/Improvements will be appreciated.

Running Lazarus IDE v1.6.4

Windows 10 x64

答:
I'm assuming your objective is to generate a filename which depends on the
particular combination of the boolean states of the two checkboxes -
see example code below.  The point of doing this is that it helps separate
the definition of what you want the file name to be from what you want to do
with it.

```<code>procedure TForm1.Button1Click(Sender: TObject);
begin
  Memo1.Lines.LoadFromFile(GetFileName);
end;

function TForm1.GetFileName: String;
begin
  //  Return empty string if neither checkbox is checked
  Result := '';

  if Checkbox1.Checked and Checkbox2.Checked then
    Result := 'files\RS.txt'
  else  // if we reach here only one of the checkboxes, or neither, is checked
    if Checkbox1.Checked then
      Result := 'files\R.txt'
    else
      if Checkbox2.Checked then
        Result := 'files\S.txt'
end;
</code>```

I've assigned an empty string to the Result of the function at the outset to ensure that the Result is always defined.

Important  You'll notice that the above does not use the Change events of the Checkboxes.  The reason is that you may not get the result you need  (or are expecting) if the Change events are never triggered - for example if one CheckBox is set to Checked in the IDE but the other isn't, and you want to get the right file name regardless of whether the user has actually clicked either one of them.

Body:
I want a text file to show contents in memo1 once I have selected 2 checkboxes.
How would I do this?

I tried the code below but I can't seem to get it right.

if CheckBox1.Checked and CheckBox2.Checked then
begin
memo1.lines.LoadFromFile('files\RS.txt');
end;

I also want to be able to select the checkboxes individually Like:
(pointing this out in case combining them prevents checking them individually)

Checkbox1:

procedure TForm1.CheckBox1Change(Sender: TObject);
begin
   memo1.lines.LoadFromFile('files\R.txt');
end;

Checkbox2:

procedure TForm1.CheckBox2Change(Sender: TObject);
begin
   memo1.lines.LoadFromFile('files\S.txt');
end;

Any suggestions/Improvements will be appreciated.

Running Lazarus IDE v1.6.4

Windows 10 x64

Body:
I'm assuming your objective is to generate a filename which depends on the
particular combination of the boolean states of the two checkboxes -
see example code below.  The point of doing this is that it helps separate
the definition of what you want the file name to be from what you want to do
with it.

procedure TForm1.Button1Click(Sender: TObject);
begin
  Memo1.Lines.LoadFromFile(GetFileName);
end;

function TForm1.GetFileName: String;
begin
  //  Return empty string if neither checkbox is checked
  Result := '';

  if Checkbox1.Checked and Checkbox2.Checked then
    Result := 'files\RS.txt'
  else  // if we reach here only one of the checkboxes, or neither, is checked
    if Checkbox1.Checked then
      Result := 'files\R.txt'
    else
      if Checkbox2.Checked then
        Result := 'files\S.txt'
end;

I've assigned an empty string to the Result of the function at the outset to ensure that the Result is always defined.

Important  You'll notice that the above does not use the Change events of the Checkboxes.  The reason is that you may not get the result you need  (or are expecting) if the Change events are never triggered - for example if one CheckBox is set to Checked in the IDE but the other isn't, and you want to get the right file name regardless of whether the user has actually clicked either one of them.


来源: stackexchange

问:
How to add | remove css class in angular element?
How to add | remove css class in angular element?

Access to angular element is via: this.elementRef.nativeElement (import { ElementRef } from '@angular/core';).
CSS class name is myclass.

答:
You can use HostBinding to do that, without using a Renderer or ElementRef. See this example :</p>

```<code>import {Component, HostBinding} from "@angular/core";

@Component({
   ...
})
export class myComponent {
    @HostBinding('class.myclass') visible: boolean = false;  // True when visible
}
</code>```

ContentLicense: CC BY-SA 3.0

Body:
You can use HostBinding to do that, without using a Renderer or ElementRef. See this example :

import {Component, HostBinding} from "@angular/core";

@Component({
   ...
})
export class myComponent {
    @HostBinding('class.myclass') visible: boolean = false;  // True when visible
}


问:
Help with SQL Stored procedure
I need some help with an SQL stored procedure, I haven't got alot of experience with it.
I have a table "dbo.Lookup_Country". It contains 3 fields: ID, Name, Code.
Now I wrote a stored procedure that retrieves the country name by Code.

```<code>Select Name from Lookup_Country where Code = @Code
</code>```

I need to adjust the stored procedure so that if there are 0 results it has to see if there are results by searching with ID:

Select Name from Lookup_Country where Id = @Code

So basically I need some kind of 'IF' structure:

```<code>if (Select Name from Lookup_Country where Code = @Code) == 0 results
      Select Name from Lookup_Country where Id = @Code
</code>```

Is this possible?

thx

Thx for the help everyone, I used this:

```<code>DECLARE @Name nvarchar(50)

-- Insert statements for procedure here
SET @Name = (SELECT Name from dbo.Lookup_Country WHERE Code = @CODE)
IF @Name != ''
    SELECT Name from dbo.Lookup_Country WHERE Code = @CODE
ELSE
    SELECT Name from dbo.Lookup_Country WHERE ID = @CODE
</code>```

答:
Put the results of the first select into a variable, then you can do a count on that result, and if that is zero then you would do the search by id.

To learn more about how to use the if statement then check out this article, if you are using SQL Server, but, if you are using a different database then the logic still applies the if syntax may differ.

http://msdn.microsoft.com/en-us/library/ms182587.aspx

ContentLicense: CC BY-SA 2.5

Title: Help with SQL Stored procedure

Body:
I need some help with an SQL stored procedure, I haven't got alot of experience with it.
I have a table "dbo.Lookup_Country". It contains 3 fields: ID, Name, Code.
Now I wrote a stored procedure that retrieves the country name by Code.

Select Name from Lookup_Country where Code = @Code

I need to adjust the stored procedure so that if there are 0 results it has to see if there are results by searching with ID:

Select Name from Lookup_Country where Id = @Code

So basically I need some kind of 'IF' structure:

if (Select Name from Lookup_Country where Code = @Code) == 0 results
      Select Name from Lookup_Country where Id = @Code

Is this possible?

thx

Thx for the help everyone, I used this:

DECLARE @Name nvarchar(50)

-- Insert statements for procedure here
SET @Name = (SELECT Name from dbo.Lookup_Country WHERE Code = @CODE)
IF @Name != ''
    SELECT Name from dbo.Lookup_Country WHERE Code = @CODE
ELSE
    SELECT Name from dbo.Lookup_Country WHERE ID = @CODE


问:
How can one use regex to capture the text occurring between lines beginning with a single semicolon?
I want to capture the text between lines which begin with single semicolons:

sample input:

```<code>s = '''
;

the color blue

;

the color green

;

the color red

;
'''
</code>```

this is the desired output:

```<code>['the color blue', 'the color green', 'the color red']
</code>```

this attempted solution doesn't work:

```<code>import re
pat = r'^;(.*)^;'
r = re.findall(pat, s, re.S|re.M)
print(r)
</code>```

this is the wrong output:

```<code>['\n\nthe color blue\n\n;\n\nthe color green\n\n;\n\nthe color red\n\n']
</code>```

答:
You didn't ask for this, I know. But it's worth considering pyparsing as an alternative to re. Indeed, pyparsing properly contains regex. Notice how this simple parser copes with various numbers of empty lines.

```<code>>>> parsifal = open('temp.txt').read()
>>> print (parsifal)

;

the colour blue
;
the colour green
;
the colour red
;
the colour purple

;

the colour magenta

;

>>> import pyparsing as pp
>>> p = pp.OneOrMore(pp.Suppress(';\n')+pp.ZeroOrMore(pp.Suppress('\n'))+pp.CharsNotIn(';\n')+pp.ZeroOrMore(pp.Suppress('\n')))
>>> p.parseString(parsifal)
(['the colour blue', 'the colour green', 'the colour red', 'the colour purple', 'the colour magenta'], {})
</code>```

As a whole, the parser matches OneOrMore sequences of semicolons or new-lines, followed by anything other than these characters followed by new-lines.

Body:
I want to capture the text between lines which begin with single semicolons:

sample input:

s = '''
;

the color blue

;

the color green

;

the color red

;
'''

this is the desired output:

['the color blue', 'the color green', 'the color red']

this attempted solution doesn't work:

import re
pat = r'^;(.*)^;'
r = re.findall(pat, s, re.S|re.M)
print(r)

this is the wrong output:

['\n\nthe color blue\n\n;\n\nthe color green\n\n;\n\nthe color red\n\n']

Body:
You didn't ask for this, I know. But it's worth considering pyparsing as an alternative to re. Indeed, pyparsing properly contains regex. Notice how this simple parser copes with various numbers of empty lines.

>>> parsifal = open('temp.txt').read()
>>> print (parsifal)

;

the colour blue
;
the colour green
;
the colour red
;
the colour purple

;

the colour magenta

;

>>> import pyparsing as pp
>>> p = pp.OneOrMore(pp.Suppress(';\n')+pp.ZeroOrMore(pp.Suppress('\n'))+pp.CharsNotIn(';\n')+pp.ZeroOrMore(pp.Suppress('\n')))
>>> p.parseString(parsifal)
(['the colour blue', 'the colour green', 'the colour red', 'the colour purple', 'the colour magenta'], {})

As a whole, the parser matches OneOrMore sequences of semicolons or new-lines, followed by anything other than these characters followed by new-lines.


问:
If I make an app at API level 21 (5.0), will it work with newer version of android?
I just started to use android 2 weeks ago.

I have successfully made my first app with API level 21 (5.1 Lollipop).
My phone's android is also 5.1 Lollipop.

I wonder if my app will work with all newer version of android,
such as 6.0 marshmallow or 7.0 nougat? Or do I need to provide
updates?

Thanks.

答:
Yes it will work on newer versions as long as you do not have maxSdkVersion set to 21

In your application manifest, you will find up to three attributes:

android:minSdkVersion

android:targetSdkVersion

android:maxSdkVersion

If your max is set to 21 then it will not work with newer versions. You might not even have a max set.

You likely have your target set at 21 or your min set at 21, or both...

You can learn more about <uses-sdk> here

One thing to note : 4.4 kitkat still has 17% of the API distribution so you might want to set your minSdkVersion to 19. You can find a weekly updated distribution chart here

ContentLicense: CC BY-SA 4.0


问:
Publicate Android App using GitHub repository
Is any way exists to publicate android app via github, not Google Play ?

I'm goind to do some app for my friends, and want be able update and easy install it without full sized publication.

答:
Buddy what i guess is
github is made for version controlling and publishing your projects codes right overthere for to help people not to publish your apk. If you want to do that u have to spent around 25$ to create a google developer play account and upload your app there.
Concluding : github is not to publish your android apks</p>


问:
I am using pusher in Laravel 5.4 but I'm getting following error:
app.js echo script:

```<code>Echo:join('chatroom')

.listen('MessagePosted', (e) => {
                this.messages.push({
                    message: e.message.message,
                    user: e.user
                });
            });
</code>```

getting following error:

app.js:37859 [Vue warn]: Error in created hook: "ReferenceError: join
  is not defined"

(found in )warn @ app.js:37859handleError @ app.js:37944callHook
  @ app.js:39983Vue._init @ app.js:41425Vue$3 @ app.js:41520(anonymous
  function) @ app.js:1127__webpack_require__ @ app.js:20(anonymous
  function) @ app.js:47150__webpack_require__ @ app.js:20(anonymous
  function) @ app.js:66(anonymous function) @ app.js:69 app.js:37948
  ReferenceError: join is not defined(…)handleError @
  app.js:37948callHook @ app.js:39983Vue._init @ app.js:41425Vue$3 @
  app.js:41520(anonymous function) @ app.js:1127__webpack_require__ @
  app.js:20(anonymous function) @ app.js:47150__webpack_require__ @
  app.js:20(anonymous function) @ app.js:66(anonymous function) @
  app.js:69 app.js:45006 Download the Vue Devtools extension for a
  better development experience:

答:
install pusher and laravel-echo

you can install it by using

```<code>npm install --save laravel-echo pusher-js
</code>```

I hope this helps

you will also need to compile the code

Body:
app.js echo script:

Echo:join('chatroom')

.listen('MessagePosted', (e) => {
                this.messages.push({
                    message: e.message.message,
                    user: e.user
                });
            });

getting following error:

app.js:37859 [Vue warn]: Error in created hook: "ReferenceError: join
  is not defined"

(found in )warn @ app.js:37859handleError @ app.js:37944callHook
  @ app.js:39983Vue._init @ app.js:41425Vue$3 @ app.js:41520(anonymous
  function) @ app.js:1127__webpack_require__ @ app.js:20(anonymous
  function) @ app.js:47150__webpack_require__ @ app.js:20(anonymous
  function) @ app.js:66(anonymous function) @ app.js:69 app.js:37948
  ReferenceError: join is not defined(…)handleError @
  app.js:37948callHook @ app.js:39983Vue._init @ app.js:41425Vue$3 @
  app.js:41520(anonymous function) @ app.js:1127__webpack_require__ @
  app.js:20(anonymous function) @ app.js:47150__webpack_require__ @
  app.js:20(anonymous function) @ app.js:66(anonymous function) @
  app.js:69 app.js:45006 Download the Vue Devtools extension for a
  better development experience:

Body:
install pusher and laravel-echo

you can install it by using

npm install --save laravel-echo pusher-js

I hope this helps

you will also need to compile the code


问:
Swift 3 - Core Data Saving with one-to-many relationship
I'm working with core data and i have two entity:

SwimmingPool
Parameters
Each swimming pool can have multiple parameters

I have already saved and fetched data for swimming pool.

I've saved them trough a form.

In my AppDelegate i have:

```<code>let ad = UIApplication.shared.delegate as! AppDelegate
let context = ad.persistentContainer.viewContext
</code>```

and here's the func:

```<code> var swimmingpool: SwimminPool!

    if swimmingPoolToEdit == nil {
        swimming = SwimminPool(context: context)
    } else {
        swimming = swimmingPoolToEdit
    }

    if let name =  swimmingName.text {
        swimming.name = name
    }
    if let volume = swimmingVolume.text {
        swimming.volume = volume
.........................................................
ad.saveContext()
</code>```

and i perform the fetch like so:

```<code>var controller: NSFetchedResultsController<SwimmingPool>!

func attemptFetch() {

    let fetchRequest: NSFetchRequest<SwimminPool> = SwimminPool.fetchRequest()
    let dataSort = NSSortDescriptor(key: "createdAt", ascending: false)

    fetchRequest.sortDescriptors = [dataSort]

     let controller = NSFetchedResultsController(fetchRequest: fetchRequest, managedObjectContext: context, sectionNameKeyPath: nil, cacheName: nil)

    controller.delegate = self
    self.controller = controller

    do {
        try controller.performFetch()
    } catch {
        let error = error as NSError
        print("\(error.debugDescription)")
    }
}
</code>```

Through a segue i pass all the data to a new controller and through a new form (in an another controller) i'm trying to save the data for the parameters and connect them to the the specific swimming pool.

Do i need to save the data like i did for the swimming pool and the relationship will automatically connect the two entities or do i need to connect them upon saving?

I'm new to swift and i'm not sure how to save related datas

The connection will be made upon saving or when i will perform the parameters fetch?

Thank you!

答:
Create Parameter managed object and then link this parameter to a SwimingPool managed object:

```<code>let parameter = Parameters(context: context)
parameter.chlorum = Double(12245454.12211) // insert your value
parameter.oxigen = "your value here"
parameter.createdAt = "your value here"

let swimming = SwimminPool(context: context)
swimming.parameter = parameter
ad.saveContext()
</code>```

Body:
I'm working with core data and i have two entity:

SwimmingPool
Parameters
Each swimming pool can have multiple parameters

I have already saved and fetched data for swimming pool.

I've saved them trough a form.

In my AppDelegate i have:

let ad = UIApplication.shared.delegate as! AppDelegate
let context = ad.persistentContainer.viewContext

and here's the func:

 var swimmingpool: SwimminPool!

    if swimmingPoolToEdit == nil {
        swimming = SwimminPool(context: context)
    } else {
        swimming = swimmingPoolToEdit
    }

    if let name =  swimmingName.text {
        swimming.name = name
    }
    if let volume = swimmingVolume.text {
        swimming.volume = volume
.........................................................
ad.saveContext()

and i perform the fetch like so:

var controller: NSFetchedResultsController<SwimmingPool>!

func attemptFetch() {

    let fetchRequest: NSFetchRequest<SwimminPool> = SwimminPool.fetchRequest()
    let dataSort = NSSortDescriptor(key: "createdAt", ascending: false)

    fetchRequest.sortDescriptors = [dataSort]

     let controller = NSFetchedResultsController(fetchRequest: fetchRequest, managedObjectContext: context, sectionNameKeyPath: nil, cacheName: nil)

    controller.delegate = self
    self.controller = controller

    do {
        try controller.performFetch()
    } catch {
        let error = error as NSError
        print("\(error.debugDescription)")
    }
}

Through a segue i pass all the data to a new controller and through a new form (in an another controller) i'm trying to save the data for the parameters and connect them to the the specific swimming pool.

Do i need to save the data like i did for the swimming pool and the relationship will automatically connect the two entities or do i need to connect them upon saving?

I'm new to swift and i'm not sure how to save related datas

The connection will be made upon saving or when i will perform the parameters fetch?

Thank you!

Body:
Create Parameter managed object and then link this parameter to a SwimingPool managed object:

let parameter = Parameters(context: context)
parameter.chlorum = Double(12245454.12211) // insert your value
parameter.oxigen = "your value here"
parameter.createdAt = "your value here"

let swimming = SwimminPool(context: context)
swimming.parameter = parameter
ad.saveContext()


问:
PHP, generate PDF file from HTML
I'm a novice when it comes to generating pdf files

I've tried tcpdf and mpdf but not getting the format the way i want it be.

Here's my mpdf code

```<code>include('./mpdf.php');
    $mpdf=new mPDF();
    $html = '<!DOCTYPE html>
<html>
<head>
    <title></title>
    <link rel="stylesheet" type="text/css" href="cssForTable.css">
</head>
<body>
<table>
    <thead>
    <tr>
        <th width="25%">Client Details</th>
        <th colspan="2" width="50%"><h2 style="padding-top: 0; margin-bottom: 0; margin-top: 0;text-align: center"><strong>ROAD TRAFFIC ACCIDENT</strong></h2></th>
        <th width="25%">Legal HQ</th>
    </tr>
    </thead>
    <tbody>
    <tr>
        <td width="50%" colspan="2">
            <strong>Instructed Another Solicito?</strong>
            Yes   <input type="checkbox" />     No   <input type="checkbox" />
        </td>
        <th width="50%" colspan="2" rowspan="3">
            Claiming For:<br />
            Personal Injury            Yes   <input type="checkbox" style="margin-bottom: 7px;" />
                                       No   <input type="checkbox" style="margin-bottom: 7px;" /><br />
            Vehicle Damage          Yes   <input type="checkbox" style="margin-bottom: 7px;" />
                                        No   <input type="checkbox" style="margin-bottom: 7px;" /><br />
            Loss of Earnings         Yes   <input type="checkbox" />
                                        No   <input type="checkbox" />
        </th>
    </tr>
    <tr><th colspan="2"><h3 style="padding-top: 0; margin-bottom: 0; margin-top: 0;">ACCIDENT DETAILS</h3></th></tr>
    <tr>
        <th width="25%">Date of Accident</th>
        <td width="25%"> </td>
    </tr>
    <tr>
        <th width="25%">Time of Accident</th>
        <td width="25%"> </td>
        <th width="25%">No of Occupants (inc driver)</th>
        <td width="25%"> </td>
    </tr>
    <tr>
        <th width="25%">Location of Accident</th>
        <td width="25%"> </td>
        <td width="50%" colspan="2" rowspan="2" valign="top" >
            <strong>Were Police Involved?
                Yes   <input type="checkbox" />
                No   <input type="checkbox" />
            <br />
            <br />If so, Police No/Station: </strong>
        </td>
    </tr>
    <tr>
        <td width="25%" colspan="2" rowspan="2" valign="top"><strong>Accident Circumstances</strong><br /><br /></td>
    </tr>
    <tr>
        <th width="25%" colspan="2">
            Is Client:<br />
            Owner <input type="checkbox" style="margin-left: 15em; margin-bottom: 7px;" /><br />
            Driver  <input type="checkbox" style="margin-left: 15em; margin-bottom: 7px;" /><br />
            Passenger  <input type="checkbox" style="margin-left: 13em;" />
        </th>
    </tr>
    <tr>
        <th width="25%">Weather Conditions</th>
        <th width="75%" colspan="3">
            <label style="margin-left: 2em; margin-bottom: 7px;" > Sunny     <input type="checkbox" /></label>
            <label style="margin-left: 8em; margin-bottom: 7px;" > Rain     <input type="checkbox" /></label>
            <label style="margin-left: 8em; margin-bottom: 7px;" > Snow     <input type="checkbox" /></label><br />
            <label style="margin-left: 2em; margin-bottom: 7px;" > Ice           <input type="checkbox" /></label>
            <label style="margin-left: 8em; margin-bottom: 7px;" > Fog       <input type="checkbox" /></label>
            <label style="margin-left: 8em; margin-bottom: 7px;" > Dark        <input type="checkbox" /></label>
        </th>
    </tr>
    </tbody>
</table>
</body>
</html>';

    $mpdf->WriteHTML($html);
    $mpdf->Output();
    exit;
</code>```

The above code generates the following PDF file (screen shot)

Where as it should look like the following

My question is, is there a way to generate PDF as we generate HTML I mean is there a way to print whatever html+PHP has generated on client side?

Any Idea?

答:
Yes, you can do this. Here is the complete code.
It works perfectly.
You can get value from another page using post method also. Your choice.</p>

```<code><?php $student_id = $_GET['student_id']; ?>
<?php
include("mpdf/mpdf.php");
$html .= "
<html>
<head>
<style>
body {font-family: sans-serif;
    font-size: 10pt;
    background-image: url(\"images/ok.jpg\");

    background-repeat: no-repeat;
    padding-top:10pt;
    margin-top: 100px;
    padding-top: 50px;
}
td { vertical-align: top;
    border-left: 0.6mm solid #000000;
    border-right: 0.6mm solid #000000;
    align: center;
}

p.student_id{
    padding-left : 140px;
    padding-top  : -27px;
}

</style>
</head>
<body>
<!--mpdf

<p class=\"student_id\">$student_id</p>

<sethtmlpageheader name='myheader' value='on' show-this-page='1' />
<sethtmlpagefooter name='myfooter' value='on' />
mpdf-->

</body>
</html>
";

$mpdf=new mPDF();
$mpdf->WriteHTML($html);
$mpdf->SetDisplayMode('fullpage');

$mpdf->Output();
?>
</code>```

Title: PHP, generate PDF file from HTML

Body:
I'm a novice when it comes to generating pdf files

I've tried tcpdf and mpdf but not getting the format the way i want it be.

Here's my mpdf code

include('./mpdf.php');
    $mpdf=new mPDF();
    $html = '<!DOCTYPE html>

    <title></title>
    <link rel="stylesheet" type="text/css" href="cssForTable.css">

        Client Details

ROAD TRAFFIC ACCIDENT

        Legal HQ

            Instructed Another Solicito?
            Yes   <input type="checkbox" />     No   <input type="checkbox" />

            Claiming For:

            Personal Injury            Yes   <input type="checkbox" style="margin-bottom: 7px;" />
                                       No   <input type="checkbox" style="margin-bottom: 7px;" />

            Vehicle Damage          Yes   <input type="checkbox" style="margin-bottom: 7px;" />
                                        No   <input type="checkbox" style="margin-bottom: 7px;" />

            Loss of Earnings         Yes   <input type="checkbox" />
                                        No   <input type="checkbox" />

ACCIDENT DETAILS

        Date of Accident

        Time of Accident

        No of Occupants (inc driver)

        Location of Accident

            Were Police Involved?
                Yes   <input type="checkbox" />
                No   <input type="checkbox" />

If so, Police No/Station:

        Accident Circumstances

            Is Client:

            Owner <input type="checkbox" style="margin-left: 15em; margin-bottom: 7px;" />

            Driver  <input type="checkbox" style="margin-left: 15em; margin-bottom: 7px;" />

            Passenger  <input type="checkbox" style="margin-left: 13em;" />

        Weather Conditions

             Sunny     <input type="checkbox" />
             Rain     <input type="checkbox" />
             Snow     <input type="checkbox" />

             Ice           <input type="checkbox" />
             Fog       <input type="checkbox" />
             Dark        <input type="checkbox" />

';

    $mpdf->WriteHTML($html);
    $mpdf->Output();
    exit;

The above code generates the following PDF file (screen shot)

Where as it should look like the following

My question is, is there a way to generate PDF as we generate HTML I mean is there a way to print whatever html+PHP has generated on client side?

Any Idea?

Body:
Yes, you can do this. Here is the complete code.
It works perfectly.
You can get value from another page using post method also. Your choice.

<?php $student_id = $_GET['student_id']; ?>
<?php
include("mpdf/mpdf.php");
$html .= "
<html>
<head>
<style>
body {font-family: sans-serif;
    font-size: 10pt;
    background-image: url(\"images/ok.jpg\");

    background-repeat: no-repeat;
    padding-top:10pt;
    margin-top: 100px;
    padding-top: 50px;
}
td { vertical-align: top;
    border-left: 0.6mm solid #000000;
    border-right: 0.6mm solid #000000;
    align: center;
}

p.student_id{
    padding-left : 140px;
    padding-top  : -27px;
}

</style>
</head>
<body>
<!--mpdf

<p class=\"student_id\">$student_id</p>

<sethtmlpageheader name='myheader' value='on' show-this-page='1' />
<sethtmlpagefooter name='myfooter' value='on' />
mpdf-->

</body>
</html>
";

$mpdf=new mPDF();
$mpdf->WriteHTML($html);
$mpdf->SetDisplayMode('fullpage');

$mpdf->Output();
?>


问:
Change interior color based on cell value of color constant
I have an Excel range with the 8 color constants.  I just wanted to simply change the interior color of the cell in the adjacent column based on the cell value.  Unfortunately, I get a type mismatch which is because it is treating the value as a string, but I don't know how to convert it to constant.

For example, to change interior color to blue this works
rng.interior.color = vbblue

but not this
rng.interior.color = rng.value 'because it is a string "vbblue"

What can I do to convert rng.value from string to the color constant so the range in column E gets background color based on value in column D?

```<code>Dim colorRange As Range
Dim rng As Range
Set colorRange = Range("D1", Range("D1").End(xlDown).Address)

For Each rng In colorRange
  rng.Offset(, 1).Interior.Color = rng.Value
Next rng
</code>```

答:
There is no "built-in" way to convert the name of a Constant to its value. You need to do the mapping yourself. Best is to use a dictionary:

```<code>Function TextToColor(s As String) As Long
  Static dict As Dictionary
  If dict Is Nothing Then
    Set dict = CreateObject("Scripting.Dictionary")
    dict("vbBlack") = vbBlack
    dict("vbWhite") = vbWhite
    dict("vbRed") = vbRed
    dict("vbGreen") = vbGreen
    dict("vbBlue") = vbBlue
    dict("vbYellow") = vbYellow
    dict("vbMagenta") = vbMagenta
    dict("vbCyan") = vbCyan
    ' dict("etc...") = etc...
  End If
  TextToColor = dict(s)
End Function
</code>```

```<code>Sub ExampleUse()
  Dim colorRange As Range: Set colorRange = Range("D1", Range("D1").End(xlDown).Address)
  Dim rng As Range
  For Each rng In colorRange
    rng.Offset(, 1).Interior.Color = TextToColor(rng.value)
  Next rng
End Sub
</code>```

Body:
I have an Excel range with the 8 color constants.  I just wanted to simply change the interior color of the cell in the adjacent column based on the cell value.  Unfortunately, I get a type mismatch which is because it is treating the value as a string, but I don't know how to convert it to constant.

For example, to change interior color to blue this works
rng.interior.color = vbblue

but not this
rng.interior.color = rng.value 'because it is a string "vbblue"

What can I do to convert rng.value from string to the color constant so the range in column E gets background color based on value in column D?

Dim colorRange As Range
Dim rng As Range
Set colorRange = Range("D1", Range("D1").End(xlDown).Address)

For Each rng In colorRange
  rng.Offset(, 1).Interior.Color = rng.Value
Next rng

Body:
There is no "built-in" way to convert the name of a Constant to its value. You need to do the mapping yourself. Best is to use a dictionary:

Function TextToColor(s As String) As Long
  Static dict As Dictionary
  If dict Is Nothing Then
    Set dict = CreateObject("Scripting.Dictionary")
    dict("vbBlack") = vbBlack
    dict("vbWhite") = vbWhite
    dict("vbRed") = vbRed
    dict("vbGreen") = vbGreen
    dict("vbBlue") = vbBlue
    dict("vbYellow") = vbYellow
    dict("vbMagenta") = vbMagenta
    dict("vbCyan") = vbCyan
    ' dict("etc...") = etc...
  End If
  TextToColor = dict(s)
End Function

Sub ExampleUse()
  Dim colorRange As Range: Set colorRange = Range("D1", Range("D1").End(xlDown).Address)
  Dim rng As Range
  For Each rng In colorRange
    rng.Offset(, 1).Interior.Color = TextToColor(rng.value)
  Next rng
End Sub


问:
R dataframe: how to find item in one column but not another column (two column contain similar lists)
I have a dataframe like this:

```<code>temp = data.frame(current=c("apple, banana, pear", "melon"),
new=c("apple, cherry, grape", "melon, blueberry"))
</code>```

How can I find what's new in the new column, in this case "cherry, grape" and "blueberry"?

Thanks.

答:
One option is</p>

```<code>mapply(function(x, y) toString(setdiff(x, y)),
      strsplit(as.character(temp$new), ", "), strsplit(as.character(temp$current), ", "))
#[1] "cherry, grape" "blueberry"
</code>```

Body:
I have a dataframe like this:

temp = data.frame(current=c("apple, banana, pear", "melon"),
new=c("apple, cherry, grape", "melon, blueberry"))

How can I find what's new in the new column, in this case "cherry, grape" and "blueberry"?

Thanks.

Body:
One option is

mapply(function(x, y) toString(setdiff(x, y)),
      strsplit(as.character(temp$new), ", "), strsplit(as.character(temp$current), ", "))
#[1] "cherry, grape" "blueberry"


问:
plot the 2d and 3d c-planes of a light distribution curve in matlab
I would like to plot the C-planes that describe the light distribution curve (ldc) of a light source in 2D and 3D space respectively. Usually the manufacturers provide the details of the ldc in polar coordinates. An example can be seen below:

together with the graph (the red lines solid/dashed represent the C-planes)

the above 2D plot can be plotted in simulation software quite nicely as you can see in the images below:

Now if it is possible I would like to plot the same graphs/plots in matlab as well. However, I am not sure how to do it. For the 2D graph I had a look at the polarplot() function but I am not sure what my input should be based on my matrix. Regarding the 3D plot, totally no clue how I could get the plot in 3D space. Therefore, if someone could provide me with some hints or a solution it would be really helpful. Below are the values of the above matrix in case someone wants to experiment with it.

Many thanks in advance.

Update:

Ok plotting the 2D polar diagram can be achieved with the following code:

```<code>ldc = [426.0060  426.0060  426.0060  426.0060  426.0060  426.0060  426.0060
  424.7540  425.0980  425.5810  425.9940  425.6490  425.1670  424.7540
  421.8600  422.2040  422.7550  423.1690  422.6860  422.2040  421.8600
  415.5200  416.0020  416.1400  416.8980  416.6910  416.2780  415.7960
  408.6290  406.9060  407.0440  408.0090  409.0420  407.3890  406.5620
  394.1580  394.2960  394.5030  395.1920  395.0540  394.5720  394.5720
  374.5880  375.8290  376.9310  376.6550  374.6570  376.3800  377.4820
  349.7810  351.3660  352.8130  351.9170  350.7460  352.1930  353.9150
  317.8070  316.2910  318.2210  316.2910  316.8420  317.1870  319.8750
  267.2280  269.4330  264.4720  267.9170  267.9170  269.6400  266.1260
  200.4280  162.1010  174.1260  163.2380  199.5320  163.8650  174.8770
  111.4940  118.7160  150.0280  118.3780  112.6450  116.1870  151.6540
   73.5810   78.4390   99.5180   80.3960   75.7450   78.4250  100.4280
   49.7660   69.2120   54.2240   71.2930   52.1980   71.8860   56.8360
   35.5290   49.5180   46.4930   48.3810   35.8390   47.2780   48.2220
   34.3720   37.9410   35.3290   38.5750   33.9930   39.9950   35.4050
   24.1730   24.9380   28.9690   25.8750   24.7800   24.6350   28.5140
   14.3050   15.9870   19.6670   16.4830   15.1460   15.9450   19.7770
    6.0920    6.5390    7.0420    7.2350    6.9940    6.8220    6.6840
    4.7550    4.9550    5.2780    5.2160    5.2090    5.4780    5.6640
    3.8590    3.8520    3.8930    3.9000    3.8870    4.3210    4.4380
    3.1150    3.1420    2.9350    2.8530    3.0870    3.4660    3.5970
    2.8670    2.6670    2.4740    2.3500    2.5700    2.9290    3.1700
    2.4120    2.4050    2.3360    2.0330    2.3500    2.6050    2.7840
    1.6540    1.6670    1.9090    1.8880    1.7300    1.5920    1.6810
    1.1300    1.1990    1.2680    1.4880    1.2270    1.1580    1.1300
    1.0470    1.0400    1.0400    1.1440    1.0750    1.0540    1.0470
    1.1300    1.1640    1.2060    1.1850    1.2130    1.1850    1.1710
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0];

color = 'r';
line = '-';
% plotting only the first and the last C-planes, i.e. 0 and 90 degrees respectively
for i = 1:6:size(ldc,2)
    polarplot(degtorad(theta),ldc(:,i), 'Color', color, 'LineStyle', line, 'LineWidth', 1.5)
    hold on
    polarplot(-degtorad(theta),ldc(:,i), 'Color' ,color, 'LineStyle', line, 'LineWidth', 1.5)
    line = ':';
end

ax = gca;
ax.ThetaZeroLocation = 'bottom';
ax.RAxisLocation = 0;
ax.ThetaTickLabel = {'0'; '30'; '60'; '90'; '120'; '150'; '180'; '150'; '120'; '90'; '60'; '30';};
</code>```

答:
I have not tried this but you could convert your polar coordinates into cartesian ones using pol2cart, then add the third dimension and use fill3 to render the surface.

Ok, I'm procrastinating and implemented it here:

```<code>% range of angles
angles = 0:0.01:(2*pi);

% light intensity example (insert values from table)
r = 1 + sin(angles);

% convert to cartesian coordinates
[p1, p2] = pol2cart(angles, r);

% plot on x-axis (x=0)
X = zeros(size(p1));
Y = p1;
Z = p2;
C = ones(size(Z)); % color input needed
fill3(X,Y,Z,C)
hold on

% plot on y-axis (y=0)
X = p1;
Y = zeros(size(p1));
Z = p2;
C = ones(size(Z))+1;
fill3(p1,zeros(size(p1)),p2,C)

xlabel('x')
ylabel('y')
zlabel('z')
grid on
</code>```

For your specific dataset, you can do the following

```<code>% angles around x-axis, need to turn by 90 degree right pol2cart output
anglesX = (0:5:360)/180*pi+pi/2;

% angles around z-axis
anglesZ = 0:15:90;

% loop over columns
for i = 1:size(ldc,2)

    % you need to create a closed contour for fill3
    ldcJoined = [ldc(:,i);ldc((end-1):-1:1,i)];

    % plot for positive and negative angle around z, i as color-index
    plotPlane(anglesX, ldcJoined, anglesZ(i), i)
    hold on
    plotPlane(anglesX, ldcJoined, -anglesZ(i), i)
end

xlabel('x')
ylabel('y')
zlabel('z')

function [] = plotPlane(anglesX, r, angleZ, c)

    % convert to cartesian coordinates
    [p1, p2] = pol2cart(anglesX, r');

    % plot on x-axis (x=0)
    X = zeros(size(p1));
    Y = p1;
    Z = p2;
    C = ones(size(Z)) .* c; % color input needed, you could e.g. C=sin(angles);
    h = fill3(X,Y,Z,C);
    rotate(h, [0,0,1], angleZ)

end
</code>```

Which gives

Body:
I would like to plot the C-planes that describe the light distribution curve (ldc) of a light source in 2D and 3D space respectively. Usually the manufacturers provide the details of the ldc in polar coordinates. An example can be seen below:

together with the graph (the red lines solid/dashed represent the C-planes)

the above 2D plot can be plotted in simulation software quite nicely as you can see in the images below:

Now if it is possible I would like to plot the same graphs/plots in matlab as well. However, I am not sure how to do it. For the 2D graph I had a look at the polarplot() function but I am not sure what my input should be based on my matrix. Regarding the 3D plot, totally no clue how I could get the plot in 3D space. Therefore, if someone could provide me with some hints or a solution it would be really helpful. Below are the values of the above matrix in case someone wants to experiment with it.

Many thanks in advance.

Update:

Ok plotting the 2D polar diagram can be achieved with the following code:

ldc = [426.0060  426.0060  426.0060  426.0060  426.0060  426.0060  426.0060
  424.7540  425.0980  425.5810  425.9940  425.6490  425.1670  424.7540
  421.8600  422.2040  422.7550  423.1690  422.6860  422.2040  421.8600
  415.5200  416.0020  416.1400  416.8980  416.6910  416.2780  415.7960
  408.6290  406.9060  407.0440  408.0090  409.0420  407.3890  406.5620
  394.1580  394.2960  394.5030  395.1920  395.0540  394.5720  394.5720
  374.5880  375.8290  376.9310  376.6550  374.6570  376.3800  377.4820
  349.7810  351.3660  352.8130  351.9170  350.7460  352.1930  353.9150
  317.8070  316.2910  318.2210  316.2910  316.8420  317.1870  319.8750
  267.2280  269.4330  264.4720  267.9170  267.9170  269.6400  266.1260
  200.4280  162.1010  174.1260  163.2380  199.5320  163.8650  174.8770
  111.4940  118.7160  150.0280  118.3780  112.6450  116.1870  151.6540
   73.5810   78.4390   99.5180   80.3960   75.7450   78.4250  100.4280
   49.7660   69.2120   54.2240   71.2930   52.1980   71.8860   56.8360
   35.5290   49.5180   46.4930   48.3810   35.8390   47.2780   48.2220
   34.3720   37.9410   35.3290   38.5750   33.9930   39.9950   35.4050
   24.1730   24.9380   28.9690   25.8750   24.7800   24.6350   28.5140
   14.3050   15.9870   19.6670   16.4830   15.1460   15.9450   19.7770
    6.0920    6.5390    7.0420    7.2350    6.9940    6.8220    6.6840
    4.7550    4.9550    5.2780    5.2160    5.2090    5.4780    5.6640
    3.8590    3.8520    3.8930    3.9000    3.8870    4.3210    4.4380
    3.1150    3.1420    2.9350    2.8530    3.0870    3.4660    3.5970
    2.8670    2.6670    2.4740    2.3500    2.5700    2.9290    3.1700
    2.4120    2.4050    2.3360    2.0330    2.3500    2.6050    2.7840
    1.6540    1.6670    1.9090    1.8880    1.7300    1.5920    1.6810
    1.1300    1.1990    1.2680    1.4880    1.2270    1.1580    1.1300
    1.0470    1.0400    1.0400    1.1440    1.0750    1.0540    1.0470
    1.1300    1.1640    1.2060    1.1850    1.2130    1.1850    1.1710
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0];

color = 'r';
line = '-';
% plotting only the first and the last C-planes, i.e. 0 and 90 degrees respectively
for i = 1:6:size(ldc,2)
    polarplot(degtorad(theta),ldc(:,i), 'Color', color, 'LineStyle', line, 'LineWidth', 1.5)
    hold on
    polarplot(-degtorad(theta),ldc(:,i), 'Color' ,color, 'LineStyle', line, 'LineWidth', 1.5)
    line = ':';
end

ax = gca;
ax.ThetaZeroLocation = 'bottom';
ax.RAxisLocation = 0;
ax.ThetaTickLabel = {'0'; '30'; '60'; '90'; '120'; '150'; '180'; '150'; '120'; '90'; '60'; '30';};

Body:
I have not tried this but you could convert your polar coordinates into cartesian ones using pol2cart, then add the third dimension and use fill3 to render the surface.

Ok, I'm procrastinating and implemented it here:

% range of angles
angles = 0:0.01:(2*pi);

% light intensity example (insert values from table)
r = 1 + sin(angles);

% convert to cartesian coordinates
[p1, p2] = pol2cart(angles, r);

% plot on x-axis (x=0)
X = zeros(size(p1));
Y = p1;
Z = p2;
C = ones(size(Z)); % color input needed
fill3(X,Y,Z,C)
hold on

% plot on y-axis (y=0)
X = p1;
Y = zeros(size(p1));
Z = p2;
C = ones(size(Z))+1;
fill3(p1,zeros(size(p1)),p2,C)

xlabel('x')
ylabel('y')
zlabel('z')
grid on

For your specific dataset, you can do the following

% angles around x-axis, need to turn by 90 degree right pol2cart output
anglesX = (0:5:360)/180*pi+pi/2;

% angles around z-axis
anglesZ = 0:15:90;

% loop over columns
for i = 1:size(ldc,2)

    % you need to create a closed contour for fill3
    ldcJoined = [ldc(:,i);ldc((end-1):-1:1,i)];

    % plot for positive and negative angle around z, i as color-index
    plotPlane(anglesX, ldcJoined, anglesZ(i), i)
    hold on
    plotPlane(anglesX, ldcJoined, -anglesZ(i), i)
end

xlabel('x')
ylabel('y')
zlabel('z')

function [] = plotPlane(anglesX, r, angleZ, c)

    % convert to cartesian coordinates
    [p1, p2] = pol2cart(anglesX, r');

    % plot on x-axis (x=0)
    X = zeros(size(p1));
    Y = p1;
    Z = p2;
    C = ones(size(Z)) .* c; % color input needed, you could e.g. C=sin(angles);
    h = fill3(X,Y,Z,C);
    rotate(h, [0,0,1], angleZ)

end

Which gives


问:
ASP.NET MVC 5 Internationalization
I'm starting a new solution in ASP.NET MVC5 and I'll have to implement internationalization for the whole views.

The best article I found so far that explains how to well implement ASP.NET MVC 5 Internationalization was this one. I also read this one.

Anyway I still have some questions that I'd like the ask here in order to make sure about the best practices of internationalization which ones I still haven't found clearly answers on web.

Where should I put my local (resources for a specific view) .resx files?
App_LocalResources folder? ItemView folder with all the other files? Where exactly and why?

How can I access my local resources values? Should I put them over the same App_GlobalResources namespace's .resx files (namespace Resources)?

Thank you in advance.

答:
You can simply put your resource files in a custom folder.
I created a "resources" folder and it works like a charm.

To access values, here an example for an action link:

```<code>@Html.ActionLink(Resources.Labels.Archivio, "Archivio", "Home")
</code>```

Note you don't specify the Language, because MVC takes the locale loaded into the current thread

```<code>        Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(cultureName);
        Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;
</code>```

Title: ASP.NET MVC 5 Internationalization

Body:
You can simply put your resource files in a custom folder.
I created a "resources" folder and it works like a charm.

To access values, here an example for an action link:

@Html.ActionLink(Resources.Labels.Archivio, "Archivio", "Home")

Note you don't specify the Language, because MVC takes the locale loaded into the current thread

        Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(cultureName);
        Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;


问:
Log in a site and navigate another pages
I have a script for Python 2 to login into a webpage and then move inside to reach a couple of files pointed to on the same site, but different pages. Python 2 let me open the site with my credentials and then create a opener.open() to keep the connection available to navigate to the other pages.

Here's the code that worked in Python 2:

```<code>$Your admin login and password
LOGIN = "*******"
PASSWORD = "********"
ROOT = "https:*********"

#The client have to take care of the cookies.
jar = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))

#POST login query on '/login_handler' (post data are: 'login' and 'password').
req = urllib2.Request(ROOT + "/login_handler",
                      urllib.urlencode({'login': LOGIN,
                                        'password': PASSWORD}))
opener.open(rep)

#Set the right accountcode

for accountcode, queues in QUEUES.items():
    req = urllib2.Request(ROOT + "/switch_to" + accountcode)
    opener.open(req)
</code>```

I need to do the same thing in Python 3. I have tried with request module and urllib, but although I can establish the first login, I don't know how to keep the opener to navigate the site. I found the OpenerDirector but it seems like I don't know how to do it, because I haven't reached my goal.

I have used this Python 3 code to get the result desired but unfortunately I can't get the csv file to print it.
enter image description here

答:
Question: I don't know how to keep the opener to navigate the site.

Python 3.6» Documentation urllib.request.build_opener

Use of Basic HTTP Authentication:

```<code>import urllib.request
# Create an OpenerDirector with support for Basic HTTP Authentication...
auth_handler = urllib.request.HTTPBasicAuthHandler()
auth_handler.add_password(realm='PDQ Application',
                      uri='https://mahler:8092/site-updates.py',
                      user='klem',
                      passwd='kadidd!ehopper')

opener = urllib.request.build_opener(auth_handler)

# ...and install it globally so it can be used with urlopen.
urllib.request.install_opener(opener)
f = urllib.request.urlopen('http://www.example.com/login.html')
csv_content = f.read()
</code>```

Body:
I have a script for Python 2 to login into a webpage and then move inside to reach a couple of files pointed to on the same site, but different pages. Python 2 let me open the site with my credentials and then create a opener.open() to keep the connection available to navigate to the other pages.

Here's the code that worked in Python 2:

$Your admin login and password
LOGIN = "*******"
PASSWORD = "********"
ROOT = "https:*********"

#The client have to take care of the cookies.
jar = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))

#POST login query on '/login_handler' (post data are: 'login' and 'password').
req = urllib2.Request(ROOT + "/login_handler",
                      urllib.urlencode({'login': LOGIN,
                                        'password': PASSWORD}))
opener.open(rep)

#Set the right accountcode

for accountcode, queues in QUEUES.items():
    req = urllib2.Request(ROOT + "/switch_to" + accountcode)
    opener.open(req)

I need to do the same thing in Python 3. I have tried with request module and urllib, but although I can establish the first login, I don't know how to keep the opener to navigate the site. I found the OpenerDirector but it seems like I don't know how to do it, because I haven't reached my goal.

I have used this Python 3 code to get the result desired but unfortunately I can't get the csv file to print it.
enter image description here

Body:
Question: I don't know how to keep the opener to navigate the site.

Python 3.6» Documentation urllib.request.build_opener

Use of Basic HTTP Authentication:

import urllib.request
# Create an OpenerDirector with support for Basic HTTP Authentication...
auth_handler = urllib.request.HTTPBasicAuthHandler()
auth_handler.add_password(realm='PDQ Application',
                      uri='https://mahler:8092/site-updates.py',
                      user='klem',
                      passwd='kadidd!ehopper')

opener = urllib.request.build_opener(auth_handler)

# ...and install it globally so it can be used with urlopen.
urllib.request.install_opener(opener)
f = urllib.request.urlopen('http://www.example.com/login.html')
csv_content = f.read()


问:
Writing variable's content to a variable file inside a variable-directory
Let's say I write the following script:

```<code>#!/bin/sh
TEXT="hello"
DIR="test"
FILE="bla.txt"
echo $TEXT > $DIR/$FILE
</code>```

When running it, I get the following error:

```<code>test.sh: line 5: test/bla.txt: No such file or directory
</code>```

But if change the last line to:

```<code>echo $TEXT > $FILE
</code>```

I don't get the error.

I know I can work around it and do:

```<code>FILE_TO_WRITE_TO=$DIR/$FILE
echo $TEXT > $FILE_TO_WRITE_TO
</code>```

But I don't understand why does the error occur in the first place.

答:
The following command gives No such file or directory error because test directory doesn't exist or Not a directory if it is not a directory.

```<code>echo "hello" > test/bla.txt
</code>```

To create the directory if necessary, and error management.

```<code>mkdir -p "$DIR" || { echo "failed to mkdir $DIR"; exit 1;}
echo "$TEXT" > "$DIR/$FILE" || { echo "failed to open $DIR/$FILE for writting"; exit 1;}
</code>```

Body:
Let's say I write the following script:

#!/bin/sh
TEXT="hello"
DIR="test"
FILE="bla.txt"
echo $TEXT > $DIR/$FILE

When running it, I get the following error:

test.sh: line 5: test/bla.txt: No such file or directory

But if change the last line to:

echo $TEXT > $FILE

I don't get the error.

I know I can work around it and do:

FILE_TO_WRITE_TO=$DIR/$FILE
echo $TEXT > $FILE_TO_WRITE_TO

But I don't understand why does the error occur in the first place.

Body:
The following command gives No such file or directory error because test directory doesn't exist or Not a directory if it is not a directory.

echo "hello" > test/bla.txt

To create the directory if necessary, and error management.

mkdir -p "$DIR" || { echo "failed to mkdir $DIR"; exit 1;}
echo "$TEXT" > "$DIR/$FILE" || { echo "failed to open $DIR/$FILE for writting"; exit 1;}


问:
Auto rotation for 1 tab out of 5
I have 5 tabs in my app and one needs to be able to autorotate. So far I have been able to get all 5 tabs to rotate using:

```<code>(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{
    return YES;
}
</code>```

However I only need 1 to rotate. How can I do this?

答:
You can try checking the active tab using myTabBarController.selectedIndex or myTabBarController.selectedViewController. Return YES or NO based on which tab is active.

Beware though: what happens if you rotate the device in a non-rotating tab (i.e. nothing happens), then go to your rotating tab? My guess is that it will be in its previous, unrotated state, as it never received any messages concerning rotation.

OwnerDisplayName: James Shaw

Title: Auto rotation for 1 tab out of 5

Body:
I have 5 tabs in my app and one needs to be able to autorotate. So far I have been able to get all 5 tabs to rotate using:

(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{
    return YES;
}

However I only need 1 to rotate. How can I do this?


问:
how programming this whidget in wordpress?
recently I work work on wordpress template and edit that . I add some block manually to that , now I want convert my code to widget . I want add 4image and link to seems like that . what can I do for this ?

答: Create A wordpress widget, add your code which to be displayed into the public area. ( public function)</p>


问:
Ionic 2 camera plugin Installation error
I am trying to install ionic plugin add cordova-plugin-camera
and getting following error in windows system-

Ionic cordova -plugin installation error

```<code>Error: Failed to fetch plugin cordova-plugin-camera via registry. Probably this is either a connection problem, or plugin spec is incorrect. Check your connection and plugin name/version/URL. Error: cmd: Command failed with exit code 4294963248 Error output: node-pre-gyp ERR! UNCAUGHT EXCEPTION node-pre-gyp ERR! stack Error: Cannot find module 'internal/fs' node-pre-gyp ERR! stack at Function.Module._resolveFilename (module.js:470:15) node-pre-gyp ERR! stack at Function.Module._load (module.js:418:25) node-pre-gyp ERR! stack at Module.require (module.js:498:17) node-pre-gyp ERR! stack at require (internal/module.js:20:19) node-pre-gyp ERR! stack at evalmachine.<anonymous>:18:20 node-pre-gyp ERR! stack at Object.<anonymous> (D:\Ionic Demo\Social-Media\node_modules\thread-sleep\node_modules\node-pre-gyp\nod e_modules\tar\node_modules\fstream\node_modules\graceful-fs\fs.js:11:1) node-pre-gyp ERR! stack at Module._compile (module.js:571:32) node-pre-gyp ERR! stack at Object.Module._extensions..js (module.js:580:10) node-pre-gyp ERR! stack at Module.load (module.js:488:32) node-pre-gyp ERR! stack at tryModuleLoad (module.js:447:12) node-pre-gyp ERR! System Windows_NT 6.1.7601 node-pre-gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "D:\\Ionic Demo\\Social-Media\\node_modules\\thread-sleep\\node_modul es\\node-pre-gyp\\bin\\node-pre-gyp" "install" "--fallback-to-build" node-pre-gyp ERR! cwd D:\Ionic Demo\Social-Media\node_modules\thread-sleep node-pre-gyp ERR! node -v v7.5.0 node-pre-gyp ERR! node-pre-gyp -v v0.6.9 node-pre-gyp ERR! This is a bug in `node-pre-gyp`. node-pre-gyp ERR! Try to update node-pre-gyp and file an issue if it does not help: node-pre-gyp ERR! <https://github.com/mapbox/node-pre-gyp/issues> npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules\chokidar\node_modules\fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.1: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"}) npm WARN optional SKIPPING OPTIONAL DEPENDENCY: thread-sleep@1.0.4 (node_modules\thread-sleep): npm WARN optional SKIPPING OPTIONAL DEPENDENCY: thread-sleep@1.0.4 install: `node-pre-gyp install --fallback-to-build` npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 7 npm ERR! Windows_NT 6.1.7601 npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "cordov a-plugin-camera" "--save" npm ERR! node v7.5.0 npm ERR! npm v4.1.2 npm ERR! path D:\Ionic Demo\Social-Media\node_modules\thread-sleep\node_modules\node-pre-gyp\node_modules\nopt\node_modules npm ERR! code EPERM npm ERR! errno -4048 npm ERR! syscall scandir npm ERR! Error: EPERM: operation not permitted, scandir 'D:\Ionic Demo\Social-Media\node_modules\thread-sleep\node_modules\node-pre-g yp\node_modules\nopt\node_modules' npm ERR! { Error: EPERM: operation not permitted, scandir 'D:\Ionic Demo\Social-Media\node_modules\thread-sleep\node_modules\node-pr e-gyp\node_modules\nopt\node_modules' npm ERR! errno: -4048, npm ERR! code: 'EPERM', npm ERR! syscall: 'scandir', npm ERR! path: 'D:\\Ionic Demo\\Social-Media\\node_modules\\thread-sleep\\node_modules\\node-pre-gyp\\node_modules\\nopt\\node_modu les' } npm ERR! npm ERR! Please try running this command again as root/Administrator. npm ERR! Please include the following file with any support request: npm ERR! D:\Ionic Demo\Social-Media\node_modules\npm-debug.log
</code>```

Any help in this would be appreciable,thanks

答:
I solved this reinstalling the plugin for backwards compatible with previous versions of Cordova cordova-plugin-compat.

You have to follow this steps:

cordova plugin remove --force cordova-plugin-compat

cordova plugin add cordova-plugin-compat

cordova plugin add cordova-plugin-camera

Body:
I am trying to install ionic plugin add cordova-plugin-camera
and getting following error in windows system-

Ionic cordova -plugin installation error

Error: Failed to fetch plugin cordova-plugin-camera via registry. Probably this is either a connection problem, or plugin spec is incorrect. Check your connection and plugin name/version/URL. Error: cmd: Command failed with exit code 4294963248 Error output: node-pre-gyp ERR! UNCAUGHT EXCEPTION node-pre-gyp ERR! stack Error: Cannot find module 'internal/fs' node-pre-gyp ERR! stack at Function.Module._resolveFilename (module.js:470:15) node-pre-gyp ERR! stack at Function.Module._load (module.js:418:25) node-pre-gyp ERR! stack at Module.require (module.js:498:17) node-pre-gyp ERR! stack at require (internal/module.js:20:19) node-pre-gyp ERR! stack at evalmachine.<anonymous>:18:20 node-pre-gyp ERR! stack at Object.<anonymous> (D:\Ionic Demo\Social-Media\node_modules\thread-sleep\node_modules\node-pre-gyp\nod e_modules\tar\node_modules\fstream\node_modules\graceful-fs\fs.js:11:1) node-pre-gyp ERR! stack at Module._compile (module.js:571:32) node-pre-gyp ERR! stack at Object.Module._extensions..js (module.js:580:10) node-pre-gyp ERR! stack at Module.load (module.js:488:32) node-pre-gyp ERR! stack at tryModuleLoad (module.js:447:12) node-pre-gyp ERR! System Windows_NT 6.1.7601 node-pre-gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "D:\\Ionic Demo\\Social-Media\\node_modules\\thread-sleep\\node_modul es\\node-pre-gyp\\bin\\node-pre-gyp" "install" "--fallback-to-build" node-pre-gyp ERR! cwd D:\Ionic Demo\Social-Media\node_modules\thread-sleep node-pre-gyp ERR! node -v v7.5.0 node-pre-gyp ERR! node-pre-gyp -v v0.6.9 node-pre-gyp ERR! This is a bug in `node-pre-gyp`. node-pre-gyp ERR! Try to update node-pre-gyp and file an issue if it does not help: node-pre-gyp ERR! <https://github.com/mapbox/node-pre-gyp/issues> npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules\chokidar\node_modules\fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.1: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"}) npm WARN optional SKIPPING OPTIONAL DEPENDENCY: thread-sleep@1.0.4 (node_modules\thread-sleep): npm WARN optional SKIPPING OPTIONAL DEPENDENCY: thread-sleep@1.0.4 install: `node-pre-gyp install --fallback-to-build` npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 7 npm ERR! Windows_NT 6.1.7601 npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "cordov a-plugin-camera" "--save" npm ERR! node v7.5.0 npm ERR! npm v4.1.2 npm ERR! path D:\Ionic Demo\Social-Media\node_modules\thread-sleep\node_modules\node-pre-gyp\node_modules\nopt\node_modules npm ERR! code EPERM npm ERR! errno -4048 npm ERR! syscall scandir npm ERR! Error: EPERM: operation not permitted, scandir 'D:\Ionic Demo\Social-Media\node_modules\thread-sleep\node_modules\node-pre-g yp\node_modules\nopt\node_modules' npm ERR! { Error: EPERM: operation not permitted, scandir 'D:\Ionic Demo\Social-Media\node_modules\thread-sleep\node_modules\node-pr e-gyp\node_modules\nopt\node_modules' npm ERR! errno: -4048, npm ERR! code: 'EPERM', npm ERR! syscall: 'scandir', npm ERR! path: 'D:\\Ionic Demo\\Social-Media\\node_modules\\thread-sleep\\node_modules\\node-pre-gyp\\node_modules\\nopt\\node_modu les' } npm ERR! npm ERR! Please try running this command again as root/Administrator. npm ERR! Please include the following file with any support request: npm ERR! D:\Ionic Demo\Social-Media\node_modules\npm-debug.log

Any help in this would be appreciable,thanks


问:
run for-loop for large numbers in python
```<code> for i in range(1000000000):
 print(i)
</code>```

This snippet gives memory error than How to run this loop. Any suggestions on how to run it.Thanks.

```<code>>>>MemoryError
</code>```

UPDATE:
Actually I was trying something like this:

```<code>arr = []

for i in xrange(1000000000):
    arr.append(i*i)
print(max(set(arr)))
</code>```

I don't know how to deal with such large numbers.

答:
Depends on exactly what you're trying to do. Given that you're using xrange already, I'm going to assume that the issue is with the size of the array that you're creating. If you only want the largest element, you don't need to keep the whole array in memory.

```<code>max_ = float("-inf")
for n in xrange(10000000000):
    if n**2 > max_:
        max_ = n**2

print(max_)
</code>```

Alternatively, if you do want the whole array, you could write the values to a file, then read the file back in chunks.

Body:
 for i in range(1000000000):
 print(i)

This snippet gives memory error than How to run this loop. Any suggestions on how to run it.Thanks.

>>>MemoryError

UPDATE:
Actually I was trying something like this:

arr = []

for i in xrange(1000000000):
    arr.append(i*i)
print(max(set(arr)))

I don't know how to deal with such large numbers.

Body:
Depends on exactly what you're trying to do. Given that you're using xrange already, I'm going to assume that the issue is with the size of the array that you're creating. If you only want the largest element, you don't need to keep the whole array in memory.

max_ = float("-inf")
for n in xrange(10000000000):
    if n**2 > max_:
        max_ = n**2

print(max_)

Alternatively, if you do want the whole array, you could write the values to a file, then read the file back in chunks.


问:
is this possible Bootstrap carousel thumbnail display 4 column in desktop and 2 column in mobile?
I'm Trying to Display Bootstrap carousel in different views. like when it is diaplay on desktop it has 4 column and in mobile it will display 2 column.
this is my code. it is 4 column thumbnail view. but when i see in mobile view it will display item below. I find on google. i got this https://www.codeply.com/go/PKto9ssn0W/bootstrap-4-carousel-with-thumbnail-navigation. but its not working.</p>

```<code><!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
 <style>

.carousel-inner.onebyone-carosel { margin: auto; width: 90%; }
.onebyone-carosel .active.left { left: -33.33%; }
.onebyone-carosel .active.right { left: 33.33%; }
.onebyone-carosel .next { left: 33.33%; }
.onebyone-carosel .prev { left: -33.33%; }
    </style>
</head>
<body>

    <div class="container">
        <div class="row">
            <div class="span12">
                <div class="well">
                    <div id="myCarousel" class="carousel fdi-Carousel slide">
                     <!-- Carousel items -->
                        <div class="carousel fdi-Carousel slide" id="eventCarousel" data-interval="0">
                            <div class="carousel-inner onebyone-carosel">
                                <div class="item active">
                                    <div class="col-md-4">
                                        <a href="#"><img src="http://placehold.it/250x250" class="img-responsive center-block"></a>
                                        <div class="text-center">1</div>
                                    </div>
                                </div>
                                <div class="item">
                                    <div class="col-md-4">
                                        <a href="#"><img src="http://placehold.it/250x250" class="img-responsive center-block"></a>
                                        <div class="text-center">2</div>
                                    </div>
                                </div>
                                <div class="item">
                                    <div class="col-md-4">
                                        <a href="#"><img src="http://placehold.it/250x250" class="img-responsive center-block"></a>
                                        <div class="text-center">3</div>
                                    </div>
                                </div>
                                <div class="item">
                                    <div class="col-md-4">
                                        <a href="#"><img src="http://placehold.it/250x250" class="img-responsive center-block"></a>
                                        <div class="text-center">4</div>
                                    </div>
                                </div>
                                <div class="item">
                                    <div class="col-md-4">
                                        <a href="#"><img src="http://placehold.it/250x250" class="img-responsive center-block"></a>
                                        <div class="text-center">5</div>
                                    </div>
                                </div>
                                <div class="item">
                                    <div class="col-md-4">
                                        <a href="#"><img src="http://placehold.it/250x250" class="img-responsive center-block"></a>
                                        <div class="text-center">6</div>
                                    </div>
                                </div>
                            </div>
                            <a class="left carousel-control" href="#eventCarousel" data-slide="prev"></a>
                            <a class="right carousel-control" href="#eventCarousel" data-slide="next"></a>
                        </div>
                        <!--/carousel-inner-->
                    </div><!--/myCarousel-->
                </div><!--/well-->
            </div>
        </div>
    </div>

<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

<script>
    $(document).ready(function () {
    $('#myCarousel').carousel({
        interval: 10000
    })
    $('.fdi-Carousel .item').each(function () {
        var next = $(this).next();
        if (!next.length) {
            next = $(this).siblings(':first');
        }
        next.children(':first-child').clone().appendTo($(this));

        if (next.next().length > 0) {
            next.next().children(':first-child').clone().appendTo($(this));
        }
        else {
            $(this).siblings(':first').children(':first-child').clone().appendTo($(this));
        }
    });
});
    </script>
</body>
</html>
</code>```

答:
This will display two columns on mobile using col-xs-6 and 3 columns on desktop using col-md-4 that you have in your example code. If you want another column on desktop, all you need to do is change the class from col-md-4 to col-md-3.

I also added a height and overflow: hidden to the #myCarousel css.

```<code><!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
 <style>

.carousel-inner.onebyone-carosel { margin: auto; width: 90%; }
.onebyone-carosel .active.left { left: -33.33%; }
.onebyone-carosel .active.right { left: 33.33%; }
.onebyone-carosel .next { left: 33.33%; }
.onebyone-carosel .prev { left: -33.33%; }
#myCarousel { height: 250px; overflow: hidden;
    }
    </style>
}
</head>
<body>

    <div class="container">
        <div class="row">
            <div class="span12">
                <div class="well">
                    <div id="myCarousel" class="carousel fdi-Carousel slide">
                     <!-- Carousel items -->
                        <div class="carousel fdi-Carousel slide" id="eventCarousel" data-interval="0">
                            <div class="carousel-inner onebyone-carosel">
                                <div class="item active">
                                    <div class="col-xs-6 col-md-4">
                                        <a href="#"><img src="http://placehold.it/250x250" class="img-responsive center-block"></a>
                                        <div class="text-center">1</div>
                                    </div>
                                </div>
                                <div class="item">
                                    <div class="col-xs-6 col-md-4">
                                        <a href="#"><img src="http://placehold.it/250x250" class="img-responsive center-block"></a>
                                        <div class="text-center">2</div>
                                    </div>
                                </div>
                                <div class="item">
                                    <div class="col-xs-6 col-md-4">
                                        <a href="#"><img src="http://placehold.it/250x250" class="img-responsive center-block"></a>
                                        <div class="text-center">3</div>
                                    </div>
                                </div>
                                <div class="item">
                                    <div class="col-xs-6 col-md-4">
                                        <a href="#"><img src="http://placehold.it/250x250" class="img-responsive center-block"></a>
                                        <div class="text-center">4</div>
                                    </div>
                                </div>
                                <div class="item">
                                    <div class="col-xs-6 col-md-4">
                                        <a href="#"><img src="http://placehold.it/250x250" class="img-responsive center-block"></a>
                                        <div class="text-center">5</div>
                                    </div>
                                </div>
                                <div class="item">
                                    <div class="col-xs-6 col-md-4">
                                        <a href="#"><img src="http://placehold.it/250x250" class="img-responsive center-block"></a>

                           <div class="text-center">6</div>
                                </div>
                            </div>
                        </div>
                        <a class="left carousel-control" href="#eventCarousel" data-slide="prev"></a>
                        <a class="right carousel-control" href="#eventCarousel" data-slide="next"></a>
                    </div>
                    <!--/carousel-inner-->
                </div><!--/myCarousel-->
            </div><!--/well-->
        </div>
    </div>
</div>

<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

<script>
    $(document).ready(function () {
    $('#myCarousel').carousel({
        interval: 10000
    })
    $('.fdi-Carousel .item').each(function () {
        var next = $(this).next();
        if (!next.length) {
            next = $(this).siblings(':first');
        }
        next.children(':first-child').clone().appendTo($(this));

        if (next.next().length > 0) {
            next.next().children(':first-child').clone().appendTo($(this));
        }
        else {
            $(this).siblings(':first').children(':first-child').clone().appendTo($(this));
        }
    });
});
    </script>
</body>
</html>
</code>```

Body:
I'm Trying to Display Bootstrap carousel in different views. like when it is diaplay on desktop it has 4 column and in mobile it will display 2 column.
this is my code. it is 4 column thumbnail view. but when i see in mobile view it will display item below. I find on google. i got this https://www.codeply.com/go/PKto9ssn0W/bootstrap-4-carousel-with-thumbnail-navigation. but its not working.

<!DOCTYPE html>

    <meta charset="UTF-8">
    <title>Document</title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

1

2

3

4

5

6

Body:
This will display two columns on mobile using col-xs-6 and 3 columns on desktop using col-md-4 that you have in your example code. If you want another column on desktop, all you need to do is change the class from col-md-4 to col-md-3.

I also added a height and overflow: hidden to the #myCarousel css.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
 <style>

.carousel-inner.onebyone-carosel { margin: auto; width: 90%; }
.onebyone-carosel .active.left { left: -33.33%; }
.onebyone-carosel .active.right { left: 33.33%; }
.onebyone-carosel .next { left: 33.33%; }
.onebyone-carosel .prev { left: -33.33%; }
#myCarousel { height: 250px; overflow: hidden;
    }
    </style>
}
</head>
<body>

    <div class="container">
        <div class="row">
            <div class="span12">
                <div class="well">
                    <div id="myCarousel" class="carousel fdi-Carousel slide">
                     <!-- Carousel items -->
                        <div class="carousel fdi-Carousel slide" id="eventCarousel" data-interval="0">
                            <div class="carousel-inner onebyone-carosel">
                                <div class="item active">
                                    <div class="col-xs-6 col-md-4">
                                        <a href="#"><img src="http://placehold.it/250x250" class="img-responsive center-block"></a>
                                        <div class="text-center">1</div>
                                    </div>
                                </div>
                                <div class="item">
                                    <div class="col-xs-6 col-md-4">
                                        <a href="#"><img src="http://placehold.it/250x250" class="img-responsive center-block"></a>
                                        <div class="text-center">2</div>
                                    </div>
                                </div>
                                <div class="item">
                                    <div class="col-xs-6 col-md-4">
                                        <a href="#"><img src="http://placehold.it/250x250" class="img-responsive center-block"></a>
                                        <div class="text-center">3</div>
                                    </div>
                                </div>
                                <div class="item">
                                    <div class="col-xs-6 col-md-4">
                                        <a href="#"><img src="http://placehold.it/250x250" class="img-responsive center-block"></a>
                                        <div class="text-center">4</div>
                                    </div>
                                </div>
                                <div class="item">
                                    <div class="col-xs-6 col-md-4">
                                        <a href="#"><img src="http://placehold.it/250x250" class="img-responsive center-block"></a>
                                        <div class="text-center">5</div>
                                    </div>
                                </div>
                                <div class="item">
                                    <div class="col-xs-6 col-md-4">
                                        <a href="#"><img src="http://placehold.it/250x250" class="img-responsive center-block"></a>

                           <div class="text-center">6</div>
                                </div>
                            </div>
                        </div>
                        <a class="left carousel-control" href="#eventCarousel" data-slide="prev"></a>
                        <a class="right carousel-control" href="#eventCarousel" data-slide="next"></a>
                    </div>
                    <!--/carousel-inner-->
                </div><!--/myCarousel-->
            </div><!--/well-->
        </div>
    </div>
</div>

<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

<script>
    $(document).ready(function () {
    $('#myCarousel').carousel({
        interval: 10000
    })
    $('.fdi-Carousel .item').each(function () {
        var next = $(this).next();
        if (!next.length) {
            next = $(this).siblings(':first');
        }
        next.children(':first-child').clone().appendTo($(this));

        if (next.next().length > 0) {
            next.next().children(':first-child').clone().appendTo($(this));
        }
        else {
            $(this).siblings(':first').children(':first-child').clone().appendTo($(this));
        }
    });
});
    </script>
</body>
</html>


问:
How to add nofollow attribute to wordpress category list?
well, this code fetches the category list and display it in the theme in which the post is assigned. I want to add nofollow tag to this out list. I surfed the net and couldn't find a solution. The only solution I found was to modify the wordpress core files. But I don't want to modify the core files.

```<code><footer class="entry-meta">
        <?php
            /* translators: used between list items, there is a space after the comma */
            $category_list = get_the_category_list( __( ', ', 'basically' ) );

            $meta_text = __( 'Category: %1$s', 'basically' );

            printf(
                $meta_text,
                $category_list,
                get_permalink(),
                the_title_attribute( 'echo=0' )
            );
        ?>
</code>```

Any other way?

答:
Try this too:</p>

```<code><footer class="entry-meta">
        <?php
            /* translators: used between list items, there is a space after the comma */
            $cat_list = get_the_category_list( __( ', ', 'basically' ) );
            $category_list = str_replace('rel="category tag"','rel="category tag nofollow"',$cat_list);

            $meta_text = __( 'Category: %1$s', 'basically' );

            printf(
                $meta_text,
                $category_list,
                get_permalink(),
                the_title_attribute( 'echo=0' )
            );
        ?>
</code>```

Body:
well, this code fetches the category list and display it in the theme in which the post is assigned. I want to add nofollow tag to this out list. I surfed the net and couldn't find a solution. The only solution I found was to modify the wordpress core files. But I don't want to modify the core files.

        <?php
            /* translators: used between list items, there is a space after the comma */
            $category_list = get_the_category_list( __( ', ', 'basically' ) );

            $meta_text = __( 'Category: %1$s', 'basically' );

            printf(
                $meta_text,
                $category_list,
                get_permalink(),
                the_title_attribute( 'echo=0' )
            );
        ?>

Any other way?

Body:
Try this too:

<footer class="entry-meta">
        <?php
            /* translators: used between list items, there is a space after the comma */
            $cat_list = get_the_category_list( __( ', ', 'basically' ) );
            $category_list = str_replace('rel="category tag"','rel="category tag nofollow"',$cat_list);

            $meta_text = __( 'Category: %1$s', 'basically' );

            printf(
                $meta_text,
                $category_list,
                get_permalink(),
                the_title_attribute( 'echo=0' )
            );
        ?>


问:
Spring Profiles org.springframework.beans.factory.NoSuchBeanDefinitionException
My sample project is Maven based structure, all my application proeprties files under src/main/resources folder. Below is the complete sample code. I am not understanding why my code not able to find profiles properly unless I use @PropertySource annotation.

My actual doubt is:  I've configured spring properties pretty well in application.properties file, but yet why it cannot find profile and their respective property files? Unless I am using @PropertySource annotation, iam not getting value for env.getProperty("mysql.url"). I mean Environment class not able to pick up values from profiles property files. WHY?

Iam getting error as below:

```<code>Jul 08, 2017 7:54:26 PM org.springframework.context.annotation.AnnotationConfigApplicationContext prepareRefresh
INFO: Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@300ffa5d: startup date [Sat Jul 08 19:54:26 IST 2017]; root of context hierarchy
helloBean
Exception in thread "main" org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'datasource' available
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:687)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1207)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:284)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1084)
    at com.oreilly.datasource.Main2.main(Main2.java:15)
</code>```

DatasourceConfig.java

```<code>package com.oreilly.datasource;

import javax.sql.DataSource;

import org.apache.commons.dbcp.BasicDataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.annotation.PropertySources;
import org.springframework.core.env.Environment;

@Configuration
/*@PropertySource("classpath:/application.properties")
@PropertySource("classpath:/dev/application-dev.properties")
@PropertySource("classpath:/prod/application-prod.properties")*/
public class DatasourceConfig {

    @Autowired
    private Environment env;

    @Bean(name="helloBean")
    public String helloWorld() {
        System.out.println("helloBean");
        return "helloWorld....";
    }

    @Bean(name="datasource")
    @Profile("dev")
    public DataSource datasourceForDev(){
        BasicDataSource dataSource = new BasicDataSource();
        System.out.println(env.getProperty("mysql.url"));
        return dataSource;
    }

    @Bean(name="datasource")
    @Profile("prod")
    public DataSource datasourceForProd(){
        BasicDataSource dataSource = new BasicDataSource();
        System.out.println(env.getProperty("mysql.url"));
        return dataSource;
    }
}
</code>```

Main2.java

```<code>package com.oreilly.datasource;

import javax.sql.DataSource;

import org.apache.commons.dbcp.BasicDataSource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class Main2 {

    public static void main(String[] args) {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(DatasourceConfig.class);

        DataSource dataSource = context.getBean("datasource", DataSource.class);
        String helloBean = context.getBean("helloBean", String.class);

    }

}
</code>```

application.properties

```<code>spring.profiles.active=prod
spring.config.name=application
spring.config.location=classpath:/application.properties,classpath:/dev/application-dev.properties,classpath:/prod/application-dev.properties
</code>```

Below is the project folder structure:

Please tell me what went wrong?

答:
```<code>@Configuration
@PropertySource("classpath:application.properties")
public class DatasourceConfig {
....
}
</code>```

put property file in same location as application.property and follow the naming convention application-{profile}.properties like application-dev.properties, application-prod.properties.

'I want properties file to be picked up automatically based upon profile I declared in application.properties.'
:

Run you application with -Dspring.profiles.active=dev/prod . Spring load 1)application.property , 2)pplication-dev/prod.properties file with overides value from application.property

Body:
My sample project is Maven based structure, all my application proeprties files under src/main/resources folder. Below is the complete sample code. I am not understanding why my code not able to find profiles properly unless I use @PropertySource annotation.

My actual doubt is:  I've configured spring properties pretty well in application.properties file, but yet why it cannot find profile and their respective property files? Unless I am using @PropertySource annotation, iam not getting value for env.getProperty("mysql.url"). I mean Environment class not able to pick up values from profiles property files. WHY?

Iam getting error as below:

Jul 08, 2017 7:54:26 PM org.springframework.context.annotation.AnnotationConfigApplicationContext prepareRefresh
INFO: Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@300ffa5d: startup date [Sat Jul 08 19:54:26 IST 2017]; root of context hierarchy
helloBean
Exception in thread "main" org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'datasource' available
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:687)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1207)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:284)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1084)
    at com.oreilly.datasource.Main2.main(Main2.java:15)

DatasourceConfig.java

package com.oreilly.datasource;

import javax.sql.DataSource;

import org.apache.commons.dbcp.BasicDataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.annotation.PropertySources;
import org.springframework.core.env.Environment;

@Configuration
/*@PropertySource("classpath:/application.properties")
@PropertySource("classpath:/dev/application-dev.properties")
@PropertySource("classpath:/prod/application-prod.properties")*/
public class DatasourceConfig {

    @Autowired
    private Environment env;

    @Bean(name="helloBean")
    public String helloWorld() {
        System.out.println("helloBean");
        return "helloWorld....";
    }

    @Bean(name="datasource")
    @Profile("dev")
    public DataSource datasourceForDev(){
        BasicDataSource dataSource = new BasicDataSource();
        System.out.println(env.getProperty("mysql.url"));
        return dataSource;
    }

    @Bean(name="datasource")
    @Profile("prod")
    public DataSource datasourceForProd(){
        BasicDataSource dataSource = new BasicDataSource();
        System.out.println(env.getProperty("mysql.url"));
        return dataSource;
    }
}

Main2.java

package com.oreilly.datasource;

import javax.sql.DataSource;

import org.apache.commons.dbcp.BasicDataSource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class Main2 {

    public static void main(String[] args) {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(DatasourceConfig.class);

        DataSource dataSource = context.getBean("datasource", DataSource.class);
        String helloBean = context.getBean("helloBean", String.class);

    }

}

application.properties

spring.profiles.active=prod
spring.config.name=application
spring.config.location=classpath:/application.properties,classpath:/dev/application-dev.properties,classpath:/prod/application-dev.properties

Below is the project folder structure:

Please tell me what went wrong?

Body:
@Configuration
@PropertySource("classpath:application.properties")
public class DatasourceConfig {
....
}

put property file in same location as application.property and follow the naming convention application-{profile}.properties like application-dev.properties, application-prod.properties.

'I want properties file to be picked up automatically based upon profile I declared in application.properties.'
:

Run you application with -Dspring.profiles.active=dev/prod . Spring load 1)application.property , 2)pplication-dev/prod.properties file with overides value from application.property


问:
change div to input on-click polymer without jquery
I have a paper-card containing user data that when I click the "edit" button, I want the data displayed to change into text boxes so that I can edit the data and save when clicking "save".

I have seen something similar in JQuery, however I am wanting to avoid using this.

Any thoughts?

```<code><paper-card>
  <div class="card-content">
    <div class="bodyHeaderText">Personal</div>
    <div class="bodyNormalText">Name: Robert Jones{{user.FUllName}}</div>
    <div class="bodyNormalText">DOB: 21/06/1987{{user.dateofbirth}}</div>
    <div class="bodyNormalText">Age: 30{{user.age}}</div>
    <div class="bodyNormalText">Gender: Male{{user.gender}}</div>
  </div>
  <div class="card-actions"
    <paper-icon-button icon="create">edit mode</paper-icon-button>
  </div>
</paper-card>
</code>```

答:
Create two paper-card elements. One with text and one with input boxes. Use iron-pages to switch between them by clicking on the edit/save button and changing a variable (_view in the example below).</p>

```<code><iron-pages attr-for-selected="data-view" selected="{{_view}}">

  <paper-card data-view="default">
    <!-- TEXT -->
  </paper-card>

  <paper-card data-view="edit">
    <!-- INPUTS -->
  </paper-card>

</iron-pages>
</code>```

Body:
I have a paper-card containing user data that when I click the "edit" button, I want the data displayed to change into text boxes so that I can edit the data and save when clicking "save".

I have seen something similar in JQuery, however I am wanting to avoid using this.

Any thoughts?

<paper-card>

Personal

Name: Robert Jones{{user.FUllName}}

DOB: 21/06/1987{{user.dateofbirth}}

Age: 30{{user.age}}

Gender: Male{{user.gender}}

  <div class="card-actions"
    <paper-icon-button icon="create">edit mode</paper-icon-button>

</paper-card>

Body:
Create two paper-card elements. One with text and one with input boxes. Use iron-pages to switch between them by clicking on the edit/save button and changing a variable (_view in the example below).

<iron-pages attr-for-selected="data-view" selected="{{_view}}">

  <paper-card data-view="default">
    <!-- TEXT -->
  </paper-card>

  <paper-card data-view="edit">
    <!-- INPUTS -->
  </paper-card>

</iron-pages>