问:
.Net xsd.exe tool doesn't generate all types
For some reason, MS .Net (v3.5) tool - xsd.exe doesn't generate types when they are not used inside any element.

e.g.

XSD File (I threw in the complex element to avoid this warning - "Warning: cannot generate classes because no top-level elements with complex type were found."):

```<code><?xml version="1.0" encoding="utf-8"?>
<xs:schema targetNamespace="http://tempuri.org/XMLSchema.xsd"
    elementFormDefault="qualified"
    xmlns="http://tempuri.org/XMLSchema.xsd"
    xmlns:mstns="http://tempuri.org/XMLSchema.xsd"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
>
  <xs:simpleType name="EnumTest">
    <xs:restriction base="xs:string">
      <xs:enumeration value="item1" />
      <xs:enumeration value="item2" />
      <xs:enumeration value="item3" />
    </xs:restriction>
  </xs:simpleType>
  <xs:complexType name="myComplexType">
    <xs:attribute name="Name" use="required" type="xs:string"/>
  </xs:complexType>
  <xs:element name="myElem" type="myComplexType"></xs:element>
</xs:schema>
</code>```

When i run this thru xsd.exe using

xsd /c xsdfile.xsd

I don't see EnumTest in the generated cs file.

Note; Even though I don't use the enum here, but in my actual project, I have cases like this where we send enum's string value as output.

How can I force the xsd tool to include these? Or should I switch to some other tool?

I work in Visual Studio 2008.

答:
I know this is very old, but it came up in google when I was searching and I found an answer.

An Xsd has to have at lease one xs:element to be valid and for xsd.exe to work right.

look at this for more info
http://keithelder.net/2008/11/02/creating-a-rest-wcf-service-from-an-existing-xsd-schema/

Body:
For some reason, MS .Net (v3.5) tool - xsd.exe doesn't generate types when they are not used inside any element.

e.g.

XSD File (I threw in the complex element to avoid this warning - "Warning: cannot generate classes because no top-level elements with complex type were found."):

<?xml version="1.0" encoding="utf-8"?>
<xs:schema targetNamespace="http://tempuri.org/XMLSchema.xsd"
    elementFormDefault="qualified"
    xmlns="http://tempuri.org/XMLSchema.xsd"
    xmlns:mstns="http://tempuri.org/XMLSchema.xsd"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
>
  <xs:simpleType name="EnumTest">
    <xs:restriction base="xs:string">
      <xs:enumeration value="item1" />
      <xs:enumeration value="item2" />
      <xs:enumeration value="item3" />
    </xs:restriction>
  </xs:simpleType>
  <xs:complexType name="myComplexType">
    <xs:attribute name="Name" use="required" type="xs:string"/>
  </xs:complexType>
  <xs:element name="myElem" type="myComplexType"></xs:element>
</xs:schema>

When i run this thru xsd.exe using

xsd /c xsdfile.xsd

I don't see EnumTest in the generated cs file.

Note; Even though I don't use the enum here, but in my actual project, I have cases like this where we send enum's string value as output.

How can I force the xsd tool to include these? Or should I switch to some other tool?

I work in Visual Studio 2008.


来源: stackexchange

问:
Transform 3d point using angles
I have a 3d point that I would like to rotate using angles (yaw, pitch and roll) around { 0, 0, 0 }.

How would I go about it, without converting the angles into a matrix?

答:
Well, you don't really "convert angles into a matrix".  Strictly speaking, rotations are linear transformation and are in general comprised of an angle and an axis (vector) about which the rotation occurs.  The two easiest approaches to define an angle / axis rotation is by using quaternions or rotation matrices.  There may be other approaches, but these two methods are used largely because they are the easiest methods anyone has proposed to date.  Of the two, I personally prefer quaternions for rotations since they are easier to implement and require fewer arithmetic operations.  3x3 matrices have the benefit that they are able to handle general 3D->3D linear transformation; 4x4 matrices can perform general 3D->3D affine transformation on 3D vectors.

If you want to use separate rotations for yaw, pitch and roll, you should probably review issues related to Euler Angles.  You can model these using either rotation matrices or quaternions.  Both approaches will essentially be equivalent.  It's simply a matter of defining a sequence of angle / axis pairs and multiplying them to get the final rotation.  That rotation is then applied to whatever points you have to arrive at the rotated value.

ContentLicense: CC BY-SA 3.0

Title: Transform 3d point using angles


问:
Table View doesn't show Data, why? (Swift 3)
I've made an app using a table view to persist data. The table view shows the elements of an array which is saved through UserDefaults. Since TableViewControllers look kind of ugly, I did it a bit different: I put a TableView into a normal ViewController.
My problem is: even though I did everything I could to get the TableView to show the data, it doesn't, and I don't know why. Could anyone help me?
Here's the code of the ViewController:

```<code>class ErfolgreicheChallenges: UIViewController, UITableViewDelegate, UITableViewDataSource {

    @IBOutlet var myTableView: UITableView!

    var data = [String]()

    override func viewDidLoad() {
        super.viewDidLoad()

        myTableView.delegate = self

        data.append("test")
        data.append("lol")

    }

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

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

    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

        myTableView.dataSource = self

        let cell = myTableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)

        cell.textLabel!.text = data[indexPath.row]

        return cell
    }

    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {

    }

}
</code>```

Thanks to everyone for having a look! Have a great day

答:
Replace viewDidLoad with

```<code>override func viewDidLoad() {
    super.viewDidLoad()

    myTableView.dataSource = self
    myTableView.delegate = self

    data.append("test")
    data.append("lol")
    myTableView.reloadData()

}
</code>```

and replace numberOfRowsInSection with

```<code>func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return data.count
    }
</code>```

and delete myTableView.dataSource = self in cellForRow.

If the code is crashing then myTableView is not connected in IB.

As mentioned in the comments, consider to use UITableViewController which got a table view instance with pre-connected data source and delegate.

Body:
I've made an app using a table view to persist data. The table view shows the elements of an array which is saved through UserDefaults. Since TableViewControllers look kind of ugly, I did it a bit different: I put a TableView into a normal ViewController.
My problem is: even though I did everything I could to get the TableView to show the data, it doesn't, and I don't know why. Could anyone help me?
Here's the code of the ViewController:

class ErfolgreicheChallenges: UIViewController, UITableViewDelegate, UITableViewDataSource {

    @IBOutlet var myTableView: UITableView!

    var data = [String]()

    override func viewDidLoad() {
        super.viewDidLoad()

        myTableView.delegate = self

        data.append("test")
        data.append("lol")

    }

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

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

    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

        myTableView.dataSource = self

        let cell = myTableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)

        cell.textLabel!.text = data[indexPath.row]

        return cell
    }

    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {

    }

}

Thanks to everyone for having a look! Have a great day

Body:
Replace viewDidLoad with

override func viewDidLoad() {
    super.viewDidLoad()

    myTableView.dataSource = self
    myTableView.delegate = self

    data.append("test")
    data.append("lol")
    myTableView.reloadData()

}

and replace numberOfRowsInSection with

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

and delete myTableView.dataSource = self in cellForRow.

If the code is crashing then myTableView is not connected in IB.

As mentioned in the comments, consider to use UITableViewController which got a table view instance with pre-connected data source and delegate.


问:
Would Window.Open() Command Be Considered A Referral?
I'm using a local script in Firefox (file:///filepath/...) to open urls. One part of the script uses the window.open() command. A sample of the code is below:

```<code>        if(x[i].indexOf('.') > 0) {
            if(x[i].indexOf('://') < 0) {
                window.open('http://' + x[i++]);
            } else {
                window.open(x[i++]);
            }
</code>```

