问:
gpgme_op_export_keys Invalid value
I am stuck with debugging gpgme.
When I turn the loglevel up to 9 i get the exact location where the error occurs.

```<code>GPGME 2017-06-02 16:25:42 <0x3968>  gpgme_op_export_keys: enter: ctx=08A19D68, mode=0x10, keydata=089C4578
GPGME 2017-06-02 16:25:42 <0x3968>  gpgme_op_export_keys: check: ctx=08A19D68, keys[0] = 089C4190 (9E799EB266729E930BE7A22B7650B73C8AD5436D)
GPGME 2017-06-02 16:25:42 <0x3968>  gpgme_op_export_keys: error: Invalid value <GPGME>
</code>```

I have a c++ library that uses gpgme. When I use the library in a Boost.Test application the error does not occur. When I use the library in a C# application the error occurs.

What I am doing is exporting a private ascii armored key from my keyring.
It is always the same fingerprint. Where can I go from here, are there things I need to validate on gpgme to find differences?

EDIT:
I have additional information about that problem.
I redistribute some gpgme files with my application.
Namely: libassuan-0.dll, libgpg-error-0.dll, libgpgme-11.dll.

When I instead copy my whole installation into the same folder the same calls run without an error.

This leads me to believe that there is a background setup running when i load the libraries. Reading the dokumentation for gpgme_set_global_flag i can see that there are some entries that refere to gpgconf.

What do I need to export in order to allow to run my application with the prosper configuration?

EDIT 2:
The gpgme.log differs from a succesful run to a failed run in the temprorary folder creation.

good:

```<code>_gpgme_io_spawn: check: path=00444FB8, CreateProcess ready: hProcess=000005D0, hThread=000005CC, dwProcessID=6184, dwThreadId=16268
</code>```

bad:

```<code>_gpgme_io_spawn: check: path=001850E8, CreateProcess failed: ec=87
</code>```

Both folders follow about the same naming scheme.
I am unsure what is failing here.

EDIT:
I am slowly driven into insanity. The setup seems non deterministic. Occasionally setup functions as expected. Occasionally it does not. I made sure I have the latest libraries - installed gpg4win and copied the libraries from there - now the debug log does either not show debug entries or gpg stopped looking for paths all together. It now fails at a later stage when I try to use OpenPGP. I recon the reason is still the same.

答:
The path of the standard installation contains spaces.

```<code>C:\Program Files (x86)\GNU\GnuPG\gpgconf.exe
</code>```

It appears as if that is not properly handled by gpgme. It looks like the path is not wrapped for a CreateProcess call.

As a hotfix I added gpgconf.exe to the execution path of my custom client.

gpgme has a detection for that file that looks in this path first.

This way when CreateProcess is invoked there are no spaces in the path and the call succeeds.

It is only a hotfix since my customer now needs to be sure he does not install my application in a path with spaces.

EDIT: unmarked it again. It worked for a short while and now gpgme has stopped calling gpgconf.exe. So naturally now there is a different bug.

....and now everything is suddently fine again.

So I guess the only correct solution with a falkey experience is to throw the whole thing out the window.

Title: gpgme_op_export_keys Invalid value

Body:
I am stuck with debugging gpgme.
When I turn the loglevel up to 9 i get the exact location where the error occurs.

GPGME 2017-06-02 16:25:42 <0x3968>  gpgme_op_export_keys: enter: ctx=08A19D68, mode=0x10, keydata=089C4578
GPGME 2017-06-02 16:25:42 <0x3968>  gpgme_op_export_keys: check: ctx=08A19D68, keys[0] = 089C4190 (9E799EB266729E930BE7A22B7650B73C8AD5436D)
GPGME 2017-06-02 16:25:42 <0x3968>  gpgme_op_export_keys: error: Invalid value <GPGME>

I have a c++ library that uses gpgme. When I use the library in a Boost.Test application the error does not occur. When I use the library in a C# application the error occurs.

What I am doing is exporting a private ascii armored key from my keyring.
It is always the same fingerprint. Where can I go from here, are there things I need to validate on gpgme to find differences?

EDIT:
I have additional information about that problem.
I redistribute some gpgme files with my application.
Namely: libassuan-0.dll, libgpg-error-0.dll, libgpgme-11.dll.

When I instead copy my whole installation into the same folder the same calls run without an error.

This leads me to believe that there is a background setup running when i load the libraries. Reading the dokumentation for gpgme_set_global_flag i can see that there are some entries that refere to gpgconf.

What do I need to export in order to allow to run my application with the prosper configuration?

EDIT 2:
The gpgme.log differs from a succesful run to a failed run in the temprorary folder creation.

good:

_gpgme_io_spawn: check: path=00444FB8, CreateProcess ready: hProcess=000005D0, hThread=000005CC, dwProcessID=6184, dwThreadId=16268

bad:

_gpgme_io_spawn: check: path=001850E8, CreateProcess failed: ec=87

Both folders follow about the same naming scheme.
I am unsure what is failing here.

EDIT:
I am slowly driven into insanity. The setup seems non deterministic. Occasionally setup functions as expected. Occasionally it does not. I made sure I have the latest libraries - installed gpg4win and copied the libraries from there - now the debug log does either not show debug entries or gpg stopped looking for paths all together. It now fails at a later stage when I try to use OpenPGP. I recon the reason is still the same.

Body:
The path of the standard installation contains spaces.

C:\Program Files (x86)\GNU\GnuPG\gpgconf.exe

It appears as if that is not properly handled by gpgme. It looks like the path is not wrapped for a CreateProcess call.

As a hotfix I added gpgconf.exe to the execution path of my custom client.

gpgme has a detection for that file that looks in this path first.

This way when CreateProcess is invoked there are no spaces in the path and the call succeeds.

It is only a hotfix since my customer now needs to be sure he does not install my application in a path with spaces.

EDIT: unmarked it again. It worked for a short while and now gpgme has stopped calling gpgconf.exe. So naturally now there is a different bug.

....and now everything is suddently fine again.

So I guess the only correct solution with a falkey experience is to throw the whole thing out the window.


来源: stackexchange

问:
Python / Scrapy - output is cut off - hence wount let me correctly build queries with Xpath
Im trying to scrape some data off a website using Scrapy and Python. The problem is the output of my search is always cut off. I tried this on 2 different Pcs. One is using windows 10, scrapy 1.4.0, python 2.7.13. The other is using Windows 7 ,scrapy 1.4.0, python 2.7.13. I have the same result on both computers.

Example :  (using scrapy shell on command line)

```<code>1. scrapy shell "www.reddit.com"
2. ..... some output comes here
3. response.xpath('//div')
</code>```

Image

so the selectors got cut after a certain amount characters

another Example :

When using the Dev Tools on the website im trying to scrape(or any other site for that matter), i see the selector should be :

```<code><Selector xpath='//div[@id="all_game_info"]' data=u'<div id="all_game_info" class="table_wrapper columns'>
</code>```

When i access it with :

```<code>response.xpath('//div[@id="all_game_info"]')
</code>```

then i get :

```<code>[<Selector xpath='//div[@id="all_game_info"]' data=u'<div id="all_game_info" class="table_wra'>]
</code>```

so it cutt off a part. When i now try to search with the class variable like this

```<code>response.xpath('//div[@class="table_wra"]')
</code>```

or

```<code>response.xpath('//div[@class="table_wrapper columns"]')
</code>```

, then i get empty brackets []

Edit1: I am aware that i can scrape the data with .extract(). Im just wondering why its cut off, and why i cant access it with the @class variable

答:
```<code>$ scrapy shell 'http://www.pro-football-reference.com/boxscores/201409040sea.htm'
2017-06-07 13:37:56 [scrapy.utils.log] INFO: Scrapy 1.4.0 started (bot: recordreviews)
(...)
>>> response.xpath('//div[@id="all_game_info"]')
[<Selector xpath='//div[@id="all_game_info"]' data='<div id="all_game_info" class="table_wra'>]
</code>```

<Selector xpath='//div[@id="all_game_info"]' data=u'
 is only a representation of the Selector object.
The data= part only shows the 40 first characters of the data you would get with .extract() on that Selector.

See the code here.

If you use .extract_first() (on the SelectorList you get from response.xpath()), you can see the raw HTML

```<code>>>> print(response.xpath('//div[@id="all_game_info"]').extract_first())
<div id="all_game_info" class="table_wrapper setup_commented commented columns">

<div class="section_heading">
  <span class="section_anchor" id="game_info_link" data-label="Game Info"></span>
    <h2>Game Info</h2>    <div class="section_heading_text">
      <ul>
      </ul>
    </div>
</div>
<div class="placeholder"></div>
<!--
   <div class="table_outer_container">
      <div class="overthrow table_container" id="div_game_info">
  <table class="suppress_all sortable stats_table" id="game_info" data-cols-to-freeze=0><caption>Game Info Table</caption><tr class="thead onecell" ><td class="right center" data-stat="onecell" colspan="2" >Game Info</td></tr>
<tr ><th scope="row" class="center " data-stat="info" >Won Toss</th><td class="center " data-stat="stat" >Seahawks (deferred)</td></tr>
<tr ><th scope="row" class="center " data-stat="info" >Roof</th><td class="center " data-stat="stat" >outdoors</td></tr>
<tr ><th scope="row" class="center " data-stat="info" >Surface</th><td class="center " data-stat="stat" >fieldturf </td></tr>
<tr ><th scope="row" class="center " data-stat="info" >Weather</th><td class="center " data-stat="stat" >71 degrees relative humidity 52%, wind 11 mph, wind chill 0</td></tr>
<tr ><th scope="row" class="center " data-stat="info" >Vegas Line</th><td class="center " data-stat="stat" >Seattle Seahawks -8.5</td></tr>
<tr ><th scope="row" class="center " data-stat="info" >Over/Under</th><td class="center " data-stat="stat" >45.0 <b>(over)</b></td></tr>

</table>

      </div>
   </div>
-->
</div>
>>>
</code>```

The source HTML contains:

```<code><div id="all_game_info" class="table_wrapper setup_commented commented columns">

<div class="section_heading">
  <span class="section_anchor" id="game_info_link" data-label="Game Info"></span>
    <h2>Game Info</h2>    <div class="section_heading_text">
      <ul>
      </ul>
    </div>
</div>
...
</code>```

The class value is "table_wrapper setup_commented commented columns", not "table_wrapper columns".

To match a node with XPath with @class=, you need an exact match:

```<code>>>> response.xpath('//div[@class="table_wrapper columns"]')
[]
>>> response.xpath('//div[@class="table_wrapper setup_commented commented columns"]')
[<Selector xpath='//div[@class="table_wrapper setup_commented commented columns"]' data='<div id="all_game_info" class="table_wra'>, <Selector xpath='//div[@class="table_wrapper setup_commented commented columns"]' data='<div id="all_officials" class="table_wra'>, <Selector xpath='//div[@class="table_wrapper setup_commented commented columns"]' data='<div id="all_home_starters" class="table'>, <Selector xpath='//div[@class="table_wrapper setup_commented commented columns"]' data='<div id="all_vis_starters" class="table_'>, <Selector xpath='//div[@class="table_wrapper setup_commented commented columns"]' data='<div id="all_home_snap_counts" class="ta'>, <Selector xpath='//div[@class="table_wrapper setup_commented commented columns"]' data='<div id="all_vis_snap_counts" class="tab'>, <Selector xpath='//div[@class="table_wrapper setup_commented commented columns"]' data='<div id="all_home_drives" class="table_w'>, <Selector xpath='//div[@class="table_wrapper setup_commented commented columns"]' data='<div id="all_vis_drives" class="table_wr'>]
>>>
</code>```

If you want to match on some of the classes in the class attribute, you may want to have a look at CSS selectors:

