问:
PSWebServiceLibrary - Webservice - Adding product simple (without combination) there are stock problem
I use PSWebServiceLibrary to have a "dialog" with Prestashop.
If I add a product with this simple code:

```<code>xmlResponse = $webService->get(['url' => PS_SHOP_PATH."/api/products?schema=blank"]);
$fieldsXML = $xmlResponse->product[0];
$fieldsXML->state = "1";
$fieldsXML->name = "test";
$fieldsXML->price = "10.00";
try {
    $addResponse = $webService->add([ 'resource' => "products", 'postXml' => $xmlResponse->asXML() ]);
    $fieldsXML = $addResponse->product[0];
    echo 'Enjoy-> Your product Id is: '.$fieldsXML->id;
}
catch (PrestaShopWebserviceException $e) {
    echo "No good -> ".$e->getMessage();
}
</code>```

I have my new product in catalog->products... but I haven't my new product in catalog->stocks.
When I go to catalog->stocks, my console show an error like this:
TypeError: Cannot read property 'split' of null (stock.bundle.js?1.7.6.3:7)

I have seen that the PS has create in Dbase a row in table product_attribute associated at new product (instead of there isn't row in tables like product_attribute, product_attribute_combination, product_attribute_image, ecc)

If I delete it (by phpMyAdmin), than all work fine and the product will be visible in stocks

If I create the product by dashboard all work fine and if I check table product_attribute there isn't correctly the product

I have searched many solution, like change attributes values in the insert, change them in a second time... nothing.

PrestaShop version: 1.7.6.3:7
PHP version: 7.0

答:
I have solved... and I think that is a bug of Prestashop or PSWebServiceLibrary
With my original code I get ALL ATTRIBUTE of the product blank shema

```<code>$xmlResponse = $webService->get(['url' => PS_SHOP_PATH."/api/products?schema=blank"]);
$fieldsXML = $xmlResponse->product[0];
</code>```

I edit only some attribute

```<code>$fieldsXML->state = "1";
$fieldsXML->name = "test";
$fieldsXML->price = "10.00";
$fieldsXML->advanced_stock_management=true;
$fieldsXML->low_stock_alert=false;
$fieldsXML->minimal_quantity = "1";
$fieldsXML->available_for_order = true;
$fieldsXML->active = true;
</code>```

I send my new xml (attribute edited and other attribute received) to Prestashop.

```<code>$webService->add([ 'resource' => "products", 'postXml' => $xmlResponse->asXML() ]);
</code>```

The problem is in the result that I have from get([...]);
The tag inside $fieldsXML have a format like (for example)  and not
So, when I edit the attribute the format will be "correct" (1) the other remain ... this will be a problem when inserting the product because it seems that it's not "completely accepted" by Prestashop.

To solve the problem I have to edit each attribute as empty and then edit that I need.
This is my working code:

```<code>$xmlResponse = $webService->get(['url' => PS_SHOP_PATH."/api/products?schema=blank"]);
$fieldsXML = $xmlResponse->product[0];
foreach ($fieldsXML as $nodeKey => $node){
    $fieldsXML->$nodeKey = "";
}
$fieldsXML->state = "1";
$fieldsXML->name = "test";
$fieldsXML->price = "10.00";
$fieldsXML->advanced_stock_management=true;
$fieldsXML->low_stock_alert=false;
$fieldsXML->minimal_quantity = "1";
$fieldsXML->available_for_order = true;
$fieldsXML->active = true;
try {
    $addResponse = $webService->add([ 'resource' => "products", 'postXml' => $xmlResponse->asXML() ]);
    $fieldsXML = $addResponse->product[0];
    echo 'Enjoy-> Your product Id is: '.$fieldsXML->id;
}
catch (PrestaShopWebserviceException $e) {
    echo "No good -> ".$e->getMessage();
}
</code>```

I hope that I have explained well and that it is helpful for everyone... because there aren't many info on web.

Body:
I use PSWebServiceLibrary to have a "dialog" with Prestashop.
If I add a product with this simple code:

xmlResponse = $webService->get(['url' => PS_SHOP_PATH."/api/products?schema=blank"]);
$fieldsXML = $xmlResponse->product[0];
$fieldsXML->state = "1";
$fieldsXML->name = "test";
$fieldsXML->price = "10.00";
try {
    $addResponse = $webService->add([ 'resource' => "products", 'postXml' => $xmlResponse->asXML() ]);
    $fieldsXML = $addResponse->product[0];
    echo 'Enjoy-> Your product Id is: '.$fieldsXML->id;
}
catch (PrestaShopWebserviceException $e) {
    echo "No good -> ".$e->getMessage();
}

I have my new product in catalog->products... but I haven't my new product in catalog->stocks.
When I go to catalog->stocks, my console show an error like this:
TypeError: Cannot read property 'split' of null (stock.bundle.js?1.7.6.3:7)

I have seen that the PS has create in Dbase a row in table product_attribute associated at new product (instead of there isn't row in tables like product_attribute, product_attribute_combination, product_attribute_image, ecc)

If I delete it (by phpMyAdmin), than all work fine and the product will be visible in stocks

If I create the product by dashboard all work fine and if I check table product_attribute there isn't correctly the product

I have searched many solution, like change attributes values in the insert, change them in a second time... nothing.

PrestaShop version: 1.7.6.3:7
PHP version: 7.0

Body:
I have solved... and I think that is a bug of Prestashop or PSWebServiceLibrary
With my original code I get ALL ATTRIBUTE of the product blank shema

$xmlResponse = $webService->get(['url' => PS_SHOP_PATH."/api/products?schema=blank"]);
$fieldsXML = $xmlResponse->product[0];

I edit only some attribute

$fieldsXML->state = "1";
$fieldsXML->name = "test";
$fieldsXML->price = "10.00";
$fieldsXML->advanced_stock_management=true;
$fieldsXML->low_stock_alert=false;
$fieldsXML->minimal_quantity = "1";
$fieldsXML->available_for_order = true;
$fieldsXML->active = true;

I send my new xml (attribute edited and other attribute received) to Prestashop.

$webService->add([ 'resource' => "products", 'postXml' => $xmlResponse->asXML() ]);

The problem is in the result that I have from get([...]);
The tag inside $fieldsXML have a format like (for example)  and not
So, when I edit the attribute the format will be "correct" (1) the other remain ... this will be a problem when inserting the product because it seems that it's not "completely accepted" by Prestashop.

To solve the problem I have to edit each attribute as empty and then edit that I need.
This is my working code:

$xmlResponse = $webService->get(['url' => PS_SHOP_PATH."/api/products?schema=blank"]);
$fieldsXML = $xmlResponse->product[0];
foreach ($fieldsXML as $nodeKey => $node){
    $fieldsXML->$nodeKey = "";
}
$fieldsXML->state = "1";
$fieldsXML->name = "test";
$fieldsXML->price = "10.00";
$fieldsXML->advanced_stock_management=true;
$fieldsXML->low_stock_alert=false;
$fieldsXML->minimal_quantity = "1";
$fieldsXML->available_for_order = true;
$fieldsXML->active = true;
try {
    $addResponse = $webService->add([ 'resource' => "products", 'postXml' => $xmlResponse->asXML() ]);
    $fieldsXML = $addResponse->product[0];
    echo 'Enjoy-> Your product Id is: '.$fieldsXML->id;
}
catch (PrestaShopWebserviceException $e) {
    echo "No good -> ".$e->getMessage();
}

I hope that I have explained well and that it is helpful for everyone... because there aren't many info on web.


来源: stackexchange

ContentLicense: CC BY-SA 4.0

Title: python converting list to a dataframe

Body:
I have a variable y as below. It is a list with 2 elements. When i convert it to a dataframe xyz it seems that i get 2 rows but just one column. I would like to have 2 rows with multiple columns. each columns should have only one value in it and columns names should be 0,1,2,3, etc

How could i do the same?

print(len(y))
print(type(y))
2
<class 'list'>

xyz=pd.DataFrame.from_records(y)
type (xyz)
pandas.core.frame.DataFrame
xyz

0
0   [-0.9459755, -0.47805053, -0.65050876, 0.77347...
1   [-0.9459755, -0.47805053, -0.65050876, 0.77347...

y as below

[array([[-0.9459755 , -0.47805053, -0.65050876,  0.7734777 ,  0.552691  ,
        -0.19007854,  0.9223234 ,  0.27941042, -0.7322695 , -0.99998975,
        -0.37605256,  0.8916531 ,  0.983763  ,  0.2527561 ,  0.966363  ,
        -0.7447939 , -0.5058228 , -0.6355803 ,  0.420939  , -0.7473378 ,
         0.74549365,  0.9999191 ,  0.36683556,  0.31255466,  0.4609189 ,
         0.9825759 , -0.8520847 ,  0.9575349 ,  0.9682904 ,  0.72985345,
        -0.82898533,  0.14331765, -0.98895043, -0.23441169, -0.7558871 ,
        -0.9913596 ,  0.39418277, -0.84416234,  0.05476778, -0.01005056,
        -0.94226193,  0.24747927,  0.99995273, -0.13606967,  0.13124019,
        -0.34404624, -0.99999994,  0.16850327, -0.8896826 ,  0.75479925,
         0.6656554 ,  0.5275847 ,  0.27075547,  0.49543703,  0.43383783,
         0.05168212, -0.11341204,  0.10182644, -0.22263326, -0.63695884,
        -0.62449884,  0.2913445 , -0.84347934, -0.9449906 ,  0.82978284,
         0.6233054 , -0.076456  , -0.2860726 , -0.12531959, -0.0440293 ,
         0.92798275,  0.27617946,  0.27131325, -0.90081406,  0.37721077,
         0.31383792, -0.6580769 ,  1.        , -0.44372475, -0.9799322 ,
         0.73667705,  0.5613586 ,  0.5506944 , -0.01951157,  0.298312  ,
        -1.        ,  0.40395644, -0.12005024, -0.99280196,  0.25549296,
         0.58356893, -0.28049406,  0.342898  ,  0.61289656, -0.4513767 ,
        -0.34312075, -0.29862905, -0.7756922 , -0.23678726, -0.25012112,
        -0.01759785, -0.28374395, -0.2618543 , -0.35386655,  0.28066075,
        -0.482542  , -0.54826105,  0.44234577, -0.02860786,  0.7147769 ,
         0.45068547, -0.38843894,  0.5060407 , -0.97053695,  0.67816174,
        -0.2818997 , -0.98881775, -0.6243588 , -0.992165  ,  0.71923774,
        -0.279121  , -0.25058544,  0.9760995 ,  0.01690155,  0.39211938,
         0.01538094, -0.6557028 , -1.        , -0.5813251 , -0.41143104,
        -0.09620688, -0.20363976, -0.9794194 , -0.9636516 ,  0.6528108 ,
         0.97018564,  0.16890207,  0.99986917, -0.28804392,  0.9545565 ,
        -0.25736585, -0.5225193 ,  0.47669268, -0.45857254,  0.6629523 ,
         0.33144143, -0.7786891 ,  0.2574491 , -0.05056868,  0.06687481,
        -0.572528  , -0.20754746, -0.58802915, -0.97018045, -0.40681118,
         0.970967  , -0.37611288, -0.8045078 ,  0.18828286, -0.16196367,
        -0.4732573 ,  0.88972455,  0.5881976 ,  0.37267888, -0.19704172,
         0.39486232,  0.13269943,  0.54943895, -0.8223527 ,  0.1638822 ,
         0.45692173, -0.3252729 , -0.59520465, -0.985078  , -0.41795856,
         0.64682806,  0.99037033,  0.8276212 ,  0.29061356,  0.58312225,
        -0.16352373,  0.64946914, -0.9703819 ,  0.9829681 , -0.35020226,
         0.26412863, -0.16023819,  0.48377427, -0.9017009 , -0.04951501,
         0.88109   , -0.572556  , -0.88953966,  0.03719393, -0.51457113,
        -0.43427563, -0.66786784,  0.55420285, -0.30180818, -0.35544968,
        -0.05752672,  0.94897026,  0.9884329 ,  0.8514675 , -0.02706478,
         0.6300914 , -0.94219875, -0.6096796 ,  0.08986723,  0.20492023,
         0.2656025 ,  0.99588263, -0.4211055 , -0.1923249 , -0.95686954,
        -0.99127907, -0.08337305, -0.9306704 , -0.18833733, -0.7482102 ,
         0.55400956,  0.0555265 ,  0.46837628,  0.38679695, -0.99511546,
        -0.80549157,  0.4122052 , -0.37963787,  0.4697992 , -0.16269048,
         0.5950353 ,  0.88734823, -0.5756747 ,  0.83287156,  0.9290157 ,
        -0.7439878 , -0.828965  ,  0.8942273 , -0.313458  ,  0.92042863,
        -0.6451802 ,  0.99454874,  0.83056575,  0.8252365 , -0.9574431 ,
        -0.5787046 , -0.93613344, -0.58610857, -0.10107749, -0.17892347,
         0.81836295,  0.6172731 ,  0.41681796,  0.57118464, -0.6225571 ,
         0.9989582 , -0.7001649 , -0.96139723, -0.27740443, -0.23548205,
        -0.98848706,  0.74846864,  0.35963902, -0.10826006, -0.46944666,
        -0.6967058 , -0.97237617,  0.9392128 ,  0.10147385,  0.9926904 ,
        -0.16881682, -0.946524  , -0.5884638 , -0.9540271 , -0.24724305,
        -0.28957403, -0.15261933, -0.11785159, -0.9682255 ,  0.49430174,
         0.5003349 ,  0.48061895, -0.6137284 ,  0.999326  ,  0.9999998 ,
         0.976841  ,  0.91392696,  0.9618617 , -0.9992805 , -0.67680204,
         0.9999956 , -0.98577553, -1.        , -0.9550538 , -0.70691264,
         0.465085  , -1.        , -0.15956445,  0.03087116, -0.9547435 ,
         0.37775376,  0.9846359 ,  0.99576795, -1.        ,  0.89814603,
         0.9636626 , -0.6454543 ,  0.9496282 , -0.26886773,  0.9733797 ,
         0.6540432 ,  0.2397651 , -0.29637057,  0.43193617, -0.84643066,
        -0.91404974, -0.29513764, -0.59079194,  0.9944733 ,  0.16350774,
        -0.7428708 , -0.9541641 ,  0.15665837, -0.253073  , -0.18864983,
        -0.97502136, -0.14366363,  0.32544258,  0.80569303,  0.14729789,
         0.28502184, -0.7632915 ,  0.27309316, -0.21719639,  0.47755685,
         0.6861862 , -0.95450646, -0.7322332 , -0.31859246, -0.3092003 ,
        -0.45525196, -0.96703494,  0.97626525, -0.47885466,  0.6296605 ,
         1.        ,  0.19711891, -0.92267424,  0.55910766,  0.26710632,
        -0.35919994,  1.        ,  0.7761388 , -0.9830818 , -0.5782019 ,
         0.40678364, -0.55976874, -0.5471115 ,  0.99937713, -0.33048865,
        -0.5061277 , -0.14908014,  0.9785268 , -0.99043804,  0.9828222 ,
        -0.9187875 , -0.9773213 ,  0.9800687 ,  0.955108  , -0.63989365,
        -0.78066677,  0.25093687, -0.52095413,  0.35847044, -0.9796438 ,
         0.77040577,  0.5041405 , -0.11713739,  0.90462315, -0.90723217,
        -0.5658021 ,  0.3393464 , -0.57253885, -0.03464808,  0.7852318 ,
         0.5863543 , -0.2903683 ,  0.10524008, -0.3157491 , -0.3283432 ,
        -0.98630184,  0.25248316,  1.        , -0.2932054 ,  0.43194744,
        -0.39159498, -0.02471775, -0.12938915,  0.5425912 ,  0.63316727,
        -0.31224072, -0.90678704,  0.6802484 , -0.98032105, -0.98643327,
         0.88515776,  0.2762025 , -0.25967157,  0.9999937 ,  0.52587867,
         0.18437354,  0.34015328,  0.97531146, -0.00961124,  0.6977997 ,
         0.7714908 ,  0.97960067, -0.19878545,  0.5547651 ,  0.91813415,
        -0.76973844, -0.29839078, -0.6457684 ,  0.11847758, -0.93472254,
         0.04859285, -0.9728577 ,  0.9758918 ,  0.79083323,  0.37397337,
         0.29322428,  0.3463571 ,  1.        , -0.28344712,  0.74565566,
        -0.65729904,  0.89706427, -0.9992633 , -0.85835195, -0.42205122,
         0.02660483, -0.6537962 , -0.31771183,  0.3093419 , -0.97574544,
         0.5961652 ,  0.48927927, -0.99429876, -0.99184316, -0.10422545,
         0.85884523,  0.00486639, -0.9560245 , -0.71263295, -0.59398985,
         0.5138035 , -0.27638632, -0.96817255,  0.17129657, -0.295536  ,
         0.56728745, -0.26840574,  0.5732834 ,  0.6681473 ,  0.7473094 ,
        -0.42653623, -0.05367717, -0.02169049, -0.8601829 ,  0.8354379 ,
        -0.84583515, -0.73801994, -0.1758596 ,  1.        , -0.5074421 ,
         0.74395454,  0.8140395 ,  0.8012395 , -0.19783951,  0.12990536,
         0.8705507 ,  0.23519993, -0.60337013, -0.6908616 , -0.85193384,
        -0.41151592,  0.6187978 ,  0.25217745,  0.43870094,  0.85306245,
         0.75531286,  0.20293558, -0.01406304, -0.10706785,  0.9998205 ,
        -0.14611307, -0.24235162, -0.6237957 ,  0.02892364, -0.4086271 ,
        -0.5665821 ,  1.        ,  0.342323  ,  0.328192  , -0.99026304,
        -0.63736963, -0.9433317 ,  0.9999989 ,  0.9019552 , -0.87858593,
         0.6951615 ,  0.5400228 , -0.09183987,  0.8488278 , -0.18790367,
        -0.31657013,  0.317574  ,  0.13583037,  0.96701694, -0.622579  ,
        -0.97985405, -0.6803688 ,  0.42359763, -0.9725251 ,  0.9994953 ,
        -0.542078  , -0.24575908, -0.4273482 , -0.01201347,  0.7613651 ,
         0.00731448, -0.98946   , -0.11817224,  0.2206094 ,  0.97735566,
         0.1929144 , -0.591835  , -0.9492599 ,  0.50090253,  0.62826014,
        -0.76978254, -0.9621842 ,  0.9751784 , -0.9908679 ,  0.66289395,
         1.        ,  0.31703115, -0.43707806,  0.15467693, -0.56510115,
         0.36916867, -0.28950256,  0.7145889 , -0.9760138 , -0.48779896,
        -0.13801542,  0.38100198, -0.13986678,  0.13865034,  0.784588  ,
         0.20181029, -0.49005198, -0.6200816 , -0.02545768,  0.51952076,
         0.8692346 , -0.36663455, -0.19382007, -0.01067433, -0.19743322,
        -0.95507383, -0.24380404, -0.29982236, -0.9999688 ,  0.79986584,
        -1.        ,  0.2695148 , -0.08518916, -0.18281214,  0.8777597 ,
         0.5447604 ,  0.49969584, -0.8048793 , -0.694106  ,  0.61722565,
         0.81101197, -0.29681554, -0.13316315, -0.7884097 ,  0.25134793,
        -0.07460118,  0.40256706, -0.33344275,  0.8121781 , -0.24125008,
         1.        ,  0.19404748, -0.61283517, -0.9879942 ,  0.22347625,
        -0.18747559,  0.99999994, -0.9469065 , -0.9642234 ,  0.35057634,
        -0.70234084, -0.88181317,  0.2818043 , -0.00923758, -0.8131019 ,
        -0.90696543,  0.97128403,  0.9361259 , -0.61874884,  0.5001946 ,
        -0.3375339 , -0.616567  ,  0.01690421,  0.60233366,  0.99087167,
         0.48337436,  0.9235803 , -0.08378224, -0.24273983,  0.9741196 ,
         0.13318112,  0.6367294 ,  0.20994084,  1.        ,  0.2779764 ,
        -0.94073814,  0.23566417, -0.9866463 , -0.20943974, -0.97578436,
         0.27121937,  0.18821484,  0.9488337 , -0.3315034 ,  0.96209157,
        -0.5729339 ,  0.05573122, -0.5332821 , -0.03750358,  0.37780896,
        -0.9583214 , -0.9877656 , -0.9878868 ,  0.6314601 , -0.4537851 ,
        -0.0323552 ,  0.24128953,  0.11342575,  0.46291897,  0.5541575 ,
        -1.        ,  0.95559114,  0.42294934,  0.77785254,  0.9710445 ,
         0.7026142 ,  0.42804685,  0.33771977, -0.9899562 , -0.9919649 ,
        -0.40367672, -0.2135195 ,  0.7956065 ,  0.6891527 ,  0.9223903 ,
         0.4893354 , -0.51037455, -0.35977358, -0.28881362, -0.7840159 ,
        -0.99540436,  0.47370532, -0.3997906 , -0.98349714,  0.95919394,
        -0.13264774, -0.16179705,  0.13471113, -0.69341195,  0.97857916,
         0.8883015 ,  0.5587162 ,  0.13504937,  0.5614963 ,  0.9285318 ,
         0.97044104,  0.9836765 , -0.6593045 ,  0.8397449 , -0.38409153,
         0.56074977,  0.6409418 , -0.9576191 ,  0.15008189,  0.32664824,
        -0.24418157,  0.22771904, -0.26481634, -0.9884511 ,  0.34720448,
        -0.17766179,  0.64612764, -0.38605484, -0.0186708 , -0.48134714,
        -0.10996526, -0.7571417 , -0.76564854,  0.6945152 ,  0.3526681 ,
         0.9315834 ,  0.71839595, -0.12440112, -0.6379952 , -0.2399207 ,
        -0.5485674 , -0.94808227,  0.9552906 , -0.03638262, -0.05993683,
         0.3750182 , -0.04180279,  0.7299626 , -0.08958837, -0.39086553,
        -0.39726564, -0.7406826 ,  0.90645045, -0.09038296, -0.56262934,
        -0.7078029 ,  0.75853217,  0.25826415,  0.99992806, -0.564312  ,
        -0.8097277 , -0.23506235, -0.442809  ,  0.354424  , -0.39383766,
        -1.        ,  0.37609363, -0.36428654,  0.53091085, -0.62894225,
         0.57903147, -0.50878316, -0.9908445 , -0.19053973,  0.4337847 ,
         0.610516  , -0.59371257, -0.66226494,  0.5636608 ,  0.06387527,
         0.95153147,  0.8910796 ,  0.10300018,  0.35302562,  0.6912232 ,
        -0.4406702 , -0.6655127 ,  0.951942  ]], dtype=float32), array([[-0.9459755 , -0.47805053, -0.65050876,  0.7734777 ,  0.552691  ,
        -0.19007854,  0.9223234 ,  0.27941042, -0.7322695 , -0.99998975,
        -0.37605256,  0.8916531 ,  0.983763  ,  0.2527561 ,  0.966363  ,
        -0.7447939 , -0.5058228 , -0.6355803 ,  0.420939  , -0.7473378 ,
         0.74549365,  0.9999191 ,  0.36683556,  0.31255466,  0.4609189 ,
         0.9825759 , -0.8520847 ,  0.9575349 ,  0.9682904 ,  0.72985345,
        -0.82898533,  0.14331765, -0.98895043, -0.23441169, -0.7558871 ,
        -0.9913596 ,  0.39418277, -0.84416234,  0.05476778, -0.01005056,
        -0.94226193,  0.24747927,  0.99995273, -0.13606967,  0.13124019,
        -0.34404624, -0.99999994,  0.16850327, -0.8896826 ,  0.75479925,
         0.6656554 ,  0.5275847 ,  0.27075547,  0.49543703,  0.43383783,
         0.05168212, -0.11341204,  0.10182644, -0.22263326, -0.63695884,
        -0.62449884,  0.2913445 , -0.84347934, -0.9449906 ,  0.82978284,
         0.6233054 , -0.076456  , -0.2860726 , -0.12531959, -0.0440293 ,
         0.92798275,  0.27617946,  0.27131325, -0.90081406,  0.37721077,
         0.31383792, -0.6580769 ,  1.        , -0.44372475, -0.9799322 ,
         0.73667705,  0.5613586 ,  0.5506944 , -0.01951157,  0.298312  ,
        -1.        ,  0.40395644, -0.12005024, -0.99280196,  0.25549296,
         0.58356893, -0.28049406,  0.342898  ,  0.61289656, -0.4513767 ,
        -0.34312075, -0.29862905, -0.7756922 , -0.23678726, -0.25012112,
        -0.01759785, -0.28374395, -0.2618543 , -0.35386655,  0.28066075,
        -0.482542  , -0.54826105,  0.44234577, -0.02860786,  0.7147769 ,
         0.45068547, -0.38843894,  0.5060407 , -0.97053695,  0.67816174,
        -0.2818997 , -0.98881775, -0.6243588 , -0.992165  ,  0.71923774,
        -0.279121  , -0.25058544,  0.9760995 ,  0.01690155,  0.39211938,
         0.01538094, -0.6557028 , -1.        , -0.5813251 , -0.41143104,
        -0.09620688, -0.20363976, -0.9794194 , -0.9636516 ,  0.6528108 ,
         0.97018564,  0.16890207,  0.99986917, -0.28804392,  0.9545565 ,
        -0.25736585, -0.5225193 ,  0.47669268, -0.45857254,  0.6629523 ,
         0.33144143, -0.7786891 ,  0.2574491 , -0.05056868,  0.06687481,
        -0.572528  , -0.20754746, -0.58802915, -0.97018045, -0.40681118,
         0.970967  , -0.37611288, -0.8045078 ,  0.18828286, -0.16196367,
        -0.4732573 ,  0.88972455,  0.5881976 ,  0.37267888, -0.19704172,
         0.39486232,  0.13269943,  0.54943895, -0.8223527 ,  0.1638822 ,
         0.45692173, -0.3252729 , -0.59520465, -0.985078  , -0.41795856,
         0.64682806,  0.99037033,  0.8276212 ,  0.29061356,  0.58312225,
        -0.16352373,  0.64946914, -0.9703819 ,  0.9829681 , -0.35020226,
         0.26412863, -0.16023819,  0.48377427, -0.9017009 , -0.04951501,
         0.88109   , -0.572556  , -0.88953966,  0.03719393, -0.51457113,
        -0.43427563, -0.66786784,  0.55420285, -0.30180818, -0.35544968,
        -0.05752672,  0.94897026,  0.9884329 ,  0.8514675 , -0.02706478,
         0.6300914 , -0.94219875, -0.6096796 ,  0.08986723,  0.20492023,
         0.2656025 ,  0.99588263, -0.4211055 , -0.1923249 , -0.95686954,
        -0.99127907, -0.08337305, -0.9306704 , -0.18833733, -0.7482102 ,
         0.55400956,  0.0555265 ,  0.46837628,  0.38679695, -0.99511546,
        -0.80549157,  0.4122052 , -0.37963787,  0.4697992 , -0.16269048,
         0.5950353 ,  0.88734823, -0.5756747 ,  0.83287156,  0.9290157 ,
        -0.7439878 , -0.828965  ,  0.8942273 , -0.313458  ,  0.92042863,
        -0.6451802 ,  0.99454874,  0.83056575,  0.8252365 , -0.9574431 ,
        -0.5787046 , -0.93613344, -0.58610857, -0.10107749, -0.17892347,
         0.81836295,  0.6172731 ,  0.41681796,  0.57118464, -0.6225571 ,
         0.9989582 , -0.7001649 , -0.96139723, -0.27740443, -0.23548205,
        -0.98848706,  0.74846864,  0.35963902, -0.10826006, -0.46944666,
        -0.6967058 , -0.97237617,  0.9392128 ,  0.10147385,  0.9926904 ,
        -0.16881682, -0.946524  , -0.5884638 , -0.9540271 , -0.24724305,
        -0.28957403, -0.15261933, -0.11785159, -0.9682255 ,  0.49430174,
         0.5003349 ,  0.48061895, -0.6137284 ,  0.999326  ,  0.9999998 ,
         0.976841  ,  0.91392696,  0.9618617 , -0.9992805 , -0.67680204,
         0.9999956 , -0.98577553, -1.        , -0.9550538 , -0.70691264,
         0.465085  , -1.        , -0.15956445,  0.03087116, -0.9547435 ,
         0.37775376,  0.9846359 ,  0.99576795, -1.        ,  0.89814603,
         0.9636626 , -0.6454543 ,  0.9496282 , -0.26886773,  0.9733797 ,
         0.6540432 ,  0.2397651 , -0.29637057,  0.43193617, -0.84643066,
        -0.91404974, -0.29513764, -0.59079194,  0.9944733 ,  0.16350774,
        -0.7428708 , -0.9541641 ,  0.15665837, -0.253073  , -0.18864983,
        -0.97502136, -0.14366363,  0.32544258,  0.80569303,  0.14729789,
         0.28502184, -0.7632915 ,  0.27309316, -0.21719639,  0.47755685,
         0.6861862 , -0.95450646, -0.7322332 , -0.31859246, -0.3092003 ,
        -0.45525196, -0.96703494,  0.97626525, -0.47885466,  0.6296605 ,
         1.        ,  0.19711891, -0.92267424,  0.55910766,  0.26710632,
        -0.35919994,  1.        ,  0.7761388 , -0.9830818 , -0.5782019 ,
         0.40678364, -0.55976874, -0.5471115 ,  0.99937713, -0.33048865,
        -0.5061277 , -0.14908014,  0.9785268 , -0.99043804,  0.9828222 ,
        -0.9187875 , -0.9773213 ,  0.9800687 ,  0.955108  , -0.63989365,
        -0.78066677,  0.25093687, -0.52095413,  0.35847044, -0.9796438 ,
         0.77040577,  0.5041405 , -0.11713739,  0.90462315, -0.90723217,
        -0.5658021 ,  0.3393464 , -0.57253885, -0.03464808,  0.7852318 ,
         0.5863543 , -0.2903683 ,  0.10524008, -0.3157491 , -0.3283432 ,
        -0.98630184,  0.25248316,  1.        , -0.2932054 ,  0.43194744,
        -0.39159498, -0.02471775, -0.12938915,  0.5425912 ,  0.63316727,
        -0.31224072, -0.90678704,  0.6802484 , -0.98032105, -0.98643327,
         0.88515776,  0.2762025 , -0.25967157,  0.9999937 ,  0.52587867,
         0.18437354,  0.34015328,  0.97531146, -0.00961124,  0.6977997 ,
         0.7714908 ,  0.97960067, -0.19878545,  0.5547651 ,  0.91813415,
        -0.76973844, -0.29839078, -0.6457684 ,  0.11847758, -0.93472254,
         0.04859285, -0.9728577 ,  0.9758918 ,  0.79083323,  0.37397337,
         0.29322428,  0.3463571 ,  1.        , -0.28344712,  0.74565566,
        -0.65729904,  0.89706427, -0.9992633 , -0.85835195, -0.42205122,
         0.02660483, -0.6537962 , -0.31771183,  0.3093419 , -0.97574544,
         0.5961652 ,  0.48927927, -0.99429876, -0.99184316, -0.10422545,
         0.85884523,  0.00486639, -0.9560245 , -0.71263295, -0.59398985,
         0.5138035 , -0.27638632, -0.96817255,  0.17129657, -0.295536  ,
         0.56728745, -0.26840574,  0.5732834 ,  0.6681473 ,  0.7473094 ,
        -0.42653623, -0.05367717, -0.02169049, -0.8601829 ,  0.8354379 ,
        -0.84583515, -0.73801994, -0.1758596 ,  1.        , -0.5074421 ,
         0.74395454,  0.8140395 ,  0.8012395 , -0.19783951,  0.12990536,
         0.8705507 ,  0.23519993, -0.60337013, -0.6908616 , -0.85193384,
        -0.41151592,  0.6187978 ,  0.25217745,  0.43870094,  0.85306245,
         0.75531286,  0.20293558, -0.01406304, -0.10706785,  0.9998205 ,
        -0.14611307, -0.24235162, -0.6237957 ,  0.02892364, -0.4086271 ,
        -0.5665821 ,  1.        ,  0.342323  ,  0.328192  , -0.99026304,
        -0.63736963, -0.9433317 ,  0.9999989 ,  0.9019552 , -0.87858593,
         0.6951615 ,  0.5400228 , -0.09183987,  0.8488278 , -0.18790367,
        -0.31657013,  0.317574  ,  0.13583037,  0.96701694, -0.622579  ,
        -0.97985405, -0.6803688 ,  0.42359763, -0.9725251 ,  0.9994953 ,
        -0.542078  , -0.24575908, -0.4273482 , -0.01201347,  0.7613651 ,
         0.00731448, -0.98946   , -0.11817224,  0.2206094 ,  0.97735566,
         0.1929144 , -0.591835  , -0.9492599 ,  0.50090253,  0.62826014,
        -0.76978254, -0.9621842 ,  0.9751784 , -0.9908679 ,  0.66289395,
         1.        ,  0.31703115, -0.43707806,  0.15467693, -0.56510115,
         0.36916867, -0.28950256,  0.7145889 , -0.9760138 , -0.48779896,
        -0.13801542,  0.38100198, -0.13986678,  0.13865034,  0.784588  ,
         0.20181029, -0.49005198, -0.6200816 , -0.02545768,  0.51952076,
         0.8692346 , -0.36663455, -0.19382007, -0.01067433, -0.19743322,
        -0.95507383, -0.24380404, -0.29982236, -0.9999688 ,  0.79986584,
        -1.        ,  0.2695148 , -0.08518916, -0.18281214,  0.8777597 ,
         0.5447604 ,  0.49969584, -0.8048793 , -0.694106  ,  0.61722565,
         0.81101197, -0.29681554, -0.13316315, -0.7884097 ,  0.25134793,
        -0.07460118,  0.40256706, -0.33344275,  0.8121781 , -0.24125008,
         1.        ,  0.19404748, -0.61283517, -0.9879942 ,  0.22347625,
        -0.18747559,  0.99999994, -0.9469065 , -0.9642234 ,  0.35057634,
        -0.70234084, -0.88181317,  0.2818043 , -0.00923758, -0.8131019 ,
        -0.90696543,  0.97128403,  0.9361259 , -0.61874884,  0.5001946 ,
        -0.3375339 , -0.616567  ,  0.01690421,  0.60233366,  0.99087167,
         0.48337436,  0.9235803 , -0.08378224, -0.24273983,  0.9741196 ,
         0.13318112,  0.6367294 ,  0.20994084,  1.        ,  0.2779764 ,
        -0.94073814,  0.23566417, -0.9866463 , -0.20943974, -0.97578436,
         0.27121937,  0.18821484,  0.9488337 , -0.3315034 ,  0.96209157,
        -0.5729339 ,  0.05573122, -0.5332821 , -0.03750358,  0.37780896,
        -0.9583214 , -0.9877656 , -0.9878868 ,  0.6314601 , -0.4537851 ,
        -0.0323552 ,  0.24128953,  0.11342575,  0.46291897,  0.5541575 ,
        -1.        ,  0.95559114,  0.42294934,  0.77785254,  0.9710445 ,
         0.7026142 ,  0.42804685,  0.33771977, -0.9899562 , -0.9919649 ,
        -0.40367672, -0.2135195 ,  0.7956065 ,  0.6891527 ,  0.9223903 ,
         0.4893354 , -0.51037455, -0.35977358, -0.28881362, -0.7840159 ,
        -0.99540436,  0.47370532, -0.3997906 , -0.98349714,  0.95919394,
        -0.13264774, -0.16179705,  0.13471113, -0.69341195,  0.97857916,
         0.8883015 ,  0.5587162 ,  0.13504937,  0.5614963 ,  0.9285318 ,
         0.97044104,  0.9836765 , -0.6593045 ,  0.8397449 , -0.38409153,
         0.56074977,  0.6409418 , -0.9576191 ,  0.15008189,  0.32664824,
        -0.24418157,  0.22771904, -0.26481634, -0.9884511 ,  0.34720448,
        -0.17766179,  0.64612764, -0.38605484, -0.0186708 , -0.48134714,
        -0.10996526, -0.7571417 , -0.76564854,  0.6945152 ,  0.3526681 ,
         0.9315834 ,  0.71839595, -0.12440112, -0.6379952 , -0.2399207 ,
        -0.5485674 , -0.94808227,  0.9552906 , -0.03638262, -0.05993683,
         0.3750182 , -0.04180279,  0.7299626 , -0.08958837, -0.39086553,
        -0.39726564, -0.7406826 ,  0.90645045, -0.09038296, -0.56262934,
        -0.7078029 ,  0.75853217,  0.25826415,  0.99992806, -0.564312  ,
        -0.8097277 , -0.23506235, -0.442809  ,  0.354424  , -0.39383766,
        -1.        ,  0.37609363, -0.36428654,  0.53091085, -0.62894225,
         0.57903147, -0.50878316, -0.9908445 , -0.19053973,  0.4337847 ,
         0.610516  , -0.59371257, -0.66226494,  0.5636608 ,  0.06387527,
         0.95153147,  0.8910796 ,  0.10300018,  0.35302562,  0.6912232 ,
        -0.4406702 , -0.6655127 ,  0.951942  ]], dtype=float32)]

Body: pd.DataFrame([np.array([1,2,3]),np.array([2,3,4])])


问:
Retrieving beans in Spring Boot?
I've worked with legacy Spring in the past. We defined our beans via xml configuration and manually wired them. My team is finally making a concerted effort to update to annotations and use Spring Boot instead of the 'traditional' approach with Spring MVC.

With that said, I cannot figure out how the heck I retrieve a bean in Boot. In legacy, Spring would either use constructor/setter injection (depending on our configuration), or we could directly call a bean with context.getBean("myBeanID"); However, it does not appear to be the case anymore.

I put together a small test case to try and get this working in the below code:

```<code>package com.ots;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@SpringBootApplication
public class GriefUIApplication{

    public static void main(String[] args) {
        SpringApplication.run(GriefUIApplication.class, args);

        SessionFactory factory = new Configuration().configure("hibernate.cfg.xml")
                .addAnnotatedClass(GriefRecord.class).addAnnotatedClass(RecordId.class)
                .addAnnotatedClass(CrossReferenceRecord.class)
                .buildSessionFactory();

        Statics.setSessionFactory(factory);

        TennisCoach tCoach = new TennisCoach();
        tCoach.getCoach();

    }

}

interface Coach{
    public String workout();
}

@Service
class TennisCoach implements Coach{

    private Coach soccerCoach;
    @Autowired
    private ApplicationContext context;

    public TennisCoach() {

    }

    public Coach getCoach() {

        System.out.println(context + " IS THE VALUE OF THE CONTEXT OBJECT");

        soccerCoach = (SoccerCoach)context.getBean("soccerCoach");

        System.out.println(soccerCoach.getClass());

        return soccerCoach;

    }

    @Override
    public String workout() {
        String practice = "practice your backhand!";
        System.out.println(practice);
        return practice;
    }

}

@Service
class SoccerCoach implements Coach{

    public SoccerCoach() {

    }

    @Override
    public String workout() {
        String practice = "practice your footwork!";
        System.out.println(practice);
        return practice;
    }

}

@RestController
class MyController{

    @GetMapping("/")
    public String sayHello() {

        return "Time on server is: " + new java.util.Date();
    }

}
</code>```

I tried autowiring the ApplicationContext object into the TennisCoach class. When I run this, that object is null.

How do we retrieve beans in Boot?

答:
The most common approach is to use the @Autowired annotation. Also, because you have two different implementations of the Coach interface, you should use the @Qualifier annotation to tell Spring which interface implementation to inject.

Some tutorials about these two annotations, to get you started:

https://www.baeldung.com/spring-autowire

https://www.baeldung.com/spring-qualifier-annotation

For your example, to inject the beans into your controller, you should do:

```<code>@RestController
class MyController {

    @Autowired
    @Qualifier("soccerCoach")
    private Coach coach;

    @GetMapping("/")
    public String sayHello() {
        // this should invoke the workout() from SoccerCoach implementation
        System.out.println(coach.workout());

        return "Time on server is: " + new java.util.Date();
    }

}
</code>```

Or, to inject the soccerCoach into the tennisCoach as you intended, using constructor injection , the code would become:

```<code>@Service
class TennisCoach implements Coach {

    private Coach soccerCoach;

    @Autowired
    public TennisCoach(@Qualifier("soccerCoach") Coach soccerCoach) {
        this.soccerCoach = soccerCoach;
    }

    public Coach getCoach() {
        System.out.println(soccerCoach.getClass());

        return soccerCoach;
    }

}
</code>```

If you really need to use the ApplicationContext to retrieve some bean, it's not advisable to do so in your class that has the main function. Just create another bean (you could use the @Componenent annotation). Here's an example:

```<code>@Component
public class AnyComponent {

    @Autowired
    private ApplicationContext applicationContext;

    public void invokeCoach() {
        System.out.println(applicationContext.getBean("tennisCoach"));
        System.out.println(applicationContext.getBean(SoccerCoach.class));
    }

}
</code>```

And inject this bean in your application flow, could be in the controller, service, or repository:

```<code>@RestController
class MyController {

    @Autowired
    private AnyComponent anyComponent;

    @GetMapping("/")
    public String sayHello() {
        anyComponent.invokeCoach();

        return "Time on server is: " + new java.util.Date();
    }

}
</code>```

Note: Injecting beans through annotation is something specific to Spring, in general, not Spring Boot in particular.

From https://www.baeldung.com/spring-autowire:

Starting with Spring 2.5, the framework introduced a new style of Dependency Injection driven by @Autowired Annotations. This annotation allows Spring to resolve and inject collaborating beans into your bean.

Title: Retrieving beans in Spring Boot?

Body:
I've worked with legacy Spring in the past. We defined our beans via xml configuration and manually wired them. My team is finally making a concerted effort to update to annotations and use Spring Boot instead of the 'traditional' approach with Spring MVC.

With that said, I cannot figure out how the heck I retrieve a bean in Boot. In legacy, Spring would either use constructor/setter injection (depending on our configuration), or we could directly call a bean with context.getBean("myBeanID"); However, it does not appear to be the case anymore.

I put together a small test case to try and get this working in the below code:

package com.ots;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@SpringBootApplication
public class GriefUIApplication{

    public static void main(String[] args) {
        SpringApplication.run(GriefUIApplication.class, args);

        SessionFactory factory = new Configuration().configure("hibernate.cfg.xml")
                .addAnnotatedClass(GriefRecord.class).addAnnotatedClass(RecordId.class)
                .addAnnotatedClass(CrossReferenceRecord.class)
                .buildSessionFactory();

        Statics.setSessionFactory(factory);

        TennisCoach tCoach = new TennisCoach();
        tCoach.getCoach();

    }

}

interface Coach{
    public String workout();
}

@Service
class TennisCoach implements Coach{

    private Coach soccerCoach;
    @Autowired
    private ApplicationContext context;

    public TennisCoach() {

    }

    public Coach getCoach() {

        System.out.println(context + " IS THE VALUE OF THE CONTEXT OBJECT");

        soccerCoach = (SoccerCoach)context.getBean("soccerCoach");

        System.out.println(soccerCoach.getClass());

        return soccerCoach;

    }

    @Override
    public String workout() {
        String practice = "practice your backhand!";
        System.out.println(practice);
        return practice;
    }

}

@Service
class SoccerCoach implements Coach{

    public SoccerCoach() {

    }

    @Override
    public String workout() {
        String practice = "practice your footwork!";
        System.out.println(practice);
        return practice;
    }

}

@RestController
class MyController{

    @GetMapping("/")
    public String sayHello() {

        return "Time on server is: " + new java.util.Date();
    }

}

I tried autowiring the ApplicationContext object into the TennisCoach class. When I run this, that object is null.

How do we retrieve beans in Boot?

Body:
The most common approach is to use the @Autowired annotation. Also, because you have two different implementations of the Coach interface, you should use the @Qualifier annotation to tell Spring which interface implementation to inject.

Some tutorials about these two annotations, to get you started:

https://www.baeldung.com/spring-autowire

https://www.baeldung.com/spring-qualifier-annotation

For your example, to inject the beans into your controller, you should do:

@RestController
class MyController {

    @Autowired
    @Qualifier("soccerCoach")
    private Coach coach;

    @GetMapping("/")
    public String sayHello() {
        // this should invoke the workout() from SoccerCoach implementation
        System.out.println(coach.workout());

        return "Time on server is: " + new java.util.Date();
    }

}

Or, to inject the soccerCoach into the tennisCoach as you intended, using constructor injection , the code would become:

@Service
class TennisCoach implements Coach {

    private Coach soccerCoach;

    @Autowired
    public TennisCoach(@Qualifier("soccerCoach") Coach soccerCoach) {
        this.soccerCoach = soccerCoach;
    }

    public Coach getCoach() {
        System.out.println(soccerCoach.getClass());

        return soccerCoach;
    }

}

If you really need to use the ApplicationContext to retrieve some bean, it's not advisable to do so in your class that has the main function. Just create another bean (you could use the @Componenent annotation). Here's an example:

@Component
public class AnyComponent {

    @Autowired
    private ApplicationContext applicationContext;

    public void invokeCoach() {
        System.out.println(applicationContext.getBean("tennisCoach"));
        System.out.println(applicationContext.getBean(SoccerCoach.class));
    }

}

And inject this bean in your application flow, could be in the controller, service, or repository:

@RestController
class MyController {

    @Autowired
    private AnyComponent anyComponent;

    @GetMapping("/")
    public String sayHello() {
        anyComponent.invokeCoach();

        return "Time on server is: " + new java.util.Date();
    }

}

Note: Injecting beans through annotation is something specific to Spring, in general, not Spring Boot in particular.

From https://www.baeldung.com/spring-autowire:

Starting with Spring 2.5, the framework introduced a new style of Dependency Injection driven by @Autowired Annotations. This annotation allows Spring to resolve and inject collaborating beans into your bean.


问:
Make the console wait for a user input to close
I have a console application that after performing its tasks, must give feedback to the user, such as "operation completed" or "operation failed" and the detailed error.

The thing is, if I just "let it run", the output message will be printed but the console will close shortly afterwards, leaving no time to read the message.

As far as I remember, in C++, every console application will end with a "press any key to exit" or something like that. In C# I can simulate this behavior with a

```<code>Console.ReadKey();
</code>```

But how can I do it in Java? I'm using the Scanner class, but given that "input" is my instance of Scanner:

```<code>input.next()
System.exit(0);
</code>```

"Any key" will work, except for return, which is quite a big deal here. Any pointers?

答:
The problem with Java console input is that it's buffered input, and requires an enter key to continue.

There are these two discussions:
Detecting and acting on keyboard direction keys in Java and Java keyboard input parsing in a console app

The latter of which used JLine to get his problem solved.

I personally haven't used it.

ContentLicense: CC BY-SA 3.0

Body:
I have a console application that after performing its tasks, must give feedback to the user, such as "operation completed" or "operation failed" and the detailed error.

The thing is, if I just "let it run", the output message will be printed but the console will close shortly afterwards, leaving no time to read the message.

As far as I remember, in C++, every console application will end with a "press any key to exit" or something like that. In C# I can simulate this behavior with a

Console.ReadKey();

But how can I do it in Java? I'm using the Scanner class, but given that "input" is my instance of Scanner:

input.next()
System.exit(0);

"Any key" will work, except for return, which is quite a big deal here. Any pointers?


问:
If Statement not working, when using elif
No Clue why this doesn't work.

```<code>Script Below:
def dirpricker():
    prompt = '<>'
    print("Where do you want to install Deploy in the Current Dir?  (Y/n ")
    Userinput = input(prompt)
    print(Userinput)
    if Userinput == "Y" or "y":
        print("Not Ready Yet!")
    elif Userinput == "N" or "n":
        print("No")
    else:
        print("Please Choose either Yes Or No.")
        print(prompt)
dirpricker()
</code>```

thanks, Matt

Output: Not Ready, Even after inputting No.

答:
You must write

```<code>if Userinput == 'Y' or Userinput == 'y':
</code>```

Same for the negative answer.
You can also replace the condition like this:

```<code>if Userinput.upper() == 'Y':
</code>```

Body:
No Clue why this doesn't work.

Script Below:
def dirpricker():
    prompt = '<>'
    print("Where do you want to install Deploy in the Current Dir?  (Y/n ")
    Userinput = input(prompt)
    print(Userinput)
    if Userinput == "Y" or "y":
        print("Not Ready Yet!")
    elif Userinput == "N" or "n":
        print("No")
    else:
        print("Please Choose either Yes Or No.")
        print(prompt)
dirpricker()

thanks, Matt

Output: Not Ready, Even after inputting No.

Body:
You must write

if Userinput == 'Y' or Userinput == 'y':

Same for the negative answer.
You can also replace the condition like this:

if Userinput.upper() == 'Y':


问:
Compile Perl without threads
I'm compiling Perl 5.30.1 and will be using mod_perl 2.0.11 with it and Apache 2.4.41.

If I try to compile mod_perl with perl MakeFile.pm I get

```<code>Configuring Apache/2.4.41 mod_perl/2.0.11 Perl/v5.30.1
Using Perl 5.030001 w/o ithreads and httpd-2.4.
Failed requirements: Perl built with ithreads (build perl with -Duseithreads)
</code>```

We don't use threads, so it feels like the simplest would be to remove that from Perl compile options...

I can see people say how to compile with it (I guess on older versions of Perl where it was off by default ?)

```<code>-Dusethreads
</code>```

But I'm assuming it now is enabled by default ? In which case, how do I compile without it ?

If I look at the myconfig file it suggests

```<code>useithreads=undef
</code>```

I've tried things like -Dusethreads=no or false, and things like that, but I'm probably missing the right one to use.

I've also got nothing against enabling threads on mod_perl (but can't find how to do that either) if there isn't a performance hit (posts on S.O seem to suggest there is a 10% hit, but not sure if that's still relevant)

The steps I took (new server) were..downloading

```<code>perl-5.30.1 and mod_perl-2.0.11
</code>```

Then

```<code>CFLAGS='-m64 -mtune=nocona' ./Configure -des -A ccflags=-fPIC -Dprefix=/opt/perl
</code>```

perl -v doesn't show threads.

And then for mod_perl

```<code>Perl Makefile.PL
</code>```

Apache compiled with

```<code>./configure --enable-proxy --enable-rewrite --enable-headers --enable-ssl --with-apr=/usr/local/apr/
</code>```

Edit: So it may be that mod_perl needs threads enabled as it is, so is there a way to turn that off in compile options if that's the case.

答:
The answer I think seems to be to compile mod_perl with the option..

```<code>perl Makefile.PL MP_NO_THREADS=1
</code>```

If anyone wants to provide a more complete answer as to whether it's not so desirable to do that now (or any other info), as there seem to be some changes with Apache 2.4 I will gladly accept their answer.

Title: Compile Perl without threads

Body:
I'm compiling Perl 5.30.1 and will be using mod_perl 2.0.11 with it and Apache 2.4.41.

If I try to compile mod_perl with perl MakeFile.pm I get

Configuring Apache/2.4.41 mod_perl/2.0.11 Perl/v5.30.1
Using Perl 5.030001 w/o ithreads and httpd-2.4.
Failed requirements: Perl built with ithreads (build perl with -Duseithreads)

We don't use threads, so it feels like the simplest would be to remove that from Perl compile options...

I can see people say how to compile with it (I guess on older versions of Perl where it was off by default ?)

-Dusethreads

But I'm assuming it now is enabled by default ? In which case, how do I compile without it ?

If I look at the myconfig file it suggests

useithreads=undef

I've tried things like -Dusethreads=no or false, and things like that, but I'm probably missing the right one to use.

I've also got nothing against enabling threads on mod_perl (but can't find how to do that either) if there isn't a performance hit (posts on S.O seem to suggest there is a 10% hit, but not sure if that's still relevant)

