问:
Error 'The operation has timed out' when calling Invoke-WebRequest
We are using Invoke-WebRequest in a number of PowerShell scripts that run in sequence over a period of about 10 minutes.

We are trying to understand why, in some rare cases, a System.Net.WebException is thrown with the message:

The operation has timed out

Reading the article Understanding MaxServicePointIdleTime and DefaultConnectionLimit does indicate that the timeout is due reaching the connection limit. Increasing the connection limit does not seem like the way to fix the root cause of the issue.

This makes us think that our scripts are not disposing all of their resources once they are finished. What is the recommended way of using Invoke-WebRequest that disposes all resources?

We are currently doing;

```<code>$response = Invoke-WebRequest -uri $uri_1 -ContentType $mime
// do stuff with $response variable

$response = Invoke-WebRequest -uri $uri_2 -ContentType $mime
// do stuff with $response variable
</code>```

答:
If you do $response | get-member you can see that the HtmlWebResponseObject object has a Dispose Method, so you should be able to dispose of the connection by doing:

```<code>$response.Dispose()
</code>```

after you have finished with it.

Body:
We are using Invoke-WebRequest in a number of PowerShell scripts that run in sequence over a period of about 10 minutes.

We are trying to understand why, in some rare cases, a System.Net.WebException is thrown with the message:

The operation has timed out

Reading the article Understanding MaxServicePointIdleTime and DefaultConnectionLimit does indicate that the timeout is due reaching the connection limit. Increasing the connection limit does not seem like the way to fix the root cause of the issue.

This makes us think that our scripts are not disposing all of their resources once they are finished. What is the recommended way of using Invoke-WebRequest that disposes all resources?

We are currently doing;

$response = Invoke-WebRequest -uri $uri_1 -ContentType $mime
// do stuff with $response variable

$response = Invoke-WebRequest -uri $uri_2 -ContentType $mime
// do stuff with $response variable

Body:
If you do $response | get-member you can see that the HtmlWebResponseObject object has a Dispose Method, so you should be able to dispose of the connection by doing:

$response.Dispose()

after you have finished with it.


来源: stackexchange

问:
UITableView not displaying data correctly with Index in Swift 3
I have a UITableView in my app project which pulls data from a Array. Also this data has to be indexed. But for some reason the data does not display in the appropriate sections i.e A, B etc. I can't seem to see whats wrong. My data so far is:

```<code>import Foundation
import UIKit

class uniVC: UITableViewController {

    let university = ["Allcat University", "Allday University", "Bejnamin University", "Cat University"]

    var universitySections = [String]()
    var wordsDict = [String:[String]]()

    let wordIndexTitles = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]

    func generateWordsDict() {

        for word in university {

            let key = "\(word[word.startIndex])"
            let lower = key.lowercased()

            if var wordValues = wordsDict[lower] {
                wordValues.append(word)
                wordsDict[lower] = wordValues
            } else {
                wordsDict[lower] = [word]
            }

        }

        universitySections = [String](wordsDict.keys)
        universitySections = universitySections.sorted()

    }

    override func viewDidLoad() {
        super.viewDidLoad()

        generateWordsDict()

    }

    override func didReceiveMemoryWarning() {

        super.didReceiveMemoryWarning()
        //Dispose
    }

    // Mark table view data source

    override func numberOfSections(in tableView: UITableView) -> Int {
        return universitySections.count
    }

    override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
        return universitySections[section]
    }

    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        let wordKey = universitySections[section]
        if let wordValues = wordsDict[wordKey] {
            return wordValues.count
        }

        return 0
    }

    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)

        let wordKey = universitySections[indexPath.section]
        if wordsDict[wordKey.lowercased()] != nil {

            cell.textLabel?.text = university[indexPath.row]

        }

        return cell
    }

    override func sectionIndexTitles(for tableView: UITableView) -> [String]? {
        return wordIndexTitles
    }

    override func tableView(_ tableView: UITableView, sectionForSectionIndexTitle title: String, at index: Int) -> Int {

        guard let index = universitySections.index(of: title) else {
            return -1
        }

        return index

    }
}
</code>```

Any ideas on this one?

答:
Your problem is here:

```<code>if wordsDict[wordKey.lowercased()] != nil {
    cell.textLabel?.text = university[indexPath.row]
}
</code>```

No matter which section you are in (i.e. a, b or c) you're then asking for the first university, not the first university in that section. You probably meant to look in wordsDict, instead of university.

Try replacing it with this:

```<code>    if let wordValues = wordsDict[wordKey.lowercased()] {
        cell.textLabel?.text = wordValues[indexPath.row]
    }
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I have a UITableView in my app project which pulls data from a Array. Also this data has to be indexed. But for some reason the data does not display in the appropriate sections i.e A, B etc. I can't seem to see whats wrong. My data so far is:

import Foundation
import UIKit

class uniVC: UITableViewController {

    let university = ["Allcat University", "Allday University", "Bejnamin University", "Cat University"]

    var universitySections = [String]()
    var wordsDict = [String:[String]]()

    let wordIndexTitles = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]

    func generateWordsDict() {

        for word in university {

            let key = "\(word[word.startIndex])"
            let lower = key.lowercased()

            if var wordValues = wordsDict[lower] {
                wordValues.append(word)
                wordsDict[lower] = wordValues
            } else {
                wordsDict[lower] = [word]
            }

        }

        universitySections = [String](wordsDict.keys)
        universitySections = universitySections.sorted()

    }

    override func viewDidLoad() {
        super.viewDidLoad()

        generateWordsDict()

    }

    override func didReceiveMemoryWarning() {

        super.didReceiveMemoryWarning()
        //Dispose
    }

    // Mark table view data source

    override func numberOfSections(in tableView: UITableView) -> Int {
        return universitySections.count
    }

    override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
        return universitySections[section]
    }

    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        let wordKey = universitySections[section]
        if let wordValues = wordsDict[wordKey] {
            return wordValues.count
        }

        return 0
    }

    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)

        let wordKey = universitySections[indexPath.section]
        if wordsDict[wordKey.lowercased()] != nil {

            cell.textLabel?.text = university[indexPath.row]

        }

        return cell
    }

    override func sectionIndexTitles(for tableView: UITableView) -> [String]? {
        return wordIndexTitles
    }

    override func tableView(_ tableView: UITableView, sectionForSectionIndexTitle title: String, at index: Int) -> Int {

        guard let index = universitySections.index(of: title) else {
            return -1
        }

        return index

    }
}

Any ideas on this one?

Body:
Your problem is here:

if wordsDict[wordKey.lowercased()] != nil {
    cell.textLabel?.text = university[indexPath.row]
}

No matter which section you are in (i.e. a, b or c) you're then asking for the first university, not the first university in that section. You probably meant to look in wordsDict, instead of university.

Try replacing it with this:

    if let wordValues = wordsDict[wordKey.lowercased()] {
        cell.textLabel?.text = wordValues[indexPath.row]
    }


问:
getting "twentyzero" "thirty zero" printout
I am trying to printout words from original number. But I was struggline when I tried to enter 20, 30, 40, etc. However, the output would be "twentyzero" instead of "twenty". I made an empty string for zeros

```<code>String [] zero = {""};
</code>```

And then made an If-statement when number = 0;

```<code>if (number == 0){
    String result = zero[number];
    System.out.print("");
    number = In.nextInt();
}
</code>```

However, this didn't work at all. Does anyone have any idea about this. Thank you!

My full code:

```<code>public class NumberToWords {

    public static void main(String[] args) {
        System.out.print("Number: ");
        int number = In.nextInt();
        int onesDigit;
        int tensDigit;
        String[] zero = {""};
        String[] ones = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten",
                "eleven", "tweleve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"};

        String[] tens = {"", "", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"};

        String[] hundreds = {"one hundred", "two hundred", "three hundred", "four hundred", "five hundred",
                "six hundred", "seven hundred", "eight hundred", "nine hundred"};
        while (number != -1) {
            if (number == 0) {
                String result = zero[number];
                System.out.print("");
                number = In.nextInt();

            }
            if (number < 20) {

                String result = ones[number];
                System.out.println("" + result);
                System.out.print("Number: ");
                number = In.nextInt();
            }
            if (number >= 20 && number <= 100) {

                tensDigit = number / 10;
                onesDigit = number % 10;
                System.out.println("" + tens[tensDigit] + "" + ones[onesDigit]);
                System.out.print("Number: ");
                number = In.nextInt();

            }

        }

    }
}
</code>```

答:
I think this can be simply fixed by checking if number is divisible by 10 for any number where 20 <= number <= 100.

```<code>if (number >= 20 && number <= 100) {

    tensDigit = number / 10;
    onesDigit = number % 10;
    if (onesDigit == 0) {
        System.out.println("" + tens[tensDigit])
    } else {
        System.out.println("" + tens[tensDigit] + "" + ones[onesDigit]);
    }
    System.out.print("Number: ");
    number = In.nextInt();

}
</code>```

Body:
I am trying to printout words from original number. But I was struggline when I tried to enter 20, 30, 40, etc. However, the output would be "twentyzero" instead of "twenty". I made an empty string for zeros

String [] zero = {""};

And then made an If-statement when number = 0;

if (number == 0){
    String result = zero[number];
    System.out.print("");
    number = In.nextInt();
}

However, this didn't work at all. Does anyone have any idea about this. Thank you!

My full code:

public class NumberToWords {

    public static void main(String[] args) {
        System.out.print("Number: ");
        int number = In.nextInt();
        int onesDigit;
        int tensDigit;
        String[] zero = {""};
        String[] ones = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten",
                "eleven", "tweleve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"};

        String[] tens = {"", "", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"};

        String[] hundreds = {"one hundred", "two hundred", "three hundred", "four hundred", "five hundred",
                "six hundred", "seven hundred", "eight hundred", "nine hundred"};
        while (number != -1) {
            if (number == 0) {
                String result = zero[number];
                System.out.print("");
                number = In.nextInt();

            }
            if (number < 20) {

                String result = ones[number];
                System.out.println("" + result);
                System.out.print("Number: ");
                number = In.nextInt();
            }
            if (number >= 20 && number <= 100) {

                tensDigit = number / 10;
                onesDigit = number % 10;
                System.out.println("" + tens[tensDigit] + "" + ones[onesDigit]);
                System.out.print("Number: ");
                number = In.nextInt();

            }

        }

    }
}

Body:
I think this can be simply fixed by checking if number is divisible by 10 for any number where 20 <= number <= 100.

if (number >= 20 && number <= 100) {

    tensDigit = number / 10;
    onesDigit = number % 10;
    if (onesDigit == 0) {
        System.out.println("" + tens[tensDigit])
    } else {
        System.out.println("" + tens[tensDigit] + "" + ones[onesDigit]);
    }
    System.out.print("Number: ");
    number = In.nextInt();

}


问:
Correct usage of Clojure for macro
There are 100 buffaloes on the field.
There are 100 whisks on the field.
Each standing buffalo eats 5 whisks.
Each lying buffalo eats 3 whisks.
Each 3 old buffaloes eat 1 whisks.
How many buffaloes of each type are there on the filed?

This is my Clojure code to solve this problem:

```<code>;; s: number of Standing buffaloes
;; l: number of Lying buffaloes
;; o: number of Old buffaloes
(for [s (range 101) l (range 101) o (range 101)
      :while (and
              (= 100 (+ s l o)
               (= 100 (+ (* s 5) (* l 3) (* o 1/3)))))]
     [s l o])