```<code>>>> response.css('div.table_wrapper.columns')
[<Selector xpath="descendant-or-self::div[@class and contains(concat(' ', normalize-space(@class), ' '), ' table_wrapper ') and (@class and contains(concat(' ', normalize-space(@class), ' '), ' columns '))]" data='<div id="all_game_info" class="table_wra'>, <Selector xpath="descendant-or-self::div[@class and contains(concat(' ', normalize-space(@class), ' '), ' table_wrapper ') and (@class and contains(concat(' ', normalize-space(@class), ' '), ' columns '))]" data='<div id="all_officials" class="table_wra'>, <Selector xpath="descendant-or-self::div[@class and contains(concat(' ', normalize-space(@class), ' '), ' table_wrapper ') and (@class and contains(concat(' ', normalize-space(@class), ' '), ' columns '))]" data='<div id="all_home_starters" class="table'>, <Selector xpath="descendant-or-self::div[@class and contains(concat(' ', normalize-space(@class), ' '), ' table_wrapper ') and (@class and contains(concat(' ', normalize-space(@class), ' '), ' columns '))]" data='<div id="all_vis_starters" class="table_'>, <Selector xpath="descendant-or-self::div[@class and contains(concat(' ', normalize-space(@class), ' '), ' table_wrapper ') and (@class and contains(concat(' ', normalize-space(@class), ' '), ' columns '))]" data='<div id="all_home_snap_counts" class="ta'>, <Selector xpath="descendant-or-self::div[@class and contains(concat(' ', normalize-space(@class), ' '), ' table_wrapper ') and (@class and contains(concat(' ', normalize-space(@class), ' '), ' columns '))]" data='<div id="all_vis_snap_counts" class="tab'>, <Selector xpath="descendant-or-self::div[@class and contains(concat(' ', normalize-space(@class), ' '), ' table_wrapper ') and (@class and contains(concat(' ', normalize-space(@class), ' '), ' columns '))]" data='<div id="all_home_drives" class="table_w'>, <Selector xpath="descendant-or-self::div[@class and contains(concat(' ', normalize-space(@class), ' '), ' table_wrapper ') and (@class and contains(concat(' ', normalize-space(@class), ' '), ' columns '))]" data='<div id="all_vis_drives" class="table_wr'>]
>>>
</code>```

ContentLicense: CC BY-SA 3.0

Body:
Im trying to scrape some data off a website using Scrapy and Python. The problem is the output of my search is always cut off. I tried this on 2 different Pcs. One is using windows 10, scrapy 1.4.0, python 2.7.13. The other is using Windows 7 ,scrapy 1.4.0, python 2.7.13. I have the same result on both computers.

Example :  (using scrapy shell on command line)

1. scrapy shell "www.reddit.com"
2. ..... some output comes here
3. response.xpath('//div')

Image

so the selectors got cut after a certain amount characters

another Example :

When using the Dev Tools on the website im trying to scrape(or any other site for that matter), i see the selector should be :

<Selector xpath='//div[@id="all_game_info"]' data=u'

When i access it with :

response.xpath('//div[@id="all_game_info"]')

then i get :

[<Selector xpath='//div[@id="all_game_info"]' data=u'
]

so it cutt off a part. When i now try to search with the class variable like this

response.xpath('//div[@class="table_wra"]')

or

response.xpath('//div[@class="table_wrapper columns"]')

, then i get empty brackets []

Edit1: I am aware that i can scrape the data with .extract(). Im just wondering why its cut off, and why i cant access it with the @class variable

Body:
$ scrapy shell 'http://www.pro-football-reference.com/boxscores/201409040sea.htm'
2017-06-07 13:37:56 [scrapy.utils.log] INFO: Scrapy 1.4.0 started (bot: recordreviews)
(...)
>>> response.xpath('//div[@id="all_game_info"]')
[<Selector xpath='//div[@id="all_game_info"]' data='<div id="all_game_info" class="table_wra'>]

<Selector xpath='//div[@id="all_game_info"]' data=u'<div id="all_game_info" class="table_wrapper columns'> is only a representation of the Selector object.
The data= part only shows the 40 first characters of the data you would get with .extract() on that Selector.

See the code here.

If you use .extract_first() (on the SelectorList you get from response.xpath()), you can see the raw HTML

>>> print(response.xpath('//div[@id="all_game_info"]').extract_first())
<div id="all_game_info" class="table_wrapper setup_commented commented columns">

<div class="section_heading">
  <span class="section_anchor" id="game_info_link" data-label="Game Info"></span>
    <h2>Game Info</h2>    <div class="section_heading_text">
      <ul>
      </ul>
    </div>
</div>
<div class="placeholder"></div>
<!--
   <div class="table_outer_container">
      <div class="overthrow table_container" id="div_game_info">
  <table class="suppress_all sortable stats_table" id="game_info" data-cols-to-freeze=0><caption>Game Info Table</caption><tr class="thead onecell" ><td class="right center" data-stat="onecell" colspan="2" >Game Info</td></tr>
<tr ><th scope="row" class="center " data-stat="info" >Won Toss</th><td class="center " data-stat="stat" >Seahawks (deferred)</td></tr>
<tr ><th scope="row" class="center " data-stat="info" >Roof</th><td class="center " data-stat="stat" >outdoors</td></tr>
<tr ><th scope="row" class="center " data-stat="info" >Surface</th><td class="center " data-stat="stat" >fieldturf </td></tr>
<tr ><th scope="row" class="center " data-stat="info" >Weather</th><td class="center " data-stat="stat" >71 degrees relative humidity 52%, wind 11 mph, wind chill 0</td></tr>
<tr ><th scope="row" class="center " data-stat="info" >Vegas Line</th><td class="center " data-stat="stat" >Seattle Seahawks -8.5</td></tr>
<tr ><th scope="row" class="center " data-stat="info" >Over/Under</th><td class="center " data-stat="stat" >45.0 <b>(over)</b></td></tr>

</table>

      </div>
   </div>
-->
</div>
>>>

The source HTML contains:

<div id="all_game_info" class="table_wrapper setup_commented commented columns">

<div class="section_heading">
  <span class="section_anchor" id="game_info_link" data-label="Game Info"></span>
    <h2>Game Info</h2>    <div class="section_heading_text">
      <ul>
      </ul>
    </div>
</div>
...

The class value is "table_wrapper setup_commented commented columns", not "table_wrapper columns".

To match a node with XPath with @class=, you need an exact match:

>>> response.xpath('//div[@class="table_wrapper columns"]')
[]
>>> response.xpath('//div[@class="table_wrapper setup_commented commented columns"]')
[<Selector xpath='//div[@class="table_wrapper setup_commented commented columns"]' data='<div id="all_game_info" class="table_wra'>, <Selector xpath='//div[@class="table_wrapper setup_commented commented columns"]' data='<div id="all_officials" class="table_wra'>, <Selector xpath='//div[@class="table_wrapper setup_commented commented columns"]' data='<div id="all_home_starters" class="table'>, <Selector xpath='//div[@class="table_wrapper setup_commented commented columns"]' data='<div id="all_vis_starters" class="table_'>, <Selector xpath='//div[@class="table_wrapper setup_commented commented columns"]' data='<div id="all_home_snap_counts" class="ta'>, <Selector xpath='//div[@class="table_wrapper setup_commented commented columns"]' data='<div id="all_vis_snap_counts" class="tab'>, <Selector xpath='//div[@class="table_wrapper setup_commented commented columns"]' data='<div id="all_home_drives" class="table_w'>, <Selector xpath='//div[@class="table_wrapper setup_commented commented columns"]' data='<div id="all_vis_drives" class="table_wr'>]
>>>

If you want to match on some of the classes in the class attribute, you may want to have a look at CSS selectors:

>>> response.css('div.table_wrapper.columns')
[<Selector xpath="descendant-or-self::div[@class and contains(concat(' ', normalize-space(@class), ' '), ' table_wrapper ') and (@class and contains(concat(' ', normalize-space(@class), ' '), ' columns '))]" data='<div id="all_game_info" class="table_wra'>, <Selector xpath="descendant-or-self::div[@class and contains(concat(' ', normalize-space(@class), ' '), ' table_wrapper ') and (@class and contains(concat(' ', normalize-space(@class), ' '), ' columns '))]" data='<div id="all_officials" class="table_wra'>, <Selector xpath="descendant-or-self::div[@class and contains(concat(' ', normalize-space(@class), ' '), ' table_wrapper ') and (@class and contains(concat(' ', normalize-space(@class), ' '), ' columns '))]" data='<div id="all_home_starters" class="table'>, <Selector xpath="descendant-or-self::div[@class and contains(concat(' ', normalize-space(@class), ' '), ' table_wrapper ') and (@class and contains(concat(' ', normalize-space(@class), ' '), ' columns '))]" data='<div id="all_vis_starters" class="table_'>, <Selector xpath="descendant-or-self::div[@class and contains(concat(' ', normalize-space(@class), ' '), ' table_wrapper ') and (@class and contains(concat(' ', normalize-space(@class), ' '), ' columns '))]" data='<div id="all_home_snap_counts" class="ta'>, <Selector xpath="descendant-or-self::div[@class and contains(concat(' ', normalize-space(@class), ' '), ' table_wrapper ') and (@class and contains(concat(' ', normalize-space(@class), ' '), ' columns '))]" data='<div id="all_vis_snap_counts" class="tab'>, <Selector xpath="descendant-or-self::div[@class and contains(concat(' ', normalize-space(@class), ' '), ' table_wrapper ') and (@class and contains(concat(' ', normalize-space(@class), ' '), ' columns '))]" data='<div id="all_home_drives" class="table_w'>, <Selector xpath="descendant-or-self::div[@class and contains(concat(' ', normalize-space(@class), ' '), ' table_wrapper ') and (@class and contains(concat(' ', normalize-space(@class), ' '), ' columns '))]" data='<div id="all_vis_drives" class="table_wr'>]
>>>


问:
Building SSIS solution using visual studio online build definition... .dtproj is not supported by MSBuild and cannot be built
I've created a build definition via visual studio online that builds an SSIS project (dtproj).  The build appears to succeed but there is a warning that appears stating "dtproj is not supported by MSBuild and cannot be built".

SSDT has been installed on the build server.

Does anyone have any ideas why this warning would be showing up?

答:
MSBuild cannot build the project file format that SSDT uses. It is a pre-msbuild visuals studio format.

There's a hacky way to create an msbuild project that performs the necessary tasks but the easiest way is not not use MSBuild for this project but build it via the visual studio command line devenv.exe /build. Since this builds from visual studio, it understands all project file formats and has the necessary SSDT plugins.


问:
Connection to the server was unsuccessful. (file ///android_asset/www/index.html)
I have an error when I run my app on ionic cordova run android.
My error is : Connection to the server was unsuccessful. (file ///android_asset/www/index.html)
I try to resolve it with forums that exists with this solution :

1)Rename your index.html to “main.html”

2)Create a new “index.html” and put the following content into it:

```<code><!doctype html>
<html>
  <head>
   <title>title</title>
   <script>
     window.location='./main.html';
   </script>
  <body>
  </body>
</html>
</code>```

Or modify in the config.xml this line :

```<code><preference name="SplashScreenDelay" value="3000" />
</code>```

to this line :

```<code><preference name="SplashScreenDelay" value="70000" />
</code>```

But when I run my app after saving my new code, the error still appear and when I return into my code, I see that the code is still the same and not has been modified (even if I modified it like I sayed previously !)

Someone know how to resolve my problem ?

Thanks in advance,
Caroline

答:
I had that error with one application and I solved it with Crosswalk.

```<code>ionic plugin add cordova-plugin-crosswalk-webview
</code>```

After installation you may have to adjust the design but the error will no longer appear.