The steps I took (new server) were..downloading

perl-5.30.1 and mod_perl-2.0.11

Then

CFLAGS='-m64 -mtune=nocona' ./Configure -des -A ccflags=-fPIC -Dprefix=/opt/perl

perl -v doesn't show threads.

And then for mod_perl

Perl Makefile.PL

Apache compiled with

./configure --enable-proxy --enable-rewrite --enable-headers --enable-ssl --with-apr=/usr/local/apr/

Edit: So it may be that mod_perl needs threads enabled as it is, so is there a way to turn that off in compile options if that's the case.

Body:
The answer I think seems to be to compile mod_perl with the option..

perl Makefile.PL MP_NO_THREADS=1

If anyone wants to provide a more complete answer as to whether it's not so desirable to do that now (or any other info), as there seem to be some changes with Apache 2.4 I will gladly accept their answer.


问:
Create a stored procedure that generates SQL Server Agent jobs
Curious if this is feasible. I am currently in the process of building a number of SQL Server agent jobs. These jobs are just SFTP jobs that pass files between the servers of 2 different clients, making a pit-stop at my local server for some pre and post processing. Yes, this setup is from one standpoint unnecessarily complicated, but it is necessary from a security standpoint. All of these jobs have identical structure:

SFTP a file from the client1server to the local server.