</code>```

My code doesn't work. It should return how many buffaloes of each type but my code only returns an empty sequence. It seems to be logically incorrect. What's wrong with it?

答:
Comment

Having taken @Carcigentate's advice to make it right, you can make it faster thus:

```<code>(for [s (range 101), l (range (- 101 s)) :let [o (- 100 s l)]
      :when (= 100 (+ (* s 5) (* l 3) (* o 1/3)))]
     [s l o])
</code>```

Title: Correct usage of Clojure for macro

Body:
There are 100 buffaloes on the field.
There are 100 whisks on the field.
Each standing buffalo eats 5 whisks.
Each lying buffalo eats 3 whisks.
Each 3 old buffaloes eat 1 whisks.
How many buffaloes of each type are there on the filed?

This is my Clojure code to solve this problem:

;; s: number of Standing buffaloes
;; l: number of Lying buffaloes
;; o: number of Old buffaloes
(for [s (range 101) l (range 101) o (range 101)
      :while (and
              (= 100 (+ s l o)
               (= 100 (+ (* s 5) (* l 3) (* o 1/3)))))]
     [s l o])

My code doesn't work. It should return how many buffaloes of each type but my code only returns an empty sequence. It seems to be logically incorrect. What's wrong with it?

Body:
Comment

Having taken @Carcigentate's advice to make it right, you can make it faster thus:

(for [s (range 101), l (range (- 101 s)) :let [o (- 100 s l)]
      :when (= 100 (+ (* s 5) (* l 3) (* o 1/3)))]
     [s l o])


问:
Login to Microsoft SQL Server Error: 18456
I am getting this error while trying to connect to the SQL Server.

Microsoft SQL Server Error: 18456

Can anybody tell me what the error code means?

答: For me, it was wrong login and password.


问:
How to set dynamic route in codeigniter from database?
In my routes.php file I have added the following code for routing:

```<code>$route['report/:num'] = "home/reportcard/$1";
</code>```

Here is my controller code:

```<code><?php
    defined('BASEPATH') OR exit('No direct script access allowed');

    class Home extends CI_Controller
    {

        function __construct() {
            parent::__construct();

        if(empty($this->session->userdata('id_user'))){
            $this->session->set_flashdata('flash_data', 'You cannot access');
                    redirect('login');
        }
        }
        public function index(){
            $this->load->model("item_model");
            $data['records'] = $this->item_model->getAllItems();
            $this->load->view('home',$data);
        }

       function reportcard($id){
            $this->load->model("item_model");
            $data['report'] = $this->item_model->getReport($id);
            $this->load->view('report', $data);
        }

        function logout(){
            $data=['id_user','username'];
            $this->session->unset_userdata($data);
            redirect('login');

        }
    }
</code>```

Here is my model code:

```<code><?php
    class Item_model extends CI_Model
    {
        function getAllItems()
        {
            $this->load->database();
            $q = $this->db->get("item");
            if($q->num_rows() > 0)
            {
                return $q->result();
            }
            return array();
        }

        public function getReport($id){
            $this->db->select('*');
            $this->db->from('item');
            $this->db->where('item.id', $id);
            $query = $this->db->get();
            if($query->num_rows() > 0)
                return $data->result();
        }

}
?>
</code>```

this is the code of view. I just print the array in my report_view for testing purpose:

```<code><?php
defined('BASEPATH') OR exit('No direct script access allowed');
print_r($report);
?>
</code>```

this is my home_view code:

```<code><div class="row">
                <ul class="home-grid">
                    <?php foreach ($query->result() as $row): ?>
                    <li>
                        <a  href="<?php echo base_url() ?>report/<?=$row->item ?>/<?=$row->id ?>" class="btn btn-lg btn-warning view-report"><span class="glyphicon glyphicon-list-alt"></span> <br/>
                        <?=$row->item ?><br/>
                         <small>Click here for see report</small>
                        </a>
                    </li>
                    <?php endforeach; ?>
                </ul>
</code>```

I have tried multiple times to view the array. But failed to get array. How can I load the view? When I click my items from home, it will create a url like http://localhost/super_shop_register/report/1

But didn't show any data. Show "Object not found!". Here is the image of my view:
After Clicking item, it will show like this:

How can I solve this?

答:
Come on man, your code works perfect in my workout example

my route

```<code>$route['report/(:num)'] = "welcome/workout/$1";
</code>```

My Welcome controller

```<code>public function workout($id)
    {

        echo $id;

    }
</code>```

my url is

```<code>http://localhost/Code/report/1
</code>```

my output is

```<code>1
</code>```

make sure you done the following

removed the index.php on the config like this ($config['index_page'] = '';).

Check .htaccess in root folder with index.php file

and make it below

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ index.php/$1 [L]

Reference: CodeIgniter object not found only the index function works

when i removed my .htaccess code, your error occurs

hope this helps :)

Body:
In my routes.php file I have added the following code for routing:

$route['report/:num'] = "home/reportcard/$1";

Here is my controller code:

<?php
    defined('BASEPATH') OR exit('No direct script access allowed');

    class Home extends CI_Controller
    {

        function __construct() {
            parent::__construct();

        if(empty($this->session->userdata('id_user'))){
            $this->session->set_flashdata('flash_data', 'You cannot access');
                    redirect('login');
        }
        }
        public function index(){
            $this->load->model("item_model");
            $data['records'] = $this->item_model->getAllItems();
            $this->load->view('home',$data);
        }

       function reportcard($id){
            $this->load->model("item_model");
            $data['report'] = $this->item_model->getReport($id);
            $this->load->view('report', $data);
        }

        function logout(){
            $data=['id_user','username'];
            $this->session->unset_userdata($data);
            redirect('login');

        }
    }

Here is my model code:

<?php
    class Item_model extends CI_Model
    {
        function getAllItems()
        {
            $this->load->database();
            $q = $this->db->get("item");
            if($q->num_rows() > 0)
            {
                return $q->result();
            }
            return array();
        }

        public function getReport($id){
            $this->db->select('*');
            $this->db->from('item');
            $this->db->where('item.id', $id);
            $query = $this->db->get();
            if($query->num_rows() > 0)
                return $data->result();
        }

}
?>

this is the code of view. I just print the array in my report_view for testing purpose:

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
print_r($report);
?>

this is my home_view code:

                    <?php foreach ($query->result() as $row): ?>

                        <a  href="<?php echo base_url() ?>report/<?=$row->item ?>/<?=$row->id ?>" class="btn btn-lg btn-warning view-report">

                        <?=$row->item ?>

                         Click here for see report

                    <?php endforeach; ?>

I have tried multiple times to view the array. But failed to get array. How can I load the view? When I click my items from home, it will create a url like http://localhost/super_shop_register/report/1

But didn't show any data. Show "Object not found!". Here is the image of my view:
After Clicking item, it will show like this:

How can I solve this?

Body:
Come on man, your code works perfect in my workout example

my route

$route['report/(:num)'] = "welcome/workout/$1";

My Welcome controller

public function workout($id)
    {

        echo $id;

    }

my url is

http://localhost/Code/report/1

my output is

1

make sure you done the following

removed the index.php on the config like this ($config['index_page'] = '';).

Check .htaccess in root folder with index.php file

and make it below

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ index.php/$1 [L]

Reference: CodeIgniter object not found only the index function works

when i removed my .htaccess code, your error occurs

hope this helps :)


问:
How to create htaccess redirect
When a user is typing below urls

```<code>http://www.oldwebsite.de/schnitz_krippen.php
http://www.oldwebsite/holzrohlinge.php
http://www.oldwebsite/neuheiten.php
http://www.oldwebsite/impressum.php
</code>```

I need these url redirect in to

```<code>http://www.newwebsite.de/impressum.php
</code>```

How it's possible with htaccess? I don't need to redirect the whole website. because some links of old website need to show. eg:http://www.oldwebsite/main.php

```<code>RewriteEngine on
RewriteOptions inherit
RewriteBase /