More about Crosswalk.

Optional config.xml settings:

```<code><preference name="loadUrlTimeoutValue" value="60000" />
<preference name="AutoHideSplashScreen" value="false" />
</code>```

Body:
I have an error when I run my app on ionic cordova run android.
My error is : Connection to the server was unsuccessful. (file ///android_asset/www/index.html)
I try to resolve it with forums that exists with this solution :

1)Rename your index.html to “main.html”

2)Create a new “index.html” and put the following content into it:

<!doctype html>

   <title>title</title>

Or modify in the config.xml this line :

<preference name="SplashScreenDelay" value="3000" />

to this line :

<preference name="SplashScreenDelay" value="70000" />

But when I run my app after saving my new code, the error still appear and when I return into my code, I see that the code is still the same and not has been modified (even if I modified it like I sayed previously !)

Someone know how to resolve my problem ?

Thanks in advance,
Caroline

Body:
I had that error with one application and I solved it with Crosswalk.

ionic plugin add cordova-plugin-crosswalk-webview

After installation you may have to adjust the design but the error will no longer appear.

More about Crosswalk.

Optional config.xml settings:

<preference name="loadUrlTimeoutValue" value="60000" />
<preference name="AutoHideSplashScreen" value="false" />


问:
Can kotlin define dynamic method when class init?
My class:

```<code>class Demo {
    init {
        // define method here my some array:[a,b,c]
        // such as fun Demo.a,Demo.b...
    }
}
</code>```

Function names are dynamic.

Can Kotlin do this?

答:
No, you can't dynamically define functions in classes, but because functions are also objects, you can dynamically store them (in a field, array, map) and call them dynamically. Using some language features of Kotlin we can get a quite terse syntax:

```<code>class Demo(name: String) {
    private val functions: Map<String, () -> Any> = mapOf(name to { "Hello $name" })

    operator fun get(name: String): Any? = functions[name]?.invoke()
}

fun main(args: Array<String>) {
    val demo = Demo("Kirill")

    println(demo["Kirill"])
}
</code>```

Output:

Hello Kirill

Body:
My class:

class Demo {
    init {
        // define method here my some array:[a,b,c]
        // such as fun Demo.a,Demo.b...
    }
}

Function names are dynamic.

Can Kotlin do this?

Body:
No, you can't dynamically define functions in classes, but because functions are also objects, you can dynamically store them (in a field, array, map) and call them dynamically. Using some language features of Kotlin we can get a quite terse syntax:

class Demo(name: String) {
    private val functions: Map<String, () -> Any> = mapOf(name to { "Hello $name" })

    operator fun get(name: String): Any? = functions[name]?.invoke()
}

fun main(args: Array<String>) {
    val demo = Demo("Kirill")

    println(demo["Kirill"])
}

Output:

Hello Kirill


问:
Rails server won't start up
I'm trying to do a Rails server won't start, I'm using linux to run the code.

Console result:

```<code>/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- bundler/setup (LoadError)
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /home/oblivio/Applications/Ruby/blog/blog/config/boot.rb:4:in `<top (required)>'
from bin/rails:3:in `require_relative'
from bin/rails:3:in `<main>'
</code>```

答: try to type 'spring stop' in your rails app. And retry 'rails s'</p>

ContentLicense: CC BY-SA 4.0

Title: Rails server won't start up

Body:
I'm trying to do a Rails server won't start, I'm using linux to run the code.

Console result:

/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- bundler/setup (LoadError)
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /home/oblivio/Applications/Ruby/blog/blog/config/boot.rb:4:in `<top (required)>'
from bin/rails:3:in `require_relative'
from bin/rails:3:in `'


Title: Calculate distances by trip in dataframe

Body:
I have a Dataframe with 46 trips made by a penguin in the Falkland Islands, I calculated few parameters, assuming that every foraging trip it is when a penguin is farther than 1000m from the coast, and stop when is back to <1000m penguin 1 data in .xlsx .Rda al dataframe stored:

library(sp)
>p.1

 date               | lon          | lat          | trip | distancetocoast
2014-06-11 19:02:00 | -58,3508585  | -51,88438373 | 1    | 2236.067977
2014-06-12 01:02:00 | -58,35589725 | -51,88349529 | 1    | 1000
2014-06-12 13:02:00 | -58,27224941 | -51,91903677 | 1    | 7211,102551
2014-06-12 19:02:00 | -58,27974654 | -51,90535003 | 1    | 5830,951895
2014-06-13 01:02:00 | -58,32331901 | -51,89410464 | 1    | 3605,551275
2014-06-13 07:02:00 | -58,35833139 | -51,88809227 | 1    | 1414,213562
2014-06-13 13:02:00 | -58,35617673 | -51,88156281 | 1    | 1000
2014-06-13 19:02:00 | -58,34055711 | -51,89002367 | 1    | 2236,067977
2014-06-14 01:02:00 | -58,34982536 | -51,8715761  | 2    | 1000
2014-06-14 13:02:00 | -58,3073814  | -51,92722937 | 2    | 7071,067812
2014-06-14 19:02:00 | -58,34581314 | -51,86761133 | 3    | 1000
2014-06-15 01:02:00 | -58,34050624 | -51,88382088 | 3    | 1414,213562
2014-06-15 13:02:00 | -58,2974691  | -51,91795326 | 3    | 6324,55532
2014-06-15 19:02:00 | -58,19881901 | -51,95172233 | 3    | 13000
2014-06-16 01:02:00 | -58,1348416  | -51,98673766 | 3    | 18788,29423
2014-06-16 07:02:00 | -57,99399544 | -52,06988191 | 3    | 28861,73938
2014-06-16 13:02:00 | -58,00469754 | -52,02795069 | 3    | 26627,05391
2014-06-16 19:02:00 | -57,92758675 | -52,02184666 | 3    | 29000
2014-06-17 01:02:00 | -57,91658235 | -51,99748699 | 3    | 28284,27125
2014-06-17 07:02:00 | -57,77015528 | -51,99031797 | 3    | 30805,8436
2014-06-17 13:02:00 | -57,99601712 | -51,91519551 | 3    | 17804,49381
2014-06-17 19:02:00 | -58,06820013 | -51,92972737 | 3    | 14866,06875
2014-06-18 01:02:00 | -58,19845185 | -51,89522513 | 3    | 7615,773106
2014-06-18 07:02:00 | -58,35241361 | -51,88015998 | 3    | 1000
2014-06-18 13:02:00 | -58,35603546 | -51,88336878 | 3    | 1000
2014-06-18 19:02:00 | -58,33350332 | -51,87308427 | 3    | 1000
2014-06-19 01:02:00 | -58,33839581 | -51,87846631 | 3    | 1414,213562
2014-06-19 07:02:00 | -58,42661519 | -51,80902388 | 4    | 0
2014-06-19 13:02:00 | -58,30461883 | -51,93745837 | 4    | 7810,249676
2014-06-19 19:02:00 | -58,18362875 | -51,96475914 | 4    | 14317,82106

I have used this code that calculates the distance from each of the points in a matrix:

distancebetwenpoints=spDists(locs1_utm, longlat=FALSE)
p.1$dist=distancebetwenpoints   #INCLUDE COLUMN DISTANCE TO THE COLONY OF EACH POINT

However, this include a huge matrix of 779 value within the dataframe p.1, I have tried other ways but I cannot make it work, and with the matrix I cannot really study the statistics properly, thus, how can I calculate the distance made by the penguin in each trip?

FalklandCRS = CRS("+proj=utm +zone=21 +south +datum=WGS84 +units=m +no_defs")
locs1 = sp::SpatialPointsDataFrame(coords = cbind(subset(p.1$lon, p.1$id == 1), subset(p.1$lat, p.1$id == 1)), data = subset(p.1, p.1$id == 1), proj4string=CRS("+proj=longlat +datum=WGS84"))
locs1_utm = sp::spTransform(locs1, FalklandCRS)

head(p.1)
id                date       lon       lat   lon.025     lon.5   lon.975   lat.025     lat.5   lat.975
1  1 2014-06-11 19:02:00 -58.35086 -51.88438 -58.35466 -58.35112 -58.34588 -51.88563 -51.88442 -51.88295
2  1 2014-06-12 01:02:00 -58.35590 -51.88350 -58.36226 -58.35594 -58.34932 -51.88602 -51.88350 -51.88068
4  1 2014-06-12 13:02:00 -58.27225 -51.91904 -58.32643 -58.26749 -58.24544 -51.93304 -51.91970 -51.90113
5  1 2014-06-12 19:02:00 -58.27975 -51.90535 -58.51877 -58.27893 -58.02546 -52.05056 -51.90636 -51.75887
6  1 2014-06-13 01:02:00 -58.32332 -51.89410 -58.56753 -58.32094 -58.09604 -52.04776 -51.89361 -51.74586
7  1 2014-06-13 07:02:00 -58.35833 -51.88809 -58.37411 -58.35856 -58.34158 -51.89519 -51.88818 -51.88029
  bathy    bathy2 distancetocoast
1    -1  4.080409        2236.068
2    -1  4.080409        1000.000
4    -6 -5.849781        7211.103
5    -4 -5.308407        5830.952
6    -1 -2.060174        3605.551
7    -1 -1.450360        1414.214

Body:
I took the liberty and created a workaround from scratch

library(lubridate)
library(data.table)

dt<-data.table(
  date=ymd_hms(c("2014-06-11 19:02:00"
             ,"2014-06-12 01:02:00"
             ,"2014-06-12 13:02:00"
             ,"2014-06-12 19:02:00"
             ,"2014-06-13 01:02:00"
             ,"2014-06-13 07:02:00"
             ,"2014-06-13 13:02:00"
             ,"2014-06-13 19:02:00"
             ,"2014-06-14 01:02:00"
             ,"2014-06-14 13:02:00"
             ,"2014-06-14 19:02:00"
             ,"2014-06-15 01:02:00"
             ,"2014-06-15 13:02:00"
             ,"2014-06-15 19:02:00"
             ,"2014-06-16 01:02:00"
             ,"2014-06-16 07:02:00"
             ,"2014-06-16 13:02:00"
             ,"2014-06-16 19:02:00"
             ,"2014-06-17 01:02:00"
             ,"2014-06-17 07:02:00"
             ,"2014-06-17 13:02:00"
             ,"2014-06-17 19:02:00"
             ,"2014-06-18 01:02:00"
             ,"2014-06-18 07:02:00"
             ,"2014-06-18 13:02:00"
             ,"2014-06-18 19:02:00"
             ,"2014-06-19 01:02:00"
             ,"2014-06-19 07:02:00"
             ,"2014-06-19 13:02:00"
             ,"2014-06-19 19:02:00"))
  ,lon=c(-58.3508585
         ,-58.35589725
         ,-58.27224941
         ,-58.27974654
         ,-58.32331901
         ,-58.35833139
         ,-58.35617673
         ,-58.34055711
     ,-58.34982536
     ,-58.3073814
     ,-58.34581314
     ,-58.34050624
     ,-58.2974691
     ,-58.19881901
     ,-58.1348416
     ,-57.99399544
     ,-58.00469754
     ,-57.92758675
     ,-57.91658235
     ,-57.77015528
     ,-57.99601712
     ,-58.06820013
     ,-58.19845185
     ,-58.35241361
     ,-58.35603546
     ,-58.33350332
     ,-58.33839581
     ,-58.42661519
     ,-58.30461883
     ,-58.18362875)
  ,lat=c(-51.88438373
     ,-51.88349529
     ,-51.91903677
     ,-51.90535003
     ,-51.89410464
     ,-51.88809227
     ,-51.88156281
     ,-51.89002367
     ,-51.8715761
     ,-51.92722937
     ,-51.86761133
     ,-51.88382088
     ,-51.91795326
     ,-51.95172233
     ,-51.98673766
     ,-52.06988191
     ,-52.02795069
     ,-52.02184666
     ,-51.99748699
     ,-51.99031797
     ,-51.91519551
     ,-51.92972737
     ,-51.89522513
     ,-51.88015998
     ,-51.88336878
     ,-51.87308427
     ,-51.87846631
     ,-51.80902388
     ,-51.93745837
     ,-51.96475914 )
  ,trip=c( 1
       , 1
       , 1
       , 1
       , 1
       , 1
       , 1
       , 1
       , 2
       , 2
       , 3
       , 3
       , 3
       , 3
       , 3
       , 3
       , 3
       , 3
       , 3
       , 3
       , 3
       , 3
       , 3
       , 3
       , 3
       , 3
       , 3
       , 4
       , 4
       , 4 )
  ,distance2coast=c(2236.067977
                ,1000
                ,7211.102551
                ,5830.951895
                ,3605.551275
                ,1414.213562
                ,1000
                ,2236.067977
                ,1000
                ,7071.067812
                ,1000
                ,1414.213562
                ,6324.55532
                ,13000
                ,18788.29423
                ,28861.73938
                ,26627.05391
                ,29000
                ,28284.27125
                ,30805.8436
                ,17804.49381
                ,14866.06875
                ,7615.773106
                ,1000
                ,1000
                ,1000
                ,1414.213562
                ,0
                ,7810.249676
                ,14317.82106)

)