Run an executable on the file

SFTP the processed file to client2server.

Wait a predetermined amount of time so that client2 can perform their query on the input.

SFTP the response file from client2server to the local server.

Run a second executable on the file.

SFTP the processed response file back to client1server.

Pretty straight forward.

There are only a handful of values that change between each job:
 - Input/output file path on client1server
 - Input/output file path on client2server
 - Directory on local server

These jobs are not complicated, so If necessary I can just create them all by hand. It seems like an unnecessary amount of work though. I had the thought that maybe I could create a stored procedure that would generate the SQL script that creates the job, and that stored procedure could simple accept the variables that change from job to job. Is this feasible?

Broadly, heres what I'm thinking:

CREATE PROCEDURE create_ftp_interface_job
    @client1input_fp nvarchar(100),
    @client1output_fp nvarchar(100),
    @client2input_fp nvarchar(100),
    @client2output_fp nvarchar(100),
    etc...

AS

<SQL Script for creating SQL Server Agent jobs, with parameters inserted>

GO
```

I've tried an early version of this, and I seem to be having trouble referencing the variables I declare in the stored procedure definition inside of the SSA job script. I came here to ask if what I'm attempting is feasible, and I just have a run of the mill reference error, or if what I'm doing is not allowed.

答:
You can use msdb.dbo.sp_add_job, msdb.dbo.sp_add_jobstep, msdb.dbo.sp_update_job, msdb.dbo.sp_add_jobschedule and msdb.dbo.sp_add_jobserver to create and manage SQL Agent Jobs programatically.

In fact there are even more stored procedures here which relate to managing SQL Agent Jobs.

Body:
Curious if this is feasible. I am currently in the process of building a number of SQL Server agent jobs. These jobs are just SFTP jobs that pass files between the servers of 2 different clients, making a pit-stop at my local server for some pre and post processing. Yes, this setup is from one standpoint unnecessarily complicated, but it is necessary from a security standpoint. All of these jobs have identical structure:

SFTP a file from the client1server to the local server.

Run an executable on the file

SFTP the processed file to client2server.

Wait a predetermined amount of time so that client2 can perform their query on the input.

SFTP the response file from client2server to the local server.

Run a second executable on the file.

SFTP the processed response file back to client1server.

Pretty straight forward.

There are only a handful of values that change between each job:
 - Input/output file path on client1server
 - Input/output file path on client2server
 - Directory on local server

These jobs are not complicated, so If necessary I can just create them all by hand. It seems like an unnecessary amount of work though. I had the thought that maybe I could create a stored procedure that would generate the SQL script that creates the job, and that stored procedure could simple accept the variables that change from job to job. Is this feasible?

Broadly, heres what I'm thinking:

CREATE PROCEDURE create_ftp_interface_job
    @client1input_fp nvarchar(100),
    @client1output_fp nvarchar(100),
    @client2input_fp nvarchar(100),
    @client2output_fp nvarchar(100),
    etc...

AS

<SQL Script for creating SQL Server Agent jobs, with parameters inserted>

GO

I've tried an early version of this, and I seem to be having trouble referencing the variables I declare in the stored procedure definition inside of the SSA job script. I came here to ask if what I'm attempting is feasible, and I just have a run of the mill reference error, or if what I'm doing is not allowed.


问:
Why does aiohttp need await to get body?
I found aiohttp server should use await keyword to get Request Body

```<code>async def handler(request):
  body = await request.json(). # or text(), read()