For the JavaScript experts, when the script is opening a url. Is there anyway the local file (file:///filepath/...) would be considered a referral?

I don't want it to show up as a referring page in analytics. I just want to confirm that the window.open command only opens windows as if I typed them in. Is that correct?

答:
I was able to confirm that the window.open command does not act as a referral. By running a few test runs on a site, I was able to verify through analytics that they are direct visits as if you typed them in.

Hope this helps anyone wondering if window.open will reveal their local path.

Body:
I'm using a local script in Firefox (file:///filepath/...) to open urls. One part of the script uses the window.open() command. A sample of the code is below:

        if(x[i].indexOf('.') > 0) {
            if(x[i].indexOf('://') < 0) {
                window.open('http://' + x[i++]);
            } else {
                window.open(x[i++]);
            }

For the JavaScript experts, when the script is opening a url. Is there anyway the local file (file:///filepath/...) would be considered a referral?

I don't want it to show up as a referring page in analytics. I just want to confirm that the window.open command only opens windows as if I typed them in. Is that correct?


问:
Not been able to set focus to my <ion-input> as i enter the page
I want focus to be set on my <ion-input> as I enter the page

This is my typescript code:

```<code>import { Component, Input, ViewChild,ElementRef,Renderer } from '@angular/core';
import { NavController, PopoverController, NavParams, ViewController, ModalController } from 'ionic-angular';

@Component({
  selector: 'page-comments',
  templateUrl: 'comments.html'
})
export class CommentsParentPage {
    @ViewChild('input') myInput;

    constructor(public navCtrl: NavController,private renderer: Renderer,
                private elementRef: ElementRef, public modalCtrl: ModalController) {
    }

    ionViewLoaded() {

       setTimeout(() => {
          let element = this.elementRef.nativeElement.querySelector('input');
          this.renderer.invokeElementMethod(element, 'focus', []);
       },150);
    }

}
</code>```

And this is what i have done with my html file:

```<code> <ion-item>
      <ion-input set-focuser type="text" placeholder="Write Your Comments" [(ngModel)]="addComment"></ion-input>

    </ion-item>
</code>```

Whenever I enter this page of my application, I would like the keyboard to be opened and focus to be set on ion-input

My config.xml includes:

```<code><preference name="KeyboardDisplayRequiresUserAction" value="false" />
</code>```

package.json

```<code> {
  "name": "sample app",
  "author": "",
  "homepage": "http://ionicframework.com/",
  "private": true,
  "scripts": {
    "clean": "ionic-app-scripts clean",
    "build": "ionic-app-scripts build",
    "ionic:build": "ionic-app-scripts build",
    "ionic:serve": "ionic-app-scripts serve"
  },
  "dependencies": {
    "@angular/common": "2.2.1",
    "@angular/compiler": "2.2.1",
    "@angular/compiler-cli": "2.2.1",
    "@angular/core": "2.2.1",
    "@angular/forms": "2.2.1",
    "@angular/http": "2.2.1",
    "@angular/platform-browser": "2.2.1",
    "@angular/platform-browser-dynamic": "2.2.1",
    "@angular/platform-server": "2.2.1",
    "@ionic-native/core": "^3.4.4",
    "@ionic-native/keyboard": "^3.4.4",
    "@ionic/cloud-angular": "^0.10.0",
    "@ionic/storage": "1.1.7",
    "angular2-moment": "^1.1.0",
    "google-libphonenumber": "^2.0.14",
    "ionic-angular": "2.0.0-rc.4",
    "ionic-gallery-modal": "0.0.7",
    "ionic-native": "2.2.11",
    "ionicons": "3.0.0",
    "rxjs": "5.0.0-beta.12",
    "zone.js": "0.6.26"
  },
  "devDependencies": {
    "@ionic/app-scripts": "1.0.0",
    "typescript": "2.0.9"
  },
  "cordovaPlugins": [
    "ionic-plugin-keyboard",
    "cordova-plugin-whitelist",
    "cordova-plugin-console",
    "cordova-plugin-statusbar",
    "cordova-plugin-device",
    "cordova-plugin-splashscreen",
    "cordova-sqlite-storage",
    "cordova-plugin-x-toast",
    "cordova-plugin-camera",
    "cordova-plugin-compat",
    "cordova-plugin-image-picker",
    "cordova.plugins.diagnostic",
    {
      "id": "phonegap-plugin-push",
      "locator": "phonegap-plugin-push",
      "variables": {
        "SENDER_ID": "461076790064"
      }
    },
    "cordova-plugin-contacts",
    "ionic-plugin-deploy",
    "cordova-plugin-x-socialsharing",
    {
      "locator": "https://github.com/napolitano/cordova-plugin-intent",
      "id": "com.napolitano.cordova.plugin.intent"
    },
    "cordova-plugin-screen-orientation",
    "cordova-plugin-file",
    "cordova-plugin-file-transfer"
  ],
  "cordovaPlatforms": [
    {
      "platform": "android",
      "version": "",
      "locator": "android"
    }
  ],
  "description": "ionic2: An Ionic project"
}
</code>```

答:
You can try simple method.

```<code> <div ng-init="getfocus()">
   <ion-input id="myAnchor" type="text" placeholder="Write Your Comments"/>
</div>
</code>```

In js file call a function with ng-init

```<code>function getfocus() {
   document.getElementById("myAnchor").focus();
}
</code>```

Hope this code will help you.if you get any error please comment.

Body:
I want focus to be set on my <ion-input> as I enter the page

This is my typescript code:

import { Component, Input, ViewChild,ElementRef,Renderer } from '@angular/core';
import { NavController, PopoverController, NavParams, ViewController, ModalController } from 'ionic-angular';

@Component({
  selector: 'page-comments',
  templateUrl: 'comments.html'
})
export class CommentsParentPage {
    @ViewChild('input') myInput;

    constructor(public navCtrl: NavController,private renderer: Renderer,
                private elementRef: ElementRef, public modalCtrl: ModalController) {
    }

    ionViewLoaded() {

       setTimeout(() => {
          let element = this.elementRef.nativeElement.querySelector('input');
          this.renderer.invokeElementMethod(element, 'focus', []);
       },150);
    }

}

And this is what i have done with my html file:

 <ion-item>
      <ion-input set-focuser type="text" placeholder="Write Your Comments" [(ngModel)]="addComment"></ion-input>

    </ion-item>

Whenever I enter this page of my application, I would like the keyboard to be opened and focus to be set on ion-input

My config.xml includes:

<preference name="KeyboardDisplayRequiresUserAction" value="false" />

package.json

 {
  "name": "sample app",
  "author": "",
  "homepage": "http://ionicframework.com/",
  "private": true,
  "scripts": {
    "clean": "ionic-app-scripts clean",
    "build": "ionic-app-scripts build",
    "ionic:build": "ionic-app-scripts build",
    "ionic:serve": "ionic-app-scripts serve"
  },
  "dependencies": {
    "@angular/common": "2.2.1",
    "@angular/compiler": "2.2.1",
    "@angular/compiler-cli": "2.2.1",
    "@angular/core": "2.2.1",
    "@angular/forms": "2.2.1",
    "@angular/http": "2.2.1",
    "@angular/platform-browser": "2.2.1",
    "@angular/platform-browser-dynamic": "2.2.1",
    "@angular/platform-server": "2.2.1",
    "@ionic-native/core": "^3.4.4",
    "@ionic-native/keyboard": "^3.4.4",
    "@ionic/cloud-angular": "^0.10.0",
    "@ionic/storage": "1.1.7",
    "angular2-moment": "^1.1.0",
    "google-libphonenumber": "^2.0.14",
    "ionic-angular": "2.0.0-rc.4",
    "ionic-gallery-modal": "0.0.7",
    "ionic-native": "2.2.11",
    "ionicons": "3.0.0",
    "rxjs": "5.0.0-beta.12",
    "zone.js": "0.6.26"
  },
  "devDependencies": {
    "@ionic/app-scripts": "1.0.0",
    "typescript": "2.0.9"
  },
  "cordovaPlugins": [
    "ionic-plugin-keyboard",
    "cordova-plugin-whitelist",
    "cordova-plugin-console",
    "cordova-plugin-statusbar",
    "cordova-plugin-device",
    "cordova-plugin-splashscreen",
    "cordova-sqlite-storage",
    "cordova-plugin-x-toast",
    "cordova-plugin-camera",
    "cordova-plugin-compat",
    "cordova-plugin-image-picker",
    "cordova.plugins.diagnostic",
    {
      "id": "phonegap-plugin-push",
      "locator": "phonegap-plugin-push",
      "variables": {
        "SENDER_ID": "461076790064"
      }
    },
    "cordova-plugin-contacts",
    "ionic-plugin-deploy",
    "cordova-plugin-x-socialsharing",
    {
      "locator": "https://github.com/napolitano/cordova-plugin-intent",
      "id": "com.napolitano.cordova.plugin.intent"
    },
    "cordova-plugin-screen-orientation",
    "cordova-plugin-file",
    "cordova-plugin-file-transfer"
  ],
  "cordovaPlatforms": [
    {
      "platform": "android",
      "version": "",
      "locator": "android"
    }
  ],
  "description": "ionic2: An Ionic project"
}

Body:
You can try simple method.

 <div ng-init="getfocus()">
   <ion-input id="myAnchor" type="text" placeholder="Write Your Comments"/>
</div>

In js file call a function with ng-init

function getfocus() {
   document.getElementById("myAnchor").focus();
}

Hope this code will help you.if you get any error please comment.


问:
How to add existing data types to SharePoint feature schema.xml
I have made a custom SharePoint feature based on default Document Library. Basically I made a copy of the DocumentLibrary folder and modified it and all the required xml files to make it unique library type. Now I need to add link to its supported content types but it seems not be working. I managed to do this via the web GUI but I need to add it straight to the CAML definition.

As far as I know the Link type should be added as ContentTypeRef tag to the schema.xml. I have the following markup inside the MetaData tag in the beginning of the file:

```<code><ContentTypes>
  <ContentTypeRef ID="0x0101">
    <Folder TargetName="Forms/Document" />
  </ContentTypeRef>
  <ContentTypeRef ID="0x0120" />
  <ContentTypeRef ID="0x0105" />
  <ContentTypeRef ID="0x01010A" />
</ContentTypes>
</code>```

Is there any other setup required to allow the link type? The above code doesn't enable links. The ID values of ContentTypeRef are from ctypewss.xml file.

Any help would be greatly appreciated.

答:
It seems your content type refs are wrong
follow  the link from this url that might be help for you Content Type IDs</p>

ContentLicense: CC BY-SA 2.5

Body:
I have made a custom SharePoint feature based on default Document Library. Basically I made a copy of the DocumentLibrary folder and modified it and all the required xml files to make it unique library type. Now I need to add link to its supported content types but it seems not be working. I managed to do this via the web GUI but I need to add it straight to the CAML definition.

As far as I know the Link type should be added as ContentTypeRef tag to the schema.xml. I have the following markup inside the MetaData tag in the beginning of the file:

<ContentTypes>
  <ContentTypeRef ID="0x0101">
    <Folder TargetName="Forms/Document" />
  </ContentTypeRef>
  <ContentTypeRef ID="0x0120" />
  <ContentTypeRef ID="0x0105" />
  <ContentTypeRef ID="0x01010A" />
</ContentTypes>

Is there any other setup required to allow the link type? The above code doesn't enable links. The ID values of ContentTypeRef are from ctypewss.xml file.

Any help would be greatly appreciated.


问:
creating a specific path in Netlogo for turtles to follow
I am creating a Netlogo model about a zoo. I need my zoo guests (multiple turtles) to follow a circular pathway that starts at the entrance of the zoo every 24 ticks (1 tick is 1 hour in my model). It has to move around cages that hold animals because I cannot have my guests enter the areas for animals. The path doesn't have to be fast or the shortest, I just need the turtle not to stray from it. I would prefer not to use GIS to create a pathway.

My world's dimensions are -30 to 30 in both directions and does not wrap around.

The whereabouts of the cages are described below:

```<code>patches-own [ tigerhabitat?
              flamingohabitat?
              monkeyhabitat?
              hippohabitat?
              giraffehabitat?
            ]

to create-habitats
  ask patches with [ pxcor < -12 and pycor > 23 ]
  [ set tigerhabitat? true
    set pcolor green ]

  ask patches with [ pxcor > 20 and pycor > 20 ]
  [ set hippohabitat? true
    set pcolor blue ]

  ask patches with [ pxcor > 18 and pycor < 15 and -1 < pycor ]
  [ set flamingohabitat? true
    set pcolor 96 ]

  ask patches with [ pxcor > -10 and pxcor < 10 and pycor < 10 and -10 < pycor ]
  [ set monkeyhabitat? true
    set pcolor green ]

  ask patches with [ pxcor < -12 and pycor < -20 ]
  [ set giraffehabitat? true
    set pcolor 67 ]

end
</code>```

答:
Paula- from your comment I think I understand a little better, thanks. One simple way to control where turtles can move is to use logical operators to exclude patches that they "consider" as they walk along. For a basic (non-path, yet) version of what you want, you could tell turtles that they can only move on patches that are not cages. You can set up a patch-only variable that explicitly says if a patch is caged or not, but in your example above all non-cage patches are black- you can use that to tell turtles that they should only walk onto a path if it is black. For example, you could add the procedures below to your code as above:

```<code>to setup
  ca
  reset-ticks
  crt 10 [
    setxy -25 0
  ]
  create-habitats
end

to go
  exclude-cage-walk
  tick
end

to exclude-cage-walk
  ask turtles [
    rt random 30 - 15
    let target one-of patches in-cone 1.5 180 with [ pcolor = black ]
    if target != nobody [
      face target
      move-to target
    ]
  ]
end
</code>```

You can see that before moving forward, each turtle assesses whether or not the patch it has chosen to move-to is black, and if it is not black, the turtle will not move there. Of course, you would have to modify this to suit your needs and have the turtles walk in a one-directional circuit, but it is a simple way to constrain turtle movement.

Body:
I am creating a Netlogo model about a zoo. I need my zoo guests (multiple turtles) to follow a circular pathway that starts at the entrance of the zoo every 24 ticks (1 tick is 1 hour in my model). It has to move around cages that hold animals because I cannot have my guests enter the areas for animals. The path doesn't have to be fast or the shortest, I just need the turtle not to stray from it. I would prefer not to use GIS to create a pathway.

My world's dimensions are -30 to 30 in both directions and does not wrap around.

The whereabouts of the cages are described below:

patches-own [ tigerhabitat?
              flamingohabitat?
              monkeyhabitat?
              hippohabitat?
              giraffehabitat?
            ]

to create-habitats
  ask patches with [ pxcor < -12 and pycor > 23 ]
  [ set tigerhabitat? true
    set pcolor green ]

  ask patches with [ pxcor > 20 and pycor > 20 ]
  [ set hippohabitat? true
    set pcolor blue ]

  ask patches with [ pxcor > 18 and pycor < 15 and -1 < pycor ]
  [ set flamingohabitat? true
    set pcolor 96 ]

  ask patches with [ pxcor > -10 and pxcor < 10 and pycor < 10 and -10 < pycor ]
  [ set monkeyhabitat? true
    set pcolor green ]

  ask patches with [ pxcor < -12 and pycor < -20 ]
  [ set giraffehabitat? true
    set pcolor 67 ]

end

Body:
Paula- from your comment I think I understand a little better, thanks. One simple way to control where turtles can move is to use logical operators to exclude patches that they "consider" as they walk along. For a basic (non-path, yet) version of what you want, you could tell turtles that they can only move on patches that are not cages. You can set up a patch-only variable that explicitly says if a patch is caged or not, but in your example above all non-cage patches are black- you can use that to tell turtles that they should only walk onto a path if it is black. For example, you could add the procedures below to your code as above:

to setup
  ca
  reset-ticks
  crt 10 [
    setxy -25 0
  ]
  create-habitats
end

to go
  exclude-cage-walk
  tick
end

to exclude-cage-walk
  ask turtles [
    rt random 30 - 15
    let target one-of patches in-cone 1.5 180 with [ pcolor = black ]
    if target != nobody [
      face target
      move-to target
    ]
  ]
end

You can see that before moving forward, each turtle assesses whether or not the patch it has chosen to move-to is black, and if it is not black, the turtle will not move there. Of course, you would have to modify this to suit your needs and have the turtles walk in a one-directional circuit, but it is a simple way to constrain turtle movement.


问:
How to remove the grey background behind JCheckboxes?
I want to remove the grey background that appears automatically when creating JCheckboxes. The panel that the JCheckboxes are in, is setOpaque(false). I have tried using setOpaque(false) with the JCheckboxes but it doesn't work. I want to make the JCheckboxes appear directly on the black background as in the image.

JCheckboxes grey background on black background:

My code is below. An arraylist was used to retrieve data from the database n display them as JCheckboxes. The ModulePanel was then added to the JFrame.

```<code>            Enrol= new JCheckBox(Modules.get(i));
            ModulePanel.add(Enrol);
</code>```

答:
First of all variable names should NOT start with an upper case character. Learn from the examples in your text book or tutorial.

Using setOpaque(false) on the check box works fine for me.

I want to make the JCheckboxes appear directly on the black background as in the image.

Looks like you are adding a panel containing the checkboxes to the component displaying the image.

I would guess the problem is that you also need to use setOpaque(false) on the panel that contains the checkboxes.

Body:
I want to remove the grey background that appears automatically when creating JCheckboxes. The panel that the JCheckboxes are in, is setOpaque(false). I have tried using setOpaque(false) with the JCheckboxes but it doesn't work. I want to make the JCheckboxes appear directly on the black background as in the image.

JCheckboxes grey background on black background:

My code is below. An arraylist was used to retrieve data from the database n display them as JCheckboxes. The ModulePanel was then added to the JFrame.

            Enrol= new JCheckBox(Modules.get(i));
            ModulePanel.add(Enrol);


问:
Export a string or an array to CSV
I have a very simple array that I'd like to export to CSV:

```<code>var uniqueCounties = ["555","123","345"];
</code>```

I have tried using methods found online but I have been getting various errors, and all the methods online deal with nested arrays.

My function at the moment is converting to a string. I was hoping it would simplify the process but I'm still now sure how to progress:

```<code>function download_csv() {
        var csv = uniqueCounties.toString();
        console.log(csv);
    }
</code>```

I was originally trying this method:

```<code>uniqueCounties.forEach(function(infoArray, index){

   dataString = infoArray.join(",");
   csvContent += index < data.length ? dataString+ "\n" : dataString;

});
</code>```

But kept getting the error infoArray.join is not a function.

答:
If you have a 2d array of strings (or anything that you are ok with toString-ing) for example:

```<code>const input = [
  ["555","123","345"],
  [1, 2, 3],
  [true, false, "foo"]
]
</code>```

Then you can do something like this:

```<code>function toCsv(input) {
  return input.map(row => row.join(',')).join('\n')
}

const csvString = toCsv(input)
</code>```

Resulting in this string:

```<code>555,123,345
1,2,3
true,false,foo
</code>```

If you just want to convert a single 1d array to csv, like in the example then:

```<code>const uniqueCounties = ["555","123","345"]

// If you want each value as a column
const csvAsSingleRow = uniqueCounties.join(',')

// If you want each value as a row
const csvAsSingleColumn = uniqueCounties.join('\n')
</code>```

This gets more and more complicated if you want to include escaping, etc... In that case I'd recommend looking for a library that does this well.

Title: Export a string or an array to CSV

Body:
I have a very simple array that I'd like to export to CSV:

var uniqueCounties = ["555","123","345"];

I have tried using methods found online but I have been getting various errors, and all the methods online deal with nested arrays.

My function at the moment is converting to a string. I was hoping it would simplify the process but I'm still now sure how to progress:

function download_csv() {
        var csv = uniqueCounties.toString();
        console.log(csv);
    }

I was originally trying this method:

uniqueCounties.forEach(function(infoArray, index){

   dataString = infoArray.join(",");
   csvContent += index < data.length ? dataString+ "\n" : dataString;

});

But kept getting the error infoArray.join is not a function.

Body:
If you have a 2d array of strings (or anything that you are ok with toString-ing) for example:

const input = [
  ["555","123","345"],
  [1, 2, 3],
  [true, false, "foo"]
]

Then you can do something like this:

function toCsv(input) {
  return input.map(row => row.join(',')).join('\n')
}

const csvString = toCsv(input)

Resulting in this string:

555,123,345
1,2,3
true,false,foo

If you just want to convert a single 1d array to csv, like in the example then:

const uniqueCounties = ["555","123","345"]

// If you want each value as a column
const csvAsSingleRow = uniqueCounties.join(',')

// If you want each value as a row
const csvAsSingleColumn = uniqueCounties.join('\n')

This gets more and more complicated if you want to include escaping, etc... In that case I'd recommend looking for a library that does this well.


问:
Extremely simple formula crashes my program after I insert a line beneath the referenced cell
I originally had code, but now I deleted all code in that project. I have a formula in sheet1 that goes "='Sheet2'!I10". Cool, I save its ok. But the moment that I insert a line beneath I10 on sheet2 and then I go back to Sheet1 click into the formula and do nothing but press the check mark the entire program crashses. With an APPCRASH report...... WHY</p>

```<code>        My Error Report:
        Problem Event Name:   APPCRASH
        Application Name: Excel.EXE
        Application Version:  14.0.7179.5000
        Application Timestamp:    58a5e2fb
        Fault Module Name:    EXCEL.EXE
        Fault Module Version: 14.0.7179.5000
        Fault Module Timestamp:   58a5e2fb
        Exception Code:   c0000005
        Exception Offset: 00261b14
        OS Version:   6.1.7601.2.1.0.256.48
        Locale ID:    1033
</code>```

答:
So thanks to nqramjets for assisting me on this question I have found that the main problem that caused this was a security patch from windows which is KB3178690. After uninstalling this, go to control panel->Uninstall a program -> on the left find & click view installed updates -> and find the above mentioned update number under Microsoft Office, and uninstall.

Furthermore there is a new update from Windows that is meant to fix this crazy bug, -> KB3191855, install this.

This information can be seen on the Microsoft community page, link below.

https://answers.microsoft.com/en-us/msoffice/forum/msoffice_excel-msoffice_custom/inserting-a-new-line-beneath-a-referenced-cell/d4c50c1e-6141-4f6f-b847-6586fe5d23a8.

Thanks again for everyone's help!
    - Googlesoar

Body:
I originally had code, but now I deleted all code in that project. I have a formula in sheet1 that goes "='Sheet2'!I10". Cool, I save its ok. But the moment that I insert a line beneath I10 on sheet2 and then I go back to Sheet1 click into the formula and do nothing but press the check mark the entire program crashses. With an APPCRASH report...... WHY

        My Error Report:
        Problem Event Name:   APPCRASH
        Application Name: Excel.EXE
        Application Version:  14.0.7179.5000
        Application Timestamp:    58a5e2fb
        Fault Module Name:    EXCEL.EXE
        Fault Module Version: 14.0.7179.5000
        Fault Module Timestamp:   58a5e2fb
        Exception Code:   c0000005
        Exception Offset: 00261b14
        OS Version:   6.1.7601.2.1.0.256.48
        Locale ID:    1033


问:
LAN web server for testing my websites on my phone?
I am a front end web developer.

I would like a web server on my local wifi network for testing my websites on my phone. I am aware that there are several options out there but witch one would be best for quick testing of multiple websites (also a GUI would be preferable)

Thanks

答:
What you want to do is pretty complex. You have to create and configure a DNS server then you have to configure your phone to get this DNS, etc.

If your phone is an android the best solution is to use your USB Cable and put your phone in dev mode, then you can debug your site with chrome directly on your phone.

how to: https://developers.google.com/web/tools/chrome-devtools/remote-debugging/

For iPhone i don't know if is possible. But the common solution is to use the simulator.


问:
Python script to recursively open .rar files in a directory
I'm writing this python script to recursively go through a directory and use the unrar utility on ubuntu to open all .rar files. For some reason it will enter the directory, list some contents, enter the first sub-directory, open one .rar file, then print all the other contents of the parent directory without going into them. Any ideas on why it would be doing this? I'm pretty new to python, so go easy.</p>

```<code>"""Recursively unrars a directory"""

import subprocess
import os

def runrar(directory):
    os.chdir(directory)

    dlist = subprocess.check_output(["ls"])
    for line in dlist.splitlines():
        print(line)
        if isRar(line):
            print("unrar e " + directory + '/' + line)
            arg = directory + '/' + line
            subprocess.call(['unrar', 'e', arg])

        if os.path.isdir(line):
            print 'here'
            runrar(directory + '/' + line)

def isRar(line):
    var = line[-4:]
    if os.path.isdir(line):
        return False
    if(var == ".rar"):
        return True
    return False

directory = raw_input("Please enter the full directory: ")
print(directory)

runrar(directory)
</code>```

答:
There are a lot of problems and clumsy uses of python in your code, I may not be able to list them. Examples:

using os.chdir

using output of ls to read a directory (very wrong and not portable on windows!)

recursivity can be avoided with os.walk

computing extension of a file is easier

checking twice if it's a directory...

my proposal:

```<code>for root,_,the_files in os.walk(path)
    for f in the_files:
        if f.lower().endswith(".rar"):
            subprocess.call(['unrar', 'e', arg],cwd=root)
</code>```

that loops through the files (and dirs, but we ignore them and we materialize it by putting the dir list into the _ variable, just a convention, but an effective one), and calls the command using subprocess which changes directory locally so unrar extracts the files in the directory where the archive is.

(In that typical os.walk loop, root is the directory and f is the filename (without path), just what we need to run a subprocess in the proper current dir, so no need for os.path.join to compute the full path)

Body:
I'm writing this python script to recursively go through a directory and use the unrar utility on ubuntu to open all .rar files. For some reason it will enter the directory, list some contents, enter the first sub-directory, open one .rar file, then print all the other contents of the parent directory without going into them. Any ideas on why it would be doing this? I'm pretty new to python, so go easy.

"""Recursively unrars a directory"""

import subprocess
import os

def runrar(directory):
    os.chdir(directory)

    dlist = subprocess.check_output(["ls"])
    for line in dlist.splitlines():
        print(line)
        if isRar(line):
            print("unrar e " + directory + '/' + line)
            arg = directory + '/' + line
            subprocess.call(['unrar', 'e', arg])

        if os.path.isdir(line):
            print 'here'
            runrar(directory + '/' + line)

def isRar(line):
    var = line[-4:]
    if os.path.isdir(line):
        return False
    if(var == ".rar"):
        return True
    return False

directory = raw_input("Please enter the full directory: ")
print(directory)

runrar(directory)

Body:
There are a lot of problems and clumsy uses of python in your code, I may not be able to list them. Examples:

using os.chdir

using output of ls to read a directory (very wrong and not portable on windows!)

recursivity can be avoided with os.walk

computing extension of a file is easier

checking twice if it's a directory...

my proposal:

for root,_,the_files in os.walk(path)
    for f in the_files:
        if f.lower().endswith(".rar"):
            subprocess.call(['unrar', 'e', arg],cwd=root)

that loops through the files (and dirs, but we ignore them and we materialize it by putting the dir list into the _ variable, just a convention, but an effective one), and calls the command using subprocess which changes directory locally so unrar extracts the files in the directory where the archive is.

(In that typical os.walk loop, root is the directory and f is the filename (without path), just what we need to run a subprocess in the proper current dir, so no need for os.path.join to compute the full path)


问:
I have file in my directory. i have imported it but still it is saying file not found..(in Xcode)
I have file in my directory. i have imported it but still it is saying file not found..(In Xcode)</p>

答:
If the file is showing up in Xcode in red it means Xcode doesn't know where the file is.  Right click on the file in the project window and select "get info".  In the "General" tab there is a button labelled "Choose..." on the right hand side below "Name" and at the same level as "Path".  Press this and you'll get a file chooser dialog so you can tell Xcode where your file is.

If the file does not appear in Xcode at all, right click the project icon at the top of the left hand tree pane and click "Add existing files to project..".


问:
change format of date from JSON to first 2 letters and year
I have the following JSON, and I need to convert the date values eg. "December 2016" to "D16", not sure how I could do this, I guess with a Regex, any help would be appreciated.</p>

```<code>[["November 2016","December 2016","January 2017","February 2017","March 2017"],["total",2,43,59,51,41
],["mammo",1,20,33,12,12],["face",1,20,16,30,27],["body",0,3,10,9,2],["photo",0,19,27,12,5],["scan",2
,24,32,39,36]]
</code>```

答:
This should work</p>

```<code> ['November16'].map(word => word.substring(0,1).concat(word.slice(-2)))
</code>```

Body:
I have the following JSON, and I need to convert the date values eg. "December 2016" to "D16", not sure how I could do this, I guess with a Regex, any help would be appreciated.

[["November 2016","December 2016","January 2017","February 2017","March 2017"],["total",2,43,59,51,41
],["mammo",1,20,33,12,12],["face",1,20,16,30,27],["body",0,3,10,9,2],["photo",0,19,27,12,5],["scan",2
,24,32,39,36]]

Body:
This should work

 ['November16'].map(word => word.substring(0,1).concat(word.slice(-2)))


问:
ActionEvent button - TextField JavaFX
Hi everyone I need to create an ActionEvent from a button and put the button name on a TextField. What i have is a kind of calculator but when I press a button doesn't fills the TextField. As an example what I want: I have the numer one on a button and when I press it the number one appears on the TextField. This is what I have until now:

AppCalculator class:

```<code>package appcalculator;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

public class AppCalculator extends Application {

@Override
public void start(Stage stage) throws Exception {
    Parent root = FXMLLoader.load(getClass().getResource("FXMLDocument.fxml"));

    Scene scene = new Scene(root);

    stage.setScene(scene);
    stage.show();
}

public static void main(String[] args) {
    launch(args);
}

}
</code>```

FXMLDocumentController:

```<code>package appcalculadora;

import java.net.URL;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.TextField;

public class FXMLDocumentController implements Initializable {

TextField texto = new TextField();

@FXML
private void btnOne(ActionEvent event) {
    texto.setText("1");

}

@FXML
private void btnTwo(ActionEvent event) {
    texto.setText("2");
}

@FXML
private void btnThree(ActionEvent event) {
    texto.setText("3");
}

@FXML
private void btnFour(ActionEvent event) {
    texto.setText("4");
}

@FXML
private void btnFive(ActionEvent event) {
    texto.setText("5");
}

@FXML
private void btnSix(ActionEvent event) {
    texto.setText("6");
}

@FXML
private void btnSevent(ActionEvent event) {
    texto.setText("7");
}

@FXML
private void btnEight(ActionEvent event) {
    texto.setText("8");
}

@FXML
private void btnNine(ActionEvent event) {
    texto.setText("9");
}

@FXML
private void btnZero(ActionEvent event) {
    texto.setText("0");
}

@FXML
private void btnPoint(ActionEvent event) {
    texto.setText(".");
}

@FXML
private void btnPlus(ActionEvent event) {
    texto.setText("+");
}

@FXML
private void btnMinus(ActionEvent event) {
    texto.setText("-");
}

@FXML
private void btnBy(ActionEvent event) {
    texto.setText("*");
}

@FXML
private void btnDivided(ActionEvent event) {
    texto.setText("/");
}

@FXML
private void btnErrase(ActionEvent event){
    texto.deletePreviousChar();
}

@FXML
private void btnTotal(ActionEvent event){
    texto.getText();
}

@Override
public void initialize(URL url, ResourceBundle rb) {
    // TODO
}

}
</code>```

And my respective FXML document

答:
This may help you with your answer. Like @James_D you are missing '@FXML private TextField texto;.' Also, you could probably get rid of most of your methods.

Here is a sample program:

Main:

```<code>import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

/**
 *
 * @author blj0011
 */
public class JavaFXApplication58 extends Application
{

    @Override
    public void start(Stage stage) throws Exception
    {
        Parent root = FXMLLoader.load(getClass().getResource("FXMLDocument.fxml"));

        Scene scene = new Scene(root);

        stage.setScene(scene);
        stage.show();
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args)
    {
        launch(args);
    }
}
</code>```

Controller:

```<code>import java.net.URL;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.*;

/**
 *
 * @author blj0011
 */
public class FXMLDocumentController implements Initializable
{

    @FXML
    private TextField texto;

    //Use this approach to replace most of your private button handlers!
    @FXML
    private void handleButtonAction(ActionEvent event)
    {
        Button button = (Button)event.getSource();
        texto.appendText(button.getText());
    }

    @Override
    public void initialize(URL url, ResourceBundle rb)
    {
        // TODO
    }
}
</code>```

FXML:

```<code><?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.Button?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.AnchorPane?>

<AnchorPane id="AnchorPane" prefHeight="200" prefWidth="320" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8.0.111" fx:controller="javafxapplication58.FXMLDocumentController">
    <children>
        <Button fx:id="btnOne" layoutX="126" layoutY="90" onAction="#handleButtonAction" text="1" />
      <Button fx:id="btnTwo" layoutX="172.0" layoutY="90.0" onAction="#handleButtonAction" text="2" />
      <TextField fx:id="texto" layoutX="86.0" layoutY="43.0" />
    </children>
</AnchorPane>
</code>```

Title: ActionEvent button - TextField JavaFX

Body:
Hi everyone I need to create an ActionEvent from a button and put the button name on a TextField. What i have is a kind of calculator but when I press a button doesn't fills the TextField. As an example what I want: I have the numer one on a button and when I press it the number one appears on the TextField. This is what I have until now:

AppCalculator class:

package appcalculator;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

public class AppCalculator extends Application {

@Override
public void start(Stage stage) throws Exception {
    Parent root = FXMLLoader.load(getClass().getResource("FXMLDocument.fxml"));

    Scene scene = new Scene(root);

    stage.setScene(scene);
    stage.show();
}

public static void main(String[] args) {
    launch(args);
}

}

FXMLDocumentController:

package appcalculadora;

import java.net.URL;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.TextField;

public class FXMLDocumentController implements Initializable {

TextField texto = new TextField();

@FXML
private void btnOne(ActionEvent event) {
    texto.setText("1");

}

@FXML
private void btnTwo(ActionEvent event) {
    texto.setText("2");
}

@FXML
private void btnThree(ActionEvent event) {
    texto.setText("3");
}

@FXML
private void btnFour(ActionEvent event) {
    texto.setText("4");
}

@FXML
private void btnFive(ActionEvent event) {
    texto.setText("5");
}

@FXML
private void btnSix(ActionEvent event) {
    texto.setText("6");
}

@FXML
private void btnSevent(ActionEvent event) {
    texto.setText("7");
}

@FXML
private void btnEight(ActionEvent event) {
    texto.setText("8");
}

@FXML
private void btnNine(ActionEvent event) {
    texto.setText("9");
}

@FXML
private void btnZero(ActionEvent event) {
    texto.setText("0");
}

@FXML
private void btnPoint(ActionEvent event) {
    texto.setText(".");
}

@FXML
private void btnPlus(ActionEvent event) {
    texto.setText("+");
}

@FXML
private void btnMinus(ActionEvent event) {
    texto.setText("-");
}

@FXML
private void btnBy(ActionEvent event) {
    texto.setText("*");
}

@FXML
private void btnDivided(ActionEvent event) {
    texto.setText("/");
}

@FXML
private void btnErrase(ActionEvent event){
    texto.deletePreviousChar();
}

@FXML
private void btnTotal(ActionEvent event){
    texto.getText();
}

@Override
public void initialize(URL url, ResourceBundle rb) {
    // TODO
}

}

And my respective FXML document

Body:
This may help you with your answer. Like @James_D you are missing '@FXML private TextField texto;.' Also, you could probably get rid of most of your methods.

Here is a sample program:

Main:

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

/**
 *
 * @author blj0011
 */
public class JavaFXApplication58 extends Application
{

    @Override
    public void start(Stage stage) throws Exception
    {
        Parent root = FXMLLoader.load(getClass().getResource("FXMLDocument.fxml"));

        Scene scene = new Scene(root);

        stage.setScene(scene);
        stage.show();
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args)
    {
        launch(args);
    }
}

Controller:

import java.net.URL;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.*;

/**
 *
 * @author blj0011
 */
public class FXMLDocumentController implements Initializable
{

    @FXML
    private TextField texto;

    //Use this approach to replace most of your private button handlers!
    @FXML
    private void handleButtonAction(ActionEvent event)
    {
        Button button = (Button)event.getSource();
        texto.appendText(button.getText());
    }

    @Override
    public void initialize(URL url, ResourceBundle rb)
    {
        // TODO
    }
}

FXML:

<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.Button?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.AnchorPane?>

<AnchorPane id="AnchorPane" prefHeight="200" prefWidth="320" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8.0.111" fx:controller="javafxapplication58.FXMLDocumentController">
    <children>
        <Button fx:id="btnOne" layoutX="126" layoutY="90" onAction="#handleButtonAction" text="1" />
      <Button fx:id="btnTwo" layoutX="172.0" layoutY="90.0" onAction="#handleButtonAction" text="2" />
      <TextField fx:id="texto" layoutX="86.0" layoutY="43.0" />
    </children>
</AnchorPane>


问:
Does "play-services:9.8.0" include "play-services-location:9.8.0"?
I am upgrading an App, and in my build.gradle file, I have this:

```<code>dependencies {
    ..........
    compile 'com.google.android.gms:play-services:9.8.0'
    ..........
}
</code>```

In the Android SDK Setup Quickstart Guide Urban Airship provides, they offer this as a sample code:

```<code>dependencies {
    ..........
    // Recommended for location services
    compile 'com.google.android.gms:play-services-location:9.8.0'
    ..........
}
</code>```

If I use "play-services:9.8.0" I would assume it would also include "play-services-location:9.8.0" because "play-services-location:9.8.0" should be a subset of "play-services:9.8.0", but I wanted to confirm. Do you know if this is a correct assumption? Thank you.

答:
From Google Api Documentation

you can use the latest Google play service api:

```<code> dependencies {
    compile 'com.google.android.gms:play-services:10.2.1'
}
</code>```

If the number of method references in your app exceeds the 65K limit, your app may fail to compile. You may be able to mitigate this problem when compiling your app by specifying only the specific Google Play services APIs your app uses, instead of all of them.

To Selectively compiling APIs into your executable:

```<code> compile 'com.google.android.gms:play-services-maps:10.2.1'
compile 'com.google.android.gms:play-services-plus:10.2.1'
compile 'com.google.android.gms:play-services-location:10.2.1'
compile 'com.google.android.gms:play-services-games:10.2.1'
compile 'com.google.android.gms:play-services-gcm:10.2.1'
</code>```

the detail lists are provided in the documentation.

Body:
I am upgrading an App, and in my build.gradle file, I have this:

dependencies {
    ..........
    compile 'com.google.android.gms:play-services:9.8.0'
    ..........
}

In the Android SDK Setup Quickstart Guide Urban Airship provides, they offer this as a sample code:

dependencies {
    ..........
    // Recommended for location services
    compile 'com.google.android.gms:play-services-location:9.8.0'
    ..........
}

If I use "play-services:9.8.0" I would assume it would also include "play-services-location:9.8.0" because "play-services-location:9.8.0" should be a subset of "play-services:9.8.0", but I wanted to confirm. Do you know if this is a correct assumption? Thank you.

Body:
From Google Api Documentation

you can use the latest Google play service api:

 dependencies {
    compile 'com.google.android.gms:play-services:10.2.1'
}

If the number of method references in your app exceeds the 65K limit, your app may fail to compile. You may be able to mitigate this problem when compiling your app by specifying only the specific Google Play services APIs your app uses, instead of all of them.

To Selectively compiling APIs into your executable:

 compile 'com.google.android.gms:play-services-maps:10.2.1'
compile 'com.google.android.gms:play-services-plus:10.2.1'
compile 'com.google.android.gms:play-services-location:10.2.1'
compile 'com.google.android.gms:play-services-games:10.2.1'
compile 'com.google.android.gms:play-services-gcm:10.2.1'

the detail lists are provided in the documentation.


问:
Python to perform SSH logins and do something
I am trying to automate few routine tasks in Netapp storage using Python.

Since I am using Windows machine and Python  I need to perform few tasks to connect storage using ssh session and perfom few things and I need view how it is acting . For example if we take we are connecting  Linux box  over ssh if I execute ls command I need to see the output of the ls.

To achieve this which tools I need to use ..I searched in web some are suggesting to use paramiko and pexpect but these  are the modules to use connect ssh and perform tasks but we cannot view the output on terminal.

答:
With the parallel-ssh library:

```<code>from pssh import ParallelSSHClient
# See also private key examples in documentation
client = ParallelSSHClient(['netapp.host'], user=<user>,
                           password=<password>)
output = client.run_command(<cmd>)
for line in output['netapp.host'].stdout:
    print line
</code>```

See parallel-ssh documentation. It uses paramiko under the hood so should work just as well on Windows.

stdin channel is also available in output for providing input like with pexpect, see run_command documentation for examples.

As a bonus, the client is parallel and can be used to run commands on any number of hosts.

Using paramiko directly is of course also possible, though a lot more code would be required which parallel-ssh does for you.

Body:
With the parallel-ssh library:

from pssh import ParallelSSHClient
# See also private key examples in documentation
client = ParallelSSHClient(['netapp.host'], user=<user>,
                           password=<password>)
output = client.run_command(<cmd>)
for line in output['netapp.host'].stdout:
    print line

See parallel-ssh documentation. It uses paramiko under the hood so should work just as well on Windows.

stdin channel is also available in output for providing input like with pexpect, see run_command documentation for examples.

As a bonus, the client is parallel and can be used to run commands on any number of hosts.

Using paramiko directly is of course also possible, though a lot more code would be required which parallel-ssh does for you.


问:
How to let my web-user-control determine automatically the url of the page where it's placed
```<code>        <asp:HyperLink
        ID="hyper1"
        runat="server"
        NavigateUrl='<%#string.Format("~/PLayer.aspx?ID={0}&Type={1}",Eval("arrange_by_id"),Eval("value"))%>'><%# Eval("value")%></asp:HyperLink>
</code>```

I've implemented this string format in my NavigateUrl to pass a dynamic querystring depending on the clicked item!

but you see the first part in the string format where it says "~/PLayer.aspx" i want the user control to automatically change this part according to where it's placed!

Body:
        <asp:HyperLink
        ID="hyper1"
        runat="server"
        NavigateUrl='<%#string.Format("~/PLayer.aspx?ID={0}&Type={1}",Eval("arrange_by_id"),Eval("value"))%>'><%# Eval("value")%></asp:HyperLink>

I've implemented this string format in my NavigateUrl to pass a dynamic querystring depending on the clicked item!

but you see the first part in the string format where it says "~/PLayer.aspx" i want the user control to automatically change this part according to where it's placed!

Body:
try this
http://www.codeproject.com/KB/aspnet/resolveurl.aspx


问:
Using ember-cli-selectize multiselect on query params
I'm currently using ember-cli-selectize on a query param in ember.js. Pretty much like the following:

Template

```<code>{{ember-selectize
  content=makes
  optionValuePath="content.make"
  optionLabelPath="content.make"
  value=car_makes
  selection=carMakes
  multiple=false
  placeholder="Filter by car make..." }}
</code>```

Controller

```<code>import Ember from 'ember';
export default Ember.Controller.extend({
   queryParams: ['car_makes'],
   car_makes: null,
   carMakes: Ember.A([])
});
</code>```

However, I want to set 'multiple' to 'true' in my template and have an multiselect. Doing so in multiple mode means that 'value' is no longer supported.

The author suggests using a computed value, like so:

```<code>car_makes: Ember.computed.mapBy('carMakes', 'make')
</code>```

The only problem is, Ember does not support query params as a computed value.

So, can anyone think of a way to trick Ember around this? Or am I going to have to make my own selectize component?

答: You can make use of add-value and remove-value actions provided by ember-cli-selectize. Take a look at the following twiddle. As you can see in my-route.hbs, I provided action handlers for add-value and remove-value. In my-route.js you can see how selected/deselected value iss added to/remove from car_makes which is an array; not a computed property. Hope this helps.

Body:
I'm currently using ember-cli-selectize on a query param in ember.js. Pretty much like the following:

Template

{{ember-selectize
  content=makes
  optionValuePath="content.make"
  optionLabelPath="content.make"
  value=car_makes
  selection=carMakes
  multiple=false
  placeholder="Filter by car make..." }}

Controller

import Ember from 'ember';
export default Ember.Controller.extend({
   queryParams: ['car_makes'],
   car_makes: null,
   carMakes: Ember.A([])
});

However, I want to set 'multiple' to 'true' in my template and have an multiselect. Doing so in multiple mode means that 'value' is no longer supported.

The author suggests using a computed value, like so:

car_makes: Ember.computed.mapBy('carMakes', 'make')

The only problem is, Ember does not support query params as a computed value.

So, can anyone think of a way to trick Ember around this? Or am I going to have to make my own selectize component?


问:
Image Blob - Pop up window not showing content
I am working on displaying an image in blob

```<code>const file = new Blob([response.data], { type: 'image/png' });
        const fileURL = URL.createObjectURL(file);
        window.open(fileURL);
        console.log('fileURL', fileURL);
        const image = document.createElement('img');
</code>```

I am getting this response

```<code>PNG

IHDR2²OósRGB®ÎégAMA±üa  pHYsÃÃÇo¨dã¼IDATx^ìý=ô<Ó¶Þ;ÐØ²g
cõ-EVÙÚÜòfã·#cV0¡\¡5È·Eüü$
]EGâ¹AD"    èî÷½þûeü÷_ý×ð\¸³µ°ñ F\¸³µ°ñ    F\¸³µ°ñ    F\¸³µ°ñ    FáË¥ßçòüù«&Þv~ÑTU?ÿ^Ý}öòóÜï×'sµùÔ¤|¼þåúE8ñp
ÎÛ3Î0
¹Þuv]áÌäZ×G#¬Ïv\f.ý{ý>ã¦ñï÷õÈõÁÛÅØã·n6«ÿÞpÙ.2ßÆ¹od
ÕEk+bv|_Hß5yÏçnØ1C´ìOÑÞøVÛ|¯
¤=ûsÔ_}BKíWÊó÷¿ç¯×ò_Þòu¸ÈÜ\dF¾a
¯FXí¸.Í\"øãñXÈ|8°àmÇýØa)@
F;L æ Øñæá_ðÉ¾´o»ìÔq#ºMxVÍ_±S.|íËs¿4×â7÷="/2GýÝù¹uyZ{c6Â×·°ãÛÆyqÎ_\ÁFøÎ)¼>a}¶àº¸r)Ý
ÄÛ® ÖáÌÁÁ\à"ó'â7|ú®HNë'/Õû
D ¶³c.!lÿÈ¶Ëhê¾ü"sÆß4ò@^¦¬XxcvÒ×·Ì½ÀEf$.í7a}¶àº4s)úáñtøÖEÛ´´ve¬í`Ê"UWäÃÛèÁ¿X}½2få¯âH²×n£Îy)U|Íg]O½{þ«}Ï®¹JÈ-ýðkÙÊ¯óR¸/ZLBd[NN±¨ùÖÌ¥x}³è:#"9¯yoLÃ·ÿBÎj¸Õvöú_æ´v8çï.òú©Cµ-/óÊõÑ   _{¹³æb[.êòRÙÖ£'lµo¦¬aò/ÌÕ1>ÿ¶ª<hPù½nüä7Ûzéú]Ïúgó=ó´ÞÛúºÓ¾KéåSÀÅ [¥8ìµÛ¸üí®õFxOáõÑë³×¥KËG1ýÿF&Êw\c´Û6¶Éðqò&¹mYÐÜ@ÝÄØtÓYÇÈ>Ó'´«6"áW±5k>\¥ñ[ëñîùkö[1X}Íãq{1K_1oÓç÷1ãÕ8t*Þå+V±]/G´v5ZI¨ÚÉ¹¼Æ5
µç°½Ö¿cþîÄÊLò#¬1CÆ³¾zrgô·mbÄjïøÛX9N½oû½â²ÖhÏZßlë]ßo=Ku³MâáôÙ;V¼W·õN}¹¾ýíÛH¨>4ðÆ`>çyÐ9x¾¿¢_;GC[
¯FXí¸.¾\J;Ýu¼í2ñÃccçp^iL|CJ~\vvobú<ª
Ê··á¾Þ9k¸ðÞùöwÆ ö£ôUcgû"þÏZ5Ú7xoìq*ò¡Zå@UÛySÞkc+{gsÛw¥Me;û²ÆS×_Ò&wzßwÉýçSoçÙÂ_#2Vïÿ¶3F¬FÏoýVì÷{¾YûÇï4WÍnÀ²]û·wãÖ;ÙëÅÂ>¯´g6®qÕüìåD·ñøëYë°®^°>Ûp]þ4´õáUíøH}{cø63}ccªXòâÙØ%yCZÛx6±óÉã/ýºkyïü
ûyncÖTYü¯b`Ì)|ÜrY÷9ÁÛªßA7úÖGSÃÂ¿]sßrSôÉöëÒË
¥Ms.Ù'ÕfÏ_ï¼
´<`Äï-¯+f#|ÈÜÑsqä·1bõÖñßddÐ7k¿óø½å¨Gíêùéy7·wÜ¾5¦k\#.¢ÂSx}4ÂúlÀuùÓ\ÒHãÀí\Yîæªí£§ÞÄV±AiÞóñHÜÏgyBØR:ñîù«ö¶¦r®úFÞ³Ø«¦®=+°\Ö}Î0_µ4y§o
ÝXi(ßv}ïGDrkåËË%_íò}æÿnÙ<ìoÖväÉ    _ÿâÛV1â°g|1\Ìñ{ë³cmZß¬ùÎí·½ß[¶Óóìßéy_onÏe!å%ïçÏq×¸Æ<´ý¾÷týu¯õFxNáõÑë³×åOsI; ["ÅhçÛÈä¸qDüL´¡o¸cçCIïÚ¶ß;Ã~sMùsßÅÿ*¿9½»@Ç;°voõâFãÛ®|<(ùÁî³ãð=Úa±mÎå'Ù¬:HùÛAËN«×C¾úrgì·ÝÀÃ¹ñ;hùNi¼ßóÍÚïöûlm},ÛÕóÓóðÆ[>çö|öKnÒ²/¿]ãqù
ìPx}4ÂúlÀuùÓ\j~àv»6²î :Ã61µ
ÛÄbÞ&;v>5}ÛoxrfMc1cvµ9;õáº·bZÞ/ëú: ßìÛ7VªøUúÉyNtN;iîÖþbÌÍ°|ÿÿÕ
®õ·V¯G|uæÎÐo»Sãwáv8¶Ý=ß¬ýîßud¯}n³úwvÇ×ÛsÙ¹pîÛs«~,&ïÄå¯½\ëñúhõÙëò§¹¤Æ#Ñ  ßF¹7Åº{h×ßàmb_IðÐ6ä+ï£æì±yPÞ=ï¦v$ÙðlóÃ7¦Ö. ÆX°q)Ù¾×ñóàöm/v+ñ=ó5çz[=;+ùÀg1Ù+6,Û$¿Ö
÷·6^ùêË=e_7ê·Ý¢õ=÷Ç/kXwíÚq~/8µ÷ö3ým½ëúÞÓo9ÇûW¿bóÜ<¯7·çµ¿æ"+Ô×®qY,qì5æ
ßÈº¸üÝ£¡-×G#¬Ïv\?Í¥øá±¬uðròKþè½Yl©´¥Â¸Mlû°ø¨mtÜNSÝùlvøØ÷Îß°ãÂ×´ö=ôIµòÃ1fDÉ¯}³îsMséÏÓ²Kö_í7È·o¬8Ú·(öóÂß&õÖïV¬ñ,´q95l¯¾üþÖmJm-ZyPèæ#fG}uä'¾ítÙ=ãù8óMä·+â+íê~&Zï"¿¹4«mfC]÷Ãó8¾ÞÜÏ~ªó¼I}÷¬igÜ3>Ø?»ßÉwähxOáõÑë³×¹ôÙèóBÞ°Ô|é"£¬-|æùóÅ|Ûú.gk?aâ¹ôáärÕUù3àïÅø©/|W¼È|Ýú&gk?a}¶àº ¾ñ+û¥X¾$|ÆÁ%/2o;Sßào°AáõÑë³×¹pfk?aâ¹pfk?aâ¹pfk?aâ¹pfk?aâ¹pfk?aâ¹pfk?aâ¹pfk?aâ¹pfk?aâ¢K?Ïð/á_ÿff¬á=þÑ´4?Ïsÿøz}Ä2ßç?þU{ß7?¾!×¿ÏÈð´´ß;Ög;®K+ :¾¯¿Èhÿ¢ñZÈ¿Û±)ßèût9ýÿXc\dt¼>bO
.2À.2`#^°>Ûp]¾*þ½~>!zAþzþÆøóÅÇ¿ß×   bó"S?K¾:sg¬ÎýcâÛà|¼)Ny>xóããóè¯÷àSà"6fk?aý«Ä'øh¾*¾úÀ_ÏÿSDlþMKåó"³x.A×ò_
±:÷OooðñVà"3¿ÞOØýõ¯à£iå<TÒFÚÄÒÙÍcÿ(ë~j·|@¬¶Y»ô§¬tÄ¨5>ßÈ×vÄÊGî·NOÌ?À×p×ZãocXgÇjò¼û"Sæb%m®%gÔxr[æ8+¾G×?0ÂG¯º}oOYñÎ´+¦[ï"Ü6¿ÐµÁÉïµHÝ1#Û)~Br{,>imø÷×9Ã×qoÝbkWç*¾ÎqÏÚü×÷¹6ñ×wlîjxæîÍpKB^Px}4ÂúlÀuiåR}øäd]5lÞê&IýÃ&Ê4Mp²
V{7ïÖm|2bWósE´çÖÔK·¿>¾§ó$;ÆÒ0ÆwÛtÄ¢G¯Ñ¶6oÇÔ~Js®|Äÿ3s_·->¦g¥Möëí)ó,´ÞIÛÊ³¦
</code>```

When I reffer some stackoverflow answers I understood my response is wrong. my questions is how to get correct binary response ..

答:
```<code>$http.get(ur1, {
                responseType: 'blob'
            }).then(function (res) {

                this.download(res)

}, function (err) {

               conseole.log(err)

            })

    }
};
    this.download = function (data) {
        var type  =  data.headers('Content-Type'),
            content = data.data,
            fileName  =  data.headers('x-ms-meta-originalname'),//Get the file name
            blob  = new Blob([content], {type: type}),
            url = window.URL.createObjectURL(blob);

        var a = document.createElement('a');
        a.href = url;
        a.target="_self";
        a.download = fileName;
        a.click();
        a = undefined;

    }
</code>```

Additinal Details here: http://angularjstricks.blogspot.in/2017/03/download-file-from-server-with-http-in.html

Body:
I am working on displaying an image in blob

const file = new Blob([response.data], { type: 'image/png' });
        const fileURL = URL.createObjectURL(file);
        window.open(fileURL);
        console.log('fileURL', fileURL);
        const image = document.createElement('img');

I am getting this response

PNG

IHDR2²OósRGB®ÎégAMA±üa  pHYsÃÃÇo¨dã¼IDATx^ìý=ô<Ó¶Þ;ÐØ²g
cõ-EVÙÚÜòfã·#cV0¡\¡5È·Eüü$
]EGâ¹AD"    èî÷½þûeü÷_ý×ð\¸³µ°ñ F\¸³µ°ñ    F\¸³µ°ñ    F\¸³µ°ñ    FáË¥ßçòüù«&Þv~ÑTU?ÿ^Ý}öòóÜï×'sµùÔ¤|¼þåúE8ñp
ÎÛ3Î0
¹Þuv]áÌäZ×G#¬Ïv\f.ý{ý>ã¦ñï÷õÈõÁÛÅØã·n6«ÿÞpÙ.2ßÆ¹od
ÕEk+bv|_Hß5yÏçnØ1C´ìOÑÞøVÛ|¯
¤=ûsÔ_}BKíWÊó÷¿ç¯×ò_Þòu¸ÈÜ\dF¾a
¯FXí¸.Í\"øãñXÈ|8°àmÇýØa)@
F;L æ Øñæá_ðÉ¾´o»ìÔq#ºMxVÍ_±S.|íËs¿4×â7÷="/2GýÝù¹uyZ{c6Â×·°ãÛÆyqÎ_\ÁFøÎ)¼>a}¶àº¸r)Ý
ÄÛ® ÖáÌÁÁ\à"ó'â7|ú®HNë'/Õû
D ¶³c.!lÿÈ¶Ëhê¾ü"sÆß4ò@^¦¬XxcvÒ×·Ì½ÀEf$.í7a}¶àº4s)úáñtøÖEÛ´´ve¬í`Ê"UWäÃÛèÁ¿X}½2få¯âH²×n£Îy)U|Íg]O½{þ«}Ï®¹JÈ-ýðkÙÊ¯óR¸/ZLBd[NN±¨ùÖÌ¥x}³è:#"9¯yoLÃ·ÿBÎj¸Õvöú_æ´v8çï.òú©Cµ-/óÊõÑ   _{¹³æb[.êòRÙÖ£'lµo¦¬aò/ÌÕ1>ÿ¶ª<hPù½nüä7Ûzéú]Ïúgó=ó´ÞÛúºÓ¾KéåSÀÅ [¥8ìµÛ¸üí®õFxOáõÑë³×¥KËG1ýÿF&Êw\c´Û6¶Éðqò&¹mYÐÜ@ÝÄØtÓYÇÈ>Ó'´«6"áW±5k>\¥ñ[ëñîùkö[1X}Íãq{1K_1oÓç÷1ãÕ8t*Þå+V±]/G´v5ZI¨ÚÉ¹¼Æ5
µç°½Ö¿cþîÄÊLò#¬1CÆ³¾zrgô·mbÄjïøÛX9N½oû½â²ÖhÏZßlë]ßo=Ku³MâáôÙ;V¼W·õN}¹¾ýíÛH¨>4ðÆ`>çyÐ9x¾¿¢_;GC[
¯FXí¸.¾\J;Ýu¼í2ñÃccçp^iL|CJ~\vvobú<ª
Ê··á¾Þ9k¸ðÞùöwÆ ö£ôUcgû"þÏZ5Ú7xoìq*ò¡Zå@UÛySÞkc+{gsÛw¥Me;û²ÆS×_Ò&wzßwÉýçSoçÙÂ_#2Vïÿ¶3F¬FÏoýVì÷{¾YûÇï4WÍnÀ²]û·wãÖ;ÙëÅÂ>¯´g6®qÕüìåD·ñøëYë°®^°>Ûp]þ4´õáUíøH}{cø63}ccªXòâÙØ%yCZÛx6±óÉã/ýºkyïü
ûyncÖTYü¯b`Ì)|ÜrY÷9ÁÛªßA7úÖGSÃÂ¿]sßrSôÉöëÒË
¥Ms.Ù'ÕfÏ_ï¼
´<`Äï-¯+f#|ÈÜÑsqä·1bõÖñßddÐ7k¿óø½å¨Gíêùéy7·wÜ¾5¦k\#.¢ÂSx}4ÂúlÀuùÓ\ÒHãÀí\Yîæªí£§ÞÄV±AiÞóñHÜÏgyBØR:ñîù«ö¶¦r®úFÞ³Ø«¦®=+°\Ö}Î0_µ4y§o
ÝXi(ßv}ïGDrkåËË%_íò}æÿnÙ<ìoÖväÉ    _ÿâÛV1â°g|1\Ìñ{ë³cmZß¬ùÎí·½ß[¶Óóìßéy_onÏe!å%ïçÏq×¸Æ<´ý¾÷týu¯õFxNáõÑë³×åOsI; ["ÅhçÛÈä¸qDüL´¡o¸cçCIïÚ¶ß;Ã~sMùsßÅÿ*¿9½»@Ç;°voõâFãÛ®|<(ùÁî³ãð=Úa±mÎå'Ù¬:HùÛAËN«×C¾úrgì·ÝÀÃ¹ñ;hùNi¼ßóÍÚïöûlm},ÛÕóÓóðÆ[>çö|öKnÒ²/¿]ãqù
ìPx}4ÂúlÀuùÓ\j~àv»6²î :Ã61µ
ÛÄbÞ&;v>5}ÛoxrfMc1cvµ9;õáº·bZÞ/ëú: ßìÛ7VªøUúÉyNtN;iîÖþbÌÍ°|ÿÿÕ
®õ·V¯G|uæÎÐo»Sãwáv8¶Ý=ß¬ýîßud¯}n³úwvÇ×ÛsÙ¹pîÛs«~,&ïÄå¯½\ëñúhõÙëò§¹¤Æ#Ñ  ßF¹7Åº{h×ßàmb_IðÐ6ä+ï£æì±yPÞ=ï¦v$ÙðlóÃ7¦Ö. ÆX°q)Ù¾×ñóàöm/v+ñ=ó5çz[=;+ùÀg1Ù+6,Û$¿Ö
÷·6^ùêË=e_7ê·Ý¢õ=÷Ç/kXwíÚq~/8µ÷ö3ým½ëúÞÓo9ÇûW¿bóÜ<¯7·çµ¿æ"+Ô×®qY,qì5æ
ßÈº¸üÝ£¡-×G#¬Ïv\?Í¥øá±¬uðròKþè½Yl©´¥Â¸Mlû°ø¨mtÜNSÝùlvøØ÷Îß°ãÂ×´ö=ôIµòÃ1fDÉ¯}³îsMséÏÓ²Kö_í7È·o¬8Ú·(öóÂß&õÖïV¬ñ,´q95l¯¾üþÖmJm-ZyPèæ#fG}uä'¾ítÙ=ãù8óMä·+â+íê~&Zï"¿¹4«mfC]÷Ãó8¾ÞÜÏ~ªó¼I}÷¬igÜ3>Ø?»ßÉwähxOáõÑë³×¹ôÙèóBÞ°Ô|é"£¬-|æùóÅ|Ûú.gk?aâ¹ôáärÕUù3àïÅø©/|W¼È|Ýú&gk?a}¶àº ¾ñ+û¥X¾$|ÆÁ%/2o;Sßào°AáõÑë³×¹pfk?aâ¹pfk?aâ¹pfk?aâ¹pfk?aâ¹pfk?aâ¹pfk?aâ¹pfk?aâ¹pfk?aâ¢K?Ïð/á_ÿff¬á=þÑ´4?Ïsÿøz}Ä2ßç?þU{ß7?¾!×¿ÏÈð´´ß;Ög;®K+ :¾¯¿Èhÿ¢ñZÈ¿Û±)ßèût9ýÿXc\dt¼>bO
.2À.2`#^°>Ûp]¾*þ½~>!zAþzþÆøóÅÇ¿ß×   bó"S?K¾:sg¬ÎýcâÛà|¼)Ny>xóããóè¯÷àSà"6fk?aý«Ä'øh¾*¾úÀ_ÏÿSDlþMKåó"³x.A×ò_
±:÷OooðñVà"3¿ÞOØýõ¯à£iå<TÒFÚÄÒÙÍcÿ(ë~j·|@¬¶Y»ô§¬tÄ¨5>ßÈ×vÄÊGî·NOÌ?À×p×ZãocXgÇjò¼û"Sæb%m®%gÔxr[æ8+¾G×?0ÂG¯º}oOYñÎ´+¦[ï"Ü6¿ÐµÁÉïµHÝ1#Û)~Br{,>imø÷×9Ã×qoÝbkWç*¾ÎqÏÚü×÷¹6ñ×wlîjxæîÍpKB^Px}4ÂúlÀuiåR}øäd]5lÞê&IýÃ&Ê4Mp²
V{7ïÖm|2bWósE´çÖÔK·¿>¾§ó$;ÆÒ0ÆwÛtÄ¢G¯Ñ¶6oÇÔ~Js®|Äÿ3s_·->¦g¥Möëí)ó,´ÞIÛÊ³¦

When I reffer some stackoverflow answers I understood my response is wrong. my questions is how to get correct binary response ..

Body:
$http.get(ur1, {
                responseType: 'blob'
            }).then(function (res) {

                this.download(res)

}, function (err) {

               conseole.log(err)

            })

    }
};
    this.download = function (data) {
        var type  =  data.headers('Content-Type'),
            content = data.data,
            fileName  =  data.headers('x-ms-meta-originalname'),//Get the file name
            blob  = new Blob([content], {type: type}),
            url = window.URL.createObjectURL(blob);

        var a = document.createElement('a');
        a.href = url;
        a.target="_self";
        a.download = fileName;
        a.click();
        a = undefined;

    }

Additinal Details here: http://angularjstricks.blogspot.in/2017/03/download-file-from-server-with-http-in.html


问:
Postgres time zones and formatting
I know there are some similar questions about this, but I'm having a hard time understanding why my database is formatting times the way it is.

I have a field called created_at and in the database the value is:

```<code>2017-03-30 11:01:25.976-04
</code>```

It's 11am New York time, with a four-hour negative offset from UTC.

I want it to display as 11:01am. When I use TO_CHAR() to format it, though, it converts the time to UTC and shows 3:01pm.

```<code>SELECT to_char(ledger.created_at, 'Mon DD YYYY HH12: MI AM') AS formatted_date ...
</code>```

I can fix this by adding AT TIME ZONE 'America/New_York' but I don't like the idea of hard-coding that in my application.

```<code>SELECT to_char(ledger.created_at AT TIME ZONE 'America/New_York', 'Mon DD YYYY HH12: MI AM') AS formatted_date ...
</code>```

It seems like the timestamp field knows what time it is already, and what time zone it's in (or at least the offset amount) and it displays 11am in the database itself.

I also know I can SET the local time before each query and it will work, but again I'm wondering if there's an easier way. It seems like maybe I could strip the timezone information and just get the 11:01am time that's in the database. If there isn't a way, I can live with it, but I needed to check.

For context, this is within a Node and Express app using Sequelize.

答: I suspect you are running into what the configured TimeZone for the server is. If that is the case, and you can't change it, your best option is to set the TimeZone for the current session using SET TIME ZONE '...';

Title: Postgres time zones and formatting

Body:
I know there are some similar questions about this, but I'm having a hard time understanding why my database is formatting times the way it is.

I have a field called created_at and in the database the value is:

2017-03-30 11:01:25.976-04

It's 11am New York time, with a four-hour negative offset from UTC.

I want it to display as 11:01am. When I use TO_CHAR() to format it, though, it converts the time to UTC and shows 3:01pm.

SELECT to_char(ledger.created_at, 'Mon DD YYYY HH12: MI AM') AS formatted_date ...

I can fix this by adding AT TIME ZONE 'America/New_York' but I don't like the idea of hard-coding that in my application.

SELECT to_char(ledger.created_at AT TIME ZONE 'America/New_York', 'Mon DD YYYY HH12: MI AM') AS formatted_date ...

It seems like the timestamp field knows what time it is already, and what time zone it's in (or at least the offset amount) and it displays 11am in the database itself.

I also know I can SET the local time before each query and it will work, but again I'm wondering if there's an easier way. It seems like maybe I could strip the timezone information and just get the 11:01am time that's in the database. If there isn't a way, I can live with it, but I needed to check.

For context, this is within a Node and Express app using Sequelize.


答: Yes, play-services is the full bundle.  They were broken apart to reduce the method count of your app so you don't hit the dex limit.  More information can be found here.

Title: Does "play-services:9.8.0" include "play-services-location:9.8.0"?


问:
Register mobile number with WhatsApp using Yowsup and phone
I have successfully registered a number with WhatsApp using Yowsup CLI like so:

Get the SMS:

```<code>python yowsup-cli registration --phone xxxxxxxxxxx --cc 1  -r sms
</code>```

Register after getting the code:

```<code>python yowsup-cli registration --register xxx-xxx --phone xxxxxxxxxxx --cc 1
</code>```

However, by doing so, it looks like it un-verifies the number from my phone.

Based on this link, it seems like there is a restriction on the WhatsApp side:
https://www.whatsapp.com/faq/en/general/21009863

Is there a way to associate a phone number in WhatsApp with Yowsup as well as a mobile device?

答: Whatsapp only has a single-session thing. You won't have any way to do it.</p>

ContentLicense: CC BY-SA 4.0

Body:
I have successfully registered a number with WhatsApp using Yowsup CLI like so:

Get the SMS:

python yowsup-cli registration --phone xxxxxxxxxxx --cc 1  -r sms

Register after getting the code:

python yowsup-cli registration --register xxx-xxx --phone xxxxxxxxxxx --cc 1

However, by doing so, it looks like it un-verifies the number from my phone.

Based on this link, it seems like there is a restriction on the WhatsApp side:
https://www.whatsapp.com/faq/en/general/21009863

Is there a way to associate a phone number in WhatsApp with Yowsup as well as a mobile device?


问:
Impementation of google map in blackberry
I have to develop an application which involves implementation of google map in blackberry.</p>

答:
u can use Static google map api.. Follow the link

Google Static Maps API


问:
Fill multidimesional array with values of another array in php
I've this array as query result:

```<code>[0]=>
array(2) {
["id_iscr"]=>
int(2)
["id_pettorina"]=>
NULL
}
[1]=>
array(2) {
["id_iscr"]=>
int(3)
["id_pettorina"]=>
NULL
}
[2]=>
array(2) {
["id_iscr"]=>
int(5)
["id_pettorina"]=>
NULL
}
[3]=>
array(2) {
["id_iscr"]=>
int(7)
["id_pettorina"]=>
NULL
}
...
</code>```

and this as array of distinct value

```<code>[0]=>
int(125)
[1]=>
int(162)
[2]=>
int(65)
[3]=>
int(98)
...
</code>```

Both array have same number of element;
my question is: in which way can I fill each NULL value of the first array with each value of the socond one and insert into mysql db?
Thanks in advance.

答:
try:

```<code>for ($i=0; i<count(array); i++)
  array[i]['id_pettorina'] = other_array[i];