A function that calculates the distance of points on a sphere:

distanceOfPoints <- function(long1, lat1, long2, lat2) {
  R <- 6371
  d <- acos(sin(lat1)*sin(lat2) + cos(lat1)*cos(lat2) * cos(long2-long1)) * R
  return(d) #km
}
##yet another function for the distance calculation between geodetic coordinates

gcd.hf <- function(long1, lat1, long2, lat2) {
  R <- 6371 # Earth mean radius [km]
   delta.long <- (long2 - long1)
   delta.lat <- (lat2 - lat1)
  a <- sin(delta.lat/2)^2 + cos(lat1) * cos(lat2) * sin(delta.long/2)^2
  c <- 2 * asin(min(1,sqrt(a)))
  d = R * c
  return(d) # Distance in km
}

Furthermore:

dt<-dt[order(date)]#order chronologically

We then split the data into list based on the "trip":

dt_split<-split(dt,by="trip")
names(dt_split)<-paste0("trip",names(dt_split))#and we give name to each element

A simple function that takes into account consecutive rows and calculates cumulative distance.

calcDistancePerTrip<-function(y){#y is dataframe-element of list
  l1<-lapply(seq_along(1:nrow(y)),function(x){
    dist<-distanceOfPoints(long1 = y[,.(lon)][x],long2= y[,.(lon)][x+1],lat1 = y[,.(lat)][x],lat2 = y[,.(lat)][x+1])
    #you can always use the gcd.hf for the dist calculation
    return(dist)
  })
  l1<-as.numeric(unlist(l1))#list to numeric vector
  tot_dist<-sum(l1,na.rm = T)#cumulative distance per trip
  return(tot_dist)
}

Finally we "loop" it over the initial list:

lapply(dt_split,calcDistancePerTrip)

yielding in:

$trip1
[1] 531.6949

$trip2
[1] 354.8975

$trip3
[1] 3067.865

$trip4
[1] 1012.005


问:
android/twitter4j question
greetings all!

i'm trying to work my way through a twitter implementation.  i've followed several tutorials and finally made progress with this implementation: code.

All appears well as i'm authorized through the twitter browser app and even returned back to my app/view via the callback.  this is where i'm confused... at this point, i assumed the onNewIntent() method is called and a test tweet is sent?  if so, this doesn't work for me...no error are thrown/logged.  can someone pls tell me what i'm missing?

resources used:
 - twitter4j-core-2.1.7
 - signpost-core-1.2.1.1
 - signpost-commonshttp4-1.2.1.1
 - 2.1 SDK

答:
added the following to my manifest file and activity:  android:launchMode="singleInstance"

works like a charm!

ContentLicense: CC BY-SA 2.5

Title: android/twitter4j question


问:
angularjs SPA - how to flush memory?
I am using angularjs single page app in my webpage,

following is code for spa constructor

```<code>app.config(config);
config.$inject = ['$stateProvider','$urlRouterProvider'];
function config($stateProvider,$urlRouterProvider){
    $stateProvider.state('dashboard',{
        url:'/{userID}/{testID}',
        templateUrl:'templates/dashboard.html',
        controller:'dashboardCtrl'
    });
}
</code>```

template dashboard.html displays number of google graphs and charts.
In controller dashboardCtrl, I make GET/POST requests to server using $http directive, and plot google graphs using response data.

following is code for service ($http request)

```<code>app.service('getGraphData',getGraphData);
getGraphData.$inject = ['$http'];
function getGraphData($http){
    var obj = this;
    obj.getLatestData = function(testID){
        return $http({
            method:'GET',
            url:'/rest/getGraphDataForTestID',
            params:{testID:testID}
        }
        ).then(function(response){
            // success response
            return(response.data);
        });
    }
    return obj;
}
</code>```

controller code -

```<code>app.controller('dashboardCtrl',dashboardCtrl);
dashboardCtrl.$inject = ['$scope','$rootScope','getGraphData','$stateParams'];
function dashboardCtrl($scope,$rootScope,getGraphData,$stateParams){
    var testID = $stateParams.testID;
    var userID = $stateParams.userID;
    var graphData = null;
    getGraphData.getLatestData(testID).then(function(response){
        $scope.testname = response.data.testname;
        $scope.tag = response.data.tag;
        ..
        ..
        $scope.results = response.data;
        graphData = response.data;
        drawBarChart(graphData);
        drawPieChart(graphData);
    });
}
</code>```

I have number of links like following in my index page

```<code><a  ui-sref = "dashboard({userID:1,testID:197})"><b>dashboard-userid:1,graphs:197</b></a>
<a  ui-sref = "dashboard({userID:1,testID:198})"><b>dashboard-userid:1,graphs:198</b></a>
</code>```

This setup is working fine for some time, but after some time I get browser error message "browser ran out of memory to display this webpage"

Maybe because angularjs is saving previous $scope and $rootScope variables, and also creating new ones when template is reloaded...
or simply JavaScript variables are not getting deleted...
(but i am not using global variables - all are declared inside controller functions, which should have same life as that function)

How do i clear/flush these $scope/$rootScope variables and free memory...
How can i analyse memory usage of my particular page..??
Please help...

答:
There is a chrome extension which lets you analyze you angular apps for performance - Batarang.

It shows $scope and $rootScope variables as well.

Title: angularjs SPA - how to flush memory?

Body:
I am using angularjs single page app in my webpage,

following is code for spa constructor

app.config(config);
config.$inject = ['$stateProvider','$urlRouterProvider'];
function config($stateProvider,$urlRouterProvider){
    $stateProvider.state('dashboard',{
        url:'/{userID}/{testID}',
        templateUrl:'templates/dashboard.html',
        controller:'dashboardCtrl'
    });
}

template dashboard.html displays number of google graphs and charts.
In controller dashboardCtrl, I make GET/POST requests to server using $http directive, and plot google graphs using response data.

following is code for service ($http request)

app.service('getGraphData',getGraphData);
getGraphData.$inject = ['$http'];
function getGraphData($http){
    var obj = this;
    obj.getLatestData = function(testID){
        return $http({
            method:'GET',
            url:'/rest/getGraphDataForTestID',
            params:{testID:testID}
        }
        ).then(function(response){
            // success response
            return(response.data);
        });
    }
    return obj;
}

controller code -

app.controller('dashboardCtrl',dashboardCtrl);
dashboardCtrl.$inject = ['$scope','$rootScope','getGraphData','$stateParams'];
function dashboardCtrl($scope,$rootScope,getGraphData,$stateParams){
    var testID = $stateParams.testID;
    var userID = $stateParams.userID;
    var graphData = null;
    getGraphData.getLatestData(testID).then(function(response){
        $scope.testname = response.data.testname;
        $scope.tag = response.data.tag;
        ..
        ..
        $scope.results = response.data;
        graphData = response.data;
        drawBarChart(graphData);
        drawPieChart(graphData);
    });
}

I have number of links like following in my index page

dashboard-userid:1,graphs:197
dashboard-userid:1,graphs:198

This setup is working fine for some time, but after some time I get browser error message "browser ran out of memory to display this webpage"

Maybe because angularjs is saving previous $scope and $rootScope variables, and also creating new ones when template is reloaded...
or simply JavaScript variables are not getting deleted...
(but i am not using global variables - all are declared inside controller functions, which should have same life as that function)

How do i clear/flush these $scope/$rootScope variables and free memory...
How can i analyse memory usage of my particular page..??
Please help...


问:
How to compare two csv files using Robot Framework
I would like to compare difference between two csv files using robot framework .Test case should fail if there is difference and pass if there is no difference.I have tried DiffLibrary in Robot framework but is returning pass status when records are not sorted. Can someone guide me how this can be achieved or if there is any alternative way to do this.

My first.csv file is having data like below

```<code>Benchmark Name,Policy Name,No of Rules,Policy Measurement SLO,Policy Remediation SLO,No of Rules Compliant in MSLO,No of Rules Non-Compliant in RSLO,No of Rules Non-Compliant OUT RSLO
CIS Red Hat Enterprise Linux 6 Benchmark v1.0.0,PCI,281,1 MONTHS,1 MONTHS,150,130
CIS Red Hat Enterprise Linux 7 Benchmark v1.2.0,PCI,281,5 MONTHS,1 MONTHS,150,137
CIS Red Hat Enterprise Linux 7 Benchmark v1.5.0,PCI,281,1 MONTHS,1 MONTHS,150,135
</code>```

And my second.csv file is having data like below

```<code>Benchmark Name,Policy Name,No of Rules,Policy Measurement SLO,Policy Remediation SLO,No of Rules Compliant in MSLO,No of Rules Non-Compliant in RSLO,No of Rules Non-Compliant OUT RSLO
CIS Red Hat Enterprise Linux 7 Benchmark v1.2.0,PCI,281,5 MONTHS,1 MONTHS,150,137
CIS Red Hat Enterprise Linux 6 Benchmark v1.0.0,PCI,281,1 MONTHS,1 MONTHS,150,130
CIS Red Hat Enterprise Linux 7 Benchmark v1.5.0,PCI,281,1 MONTHS,1 MONTHS,150,135
</code>```

Robot code is below

```<code>*** Settings ***
Library  DiffLibrary
Library  OperatingSystem

*** Test Cases ***

Diffing two files one being different
    Run Keyword And Expect Error  differences*  Diff Files  first.csv  second.csv
</code>```

答:
How about just using BuiltIn's Should Be Equal As Strings?

```<code># Using Get File you easily get a file's content into a string variable
${csvA} =    Get File    ${filePathA}
${csvB} =    Get File    ${filePathB}
Should Be Equal As Strings    ${csvA}    ${csvB}
</code>```

I use that model for comparing lines only, you might need to edit the file string in case there's difference in file encoding (BOM leaves a special BOM character in the beginning of the file, etc.)

Body:
I would like to compare difference between two csv files using robot framework .Test case should fail if there is difference and pass if there is no difference.I have tried DiffLibrary in Robot framework but is returning pass status when records are not sorted. Can someone guide me how this can be achieved or if there is any alternative way to do this.

My first.csv file is having data like below