</code>```

I think when the handler is called, the request body is already in server side memory and I don't think it is I/O intensive work, needing asynchronous operation.

Any missing point?

答:
On the contrary, they are not in memory. Quoting the documentation:

While methods read(), json() and text() are very convenient you should use them carefully. All these methods load the whole response in memory. For example if you want to download several gigabyte sized files, these methods will load all the data in memory. Instead you can use the content attribute.

Also see the other answer for the inner workings of the HTTP protocol.

Body:
I found aiohttp server should use await keyword to get Request Body

async def handler(request):
  body = await request.json(). # or text(), read()

I think when the handler is called, the request body is already in server side memory and I don't think it is I/O intensive work, needing asynchronous operation.

Any missing point?


问:
How to perform client side data fetching in Next.js
I am working on a search engine product and need to know the client country code.

I tried to get it with this URL and it returns server side country code.

How can I get the correct user country code when using getInitialProps?

答:
You can do it like this:</p>
```<code>import React from 'react';
import fetch from 'isomorphic-unfetch';
// Vercel has created a data-fetching library called SWR (client side).
import useSWR from 'swr';

const API_URL = 'https://extreme-ip-lookup.com/json/';

async function fetcher(url) {
  const res = await fetch(url);
  const json = await res.json();
  return json;
}

