问:
Mojo WP Plugin issue - cli-init.php error
I created a WP website and now locked out with the following error:

Parse error: syntax error, unexpected '.', expecting ')' in [my site]/wp-content/plugins/mojo-marketplace-wp-plugin/inc/cli-init.php on line 25. I have traced this back to my code. Here is what lines 20-35:

```<code>protected $commands = array(
    array(
        'cmd'       => 'branding',
        'class'     => 'EIG_WP_CLI_Branding',
        'shortdesc' => 'Control hosting branding and UX.',
        'longdesc'  => 'Control the admin interface, default modules and UX for an Endurance hosting brand.' .
                       PHP_EOL . 'Subcommands: update, remove',
    ),
    array(
        'cmd'       => 'cache',
        'class'     => 'EIG_WP_CLI_Cache',
        'shortdesc' => 'Control all forms of caching.',
        'longdesc'  => 'Control how browser cache, page cache and browser caching are configured.' .
                       PHP_EOL . 'Cache Types: browser, page, object (not functional yet)' .
                       PHP_EOL . 'Subcommands: add, update, status',
    ),
</code>```

I am not seeing any issues although I am not super familiar with the code. Any thoughts on what can be going on? I am  currently configured to use PHP Edge (7.1) Thanks in advance!

答:
For some reason, it was not able to parse the string inside the array.

I changed the syntax to remove the concatenation with PHP_EOL and I was able to fix it without changing the PHP version or deleting the plugin:

```<code>    /**
     * Main variable containing all WP-CLI commands and callbacks.
     *
     * @var array
     */
    protected $commands = array(
        array(
            'cmd'       => 'branding',
            'class'     => 'EIG_WP_CLI_Branding',
            'shortdesc' => 'Control hosting branding and UX.',
            'longdesc'  => 'Control the admin interface, default modules and UX for an Endurance hosting brand.\n
            Subcommands: update, remove',
        ),
        array(
            'cmd'       => 'cache',
            'class'     => 'EIG_WP_CLI_Cache',
            'shortdesc' => 'Control all forms of caching.',
            'longdesc'  => 'Control how browser cache, page cache and browser caching are configured.\n
            Cache Types: browser, page, object (not functional yet)\n
            Subcommands: add, update, status',
        ),
        array(
            'cmd'       => 'digest',
            'class'     => 'EIG_WP_CLI_Digest',
            'shortdesc' => 'Analyze WordPress for this site.',
            'longdesc'  => 'Analyze WordPress content, configuration and server environment.\n
                           Associative Args: --full --noprompt',
        ),
        array(
            'cmd'       => 'secrets',
            'class'     => 'EIG_WP_CLI_Secrets',
            'shortdesc' => 'Control the WordPress Salts.',
            'longdesc'  => 'Read and update WordPress salts in the wp-config.php file.\n
                           Subcommands: update, age, list',
        ),
        array(
            'cmd'       => 'remove_orphan_post_meta',
            'class'     => 'EIG_WP_CLI_Remove_Orphan_Post_Meta',
            'shortdesc' => 'Legacy cmd for removing orphan meta.',
            'longdesc'  => 'Legacy WP-CLI command used for checking for orphaned postmeta.',
        ),
        array(
            'cmd'       => 'sso',
            'class'     => 'EIG_WP_CLI_SSO',
            'shortdesc' => 'Single sign-on from hosting platform.',
            'longdesc'  => 'Handle single sign-on from Endurance hosting platforms and get magic link.\n
                           Associative Args: --username --role --email --id --min=MINUTES_UNTIL_EXPIRE --url-only',
        ),
        array(
            'cmd'       => 'staging',
            'class'     => 'EIG_WP_CLI_Staging',
            'shortdesc' => 'CRUD operations for EIG staging.',
            'longdesc'  => 'Internal commands to handle staging environment.\n
                                         Subcommands: create, clone, destroy, sso_staging, deploy, deploy_files,
                                         deploy_db, deploy_files_db, save_state, restore_state, sso_production',
        ),
        array(
            'cmd'       => 'module',
            'class'     => 'EIG_WP_CLI_Module',
            'shortdesc' => 'Control hosting plugin modules.',
            'longdesc'  => 'Enable, disable and check status of internal modules in the hosting plugin.\n
                           Subcommands: enable, disable, status, list, reset',
        ),
    );
</code>```

Body:
I created a WP website and now locked out with the following error:

Parse error: syntax error, unexpected '.', expecting ')' in [my site]/wp-content/plugins/mojo-marketplace-wp-plugin/inc/cli-init.php on line 25. I have traced this back to my code. Here is what lines 20-35:

protected $commands = array(
    array(
        'cmd'       => 'branding',
        'class'     => 'EIG_WP_CLI_Branding',
        'shortdesc' => 'Control hosting branding and UX.',
        'longdesc'  => 'Control the admin interface, default modules and UX for an Endurance hosting brand.' .
                       PHP_EOL . 'Subcommands: update, remove',
    ),
    array(
        'cmd'       => 'cache',
        'class'     => 'EIG_WP_CLI_Cache',
        'shortdesc' => 'Control all forms of caching.',
        'longdesc'  => 'Control how browser cache, page cache and browser caching are configured.' .
                       PHP_EOL . 'Cache Types: browser, page, object (not functional yet)' .
                       PHP_EOL . 'Subcommands: add, update, status',
    ),

I am not seeing any issues although I am not super familiar with the code. Any thoughts on what can be going on? I am  currently configured to use PHP Edge (7.1) Thanks in advance!

Body:
For some reason, it was not able to parse the string inside the array.

I changed the syntax to remove the concatenation with PHP_EOL and I was able to fix it without changing the PHP version or deleting the plugin:

    /**
     * Main variable containing all WP-CLI commands and callbacks.
     *
     * @var array
     */
    protected $commands = array(
        array(
            'cmd'       => 'branding',
            'class'     => 'EIG_WP_CLI_Branding',
            'shortdesc' => 'Control hosting branding and UX.',
            'longdesc'  => 'Control the admin interface, default modules and UX for an Endurance hosting brand.\n
            Subcommands: update, remove',
        ),
        array(
            'cmd'       => 'cache',
            'class'     => 'EIG_WP_CLI_Cache',
            'shortdesc' => 'Control all forms of caching.',
            'longdesc'  => 'Control how browser cache, page cache and browser caching are configured.\n
            Cache Types: browser, page, object (not functional yet)\n
            Subcommands: add, update, status',
        ),
        array(
            'cmd'       => 'digest',
            'class'     => 'EIG_WP_CLI_Digest',
            'shortdesc' => 'Analyze WordPress for this site.',
            'longdesc'  => 'Analyze WordPress content, configuration and server environment.\n
                           Associative Args: --full --noprompt',
        ),
        array(
            'cmd'       => 'secrets',
            'class'     => 'EIG_WP_CLI_Secrets',
            'shortdesc' => 'Control the WordPress Salts.',
            'longdesc'  => 'Read and update WordPress salts in the wp-config.php file.\n
                           Subcommands: update, age, list',
        ),
        array(
            'cmd'       => 'remove_orphan_post_meta',
            'class'     => 'EIG_WP_CLI_Remove_Orphan_Post_Meta',
            'shortdesc' => 'Legacy cmd for removing orphan meta.',
            'longdesc'  => 'Legacy WP-CLI command used for checking for orphaned postmeta.',
        ),
        array(
            'cmd'       => 'sso',
            'class'     => 'EIG_WP_CLI_SSO',
            'shortdesc' => 'Single sign-on from hosting platform.',
            'longdesc'  => 'Handle single sign-on from Endurance hosting platforms and get magic link.\n
                           Associative Args: --username --role --email --id --min=MINUTES_UNTIL_EXPIRE --url-only',
        ),
        array(
            'cmd'       => 'staging',
            'class'     => 'EIG_WP_CLI_Staging',
            'shortdesc' => 'CRUD operations for EIG staging.',
            'longdesc'  => 'Internal commands to handle staging environment.\n
                                         Subcommands: create, clone, destroy, sso_staging, deploy, deploy_files,
                                         deploy_db, deploy_files_db, save_state, restore_state, sso_production',
        ),
        array(
            'cmd'       => 'module',
            'class'     => 'EIG_WP_CLI_Module',
            'shortdesc' => 'Control hosting plugin modules.',
            'longdesc'  => 'Enable, disable and check status of internal modules in the hosting plugin.\n
                           Subcommands: enable, disable, status, list, reset',
        ),
    );


来源: stackexchange

问:
Is it possible to specify name of .rmd file when knitting/rendering in r-markdown?
After knitting to a word doc, I would like to specify the name of the .rmd file when it is saved. For instance I have set the name of the word doc to include date and time so that each word doc version is saved as a different file:

```<code>'''{r}
 knit: (function(inputFile, encoding) { rmarkdown::render(inputFile, encoding =
 encoding, output_file = paste0(substr(inputFile,1,nchar(inputFile)-4),'_',lubridate::today(),'_',paste0(lubridate::hour(lubridate::now()), lubridate::minute(lubridate::now())),'.docx')) })
'''
</code>```

So in my directory I have the following:

FileName_2019-05-27_1741.docx

FileName.rmd

FileName_2019-05-27_1329.docx

FileName_2019-05-26_1420.docx

I'd like to have the .rmd files automatically saved the same way with date and time in case I want to go back and look at an earlier version of my .rmd file.

答:
The below code worked for me thanks to an earlier tip to copy/rename the file (I was looking for ways to save the file as opposed to copying):

```<code>file.copy(from = "FileName.rmd",
          to = paste0('FileName_',lubridate::today(),'_',paste0(lubridate::hour(lubridate::now()),
          lubridate::minute(lubridate::now())),'.rmd'))
</code>```

I entered this in a new code chunk as I couldn't figure out how to do it within the header (which is where I had the code to name the word file). It does exactly what I need it to do now!

ContentLicense: CC BY-SA 4.0

Body:
After knitting to a word doc, I would like to specify the name of the .rmd file when it is saved. For instance I have set the name of the word doc to include date and time so that each word doc version is saved as a different file:

'''{r}
 knit: (function(inputFile, encoding) { rmarkdown::render(inputFile, encoding =
 encoding, output_file = paste0(substr(inputFile,1,nchar(inputFile)-4),'_',lubridate::today(),'_',paste0(lubridate::hour(lubridate::now()), lubridate::minute(lubridate::now())),'.docx')) })
'''

So in my directory I have the following:

FileName_2019-05-27_1741.docx

FileName.rmd

FileName_2019-05-27_1329.docx

FileName_2019-05-26_1420.docx

I'd like to have the .rmd files automatically saved the same way with date and time in case I want to go back and look at an earlier version of my .rmd file.

Body:
The below code worked for me thanks to an earlier tip to copy/rename the file (I was looking for ways to save the file as opposed to copying):

file.copy(from = "FileName.rmd",
          to = paste0('FileName_',lubridate::today(),'_',paste0(lubridate::hour(lubridate::now()),
          lubridate::minute(lubridate::now())),'.rmd'))

I entered this in a new code chunk as I couldn't figure out how to do it within the header (which is where I had the code to name the word file). It does exactly what I need it to do now!


问:
(Unity) Enabling App Bundle (Google Play) option when building with the BuildPipeline?
Does anyone know how I can enable the App Bundle (Google Play) option when building with the Unity BuildPipeline? Trying to get this to work with our CI server, this is the code currently used to create an APK:

```<code>BuildPlayerOptions prodBuildPlayerOptions = new BuildPlayerOptions();
 prodBuildPlayerOptions.scenes = scenes;
 prodBuildPlayerOptions.locationPathName = $"PSS.Prod.{baseBuildFileName}.apk";
 prodBuildPlayerOptions.target = BuildTarget.Android;
 prodBuildPlayerOptions.options = BuildOptions.None;
 BuildPipeline.BuildPlayer(prodBuildPlayerOptions);
</code>```

Any help would be greatly appreciated!
Cheers, Thomas

答:
I am using this code in old version Unity(2017.4.1f1), and I think you can find AppBundle option in 'EditorUserBuildSetting' like this:</p>

```<code>EditorUserBuildSettings.androidBuildSystem = AndroidBuildSystem.Gradle;
EditorUserBuildSettings.exportAsGoogleAndroidProject = true;
</code>```

Body:
Does anyone know how I can enable the App Bundle (Google Play) option when building with the Unity BuildPipeline? Trying to get this to work with our CI server, this is the code currently used to create an APK:

BuildPlayerOptions prodBuildPlayerOptions = new BuildPlayerOptions();
 prodBuildPlayerOptions.scenes = scenes;
 prodBuildPlayerOptions.locationPathName = $"PSS.Prod.{baseBuildFileName}.apk";
 prodBuildPlayerOptions.target = BuildTarget.Android;
 prodBuildPlayerOptions.options = BuildOptions.None;
 BuildPipeline.BuildPlayer(prodBuildPlayerOptions);

Any help would be greatly appreciated!
Cheers, Thomas

Body:
I am using this code in old version Unity(2017.4.1f1), and I think you can find AppBundle option in 'EditorUserBuildSetting' like this:

EditorUserBuildSettings.androidBuildSystem = AndroidBuildSystem.Gradle;
EditorUserBuildSettings.exportAsGoogleAndroidProject = true;


问:
MKCoordinateRegionMakeWithDistance is unavailable on MonoTouch?
I am trying to convert a Map example from objective-c to MonoTouch but the MKCoordinateRegionMakeWithDistance isn't wrapped in .NET as far as I managed to find.

This issue has been marked as resolved by the MonoTouch team, so where is it? :-)
https://bugzilla.novell.com/show_bug.cgi?id=629743