</code>```

Inserting it into MySQL depends on your database API

Body:
I've this array as query result:

[0]=>
array(2) {
["id_iscr"]=>
int(2)
["id_pettorina"]=>
NULL
}
[1]=>
array(2) {
["id_iscr"]=>
int(3)
["id_pettorina"]=>
NULL
}
[2]=>
array(2) {
["id_iscr"]=>
int(5)
["id_pettorina"]=>
NULL
}
[3]=>
array(2) {
["id_iscr"]=>
int(7)
["id_pettorina"]=>
NULL
}
...

and this as array of distinct value

[0]=>
int(125)
[1]=>
int(162)
[2]=>
int(65)
[3]=>
int(98)
...

Both array have same number of element;
my question is: in which way can I fill each NULL value of the first array with each value of the socond one and insert into mysql db?
Thanks in advance.

Body:
try:

for ($i=0; i<count(array); i++)
  array[i]['id_pettorina'] = other_array[i];

Inserting it into MySQL depends on your database API


问:
Loading a XIB file to a UIView Swift
I am trying to load my XIB file into a UIView but I am having some trouble. I have the required override functions but they seem to be crashing. Saying this error, warning:

could not load any Objective-C class information. This will
  significantly reduce the quality of type information available.

I was wondering if someone could show me how to properly load the XIB file into a UIView

```<code>import UIKit