RewriteCond %{HTTP_HOST} ^www.oldwebsite.com$ [NC]
RewriteRule ^(.*)$ http://www.newwebsite.com/impressum.php [L]
</code>```

答:
This will redirect all the calls to your virtualhost to the new website url:

```<code>RedirectMatch permanent ^(.*)$ http://www.newwebsite.com/impressum.php
</code>```

If you want only certain urls to be redirected:

```<code>Redirect "/schnitz_krippen.php" "http://www.newwebsite.com/impressum.php"
Redirect "/holzrohlinge.php" "http://www.newwebsite.com/impressum.php"
Redirect "/neuheiten.php" "http://www.newwebsite.com/impressum.php"
Redirect "/impressum.php" "http://www.newwebsite.com/impressum.php"
</code>```

Title: How to create htaccess redirect

Body:
When a user is typing below urls

http://www.oldwebsite.de/schnitz_krippen.php
http://www.oldwebsite/holzrohlinge.php
http://www.oldwebsite/neuheiten.php
http://www.oldwebsite/impressum.php

I need these url redirect in to

http://www.newwebsite.de/impressum.php

How it's possible with htaccess? I don't need to redirect the whole website. because some links of old website need to show. eg:http://www.oldwebsite/main.php

RewriteEngine on
RewriteOptions inherit
RewriteBase /

RewriteCond %{HTTP_HOST} ^www.oldwebsite.com$ [NC]
RewriteRule ^(.*)$ http://www.newwebsite.com/impressum.php [L]

Body:
This will redirect all the calls to your virtualhost to the new website url:

RedirectMatch permanent ^(.*)$ http://www.newwebsite.com/impressum.php

If you want only certain urls to be redirected:

Redirect "/schnitz_krippen.php" "http://www.newwebsite.com/impressum.php"
Redirect "/holzrohlinge.php" "http://www.newwebsite.com/impressum.php"
Redirect "/neuheiten.php" "http://www.newwebsite.com/impressum.php"
Redirect "/impressum.php" "http://www.newwebsite.com/impressum.php"


问:
How To Use Exception Manager Enterprise Library 6.0
When using Enterprise Library 6.0, this error occurs in the code below:

```<code>bool rethrow = ExceptionPolicy.HandleException(ex, "ReplacePolicy1")
</code>```

"Must set an ExceptionManager in the ExceptionPolicy class using the SetExceptionManager method."

In Enterprise Library 5.0 this code worked:

```<code>public static bool HandleException(Exception exception, string PolicyName)
{
    ExceptionManager exManager = EnterpriseLibraryContainer.Current.GetInstance<ExceptionManager>();
    ExceptionPolicy.SetExceptionManager(exManager);
    bool rethrow = ExceptionPolicy.HandleException(ex, "ReplacePolicy1");
    return reThrow;
}
</code>```

But in Enterprise Library 6.0 the EnterpriseLibraryContainer class is not found.
I want get instance of ExceptionManager.
How do I solve this problem ?

答:
I also faced this issue and now i've solved this. So, you can also try to set the following code in the Application_Start() in the Global.asax file:

```<code>IConfigurationSource configurationSource = ConfigurationSourceFactory.Create();
DatabaseFactory.SetDatabaseProviderFactory(new DatabaseProviderFactory());
if (configurationSource.GetSection(LoggingSettings.SectionName) != null)
Logger.SetLogWriter(new LogWriterFactory(configurationSource).Create());
ExceptionPolicy.SetExceptionManager(new ExceptionPolicyFactory(configurationSource).CreateManager());
</code>```

Body:
When using Enterprise Library 6.0, this error occurs in the code below:

bool rethrow = ExceptionPolicy.HandleException(ex, "ReplacePolicy1")

"Must set an ExceptionManager in the ExceptionPolicy class using the SetExceptionManager method."

In Enterprise Library 5.0 this code worked:

public static bool HandleException(Exception exception, string PolicyName)
{
    ExceptionManager exManager = EnterpriseLibraryContainer.Current.GetInstance<ExceptionManager>();
    ExceptionPolicy.SetExceptionManager(exManager);
    bool rethrow = ExceptionPolicy.HandleException(ex, "ReplacePolicy1");
    return reThrow;
}

But in Enterprise Library 6.0 the EnterpriseLibraryContainer class is not found.
I want get instance of ExceptionManager.
How do I solve this problem ?

Body:
I also faced this issue and now i've solved this. So, you can also try to set the following code in the Application_Start() in the Global.asax file:

IConfigurationSource configurationSource = ConfigurationSourceFactory.Create();
DatabaseFactory.SetDatabaseProviderFactory(new DatabaseProviderFactory());
if (configurationSource.GetSection(LoggingSettings.SectionName) != null)
Logger.SetLogWriter(new LogWriterFactory(configurationSource).Create());
ExceptionPolicy.SetExceptionManager(new ExceptionPolicyFactory(configurationSource).CreateManager());


问:
PHP PDO fetchAll fails with latin characters
I faced a problem with reading the resaults of a select query which it brings back some strings that contains latin character. In my case i´m using the PDO function with ODBC driver on Windows to connect to a SQL server 2005, the table char set as i saw in sql server is "SQL_Latin1_General_CP1_CI_AS" and when i print_r the resault the array contains � characters this is the php code:

```<code>        try {
        $pdo = new PDO ("odbc:SQL_FLOC", $username, $password);
        //$pdo->exec("SET CHARACTER SET ISO8859-1");
        $sql=$pdo->prepare('select * from meteo.dbo.Causa');
        $sql->execute();
        $resultado=$sql->fetchAll(PDO::FETCH_ASSOC);
        //Lo convertimos en formato json
        //$resultado = iconv('UCS-2LE', 'UTF-8', $resultado);
        print_r ($resultado);
        }
    catch(PDOException $e)
        {
            echo($e->getMessage());
        exit;}
