问:
Shiny: dynamic dataframe construction; choose variables
I have one question to open the topic already. Well, I'm trying to do a similar app to this one Shiny: dynamic dataframe construction; renderUI, observe, reactiveValues. And I would like to add a new category at the beginning which will select the variables from the table. I'm going in the right direction?</p>

```<code>Data <- reactive({

    if(input$table == "All"){df_subset <- data}
    else{df_subset <- data[,input$show_vars,drop=FALSE]}

  })
</code>```

答:
You probably want something like this:

```<code>    Data <- reactive({
      req(input$table)
      if(input$table == "All"){
        return(data)
      }
      else{
        df_subset <- data[,names(data) %in% input$show_vars]
      }
      df_subset
    })
</code>```

or even shorter:

```<code>Data <- reactive({
  req(input$table)
  if(input$table == "All"){
    return(data)
  }
  data[,names(data) %in% input$show_vars]
})
</code>```

Body:
I have one question to open the topic already. Well, I'm trying to do a similar app to this one Shiny: dynamic dataframe construction; renderUI, observe, reactiveValues. And I would like to add a new category at the beginning which will select the variables from the table. I'm going in the right direction?

Data <- reactive({

    if(input$table == "All"){df_subset <- data}
    else{df_subset <- data[,input$show_vars,drop=FALSE]}

  })

Body:
You probably want something like this:

    Data <- reactive({
      req(input$table)
      if(input$table == "All"){
        return(data)
      }
      else{
        df_subset <- data[,names(data) %in% input$show_vars]
      }
      df_subset
    })

or even shorter:

Data <- reactive({
  req(input$table)
  if(input$table == "All"){
    return(data)
  }
  data[,names(data) %in% input$show_vars]
})


来源: stackexchange

问:
how to load escaped character html content in webview
I am using json api in my wordpress site to get the posts in json format. And I am also retrieving this json response and store in the string variable.
I use
webview.loadData(html_value, "text/html", "UTF-8");
to load data into my webview.
But it is not working with escaped character in HTML content. It displays the content in unknown format.
My json respone is

\u0c9f\u0c97\u0cb0\u0cc1, \u0cae\u0cc8\u0caf\u0cc6\u0cb2\u0ccd\u0cb2\u0cbe \u0caa\u0cca\u0c97\u0cb0\u0cc1<\/strong>, \u0cb6\u0cc0\u0cb0\u0ccd\u0cb7\u0cbf\u0c95\u0cc6 \u0c85\u0c82\u0ca4\u0cc6 \u0c9a\u0cbf\u0ca4\u0ccd\u0c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ca6\u0cb2\u0cc7 \u0c92\u0c82\u0ca6\u0cc1 \u0cae\u0cc1\u0c95\u0ccd\u0c95\u0cbe\u0cb2\u0cc1 \u0cb2\u0c95\u0ccd\u0cb7\u0c95\u0ccd\u0c95\u0cbf\u0c82\u0ca4 \u0c9c\u0cbe\u0cb8\u0ccd\u0ca4\u0cbf \u0c9c\u0ca8 \u0c88 …```

I have also used String webdata= StringEscapeUtils.unescapeHtml4(jsonHTMLContent); to convert escaped character into UTF-8 But no use. Please help me to solve this problem.

答:
how to load escaped character html content in webview.

Note : please remove extra add slashes.

```<code> web.loadData("<p style='text-align: left;'><strong>Testing</strong></p><p style='text-align: center;'><iframe src='https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/352880786&color=%23ff5500&auto_play=false&hide_related=false&show_comments=true&show_user=true&show_reposts=false&show_teaser=true&visual=true' width='100%' height='300' frameborder='no' scrolling='no'></iframe></p>\n","text/html", "UTF-8");
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I am using json api in my wordpress site to get the posts in json format. And I am also retrieving this json response and store in the string variable.
I use
webview.loadData(html_value, "text/html", "UTF-8");
to load data into my webview.
But it is not working with escaped character in HTML content. It displays the content in unknown format.
My json respone is

\u0c9f\u0c97\u0cb0\u0cc1, \u0cae\u0cc8\u0caf\u0cc6\u0cb2\u0ccd\u0cb2\u0cbe \u0caa\u0cca\u0c97\u0cb0\u0cc1<\/strong>, \u0cb6\u0cc0\u0cb0\u0ccd\u0cb7\u0cbf\u0c95\u0cc6 \u0c85\u0c82\u0ca4\u0cc6 \u0c9a\u0cbf\u0ca4\u0ccd\u0cb0 \u0c9f\u0c97\u0cb0\u0cc1 \u0cac\u0cbf\u0ca1\u0cc1\u0c97\u0ca1\u0cc6\u0c97\u0cc2 \u0cae\u0cc1\u0ca8\u0ccd\u0ca8 \u0cad\u0cb0\u0ccd\u0c9c\u0cb0\u0cbf\u0caf\u0cbe\u0c97\u0cbf \u0c95\u0c82\u0ca1\u0cc1 \u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\u0c88 …

I have also used String webdata= StringEscapeUtils.unescapeHtml4(jsonHTMLContent); to convert escaped character into UTF-8 But no use. Please help me to solve this problem.

Body:
how to load escaped character html content in webview.

Note : please remove extra add slashes.

 web.loadData("<p style='text-align: left;'><strong>Testing</strong></p><p style='text-align: center;'><iframe src='https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/352880786&amp;color=%23ff5500&amp;auto_play=false&amp;hide_related=false&amp;show_comments=true&amp;show_user=true&amp;show_reposts=false&amp;show_teaser=true&amp;visual=true' width='100%' height='300' frameborder='no' scrolling='no'></iframe></p>\n","text/html", "UTF-8");


问:
OpenCV return None whan imread is called with GDAL support
I have a very simple program in python with OpenCV and GDAL. In this program i read GeoTiff image with the following line

```<code>image = cv2.imread(sys.argv[1], cv2.IMREAD_LOAD_GDAL | cv2.IMREAD_COLOR)
</code>```

The problem is for a specific image imread return None. I am using images from: https://www.sensefly.com/drones/example-datasets.html

Image in Assessing crops with RGB imagery (eBee SQ) > Map (orthomosaic) works well. Its size is: 19428, 19784 with 4 bands.

Image in Urban mapping (eBee Plus/senseFly S.O.D.A.) > Map (orthomosaic) doesn't work. Its size is: 26747, 25388 and 4 bands.

Any help to figure out what is the problem?

Edit: I tried the solution suggested by @en_lorithai and it works, the problem is then I need to do some image processing with OpenCV and the image loaded by GDAL has several issues

GDAL load images as RGB instead of BGR (used by default in OpenCV)

The image shape expected by OpenCV is (width, height, channels) and GDAL return an image with (channels, width, height) shape

The image returned by GDAL is flipped in Y-axe and rotate clockwise by 90 degree.

The image loaded by OpenCV is (resized to 700x700):

The image loaded by GDAL (after change shape, of course) is (resized to 700x700)

Finally, If I try to convert this image from BGR to RGB with

```<code>image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
</code>```

I get (resized to 700x700)

I can convert from GDAL format to OpenCV format with the following code

```<code>image = ds.ReadAsArray() #Load image with GDAL
tmp = image.copy()
image[0] = tmp[2,:,:] # swap read channel and blue channel
image[2] = tmp[0,:,:]
image = np.swapaxes(image,2,0) # convert from (height, width, channels) to (channels, height, width)

image = cv2.flip(image,0) # flip in Y-axis
image = cv2.transpose(image) # Rotate by 90 degress (clockwise)
image = cv2.flip(image,1)
</code>```

The problem is I think that this is a very slow process and I want to know if there is a automatic convert-process.

答:
You can try and open the image in gdal instead

```<code>from osgeo import gdal

g_image = gdal.Open('161104_hq_transparent_mosaic_group1.tif')
a_image = g_image.ReadAsArray()
</code>```

can't test as i don't have enough available memory to open that image.

Edit: equivalent operation on another image

```<code>from osgeo import gdal
import matplotlib.pyplot as plt

g_image = gdal.Open('Water-scenes-014.jpg') # 3 channel rgb image
a_image = g_image.ReadAsArray()
s_image = np.dstack((a_image[0],a_image[1],a_image[2]))
plt.imshow(s_image) # show image in matplotlib (no need for color swap)
s_image = cv2.cvtColor(s_image,cv2.COLOR_RGB2BGR) # colorswap for cv
cv2.imshow('name',s_image)
</code>```

Another method of getting individual bands from gdal