function Index() {
  const { data, error } = useSWR(API_URL, fetcher);

  if (error) return <div>failed to load</div>;
  if (!data) return <div>loading...</div>;

  const { countryCode } = data;

  return (
    <div>
      <p>Country Code: {countryCode}</p>
    </div>
  );
}

export default Index;
</code>```

Body:
You can do it like this:

import React from 'react';
import fetch from 'isomorphic-unfetch';
// Vercel has created a data-fetching library called SWR (client side).
import useSWR from 'swr';

const API_URL = 'https://extreme-ip-lookup.com/json/';

async function fetcher(url) {
  const res = await fetch(url);
  const json = await res.json();
  return json;
}

function Index() {
  const { data, error } = useSWR(API_URL, fetcher);

  if (error) return <div>failed to load</div>;
  if (!data) return <div>loading...</div>;

  const { countryCode } = data;

  return (
    <div>
      <p>Country Code: {countryCode}</p>
    </div>
  );
}

export default Index;


问:
Crash on iPhone?
Can anyone help with any hints by looking into following iPhone device crash log why is the app is getting crashed at the startup itself?

Note: App crashes not all time it does only 50% times of app launch.
Any suggestion are welcome. Thanks in advance.

```<code>Date/Time:       2011-03-21 19:15:21.363 +0000