</code>```

I already tried CHARSET and it didn't

答:
Did you try to set default charset in .htaccess?</p>

```<code>AddDefaultCharset UTF-8
</code>```

Body:
I faced a problem with reading the resaults of a select query which it brings back some strings that contains latin character. In my case i´m using the PDO function with ODBC driver on Windows to connect to a SQL server 2005, the table char set as i saw in sql server is "SQL_Latin1_General_CP1_CI_AS" and when i print_r the resault the array contains � characters this is the php code:

        try {
        $pdo = new PDO ("odbc:SQL_FLOC", $username, $password);
        //$pdo->exec("SET CHARACTER SET ISO8859-1");
        $sql=$pdo->prepare('select * from meteo.dbo.Causa');
        $sql->execute();
        $resultado=$sql->fetchAll(PDO::FETCH_ASSOC);
        //Lo convertimos en formato json
        //$resultado = iconv('UCS-2LE', 'UTF-8', $resultado);
        print_r ($resultado);
        }
    catch(PDOException $e)
        {
            echo($e->getMessage());
        exit;}

I already tried CHARSET and it didn't

Body:
Did you try to set default charset in .htaccess?

AddDefaultCharset UTF-8


问:
Run Android Service every 30 seconds
I am creating a Notification using Android Service independent from UI. This works perfectly fine. Below is the code.

```<code>public class SendNotificationService extends Service {
    Context context;
    String test_heading;
    String test_body;

    final class notifThread implements Runnable {
        int service_id;

        notifThread(int service_id) {
            this.service_id = service_id;
        }

        @Override
        public void run() {
            String requested_method = "LoadBU";
            String bu_status = "1";

            CheckNewEntry checkNewEntry = new CheckNewEntry(SendNotificationService.this);
            checkNewEntry.execute(requested_method, bu_status);

            stopSelf(this.service_id);
        }
    }

    @Override
    public void onCreate() {
        super.onCreate();
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        Thread thread = new Thread(new notifThread(startId));
        thread.start();

        return START_STICKY;
    }

    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }

    @Override
    public void onDestroy() {
        super.onDestroy();

        Toast.makeText(this, "Notifications Stopped...", Toast.LENGTH_LONG).show();
    }
}
</code>```

This service also starts automatically on system boot. CheckNewEntry is my AsyncTask that checks the database and sends notification if there is any change. I have not added CheckNewEntry as it is beyond the scope of this question.

Now what I want to do is, run CheckNewEntry every 30 seconds or 1 minute.

Can anyone help?

答:
After going through different Stackoverflow questions/answers, I managed to come up with my own solution.

Below is the code that I have created and is working now.

```<code>    public class SendNotificationService extends Service {
    public Context context = this;
    public Handler handler = null;
    public static Runnable runnable = null;

    @Override
    public void onCreate() {
        handler = new Handler();
        runnable = new Runnable() {
            public void run() {
                String requested_method = "LoadBU";
                String bu_status = "1";

                CheckNewEntry checkNewEntry = new CheckNewEntry(SendNotificationService.this);
                checkNewEntry.execute(requested_method, bu_status);

                handler.postDelayed(runnable, 10000);
            }
        };

        handler.postDelayed(runnable, 15000);
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {

        return START_STICKY;
    }

    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }

    @Override
    public void onDestroy() {
        handler.removeCallbacks(runnable);

        Toast.makeText(this, "Notifications Stopped...", Toast.LENGTH_LONG).show();
    }
}
</code>```

If anyone of you can provide a better solution, please do post.

Title: Run Android Service every 30 seconds

Body:
I am creating a Notification using Android Service independent from UI. This works perfectly fine. Below is the code.

public class SendNotificationService extends Service {
    Context context;
    String test_heading;
    String test_body;

    final class notifThread implements Runnable {
        int service_id;

        notifThread(int service_id) {
            this.service_id = service_id;
        }

        @Override
        public void run() {
            String requested_method = "LoadBU";
            String bu_status = "1";

            CheckNewEntry checkNewEntry = new CheckNewEntry(SendNotificationService.this);
            checkNewEntry.execute(requested_method, bu_status);

            stopSelf(this.service_id);
        }
    }

    @Override
    public void onCreate() {
        super.onCreate();
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        Thread thread = new Thread(new notifThread(startId));
        thread.start();

        return START_STICKY;
    }

    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }

    @Override
    public void onDestroy() {
        super.onDestroy();

        Toast.makeText(this, "Notifications Stopped...", Toast.LENGTH_LONG).show();
    }
}

This service also starts automatically on system boot. CheckNewEntry is my AsyncTask that checks the database and sends notification if there is any change. I have not added CheckNewEntry as it is beyond the scope of this question.

Now what I want to do is, run CheckNewEntry every 30 seconds or 1 minute.

Can anyone help?

Body:
After going through different Stackoverflow questions/answers, I managed to come up with my own solution.

Below is the code that I have created and is working now.

    public class SendNotificationService extends Service {
    public Context context = this;
    public Handler handler = null;
    public static Runnable runnable = null;

    @Override
    public void onCreate() {
        handler = new Handler();
        runnable = new Runnable() {
            public void run() {
                String requested_method = "LoadBU";
                String bu_status = "1";

                CheckNewEntry checkNewEntry = new CheckNewEntry(SendNotificationService.this);
                checkNewEntry.execute(requested_method, bu_status);

                handler.postDelayed(runnable, 10000);
            }
        };

        handler.postDelayed(runnable, 15000);
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {

        return START_STICKY;
    }

    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }

    @Override
    public void onDestroy() {
        handler.removeCallbacks(runnable);

        Toast.makeText(this, "Notifications Stopped...", Toast.LENGTH_LONG).show();
    }
}

If anyone of you can provide a better solution, please do post.


问:
PHP - Text preprocess on text mining slow process
i make a text preprocess on text mining with large database,, i want make a camus data from all article on database into array, but it take to long process.

```<code>$multiMem   = memory_get_usage();
$xstart = microtime(TRUE);
$word = "";
$sql = mysql_query("SELECT * FROM tbl_content");
while($data = mysql_fetch_assoc($sql)){
  $word = $word."".$data['article'];
}

$preprocess = new preprocess($word);
$word= $preprocess->preprocess($word);
print_r($kata);

$xfinish = microtime(TRUE);
</code>```

here is my class preprocess

```<code>class preprocess {

  var $teks;

  function preprocess($teks){
  /*start process segmentation*/
  $teks = trim($teks);

  //menghapus tanda baca
  $teks = str_replace("'", "", $teks);
  $teks = str_replace("-", "", $teks);
  $teks = str_replace(")", "", $teks);
  $teks = str_replace("(", "", $teks);
  $teks = str_replace("=", "", $teks);
  $teks = str_replace(".", "", $teks);
  $teks = str_replace(",", "", $teks);
  $teks = str_replace(":", "", $teks);
  $teks = str_replace(";", "", $teks);
  $teks = str_replace("!", "", $teks);
  $teks = str_replace("?", "", $teks);

  //remove HTML tags
  $teks = strip_tags($teks);
  $teks = preg_replace('@<(\w+)\b.*?>.*?</\1>@si', '', $teks);
  /*end proses segmentation*/

  /*start case folding*/
  $teks = strtolower($teks);

  $teks = preg_replace('/[0-9]+/', '', $teks);
  /*end case folding*/

  /*start of tokenizing*/
  $teks = explode(" ", $teks);

  /*end of tokenizing*/

  /*start of filtering*/
  //stopword
  $file = file_get_contents('stopword.txt', FILE_USE_INCLUDE_PATH);
  $stopword = explode("\n", $file);

  //remove stopword
  $teks = preg_replace('/\b('.implode('|',$stopword).')\b/','',$teks);

  /*end of filtering*/

  /*start of stemming*/
  require_once('stemming.php');
  foreach($teks as $t => $value){
    $teks[$t] = stemming($value);
  }
  /*end of stemming*/

  $teks = array_filter($teks);
  $teks = array_values($teks);

  return $teks;
 }
}
</code>```

anyone have any idea to make fast process on my program? pls help

thanks for advance

答:
Ther are a couple of things that might be  improoved...

After building up the $word you could free the query result $sql and the data

```<code>$word = '';
$sql = mysql_query("SELECT * FROM tbl_content");
while($data = mysql_fetch_assoc($sql)){
  $word = $word . $data['article'];
}
mysql_free_result($sql);
unset($sql, $data);
</code>```

This block:

```<code>$teks = str_replace("'", "", $teks);
$teks = str_replace("-", "", $teks);
$teks = str_replace(")", "", $teks);
$teks = str_replace("(", "", $teks);
$teks = str_replace("=", "", $teks);
$teks = str_replace(".", "", $teks);
$teks = str_replace(",", "", $teks);
$teks = str_replace(":", "", $teks);
$teks = str_replace(";", "", $teks);
$teks = str_replace("!", "", $teks);
$teks = str_replace("?", "", $teks);
</code>```

can be written like this:

```<code>    $teks = str_replace(array('(','-',')',',','.','=',';','!','?'), '', $teks);
</code>```

since you later in the code replace the numbers with a regular expression, you could add numbers in the upper str_replace call, or add the upper chars to the preg_replace

```<code>$teks = str_replace(array('0','1','2','3','4','5','6','7','8','9','(','-',')',',','.','=',';','!','?'), '', $teks);
</code>```

OR

```<code>$teks = preg_replace('/[0-9,\(\)\-\=\.\,\;\!\?]+/', '', $teks);
</code>```

$teks = strip_tags($teks); should be enough. If it isn'y then use just the preg_replace following, since it's doing kind of the same thing.

use file insted of the file_get_contentsfollowed by theexplodesince thefilereturns an array directly. Also there is no need to explode the $teks

```<code>   $stopword = file('stopword.txt');
   array_walk($stopword, function(&$item1){
     $item1 = '/\b' . $item1 . '\b/';
   });
   $teks = preg_replace($stopword, '', $teks);