Benchmark Name,Policy Name,No of Rules,Policy Measurement SLO,Policy Remediation SLO,No of Rules Compliant in MSLO,No of Rules Non-Compliant in RSLO,No of Rules Non-Compliant OUT RSLO
CIS Red Hat Enterprise Linux 6 Benchmark v1.0.0,PCI,281,1 MONTHS,1 MONTHS,150,130
CIS Red Hat Enterprise Linux 7 Benchmark v1.2.0,PCI,281,5 MONTHS,1 MONTHS,150,137
CIS Red Hat Enterprise Linux 7 Benchmark v1.5.0,PCI,281,1 MONTHS,1 MONTHS,150,135

And my second.csv file is having data like below

Benchmark Name,Policy Name,No of Rules,Policy Measurement SLO,Policy Remediation SLO,No of Rules Compliant in MSLO,No of Rules Non-Compliant in RSLO,No of Rules Non-Compliant OUT RSLO
CIS Red Hat Enterprise Linux 7 Benchmark v1.2.0,PCI,281,5 MONTHS,1 MONTHS,150,137
CIS Red Hat Enterprise Linux 6 Benchmark v1.0.0,PCI,281,1 MONTHS,1 MONTHS,150,130
CIS Red Hat Enterprise Linux 7 Benchmark v1.5.0,PCI,281,1 MONTHS,1 MONTHS,150,135

Robot code is below

*** Settings ***
Library  DiffLibrary
Library  OperatingSystem

*** Test Cases ***

Diffing two files one being different
    Run Keyword And Expect Error  differences*  Diff Files  first.csv  second.csv

Body:
How about just using BuiltIn's Should Be Equal As Strings?

# Using Get File you easily get a file's content into a string variable
${csvA} =    Get File    ${filePathA}
${csvB} =    Get File    ${filePathB}
Should Be Equal As Strings    ${csvA}    ${csvB}

I use that model for comparing lines only, you might need to edit the file string in case there's difference in file encoding (BOM leaves a special BOM character in the beginning of the file, etc.)


问:
undefined number after removing special characters javascript
The string - USD 255,012
I only just need numbers 255012
I am using a method  getNumbers(str) to remove the text USD and , or any dot .

Function is getting fine but return value from function is NAN.

I am using this method

```<code>function getNumbers(str)
{
  return parseInt(str.replace(/[^0-9]/g, "")); // it will get only numbers.
}
</code>```

Whenever I use above method

```<code> var piInput = getNumbers( 1,50.00 );
</code>```

return value in variable piInput  is undefined type why is that?

my jsfiddle link
https://jsfiddle.net/c0x7wko3/

not sure why it is not showing the result.

My method detecting type of variable.

```<code>   function getTypeofVariable( msg ,  myvar ) {

    if ( typeof myvar === 'string' )
    {
        alert(msg + myvar + " is STRING type vairable " );
    }
    if ( typeof myvar === 'number' )
    {
        alert(msg + myvar + " is number type vairable " );
    }
    if ( typeof myvar === 'boolean' )
    {
        alert(msg + myvar + " is boolean type vairable " );
    }
        if ( typeof myvar === 'symbol' )
    {
        alert(msg + myvar + " is symbol type vairable " );
    }
        if ( typeof myvar === 'object' )
    {
        alert(msg + myvar + " is object type vairable " );
    }
        if ( typeof myvar === 'undefined' )
    {
        alert(msg + myvar + " is undefined type vairable " );
    }

    if ( typeof myvar === 'number' )
    {
        alert(msg + myvar + " is number type vairable " );
    }
}
</code>```

答:
Pass string to getNumbers and there is also some syntax errors please check out that too:</p>

```<code>function getNumbers(str)
{
    return (str.replace(/[^0-9]/g, ""));
}

var piInput = getNumbers( "1,50.00" );
alert(piInput);
</code>```

Body:
The string - USD 255,012
I only just need numbers 255012
I am using a method  getNumbers(str) to remove the text USD and , or any dot .

Function is getting fine but return value from function is NAN.

I am using this method

function getNumbers(str)
{
  return parseInt(str.replace(/[^0-9]/g, "")); // it will get only numbers.
}

Whenever I use above method

 var piInput = getNumbers( 1,50.00 );

return value in variable piInput  is undefined type why is that?

my jsfiddle link
https://jsfiddle.net/c0x7wko3/

not sure why it is not showing the result.

My method detecting type of variable.

   function getTypeofVariable( msg ,  myvar ) {

    if ( typeof myvar === 'string' )
    {
        alert(msg + myvar + " is STRING type vairable " );
    }
    if ( typeof myvar === 'number' )
    {
        alert(msg + myvar + " is number type vairable " );
    }
    if ( typeof myvar === 'boolean' )
    {
        alert(msg + myvar + " is boolean type vairable " );
    }
        if ( typeof myvar === 'symbol' )
    {
        alert(msg + myvar + " is symbol type vairable " );
    }
        if ( typeof myvar === 'object' )
    {
        alert(msg + myvar + " is object type vairable " );
    }
        if ( typeof myvar === 'undefined' )
    {
        alert(msg + myvar + " is undefined type vairable " );
    }

    if ( typeof myvar === 'number' )
    {
        alert(msg + myvar + " is number type vairable " );
    }
}

Body:
Pass string to getNumbers and there is also some syntax errors please check out that too:

function getNumbers(str)
{
    return (str.replace(/[^0-9]/g, ""));
}

var piInput = getNumbers( "1,50.00" );
alert(piInput);


问:
How to edit file online which is saved on Azure Storage
I am saving files on Azure file storage. I want to update these files online from my web application. How can I do that?</p>

答:
You need to build a suitable application either Web based or Desktop based. All the crud operations you can perform via accessing the APIs of Blob.

You can refer Azure Storage Sample Repository for get complete understanding about how to perform each tasks with blobs. Ex: Append, Copy, Delete Blobs etc..

https://learn.microsoft.com/en-us/azure/storage/storage-samples-dotnet

Also refer following links for additional information.

https://learn.microsoft.com/en-us/azure/storage/storage-dotnet-how-to-use-blobs
https://azure.microsoft.com/en-us/resources/samples/storage-blob-dotnet-getting-started


问:
PHP nested ternary if condition
```<code><?php
$var = 4;
echo $current = ($var > 2) ? "gr than 2" : ($var > 6) ? "gr than 6" : "not gr than 2 or 6";
?>
</code>```

for the above code, it always returns - gr than 6. Can someone please suggest what did I wrong?

答:
use below code</p>

```<code><?php
$var = 4;
echo $current = (($var > 2) ? "gr than 2" : (($var > 6) ? "gr than 6" : "not gr than 2 or 6") );
?>
</code>```

Title: PHP nested ternary if condition

Body:
<?php
$var = 4;
echo $current = ($var > 2) ? "gr than 2" : ($var > 6) ? "gr than 6" : "not gr than 2 or 6";
?>

for the above code, it always returns - gr than 6. Can someone please suggest what did I wrong?

Body:
use below code

<?php
$var = 4;
echo $current = (($var > 2) ? "gr than 2" : (($var > 6) ? "gr than 6" : "not gr than 2 or 6") );
?>


问:
How to ajax call a php file hosted on remote server and receive a response?
We are trying to call from index.html on local, a simple PHP file hosted on webhost000 to receive a response. PHP file is:

```<code><?php
if (isset($_POST['name'])) {
    $name = $_POST['name'];
    echo ($name);
}
?>
</code>```

We would like to simply input a character on a textbox in html.index and receive the same character as response from the php. We are using an ajax call to do this in html file:

```<code><script>
    $(document).ready(function() {
        $('#name').keyup(function() {
        var name = $('#name').val();
        var request = $.ajax({
              url: "https://nedo93.000webhostapp.com/phpdemo.php",
              method: "POST",
              data: { name : name },
              dataType: "html"
            });

            request.done(function( msg ) {
              alert( "Request done: " + msg );
            });

            request.fail(function( jqXHR, textStatus ) {
              alert( "Request failed: " + textStatus );
            });
        });
    });
    </script>
</code>```

(The remaining html should not be important, it works perfectly, tested and retested)

If we try to debug this we can see that the file is found, the request is sent, but we can't receive a response: screenshot

If we use this browser function instead, we can send data and receive a response without a problem, don't know if this can help.

Thank you in advance if you can answer this question.

答:
use json_encode

your code should be....

```<code><?php
if (isset($_POST['name'])) {
    $name = $_POST['name'];
    header('Content-Type: application/json'); //just used as info for your application
    echo json_encode($name); //encode to JSON object
}
?>
</code>```

after that do JQuery validation for checking Json reply (specially for error).

Body:
We are trying to call from index.html on local, a simple PHP file hosted on webhost000 to receive a response. PHP file is:

<?php
if (isset($_POST['name'])) {
    $name = $_POST['name'];
    echo ($name);
}
?>

We would like to simply input a character on a textbox in html.index and receive the same character as response from the php. We are using an ajax call to do this in html file:

(The remaining html should not be important, it works perfectly, tested and retested)

If we try to debug this we can see that the file is found, the request is sent, but we can't receive a response: screenshot

If we use this browser function instead, we can send data and receive a response without a problem, don't know if this can help.

Thank you in advance if you can answer this question.

Body:
use json_encode

your code should be....

<?php
if (isset($_POST['name'])) {
    $name = $_POST['name'];
    header('Content-Type: application/json'); //just used as info for your application
    echo json_encode($name); //encode to JSON object
}
?>

after that do JQuery validation for checking Json reply (specially for error).


问:
How to select a value from Dropdown without using SELECT statement
In my automation suite I want to select a value from dropdown without using SELECT statement. Can someone please help me out with this.

Example:
I want to select a country name(India) from dropdown and I should not be using SELECT here.

Automation suite(Selenium with java)

Code:

```<code><div id="pie_register_reg_form">
    <form id="pie_regiser_form" enctype="multipart/form-data" method="post" action="/registration/">
    <ul id="pie_register">
    <div class="fieldset">
    <label for="dropdown_7">Country</label>
        <select id="dropdown_7" class="piereg_validate[required]" name="dropdown_7">
        <option value="Afghanistan">Afghanistan</option>
        <option value="Albania">Albania</option>
        <option value="Algeria">Algeria</option>
        …
        <option value="India">India</option>
        …
        <option value="Zambia">Zambia</option>
        <option value="Zimbabwe">Zimbabwe</option>
        </select>
    </div>
</li>
</code>```

I can select India from dropdown using the below code.

```<code>Select select = new Select(driver.findElement(By.xpath("path of the dropdown")));
select.selectByVisibleText("India");
</code>```

But I don't want to use Select here. Is there any other way to select India from dropdown.

Thanks in Advance

答:
```<code>driver.findElement(By.xpath("//path of dropdown"));

List<WebElement> allOptions = driver.findElements(By.xpath("//select[@id='xxxxx']//option")); //get all the options from the dropdown

for(WebElement option : allOptions) {
if (option.getText().equals("India"))
{

option.click();

}

}
</code>```

This code can be used

Body:
In my automation suite I want to select a value from dropdown without using SELECT statement. Can someone please help me out with this.

Example:
I want to select a country name(India) from dropdown and I should not be using SELECT here.

Automation suite(Selenium with java)

Code:

    <form id="pie_regiser_form" enctype="multipart/form-data" method="post" action="/registration/">

    Country
        <select id="dropdown_7" class="piereg_validate[required]" name="dropdown_7">
        <option value="Afghanistan">Afghanistan</option>
        <option value="Albania">Albania</option>
        <option value="Algeria">Algeria</option>
        …
        <option value="India">India</option>
        …
        <option value="Zambia">Zambia</option>
        <option value="Zimbabwe">Zimbabwe</option>
        </select>

I can select India from dropdown using the below code.

Select select = new Select(driver.findElement(By.xpath("path of the dropdown")));
select.selectByVisibleText("India");

But I don't want to use Select here. Is there any other way to select India from dropdown.

Thanks in Advance