OS Version:      iPhone OS 4.2.1 (8C148)

Report Version:  104

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)

Exception Codes: KERN_INVALID_ADDRESS at 0x736f485b

Crashed Thread:  0

Thread 0 Crashed:

0   libobjc.A.dylib                 0x00003f24 objc_msgSend + 24

1   UIKit                           0x0002ff18 -[UIApplication sendAction:to:from:forEvent:] + 128

2   UIKit                           0x000ff538 -[UIBarButtonItem(UIInternal) _sendAction:withEvent:] + 128

3   CoreFoundation                  0x00049a3c -[NSObject(NSObject) performSelector:withObject:withObject:] + 20

4   UIKit                           0x0015d968 -[UIApplication sendAction:fromSender:toTarget:forEvent:] + 132

5   UIKit                           0x0019a1dc -[UIControl(Deprecated) sendAction:toTarget:forEvent:] + 48

6   UIKit                           0x000e6a68 -[UIControl(Internal) _sendActionsForEventMask:withEvent:] + 520

7   UIKit                           0x0019af68 -[UIControl mouseUp:] + 500

8   UIKit                           0x00171fbc -[UIView(Internal) _mouseUp:] + 52

9   UIKit                           0x0016cb8c -[UIWindow _handleMouseUp:] + 164