</code>```

Generally don't use "" since the processor will try to evaluate the content and that takes longer.

If the stopword.txt list is not changing it is better and faster to have it in the code as an array directly then accessing the file system to read it.

Body:
i make a text preprocess on text mining with large database,, i want make a camus data from all article on database into array, but it take to long process.

$multiMem   = memory_get_usage();
$xstart = microtime(TRUE);
$word = "";
$sql = mysql_query("SELECT * FROM tbl_content");
while($data = mysql_fetch_assoc($sql)){
  $word = $word."".$data['article'];
}

$preprocess = new preprocess($word);
$word= $preprocess->preprocess($word);
print_r($kata);

$xfinish = microtime(TRUE);

here is my class preprocess

class preprocess {

  var $teks;

  function preprocess($teks){
  /*start process segmentation*/
  $teks = trim($teks);

  //menghapus tanda baca
  $teks = str_replace("'", "", $teks);
  $teks = str_replace("-", "", $teks);
  $teks = str_replace(")", "", $teks);
  $teks = str_replace("(", "", $teks);
  $teks = str_replace("=", "", $teks);
  $teks = str_replace(".", "", $teks);
  $teks = str_replace(",", "", $teks);
  $teks = str_replace(":", "", $teks);
  $teks = str_replace(";", "", $teks);
  $teks = str_replace("!", "", $teks);
  $teks = str_replace("?", "", $teks);

  //remove HTML tags
  $teks = strip_tags($teks);
  $teks = preg_replace('@<(\w+)\b.*?>.*?</\1>@si', '', $teks);
  /*end proses segmentation*/

  /*start case folding*/
  $teks = strtolower($teks);

  $teks = preg_replace('/[0-9]+/', '', $teks);
  /*end case folding*/

  /*start of tokenizing*/
  $teks = explode(" ", $teks);

  /*end of tokenizing*/

  /*start of filtering*/
  //stopword
  $file = file_get_contents('stopword.txt', FILE_USE_INCLUDE_PATH);
  $stopword = explode("\n", $file);

  //remove stopword
  $teks = preg_replace('/\b('.implode('|',$stopword).')\b/','',$teks);

  /*end of filtering*/

  /*start of stemming*/
  require_once('stemming.php');
  foreach($teks as $t => $value){
    $teks[$t] = stemming($value);
  }
  /*end of stemming*/

  $teks = array_filter($teks);
  $teks = array_values($teks);

  return $teks;
 }
}

anyone have any idea to make fast process on my program? pls help

thanks for advance

Body:
Ther are a couple of things that might be  improoved...

After building up the $word you could free the query result $sql and the data

$word = '';
$sql = mysql_query("SELECT * FROM tbl_content");
while($data = mysql_fetch_assoc($sql)){
  $word = $word . $data['article'];
}
mysql_free_result($sql);
unset($sql, $data);

This block:

$teks = str_replace("'", "", $teks);
$teks = str_replace("-", "", $teks);
$teks = str_replace(")", "", $teks);
$teks = str_replace("(", "", $teks);
$teks = str_replace("=", "", $teks);
$teks = str_replace(".", "", $teks);
$teks = str_replace(",", "", $teks);
$teks = str_replace(":", "", $teks);
$teks = str_replace(";", "", $teks);
$teks = str_replace("!", "", $teks);
$teks = str_replace("?", "", $teks);

can be written like this:

    $teks = str_replace(array('(','-',')',',','.','=',';','!','?'), '', $teks);

since you later in the code replace the numbers with a regular expression, you could add numbers in the upper str_replace call, or add the upper chars to the preg_replace

$teks = str_replace(array('0','1','2','3','4','5','6','7','8','9','(','-',')',',','.','=',';','!','?'), '', $teks);

OR

$teks = preg_replace('/[0-9,\(\)\-\=\.\,\;\!\?]+/', '', $teks);

$teks = strip_tags($teks); should be enough. If it isn'y then use just the preg_replace following, since it's doing kind of the same thing.

use file insted of the file_get_contentsfollowed by theexplodesince thefilereturns an array directly. Also there is no need to explode the $teks

   $stopword = file('stopword.txt');
   array_walk($stopword, function(&$item1){
     $item1 = '/\b' . $item1 . '\b/';
   });
   $teks = preg_replace($stopword, '', $teks);

Generally don't use "" since the processor will try to evaluate the content and that takes longer.

If the stopword.txt list is not changing it is better and faster to have it in the code as an array directly then accessing the file system to read it.


问:
Yii2 select2 ajax dropdown loading
I am using two select2 ajax loading dropdown list using Yii2 kartik widget. I need to change selection of second dropdown while changing selection of first dropdown.

First Dropdown

 <?php

     $qtnno = '';
     $qtn = ServiceQuotation::find()->where(['UDNO' => $model->QTN_UDNO])->one();
     if($qtn != null)  $qtnno = $qtn->UDNO;

    echo $form->field($model, 'QTN_UDNO')->widget(Select2::classname(), [
    'initValueText' => $qtnno, // set the initial display text
    'options' => ['placeholder' => 'Search for a Quotation ...',
             'onchange'=>'
                  $.getJSON( "'.Url::toRoute('getqtndetails').'", { id: $("#servicejobcard-qtn_udno").val() } )
                      .done(function( data ) {
                          $( "#'.Html::getInputId($model, 'QTNNO').'" ).val( data.qtnno );
                          $( "#'.Html::getInputId($model, 'QTNDATE').'" ).val( data.qtndate );
                          $( "#'.Html::getInputId($model, 'PCODE').'" ).select2({ data: [{id: data.pcode, text: data.pname}]});;
                                $( "#'.Html::getInputId($model, 'PCODE').'" ).select2("val",data.pcode);
                                $( "#'.Html::getInputId($model, 'PROJECTNAME').'" ).val( data.projectname );
                      }
                  );'
                 ],
      'pluginOptions' => [
        'allowClear' => true,
        'minimumInputLength' => 3,
        'ajax' => [
            'url' => $urlQtn,
            'dataType' => 'json',
            'data' => new JsExpression('function(params) { return {q:params.term}; }')
        ],
        'escapeMarkup' => new JsExpression('function (markup) { return markup; }'),
        'templateResult' => new JsExpression('function(data) { return data.text; }'),
        'templateSelection' => new JsExpression('function (data) { return data.text; }'),
    ],
]);
         ?>```
</div>
</div>
</p>

<p><strong>Second Drop Down</strong></p>