Body:
driver.findElement(By.xpath("//path of dropdown"));

List<WebElement> allOptions = driver.findElements(By.xpath("//select[@id='xxxxx']//option")); //get all the options from the dropdown

for(WebElement option : allOptions) {
if (option.getText().equals("India"))
{

option.click();

}

}

This code can be used


问:
Not able to install apple watch app
I created an application for Apple watch Model MJ3T2B/A using health kit. It is with watch OS version 2.0. I used Xcode version 7.3.1 to create the app and installed it in my iPhone using diawi. I am not able to run it directly since it said deployment version of watch app is 2.2 and the one i am using is 2.0.

When i enable Show App in Apple Watch it is automatically getting disabled after some time in iPhone(iOS 9.3.2) watch application. Do i need to use different xcode version to create my app? I am not getting any OS updates also in my iPhone app. It says watch OS 2.0 and software is upto date.

答: I got what was the issue. It is the deployment target which keeps me from installing the watch app. I changed the deployment target to 2.0 in Project->Build settings and now i am able to install the application</p>

Title: Not able to install apple watch app


问:
Not a single angular directive working in this code.The function define in submit button does not work
I have tried many angular directive in this code but none of them is
          working. Is there any library file is missing or something wrong in
          this code  or is there any effect due to jQuery file.
           The complete code is define below:</p>

```<code>        <!DOCTYPE html>
<html ng-app="myapp" ng-controller="ticketcontroller">

<head>
    <title>Ticket</title>

    <link href="css/style.css" rel="stylesheet"
    type="text/css" media="all" />
    <link rel="stylesheet" href="css/flexslider.css"
    type="text/css" media="screen" property=""
    />
    <link rel="stylesheet" href="css/flexslider.css"
    type="text/css" media="screen" property=""
    />
    <script src="js/jquery-2.2.3.min.js"></script>
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js">
    </script>
    <link href="//fonts.googleapis.com/css?family=Montserrat:400,700"
    rel="stylesheet">
</head>

<body>
    <div class="main">
        <h1>Ticket Details Forum</h1>

        <div class="w3_agile_main_grids">
            <section class="slider">
                <div class="flexslider">

                    <div class="agileits_w3layouts_main_grid">
                        <h3>Service Details</h3>
                        <form>
                            <span>
                                         <label>Category</label>
                                         <select  required="" ng-
                                          model="service">
                                             <option value="">Laptop
                                            Repair</option>
                                             <option value="">Refrigerator
                                             repair</option>
                                             <option value="">Microwave
                                                  repair</option>

                                         </select>
                                     </span>
                            <span>
                                         <label>Priority</label>
                                         <select  required="" ng-
                                           model="priority">
                                             <option value="">Low</option>
                                             <option
                                          value="">Normal</option>
                                             <option value="">High</option>

                                         </select>
                                     </span>

                            <span>
                                         <label>Description</label>
                                        <input name="description"
    type="text" placeholder="Enter Description here" ng-model="description">
                                     </span>

                            <div class="w3_agileits_submit">

                                <button class="btn btn-success" ng- click="submitdata()">submit</button>

                            </div>

                        </form>
                    </div>
            </section>
            </div>

        </div>

        <!-- flexSlider -->
        <script defer src="js/jquery.flexslider.js"></script>
        <script type="text/javascript">
            $(window).load(function() {
                $('.flexslider')
                    .flexslider({
                        animation: "slide",
                        start: function(
                            slider
                        ) {
                            $
                                (
                                    'body'
                                )
                                .removeClass(
                                    'loading'
                                );
                        }
                    });
            });
        </script>

</body>

</html>

<script>
    var ap = angular.module("myapp", []);
    ap.controller("ticketcontroller", [
                '$scope', '$http',
                '$window',
                function($scope, $http,
                    $window) {
                    $scope.submitdata =
                        function() {
                            $window.alert(
                                "dhbhhfgh);
                            }
                        }]);
</script>
</code>```

答:
Corrected just with the angular directive, add flexslider later.

```<code>     <!DOCTYPE html>
<html ng-app="myapp">
<head>
<title>Ticket</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script>
    <!--<script src="controllers.js"></script>-->
    <!--this (under) should be into controllers.js-->
    <script>
      var apk = angular.module('myapp', []);
  apk.controller("ticketcontroller",function($scope,$http,$window){
      var service;
      var priority;
      var description;
   $scope.submitdata=function(){
            var vm = this;
            service = vm.service;
            priority = vm.priority;
            description = vm.description;
            alert("this is my desc: /"+service+"/ with priority: /"+priority+"/ and description: /"+description+"/");
   }
  });
  </script>
  <!-- I REMOVED ALL FLEXSLIDER FROM THIS CODE PUT IT BACK -->
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js"></script>
  </script>
 </head>
 <body  ng-controller="ticketcontroller" >
            <div class="main">
            <h1>Ticket Details Forum</h1>

            <div class="w3_agile_main_grids">
            <section class="slider">
            <div class="flexslider">

            <div class="agileits_w3layouts_main_grid">
            <h3>Service Details</h3>
            <form action="#">
            <span>
            <label>Category</label>
            <select  required="" ng-model="service">
            <option>Laptop Repair</option>
            <option>Refrigerator repair</option>
            <option>Microwave repair</option>
            </select>
            </span>
            <span>
            <label>Priority</label>
            <select  required="" ng-model="priority">
            <option>Low</option>
            <option>Normal</option>
            <option>High</option>
              <!-- BE AWARE, I REMOVED VALUE FROM OPTION IN CONTROLLER -->
            </select>
            </span>
            <span>
            <label>Description</label>
            <input name="description" type="text" placeholder="Enter Description here" ng-model="description"> </input>
            </span>

            <div class="w3_agileits_submit">
            <button class="btn btn-success" ng-click="submitdata()">submit</button>
            </div>
            </form>
                </div>
                </section>
                </div>
                </div>
        </body>
  </html>
</code>```

works like a charm. Copy paste and try, remember you had different script-links, update mine to your needs.

Body:
I have tried many angular directive in this code but none of them is
          working. Is there any library file is missing or something wrong in
          this code  or is there any effect due to jQuery file.
           The complete code is define below:

        <!DOCTYPE html>

    <title>Ticket</title>

    <link href="css/style.css" rel="stylesheet"
    type="text/css" media="all" />
    <link rel="stylesheet" href="css/flexslider.css"
    type="text/css" media="screen" property=""
    />
    <link rel="stylesheet" href="css/flexslider.css"
    type="text/css" media="screen" property=""
    />

    <link href="css/bootstrap.min.css" rel="stylesheet">

    <link href="//fonts.googleapis.com/css?family=Montserrat:400,700"
    rel="stylesheet">

Ticket Details Forum

Service Details

                        <form>

                                         Category
                                         <select  required="" ng-
                                          model="service">
                                             <option value="">Laptop
                                            Repair</option>
                                             <option value="">Refrigerator
                                             repair</option>
                                             <option value="">Microwave
                                                  repair</option>

                                         </select>

                                         Priority
                                         <select  required="" ng-
                                           model="priority">
                                             <option value="">Low</option>
                                             <option
                                          value="">Normal</option>
                                             <option value="">High</option>

                                         </select>

                                         Description
                                        <input name="description"
    type="text" placeholder="Enter Description here" ng-model="description">

                                <button class="btn btn-success" ng- click="submitdata()">submit</button>

                        </form>

Body:
Corrected just with the angular directive, add flexslider later.

     <!DOCTYPE html>
<html ng-app="myapp">
<head>
<title>Ticket</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script>
    <!--<script src="controllers.js"></script>-->
    <!--this (under) should be into controllers.js-->
    <script>
      var apk = angular.module('myapp', []);
  apk.controller("ticketcontroller",function($scope,$http,$window){
      var service;
      var priority;
      var description;
   $scope.submitdata=function(){
            var vm = this;
            service = vm.service;
            priority = vm.priority;
            description = vm.description;
            alert("this is my desc: /"+service+"/ with priority: /"+priority+"/ and description: /"+description+"/");
   }
  });
  </script>
  <!-- I REMOVED ALL FLEXSLIDER FROM THIS CODE PUT IT BACK -->
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js"></script>
  </script>
 </head>
 <body  ng-controller="ticketcontroller" >
            <div class="main">
            <h1>Ticket Details Forum</h1>

            <div class="w3_agile_main_grids">
            <section class="slider">
            <div class="flexslider">

            <div class="agileits_w3layouts_main_grid">
            <h3>Service Details</h3>
            <form action="#">
            <span>
            <label>Category</label>
            <select  required="" ng-model="service">
            <option>Laptop Repair</option>
            <option>Refrigerator repair</option>
            <option>Microwave repair</option>
            </select>
            </span>
            <span>
            <label>Priority</label>
            <select  required="" ng-model="priority">
            <option>Low</option>
            <option>Normal</option>
            <option>High</option>
              <!-- BE AWARE, I REMOVED VALUE FROM OPTION IN CONTROLLER -->
            </select>
            </span>
            <span>
            <label>Description</label>
            <input name="description" type="text" placeholder="Enter Description here" ng-model="description"> </input>
            </span>

            <div class="w3_agileits_submit">
            <button class="btn btn-success" ng-click="submitdata()">submit</button>
            </div>
            </form>
                </div>
                </section>
                </div>
                </div>
        </body>
  </html>

works like a charm. Copy paste and try, remember you had different script-links, update mine to your needs.


问:
How to compile PHP to make it independend from system libraries?
I need a standalone independent-from-system-libraries version of PHP to be able to distribute it as a .zip file containing binaries. Previously the .zip was containing libxml2.so.2, libpng12.so.0, php.ini and php executable.
Recently I needed to add some functionalities and recompile the PHP. I did it with:

```<code>./configure \
    --prefix=/home/user/php/out \
    --libdir=. \
    --enable-static=YES \
    --enable-shared=NO \
    --with-pdo_mysql \
    --with-gd \
    --with-mysql \
    --enable-zip \
    --enable-zend-multibyte \
    --enable-cgi \
    --enable-fastcgi \
    --with-ldap=shared
make && make install
</code>```

Then I took php from out/bin and libmysqlclient.so.16 from /usr/lib/. But the new php doesn't want to pick up the library. Once I run it I get the following error:

```<code>./php: error while loading shared libraries: libmysqlclient.so.16: cannot open shared object file: No such file or directory
</code>```

libmysqlclient.so.16 and php are in the same directory. If i put libmysqlclient.so.16 to /usr/lib, php works fine.

Is there any additional option that I've forgotten about during compilation? Why isn't the "--libdir=." option working?

答:
Maybe you could use XAMPP and save yourself sometime? It comes prepackaged and pretty portable.

http://www.apachefriends.org/en/xampp.html

Body:
I need a standalone independent-from-system-libraries version of PHP to be able to distribute it as a .zip file containing binaries. Previously the .zip was containing libxml2.so.2, libpng12.so.0, php.ini and php executable.
Recently I needed to add some functionalities and recompile the PHP. I did it with:

./configure \
    --prefix=/home/user/php/out \
    --libdir=. \
    --enable-static=YES \
    --enable-shared=NO \
    --with-pdo_mysql \
    --with-gd \
    --with-mysql \
    --enable-zip \
    --enable-zend-multibyte \
    --enable-cgi \
    --enable-fastcgi \
    --with-ldap=shared
make && make install

Then I took php from out/bin and libmysqlclient.so.16 from /usr/lib/. But the new php doesn't want to pick up the library. Once I run it I get the following error:

./php: error while loading shared libraries: libmysqlclient.so.16: cannot open shared object file: No such file or directory

libmysqlclient.so.16 and php are in the same directory. If i put libmysqlclient.so.16 to /usr/lib, php works fine.

