问:
ion-infinite-scroll firing extremely infrequently
I am trying to get ionInfiniteScroll to work - I have already gotten it to work in several other places in my app, and this page is actually almost identical to another page where it is working fine. When I scroll down nothing happens, no loading graphic. I have a console message right on the inside of my doInfinite method and it never executes...so the doInfinite code is never executing. I'm thinking maybe there is something wrong with the html structure since the method doesn't execute:

```<code><ion-content no-padding>
  <div (swipeLeft)="swipeLeft()" (swipeRight)="toFull()"> <!--(swipeRight)="toProfile()"-->

    ...

   <div class ='weeklydeals contentone' #weeklydeals [@moveList]='moveState'>
   <ion-list class="marginstatus" no-padding>
     <ion-item *ngFor="let a of promotions" no-padding>
      <div class="feedtoptextcontainer">
        <!--<div class="imageparent">
          <img class="postprofilepic" src="{{a.url}}">
        </div>-->
        <div class="usernamecontainer">
          <h4 class="postusername">@{{a.username}}</h4><br>
        </div>
        <h3 class="promotitle">{{a.title}}</h3>
        <div class="desccontainer">
          <h4 class="deal">{{a.caption}}</h4>
        </div>
      </div>
      <!--<img class="imagepost" src="{{i}}">-->
     </ion-item>
   </ion-list>
   <ion-infinite-scroll (ionInfinite)="doInfinite($event)">
    <ion-infinite-scroll-content
      loadingSpinner="bubbles"
      loadingText="Loading more data...">
    </ion-infinite-scroll-content>
   </ion-infinite-scroll>
  </div>

  ...

  <ion-item class="noavail" #noavail no-padding no-lines>NO RESULTS</ion-item>
</div>
</code>```

doInfinite method code:

```<code>doInfinite(infiniteScroll) {
    console.log("in doinfinite promotionsssssss");
    setTimeout(() => {
      console.log('Begin async operation');
      /*console.log(this.content.directionY + "        upupupupupupu********");
      if(this.content.directionY == 'up') {
        this.show = false
      }
      else {
        this.show = true;
      }*/

      console.log(this.startAtKey1 + "     before %%^&^&^% start at");
      this.list2 = this.af.list('/promotions', {
      query: {
        orderByKey: true,
        endAt: this.startAtKey1,
        limitToLast: 11
      }});

      this.subscription11 = this.list2.subscribe(items => {
          let x = 0;
          this.lastKey1 = this.startAtKey1;
          items.forEach(item => {

            let storageRef = firebase.storage().ref().child('/settings/' + item.customMetadata.username + '/profilepicture.png');

            storageRef.getDownloadURL().then(url => {
              console.log(url + "in download url !!!!!!!!!!!!!!!!!!!!!!!!");
              item.customMetadata.picURL = url;
            }).catch((e) => {
              console.log("in caught url !!!!!!!$$$$$$$!!");
              item.customMetadata.picURL = 'assets/blankprof.png';
            });

            if(this.startAtKey1 !== item.$key && this.lastKey1 !== item.$key) {
              console.log(this.startAtKey1 + "   :startAtKey1 before 4444444        item key:     " + item.$key);
              this.promotions.push(item.customMetadata); //unshift?**************
            }

            if(x == 0) {
              this.startAtKey1 = item.$key;
            }

            x++;
          });

      })

      infiniteScroll.complete();

    }, 500);
  }
</code>```

UPDATE

I think another important thing to note is that I am using 5 different lists that look like the one below...all on the same page (I only have included 2 below - that is what I was last testing with). Where the ... is in the code, that are 4 more lists like the one you see above. They are all enclosed in
's like the one above - and none of them are ever being displayed at the same time - I think I should post the whole <ion-content> just incase things are interfering with one another:

```<code><ion-content no-padding>
<div (swipeLeft)="swipeLeft()" (swipeRight)="toFull()"> <!--(swipeRight)="toProfile()"-->

  <!--<ion-refresher (ionRefresh)="doRefresh($event)">
    <ion-refresher-content></ion-refresher-content>
  </ion-refresher>-->

  <div class ='availability contentone' #availability [@moveList]='moveState'>
   <ion-list class="marginstatus" no-padding>
     <ion-item *ngFor="let z of availabilities" no-padding (tap)="presentProfileModal(z.salon, z.time)">
      <div class="feedtoptextcontainer">
        <div class="imageparent">
          <img class="postprofilepic" src="{{z.pic}}">
        </div>
        <div class="usernamecontainer">
          <h4 class="postusername">@{{z.salon}}</h4><br>
          <h4 class="poststudio">{{z.time}}</h4>
        </div>
      </div>
      <!--<img class="imagepost" src="{{i}}">-->
     </ion-item>
   </ion-list>
  </div>

  <div class ='distance contentone' #distance [@moveList]='moveState'>
   <ion-list class="marginstatus" no-padding>
     <ion-item *ngFor="let z of distances" no-padding (tap)="presentProfileModalDistance(z.salon)">
      <div class="feedtoptextcontainer">
        <div class="imageparent">
          <img class="postprofilepic" src="{{z.pic}}">
        </div>
        <div class="usernamecontainer">
          <h4 class="postusername">@{{z.salon}}</h4><br>
          <h4 class="poststudio">{{z.distance}} mi</h4>
        </div>
      </div>
      <!--<img class="imagepost" src="{{i}}">-->
     </ion-item>
   </ion-list>
  </div>

  <div class ='ratings contentone' #ratings [@moveList]='moveState'>
   <ion-list class="marginstatus" no-padding>
     <ion-item *ngFor="let a of rating ; let i = index" no-padding (tap)="presentProfileModalRatings(a.username)">
      <div class="feedtoptextcontainer">
        <div class="imageparent">
          <img class="postprofilepic" src="{{a.picURL}}">
        </div>
        <div class="usernamecontainer">
          <h4 class="postusername">@{{a.username}}</h4><br>
          <h4 class="poststudio">{{a.stars}}</h4>
        </div>
      </div>
      <!--<img class="imagepost" src="{{i}}">-->
     </ion-item>
   </ion-list>
  </div>

  <div class ='price contentone' #price [@moveList]='moveState'>
   <ion-list class="marginstatus" no-padding>
     <ion-item *ngFor="let a of pricesArray" no-padding (tap)="presentProfileModalPrice(a.username)">
      <div class="feedtoptextcontainer">
        <div class="imageparent">
          <img class="postprofilepic" src="{{a.picURL}}">
        </div>
        <div class="usernamecontainer">
          <h4 class="postusername">@{{a.username}}</h4><br>
          <h4 class="poststudio">{{a.price}}</h4>
        </div>
      </div>
      <!--<img class="imagepost" src="{{i}}">-->
     </ion-item>
   </ion-list>
   <ion-infinite-scroll (ionInfinite)="doInfiniteP($event)">
    <ion-infinite-scroll-content
      loadingSpinner="bubbles"
      loadingText="Loading more data...">
    </ion-infinite-scroll-content>
   </ion-infinite-scroll>
  </div>

  <div class ='weeklydeals contentone' #weeklydeals [@moveList]='moveState'>
   <ion-list class="marginstatus" no-padding>
     <ion-item *ngFor="let a of promotions" no-padding>
      <div class="feedtoptextcontainer">
        <!--<div class="imageparent">
          <img class="postprofilepic" src="{{a.url}}">
        </div>-->
        <div class="usernamecontainer">
          <h4 class="postusername">@{{a.username}}</h4><br>
        </div>
        <h3 class="promotitle">{{a.title}}</h3>
        <div class="desccontainer">
          <h4 class="deal">{{a.caption}}</h4>
        </div>
      </div>
      <!--<img class="imagepost" src="{{i}}">-->
     </ion-item>
   </ion-list>
   <ion-infinite-scroll (ionInfinite)="doInfinite($event)">
    <ion-infinite-scroll-content
      loadingSpinner="bubbles"
      loadingText="Loading more data...">
    </ion-infinite-scroll-content>
   </ion-infinite-scroll>
  </div>

  <ion-item class="noavail" #noavail no-padding no-lines>NO RESULTS</ion-item>
</div>
</ion-content>
</code>```