答:
It's there in MonoTouch 4.

```<code>using MonoTouch.MapKit;
...
var region = MKCoordinateRegion.FromDistance(center, latmeters, lngmeters);
</code>```

Hope this helps.

ContentLicense: CC BY-SA 3.0

Body:
It's there in MonoTouch 4.

using MonoTouch.MapKit;
...
var region = MKCoordinateRegion.FromDistance(center, latmeters, lngmeters);

Hope this helps.


问:
Find the second largest score in a team and return name
Using excel how can I lookup a team in column 1, find the second largest score for that team and return the name from the second column. Without using VBA.

```<code>Teams   Name    Score
team 1  Jill    4.0%
team 1  Bill    68.0%
team 1  Lill    1.0%
team 2  Bob     55.0%
team 2  Dot     71.0%
team 2  Rob     44.0%
team 3  Anna    71.0%
team 3  Elle    74.0%
team 3  Ada     19.0%
</code>```

So for the given table the answers would be

This is my current attempt. Trying to find a match in teams and return that dereferenced result as an array offset to the score column. Where H1 references "team 1".

```<code>{=LARGE(OFFSET(N(IF(1,IF(H1=A1:A9,H1))),,2),2)}
</code>```

答:
with your provided data a solution could look like this ARRAY FORMULA: CTRL + SHIFT + ENTER

```<code>=INDEX($B$2:$B$10,MATCH(LARGE((C2:C10)*(A2:A10=F2),F3),(C2:C10)*(A2:A10=F2),0))
</code>```

Be aware though, that this just finds the first occurance of the ranked score in the chosen team. So if Anna and Ada of team 3 both have the same score just Anna will be shown as result. You could add another column to count number of occurances of this specific score in the team.

```<code>=SUMPRODUCT((A2:A10=F2)*(C2:C10=LARGE((C2:C10)*(A2:A10=F2),F3)))
</code>```

Body:
Using excel how can I lookup a team in column 1, find the second largest score for that team and return the name from the second column. Without using VBA.

Teams   Name    Score
team 1  Jill    4.0%
team 1  Bill    68.0%
team 1  Lill    1.0%
team 2  Bob     55.0%
team 2  Dot     71.0%
team 2  Rob     44.0%
team 3  Anna    71.0%
team 3  Elle    74.0%
team 3  Ada     19.0%

So for the given table the answers would be

This is my current attempt. Trying to find a match in teams and return that dereferenced result as an array offset to the score column. Where H1 references "team 1".

{=LARGE(OFFSET(N(IF(1,IF(H1=A1:A9,H1))),,2),2)}

Body:
with your provided data a solution could look like this ARRAY FORMULA: CTRL + SHIFT + ENTER

=INDEX($B$2:$B$10,MATCH(LARGE((C2:C10)*(A2:A10=F2),F3),(C2:C10)*(A2:A10=F2),0))

Be aware though, that this just finds the first occurance of the ranked score in the chosen team. So if Anna and Ada of team 3 both have the same score just Anna will be shown as result. You could add another column to count number of occurances of this specific score in the team.

=SUMPRODUCT((A2:A10=F2)*(C2:C10=LARGE((C2:C10)*(A2:A10=F2),F3)))


问:
How to set the background color of a search container put into a blue top bar?
I'm setting up a search field on my website's topbar and all my attempts to style it have failed. Topbar and topbar icons background color are blue (#6495ed) as it should be, the icons are white (as it should be), but the search container stays white. How to set it blue?

As the search input and button are placed in a search container (= a div), I have set background:#6495ed of the button and its container. I have modified several times their margin, their padding, but I haven't figured out the proper combination.

I've set a JsFiddle and weird, I can't reproduce the problem within JsFiddle! Why, strange isn't it?
https://jsfiddle.net/r5uqb8v0/1/

So this picture should explain.

https://drive.google.com/file/d/1idQKbtKHaOT-QXByAMw1tXR9l9owMUlc/view?usp=sharing

It's same problem on Chrome and Firefox.

I'm coding on a Windows 10, running MySQL 5.7.22, PHP 7.2.4 and Apache 2.4.33 (WampServer).

This is the search field HTML :

```<code><div class="item3 search-container">
  <form action="/action_page.php">
   <input type="text" placeholder="Search..." name="search">
   <button type="submit"><i class="fa fa-search"></i></button>
  </form>
</div>
</code>```

As for the CSS :

```<code>.topnav .search-container {
  border: none;
  outline: none;
  color: inherit;
  padding: 0;
  float: right;
  background: #6495ed;
  margin: 0;
  text-decoration: none;
  cursor: pointer;
}
.topnav .search-container input {
  padding: 0px;
  margin: 0;
  border: none;
  font-size: 1em;
  display: none;
  width: 100%; /* Full width */
  cursor: pointer;
}
.topnav .search-container button {
  font-size: 1.875em;
  border: none;
  outline: none;
  color: white;
  padding: 6px 10px;
  background: #6495ed;
  margin: 0;
  display: inline;
  cursor: pointer;
  width: 100%; /* Full width */
}
</code>```

Topbar and topbar icons background color are blue (#6495ed) as it should be, the icons are white (as it should be), but the search container stays white (this is the problem).

Any suggestion would be very appreciated! Thank you already for reading!

Best regards

Samuel

答:
You can define your style properties inside the

For example

fa fa -car - is a font awesome icon class i used above.

Just use style properties inside the

Body:
I'm setting up a search field on my website's topbar and all my attempts to style it have failed. Topbar and topbar icons background color are blue (#6495ed) as it should be, the icons are white (as it should be), but the search container stays white. How to set it blue?

As the search input and button are placed in a search container (= a div), I have set background:#6495ed of the button and its container. I have modified several times their margin, their padding, but I haven't figured out the proper combination.

I've set a JsFiddle and weird, I can't reproduce the problem within JsFiddle! Why, strange isn't it?
https://jsfiddle.net/r5uqb8v0/1/

So this picture should explain.

https://drive.google.com/file/d/1idQKbtKHaOT-QXByAMw1tXR9l9owMUlc/view?usp=sharing

It's same problem on Chrome and Firefox.

I'm coding on a Windows 10, running MySQL 5.7.22, PHP 7.2.4 and Apache 2.4.33 (WampServer).

This is the search field HTML :

  <form action="/action_page.php">
   <input type="text" placeholder="Search..." name="search">
   <button type="submit"></button>
  </form>

As for the CSS :

.topnav .search-container {
  border: none;
  outline: none;
  color: inherit;
  padding: 0;
  float: right;
  background: #6495ed;
  margin: 0;
  text-decoration: none;
  cursor: pointer;
}
.topnav .search-container input {
  padding: 0px;
  margin: 0;
  border: none;
  font-size: 1em;
  display: none;
  width: 100%; /* Full width */
  cursor: pointer;
}
.topnav .search-container button {
  font-size: 1.875em;
  border: none;
  outline: none;
  color: white;
  padding: 6px 10px;
  background: #6495ed;
  margin: 0;
  display: inline;
  cursor: pointer;
  width: 100%; /* Full width */
}

Topbar and topbar icons background color are blue (#6495ed) as it should be, the icons are white (as it should be), but the search container stays white (this is the problem).

Any suggestion would be very appreciated! Thank you already for reading!

Best regards

Samuel

Body:
You can define your style properties inside the

For example<i class="fa fa-car" style="font-size:60px;color:red;"></i>

fa fa -car - is a font awesome icon class i used above.

Just use style properties inside the <i>


问:
Problems aligning css into middle
I'm having some issues trying to align the error text center down in the middle of the screen, padding works but both of the
 start to separate in a large gap, I want it to be the same as it is now but in the center of the screen. All the
 that say display: none; are used to hide the mobile navigation bar in desktop mode which works correctly.

.nav2 {
   display: none;
   }

   .nav-header{
   display: none;
   }

   .nav-title{
   display: none;
   }

   .nav-btn{
   display: none;
   }

   .nav-check{
   display: none;
   }

   #nav-check{
   display: none;
   }

   .nav-links{
   display: none;
   }

   .nav-header{
   display: none;
   }

   .nav2 a {
   display: none;
   }

   .nav-header a{
   display: none;
   }

   .nav-title a{
   display: none;
   }

   .nav-btn a {
   display: none;
   }

   .nav-check a{
   display: none;
   }

   #nav-check a{
   display: none;
   }

   .nav-links a{
   display: none;
   }

   .nav-header a{
   display: none;
   }

   body > #header{position:fixed;}
   #header {
       width: 100%;
       position: fixed;
       z-index:9000;
       color: #000000;
       WHITE BG // color/ #8c8c8c;
       font-size: 25px;
       text-align: left;
       font-family: 'Pacifico', cursive;
       left: 15px;
       top: 25px;
       transition: all 0.5s linear;
       transition: height 0.5s ease;
       -webkit-transition: height 0.5s ease;
       -moz-transition: height 0.5s ease;
       -o-transition: height 0.5s ease;
       -ms-transition: height 0.5s ease;
       transition: background-color 0.5s ease;
       -webkit-transition: background-color 0.5s ease;
       -moz-transition: background-color 0.5s ease;
       -o-transition: background-color 0.5s ease;
       -ms-transition: background-color 0.5s ease;
       transition: background-color 0.5s ease;
       -webkit-animation: fadein 2s; /* Safari, Chrome and Opera > 12.1 */
          -moz-animation: fadein 2s; /* Firefox < 16 */
           -ms-animation: fadein 2s; /* Internet Explorer */
            -o-animation: fadein 2s; /* Opera < 12.1 */
               animation: fadein 2s;

   }

   #navigation {
   width: 100%;
       position: fixed;
       z-index: 9000;
       text-decoration: none!important;
       list-style-type: none;
       color: #006CFF;
       font-family: 'Ubuntu', sans-serif;
       font-size: 15px;
       text-align: right;
       margin: 22px -20px;
       -webkit-animation: fadein 2s; /* Safari, Chrome and Opera > 12.1 */
          -moz-animation: fadein 2s; /* Firefox < 16 */
           -ms-animation: fadein 2s; /* Internet Explorer */
            -o-animation: fadein 2s; /* Opera < 12.1 */
               animation: fadein 2s;

   }

   .feedback {
text-align: center;
font-size: 22px;
color: #494949;

}