```<code>g_image = gdal.Open('image_name.PNG')
band1 = g_image.GetRasterBand(1).ReadAsArray()
</code>```

You can then do a numpy dstack of each of the bands.

Body:
I have a very simple program in python with OpenCV and GDAL. In this program i read GeoTiff image with the following line

image = cv2.imread(sys.argv[1], cv2.IMREAD_LOAD_GDAL | cv2.IMREAD_COLOR)

The problem is for a specific image imread return None. I am using images from: https://www.sensefly.com/drones/example-datasets.html

Image in Assessing crops with RGB imagery (eBee SQ) > Map (orthomosaic) works well. Its size is: 19428, 19784 with 4 bands.

Image in Urban mapping (eBee Plus/senseFly S.O.D.A.) > Map (orthomosaic) doesn't work. Its size is: 26747, 25388 and 4 bands.

Any help to figure out what is the problem?

Edit: I tried the solution suggested by @en_lorithai and it works, the problem is then I need to do some image processing with OpenCV and the image loaded by GDAL has several issues

GDAL load images as RGB instead of BGR (used by default in OpenCV)

The image shape expected by OpenCV is (width, height, channels) and GDAL return an image with (channels, width, height) shape

The image returned by GDAL is flipped in Y-axe and rotate clockwise by 90 degree.

The image loaded by OpenCV is (resized to 700x700):

The image loaded by GDAL (after change shape, of course) is (resized to 700x700)

Finally, If I try to convert this image from BGR to RGB with

image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)

I get (resized to 700x700)

I can convert from GDAL format to OpenCV format with the following code

image = ds.ReadAsArray() #Load image with GDAL
tmp = image.copy()
image[0] = tmp[2,:,:] # swap read channel and blue channel
image[2] = tmp[0,:,:]
image = np.swapaxes(image,2,0) # convert from (height, width, channels) to (channels, height, width)

image = cv2.flip(image,0) # flip in Y-axis
image = cv2.transpose(image) # Rotate by 90 degress (clockwise)
image = cv2.flip(image,1)

The problem is I think that this is a very slow process and I want to know if there is a automatic convert-process.

Body:
You can try and open the image in gdal instead

from osgeo import gdal

g_image = gdal.Open('161104_hq_transparent_mosaic_group1.tif')
a_image = g_image.ReadAsArray()

can't test as i don't have enough available memory to open that image.

Edit: equivalent operation on another image

from osgeo import gdal
import matplotlib.pyplot as plt

g_image = gdal.Open('Water-scenes-014.jpg') # 3 channel rgb image
a_image = g_image.ReadAsArray()
s_image = np.dstack((a_image[0],a_image[1],a_image[2]))
plt.imshow(s_image) # show image in matplotlib (no need for color swap)
s_image = cv2.cvtColor(s_image,cv2.COLOR_RGB2BGR) # colorswap for cv
cv2.imshow('name',s_image)

Another method of getting individual bands from gdal

g_image = gdal.Open('image_name.PNG')
band1 = g_image.GetRasterBand(1).ReadAsArray()

You can then do a numpy dstack of each of the bands.


