design models – Should a function raise exceptions based on its expected behavior or goal state?

My colleague and I discuss the correct design of an API. Let's say we have a function void deleteBlogPost(int postId). What should this function do if the blog post indexed with postId doesn’t exist?

I think it would be appropriate to throw an exception, because the function should be designed to do one thing. When the user calls a function called deleteBlogPost, they are still waiting for publication with ID postId to delete. To try to delete a message with an invalid postId does not make sense, so an exception should be thrown.

My colleague argues that the appellant does not really intend to remove a specific extension, just to make sure that after the call, the extension does not exist. If you call deleteBlogPost with a non-existent publication ID, the goal state is already reached, so nothing should happen. He also noted that this design deleteBlogPost are idempotent, but I am not convinced that this is a good thing.

We have found examples of both models in several APIs. For example, compare deleting a dictionary / card entry with a key that does not exist between Python and Java:


my_dict = {}
del my_dict('test')   # KeyError: 'test'


Map map = new HashMap<>();
map.remove("test");   // no exception thrown

Should a function raise exceptions based on its expected behavior or its goal state?

Azure: Docker application error "… the site did not start within the expected time" and "container X did not respond to HTTP pings on port 80"

I have a Flask Python application which is run via Gunicorn from a Linux Docker container. Running the Docker container on Ubuntu works fine locally, but when the container is pushed to the Azure container registry and then deployed as an Azure application, it fails with the following error messages:

  1. The my-app_900f4c container for the my-app site did not start on schedule.
  2. The my-app_900f4c container did not respond to HTTP pings on port: 80, the site startup failed.

Docker Journal

2020-02-17 INFO  - Pull Image successful, Time taken: 0 Minutes and 15 Seconds
2020-02-17 INFO  - Starting container for site
2020-02-17 INFO  - docker run -d -p 9031:80 --name my-app_900f4c -e PORT=80 -e WEBSITES_PORT=80 -e WEBSITE_SITE_NAME=my-app -e WEBSITE_AUTH_ENABLED=False -e WEBSITE_ROLE_INSTANCE_ID=0 -e -e WEBSITE_INSTANCE_ID=eaaf...51e441df96704916ba7b506b6150b26cdc7 -e HTTP_LOGGING_ENABLED=1  

2020-02-17 INFO  - Initiating warmup request to container my-app_900f4c for site my-app
2020-02-17 ERROR - Container my-app_900f4c for site my-app did not start within expected time limit. Elapsed time = 255.9515056 sec
2020-02-17 ERROR - Container my-app_900f4c didn't respond to HTTP pings on port: 80, failing site start. See container logs for debugging.
2020-02-17 INFO  - Stopping site my-app because it failed during startup.

Docker default log

2020-02-17 (1) (INFO) Starting gunicorn 20.0.4
2020-02-17 (1) (INFO) Listening at: (1)
2020-02-17 (1) (INFO) Using worker: gthread
2020-02-17 (7) (INFO) Booting worker with pid: 7
2020-02-17 (8) (INFO) Booting worker with pid: 8
2020-02-17 (9) (INFO) Booting worker with pid: 9
2020-02-17 (10) (INFO) Booting worker with pid: 10

In the Azure portal under Settings> Configuration I have the following Application settings:


FROM python:3.8-slim-buster

LABEL Name=my_app Version=0.0.1

ADD . /app

RUN python3 -m pip install --upgrade pip
RUN python3 -m pip install -r requirements.txt
CMD ("gunicorn", "-c", "", "main:app")

I don't understand what causes HTTP pings on the port 80 to failure, when the newspapers show that Gunicorn is listening

Similar questions that have do not solved the problem:

probability – Expected volume of a normal simplex

assume $ X_1, …, X_ {n + 1} $ are $ n $ i.d.d. random points $ mathbb {R} ^ n $ with distribution $ N (0, I) $ (multivariate normal with zero mean and identity covariance matrix). assume $ C $ is the convex shell of $ X_1,…, X_ {n + 1} $. It is not difficult to see that $ C $ is almost surely a $ n $-dimensionalimplex. My question is – what is the asymptotic $ n $-Dimensional Lebesgue measurement $ n to infty $?

Note that the explicit calculation of the values ​​in this sequence seems to be quite difficult in general:

For $ n = $ 1 (the simplest case) the wait is $ frac {2} { sqrt { pi} $. For $ n = 2 $ it can be represented as an integral using Heron's formula, but I'm too lazy to calculate it explicitly. How to get the exact numbers for larger dimensions is a complete mystery to me…

However, I'm not interested in exact values, but in asymptotic for $ n to infty $ (and, unfortunately, I currently have no idea how to get it).

mysql – lock-ddl-per-table option doesn't work as expected in Xtrabackup

I recently received the following errors on some of my Percona XtraBackup backups:

InnoDB: An optimized (without redo logging) DDL operation has been performed. All modified pages may not have been flushed to the disk yet.

However, I understand that this should be avoided by including --lock-ddl-per-table option.

The script I use is as follows:

xtrabackup ${MySQLConnectionString} --backup --parallel=${CPUCount} --compress --compress-threads=${CPUCount} --throttle=${throttle} --slave-info --extra-lsndir="${LogsDir}" --target-dir="${CurrentDir}" --lock-ddl-per-table

xtrabackup ${MySQLConnectionString} --backup --parallel=${CPUCount} --compress --compress-threads=${CPUCount} --throttle=${throttle} --slave-info --extra-lsndir="${LogsDir}" --target-dir="${NewDir}" --incremental-basedir="${BaseDir}" --lock-ddl-per-table

My databases are all MySQL 5.7.28 and they are slave databases. They all run on Debian 9 and use PXB version 2.4.16.

Did I misunderstand the use of this option?

Numenera – Health better than expected on NPCs

I'm looking to understand the inflation of health commonly imprinted in Cypher system hardware (often in module adventures or in small sidebars when describing configuration NPCs)

In Numenera Health (HP) is usually determined by the standard target number

Numenera – Discovery, p 222 (Also the same in the 1st edition)

Health: The target number of a creature is usually also its health, which is the amount of damage it can take before it is dead or incapacitated. For ease of reference, entries always list the health of a creature, even when it is the normal amount for a creature of its level.

Which is 3 x the Difficult level, just for reference.

The designers evade a warning that sometimes the monsters will simply break the usual defined health often for a much higher number. I remember somewhere in 1st Ed Numenera referring to this to provide more difficult fights for higher level characters.

A brief overview of Discovery / Destiny, I took a few examples:

  • Discovery p 367 – Teratoma – Level: 3 VP: 12
  • Discovery p 381 – Octopus – Level: 3 VP: 15
  • Discovery p 369 – Teratoma (M) – Level: 4 VP: 15
  • Destiny p 371 – Assassin – Level: 4 HP: 20
  • Discovery p 375 – Weymel – Level: 5 VP: 20
  • Discovery p 385 – Latos – Level: 5 VP: 25
  • Destiny p 389 – Halcus – Level: 5 HP: 20
  • Destiny p 389 – Drayva – Level: 5 HP: 20
  • Destiny p 362 – Khagun Semper – Level: 5 HP: 26
  • Destiny p 373 – Soludi – Level: 6 HP: 24
  • Destiny p 398 – Heri – Level: 6 HP: 27
  • Destiny p 398 – Scrose – Level: 7 HP: 30

There are many other examples spread over the Cypher, OG-Numenera, Discovery, Destiny, The Strange and Predation systems. And they are not unique or used liberally, HP inflation is extremely common. As you can see on this little list, creatures range from meeting a boss to little random animals with no rhyme or reason I can perceive. On all level ranges.

My question is why? Is there a systematic process for doing this? Is the standard HP suggested in the Creature section just too low? I'm looking for designer notes, or even personal GM experience to help assess the appropriate amount of HP to assign to fighters.

sharepoint online – List layout with json does not work as expected

I tried to use the json code below to create a list like a tile.

It works as expected when opened in the list, but the layout has changed when using this list as a web part on the page.

Figure 1: Open in the list

enter description of image here

Figure 2: List used as web part

enter description of image here

Is there a way to make the layout of Figure 2 identical to Figure 1?

I appreciate your great help!

Json code:

     "hideSelection": "true", 
     "hideColumnHeader": "true", 
     { "elmType": "a", 
     "href": "($URL)", 
    "target": "=if(($OpenInNewTab) == true, '_blank', '')" 
    "style": { "float": "left" }, 
    "children": ( { 
    "elmType": "div", 
    "class": "ms-bgColor-themeLighterAlt ms-bgColor-themePrimary--hover ms-fontColor-white--hover" 
    "display": "flex", 
    "flex-wrap": "wrap", 
    "min-width": "80px", 
    "min-height": "50px", 
    "margin-right": "10px", 
    "box-shadow": "2px 2px 4px darkgrey" 
    "elmType": "div", 
    "padding": "0 25%", 
    "elmType": "img", 
    "vertical-align": "top" 
    "src": "($thumbnail)" 


co.combinatorics – Question of the expected number of consecutive draws with increasing bias

This is a question I found on the book and I don't know how to deal with it. Thanks to any help or advice in advance.

I have a piece that, I could get 100% head on the first flip, $ frac {1} {3} $ on the second flip, $ frac {1} {5} $ on the third flip …… $ frac {1} {2i – 1} $ at $ i ^ {th} $ return.

Suppose I get a point when I get 4 consecutive flips (4 heads or 4 tails). If I return 100 times, what is the expected number of points I would get?

c – Problem with the Cuda program: expected "")

I'm new to Cuda programming and this is my first code in Cuda. I need serious help. I wrote a vector addition code. but when I check it seems to be fine. This is my first question on stackoverflow. Sorry for the poor framing of the question.

here is my code:

#define N 100000000
#define THREADS_PER_BLOCK 1024

__global__ void add(int *a, int *b, int *c, int n){
    int index =threadIdx.x + blockIdx.x * blockDim.x;
    if(index>>(d_a, d_b, d_c,N);
    // Copy result back to host
    cudaMemcpy(c, d_c, size, cudaMemcpyDeviceToHost);
    // Cleanup
    return 0;

I get an error in the online random function: void random (int * a, int N)
Fault: error: expected a ")"

1 error detected in the compilation of "/tmp/tmpxft_00001344_00000000-8_vectorAdd.cpp1.ii"

probability theory – From a randomized algorithm with the expected time $ O (n) $ to a reliable one with a determined execution time

Let $ A $ to be a randomized algorithm and $ F $ to be a function such as $ A $ Return $ F (x) $ on any entry $ x $. Suppose further that for the input $ x $ of size $ n $, the $ textbf {expected} $ duration $ A $ East $ O (n) $. Give an algorithm that will end in time $ O (n) $ for each entry, and which entry $ x $ the exits $ F (x) $ with probability at least $ 1- varepsilon $ and return otherwise $ { tt timeout} $.

Is there a way to do it with derandomization $ A $ and use the timer option intelligently? I have no other idea. Any help appreciated!

javascript – Select materialization cloning doesn't work as expected

I am trying to create an estimate where products can be selected.

I chose Select so that users can choose from the drop-down list.

I'm also trying to increment the ID, but it doesn't seem to increment.

In addition, cloning introduces two Selects in which the first element displays a popup and there after that the popups do not work.

Laravel blade extract



enter description of image here