h1 {
text-align: center;
font-size: 50px;
font-weight: bolder;
color: #494949;

}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><doctype! html>
<html>
<head>
<link href="https://cdn.rawgit.com/michalsnik/aos/2.1.1/dist/aos.css" rel="stylesheet">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Oops.. Dead End</title>
<script src="https://cdn.rawgit.com/michalsnik/aos/2.1.1/dist/aos.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-136743580-1"></script>
<div id="header">adamferreira</div>
<div id="navigation">
    <ul>
         Return Home
    </ul>
    </div>

<div class="headerBackground"></div>
<body>

<div class="container" data-aos="ease-in-out-back" data-aos="zoom out">
<h1>Looks like this page doesn't exist</h1>
<h1 class="feedback">Please double-check you are entering the correct information in your address bar.<br> This page may also have been moved, deleted or a feature may not be available to you.</h1>

</head>

</body>
</html></code>```

答:
I hope you're doing well. Following is the code change that I'd suggest in this case:

```<code><div class="new">
 <h1>Looks like this page doesn't exist</h1>
 <h2 class="feedback">Please double-check you are entering the correct
 information in your address bar.<br> This page may also have been moved,
 deleted or a feature may not be available to you.</h1>
</div>
</code>```

I've created a new div with class name "new" and altered the second tag (changed it to h2) as per standards. And most importantly, added the following in the CSS:

```<code>.new {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}
</code>```

I hope this helps.

Title: Problems aligning css into middle

Body:
I'm having some issues trying to align the error text center down in the middle of the screen, padding works but both of the
 start to separate in a large gap, I want it to be the same as it is now but in the center of the screen. All the
 that say display: none; are used to hide the mobile navigation bar in desktop mode which works correctly.

.nav2 {
   display: none;
   }

   .nav-header{
   display: none;
   }

   .nav-title{
   display: none;
   }

   .nav-btn{
   display: none;
   }

   .nav-check{
   display: none;
   }

   #nav-check{
   display: none;
   }

   .nav-links{
   display: none;
   }

   .nav-header{
   display: none;
   }

   .nav2 a {
   display: none;
   }

   .nav-header a{
   display: none;
   }

   .nav-title a{
   display: none;
   }

   .nav-btn a {
   display: none;
   }

   .nav-check a{
   display: none;
   }

   #nav-check a{
   display: none;
   }

   .nav-links a{
   display: none;
   }

   .nav-header a{
   display: none;
   }

   body > #header{position:fixed;}
   #header {
       width: 100%;
       position: fixed;
       z-index:9000;
       color: #000000;
       WHITE BG // color/ #8c8c8c;
       font-size: 25px;
       text-align: left;
       font-family: 'Pacifico', cursive;
       left: 15px;
       top: 25px;
       transition: all 0.5s linear;
       transition: height 0.5s ease;
       -webkit-transition: height 0.5s ease;
       -moz-transition: height 0.5s ease;
       -o-transition: height 0.5s ease;
       -ms-transition: height 0.5s ease;
       transition: background-color 0.5s ease;
       -webkit-transition: background-color 0.5s ease;
       -moz-transition: background-color 0.5s ease;
       -o-transition: background-color 0.5s ease;
       -ms-transition: background-color 0.5s ease;
       transition: background-color 0.5s ease;
       -webkit-animation: fadein 2s; /* Safari, Chrome and Opera > 12.1 */
          -moz-animation: fadein 2s; /* Firefox < 16 */
           -ms-animation: fadein 2s; /* Internet Explorer */
            -o-animation: fadein 2s; /* Opera < 12.1 */
               animation: fadein 2s;

   }

   #navigation {
   width: 100%;
       position: fixed;
       z-index: 9000;
       text-decoration: none!important;
       list-style-type: none;
       color: #006CFF;
       font-family: 'Ubuntu', sans-serif;
       font-size: 15px;
       text-align: right;
       margin: 22px -20px;
       -webkit-animation: fadein 2s; /* Safari, Chrome and Opera > 12.1 */
          -moz-animation: fadein 2s; /* Firefox < 16 */
           -ms-animation: fadein 2s; /* Internet Explorer */
            -o-animation: fadein 2s; /* Opera < 12.1 */
               animation: fadein 2s;

   }

   .feedback {
text-align: center;
font-size: 22px;
color: #494949;

}

h1 {
text-align: center;
font-size: 50px;
font-weight: bolder;
color: #494949;

}

<doctype! html>

<link href="https://cdn.rawgit.com/michalsnik/aos/2.1.1/dist/aos.css" rel="stylesheet">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Oops.. Dead End</title>

adamferreira

         Return Home

Looks like this page doesn't exist

Please double-check you are entering the correct information in your address bar.
 This page may also have been moved, deleted or a feature may not be available to you.

Body:
I hope you're doing well. Following is the code change that I'd suggest in this case:

<div class="new">
 <h1>Looks like this page doesn't exist</h1>
 <h2 class="feedback">Please double-check you are entering the correct
 information in your address bar.<br> This page may also have been moved,
 deleted or a feature may not be available to you.</h1>
</div>

I've created a new div with class name "new" and altered the second tag (changed it to h2) as per standards. And most importantly, added the following in the CSS:

.new {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

I hope this helps.


问:
azure-devops-node-api - getPersonalAccessTokenHandler(tokenHandler) not working
having node v8.15 and Typescript of 3.4.3. Installed the latest version on azure-devops-node-api . imported the module to ts file .

```<code>let authHandler = azdev.getPersonalAccessTokenHandler(token);
</code>```

giving me error as

```<code>[SPLoaderError.loadComponentError]:
***Failed to load component "50c18491-a471-4da6-8936-11a40cef9265" (HelloWorldWebPart).
Original error: ***Failed to load entry point from component "50c18491-a471-4da6-8936-11a40cef9265" (HelloWorldWebPart).
Original error: Error loading https://component-id.invalid/50c18491-a471-4da6-8936-11a40cef9265_0.0.1
Cannot find module "net"