<p><div class="snippet" data-lang="js" data-hide="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>  <?php

     $cusName = empty($model->PCODE) ? '' : Customer::findOne($model->PCODE)->PNAME;

    echo $form->field($model, 'PCODE')->widget(Select2::classname(), [
    'initValueText' => $cusName, // set the initial display text
    'options' => ['placeholder' => 'Search for a Customer ...',
                 ],
      'pluginOptions' => [
        'allowClear' => true,
        'minimumInputLength' => 3,
        'ajax' => [
            'url' => $url,
            'dataType' => 'json',
            'data' => new JsExpression('function(params) { return {q:params.term}; }')
        ],
        'escapeMarkup' => new JsExpression('function (markup) { return markup; }'),
        'templateResult' => new JsExpression('function(party) { return party.text; }'),
        'templateSelection' => new JsExpression('function (party) { return party.text; }'),
    ],
]);
         ?></code>```

Using the above code i'm able to change the selection in second dropdown. But after the change, i'm not able to make selection in second dropdown.

Please help...

答:
you can add this kind of query to make the job.

$cusname=QtnUdno::find()->select('PCODE')->where(['UDNO'=>$model->QTN_UDNO])->one();

Title: Yii2 select2 ajax dropdown loading

Body:
I am using two select2 ajax loading dropdown list using Yii2 kartik widget. I need to change selection of second dropdown while changing selection of first dropdown.

First Dropdown

 <?php

     $qtnno = '';
     $qtn = ServiceQuotation::find()->where(['UDNO' => $model->QTN_UDNO])->one();
     if($qtn != null)  $qtnno = $qtn->UDNO;

    echo $form->field($model, 'QTN_UDNO')->widget(Select2::classname(), [
    'initValueText' => $qtnno, // set the initial display text
    'options' => ['placeholder' => 'Search for a Quotation ...',
             'onchange'=>'
                  $.getJSON( "'.Url::toRoute('getqtndetails').'", { id: $("#servicejobcard-qtn_udno").val() } )
                      .done(function( data ) {
                          $( "#'.Html::getInputId($model, 'QTNNO').'" ).val( data.qtnno );
                          $( "#'.Html::getInputId($model, 'QTNDATE').'" ).val( data.qtndate );
                          $( "#'.Html::getInputId($model, 'PCODE').'" ).select2({ data: [{id: data.pcode, text: data.pname}]});;
                                $( "#'.Html::getInputId($model, 'PCODE').'" ).select2("val",data.pcode);
                                $( "#'.Html::getInputId($model, 'PROJECTNAME').'" ).val( data.projectname );
                      }
                  );'
                 ],
      'pluginOptions' => [
        'allowClear' => true,
        'minimumInputLength' => 3,
        'ajax' => [
            'url' => $urlQtn,
            'dataType' => 'json',
            'data' => new JsExpression('function(params) { return {q:params.term}; }')
        ],
        'escapeMarkup' => new JsExpression('function (markup) { return markup; }'),
        'templateResult' => new JsExpression('function(data) { return data.text; }'),
        'templateSelection' => new JsExpression('function (data) { return data.text; }'),
    ],
]);
         ?>

Second Drop Down

  <?php

     $cusName = empty($model->PCODE) ? '' : Customer::findOne($model->PCODE)->PNAME;

    echo $form->field($model, 'PCODE')->widget(Select2::classname(), [
    'initValueText' => $cusName, // set the initial display text
    'options' => ['placeholder' => 'Search for a Customer ...',
                 ],
      'pluginOptions' => [
        'allowClear' => true,
        'minimumInputLength' => 3,
        'ajax' => [
            'url' => $url,
            'dataType' => 'json',
            'data' => new JsExpression('function(params) { return {q:params.term}; }')
        ],
        'escapeMarkup' => new JsExpression('function (markup) { return markup; }'),
        'templateResult' => new JsExpression('function(party) { return party.text; }'),
        'templateSelection' => new JsExpression('function (party) { return party.text; }'),
    ],
]);
         ?>

Using the above code i'm able to change the selection in second dropdown. But after the change, i'm not able to make selection in second dropdown.

Please help...


问:
What are the settings in PHP.ini file to start xdebugger?
I have below settings in PHP.ini file for XDebug.</p>

```<code>[XDebug]
;; Only Zend OR (!) XDebug
zend_extension_ts ="C:\xampp\php\ext\php_xdebug.dll"
xdebug.remote_enable=true
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9001
xdebug.remote_handler=dbgp
xdebug.profiler_enable=1
xdebug.profiler_output_dir="C:\xampp\tmp"
</code>```

答:
You need to send a cookie called XDEBUG_PROFILE to the server. You can use browser plugins to do that for you like easy Xdebug (Firefox) or Xdebug helper (Chrome).

If you want to keep the debugger active, you can add this line to your php.ini:

```<code>xdebug.remote_autostart = 1
</code>```

https://xdebug.org/docs/remote

Body:
I have below settings in PHP.ini file for XDebug.

[XDebug]
;; Only Zend OR (!) XDebug
zend_extension_ts ="C:\xampp\php\ext\php_xdebug.dll"
xdebug.remote_enable=true
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9001
xdebug.remote_handler=dbgp
xdebug.profiler_enable=1
xdebug.profiler_output_dir="C:\xampp\tmp"

Body:
You need to send a cookie called XDEBUG_PROFILE to the server. You can use browser plugins to do that for you like easy Xdebug (Firefox) or Xdebug helper (Chrome).

If you want to keep the debugger active, you can add this line to your php.ini:

xdebug.remote_autostart = 1

https://xdebug.org/docs/remote


问:
Xcode "Missing Submodule" warning
I'm using Xcode6 GM to create a Coacoa Touch Framework (a new function in Xcode6), then this framework is included into my app.

Everything is fine (works fine), except that I get warnings in "#import". What is the root cause?

答:
I had same issue and my solution was..

When you create the framework project.Your project automatically "yourProjectName.h" file gets created, In this header file import class class.

In my case I am getting missing submodule 'MSFramework.MSLocationManager' [-Wincomplete-umbrella]this warning.

resolved by Just importing

```<code>   #import <UIKit/UIKit.h>
    # import "MSLocationManager.h"

    //! Project version number for MSFramework.
    FOUNDATION_EXPORT double MSFrameworkVersionNumber;

    //! Project version string for MSFramework.
    FOUNDATION_EXPORT const unsigned char MSFrameworkVersionString[];
</code>```

here I just add the # import "MSLocationManager.h"in header file.

Title: Xcode "Missing Submodule" warning

Body:
I had same issue and my solution was..

When you create the framework project.Your project automatically "yourProjectName.h" file gets created, In this header file import class class.

In my case I am getting missing submodule 'MSFramework.MSLocationManager' [-Wincomplete-umbrella]this warning.

resolved by Just importing

   #import <UIKit/UIKit.h>
    # import "MSLocationManager.h"

    //! Project version number for MSFramework.
    FOUNDATION_EXPORT double MSFrameworkVersionNumber;

    //! Project version string for MSFramework.
    FOUNDATION_EXPORT const unsigned char MSFrameworkVersionString[];

here I just add the # import "MSLocationManager.h"in header file.


问:
Parse error in Google Tag Manager script in XML Package
I have a webstore, running ASPDOTNETSTOREFRONT.

I'm trying to add a custom line of tracking script to a set of webpages.

To do this, i'm adding a Google Tag Manager script to the XML package that these pages use, so it appears on all the pages I want to track.

I've simply copied and pasted the Google Tag Manager script into my XML package.

```<code>`<!-- Google Tag Manager -->
<noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-5HD6WH"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-5HD6WH');</script>
<!-- End Google Tag Manager -->`
</code>```

But when I try to load a page using this package, it gives the following error.

```<code>Exception=Error in XmlPackage(.Load), Package=[product.engineproduct.xml.config], Msg=[Exception=An error occurred while parsing EntityName. Line 246, position 42.
]
</code>```

So people can see the line numbers and position, I can show a screenshot from the XML package (source code).

http://i.stack.imgur.com/mJ2Tb.jpg

Anyone have any suggestions how to fix this?

答:
And 1 year later... I had the same problem in DNN 7.4.2.

I had something like this in httpdocs/SiteAnalytics.config

```<code><?xml version="1.0" encoding="utf-8" ?>
<AnalyticsEngineConfig>
    <Engines>
        <AnalyticsEngine>
            <EngineType>DotNetNuke.Services.Analytics.GoogleAnalyticsEngine, DotNetNuke</EngineType>
            <ElementId>Head</ElementId>
            <InjectTop>False</InjectTop>
            <ScriptTemplate>

                <!-- Google Tag Manager -->

                <script type="text/javascript">

          (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
                new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
                j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
                'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
                })(window,document,'script','dataLayer','<Tracking ID>');

        </script>

        <!-- End Google Tag Manager -->

                <!-- documented... we would like to disable it by now
        <![CDATA[

                <script type="text/javascript">
                  var _gaq = _gaq || [];
                  _gaq.push(['_setAccount', '[TRACKING_ID]']);
                  _gaq.push(['_trackPageview']);
                  [PAGE_URL]

                  (function() {
                    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
                    ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';
                    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
                  })();
                </script>

          ]]>
          -->
            </ScriptTemplate>
        </AnalyticsEngine>
    </Engines>
</AnalyticsEngineConfig>
</code>```

See, by know i am leaving this as a manual change (but, as i am seeing now I think it will be very easy to integrate new google tag manager with DNN functionality and menus).

The change @dubloons proposed doesn't work for me, so i did it like this:

```<code><?xml version="1.0" encoding="utf-8" ?>
<AnalyticsEngineConfig>
    <Engines>
        <AnalyticsEngine>
            <EngineType>DotNetNuke.Services.Analytics.GoogleAnalyticsEngine, DotNetNuke</EngineType>
            <ElementId>Head</ElementId>
            <InjectTop>False</InjectTop>
            <ScriptTemplate>

                <!-- Google Tag Manager -->
        <![CDATA[
                <script type="text/javascript">

          (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
                new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
                j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
                'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
                })(window,document,'script','dataLayer','<Tracking ID>');

        </script>
        ]]>
        <!-- End Google Tag Manager -->

                <!-- documented... we would like to disable it by now
        <![CDATA[

                <script type="text/javascript">
                  var _gaq = _gaq || [];
                  _gaq.push(['_setAccount', '[TRACKING_ID]']);
                  _gaq.push(['_trackPageview']);
                  [PAGE_URL]

                  (function() {
                    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
                    ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';
                    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
                  })();
                </script>

          ]]>
          -->
            </ScriptTemplate>
        </AnalyticsEngine>
    </Engines>
</AnalyticsEngineConfig>
</code>```

As you see, i sourrounded al script tag within CDATA, not just JS code.
 will be something like GTM-XXXXXX.
As you can see Tracking ID is hardcoded by know, but thats another issue ;D.

Body:
I have a webstore, running ASPDOTNETSTOREFRONT.

I'm trying to add a custom line of tracking script to a set of webpages.

To do this, i'm adding a Google Tag Manager script to the XML package that these pages use, so it appears on all the pages I want to track.

I've simply copied and pasted the Google Tag Manager script into my XML package.

`

