beginner – Double_or_Squared(x) function python syntax error

I have been trying to create a double or square function on python where the result is to give the user the biggest number back when doubling or squaring. The problem states:

double(x) returns 2 * x square(x) returns x**2 double_or_square(x) returns the larger number between double(x) and square(x)

My code so far has been:

def double(x):
    return (2 * x)
def square(x):
    return (x ** 2)
def double_or_square(x):
    return max(d, q)
d = double
q = square

I keep getting errors, what did I do wrong?

windows 10 – Suddenly “The syntax of the command is incorrect” in batch SET line

I’m running the current version of Windows 10 (updated yesterday) and for unknown reasons, I am not able to start Maven anymore, with Windows (the PowerShell as well as the Command Prompt) giving me “The syntax of the command is incorrect” – without me having changed anything in maven. I also downloaded the most recent version, same problem. Might have to do with the recent windows update, not sure there, but it worked for years without problems.

I’ve tried to switch to @echo=on for some output where this might fail, but it really doesn’t help me much…


C:(..)apache-maven-3.8.2bin>if not "" == "" goto skipRcPre

C:(..)apache-maven-3.8.2bin>if exist "C:UsersKleanthesmavenrc_pre.bat" call "C:UsersKleanthesmavenrc_pre.bat"

C:(..)apache-maven-3.8.2bin>if exist "C:UsersKleanthesmavenrc_pre.cmd" call "C:UsersKleanthesmavenrc_pre.cmd"

C:(..)apache-maven-3.8.2bin>set ERROR_CODE=0 

The syntax of the command is incorrect.

C:(..)apache-maven-3.8.2bin>if not "C:Program FilesJavajdk-11.0.10""=="" goto OkJHome


Strangely, calling set ERROR_CODE=0 manually in the console doesn’t display any error.

php – Syntax Error, malformed JSON HTTP POST

Tengo un objeto que he pasado a JSON mediante Gson. El caso es que en mi WebService php he puesto una función que analiza si el JSON es correcto y me está dando el error:

Syntax error, malformed JSON

Este es mi funcion en php que comprueba el JSON:

function json_validate($string)
    // decode the JSON data
    $result = json_decode($string);

    // switch and check possible JSON errors
    switch (json_last_error()) {
        case JSON_ERROR_NONE:
            $error = ''; // JSON is valid // No error has occurred
        case JSON_ERROR_DEPTH:
            $error = 'The maximum stack depth has been exceeded.';
            $error = 'Invalid or malformed JSON.';
        case JSON_ERROR_CTRL_CHAR:
            $error = 'Control character error, possibly incorrectly encoded.';
        case JSON_ERROR_SYNTAX:
            $error = 'Syntax error, malformed JSON.';
        // PHP >= 5.3.3
        case JSON_ERROR_UTF8:
            $error = 'Malformed UTF-8 characters, possibly incorrectly encoded.';
        // PHP >= 5.5.0
            $error = 'One or more recursive references in the value to be encoded.';
        // PHP >= 5.5.0
        case JSON_ERROR_INF_OR_NAN:
            $error = 'One or more NAN or INF values in the value to be encoded.';
            $error = 'A value of a type that cannot be encoded was given.';
            $error = 'Unknown JSON error occured.';

    if ($error !== '') {
        // throw the Exception or exit // or whatever :)

    // everything is OK
    return $result;

Así es como recojo y compruebo el JSON en el webservice php:

    $json = file_get_contents('php://input');
    $obj = json_decode($json);

    $output = json_validate($json);

y por ultimo cómo transformo el objeto a JSON y lo envío desde Android:

public void sendPost() {

        Thread thread = new Thread(new Runnable() {
            public void run() {
                try {
                    URL url = new URL(myURL);
                    HttpURLConnection conn = (HttpURLConnection) url.openConnection();
                    conn.setRequestProperty("Content-Type", "application/json;charset=UTF-8");

                    Gson gson = new Gson();
                    String JSON = gson.toJson(miPlan);

                    DataOutputStream os = new DataOutputStream(conn.getOutputStream());
                    os.writeBytes(URLEncoder.encode(JSON, "UTF-8"));;


                    Log.i("STATUS", String.valueOf(conn.getResponseCode()));
                    Log.i("MSG" , conn.getResponseMessage());

                    StringBuffer response = null;

                    BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
                    String inputLine;
                    response = new StringBuffer();
                    while ((inputLine = in.readLine()) != null) {

Log.i("RESPUESTA" , response.toString().trim());



                } catch (Exception e) {


¿Alguien ve lo que está fallando? Muchas gracias.

testing – Where to specify mock behavior in Given-When-then syntax?

The scenario should be set up in the Given step. This involves mocking parts of the system. However, a mock might be used in the When step when that’s part of the action.

When reading your two scenarios, they both look reasonable as natural language:

  • Given a control panel in its initial state, And an engine that will fail to start, When the start button is pressed, Then the LED will become red.
  • Given a control panel in its initial state, When the start button is pressed, And the engine fails to start, Then the LED will become red.

However, the second variant does not conform to the Given-When-Then structure.

  • Given describes the initial context of the scenario.
  • When describes actions or interaction with the system.
  • Then describes the outcome of the actions.

Both of your scenarios obfuscate the actions by using passive voice: “the button is pressed”. In my experience, it is better to name an actor who interacts with the system (third-person perspective) or to write the scenario from a first-person perspective: “When the driver presses the button” or “When I press then button”.

From this, it is clear that “the engine fails to start” is not an action – it is an outcome. But asserting that as an outcome makes no sense for the scenario that you’re trying to test. That the engine will fail to start is an essential part of the context of your scenario, so it should be specified in the Given step.

I would write your scenario as:

Scenario: the engine status LED reports a failing engine.

Given a control panel
And and a broken engine
When the driver starts the car
Then the engine fails to start
And the engine status LED lights up red.

sql – Flutter Sqflite syntax error in CREATE TABLE

I created a database with sqflite in Flutter. When I try to insert data I get the error

error DatabaseException(near ")": syntax error (code 1 SQLITE_ERROR): , while compiling: CREATE TABLE nutritionTable(

My code to create a table looks like this:

  static final _dbName = 'userNutritionSql.db';
  static final _dbVersion = 1;
  static final _tableName = 'nutritionTable';

  static final columnId = '_id';
  static final columnCalories = 'calories';
  static final columnCarbs = 'carbs';
  static final columnFat = 'fat';
  static final columnProtein = 'protein';

Future _onCreate(Database db, int version) async{
    final idType = 'INTEGER PRIMARY KEY';
    final intType = 'INTEGER NOT NULL';

    await db.execute(
      CREATE TABLE $_tableName(
      $columnId $idType,
      $columnCalories $intType,
      $columnCarbs $intType,
      $columnFat $intType,
      $columnProtein $intType,

I cant spot the syntax error, does anyone has an idea whats wrong?

magento2.3.4 – SQLSTATE[42000]: Syntax error or access violation: 1142 TRIGGER command denied to user

First post so bear with me.

Magento 2.3.4

I was trying to figure out how to export products on a csv to alter the prices and import back in. I should have waited on my Developer but I found on Google – System – Data Transfer – Export.
So I went through this and exported a csv, had a look at it and thought no more of it.

Then when I went to save a product I am getting the – SQLSTATE(42000): Syntax error or access violation: 1142 TRIGGER command denied to user

Full error reads

SQLSTATE(42000): Syntax error or access violation: 1142 TRIGGER
command denied to user ‘dev_newbyhouse’@’localhost’ for table
‘catalog_product_entity’, query was: UPDATE catalog_product_entity
SET attribute_set_id = ?, type_id = ?, sku = ?, has_options =
?, required_options = ?, created_at = ?, updated_at = ?,
mageworx_is_require = ?, mst_search_weight = ? WHERE (entity_id =

So seems I have broke something

My hosting company restored a back up to the previous day when all was fine, but the error has stayed making me think it has triggered an issue on the server but the hosting company are saying they do not know and speak to a developer.
Configurable items wont save either, and when I go to cache management, there is just a white page with lots of weird code starting with

1 exception(s): Exception #0
(MagentoFrameworkExceptionValidatorException): Invalid template
file: ‘Magento_Backend::system/cache/additional.phtml’ in module:
‘Magento_Backend’ block’s name: ‘cache.additional’

Presuming all these issues are connected and I am now worried as a restore has not got rid of any of it.

python – Invalid Syntax: ImportError,e

I am trying to make migrations for my Django project, it was working and building fine before I installed and implemented the Django registration-redux module.

These are the errors I currently get and I don’t understand why or how to fix it.

 File "/Users/user/Documents/django-projects/tango_with_django_project/", line 22, in <module>
  File "/Users/user/Documents/django-projects/tango_with_django_project/", line 11, in main
    from import execute_from_command_line
  File "/opt/homebrew/lib/python3.9/site-packages/django/core/management/", line 54
    except ImportError,e:
SyntaxError: invalid syntax