问:
Perform search with filled textboxes only
I have a search bar with different search options, I want the SQL query to only search with the filled textboxes

I made a simple SP that worked fine when I had a search bar with only two search options (Name and Code) using if statements (not the best practice). However now that I had search bbars with 4-5 elements the IF statements don't seem like the best practice for performance

This is the procedure I made for the case where I only had 2 search options:

```<code>@Code_client nvarchar(50),
@Intitule_client varchar(100)
as
IF (@Code_client is not NULL AND @Code_client!='')
   BEGIN
   IF (@Intitule_client IS not NULL AND @Intitule_client!='')
      select * from Clients where Code_client=@Code_client and Intitule_client=@Intitule_client
   ELSE
      select * from Clients where Code_client=@Code_client
   END
ELSE IF (@Intitule_client is not null AND @Intitule_client!='')
    BEGIN
    select * from Clients where Intitule_client=@Intitule_client
    END
</code>```

But for this case, I have 4 search options like this:

```<code><div id="chercher_employe" class="Rechercher">
                <ul>
                    <li>
                        <asp:TextBox runat="server" ID="chercher_employe_Nom" CssClass="Input" placeholder="Nom employe"></asp:TextBox>
                    </li>

                    <li>
                        <asp:TextBox runat="server" ID="chercher_employe_Departement" CssClass="Input" placeholder="Departement"></asp:TextBox>
                    </li>

                    <li>
                        <asp:TextBox runat="server" ID="chercher_employe_occupation" CssClass="Input" placeholder="Occupation"></asp:TextBox>
                    </li>

                    <li>
                        <asp:TextBox runat="server" ID="chercher_employe_IntituleProfil" CssClass="Input" placeholder="Profil"></asp:TextBox>
                    </li>

                    <li>
                        <asp:LinkButton runat="server" CssClass="button">  <i class="fas fa-search"></i> </asp:LinkButton>
                    </li>
                </ul>
            </div>
</code>```

I can't figure out another way except for using the if statements with C# or SQL, any suggestions please?

答:
@Larnu and @jarlh proposition is what worked best for me.
This link explains it very well:
 https://blogs.sentryone.com/aaronbertrand/backtobasics-updated-kitchen-sink-example/

Thank you everyone for your answers, appreciate it :)

(Kindly write your answer down here so I can accept it if anyone had the same problem ^^)

Body:
I have a search bar with different search options, I want the SQL query to only search with the filled textboxes

I made a simple SP that worked fine when I had a search bar with only two search options (Name and Code) using if statements (not the best practice). However now that I had search bbars with 4-5 elements the IF statements don't seem like the best practice for performance

This is the procedure I made for the case where I only had 2 search options:

@Code_client nvarchar(50),
@Intitule_client varchar(100)
as
IF (@Code_client is not NULL AND @Code_client!='')
   BEGIN
   IF (@Intitule_client IS not NULL AND @Intitule_client!='')
      select * from Clients where Code_client=@Code_client and Intitule_client=@Intitule_client
   ELSE
      select * from Clients where Code_client=@Code_client
   END
ELSE IF (@Intitule_client is not null AND @Intitule_client!='')
    BEGIN
    select * from Clients where Intitule_client=@Intitule_client
    END

But for this case, I have 4 search options like this:

                        <asp:TextBox runat="server" ID="chercher_employe_Nom" CssClass="Input" placeholder="Nom employe"></asp:TextBox>

                        <asp:TextBox runat="server" ID="chercher_employe_Departement" CssClass="Input" placeholder="Departement"></asp:TextBox>

                        <asp:TextBox runat="server" ID="chercher_employe_occupation" CssClass="Input" placeholder="Occupation"></asp:TextBox>

                        <asp:TextBox runat="server" ID="chercher_employe_IntituleProfil" CssClass="Input" placeholder="Profil"></asp:TextBox>

                        <asp:LinkButton runat="server" CssClass="button">   </asp:LinkButton>

I can't figure out another way except for using the if statements with C# or SQL, any suggestions please?


来源: stackexchange

问:
Reacts this.props.children in vue.js component
React has something like this.props.children: https://facebook.github.io/react/tips/children-props-type.html

Does Vue.js have also some similar to access the child-elements?

答:
The equivalent to this.props.children in Vue is <slot />.

Example

```<code><template>
  <div>
    <slot />
  </div>
</template>
</code>```

See http://vuejs.org/guide/components.html#Content-Distribution-with-Slots

ContentLicense: CC BY-SA 3.0

Body:
The equivalent to this.props.children in Vue is <slot />.

Example

<template>
  <div>
    <slot />
  </div>
</template>

See http://vuejs.org/guide/components.html#Content-Distribution-with-Slots

ContentLicense: CC BY-SA 4.0


问:
iOS Developer Enterprise Program and iOS Developer Program
I'm got an account for iOS Developer Program.

Can I upgrade my current account to iOS Developer Enterprise Program?

Can iOS Developer Enterprise Program allow developer to distribute the application to app store?

Can iOS Developer Enterprise Program and iOS Developer Program account join together? Or it's different account?

答:
No, once you buy one of a certain type, it stays that type

No, only enterprise distribution is allowed for enterprise accounts

No, they must remain separate accounts


问:
PHP Function pt_register
I'm a beginner with PHP, I was exposed to processed HTML forms and I'm learning how to use it to do more and more...

I'm using this function (and based on Google so are a lot of people) but I really want to understand what it's doing....

```<code>function pt_register()
{
  $num_args = func_num_args();
   $vars = array();

   if ($num_args >= 2) {
       $method = strtoupper(func_get_arg(0));

       if (($method != 'SESSION') && ($method != 'GET') && ($method != 'POST') && ($method != 'SERVER') && ($method != 'COOKIE') && ($method != 'ENV')) {
           die('The first argument of pt_register must be one of the following: GET, POST, SESSION, SERVER, COOKIE, or ENV');
     }

       $varname = "HTTP_{$method}_VARS";
      global ${$varname};

       for ($i = 1; $i < $num_args; $i++) {
           $parameter = func_get_arg($i);

           if (isset(${$varname}[$parameter])) {
               global $$parameter;
               $$parameter = ${$varname}[$parameter];
          }

       }

   } else {
       die('You must specify at least two arguments');
   }

}
</code>```

Can anyone walk through this in English for me?

答:
It looks like it's trying to be a replacement for register_globals

```<code>function pt_register()
{
  // Look at the arguments passed in...
  $num_args = func_num_args();
   $vars = array();

   // .. we need at least 2 arguments
   if ($num_args >= 2) {

        // $method is the middle part of name of one of PHPs old-style variables
       $method = strtoupper(func_get_arg(0));

       if (($method != 'SESSION') && ($method != 'GET') && ($method != 'POST') && ($method != 'SERVER') && ($method != 'COOKIE') && ($method != 'ENV')) {
           die('The first argument of pt_register must be one of the following: GET, POST, SESSION, SERVER, COOKIE, or ENV');
     }

      // $varname is the whole name of the variable
       $varname = "HTTP_{$method}_VARS";

      // Make the global variable (for example HTTP_SESSION_VARS) accessible from this function
      // ${$varname} is using a technique called "variable variables"
      // If $varname == "HTTP_SESSION_VARS" then $$varname (or ${$varname}) is the same as $HTTP_SESSION_VARS
      global ${$varname};

       // For each argument after the method
       for ($i = 1; $i < $num_args; $i++) {
           $parameter = func_get_arg($i);

           // If the parameter exists in the global variable...
           if (isset(${$varname}[$parameter])) {
               // .. make it global...
               global $$parameter;
               // ... and set its value
               $$parameter = ${$varname}[$parameter];
          }

       }

   } else {
       die('You must specify at least two arguments');
   }

}
</code>```

So, a for example: pt_register('SESSION', 'foo'); does, in effect

```<code>function example()
{
    global $HTTP_SESSION_VARS;
    global $foo;
    $foo = $HTTP_SESSION_VARS['foo'];
}
</code>```

IMHO, this script is outdated and evil!
The superglobals $_SESSION etc mean you shouldn't be doing this

OwnerDisplayName: HaArD

ContentLicense: CC BY-SA 2.5

Title: PHP Function pt_register

Body:
I'm a beginner with PHP, I was exposed to processed HTML forms and I'm learning how to use it to do more and more...

I'm using this function (and based on Google so are a lot of people) but I really want to understand what it's doing....

function pt_register()
{
  $num_args = func_num_args();
   $vars = array();

   if ($num_args >= 2) {
       $method = strtoupper(func_get_arg(0));

       if (($method != 'SESSION') && ($method != 'GET') && ($method != 'POST') && ($method != 'SERVER') && ($method != 'COOKIE') && ($method != 'ENV')) {
           die('The first argument of pt_register must be one of the following: GET, POST, SESSION, SERVER, COOKIE, or ENV');
     }

       $varname = "HTTP_{$method}_VARS";
      global ${$varname};

       for ($i = 1; $i < $num_args; $i++) {
           $parameter = func_get_arg($i);

           if (isset(${$varname}[$parameter])) {
               global $$parameter;
               $$parameter = ${$varname}[$parameter];
          }

       }

   } else {
       die('You must specify at least two arguments');
   }

}

Can anyone walk through this in English for me?

LastEditorDisplayName: RoBorg

Body:
It looks like it's trying to be a replacement for register_globals

function pt_register()
{
  // Look at the arguments passed in...
  $num_args = func_num_args();
   $vars = array();

   // .. we need at least 2 arguments
   if ($num_args >= 2) {

        // $method is the middle part of name of one of PHPs old-style variables
       $method = strtoupper(func_get_arg(0));

       if (($method != 'SESSION') && ($method != 'GET') && ($method != 'POST') && ($method != 'SERVER') && ($method != 'COOKIE') && ($method != 'ENV')) {
           die('The first argument of pt_register must be one of the following: GET, POST, SESSION, SERVER, COOKIE, or ENV');
     }

      // $varname is the whole name of the variable
       $varname = "HTTP_{$method}_VARS";

      // Make the global variable (for example HTTP_SESSION_VARS) accessible from this function
      // ${$varname} is using a technique called "variable variables"
      // If $varname == "HTTP_SESSION_VARS" then $$varname (or ${$varname}) is the same as $HTTP_SESSION_VARS
      global ${$varname};

       // For each argument after the method
       for ($i = 1; $i < $num_args; $i++) {
           $parameter = func_get_arg($i);

           // If the parameter exists in the global variable...
           if (isset(${$varname}[$parameter])) {
               // .. make it global...
               global $$parameter;
               // ... and set its value
               $$parameter = ${$varname}[$parameter];
          }

       }

   } else {
       die('You must specify at least two arguments');
   }

}

So, a for example: pt_register('SESSION', 'foo'); does, in effect

function example()
{
    global $HTTP_SESSION_VARS;
    global $foo;
    $foo = $HTTP_SESSION_VARS['foo'];
}

IMHO, this script is outdated and evil!
The superglobals $_SESSION etc mean you shouldn't be doing this

OwnerDisplayName: RoBorg


问:
Simulating clicks, keyboard input etc in a web view?
I have decided to have some fun with VB.NET and make a bot for some online games.
First of all, I plan on viewing the game through a webview control, which I believe is perfectly possible... unless I can't see Flash/Java content?

If it is possible, I've been wondering how would you "simulate a click" in the web view control? And, of course, keyboard input?

答: Try for WatiN, its like testing a web application</p>


问:
Booking system remove all saved bookings during a period
I have multiple bookings in pending status. But 1 of them is paid and the status is now confirmed.

Here is an example of what I have :