`

But when I try to load a page using this package, it gives the following error.

Exception=Error in XmlPackage(.Load), Package=[product.engineproduct.xml.config], Msg=[Exception=An error occurred while parsing EntityName. Line 246, position 42.
]

So people can see the line numbers and position, I can show a screenshot from the XML package (source code).

http://i.stack.imgur.com/mJ2Tb.jpg

Anyone have any suggestions how to fix this?

Body:
And 1 year later... I had the same problem in DNN 7.4.2.

I had something like this in httpdocs/SiteAnalytics.config

<?xml version="1.0" encoding="utf-8" ?>
<AnalyticsEngineConfig>
    <Engines>
        <AnalyticsEngine>
            <EngineType>DotNetNuke.Services.Analytics.GoogleAnalyticsEngine, DotNetNuke</EngineType>
            <ElementId>Head</ElementId>
            <InjectTop>False</InjectTop>
            <ScriptTemplate>

                <!-- Google Tag Manager -->

                <script type="text/javascript">

          (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
                new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
                j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
                'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
                })(window,document,'script','dataLayer','<Tracking ID>');

        </script>

        <!-- End Google Tag Manager -->

                <!-- documented... we would like to disable it by now
        <![CDATA[

                <script type="text/javascript">
                  var _gaq = _gaq || [];
                  _gaq.push(['_setAccount', '[TRACKING_ID]']);
                  _gaq.push(['_trackPageview']);
                  [PAGE_URL]

                  (function() {
                    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
                    ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';
                    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
                  })();
                </script>

          ]]>
          -->
            </ScriptTemplate>
        </AnalyticsEngine>
    </Engines>
</AnalyticsEngineConfig>

See, by know i am leaving this as a manual change (but, as i am seeing now I think it will be very easy to integrate new google tag manager with DNN functionality and menus).

The change @dubloons proposed doesn't work for me, so i did it like this:

<?xml version="1.0" encoding="utf-8" ?>
<AnalyticsEngineConfig>
    <Engines>
        <AnalyticsEngine>
            <EngineType>DotNetNuke.Services.Analytics.GoogleAnalyticsEngine, DotNetNuke</EngineType>
            <ElementId>Head</ElementId>
            <InjectTop>False</InjectTop>
            <ScriptTemplate>

                <!-- Google Tag Manager -->
        <![CDATA[
                <script type="text/javascript">

          (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
                new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
                j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
                'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
                })(window,document,'script','dataLayer','<Tracking ID>');

        </script>
        ]]>
        <!-- End Google Tag Manager -->

                <!-- documented... we would like to disable it by now
        <![CDATA[

                <script type="text/javascript">
                  var _gaq = _gaq || [];
                  _gaq.push(['_setAccount', '[TRACKING_ID]']);
                  _gaq.push(['_trackPageview']);
                  [PAGE_URL]

                  (function() {
                    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
                    ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';
                    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
                  })();
                </script>

          ]]>
          -->
            </ScriptTemplate>
        </AnalyticsEngine>
    </Engines>
</AnalyticsEngineConfig>

As you see, i sourrounded al script tag within CDATA, not just JS code.
 will be something like GTM-XXXXXX.
As you can see Tracking ID is hardcoded by know, but thats another issue ;D.


问:
Display the result of a registration page on top of the registration form
I know little about coding.
This is relating to a registration form i am creating. I have created the form. It is adding the form to database. But it want it to be displaying the result, for example - 'Passwords not matching, please try again' on top of the form. How to get that?
Thanks in advance

Here my code:

```<code><?php

$conn = mysqli_connect("localhost","root","");
if(! $conn ) {
      die('Could not connect: ' . mysql_error());
   }
mysqli_select_db($conn, 'registration');

    if(isset($_POST['submitbutton'])){

        if ($_POST['password'] == $_POST['confirm_password']) {
            $email = mysqli_real_escape_string($conn, $_POST['email']);
            $password = mysqli_real_escape_string($conn, $_POST['password']);
            $gender = mysqli_real_escape_string($conn, $_POST['gender']);
            $fname = mysqli_real_escape_string($conn, $_POST['fname']);
            $lname = mysqli_real_escape_string($conn, $_POST['lname']);
            $firm = mysqli_real_escape_string($conn, $_POST['firm']);

            $check_email_exists = mysqli_query($conn, "SELECT email FROM users WHERE email = '$email'");
            $count = mysqli_num_rows($check_email_exists);
            if ($count == 0) {
                $sql = "INSERT INTO users(email, password, gender, fname, lname, firm) VALUES('$email', '$password', '$gender', '$fname', '$lname', '$firm')";

                if(mysqli_query($conn, $sql)){
                    echo "Records added successfully.";
                } else{
                    echo "ERROR: Could not able to execute $sql. " . mysqli_error($conn);
                }

                // close connection
                mysqli_close($conn);
            } else {
                die('Email exists, Please use a different email');
            }
        }
        else {
            die('Passwords not matching, please try again');
        }
    }
</code>```

and here my html

```<code><div class="registration-container">
    <div class="registrationpage-heading">
        <h2>Kostenlos und ohne Installation testen</h2>
        <p>Nutzen Sie den kostenlosen Funktionumfang von bmgenerator zeitlich uneingeschränkt. Weder Bankdaten noch Kreditkarte notwendig.</p>
    </div>

    <div class="user-login">
        <form class="login-form" action="user_login.php" method="post">
            <input required type="email" name="email" id="user_email" style="color:#888" size="35" value="E-mail"
            onfocus="if(this.value==this.defaultValue)this.value=''"
            onblur="if(this.value=='')this.value=this.defaultValue" ><br><br>

            <input required type="password" name="password" id="user_password" style="color:#888" size="35" placeholder="Passwort"
            onfocus="if(this.value==this.defaultValue)this.value=''"
            onblur="if(this.value=='')this.value=this.defaultValue" ><br><br>

            <input required type="password" name="confirm_password" id="user_confirm_password" style="color:#888" size="35" placeholder="Passwort wiederholen"
            onfocus="if(this.value==this.defaultValue)this.value=''"
            onblur="if(this.value=='')this.value=this.defaultValue" ><br><br>

            <select name="gender">
            <option>Herr</option>
            <option>Frau </option>
            </select><br><br>

            <input required type="text" name="fname" id="user_firstname" style="color:#888" size="35" placeholder="Vorname"
            onfocus="if(this.value==this.defaultValue)this.value=''"
            onblur="if(this.value=='')this.value=this.defaultValue" ><br><br>

            <input required type="text" name="lname" id="user_lastname" style="color:#888" size="35" placeholder="Nachname"
            onfocus="if(this.value==this.defaultValue)this.value=''"
            onblur="if(this.value=='')this.value=this.defaultValue" ><br><br>

            <input required type="text" name="firm" id="user_companyname" style="color:#888" size="35" placeholder="Firmenname"
            onfocus="if(this.value==this.defaultValue)this.value=''"
            onblur="if(this.value=='')this.value=this.defaultValue" ><br><br>

            <input type="submit" name="submitbutton" id="submit" value="Kostenlos registrieren">
        </form>
    </div>

    <div class="register-terms">
        <p>Mit der Registrierung stimmen Sie den Datenschutzbestimmungen und den AGB zu.</p>
    </div>