class Widget: UIView {

    let view = UIView()

    override init(frame: CGRect) {
        super.init(frame: frame)

        //call function

        loadNib()

    }

    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)

        loadNib()

        //fatalError("init(coder:) has not been implemented")
    }

    func loadNib() {
        let bundle = NSBundle(forClass: self.dynamicType)
        let nib = UINib(nibName: "nib", bundle: bundle)
        let view = nib.instantiateWithOwner(self, options: nil)[0] as! UIView
        view.frame = bounds
        view.autoresizingMask = [.FlexibleWidth, .FlexibleHeight]
        self.addSubview(view);
    }
}
</code>```

答:
Here is my approach (written in Swift 3.1):

```<code>protocol XibDesignable : class {}

extension XibDesignable where Self : UIView {

    static func instantiateFromXib() -> Self {

        let dynamicMetatype = Self.self
        let bundle = Bundle(for: dynamicMetatype)
        let nib = UINib(nibName: "\(dynamicMetatype)", bundle: bundle)

        guard let view = nib.instantiate(withOwner: nil, options: nil).first as? Self else {

            fatalError("Could not load view from nib file.")
        }
        return view
    }
}

extension UIView : XibDesignable {}
</code>```

Now I simply can create any UIView subclass from a Xib (assuming there is one) like so MyCustomView.instantiateFromXib(). Remember to name your Xib file exactly as your UIView subclass and set the type of the main view in that Xib file correctly.

As soon as SE-0068 will be implemented one could drop the protocol and move the function directly into the UIView extension.

Just a note: The original post uses a commonly used pattern with a nested view. IMHO this is a bad pattern which does not utilize the resources and only creates unnecessary view hierarchy.

Title: Loading a XIB file to a UIView Swift

Body:
I am trying to load my XIB file into a UIView but I am having some trouble. I have the required override functions but they seem to be crashing. Saying this error, warning:

could not load any Objective-C class information. This will
  significantly reduce the quality of type information available.

I was wondering if someone could show me how to properly load the XIB file into a UIView

import UIKit

class Widget: UIView {

    let view = UIView()

    override init(frame: CGRect) {
        super.init(frame: frame)

        //call function

        loadNib()

    }

    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)

        loadNib()

        //fatalError("init(coder:) has not been implemented")
    }

    func loadNib() {
        let bundle = NSBundle(forClass: self.dynamicType)
        let nib = UINib(nibName: "nib", bundle: bundle)
        let view = nib.instantiateWithOwner(self, options: nil)[0] as! UIView
        view.frame = bounds
        view.autoresizingMask = [.FlexibleWidth, .FlexibleHeight]
        self.addSubview(view);
    }
}

Body:
Here is my approach (written in Swift 3.1):

protocol XibDesignable : class {}

extension XibDesignable where Self : UIView {

    static func instantiateFromXib() -> Self {

        let dynamicMetatype = Self.self
        let bundle = Bundle(for: dynamicMetatype)
        let nib = UINib(nibName: "\(dynamicMetatype)", bundle: bundle)

        guard let view = nib.instantiate(withOwner: nil, options: nil).first as? Self else {

            fatalError("Could not load view from nib file.")
        }
        return view
    }
}

extension UIView : XibDesignable {}

Now I simply can create any UIView subclass from a Xib (assuming there is one) like so MyCustomView.instantiateFromXib(). Remember to name your Xib file exactly as your UIView subclass and set the type of the main view in that Xib file correctly.

As soon as SE-0068 will be implemented one could drop the protocol and move the function directly into the UIView extension.

Just a note: The original post uses a commonly used pattern with a nested view. IMHO this is a bad pattern which does not utilize the resources and only creates unnecessary view hierarchy.


问:
How to remove the grey background behind JCheckboxes?
I want to remove the grey background that appears automatically when creating JCheckboxes. The panel that the JCheckboxes are in, is setOpaque(false). I have tried using setOpaque(false) with the JCheckboxes but it doesn't work. I want to make the JCheckboxes appear directly on the black background as in the image.

JCheckboxes grey background on black background:

My code is below. An arraylist was used to retrieve data from the database n display them as JCheckboxes. The ModulePanel was then added to the JFrame.

```<code>            Enrol= new JCheckBox(Modules.get(i));
            ModulePanel.add(Enrol);