Is there any additional option that I've forgotten about during compilation? Why isn't the "--libdir=." option working?


问:
PHP replace 2nd occurrence of word
I have sentence in my text file like below.

The quick brown fox jumps over the lazy fox.

How do I replace the second occurrence of "fox" with some other word like "dog" in PHP.

The result should be

The quick brown fox jumps over the lazy dog.

'How to replace a nth occurrence in a string', this question is for how to replace (for eg) 2nd character in a string but my question is replace 2nd word in a sentence.

答:
this function help you to replace last occurrence </p>

```<code>echo str_lreplace('fox','dog','The quick brown fox jumps over the lazy fox.');
function str_lreplace($search, $replace, $subject)
{
$pos = strrpos($subject, $search);

if($pos !== false)
{
    $subject = substr_replace($subject, $replace, $pos, strlen($search));
}

return $subject;
}
</code>```

Title: PHP replace 2nd occurrence of word

Body:
this function help you to replace last occurrence

echo str_lreplace('fox','dog','The quick brown fox jumps over the lazy fox.');
function str_lreplace($search, $replace, $subject)
{
$pos = strrpos($subject, $search);

if($pos !== false)
{
    $subject = substr_replace($subject, $replace, $pos, strlen($search));
}

return $subject;
}


问:
Supported html tags on Android TextView
I need an official list of supported HTML tags on Android TextView.
I'm using textView.setText(Html.fromHtml(label)); but I don't know which tags are supported.

答:
Note:

This targets API 27. Earlier versions are NOT guaranteed to support the tags seen in this list, and same for later ones (they could be removed). See the equivalent class for the applicable API versions for the applicable list.

It seems these aren't documented anywhere (correction, 2021: no longer the case), and there isn't a concrete list of when tags are added (2021: this still appears to be the case). I figured the HTML tags would need to be declared somewhere, if not in the docs, at least in the code. Fortunately, Android's HTML parsing is straight-forward enough to easily understand the relevant bits without dumpster-diving too much.

For future versions: you can either use IntelliJ or some other IDE to explore the source code of Html.java, or you can always go to the AOSP site or the equivalent GitHub repository. Using an IDE is potentially the easiest option.

Html#fromHtml(String, int) calls Html#fromHtml(String, Int, ImageGetter, TagHandler. The last method creates a HtmlToSpannedConverter, and returns the result of the conversion. I dug into that code, and I found this method:

```<code>private void handleStartTag(String tag, Attributes attributes) {
</code>```

```<code>    if (tag.equalsIgnoreCase("br")) {
        // We don't need to handle this. TagSoup will ensure that there's a </br> for each <br>
        // so we can safely emit the linebreaks when we handle the close tag.
    } else if (tag.equalsIgnoreCase("p")) {
        startBlockElement(mSpannableStringBuilder, attributes, getMarginParagraph());
        startCssStyle(mSpannableStringBuilder, attributes);
    } else if (tag.equalsIgnoreCase("ul")) {
        startBlockElement(mSpannableStringBuilder, attributes, getMarginList());
    } else if (tag.equalsIgnoreCase("li")) {
        startLi(mSpannableStringBuilder, attributes);
    } else if (tag.equalsIgnoreCase("div")) {
        startBlockElement(mSpannableStringBuilder, attributes, getMarginDiv());
    } else if (tag.equalsIgnoreCase("span")) {
        startCssStyle(mSpannableStringBuilder, attributes);
    } else if (tag.equalsIgnoreCase("strong")) {
        start(mSpannableStringBuilder, new Bold());
    } else if (tag.equalsIgnoreCase("b")) {
        start(mSpannableStringBuilder, new Bold());
    } else if (tag.equalsIgnoreCase("em")) {
        start(mSpannableStringBuilder, new Italic());
    } else if (tag.equalsIgnoreCase("cite")) {
        start(mSpannableStringBuilder, new Italic());
    } else if (tag.equalsIgnoreCase("dfn")) {
        start(mSpannableStringBuilder, new Italic());
    } else if (tag.equalsIgnoreCase("i")) {
        start(mSpannableStringBuilder, new Italic());
    } else if (tag.equalsIgnoreCase("big")) {
        start(mSpannableStringBuilder, new Big());
    } else if (tag.equalsIgnoreCase("small")) {
        start(mSpannableStringBuilder, new Small());
    } else if (tag.equalsIgnoreCase("font")) {
        startFont(mSpannableStringBuilder, attributes);
    } else if (tag.equalsIgnoreCase("blockquote")) {
        startBlockquote(mSpannableStringBuilder, attributes);
    } else if (tag.equalsIgnoreCase("tt")) {
        start(mSpannableStringBuilder, new Monospace());
    } else if (tag.equalsIgnoreCase("a")) {
        startA(mSpannableStringBuilder, attributes);
    } else if (tag.equalsIgnoreCase("u")) {
        start(mSpannableStringBuilder, new Underline());
    } else if (tag.equalsIgnoreCase("del")) {
        start(mSpannableStringBuilder, new Strikethrough());
    } else if (tag.equalsIgnoreCase("s")) {
        start(mSpannableStringBuilder, new Strikethrough());
    } else if (tag.equalsIgnoreCase("strike")) {
        start(mSpannableStringBuilder, new Strikethrough());
    } else if (tag.equalsIgnoreCase("sup")) {
        start(mSpannableStringBuilder, new Super());
    } else if (tag.equalsIgnoreCase("sub")) {
        start(mSpannableStringBuilder, new Sub());
    } else if (tag.length() == 2 &&
            Character.toLowerCase(tag.charAt(0)) == 'h' &&
            tag.charAt(1) >= '1' && tag.charAt(1) <= '6') {
        startHeading(mSpannableStringBuilder, attributes, tag.charAt(1) - '1');
    } else if (tag.equalsIgnoreCase("img")) {
        startImg(mSpannableStringBuilder, attributes, mImageGetter);
    } else if (mTagHandler != null) {
        mTagHandler.handleTag(true, tag, mSpannableStringBuilder, mReader);
    }
}
</code>```

Which does contain all of the supported HTML tags. This list might change in future versions (it did from the original answer I had), but you can dig through the source yourself to find it in later versions. With the above code, this is the currently supported list:

br
p
ul
li
div
span
strong
b
em
cite
dfn
i
big
small
font
blockquote
tt
a
u
del
s
strike
sub
sup
img
h1
h2
h3
h4
h5
h6
```
<p>Further methods cover supported attributes (in <code></code>, <code>href</code> is an attribute):</p>
<hr />
<p>img:</p>
```src
```
<hr />
<p>font:</p>
```color
face
```
<p><code>size</code> is apparently not supported.</p>
<hr />
<p>a:</p>
```href
```
<hr />
<p>p, ul, and div calls startBlockElement, which gives one attrib:</p>
```text-align
```
<p>Something special worth noting about this is the supported align variables.</p>
<ul>
<li>center - standard and self-explanatory</li>
<li>start - aligns left</li>
<li>end - aligns right</li>
</ul>
<p>start and end might be inverted in RTL layouts - I haven't tested.</p>
<hr />
<p>span and p, and li calls startCssStyle, which gives access to the href="https://www.w3schools.com/html/html_styles.asp" rel="nofollow noreferrer">following <code>style</code> attributes:</p>
```text-decoration
background-color or background
color
```

text-decoration seems to be limited to line-through.

Title: Supported html tags on Android TextView

Body:
Note:

This targets API 27. Earlier versions are NOT guaranteed to support the tags seen in this list, and same for later ones (they could be removed). See the equivalent class for the applicable API versions for the applicable list.

It seems these aren't documented anywhere (correction, 2021: no longer the case), and there isn't a concrete list of when tags are added (2021: this still appears to be the case). I figured the HTML tags would need to be declared somewhere, if not in the docs, at least in the code. Fortunately, Android's HTML parsing is straight-forward enough to easily understand the relevant bits without dumpster-diving too much.

For future versions: you can either use IntelliJ or some other IDE to explore the source code of Html.java, or you can always go to the AOSP site or the equivalent GitHub repository. Using an IDE is potentially the easiest option.

Html#fromHtml(String, int) calls Html#fromHtml(String, Int, ImageGetter, TagHandler. The last method creates a HtmlToSpannedConverter, and returns the result of the conversion. I dug into that code, and I found this method:

private void handleStartTag(String tag, Attributes attributes) {

    if (tag.equalsIgnoreCase("br")) {
        // We don't need to handle this. TagSoup will ensure that there's a </br> for each <br>
        // so we can safely emit the linebreaks when we handle the close tag.
    } else if (tag.equalsIgnoreCase("p")) {
        startBlockElement(mSpannableStringBuilder, attributes, getMarginParagraph());
        startCssStyle(mSpannableStringBuilder, attributes);
    } else if (tag.equalsIgnoreCase("ul")) {
        startBlockElement(mSpannableStringBuilder, attributes, getMarginList());
    } else if (tag.equalsIgnoreCase("li")) {
        startLi(mSpannableStringBuilder, attributes);
    } else if (tag.equalsIgnoreCase("div")) {
        startBlockElement(mSpannableStringBuilder, attributes, getMarginDiv());
    } else if (tag.equalsIgnoreCase("span")) {
        startCssStyle(mSpannableStringBuilder, attributes);
    } else if (tag.equalsIgnoreCase("strong")) {
        start(mSpannableStringBuilder, new Bold());
    } else if (tag.equalsIgnoreCase("b")) {
        start(mSpannableStringBuilder, new Bold());
    } else if (tag.equalsIgnoreCase("em")) {
        start(mSpannableStringBuilder, new Italic());
    } else if (tag.equalsIgnoreCase("cite")) {
        start(mSpannableStringBuilder, new Italic());
    } else if (tag.equalsIgnoreCase("dfn")) {
        start(mSpannableStringBuilder, new Italic());
    } else if (tag.equalsIgnoreCase("i")) {
        start(mSpannableStringBuilder, new Italic());
    } else if (tag.equalsIgnoreCase("big")) {
        start(mSpannableStringBuilder, new Big());
    } else if (tag.equalsIgnoreCase("small")) {
        start(mSpannableStringBuilder, new Small());
    } else if (tag.equalsIgnoreCase("font")) {
        startFont(mSpannableStringBuilder, attributes);
    } else if (tag.equalsIgnoreCase("blockquote")) {
        startBlockquote(mSpannableStringBuilder, attributes);
    } else if (tag.equalsIgnoreCase("tt")) {
        start(mSpannableStringBuilder, new Monospace());
    } else if (tag.equalsIgnoreCase("a")) {
        startA(mSpannableStringBuilder, attributes);
    } else if (tag.equalsIgnoreCase("u")) {
        start(mSpannableStringBuilder, new Underline());
    } else if (tag.equalsIgnoreCase("del")) {
        start(mSpannableStringBuilder, new Strikethrough());
    } else if (tag.equalsIgnoreCase("s")) {
        start(mSpannableStringBuilder, new Strikethrough());
    } else if (tag.equalsIgnoreCase("strike")) {
        start(mSpannableStringBuilder, new Strikethrough());
    } else if (tag.equalsIgnoreCase("sup")) {
        start(mSpannableStringBuilder, new Super());
    } else if (tag.equalsIgnoreCase("sub")) {
        start(mSpannableStringBuilder, new Sub());
    } else if (tag.length() == 2 &&
            Character.toLowerCase(tag.charAt(0)) == 'h' &&
            tag.charAt(1) >= '1' && tag.charAt(1) <= '6') {
        startHeading(mSpannableStringBuilder, attributes, tag.charAt(1) - '1');
    } else if (tag.equalsIgnoreCase("img")) {
        startImg(mSpannableStringBuilder, attributes, mImageGetter);
    } else if (mTagHandler != null) {
        mTagHandler.handleTag(true, tag, mSpannableStringBuilder, mReader);
    }
}

Which does contain all of the supported HTML tags. This list might change in future versions (it did from the original answer I had), but you can dig through the source yourself to find it in later versions. With the above code, this is the currently supported list:

br
p
ul
li
div
span
strong
b
em
cite
dfn
i
big
small
font
blockquote
tt
a
u
del
s
strike
sub
sup
img
h1
h2
h3
h4
h5
h6

Further methods cover supported attributes (in <a href="">, href is an attribute):

img:

src

font:

color
face

size is apparently not supported.

a:

href

p, ul, and div calls startBlockElement, which gives one attrib:

text-align

Something special worth noting about this is the supported align variables.

center - standard and self-explanatory

start - aligns left

end - aligns right

start and end might be inverted in RTL layouts - I haven't tested.

span and p, and li calls startCssStyle, which gives access to the following style attributes:

text-decoration
background-color or background
color

text-decoration seems to be limited to line-through.


问:
gitlab: how to change(reset) user info in terminal, and https push restricted
If I have a gitlab account,
username: account1
email: email1@outlook.con

the initial setting in terminal:

```<code>git config --global user.name account1
git config --global user.email email1@outlook.con
</code>```

if I have another one gitlab account,
username: account2
email: email2@outlook.con

when I change the user info in termal:

```<code>git config --global user.name account2
git config --global user.email email2@outlook.con
</code>```

I push file to gitlab , the "Activity" info still show account1.

and I push file by tortoisegit through https path.

I found that even deleted the SSH KEY in gitlab, can still be to push file by https path.

I need to reset?
How can I do?

＊I removed the git and re-installed, and found that the user information still exists...

答:
Author/committer info (name+email) is written in every commit. The info is copied to commits from config so you have to edit config before making commits.

If you have made a mistake and want to change author/committer name — see https://stackoverflow.com/a/750182/7976758.

If you have two different identities I recommend to put them into different git config files — one global and one local for a project:

```<code>git config --global user.name account1
git config --global user.email email1@outlook.con
git config user.name account2
git config user.email email2@outlook.con
</code>```

Body:
If I have a gitlab account,
username: account1
email: email1@outlook.con

the initial setting in terminal:

git config --global user.name account1
git config --global user.email email1@outlook.con

if I have another one gitlab account,
username: account2
email: email2@outlook.con

when I change the user info in termal:

git config --global user.name account2
git config --global user.email email2@outlook.con

I push file to gitlab , the "Activity" info still show account1.

and I push file by tortoisegit through https path.

I found that even deleted the SSH KEY in gitlab, can still be to push file by https path.

I need to reset?
How can I do?

＊I removed the git and re-installed, and found that the user information still exists...

Body:
Author/committer info (name+email) is written in every commit. The info is copied to commits from config so you have to edit config before making commits.

If you have made a mistake and want to change author/committer name — see https://stackoverflow.com/a/750182/7976758.

If you have two different identities I recommend to put them into different git config files — one global and one local for a project:

git config --global user.name account1
git config --global user.email email1@outlook.con
git config user.name account2
git config user.email email2@outlook.con


问:
Using multiple test directorys Java / Maven
i got a Java project which has multiple test directorys at resources.

```<code>\target\test-classes
                   |___conf
                   |      |_ items...
                   |___otherdata
                          |_ items...