***INNERERROR:
***Failed to load entry point from component "50c18491-a471-4da6-8936-11a40cef9265" (HelloWorldWebPart).
Original error: Error loading https://component-id.invalid/50c18491-a471-4da6-8936-11a40cef9265_0.0.1
Cannot find module "net"
***CALLSTACK:
Error
at SPLoaderError.SPError [as constructor] (https://localhost:4321/temp/workbench-packages/@microsoft_sp-loader/dist/sp-loader-assembly_default.js:8390:24)
at new SPLoaderError (https://localhost:4321/temp/workbench-packages/@microsoft_sp-loader/dist/sp-loader-assembly_default.js:4036:28)
at Function.ErrorBuilder.buildErrorWithVerboseLog (https://localhost:4321/temp/workbench-packages/@microsoft_sp-loader/dist/sp-loader-assembly_default.js:3789:21)
at Function.ErrorBuilder.buildLoadComponentError (https://localhost:4321/temp/workbench-packages/@microsoft_sp-loader/dist/sp-loader-assembly_default.js:3697:21)
at https://localhost:4321/temp/workbench-packages/@microsoft_sp-loader/dist/sp-loader-assembly_default.js:6275:47
</code>```

答:
The above issue may raise due to the incorrect reference in the code.
Other contributors provided a workaround to resolve this issue.

In his case,he tried to call the webpartcontext code and use the below references in the code.

```<code>1 import IWebPartContext from '@microsoft/sp-webpart-base/lib/core/IWebPartContext';
2 import SPHttpClient from '@microsoft/sp-http/lib/spHttpClient/SPHttpClient';
</code>```

He added the below references by replacing the above code to resolve the issue.

```<code>1 import { IWebPartContext } from '@microsoft/sp-webpart-base';
2 import { SPHttpClient } from '@microsoft/sp-http';
</code>```

You can also try this way to see if it could resolve your issue. For details,please refer to this link.

Hope this helps.

Body:
having node v8.15 and Typescript of 3.4.3. Installed the latest version on azure-devops-node-api . imported the module to ts file .

let authHandler = azdev.getPersonalAccessTokenHandler(token);

giving me error as

[SPLoaderError.loadComponentError]:
***Failed to load component "50c18491-a471-4da6-8936-11a40cef9265" (HelloWorldWebPart).
Original error: ***Failed to load entry point from component "50c18491-a471-4da6-8936-11a40cef9265" (HelloWorldWebPart).
Original error: Error loading https://component-id.invalid/50c18491-a471-4da6-8936-11a40cef9265_0.0.1
Cannot find module "net"

***INNERERROR:
***Failed to load entry point from component "50c18491-a471-4da6-8936-11a40cef9265" (HelloWorldWebPart).
Original error: Error loading https://component-id.invalid/50c18491-a471-4da6-8936-11a40cef9265_0.0.1
Cannot find module "net"
***CALLSTACK:
Error
at SPLoaderError.SPError [as constructor] (https://localhost:4321/temp/workbench-packages/@microsoft_sp-loader/dist/sp-loader-assembly_default.js:8390:24)
at new SPLoaderError (https://localhost:4321/temp/workbench-packages/@microsoft_sp-loader/dist/sp-loader-assembly_default.js:4036:28)
at Function.ErrorBuilder.buildErrorWithVerboseLog (https://localhost:4321/temp/workbench-packages/@microsoft_sp-loader/dist/sp-loader-assembly_default.js:3789:21)
at Function.ErrorBuilder.buildLoadComponentError (https://localhost:4321/temp/workbench-packages/@microsoft_sp-loader/dist/sp-loader-assembly_default.js:3697:21)
at https://localhost:4321/temp/workbench-packages/@microsoft_sp-loader/dist/sp-loader-assembly_default.js:6275:47

Body:
The above issue may raise due to the incorrect reference in the code.
Other contributors provided a workaround to resolve this issue.

In his case,he tried to call the webpartcontext code and use the below references in the code.

1 import IWebPartContext from '@microsoft/sp-webpart-base/lib/core/IWebPartContext';
2 import SPHttpClient from '@microsoft/sp-http/lib/spHttpClient/SPHttpClient';

He added the below references by replacing the above code to resolve the issue.

1 import { IWebPartContext } from '@microsoft/sp-webpart-base';
2 import { SPHttpClient } from '@microsoft/sp-http';

You can also try this way to see if it could resolve your issue. For details,please refer to this link.

Hope this helps.


问:
Why do I not have to define the variable in a for loop using range(), but I do have to in a while loop in Python?
I have the following code using a for loop:

```<code>    total = 0
    for num in range(101):
       total = total + num
       print(total)
</code>```

Now the same result using a while loop:

```<code>    num = 0
    total = 0
    while num <= 99:
         num = num + 1
         total = total + num
         print(total)
</code>```

Why is it that I do not have to define num in the first case, but I do have to define it in the second? Are they both not variables?

答:
In python there is no need, in most cases, to define/declare variables.

The rule is that if you write (assign) a variable then the variable is a local variable of the function; if you only read it instead then it's a global.

Variables assigned at top-level (outside any function) are global... so for example:

```<code>x = 12     # this is an assignment, and because we're outside functions x
           # is deduced to be a global

def foo():
    print(x)     # we only "read" x, thus we're talking of the global

def bar():
    x = 3        # this is an assignment inside a function, so x is local
    print(x)     # will print 3, not touching the global

def baz():
    x += 3       # this will generate an error: we're writing so it's a
                 # local, but no value has been ever assigned to it so it
                 # has "no value" and we cannot "increment" it

def baz2():
    global x     # this is a declaration, even if we write in the code
                 # x refers to the global
    x += 3       # Now fine... will increment the global
</code>```

The for statement is simply a loop that writes to a variable: if no declaration is present then the variable will be assumed to be a local; if there is a global or nonlocal declaration then the variable used will have the corresponding scope (nonlocal is used to write to local variable of the enclosing function from code in a nested function: it's not used very frequently in Python).

Body:
I have the following code using a for loop:

    total = 0
    for num in range(101):
       total = total + num
       print(total)

Now the same result using a while loop:

    num = 0
    total = 0
    while num <= 99:
         num = num + 1
         total = total + num
         print(total)

Why is it that I do not have to define num in the first case, but I do have to define it in the second? Are they both not variables?

Body:
In python there is no need, in most cases, to define/declare variables.

The rule is that if you write (assign) a variable then the variable is a local variable of the function; if you only read it instead then it's a global.

Variables assigned at top-level (outside any function) are global... so for example:

x = 12     # this is an assignment, and because we're outside functions x
           # is deduced to be a global

def foo():
    print(x)     # we only "read" x, thus we're talking of the global

def bar():
    x = 3        # this is an assignment inside a function, so x is local
    print(x)     # will print 3, not touching the global

def baz():
    x += 3       # this will generate an error: we're writing so it's a
                 # local, but no value has been ever assigned to it so it
                 # has "no value" and we cannot "increment" it

def baz2():
    global x     # this is a declaration, even if we write in the code
                 # x refers to the global
    x += 3       # Now fine... will increment the global

The for statement is simply a loop that writes to a variable: if no declaration is present then the variable will be assumed to be a local; if there is a global or nonlocal declaration then the variable used will have the corresponding scope (nonlocal is used to write to local variable of the enclosing function from code in a nested function: it's not used very frequently in Python).


问:
Why does an empty Perl hash have one key?
The standard googleable answer to "How do I find out the size of a hash in Perl?" is "take the size of keys(%hash)":

```<code>my %h = {};
print scalar (keys (%h));
</code>```

This prints '1'. I was expecting zero. On the other hand. Similarly,

```<code>my %h = {};
$h{"a"} = "b";
$h{"x"} = "y";
print scalar keys (%h);
print "\nKey: $_" for (keys %h);
</code>```

Prints:

3

Key: a

Key: x

Key: HASH(0x229e8)

Where has this extra value come from?

答:
{} is a reference to an anonymous hash. So my %h = {} is equivalent to my %h = ({} => undef).

Perl requires hash keys to be strings, so when you use a reference as a key, Perl uses the reference's string representation (HASH(0x229e8)).

Body:
The standard googleable answer to "How do I find out the size of a hash in Perl?" is "take the size of keys(%hash)":

my %h = {};
print scalar (keys (%h));

This prints '1'. I was expecting zero. On the other hand. Similarly,

my %h = {};
$h{"a"} = "b";
$h{"x"} = "y";
print scalar keys (%h);
print "\nKey: $_" for (keys %h);

Prints:

3

Key: a

Key: x

Key: HASH(0x229e8)

Where has this extra value come from?


问:
Overloading a function with void
Trying to overloading a function in C programming language with _Generic. Have found examples:

https://www.quora.com/Does-C-support-function-overloading

How to achieve function overloading in C?

This the example:

```<code>#include <stdio.h>
#include <math.h>

void display_float(float dispid) ;
void display_int(int dispid) ;
void display_void(void) ;

#define display(x) _Generic((x), \
          float: display_float, \
          int: display_int,  \
          default: display_float  \
)(x)

void display_void(void){
    printf("display id: 0\n") ;
}

void display_float(float dispid){
   printf("display id: %f\n", dispid) ;
}

void display_int(int dispid){
    printf("display id: %d\n", dispid) ;
}

void main(void){

    display(5) ;
    display(6.5) ;
}
</code>```

Now I also want to overload the function with display(). Meaning the function would intake a void, call the function display_void(), and display 0. Can't seem to do this. Any help would be appreciated.

EDIT 1:

Also, see the examples here. One of the examples (I think) is passing a pointer to a void. Can this be implemented?

答:
Sure. Overload Macro on Number of Arguments.

```<code>void display_float(float dispid) ;
void display_int(int dispid) ;
void display_void(void) ;

#define _display_1(x) _Generic((x), \
          float: display_float, \
          int: display_int,  \
          default: display_float  \
)(x)
#define _display_0()  display_void()
#define _display_N(_0,_1,N,...)  _display_ ## N
#define display(...) _display_N(_0,##__VA_ARGS__,1,0)(__VA_ARGS__)

int main() {
    display();
    display(1);
    display(1.1);
}
</code>```

Tested on godbolt.

Note that , ##__VA_ARGS__ is a gcc extension not described in the C standard.

Title: Overloading a function with void

Body:
Trying to overloading a function in C programming language with _Generic. Have found examples:

https://www.quora.com/Does-C-support-function-overloading

How to achieve function overloading in C?

This the example:

#include <stdio.h>
#include <math.h>

void display_float(float dispid) ;
void display_int(int dispid) ;
void display_void(void) ;

#define display(x) _Generic((x), \
          float: display_float, \
          int: display_int,  \
          default: display_float  \
)(x)

void display_void(void){
    printf("display id: 0\n") ;
}

void display_float(float dispid){
   printf("display id: %f\n", dispid) ;
}

void display_int(int dispid){
    printf("display id: %d\n", dispid) ;
}

void main(void){

    display(5) ;
    display(6.5) ;
}

Now I also want to overload the function with display(). Meaning the function would intake a void, call the function display_void(), and display 0. Can't seem to do this. Any help would be appreciated.

EDIT 1:

Also, see the examples here. One of the examples (I think) is passing a pointer to a void. Can this be implemented?

Body:
Sure. Overload Macro on Number of Arguments.

void display_float(float dispid) ;
void display_int(int dispid) ;
void display_void(void) ;

#define _display_1(x) _Generic((x), \
          float: display_float, \
          int: display_int,  \
          default: display_float  \
)(x)
#define _display_0()  display_void()
#define _display_N(_0,_1,N,...)  _display_ ## N
#define display(...) _display_N(_0,##__VA_ARGS__,1,0)(__VA_ARGS__)

int main() {
    display();
    display(1);
    display(1.1);
}

Tested on godbolt.

Note that , ##__VA_ARGS__ is a gcc extension not described in the C standard.


问:
Robolectric fails on command line but succeeds in Android Studio
I have a test where I use Robolectric which succeeds in Android Studio, but does not on the command line.

I use Robolectric 4.2 and the test involves a cipher which I partially mock for this test.

```<code>//How the cipher is created
val mockCipher = object : Cipher(MockCipherSpi(), null, null) {}
</code>```

The MockCipher basically just returns the unencrypted input:

```<code>class MockCipherSpi : CipherSpi() {
...
    private val algorithmParametersSpi: AlgorithmParametersSpi? = object : AlgorithmParametersSpi() {
        ...
        override fun <T : AlgorithmParameterSpec?> engineGetParameterSpec(paramSpec: Class<T>?): T {
            return IvParameterSpec(byteArrayOf()) as T
        }
    }
    ...
    override fun engineGetParameters(): AlgorithmParameters {
        return object : AlgorithmParameters(algorithmParametersSpi, null, null) {
            init {
                init(byteArrayOf())
            }
        }
    }
}
</code>```

The reason my test fails is that I get a null pointer exception when I try to get the IV from the cipher:

```<code>cipher.parameters.getParameterSpec(IvParameterSpec::class.java).iv
</code>```

This works perfectly fine for Android Studio and I can even debug it, but running it from the command line with ./gradlew test this fails.

```<code>java.lang.NullPointerException
at javax.crypto.Cipher.<init>(Cipher.java:268)
at the place where I try to access the iv
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.robolectric.RobolectricTestRunner$HelperTestRunner$1.evaluate(RobolectricTestRunner.java:601)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.robolectric.internal.SandboxTestRunner$2.evaluate(SandboxTestRunner.java:260)
at org.robolectric.internal.SandboxTestRunner.runChild(SandboxTestRunner.java:130)
at org.robolectric.internal.SandboxTestRunner.runChild(SandboxTestRunner.java:42)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.robolectric.internal.SandboxTestRunner$1.evaluate(SandboxTestRunner.java:84)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:116)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:59)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:39)
at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:66)
at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32)
at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
at com.sun.proxy.$Proxy1.processTestClass(Unknown Source)
at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:109)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:146)
at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:128)
at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:404)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
at java.lang.Thread.run(Thread.java:748)
</code>```

It seems there are two javax.crypto.Cipher one from the in the android.jar and one in the jce.jar I assume that AS is using one and the gradle command the other.

Do I have to tell gradle to use an other jar or can I solve this problem otherwise?

答: You are trying to use a class from the android SDK in a desktop test. That's always going to fail. The Android SDK has classes that simply aren't available in the Java Development Kit. The Android jar provides just an empty API for development purposes, but to run the programs, you need to execute them into an android device. In this case, you would need to either mock the entire call, or locate an equivalent desktop implementation and replace the android calls with the desktop ones during the test (maybe by splitting your class in two, logic and API access for example). Given that the methods you are running are exposing a native (C level) api, mocking the entire API call looks like the fastest way to solve this into the test.</p>

Body:
I have a test where I use Robolectric which succeeds in Android Studio, but does not on the command line.

I use Robolectric 4.2 and the test involves a cipher which I partially mock for this test.

//How the cipher is created
val mockCipher = object : Cipher(MockCipherSpi(), null, null) {}

The MockCipher basically just returns the unencrypted input:

class MockCipherSpi : CipherSpi() {
...
    private val algorithmParametersSpi: AlgorithmParametersSpi? = object : AlgorithmParametersSpi() {
        ...
        override fun <T : AlgorithmParameterSpec?> engineGetParameterSpec(paramSpec: Class<T>?): T {
            return IvParameterSpec(byteArrayOf()) as T
        }
    }
    ...
    override fun engineGetParameters(): AlgorithmParameters {
        return object : AlgorithmParameters(algorithmParametersSpi, null, null) {
            init {
                init(byteArrayOf())
            }
        }
    }
}

The reason my test fails is that I get a null pointer exception when I try to get the IV from the cipher:

cipher.parameters.getParameterSpec(IvParameterSpec::class.java).iv

This works perfectly fine for Android Studio and I can even debug it, but running it from the command line with ./gradlew test this fails.

java.lang.NullPointerException
at javax.crypto.Cipher.<init>(Cipher.java:268)
at the place where I try to access the iv
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.robolectric.RobolectricTestRunner$HelperTestRunner$1.evaluate(RobolectricTestRunner.java:601)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.robolectric.internal.SandboxTestRunner$2.evaluate(SandboxTestRunner.java:260)
at org.robolectric.internal.SandboxTestRunner.runChild(SandboxTestRunner.java:130)
at org.robolectric.internal.SandboxTestRunner.runChild(SandboxTestRunner.java:42)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.robolectric.internal.SandboxTestRunner$1.evaluate(SandboxTestRunner.java:84)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:116)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:59)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:39)
at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:66)
at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32)
at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
at com.sun.proxy.$Proxy1.processTestClass(Unknown Source)
at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:109)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:146)
at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:128)
at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:404)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
at java.lang.Thread.run(Thread.java:748)

It seems there are two javax.crypto.Cipher one from the in the android.jar and one in the jce.jar I assume that AS is using one and the gradle command the other.

Do I have to tell gradle to use an other jar or can I solve this problem otherwise?


问:
How much can I rely on the inspectdb command of django for using a large legacy MySQL database?
I need to make a website portal for generating reports based on the activities in the library of my college. For that, I have been given a large database with more than 200 tables.

Since I have done website development on django, I was hoping to use that. Now, since I already have a legacy database, I thought of using inspectdb command of django to automatically generate the models according to the database.

```<code>python manage.py inspectdb > portal/models.py
</code>```

This generated the models for me. I wish to know, how much can I rely on these models. There are multiple OneToOne relations in my database, but django simply made them as ForeignKeys. Could there be more such errors in the models generated? Since the number of tables are large, it's difficult for me to go through every table and check the corresponding models.

If the models so generated can't be trusted, I was hoping to make a website using simple python and connection string for connecting MySQL to python. That allows me to access the database, though I'm not sure how to create a website without using a framework and how to integrate front pages to the website.

答:
It is best to check the bug tracker for all known bugs.

The issue you mentioned has already been (recently) fixed in an upcoming release: https://code.djangoproject.com/ticket/30388

Made inspectdb generate OneToOneFields rather than ForeignKey(unique/primary_key=True).

Body:
I need to make a website portal for generating reports based on the activities in the library of my college. For that, I have been given a large database with more than 200 tables.

Since I have done website development on django, I was hoping to use that. Now, since I already have a legacy database, I thought of using inspectdb command of django to automatically generate the models according to the database.

python manage.py inspectdb > portal/models.py

This generated the models for me. I wish to know, how much can I rely on these models. There are multiple OneToOne relations in my database, but django simply made them as ForeignKeys. Could there be more such errors in the models generated? Since the number of tables are large, it's difficult for me to go through every table and check the corresponding models.

If the models so generated can't be trusted, I was hoping to make a website using simple python and connection string for connecting MySQL to python. That allows me to access the database, though I'm not sure how to create a website without using a framework and how to integrate front pages to the website.


问:
EditText with bottom border only
I am trying to make a custom edit text that has only a bottom border. I have tried this code and set it as background:

```<code><item android:gravity="bottom">
        <shape android:shape="line">
            <stroke android:width="1dp" android:color="@color/lightGray"/>
            <padding android:left="12dp" android:right="12dp" android:top="12dp" android:bottom="12dp" />
        </shape>
    </item>
