问:
Swift 3 - Pulling images from mySQL database
I am currently in the process of designing an application that has a newsfeed. Images and text are stored in our database but I am having trouble pulling the image and displaying it. The code I have should work but I am getting a fatal error saying "THREAD 1: EXC_BAD_INSTRUCTION" around

```<code>let imageData = try? Data(contentsOf: url)
let image = UIImage(data: imageData!)!
</code>```

and the compiler displays this message - "fatal error: unexpectedly found nil while unwrapping an Optional value".

I'm getting the error in this snippet of code:

```<code>if!path!.isEmpty {
    let url = URL(string: path!)!
    let imageData = try? Data(contentsOf: url)
    let image = UIImage(data: imageData!)!
    self.images.append(image)
} else {
    let image = UIImage()
    self.images.append(image)
}
</code>```

Being very new to programming, I've been stuck on this for quite a while now. If there is anything you suggest, let me know! Thanks!

Also, the photo I am trying to retrieve is a .jpg, not sure if that may be important.

(Here's the rest of the code if it is needed)

```<code>import UIKit

class SecondViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {

var activities = [AnyObject]()
var images = [UIImage]()

@IBOutlet var tableView: UITableView!

override func viewDidLoad() {
    super.viewDidLoad()

    //tableView.contentInset = UIEdgeInsetsMake(2, 0, 0, 0)

}

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return activities.count
}

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

    let post = activities[indexPath.row]
    let image = images[indexPath.row]
    let username = post["username"] as? String
    let text = post["text"] as? String

    cell.titleLbl.text = text
    cell.userLbl.text = username
    cell.activityImage.image! = image
    //cell.dateLbl.text = activities[indexPath.row]
    //cell.activityImage.image = images[indexPath.row]

    return cell
}

override func viewWillAppear(_ animated: Bool) {
    loadActivities()
}

func loadActivities() {
    let id = user!["id"] as! String
    let url = URL(string: "https://cgi.soic.indiana.edu/~team7/posts.php")!

    var request = URLRequest(url: url)

    request.httpMethod = "POST"

    let body = "id=\(id)&text=&uuid="
    request.httpBody = body.data(using: String.Encoding.utf8)

    URLSession.shared.dataTask(with: request) { data, response, error in
        DispatchQueue.main.async(execute: {

            if error == nil {

                do {

                    let json = try JSONSerialization.jsonObject(with: data!, options: .mutableContainers) as? NSDictionary

                    // clean up
                    self.activities.removeAll(keepingCapacity: false)
                    self.images.removeAll(keepingCapacity: false)
                    self.tableView.reloadData()

                    guard let parseJSON = json else {
                        print("Error while parsing")
                        return
                    }

                    guard let posts = parseJSON["posts"] as? [AnyObject] else {
                        print("Error while parseJSONing")
                        return
                    }

                    self.activities = posts

                    for i in 0 ..< self.activities.count {

                        let path = self.activities[i]["path"] as? String

                        if !path!.isEmpty {
                            let url = URL(string: path!)!
                            let imageData = try? Data(contentsOf: url)
                            let image = UIImage(data: imageData!)!
                            self.images.append(image)
                        } else {
                            let image = UIImage()
                            self.images.append(image)
                        }

                    }

                    self.tableView.reloadData()

                } catch {
                }

            } else {
            }

        })

        }.resume()

}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}

}

extension NSMutableData {

func appendString(_ string : String) {

    let data = string.data(using: String.Encoding.utf8, allowLossyConversion: true)
    append(data!)

}

}
</code>```

答:
you could try something like this to avoid runtime errors:

```<code>if let actualPath = path, !actualPath.isEmpty, let url = URL(string: actualPath) {
    if let imageData = try? Data(contentsOf: url) {
        if let image = UIImage(data: imageData) {
            self.images.append(image)
        }
    }
}
</code>```

instead of this

```<code>if!path!.isEmpty {
    let url = URL(string: path!)!
    let imageData = try? Data(contentsOf: url)
    let image = UIImage(data: imageData!)!
    self.images.append(image)
}
</code>```

Body:
I am currently in the process of designing an application that has a newsfeed. Images and text are stored in our database but I am having trouble pulling the image and displaying it. The code I have should work but I am getting a fatal error saying "THREAD 1: EXC_BAD_INSTRUCTION" around

let imageData = try? Data(contentsOf: url)
let image = UIImage(data: imageData!)!

and the compiler displays this message - "fatal error: unexpectedly found nil while unwrapping an Optional value".

I'm getting the error in this snippet of code:

if!path!.isEmpty {
    let url = URL(string: path!)!
    let imageData = try? Data(contentsOf: url)
    let image = UIImage(data: imageData!)!
    self.images.append(image)
} else {
    let image = UIImage()
    self.images.append(image)
}

Being very new to programming, I've been stuck on this for quite a while now. If there is anything you suggest, let me know! Thanks!

Also, the photo I am trying to retrieve is a .jpg, not sure if that may be important.

(Here's the rest of the code if it is needed)

import UIKit

class SecondViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {

var activities = [AnyObject]()
var images = [UIImage]()

@IBOutlet var tableView: UITableView!

override func viewDidLoad() {
    super.viewDidLoad()

    //tableView.contentInset = UIEdgeInsetsMake(2, 0, 0, 0)

}

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return activities.count
}

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

    let post = activities[indexPath.row]
    let image = images[indexPath.row]
    let username = post["username"] as? String
    let text = post["text"] as? String

    cell.titleLbl.text = text
    cell.userLbl.text = username
    cell.activityImage.image! = image
    //cell.dateLbl.text = activities[indexPath.row]
    //cell.activityImage.image = images[indexPath.row]

    return cell
}

override func viewWillAppear(_ animated: Bool) {
    loadActivities()
}

func loadActivities() {
    let id = user!["id"] as! String
    let url = URL(string: "https://cgi.soic.indiana.edu/~team7/posts.php")!

    var request = URLRequest(url: url)

    request.httpMethod = "POST"

    let body = "id=\(id)&text=&uuid="
    request.httpBody = body.data(using: String.Encoding.utf8)

    URLSession.shared.dataTask(with: request) { data, response, error in
        DispatchQueue.main.async(execute: {

            if error == nil {

                do {

                    let json = try JSONSerialization.jsonObject(with: data!, options: .mutableContainers) as? NSDictionary

                    // clean up
                    self.activities.removeAll(keepingCapacity: false)
                    self.images.removeAll(keepingCapacity: false)
                    self.tableView.reloadData()

                    guard let parseJSON = json else {
                        print("Error while parsing")
                        return
                    }

                    guard let posts = parseJSON["posts"] as? [AnyObject] else {
                        print("Error while parseJSONing")
                        return
                    }

                    self.activities = posts

                    for i in 0 ..< self.activities.count {

                        let path = self.activities[i]["path"] as? String

                        if !path!.isEmpty {
                            let url = URL(string: path!)!
                            let imageData = try? Data(contentsOf: url)
                            let image = UIImage(data: imageData!)!
                            self.images.append(image)
                        } else {
                            let image = UIImage()
                            self.images.append(image)
                        }

                    }

                    self.tableView.reloadData()

                } catch {
                }

            } else {
            }

        })

        }.resume()

}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}

}

extension NSMutableData {

func appendString(_ string : String) {

    let data = string.data(using: String.Encoding.utf8, allowLossyConversion: true)
    append(data!)

}

}

Body:
you could try something like this to avoid runtime errors:

if let actualPath = path, !actualPath.isEmpty, let url = URL(string: actualPath) {
    if let imageData = try? Data(contentsOf: url) {
        if let image = UIImage(data: imageData) {
            self.images.append(image)
        }
    }
}

instead of this

if!path!.isEmpty {
    let url = URL(string: path!)!
    let imageData = try? Data(contentsOf: url)
    let image = UIImage(data: imageData!)!
    self.images.append(image)
}


来源: stackexchange

问:
Media is not fetching with Instagram API
I am trying to fetch media in a particular place with Instagram API, I am following this link: https://www.instagram.com/developer/endpoints/media/#get_media_search to get media in a particular location and trying this: https://api.instagram.com/v1/media/search?lat=48.858844&lng=2.294351&access_token=XXXXX

But this is given me empty data {"meta": {"code": 200}, "data": []}

Can someone tell me why I am getting empty data, even in example they showing the data in response.

答: I am able to get my own media on which I have added location, but I want to fetch media by passing the latitude and longitude of any location. It seems as I logged in, it is like combined with my access token.</p>

ContentLicense: CC BY-SA 3.0


问:
decommissioned beacon how to add to another project
I registry Estimote beacon, using Beacon Tools (app by google) and assign to one of my projects. Then I want to delete (in purpose to assign it to another project) this beacon from this project so I decommissioned it. Now I can't do anything with it ? what should I do to reset/delete it ?</p>

答:
Only what you can do is change ID of this Estimote beacon. Log into Estimote app select your devices and change UUID/MINOR/MAJOR.
More: https://community.estimote.com/hc/en-us/articles/200868188-How-to-modify-UUID-Major-and-Minor-values-</p>


问:
wcf - why can't I desealize a string array using the client
I have the following in my client but I can't seem to deserialise the json into the UserRoleGetResult

```<code> public class WCFRootObject
    {
       public SignInResult SignInResult { get; set; }
       public bool UserIsInRoleResult { get; set; }
       public bool ChangePasswordRequiredResult { get; set; }

       public UserRoleGetResultWrapper UserRoleGetResult { get; set; }
    }

    public class UserRoleGetResultWrapper
    {
        public string[] UserRoleGetResult { get; set; }
    }
</code>```

Here's the json it returns

```<code> {
      "UserRoleGetResult": [
        "MarbleAccess",
        "MartinAccess",
        "OLBAccess",
        "SuperUser",
        "Supervisor"
      ]
    }
</code>```

Is there some documentation I;ve not read which explains how I should of implemented the rootObject?

why?

答:
i guess you are tiring to deserilize the json object into WCFRootObject. please try deserilzing your json into this object:

```<code> public class WCFRootObject
    {
       public SignInResult SignInResult { get; set; }
       public bool UserIsInRoleResult { get; set; }
       public bool ChangePasswordRequiredResult { get; set; }

       public string[] UserRoleGetResult { get; set; }
    }
</code>```

you wrapped the object twice.

Body:
I have the following in my client but I can't seem to deserialise the json into the UserRoleGetResult

 public class WCFRootObject
    {
       public SignInResult SignInResult { get; set; }
       public bool UserIsInRoleResult { get; set; }
       public bool ChangePasswordRequiredResult { get; set; }

       public UserRoleGetResultWrapper UserRoleGetResult { get; set; }
    }

    public class UserRoleGetResultWrapper
    {
        public string[] UserRoleGetResult { get; set; }
    }