10  UIKit                           0x0016d144 -[UIWindow _statusBarMouseUp:] + 184

11  UIKit                           0x0035e768 -[UIStatusBar touchesEnded:withEvent:] + 436

12  CoreFoundation                  0x00049a3c -[NSObject(NSObject) performSelector:withObject:withObject:] + 20

13  UIKit                           0x00030160 forwardMethod2 + 72

14  UIKit                           0x00021ea8 -[UIWindow _sendTouchesForEvent:] + 580

15  UIKit                           0x000214dc -[UIWindow sendEvent:] + 388

16  UIKit                           0x00004c94 -[UIApplication sendEvent:] + 444

17  UIKit                           0x000043ac _UIApplicationHandleEvent + 6816

18  GraphicsServices                0x00005c80 PurpleEventCallback + 1040

19  CoreFoundation                  0x000365c4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 22

20  CoreFoundation                  0x00036582 __CFRunLoopDoSource1 + 158

21  CoreFoundation                  0x0002882e __CFRunLoopRun + 574

22  CoreFoundation                  0x00028504 CFRunLoopRunSpecific + 220

23  CoreFoundation                  0x00028412 CFRunLoopRunInMode + 54

24  GraphicsServices                0x00004d1c GSEventRunModal + 188

25  UIKit                           0x0004a574 -[UIApplication _run] + 580

26  UIKit                           0x00047550 UIApplicationMain + 964

27  checkmate                       0x00002bbe main + 74