</code>```

and the border is exactly how I want it but it is placed in the middle of the edit text and not at the bottom. How can I solve this?

答:
You can create a bottom bordered edittext by using  ;
the below xml

```<code><?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >

    <item android:bottom="1dp"
        android:left="-2dp"
        android:right="-2dp"
        android:top="-2dp">
        <shape android:shape="rectangle" >
            <stroke
                android:width="0.5dp"
                android:color="@android:color/black" />
        </shape>
    </item>

</layer-list>
</code>```

Title: EditText with bottom border only

Body:
I am trying to make a custom edit text that has only a bottom border. I have tried this code and set it as background:

<item android:gravity="bottom">
        <shape android:shape="line">
            <stroke android:width="1dp" android:color="@color/lightGray"/>
            <padding android:left="12dp" android:right="12dp" android:top="12dp" android:bottom="12dp" />
        </shape>
    </item>

and the border is exactly how I want it but it is placed in the middle of the edit text and not at the bottom. How can I solve this?

Body:
You can create a bottom bordered edittext by using  ;
the below xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >

    <item android:bottom="1dp"
        android:left="-2dp"
        android:right="-2dp"
        android:top="-2dp">
        <shape android:shape="rectangle" >
            <stroke
                android:width="0.5dp"
                android:color="@android:color/black" />
        </shape>
    </item>

</layer-list>


问:
What is the interface type format in the angular cli?
I was looking at the docs and became lost.

ng generate interface <name> <type>

However it doesn't tell what to put in for type. Like is it just a string, object, array, etc or can I specify properties like email:String username:String age:Number?

答:
Using Angular CLI,

```<code>ng g i filename
</code>```

will create a file by the name filename.ts and
will have export interface filename {} in it

Body:
Using Angular CLI,

ng g i filename

will create a file by the name filename.ts and
will have export interface filename {} in it


问:
Mongodb: too many users are authenticated
I try to authorize on my db and get some records, but i get this strange error:

How can I fix it?

答:
Not sure if this ticket is related, because I still see this issue with MongoDB 4.0.9, but the way I fixed it was to not use db.auth() but exit the shell, then log in again:

```<code>mongo --ssl mongodb://myhost.io --authenticationDatabase admin -u adminUser -p
</code>```

Body:
Not sure if this ticket is related, because I still see this issue with MongoDB 4.0.9, but the way I fixed it was to not use db.auth() but exit the shell, then log in again:

mongo --ssl mongodb://myhost.io --authenticationDatabase admin -u adminUser -p


问:
WiX Bundle gets "Failed to verify hash of payload" when trying to install .net core hosting bundle from web
I have a burn/bootstrapper WiX bundle with:

        <?define DotNetVersion = "2.1.11"?>

        <Variable Name='MinDotNetVersion' Type='string' Value='2.1.0' bal:Overridable='no'/>
        <Variable Name='NextDotNetVersion' Type='string' Value='2.2.0' bal:Overridable='no'/>

        <?define HostingBundleUrl = "https://www.microsoft.com/net/download/thank-you/dotnet-runtime-$(var.DotNetVersion)-windows-hosting-bundle-installer" ?>
        <util:RegistrySearch Id="DotNetHostingBundle86"
                             Root="HKLM"
                             Key="SOFTWARE\dotnet\Setup\InstalledVersions\$(var.Platform)\sharedhost"
                             Value="Version"
                             Variable="DotNetHostingBundleVersion" />

        <util:RegistrySearch Id="DotNetHostingBundle64"
                             After="DotNetHostingBundle86"
                             Condition="NOT DotNetHostingBundleVersion AND VersionNT64"
                             Root="HKLM"
                             Key="SOFTWARE\dotnet\Setup\InstalledVersions\$(var.Platform)\sharedhost"
                             Value="Version"
                             Variable="DotNetHostingBundleVersion"
                             Win64="yes"/>

        <Chain>
            <ExePackage Id="DotNetCoreHostingBundle"
                        Vital="yes"
                        Name=".Net Hosting Bundle Setup"
                        DownloadUrl="$(var.HostingBundleUrl)"
                        Compressed="no"
                        SourceFile=".\ExtResourcesCopy\dotnet-hosting-$(var.DotNetVersion)-win.exe"
                        InstallCondition="NOT DotNetHostingBundleVersion OR (DotNetHostingBundleVersion < MinDotNetVersion OR DotNetHostingBundleVersion >= NextDotNetVersion)"
                        Description="Installing .Net Hosting Bundle $(var.DotNetVersion). This includes the 32 bit and 64 bit runtimes, the Asp.net runtime packages (Microsoft.AspNetCore.App and .All), and the IIS Hosting Components."
                         />
            ...
```