问:
Which C++ random number engines have a O(1) discard function?
Since C++11 there are a number of std random number engines. One of the member functions they implement is void discard(int long long z) which skips over z randomly generated numbers. The complexity of this function is given as O(z) on www.cplusplus.com (http://www.cplusplus.com/reference/random/mersenne_twister_engine/discard/)

However, on www.cppreference.com (http://en.cppreference.com/w/cpp/numeric/random/mersenne_twister_engine/discard) there is a note to say that

For some engines, "fast jump" algorithms are known, which advancing
  the state by many steps (order of millions) without calculating
  intermediate state transitions.

How do I know for which engines the actual cost of discard is O(1)?

答:
Well, if you use precomputed jump points, O(1) will work for each and every RNG in existence. Please, remember, that there are algorithm which might have better than  O(z), but not O(1) - say, O(log2 z).

If we're talking about jump to arbitrary point, things get interesting. For example, for linear congruential generator there is known O(log2 z) jump ahead algorithm, based upon paper by F. Brown, "Random Number Generation with Arbitrary Stride," Trans. Am. Nucl. Soc. (Nov. 1994). Code example is here.

There is LCG RNG in the C++11 standard, not sure how fast jump ahead is done in particular implementation (http://en.cppreference.com/w/cpp/numeric/random/linear_congruential_engine)

PCG family of RNGs share the same property, I believe


问:
Find maximum number from array in assembly program
I have written a program to find max number from array of 15 numbers but my output is coming wrong. I have store result in AX register.

Here is my code.

```<code>[org 0x0100]

array_nums: dw 19, 50, 30, 24, 19, 2, 5, 6, 40, 8, 23, 16, 17, 28, 86
max: dw 0
        mov bx, 0 ; initialize array index to zero
        mov ax, 0 ; initialize min to zero

        mov ax, [array_nums+bx]     ; max number to ax
        mov cx, 15

maxvalue:   cmp ax, [array_nums+bx]     ; find the maximun number
            jge maxloop                 ; if greater or equal number
            mov ax, [array_nums+bx]     ; ax contains the maximun number
maxloop:

        add bx, 2                   ; advance bx to next index
        loop maxvalue

        mov [max], ax               ; write back maximun in memory

        mov ax, 0x4c00              ; terminate program
        int 0x21
</code>```

答:
'I have to store the result in ...' tells me this is probably a homework.

To please your teacher, don't just write a program able to solve the one task. Write a function (to make it reusable), use an API (either some standard, or define your own, like "pointer in array must be defined in BX". then embed this function into a program, to test it.

Something like this perhaps (shot from the hip, test it before you use it ;-) )

```<code>[org 0x0100]
jmp start

array_nums: dw 19, 50, 30, 24, 19, 2, 5, 6, 40, 8, 23, 16, 17, 28, 86

; ----------------------------------------------------------
; find the largest value in an array of ints
; in-params:
;   CX = number of values in array
;   BX = pointer to array
; out-params
;    AX = biggest value

findBiggest:
            mov ax, [bx]     ; first number to ax
            mov cx, 15

maxvalue:   cmp ax, [bx]     ; find the maximun number
            jge maxloop      ; if greater or equal number
            mov ax, [bx]     ; maximum number was larger
maxloop:
            add bx, 2        ; advance bx to next index
            loop maxvalue
            ret
; ----------------------------------------------------------

 start:     mov bx, offset array_nums     ; use find function on 'array_nums'
            mov cx, 15
            call findBiggest

            ; add some code here to show a
            ; message if AX is what you expected or not
            ; AX should be 86 for the example array

            mov ax, 0x4c00              ; terminate program
            int 0x21
</code>```

Body:
I have written a program to find max number from array of 15 numbers but my output is coming wrong. I have store result in AX register.

Here is my code.

[org 0x0100]

array_nums: dw 19, 50, 30, 24, 19, 2, 5, 6, 40, 8, 23, 16, 17, 28, 86
max: dw 0
        mov bx, 0 ; initialize array index to zero
        mov ax, 0 ; initialize min to zero

        mov ax, [array_nums+bx]     ; max number to ax
        mov cx, 15

maxvalue:   cmp ax, [array_nums+bx]     ; find the maximun number
            jge maxloop                 ; if greater or equal number
            mov ax, [array_nums+bx]     ; ax contains the maximun number
maxloop:

        add bx, 2                   ; advance bx to next index
        loop maxvalue

        mov [max], ax               ; write back maximun in memory

        mov ax, 0x4c00              ; terminate program
        int 0x21

Body:
'I have to store the result in ...' tells me this is probably a homework.

To please your teacher, don't just write a program able to solve the one task. Write a function (to make it reusable), use an API (either some standard, or define your own, like "pointer in array must be defined in BX". then embed this function into a program, to test it.

Something like this perhaps (shot from the hip, test it before you use it ;-) )

[org 0x0100]
jmp start

array_nums: dw 19, 50, 30, 24, 19, 2, 5, 6, 40, 8, 23, 16, 17, 28, 86

; ----------------------------------------------------------
; find the largest value in an array of ints
; in-params:
;   CX = number of values in array
;   BX = pointer to array
; out-params
;    AX = biggest value

findBiggest:
            mov ax, [bx]     ; first number to ax
            mov cx, 15

maxvalue:   cmp ax, [bx]     ; find the maximun number
            jge maxloop      ; if greater or equal number
            mov ax, [bx]     ; maximum number was larger
maxloop:
            add bx, 2        ; advance bx to next index
            loop maxvalue
            ret
; ----------------------------------------------------------

 start:     mov bx, offset array_nums     ; use find function on 'array_nums'
            mov cx, 15
            call findBiggest

            ; add some code here to show a
            ; message if AX is what you expected or not
            ; AX should be 86 for the example array

            mov ax, 0x4c00              ; terminate program
            int 0x21


问:
WordPress check_ajax_referer gives 403 forbidden when using inside AJAX action
I am making an AJAX call in WordPress to connect an API. For this I am trying to use a nonce in order to prevent any unauthorized or robot access. This is my code:

functions.php

```<code>add_action('wp_enqueue_scripts', 'yrc_cst_ajax_platform_script_enqueue');

function yrc_cst_ajax_platform_script_enqueue () {
    wp_enqueue_script(
        'platform',
        get_template_directory_uri(). '/includes/platform.js',
        array('jquery'), '1.0', true);

    wp_localize_script('platform', 'yrc_cst_platform', array(
        'ajax_url' => admin_url('admin-ajax.php'),
        'ajax_nonce' => wp_create_nonce('platform_security')
    ));
}

add_action('wp_ajax_save_platform_contact', 'yrc_cst_save_platform_contact');
</code>```

Inside AJAX action method I wrote this (functions.php):

```<code>function yrc_cst_save_platform_contact() {
   if ( check_ajax_referer( 'platform_security', $_POST['security'] ) ) {
      var_dump($_POST['security']);
   }
   ...
}
</code>```

And here is the AJAX call:

```<code>jQuery.ajax({
   url: yrc_cst_platform.ajax_url,
   type: 'post',
   data: {
      action: 'save_platform_contact',
      security: yrc_cst_platform.ajax_nonce,
      contact_email: client_email
   },
   success: function(response) {
      // Doing my stuff...
   }
});
</code>```

In the console I see this

Failed to load resource. The server responded with a status code: 403
  (Forbidden) /wp-admin/admin-ajax.php

If I remove the block check_ajax_referer(...), things are working OK. Everything is in my local. I am testing the cycle as a logged in user only.

I don't know how to fix it.

答:
The second parameter of check_ajax_referer is used to specify where to look for nonce in $_REQUEST. When you call check_ajax_referer( 'platform_security', $_POST['security'] ) you basically tell the function to check on $_REQUEST[$_POST['security']].

You should use it like this:

```<code>check_ajax_referer( 'platform_security', 'security' )
</code>```

You can read more about it here: https://codex.wordpress.org/Function_Reference/check_ajax_referer

ContentLicense: CC BY-SA 4.0

Body:
I am making an AJAX call in WordPress to connect an API. For this I am trying to use a nonce in order to prevent any unauthorized or robot access. This is my code:

functions.php

add_action('wp_enqueue_scripts', 'yrc_cst_ajax_platform_script_enqueue');

function yrc_cst_ajax_platform_script_enqueue () {
    wp_enqueue_script(
        'platform',
        get_template_directory_uri(). '/includes/platform.js',
        array('jquery'), '1.0', true);

    wp_localize_script('platform', 'yrc_cst_platform', array(
        'ajax_url' => admin_url('admin-ajax.php'),
        'ajax_nonce' => wp_create_nonce('platform_security')
    ));
}

add_action('wp_ajax_save_platform_contact', 'yrc_cst_save_platform_contact');

Inside AJAX action method I wrote this (functions.php):

function yrc_cst_save_platform_contact() {
   if ( check_ajax_referer( 'platform_security', $_POST['security'] ) ) {
      var_dump($_POST['security']);
   }
   ...
}

And here is the AJAX call:

jQuery.ajax({
   url: yrc_cst_platform.ajax_url,
   type: 'post',
   data: {
      action: 'save_platform_contact',
      security: yrc_cst_platform.ajax_nonce,
      contact_email: client_email
   },
   success: function(response) {
      // Doing my stuff...
   }
});

In the console I see this

Failed to load resource. The server responded with a status code: 403
  (Forbidden) /wp-admin/admin-ajax.php

If I remove the block check_ajax_referer(...), things are working OK. Everything is in my local. I am testing the cycle as a logged in user only.

I don't know how to fix it.

Body:
The second parameter of check_ajax_referer is used to specify where to look for nonce in $_REQUEST. When you call check_ajax_referer( 'platform_security', $_POST['security'] ) you basically tell the function to check on $_REQUEST[$_POST['security']].

You should use it like this:

check_ajax_referer( 'platform_security', 'security' )

You can read more about it here: https://codex.wordpress.org/Function_Reference/check_ajax_referer


问:
How to get the sum of timedelta in Python?
Python: How to get the sum of timedelta?

Eg. I just got a lot of timedelta object, and now I want the sum. That's it!

答:
(Edit: Assuming that by "sum timedelta" you mean "convert a timedelta to int seconds".)

This is very inefficient, but it is simple:

```<code>int((datetime.datetime.fromtimestamp(0) + myTimeDelta).strftime("%s"))
</code>```

This converts a Unix timestamp (0) into a datetime object, adds your delta to it, and then converts back to a Unix time. Since Unix time counts seconds, this is the number of seconds your timedelta represented.

Body:
(Edit: Assuming that by "sum timedelta" you mean "convert a timedelta to int seconds".)

This is very inefficient, but it is simple:

int((datetime.datetime.fromtimestamp(0) + myTimeDelta).strftime("%s"))

This converts a Unix timestamp (0) into a datetime object, adds your delta to it, and then converts back to a Unix time. Since Unix time counts seconds, this is the number of seconds your timedelta represented.

ContentLicense: CC BY-SA 2.5


问:
Adding extra files to an Android Application
I am using qt 5.2 and I have been trying to figure out how to have extra files along with my application when it installs. I want to be able to use adb shell and then cd into data/data/org.qtproject.example.myProjectPath/. I would like to be able to find that file somewhere. I had posted a question about this already but was unable to find answers. Some people did reply and there was mentioning of assets but qt 5.2 doesn't create an assets file. I was also told to try something along the lines of

deployment.files += program
deployment.path = /assets
INSTALLS += deployment
```

<p>and also</p>

<pre class="lang-none prettyprint-override"><code>documentation.path = /usr/local/program/doc
documentation.files = docs/*
INSTALLS += documentation
</code>```

Neither of these I could get to work. I was also given this link but it does not seem to be Android-specific.

答:
A solution that works for me (Qt 5.9.2):

add the following line to the .pro file if you don't already have it for e.g. a custom manifest file (folder name doesn't matter for pkg_src):

```<code>ANDROID_PACKAGE_SOURCE_DIR = $$PWD/pkg_src
</code>```

create a folder "pkg_src/assets" relative to the .pro file

copy the files you need to this folder, either manually or e.g. with a QMAKE_POST_LINK command which copies the files there after the app build.

This is not 100% ideal, since QMAKE_POST_LINK is only executed if there is something to build, but is at least sufficient for my needs.

Body:
I am using qt 5.2 and I have been trying to figure out how to have extra files along with my application when it installs. I want to be able to use adb shell and then cd into data/data/org.qtproject.example.myProjectPath/. I would like to be able to find that file somewhere. I had posted a question about this already but was unable to find answers. Some people did reply and there was mentioning of assets but qt 5.2 doesn't create an assets file. I was also told to try something along the lines of

deployment.files += program
deployment.path = /assets
INSTALLS += deployment

and also