</code>```

答:
I have tried using setOpaque(false) with the JCheckboxes but it doesn't work

Well, that's the right way to do it.

For example, try setting the background of the panel where the boxes are held to other color and call your checkBox.setOpaque(false);

For example:

```<code>import java.awt.Color;

import javax.swing.BoxLayout;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;

public class CheckBoxNoBackground {
    private JFrame frame;
    private JPanel pane;
    private JCheckBox box1;
    private JCheckBox box2;

    public static void main(String[] args) {
        SwingUtilities.invokeLater(() -> new CheckBoxNoBackground().createAndShowGui());
    }

    public void createAndShowGui() {
        frame = new JFrame(getClass().getSimpleName());

        pane = new JPanel();
        pane.setLayout(new BoxLayout(pane, BoxLayout.PAGE_AXIS));

        box1 = new JCheckBox("I'm a check box");
        box2 = new JCheckBox("I'm also a check box");

        box1.setOpaque(false);
        pane.setBackground(Color.CYAN);

        pane.add(box1);
        pane.add(box2);

        frame.add(pane);
        frame.pack();
        frame.setVisible(true);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
}
</code>```

The panel that the JCheckboxes are in, is setOpaque(false).

If you do that, you're seeing the background of the JFrame's content pane (which is gray)

If I add this line:

```<code>pane.setOpaque(false);
</code>```

I get this:

However if you want more help on your code, post a valid MCVE as said before in the comments.

Body:
I want to remove the grey background that appears automatically when creating JCheckboxes. The panel that the JCheckboxes are in, is setOpaque(false). I have tried using setOpaque(false) with the JCheckboxes but it doesn't work. I want to make the JCheckboxes appear directly on the black background as in the image.

JCheckboxes grey background on black background:

My code is below. An arraylist was used to retrieve data from the database n display them as JCheckboxes. The ModulePanel was then added to the JFrame.

            Enrol= new JCheckBox(Modules.get(i));
            ModulePanel.add(Enrol);

Body:
I have tried using setOpaque(false) with the JCheckboxes but it doesn't work

Well, that's the right way to do it.

For example, try setting the background of the panel where the boxes are held to other color and call your checkBox.setOpaque(false);

For example:

import java.awt.Color;

import javax.swing.BoxLayout;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;

public class CheckBoxNoBackground {
    private JFrame frame;
    private JPanel pane;
    private JCheckBox box1;
    private JCheckBox box2;

    public static void main(String[] args) {
        SwingUtilities.invokeLater(() -> new CheckBoxNoBackground().createAndShowGui());
    }

    public void createAndShowGui() {
        frame = new JFrame(getClass().getSimpleName());

        pane = new JPanel();
        pane.setLayout(new BoxLayout(pane, BoxLayout.PAGE_AXIS));

        box1 = new JCheckBox("I'm a check box");
        box2 = new JCheckBox("I'm also a check box");

        box1.setOpaque(false);
        pane.setBackground(Color.CYAN);

        pane.add(box1);
        pane.add(box2);

        frame.add(pane);
        frame.pack();
        frame.setVisible(true);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
}

The panel that the JCheckboxes are in, is setOpaque(false).

If you do that, you're seeing the background of the JFrame's content pane (which is gray)

If I add this line:

pane.setOpaque(false);

I get this:

However if you want more help on your code, post a valid MCVE as said before in the comments.


问:
How to make a search webservice API with Codeigniter
I've made a Search API with native PHP in the past, but I don't know how to make it in Codeigniter. The code below is not showing the data. Could someone point me in the right direction?</p>

```<code>public function peta(){
    $data = array();

    // $query = "select * from tb_peta";
    $cari = isset($_REQUEST['cari']) ? $_REQUEST['cari'] : '';

    if ($cari != null) {
        $result = $this->db->query("SELECT * FROM tb_peta WHERE nama LIKE "."'%".$cari."%'");
    } else {
        $result = $this->db->query( "SELECT * FROM tb_peta");
    }

    // $q = $this->db->query($query);
    if ($q -> num_rows() >0) {
        $data ['success'] = 1;
        $data ['message'] = 'data ada';
        $data ['data']=$q->result();
    } else {
        $data['result']='0';
        $data['message'] ='kosong';
    }

    while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
        $data[] = $row;
    }