<p>I've downloaded the dotnet-hosting-2.1.11-win.exe file into the ExtResourcesCopy folder, and since I set the SourceFile to this it gets its own Payload data. </p>

<p>I then build my .exe and run it on another computer and get the following error:</p>

```Acquiring package: DotNetCoreHostingBundle, payload: DotNetCoreHostingBundle, download from: https://www.microsoft.com/net/download/thank-you/dotnet-runtime-2.1.11-windows-hosting-bundle-installer
Error 0x80091007: Hash mismatch for path: C:\ProgramData\Package Cache\.unverified\DotNetCoreHostingBundle, expected: 1ED626AD403D6E5D99AB69DB7C281FB8E8A8D0A2, actual: F21BF2F13F89D1C9DFD2844D57728102D5714EAA
Error 0x80091007: Failed to verify hash of payload: DotNetCoreHostingBundle
Failed to verify payload: DotNetCoreHostingBundle at path: C:\ProgramData\Package Cache\.unverified\DotNetCoreHostingBundle, error: 0x80091007. Deleting file.
```

<p>I then checked the SHA1 hash on the target computer by downloading the dotnet-hosting-2.1.11-win.exe file manually from Microsoft, using the exact url from the log file, and running:</p>

```certutil -hashfile dotnet-hosting-2.1.11-win.exe
```

This gave me the expected hash of: 1ed626ad403d6e5d99ab69db7c281fb8e8a8d0a2

So where is this "actual" hash of F21BF2F13F89D1C9DFD2844D57728102D5714EAA coming from? Is there a way of pausing the installer so I can inspect the file in the .unverified folder? And/or what can I do about this?

答:
You should be able to use dark.exe to decompile your bundle executable and see the hashes for all of the payloads.

Note: Those hashes are present for security purposes. They prevent bad actors from tampering with the install content.

Body:
I have a burn/bootstrapper WiX bundle with:

        <?define DotNetVersion = "2.1.11"?>

        <Variable Name='MinDotNetVersion' Type='string' Value='2.1.0' bal:Overridable='no'/>
        <Variable Name='NextDotNetVersion' Type='string' Value='2.2.0' bal:Overridable='no'/>

        <?define HostingBundleUrl = "https://www.microsoft.com/net/download/thank-you/dotnet-runtime-$(var.DotNetVersion)-windows-hosting-bundle-installer" ?>
        <util:RegistrySearch Id="DotNetHostingBundle86"
                             Root="HKLM"
                             Key="SOFTWARE\dotnet\Setup\InstalledVersions\$(var.Platform)\sharedhost"
                             Value="Version"
                             Variable="DotNetHostingBundleVersion" />

        <util:RegistrySearch Id="DotNetHostingBundle64"
                             After="DotNetHostingBundle86"
                             Condition="NOT DotNetHostingBundleVersion AND VersionNT64"
                             Root="HKLM"
                             Key="SOFTWARE\dotnet\Setup\InstalledVersions\$(var.Platform)\sharedhost"
                             Value="Version"
                             Variable="DotNetHostingBundleVersion"
                             Win64="yes"/>

        <Chain>
            <ExePackage Id="DotNetCoreHostingBundle"
                        Vital="yes"
                        Name=".Net Hosting Bundle Setup"
                        DownloadUrl="$(var.HostingBundleUrl)"
                        Compressed="no"
                        SourceFile=".\ExtResourcesCopy\dotnet-hosting-$(var.DotNetVersion)-win.exe"
                        InstallCondition="NOT DotNetHostingBundleVersion OR (DotNetHostingBundleVersion < MinDotNetVersion OR DotNetHostingBundleVersion >= NextDotNetVersion)"
                        Description="Installing .Net Hosting Bundle $(var.DotNetVersion). This includes the 32 bit and 64 bit runtimes, the Asp.net runtime packages (Microsoft.AspNetCore.App and .All), and the IIS Hosting Components."
                         />
            ...

I've downloaded the dotnet-hosting-2.1.11-win.exe file into the ExtResourcesCopy folder, and since I set the SourceFile to this it gets its own Payload data.

I then build my .exe and run it on another computer and get the following error:

Acquiring package: DotNetCoreHostingBundle, payload: DotNetCoreHostingBundle, download from: https://www.microsoft.com/net/download/thank-you/dotnet-runtime-2.1.11-windows-hosting-bundle-installer
Error 0x80091007: Hash mismatch for path: C:\ProgramData\Package Cache\.unverified\DotNetCoreHostingBundle, expected: 1ED626AD403D6E5D99AB69DB7C281FB8E8A8D0A2, actual: F21BF2F13F89D1C9DFD2844D57728102D5714EAA
Error 0x80091007: Failed to verify hash of payload: DotNetCoreHostingBundle
Failed to verify payload: DotNetCoreHostingBundle at path: C:\ProgramData\Package Cache\.unverified\DotNetCoreHostingBundle, error: 0x80091007. Deleting file.

I then checked the SHA1 hash on the target computer by downloading the dotnet-hosting-2.1.11-win.exe file manually from Microsoft, using the exact url from the log file, and running:

certutil -hashfile dotnet-hosting-2.1.11-win.exe

This gave me the expected hash of: 1ed626ad403d6e5d99ab69db7c281fb8e8a8d0a2

So where is this "actual" hash of F21BF2F13F89D1C9DFD2844D57728102D5714EAA coming from? Is there a way of pausing the installer so I can inspect the file in the .unverified folder? And/or what can I do about this?


问:
How tunelength parameter works in caret
I'm using following code to implement elastic net using R

```<code>model <- train(
Sales ~., data = train_data, method = "glmnet",
trControl = trainControl("cv", number = 10),
tuneLength = 10
)
</code>```

I'm confused about tunelength paramater. In Cran I'm seeing that

To change the candidate values of the tuning parameter, either of the
  tuneLength or tuneGrid arguments can be used. The train function can
  generate a candidate set of parameter values and the tuneLength
  argument  controls how many are evaluated. In the case of PLS, the
  function uses a  sequence of integers from 1 to tuneLength. If we want
  to evaluate all  integers between 1 and 15, setting tuneLength = 15
  would achieve this

But train function is taking dependent & independent variable from my data then how it's using tuneLength parameter? Can you please help me understand?

答:
In caret the train() function has a number of arguments to help select the "optimal" tuning parameters for your chosen model.

Model tuning is explained in detail in package documentation here.

Users can customize the tuning process by specifying a grid of possible parameter values that the model will use when training the model.

For some models, the use of tuneLength is an alternative to specifying a tuneGird.

For example, one method of searching for the 'optimal' model parameters is using random selection. In this case the tuneLength argument is used to control the number of combinations generated by this random tuning parameter search.

To use random search, another option is available in trainControl called search. Possible values of this argument are "grid" and "random". The built-in models contained in caret contain code to generate random tuning parameter combinations. The total number of unique combinations is specified by the tuneLength option to train.

It is covered in more detail here:
http://topepo.github.io/caret/random-hyperparameter-search.html

It is important to check the model you are using in the train function and look at which tuning parameters are used for that model. It will then be easier to understand how to correctly customize the model fitting process.

For your example of using method = 'glmnet' here is a comparison using tuneGrid and tuneLength (taken from package tests):

```<code>cctrl1 <- trainControl(method = "cv", number = 3, returnResamp = "all",
                       classProbs = TRUE, summaryFunction = twoClassSummary)

test_class_cv_model <- train(trainX, trainY,
                             method = "glmnet",
                             trControl = cctrl1,
                             metric = "ROC",
                             preProc = c("center", "scale"),
                             tuneGrid = expand.grid(.alpha = seq(.05, 1, length = 15),
                                                    .lambda = c((1:5)/10)))

</code>```

```<code>cctrlR <- trainControl(method = "cv", number = 3, returnResamp = "all", search = "random")

test_class_rand <- train(trainX, trainY,
                         method = "glmnet",
                         trControl = cctrlR,
                         tuneLength = 4)

</code>```

Title: How tunelength parameter works in caret

Body:
I'm using following code to implement elastic net using R

model <- train(
Sales ~., data = train_data, method = "glmnet",
trControl = trainControl("cv", number = 10),
tuneLength = 10
)

I'm confused about tunelength paramater. In Cran I'm seeing that

To change the candidate values of the tuning parameter, either of the
  tuneLength or tuneGrid arguments can be used. The train function can
  generate a candidate set of parameter values and the tuneLength
  argument  controls how many are evaluated. In the case of PLS, the
  function uses a  sequence of integers from 1 to tuneLength. If we want
  to evaluate all  integers between 1 and 15, setting tuneLength = 15
  would achieve this

But train function is taking dependent & independent variable from my data then how it's using tuneLength parameter? Can you please help me understand?

Body:
In caret the train() function has a number of arguments to help select the "optimal" tuning parameters for your chosen model.

Model tuning is explained in detail in package documentation here.

Users can customize the tuning process by specifying a grid of possible parameter values that the model will use when training the model.

For some models, the use of tuneLength is an alternative to specifying a tuneGird.