documentation.path = /usr/local/program/doc
documentation.files = docs/*
INSTALLS += documentation

Neither of these I could get to work. I was also given this link but it does not seem to be Android-specific.

Body:
A solution that works for me (Qt 5.9.2):

add the following line to the .pro file if you don't already have it for e.g. a custom manifest file (folder name doesn't matter for pkg_src):

ANDROID_PACKAGE_SOURCE_DIR = $$PWD/pkg_src

create a folder "pkg_src/assets" relative to the .pro file

copy the files you need to this folder, either manually or e.g. with a QMAKE_POST_LINK command which copies the files there after the app build.

This is not 100% ideal, since QMAKE_POST_LINK is only executed if there is something to build, but is at least sufficient for my needs.


问:
Hiding wsdl's xml information in web browser on WCF?
Is there a way to let the clients use the wsdl, however only hide its xml which shows methods when opened in a web browser.

For example, following works very well for asmx:

```<code>  <system.web>
    <webServices>
      <wsdlHelpGenerator href="Blank.aspx"/>
    </webServices>
  </system.web>
</code>```

Is there any alternative of the above for svc?

Removing serviceMetadata or changing httpGetEnabled to false makes wsdl unusable, which is not what I want. I just want to make its contents invisible when opened in a web browser.

答:
This is the right direction, however that particular regex and action are not working exactly as I want

1) http://{domain}/{service}.svc -> https://{domain}/blank.aspx (good)

2) http://{domain}/{service}.svc?wsdl -> (shows an error when i press F12 as it is unable to find the blank.html page)

3) http://{domain}/{service}.svc?singleWsdl -> (does not change)

4) https://{domain}/{service}.svc -> (does not change)

5) https://{domain}/{service}.svc?wsdl -> (does not change)

6) https://{domain}/{service}.svc?singleWsdl -> (does not change)

Body:
Is there a way to let the clients use the wsdl, however only hide its xml which shows methods when opened in a web browser.

For example, following works very well for asmx:

  <system.web>
    <webServices>
      <wsdlHelpGenerator href="Blank.aspx"/>
    </webServices>
  </system.web>

Is there any alternative of the above for svc?

Removing serviceMetadata or changing httpGetEnabled to false makes wsdl unusable, which is not what I want. I just want to make its contents invisible when opened in a web browser.


问:
Eclipse Oxygen and Google Cloud Tools Missing javax.servlet Classes from Build Path
I have a GAE project in Eclipse that has been working without a problem.  I recently upgraded to the Google Cloud SDK 179.0.0 and Eclipse Oxygen.1a Release (4.7.1a) and now, when I open the project, I'm getting build path errors on classes in the javax.servlet.http package.  Specifically, the following classes are missing from my project's build path.

```<code>javax.servlet.ServletContext
javax.servlet.http.HttpServlet
</code>```

If you start Eclipse from the console using the following commands (assuming Eclipse is installed in your /Applications folder):

```<code>cd  /Applications/Eclipse.app/Contents/MacOS
./eclipse
</code>```

And you watch the terminal window, you'll see a bunch of stack traces similar to the following:

```<code>Nov 10, 2017 9:24:57 AM com.google.cloud.tools.eclipse.appengine.localserver.ServletClasspathProvider doResolveClasspathContainer
WARNING: Failed to initialize libraries
org.eclipse.core.runtime.CoreException: Could not resolve artifact com.google.appengine:appengine-api-1.0-sdk:jar:1.9.57
    at org.eclipse.m2e.core.internal.embedder.MavenImpl$5.call(MavenImpl.java:776)
    at org.eclipse.m2e.core.internal.embedder.MavenImpl$5.call(MavenImpl.java:1)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:177)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:151)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:99)
    at org.eclipse.m2e.core.internal.embedder.MavenImpl.resolve(MavenImpl.java:743)
    at org.eclipse.m2e.core.internal.embedder.MavenImpl.resolve(MavenImpl.java:720)
    at com.google.cloud.tools.eclipse.util.MavenUtils.resolveArtifact(MavenUtils.java:69)
    at com.google.cloud.tools.eclipse.appengine.libraries.repository.MavenHelper.resolveArtifact(MavenHelper.java:46)
    at com.google.cloud.tools.eclipse.appengine.libraries.repository.M2RepositoryService.resolveArtifact(M2RepositoryService.java:50)
    at com.google.cloud.tools.eclipse.appengine.libraries.repository.LibraryClasspathContainerResolverService.resolveLibraryFileAttachSourceSync(LibraryClasspathContainerResolverService.java:245)
    at com.google.cloud.tools.eclipse.appengine.libraries.repository.LibraryClasspathContainerResolverService.resolveLibraryAttachSourcesSync(LibraryClasspathContainerResolverService.java:106)
    at com.google.cloud.tools.eclipse.appengine.localserver.ServletClasspathProvider.doResolveClasspathContainer(ServletClasspathProvider.java:100)
    at com.google.cloud.tools.eclipse.appengine.localserver.ServletClasspathProvider.resolveClasspathContainer(ServletClasspathProvider.java:79)
    at org.eclipse.jst.server.core.RuntimeClasspathProviderDelegate.resolveClasspathContainerImpl(RuntimeClasspathProviderDelegate.java:135)
    at org.eclipse.jst.server.core.internal.RuntimeClasspathProviderWrapper.resolveClasspathContainerImpl(RuntimeClasspathProviderWrapper.java:155)
    at org.eclipse.jst.server.core.internal.RuntimeClasspathContainer.getClasspathEntries(RuntimeClasspathContainer.java:77)
    at org.eclipse.jdt.internal.core.JavaProject.resolveClasspath(JavaProject.java:2693)
    at org.eclipse.jdt.internal.core.JavaProject.resolveClasspath(JavaProject.java:2851)
    at org.eclipse.jdt.internal.core.JavaProject.getResolvedClasspath(JavaProject.java:1956)
    at org.eclipse.jdt.internal.core.ExternalFolderChange.updateExternalFoldersIfNecessary(ExternalFolderChange.java:39)
    at org.eclipse.jdt.internal.core.ChangeClasspathOperation.classpathChanged(ChangeClasspathOperation.java:59)
    at org.eclipse.jdt.internal.core.SetContainerOperation.executeOperation(SetContainerOperation.java:111)
    at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:724)
    at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2240)
    at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2267)
    at org.eclipse.jdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:795)
    at org.eclipse.jdt.internal.core.JavaModelManager$10.run(JavaModelManager.java:3001)
    at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2240)
    at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2267)
    at org.eclipse.jdt.internal.core.JavaModelManager.initializeAllContainers(JavaModelManager.java:3017)
    at org.eclipse.jdt.internal.core.JavaModelManager.getClasspathContainer(JavaModelManager.java:2038)
    at org.eclipse.jdt.core.JavaCore.getClasspathContainer(JavaCore.java:3497)
    at org.eclipse.jdt.internal.core.JavaProject.resolveClasspath(JavaProject.java:2687)
    at org.eclipse.jdt.internal.core.JavaProject.resolveClasspath(JavaProject.java:2851)
    at org.eclipse.jdt.internal.core.JavaProject.getResolvedClasspath(JavaProject.java:1956)
    at org.eclipse.jdt.internal.core.DynamicProjectReferences.getDependentProjects(DynamicProjectReferences.java:34)
    at org.eclipse.core.internal.resources.ProjectDescription.computeDynamicReferencesForProject(ProjectDescription.java:950)
    at org.eclipse.core.internal.resources.ProjectDescription.getAllBuildConfigReferences(ProjectDescription.java:265)
    at org.eclipse.core.internal.resources.ProjectDescription.getAllReferences(ProjectDescription.java:221)
    at org.eclipse.core.internal.resources.Project.getReferencedProjects(Project.java:469)
    at org.eclipse.ui.actions.CloseUnrelatedProjectsAction.buildConnectedComponents(CloseUnrelatedProjectsAction.java:78)
    at org.eclipse.ui.actions.CloseUnrelatedProjectsAction.computeRelated(CloseUnrelatedProjectsAction.java:195)
    at org.eclipse.ui.actions.CloseUnrelatedProjectsAction.getSelectedResources(CloseUnrelatedProjectsAction.java:211)
    at org.eclipse.ui.actions.SelectionListenerAction.selectionIsOfType(SelectionListenerAction.java:240)
    at org.eclipse.ui.actions.CloseResourceAction.updateSelection(CloseResourceAction.java:187)
    at org.eclipse.ui.actions.BaseSelectionListenerAction.selectionChanged(BaseSelectionListenerAction.java:124)
    at org.eclipse.ui.internal.navigator.resources.actions.ResourceMgmtActionProvider.updateActionBars(ResourceMgmtActionProvider.java:254)
    at org.eclipse.ui.internal.navigator.resources.actions.ResourceMgmtActionProvider.fillActionBars(ResourceMgmtActionProvider.java:84)
    at org.eclipse.ui.navigator.NavigatorActionService$3.run(NavigatorActionService.java:265)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.ui.navigator.NavigatorActionService.fillActionBars(NavigatorActionService.java:258)
    at org.eclipse.ui.navigator.CommonNavigatorManager$UpdateActionBarsJob$1.run(CommonNavigatorManager.java:95)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.ui.navigator.CommonNavigatorManager$UpdateActionBarsJob.runInUIThread(CommonNavigatorManager.java:89)
    at org.eclipse.ui.progress.UIJob.lambda$0(UIJob.java:95)
    at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:37)
    at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:182)
    at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4033)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3700)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1155)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1044)
    at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:153)
    at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:680)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:594)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:148)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:151)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:388)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:653)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:590)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1499)
Contains: Missing com.google.appengine:appengine-api-1.0-sdk:jar:1.9.57
</code>```

With the 179.0 version of the Google Cloud SDK installed, I now have App Engine 1.9.59 installed versus 1.9.57.

The Eclipse build path contains the following libraries:

App Engine Standard Runtime [App Engine Standard Runtime]

EAR Libraries

JRE System Library [JavaSE-1.8]

TestNG

Web App Libraries

I encounter this same problem with the following Eclipse releases:

4.7.0 (Build Id: 20170620-1800)

4.7.1a (Build Id: 20171005-1200)

The following is a list of errors my project now has:

RequestDispatcher cannot be resolved to a type

The project was not built since its build path is incomplete.  Cannot find the class for javax.servlet.ServletContext.  Fix the build path then try building this project

The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path

The type javax.servlet.ServletContext cannot be resolved.  It is indirectly referenced from required .class files

Creating a new App Engine Standard Edition project as a Maven project specifies a dependency on the 1.9.57 version of the App Engine API.

```<code><dependency>
  <groupId>com.google.appengine</groupId>
  <artifactId>appengine-api-1.0-sdk</artifactId>
  <version>1.9.57</version>
  <scope>provided</scope>
</dependency>
</code>```

Created issue #2754 for this problem on GitHub under the "GoogleCloudPlatform/google-cloud-eclipse" project.

https://github.com/GoogleCloudPlatform/google-cloud-eclipse/issues/2574

Version Information

Eclipse Oxygen.1a Release (4.7.1a Build: 20171005-1200)

Google Cloud Platform for Eclipse 4.5 and later 1.4.1.201710261936

Google Cloud SDK 179.0.0

alpha 2017.09.15

app-engine-java 1.9.59

app-engine-python 1.9.62

beta 2017.09.15

bq 2.0.27

core 2017.11.06

gcd-emulator v1beta3-1.0.0

gcloud

gsutil 4.28

kubectl

pubsub-emulator 2017.09.15

答:
I don't know the exact cause of the problem, but rebooting my computer resolved the problem reported in this bug.  In the course of trying to resolve this problem, I did stop and start Eclipse several times in an effort to address the problem.  I started new terminal window sessions in an effort to fix the problem, but that didn't work.

After completely rebooting my machine, the problem reported in this bug went away.

Body:
I have a GAE project in Eclipse that has been working without a problem.  I recently upgraded to the Google Cloud SDK 179.0.0 and Eclipse Oxygen.1a Release (4.7.1a) and now, when I open the project, I'm getting build path errors on classes in the javax.servlet.http package.  Specifically, the following classes are missing from my project's build path.

javax.servlet.ServletContext
javax.servlet.http.HttpServlet

If you start Eclipse from the console using the following commands (assuming Eclipse is installed in your /Applications folder):

cd  /Applications/Eclipse.app/Contents/MacOS
./eclipse

And you watch the terminal window, you'll see a bunch of stack traces similar to the following:

Nov 10, 2017 9:24:57 AM com.google.cloud.tools.eclipse.appengine.localserver.ServletClasspathProvider doResolveClasspathContainer
WARNING: Failed to initialize libraries
org.eclipse.core.runtime.CoreException: Could not resolve artifact com.google.appengine:appengine-api-1.0-sdk:jar:1.9.57
    at org.eclipse.m2e.core.internal.embedder.MavenImpl$5.call(MavenImpl.java:776)
    at org.eclipse.m2e.core.internal.embedder.MavenImpl$5.call(MavenImpl.java:1)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:177)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:151)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:99)
    at org.eclipse.m2e.core.internal.embedder.MavenImpl.resolve(MavenImpl.java:743)
    at org.eclipse.m2e.core.internal.embedder.MavenImpl.resolve(MavenImpl.java:720)
    at com.google.cloud.tools.eclipse.util.MavenUtils.resolveArtifact(MavenUtils.java:69)
    at com.google.cloud.tools.eclipse.appengine.libraries.repository.MavenHelper.resolveArtifact(MavenHelper.java:46)
    at com.google.cloud.tools.eclipse.appengine.libraries.repository.M2RepositoryService.resolveArtifact(M2RepositoryService.java:50)
    at com.google.cloud.tools.eclipse.appengine.libraries.repository.LibraryClasspathContainerResolverService.resolveLibraryFileAttachSourceSync(LibraryClasspathContainerResolverService.java:245)
    at com.google.cloud.tools.eclipse.appengine.libraries.repository.LibraryClasspathContainerResolverService.resolveLibraryAttachSourcesSync(LibraryClasspathContainerResolverService.java:106)
    at com.google.cloud.tools.eclipse.appengine.localserver.ServletClasspathProvider.doResolveClasspathContainer(ServletClasspathProvider.java:100)
    at com.google.cloud.tools.eclipse.appengine.localserver.ServletClasspathProvider.resolveClasspathContainer(ServletClasspathProvider.java:79)
    at org.eclipse.jst.server.core.RuntimeClasspathProviderDelegate.resolveClasspathContainerImpl(RuntimeClasspathProviderDelegate.java:135)
    at org.eclipse.jst.server.core.internal.RuntimeClasspathProviderWrapper.resolveClasspathContainerImpl(RuntimeClasspathProviderWrapper.java:155)
    at org.eclipse.jst.server.core.internal.RuntimeClasspathContainer.getClasspathEntries(RuntimeClasspathContainer.java:77)
    at org.eclipse.jdt.internal.core.JavaProject.resolveClasspath(JavaProject.java:2693)
    at org.eclipse.jdt.internal.core.JavaProject.resolveClasspath(JavaProject.java:2851)
    at org.eclipse.jdt.internal.core.JavaProject.getResolvedClasspath(JavaProject.java:1956)
    at org.eclipse.jdt.internal.core.ExternalFolderChange.updateExternalFoldersIfNecessary(ExternalFolderChange.java:39)
    at org.eclipse.jdt.internal.core.ChangeClasspathOperation.classpathChanged(ChangeClasspathOperation.java:59)
    at org.eclipse.jdt.internal.core.SetContainerOperation.executeOperation(SetContainerOperation.java:111)
    at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:724)
    at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2240)
    at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2267)
    at org.eclipse.jdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:795)
    at org.eclipse.jdt.internal.core.JavaModelManager$10.run(JavaModelManager.java:3001)
    at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2240)
    at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2267)
    at org.eclipse.jdt.internal.core.JavaModelManager.initializeAllContainers(JavaModelManager.java:3017)
    at org.eclipse.jdt.internal.core.JavaModelManager.getClasspathContainer(JavaModelManager.java:2038)
    at org.eclipse.jdt.core.JavaCore.getClasspathContainer(JavaCore.java:3497)
    at org.eclipse.jdt.internal.core.JavaProject.resolveClasspath(JavaProject.java:2687)
    at org.eclipse.jdt.internal.core.JavaProject.resolveClasspath(JavaProject.java:2851)
    at org.eclipse.jdt.internal.core.JavaProject.getResolvedClasspath(JavaProject.java:1956)
    at org.eclipse.jdt.internal.core.DynamicProjectReferences.getDependentProjects(DynamicProjectReferences.java:34)
    at org.eclipse.core.internal.resources.ProjectDescription.computeDynamicReferencesForProject(ProjectDescription.java:950)
    at org.eclipse.core.internal.resources.ProjectDescription.getAllBuildConfigReferences(ProjectDescription.java:265)
    at org.eclipse.core.internal.resources.ProjectDescription.getAllReferences(ProjectDescription.java:221)
    at org.eclipse.core.internal.resources.Project.getReferencedProjects(Project.java:469)
    at org.eclipse.ui.actions.CloseUnrelatedProjectsAction.buildConnectedComponents(CloseUnrelatedProjectsAction.java:78)
    at org.eclipse.ui.actions.CloseUnrelatedProjectsAction.computeRelated(CloseUnrelatedProjectsAction.java:195)
    at org.eclipse.ui.actions.CloseUnrelatedProjectsAction.getSelectedResources(CloseUnrelatedProjectsAction.java:211)
    at org.eclipse.ui.actions.SelectionListenerAction.selectionIsOfType(SelectionListenerAction.java:240)
    at org.eclipse.ui.actions.CloseResourceAction.updateSelection(CloseResourceAction.java:187)
    at org.eclipse.ui.actions.BaseSelectionListenerAction.selectionChanged(BaseSelectionListenerAction.java:124)
    at org.eclipse.ui.internal.navigator.resources.actions.ResourceMgmtActionProvider.updateActionBars(ResourceMgmtActionProvider.java:254)
    at org.eclipse.ui.internal.navigator.resources.actions.ResourceMgmtActionProvider.fillActionBars(ResourceMgmtActionProvider.java:84)
    at org.eclipse.ui.navigator.NavigatorActionService$3.run(NavigatorActionService.java:265)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.ui.navigator.NavigatorActionService.fillActionBars(NavigatorActionService.java:258)
    at org.eclipse.ui.navigator.CommonNavigatorManager$UpdateActionBarsJob$1.run(CommonNavigatorManager.java:95)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.ui.navigator.CommonNavigatorManager$UpdateActionBarsJob.runInUIThread(CommonNavigatorManager.java:89)
    at org.eclipse.ui.progress.UIJob.lambda$0(UIJob.java:95)
    at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:37)
    at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:182)
    at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4033)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3700)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1155)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1044)
    at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:153)
    at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:680)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:594)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:148)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:151)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:388)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:653)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:590)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1499)
Contains: Missing com.google.appengine:appengine-api-1.0-sdk:jar:1.9.57

With the 179.0 version of the Google Cloud SDK installed, I now have App Engine 1.9.59 installed versus 1.9.57.

The Eclipse build path contains the following libraries:

App Engine Standard Runtime [App Engine Standard Runtime]

EAR Libraries

JRE System Library [JavaSE-1.8]

TestNG

Web App Libraries

I encounter this same problem with the following Eclipse releases:

4.7.0 (Build Id: 20170620-1800)

4.7.1a (Build Id: 20171005-1200)

The following is a list of errors my project now has:

RequestDispatcher cannot be resolved to a type

The project was not built since its build path is incomplete.  Cannot find the class for javax.servlet.ServletContext.  Fix the build path then try building this project

The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path

The type javax.servlet.ServletContext cannot be resolved.  It is indirectly referenced from required .class files

Creating a new App Engine Standard Edition project as a Maven project specifies a dependency on the 1.9.57 version of the App Engine API.

<dependency>
  <groupId>com.google.appengine</groupId>
  <artifactId>appengine-api-1.0-sdk</artifactId>
  <version>1.9.57</version>
  <scope>provided</scope>
</dependency>

Created issue #2754 for this problem on GitHub under the "GoogleCloudPlatform/google-cloud-eclipse" project.

https://github.com/GoogleCloudPlatform/google-cloud-eclipse/issues/2574

Version Information

Eclipse Oxygen.1a Release (4.7.1a Build: 20171005-1200)

Google Cloud Platform for Eclipse 4.5 and later 1.4.1.201710261936

Google Cloud SDK 179.0.0

alpha 2017.09.15

app-engine-java 1.9.59

app-engine-python 1.9.62

beta 2017.09.15

bq 2.0.27

core 2017.11.06

gcd-emulator v1beta3-1.0.0

gcloud

gsutil 4.28

kubectl

pubsub-emulator 2017.09.15


问:
EditText changes background color after focus
I have an EditText inside CardView which changes its background color after gaining focus, like writing text in it. I want it to be like the second picture.

Before focus:

After focus:

Code:

```<code><android.support.v7.widget.CardView
    android:layout_width="match_parent"
    android:layout_height="56dp"
    android:clickable="true"
    android:focusable="true"
    android:focusableInTouchMode="true"
    android:foreground="?android:attr/selectableItemBackground">

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@android:color/transparent"
        android:drawableLeft="@drawable/ic_search"
        android:drawablePadding="16dp"
        android:drawableStart="@drawable/ic_search"
        android:hint="@string/search_library"
        android:imeOptions="actionSearch"
        android:inputType="textCapSentences"
        android:padding="16dp"
        android:textSize="16sp"/>
</android.support.v7.widget.CardView>
</code>```

答: Please remove the foreground attr.</p>

Body:
I have an EditText inside CardView which changes its background color after gaining focus, like writing text in it. I want it to be like the second picture.

Before focus:

After focus:

Code:

<android.support.v7.widget.CardView
    android:layout_width="match_parent"
    android:layout_height="56dp"
    android:clickable="true"
    android:focusable="true"
    android:focusableInTouchMode="true"
    android:foreground="?android:attr/selectableItemBackground">

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@android:color/transparent"
        android:drawableLeft="@drawable/ic_search"
        android:drawablePadding="16dp"
        android:drawableStart="@drawable/ic_search"
        android:hint="@string/search_library"
        android:imeOptions="actionSearch"
        android:inputType="textCapSentences"
        android:padding="16dp"
        android:textSize="16sp"/>
</android.support.v7.widget.CardView>

Body: Please remove the foreground attr.


问:
css: how to "center" a big image inside limited width and height without changing dimensions
before anything: No I don't mean centering an image inside a div

WHAT I WANT TO DO IS SIMILAR TO THE DESKTOP 'CENTER' OPTION HENCE THE TITLE PLEASE DON'T BE CONFUSED I JUST DON'T KNOW THE SUITABLE TERM OF WHAT I WANT

I am making a certian css template for my use, but I have this question that I couldn't figure out ..

basically, there is an image before each post, so the width is known. I set it to 100% of a container called "post". post has a width of 75% of the browser

```<code><div class="post">
  <h1>post title</h1>
  <img class="post-img" src="myImg.png" />
  <!--other elements-->
</div>
</code>```

css:

```<code>.post {
  width: 75%;
.post-img {
  max-width: 100%;
}
</code>```

Now to the problem ..
although the width now is fixed regardless of the image, the height is pretty much automatic

I want to set the height to a certain value, like max-height: 500px; for example .. so when a picture is big:

make width = 100% of the post div

is the height > 500px? no then make it auto. yes then crop the extra part

an image

as you can see, the black stroke is the limited width and height

the width was checked first so no extra parts to the left and right

the height is more than 500px, so it will be cropped and the viewed image would be the one inside the black frame

答:
I think what you need is to wrap your image in a container and set the maximum sizes and overflow:hidden; on that container

Something like:

```<code><div class="post">
    <h1>post title</h1>
    <div class="img-container">
        <img class="post-img" src="img.jpg" />
    </div>
</div>

<style>
    .post {
        width: 75%;
    }

   .img-container {
       max-width: 100%;
       max-height: 100px;
       overflow: hidden;
   }
</style>
</code>```

Body:
before anything: No I don't mean centering an image inside a div

WHAT I WANT TO DO IS SIMILAR TO THE DESKTOP 'CENTER' OPTION HENCE THE TITLE PLEASE DON'T BE CONFUSED I JUST DON'T KNOW THE SUITABLE TERM OF WHAT I WANT

I am making a certian css template for my use, but I have this question that I couldn't figure out ..

basically, there is an image before each post, so the width is known. I set it to 100% of a container called "post". post has a width of 75% of the browser

post title

css:

.post {
  width: 75%;
.post-img {
  max-width: 100%;
}

Now to the problem ..
although the width now is fixed regardless of the image, the height is pretty much automatic

I want to set the height to a certain value, like max-height: 500px; for example .. so when a picture is big:

make width = 100% of the post div

is the height > 500px? no then make it auto. yes then crop the extra part

an image

as you can see, the black stroke is the limited width and height

the width was checked first so no extra parts to the left and right

the height is more than 500px, so it will be cropped and the viewed image would be the one inside the black frame

Body:
I think what you need is to wrap your image in a container and set the maximum sizes and overflow:hidden; on that container

Something like:

<div class="post">
    <h1>post title</h1>
    <div class="img-container">
        <img class="post-img" src="img.jpg" />
    </div>
</div>

<style>
    .post {
        width: 75%;
    }

   .img-container {
       max-width: 100%;
       max-height: 100px;
       overflow: hidden;
   }
</style>


问:
Convert InputStream to JSONObject
I am converting InputStream to JSONObject using following code. My question is, is there any simple way to convert InputStream to JSONObject. Without doing InputStream -> BufferedReader -> StringBuilder -> loop -> JSONObject.toString(). </p>

```<code>    InputStream inputStreamObject = PositionKeeperRequestTest.class.getResourceAsStream(jsonFileName);
    BufferedReader streamReader = new BufferedReader(new InputStreamReader(inputStreamObject, "UTF-8"));
    StringBuilder responseStrBuilder = new StringBuilder();

    String inputStr;
    while ((inputStr = streamReader.readLine()) != null)
        responseStrBuilder.append(inputStr);

    JSONObject jsonObject = new JSONObject(responseStrBuilder.toString());
</code>```

答:
Simple Solution:</p>

```<code>JsonElement element = new JsonParser().parse(new InputStreamReader(inputStream));
JSONObject jsonObject = new JSONObject(element.getAsJsonObject().toString());
</code>```

Title: Convert InputStream to JSONObject

Body:
I am converting InputStream to JSONObject using following code. My question is, is there any simple way to convert InputStream to JSONObject. Without doing InputStream -> BufferedReader -> StringBuilder -> loop -> JSONObject.toString().

    InputStream inputStreamObject = PositionKeeperRequestTest.class.getResourceAsStream(jsonFileName);
    BufferedReader streamReader = new BufferedReader(new InputStreamReader(inputStreamObject, "UTF-8"));
    StringBuilder responseStrBuilder = new StringBuilder();

    String inputStr;
    while ((inputStr = streamReader.readLine()) != null)
        responseStrBuilder.append(inputStr);

    JSONObject jsonObject = new JSONObject(responseStrBuilder.toString());

Body:
Simple Solution:

JsonElement element = new JsonParser().parse(new InputStreamReader(inputStream));
JSONObject jsonObject = new JSONObject(element.getAsJsonObject().toString());


问:
Wait until paramiko exec_command is finished
I've got a python script I'm trying to install a rpm package on but when I send the command to install it doesn't wait for the command to finish before restarting the service. I've read a lot of forums about using recv_exit_status() but I don't think I'm using it right.

This is what I have:

```<code>#!/usr/bin/python

import paramiko, os
from getpass import getpass

# Setting Variables
Hosts = [ '192.168.1.1', '192.168.1.2'] #IPs changed for posting
username = 'root'
print 'Enter root password on remote computer:'
password = getpass()
port = 22
File = 'Nessus-6.11.2-es7.x86_64.rpm'

for host in Hosts:
    print 'Finished copying files. Now executing on remote computer'

    #Setting up SSH session to run commands
    remote_client = paramiko.SSHClient()
    remote_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    remote_client.connect(host, username=username, password=password)

    InstallNessus = 'rpm -U --percent %s'%File
    stdin, stdout, stderr = remote_client.exec_command(InstallNessus)
    stdout.channel.recv_exit_status()
    lines = stdout.readlines()
    for line in lines:
        print line
    stdin, stdout, stderr = remote_client.exec_command('systemctl restart nessusd.service')

    remote_client.close()
</code>```

I've tried using Fabric but I seem to be messing up my syntax somewhere.

答:
It's channel.recv_exit_status(), not stdout.channel.recv_exit_status().

However, since you are trying to run the same command over many servers, something like parallel-ssh is a better fit and much faster than paramiko, both sequentially and in parallel.

Code to do it is also much simpler, just:

```<code>from pssh.pssh2_client import ParallelSSHClient

hosts = ['192.168.1.1', '192.168.1.2']
_file = 'Nessus-6.11.2-es7.x86_64.rpm'
cmd = 'rpm -U --percent %s' % _file

client = ParallelSSHClient(hosts, user='<user>', password='<password>')

output = client.run_command(cmd)
for host, host_output in output.items():
    for line in host_output.stdout:
        print "Host %s: %s" % (host, line)
    print "Host %s exit code %s" % (host, host_output.exit_code)

restart_out = client.run_command('systemctl restart nessusd.service')
# Just wait for completion
client.join(restart_out)
</code>```

See documentation for further information.

Body:
I've got a python script I'm trying to install a rpm package on but when I send the command to install it doesn't wait for the command to finish before restarting the service. I've read a lot of forums about using recv_exit_status() but I don't think I'm using it right.

This is what I have:

#!/usr/bin/python

import paramiko, os
from getpass import getpass

# Setting Variables
Hosts = [ '192.168.1.1', '192.168.1.2'] #IPs changed for posting
username = 'root'
print 'Enter root password on remote computer:'
password = getpass()
port = 22
File = 'Nessus-6.11.2-es7.x86_64.rpm'

for host in Hosts:
    print 'Finished copying files. Now executing on remote computer'

    #Setting up SSH session to run commands
    remote_client = paramiko.SSHClient()
    remote_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    remote_client.connect(host, username=username, password=password)

    InstallNessus = 'rpm -U --percent %s'%File
    stdin, stdout, stderr = remote_client.exec_command(InstallNessus)
    stdout.channel.recv_exit_status()
    lines = stdout.readlines()
    for line in lines:
        print line
    stdin, stdout, stderr = remote_client.exec_command('systemctl restart nessusd.service')

    remote_client.close()

I've tried using Fabric but I seem to be messing up my syntax somewhere.

Body:
It's channel.recv_exit_status(), not stdout.channel.recv_exit_status().

However, since you are trying to run the same command over many servers, something like parallel-ssh is a better fit and much faster than paramiko, both sequentially and in parallel.

Code to do it is also much simpler, just:

from pssh.pssh2_client import ParallelSSHClient

hosts = ['192.168.1.1', '192.168.1.2']
_file = 'Nessus-6.11.2-es7.x86_64.rpm'
cmd = 'rpm -U --percent %s' % _file

client = ParallelSSHClient(hosts, user='<user>', password='<password>')

output = client.run_command(cmd)
for host, host_output in output.items():
    for line in host_output.stdout:
        print "Host %s: %s" % (host, line)
    print "Host %s exit code %s" % (host, host_output.exit_code)

restart_out = client.run_command('systemctl restart nessusd.service')
# Just wait for completion
client.join(restart_out)

See documentation for further information.


问:
parsing commands into tree python : multiple key dictionary?
I have a list of commands looking like this :

set_string equipment_type 3 Pump

All commands almost follow this template:

cmd_type propertyname equipment_id value

What I am trying to do is to go through a txt document full of this kind of commands and store all possible combinations of command statements. I am only interested in cmd, type, dimension of equipment_id and property name.

What I already did was using a dictionary with tuples (cmd,type,dimension) as keys and a set of property names as a value.

But I would like to add a notion of priority into this data structure : cmd then type then dimension. Is there a tree-like data structure in python that can permit me to store this kind of data? First layer would be : cmd, Second layer : type, Third layer would be : dimension and the leaves are the set of property names that can be used following the corresponding path in the tree.

Thank you for your help!

答:
One relatively clean way is the infinetely nested defaultdict tree:

```<code>from collections import defaultdict

def tree():
    return defaultdict(tree)

t = tree()
for cmd, type, dim, prop in (l.split() for l in open('file.txt')):
    t[cmd][type][dim][prop] = True
</code>```

This will allow you to iterate through all props of one (cmd, type, dim) triplet via:

```<code>for prop in t[cmd][type][dim]:
    # ...
</code>```

Body:
One relatively clean way is the infinetely nested defaultdict tree:

from collections import defaultdict

def tree():
    return defaultdict(tree)

t = tree()
for cmd, type, dim, prop in (l.split() for l in open('file.txt')):
    t[cmd][type][dim][prop] = True

This will allow you to iterate through all props of one (cmd, type, dim) triplet via:

for prop in t[cmd][type][dim]:
    # ...


问:
How do you set up a Python WSGI server under IIS?
I work in a Windows environment and would prefer to deploy code to IIS. At the same time I would like to code in Python.

Having read that IIS can run fastCGI application, I went to the IIS site where it describes in detail how to get PHP up and running but not much about anything else.

Does anyone have experience getting a Python framework running under IIS using something other that plain old CGI?

If so can you explain to direct me to some instructions on setting this up?

答: There shouldn't be any need to use FastCGI. There exists a ISAPI extension for WSGI.</p>

OwnerDisplayName: minty

LastEditorDisplayName: minty

OwnerDisplayName: John Millikin


问:
Getting coordinates of manually drawn points
I have a graph as a result of executing ListPlot[] function.
I can manually edit this graph by moving points to a different location
and also adding new points using the Drawing Tools.

How do I get the coordinates of new and changed points from the edited graphics?

答:
The easy option is to use the "Get Coordinates" menu option. If you right click on the graphic, in the pop-up menu you'll see "Get Coordinates" which allows you to mouse-over a point and see that point's coordinates. Of course this isn't going to be accurate... but the way you're editing the graphic isn't very accurate either.

You could use the InputForm (or FullForm) function, but I am not sure how well this works...

```<code>In[1]:= a = ListPlot[{{1, 0}, {0, 1}, {1, 1}}];
        a // InputForm

Out[2]//InputForm=
Graphics[{{{}, {Hue[0.67, 0.6, 0.6], Point[{{1., 0.}, {0., 1.}, {1., 1.}}]},
   {}}}, {AspectRatio -> GoldenRatio^(-1), Axes -> True, AxesOrigin -> {0, 0},
  PlotRange -> {{0., 1.}, {0., 1.}}, PlotRangeClipping -> True,
  PlotRangePadding -> {Scaled[0.02], Scaled[0.02]}}]
</code>```

You'll notice that there's a Point expression in there.

The third option would be to use Locator in some way I guess.

Body:
The easy option is to use the "Get Coordinates" menu option. If you right click on the graphic, in the pop-up menu you'll see "Get Coordinates" which allows you to mouse-over a point and see that point's coordinates. Of course this isn't going to be accurate... but the way you're editing the graphic isn't very accurate either.

You could use the InputForm (or FullForm) function, but I am not sure how well this works...

In[1]:= a = ListPlot[{{1, 0}, {0, 1}, {1, 1}}];
        a // InputForm

Out[2]//InputForm=
Graphics[{{{}, {Hue[0.67, 0.6, 0.6], Point[{{1., 0.}, {0., 1.}, {1., 1.}}]},
   {}}}, {AspectRatio -> GoldenRatio^(-1), Axes -> True, AxesOrigin -> {0, 0},
  PlotRange -> {{0., 1.}, {0., 1.}}, PlotRangeClipping -> True,
  PlotRangePadding -> {Scaled[0.02], Scaled[0.02]}}]

You'll notice that there's a Point expression in there.

The third option would be to use Locator in some way I guess.


问:
Some good answers by the rule, but cannot get them all
These are my rules, where my problem lies:

```<code>get_row([H|_],1,H):-!.
get_row([_|T],I,X) :-
    I1 is I-1,
    get_row(T,I1,X).

get_column([],_,[]).
get_column([H|T], I, [R|X]):-
   get_row(H, I, R),
   get_column(T,I,X).

good_by_coulmns(Solution) :-
      length(Solution, Length),
      forall((between(1, Length, X),
              get_column(Solution, X, Y)),
              all_distinct(Y)).

createRow(Solution, Domain, Row) :-
      maplist(member, Row, Domain),
      all_distinct(Row),
      good_by_coulmns(Solution).
      %, write(Solution), nl.

tryToSolve(Domains, Solution) :-
      maplist(createRow(Solution),
              Domains, Solution),
      length(Solution, L),
      length(Domains, L),
      good_by_coulmns(Solution).
</code>```

The problem is, that the last rule generates about 20 good answers, but, after that it goes into an infinite loop. There is a debug write in the first rule.

It writes lines like these (with always changing numbers), while looping infinitely:

```<code>[[1, 2, 3, 4], [3, 1, 4, 2], [4, 3, 2, 1], [2, 4, 1, 3], _8544, _8550, _8556, _8562]
[[1, 2, 3, 4], [3, 4, 1, 2], _8532, _8538, _8544, _8550, _8556, _8562]
</code>```

The solution, we wait is a 4x4 matrix. in the first line, if we cut out the first 4 elements, it is a good solution.

The number of variables starting with _ is always increasing, while the first line of the matrix([1,2,3,4]) is never changing.

Do you have any idea, what goes wrong here?

Actual query:

```<code>tryToSolve([[[1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4]], [[1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4]], [[1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4]], [[1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4]]], L).
</code>```

答:
To identify the problem, I will use a failure-slice. In this I insert false goals into your program. By inserting these goals, I will reduce the number of inferences your program needs to execute. If that number is still infinite, then the visible part contains an error1.

```
?- D = [1,2,3,4], D4 = [D,D,D,D], tryToSolve([D4,D4,D4,D4], L), <b>false</b>.

good_by_coulmns(Solution) :-
   length(Solution, Length), <b>false</b>,
   <s>forall((between(1, Length, X),get_column(Solution, X, Y)), all_distinct(Y))</s>.

createRow(Solution, Domain, Row) :-
   maplist(member, Row, Domain),
   all_distinct(Row),         % false, % terminates here
   good_by_coulmns(Solution), <b>false</b>.

tryToSolve(Domains, Solution) :-
   maplist(createRow(Solution), Domains, Solution), <b>false</b>,
   <s>length(Solution, L)</s>,
   <s>length(Domains, L)</s>,
   <s>good_by_coulmns(Solution)</s>.
```

This fragment does loop already. Therefore, there must be an error in the visible part. Note the variable Solution! It should be a list of fixed length to make length(Solution, Length) terminate, after all Length occurs here for the first time.

Suggestion: Put the goals length(Domains, L), length(Solution, L) first.

Some remarks on your program: forall/2 is a highly problematic construct. Avoid it at all cost. Nicely, the fragment does not contain it - that would have made the diagnosis much more complex.

Also, try to start with a shorter problem first - this simplifies the observation of termination.

How have I placed those false goals? Well, it was a bit of intuition and trial-and-error. Strictly speaking, any1 placement of false goals is ok that results in a still looping fragment. When considering all possibilities, that is ~2lines failure slices, those that are minimal are most interesting. For more, see failure-slice.

1 Actually, the precise preconditions are a bit more complex. Roughly, the obtained fragment must be pure to a certain degree.

Body:
These are my rules, where my problem lies:

get_row([H|_],1,H):-!.
get_row([_|T],I,X) :-
    I1 is I-1,
    get_row(T,I1,X).

get_column([],_,[]).
get_column([H|T], I, [R|X]):-
   get_row(H, I, R),
   get_column(T,I,X).

good_by_coulmns(Solution) :-
      length(Solution, Length),
      forall((between(1, Length, X),
              get_column(Solution, X, Y)),
              all_distinct(Y)).

createRow(Solution, Domain, Row) :-
      maplist(member, Row, Domain),
      all_distinct(Row),
      good_by_coulmns(Solution).
      %, write(Solution), nl.

tryToSolve(Domains, Solution) :-
      maplist(createRow(Solution),
              Domains, Solution),
      length(Solution, L),
      length(Domains, L),
      good_by_coulmns(Solution).

The problem is, that the last rule generates about 20 good answers, but, after that it goes into an infinite loop. There is a debug write in the first rule.

It writes lines like these (with always changing numbers), while looping infinitely:

[[1, 2, 3, 4], [3, 1, 4, 2], [4, 3, 2, 1], [2, 4, 1, 3], _8544, _8550, _8556, _8562]
[[1, 2, 3, 4], [3, 4, 1, 2], _8532, _8538, _8544, _8550, _8556, _8562]

The solution, we wait is a 4x4 matrix. in the first line, if we cut out the first 4 elements, it is a good solution.

The number of variables starting with _ is always increasing, while the first line of the matrix([1,2,3,4]) is never changing.

Do you have any idea, what goes wrong here?

Actual query:

tryToSolve([[[1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4]], [[1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4]], [[1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4]], [[1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4]]], L).

Body:
To identify the problem, I will use a failure-slice. In this I insert false goals into your program. By inserting these goals, I will reduce the number of inferences your program needs to execute. If that number is still infinite, then the visible part contains an error1.

?- D = [1,2,3,4], D4 = [D,D,D,D], tryToSolve([D4,D4,D4,D4], L), false.

good_by_coulmns(Solution) :-
   length(Solution, Length), false,
   <s>forall((between(1, Length, X),get_column(Solution, X, Y)), all_distinct(Y))</s>.

createRow(Solution, Domain, Row) :-
   maplist(member, Row, Domain),
   all_distinct(Row),         % false, % terminates here
   good_by_coulmns(Solution), false.

tryToSolve(Domains, Solution) :-
   maplist(createRow(Solution), Domains, Solution), false,
   <s>length(Solution, L)</s>,
   <s>length(Domains, L)</s>,
   <s>good_by_coulmns(Solution)</s>.

This fragment does loop already. Therefore, there must be an error in the visible part. Note the variable Solution! It should be a list of fixed length to make length(Solution, Length) terminate, after all Length occurs here for the first time.

Suggestion: Put the goals length(Domains, L), length(Solution, L) first.

Some remarks on your program: forall/2 is a highly problematic construct. Avoid it at all cost. Nicely, the fragment does not contain it - that would have made the diagnosis much more complex.

Also, try to start with a shorter problem first - this simplifies the observation of termination.

How have I placed those false goals? Well, it was a bit of intuition and trial-and-error. Strictly speaking, any1 placement of false goals is ok that results in a still looping fragment. When considering all possibilities, that is ~2lines failure slices, those that are minimal are most interesting. For more, see failure-slice.

1 Actually, the precise preconditions are a bit more complex. Roughly, the obtained fragment must be pure to a certain degree.