</div>
</code>```

答:
For each error message make a variable $message="Password not matching..." and then after
 you can put:

<?php echo "
$message
"; ?>

Remember to create a blank $message="".
Hope it helps.

Body:
I know little about coding.
This is relating to a registration form i am creating. I have created the form. It is adding the form to database. But it want it to be displaying the result, for example - 'Passwords not matching, please try again' on top of the form. How to get that?
Thanks in advance

Here my code:

<?php

$conn = mysqli_connect("localhost","root","");
if(! $conn ) {
      die('Could not connect: ' . mysql_error());
   }
mysqli_select_db($conn, 'registration');

    if(isset($_POST['submitbutton'])){

        if ($_POST['password'] == $_POST['confirm_password']) {
            $email = mysqli_real_escape_string($conn, $_POST['email']);
            $password = mysqli_real_escape_string($conn, $_POST['password']);
            $gender = mysqli_real_escape_string($conn, $_POST['gender']);
            $fname = mysqli_real_escape_string($conn, $_POST['fname']);
            $lname = mysqli_real_escape_string($conn, $_POST['lname']);
            $firm = mysqli_real_escape_string($conn, $_POST['firm']);

            $check_email_exists = mysqli_query($conn, "SELECT email FROM users WHERE email = '$email'");
            $count = mysqli_num_rows($check_email_exists);
            if ($count == 0) {
                $sql = "INSERT INTO users(email, password, gender, fname, lname, firm) VALUES('$email', '$password', '$gender', '$fname', '$lname', '$firm')";

                if(mysqli_query($conn, $sql)){
                    echo "Records added successfully.";
                } else{
                    echo "ERROR: Could not able to execute $sql. " . mysqli_error($conn);
                }

                // close connection
                mysqli_close($conn);
            } else {
                die('Email exists, Please use a different email');
            }
        }
        else {
            die('Passwords not matching, please try again');
        }
    }

and here my html

Kostenlos und ohne Installation testen

Nutzen Sie den kostenlosen Funktionumfang von bmgenerator zeitlich uneingeschränkt. Weder Bankdaten noch Kreditkarte notwendig.

        <form class="login-form" action="user_login.php" method="post">
            <input required type="email" name="email" id="user_email" style="color:#888" size="35" value="E-mail"
            onfocus="if(this.value==this.defaultValue)this.value=''"
            onblur="if(this.value=='')this.value=this.defaultValue" >

            <input required type="password" name="password" id="user_password" style="color:#888" size="35" placeholder="Passwort"
            onfocus="if(this.value==this.defaultValue)this.value=''"
            onblur="if(this.value=='')this.value=this.defaultValue" >

            <input required type="password" name="confirm_password" id="user_confirm_password" style="color:#888" size="35" placeholder="Passwort wiederholen"
            onfocus="if(this.value==this.defaultValue)this.value=''"
            onblur="if(this.value=='')this.value=this.defaultValue" >

            <select name="gender">
            <option>Herr</option>
            <option>Frau </option>
            </select>

            <input required type="text" name="fname" id="user_firstname" style="color:#888" size="35" placeholder="Vorname"
            onfocus="if(this.value==this.defaultValue)this.value=''"
            onblur="if(this.value=='')this.value=this.defaultValue" >

            <input required type="text" name="lname" id="user_lastname" style="color:#888" size="35" placeholder="Nachname"
            onfocus="if(this.value==this.defaultValue)this.value=''"
            onblur="if(this.value=='')this.value=this.defaultValue" >

            <input required type="text" name="firm" id="user_companyname" style="color:#888" size="35" placeholder="Firmenname"
            onfocus="if(this.value==this.defaultValue)this.value=''"
            onblur="if(this.value=='')this.value=this.defaultValue" >

            <input type="submit" name="submitbutton" id="submit" value="Kostenlos registrieren">
        </form>

Mit der Registrierung stimmen Sie den Datenschutzbestimmungen und den AGB zu.

Body:
For each error message make a variable $message="Password not matching..." and then after <div class="user-login"> you can put:

<?php echo "<p>$message</p>"; ?>

Remember to create a blank $message="".
Hope it helps.


问:
DB2 Drop table if exists equivalent
I need to drop a DB2 table if it exists, or drop and ignore errors.</p>

答:
Try this one: </p>

```<code>IF EXISTS (SELECT name FROM sysibm.systables WHERE name = 'tab_name') THEN
DROP TABLE tab_name;END IF;
</code>```

Title: DB2 Drop table if exists equivalent

Body:
Try this one:

IF EXISTS (SELECT name FROM sysibm.systables WHERE name = 'tab_name') THEN
DROP TABLE tab_name;END IF;


问:
Send form data with requests in Python not working
I'm start learning python with requests library and i get facebook for example.

This is my code:

```<code>import requests
get_response = requests.get(url='https://www.facebook.com/login/identify?
ctx=recover')
post_data = {'email':'mycorrectemailaddress'}
post_response = requests.post(url="https://www.facebook.com/login/identify?ctx=recover/POST", data=post_data)
print(post_response.text)
</code>```

And my script not going to the next page, i don't know where is my fault.

答:
You didn't pass all the required data.

```<code>payload = {lsd:AVpg3ZvY
           email:your@email.com
           did_submit:Search
           __user:0
           __a:1
           __dyn:7AzHK4GgN1t2u6XgmwCwRAKGzEy4S-C11xG12wAxu13wIwHx27QdwPG2iuUG4XzEa8uwh9UcU88lwIwHwJwnoCcxG48hwv9FovgeFUuzUhws82BxCqUkguy99UK
           __af:iw
           __req:5
           __be:-1
           __pc:PHASED:DEFAULT
           __rev:2929740}
</code>```

Sadly, I don't know what are these args. But you could parse it from a get requrest on the page or use selenium for the informations, and pass cookies to the requests module, and then make the post request.

Body:
I'm start learning python with requests library and i get facebook for example.

This is my code:

import requests
get_response = requests.get(url='https://www.facebook.com/login/identify?
ctx=recover')
post_data = {'email':'mycorrectemailaddress'}
post_response = requests.post(url="https://www.facebook.com/login/identify?ctx=recover/POST", data=post_data)
print(post_response.text)

And my script not going to the next page, i don't know where is my fault.

Body:
You didn't pass all the required data.

payload = {lsd:AVpg3ZvY
           email:your@email.com
           did_submit:Search
           __user:0
           __a:1
           __dyn:7AzHK4GgN1t2u6XgmwCwRAKGzEy4S-C11xG12wAxu13wIwHx27QdwPG2iuUG4XzEa8uwh9UcU88lwIwHwJwnoCcxG48hwv9FovgeFUuzUhws82BxCqUkguy99UK
           __af:iw
           __req:5
           __be:-1
           __pc:PHASED:DEFAULT
           __rev:2929740}

Sadly, I don't know what are these args. But you could parse it from a get requrest on the page or use selenium for the informations, and pass cookies to the requests module, and then make the post request.


问:
How can one test session features in helper modules in Rails?
I have a helper which has some logic for controlling the display of a partial :

```<code>module BannerHelper
  def show_add_friend_link?
    !current_page(friends_path) && !current_user.has_friends?
  end
end

require 'rails_helper'

describe BannerHelper do
  context 'when user has friends'
    it 'does not show the add friends link' do
      expect(helper.show_add_friend_link?).to eq false
    end
  end
end
</code>```

I'm trying to create a test (using rspec 3.2) but current_user isn't defined. I have been able to use current_user from controller tests. current_user is defined in application_controller. Perhaps current_user shouldn't be referred to from a helper though I am not sure where to place this logic.

答:
I have solved this by abandoning RSpec's helper test features and instead testing helper modules within the controller test ecosystem. Doing so provides access to the request and session objects, as well as other helper methods.

Here is an example:

```<code>describe BannerHelper, type: :controller do
  controller(ApplicationController) do
    include BannerHelper
  end

  describe "#show_add_friend_link?" do
    context 'when user has friends'
      it 'does not show the add friends link' do
        allow(subject).to receive(:current_user).and_return(some_user)
        # note that instead of ^ mock you can also simply set needed session key as it is accessible.

         expect(subject.send(:show_add_friend_link?)).to eq false
      end
    end
  end
</code>```

end

Body:
I have a helper which has some logic for controlling the display of a partial :

module BannerHelper
  def show_add_friend_link?
    !current_page(friends_path) && !current_user.has_friends?
  end
end

require 'rails_helper'

describe BannerHelper do
  context 'when user has friends'
    it 'does not show the add friends link' do
      expect(helper.show_add_friend_link?).to eq false
    end
  end
end

I'm trying to create a test (using rspec 3.2) but current_user isn't defined. I have been able to use current_user from controller tests. current_user is defined in application_controller. Perhaps current_user shouldn't be referred to from a helper though I am not sure where to place this logic.

Body:
I have solved this by abandoning RSpec's helper test features and instead testing helper modules within the controller test ecosystem. Doing so provides access to the request and session objects, as well as other helper methods.

Here is an example:

describe BannerHelper, type: :controller do
  controller(ApplicationController) do
    include BannerHelper
  end

  describe "#show_add_friend_link?" do
    context 'when user has friends'
      it 'does not show the add friends link' do
        allow(subject).to receive(:current_user).and_return(some_user)
        # note that instead of ^ mock you can also simply set needed session key as it is accessible.

         expect(subject.send(:show_add_friend_link?)).to eq false
      end
    end
  end

end


问:
Kendo-Grid with Angular
I am somewhat new to Angular and trying to learn how to use Kendo Grid without jQuery using Angular. I get the jQuery code that is used for the widget configuration is written in javascript but i am not getting the HTML directives.

```<code><kendo-grid options="mainGridOptions">
</code>```

What does "options" attribute mean ? I am assuming its an attribute that the kendo-grid (as defined by the directive) widget has ? But when i go the documentation, I don't see it in the configuration of fields drop-down ?

答:
The attribute k-options can be used to store the whole widget configuration in the controller. This attribute can also be used in other Kendo components like scheduler, date picker etc.

Here an example for Kendo datepicker implemented with the k-options attribute:

```<code><div ng-app="app" ng-controller="MyCtrl">
    <input kendo-date-picker k-options="monthPickerConfig">
</div>

<script>
angular.module("app", ["kendo.directives"]).controller("MyCtrl", function($scope) {
    $scope.monthPickerConfig = {
      start  : "year",
      depth  : "year",
      format : "MMMM yyyy"
    };
});
</script>
</code>```

Title: Kendo-Grid with Angular

Body:
I am somewhat new to Angular and trying to learn how to use Kendo Grid without jQuery using Angular. I get the jQuery code that is used for the widget configuration is written in javascript but i am not getting the HTML directives.

<kendo-grid options="mainGridOptions">

What does "options" attribute mean ? I am assuming its an attribute that the kendo-grid (as defined by the directive) widget has ? But when i go the documentation, I don't see it in the configuration of fields drop-down ?

Body:
The attribute k-options can be used to store the whole widget configuration in the controller. This attribute can also be used in other Kendo components like scheduler, date picker etc.

Here an example for Kendo datepicker implemented with the k-options attribute:

<div ng-app="app" ng-controller="MyCtrl">
    <input kendo-date-picker k-options="monthPickerConfig">
</div>

<script>
angular.module("app", ["kendo.directives"]).controller("MyCtrl", function($scope) {
    $scope.monthPickerConfig = {
      start  : "year",
      depth  : "year",
      format : "MMMM yyyy"
    };
});
</script>