Here's the json it returns

 {
      "UserRoleGetResult": [
        "MarbleAccess",
        "MartinAccess",
        "OLBAccess",
        "SuperUser",
        "Supervisor"
      ]
    }

Is there some documentation I;ve not read which explains how I should of implemented the rootObject?

why?

Body:
i guess you are tiring to deserilize the json object into WCFRootObject. please try deserilzing your json into this object:

 public class WCFRootObject
    {
       public SignInResult SignInResult { get; set; }
       public bool UserIsInRoleResult { get; set; }
       public bool ChangePasswordRequiredResult { get; set; }

       public string[] UserRoleGetResult { get; set; }
    }

you wrapped the object twice.


问:
Hidden features of Scala
What are the hidden features of Scala that every Scala developer should be aware of?

One hidden feature per answer, please.

答:
Dunno if this is really hidden, but I find it quite nice.

Typeconstructors that take 2 type parameters can be written in infix notation

```<code>object Main {
  class FooBar[A, B]

  def main(args: Array[String]): Unit = {
    var x: FooBar[Int, BigInt] = null
    var y: Int FooBar BigInt   = null
  }
}
</code>```

ContentLicense: CC BY-SA 2.5

Title: Hidden features of Scala

LastEditorDisplayName: Roger Pate

Body:
Dunno if this is really hidden, but I find it quite nice.

Typeconstructors that take 2 type parameters can be written in infix notation

object Main {
  class FooBar[A, B]

  def main(args: Array[String]): Unit = {
    var x: FooBar[Int, BigInt] = null
    var y: Int FooBar BigInt   = null
  }
}


问:
What day number in TABLEAU online
I want to extract DAY number from any dynamic date
is there a better way to do it?
I need to recieve an integer as a result

this does not work =

```<code>DAY(Today())
</code>```

答: added MAX to property and it sorted out </p>

Title: What day number in TABLEAU online

Body:
I want to extract DAY number from any dynamic date
is there a better way to do it?
I need to recieve an integer as a result

this does not work =

DAY(Today())

Body: added MAX to property and it sorted out


问:
C# Streamreader add new line
I have searched for this but every solution I've come across involves regex witch is not a solution for me.

My question is simple, I want the streamreader to add a new line everytime it reads the word "ice". Keep in mind that the streamreader is reading the input as 1 line.

My code is as follow:

```<code>using (StreamReader sr = new StreamReader(stream))
{
    VarrileKeeper.s = sr.ReadToEnd();
    //Console.WriteLine(VarrileKeeper.s);
    if (VarrileKeeper.s.ToString().Contains("ice"))
    {
        //insert newline in string
    }
    sr.Close();
}
</code>```