For example, one method of searching for the 'optimal' model parameters is using random selection. In this case the tuneLength argument is used to control the number of combinations generated by this random tuning parameter search.

To use random search, another option is available in trainControl called search. Possible values of this argument are "grid" and "random". The built-in models contained in caret contain code to generate random tuning parameter combinations. The total number of unique combinations is specified by the tuneLength option to train.

It is covered in more detail here:
http://topepo.github.io/caret/random-hyperparameter-search.html

It is important to check the model you are using in the train function and look at which tuning parameters are used for that model. It will then be easier to understand how to correctly customize the model fitting process.

For your example of using method = 'glmnet' here is a comparison using tuneGrid and tuneLength (taken from package tests):

cctrl1 <- trainControl(method = "cv", number = 3, returnResamp = "all",
                       classProbs = TRUE, summaryFunction = twoClassSummary)

test_class_cv_model <- train(trainX, trainY,
                             method = "glmnet",
                             trControl = cctrl1,
                             metric = "ROC",
                             preProc = c("center", "scale"),
                             tuneGrid = expand.grid(.alpha = seq(.05, 1, length = 15),
                                                    .lambda = c((1:5)/10)))

cctrlR <- trainControl(method = "cv", number = 3, returnResamp = "all", search = "random")

test_class_rand <- train(trainX, trainY,
                         method = "glmnet",
                         trControl = cctrlR,
                         tuneLength = 4)


问:
Pass DialogFlow session ID as a url parameter on a button
I am trying to implement a facebook webview with Dialogflow chatbot

I can't find a way to pass back data from web view to the conversation.

What I am now exploring is if it's possible to pass the session ID of the conversation thread from where the button was clicked as a query parameter on the button url.

This way, I can use detect-intent to do something with the data and post a response back to the thread

答:
`            MessengerExtensions.getSupportedFeatures(function success(result) {
                let features = result.supported_features;
                console.log(features);

```<code>            if (features.includes("context")) {
                MessengerExtensions.getContext('APPID',
                    function success(thread_context) {
                        console.log(thread_context.psid);
                        // success
                        document.getElementById("psid").value = thread_context.psid;
                    },
                    function error(err) {
                        // error
                        console.log(err);
                    }
                );
            }
        }, function error(err) {
            // error retrieving supported features
            console.log(err);
        });`
</code>```

<input type="hidden" name="psid" id="psid">

You will get sender ID and based on that you can find session ID if you are Mapping the sender with session ID.

Body:
`            MessengerExtensions.getSupportedFeatures(function success(result) {
                let features = result.supported_features;
                console.log(features);

            if (features.includes("context")) {
                MessengerExtensions.getContext('APPID',
                    function success(thread_context) {
                        console.log(thread_context.psid);
                        // success
                        document.getElementById("psid").value = thread_context.psid;
                    },
                    function error(err) {
                        // error
                        console.log(err);
                    }
                );
            }
        }, function error(err) {
            // error retrieving supported features
            console.log(err);
        });`

<input type="hidden" name="psid" id="psid">

You will get sender ID and based on that you can find session ID if you are Mapping the sender with session ID.


问:
How to Encrypt or Decrypt a File in Java?
I want to encrypt and decrypt a file in java, i had read this url http://www-users.york.ac.uk/~mal503/lore/pkencryption.htm and i got two files namely public Security certificate and private security certificate file and private.pem file, i copied these files and pasted in the current directory and worte java code as follows, when i run this no encryption or decryption is performed, pls see this and tell me where i went wrong

Encrypt Code

```<code>File ecryptfile=new File("encrypt data");
                File publickeydata=new File("/publickey");
                File encryptmyfile=new File("/sys_data.db");
                File copycontent =new File("Copy Data");
                secure.makeKey();
                secure.saveKey(ecryptfile, publickeydata);
                secure.encrypt(encryptmyfile, copycontent);
</code>```

Decrypt code

```<code>File ecryptfile=new File("encrypt data");
                File privateKeyFile=new File("/privatekey");
                File encryptmyfile=new File("/sys_data.db");
                File unencryptedFile =new File("unencryptedFile");
                try {
                                secure.loadKey(encryptmyfile, privateKeyFile);
                                secure.decrypt(encryptmyfile, unencryptedFile);
                        } catch (GeneralSecurityException e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
                        } catch (IOException e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
                        }
</code>```

答:
You simply have muddled your files. This code works using the DER files generated from openssl as described in the article you linked:</p>

```<code>    FileEncryption secure = new FileEncryption();

    // Encrypt code
    {
        File encryptFile = new File("encrypt.data");
        File publicKeyData = new File("public.der");
        File originalFile = new File("sys_data.db");
        File secureFile = new File("secure.data");

        // create AES key
        secure.makeKey();

        // save AES key using public key
        secure.saveKey(encryptFile, publicKeyData);

        // save original file securely
        secure.encrypt(originalFile, secureFile);
    }

    // Decrypt code
    {
        File encryptFile = new File("encrypt.data");
        File privateKeyFile = new File("private.der");
        File secureFile = new File("secure.data");
        File unencryptedFile = new File("unencryptedFile");

        // load AES key
        secure.loadKey(encryptFile, privateKeyFile);

        // decrypt file
        secure.decrypt(secureFile, unencryptedFile);
    }
</code>```

Body:
I want to encrypt and decrypt a file in java, i had read this url http://www-users.york.ac.uk/~mal503/lore/pkencryption.htm and i got two files namely public Security certificate and private security certificate file and private.pem file, i copied these files and pasted in the current directory and worte java code as follows, when i run this no encryption or decryption is performed, pls see this and tell me where i went wrong

Encrypt Code

File ecryptfile=new File("encrypt data");
                File publickeydata=new File("/publickey");
                File encryptmyfile=new File("/sys_data.db");
                File copycontent =new File("Copy Data");
                secure.makeKey();
                secure.saveKey(ecryptfile, publickeydata);
                secure.encrypt(encryptmyfile, copycontent);

Decrypt code

File ecryptfile=new File("encrypt data");
                File privateKeyFile=new File("/privatekey");
                File encryptmyfile=new File("/sys_data.db");
                File unencryptedFile =new File("unencryptedFile");
                try {
                                secure.loadKey(encryptmyfile, privateKeyFile);
                                secure.decrypt(encryptmyfile, unencryptedFile);
                        } catch (GeneralSecurityException e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
                        } catch (IOException e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
                        }

Body:
You simply have muddled your files. This code works using the DER files generated from openssl as described in the article you linked:

    FileEncryption secure = new FileEncryption();

    // Encrypt code
    {
        File encryptFile = new File("encrypt.data");
        File publicKeyData = new File("public.der");
        File originalFile = new File("sys_data.db");
        File secureFile = new File("secure.data");

        // create AES key
        secure.makeKey();

        // save AES key using public key
        secure.saveKey(encryptFile, publicKeyData);

        // save original file securely
        secure.encrypt(originalFile, secureFile);
    }

    // Decrypt code
    {
        File encryptFile = new File("encrypt.data");
        File privateKeyFile = new File("private.der");
        File secureFile = new File("secure.data");
        File unencryptedFile = new File("unencryptedFile");

        // load AES key
        secure.loadKey(encryptFile, privateKeyFile);

        // decrypt file
        secure.decrypt(secureFile, unencryptedFile);
    }


答:
Well, for is a special statement that automatically defines the variable for you. It would be redundant to require you to declare the variable in advance.

while is a general purpose loop construct. The condition for a while statement doesn't even have to include a variable; for example

```<code>while True:
</code>```

or

```<code>while my_function() > 0:
</code>```

Title: Why do I not have to define the variable in a for loop using range(), but I do have to in a while loop in Python?

Body:
I have the following code using a for loop:

    total = 0
    for num in range(101):
       total = total + num
       print(total)

Now the same result using a while loop:

    num = 0
    total = 0
    while num <= 99:
         num = num + 1
         total = total + num
         print(total)

Why is it that I do not have to define num in the first case, but I do have to define it in the second? Are they both not variables?

Body:
Well, for is a special statement that automatically defines the variable for you. It would be redundant to require you to declare the variable in advance.

while is a general purpose loop construct. The condition for a while statement doesn't even have to include a variable; for example

while True:

or

while my_function() > 0:


问:
How to use Multiprocessing in Pandas?
when i use multiprocessing in normal program its working fine in pandas,but when i use this multiprocessing time is not reducing.

i tried with normal code using multiprocessing

```<code>import multiprocessing
import time
import pandas as pd
start=time.time()

def square(df1):
    df1['M_threading'] = df1['M_Invoice_type']
def multiply(df4):
    df4['M_threading'] = df4['M_Invoice_type']

if __name__ == '__main__':
    df = pd.read_excel("filename.xlsx")
    df1 = df.loc[df['M_Invoice_type'] == 'B2B']
    df4 = df.loc[df['M_Invoice_type'] == 'B2BUR']
    p=multiprocessing.Process(target=square,args=(df1,))
    p1 = multiprocessing.Process(target=multiply, args=(df4,))
    p.start()
    p1.start()
    p.join()
    p1.join()
    print("Done")
    end=time.time()
    print(end-start)
</code>```

I expect the output time of  code 25sec, but the actual output is 51sec.

答:
Try calling multiprocessing.Process with the two new dataframes created.

```<code>p = multiprocessing.Process(target=square,args=(df1,))
p1 = multiprocessing.Process(target=multiply, args=(df4,))
</code>```

Title: How to use Multiprocessing in Pandas?

Body:
when i use multiprocessing in normal program its working fine in pandas,but when i use this multiprocessing time is not reducing.

i tried with normal code using multiprocessing

import multiprocessing
import time
import pandas as pd
start=time.time()

def square(df1):
    df1['M_threading'] = df1['M_Invoice_type']
def multiply(df4):
    df4['M_threading'] = df4['M_Invoice_type']

if __name__ == '__main__':
    df = pd.read_excel("filename.xlsx")
    df1 = df.loc[df['M_Invoice_type'] == 'B2B']
    df4 = df.loc[df['M_Invoice_type'] == 'B2BUR']
    p=multiprocessing.Process(target=square,args=(df1,))
    p1 = multiprocessing.Process(target=multiply, args=(df4,))
    p.start()
    p1.start()
    p.join()
    p1.join()
    print("Done")
    end=time.time()
    print(end-start)

I expect the output time of  code 25sec, but the actual output is 51sec.

Body:
Try calling multiprocessing.Process with the two new dataframes created.