```<code>id |       start_date       |        end_date       |  status
   |                        |                       |
1  |   2019-06-10 08:00:00  |  2019-06-10 20:00:00  |  pending    <-- To delete
2  |   2019-06-10 10:00:00  |  2019-06-10 13:00:00  |  confirmed
3  |   2019-06-09 06:00:00  |  2019-06-11 11:00:00  |  pending    <-- To delete
4  |   2019-06-10 21:00:00  |  2019-06-10 22:00:00  |  pending    <-- Keep it
5  |   2019-06-10 11:00:00  |  2019-06-10 12:00:00  |  pending    <-- To delete
</code>```

The id 2 is confirmed and I need to delete all other bookings in pending status who are in the same period of the confirmed status.

So I need to delete ids 1, 3 and 5

How can I do that with SQL query ?

I thought about but I'm not sure it will cover all possible cases:

```<code>DELETE FROM booking
WHERE status = 'pending'
AND start_date <= '2019-06-10 10:00:00'
AND end_date >= '2019-06-10 13:00:00'
</code>```

答:
I think you want overlapping intervals.  This would be:

```<code>DELETE b
    FROM booking b
    WHERE b.status = 'pending' AND
          b.end_date >= '2019-06-10 10:00:00' AND
          b.start_date <= '2019-06-10 13:00:00';
</code>```

Two intervals overlap if the second ends on or after the first starts, and the second starts on or before the first ends.

Body:
I have multiple bookings in pending status. But 1 of them is paid and the status is now confirmed.

Here is an example of what I have :

id |       start_date       |        end_date       |  status
   |                        |                       |
1  |   2019-06-10 08:00:00  |  2019-06-10 20:00:00  |  pending    <-- To delete
2  |   2019-06-10 10:00:00  |  2019-06-10 13:00:00  |  confirmed
3  |   2019-06-09 06:00:00  |  2019-06-11 11:00:00  |  pending    <-- To delete
4  |   2019-06-10 21:00:00  |  2019-06-10 22:00:00  |  pending    <-- Keep it
5  |   2019-06-10 11:00:00  |  2019-06-10 12:00:00  |  pending    <-- To delete

The id 2 is confirmed and I need to delete all other bookings in pending status who are in the same period of the confirmed status.

So I need to delete ids 1, 3 and 5

How can I do that with SQL query ?

I thought about but I'm not sure it will cover all possible cases:

DELETE FROM booking
WHERE status = 'pending'
AND start_date <= '2019-06-10 10:00:00'
AND end_date >= '2019-06-10 13:00:00'

Body:
I think you want overlapping intervals.  This would be:

DELETE b
    FROM booking b
    WHERE b.status = 'pending' AND
          b.end_date >= '2019-06-10 10:00:00' AND
          b.start_date <= '2019-06-10 13:00:00';

Two intervals overlap if the second ends on or after the first starts, and the second starts on or before the first ends.


问:
Is it possible to make a partial refund multiple times?
Is it possible to make partial refund using Authorize.Net? E.g. I have a transaction by 300$. First time I need to make a refund 100$ on this transaction. And second time to make a refund 50$.

What kind of transaction status will be after that?

first request:

```<code>...
      "refId": "123456",
        "transactionRequest": {
            "transactionType": "refundTransaction",
            "amount": "100.00",}
            "refTransId": "1234567890"
        }
...
</code>```

second request:

```<code>...
      "refId": "123456",
        "transactionRequest": {
            "transactionType": "refundTransaction",
            "amount": "50.00",}
            "refTransId": "1234567890"
        }
...
</code>```

答:
Yes, you can make multiple refunds against one transaction as long as you do not go over the original transaction amount.

Below I made a $50 payment and then following up with a $20 and $10 refund. Both were successful.

Here is my original AUTH_CAPTURE request:

```<code>{
  "createTransactionRequest": {
    "merchantAuthentication": {
      "name": "",
      "transactionKey": ""
    },
    "refId": 38947161,
    "transactionRequest": {
      "transactionType": "authCaptureTransaction",
      "amount": 100,
      "payment": {
        "creditCard": {
          "cardNumber": "4111111111111111",
          "expirationDate": "122020",
          "cardCode": "999"
        }
      },
      "order": {
        "invoiceNumber": "1324567890",
        "description": "this is a test transaction"
      },
      "lineItems": {
        "lineItem": [
          {
            "itemId": "1",
            "name": "vase",
            "description": "Cannes logo",
            "quantity": "18",
            "unitPrice": "45.00"
          },
          {
            "itemId": "2",
            "name": "desk",
            "description": "Big Desk",
            "quantity": "10",
            "unitPrice": "85.00"
          }
        ]
      },
      "tax": {
        "amount": "4.26",
        "name": "level2 tax name",
        "description": "level2 tax"
      },
      "duty": {
        "amount": "8.55",
        "name": "duty name",
        "description": "duty description"
      },
      "shipping": {
        "amount": "4.26",
        "name": "level2 tax name",
        "description": "level2 tax"
      },
      "poNumber": "456654",
      "customer": {
        "id": "18",
        "email": "someone@blackhole.tv"
      },
      "billTo": {
        "firstName": "Ellen",
        "lastName": "Johnson",
        "company": "Souveniropolis",
        "address": "14 Main Street",
        "city": "Pecan Springs",
        "state": "TX",
        "zip": "44628",
        "country": "USA"
      },
      "shipTo": {
        "firstName": "China",
        "lastName": "Bayles",
        "company": "Thyme for Tea",
        "address": "12 Main Street",
        "city": "Pecan Springs",
        "state": "TX",
        "zip": "44628",
        "country": "USA"
      },
      "customerIP": "192.168.1.1",
      "transactionSettings": {
        "setting": [
          {
            "settingName": "allowPartialAuth",
            "settingValue": "false"
          },
          {
            "settingName": "duplicateWindow",
            "settingValue": "0"
          },
          {
            "settingName": "emailCustomer",
            "settingValue": "false"
          },
          {
            "settingName": "recurringBilling",
            "settingValue": "false"
          },
          {
            "settingName": "testRequest",
            "settingValue": "false"
          }
        ]
      },
      "userFields": {
        "userField": {
          "name": "favorite_color",
          "value": "blue"
        }
      }
    }
  }
}
</code>```

Here is my original AUTH_CAPTURE response:

```<code>{
  "transactionResponse": {
    "responseCode": "1",
    "authCode": "TTJ26B",
    "avsResultCode": "Y",
    "cvvResultCode": "P",
    "cavvResultCode": "2",
    "transId": "40032153203",
    "refTransID": "",
    "transHash": "",
    "testRequest": "0",
    "accountNumber": "XXXX1111",
    "accountType": "Visa",
    "messages": [
      {
        "code": "1",
        "description": "This transaction has been approved."
      }
    ],
    "userFields": [
      {
        "name": "favorite_color",
        "value": "blue"
      }
    ],
    "transHashSha2": "0C9E5A47F93CD5B770A6B4AB24FE0F0D6F3B909066C72A10C4746F48C9886527A18B654736AE8D920D9048A14F2823A0DEC5B5F775A1C48DE9CBCF41C8D28CA3",
    "SupplementalDataQualificationIndicator": 0
  },
  "refId": "38947161",
  "messages": {
    "resultCode": "Ok",
    "message": [
      {
        "code": "I00001",
        "text": "Successful."
      }
    ]
  }
}
</code>```

Here is my first REFUND request (successful):

```<code>{
  "createTransactionRequest": {
    "merchantAuthentication": {
      "name": "",
      "transactionKey": ""
    },
    "refId": 30777668,
    "transactionRequest": {
      "transactionType": "refundTransaction",
      "amount": 20,
      "payment": {
        "creditCard": {
          "cardNumber": "4111111111111111",
          "expirationDate": "122020"
        }
      },
      "authCode": "40032153203"
    }
  }
}
</code>```

Here is my first REFUND response (successful):

```<code>{
  "transactionResponse": {
    "responseCode": "1",
    "authCode": "",
    "avsResultCode": "P",
    "cvvResultCode": "",
    "cavvResultCode": "",
    "transId": "40032153314",
    "refTransID": "",
    "transHash": "",
    "testRequest": "0",
    "accountNumber": "XXXX1111",
    "accountType": "Visa",
    "messages": [
      {
        "code": "1",
        "description": "This transaction has been approved."
      }
    ],
    "transHashSha2": "4CE2D83B56C09494AD5609440E3337A6DEE0F4C74FBC99B218D65F6A121EFFC269F8954AC47C17B3B739E61A860C7B0818A8497D85D314D6E0CD89C9FE71A071",
    "SupplementalDataQualificationIndicator": 0
  },
  "refId": "30777668",
  "messages": {
    "resultCode": "Ok",
    "message": [
      {
        "code": "I00001",
        "text": "Successful."
      }
    ]
  }
}
</code>```

Here is my second REFUND request (successful):

```<code>{
  "createTransactionRequest": {
    "merchantAuthentication": {
      "name": "",
      "transactionKey": ""
    },
    "refId": 40597686,
    "transactionRequest": {
      "transactionType": "refundTransaction",
      "amount": 10,
      "payment": {
        "creditCard": {
          "cardNumber": "4111111111111111",
          "expirationDate": "122020"
        }
      },
      "authCode": "40032153203"
    }
  }
}
</code>```

Here is my second REFUND response (successful):

```<code>{
  "transactionResponse": {
    "responseCode": "1",
    "authCode": "",
    "avsResultCode": "P",
    "cvvResultCode": "",
    "cavvResultCode": "",
    "transId": "40032153319",
    "refTransID": "",
    "transHash": "",
    "testRequest": "0",
    "accountNumber": "XXXX1111",
    "accountType": "Visa",
    "messages": [
      {
        "code": "1",
        "description": "This transaction has been approved."
      }
    ],
    "transHashSha2": "FD146FC0F8F3F31068905EC6C8D252662AA735ACDFAC53B4A8D808060C244C06288700AA8872466C3E240B62130D010CFBDE0473D09B631514A6E2E2CB77804F",
    "SupplementalDataQualificationIndicator": 0
  },
  "refId": "40597686",
  "messages": {
    "resultCode": "Ok",
    "message": [
      {
        "code": "I00001",
        "text": "Successful."
      }
    ]
  }
}
</code>```

Body:
Is it possible to make partial refund using Authorize.Net? E.g. I have a transaction by 300$. First time I need to make a refund 100$ on this transaction. And second time to make a refund 50$.

What kind of transaction status will be after that?

first request:

...
      "refId": "123456",
        "transactionRequest": {
            "transactionType": "refundTransaction",
            "amount": "100.00",}
            "refTransId": "1234567890"
        }
...

second request:

...
      "refId": "123456",
        "transactionRequest": {
            "transactionType": "refundTransaction",
            "amount": "50.00",}
            "refTransId": "1234567890"
        }
...

Body:
Yes, you can make multiple refunds against one transaction as long as you do not go over the original transaction amount.

Below I made a $50 payment and then following up with a $20 and $10 refund. Both were successful.

Here is my original AUTH_CAPTURE request:

{
  "createTransactionRequest": {
    "merchantAuthentication": {
      "name": "",
      "transactionKey": ""
    },
    "refId": 38947161,
    "transactionRequest": {
      "transactionType": "authCaptureTransaction",
      "amount": 100,
      "payment": {
        "creditCard": {
          "cardNumber": "4111111111111111",
          "expirationDate": "122020",
          "cardCode": "999"
        }
      },
      "order": {
        "invoiceNumber": "1324567890",
        "description": "this is a test transaction"
      },
      "lineItems": {
        "lineItem": [
          {
            "itemId": "1",
            "name": "vase",
            "description": "Cannes logo",
            "quantity": "18",
            "unitPrice": "45.00"
          },
          {
            "itemId": "2",
            "name": "desk",
            "description": "Big Desk",
            "quantity": "10",
            "unitPrice": "85.00"
          }
        ]
      },
      "tax": {
        "amount": "4.26",
        "name": "level2 tax name",
        "description": "level2 tax"
      },
      "duty": {
        "amount": "8.55",
        "name": "duty name",
        "description": "duty description"
      },
      "shipping": {
        "amount": "4.26",
        "name": "level2 tax name",
        "description": "level2 tax"
      },
      "poNumber": "456654",
      "customer": {
        "id": "18",
        "email": "someone@blackhole.tv"
      },
      "billTo": {
        "firstName": "Ellen",
        "lastName": "Johnson",
        "company": "Souveniropolis",
        "address": "14 Main Street",
        "city": "Pecan Springs",
        "state": "TX",
        "zip": "44628",
        "country": "USA"
      },
      "shipTo": {
        "firstName": "China",
        "lastName": "Bayles",
        "company": "Thyme for Tea",
        "address": "12 Main Street",
        "city": "Pecan Springs",
        "state": "TX",
        "zip": "44628",
        "country": "USA"
      },
      "customerIP": "192.168.1.1",
      "transactionSettings": {
        "setting": [
          {
            "settingName": "allowPartialAuth",
            "settingValue": "false"
          },
          {
            "settingName": "duplicateWindow",
            "settingValue": "0"
          },
          {
            "settingName": "emailCustomer",
            "settingValue": "false"
          },
          {
            "settingName": "recurringBilling",
            "settingValue": "false"
          },
          {
            "settingName": "testRequest",
            "settingValue": "false"
          }
        ]
      },
      "userFields": {
        "userField": {
          "name": "favorite_color",
          "value": "blue"
        }
      }
    }
  }
}

Here is my original AUTH_CAPTURE response:

{
  "transactionResponse": {
    "responseCode": "1",
    "authCode": "TTJ26B",
    "avsResultCode": "Y",
    "cvvResultCode": "P",
    "cavvResultCode": "2",
    "transId": "40032153203",
    "refTransID": "",
    "transHash": "",
    "testRequest": "0",
    "accountNumber": "XXXX1111",
    "accountType": "Visa",
    "messages": [
      {
        "code": "1",
        "description": "This transaction has been approved."
      }
    ],
    "userFields": [
      {
        "name": "favorite_color",
        "value": "blue"
      }
    ],
    "transHashSha2": "0C9E5A47F93CD5B770A6B4AB24FE0F0D6F3B909066C72A10C4746F48C9886527A18B654736AE8D920D9048A14F2823A0DEC5B5F775A1C48DE9CBCF41C8D28CA3",
    "SupplementalDataQualificationIndicator": 0
  },
  "refId": "38947161",
  "messages": {
    "resultCode": "Ok",
    "message": [
      {
        "code": "I00001",
        "text": "Successful."
      }
    ]
  }
}

Here is my first REFUND request (successful):

{
  "createTransactionRequest": {
    "merchantAuthentication": {
      "name": "",
      "transactionKey": ""
    },
    "refId": 30777668,
    "transactionRequest": {
      "transactionType": "refundTransaction",
      "amount": 20,
      "payment": {
        "creditCard": {
          "cardNumber": "4111111111111111",
          "expirationDate": "122020"
        }
      },
      "authCode": "40032153203"
    }
  }
}

Here is my first REFUND response (successful):

{
  "transactionResponse": {
    "responseCode": "1",
    "authCode": "",
    "avsResultCode": "P",
    "cvvResultCode": "",
    "cavvResultCode": "",
    "transId": "40032153314",
    "refTransID": "",
    "transHash": "",
    "testRequest": "0",
    "accountNumber": "XXXX1111",
    "accountType": "Visa",
    "messages": [
      {
        "code": "1",
        "description": "This transaction has been approved."
      }
    ],
    "transHashSha2": "4CE2D83B56C09494AD5609440E3337A6DEE0F4C74FBC99B218D65F6A121EFFC269F8954AC47C17B3B739E61A860C7B0818A8497D85D314D6E0CD89C9FE71A071",
    "SupplementalDataQualificationIndicator": 0
  },
  "refId": "30777668",
  "messages": {
    "resultCode": "Ok",
    "message": [
      {
        "code": "I00001",
        "text": "Successful."
      }
    ]
  }
}

Here is my second REFUND request (successful):

{
  "createTransactionRequest": {
    "merchantAuthentication": {
      "name": "",
      "transactionKey": ""
    },
    "refId": 40597686,
    "transactionRequest": {
      "transactionType": "refundTransaction",
      "amount": 10,
      "payment": {
        "creditCard": {
          "cardNumber": "4111111111111111",
          "expirationDate": "122020"
        }
      },
      "authCode": "40032153203"
    }
  }
}

Here is my second REFUND response (successful):

{
  "transactionResponse": {
    "responseCode": "1",
    "authCode": "",
    "avsResultCode": "P",
    "cvvResultCode": "",
    "cavvResultCode": "",
    "transId": "40032153319",
    "refTransID": "",
    "transHash": "",
    "testRequest": "0",
    "accountNumber": "XXXX1111",
    "accountType": "Visa",
    "messages": [
      {
        "code": "1",
        "description": "This transaction has been approved."
      }
    ],
    "transHashSha2": "FD146FC0F8F3F31068905EC6C8D252662AA735ACDFAC53B4A8D808060C244C06288700AA8872466C3E240B62130D010CFBDE0473D09B631514A6E2E2CB77804F",
    "SupplementalDataQualificationIndicator": 0
  },
  "refId": "40597686",
  "messages": {
    "resultCode": "Ok",
    "message": [
      {
        "code": "I00001",
        "text": "Successful."
      }
    ]
  }
}


问:
Need a way to add a button to this android xamarin sample
I used this sample here : https://github.com/xamarin/xamarin-forms-samples/blob/master/CustomRenderers/View/Droid/CameraPreview.cs

to get a camera feed on my project. On the IOS part, I easily added a takepicture button over the camera feed. Im trying to do the exact same thing here on the android side but I cant find a way on how to do that... Everything I tried render a blank page or throw an error.

What is the simpliest way to add a button on this camera feed? Thanks in advance

答:
This worked for me.
In the CameraPreview class just add a new View member (cameraLayoutView) and a button:

```<code>public sealed class CameraPreview : ViewGroup, ISurfaceHolderCallback
{
    View cameraLayoutView;
    global::Android.Widget.Button takePhotoButton;
}
</code>```

Then in the constructor instantiate this view and button:

```<code>public CameraPreview (Context context)
            : base (context)
{
    surfaceView = new SurfaceView (context);
    AddView (surfaceView);

    Activity activity = this.Context as Activity;
    cameraLayoutView = activity.LayoutInflater.Inflate(Resource.Layout.CameraLayout, this, false);
    AddView(cameraLayoutView);

    takePhotoButton = this.FindViewById<global::Android.Widget.Button>(Resource.Id.takePhotoButton);
    takePhotoButton.Click += TakePhotoButtonTapped;

    windowManager = Context.GetSystemService (Context.WindowService).JavaCast<IWindowManager> ();

    IsPreviewing = false;
    holder = surfaceView.Holder;
    holder.AddCallback (this);
}

async void TakePhotoButtonTapped(object sender, EventArgs e)
{
       //handle the click here
}

protected override void OnLayout (bool changed, int l, int t, int r, int b)
{
    var msw = MeasureSpec.MakeMeasureSpec (r - l, MeasureSpecMode.Exactly);
    var msh = MeasureSpec.MakeMeasureSpec (b - t, MeasureSpecMode.Exactly);

    surfaceView.Measure (msw, msh);
    surfaceView.Layout (0, 0, r - l, b - t);

    cameraLayoutView.Measure(msw, msh);
    cameraLayoutView.Layout(0, 0, r - l, b - t);
}
</code>```

Also add this layout in Resources/Layout:

```<code><?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_weight="1">
    <TextureView
        android:id="@+id/textureView"
        android:layout_marginTop="-95dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
    <Button
        android:id="@+id/toggleFlashButton"
        android:layout_width="37dp"
        android:layout_height="37dp"
        android:layout_gravity="top|left"
        android:layout_marginLeft="25dp"
        android:layout_marginTop="25dp"
        android:background="@drawable/NoFlashButton" />
    <Button
        android:id="@+id/switchCameraButton"
        android:layout_width="35dp"
        android:layout_height="26dp"
        android:layout_gravity="top|right"
        android:layout_marginRight="25dp"
        android:layout_marginTop="25dp"
        android:background="@drawable/ToggleCameraButton" />
    <Button
        android:id="@+id/takePhotoButton"
        android:layout_width="65dp"
        android:layout_height="65dp"
        android:layout_marginBottom="15dp"
        android:layout_gravity="center|bottom"
        android:background="@drawable/TakePhotoButton" />
</FrameLayout>
</code>```

And the button icons in Resources/drawable.

Body:
This worked for me.
In the CameraPreview class just add a new View member (cameraLayoutView) and a button:

public sealed class CameraPreview : ViewGroup, ISurfaceHolderCallback
{
    View cameraLayoutView;
    global::Android.Widget.Button takePhotoButton;
}

Then in the constructor instantiate this view and button:

public CameraPreview (Context context)
            : base (context)
{
    surfaceView = new SurfaceView (context);
    AddView (surfaceView);

    Activity activity = this.Context as Activity;
    cameraLayoutView = activity.LayoutInflater.Inflate(Resource.Layout.CameraLayout, this, false);
    AddView(cameraLayoutView);

    takePhotoButton = this.FindViewById<global::Android.Widget.Button>(Resource.Id.takePhotoButton);
    takePhotoButton.Click += TakePhotoButtonTapped;

    windowManager = Context.GetSystemService (Context.WindowService).JavaCast<IWindowManager> ();

    IsPreviewing = false;
    holder = surfaceView.Holder;
    holder.AddCallback (this);
}

async void TakePhotoButtonTapped(object sender, EventArgs e)
{
       //handle the click here
}

protected override void OnLayout (bool changed, int l, int t, int r, int b)
{
    var msw = MeasureSpec.MakeMeasureSpec (r - l, MeasureSpecMode.Exactly);
    var msh = MeasureSpec.MakeMeasureSpec (b - t, MeasureSpecMode.Exactly);

    surfaceView.Measure (msw, msh);
    surfaceView.Layout (0, 0, r - l, b - t);

    cameraLayoutView.Measure(msw, msh);
    cameraLayoutView.Layout(0, 0, r - l, b - t);
}

Also add this layout in Resources/Layout:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_weight="1">
    <TextureView
        android:id="@+id/textureView"
        android:layout_marginTop="-95dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
    <Button
        android:id="@+id/toggleFlashButton"
        android:layout_width="37dp"
        android:layout_height="37dp"
        android:layout_gravity="top|left"
        android:layout_marginLeft="25dp"
        android:layout_marginTop="25dp"
        android:background="@drawable/NoFlashButton" />
    <Button
        android:id="@+id/switchCameraButton"
        android:layout_width="35dp"
        android:layout_height="26dp"
        android:layout_gravity="top|right"
        android:layout_marginRight="25dp"
        android:layout_marginTop="25dp"
        android:background="@drawable/ToggleCameraButton" />
    <Button
        android:id="@+id/takePhotoButton"
        android:layout_width="65dp"
        android:layout_height="65dp"
        android:layout_marginBottom="15dp"
        android:layout_gravity="center|bottom"
        android:background="@drawable/TakePhotoButton" />
</FrameLayout>

And the button icons in Resources/drawable.


问:
How to get the variable name of GameObject
I have a list of GameObject. What I'm doing is Whenever I instantiate a prefab I stored in GameObject variable then destroy it later on.

```<code>List<GameObject> listofGameObject;
blueLine = Instantiate(monitorShapes, transform.position, transform.rotation);
</code>```

Then Later on I'll access that GameObject using listofGameObject[2]. What I'm trying to achieve is get the variable name of the GameObject stored in index 2 of listofGameObject which is blueLine. I tried using listofGameObject[2].name but it returns the name of prefab in asset.

答:
Why exactly do you need to get the variable name? You can remove the gameobject from the list, store it in a gameobject and then Destroy the gameobject.