I switch the lists in and out by using renderer like renderer.setElementStyle(el, 'display', 'none) or block.

答: It turned out to be conflicting css that I had on .scroll-content. It seems if you add css to .scroll-content, ion-infinite-scroll stops working.

Body:
I am trying to get ionInfiniteScroll to work - I have already gotten it to work in several other places in my app, and this page is actually almost identical to another page where it is working fine. When I scroll down nothing happens, no loading graphic. I have a console message right on the inside of my doInfinite method and it never executes...so the doInfinite code is never executing. I'm thinking maybe there is something wrong with the html structure since the method doesn't execute:

<ion-content no-padding>

    ...

   <ion-list class="marginstatus" no-padding>
     <ion-item *ngFor="let a of promotions" no-padding>

@{{a.username}}

{{a.title}}

{{a.caption}}

     </ion-item>
   </ion-list>
   <ion-infinite-scroll (ionInfinite)="doInfinite($event)">
    <ion-infinite-scroll-content
      loadingSpinner="bubbles"
      loadingText="Loading more data...">
    </ion-infinite-scroll-content>
   </ion-infinite-scroll>

  ...

  <ion-item class="noavail" #noavail no-padding no-lines>NO RESULTS</ion-item>

doInfinite method code:

doInfinite(infiniteScroll) {
    console.log("in doinfinite promotionsssssss");
    setTimeout(() => {
      console.log('Begin async operation');
      /*console.log(this.content.directionY + "        upupupupupupu********");
      if(this.content.directionY == 'up') {
        this.show = false
      }
      else {
        this.show = true;
      }*/

      console.log(this.startAtKey1 + "     before %%^&^&^% start at");
      this.list2 = this.af.list('/promotions', {
      query: {
        orderByKey: true,
        endAt: this.startAtKey1,
        limitToLast: 11
      }});

      this.subscription11 = this.list2.subscribe(items => {
          let x = 0;
          this.lastKey1 = this.startAtKey1;
          items.forEach(item => {

            let storageRef = firebase.storage().ref().child('/settings/' + item.customMetadata.username + '/profilepicture.png');

            storageRef.getDownloadURL().then(url => {
              console.log(url + "in download url !!!!!!!!!!!!!!!!!!!!!!!!");
              item.customMetadata.picURL = url;
            }).catch((e) => {
              console.log("in caught url !!!!!!!$$$$$$$!!");
              item.customMetadata.picURL = 'assets/blankprof.png';
            });

            if(this.startAtKey1 !== item.$key && this.lastKey1 !== item.$key) {
              console.log(this.startAtKey1 + "   :startAtKey1 before 4444444        item key:     " + item.$key);
              this.promotions.push(item.customMetadata); //unshift?**************
            }

            if(x == 0) {
              this.startAtKey1 = item.$key;
            }

            x++;
          });

      })

      infiniteScroll.complete();

    }, 500);
  }

UPDATE

I think another important thing to note is that I am using 5 different lists that look like the one below...all on the same page (I only have included 2 below - that is what I was last testing with). Where the ... is in the code, that are 4 more lists like the one you see above. They are all enclosed in
's like the one above - and none of them are ever being displayed at the same time - I think I should post the whole <ion-content> just incase things are interfering with one another:

<ion-content no-padding>

   <ion-list class="marginstatus" no-padding>
     <ion-item *ngFor="let z of availabilities" no-padding (tap)="presentProfileModal(z.salon, z.time)">

@{{z.salon}}

{{z.time}}

     </ion-item>
   </ion-list>

   <ion-list class="marginstatus" no-padding>
     <ion-item *ngFor="let z of distances" no-padding (tap)="presentProfileModalDistance(z.salon)">

@{{z.salon}}

{{z.distance}} mi

     </ion-item>
   </ion-list>

   <ion-list class="marginstatus" no-padding>
     <ion-item *ngFor="let a of rating ; let i = index" no-padding (tap)="presentProfileModalRatings(a.username)">

@{{a.username}}

{{a.stars}}

     </ion-item>
   </ion-list>

   <ion-list class="marginstatus" no-padding>
     <ion-item *ngFor="let a of pricesArray" no-padding (tap)="presentProfileModalPrice(a.username)">

@{{a.username}}

{{a.price}}

     </ion-item>
   </ion-list>
   <ion-infinite-scroll (ionInfinite)="doInfiniteP($event)">
    <ion-infinite-scroll-content
      loadingSpinner="bubbles"
      loadingText="Loading more data...">
    </ion-infinite-scroll-content>
   </ion-infinite-scroll>

   <ion-list class="marginstatus" no-padding>
     <ion-item *ngFor="let a of promotions" no-padding>

@{{a.username}}

{{a.title}}

{{a.caption}}

     </ion-item>
   </ion-list>
   <ion-infinite-scroll (ionInfinite)="doInfinite($event)">
    <ion-infinite-scroll-content
      loadingSpinner="bubbles"
      loadingText="Loading more data...">
    </ion-infinite-scroll-content>
   </ion-infinite-scroll>

  <ion-item class="noavail" #noavail no-padding no-lines>NO RESULTS</ion-item>

</ion-content>

I switch the lists in and out by using renderer like renderer.setElementStyle(el, 'display', 'none) or block.


来源: stackexchange

问:
API URL call with PHP and cURL
I'm hoping someone can help me out.

I have an API call using this URL.

```<code>https://192.168.11.234:4444/webconsole/APIController?reqxml=<Request><Login<Username>XXXXX</Username><Password>XXXXX></Password></Login><Get><User><Username>manager</Username></User></Get></Request>
</code>```

This works fine and returns an XML as expected.

However I'm attempting to do the same thing with PHP and cURL.

I have very little experience with cURL

So far I've tried variations of this but I get no response. only a blank page.  wondering if maybe someone could help me out.

```<code><?php
$input_xml = '<Request><Login><Username>XXXX</Username><Password>XXXX</Password></Login><Get><User></User></Get></Request>';
$url = "https://192.168.11.234:4444/webconsole/APIController";

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);

curl_setopt($ch, CURLOPT_POSTFIELDS,
            "reqxml=" . $input_xml);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 300);
$data = curl_exec($ch);
curl_close($ch);

$array_data = json_decode(json_encode(simplexml_load_string($data)), true);

print_r('```');
print_r($array_data);
print_r('```');
?>
</code>```

I will admit I have not worked with cURL much, so I may be way off.

答:
1) If your server doesn't accept POST requests then remove this line:

```<code>curl_setopt($ch, CURLOPT_POSTFIELDS, "reqxml=" . $input_xml);
</code>```

and add:

```<code>curl_setopt($ch, CURLOPT_URL, $url.'?reqxml='.urlencode($input_xml));
</code>```

to send data in GET request.

2) Set the correct HTTP headers:

```<code>$headers = [
    "Content-type: text/xml;charset=\"utf-8\"",
    "Accept: text/xml",
    "Content-length: ".strlen($xml_data)
];

curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
</code>```

3) To see possible errors, add these lines before line $data = curl_exec($ch);:

```<code>curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
if (curl_error($ch)) {
    echo 'error:' . curl_error($ch);
}
</code>```

4) Also you need to add check for simplexml_load_string, because it returns false on failure:

```<code>if (simplexml_load_string($data) === false) {
// do something
}
</code>```

Please let me know if my answer helped you.

ContentLicense: CC BY-SA 4.0

Title: API URL call with PHP and cURL

Body:
I'm hoping someone can help me out.

I have an API call using this URL.

https://192.168.11.234:4444/webconsole/APIController?reqxml=<Request><Login<Username>XXXXX</Username><Password>XXXXX></Password></Login><Get><User><Username>manager</Username></User></Get></Request>

This works fine and returns an XML as expected.

However I'm attempting to do the same thing with PHP and cURL.

I have very little experience with cURL

So far I've tried variations of this but I get no response. only a blank page.  wondering if maybe someone could help me out.

<?php
$input_xml = '<Request><Login><Username>XXXX</Username><Password>XXXX</Password></Login><Get><User></User></Get></Request>';
$url = "https://192.168.11.234:4444/webconsole/APIController";

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);

curl_setopt($ch, CURLOPT_POSTFIELDS,
            "reqxml=" . $input_xml);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 300);
$data = curl_exec($ch);
curl_close($ch);

$array_data = json_decode(json_encode(simplexml_load_string($data)), true);

print_r('
');
print_r($array_data);
print_r('
');
?>

I will admit I have not worked with cURL much, so I may be way off.

Body:
1) If your server doesn't accept POST requests then remove this line:

curl_setopt($ch, CURLOPT_POSTFIELDS, "reqxml=" . $input_xml);

and add:

curl_setopt($ch, CURLOPT_URL, $url.'?reqxml='.urlencode($input_xml));

to send data in GET request.

2) Set the correct HTTP headers:

$headers = [
    "Content-type: text/xml;charset=\"utf-8\"",
    "Accept: text/xml",
    "Content-length: ".strlen($xml_data)
];

curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

3) To see possible errors, add these lines before line $data = curl_exec($ch);:

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
if (curl_error($ch)) {
    echo 'error:' . curl_error($ch);
}

4) Also you need to add check for simplexml_load_string, because it returns false on failure:

if (simplexml_load_string($data) === false) {
// do something
}

Please let me know if my answer helped you.

ContentLicense: CC BY-SA 3.0


问:
Difference between load all and build & reload
What is the difference between the Load All command and the Build & Reload command in RStudio when working with packages?

My primary workstream now is to incorporate the current changes of the package I'm building so that I can actually use the latest functions on my machine in a different RStudio session.

答:
I've been exploring this sort of workflow and will use your question to document what I've found.

Case 1: Pkg and Code in Same Session

In RStudio choose File / New Project ... New Directory / R Package. Put scripts that define a library of functions in the R directory. Put any open code elsewhere (e.g., in a subdirectory named "scripts"). Use dev_tools::load_all (Ctrl-Shift-L) to load any objects defined in the R directory into the current session. This works for simple objects and avoids a slower Build & Reload cycle.

If you like working in this mode, recognize that any Build operation is going to make a copy of many of these files. For code this is fine but if you have large data files in a subdirectory it can be slow to build and consume a lot of storage. Consider putting them in a directory that is ignored at Build or outside the project altogether if that is more appropriate.

One nice side-effect of Build in RStudio is that you can build documentation for all the objects. We can still do this without installing the package by running roxygen2::roxygenise().

Case 2: Pkg and Code in Separate Sessions

This happens when you have functions that may be used by different projects but you need to go back and edit one of the packages.

In the first session, suppose we load a package named "greetings". Do this with RStudio as above and it will define a "hello world" function: hello(). Run Build & Reload to install this package in the local package library. Open a second session to confirm you can call this function:

```<code>greetings::hello()
#> "Hello, world!"
</code>```

In the first session, modify greetings::hello() to say goodbye instead. Build & Reload (Ctrl+Shift+B) to install the changes into the package library. The second session won't pick up the change:

```<code>greetings::hello()
#> "Hello, world!"
</code>```

devtools:reload() doesn't help because it exits silently if the package is not attached:

```<code>reload(inst("greetings"))
greetings::hello()
#> "Hello, world!"
</code>```

However, I have found that this combination will pick up the changes in the second session:

```<code>unload(inst("greetings"))
reload(inst("greetings"))
greetings::hello()
#> "Goodbye, cruel world!"
</code>```

So development in Case 2 has some limitations.

Body:
I've been exploring this sort of workflow and will use your question to document what I've found.

Case 1: Pkg and Code in Same Session

In RStudio choose File / New Project ... New Directory / R Package. Put scripts that define a library of functions in the R directory. Put any open code elsewhere (e.g., in a subdirectory named "scripts"). Use dev_tools::load_all (Ctrl-Shift-L) to load any objects defined in the R directory into the current session. This works for simple objects and avoids a slower Build & Reload cycle.

If you like working in this mode, recognize that any Build operation is going to make a copy of many of these files. For code this is fine but if you have large data files in a subdirectory it can be slow to build and consume a lot of storage. Consider putting them in a directory that is ignored at Build or outside the project altogether if that is more appropriate.

One nice side-effect of Build in RStudio is that you can build documentation for all the objects. We can still do this without installing the package by running roxygen2::roxygenise().

Case 2: Pkg and Code in Separate Sessions

This happens when you have functions that may be used by different projects but you need to go back and edit one of the packages.

In the first session, suppose we load a package named "greetings". Do this with RStudio as above and it will define a "hello world" function: hello(). Run Build & Reload to install this package in the local package library. Open a second session to confirm you can call this function:

greetings::hello()
#> "Hello, world!"

In the first session, modify greetings::hello() to say goodbye instead. Build & Reload (Ctrl+Shift+B) to install the changes into the package library. The second session won't pick up the change:

greetings::hello()
#> "Hello, world!"

devtools:reload() doesn't help because it exits silently if the package is not attached:

reload(inst("greetings"))
greetings::hello()
#> "Hello, world!"

However, I have found that this combination will pick up the changes in the second session:

unload(inst("greetings"))
reload(inst("greetings"))
greetings::hello()
#> "Goodbye, cruel world!"

So development in Case 2 has some limitations.


问:
scikit-image: write a ndarray to image with imsave, read back with imread, data don't match
here is the minimum working example:

```<code>import numpy as np
from skimage.io import imsave, imread

image = np.array([[[109, 232, 173],
                [ 55,  35, 144]],
                [[ 43, 124, 185],
                [234, 127, 246]]], dtype=np.uint8)

imsave("test.jpg", image)
rb_image = imread("test.jpg")
print("original image")
print(image)
print("read back image")
print(rb_image)
</code>```

after run it, the result is, the ndarray read back from file don't match with

```<code>original image
[[[109 232 173]
  [ 55  35 144]]

 [[ 43 124 185]
  [234 127 246]]]
read back image
[[[111 208 255]
  [ 42  61 138]]

 [[ 72 140 201]
  [141 131 218]]]
</code>```

can some one give me some suggestiones?

答:
Scikit uses PIL underneath, have you tried using straight PIL

In Example

```<code>   import numpy as np
   from skimage.io import imsave, imread
   from PIL import Image

   image = np.array([[[109, 232, 173],
                [ 55,  35, 144]],
                [[ 43, 124, 185],
                [234, 127, 246]]], dtype=np.uint8)

   Image.fromarray(image).save()
   rb_image = imread("test.jpg")
   print("original image")
   print(image)
   print("read back image")
   print(rb_image)
</code>```

Body:
here is the minimum working example:

import numpy as np
from skimage.io import imsave, imread

image = np.array([[[109, 232, 173],
                [ 55,  35, 144]],
                [[ 43, 124, 185],
                [234, 127, 246]]], dtype=np.uint8)

imsave("test.jpg", image)
rb_image = imread("test.jpg")
print("original image")
print(image)
print("read back image")
print(rb_image)

after run it, the result is, the ndarray read back from file don't match with

original image
[[[109 232 173]
  [ 55  35 144]]

 [[ 43 124 185]
  [234 127 246]]]
read back image
[[[111 208 255]
  [ 42  61 138]]

 [[ 72 140 201]
  [141 131 218]]]

can some one give me some suggestiones?

Body:
Scikit uses PIL underneath, have you tried using straight PIL

In Example

   import numpy as np
   from skimage.io import imsave, imread
   from PIL import Image

   image = np.array([[[109, 232, 173],
                [ 55,  35, 144]],
                [[ 43, 124, 185],
                [234, 127, 246]]], dtype=np.uint8)

   Image.fromarray(image).save()
   rb_image = imread("test.jpg")
   print("original image")
   print(image)
   print("read back image")
   print(rb_image)


问:
How do i check if a user info is correct python
So i am making a password system.
It ask for the user to enter the password, then check if it's right. I am getting a error with:

```<code> %Run HelloPython.py
  File "/home/pi/Python Coding/HelloPython.py", line 17
    print('Welcome home,', name,)
        ^
SyntaxError: expected an indented block
</code>```

Something is wrong.
Code:

```<code>    print('What is your name?')

# Stores everything typed up until ENTER
name = sys.stdin.readline()

print('Hello', name,'Enter password.')
password = sys.stdin.readline()
if password == ("1"):
print('Welcome home,', name,)
    else:
      print("Password:", password,"Is incorect. Please try again.")
</code>```

答:
SyntaxError: expected an indented block

Indent your if-else statements like below.

To check "is equal to", use == instead of = which is an assignment.

readline returns a string, so you should compare it with '1' string.

readline includes a newline \n at the end, so call strip() on it.

```<code>import sys

print('What is your name?')

# Stores everything typed up until ENTER
name = sys.stdin.readline()
print('Hello', name, 'Enter password.')

password = sys.stdin.readline().strip()
if password == '1':
    print("Welcome home,", name)
else:
    print("Password:", password, "Is incorrect. Please try again.")
</code>```

Body:
So i am making a password system.
It ask for the user to enter the password, then check if it's right. I am getting a error with:

 %Run HelloPython.py
  File "/home/pi/Python Coding/HelloPython.py", line 17
    print('Welcome home,', name,)
        ^
SyntaxError: expected an indented block

Something is wrong.
Code:

    print('What is your name?')

# Stores everything typed up until ENTER
name = sys.stdin.readline()

print('Hello', name,'Enter password.')
password = sys.stdin.readline()
if password == ("1"):
print('Welcome home,', name,)
    else:
      print("Password:", password,"Is incorect. Please try again.")

Body:
SyntaxError: expected an indented block

Indent your if-else statements like below.

To check "is equal to", use == instead of = which is an assignment.

readline returns a string, so you should compare it with '1' string.

readline includes a newline \n at the end, so call strip() on it.

import sys

print('What is your name?')

# Stores everything typed up until ENTER
name = sys.stdin.readline()
print('Hello', name, 'Enter password.')

password = sys.stdin.readline().strip()
if password == '1':
    print("Welcome home,", name)
else:
    print("Password:", password, "Is incorrect. Please try again.")


问:
Get int variables within a String method Java
This is homework. Just going to put that out there. I feel it is best to show my code first and explain what I'm attempting to do

```<code>import java.util.Scanner;
public class Question1 {
public static void main(String[] args){
    int length, odd, even, largest;
    int n = getNumber();
    length=odd=even=largest=initialize();
    String sequence=createSequence(n, largest, odd, even, length);
    displaySequence(sequence);
    displayStatistics(largest, length, odd, even);
}
private static int getNumber(){
   Scanner kb = new Scanner(System.in);
   System.out.println("Enter the value of the number: ");
   int number = kb.nextInt();
   return number;
}
private static int initialize(){
    return 0;
}
public static String createSequence(int n, int largest, int odd, int even, int length){
    String sequence="";
    sequence+=n+" ";
    while (n!=1){
        n = (n%2==0) ? n/2 : 3*n+1;
        System.out.print(", "+n);
        sequence+=n+" ";
        if(n%2==0){ even++;
        }else{ odd++;}
        if(n>=largest){ largest = n;
        }
        length++;
    }
    return sequence;
}
private static void displaySequence(String sequence){
    System.out.println(sequence);
}
public static String displayStatistics(int length, int even, int odd, int largest){
    String nil = "";
    System.out.println("The largest number in the sequence was "+largest);
    System.out.println("The length of the sequence was "+length);
    System.out.println("There were "+odd+" odd numbers");
    System.out.println("There were "+even+" even numbers");
    return nil;
}

}
</code>```

I need attempting to display the largest number in the sequence, the length of the sequence, how many even numbers there were in the sequence and how many odd numbers there were in the sequence. But since I cannot return an int value in the createSequence method, I cannot get the new values for each statistic. Preventing me from displaying said statistics. How would I access these new variables to be used in the final method?

Note:

Requirements:

Declare variables in main

Initialize variables in Initialize()

createSequence (Create the sequence)

displaySequence (Then display the sequence in a separate method)

finally displayStatistics i.e. length, evens, odds, largest (in its own method), this is the one that's troubling me

答: Your teacher may be a bit more impressed if you created a Sequence class.  The class attributes would be the stats (which could be accessed via getter methods).  The createSequence method would become the constructor.  And you could implement a toString method to return a string representation of the contents.</p>

Body:
This is homework. Just going to put that out there. I feel it is best to show my code first and explain what I'm attempting to do

import java.util.Scanner;
public class Question1 {
public static void main(String[] args){
    int length, odd, even, largest;
    int n = getNumber();
    length=odd=even=largest=initialize();
    String sequence=createSequence(n, largest, odd, even, length);
    displaySequence(sequence);
    displayStatistics(largest, length, odd, even);
}
private static int getNumber(){
   Scanner kb = new Scanner(System.in);
   System.out.println("Enter the value of the number: ");
   int number = kb.nextInt();
   return number;
}
private static int initialize(){
    return 0;
}
public static String createSequence(int n, int largest, int odd, int even, int length){
    String sequence="";
    sequence+=n+" ";
    while (n!=1){
        n = (n%2==0) ? n/2 : 3*n+1;
        System.out.print(", "+n);
        sequence+=n+" ";
        if(n%2==0){ even++;
        }else{ odd++;}
        if(n>=largest){ largest = n;
        }
        length++;
    }
    return sequence;
}
private static void displaySequence(String sequence){
    System.out.println(sequence);
}
public static String displayStatistics(int length, int even, int odd, int largest){
    String nil = "";
    System.out.println("The largest number in the sequence was "+largest);
    System.out.println("The length of the sequence was "+length);
    System.out.println("There were "+odd+" odd numbers");
    System.out.println("There were "+even+" even numbers");
    return nil;
}

}

I need attempting to display the largest number in the sequence, the length of the sequence, how many even numbers there were in the sequence and how many odd numbers there were in the sequence. But since I cannot return an int value in the createSequence method, I cannot get the new values for each statistic. Preventing me from displaying said statistics. How would I access these new variables to be used in the final method?

Note:

Requirements:

Declare variables in main

Initialize variables in Initialize()

createSequence (Create the sequence)

displaySequence (Then display the sequence in a separate method)

finally displayStatistics i.e. length, evens, odds, largest (in its own method), this is the one that's troubling me


问:
Jenkins Maven how to fix wrong command
Learning Jenkins. Windows 7 running jenkins-2.73.3, a maven project gives following output:

20:29:11 [test] $ "C:\Program Files\Java\jdk1.8.0_102/bin/java" –Xmx1024m –XX:MaxPermSize=256m -cp "C:\Program Files (x86)\Jenkins\plugins\maven-plugin\WEB-INF\lib\maven33-agent-1.12-alpha-1.jar;C:\Apps\apache-maven-3.3.9\boot\plexus-classworlds-2.5.2.jar;C:\Apps\apache-maven-3.3.9/conf/logging" jenkins.maven3.agent.Maven33Main C:\Apps\apache-maven-3.3.9 "C:\Program Files (x86)\Jenkins\war\WEB-INF\lib\remoting-3.10.2.jar" "C:\Program Files (x86)\Jenkins\plugins\maven-plugin\WEB-INF\lib\maven33-interceptor-1.12-alpha-1.jar" "C:\Program Files (x86)\Jenkins\plugins\maven-plugin\WEB-INF\lib\maven3-interceptor-commons-1.12-alpha-1.jar" 50129
20:29:11 Error: Could not find or load main class –Xmx1024m
20:29:41 ERROR: Failed to launch Maven. Exit code = 1
20:29:41 Finished: FAILURE

The problem is obvious: java takes -Xmx1024m as the main class. But the command is generated, how can I move "-Xmx.. -XX:Max.." to the end of the command?

答: Removing "–Xmx1024m –XX:MaxPermSize=256m" from Maven Project Configuration / Global MAVEN_OPTS on Jenkins fixed the issue.</p>

Title: Jenkins Maven how to fix wrong command


问:
How to correctly install TFServing via docker container
I have tried to install TFServing in docker container several times.
However I still can't build it without any error.

I follow the installation steps on the official site. But I still meet compile error during building.
I doubt that if there is some flaw in dockerfile which I built.
I attach the screenshot of the error.

答:
I found a dockerfile on the net which meet my demand.
https://github.com/posutsai/DeepLearning_Docker/blob/master/Tensorflow-serving/Dockerfile-Tensorflow-serving-gpu</p>


问:
Return false within anchor tag gives error
I have the following statement

```<code><a href="javascript: return false;" id="addNew1">ADD NEW ROW</a>
</code>```

If I click on this I get the following error in my browser.

```<code>return not in function
</code>```

I use the following JQuery function

```<code>$('#addNew,#addNew1').click(function(){
</code>```

Do I need to include this in the function, the reason I do not add 'n # sign in is because the the page jumps to the top of the page.

答:
The href attribute should point to a real URL that will serve the same purpose as the JavaScript if the JavaScript should fail for any reason. Build on things that work.

The click handler should return false so the link isn't followed if the JavaScript doesn't fail (at which point the value of href doesn't matter).

ContentLicense: CC BY-SA 2.5

Body:
I have the following statement

ADD NEW ROW

If I click on this I get the following error in my browser.

return not in function

I use the following JQuery function

$('#addNew,#addNew1').click(function(){

Do I need to include this in the function, the reason I do not add 'n # sign in is because the the page jumps to the top of the page.


答:
This is not your only error, but it is probably the most easily overlooked:

```<code>if password = 1:
</code>```

What's going on here: 1 is getting stored to the variable password (Since = is the storing operator). Then if password is getting evaluated; variables are truthy in python, so that will evaluate to True, regardless of what you had stored in password above.

To remedy this, use == for comparing password, and also since password is a string, put the 1 in quotes so that it is compared as a string.

```<code>if password == "1":
</code>```

You need to fix your indentation as well, python is dependent on whitespace.

Title: How do i check if a user info is correct python

Body:
This is not your only error, but it is probably the most easily overlooked:

if password = 1:

What's going on here: 1 is getting stored to the variable password (Since = is the storing operator). Then if password is getting evaluated; variables are truthy in python, so that will evaluate to True, regardless of what you had stored in password above.

To remedy this, use == for comparing password, and also since password is a string, put the 1 in quotes so that it is compared as a string.

if password == "1":

You need to fix your indentation as well, python is dependent on whitespace.


问:
Why function if/else not work in Datatables CI (use Ignited)
I get this library datatbles on git hub, this is ignited datatbles.

Ok, i've code in my Controller,

```<code>function json_survey(){
        header('Content-Type: application/json');
        $this->load->library('Datatables');
        $this->load->helper('datatables_helper');
        $this->datatables->SELECT('id_survey,judul_survey,status_survey,responden,detail_target,judul_kategori,judul_target');
        $dataids = array('id_survey'=> '$1','status_survey'=> '$2');
        $this->datatables->add_column('action',tombol_survey($dataids), 'id_survey,status_survey');
        $this->datatables->FROM('survey');
        $this->datatables->JOIN('kategori','survey.id_kategori=kategori.id_kategori');
        $this->datatables->JOIN('target','survey.id_target=target.id_target');

        return print_r($this->datatables->generate('json',''));
    }
</code>```

And i have code in muy Helper to create button with function if/else

```<code>function tombol_survey($ids)
    {
        $ci = & get_instance();
        if(!empty($ids)){
            $html = '<span class="actions">';
            if($ids['status_survey']=='terbit'){
                $html .= '<a href="' . base_url() . 'survey/edit/'.$ids['id_survey'].'">Tutup</a>';
            }
            if($ids['status_survey']=='tertunda'){
                $html .= '<a href="' . base_url() . 'pertanyaan/tambah/'.$ids['id_survey'].'">Tambah</a>';
            }
            if($ids['status_survey']=='tutup'){
                $html .= 'Hapus | ';
            }
            $html .= '<a href="' . base_url() . 'pertanyaan/tambah/' .$ids['id_survey']. '">Test</a>';
            $html .= '</span>';

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

my problem, function if not work but 2 parameter (id_survey & status_survey) was inclued.
Please help me sir

Look my picture

答:
Hello @Muhammad Rizki,

You have to check ids format first how it will come in function. You have to use json_decode to convert JSON data into array. then you can access values using $ids['status_survey'].

example :

```<code>$ids = json_decode($ids);
</code>```

Thanks

Body:
I get this library datatbles on git hub, this is ignited datatbles.

Ok, i've code in my Controller,

function json_survey(){
        header('Content-Type: application/json');
        $this->load->library('Datatables');
        $this->load->helper('datatables_helper');
        $this->datatables->SELECT('id_survey,judul_survey,status_survey,responden,detail_target,judul_kategori,judul_target');
        $dataids = array('id_survey'=> '$1','status_survey'=> '$2');
        $this->datatables->add_column('action',tombol_survey($dataids), 'id_survey,status_survey');
        $this->datatables->FROM('survey');
        $this->datatables->JOIN('kategori','survey.id_kategori=kategori.id_kategori');
        $this->datatables->JOIN('target','survey.id_target=target.id_target');

        return print_r($this->datatables->generate('json',''));
    }

And i have code in muy Helper to create button with function if/else

function tombol_survey($ids)
    {
        $ci = & get_instance();
        if(!empty($ids)){
            $html = '';
            if($ids['status_survey']=='terbit'){
                $html .= 'Tutup';
            }
            if($ids['status_survey']=='tertunda'){
                $html .= 'Tambah';
            }
            if($ids['status_survey']=='tutup'){
                $html .= 'Hapus | ';
            }
            $html .= 'Test';
            $html .= '';

            return $html;
        }
    }

my problem, function if not work but 2 parameter (id_survey & status_survey) was inclued.
Please help me sir

Look my picture

Body:
Hello @Muhammad Rizki,

You have to check ids format first how it will come in function. You have to use json_decode to convert JSON data into array. then you can access values using $ids['status_survey'].

example :

$ids = json_decode($ids);

Thanks


答:
So I've re-wrote your code. You're forgetting to indent your if-statements. http://www.secnetix.de/olli/Python/block_indentation.hawk</p>

```<code>import sys    # Import the 'sys' module

print('What is your name?')

name = sys.stdin.readline()

print('Hello ', name, '. Enter password.')
password = sys.stdin.readline()

# Use '=='
if password == 1:
    print("Welcome home, ", name)
    # Here you need indentation.
else:
    print("Password: ", password," is incorect. Please try again.")
</code>```

Body:
So I've re-wrote your code. You're forgetting to indent your if-statements. http://www.secnetix.de/olli/Python/block_indentation.hawk

import sys    # Import the 'sys' module

print('What is your name?')

name = sys.stdin.readline()

print('Hello ', name, '. Enter password.')
password = sys.stdin.readline()

# Use '=='
if password == 1:
    print("Welcome home, ", name)
    # Here you need indentation.
else:
    print("Password: ", password," is incorect. Please try again.")


问:
What exactly is a reference variable in Java? How does it differ from other variables?
I have been studying Inheritance in Java and the writer makes the statement "it is the type of object being referred to (not the type of reference variable) that determines which version of an overridden method will be executed."
This statement is awfully confusing.</p>

答:
What the book is referring to is polymorphism, more specifically through dynamic dispatch.

In a nutshell, imagine the following classes:

```<code>public class Person {

    public Person() {
    }

    public void introduceYourself() {
    }

}

public class Texan extends Person {

    public Texan() {
    }

    public void introduceYourself() {
        System.out.printLn("Howdy y'all!");
    }

}

public class NewYorker extends Person {

    public NewYorker() {
    }

    public void introduceYourself() {
        System.out.printLn("Yo. You got a problem with that?");
    }

}
</code>```

Now, let's create a reference variable of type Person.

```<code>Person myBFF;
</code>```

Let's instantiate him

```<code>myBFF = new NewYorker();
</code>```

Let's ask him to introduce himself

```<code>myBFF.introduceYourself();
</code>```

This prints:

Yo. You got a problem with that?

Now, let's change your BFF to a Texan.

```<code>myBFF = new Texan();
</code>```

Let's call that same line again and ask our BFF to introduce himself.

```<code>myBFF.introduceYourself();
</code>```

This prints:

Howdy y'all!

In each case, the reference variable you were using was of type Person. The instance of the variable, in each case, was NewYorker and Texan respectively. That instance type determines which verson of introduceYourself() is called.

Body:
What the book is referring to is polymorphism, more specifically through dynamic dispatch.

In a nutshell, imagine the following classes:

public class Person {

    public Person() {
    }

    public void introduceYourself() {
    }

}

public class Texan extends Person {

    public Texan() {
    }

    public void introduceYourself() {
        System.out.printLn("Howdy y'all!");
    }

}

public class NewYorker extends Person {

    public NewYorker() {
    }

    public void introduceYourself() {
        System.out.printLn("Yo. You got a problem with that?");
    }

}

Now, let's create a reference variable of type Person.

Person myBFF;

Let's instantiate him

myBFF = new NewYorker();

Let's ask him to introduce himself

myBFF.introduceYourself();

This prints:

Yo. You got a problem with that?

Now, let's change your BFF to a Texan.

myBFF = new Texan();

Let's call that same line again and ask our BFF to introduce himself.

myBFF.introduceYourself();

This prints:

Howdy y'all!

In each case, the reference variable you were using was of type Person. The instance of the variable, in each case, was NewYorker and Texan respectively. That instance type determines which verson of introduceYourself() is called.


问:
Hide a report item from print / export of an rdlc report
I have an RDLC with multiple tables and for each table, I have a toggle TextBox Item that hides the corresponding table from the report. It works perfectly, however, I don't want these text boxes to be visible in the printed/exported reports. They are really meant for disabling content in the report and not as content themselves. Is there a way to hide those toggle boxes from only Print Layout and exported versions of the report?

I looked at all of the properties of the report textbox and at the available expressions that I can use to toggle visibility, but I didn't find anything that I can use to hide the item. There is a DataElementOutput property that seems to be what I want, but I believe that it is only useful for XML.

答:
This can be achieved using a simple visibility toggle. You can use the RenderFormat.IsInteractive variable to determine whether a report is shown in report viewer or is being exported. An MSDN article explains this about this global variable,

Furthermore, a Boolean flag (=Globals!RenderFormat.IsInteractive)
  determines whether a rendering extension is an interactive renderer,
  i.e. not an export format. Preview (GDI/Winforms) and HTML viewing are
  considered interactive renderers.

Set the visibility of the text box you want to hide in the export to the following expression

=NOT(Globals!RenderFormat.IsInteractive)
```

Refer to the following image (courtesy of blog.hoegaerden.be) to know the values assigned to RenderFormat.IsInteractive

Body:
This can be achieved using a simple visibility toggle. You can use the RenderFormat.IsInteractive variable to determine whether a report is shown in report viewer or is being exported. An MSDN article explains this about this global variable,

Furthermore, a Boolean flag (=Globals!RenderFormat.IsInteractive)
  determines whether a rendering extension is an interactive renderer,
  i.e. not an export format. Preview (GDI/Winforms) and HTML viewing are
  considered interactive renderers.

Set the visibility of the text box you want to hide in the export to the following expression

=NOT(Globals!RenderFormat.IsInteractive)

Refer to the following image (courtesy of blog.hoegaerden.be) to know the values assigned to RenderFormat.IsInteractive


问:
Installing APK from email attachment

Whenever i send a .apk file via email as an attachment and then open the .apk-file in my phone from my email-account, i get a parsing error.

However if i put the .apk on my website and provide a URL to it, it works like a charm.

A bug? Just me? Am i doing it wrong?

Thanks

答:
I can install apps received from in my gmail account.  My exchange and pop mail accounts will not allow it.

FYI - If you have Astro File Browser make sure the 'Enable Browser Download' option is disabled.  It is a handy feature to allow download of any file type, but it interferes with gmail attachments.

Title: Installing APK from email attachment


问:
jquery If statement based on a previous element
I want to hide an element if the previous element has a number less than 0.

https://jsfiddle.net/82bysjag/2/

$(document).on("click", function() {
  $(".hide").each(function() {
    var prevqty = $(".hide").prev().text();

    if (prevqty < 0) {
      $(this).hide();
    } else {}
  });
});```
<pre class="snippet-code-css lang-css prettyprint-override"><code>div {
  display: inline-block;
}</code>```

  -2

  Hide

  1

  Hide

```

Is there an error with my var prevqty?

答:
Use $(this) and parseInt to

$(".hide").each(function() {
  var prevqty = parseInt($(this).prev().text(), 10);
  if (prevqty < 0) {
    $(this).hide();
  } else {}
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div>-2</div>
<div class="hide">Hide</div></code>```

Body:
I want to hide an element if the previous element has a number less than 0.

https://jsfiddle.net/82bysjag/2/

$(document).on("click", function() {
  $(".hide").each(function() {
    var prevqty = $(".hide").prev().text();

    if (prevqty < 0) {
      $(this).hide();
    } else {}
  });
});

div {
  display: inline-block;
}

  -2

  Hide

  1

  Hide

Is there an error with my var prevqty?

Body:
Use $(this) and parseInt to

$(".hide").each(function() {
  var prevqty = parseInt($(this).prev().text(), 10);
  if (prevqty < 0) {
    $(this).hide();
  } else {}
});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div>-2</div>
<div class="hide">Hide</div>


问:
Auto deducing a type template argument from a dependent non-type template argument
I defined a class template X like this:

```<code>template <typename T>
using Func = void(T);

template <typename T, Func<T> F>
class X { ... };
</code>```

Now I can use class X like this:

```<code>void func(int i);

X<int, &func> x;
</code>```

It seems redundant to me to repeat the type int in the declaration of x. Is there a way this can be auto deduced? I mean I want to have a type template Y which can be used via Y<&func> and equals X<int, &func> with auto deduced int.

I tried a lot, even defining crazy templated functions and using decltype, but it seems there is no way to drop the T before naming of &func.

Update: It seems to be a restriction that I am using MSVC 2017.5 which prevents me from using auto in template parameter lists as suggested by Kerrek. I wonder if there is some "hack" to get the same effect without this feature.

答:
Sure, use auto and specialize partially:

```<code>template <auto F> struct X;

template <typename T, void (*F)(T)> struct X<F>
{
    // ...
};
</code>```

Usage:

```<code>void f(int);

X<f> x;   // deduces T = int, F = f in the partial specialization
</code>```

Body:
I defined a class template X like this:

template <typename T>
using Func = void(T);

template <typename T, Func<T> F>
class X { ... };

Now I can use class X like this:

void func(int i);

X<int, &func> x;

It seems redundant to me to repeat the type int in the declaration of x. Is there a way this can be auto deduced? I mean I want to have a type template Y which can be used via Y<&func> and equals X<int, &func> with auto deduced int.

I tried a lot, even defining crazy templated functions and using decltype, but it seems there is no way to drop the T before naming of &func.

Update: It seems to be a restriction that I am using MSVC 2017.5 which prevents me from using auto in template parameter lists as suggested by Kerrek. I wonder if there is some "hack" to get the same effect without this feature.

Body:
Sure, use auto and specialize partially:

template <auto F> struct X;

template <typename T, void (*F)(T)> struct X<F>
{
    // ...
};

Usage:

void f(int);

X<f> x;   // deduces T = int, F = f in the partial specialization


问:
Count from column in a table by referencing a column in another table
I wasn't really sure what to title this but this is what I'm trying to do:

I have a table of teams:

```<code>teamid | city | name
</code>```

and I have a table of games played:

```<code>gameid | teamid | points
</code>```

What I'm trying to do is tally the total points scored in all games played by the 'Raptors'.

I've tried it this way:

```<code>SELECT COUNT(points) AS "Raptors Points" FROM TEAMS, GAMES
    WHERE name = 'Raptors' AND TEAMS.teamid = GAMES.teamid;
</code>```

and this way:

```<code>SELECT COUNT(points) AS "Raptors Points" FROM (SELECT * FROM
    TEAMS JOIN GAMES ON TEAMS.teamid = GAMES.teamid WHERE
    name = 'Raptors') AS foo;
</code>```

Both result in a table displaying only points from one of the games (the first one) instead of a total count from all games.

I'm really stumped as to what I'm doing wrong. Any suggestions?

Thanks

答:
Most likely you are seeing the wrong value and thinking it's a proper value.  You need to change COUNT(points) with SUM(points)

Count will give you the total number of records, SUM will give you the total number of points

BTW your first query should work if you fix that

Body:
I wasn't really sure what to title this but this is what I'm trying to do:

I have a table of teams:

teamid | city | name

and I have a table of games played:

gameid | teamid | points

What I'm trying to do is tally the total points scored in all games played by the 'Raptors'.

I've tried it this way:

SELECT COUNT(points) AS "Raptors Points" FROM TEAMS, GAMES
    WHERE name = 'Raptors' AND TEAMS.teamid = GAMES.teamid;

and this way:

SELECT COUNT(points) AS "Raptors Points" FROM (SELECT * FROM
    TEAMS JOIN GAMES ON TEAMS.teamid = GAMES.teamid WHERE
    name = 'Raptors') AS foo;

Both result in a table displaying only points from one of the games (the first one) instead of a total count from all games.

I'm really stumped as to what I'm doing wrong. Any suggestions?

Thanks


问:
Unit tests with RSpec on the Ruby: "No test report files were found. Configuration error?"
I need to run unit tests with RSpec on the Ruby project that runs on Jenkins.

At this moment there is no code in the project, it's just a vanilla project. So I add a dummy test:

test_example.rb:

```<code>describe Hash do
  it "should return a blank instance" do
Hash.new.should == {}
  end
end
</code>```

My Gemfile:

```<code>source 'https://rubygems.org'
git_source(:github) do |repo_name|
  repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
  "https://github.com/#{repo_name}.git"
end

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.1.4'
# Use postgres as the database for Active Record
gem 'pg'
# Use Puma as the app server
gem 'puma', '~> 3.7'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# Turbolinks makes navigating your web application faster.
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

group :development, :test do
 # Call 'byebug' anywhere in the code to stop execution and get a debugger console
 gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
 # Adds support for Capybara system testing and selenium driver
 gem 'capybara', '~> 2.13'
 gem 'selenium-webdriver'
  # Adds support for RSpec - <<<<<<<<<<<<<<<<<<<<<<<<<<< HERE IS MY CHANGES
  gem 'rspec-rails', '~> 3.7.1'
end

group :development do
  # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
  gem 'web-console', '>= 3.3.0'
  gem 'listen', '>= 3.0.5', '< 3.2'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
</code>```

And add the link on new test file in the Rakefile:

```<code>require_relative 'config/application'
Rails.application.load_tasks

require 'rake/testtask'

Rake::TestTask.new do |t|
  t.libs << "test"
  t.test_files = FileList['test/test_example.rb']
  t.verbose = true
end
</code>```

Of course, I add the test step in my Jenkinsfile:

```<code>stage("test") {
            junit keepLongStdio: true, testResults: 'rspec/reports/**/*.xml'
       }
</code>```

But when I run the build, I see this error:

What am I doing wrong?

I'm sorry I'm a little bit confused that I have so many steps and the problem can be everywhere... I don't know where should I search

答: You're using ruby's test-unit testing framework for that example test, yet you're using the ci_reporter_rspec gem to generate test report xmls. rspec and test-unit are not compatible testing frameworks, and the gem you've chosen will not generate test report xmls for test-unit. You either need to write rspec tests or use the ci_reporter gem.</p>

Body:
I need to run unit tests with RSpec on the Ruby project that runs on Jenkins.

At this moment there is no code in the project, it's just a vanilla project. So I add a dummy test:

test_example.rb:

describe Hash do
  it "should return a blank instance" do
Hash.new.should == {}
  end
end

My Gemfile:

source 'https://rubygems.org'
git_source(:github) do |repo_name|
  repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
  "https://github.com/#{repo_name}.git"
end

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.1.4'
# Use postgres as the database for Active Record
gem 'pg'
# Use Puma as the app server
gem 'puma', '~> 3.7'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# Turbolinks makes navigating your web application faster.
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

group :development, :test do
 # Call 'byebug' anywhere in the code to stop execution and get a debugger console
 gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
 # Adds support for Capybara system testing and selenium driver
 gem 'capybara', '~> 2.13'
 gem 'selenium-webdriver'
  # Adds support for RSpec - <<<<<<<<<<<<<<<<<<<<<<<<<<< HERE IS MY CHANGES
  gem 'rspec-rails', '~> 3.7.1'
end

group :development do
  # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
  gem 'web-console', '>= 3.3.0'
  gem 'listen', '>= 3.0.5', '< 3.2'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

And add the link on new test file in the Rakefile:

require_relative 'config/application'
Rails.application.load_tasks

require 'rake/testtask'

Rake::TestTask.new do |t|
  t.libs << "test"
  t.test_files = FileList['test/test_example.rb']
  t.verbose = true
end

Of course, I add the test step in my Jenkinsfile:

stage("test") {
            junit keepLongStdio: true, testResults: 'rspec/reports/**/*.xml'
       }

But when I run the build, I see this error:

What am I doing wrong?

I'm sorry I'm a little bit confused that I have so many steps and the problem can be everywhere... I don't know where should I search


答:
The problem is from prevqty. JavaScript is seing it as a string. Convert it to number first as follows;

```<code> var prevqty = $(".hide").prev().text();
 prevqty =Number(prevqty );
</code>```

Then you can compare

Title: jquery If statement based on a previous element

Body:
The problem is from prevqty. JavaScript is seing it as a string. Convert it to number first as follows;

 var prevqty = $(".hide").prev().text();
 prevqty =Number(prevqty );

Then you can compare


问:
Most suitable buffer texture format for bool data storage?
I have seen some examples simply using the R8Uint format for bool data usage. But is there any other solution that's storage-saving?

答:
Well, the smallest format is 1 byte.

Stating the obvious: Depending on your situation you could pack 8 bits (Booleans) into that byte.


问:
How to fix shifting text in select box while zooming in IE?
when selecting item in drop down list then zooming in IE selected text hiding below select input area or shifting down. How to fix it?</p>

答: Could we see some of your HTML and CSS that is relevant to the question please? Might just be a problem with font-size being declared in px instead of em, or it could be something else entirely. No way to know without some code to look at.</p>


问:
Is there a method to limit/clamp a number?
I wrote the following code, which keeps x within the range (a..b). In pseudo code:

```<code>(if x < a, x = a; if x > b, x = b)
</code>```

In Ruby it would be something like:

```<code>x = [a, [x, b].min].max
</code>```

As it is quite basic and useful function, I was wondering if there is a native method to do that in ruby.

As of Ruby 2.3.3 there is apparently no method like this, what would be the shortest/more readable way to do it?

I found:

```<code>x = [a, x, b].sort[1]
</code>```

so far, but I'm not sure if it is more readable.

答:
Here is my solution which borrows heavily from the actual implementation:</p>

```<code>unless Comparable.method_defined? :clamp
  module Comparable
    def clamp min, max
      if max-min<0
        raise ArgumentError, 'min argument must be smaller than max argument'
      end
      self>max ? max : self<min ? min : self
    end
  end
end
</code>```

Body:
I wrote the following code, which keeps x within the range (a..b). In pseudo code:

(if x  b, x = b)

In Ruby it would be something like:

x = [a, [x, b].min].max

As it is quite basic and useful function, I was wondering if there is a native method to do that in ruby.

As of Ruby 2.3.3 there is apparently no method like this, what would be the shortest/more readable way to do it?

I found:

x = [a, x, b].sort[1]

so far, but I'm not sure if it is more readable.

Body:
Here is my solution which borrows heavily from the actual implementation:

unless Comparable.method_defined? :clamp
  module Comparable
    def clamp min, max
      if max-min<0
        raise ArgumentError, 'min argument must be smaller than max argument'
      end
      self>max ? max : self<min ? min : self
    end
  end
end


问:
Gnuplot : Format yaxis in terms of 10^x
I have the following data:
N Computed Value of pi

```<code> y, x
1, 8.0
10, 3.6
100, 3.36
1000, 3.212
10000, 3.152
100000, 3.14316
1000000, 3.14266
10000000, 3.1420448
100000000, 3.14190876
1000000000, 3.141573084
</code>```

And I am trying format y axis in terms of 10^x

I used the following code:

```<code>set terminal pngcairo size 1280,800 enhanced font 'Helvetica,24'
set output "fig.png"

# Title, axis label, range and ticks
set title "Simulations"
set xlabel "Number of Iterations(n)"
set ylabel "Computed  values"

# Legend location and grid

set key top left
set grid
set ytics out nomirror
set xtics out nomirror
set format y "10^{%L}"

# Plot the data
plot data.dat" using 2:1 title "" with linesp lw 2 pt 7 ps 1.5
</code>```

But i am getting the following output:

Please help

Thanks

答:
I had to guess what you really want because there were some inconsistencies. Here is what I believe brings you where you want, changes commented in the source file.

```<code># Title, axis label, range and ticks
set title "Simulations"
set xlabel "Number of Iterations(n)"
set ylabel "Computed  values"

# Legend location and grid

set datafile separator comma  # gnuplot looks for spaces
                              # you must tell it about the comma
unset key                     # same as title "" as you have in your plot command
set grid
set ytics out nomirror
set xtics out nomirror
set logscale x                # I guess that's what you want and how it should be
set format x "10^{%L}"        # yr x axis is labeled iterations, so I guess
                              # that's what you want

# Plot the data
plot [][2:10] "data.dat" using 1:2 with linesp lw 2 pt 7 ps 1.5
    # swapped 2:1 so that the iterations are on the x axis
    # introduced a range for y so that it is better to see
    # 'title ""' removed, see 'unset key'
</code>```

This gives you

May not be exactly what you want but should move you to the next level I hope.

Title: Gnuplot : Format yaxis in terms of 10^x

Body:
I have the following data:
N Computed Value of pi

 y, x
1, 8.0
10, 3.6
100, 3.36
1000, 3.212
10000, 3.152
100000, 3.14316
1000000, 3.14266
10000000, 3.1420448
100000000, 3.14190876
1000000000, 3.141573084

And I am trying format y axis in terms of 10^x

I used the following code:

set terminal pngcairo size 1280,800 enhanced font 'Helvetica,24'
set output "fig.png"

# Title, axis label, range and ticks
set title "Simulations"
set xlabel "Number of Iterations(n)"
set ylabel "Computed  values"

# Legend location and grid

set key top left
set grid
set ytics out nomirror
set xtics out nomirror
set format y "10^{%L}"

# Plot the data
plot data.dat" using 2:1 title "" with linesp lw 2 pt 7 ps 1.5

But i am getting the following output:

Please help

Thanks

Body:
I had to guess what you really want because there were some inconsistencies. Here is what I believe brings you where you want, changes commented in the source file.

# Title, axis label, range and ticks
set title "Simulations"
set xlabel "Number of Iterations(n)"
set ylabel "Computed  values"

# Legend location and grid

set datafile separator comma  # gnuplot looks for spaces
                              # you must tell it about the comma
unset key                     # same as title "" as you have in your plot command
set grid
set ytics out nomirror
set xtics out nomirror
set logscale x                # I guess that's what you want and how it should be
set format x "10^{%L}"        # yr x axis is labeled iterations, so I guess
                              # that's what you want

# Plot the data
plot [][2:10] "data.dat" using 1:2 with linesp lw 2 pt 7 ps 1.5
    # swapped 2:1 so that the iterations are on the x axis
    # introduced a range for y so that it is better to see
    # 'title ""' removed, see 'unset key'

This gives you

May not be exactly what you want but should move you to the next level I hope.


问:
PHP echo MYSQL Value to URL
I'm attempting to carry the value of a cell to the end of my URL so that I delete the targeted row from a MYSQL table respectively. However, the value in $row['waybill_ID'] does not carry as expected. What can I do to remedy this? I understand that this is slightly drawn out, but I am doing this a part of a 'are you sure' prompt.

```<code><html>
<body>

<div id="myNav" class="overlay">
<a href="javascript:void(0)" class="closebtn" onclick="closeNav()">×
</a>
<div class="overlay-content">
<h2 style="color: white">Are you sure you want to delete this record?</h2>
<h2 style="color: white">This record will no longer exist after
deletion</h2>
<a id="deletePrompt" href="#" target="blank">Delete Record</a>
</div>
</div>

<div class="midA">
    <div class='wrapper'>
        <button class="accordion">Unit(s) and Driver(s)</button>
        <div class="panel">
            <div class='buffer'>
        <?php

        //Unitboard Display
        $issue_ID = $_GET['idx'];
        $mysqli = new mysqli('localhost', 'root', '', 'disolDemo');
        $query = $mysqli->query("SELECT * FROM unitboard WHERE issue_ID = '$issue_ID'") or die($msqli->error);
                    echo"
        <table border= 1px solid white>
        <tr>
            <th>Action</th>
            <th>Waybill_ID</th>
            <th>Driver</th>
            <th>Unit Type</th>
            <th>Move Type</th>
            <th>Route ID</th>
            <th>Tractor Number</th>
            <th>Trailer Number</th>
            <th>Waybill Status</th>
        </tr>
        <tr>";?><?php
        while($row = mysqli_fetch_assoc($query)){?>
        <td>
            <a href="#" onclick="window.open( 'editUnitBoard.php?idx=<?php echo $row['waybill_ID'] ?>', 'name', 'location=no,scrollbars=yes,status=no,toolbar=no,resizable=no' )">edit</a>
            <a href="#" onclick="openNav()">delete</a>
        </td>
         <?php echo"
            <td>{$row['waybill_ID']}</td>
            <td>{$row['driver']}</td>
            <td>{$row['unitType']}</td>
            <td>{$row['moveType']}</td>
            <td>{$row['location_ID']}</td>
            <td>{$row['tractorNum']}</td>
            <td>{$row['trailerNum']}</td>
            <td>{$row['waybillStatus']}</td>
        </tr>";
        }
        echo'<table></table>';

        ?>

            <button style="margin-top: 15px; float: right" class='button' type="button" a href="#" onclick="window.open( 'formNewUnit.php?idx=<?php echo $_GET['idx'] ?>', 'name', 'location=no,scrollbars=yes,status=no,toolbar=no,resizable=no' )">Create New Unit</button>

            <a href="viewRun.php?idx=<?php echo $_GET['idx'] ?>" target="_blank">view</a>

            <div style="clear: both;"></div>
            </div>
        </div>
    </div>
</div>

<script>
function openNav() {
document.getElementById("myNav").style.width = "100%";
document.getElementById("deletePrompt").href="editUnitBoard.php?idx=<?php
echo $row['waybill_ID']; ?>";
return false;
}

function closeNav() {
document.getElementById("myNav").style.width = "0%";
}
</script>

</body>
</html>
</code>```

The result is   editUnitBoard.php?idx=   but    I need something link editUnitBoard.php?id=1234    for example

答:
The code below is what I've been looking for. Thank you all for your time!</p>

```<code>        $testro = $row['driver'];
        $mysqli2 = new mysqli('localhost', 'root', '', 'disolDemo');
        $query2 = " SELECT
            unitboard.driver,
            unitboard.officeLocation,
            trackingboard.issue_ID,
            unitboard.waybill_ID,
            unitboard.arrivalDateTimeDest,
            unitboard.unitType,
            unitboard.totalMiles,
            unitboard.waybillStatus,
            unitboard.moveType,
            trackingboard.customer

        FROM trackingboard INNER JOIN unitboard ON trackingboard.issue_ID = unitboard.issue_ID WHERE driver = '$testro'";
</code>```

Title: PHP echo MYSQL Value to URL

Body:
I'm attempting to carry the value of a cell to the end of my URL so that I delete the targeted row from a MYSQL table respectively. However, the value in $row['waybill_ID'] does not carry as expected. What can I do to remedy this? I understand that this is slightly drawn out, but I am doing this a part of a 'are you sure' prompt.

×

Are you sure you want to delete this record?

This record will no longer exist after
deletion

Delete Record

        <button class="accordion">Unit(s) and Driver(s)</button>

        <?php

        //Unitboard Display
        $issue_ID = $_GET['idx'];
        $mysqli = new mysqli('localhost', 'root', '', 'disolDemo');
        $query = $mysqli->query("SELECT * FROM unitboard WHERE issue_ID = '$issue_ID'") or die($msqli->error);
                    echo"

            Action
            Waybill_ID
            Driver
            Unit Type
            Move Type
            Route ID
            Tractor Number
            Trailer Number
            Waybill Status

";?><?php
        while($row = mysqli_fetch_assoc($query)){?>

            <a href="#" onclick="window.open( 'editUnitBoard.php?idx=<?php echo $row['waybill_ID'] ?>', 'name', 'location=no,scrollbars=yes,status=no,toolbar=no,resizable=no' )">edit
            delete

         <?php echo"
            {$row['waybill_ID']}
            {$row['driver']}
            {$row['unitType']}
            {$row['moveType']}
            {$row['location_ID']}
            {$row['tractorNum']}
            {$row['trailerNum']}
            {$row['waybillStatus']}

";
        }
        echo'

';

        ?>

            <button style="margin-top: 15px; float: right" class='button' type="button" a href="#" onclick="window.open( 'formNewUnit.php?idx=<?php echo $_GET['idx'] ?>', 'name', 'location=no,scrollbars=yes,status=no,toolbar=no,resizable=no' )">Create New Unit</button>

            <a href="viewRun.php?idx=<?php echo $_GET['idx'] ?>" target="_blank">view

The result is   editUnitBoard.php?idx=   but    I need something link editUnitBoard.php?id=1234    for example

Body:
The code below is what I've been looking for. Thank you all for your time!

        $testro = $row['driver'];
        $mysqli2 = new mysqli('localhost', 'root', '', 'disolDemo');
        $query2 = " SELECT
            unitboard.driver,
            unitboard.officeLocation,
            trackingboard.issue_ID,
            unitboard.waybill_ID,
            unitboard.arrivalDateTimeDest,
            unitboard.unitType,
            unitboard.totalMiles,
            unitboard.waybillStatus,
            unitboard.moveType,
            trackingboard.customer

        FROM trackingboard INNER JOIN unitboard ON trackingboard.issue_ID = unitboard.issue_ID WHERE driver = '$testro'";


问:
How do I remove the footer in MediaWiki?
I am trying to remove the footer in my MediaWiki installation

"This page was last modified..."

Number of views

Privacy policy link

MediaWiki image

I am using the Vector theme.

The instructions on the MediaWiki site don't seem to match the Vector theme, which appears to be the default one.

I can't find any of the $wg elements mentioned on the MediaWiki site (such as $wgHooks and $wgMaxCredits) in the Vector theme itself. So how can I modify the theme to remove the footer elements?

Any help or advice would be much appreciated. I am sure I am missing some part of the MediaWiki site, but can't seem to find it.

答:
You can use CSS to remove the footer for any theme or skin:  there is a common CSS file built into the MediaWiki database behind each wiki:

```<code>http://<your-site>/wiki/index.php/MediaWiki:Common.css
</code>```

Enter that link in your browser to go that page.  Then click the "Edit" link to edit that page and add this line to the page:

```<code>#footer { display: none; }
</code>```

NOTE:  You may not want to remove the entire footer.  You can remove individual components by entering them in the WikiMedia:Common.css instead:

```<code>/* last modification stuff */
#footer-info { display: none; }

/* footer links */
#footer-places { display: none; }

/* powered by icon */
#footer-icon { display: none; }
</code>```

Personally, I would keep the footer-icon which contains the Powered by MediaWiki icon, and give credit where it is due.

If you are working with the MobileFrontend extension then you will also need to add the same lines to:

```<code>http://<your-site>/wiki/index.php/MediaWiki:Mobile.css
</code>```

Do you want to remove the WikiMedia footer or just change it?

I can see wanting to remove parts of the default footer like the last modification string.  You can use CSS to hide it as I mentioned above or you can enter this URL into your browser:

```<code>http://<your-site>/wiki/index.php/MediaWiki:Lastmodifiedat
</code>```

Edit that page and remove the line that's there, then save the page.  The last modification stuff will disappear from your wiki pages.

But the footer links section can be very useful.  If you want to CHANGE the footer links, there is a hook (SkinTemplateOutputPageBeforeExec) provided in the MediaWiki docs:

https://www.mediawiki.org/wiki/Manual%3AFooter#Add_links_to_the_footer

If you want to REMOVE the existing footer links and ADD YOUR OWN new footer links, follow the instructions in the embedded comments and then add this PHP code to your LocalSettings.php file:

```<code># Remove all existing footer links and add my own
$wgHooks['SkinTemplateOutputPageBeforeExec'][] = function( $sk, &$tpl ) {

        # IMPORTANT:  this is the secret sauce - remove all existing footer links
        $tpl->data['footerlinks']['places'] = array();

        # To add new footer links to local wiki pages:
        #
        # 1) You MUST create your new pages in your (Main) namespace first, for example:
        #
        #       http://<your-site>/wiki/index.php/About_Us
        #       http://<your-site>/wiki/index.php/Contact_Us
        #       http://<your-site>/wiki/index.php/Disclaimer
        #       http://<your-site>/wiki/index.php/Download
        #       http://<your-site>/wiki/index.php/Privacy_Policy
        #
        # 2) You MUST then create each of these pages in your MediaWiki namespace:
        #
        #       http://<your-site>/wiki/index.php/MediaWiki:Aboutpage
        #               - Insert 1 line, with "About Us" (no quotes)
        #       http://<your-site>/wiki/index.php/MediaWiki:Contactpage
        #               - Insert 1 line, with "Contact Us" (no quotes)
        #       http://<your-site>/wiki/index.php/MediaWiki:Disclaimerpage
        #               - Insert 1 line, with "Disclaimer" (no quotes)
        #       http://<your-site>/wiki/index.php/MediaWiki:Downloadpage
        #               - Insert 1 line, with "Download" (no quotes)
        #       http://<your-site>/wiki/index.php/MediaWiki:Privacypage
        #               - Insert 1 line, with "Privacy Policy" (no quotes)
        #
        # 3) Add new footer links like this:

        $tpl->set( 'aboutpage', $sk->footerLink( 'aboutpage', 'aboutpage' ) );
        $tpl->data['footerlinks']['places'][] = 'aboutpage';
        $tpl->set( 'contactpage', $sk->footerLink( 'contactpage', 'contactpage' ) );
        $tpl->data['footerlinks']['places'][] = 'contactpage';
        $tpl->set( 'disclaimerpage', $sk->footerLink( 'disclaimerpage', 'disclaimerpage' ) );
        $tpl->data['footerlinks']['places'][] = 'disclaimerpage';
        $tpl->set( 'downloadpage', $sk->footerLink( 'downloadpage', 'downloadpage' ) );
        $tpl->data['footerlinks']['places'][] = 'downloadpage';
        $tpl->set( 'privacypage', $sk->footerLink( 'privacypage', 'privacypage' ) );
        $tpl->data['footerlinks']['places'][] = 'privacypage';

        return true;
};
</code>```

IMPORTANT: Don't forget to follow the instructions and create your own pages and the corresponding MediaWiki redirects, or your links may not show or they may be broken.

Body:
You can use CSS to remove the footer for any theme or skin:  there is a common CSS file built into the MediaWiki database behind each wiki:

http://<your-site>/wiki/index.php/MediaWiki:Common.css

Enter that link in your browser to go that page.  Then click the "Edit" link to edit that page and add this line to the page:

#footer { display: none; }

NOTE:  You may not want to remove the entire footer.  You can remove individual components by entering them in the WikiMedia:Common.css instead:

/* last modification stuff */
#footer-info { display: none; }

/* footer links */
#footer-places { display: none; }

/* powered by icon */
#footer-icon { display: none; }

Personally, I would keep the footer-icon which contains the Powered by MediaWiki icon, and give credit where it is due.

If you are working with the MobileFrontend extension then you will also need to add the same lines to:

http://<your-site>/wiki/index.php/MediaWiki:Mobile.css

Do you want to remove the WikiMedia footer or just change it?

I can see wanting to remove parts of the default footer like the last modification string.  You can use CSS to hide it as I mentioned above or you can enter this URL into your browser:

http://<your-site>/wiki/index.php/MediaWiki:Lastmodifiedat

Edit that page and remove the line that's there, then save the page.  The last modification stuff will disappear from your wiki pages.

But the footer links section can be very useful.  If you want to CHANGE the footer links, there is a hook (SkinTemplateOutputPageBeforeExec) provided in the MediaWiki docs:

https://www.mediawiki.org/wiki/Manual%3AFooter#Add_links_to_the_footer

If you want to REMOVE the existing footer links and ADD YOUR OWN new footer links, follow the instructions in the embedded comments and then add this PHP code to your LocalSettings.php file:

# Remove all existing footer links and add my own
$wgHooks['SkinTemplateOutputPageBeforeExec'][] = function( $sk, &$tpl ) {

        # IMPORTANT:  this is the secret sauce - remove all existing footer links
        $tpl->data['footerlinks']['places'] = array();

        # To add new footer links to local wiki pages:
        #
        # 1) You MUST create your new pages in your (Main) namespace first, for example:
        #
        #       http://<your-site>/wiki/index.php/About_Us
        #       http://<your-site>/wiki/index.php/Contact_Us
        #       http://<your-site>/wiki/index.php/Disclaimer
        #       http://<your-site>/wiki/index.php/Download
        #       http://<your-site>/wiki/index.php/Privacy_Policy
        #
        # 2) You MUST then create each of these pages in your MediaWiki namespace:
        #
        #       http://<your-site>/wiki/index.php/MediaWiki:Aboutpage
        #               - Insert 1 line, with "About Us" (no quotes)
        #       http://<your-site>/wiki/index.php/MediaWiki:Contactpage
        #               - Insert 1 line, with "Contact Us" (no quotes)
        #       http://<your-site>/wiki/index.php/MediaWiki:Disclaimerpage
        #               - Insert 1 line, with "Disclaimer" (no quotes)
        #       http://<your-site>/wiki/index.php/MediaWiki:Downloadpage
        #               - Insert 1 line, with "Download" (no quotes)
        #       http://<your-site>/wiki/index.php/MediaWiki:Privacypage
        #               - Insert 1 line, with "Privacy Policy" (no quotes)
        #
        # 3) Add new footer links like this:

        $tpl->set( 'aboutpage', $sk->footerLink( 'aboutpage', 'aboutpage' ) );
        $tpl->data['footerlinks']['places'][] = 'aboutpage';
        $tpl->set( 'contactpage', $sk->footerLink( 'contactpage', 'contactpage' ) );
        $tpl->data['footerlinks']['places'][] = 'contactpage';
        $tpl->set( 'disclaimerpage', $sk->footerLink( 'disclaimerpage', 'disclaimerpage' ) );
        $tpl->data['footerlinks']['places'][] = 'disclaimerpage';
        $tpl->set( 'downloadpage', $sk->footerLink( 'downloadpage', 'downloadpage' ) );
        $tpl->data['footerlinks']['places'][] = 'downloadpage';
        $tpl->set( 'privacypage', $sk->footerLink( 'privacypage', 'privacypage' ) );
        $tpl->data['footerlinks']['places'][] = 'privacypage';

        return true;
};

IMPORTANT: Don't forget to follow the instructions and create your own pages and the corresponding MediaWiki redirects, or your links may not show or they may be broken.


问:
How to apply postprocessing SSAA to OutlinePass
I am trying to use the OutlinePass after SSAA postprocessing but my outline does not show up if I call SSAA after OutlinePass. How can I apply SSAA to my outline? I know FXAA will work but I want to use SSAA.

I have something like:

```<code>var composer = new THREE.EffectComposer( renderer );

outlinePass = new THREE.OutlinePass( new THREE.Vector2( window.innerWidth, window.innerHeight ), scene, camera );
composer.addPass( outlinePass );
outlinePass.visibleEdgeColor.set('#ffffff');
outlinePass.hiddenEdgeColor.set( '#190a05' );
outlinePass.edgeThickness = 5.0;
outlinePass.edgeStrength = 5.0;
outlinePass.edgeGlow = 0.0;
outlinePass.pulsePeriod = 0;
outlinePass.rotate = false;
outlinePass.usePatternTexture = false;

outlinePass.selectedObjects = [cube];

let ssaaRenderPass = new THREE.SSAARenderPass( scene, camera );
ssaaRenderPass.sampleLevel = 2;
composer.addPass( ssaaRenderPass );

copyPass = new THREE.ShaderPass( THREE.CopyShader );
copyPass.renderToScreen = true;
composer.addPass( copyPass );
</code>```

答:
Nevermind, I just applied FXAA to the outline and it looks OK.

So I did SSAA, outlinePass, then FXAA. The FXAA smooth out the shape in the outline.

Body:
I am trying to use the OutlinePass after SSAA postprocessing but my outline does not show up if I call SSAA after OutlinePass. How can I apply SSAA to my outline? I know FXAA will work but I want to use SSAA.

I have something like:

var composer = new THREE.EffectComposer( renderer );

outlinePass = new THREE.OutlinePass( new THREE.Vector2( window.innerWidth, window.innerHeight ), scene, camera );
composer.addPass( outlinePass );
outlinePass.visibleEdgeColor.set('#ffffff');
outlinePass.hiddenEdgeColor.set( '#190a05' );
outlinePass.edgeThickness = 5.0;
outlinePass.edgeStrength = 5.0;
outlinePass.edgeGlow = 0.0;
outlinePass.pulsePeriod = 0;
outlinePass.rotate = false;
outlinePass.usePatternTexture = false;

outlinePass.selectedObjects = [cube];

let ssaaRenderPass = new THREE.SSAARenderPass( scene, camera );
ssaaRenderPass.sampleLevel = 2;
composer.addPass( ssaaRenderPass );

copyPass = new THREE.ShaderPass( THREE.CopyShader );
copyPass.renderToScreen = true;
composer.addPass( copyPass );


问:
Finding the url for an image
I'm currently using a python web crawler to collect images searched on google. I used selenium to scroll down the searching page and used beautiful soup to record all the elements.

For some pictures, I can easily find the url without extra clicking, like "http://www.XXXXX.jpg". But for some pictures, if I don't click on it and just inspect the element, the src part would be like "data:image/jpeg;base 64,/...". And I will get the desired url by inspecting the zoomed image after clicking. But I don't know how to use selenium to click on the picture.

Are there any ways to get the urls for this kind of images?

答:
It could mean the image is encoded inside the src part of the html
to save the image you only have to get the long line of text after

```<code>data:image/jpeg;base 64,/
</code>```

and decode it.

for instance

```<code>import base64
b64_data = "here_text"
imgdata = base64.b64decode(b64_data)
filename = 'some_image.jpg'  # I assume you have a way of picking unique filenames
with open(filename, 'wb') as f:
    f.write(imgdata)
</code>```

it could also mean to run javascript after clicking a thumbnail, then to click the element all you have to do is

```<code>driver.find_element_by_css_selector(".classname").click()
</code>```

Title: Finding the url for an image

Body:
It could mean the image is encoded inside the src part of the html
to save the image you only have to get the long line of text after

data:image/jpeg;base 64,/

and decode it.

for instance

import base64
b64_data = "here_text"
imgdata = base64.b64decode(b64_data)
filename = 'some_image.jpg'  # I assume you have a way of picking unique filenames
with open(filename, 'wb') as f:
    f.write(imgdata)

it could also mean to run javascript after clicking a thumbnail, then to click the element all you have to do is

driver.find_element_by_css_selector(".classname").click()


问:
Making list of unique numbers
I am trying to make a list of unique numbers and I am getting the wrong output.

I want to get each unique number from a file where each line has two numbers:
friends=['4 6', '4 7', '4 8', '5 9', '6 8', '7 8', '100 112', '112 114', '78 44']

Answer:
user=['4', '6', '7', '8','44','78', '100', '112', '114']

However my following code outputs user= ['0', '1', '2', '4', '5', '6', '7', '8', '9'] instead

I am unsure of how to make my code recognize two and three digit numbers in the file, basically this my problem

```<code>user=[]
for row in friends:
    for column in row:
            if column not in user and column.isdigit():
                user.append(column)

    user.sort()
print(user)
</code>```

*I am not allowed to use dictionaries, sets, deque, bisect module

答:
Something like this:

```<code>friends=['4 6', '4 7', '4 8', '5 9', '6 8', '7 8', '100 112', '112 114', '78 44']

def get_numbers(mylist):
    nums = []                            # create a new list
    for i in mylist:                     # for each pair in the friends list
        nums.append(map(int, i.split())) # split each pair
                                         # convert them to integers
                                         # and append them to the new list
    return nums                          # return the new list

numbers = get_numbers(friends)           # call the function with the old list
</code>```

then you can do:

```<code>print(numbers)
[[4, 6], [4, 7], [4, 8], [5, 9], [6, 8], [7, 8], [100, 112], [112, 114], [78, 44]]
</code>```

This should help get you started. If you get stuck, post a comment, and we can update it.

Title: Making list of unique numbers

Body:
I am trying to make a list of unique numbers and I am getting the wrong output.

I want to get each unique number from a file where each line has two numbers:
friends=['4 6', '4 7', '4 8', '5 9', '6 8', '7 8', '100 112', '112 114', '78 44']

Answer:
user=['4', '6', '7', '8','44','78', '100', '112', '114']

However my following code outputs user= ['0', '1', '2', '4', '5', '6', '7', '8', '9'] instead

I am unsure of how to make my code recognize two and three digit numbers in the file, basically this my problem

user=[]
for row in friends:
    for column in row:
            if column not in user and column.isdigit():
                user.append(column)

    user.sort()
print(user)

*I am not allowed to use dictionaries, sets, deque, bisect module

Body:
Something like this:

friends=['4 6', '4 7', '4 8', '5 9', '6 8', '7 8', '100 112', '112 114', '78 44']

def get_numbers(mylist):
    nums = []                            # create a new list
    for i in mylist:                     # for each pair in the friends list
        nums.append(map(int, i.split())) # split each pair
                                         # convert them to integers
                                         # and append them to the new list
    return nums                          # return the new list

numbers = get_numbers(friends)           # call the function with the old list

then you can do:

print(numbers)
[[4, 6], [4, 7], [4, 8], [5, 9], [6, 8], [7, 8], [100, 112], [112, 114], [78, 44]]

This should help get you started. If you get stuck, post a comment, and we can update it.


问:
Bootstrap change navbar color
In Bootstrap 4, how do I go about changing the background color of a navbar? The code from twbscolor doesn't work. I want to make the background color a different color and the font color white.

    <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">

    </button>
    Jordan Baron

            Home

```

答:
I got it. This is very simple. Using the class bg you can achieve this easily.

Let me show you:

```<code><nav class="navbar navbar-expand-lg navbar-dark navbar-full bg-primary"></nav>
</code>```

This gives you the default blue navbar

If you want to change your favorite color, then simply use the style tag within the nav:

```<code><nav class="navbar navbar-expand-lg navbar-dark navbar-full" style="background-color: #FF0000">
</code>```

Title: Bootstrap change navbar color

Body:
I got it. This is very simple. Using the class bg you can achieve this easily.

Let me show you:

<nav class="navbar navbar-expand-lg navbar-dark navbar-full bg-primary"></nav>

This gives you the default blue navbar

If you want to change your favorite color, then simply use the style tag within the nav:

<nav class="navbar navbar-expand-lg navbar-dark navbar-full" style="background-color: #FF0000">


问:
Is there a Python datatype for unordered sets of sets?
I want to store sets A and B, in a set C.
My condition is that if set A = {a,b} and set B = {b,a}

Then set A is equal to set B

Set C will then be = {{a,b}}

Is there a datatype which supports something like this?

答:
The frozenset() type meets your criteria:

```<code>>>> A = frozenset({"a", "b"})
>>> B = frozenset({"b", "a"})
>>> A == B
True
>>> frozenset({ A, B })
frozenset({frozenset({'b', 'a'})})
</code>```

Body:
The frozenset() type meets your criteria:

>>> A = frozenset({"a", "b"})
>>> B = frozenset({"b", "a"})
>>> A == B
True
>>> frozenset({ A, B })
frozenset({frozenset({'b', 'a'})})


答:
Yes, and that datatype is just set. The trick is that the inside sets have to be frozensets, the immutable counterpart of set, for them to be placed inside another set. You may also want to make the outer set a frozenset, depending on what you want to do with it; for example, if you want to stick these sets inside more layers of sets indefinitely, it's probably easier to go with frozensets for everything.

```<code>>>> A = frozenset(['a', 'b'])
>>> B = frozenset(['b', 'a'])
>>> C = {A, B}
>>> C
set([frozenset(['a', 'b'])])
</code>```

Title: Is there a Python datatype for unordered sets of sets?

Body:
I want to store sets A and B, in a set C.
My condition is that if set A = {a,b} and set B = {b,a}

Then set A is equal to set B

Set C will then be = {{a,b}}

Is there a datatype which supports something like this?

Body:
Yes, and that datatype is just set. The trick is that the inside sets have to be frozensets, the immutable counterpart of set, for them to be placed inside another set. You may also want to make the outer set a frozenset, depending on what you want to do with it; for example, if you want to stick these sets inside more layers of sets indefinitely, it's probably easier to go with frozensets for everything.

>>> A = frozenset(['a', 'b'])
>>> B = frozenset(['b', 'a'])
>>> C = {A, B}
>>> C
set([frozenset(['a', 'b'])])


问:
Stencil CLI - Installation Error - Stencil Init - command not found
I tried to install stencil CLI on my Mac Sierra 10.12.6
I keep on getting an error when trying to do stencil init

```<code>-bash: stencil: command not found
</code>```

I have installed:

node -v  -  v9.1.0

npm -v  -  5.5.1

Please help ;-)  it used to run on my mac not sure what I did wrong.... it is not working anymore

答:
It could be that Stencil CLI was installed in a local directory instead of globally. You can try to rerun the command to install the CLI: npm install -g @bigcommerce/stencil-cli and be sure that the -g isn't omitted.

You can also try entering echo $NVM_DIR and if it returns nothing in the terminal, run source ~/.bash_profile and then try stencil init again.

Body:
I tried to install stencil CLI on my Mac Sierra 10.12.6
I keep on getting an error when trying to do stencil init

-bash: stencil: command not found

I have installed:

node -v  -  v9.1.0

npm -v  -  5.5.1

Please help ;-)  it used to run on my mac not sure what I did wrong.... it is not working anymore


问:
how to separated One column to two with cases
I have a table and I would want to separate the data to multiple columns, how i can do it ?

I tried this:

```<code> select a.[batch],a.[Doc_Type],
    Soaking Out =
      CASE a.[Doc_Type]
         WHEN 'BB' THEN 'Soaking Out'
      END,

        Soaking In =
      CASE a.[Doc_Type]
         WHEN 'AA' THEN 'Soaking In'
      END,

     FROM Transaction_Hdr a JOIN Transaction_dtl b
on a.Doc_Number=b.Doc_Number
</code>```

答:
I think you are looking for quantity in result table, So you should use that instead of string 'Soaking In' and 'Soaking Out' as follows </p>

```<code>select a.[batch],a.[Doc_Type],
SoakingOut =
  CASE a.[Doc_Type]
     WHEN 'BB' THEN Qty
  END    ,

    SoakingIn =
  CASE a.[Doc_Type]
     WHEN 'AA' THEN Qty
  END

 FROM #temp a
</code>```

Body:
I have a table and I would want to separate the data to multiple columns, how i can do it ?

I tried this:

 select a.[batch],a.[Doc_Type],
    Soaking Out =
      CASE a.[Doc_Type]
         WHEN 'BB' THEN 'Soaking Out'
      END,

        Soaking In =
      CASE a.[Doc_Type]
         WHEN 'AA' THEN 'Soaking In'
      END,

     FROM Transaction_Hdr a JOIN Transaction_dtl b
on a.Doc_Number=b.Doc_Number

Body:
I think you are looking for quantity in result table, So you should use that instead of string 'Soaking In' and 'Soaking Out' as follows

select a.[batch],a.[Doc_Type],
SoakingOut =
  CASE a.[Doc_Type]
     WHEN 'BB' THEN Qty
  END    ,

    SoakingIn =
  CASE a.[Doc_Type]
     WHEN 'AA' THEN Qty
  END

 FROM #temp a