p = multiprocessing.Process(target=square,args=(df1,))
p1 = multiprocessing.Process(target=multiply, args=(df4,))


问:
Xamarin App Exception: "Objective-C exception thrown. Name: NSInvalidArgumentException"
I tried building a simple Xamarin Forms application that groups a list of contacts. in this case I only had two contacts to keep it easy. When launching the app on the iOS-Simulator or on my iPhone 6s (iOS 12) an error appears that says:

"{Foundation.MonoTouchException: Objective-C exception thrown.  Name:
  NSInvalidArgumentException Reason: *** -[NSPlaceholderString
  initWithUTF8String:]: NULL cString Native stack trace:    0

  CoreFoundation  0x00000001068e56fb __exceptionPrepr…}"

c#

```<code>namespace Lists{
    public partial class MainPage : ContentPage
    {
        public MainPage()
        {
            InitializeComponent();

            listView.ItemsSource = new List<ContactGroup> {
                new ContactGroup("P", "P")
                {
                    new Contact { Name = "Peter Parker", Status = "Nice to meet you!" }
                },
                new ContactGroup("J", "J")
                {
                    new Contact { Name = "John Smith", Status = "Hey, let's talk!" }
                }
            };
        }
    }
    public class Contact
    {
        public string Name { get; set; }
        public string Status { get; set; }
    }

    public class ContactGroup : List<Contact>
    {
        public string Title { get; set; }
        public string ShortTitle { get; set; }

        public ContactGroup(string title, string shortTitle)
        {
            Title = title;
            ShortTitle = shortTitle;
        }
    }
}
</code>```

xaml

```<code><?xml version="1.0" encoding="utf-8"?>
<ContentPage
    Padding="0, 20, 0, 0"
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:local="clr-namespace:Lists" x:Class="Lists.MainPage">

    <ListView x:Name="listView"
              IsGroupingEnabled="true"
              GroupDisplayBinding="{Binding Title}"
              GroupShortNameBinding="{Binding shortTitle}">
        <ListView.ItemTemplate>
            <DataTemplate>
                <TextCell Text="{Binding Name}" Detail="{Binding Status}"/>
            </DataTemplate>
        </ListView.ItemTemplate>
    </ListView>

</ContentPage>
</code>```

答:
In the line:

```<code>  GroupShortNameBinding="{Binding shortTitle}">
</code>```

You should set binding to ShortTitle  instead of shortTitle.

Here is a demo with the code and you can check it: grouped-listView

Body:
I tried building a simple Xamarin Forms application that groups a list of contacts. in this case I only had two contacts to keep it easy. When launching the app on the iOS-Simulator or on my iPhone 6s (iOS 12) an error appears that says:

"{Foundation.MonoTouchException: Objective-C exception thrown.  Name:
  NSInvalidArgumentException Reason: *** -[NSPlaceholderString
  initWithUTF8String:]: NULL cString Native stack trace:    0

  CoreFoundation  0x00000001068e56fb __exceptionPrepr…}"

c#

namespace Lists{
    public partial class MainPage : ContentPage
    {
        public MainPage()
        {
            InitializeComponent();

            listView.ItemsSource = new List<ContactGroup> {
                new ContactGroup("P", "P")
                {
                    new Contact { Name = "Peter Parker", Status = "Nice to meet you!" }
                },
                new ContactGroup("J", "J")
                {
                    new Contact { Name = "John Smith", Status = "Hey, let's talk!" }
                }
            };
        }
    }
    public class Contact
    {
        public string Name { get; set; }
        public string Status { get; set; }
    }

    public class ContactGroup : List<Contact>
    {
        public string Title { get; set; }
        public string ShortTitle { get; set; }

        public ContactGroup(string title, string shortTitle)
        {
            Title = title;
            ShortTitle = shortTitle;
        }
    }
}

xaml

<?xml version="1.0" encoding="utf-8"?>
<ContentPage
    Padding="0, 20, 0, 0"
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:local="clr-namespace:Lists" x:Class="Lists.MainPage">

    <ListView x:Name="listView"
              IsGroupingEnabled="true"
              GroupDisplayBinding="{Binding Title}"
              GroupShortNameBinding="{Binding shortTitle}">
        <ListView.ItemTemplate>
            <DataTemplate>
                <TextCell Text="{Binding Name}" Detail="{Binding Status}"/>
            </DataTemplate>
        </ListView.ItemTemplate>
    </ListView>

</ContentPage>

Body:
In the line:

  GroupShortNameBinding="{Binding shortTitle}">

You should set binding to ShortTitle  instead of shortTitle.

Here is a demo with the code and you can check it: grouped-listView


问:
Making python input search function case insensitive
I'm creating a python 3 search function that accepts input from the user. The user inputs a string, which is then searched in a word document.

I have tested the function with 2 docx files - one with the word "hello" in it and the other with "There".

When I input the words with the exact case as they are in the docx file the search function returns the name of the file - success! However, when I input the words without the correct case I don't get anything returned.

I've seen a few questions on here about case insensitive options but I couldn't really find one that was similar enough to my project. Any help would be much appreciated.

```<code>import os
import docx2txt

os.chdir('c:/users/Says/desktop/projectx')

path = ('c:/users/Says/desktop/projectx')

files = []

x = str(input("search: "))

for file in os.listdir(path):
    if file.endswith('.docx'):
        files.append(file)

for i in range(len(files)):
    text = docx2txt.process(files[i])
    if x in text:
        print (files[i])
</code>```

答:
One way is which I can suggest is just convert x and test to either upper or lower and then compare as follows, it will give you desired result.

if x.upper() in text.upper():

if x.lower() in text.lower():

Body:
I'm creating a python 3 search function that accepts input from the user. The user inputs a string, which is then searched in a word document.

I have tested the function with 2 docx files - one with the word "hello" in it and the other with "There".

When I input the words with the exact case as they are in the docx file the search function returns the name of the file - success! However, when I input the words without the correct case I don't get anything returned.

I've seen a few questions on here about case insensitive options but I couldn't really find one that was similar enough to my project. Any help would be much appreciated.

import os
import docx2txt

os.chdir('c:/users/Says/desktop/projectx')

path = ('c:/users/Says/desktop/projectx')

files = []

x = str(input("search: "))

for file in os.listdir(path):
    if file.endswith('.docx'):
        files.append(file)

for i in range(len(files)):
    text = docx2txt.process(files[i])
    if x in text:
        print (files[i])


问:
Using reference of Windows.Input for using ICommand in the VM
I am working on a UWP application which is based on the MVVM Pattern. for binding the UI actions I am using ICommand in the VM for which I need to provide a reference to Windows.Input .Is It breaking the MVVM.

If I create a class which implements the ICommand interface and use it for command binding then it breaks the rule of "Coding to Interfaces".

```<code>//This is what i am doing currently

public ICommand command;
command = new RelayCommand();

// I have tried this to remove the reference of windows.input from the VM

public RelayCommand command;
command = new RelayCommand();

//isn't it breaking the rule of coding to interfaces
</code>```

Which approach should I follow

答:
The first method is correct.

Why are you trying to remove the reference to System.Windows.Input? That's just the namespace, the actual project reference is to System.dll which is platform-independent.

Body:
I am working on a UWP application which is based on the MVVM Pattern. for binding the UI actions I am using ICommand in the VM for which I need to provide a reference to Windows.Input .Is It breaking the MVVM.

If I create a class which implements the ICommand interface and use it for command binding then it breaks the rule of "Coding to Interfaces".

//This is what i am doing currently

public ICommand command;
command = new RelayCommand();

// I have tried this to remove the reference of windows.input from the VM

public RelayCommand command;
command = new RelayCommand();

//isn't it breaking the rule of coding to interfaces

Which approach should I follow


问:
Getting WordPress post ID from within a filter
I'm trying to add a content_save_pre filter to update a custom field based on text in the content, e.g. [something]Thing[/something] will tell the plugin to set a custom field to "Thing".

My code (below) works fine when posting through the web interface, but fails on the clients I've tried (MarsEdit and WordPress iOS) and also the "Press This" bookmarklet. The [] tags get removed, but the custom field doesn't get set.

```<code>function dfll_get_link($post_content) {
  $dflink = dfll_find_link($post_content);
  if ($dflink) {
    global $post;
    $post_id = $post->ID;
    update_post_meta($post_id, 'linked_list_url', $dflink);
  }
  $temp = '/(' . dfll_regesc('[ll]') . '(.*?)' . dfll_regesc('[/ll]') . ')/i';
  $post_content = (preg_replace($temp, '', $post_content));
  return $post_content;
}

add_filter('content_save_pre', 'dfll_get_link');
</code>```

From some testing, it seems that the $post_id variable isn't being set. Is there a way to get the post ID in these cases? Or should I try and add the filter to a different hook? (I can't think of any that fit, though.)

答: Found the solution, using Justin Blanton's CF Setter plugin. Extract the information and store as a global, then apply the setting as an action for save_post. </p>

Body:
I'm trying to add a content_save_pre filter to update a custom field based on text in the content, e.g. [something]Thing[/something] will tell the plugin to set a custom field to "Thing".

My code (below) works fine when posting through the web interface, but fails on the clients I've tried (MarsEdit and WordPress iOS) and also the "Press This" bookmarklet. The [] tags get removed, but the custom field doesn't get set.

function dfll_get_link($post_content) {
  $dflink = dfll_find_link($post_content);
  if ($dflink) {
    global $post;
    $post_id = $post->ID;
    update_post_meta($post_id, 'linked_list_url', $dflink);
  }
  $temp = '/(' . dfll_regesc('[ll]') . '(.*?)' . dfll_regesc('[/ll]') . ')/i';
  $post_content = (preg_replace($temp, '', $post_content));
  return $post_content;
}

add_filter('content_save_pre', 'dfll_get_link');

From some testing, it seems that the $post_id variable isn't being set. Is there a way to get the post ID in these cases? Or should I try and add the filter to a different hook? (I can't think of any that fit, though.)


问:
Custom ocmod modification not working in opencart version 3.0.2.0
I have successfully uploaded my customised .ocmod folder(.ocmode.zip) in the extension installer and got success message too. But this is not loading in the extensions.
I'm using opencart Version 3.0.3.2.

My files are in the structure:
 - upload
     - admin
     - catalog

Is there an alternative way to approach this?
Please help.

Thanks in advance.

答: Ok. Encoding of the files you should convert to UTF-8 for example using Notepad++ This should help.XML file does not mater in your case, because it not have any important information. </p>