28  checkmate                       0x00002b34 start + 44
</code>```

答: You try to access an object that is not allocated. Paste the lines where app crashes.</p>

Title: Crash on iPhone?

Body:
Can anyone help with any hints by looking into following iPhone device crash log why is the app is getting crashed at the startup itself?

Note: App crashes not all time it does only 50% times of app launch.
Any suggestion are welcome. Thanks in advance.

Date/Time:       2011-03-21 19:15:21.363 +0000

OS Version:      iPhone OS 4.2.1 (8C148)

Report Version:  104

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)

Exception Codes: KERN_INVALID_ADDRESS at 0x736f485b

Crashed Thread:  0

Thread 0 Crashed:

0   libobjc.A.dylib                 0x00003f24 objc_msgSend + 24

1   UIKit                           0x0002ff18 -[UIApplication sendAction:to:from:forEvent:] + 128

2   UIKit                           0x000ff538 -[UIBarButtonItem(UIInternal) _sendAction:withEvent:] + 128

3   CoreFoundation                  0x00049a3c -[NSObject(NSObject) performSelector:withObject:withObject:] + 20

4   UIKit                           0x0015d968 -[UIApplication sendAction:fromSender:toTarget:forEvent:] + 132

5   UIKit                           0x0019a1dc -[UIControl(Deprecated) sendAction:toTarget:forEvent:] + 48

6   UIKit                           0x000e6a68 -[UIControl(Internal) _sendActionsForEventMask:withEvent:] + 520

7   UIKit                           0x0019af68 -[UIControl mouseUp:] + 500

8   UIKit                           0x00171fbc -[UIView(Internal) _mouseUp:] + 52

9   UIKit                           0x0016cb8c -[UIWindow _handleMouseUp:] + 164

10  UIKit                           0x0016d144 -[UIWindow _statusBarMouseUp:] + 184

11  UIKit                           0x0035e768 -[UIStatusBar touchesEnded:withEvent:] + 436

12  CoreFoundation                  0x00049a3c -[NSObject(NSObject) performSelector:withObject:withObject:] + 20

13  UIKit                           0x00030160 forwardMethod2 + 72

14  UIKit                           0x00021ea8 -[UIWindow _sendTouchesForEvent:] + 580

15  UIKit                           0x000214dc -[UIWindow sendEvent:] + 388

16  UIKit                           0x00004c94 -[UIApplication sendEvent:] + 444

17  UIKit                           0x000043ac _UIApplicationHandleEvent + 6816

18  GraphicsServices                0x00005c80 PurpleEventCallback + 1040

19  CoreFoundation                  0x000365c4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 22

20  CoreFoundation                  0x00036582 __CFRunLoopDoSource1 + 158

21  CoreFoundation                  0x0002882e __CFRunLoopRun + 574

22  CoreFoundation                  0x00028504 CFRunLoopRunSpecific + 220

23  CoreFoundation                  0x00028412 CFRunLoopRunInMode + 54

24  GraphicsServices                0x00004d1c GSEventRunModal + 188

25  UIKit                           0x0004a574 -[UIApplication _run] + 580

26  UIKit                           0x00047550 UIApplicationMain + 964

27  checkmate                       0x00002bbe main + 74

28  checkmate                       0x00002b34 start + 44


问:
SwiftUI - Editing a value of an item in a Codable Array Cannot use mutating member on immutable value
I have a built up List with using an array of Codable type called Package. At some point, I need to update the isFavorite value of an Package item when user taps favorite button in the list. However I am getting the error of Cannot use mutating member on immutable value: 'package' is a 'let' constant. First I tried to directly change the value in the action. It did not work, so the point I got so far is below.

Obviously the code is longer than that but I just wanted make it simple and deleted irrelevant parts.

SwiftUIView

```<code>struct AView: View {

    @ObservedObject var store: JSONController

    var body: some View {
        NavigationView {
            List(self.store.packages) { (package) in
                return self.row(package)
            }
        }
    }

    private func row(_ package: Package) -> some View {
        HStack{
            Text(package.name)
            Spacer()
            Button(action: {
                package.changeFavoriteState()
            }) {
                Image(systemName: package.isFavorite ? "star.fill" : "star")
            }.buttonStyle(PlainButtonStyle())
        }
    }
}
</code>```

Package.struct

```<code>struct Package: Codable, Identifiable {

    var id: UUID
    var isFavorite: Bool

    mutating func changeFavoriteState() {
        self.isFavorite.toggle()
    }
}
</code>```

PackageList.struct

```<code>struct PackageList: Codable {

    var packages: [Package]

    private enum CodingKeys: CodingKey {
        case packages
    }

    init(){
        self.packages = [Package]()
    }

    init(from decoder: Decoder) throws {
        do {
            let container = try decoder.container(keyedBy: CodingKeys.self)
            self.packages = try container.decode([Package].self, forKey: .packages)
        }catch let error {
            print(error.localizedDescription+" Initializing packages with an empty array.")
            self.packages = [Package]()
        }
    }
}
</code>```

JSONController.class

```<code>class JSONController: ObservableObject {

    @Published var packages: [Package] = [Package]()

    init(){
        self.readJSONFile(from: "packageList")
    }

    func readJSONFile(from url: String) {
        //stuff
    }

}
</code>```

And finally the error I got,

答:
Change the signature of your function to

```<code>private func row(_ package: inout Package) -> some View
</code>```

Why is that necessary? Because when you are passing a parameter to a function, that parameter is a let constant. Package is a struct so modifying any of its properties means actually modifying the instance itself. Which you cannot do, because it's a let constant.

Another thing is that since Package is a struct it means that when you are passing it to your function, you are actually passing a copy, not the original value.

An inout parameter has a value that is passed in to the function, is modified by the function, and is passed back out of the function to replace the original value.

Body:
I have a built up List with using an array of Codable type called Package. At some point, I need to update the isFavorite value of an Package item when user taps favorite button in the list. However I am getting the error of Cannot use mutating member on immutable value: 'package' is a 'let' constant. First I tried to directly change the value in the action. It did not work, so the point I got so far is below.

Obviously the code is longer than that but I just wanted make it simple and deleted irrelevant parts.

SwiftUIView

struct AView: View {

    @ObservedObject var store: JSONController

    var body: some View {
        NavigationView {
            List(self.store.packages) { (package) in
                return self.row(package)
            }
        }
    }

    private func row(_ package: Package) -> some View {
        HStack{
            Text(package.name)
            Spacer()
            Button(action: {
                package.changeFavoriteState()
            }) {
                Image(systemName: package.isFavorite ? "star.fill" : "star")
            }.buttonStyle(PlainButtonStyle())
        }
    }
}

Package.struct

struct Package: Codable, Identifiable {

    var id: UUID
    var isFavorite: Bool

    mutating func changeFavoriteState() {
        self.isFavorite.toggle()
    }
}

PackageList.struct

struct PackageList: Codable {

    var packages: [Package]

    private enum CodingKeys: CodingKey {
        case packages
    }

    init(){
        self.packages = [Package]()
    }

    init(from decoder: Decoder) throws {
        do {
            let container = try decoder.container(keyedBy: CodingKeys.self)
            self.packages = try container.decode([Package].self, forKey: .packages)
        }catch let error {
            print(error.localizedDescription+" Initializing packages with an empty array.")
            self.packages = [Package]()
        }
    }
}

JSONController.class

class JSONController: ObservableObject {

    @Published var packages: [Package] = [Package]()

    init(){
        self.readJSONFile(from: "packageList")
    }

    func readJSONFile(from url: String) {
        //stuff
    }

}

And finally the error I got,

Body:
Change the signature of your function to

private func row(_ package: inout Package) -> some View

Why is that necessary? Because when you are passing a parameter to a function, that parameter is a let constant. Package is a struct so modifying any of its properties means actually modifying the instance itself. Which you cannot do, because it's a let constant.

Another thing is that since Package is a struct it means that when you are passing it to your function, you are actually passing a copy, not the original value.

An inout parameter has a value that is passed in to the function, is modified by the function, and is passed back out of the function to replace the original value.


问:
Notarizing Mac OS app built with Corona SDK no longer working. Fails validation
These are the commands I'm running.  This used to work for me every time but now it's failing.

codesign -s "Developer ID Application: <YOUR NAME>" --timestamp --options runtime -f --entitlements entitlements.plist --deep <APP NAME>.app

/usr/bin/ditto -c -k --keepParent <APP NAME>.app <APPNAME>.zip

xcrun altool --notarize-app --primary-bundle-id "<BUNDLE ID>" -u "<YOUR EMAIL>" -p "<APP SPECIFIC PASSWORD>" --file <YOURAPP>.zip

I get an email with "your app has failed notarization" or whatnot.

These are the errors I'm getting.

```<code>{
"logFormatVersion": 1,
"jobId": "69910cca-87c0-44f6-a8ec-a0c8a6a7b614",
"status": "Invalid",
"statusSummary": "Archive contains critical validation errors",
"statusCode": 4000,
"archiveFilename": "MegaHasan.zip",
"uploadDate": "2020-02-05T19:07:48Z",
"sha256": "b6b7c75a0e50a9ec9f238360c674f9345ef6a97d27a21a69e793b7938927eb42",
"ticketContents": null,
"issues": [
{
"severity": "error",
"code": null,
"path": "MegaHasan.zip/Mega Hasan.app/Contents/Plugins/plugin_bit.dylib",
"message": "The binary is not signed with a valid Developer ID certificate.",
"docUrl": null,
"architecture": "x86_64"
},
{
"severity": "error",
"code": null,
"path": "MegaHasan.zip/Mega Hasan.app/Contents/Plugins/plugin_bit.dylib",
"message": "The signature does not include a secure timestamp.",
"docUrl": null,
"architecture": "x86_64"
},
{
"severity": "error",
"code": null,
"path": "MegaHasan.zip/Mega Hasan.app/Contents/Plugins/plugin_bit.dylib",
"message": "The binary uses an SDK older than the 10.9 SDK.",
"docUrl": null,
"architecture": "x86_64"
},
{
"severity": "error",
"code": null,
"path": "MegaHasan.zip/Mega Hasan.app/Contents/Plugins/libsteam_api.dylib",
"message": "The binary is not signed with a valid Developer ID certificate.",
"docUrl": null,
"architecture": "x86_64"
},
{
"severity": "error",
"code": null,
"path": "MegaHasan.zip/Mega Hasan.app/Contents/Plugins/libsteam_api.dylib",
"message": "The signature does not include a secure timestamp.",
"docUrl": null,
"architecture": "x86_64"
},
{
"severity": "error",
"code": null,
"path": "MegaHasan.zip/Mega Hasan.app/Contents/Plugins/plugin_steamworks.dylib",
"message": "The binary is not signed with a valid Developer ID certificate.",
"docUrl": null,
"architecture": "x86_64"
},
{
"severity": "error",
"code": null,
"path": "MegaHasan.zip/Mega Hasan.app/Contents/Plugins/plugin_steamworks.dylib",
"message": "The signature does not include a secure timestamp.",
"docUrl": null,
"architecture": "x86_64"
},
{
"severity": "error",
"code": null,
"path": "MegaHasan.zip/Mega Hasan.app/Contents/Frameworks/CoronaCards.framework/Versions/A/Frameworks/gameNetwork.dylib",
"message": "The binary uses an SDK older than the 10.9 SDK.",
"docUrl": null,
"architecture": "x86_64"
},
{
"severity": "error",
"code": null,
"path": "MegaHasan.zip/Mega Hasan.app/Contents/Frameworks/CoronaCards.framework/Versions/A/Frameworks/licensing.dylib",
"message": "The binary uses an SDK older than the 10.9 SDK.",
"docUrl": null,
"architecture": "x86_64"
}
]
}
</code>```

答:
I'm running to similar issues with a notarization process for electron that used to work and now doesn't. I found that somehow some of my certificates had been revoked. They didn't show that way in the Apple Developer site, but when I went into Xcode: Preferences: Accounts and clicked on the Manage Certificates button.

Creating new certificates did get me to the point where I made it through notarization but now get signing errors when I upload with Application Loader, so I may have done something else wrong making the new certificates and regenerating my provisioning profiles, but hopefully this helps you out.

Body:
These are the commands I'm running.  This used to work for me every time but now it's failing.

codesign -s "Developer ID Application: <YOUR NAME>" --timestamp --options runtime -f --entitlements entitlements.plist --deep <APP NAME>.app

/usr/bin/ditto -c -k --keepParent <APP NAME>.app <APPNAME>.zip

xcrun altool --notarize-app --primary-bundle-id "<BUNDLE ID>" -u "<YOUR EMAIL>" -p "<APP SPECIFIC PASSWORD>" --file <YOURAPP>.zip

I get an email with "your app has failed notarization" or whatnot.

These are the errors I'm getting.

{
"logFormatVersion": 1,
"jobId": "69910cca-87c0-44f6-a8ec-a0c8a6a7b614",
"status": "Invalid",
"statusSummary": "Archive contains critical validation errors",
"statusCode": 4000,
"archiveFilename": "MegaHasan.zip",
"uploadDate": "2020-02-05T19:07:48Z",
"sha256": "b6b7c75a0e50a9ec9f238360c674f9345ef6a97d27a21a69e793b7938927eb42",
"ticketContents": null,
"issues": [
{
"severity": "error",
"code": null,
"path": "MegaHasan.zip/Mega Hasan.app/Contents/Plugins/plugin_bit.dylib",
"message": "The binary is not signed with a valid Developer ID certificate.",
"docUrl": null,
"architecture": "x86_64"
},
{
"severity": "error",
"code": null,
"path": "MegaHasan.zip/Mega Hasan.app/Contents/Plugins/plugin_bit.dylib",
"message": "The signature does not include a secure timestamp.",
"docUrl": null,
"architecture": "x86_64"
},
{
"severity": "error",
"code": null,
"path": "MegaHasan.zip/Mega Hasan.app/Contents/Plugins/plugin_bit.dylib",
"message": "The binary uses an SDK older than the 10.9 SDK.",
"docUrl": null,
"architecture": "x86_64"
},
{
"severity": "error",
"code": null,
"path": "MegaHasan.zip/Mega Hasan.app/Contents/Plugins/libsteam_api.dylib",
"message": "The binary is not signed with a valid Developer ID certificate.",
"docUrl": null,
"architecture": "x86_64"
},
{
"severity": "error",
"code": null,
"path": "MegaHasan.zip/Mega Hasan.app/Contents/Plugins/libsteam_api.dylib",
"message": "The signature does not include a secure timestamp.",
"docUrl": null,
"architecture": "x86_64"
},
{
"severity": "error",
"code": null,
"path": "MegaHasan.zip/Mega Hasan.app/Contents/Plugins/plugin_steamworks.dylib",
"message": "The binary is not signed with a valid Developer ID certificate.",
"docUrl": null,
"architecture": "x86_64"
},
{
"severity": "error",
"code": null,
"path": "MegaHasan.zip/Mega Hasan.app/Contents/Plugins/plugin_steamworks.dylib",
"message": "The signature does not include a secure timestamp.",
"docUrl": null,
"architecture": "x86_64"
},
{
"severity": "error",
"code": null,
"path": "MegaHasan.zip/Mega Hasan.app/Contents/Frameworks/CoronaCards.framework/Versions/A/Frameworks/gameNetwork.dylib",
"message": "The binary uses an SDK older than the 10.9 SDK.",
"docUrl": null,
"architecture": "x86_64"
},
{
"severity": "error",
"code": null,
"path": "MegaHasan.zip/Mega Hasan.app/Contents/Frameworks/CoronaCards.framework/Versions/A/Frameworks/licensing.dylib",
"message": "The binary uses an SDK older than the 10.9 SDK.",
"docUrl": null,
"architecture": "x86_64"
}
]
}


问:
When a variable goes out of scope does that mean it doesn't exist?
I'm not sure I understand scope - does an out-of-scope variable (I'm using Ruby) exist in memory somewhere or does it stop existing (I know you can't access it). Would it be inaccurate to say that an out-of-scope variable does not exist any more?

Maybe this is a philosophical question.

答:
Rob Kennedy has this answered appropriately, but I thought I would add a little more detail.

The important thing to recognize is the difference between a variable and the value it represents.

Here's an example (in C# because I don't know Ruby):

```<code>object c = null;
if (1 == 1) // Just to get a different scope
{
    var newObj = new SomeClass();
    newObj.SomeProperty = true;
    c = newObj;
}
</code>```

In the code above, newObj goes out of scope at the end of the if statement and as such "doesn't exist", but the value that it was referring to is still alive and well, referenced by c.  Once all of the references to the object are gone, then the garbage collector will take care of cleaning it up.

OwnerDisplayName: Mark

ContentLicense: CC BY-SA 2.5

Body:
Rob Kennedy has this answered appropriately, but I thought I would add a little more detail.

The important thing to recognize is the difference between a variable and the value it represents.

Here's an example (in C# because I don't know Ruby):

object c = null;
if (1 == 1) // Just to get a different scope
{
    var newObj = new SomeClass();
    newObj.SomeProperty = true;
    c = newObj;
}

In the code above, newObj goes out of scope at the end of the if statement and as such "doesn't exist", but the value that it was referring to is still alive and well, referenced by c.  Once all of the references to the object are gone, then the garbage collector will take care of cleaning it up.

OwnerDisplayName: Chris


问:
Url with special char #
I've to show with a browser some files that contains this # on the name. Using it on the url the file seems to be not available.

How can I configure IIS or my web.config to allow this?

thanks,
Andrea

答:
You need to UrlEncode the file name as you build your URL. This will escape the '#' character, allowing the browser to interpret it appropriately.

Proper encoding is very important for preventing Cross-Site Scripting attacks against your application, which can be devastating.

Title: Url with special char #