</code>```

I need to access \target\test-classes at it's root, so I can switch between directories since a testcase uses files from BOTH directories at once.

Tried:

```<code>File targetClassesDir = new File(getClass().getProtectionDomain().getCodeSource().getLocation().getPath());
File targetDir = targetClassesDir.getParentFile();
</code>```

and

```<code>getClass().getResource("test-classes").getPath()
</code>```

but counldn't access the root of test-classes yet.

I've constructed a pretty shitty workaround...:

```<code>tuple4TestsuiteContainer.add(new HeaderBodyPayloadTestcase(
                                    "conf\\" + xqueries[0],
                                    getClass().getResource("/").getPath(),
                                    "xquery-testdata\\" + file.substring(file.lastIndexOf(File.separatorChar) + 1),
                                    "xquery-testdata\\" +expectedFiles[0].substring(expectedFiles[0].lastIndexOf(File.separatorChar) + 1)
                            ));
</code>```

and in the actual tester:

```<code>String xqueryFileContent = readFile(testDataBasePath + xQueryUnderTestPath, encoding);
</code>```

答:
I am not sure whether, I was able to understand your problem correctly. If in java while running you are trying to change the directory, you can simply do something like this :

```<code>    public class Main {
            public static void main(String args[]) {
                    String[] s = { "c:\\some\\place\\cdexe.exe",
                    "c:\\start\\dir", "c:\\my\\batch\\file.bat", "arg1", "..." };
                    try {
                            java.lang.Runtime.getRuntime().exec(s);
                    } catch (java.io.IOException e) {
                            e.printStackTrace();
                    }
            } }
</code>```

Let me know if this helps, would like to understand your problem more.

Body:
i got a Java project which has multiple test directorys at resources.

\target\test-classes
                   |___conf
                   |      |_ items...
                   |___otherdata
                          |_ items...

I need to access \target\test-classes at it's root, so I can switch between directories since a testcase uses files from BOTH directories at once.

Tried:

File targetClassesDir = new File(getClass().getProtectionDomain().getCodeSource().getLocation().getPath());
File targetDir = targetClassesDir.getParentFile();

and

getClass().getResource("test-classes").getPath()

but counldn't access the root of test-classes yet.

I've constructed a pretty shitty workaround...:

tuple4TestsuiteContainer.add(new HeaderBodyPayloadTestcase(
                                    "conf\\" + xqueries[0],
                                    getClass().getResource("/").getPath(),
                                    "xquery-testdata\\" + file.substring(file.lastIndexOf(File.separatorChar) + 1),
                                    "xquery-testdata\\" +expectedFiles[0].substring(expectedFiles[0].lastIndexOf(File.separatorChar) + 1)
                            ));

and in the actual tester:

String xqueryFileContent = readFile(testDataBasePath + xQueryUnderTestPath, encoding);

Body:
I am not sure whether, I was able to understand your problem correctly. If in java while running you are trying to change the directory, you can simply do something like this :

    public class Main {
            public static void main(String args[]) {
                    String[] s = { "c:\\some\\place\\cdexe.exe",
                    "c:\\start\\dir", "c:\\my\\batch\\file.bat", "arg1", "..." };
                    try {
                            java.lang.Runtime.getRuntime().exec(s);
                    } catch (java.io.IOException e) {
                            e.printStackTrace();
                    }
            } }

Let me know if this helps, would like to understand your problem more.


问:
How to get defaulValue of YouCanBookMe/react-datetime component?
I am using react-dateTime version"react-datetime": "^2.8.10",
I am using default Value. When i click on edit button i get the default value of react-dateTime. but when i update data and i am not changing the datetime.I want that that defaultValue.and when i update data with out changing date-time.i get current date-time.Then in that case how to get that defaultValue.
How to get defaultValue of react-DateTime?

```<code>renderForm:function(){
    var yesterday = Datetime.moment().subtract( 1, 'day' );
        var valid = function( current ){
        return current.isAfter( yesterday );
        };
        var dateTimeStart=moment(this.props.todo_start_at);
        var dateTimeEnd=moment(this.props.todo_end_at);
        console.log("dateTimeStart ",dateTimeStart)
        console.log("dateTimeEnd ",dateTimeEnd)
    return(
        <form onSubmit={this.handleUpdate}>
            <input type="text"ref={(value)=>{
                this.input=value
            }}defaultValue={this.props.todo_text}/>
            <div className="column medium-4">
                When To Start
                <Datetime input={ true } isValidDate={ valid } dateFormat="YYYY-MM-DD"  defaultValue= { dateTimeStart }onChange={ this.handleDateTimeStart } />
            </div>
            <div className="column medium-4">
                When To End
                <Datetime input={ true } isValidDate={ valid } dateFormat="YYYY-MM-DD" defaultValue= { dateTimeEnd }onChange={ this.handleDateTimeEnd }  />
            </div>
                <br/>
            <button type="button" className="button" onClick={this.handleUpdate}>Update</button>
        </form>
        )
},
</code>```

handleupdate

```<code>handleUpdate:function(event){
        event.preventDefault();
        //console.log(this.dateTimeStart.value);
        var startDate=this.state.dateTimeStart.value;
        console.log(startDate);
        var todoStartDate= moment(startDate).format('YYYY-MM-DD HH:mm');
        var dueDate=this.state.dateTimeEnd.value;
        var todoEndDate=moment(dueDate).format('YYYY-MM-DD HH:mm');
        console.log("handle update",todoEndDate)
        this.props.editTask(this.props.todo_id,this.input.value,todoStartDate,todoEndDate);
        this.toggleState();
    },
</code>```

答:
Reason is, you are initialising the state value by "" (blank value), and updating that when user changes the date, otherwise not. So in that case when user is not updating the value this.state.dateTimeStart.value will be undefined, previous value (default value) will be present in this.props.todo_start_at.

You need to take that default value when user is not doing any change.

Use these line inside handleUpdate method:

```<code>var startDate = this.state.dateTimeStart.value || this.props.todo_start_at;
var dueDate = this.state.dateTimeEnd.value || this.props.todo_end_at;
</code>```

Body:
I am using react-dateTime version"react-datetime": "^2.8.10",
I am using default Value. When i click on edit button i get the default value of react-dateTime. but when i update data and i am not changing the datetime.I want that that defaultValue.and when i update data with out changing date-time.i get current date-time.Then in that case how to get that defaultValue.
How to get defaultValue of react-DateTime?

renderForm:function(){
    var yesterday = Datetime.moment().subtract( 1, 'day' );
        var valid = function( current ){
        return current.isAfter( yesterday );
        };
        var dateTimeStart=moment(this.props.todo_start_at);
        var dateTimeEnd=moment(this.props.todo_end_at);
        console.log("dateTimeStart ",dateTimeStart)
        console.log("dateTimeEnd ",dateTimeEnd)
    return(
        <form onSubmit={this.handleUpdate}>
            <input type="text"ref={(value)=>{
                this.input=value
            }}defaultValue={this.props.todo_text}/>

                When To Start
                <Datetime input={ true } isValidDate={ valid } dateFormat="YYYY-MM-DD"  defaultValue= { dateTimeStart }onChange={ this.handleDateTimeStart } />

                When To End
                <Datetime input={ true } isValidDate={ valid } dateFormat="YYYY-MM-DD" defaultValue= { dateTimeEnd }onChange={ this.handleDateTimeEnd }  />

            <button type="button" className="button" onClick={this.handleUpdate}>Update</button>
        </form>
        )
},

handleupdate

handleUpdate:function(event){
        event.preventDefault();
        //console.log(this.dateTimeStart.value);
        var startDate=this.state.dateTimeStart.value;
        console.log(startDate);
        var todoStartDate= moment(startDate).format('YYYY-MM-DD HH:mm');
        var dueDate=this.state.dateTimeEnd.value;
        var todoEndDate=moment(dueDate).format('YYYY-MM-DD HH:mm');
        console.log("handle update",todoEndDate)
        this.props.editTask(this.props.todo_id,this.input.value,todoStartDate,todoEndDate);
        this.toggleState();
    },

Body:
Reason is, you are initialising the state value by "" (blank value), and updating that when user changes the date, otherwise not. So in that case when user is not updating the value this.state.dateTimeStart.value will be undefined, previous value (default value) will be present in this.props.todo_start_at.

You need to take that default value when user is not doing any change.

Use these line inside handleUpdate method:

var startDate = this.state.dateTimeStart.value || this.props.todo_start_at;
var dueDate = this.state.dateTimeEnd.value || this.props.todo_end_at;