    echo json_encode(array('planet' => $json_response));
}
</code>```

答:
Make use of codeigniter query builder.

```<code>public function peta(){
    $data = array();

    $cari = isset($_REQUEST['cari']) ? $_REQUEST['cari'] : '';

    if ($cari != null) {
        $this->db->like('name',$cari,'both');
        $result = $this->db->get("tb_peta");
    } else {
        $result = $this->db->get("tb_peta");
    }

    if ($result->num_rows() >0) {
        $data ['success'] = 1;
        $data ['message'] = 'data ada';
        $data ['data']=$result->result_array();
    } else {
        $data['result']='0';
        $data['message'] ='kosong';
    }

    echo json_encode(array('planet' => $data));
}
</code>```

Body:
I've made a Search API with native PHP in the past, but I don't know how to make it in Codeigniter. The code below is not showing the data. Could someone point me in the right direction?

public function peta(){
    $data = array();

    // $query = "select * from tb_peta";
    $cari = isset($_REQUEST['cari']) ? $_REQUEST['cari'] : '';

    if ($cari != null) {
        $result = $this->db->query("SELECT * FROM tb_peta WHERE nama LIKE "."'%".$cari."%'");
    } else {
        $result = $this->db->query( "SELECT * FROM tb_peta");
    }

    // $q = $this->db->query($query);
    if ($q -> num_rows() >0) {
        $data ['success'] = 1;
        $data ['message'] = 'data ada';
        $data ['data']=$q->result();
    } else {
        $data['result']='0';
        $data['message'] ='kosong';
    }

    while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
        $data[] = $row;
    }

    echo json_encode(array('planet' => $json_response));
}

Body:
Make use of codeigniter query builder.

public function peta(){
    $data = array();

    $cari = isset($_REQUEST['cari']) ? $_REQUEST['cari'] : '';

    if ($cari != null) {
        $this->db->like('name',$cari,'both');
        $result = $this->db->get("tb_peta");
    } else {
        $result = $this->db->get("tb_peta");
    }

    if ($result->num_rows() >0) {
        $data ['success'] = 1;
        $data ['message'] = 'data ada';
        $data ['data']=$result->result_array();
    } else {
        $data['result']='0';
        $data['message'] ='kosong';
    }

    echo json_encode(array('planet' => $data));
}


问:
Using pip behind a proxy with CNTLM
I am trying to use pip behind a proxy at work.

One of the answers from this post suggested using CNTLM. I installed and configured it per this other post, but running cntlm.exe -c cntlm.ini -I -M http://google.com gave the error Connection to proxy failed, bailing out.

I also tried pip install -–proxy=user:pass@localhost:3128 (the default CNTLM port) but that raised Cannot fetch index base URL http://pypi.python.org/simple/. Clearly something's up with the proxy.

Does anyone know how to check more definitively whether CNTLM is set up right, or if there's another way around this altogether? I know you can also set the http_proxy environment variable as described here but I'm not sure what credentials to put in. The ones from cntlm.ini?

答:
This is what works for me: </p>

```<code>pip --proxy proxy url:port command package
</code>```

Title: Using pip behind a proxy with CNTLM

Body:
This is what works for me:

pip --proxy proxy url:port command package


问:
I can load static files locally with 'runserver' but not in production
I can load static files locally with 'runserver' but not in production.
I successfully manage to load templates in production, but not static files.

in the .html page I included the lines:

```<code><!DOCTYPE html>
{% load staticfiles %}
</code>```

...
...

```<code><img src="{% static "images/mypic.jpg" %}" alt="this pic" />
</code>```

my settings in settings.py include these lines

```<code>BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
STATIC_DIR = os.path.join(BASE_DIR, 'static')
STATICFILES_DIRS = [STATIC_DIR, ]
STATIC_URL = '/static/'
</code>```

and in urls.py I have:

```<code>from django.conf.urls.static import static
</code>```

and

```<code>urlpatterns = [
    url(r'^$', views.index, name='index'),
    url(r'^pages/', include('pages.urls')),
    url(r'^admin/', admin.site.urls),
    url(r'about^$', views.about, name='about'),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
</code>```

I've been trying for hours, any idea why I can't access them?

答:
In produzion sistem is un suggestable  use link to file and probabily work thanks to the DEBUG=TRUE.
In product environment is always better use a webserver like nginx and load the static by the  webserver </p>

Body:
I can load static files locally with 'runserver' but not in production.
I successfully manage to load templates in production, but not static files.

in the .html page I included the lines:

<!DOCTYPE html>
{% load staticfiles %}

...
...

my settings in settings.py include these lines

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
STATIC_DIR = os.path.join(BASE_DIR, 'static')
STATICFILES_DIRS = [STATIC_DIR, ]
STATIC_URL = '/static/'

and in urls.py I have:

from django.conf.urls.static import static

and

urlpatterns = [
    url(r'^$', views.index, name='index'),
    url(r'^pages/', include('pages.urls')),
    url(r'^admin/', admin.site.urls),
    url(r'about^$', views.about, name='about'),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

I've been trying for hours, any idea why I can't access them?