So the code would look something like this:

```<code>//Creates the list
List<GameObject> listOfGameObjects = new List<GameObject>();
//Creates the blueLine GameObject
blueLine = Instantiate(monitorShapes, transform.position, transform.rotation);
//Adds the blueLine object to the list
listOfGameObjects.Add(blueLine);
</code>```

Then when you want to delete the object from the list you do the following:

```<code>//Removes the blueLine object from the list
listOfGameObjects.Remove(blueLine);
//Destroys the blueLine Object from the scene
Destroy(blueLine);
</code>```

I hope this is the solution you were looking for

Body:
I have a list of GameObject. What I'm doing is Whenever I instantiate a prefab I stored in GameObject variable then destroy it later on.

List<GameObject> listofGameObject;
blueLine = Instantiate(monitorShapes, transform.position, transform.rotation);

Then Later on I'll access that GameObject using listofGameObject[2]. What I'm trying to achieve is get the variable name of the GameObject stored in index 2 of listofGameObject which is blueLine. I tried using listofGameObject[2].name but it returns the name of prefab in asset.

Body:
Why exactly do you need to get the variable name? You can remove the gameobject from the list, store it in a gameobject and then Destroy the gameobject.

So the code would look something like this:

//Creates the list
List<GameObject> listOfGameObjects = new List<GameObject>();
//Creates the blueLine GameObject
blueLine = Instantiate(monitorShapes, transform.position, transform.rotation);
//Adds the blueLine object to the list
listOfGameObjects.Add(blueLine);

Then when you want to delete the object from the list you do the following:

//Removes the blueLine object from the list
listOfGameObjects.Remove(blueLine);
//Destroys the blueLine Object from the scene
Destroy(blueLine);

I hope this is the solution you were looking for


问:
Downloading picture with text in ReactJS
I created a react app for a tutorial and it writes text over an uploaded image. The user after image upload types in Top Box and Bottom Box but when I try to save the image after the user has typed text, no text shows up. Can anyone please help as I want the image to be downloaded with text.

The files are Header.js with code:

```<code>import React, {Component} from 'react';
import logo from './logo.svg';
import './App.css';
import CardMedia from '@material-ui/core/CardMedia';
import { withStyles } from '@material-ui/core/styles';
import CardActionArea from '@material-ui/core/CardActionArea';
import { Card, CardContent } from "@material-ui/core";
import IconButton from '@material-ui/core/IconButton';
import PhotoCamera from '@material-ui/icons/PhotoCamera';

const styles = theme => ({
  media: {
      display: 'flex',
      height: 400,
      objectFit: 'contain',
      alignItems: 'center',
  },
})

class Header extends Component {
  render() {
    const {classes} = this.props;
    return(
      <Card >
        <CardContent >
          <div style={{position:'relative'}}>
            <CardMedia
              component="img"
              image = {this.props.imageIn}
            />
            <div style={{position: 'absolute', color: 'white', top: '5%', left: '50%', transform:'translateX(-50%)'}}>
              {this.props.topText}
            </div>

            <div style={{position: 'absolute', color: 'white', bottom: '5%', left: '50%', transform:'translateX(-50%)'}}>
              {this.props.bottomText}
            </div>
          </div>
        </CardContent>
      </Card>

    );
  }
}

export default withStyles(styles)(Header)
</code>```

and App.js as:

```<code>import React, {Component} from 'react';
import logo from './logo.svg';
import './App.css';
import CardMedia from '@material-ui/core/CardMedia';
import { withStyles } from '@material-ui/core/styles';
import CardActionArea from '@material-ui/core/CardActionArea';
import { Card, CardContent } from "@material-ui/core";
import Header from './Header';
import Grid from '@material-ui/core/Grid';
import TextField from '@material-ui/core/TextField';
import IconButton from '@material-ui/core/IconButton';
import PhotoCamera from '@material-ui/icons/PhotoCamera';

const styles = (theme) => ({
  input: {
      display: 'none'
  }
});

class App extends Component{
  state = {
    topText: '',
    bottomText: '',
    randomImg: "http://i.imgflip.com/1bij.jpg",
    allImages: [],
    images: []
  }

  handleChange = (event) => {
    const {name, value} = event.target
    this.setState({ [name]: value })
  }

  handleCapture = ({ target }) => {
    const fileReader = new FileReader();
    const name = target.accept.includes('image') ? 'images' : 'videos';

    fileReader.readAsDataURL(target.files[0]);
    fileReader.onload = (e) => {
        this.setState((prevState) => ({
            [name]: [...prevState[name], e.target.result]
        }));
    };
};

  render() {
    return(
      <div>
        <input
          accept="image/*"
          style={{display: 'none'}}
          id="icon-button-photo"
          onChange={this.handleCapture}
          type="file"
        />
        <label htmlFor="icon-button-photo">
          <IconButton color="primary" component="span">
              <PhotoCamera />
          </IconButton>
        </label>

        <Grid container justify="left" spacing={8}>
          <Grid item xs={12} sm={6}>
            <TextField
              id="standard-name"
              label="Top Text"
              name = "topText"
              value={this.state.topText}
              onChange={this.handleChange}
              margin="normal"
              variant="filled"
            />
          </Grid>

          <Grid item xs={12} sm={6}>
            <TextField
              id="standard-name"
              label="Bottom Text"
              name = "bottomText"
              value={this.state.bottomText}
              onChange={this.handleChange}
              margin="normal"
              variant="filled"
            />
          </Grid>
          <Header topText = {this.state.topText} bottomText = {this.state.bottomText} imageIn = {this.state.images}/>
        </Grid>
      </div>
    )
  }
}

export default App
</code>```