答:
It seems that your question is exceedingly simple (or you haven't explained the complexities behind your problem).

I'd rather use System.IO.File and String.Replace to solve your problem:

```<code>string filename = "D:\\test.txt";
string output = System.IO.File.ReadAllText(filename).Replace("ice", "ice\n");
System.IO.File.WriteAllText(filename, output);
</code>```

Hope that helped!

Title: C# Streamreader add new line

Body:
I have searched for this but every solution I've come across involves regex witch is not a solution for me.

My question is simple, I want the streamreader to add a new line everytime it reads the word "ice". Keep in mind that the streamreader is reading the input as 1 line.

My code is as follow:

using (StreamReader sr = new StreamReader(stream))
{
    VarrileKeeper.s = sr.ReadToEnd();
    //Console.WriteLine(VarrileKeeper.s);
    if (VarrileKeeper.s.ToString().Contains("ice"))
    {
        //insert newline in string
    }
    sr.Close();
}

Body:
It seems that your question is exceedingly simple (or you haven't explained the complexities behind your problem).

I'd rather use System.IO.File and String.Replace to solve your problem:

string filename = "D:\\test.txt";
string output = System.IO.File.ReadAllText(filename).Replace("ice", "ice\n");
System.IO.File.WriteAllText(filename, output);

Hope that helped!


问:
Test with locust and [Errno 111] Connection refused
I have django (1.6) app and I want to test it with locust.
I installed locust==0.7.5 and pyzmq==16.0.2 and I revived a lot of fails: [Errno 111] Connection refused' more details below

When I run app with command: locust --host=http://127.0.0.1  I receive the following error:

```<code>ConnectionError(MaxRetryError("HTTPConnectionPool(host='127.0.0.1', port=80): Max retries exceeded with url: / (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x7f7639d89750>: Failed to establish a new connection: [Errno 111] Connection refused',))",),)
</code>```

My locust file:

```<code>from locust import TaskSet, HttpLocust, task

class UserBehavior(TaskSet):
    @task
    def home(self):
        self.client.get('/')

    @task
    def programm(self):
        self.client.get('/programm')

class WebsiteUser(HttpLocust):
    task_set = UserBehavior
</code>```

Any help on regarding how to resolve the error would be appreciated!

答:
Since your server is running on port 8000 and not 80, try running the command</p>

```<code>locust --host=http://127.0.0.1:8000 -f <your-locust-file.py>
</code>```

Body:
I have django (1.6) app and I want to test it with locust.
I installed locust==0.7.5 and pyzmq==16.0.2 and I revived a lot of fails: [Errno 111] Connection refused' more details below

When I run app with command: locust --host=http://127.0.0.1  I receive the following error:

ConnectionError(MaxRetryError("HTTPConnectionPool(host='127.0.0.1', port=80): Max retries exceeded with url: / (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x7f7639d89750>: Failed to establish a new connection: [Errno 111] Connection refused',))",),)

My locust file:

from locust import TaskSet, HttpLocust, task

class UserBehavior(TaskSet):
    @task
    def home(self):
        self.client.get('/')

    @task
    def programm(self):
        self.client.get('/programm')

class WebsiteUser(HttpLocust):
    task_set = UserBehavior

Any help on regarding how to resolve the error would be appreciated!

Body:
Since your server is running on port 8000 and not 80, try running the command

locust --host=http://127.0.0.1:8000 -f <your-locust-file.py>


问:
Page redirection using if statement with javascript and php
I want to redirect a php page using php if statement. I did the redirect code with javascript but its not working.

Can someone please help me modify my code if i missed something out or help me out with a better solution.

Below is the code;

```<code>$vbi = $row_rsRek['duck'];
if ($vbi == "blocked"){'<script>window.location.href = "http://www.url.com/login.php";
</script>
';}
else {echo "NOT WORKING";}
</code>```

I tried this too

```<code>$vbi = $row_rsRek['duck'];
if ($vbi == "blocked"){header("Location: www.url.com/login.php");}
else {echo "NOT WORKING";}
</code>```

答:
PHP has a build in feature for your needs

```<code>header("Location: path/to/file");
</code>```

Remember that header() must be called before any actual output is
  sent, either by normal HTML tags, blank lines in a file, or from PHP.

http://php.net/manual/en/function.header.php

Body:
I want to redirect a php page using php if statement. I did the redirect code with javascript but its not working.

Can someone please help me modify my code if i missed something out or help me out with a better solution.

Below is the code;

$vbi = $row_rsRek['duck'];
if ($vbi == "blocked"){'
';}
else {echo "NOT WORKING";}

I tried this too

$vbi = $row_rsRek['duck'];
if ($vbi == "blocked"){header("Location: www.url.com/login.php");}
else {echo "NOT WORKING";}

Body:
PHP has a build in feature for your needs

header("Location: path/to/file");

Remember that header() must be called before any actual output is
  sent, either by normal HTML tags, blank lines in a file, or from PHP.

http://php.net/manual/en/function.header.php


问:
SSRS reports gap in the end of group
I am building SSRS report for invoices using SSRS 2008 R2
each invoice has list of items

I have built the report successfully but there was a little problem that we need to display page number of the invoice (i.e Page 1 of 3)
the page number is based on the group ( which is the invoice number ) so for every invoice in the report page 1 will be the first page in the invoice
 and once invoice ends a new page started with reset of page number

after 2 weeks of research i managed to  do this

now I am stuck on a gap at the end of the report that i dont know how to get rid of. and an initial empty page that I cant get rid of too.
and I would appreciate if someone can help me here

I have created a simpler structure that shows my problem and sample data too

```<code>insert into xRep01 values('Inv01','Item0101', '')
insert into xRep01 values('Inv01','Item0102', '')
insert into xRep01 values('Inv01','Item0103', '')
insert into xRep01 values('Inv01','Item0104', '')
insert into xRep01 values('Inv01','Item0105', '')
insert into xRep01 values('Inv01','Item0106', '')
insert into xRep01 values('Inv01','Item0107', '')
insert into xRep01 values('Inv01','Item0108', '')
insert into xRep01 values('Inv01','Item0109', '')
insert into xRep01 values('Inv01','Item0110', '')
insert into xRep01 values('Inv01','Item0111', '')
insert into xRep01 values('Inv01','Item0112', '')
insert into xRep01 values('Inv01','Item0113', '')
insert into xRep01 values('Inv01','Item0114', '')
insert into xRep01 values('Inv01','Item0115', '')
insert into xRep01 values('Inv01','Item0116', '')
insert into xRep01 values('Inv01','Item0117', '')
insert into xRep01 values('Inv01','Item0118', '')
insert into xRep01 values('Inv01','Item0119', '')
insert into xRep01 values('Inv01','Item0120', '')
insert into xRep01 values('Inv01','Item0121', '')
insert into xRep01 values('Inv01','Item0122', '')
insert into xRep01 values('Inv01','Item0123', '')
insert into xRep01 values('Inv01','Item0124', '')
insert into xRep01 values('Inv01','Item0125', '')
insert into xRep01 values('Inv01','Item0126', '')
insert into xRep01 values('Inv01','Item0127', '')
insert into xRep01 values('Inv01','Item0128', '')
insert into xRep01 values('Inv01','Item0129', '')
insert into xRep01 values('Inv01','Item0130', '')
insert into xRep01 values('Inv01','Item0131', '')
insert into xRep01 values('Inv02','Item0201', '')
insert into xRep01 values('Inv02','Item0202', '')
insert into xRep01 values('Inv02','Item0203', '')
insert into xRep01 values('Inv02','Item0204', '')
insert into xRep01 values('Inv02','Item0205', '')
insert into xRep01 values('Inv02','Item0206', '')
insert into xRep01 values('Inv02','Item0207', '')
insert into xRep01 values('Inv02','Item0208', '')
insert into xRep01 values('Inv02','Item0209', '')
insert into xRep01 values('Inv02','Item0210', '')
insert into xRep01 values('Inv02','Item0211', '')
insert into xRep01 values('Inv02','Item0212', '')
insert into xRep01 values('Inv02','Item0213', '')
insert into xRep01 values('Inv02','Item0214', '')
insert into xRep01 values('Inv02','Item0215', '')
insert into xRep01 values('Inv02','Item0216', '')
insert into xRep01 values('Inv02','Item0217', '')
insert into xRep01 values('Inv02','Item0218', '')
insert into xRep01 values('Inv02','Item0219', '')
insert into xRep01 values('Inv02','Item0220', '')
insert into xRep01 values('Inv02','Item0221', '')
insert into xRep01 values('Inv02','Item0222', '')
insert into xRep01 values('Inv02','Item0223', '')
insert into xRep01 values('Inv02','Item0224', '')
insert into xRep01 values('Inv02','Item0225', '')
insert into xRep01 values('Inv02','Item0226', '')
insert into xRep01 values('Inv02','Item0227', '')
insert into xRep01 values('Inv02','Item0228', '')
insert into xRep01 values('Inv02','Item0229', '')
insert into xRep01 values('Inv02','Item0230', '')
insert into xRep01 values('Inv02','Item0231', '')
insert into xRep01 values('Inv02','Item0232', '')
insert into xRep01 values('Inv02','Item0233', '')
insert into xRep01 values('Inv02','Item0234', '')
insert into xRep01 values('Inv02','Item0235', '')
insert into xRep01 values('Inv02','Item0236', '')
insert into xRep01 values('Inv02','Item0237', '')
insert into xRep01 values('Inv02','Item0238', '')
insert into xRep01 values('Inv02','Item0239', '')
</code>```

this is the report code

https://ufile.io/4e6481

答:
Your initial blank page is because you have set page break on the start and end of the group in your table1_Details_Group group. You should only need "Between each instance of a group".

The gap near the end of the detail rows is there because of keep with group and keep together settings. Set them all back to defaults and you'll probably find it works. I've just set most of them back to default and it looks OK (I think, maybe I've misinterpreted your intentions.)

Just as a note: I would normally approach reports like this using a master and sub report. The subreport would be the entire report but for a single Invoice ID. This gives you more control over the layout rather than trying to get grouping and page breaks to work together as this is a pain if the reports can span over an unknown number of pages. Then use a master report with a single cell table pointing to a dataset that contains a list of invoices to print. In the single cell, insert your sub-report and pass the parameters from your invoice list dataset.

Title: SSRS reports gap in the end of group

Body:
I am building SSRS report for invoices using SSRS 2008 R2
each invoice has list of items

I have built the report successfully but there was a little problem that we need to display page number of the invoice (i.e Page 1 of 3)
the page number is based on the group ( which is the invoice number ) so for every invoice in the report page 1 will be the first page in the invoice
 and once invoice ends a new page started with reset of page number

after 2 weeks of research i managed to  do this

now I am stuck on a gap at the end of the report that i dont know how to get rid of. and an initial empty page that I cant get rid of too.
and I would appreciate if someone can help me here

I have created a simpler structure that shows my problem and sample data too

insert into xRep01 values('Inv01','Item0101', '')
insert into xRep01 values('Inv01','Item0102', '')
insert into xRep01 values('Inv01','Item0103', '')
insert into xRep01 values('Inv01','Item0104', '')
insert into xRep01 values('Inv01','Item0105', '')
insert into xRep01 values('Inv01','Item0106', '')
insert into xRep01 values('Inv01','Item0107', '')
insert into xRep01 values('Inv01','Item0108', '')
insert into xRep01 values('Inv01','Item0109', '')
insert into xRep01 values('Inv01','Item0110', '')
insert into xRep01 values('Inv01','Item0111', '')
insert into xRep01 values('Inv01','Item0112', '')
insert into xRep01 values('Inv01','Item0113', '')
insert into xRep01 values('Inv01','Item0114', '')
insert into xRep01 values('Inv01','Item0115', '')
insert into xRep01 values('Inv01','Item0116', '')
insert into xRep01 values('Inv01','Item0117', '')
insert into xRep01 values('Inv01','Item0118', '')
insert into xRep01 values('Inv01','Item0119', '')
insert into xRep01 values('Inv01','Item0120', '')
insert into xRep01 values('Inv01','Item0121', '')
insert into xRep01 values('Inv01','Item0122', '')
insert into xRep01 values('Inv01','Item0123', '')
insert into xRep01 values('Inv01','Item0124', '')
insert into xRep01 values('Inv01','Item0125', '')
insert into xRep01 values('Inv01','Item0126', '')
insert into xRep01 values('Inv01','Item0127', '')
insert into xRep01 values('Inv01','Item0128', '')
insert into xRep01 values('Inv01','Item0129', '')
insert into xRep01 values('Inv01','Item0130', '')
insert into xRep01 values('Inv01','Item0131', '')
insert into xRep01 values('Inv02','Item0201', '')
insert into xRep01 values('Inv02','Item0202', '')
insert into xRep01 values('Inv02','Item0203', '')
insert into xRep01 values('Inv02','Item0204', '')
insert into xRep01 values('Inv02','Item0205', '')
insert into xRep01 values('Inv02','Item0206', '')
insert into xRep01 values('Inv02','Item0207', '')
insert into xRep01 values('Inv02','Item0208', '')
insert into xRep01 values('Inv02','Item0209', '')
insert into xRep01 values('Inv02','Item0210', '')
insert into xRep01 values('Inv02','Item0211', '')
insert into xRep01 values('Inv02','Item0212', '')
insert into xRep01 values('Inv02','Item0213', '')
insert into xRep01 values('Inv02','Item0214', '')
insert into xRep01 values('Inv02','Item0215', '')
insert into xRep01 values('Inv02','Item0216', '')
insert into xRep01 values('Inv02','Item0217', '')
insert into xRep01 values('Inv02','Item0218', '')
insert into xRep01 values('Inv02','Item0219', '')
insert into xRep01 values('Inv02','Item0220', '')
insert into xRep01 values('Inv02','Item0221', '')
insert into xRep01 values('Inv02','Item0222', '')
insert into xRep01 values('Inv02','Item0223', '')
insert into xRep01 values('Inv02','Item0224', '')
insert into xRep01 values('Inv02','Item0225', '')
insert into xRep01 values('Inv02','Item0226', '')
insert into xRep01 values('Inv02','Item0227', '')
insert into xRep01 values('Inv02','Item0228', '')
insert into xRep01 values('Inv02','Item0229', '')
insert into xRep01 values('Inv02','Item0230', '')
insert into xRep01 values('Inv02','Item0231', '')
insert into xRep01 values('Inv02','Item0232', '')
insert into xRep01 values('Inv02','Item0233', '')
insert into xRep01 values('Inv02','Item0234', '')
insert into xRep01 values('Inv02','Item0235', '')
insert into xRep01 values('Inv02','Item0236', '')
insert into xRep01 values('Inv02','Item0237', '')
insert into xRep01 values('Inv02','Item0238', '')
insert into xRep01 values('Inv02','Item0239', '')

this is the report code

https://ufile.io/4e6481


问:
jQuery number animation for 3,450.86
I want to animate number using jQuery. My number is 3,450.86 when i'm trying to animate this number i can able to animate 3,450 this number only not getting decimal values.

Can any one help me. Thanks in advance.

答:
I have used below code once, if you like to add counterUp library in your code then use below code. Thanks.

jQuery(document).ready(function ($) {
  $('span').counterUp({
    delay: 10,
    time: 1000
  });
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="http://www.jqueryscript.net/demo/Animating-Numbers-Counting-Up-with-jQuery-Counter-Up-Plugin/jquery.counterup.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/waypoints/2.0.3/waypoints.min.js"></script>
<span class=".integers">12345</span><br><br>
<span class=".floats">123.45</span><br><br>
<span class=".numbers-with-commas">12,345.00</span></code>```

Title: jQuery number animation for 3,450.86

Body:
I have used below code once, if you like to add counterUp library in your code then use below code. Thanks.

jQuery(document).ready(function ($) {
  $('span').counterUp({
    delay: 10,
    time: 1000
  });
});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="http://www.jqueryscript.net/demo/Animating-Numbers-Counting-Up-with-jQuery-Counter-Up-Plugin/jquery.counterup.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/waypoints/2.0.3/waypoints.min.js"></script>
<span class=".integers">12345</span><br><br>
<span class=".floats">123.45</span><br><br>
<span class=".numbers-with-commas">12,345.00</span>


问:
Automatically change header name in matlab
I have two equations z=x+an and ze=x+bn, where a and b are constant. Here x and n varies from 0 to 10 with 1 interval. I have to write all these on to a dat file with first column with all values of x, then next column with values of z with n=0, next column with values of ze with n=0, next column value of z with n=1, next column value of ze with n=1 and so on. And also I have to put a header. The code goes like this:

```<code>clear all;clc;
format long;
a=4;
b=2;
mat1=[];
mat2=[];
for n=0:10
    i=0;
    for x=0:1:10
        i=i+1;
         z(i,:)= x+a*n;
         ze(i,:)= x+b*n;
    end
    mat1=[mat1,z, ze];
end
x1(:,1)=0:1:10;
dat1=[x1,mat1];
outputfilename1=('mat1.dat');
fileidentifier1=fopen(outputfilename1,'w+');
fprintf(fileidentifier1,'x\t z0\t ze0\t z1\t ze1\t z2\t ze2\t z3\t ze3\t z4\t ze4\t z5\t ze5\t z6\t ze6\t z7\t ze7\t z8\t ze8\t z9\t ze9\t z10\t ze10\t \r');
fprintf(fileidentifier1,'%7.10f %7.10f %7.10f %7.10f %7.10f %7.10f %7.10f %7.10f %7.10f %7.10f %7.10f %7.10f %7.10f %7.10f %7.10f %7.10f %7.10f %7.10f %7.10f %7.10f %7.10f %7.10f %7.10f \n',dat1');
fclose(fileidentifier1);
</code>```

Problem starts from putting header.

What I used to do is that I used to give the command for each of these thing manually: i.e. ‘x’, for first column, ‘z0’ for second column corresponding to n=0, ‘ze0’ corresponding to ze with n=0, 'z1' for z where n=1, 'ze1' for ze where n=1 and so on. Similarly, for format specification (ie %7.10f). As you can see that it will be a hectic of a task if that ‘n’ varies up to 100 or more. Also if you want to change the value of n from 10 to 9, the output file will still show the correct values, but the way it is arranged will become haywire (you can try for yourself). Is there any way to write do this automatically?

Thanks in advance....

答:
So your issue is dynamically creating the string

```<code>'x\t z0\t z1\t z2\t z3\t z4\t z5\t z6\t z7\t z8\t z9\t z10\t \r'
</code>```

You can simply do this in a loop:

```<code>str = 'x\t';
for zNum = 0:10
    str = [str, ' z', num2str(zNum), '\t'];
end
str = [str, ' \r'];
</code>```

Output:

```<code>str = 'x\t z0\t z1\t z2\t z3\t z4\t z5\t z6\t z7\t z8\t z9\t z10\t \r'
</code>```

Now in your code you can use it in the relevant lines

```<code>fprintf(fileidentifier1, str);
</code>```

Body:
I have two equations z=x+an and ze=x+bn, where a and b are constant. Here x and n varies from 0 to 10 with 1 interval. I have to write all these on to a dat file with first column with all values of x, then next column with values of z with n=0, next column with values of ze with n=0, next column value of z with n=1, next column value of ze with n=1 and so on. And also I have to put a header. The code goes like this:

clear all;clc;
format long;
a=4;
b=2;
mat1=[];
mat2=[];
for n=0:10
    i=0;
    for x=0:1:10
        i=i+1;
         z(i,:)= x+a*n;
         ze(i,:)= x+b*n;
    end
    mat1=[mat1,z, ze];
end
x1(:,1)=0:1:10;
dat1=[x1,mat1];
outputfilename1=('mat1.dat');
fileidentifier1=fopen(outputfilename1,'w+');
fprintf(fileidentifier1,'x\t z0\t ze0\t z1\t ze1\t z2\t ze2\t z3\t ze3\t z4\t ze4\t z5\t ze5\t z6\t ze6\t z7\t ze7\t z8\t ze8\t z9\t ze9\t z10\t ze10\t \r');
fprintf(fileidentifier1,'%7.10f %7.10f %7.10f %7.10f %7.10f %7.10f %7.10f %7.10f %7.10f %7.10f %7.10f %7.10f %7.10f %7.10f %7.10f %7.10f %7.10f %7.10f %7.10f %7.10f %7.10f %7.10f %7.10f \n',dat1');
fclose(fileidentifier1);

Problem starts from putting header.

What I used to do is that I used to give the command for each of these thing manually: i.e. ‘x’, for first column, ‘z0’ for second column corresponding to n=0, ‘ze0’ corresponding to ze with n=0, 'z1' for z where n=1, 'ze1' for ze where n=1 and so on. Similarly, for format specification (ie %7.10f). As you can see that it will be a hectic of a task if that ‘n’ varies up to 100 or more. Also if you want to change the value of n from 10 to 9, the output file will still show the correct values, but the way it is arranged will become haywire (you can try for yourself). Is there any way to write do this automatically?

Thanks in advance....

Body:
So your issue is dynamically creating the string

'x\t z0\t z1\t z2\t z3\t z4\t z5\t z6\t z7\t z8\t z9\t z10\t \r'

You can simply do this in a loop:

str = 'x\t';
for zNum = 0:10
    str = [str, ' z', num2str(zNum), '\t'];
end
str = [str, ' \r'];

Output:

str = 'x\t z0\t z1\t z2\t z3\t z4\t z5\t z6\t z7\t z8\t z9\t z10\t \r'

Now in your code you can use it in the relevant lines

fprintf(fileidentifier1, str);


问:
Sending input to a screen window from vim
I have a vim function set up where I can highlight a line of text and execute in clojure. Here's the function:

```<code> function! Clojure_execline()
     let cl = (getline(line(".")))
     // ...
     exec 'clojure -e "' . cl . '"'
 endfunction
</code>```

The problem with this is that it's slow to start and because it spawns a new clojure session every time I run it, I can't call a function I ran previously. Ideally, I'd like for a hidden repl to be running where I could send input from vim and retrieve the output from as well. I learned about gnu screen and thought it could help me, but I don't know how to send input from one screen window to another.

To clarify my problem, take this line of clojure:

```<code>(defn add2 [x y] (+ x y))
</code>```

I'd like to be able to highlight this line in vim and execute in a running repl. I want to be able to call the line below and have it execute in the same repl:

```<code>(add2 4 5)
</code>```

Afterwards, I'd like to be able to get the output of the function.

So, basically, my question is, how do I send input from one screen window to another?

答:
I don't have an exact answer, but it might be worth taking a look at slime.vim and seeing if anything can be learned from it.

blog post about it

script at vim.org

Body:
I have a vim function set up where I can highlight a line of text and execute in clojure. Here's the function:

 function! Clojure_execline()
     let cl = (getline(line(".")))
     // ...
     exec 'clojure -e "' . cl . '"'
 endfunction

The problem with this is that it's slow to start and because it spawns a new clojure session every time I run it, I can't call a function I ran previously. Ideally, I'd like for a hidden repl to be running where I could send input from vim and retrieve the output from as well. I learned about gnu screen and thought it could help me, but I don't know how to send input from one screen window to another.

To clarify my problem, take this line of clojure:

(defn add2 [x y] (+ x y))

I'd like to be able to highlight this line in vim and execute in a running repl. I want to be able to call the line below and have it execute in the same repl:

(add2 4 5)

Afterwards, I'd like to be able to get the output of the function.

So, basically, my question is, how do I send input from one screen window to another?


问:
Recurring events in FullCalendar ASP MVC
I am using jQuery FullCalendar as my calendar. I want to add a function that can recurring my events. I am not sure if FullCalendar has this function available or we need to customize ourself. I am using ASP MVC. I start with this code

```<code>public ActionResult Create(string start)
{
    var a = startdt.ToString("dddd");
    if (repeat == "daily")
    {
        if (a == "monday")
        {
            for (start, till, ++days)
            {
                //not sure what to do
            }
        }

    }
}
</code>```

I want it be like for every monday after start date, the session is automatically book by this person. I am pretty sure I am not doing this right since I dont find any reference to follow. Can anyone help me?

答: I'm not sure it supports a complete solution but take a look here. [Recurring Events in FullCalendar</p>

Body:
I am using jQuery FullCalendar as my calendar. I want to add a function that can recurring my events. I am not sure if FullCalendar has this function available or we need to customize ourself. I am using ASP MVC. I start with this code

public ActionResult Create(string start)
{
    var a = startdt.ToString("dddd");
    if (repeat == "daily")
    {
        if (a == "monday")
        {
            for (start, till, ++days)
            {
                //not sure what to do
            }
        }

    }
}

I want it be like for every monday after start date, the session is automatically book by this person. I am pretty sure I am not doing this right since I dont find any reference to follow. Can anyone help me?


问:
Using bootstrap how can I put this text in the middle of the nav bar?
How can I put the text
Liam Docherty's Digital Portfolio
in the middle of the navigation bar so it in line with the other nav bar webpages text?

```
<pre class="snippet-code-html lang-html prettyprint-override"><code><!DOCTYPE html>
<html lang="en">
   <head>
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
      <script src="https://code.jquery.com/jquery-3.1.1.js" integrity="sha256-16cdPddA6VdVInumRGo6IbivbERE8p7CQR3HzTBuELA=" crossorigin="anonymous"></script>
      <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
      <script src="https://cdnjs.cloudflare.com/ajax/libs/fullPage.js/2.9.4/jquery.fullpage.min.js"></script>
   </head>

   <body>
      <nav class="navbar navbar-default navbar-fixed-top">
         <div class="container-fluid">
            <div class="navbar-header">
               <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
               <span class="sr-only">Toggle navigation</span>
               <span class="icon-bar"></span>
               <span class="icon-bar"></span>
               <span class="icon-bar"></span>
               </button>
               <img id="nav_img" class="img-responsive" src="http://i1126.photobucket.com/albums/l611/ldocherty1/logo1_zpsep8qps5m.png" alt="Logo design">
               <h5 class="nav-title text-center center-block hidden-sm hidden-md hidden-lg" id="nav-center">Liam Docherty's Digital Portfolio</h5>
            </div>
            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
               <ul class="nav navbar-nav navbar-center">
                  <h5 class="nav-title text-center center-block hidden-xs ">Liam Docherty's Digital Portfolio</h5>
               </ul>
               <ul class="nav navbar-nav navbar-right">
                  <li>Home
                  </li>
                  <li class="dropdown">
                     Units <span class="caret"></span>
                     <ul class="dropdown-menu">
                        <li>Unit 6
                        </li>
                        <li>Unit 14
                        </li>
                        <li>Unit 7
                        </li>
                        <li>Unit 1
                        </li>
                     </ul>
                  </li>
                  <li class="dropdown">
                     About <span class="caret"></span>
                     <ul class="dropdown-menu">
                        <li>About Me
                        </li>
                        <li>CV
                        </li>
                        <li>Education
                        </li>
                     </ul>
                  </li>
                  <li>Contact Me
                  </li>
               </ul>
            </div>
         </div>
      </nav>
      <div id="sections">
         <div class="section one">
            <div class="shape"></div>
            <div class="hero"></div>
            <h1 class="s1-text center-block">WELCOME TO MY</h1>
            <h1 class="s2-text center-block">PORTFOLIO</h1>
             <i class="fa fa-angle-down" style="font-size:100px;"></i>
         </div>
         <section id="contact-me" class="section two">
          <i class="fa fa-angle-up" style="font-size:100px;"></i>
      </div>
      <script>
         $(document).ready(function() {
           $('#sections').fullpage();
         });
      </script>
   </body>
</html></code>```

答:
try,</p>

```<code>.center-block {
 display: block;
 width: 100%;
 position: absolute;
}
</code>```

Body:
How can I put the text
Liam Docherty's Digital Portfolio
in the middle of the navigation bar so it in line with the other nav bar webpages text?

<!DOCTYPE html>

      <meta name="viewport" content="width=device-width, initial-scale=1">
      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

               <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
               Toggle navigation

               </button>

Liam Docherty's Digital Portfolio

Liam Docherty's Digital Portfolio

Home

                     Units

Unit 6

Unit 14

Unit 7

Unit 1

                     About

About Me

CV

Education

Contact Me

WELCOME TO MY

PORTFOLIO

Body:
try,

.center-block {
 display: block;
 width: 100%;
 position: absolute;
}


问:
A Function with multiple outputs in C#
I want to define a function with two outputs. The first one is a boolean variable and the second one is 2D array with unknown numbers of rows and columns but the array will be defined if the boolean variable is true and if the boolean variable is false, the array is not defined. how can I define this function? I am thankful if anybody can exemplify it in an example.
Thanks</p>

答:
You want something like this .</p>

```<code>Tuple<string, int> NameAndId()
{
    // This method returns multiple values.
    return new Tuple<string, int>("Test", 100);
}
</code>```

Title: A Function with multiple outputs in C#

Body:
You want something like this .

Tuple<string, int> NameAndId()
{
    // This method returns multiple values.
    return new Tuple<string, int>("Test", 100);
}


问:
ImageMagick : ERROR: Failed to build gem native extension
i have a error installing the gem called rmagick. I have seen other Stack Over flow websites regarding the same issue. but din't work.

Error:

```<code>Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
ERROR:  Error installing rmagick:
        ERROR: Failed to build gem native extension.

    current directory: C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rmagick-2.16.0/ext/RMagick
C:/Ruby22-x64/bin/ruby.exe -r ./siteconf20170403-8836-1ebgkj8.rb extconf.rb
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=C:/Ruby22-x64/bin/$(RUBY_BASE_NAME)
extconf.rb:141:in ``': No such file or directory - identify -version (Errno::ENOENT)
        from extconf.rb:141:in `configure_compile_options'
        from extconf.rb:16:in `initialize'
        from extconf.rb:548:in `new'
        from extconf.rb:548:in `<main>'

extconf failed, exit code 1

Gem files will remain installed in C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rmagick-2.16.0 for inspection.
Results logged to C:/Ruby22-x64/lib/ruby/gems/2.2.0/extensions/x64-mingw32/2.2.0/rmagick-2.16.0/gem_make.out

C:\Users\suresh>gem install rmagick
Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
ERROR:  Error installing rmagick:
        ERROR: Failed to build gem native extension.

    current directory: C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rmagick-2.16.0/ext/RMagick
C:/Ruby22-x64/bin/ruby.exe -r ./siteconf20170403-7540-1x6tan0.rb extconf.rb
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=C:/Ruby22-x64/bin/$(RUBY_BASE_NAME)
extconf.rb:141:in ``': No such file or directory - identify -version (Errno::ENOENT)
        from extconf.rb:141:in `configure_compile_options'
        from extconf.rb:16:in `initialize'
        from extconf.rb:548:in `new'
        from extconf.rb:548:in `<main>'

extconf failed, exit code 1

Gem files will remain installed in C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rmagick-2.16.0 for inspection.
Results logged to C:/Ruby22-x64/lib/ruby/gems/2.2.0/extensions/x64-mingw32/2.2.0/rmagick-2.16.0/gem_make.out
</code>```

What i actually did, step 3 and step 4 output the same error above.

```<code>    1.Downloaded ImageMagick-7.0.5-4-Q16-x64-dll
    2.Set my Path to C:\Program Files (x86)\ImageMagick-7.0.5-Q16\include
    set
    3.Install the gem using this command:
      gem install rmagick --platform=ruby -- --with-opt-lib=C:\ImageMagick-7.0.5-Q16\lib --with-opt-include=C:\ImageMagick-7.0.5-Q16\include
    4. or gem install rmagick
    5. Using Windows 10 machine
</code>```

答: RMagick doesn't seem to support ImageMagick 7 yet. Try to install rmagick with the latest build of ImageMagick 6.9.

Body:
i have a error installing the gem called rmagick. I have seen other Stack Over flow websites regarding the same issue. but din't work.

Error:

Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
ERROR:  Error installing rmagick:
        ERROR: Failed to build gem native extension.

    current directory: C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rmagick-2.16.0/ext/RMagick
C:/Ruby22-x64/bin/ruby.exe -r ./siteconf20170403-8836-1ebgkj8.rb extconf.rb
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=C:/Ruby22-x64/bin/$(RUBY_BASE_NAME)
extconf.rb:141:in ``': No such file or directory - identify -version (Errno::ENOENT)
        from extconf.rb:141:in `configure_compile_options'
        from extconf.rb:16:in `initialize'
        from extconf.rb:548:in `new'
        from extconf.rb:548:in `'

extconf failed, exit code 1

Gem files will remain installed in C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rmagick-2.16.0 for inspection.
Results logged to C:/Ruby22-x64/lib/ruby/gems/2.2.0/extensions/x64-mingw32/2.2.0/rmagick-2.16.0/gem_make.out

C:\Users\suresh>gem install rmagick
Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
ERROR:  Error installing rmagick:
        ERROR: Failed to build gem native extension.

    current directory: C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rmagick-2.16.0/ext/RMagick
C:/Ruby22-x64/bin/ruby.exe -r ./siteconf20170403-7540-1x6tan0.rb extconf.rb
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=C:/Ruby22-x64/bin/$(RUBY_BASE_NAME)
extconf.rb:141:in ``': No such file or directory - identify -version (Errno::ENOENT)
        from extconf.rb:141:in `configure_compile_options'
        from extconf.rb:16:in `initialize'
        from extconf.rb:548:in `new'
        from extconf.rb:548:in `'

extconf failed, exit code 1

Gem files will remain installed in C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rmagick-2.16.0 for inspection.
Results logged to C:/Ruby22-x64/lib/ruby/gems/2.2.0/extensions/x64-mingw32/2.2.0/rmagick-2.16.0/gem_make.out

What i actually did, step 3 and step 4 output the same error above.

    1.Downloaded ImageMagick-7.0.5-4-Q16-x64-dll
    2.Set my Path to C:\Program Files (x86)\ImageMagick-7.0.5-Q16\include
    set
    3.Install the gem using this command:
      gem install rmagick --platform=ruby -- --with-opt-lib=C:\ImageMagick-7.0.5-Q16\lib --with-opt-include=C:\ImageMagick-7.0.5-Q16\include
    4. or gem install rmagick
    5. Using Windows 10 machine


问:
ScrollViewSuite Example Code Uses More Memory than Necessary?
There is problem in ScrollViewSuite. it use more memory than needed .
for example:

Load image in 25% and measure memory (4 MB)

Zoom in image to 100% and measure memory (30 MB)

Zoom out to 25% and measure memory (30 MB) - why 30 ? it must use only 4 MB - that is the problem.

How to fix the problem ?

```<code>/***********************************************************************************/
/* Most of the work of tiling is done in layoutSubviews, which we override here.   */
/* We recycle the tiles that are no longer in the visible bounds of the scrollView */
/* and we add any tiles that should now be present but are missing.                */
/***********************************************************************************/

- (void)layoutSubviews
{
 [self updateResolution];
 NSLog(@"layoutSubviews ");
    [super layoutSubviews];

    CGRect visibleBounds = [self bounds];

    // first recycle all tiles that are no longer visible
    for (UIView *tile in [tileContainerView subviews]) {

        // We want to see if the tiles intersect our (i.e. the scrollView's) bounds, so we need to convert their
        // frames to our own coordinate system
        CGRect scaledTileFrame = [tileContainerView convertRect:[tile frame] toView:self];

        // If the tile doesn't intersect, it's not visible, so we can recycle it
        if (! CGRectIntersectsRect(scaledTileFrame, visibleBounds)) {
            [reusableTiles addObject:tile];
            [tile removeFromSuperview];

        }
    }

    // calculate which rows and columns are visible by doing a bunch of math.
    float scaledTileWidth  = [self tileSize].width  * [self zoomScale];
    float scaledTileHeight = [self tileSize].height * [self zoomScale];
    int maxRow = floorf([tileContainerView frame].size.height / scaledTileHeight); // this is the maximum possible row
    int maxCol = floorf([tileContainerView frame].size.width  / scaledTileWidth);  // and the maximum possible column
    int firstNeededRow = MAX(0, floorf(visibleBounds.origin.y / scaledTileHeight));
    int firstNeededCol = MAX(0, floorf(visibleBounds.origin.x / scaledTileWidth));
    int lastNeededRow  = MIN(maxRow, floorf(CGRectGetMaxY(visibleBounds) / scaledTileHeight));
    int lastNeededCol  = MIN(maxCol, floorf(CGRectGetMaxX(visibleBounds) / scaledTileWidth));

    // iterate through needed rows and columns, adding any tiles that are missing
    for (int row = firstNeededRow; row <= lastNeededRow; row++) {
        for (int col = firstNeededCol; col <= lastNeededCol; col++) {

            BOOL tileIsMissing = (firstVisibleRow > row || firstVisibleColumn > col ||
                                  lastVisibleRow  < row || lastVisibleColumn  < col);

            if (tileIsMissing) {
                UIView *tile = [dataSource tiledScrollView:self tileForRow:row column:col resolution:resolution];

                // set the tile's frame so we insert it at the correct position
                CGRect frame = CGRectMake([self tileSize].width * col, [self tileSize].height * row, [self tileSize].width, [self tileSize].height);
                [tile setFrame:frame];
                [tileContainerView addSubview:tile];

                // annotateTile draws green lines and tile numbers on the tiles for illustration purposes.
                [self annotateTile:tile];

            }
        }
    }

    // update our record of which rows/cols are visible
    firstVisibleRow = firstNeededRow; firstVisibleColumn = firstNeededCol;
    lastVisibleRow  = lastNeededRow;  lastVisibleColumn  = lastNeededCol;
}
</code>```

答: Are you sure that it isn't because extra memory is being used when you zoom in and just cached off for increased performance? Things such as UIImages do such, but will release correctly when memory warnings start hitting. Increased memory usage does not necessarily mean leakage, nor is it always even desirable for memory usage to shrink down to the minimum possible. Heck, more often than not, unused memory is more wasteful than memory that's occupied but can be deallocated at any time for real usage.</p>

Body:
There is problem in ScrollViewSuite. it use more memory than needed .
for example:

Load image in 25% and measure memory (4 MB)

Zoom in image to 100% and measure memory (30 MB)

Zoom out to 25% and measure memory (30 MB) - why 30 ? it must use only 4 MB - that is the problem.

How to fix the problem ?

/***********************************************************************************/
/* Most of the work of tiling is done in layoutSubviews, which we override here.   */
/* We recycle the tiles that are no longer in the visible bounds of the scrollView */
/* and we add any tiles that should now be present but are missing.                */
/***********************************************************************************/

- (void)layoutSubviews
{
 [self updateResolution];
 NSLog(@"layoutSubviews ");
    [super layoutSubviews];

    CGRect visibleBounds = [self bounds];

    // first recycle all tiles that are no longer visible
    for (UIView *tile in [tileContainerView subviews]) {

        // We want to see if the tiles intersect our (i.e. the scrollView's) bounds, so we need to convert their
        // frames to our own coordinate system
        CGRect scaledTileFrame = [tileContainerView convertRect:[tile frame] toView:self];

        // If the tile doesn't intersect, it's not visible, so we can recycle it
        if (! CGRectIntersectsRect(scaledTileFrame, visibleBounds)) {
            [reusableTiles addObject:tile];
            [tile removeFromSuperview];

        }
    }

    // calculate which rows and columns are visible by doing a bunch of math.
    float scaledTileWidth  = [self tileSize].width  * [self zoomScale];
    float scaledTileHeight = [self tileSize].height * [self zoomScale];
    int maxRow = floorf([tileContainerView frame].size.height / scaledTileHeight); // this is the maximum possible row
    int maxCol = floorf([tileContainerView frame].size.width  / scaledTileWidth);  // and the maximum possible column
    int firstNeededRow = MAX(0, floorf(visibleBounds.origin.y / scaledTileHeight));
    int firstNeededCol = MAX(0, floorf(visibleBounds.origin.x / scaledTileWidth));
    int lastNeededRow  = MIN(maxRow, floorf(CGRectGetMaxY(visibleBounds) / scaledTileHeight));
    int lastNeededCol  = MIN(maxCol, floorf(CGRectGetMaxX(visibleBounds) / scaledTileWidth));

    // iterate through needed rows and columns, adding any tiles that are missing
    for (int row = firstNeededRow; row <= lastNeededRow; row++) {
        for (int col = firstNeededCol; col <= lastNeededCol; col++) {

            BOOL tileIsMissing = (firstVisibleRow > row || firstVisibleColumn > col ||
                                  lastVisibleRow  < row || lastVisibleColumn  < col);

            if (tileIsMissing) {
                UIView *tile = [dataSource tiledScrollView:self tileForRow:row column:col resolution:resolution];

                // set the tile's frame so we insert it at the correct position
                CGRect frame = CGRectMake([self tileSize].width * col, [self tileSize].height * row, [self tileSize].width, [self tileSize].height);
                [tile setFrame:frame];
                [tileContainerView addSubview:tile];

                // annotateTile draws green lines and tile numbers on the tiles for illustration purposes.
                [self annotateTile:tile];

            }
        }
    }

    // update our record of which rows/cols are visible
    firstVisibleRow = firstNeededRow; firstVisibleColumn = firstNeededCol;
    lastVisibleRow  = lastNeededRow;  lastVisibleColumn  = lastNeededCol;
}


问:
Can't replace string in a text file
Following this thread:

I have a text file storing usernames password and bestscore for that user.

Trying to make a simple quiz game. I have a signup panel and when user signs up I store the data in this file and make his best score 0 for the new user.

The text file format for every single line is

{username} {password} {bestScore}

And when the user makes more than his bestScore i try to replace the actual score in the text file with the bestScore.

Well, back to that thread. I did everything line @meriton posted but the text file still hadn't changed. Here is my code:

```<code>if (gameData.getBestScore() < gameData.getScore()) {
            int oldBestScore = gameData.getBestScore();
            String oldLine = gameData.getCurrentUser() + " " + gameData.getCurrentUserPassword() + " " + oldBestScore;
            gameData.setBestScore(gameData.getScore());
            String newLine = gameData.getCurrentUser() + " " + gameData.getCurrentUserPassword() + " " + gameData.getBestScore();

            // TODO replace the points in the text file
            //first method
            /*try(BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(new File("C:\\Users\\Niki\\Desktop\\Java Projects\\QuizGame\\QuizGame\\usernames.txt"))))) {
                String line = br.readLine();

                while (line != null) {
                    if (line.contains(gameData.getCurrentUser())) {
                        String newLine = gameData.getCurrentUser() + " " + gameData.getCurrentUserPassword() + " " + gameData.getBestScore();
                        line = line.replace(line, newLine);
                        break;
                    }
                    line = br.readLine();
                }

            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }*/

            //second method
            Path path = Paths.get("C:\\Users\\Niki\\Desktop\\Java Projects\\QuizGame\\QuizGame\\usernames.txt");
            Charset charset = StandardCharsets.UTF_8;

            String content = null;
            try {
                content = new String(Files.readAllBytes(path), charset);
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            System.out.println(content);
            content = content.replaceAll(oldLine, newLine);
            System.out.println(content);

            gameOverPanel.gameOverLabel.setText("<html><h1>You didn't answer correctly!</h1><hr><h2>The correct answer is: " + gameData.getCurrentQuestion().getCorrectAnswer().getText() + "</h2><h3>Congratulations! New High Score: " + gameData.getBestScore() + "</h3></html>");
        }
        else {
            gameOverPanel.gameOverLabel.setText("<html><h1>You didn't answer correctly!</h1><hr><h2>The correct answer is: " + gameData.getCurrentQuestion().getCorrectAnswer().getText() + "</h2><h3>Your score: " + gameData.getBestScore() + "</h3></html>");
        }
    }
</code>```

As you can see I println before editing the content and after that to the console and everything is ok there. The old content is replaced with the new one but the file is not updated with the new content.

Also i tried to do it my way you can see the commented section in my code under the //first method comment. That way still didn't work.

答:
Here:

```<code>System.out.println(content);
content = content.replaceAll(oldLine, newLine);
System.out.println(content);
</code>```

That updates your String variable in memory. That's all this does. But there is no "magic" connection between that value in your memory and the file on disc. That string variable does neither know nor care that you read its content from a file initially.

If you want to update the file content; then you have to write back the changed string into your file. See here for ideas how to do that.

Title: Can't replace string in a text file

Body:
Following this thread:

I have a text file storing usernames password and bestscore for that user.

Trying to make a simple quiz game. I have a signup panel and when user signs up I store the data in this file and make his best score 0 for the new user.

The text file format for every single line is

{username} {password} {bestScore}

And when the user makes more than his bestScore i try to replace the actual score in the text file with the bestScore.

Well, back to that thread. I did everything line @meriton posted but the text file still hadn't changed. Here is my code:

if (gameData.getBestScore() < gameData.getScore()) {
            int oldBestScore = gameData.getBestScore();
            String oldLine = gameData.getCurrentUser() + " " + gameData.getCurrentUserPassword() + " " + oldBestScore;
            gameData.setBestScore(gameData.getScore());
            String newLine = gameData.getCurrentUser() + " " + gameData.getCurrentUserPassword() + " " + gameData.getBestScore();

            // TODO replace the points in the text file
            //first method
            /*try(BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(new File("C:\\Users\\Niki\\Desktop\\Java Projects\\QuizGame\\QuizGame\\usernames.txt"))))) {
                String line = br.readLine();

                while (line != null) {
                    if (line.contains(gameData.getCurrentUser())) {
                        String newLine = gameData.getCurrentUser() + " " + gameData.getCurrentUserPassword() + " " + gameData.getBestScore();
                        line = line.replace(line, newLine);
                        break;
                    }
                    line = br.readLine();
                }

            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }*/

            //second method
            Path path = Paths.get("C:\\Users\\Niki\\Desktop\\Java Projects\\QuizGame\\QuizGame\\usernames.txt");
            Charset charset = StandardCharsets.UTF_8;

            String content = null;
            try {
                content = new String(Files.readAllBytes(path), charset);
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            System.out.println(content);
            content = content.replaceAll(oldLine, newLine);
            System.out.println(content);

            gameOverPanel.gameOverLabel.setText("
You didn't answer correctly!

The correct answer is: " + gameData.getCurrentQuestion().getCorrectAnswer().getText() + "

Congratulations! New High Score: " + gameData.getBestScore() + "
");
        }
        else {
            gameOverPanel.gameOverLabel.setText("
You didn't answer correctly!

The correct answer is: " + gameData.getCurrentQuestion().getCorrectAnswer().getText() + "

Your score: " + gameData.getBestScore() + "
");
        }
    }

As you can see I println before editing the content and after that to the console and everything is ok there. The old content is replaced with the new one but the file is not updated with the new content.

Also i tried to do it my way you can see the commented section in my code under the //first method comment. That way still didn't work.

Body:
Here:

System.out.println(content);
content = content.replaceAll(oldLine, newLine);
System.out.println(content);

That updates your String variable in memory. That's all this does. But there is no "magic" connection between that value in your memory and the file on disc. That string variable does neither know nor care that you read its content from a file initially.

If you want to update the file content; then you have to write back the changed string into your file. See here for ideas how to do that.


问:
choose the class to be dynamically loaded in python
An event mapper program receives a stream of events based on the event key attribute. Specific handler classes are required to handle that event.

My requirement is that I want to be able to add new event handlers in the future, without restarting the event mapper program.

I am able to load the specific event handler classes dynamically.

```<code>def loadClass(self,module,file_name,class_name):
    try:
        worker_module = getattr(__import__(module+'.'+file_name),file_name)
        return getattr(worker_module, class_name)
    except Exception as e:
        print e
        return None
</code>```

I need a mapping between the event key attribute and the specific module,file_name and class_name

I'm thinking of maintaining the mapping in a seperate file with this mapping infomation, and read that to map every event, but I'm hoping that there is a better way.

答:
Could it be you are looking for dicts? I'm not quite sure what's your workflow (maybe clear that up), but what I understand is that:

event -> HandlerMapper reads event.key -> calls correct HandlerClass(event)

Which is exactly what a dictionary does:

```<code>#definition
handlers=dict()
handleEvent(event):
    if event.key in handlers:
        return handlers[event.key](event)
    else:
        #do magic to load class as HandlerClass
        handlers[event.key] = HandlerClass
        return handlers[event.key](event)
</code>```

What I don't understand is why you need this loader-magic at all. To add new handlers, simply add the class after it's loaded (i.e. call handler['key_of_new_event'] = NewHandlerClass)

Body:
An event mapper program receives a stream of events based on the event key attribute. Specific handler classes are required to handle that event.

My requirement is that I want to be able to add new event handlers in the future, without restarting the event mapper program.

I am able to load the specific event handler classes dynamically.

def loadClass(self,module,file_name,class_name):
    try:
        worker_module = getattr(__import__(module+'.'+file_name),file_name)
        return getattr(worker_module, class_name)
    except Exception as e:
        print e
        return None

I need a mapping between the event key attribute and the specific module,file_name and class_name

I'm thinking of maintaining the mapping in a seperate file with this mapping infomation, and read that to map every event, but I'm hoping that there is a better way.

Body:
Could it be you are looking for dicts? I'm not quite sure what's your workflow (maybe clear that up), but what I understand is that:

event -> HandlerMapper reads event.key -> calls correct HandlerClass(event)

Which is exactly what a dictionary does:

#definition
handlers=dict()
handleEvent(event):
    if event.key in handlers:
        return handlers[event.key](event)
    else:
        #do magic to load class as HandlerClass
        handlers[event.key] = HandlerClass
        return handlers[event.key](event)

What I don't understand is why you need this loader-magic at all. To add new handlers, simply add the class after it's loaded (i.e. call handler['key_of_new_event'] = NewHandlerClass)


问:
SQL - Convert a String into a Text
Sorry for bothering you again... I have a question about the SQLite database. I need to know how to transform a String into a Text so I can add this information to the table through a showInputDialog.

In the project, I've already converted a string into an integer without problems with this code:

```<code>String input = advice.showInputDialog("Insert number of the experiment:");
//String to integer
numExperiment = new Integer(input).intValue();

sql = "INSERT INTO Table VALUES ("+numExperiment+", "+column2+", "+column3+");";
</code>```

But now in my database, in another table, I have this TEXT column and I need to insert data with the showInputDialog. I'm using the same setting for the first part... but how to proceed? I tried searching online but I can't find the method to do this o something similar.

```<code>String input = pGame.showInputDialog("Add a new game");

//Code that I don't know how to put

sql2 = "INSERT INTO Game VALUES ("+nGame+");";
</code>```

Where nGame is the name of the column.

Thanks in advance for any advice or solution. Have a nice day.

答:
String can be used directly in the sql statement with single quotes:</p>

```<code>"INSERT INTO Game VALUES ('"+input+"');";
</code>```

Title: SQL - Convert a String into a Text

Body:
Sorry for bothering you again... I have a question about the SQLite database. I need to know how to transform a String into a Text so I can add this information to the table through a showInputDialog.

In the project, I've already converted a string into an integer without problems with this code:

String input = advice.showInputDialog("Insert number of the experiment:");
//String to integer
numExperiment = new Integer(input).intValue();

sql = "INSERT INTO Table VALUES ("+numExperiment+", "+column2+", "+column3+");";

But now in my database, in another table, I have this TEXT column and I need to insert data with the showInputDialog. I'm using the same setting for the first part... but how to proceed? I tried searching online but I can't find the method to do this o something similar.

String input = pGame.showInputDialog("Add a new game");

//Code that I don't know how to put

sql2 = "INSERT INTO Game VALUES ("+nGame+");";

Where nGame is the name of the column.

Thanks in advance for any advice or solution. Have a nice day.

Body:
String can be used directly in the sql statement with single quotes:

"INSERT INTO Game VALUES ('"+input+"');";


问:
dismiss progress dialog in asyntask
I have search box in my page,I added onTextChangeListener() too. When I am add/removing letters/characters from search box ,every time I am calling same asyntask.Suppose 3 times called then 3 times progress dialog instances getting created and need to dismissed.Here progress dialog is not getting dismissed.

```<code>search.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }
            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                searchresult = search.getText().toString();

                if (count == 0) {
                    pageCount = 1;
                    productsList.clear();
                    mCount = 0;
                    if (isTextWatcherVisible) {
//                        GetProductsTask();
                        new GetProductsTask().execute();
                    }
                }
            }
            @Override
            public void afterTextChanged(Editable s) {
            }
        });
class GetProductsTask extends AsyncTask<Void, Void, Void> {

    final String pcid = Preferences.getString(Preferences.PrefType.enum_company_id, getActivity());

    String url1 = getContext().getString(R.string.url) + "products?company_id=" + pcid + "&page=" + pageCount;

    public GetProductsTask() {
        progressDialog = new ProgressDialog(getActivity());
        progressDialog.setMessage("Loading...");
        progressDialog.setIndeterminate(false);
        progressDialog.setCancelable(false);
    }
    protected void onPreExecute() {
        super.onPreExecute();
//                progressDialog = new ProgressDialog(getActivity());
//                progressDialog.setMessage("Loading...");
//                progressDialog.setIndeterminate(false);
//                progressDialog.setCancelable(false);
        progressDialog.show();

    }

    @Override
    protected Void doInBackground(Void... params) {
      // somthig here
    }
    protected void onPostExecute(Void result) {
        super.onPostExecute(result);
        ProductslistAdapter adapter = new ProductslistAdapter(getActivity(), R.layout.vendor_products_item, productsList, searchresult);

        list.setAdapter(adapter);
        int count = pageCount - 1;
        list.setSelection(count * 24);
        if (progressDialog.isShowing())
            progressDialog.dismiss();

    }
</code>```

答:
In your AsynchTask onPreExecute() method first check for progress Dialog if it is null then initialize and show it.

```<code>protected void onPreExecute() {
        super.onPreExecute();
         if (progressDialog == null) {
            progressDialog = new ProgressDialog(getActivity());
            progressDialog.setMessage("Loading...");
            progressDialog.setIndeterminate(false);
            progressDialog.setCancelable(false);
            progressDialog.show();
        }
    }
</code>```

And in onPostExecute() method just dismiss it.

```<code>protected void onPostExecute(Void result) {
        super.onPostExecute(result);
        // Your other code goes here
        if(progressDialog != null && progressDialog.isShowing()) {
                progressDialog.dismiss();
                progressDialog = null;
         }
        }
</code>```

Title: dismiss progress dialog in asyntask

Body:
I have search box in my page,I added onTextChangeListener() too. When I am add/removing letters/characters from search box ,every time I am calling same asyntask.Suppose 3 times called then 3 times progress dialog instances getting created and need to dismissed.Here progress dialog is not getting dismissed.

search.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }
            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                searchresult = search.getText().toString();

                if (count == 0) {
                    pageCount = 1;
                    productsList.clear();
                    mCount = 0;
                    if (isTextWatcherVisible) {
//                        GetProductsTask();
                        new GetProductsTask().execute();
                    }
                }
            }
            @Override
            public void afterTextChanged(Editable s) {
            }
        });
class GetProductsTask extends AsyncTask<Void, Void, Void> {

    final String pcid = Preferences.getString(Preferences.PrefType.enum_company_id, getActivity());

    String url1 = getContext().getString(R.string.url) + "products?company_id=" + pcid + "&page=" + pageCount;

    public GetProductsTask() {
        progressDialog = new ProgressDialog(getActivity());
        progressDialog.setMessage("Loading...");
        progressDialog.setIndeterminate(false);
        progressDialog.setCancelable(false);
    }
    protected void onPreExecute() {
        super.onPreExecute();
//                progressDialog = new ProgressDialog(getActivity());
//                progressDialog.setMessage("Loading...");
//                progressDialog.setIndeterminate(false);
//                progressDialog.setCancelable(false);
        progressDialog.show();

    }

    @Override
    protected Void doInBackground(Void... params) {
      // somthig here
    }
    protected void onPostExecute(Void result) {
        super.onPostExecute(result);
        ProductslistAdapter adapter = new ProductslistAdapter(getActivity(), R.layout.vendor_products_item, productsList, searchresult);

        list.setAdapter(adapter);
        int count = pageCount - 1;
        list.setSelection(count * 24);
        if (progressDialog.isShowing())
            progressDialog.dismiss();

    }

Body:
In your AsynchTask onPreExecute() method first check for progress Dialog if it is null then initialize and show it.

protected void onPreExecute() {
        super.onPreExecute();
         if (progressDialog == null) {
            progressDialog = new ProgressDialog(getActivity());
            progressDialog.setMessage("Loading...");
            progressDialog.setIndeterminate(false);
            progressDialog.setCancelable(false);
            progressDialog.show();
        }
    }

And in onPostExecute() method just dismiss it.

protected void onPostExecute(Void result) {
        super.onPostExecute(result);
        // Your other code goes here
        if(progressDialog != null && progressDialog.isShowing()) {
                progressDialog.dismiss();
                progressDialog = null;
         }
        }


问:
sql delete query with where, and, or laravel
Hello i am building a delete query to delete an row out of my database in laravel and i came to this problem i need to find a row where ... and ... or ... and ...

So in normal php that would be

```<code>DELETE * FROM connection_requests
WHERE `user_id`=$user->id AND `selected_user_id`=$id OR
`selected_user_id`=$user->id AND `user_id`=$id;
</code>```

(The first and belongs to the where and the second and belongs to the or)

now how do i do this in laravel

答:
You may try this</p>

```<code>DB::table('connection_requests')
    ->where(function ($query) use ($user->id, $id) {
        $query->where('user_id', '=', $user->id)
              ->where('selected_user_id', '=', $id);
    })
    ->orWhere(function ($query) use ($user->id, $id) {
            $query->where('selected_user_id', '=', $user->id)
                  ->where('user_id', '=', $id);
    })
    ->delete();
</code>```

Body:
Hello i am building a delete query to delete an row out of my database in laravel and i came to this problem i need to find a row where ... and ... or ... and ...

So in normal php that would be

DELETE * FROM connection_requests
WHERE `user_id`=$user->id AND `selected_user_id`=$id OR
`selected_user_id`=$user->id AND `user_id`=$id;

(The first and belongs to the where and the second and belongs to the or)

now how do i do this in laravel

Body:
You may try this

DB::table('connection_requests')
    ->where(function ($query) use ($user->id, $id) {
        $query->where('user_id', '=', $user->id)
              ->where('selected_user_id', '=', $id);
    })
    ->orWhere(function ($query) use ($user->id, $id) {
            $query->where('selected_user_id', '=', $user->id)
                  ->where('user_id', '=', $id);
    })
    ->delete();


问:
How to retrieve data that is not in the same order as the query in SQL?
I am trying to retrieve a record from a table in SQL.

Here is what I want. For example:

I have a table name studentScore with two columns:

```<code>studentName -----  Scores
John Smith  ----- 75,83, 96
</code>```

I want to do this: When I type the score in a search box, I want it to show me the name of the student. For example: I could type "83, 96, 75", (the scores can be in any order) and this should show me the student name "John Smith". But I'm wondering how we could specify in the WHERE clause so that it picks up the correct record, if what we type in the box is not in the same order as the original data in the column?

答:
You could use Regular expressions or the Like operator

A regexp solution could look like

```<code>SIMILAR TO '%(SCORE1|SCORE2|SCORE3)%'
</code>```

That's the easiest way to go
but I recommend you changing your entire table structure as been mentioned now
a couple of times, since you have no possibility to take advantage of an index or key
which will exhaust the computer in matter of a couple tens of visitors

Body:
I am trying to retrieve a record from a table in SQL.

Here is what I want. For example:

I have a table name studentScore with two columns:

studentName -----  Scores
John Smith  ----- 75,83, 96

I want to do this: When I type the score in a search box, I want it to show me the name of the student. For example: I could type "83, 96, 75", (the scores can be in any order) and this should show me the student name "John Smith". But I'm wondering how we could specify in the WHERE clause so that it picks up the correct record, if what we type in the box is not in the same order as the original data in the column?

Body:
You could use Regular expressions or the Like operator

A regexp solution could look like

SIMILAR TO '%(SCORE1|SCORE2|SCORE3)%'

That's the easiest way to go
but I recommend you changing your entire table structure as been mentioned now
a couple of times, since you have no possibility to take advantage of an index or key
which will exhaust the computer in matter of a couple tens of visitors


问:
Java Multiple Sets within a Map
I am reading from a CSV file which contains data about Hills, all the reading etc works fine but now I want to create a map which associates the "County Name" (A column header in the file) with all the hills that have the county name in it.

I am along the right path, because my code works for the first countyName, but the problem is when my for loop If statement goes to the else statement, I want it to technically create another set (clearing the previous values) and assigning the new hill data with the county name

My output is:

```<code>{Perth and Kinross=[16,Knock of Crieff,Perth and Kinross,279.0,56.389329,-3.826973, 3,Creag Uchdag,Perth and Kinross,879.0,56.465278,-4.098107]}
</code>```

So it has all the hills with "Perth and Kinross" in it. So now my next county name is "Stirling" for example so the map should end up like

```<code>{Perth and Kinross=[16,Knock of Crieff,Perth and Kinross,279.0,56.389329,-3.826973, 3,Creag Uchdag,Perth and Kinross,879.0,56.465278,-4.098107], Stirling=[7,Meall Buidhe,Stirling,719.0,56.419004,-4.308645]}
</code>```

What I'm unsure about is how to create another set without clearing the values stored for Perth and Kinross

My code is:

```<code>    Map<String, Set<Hill>> hillsByCounty = new HashMap<>();

        if (h.getCounty().equals(countyName)) {
            hillsByCounty.get(countyName);
            currentSet.add(h);
            hillsByCounty.put(countyName, currentSet);

        } else {

            countyName = h.getCounty();
            currentSet.clear();
            currentSet.add(h);

        }
    }

    return hillsByCounty;
}
</code>```

Where exactly is it going wrong. I have a feeling it is the clear function but i'm not sure how else i would do this.

My current code prints out:

```<code>{Perth and Kinross=[7,Meall Buidhe,Stirling,719.0,56.419004,-4.308645], Stirling=[7,Meall Buidhe,Stirling,719.0,56.419004,-4.308645]}
</code>```

As its overwriting the set. What would be my workaround?

答: You reuse the same set. So if your county changes, you clear the set and fill it with the next county. Instead you should create a new set. As long as you reuse the same set, well, you reuse the same set, empty it and fill something else in it. hillsByCounty.put(...) does not clone the set, but just stores a reference.

Title: Java Multiple Sets within a Map

Body:
I am reading from a CSV file which contains data about Hills, all the reading etc works fine but now I want to create a map which associates the "County Name" (A column header in the file) with all the hills that have the county name in it.

I am along the right path, because my code works for the first countyName, but the problem is when my for loop If statement goes to the else statement, I want it to technically create another set (clearing the previous values) and assigning the new hill data with the county name

My output is:

{Perth and Kinross=[16,Knock of Crieff,Perth and Kinross,279.0,56.389329,-3.826973, 3,Creag Uchdag,Perth and Kinross,879.0,56.465278,-4.098107]}

So it has all the hills with "Perth and Kinross" in it. So now my next county name is "Stirling" for example so the map should end up like

{Perth and Kinross=[16,Knock of Crieff,Perth and Kinross,279.0,56.389329,-3.826973, 3,Creag Uchdag,Perth and Kinross,879.0,56.465278,-4.098107], Stirling=[7,Meall Buidhe,Stirling,719.0,56.419004,-4.308645]}

What I'm unsure about is how to create another set without clearing the values stored for Perth and Kinross

My code is:

    Map<String, Set<Hill>> hillsByCounty = new HashMap<>();

        if (h.getCounty().equals(countyName)) {
            hillsByCounty.get(countyName);
            currentSet.add(h);
            hillsByCounty.put(countyName, currentSet);

        } else {

            countyName = h.getCounty();
            currentSet.clear();
            currentSet.add(h);

        }
    }

    return hillsByCounty;
}

Where exactly is it going wrong. I have a feeling it is the clear function but i'm not sure how else i would do this.

My current code prints out:

{Perth and Kinross=[7,Meall Buidhe,Stirling,719.0,56.419004,-4.308645], Stirling=[7,Meall Buidhe,Stirling,719.0,56.419004,-4.308645]}

As its overwriting the set. What would be my workaround?


问:
PostgreSQL Need to make TOTAL ROW
enter image description hereHello I'm Begginer and I need some help, I have this code in my SQL database

```<code>SELECT round(SUM(Cena)::NUMERIC,2) AS CelkovaCena, a.Meno, a.Priezvisko,Nazov
FROM Predstavenie
JOIN Autor a ON Predstavenie.ID_Autor = a.ID_Autor
WHERE a.Meno = 'Juraj' AND a.Priezvisko = 'Klein'
GROUP BY a.Meno,a.Priezvisko,Nazov;
</code>```

This is what i get after i run this SELECT.

```<code>2.2 |    Juraj   |  Klein  |    Po východe slnka
5.4 |    Juraj   |  Klein  |    Ako išiel Ferenc po hlavnej
0.5 |    Juraj   |  Klein  |    Protialkoholické hnutie Klein Ferenc PHKF
</code>```

I need to make total row below, from col "cena". I need to have something like this.

```<code>2.2 |    Juraj   |  Klein  |    Po východe slnka
5.4 |    Juraj   |  Klein  |    Ako išiel Ferenc po hlavnej
0.5 |    Juraj   |  Klein  |    Protialkoholické hnutie Klein Ferenc PHKF
8.1 |                      |                          |
</code>```

Rollup doesnt seem to work because of groups. I looked up on internet for various solutions, but none of them works... Thank you.

答:
Combining WITH and UNION can get you what you need if you put this in a subquery.

```<code>WITH subq AS (SELECT round(SUM(Cena)::NUMERIC,2) AS CelkovaCena, a.Meno, a.Priezvisko,Nazov
FROM Predstavenie
JOIN Autor a ON Predstavenie.ID_Autor = a.ID_Autor
WHERE a.Meno = 'Juraj' AND a.Priezvisko = 'Klein'
GROUP BY a.Meno,a.Priezvisko,Nazov)
SELECT * FROM subq
UNION
SELECT SUM(CelkovaCena), '', '', '' FROM subq;
</code>```

This saves you having to get the results twice and slowing things down unnecessarily. Just make sure every SELECT has the same number and type of columns as the first one.

Title: PostgreSQL Need to make TOTAL ROW

Body:
enter image description hereHello I'm Begginer and I need some help, I have this code in my SQL database

SELECT round(SUM(Cena)::NUMERIC,2) AS CelkovaCena, a.Meno, a.Priezvisko,Nazov
FROM Predstavenie
JOIN Autor a ON Predstavenie.ID_Autor = a.ID_Autor
WHERE a.Meno = 'Juraj' AND a.Priezvisko = 'Klein'
GROUP BY a.Meno,a.Priezvisko,Nazov;

This is what i get after i run this SELECT.

2.2 |    Juraj   |  Klein  |    Po východe slnka
5.4 |    Juraj   |  Klein  |    Ako išiel Ferenc po hlavnej
0.5 |    Juraj   |  Klein  |    Protialkoholické hnutie Klein Ferenc PHKF

I need to make total row below, from col "cena". I need to have something like this.

2.2 |    Juraj   |  Klein  |    Po východe slnka
5.4 |    Juraj   |  Klein  |    Ako išiel Ferenc po hlavnej
0.5 |    Juraj   |  Klein  |    Protialkoholické hnutie Klein Ferenc PHKF
8.1 |                      |                          |

Rollup doesnt seem to work because of groups. I looked up on internet for various solutions, but none of them works... Thank you.

Body:
Combining WITH and UNION can get you what you need if you put this in a subquery.

WITH subq AS (SELECT round(SUM(Cena)::NUMERIC,2) AS CelkovaCena, a.Meno, a.Priezvisko,Nazov
FROM Predstavenie
JOIN Autor a ON Predstavenie.ID_Autor = a.ID_Autor
WHERE a.Meno = 'Juraj' AND a.Priezvisko = 'Klein'
GROUP BY a.Meno,a.Priezvisko,Nazov)
SELECT * FROM subq
UNION
SELECT SUM(CelkovaCena), '', '', '' FROM subq;

This saves you having to get the results twice and slowing things down unnecessarily. Just make sure every SELECT has the same number and type of columns as the first one.


问:
How to retain a space after floated :first-letter when the first letter is immediately followed by a space?
What's an elegant solution (i.e. without adding a   to the text), to introduce a space between the drop capital and the second letter, when the first word is a single letter?

I'm trying to add drop capitals to the first letter of a paragraph. The problem I am encountering is that it looks confusing if the first word is a 1 letter word, like I, which causes the space after to disappear.

An example is below:

p::first-letter {
  font-size: 150%;
  float: left;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><p>Some text.</p>

<p>
    I am some long text. I am some long text. I am some long text. I am some long text. I am some long text. I am some long text. I am some long text. I am some long text. I am some long text. I am some long text. I am some long text. I am some long text. I am some long text. I am some long text. I am some long text. I am some long text. I am some long text. I am some long text. I am some long text. I am some long text.
</p></code>```

The solution must keep the line height the same between lines in the same way that float: left does.

答:
The following solution preserves the whitespace after the first character.

p {
  white-space: pre-wrap;
}

p::first-letter {
  font-size: 150%;
  float: left;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><p>Some text.</p>

<p>I am some long text. I am some long text. I am some long text. I am some long text. I am some long text. I am some long text. I am some long text. I am some long text. I am some long text. I am some long text. I am some long text. I am some long text. I am some long text. I am some long text. I am some long text. I am some long text. I am some long text. I am some long text. I am some long text. I am some long text.</p></code>```

NB: this requires the inner html to the p to be formatted on one line and the whitespace to be correct for the rest of the line, so that it doesn't interfere with the rest of the whitespace.

Body:
What's an elegant solution (i.e. without adding a   to the text), to introduce a space between the drop capital and the second letter, when the first word is a single letter?

I'm trying to add drop capitals to the first letter of a paragraph. The problem I am encountering is that it looks confusing if the first word is a 1 letter word, like I, which causes the space after to disappear.

An example is below:

p::first-letter {
  font-size: 150%;
  float: left;
}

Some text.

    I am some long text. I am some long text. I am some long text. I am some long text. I am some long text. I am some long text. I am some long text. I am some long text. I am some long text. I am some long text. I am some long text. I am some long text. I am some long text. I am some long text. I am some long text. I am some long text. I am some long text. I am some long text. I am some long text. I am some long text.

The solution must keep the line height the same between lines in the same way that float: left does.

Body:
The following solution preserves the whitespace after the first character.

p {
  white-space: pre-wrap;
}

p::first-letter {
  font-size: 150%;
  float: left;
}

<p>Some text.</p>

<p>I am some long text. I am some long text. I am some long text. I am some long text. I am some long text. I am some long text. I am some long text. I am some long text. I am some long text. I am some long text. I am some long text. I am some long text. I am some long text. I am some long text. I am some long text. I am some long text. I am some long text. I am some long text. I am some long text. I am some long text.</p>

NB: this requires the inner html to the p to be formatted on one line and the whitespace to be correct for the rest of the line, so that it doesn't interfere with the rest of the whitespace.


答:
Add margin-top for centered horizontaly the text :)</p>

```<code>    .center-block {
    display: block;
    margin-right: auto;
    **margin-top: 30px;**
    margin-left: auto;
}
</code>```

Title: Using bootstrap how can I put this text in the middle of the nav bar?

Body:
How can I put the text
Liam Docherty's Digital Portfolio
in the middle of the navigation bar so it in line with the other nav bar webpages text?

<!DOCTYPE html>

      <meta name="viewport" content="width=device-width, initial-scale=1">
      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

               <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
               Toggle navigation

               </button>

Liam Docherty's Digital Portfolio

Liam Docherty's Digital Portfolio

Home

                     Units

Unit 6

Unit 14

Unit 7

Unit 1

                     About

About Me

CV

Education

Contact Me

WELCOME TO MY

PORTFOLIO

Body:
Add margin-top for centered horizontaly the text :)

    .center-block {
    display: block;
    margin-right: auto;
    **margin-top: 30px;**
    margin-left: auto;
}