答:
In your code the texts are distinct elements (childs of the div's in below code):

```<code>            <CardMedia
              component="img"
              image = {this.props.imageIn}
            />
            <div style={{position: 'absolute', color: 'white', top: '5%', left: '50%', transform:'translateX(-50%)'}}>
              {this.props.topText}
            </div>

            <div style={{position: 'absolute', color: 'white', bottom: '5%', left: '50%', transform:'translateX(-50%)'}}>
              {this.props.bottomText}
            </div>
          </div>
</code>```

Rather you may try to incorporate the text into image like:

```<code>    const canvas = this.refs.canvas;
    const ctx = canvas.getContext("2d");
    const img = this.refs.image;

    img.onload = () => {
      ctx.drawImage(img, 0, 0);
      ctx.font = "40px Courier";
      ctx.fillText(this.props.text, 210, 75); // THIS IS THE PLACE TEXT IS EMBEDDED INTO THE PICTURE
    };
</code>```

In this code sandbox link, https://codesandbox.io/s/blazing-sun-e2bgf , you can find a simple class named Canvas which uses above method so that when the file is saved you can see the text.

One catch here, the example I provided is free from material UI. You are using CardMedia class which takes the image and shows it. But in the example I provided, the method is generic. So you can place the image seperately in the card.

Credit: https://blog.cloudboost.io/using-html5-canvas-with-react-ff7d93f5dc76

Body:
I created a react app for a tutorial and it writes text over an uploaded image. The user after image upload types in Top Box and Bottom Box but when I try to save the image after the user has typed text, no text shows up. Can anyone please help as I want the image to be downloaded with text.

The files are Header.js with code:

import React, {Component} from 'react';
import logo from './logo.svg';
import './App.css';
import CardMedia from '@material-ui/core/CardMedia';
import { withStyles } from '@material-ui/core/styles';
import CardActionArea from '@material-ui/core/CardActionArea';
import { Card, CardContent } from "@material-ui/core";
import IconButton from '@material-ui/core/IconButton';
import PhotoCamera from '@material-ui/icons/PhotoCamera';

const styles = theme => ({
  media: {
      display: 'flex',
      height: 400,
      objectFit: 'contain',
      alignItems: 'center',
  },
})

class Header extends Component {
  render() {
    const {classes} = this.props;
    return(
      <Card >
        <CardContent >

            <CardMedia
              component="img"
              image = {this.props.imageIn}
            />

              {this.props.topText}

              {this.props.bottomText}

        </CardContent>
      </Card>

    );
  }
}

export default withStyles(styles)(Header)

and App.js as:

import React, {Component} from 'react';
import logo from './logo.svg';
import './App.css';
import CardMedia from '@material-ui/core/CardMedia';
import { withStyles } from '@material-ui/core/styles';
import CardActionArea from '@material-ui/core/CardActionArea';
import { Card, CardContent } from "@material-ui/core";
import Header from './Header';
import Grid from '@material-ui/core/Grid';
import TextField from '@material-ui/core/TextField';
import IconButton from '@material-ui/core/IconButton';
import PhotoCamera from '@material-ui/icons/PhotoCamera';

const styles = (theme) => ({
  input: {
      display: 'none'
  }
});

class App extends Component{
  state = {
    topText: '',
    bottomText: '',
    randomImg: "http://i.imgflip.com/1bij.jpg",
    allImages: [],
    images: []
  }

  handleChange = (event) => {
    const {name, value} = event.target
    this.setState({ [name]: value })
  }

  handleCapture = ({ target }) => {
    const fileReader = new FileReader();
    const name = target.accept.includes('image') ? 'images' : 'videos';

    fileReader.readAsDataURL(target.files[0]);
    fileReader.onload = (e) => {
        this.setState((prevState) => ({
            [name]: [...prevState[name], e.target.result]
        }));
    };
};

  render() {
    return(

        <input
          accept="image/*"
          style={{display: 'none'}}
          id="icon-button-photo"
          onChange={this.handleCapture}
          type="file"
        />

          <IconButton color="primary" component="span">
              <PhotoCamera />
          </IconButton>

        <Grid container justify="left" spacing={8}>
          <Grid item xs={12} sm={6}>
            <TextField
              id="standard-name"
              label="Top Text"
              name = "topText"
              value={this.state.topText}
              onChange={this.handleChange}
              margin="normal"
              variant="filled"
            />
          </Grid>

          <Grid item xs={12} sm={6}>
            <TextField
              id="standard-name"
              label="Bottom Text"
              name = "bottomText"
              value={this.state.bottomText}
              onChange={this.handleChange}
              margin="normal"
              variant="filled"
            />
          </Grid>

        </Grid>

    )
  }
}

export default App

Body:
In your code the texts are distinct elements (childs of the div's in below code):

            <CardMedia
              component="img"
              image = {this.props.imageIn}
            />
            <div style={{position: 'absolute', color: 'white', top: '5%', left: '50%', transform:'translateX(-50%)'}}>
              {this.props.topText}
            </div>

            <div style={{position: 'absolute', color: 'white', bottom: '5%', left: '50%', transform:'translateX(-50%)'}}>
              {this.props.bottomText}
            </div>
          </div>

Rather you may try to incorporate the text into image like:

    const canvas = this.refs.canvas;
    const ctx = canvas.getContext("2d");
    const img = this.refs.image;

    img.onload = () => {
      ctx.drawImage(img, 0, 0);
      ctx.font = "40px Courier";
      ctx.fillText(this.props.text, 210, 75); // THIS IS THE PLACE TEXT IS EMBEDDED INTO THE PICTURE
    };

In this code sandbox link, https://codesandbox.io/s/blazing-sun-e2bgf , you can find a simple class named Canvas which uses above method so that when the file is saved you can see the text.

One catch here, the example I provided is free from material UI. You are using CardMedia class which takes the image and shows it. But in the example I provided, the method is generic. So you can place the image seperately in the card.

Credit: https://blog.cloudboost.io/using-html5-canvas-with-react-ff7d93f5dc76


问:
I need help to modify a very basic loop to use indexes instead of variable names
new to programming. I have an issue where I need to modify a loop that searches a list in order to use indexes and start at index 1.

```<code># find the coldest day in a range of daily temps
## input: 7 days worth of temps
temps = [7, 4, 1, -9, 18, 32, 10]

## output: lowest temp among the list
coolest = temps[0]

for temperature in temps:
    if temperature < coolest:
        coolest = temperature
print (coolest)
</code>```

I want to change this so that we start at index 1, since using the current implementation causes a redundant step on the first iteration.

Many thanks, Michael

答:
A very short and preferable way to find the minimum temperature value in the list is using pythons min function

```<code>coolest = min(temps)
</code>```

If you want to write a loop over a list with indices, you can do it like that (it is what people are used to from other languages like C, but not recommended in python unless you really need the index, which is not the case here):

```<code>coolest = temps[0]

for i in range(1,len(temps)):
    if temps[i] < coolest:
        coolest = temps[i]
print (coolest)
</code>```

index i will start at 1 up to the length of the list temps.

I agree with Paritosh Singhs concerns in the comments and therefore want to point out the link there with further descriptions why it is bad practise to loop with indices in python.

Since you might see this very often, in my opinion it is good to know how it works when you also know why and when not to use it. I recommend to follow the link in the comment below.

Body:
new to programming. I have an issue where I need to modify a loop that searches a list in order to use indexes and start at index 1.

# find the coldest day in a range of daily temps
## input: 7 days worth of temps
temps = [7, 4, 1, -9, 18, 32, 10]

## output: lowest temp among the list
coolest = temps[0]

for temperature in temps:
    if temperature < coolest:
        coolest = temperature
print (coolest)

I want to change this so that we start at index 1, since using the current implementation causes a redundant step on the first iteration.

Many thanks, Michael

Body:
A very short and preferable way to find the minimum temperature value in the list is using pythons min function

coolest = min(temps)

If you want to write a loop over a list with indices, you can do it like that (it is what people are used to from other languages like C, but not recommended in python unless you really need the index, which is not the case here):

coolest = temps[0]

for i in range(1,len(temps)):
    if temps[i] < coolest:
        coolest = temps[i]
print (coolest)

index i will start at 1 up to the length of the list temps.

I agree with Paritosh Singhs concerns in the comments and therefore want to point out the link there with further descriptions why it is bad practise to loop with indices in python.

Since you might see this very often, in my opinion it is good to know how it works when you also know why and when not to use it. I recommend to follow the link in the comment below.


问:
How to set environment variable for google cloud speech API in php
I have installed google cloud SDK and trying set environment variable, so I could not do the configuration for google cloud speech API please help me to understand and integrate google API into my system

I have installed google cloud SDK powershell and tried to set environment variable with folder name i.e:

set GOOGLE_APPLICATION_CREDENTIALS="[C:\Users\Desktop\s\google speech\My-9ef3b2edbbdb.json]"

答:
As described in Apache documentation, you should add to the .htaccess file or in the httpd.conf file.

```<code>SetEnv GOOGLE_APPLICATION_CREDENTIALS C:\Users\Desktop\s\google speech\My-9ef3b2edbbdb.json
</code>```

After you saved httpd.conf, the apache server should be reloaded. Otherwise, the environment variable will not be set in this apache session!

Be careful, the Apache module mod_env shall be installed.

Body:
As described in Apache documentation, you should add to the .htaccess file or in the httpd.conf file.

SetEnv GOOGLE_APPLICATION_CREDENTIALS C:\Users\Desktop\s\google speech\My-9ef3b2edbbdb.json

After you saved httpd.conf, the apache server should be reloaded. Otherwise, the environment variable will not be set in this apache session!

Be careful, the Apache module mod_env shall be installed.


问:
Maven: Failed to read artifact descriptor
I am hoping someone can help me with a problem I am struggling with.

When I try to build my project from the terminal I get this error:

```<code>Failed to read artifact descriptor for com.morrislgn.merchandising.common:test-data-utils:jar:0.3b-SNAPSHOT: Could not find artifact com.morrislgn.merchandising:merchandising:pom:0.3b-SNAPSHOT
</code>```

The common.test-data-utils jar is created by a separate project and shared between this and another project (the other project doesn't build either, but that is down to another problem).

I am able to build com.morrislgn.merchandising.common:test-data-utils without issue, I can see the entry it makes in the .m2 local repository on my machine. I have reindexed my repository in Eclipse also.

The POM for my project has this entry:

```<code><dependency>
    <groupId>com.morrislgn.merchandising.common</groupId>
    <artifactId>test-data-utils</artifactId>
    <version>0.3b-SNAPSHOT</version>
</dependency>
</code>```

Which appears to be correct to me - the POM doesn't report any errors either when it is viewed in Eclipse.

Can some one tell me what I am missing here or doing wrong?

答:
Navigate via shell inside of your project folder and run following command:

mvn -U clean install
```

<p>Usually this should already solve your problem.</p>

<p>If you see a message like this:</p>

<blockquote>
  <p>Could not resolve dependencies for project :war:0.0.1-SNAPSHOT: Failed to collect dependencies at com.sun.jersey:jersey-server:jar:1.9</p>
</blockquote>

<p>Then execute:</p>

<pre class="lang-sh prettyprint-override"><code>export MAVEN_OPTS=-Dhttps.protocols=TLSv1,TLSv1.1,TLSv1.2
</code>```

followed by:

mvn -U clean install
```

<p>again to finally update your dependencies. </p>

<p>Afterwards perform clean maven build: </p>

<pre class="lang-sh prettyprint-override"><code>maven clean install
</code>```

Body:
I am hoping someone can help me with a problem I am struggling with.

When I try to build my project from the terminal I get this error:

Failed to read artifact descriptor for com.morrislgn.merchandising.common:test-data-utils:jar:0.3b-SNAPSHOT: Could not find artifact com.morrislgn.merchandising:merchandising:pom:0.3b-SNAPSHOT

The common.test-data-utils jar is created by a separate project and shared between this and another project (the other project doesn't build either, but that is down to another problem).

I am able to build com.morrislgn.merchandising.common:test-data-utils without issue, I can see the entry it makes in the .m2 local repository on my machine. I have reindexed my repository in Eclipse also.

The POM for my project has this entry:

<dependency>
    <groupId>com.morrislgn.merchandising.common</groupId>
    <artifactId>test-data-utils</artifactId>
    <version>0.3b-SNAPSHOT</version>
</dependency>

Which appears to be correct to me - the POM doesn't report any errors either when it is viewed in Eclipse.

Can some one tell me what I am missing here or doing wrong?

Body:
Navigate via shell inside of your project folder and run following command:

mvn -U clean install

Usually this should already solve your problem.

If you see a message like this:

Could not resolve dependencies for project :war:0.0.1-SNAPSHOT: Failed to collect dependencies at com.sun.jersey:jersey-server:jar:1.9

Then execute:

export MAVEN_OPTS=-Dhttps.protocols=TLSv1,TLSv1.1,TLSv1.2

followed by:

mvn -U clean install

again to finally update your dependencies.

Afterwards perform clean maven build:

maven clean install


问:
How to apply colors programmatically to app theme?
I have some problem about apply colors to my app.
I want to achieve to get some json from the web, like this:

```<code>{
   "colorPrimary": "#45a02c",
   "colorAccent": "#a02c2c",
   "backgroundColor": "#FFFFFF"
}
</code>```

and store it in a object like ThemeColor, i created. Parsing the json to object is no problem, but now i want to create a method in my ThemeColor class,  that will apply the colors of the object to my app, so that my toolbar will colored in this primary color or i can use it with ?attr/colorPrimary .

Is that possible?
And what would be a good way to achieve this?

答:
Define your custom theme inside style.xml and use that inside your activity

style.xml

```<code><style name="CustomTheme" parent="Theme.AppCompat.NoActionBar">
     <!-- Customize your theme here. -->
     <item name="colorPrimary">@color/your_custom_color</item>
     <item name="colorPrimaryDark">@color/your_custom_color_2</item>
     <item name="android:navigationBarColor">@color/your_custom_colot_3</item>
</style>
</code>```

And use that theme inside your activity

```<code>public void onCreate(Bundle savedInstanceState) {
    setTheme(android.R.style.CustomTheme); //here your custom theme
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_second);
}
</code>```

Body:
I have some problem about apply colors to my app.
I want to achieve to get some json from the web, like this:

{
   "colorPrimary": "#45a02c",
   "colorAccent": "#a02c2c",
   "backgroundColor": "#FFFFFF"
}

and store it in a object like ThemeColor, i created. Parsing the json to object is no problem, but now i want to create a method in my ThemeColor class,  that will apply the colors of the object to my app, so that my toolbar will colored in this primary color or i can use it with ?attr/colorPrimary .

Is that possible?
And what would be a good way to achieve this?

Body:
Define your custom theme inside style.xml and use that inside your activity

style.xml

<style name="CustomTheme" parent="Theme.AppCompat.NoActionBar">
     <!-- Customize your theme here. -->
     <item name="colorPrimary">@color/your_custom_color</item>
     <item name="colorPrimaryDark">@color/your_custom_color_2</item>
     <item name="android:navigationBarColor">@color/your_custom_colot_3</item>
</style>

And use that theme inside your activity

public void onCreate(Bundle savedInstanceState) {
    setTheme(android.R.style.CustomTheme); //here your custom theme
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_second);
}


问:
I am Using AES ECB 256 padding - Encryption to send data , but Decryption i am not able to achieve
I am sending data to API and They uses Java Function, I Replicated Encryption in PHP but I am unable to Decrypt Response Data.

I tried Various Encryption but They Strictly Use this Encryption Decryption, I cannot Change Encryption I had to follow this.

Encryption Function Works Properly:

```<code>function encrypt($input, $key) {
        $size = mcrypt_get_block_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB);
        $input = pkcs5_pad($input, $size);
        $td = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_ECB, '');
        $iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
        mcrypt_generic_init($td, $key, $iv);
        $data = mcrypt_generic($td, $input);
        mcrypt_generic_deinit($td);
        mcrypt_module_close($td);
        $data = base64_encode($data);
        return $data;
    }

    function pkcs5_pad($text, $blocksize) {
        $pad = $blocksize - (strlen($text) % $blocksize);
        return $text . str_repeat(chr($pad), $pad);
    }

</code>```

Decryption Function I tried:

```<code>function decrypt($sStr, $sKey) {
        $decrypted = mcrypt_decrypt(
                MCRYPT_RIJNDAEL_128, $sKey, base64_decode($sStr), MCRYPT_MODE_ECB
        );
        $dec_s = strlen($decrypted);
        $padding = ord($decrypted[$dec_s - 1]);
        $decrypted = substr($decrypted, 0, -$padding);
        return $decrypted;
    }

</code>```

As an Output I am Getting ??? which is wrong Encryption.

Do not Duplicate this As I have Searched More than 3 hours, then I posted Question.

答:
```<code>function decrypt($sStr, $sKey) {
        $decrypted = mcrypt_decrypt(
                MCRYPT_RIJNDAEL_128, $sKey, base64_decode($sStr), MCRYPT_MODE_ECB
        );
        $dec_s = strlen($decrypted);
        $padding = ord($decrypted[$dec_s - 1]);
        $decrypted = substr($decrypted, 0, -$padding);
        $decrypted = base64_encode($decrypted );    //This line Added.
        return $decrypted;
    }
</code>```

I was getting Byte format I wasn't converting the data into base64_encode, Now It is Working.

Body:
I am sending data to API and They uses Java Function, I Replicated Encryption in PHP but I am unable to Decrypt Response Data.

I tried Various Encryption but They Strictly Use this Encryption Decryption, I cannot Change Encryption I had to follow this.

Encryption Function Works Properly:

function encrypt($input, $key) {
        $size = mcrypt_get_block_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB);
        $input = pkcs5_pad($input, $size);
        $td = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_ECB, '');
        $iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
        mcrypt_generic_init($td, $key, $iv);
        $data = mcrypt_generic($td, $input);
        mcrypt_generic_deinit($td);
        mcrypt_module_close($td);
        $data = base64_encode($data);
        return $data;
    }

    function pkcs5_pad($text, $blocksize) {
        $pad = $blocksize - (strlen($text) % $blocksize);
        return $text . str_repeat(chr($pad), $pad);
    }

Decryption Function I tried:

function decrypt($sStr, $sKey) {
        $decrypted = mcrypt_decrypt(
                MCRYPT_RIJNDAEL_128, $sKey, base64_decode($sStr), MCRYPT_MODE_ECB
        );
        $dec_s = strlen($decrypted);
        $padding = ord($decrypted[$dec_s - 1]);
        $decrypted = substr($decrypted, 0, -$padding);
        return $decrypted;
    }

As an Output I am Getting ??? which is wrong Encryption.

Do not Duplicate this As I have Searched More than 3 hours, then I posted Question.

Body:
function decrypt($sStr, $sKey) {
        $decrypted = mcrypt_decrypt(
                MCRYPT_RIJNDAEL_128, $sKey, base64_decode($sStr), MCRYPT_MODE_ECB
        );
        $dec_s = strlen($decrypted);
        $padding = ord($decrypted[$dec_s - 1]);
        $decrypted = substr($decrypted, 0, -$padding);
        $decrypted = base64_encode($decrypted );    //This line Added.
        return $decrypted;
    }

I was getting Byte format I wasn't converting the data into base64_encode, Now It is Working.


问:
Efficiently matching Words against a sorted Vocabulary in Python
On one hand, I have an alphabetically sorted noun vocabulary (#7000)

```<code>aardvark
abacus
abbey
abbreviation
abdomen
ability
abnormal
</code>```

On the other hand I have a set of words (#1E6)

```<code>['Hello', 'airport', 'really', 'sorry', 'to', 'hear', 'this'...]
</code>```

What is the most efficient way to find out if a word is present in the vocabulary, and the index?

I could simply use lists/arrays and compare strings, but this does not take advantage of the alphabetic sorting of the vocabulary

答:
As commented previously:

```<code>>>> vocab = ['a', 'b', 'c']
>>> vocab_lookup = {k:v for v,k in enumerate(vocab)}
</code>```

And now all you need to use is dict.get or simply dict[]

```<code>>>> 'a' in vocab_lookup
True
>>> 'd' in vocab_lookup
False
>>> vocab_lookup.get('a')
0
>>> vocab_lookup.get('d')
>>> # None
</code>```

Body:
On one hand, I have an alphabetically sorted noun vocabulary (#7000)

aardvark
abacus
abbey
abbreviation
abdomen
ability
abnormal

On the other hand I have a set of words (#1E6)

['Hello', 'airport', 'really', 'sorry', 'to', 'hear', 'this'...]

What is the most efficient way to find out if a word is present in the vocabulary, and the index?

I could simply use lists/arrays and compare strings, but this does not take advantage of the alphabetic sorting of the vocabulary

Body:
As commented previously:

>>> vocab = ['a', 'b', 'c']
>>> vocab_lookup = {k:v for v,k in enumerate(vocab)}

And now all you need to use is dict.get or simply dict[]

>>> 'a' in vocab_lookup
True
>>> 'd' in vocab_lookup
False
>>> vocab_lookup.get('a')
0
>>> vocab_lookup.get('d')
>>> # None


问:
Awk with an IF condition
I have a file called: input:

```<code>160957 docliente_up hdfs://nameservice1/user/hive/warehouse/docliente_up.db
160958 docliente_bu hdfs://nameservice1/user/hive/warehouse/docliente_bu.db
</code>```

I am using awk to compare $2 with words ending in up

```<code>awk '{ if ($2 = "*_up" )
print "UPDATE DBS SET DB_LOCATION_URI=\"hdfs://nameservice1/databases_users/" $2"\"" " WHERE DB_ID=\""$1"\";";
else
print "UPDATE DBS SET DB_LOCATION_URI=\"hdfs://nameservice1/databases/" $2"\"" " WHERE DB_ID=\""$1"\";";}' input
</code>```

but isn't work. I have been looking for a expresion to solve my problems but I can't find it.

答:
Could you please try following.

```<code>awk '($2 ~ /_up$/){print "UPDATE DBS SET DB_LOCATION_URI=\"hdfs://nameservice1/databases_users/" $2"\"" " WHERE DB_ID=\""$1"\";"}'  Input_file
</code>```

Output will be as follows.

```<code>UPDATE DBS SET DB_LOCATION_URI="hdfs://nameservice1/databases_users/docliente_up" WHERE DB_ID="160957";
</code>```

Title: Awk with an IF condition

Body:
I have a file called: input:

160957 docliente_up hdfs://nameservice1/user/hive/warehouse/docliente_up.db
160958 docliente_bu hdfs://nameservice1/user/hive/warehouse/docliente_bu.db

I am using awk to compare $2 with words ending in up

awk '{ if ($2 = "*_up" )
print "UPDATE DBS SET DB_LOCATION_URI=\"hdfs://nameservice1/databases_users/" $2"\"" " WHERE DB_ID=\""$1"\";";
else
print "UPDATE DBS SET DB_LOCATION_URI=\"hdfs://nameservice1/databases/" $2"\"" " WHERE DB_ID=\""$1"\";";}' input

but isn't work. I have been looking for a expresion to solve my problems but I can't find it.

Body:
Could you please try following.

awk '($2 ~ /_up$/){print "UPDATE DBS SET DB_LOCATION_URI=\"hdfs://nameservice1/databases_users/" $2"\"" " WHERE DB_ID=\""$1"\";"}'  Input_file

Output will be as follows.

UPDATE DBS SET DB_LOCATION_URI="hdfs://nameservice1/databases_users/docliente_up" WHERE DB_ID="160957";


问:
No full-size app banner :Eligibility issues by version
I am trying to publish an update to my android app and the review done by play console is rejecting the app. I have added different xhdpi icons and changed the app title as well. More than 4-5 iterations have been done.

I have already added xhdpi icons and changed the title of the icons/banners to match the app title. Added icons in the drawable folder

No specific code.

Successful app publishing.

Please refer the message

Following is the message:-

答:
I want to post an update here. The issue got resolved when I added the app title on the image used as a banner/icon.

I received a detailed response from Google Playstore team that my app banner/icon was not having app title which should be visible for end users trying to lauch the app from launcher.

Following was the response.

Please note that our banner requirements are as follows:  App name
  must be included in the image.


问:
Replacing duplicate list elements with NaN
I would like to replace all duplicates of elements in arrays with NaN.
For example:

```<code>a = [1, 1, 2, 3, 1, 8, 5, 6, 7, 5, 5]
</code>```

Goal:

```<code>a = [NaN, NaN, 2, 3, NaN, 8, NaN, 6, 7, NaN, NaN]
</code>```

答:
it is not pretty but i think it keeps the cost low.</p>

```<code>import math

seen = []
a = [1, 1, 2, 3, 1, 8, 5, 6, 7, 5, 5]

for e in a:
    if e not in seen and not math.isnan(e):
        seen.append(e)
    else:
        indexes = ([i for i, x in enumerate(a) if x == e])
        for val in indexes:
            a[val] = float('NaN')

print(a)
</code>```

Body:
I would like to replace all duplicates of elements in arrays with NaN.
For example:

a = [1, 1, 2, 3, 1, 8, 5, 6, 7, 5, 5]

Goal:

a = [NaN, NaN, 2, 3, NaN, 8, NaN, 6, 7, NaN, NaN]

Body:
it is not pretty but i think it keeps the cost low.

import math

seen = []
a = [1, 1, 2, 3, 1, 8, 5, 6, 7, 5, 5]

for e in a:
    if e not in seen and not math.isnan(e):
        seen.append(e)
    else:
        indexes = ([i for i, x in enumerate(a) if x == e])
        for val in indexes:
            a[val] = float('NaN')

print(a)


问:
How to get vertical highlighting in VSC
In Visual Studio Code, I'm trying to get the whole column highlighted where my cursor is. The same way a line is highlighted, I'd like to get the column highlighted as well.

It exists in Atom, as shown below, as an independant package.

I didn't find the same setting or package to do it in VSC. Anyone knows how to achieve that?

答: I don't think it is possible to get the exact same effect as with Atom, where you highlight a column, but for the same functionality (vertical line where your cursor is), you can install the extension cursoruler.</p>

Title: How to get vertical highlighting in VSC


问:
Compare objects and search in list
I use Python 3 and PySide2 (Qt for Python) (both up to date). I have a list of PySide2 objects and have to check if an item exists in the list. If I try to do this, I get the error:

NotImplementedError: operator not implemented.
```

<pre class="lang-py prettyprint-override"><code>from PySide2 import QtGui
item = QtGui.QStandardItem()
item1 = QtGui.QStandardItem()

item == item1 # creates error

list1 = [item, item1]
item1 in list1 # creats error
</code>```

What do I wrong? How can I do this? Do I have to implement the "==" operator myself?
Thank you in advance for your help!

答:
As noted in a comment, the error you get is part of a bug that is remnants of PySide.

I think that you have an XY problem, and what you want is to check if there is an item with a predefined text. If so, it is not necessary to implement the operator == but use the findItems() method:

```<code>from PySide2 import QtCore, QtGui

if __name__ == "__main__":
    import sys

    md = QtGui.QStandardItemModel()
    for text in ("Hello", "Stack", "Overflow"):
        md.appendRow(QtGui.QStandardItem(text))

    words = ("Hello", "World")

    for word in words:
        if md.findItems(word, flags=QtCore.Qt.MatchExactly, column=0):
            print(f"{word} exists")
        else:
            print(f"{word} not exists")
</code>```

Or use the match() method if you want to search for some other role:

from PySide2 import QtCore, QtGui

FooRole = QtCore.Qt.UserRole + 1000

if __name__ == "__main__":
    import sys

    md = QtGui.QStandardItemModel()
    for i, text in enumerate(("Hello", "Stack", "Overflow")):
        it = QtGui.QStandardItem(str(i))
        it.setData(text, FooRole)
        md.appendRow(it)

    words = ("Hello", "World")

    for word in words:
        if md.match(
            md.index(0, 0), FooRole, word, hits=1, flags=QtCore.Qt.MatchExactly
        ):
            print(f"{word} exists")
        else:
            print(f"{word} not exists")
```

Title: Compare objects and search in list

Body:
I use Python 3 and PySide2 (Qt for Python) (both up to date). I have a list of PySide2 objects and have to check if an item exists in the list. If I try to do this, I get the error:

NotImplementedError: operator not implemented.

from PySide2 import QtGui
item = QtGui.QStandardItem()
item1 = QtGui.QStandardItem()

item == item1 # creates error

list1 = [item, item1]
item1 in list1 # creats error

What do I wrong? How can I do this? Do I have to implement the "==" operator myself?
Thank you in advance for your help!

Body:
As noted in a comment, the error you get is part of a bug that is remnants of PySide.

I think that you have an XY problem, and what you want is to check if there is an item with a predefined text. If so, it is not necessary to implement the operator == but use the findItems() method:

from PySide2 import QtCore, QtGui

if __name__ == "__main__":
    import sys

    md = QtGui.QStandardItemModel()
    for text in ("Hello", "Stack", "Overflow"):
        md.appendRow(QtGui.QStandardItem(text))

    words = ("Hello", "World")

    for word in words:
        if md.findItems(word, flags=QtCore.Qt.MatchExactly, column=0):
            print(f"{word} exists")
        else:
            print(f"{word} not exists")

Or use the match() method if you want to search for some other role:

from PySide2 import QtCore, QtGui

FooRole = QtCore.Qt.UserRole + 1000

if __name__ == "__main__":
    import sys

    md = QtGui.QStandardItemModel()
    for i, text in enumerate(("Hello", "Stack", "Overflow")):
        it = QtGui.QStandardItem(str(i))
        it.setData(text, FooRole)
        md.appendRow(it)

    words = ("Hello", "World")

    for word in words:
        if md.match(
            md.index(0, 0), FooRole, word, hits=1, flags=QtCore.Qt.MatchExactly
        ):
            print(f"{word} exists")
        else:
            print(f"{word} not exists")


问:
Angular 7 File '../src/types/@angular/common.d.ts' is not a module
I've created a new Angular 7 project and in ap.routing.ts I have

```<code>import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { RouterModule, Routes } from '@angular/router';
import { ClientsComponent } from './components/clients/clients.component';
import { HomeComponent } from './components/commons/home/home.component';
import { FunctionalitiesComponent } from './components/functionalities/functionalities.component';
import { ProcessesComponent } from './components/processes/processes.component';
import { ProjectsComponent } from './components/projects/projects.component';
import { UsersComponent } from './components/users/users.component';
import { AuthenticationGuard } from './_guards/authentication.guard';
import { LoginComponent } from './components/users/login/login.component';
import { RegistrationComponent } from './components/users/registration/registration.component';

const routes: Routes = [
  { path: '', redirectTo: 'home', pathMatch: 'full' },
  { path: 'home', component: HomeComponent, canActivate: [AuthenticationGuard] },
  { path: 'clients', component: ClientsComponent },
  { path: 'projects', component: ProjectsComponent },
  { path: 'functionalities', component: FunctionalitiesComponent },
  { path: 'processes', component: ProcessesComponent },
  { path: 'login', component: LoginComponent },
  { path: 'users', component: UsersComponent }

];

@NgModule({
  imports: [
    CommonModule,
    BrowserModule,
    RouterModule.forRoot(routes, { enableTracing: true , onSameUrlNavigation: 'reload'})
  ],
  exports: [
  ],
})
export class AppRoutingModule { }
</code>```

'@angular/common' is underlined in red and the following error is given:

```<code>File '{pathTo}/src/types/@angular/common.d.ts' is not a module
</code>```

I have installed the module using

```<code>npm i @angular/common
</code>```

restarted the visual editor (VS Code), re-run ng serve but nothing changed.

This is the package.json file:

```<code>{
  "name": "material-dashboard-angular",
  "version": "2.2.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve --base-href /admin/",
    "build": "ng build --aot --base-href /admin/",
    "build-prod": "ng build --prod --aot",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "install:clean": "rm -rf node_modules/ && rm -rf package-lock.json && npm install && ng serve -o"
  },
  "engines": {
    "node": "6.11.1",
    "npm": "3.10.9"
  },
  "private": true,
  "dependencies": {
    "@agm/core": "1.0.0-beta.5",
    "@angular/animations": "7.0.2",
    "@angular/cdk": "7.0.2",
    "@angular/common": "7.0.2",
    "@angular/compiler": "7.0.2",
    "@angular/core": "7.0.2",
    "@angular/forms": "7.0.2",
    "@angular/http": "7.0.2",
    "@angular/material": "7.0.2",
    "@angular/platform-browser": "7.0.2",
    "@angular/platform-browser-dynamic": "7.0.2",
    "@angular/platform-server": "7.0.2",
    "@angular/router": "7.0.2",
    "@auth0/angular-jwt": "^2.1.0",
    "@ngx-translate/core": "^11.0.1",
    "@ngx-translate/http-loader": "^4.0.0",
    "acorn": "^6.1.1",
    "ajv": "6.4.0",
    "angular-http-server": "^1.9.0",
    "angular-svg-icon": "^7.2.1",
    "arrive": "2.4.1",
    "bootstrap": "4.1.0",
    "bootstrap-material-design": "4.1.1",
    "bootstrap-notify": "3.1.3",
    "chartist": "0.11.0",
    "classlist.js": "1.1.20150312",
    "core-js": "2.4.1",
    "cron-validator": "^1.0.1",
    "express": "4.16.3",
    "file-input-accessor": "^7.0.0",
    "googleapis": "28.1.0",
    "hammerjs": "2.0.8",
    "jquery": "^3.4.1",
    "moment": "2.22.1",
    "perfect-scrollbar": "1.1.0",
    "popper.js": "1.14.3",
    "rxjs": "6.3.3",
    "rxjs-compat": "6.3.3",
    "sancronos-validator": "^1.2.0",
    "web-animations-js": "2.3.1",
    "zone.js": "0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^0.13.9",
    "@angular/cli": "6.0.3",
    "@angular/compiler-cli": "^7.2.15",
    "@angular/language-service": "7.0.2",
    "@types/bootstrap": "3.3.32",
    "@types/chartist": "0.9.34",
    "@types/googlemaps": "3.30.8",
    "@types/jasmine": "2.5.38",
    "@types/jquery": "1.10.31",
    "@types/node": "^6.0.73",
    "codelyzer": "4.2.1",
    "jasmine-core": "3.1.0",
    "jasmine-spec-reporter": "4.2.1",
    "karma": "^4.1.0",
    "karma-chrome-launcher": "2.2.0",
    "karma-cli": "1.0.1",
    "karma-coverage-istanbul-reporter": "1.4.2",
    "karma-jasmine": "1.1.1",
    "protractor": "^6.0.0",
    "ts-node": "5.0.1",
    "tslint": "5.9.1",
    "typescript": "3.1.6"
  }
}
</code>```

ERROR LOG

ERROR in
  node_modules/@angular/cdk/overlay/typings/overlay-ref.d.ts(11,26):
  error TS2306: File
  'C:/Users/Marina/Desktop/heliosFrontEnd_admin/src/types/@angular/common.d.ts'
  is not a module.
  node_modules/@angular/cdk/overlay/typings/overlay.d.ts(9,26): error
  TS2306: File
  'C:/Users/Marina/Desktop/heliosFrontEnd_admin/src/types/@angular/common.d.ts'
  is not a module.
  node_modules/@angular/material/bottom-sheet/typings/bottom-sheet-ref.d.ts(8,26):
  error TS2306: File
  'C:/Users/Marina/Desktop/heliosFrontEnd_admin/src/types/@angular/common.d.ts'
  is not a module.
  node_modules/@angular/material/bottom-sheet/typings/bottom-sheet.d.ts(11,26):
  error TS2306: File
  'C:/Users/Marina/Desktop/heliosFrontEnd_admin/src/types/@angular/common.d.ts'
  is not a module.
  node_modules/@angular/material/dialog/typings/dialog-ref.d.ts(9,26):
  error TS2306: File
  'C:/Users/Marina/Desktop/heliosFrontEnd_admin/src/types/@angular/common.d.ts'
  is not a module.
  node_modules/@angular/material/dialog/typings/dialog.d.ts(10,26):
  error TS2306: File
  'C:/Users/Marina/Desktop/heliosFrontEnd_admin/src/types/@angular/common.d.ts'
  is not a module.
  node_modules/@angular/platform-browser/src/browser/location/browser_platform_location.d.ts(8,58):
  error TS2306: File
  'C:/Users/Marina/Desktop/heliosFrontEnd_admin/src/types/@angular/common.d.ts'
  is not a module.
  node_modules/@angular/router/src/directives/router_link.d.ts(8,34):
  error TS2306: File
  'C:/Users/Marina/Desktop/heliosFrontEnd_admin/src/types/@angular/common.d.ts'
  is not a module. node_modules/@angular/router/src/router.d.ts(8,26):
  error TS2306: File
  'C:/Users/Marina/Desktop/heliosFrontEnd_admin/src/types/@angular/common.d.ts'
  is not a module.
  node_modules/@angular/router/src/router_module.d.ts(8,106): error
  TS2306: File
  'C:/Users/Marina/Desktop/heliosFrontEnd_admin/src/types/@angular/common.d.ts'
  is not a module.
  node_modules/@angular/router/src/router_scroller.d.ts(8,34): error
  TS2306: File
  'C:/Users/Marina/Desktop/heliosFrontEnd_admin/src/types/@angular/common.d.ts'
  is not a module. src/app/app.routing.ts(1,30): error TS2306: File
  'C:/Users/Marina/Desktop/heliosFrontEnd_admin/src/types/@angular/common.d.ts'
  is not a module.

答:
Based on your error logs, you are using MatBottomSheet. So you need to import the MatBottomSheetModule from @angular/material. Also include it into imports array.

In angular material every components has it's own module. So before using that component, import it's relevant module.

Body:
I've created a new Angular 7 project and in ap.routing.ts I have

import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { RouterModule, Routes } from '@angular/router';
import { ClientsComponent } from './components/clients/clients.component';
import { HomeComponent } from './components/commons/home/home.component';
import { FunctionalitiesComponent } from './components/functionalities/functionalities.component';
import { ProcessesComponent } from './components/processes/processes.component';
import { ProjectsComponent } from './components/projects/projects.component';
import { UsersComponent } from './components/users/users.component';
import { AuthenticationGuard } from './_guards/authentication.guard';
import { LoginComponent } from './components/users/login/login.component';
import { RegistrationComponent } from './components/users/registration/registration.component';

const routes: Routes = [
  { path: '', redirectTo: 'home', pathMatch: 'full' },
  { path: 'home', component: HomeComponent, canActivate: [AuthenticationGuard] },
  { path: 'clients', component: ClientsComponent },
  { path: 'projects', component: ProjectsComponent },
  { path: 'functionalities', component: FunctionalitiesComponent },
  { path: 'processes', component: ProcessesComponent },
  { path: 'login', component: LoginComponent },
  { path: 'users', component: UsersComponent }

];

@NgModule({
  imports: [
    CommonModule,
    BrowserModule,
    RouterModule.forRoot(routes, { enableTracing: true , onSameUrlNavigation: 'reload'})
  ],
  exports: [
  ],
})
export class AppRoutingModule { }

'@angular/common' is underlined in red and the following error is given:

File '{pathTo}/src/types/@angular/common.d.ts' is not a module

I have installed the module using

npm i @angular/common

restarted the visual editor (VS Code), re-run ng serve but nothing changed.

This is the package.json file:

{
  "name": "material-dashboard-angular",
  "version": "2.2.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve --base-href /admin/",
    "build": "ng build --aot --base-href /admin/",
    "build-prod": "ng build --prod --aot",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "install:clean": "rm -rf node_modules/ && rm -rf package-lock.json && npm install && ng serve -o"
  },
  "engines": {
    "node": "6.11.1",
    "npm": "3.10.9"
  },
  "private": true,
  "dependencies": {
    "@agm/core": "1.0.0-beta.5",
    "@angular/animations": "7.0.2",
    "@angular/cdk": "7.0.2",
    "@angular/common": "7.0.2",
    "@angular/compiler": "7.0.2",
    "@angular/core": "7.0.2",
    "@angular/forms": "7.0.2",
    "@angular/http": "7.0.2",
    "@angular/material": "7.0.2",
    "@angular/platform-browser": "7.0.2",
    "@angular/platform-browser-dynamic": "7.0.2",
    "@angular/platform-server": "7.0.2",
    "@angular/router": "7.0.2",
    "@auth0/angular-jwt": "^2.1.0",
    "@ngx-translate/core": "^11.0.1",
    "@ngx-translate/http-loader": "^4.0.0",
    "acorn": "^6.1.1",
    "ajv": "6.4.0",
    "angular-http-server": "^1.9.0",
    "angular-svg-icon": "^7.2.1",
    "arrive": "2.4.1",
    "bootstrap": "4.1.0",
    "bootstrap-material-design": "4.1.1",
    "bootstrap-notify": "3.1.3",
    "chartist": "0.11.0",
    "classlist.js": "1.1.20150312",
    "core-js": "2.4.1",
    "cron-validator": "^1.0.1",
    "express": "4.16.3",
    "file-input-accessor": "^7.0.0",
    "googleapis": "28.1.0",
    "hammerjs": "2.0.8",
    "jquery": "^3.4.1",
    "moment": "2.22.1",
    "perfect-scrollbar": "1.1.0",
    "popper.js": "1.14.3",
    "rxjs": "6.3.3",
    "rxjs-compat": "6.3.3",
    "sancronos-validator": "^1.2.0",
    "web-animations-js": "2.3.1",
    "zone.js": "0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^0.13.9",
    "@angular/cli": "6.0.3",
    "@angular/compiler-cli": "^7.2.15",
    "@angular/language-service": "7.0.2",
    "@types/bootstrap": "3.3.32",
    "@types/chartist": "0.9.34",
    "@types/googlemaps": "3.30.8",
    "@types/jasmine": "2.5.38",
    "@types/jquery": "1.10.31",
    "@types/node": "^6.0.73",
    "codelyzer": "4.2.1",
    "jasmine-core": "3.1.0",
    "jasmine-spec-reporter": "4.2.1",
    "karma": "^4.1.0",
    "karma-chrome-launcher": "2.2.0",
    "karma-cli": "1.0.1",
    "karma-coverage-istanbul-reporter": "1.4.2",
    "karma-jasmine": "1.1.1",
    "protractor": "^6.0.0",
    "ts-node": "5.0.1",
    "tslint": "5.9.1",
    "typescript": "3.1.6"
  }
}

ERROR LOG

ERROR in
  node_modules/@angular/cdk/overlay/typings/overlay-ref.d.ts(11,26):
  error TS2306: File
  'C:/Users/Marina/Desktop/heliosFrontEnd_admin/src/types/@angular/common.d.ts'
  is not a module.
  node_modules/@angular/cdk/overlay/typings/overlay.d.ts(9,26): error
  TS2306: File
  'C:/Users/Marina/Desktop/heliosFrontEnd_admin/src/types/@angular/common.d.ts'
  is not a module.
  node_modules/@angular/material/bottom-sheet/typings/bottom-sheet-ref.d.ts(8,26):
  error TS2306: File
  'C:/Users/Marina/Desktop/heliosFrontEnd_admin/src/types/@angular/common.d.ts'
  is not a module.
  node_modules/@angular/material/bottom-sheet/typings/bottom-sheet.d.ts(11,26):
  error TS2306: File
  'C:/Users/Marina/Desktop/heliosFrontEnd_admin/src/types/@angular/common.d.ts'
  is not a module.
  node_modules/@angular/material/dialog/typings/dialog-ref.d.ts(9,26):
  error TS2306: File
  'C:/Users/Marina/Desktop/heliosFrontEnd_admin/src/types/@angular/common.d.ts'
  is not a module.
  node_modules/@angular/material/dialog/typings/dialog.d.ts(10,26):
  error TS2306: File
  'C:/Users/Marina/Desktop/heliosFrontEnd_admin/src/types/@angular/common.d.ts'
  is not a module.
  node_modules/@angular/platform-browser/src/browser/location/browser_platform_location.d.ts(8,58):
  error TS2306: File
  'C:/Users/Marina/Desktop/heliosFrontEnd_admin/src/types/@angular/common.d.ts'
  is not a module.
  node_modules/@angular/router/src/directives/router_link.d.ts(8,34):
  error TS2306: File
  'C:/Users/Marina/Desktop/heliosFrontEnd_admin/src/types/@angular/common.d.ts'
  is not a module. node_modules/@angular/router/src/router.d.ts(8,26):
  error TS2306: File
  'C:/Users/Marina/Desktop/heliosFrontEnd_admin/src/types/@angular/common.d.ts'
  is not a module.
  node_modules/@angular/router/src/router_module.d.ts(8,106): error
  TS2306: File
  'C:/Users/Marina/Desktop/heliosFrontEnd_admin/src/types/@angular/common.d.ts'
  is not a module.
  node_modules/@angular/router/src/router_scroller.d.ts(8,34): error
  TS2306: File
  'C:/Users/Marina/Desktop/heliosFrontEnd_admin/src/types/@angular/common.d.ts'
  is not a module. src/app/app.routing.ts(1,30): error TS2306: File
  'C:/Users/Marina/Desktop/heliosFrontEnd_admin/src/types/@angular/common.d.ts'
  is not a module.


问:
How to get Joining an IQueryable with model any types sql c#
I have this model ExpenseReport

```<code>public class ExpenseReport
    {
        public Guid Id { get; set; }
        public Guid InternalId { get; set; }
        public Guid AccountId { get; set; }
        public string Alias { get; set; }
        public bool IsDraft { get; set; }
        public int BaseCurrencyId { get; set; }
        public Guid ContactId { get; set; }
        public Contact Contact { get; set; }
        public Guid? JobId { get; set; }
        public Job Job { get; set; }
        public Customer Customer { get; set; }
        public Guid CustomerId { get; set; }
        public DateTime? PublishedOn { get; set; }
        public DateTime? ExpectedPayDate { get; set; }
        public ExpenseReportStatus Status { get; set; }
        public ExpenseReportStatusEnum StatusId { get; set; }
        public string OriginReference { get; set; }
        public decimal AdvanceValue { get; set; }
        public decimal TotalValue { get; set; }
        public string CreatedBy { get; set; }
        public DateTime CreatedOn { get; set; }
        public string UpdatedBy { get; set; }
        public DateTime UpdatedOn { get; set; }
    }
</code>```

I Need to Join to get JOB, CUSTOMER, and Contact from another table

when I use LINQ to get these values it returns me null them. What would be the junction of this return

My query

```<code>  public IQueryable<ExpenseReport> ExpenseReports => (from exReport in _dataContext.ExpenseReport
                                                            join job in _dataContext.Job on exReport.JobId equals job.Id
                                                            join contact in _dataContext.Contact on exReport.ContactId equals contact.Id
                                                            join customer in _dataContext.Customer on exReport.CustomerId equals customer.Id
                                                            select exReport );
</code>```

答:
My solution was to create a DTO that only returns that I need and use .Include

var ownerData = _repository.ExpenseReports
                .Where(w => w.AccountId.Equals(_identityService.Identity.CurrentAccount.Id))
                .Include(x => x.Customer)
                .Include(x => x.Job)
                .Select(x => new MyExpenseReportDTO
                {
                   Id = x.Id,
                   InternalId = x.InternalId,
                   Alias = x.Alias,
                   Job = x.Job.Name,
                   CreatedOn = x.CreatedOn,
                   ExpectedPayDate = x.ExpectedPayDate,
                   Customer = x.Customer.Name,
                   CostCenterName = x.Job.CostCenter.Name,
                   BaseCurrencyId = x.BaseCurrencyId,
                   Status = x.Status.Name,
                   TotalValue = x.TotalValue
                });```

Body:
I have this model ExpenseReport

public class ExpenseReport
    {
        public Guid Id { get; set; }
        public Guid InternalId { get; set; }
        public Guid AccountId { get; set; }
        public string Alias { get; set; }
        public bool IsDraft { get; set; }
        public int BaseCurrencyId { get; set; }
        public Guid ContactId { get; set; }
        public Contact Contact { get; set; }
        public Guid? JobId { get; set; }
        public Job Job { get; set; }
        public Customer Customer { get; set; }
        public Guid CustomerId { get; set; }
        public DateTime? PublishedOn { get; set; }
        public DateTime? ExpectedPayDate { get; set; }
        public ExpenseReportStatus Status { get; set; }
        public ExpenseReportStatusEnum StatusId { get; set; }
        public string OriginReference { get; set; }
        public decimal AdvanceValue { get; set; }
        public decimal TotalValue { get; set; }
        public string CreatedBy { get; set; }
        public DateTime CreatedOn { get; set; }
        public string UpdatedBy { get; set; }
        public DateTime UpdatedOn { get; set; }
    }

I Need to Join to get JOB, CUSTOMER, and Contact from another table

when I use LINQ to get these values it returns me null them. What would be the junction of this return

My query

  public IQueryable<ExpenseReport> ExpenseReports => (from exReport in _dataContext.ExpenseReport
                                                            join job in _dataContext.Job on exReport.JobId equals job.Id
                                                            join contact in _dataContext.Contact on exReport.ContactId equals contact.Id
                                                            join customer in _dataContext.Customer on exReport.CustomerId equals customer.Id
                                                            select exReport );


问:
How to add objects to a private list with a method?
You can see the list i created is private and I want to be able to add objects to the list aswell as showing the user the list through methods AddBook() and ShowBooks().

```<code>public class Library
{
    private List<Book> Books = new List<Book>();

    public static void AddBook()
    {
    }

    public static void ShowBooks()
    {
        foreach (Book item in Books)
        //This foreach-loop doesn't work since its a private list.
        {
            Console.WriteLine("Books found");
        }
    }
}
</code>```

The loop doesnt work since "An object reference is required for the non-static field, method, or property" refering to the list.

答:
if you want to use static methods you can try this

```<code>using System;
</code>```

using System.Collections.Generic;

```<code>public class Program
{
    public static void Main()
    {

        Library.AddBook(new Book(){name = "test"});
        Library.AddBook(new Book(){name = "test1"});

        Library.ShowBooks();
    }
}

public class Book
{
    public string name;
}

public static class Library
{
    private static List<Book> Books = new List<Book>();

    public static void AddBook(Book b1)
    {
        Books.Add(b1);
    }

    public static void ShowBooks()
    {
        foreach (Book item in Books)
        //This foreach-loop doesn't work since its a private list.
        {
            Console.WriteLine(item.name);
        }
    }
}
</code>```

without static methods you can try this

```<code>using System;
using System.Collections.Generic;

public class Program
{
    public static void Main()
    {
        Library l1 = new Library();
        l1.AddBook(new Book(){name = "test"});
        l1.AddBook(new Book(){name = "test1"});

        l1.ShowBooks();
    }
}

public class Book
{
    public string name;
}

public  class Library
{
    private  List<Book> Books = new List<Book>();

    public  void AddBook(Book b1)
    {
        Books.Add(b1);
    }

    public  void ShowBooks()
    {
        foreach (Book item in Books)
        //This foreach-loop doesn't work since its a private list.
        {
            Console.WriteLine(item.name);
        }
    }
}
</code>```

Body:
You can see the list i created is private and I want to be able to add objects to the list aswell as showing the user the list through methods AddBook() and ShowBooks().

public class Library
{
    private List<Book> Books = new List<Book>();

    public static void AddBook()
    {
    }

    public static void ShowBooks()
    {
        foreach (Book item in Books)
        //This foreach-loop doesn't work since its a private list.
        {
            Console.WriteLine("Books found");
        }
    }
}

The loop doesnt work since "An object reference is required for the non-static field, method, or property" refering to the list.

Body:
if you want to use static methods you can try this

using System;

using System.Collections.Generic;

public class Program
{
    public static void Main()
    {

        Library.AddBook(new Book(){name = "test"});
        Library.AddBook(new Book(){name = "test1"});

        Library.ShowBooks();
    }
}

public class Book
{
    public string name;
}

public static class Library
{
    private static List<Book> Books = new List<Book>();

    public static void AddBook(Book b1)
    {
        Books.Add(b1);
    }

    public static void ShowBooks()
    {
        foreach (Book item in Books)
        //This foreach-loop doesn't work since its a private list.
        {
            Console.WriteLine(item.name);
        }
    }
}

without static methods you can try this

using System;
using System.Collections.Generic;

public class Program
{
    public static void Main()
    {
        Library l1 = new Library();
        l1.AddBook(new Book(){name = "test"});
        l1.AddBook(new Book(){name = "test1"});

        l1.ShowBooks();
    }
}

public class Book
{
    public string name;
}

public  class Library
{
    private  List<Book> Books = new List<Book>();

    public  void AddBook(Book b1)
    {
        Books.Add(b1);
    }

    public  void ShowBooks()
    {
        foreach (Book item in Books)
        //This foreach-loop doesn't work since its a private list.
        {
            Console.WriteLine(item.name);
        }
    }
}