问:
Flutter PageView keep rebuilding the main widget on setState value
currently flutter app structure

StackedHome has a pageview with 2 children

Pageview(parent):

HomeScreen(child#1)

Vertical PageView

bottom navigation bar

UserProfilePage(child#2)

HomeScreen should pass the index value to UserProfilePage, so when scrolling horizontally, we will get user profilescreen with id passed to that received from HomeScreen. based on the id passed i will display related user profile

Here is sample video showing the problem :

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

Problem:
i managed to do that and its working fine, but my problem on setState of that variable

```<code>setState(() {
      _postIndex = postIndex;
    });

</code>```

on each HomeScreen > onPageChanged call i am updating the index value pass it to the parent (StackedHome) class, and since there is a setState to update profile index (UserProfilePage)...the whole app will be rebuild on each pageview change...

What i need is to disable that main widget to be rebuilt again and again on value update..

StackedHome

```<code>class StackedHome extends StatefulWidget {
  final int data;
  final Function(int) onDataChange;

  const StackedHome({
    this.data,
    this.onDataChange,
    Key key,
  }) : super(key: key);

  @override
  _StackedHomeState createState() => _StackedHomeState();
}

class _StackedHomeState extends State<StackedHome>{
  PageController pageController;

  int _count = 0;
  int _postIndex = 0;

  void _postId(int postIndex) {

//This cuasing main screen to be rebuilt everytime on pageview scroll
//but getting the value correctly
  setState(() {
      _postIndex = postIndex;
    });

  }

  @override
  void initState() {
    super.initState();
    pageController = PageController();
  }

  @override
  void dispose() {
    pageController.dispose();
    super.dispose();
  }

  int index = 0;

  @override
  Future<void> _refreshPosts() async {
    PostApi postApi = PostApi();

    setState(() {
      postApi.fetchAllPosts();
    });
  }

  Widget build(BuildContext context) {
    PostApi postApi = PostApi();

    return FutureBuilder(
      future: postApi.fetchAllPosts(),
      builder: (BuildContext context, AsyncSnapshot<List<Post>> snapshot) {
        switch (snapshot.connectionState) {
          case ConnectionState.none:
            return apiError('No Connection Made');
            break;

          case ConnectionState.waiting:
          case ConnectionState.active:
            return ApiLoading(color:0xff000000);
            break;

          case ConnectionState.done:
            if (snapshot.hasError) {
              return apiError(snapshot.error.toString());
            }

            if (snapshot.hasData) {
              return _drawPostsList(snapshot.data, context);
            }
            break;
        }

        return Container();
      },
    );
  }

  Widget _drawPostsList(List<Post> posts, BuildContext context) {

    return PageView(
      reverse: true,
      children: <Widget>[
        HomeScreen(
          posts: posts,
          index: index,
          postId: _postId,//function Passed
        ),
        UserProfilePage(
          posts: posts,
          index: _postIndex,
        )
      ],
    );
  }
}

</code>```

HomeScreen

```<code>class HomeScreen extends StatefulWidget {
  @override
  final List posts;
  final int index;
  final Function(int) postId;

  int getPage() {
    return value;
  }

  void setPage(int page) {
    value = page;
  }

  HomeScreen({Key key, this.posts, this.index, this.postId}) : super(key: key);

  HomeScreenState createState() => HomeScreenState();
}

class HomeScreenState extends State<HomeScreen>
    with SingleTickerProviderStateMixin {
  final PageController _controller = PageController();
  PageController _pageController = PageController();

  int index = 0;

  @override
  void initState() {
    super.initState();

    //Set pageview inital page
    _pageController = PageController(
      keepPage: true,
      initialPage: widget.getPage(),
    );

  }

  @override
  Widget build(BuildContext context) {

    return RefreshIndicator(
      onRefresh: _refreshPosts,
      child: Stack(children: <Widget>[
        PageView.builder(
          controller: _pageController,
          onPageChanged: (index) => setState(() {
            .
            widget.postId(index);//I am calling parent class and updating the vlaue with new index value
            .
          }),
          scrollDirection: Axis.vertical,
          itemBuilder: (context, position) {

//Build image lists
return _homeList(widget.posts, position);
          },
        ),
        BottomNavigation("light"),
      ]),
    );
  }

}
</code>```

i hope my problem is clear enough....i need to pass the value to parent so i can pass it to second child which is the profile screen so it will show user profile realted to that post

答: Ohh wow, managed to solve this problem using provider and consumer, by listening to any update on index id... this post helped me to solve it https://medium.com/flutter-nyc/a-closer-look-at-the-provider-package-993922d3a5a5</p>

Body:
currently flutter app structure

StackedHome has a pageview with 2 children

Pageview(parent):

HomeScreen(child#1)

Vertical PageView

bottom navigation bar

UserProfilePage(child#2)

HomeScreen should pass the index value to UserProfilePage, so when scrolling horizontally, we will get user profilescreen with id passed to that received from HomeScreen. based on the id passed i will display related user profile

Here is sample video showing the problem :

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

Problem:
i managed to do that and its working fine, but my problem on setState of that variable

setState(() {
      _postIndex = postIndex;
    });

on each HomeScreen > onPageChanged call i am updating the index value pass it to the parent (StackedHome) class, and since there is a setState to update profile index (UserProfilePage)...the whole app will be rebuild on each pageview change...

What i need is to disable that main widget to be rebuilt again and again on value update..

StackedHome

class StackedHome extends StatefulWidget {
  final int data;
  final Function(int) onDataChange;

  const StackedHome({
    this.data,
    this.onDataChange,
    Key key,
  }) : super(key: key);

  @override
  _StackedHomeState createState() => _StackedHomeState();
}

class _StackedHomeState extends State<StackedHome>{
  PageController pageController;

  int _count = 0;
  int _postIndex = 0;

  void _postId(int postIndex) {

//This cuasing main screen to be rebuilt everytime on pageview scroll
//but getting the value correctly
  setState(() {
      _postIndex = postIndex;
    });

  }

  @override
  void initState() {
    super.initState();
    pageController = PageController();
  }

  @override
  void dispose() {
    pageController.dispose();
    super.dispose();
  }

  int index = 0;

  @override
  Future<void> _refreshPosts() async {
    PostApi postApi = PostApi();

    setState(() {
      postApi.fetchAllPosts();
    });
  }

  Widget build(BuildContext context) {
    PostApi postApi = PostApi();

    return FutureBuilder(
      future: postApi.fetchAllPosts(),
      builder: (BuildContext context, AsyncSnapshot<List<Post>> snapshot) {
        switch (snapshot.connectionState) {
          case ConnectionState.none:
            return apiError('No Connection Made');
            break;

          case ConnectionState.waiting:
          case ConnectionState.active:
            return ApiLoading(color:0xff000000);
            break;

          case ConnectionState.done:
            if (snapshot.hasError) {
              return apiError(snapshot.error.toString());
            }

            if (snapshot.hasData) {
              return _drawPostsList(snapshot.data, context);
            }
            break;
        }

        return Container();
      },
    );
  }

  Widget _drawPostsList(List<Post> posts, BuildContext context) {

    return PageView(
      reverse: true,
      children: <Widget>[
        HomeScreen(
          posts: posts,
          index: index,
          postId: _postId,//function Passed
        ),
        UserProfilePage(
          posts: posts,
          index: _postIndex,
        )
      ],
    );
  }
}

HomeScreen

class HomeScreen extends StatefulWidget {
  @override
  final List posts;
  final int index;
  final Function(int) postId;

  int getPage() {
    return value;
  }

  void setPage(int page) {
    value = page;
  }

  HomeScreen({Key key, this.posts, this.index, this.postId}) : super(key: key);

  HomeScreenState createState() => HomeScreenState();
}

class HomeScreenState extends State<HomeScreen>
    with SingleTickerProviderStateMixin {
  final PageController _controller = PageController();
  PageController _pageController = PageController();

  int index = 0;

  @override
  void initState() {
    super.initState();

    //Set pageview inital page
    _pageController = PageController(
      keepPage: true,
      initialPage: widget.getPage(),
    );

  }

  @override
  Widget build(BuildContext context) {

    return RefreshIndicator(
      onRefresh: _refreshPosts,
      child: Stack(children: <Widget>[
        PageView.builder(
          controller: _pageController,
          onPageChanged: (index) => setState(() {
            .
            widget.postId(index);//I am calling parent class and updating the vlaue with new index value
            .
          }),
          scrollDirection: Axis.vertical,
          itemBuilder: (context, position) {

//Build image lists
return _homeList(widget.posts, position);
          },
        ),
        BottomNavigation("light"),
      ]),
    );
  }

}

i hope my problem is clear enough....i need to pass the value to parent so i can pass it to second child which is the profile screen so it will show user profile realted to that post


来源: stackexchange

问:
it is giving me a error with position of with
```<code>WITH cte AS ( SELECT id,
                     email,
                     ROW_NUMBER() OVER (PARTITION BY id, email
                                        ORDER BY id, email) row_num
              FROM requests_data)
DELETE FROM cte
WHERE row_num > 1
</code>```

答:
By way of illustration of my comment, consider the following:</p>

```<code>DROP TABLE IF EXISTS my_table;

CREATE TABLE my_table
(id INT NOT NULL
,email VARCHAR(30) NOT NULL
);

INSERT INTO my_table VALUES
(1,'adam@pmail.con'),
(1,'ben@pmail.con'),
(1,'charlie@pmail.con'),
(1,'dave@pmail.con'),
(2,'alice@pmail.con'),
(2,'bertha@pmail.con'),
(2,'carol@pmail.con'),
(2,'diana@pmail.con'),
(2,'erica@pmail.con');

DROP TABLE IF EXISTS my_new_table;

CREATE TABLE my_new_table AS
SELECT id,MIN(email) email FROM my_table GROUP BY id;

DROP TABLE my_table;

RENAME TABLE my_new_table TO my_table;

SELECT * FROM my_table;

+----+-----------------+
| id | email           |
+----+-----------------+
|  1 | adam@pmail.con  |
|  2 | alice@pmail.con |
+----+-----------------+
</code>```

ContentLicense: CC BY-SA 4.0

Body:
By way of illustration of my comment, consider the following:

DROP TABLE IF EXISTS my_table;

CREATE TABLE my_table
(id INT NOT NULL
,email VARCHAR(30) NOT NULL
);

INSERT INTO my_table VALUES
(1,'adam@pmail.con'),
(1,'ben@pmail.con'),
(1,'charlie@pmail.con'),
(1,'dave@pmail.con'),
(2,'alice@pmail.con'),
(2,'bertha@pmail.con'),
(2,'carol@pmail.con'),
(2,'diana@pmail.con'),
(2,'erica@pmail.con');

DROP TABLE IF EXISTS my_new_table;

CREATE TABLE my_new_table AS
SELECT id,MIN(email) email FROM my_table GROUP BY id;

DROP TABLE my_table;

RENAME TABLE my_new_table TO my_table;

SELECT * FROM my_table;

+----+-----------------+
| id | email           |
+----+-----------------+
|  1 | adam@pmail.con  |
|  2 | alice@pmail.con |
+----+-----------------+


问:
Is there a grid for storing data?
I need to store data in a grid like this:

```<code>{0,1,2,3}
{4,5,6,7}
{8,9,10,11}
{12,13,14,15}
</code>```

I know I can use multi dimensional arrays, but Is there any easier way to do it? Also I need to get values from it like myData.Item(0,1) would return 1.

答:
You can have a list of tuples if you are using .NET 4.0.

In this case, Tuple(Of T1, T2, T3, T4):

```<code>Dim matrix() =
           { Tuple.Create(0,1,2,3),
             Tuple.Create(4,5,6,7),
             Tuple.Create(8,9,10,11),
             Tuple.Create(12,13,14,15)}
</code>```

ContentLicense: CC BY-SA 3.0

Title: Is there a grid for storing data?

Body:
I need to store data in a grid like this:

{0,1,2,3}
{4,5,6,7}
{8,9,10,11}
{12,13,14,15}

I know I can use multi dimensional arrays, but Is there any easier way to do it? Also I need to get values from it like myData.Item(0,1) would return 1.

Body:
You can have a list of tuples if you are using .NET 4.0.

In this case, Tuple(Of T1, T2, T3, T4):

Dim matrix() =
           { Tuple.Create(0,1,2,3),
             Tuple.Create(4,5,6,7),
             Tuple.Create(8,9,10,11),
             Tuple.Create(12,13,14,15)}


问:
Vertx is not available in Quarkus vertx munity web client extesions
I tried to test the reactive web client provided by vertx munity web client.

I followed the official guide Quarkus - Getting Started with Reactive.

And added the following in dependencies.

        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-resteasy</artifactId>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-resteasy-jsonb</artifactId>
        </dependency>
        <dependency>
            <groupId>io.smallrye.reactive</groupId>
            <artifactId>smallrye-mutiny-vertx-web-client</artifactId>
        </dependency>
```

<p>But when I injected <code>Vertx</code> as mentioned in the article, and got the CDI unsatisfied dependency exception. <code>Vertx</code> is not available.</p>

<pre class="lang-sh prettyprint-override"><code>Caused by: javax.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type io.vertx.mutiny.core.Vertx and qualifiers [@Default]
        - java member: com.example.PostResourceClient#vertx
</code>```

The complete codes are here.

答: You need to add the io.quarkus:quarkus-vertx dependency to your POM to activate the Vertx extension. io.smallrye.reactive:smallrye-mutiny-vertx-web-client is an external dependency that does not activate any extension.

Body:
I tried to test the reactive web client provided by vertx munity web client.

I followed the official guide Quarkus - Getting Started with Reactive.

And added the following in dependencies.

        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-resteasy</artifactId>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-resteasy-jsonb</artifactId>
        </dependency>
        <dependency>
            <groupId>io.smallrye.reactive</groupId>
            <artifactId>smallrye-mutiny-vertx-web-client</artifactId>
        </dependency>

But when I injected Vertx as mentioned in the article, and got the CDI unsatisfied dependency exception. Vertx is not available.

Caused by: javax.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type io.vertx.mutiny.core.Vertx and qualifiers [@Default]
        - java member: com.example.PostResourceClient#vertx

The complete codes are here.


问:
Does + 1 really matter in the python function below?
I am new to programming and I'm taking a online course in python. I have a question to ask about a line in the below function:

```<code>def sum_first_n(n):
    result = 0
    for i in range(n):
        result += i + 1
    print(result)
sum_first_n(100)
</code>```

The result is 5050. Now looking at line 4: result += i  + 1, if I remove the  + 1  from that line, I still get the same result. Can anyone kindly explain what the work of + 1 is or can it be omitted when writing?

答:
I removed +1 from the line, and it printed 4950. +1 matters. Let me explain.

First, result = 0, nothing to do here.

for i in range(n) means repeat n times, STARTING from i=0 so it ends at n=99.

For each loop, result = result + i + 1. Since your loop only sums 100 times, it stops at i=99, but there's 100 +1 so the result is 5050.

To make this code more readable, change it into for i in range(n+1): result += i means the loop starts at 0 and ends at 100, and that's your sum of the first 100 positive integer numbers.

Body:
I am new to programming and I'm taking a online course in python. I have a question to ask about a line in the below function:

def sum_first_n(n):
    result = 0
    for i in range(n):
        result += i + 1
    print(result)
sum_first_n(100)

The result is 5050. Now looking at line 4: result += i  + 1, if I remove the  + 1  from that line, I still get the same result. Can anyone kindly explain what the work of + 1 is or can it be omitted when writing?


问:
how can I use the event parameter when the code is written inline in the mxml tag in flex
What is the difference between :

giving a function reference in the result attribute of the HTTPService class like this :

```<code>protected function httpserviceCheckUpdate_resultHandler(event:ResultEvent):void
{
     var version:Number = event.result.text.version as Number;
     var xmldata:XML = XML(event.result);
     // and all the processing you want to do
}
<mx:HTTPService id="httpserviceCheckUpdate"
                    method="POST"
                    url="http://abc.com/actions.php"
                    resultFormat="text"
                    fault="httpservicexml_faultHandler(event)"
                    result="httpserviceCheckUpdate_resultHandler(event)">
        <mx:request xmlns="">
            <action>versionCheck</action>
        </mx:request>
    </mx:HTTPService>
</code>```

and

coding the complete function in the <mx:result></mx:result> of the same HTTPService class.

```<code><mx:HTTPService id="httpserviceCheckUpdate"
                method="POST"
                url="http://abc.com/actions.php"
                resultFormat="text"
                fault="httpservicexml_faultHandler(event)"
                result="httpserviceCheckUpdate_resultHandler(event)">
    <mx:request xmlns="">
        <action>versionCheck</action>
    </mx:request>
    <mx:result>
        <![CDATA[
        var version:Number = event.result.text.version as Number;
        var xmldata:XML = XML(event.result);
        // and all the processing you want to do
        ]]>
    </mx:result>
</mx:HTTPService>
</code>```

If both of them are same then how can I provide the event parameter using the second approach (as written in the result attribute of the httpservice class)?

Which one of them is the better way of doing things in FLEX

Thanks

答:
Using the <mx:result> tag is not a standard way of doing things.  You can use tags for any events using MXML.  It's made for quick prototyping but not code cleanliness.  They're not exactly the same since the latter is an anonymous function with no parameters, however you can access the result using the httpserviceCheckUpdate.lastResult property.

Your first approach is the better one because it's the standard, it's cleaner, resuable and you can set the parameters.

Body:
What is the difference between :

giving a function reference in the result attribute of the HTTPService class like this :

protected function httpserviceCheckUpdate_resultHandler(event:ResultEvent):void
{
     var version:Number = event.result.text.version as Number;
     var xmldata:XML = XML(event.result);
     // and all the processing you want to do
}
<mx:HTTPService id="httpserviceCheckUpdate"
                    method="POST"
                    url="http://abc.com/actions.php"
                    resultFormat="text"
                    fault="httpservicexml_faultHandler(event)"
                    result="httpserviceCheckUpdate_resultHandler(event)">
        <mx:request xmlns="">
            <action>versionCheck</action>
        </mx:request>
    </mx:HTTPService>

and

coding the complete function in the <mx:result></mx:result> of the same HTTPService class.

<mx:HTTPService id="httpserviceCheckUpdate"
                method="POST"
                url="http://abc.com/actions.php"
                resultFormat="text"
                fault="httpservicexml_faultHandler(event)"
                result="httpserviceCheckUpdate_resultHandler(event)">
    <mx:request xmlns="">
        <action>versionCheck</action>
    </mx:request>
    <mx:result>
        <![CDATA[
        var version:Number = event.result.text.version as Number;
        var xmldata:XML = XML(event.result);
        // and all the processing you want to do
        ]]>
    </mx:result>
</mx:HTTPService>

If both of them are same then how can I provide the event parameter using the second approach (as written in the result attribute of the httpservice class)?

Which one of them is the better way of doing things in FLEX

Thanks


问:
Eclipse - Can not reach market place
I am trying to install glassfish on my Eclipse but I have an issue each time I try to access it :

Resource not found: http://marketplace.eclipse.org/api/p?client=org.eclipse.epp.mpc.core&client.version=1.8.2.v20200210-1402&os=win32&ws=win32&nl=fr_FR&java.version=1.8.0_231&product=org.eclipse.epp.package.jee.product&product.version=4.15.0.I20200305-0155&runtime.version=3.17.100.v20200203-0917&platform.version=4.15.0.v20200305-0155
http://marketplace.eclipse.org/api/p?client=org.eclipse.epp.mpc.core&client.version=1.8.2.v20200210-1402&os=win32&ws=win32&nl=fr_FR&java.version=1.8.0_231&product=org.eclipse.epp.package.jee.product&product.version=4.15.0.I20200305-0155&runtime.version=3.17.100.v20200203-0917&platform.version=4.15.0.v20200305-0155

I can reach web page from inside eclipse web browser and I can reach the market place with my browser I guess it is coming from eclipse but I don't know how to solve it.

I tried to change the Network Connections settings from Native to Manual but no luck so far.

If anyone as an idea ?

Here is the stack trace :

```<code>eclipse.buildId=4.15.0.I20200305-0155
java.version=1.8.0_231
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=fr_FR
Framework arguments:  -product org.eclipse.epp.package.jee.product
Command-line arguments:  -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.jee.product

org.eclipse.epp.mpc.core
Error
Tue Jun 02 10:54:16 CEST 2020
Failed to stream using org.eclipse.epp.internal.mpc.core.transport.httpclient.HttpClientTransport@27a4a153 - falling back to org.eclipse.epp.internal.mpc.core.util.TransportFactory$$Lambda$811/602501626@46a0adaa: Connection failed

This is most often caused by a problem with your internet connection. Please check your internet connection and retry.

org.eclipse.core.runtime.CoreException: Connection failed

This is most often caused by a problem with your internet connection. Please check your internet connection and retry.
    at org.eclipse.epp.internal.mpc.core.transport.httpclient.HttpClientTransport.stream(HttpClientTransport.java:119)
    at org.eclipse.epp.internal.mpc.core.util.FallbackTransportFactory$FallbackTransport.stream(FallbackTransportFactory.java:71)
    at org.eclipse.epp.internal.mpc.core.service.RemoteMarketplaceService.processRequest(RemoteMarketplaceService.java:165)
    at org.eclipse.epp.internal.mpc.core.service.RemoteMarketplaceService.processRequest(RemoteMarketplaceService.java:130)
    at org.eclipse.epp.internal.mpc.core.service.RemoteMarketplaceService.processRequest(RemoteMarketplaceService.java:117)
    at org.eclipse.epp.internal.mpc.core.service.DefaultMarketplaceService.news(DefaultMarketplaceService.java:788)
    at org.eclipse.epp.internal.mpc.core.service.DefaultMarketplaceService.news(DefaultMarketplaceService.java:1)
    at org.eclipse.epp.internal.mpc.core.service.CachingMarketplaceService.news(CachingMarketplaceService.java:405)
    at org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceDiscoveryStrategy.performNewsDiscovery(MarketplaceDiscoveryStrategy.java:947)
    at org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceCatalog.performNewsDiscovery(MarketplaceCatalog.java:584)
    at org.eclipse.epp.internal.mpc.ui.wizards.MarketplaceWizard.lambda$3(MarketplaceWizard.java:944)
    at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:122)
Caused by: java.net.SocketTimeoutException: Read timed out
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.socketRead(Unknown Source)
    at java.net.SocketInputStream.read(Unknown Source)
    at java.net.SocketInputStream.read(Unknown Source)
    at org.apache.http.impl.io.SessionInputBufferImpl.streamRead(SessionInputBufferImpl.java:137)
    at org.apache.http.impl.io.SessionInputBufferImpl.fillBuffer(SessionInputBufferImpl.java:153)
    at org.apache.http.impl.io.SessionInputBufferImpl.readLine(SessionInputBufferImpl.java:280)
    at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:138)
    at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:56)
    at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:259)
    at org.apache.http.impl.DefaultBHttpClientConnection.receiveResponseHeader(DefaultBHttpClientConnection.java:163)
    at org.apache.http.impl.conn.CPoolProxy.receiveResponseHeader(CPoolProxy.java:157)
    at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:273)
    at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:125)
    at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:272)
    at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186)
    at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
    at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
    at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56)
    at org.apache.http.client.fluent.Request.internalExecute(Request.java:173)
    at org.apache.http.client.fluent.Executor.execute(Executor.java:262)
    at org.eclipse.epp.internal.mpc.core.transport.httpclient.HttpClientTransport.execute(HttpClientTransport.java:93)
    at org.eclipse.epp.internal.mpc.core.transport.httpclient.RequestTemplate.executeImpl(RequestTemplate.java:96)
    at org.eclipse.epp.internal.mpc.core.transport.httpclient.RequestTemplate.execute(RequestTemplate.java:55)
    at org.eclipse.epp.internal.mpc.core.transport.httpclient.HttpClientTransport.stream(HttpClientTransport.java:104)
    ... 11 more
Contains: Connection failed

This is most often caused by a problem with your internet connection. Please check your internet connection and retry.
java.net.SocketTimeoutException: Read timed out
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.socketRead(Unknown Source)
    at java.net.SocketInputStream.read(Unknown Source)
    at java.net.SocketInputStream.read(Unknown Source)
    at org.apache.http.impl.io.SessionInputBufferImpl.streamRead(SessionInputBufferImpl.java:137)
    at org.apache.http.impl.io.SessionInputBufferImpl.fillBuffer(SessionInputBufferImpl.java:153)
    at org.apache.http.impl.io.SessionInputBufferImpl.readLine(SessionInputBufferImpl.java:280)
    at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:138)
    at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:56)
    at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:259)
    at org.apache.http.impl.DefaultBHttpClientConnection.receiveResponseHeader(DefaultBHttpClientConnection.java:163)
    at org.apache.http.impl.conn.CPoolProxy.receiveResponseHeader(CPoolProxy.java:157)
    at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:273)
    at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:125)
    at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:272)
    at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186)
    at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
    at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
    at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56)
    at org.apache.http.client.fluent.Request.internalExecute(Request.java:173)
    at org.apache.http.client.fluent.Executor.execute(Executor.java:262)
    at org.eclipse.epp.internal.mpc.core.transport.httpclient.HttpClientTransport.execute(HttpClientTransport.java:93)
    at org.eclipse.epp.internal.mpc.core.transport.httpclient.RequestTemplate.executeImpl(RequestTemplate.java:96)
    at org.eclipse.epp.internal.mpc.core.transport.httpclient.RequestTemplate.execute(RequestTemplate.java:55)
    at org.eclipse.epp.internal.mpc.core.transport.httpclient.HttpClientTransport.stream(HttpClientTransport.java:104)
    at org.eclipse.epp.internal.mpc.core.util.FallbackTransportFactory$FallbackTransport.stream(FallbackTransportFactory.java:71)
    at org.eclipse.epp.internal.mpc.core.service.RemoteMarketplaceService.processRequest(RemoteMarketplaceService.java:165)
    at org.eclipse.epp.internal.mpc.core.service.RemoteMarketplaceService.processRequest(RemoteMarketplaceService.java:130)
    at org.eclipse.epp.internal.mpc.core.service.RemoteMarketplaceService.processRequest(RemoteMarketplaceService.java:117)
    at org.eclipse.epp.internal.mpc.core.service.DefaultMarketplaceService.news(DefaultMarketplaceService.java:788)
    at org.eclipse.epp.internal.mpc.core.service.DefaultMarketplaceService.news(DefaultMarketplaceService.java:1)
    at org.eclipse.epp.internal.mpc.core.service.CachingMarketplaceService.news(CachingMarketplaceService.java:405)
    at org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceDiscoveryStrategy.performNewsDiscovery(MarketplaceDiscoveryStrategy.java:947)
    at org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceCatalog.performNewsDiscovery(MarketplaceCatalog.java:584)
    at org.eclipse.epp.internal.mpc.ui.wizards.MarketplaceWizard.lambda$3(MarketplaceWizard.java:944)
    at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:122)
</code>```

I have the same issue from Help->Marketplace and from the welcome menu.

Thx

UPDATE : I manage to make it work again by deleting all the . folder (.me2, .plguings ...)

答: UPDATE : I manage to make it work again by deleting all the . folder (.me2, .plguings ...)</p>

Title: Eclipse - Can not reach market place

Body:
I am trying to install glassfish on my Eclipse but I have an issue each time I try to access it :

Resource not found: http://marketplace.eclipse.org/api/p?client=org.eclipse.epp.mpc.core&client.version=1.8.2.v20200210-1402&os=win32&ws=win32&nl=fr_FR&java.version=1.8.0_231&product=org.eclipse.epp.package.jee.product&product.version=4.15.0.I20200305-0155&runtime.version=3.17.100.v20200203-0917&platform.version=4.15.0.v20200305-0155
http://marketplace.eclipse.org/api/p?client=org.eclipse.epp.mpc.core&client.version=1.8.2.v20200210-1402&os=win32&ws=win32&nl=fr_FR&java.version=1.8.0_231&product=org.eclipse.epp.package.jee.product&product.version=4.15.0.I20200305-0155&runtime.version=3.17.100.v20200203-0917&platform.version=4.15.0.v20200305-0155

I can reach web page from inside eclipse web browser and I can reach the market place with my browser I guess it is coming from eclipse but I don't know how to solve it.

I tried to change the Network Connections settings from Native to Manual but no luck so far.

If anyone as an idea ?

Here is the stack trace :

eclipse.buildId=4.15.0.I20200305-0155
java.version=1.8.0_231
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=fr_FR
Framework arguments:  -product org.eclipse.epp.package.jee.product
Command-line arguments:  -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.jee.product

org.eclipse.epp.mpc.core
Error
Tue Jun 02 10:54:16 CEST 2020
Failed to stream using org.eclipse.epp.internal.mpc.core.transport.httpclient.HttpClientTransport@27a4a153 - falling back to org.eclipse.epp.internal.mpc.core.util.TransportFactory$$Lambda$811/602501626@46a0adaa: Connection failed

This is most often caused by a problem with your internet connection. Please check your internet connection and retry.

org.eclipse.core.runtime.CoreException: Connection failed

This is most often caused by a problem with your internet connection. Please check your internet connection and retry.
    at org.eclipse.epp.internal.mpc.core.transport.httpclient.HttpClientTransport.stream(HttpClientTransport.java:119)
    at org.eclipse.epp.internal.mpc.core.util.FallbackTransportFactory$FallbackTransport.stream(FallbackTransportFactory.java:71)
    at org.eclipse.epp.internal.mpc.core.service.RemoteMarketplaceService.processRequest(RemoteMarketplaceService.java:165)
    at org.eclipse.epp.internal.mpc.core.service.RemoteMarketplaceService.processRequest(RemoteMarketplaceService.java:130)
    at org.eclipse.epp.internal.mpc.core.service.RemoteMarketplaceService.processRequest(RemoteMarketplaceService.java:117)
    at org.eclipse.epp.internal.mpc.core.service.DefaultMarketplaceService.news(DefaultMarketplaceService.java:788)
    at org.eclipse.epp.internal.mpc.core.service.DefaultMarketplaceService.news(DefaultMarketplaceService.java:1)
    at org.eclipse.epp.internal.mpc.core.service.CachingMarketplaceService.news(CachingMarketplaceService.java:405)
    at org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceDiscoveryStrategy.performNewsDiscovery(MarketplaceDiscoveryStrategy.java:947)
    at org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceCatalog.performNewsDiscovery(MarketplaceCatalog.java:584)
    at org.eclipse.epp.internal.mpc.ui.wizards.MarketplaceWizard.lambda$3(MarketplaceWizard.java:944)
    at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:122)
Caused by: java.net.SocketTimeoutException: Read timed out
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.socketRead(Unknown Source)
    at java.net.SocketInputStream.read(Unknown Source)
    at java.net.SocketInputStream.read(Unknown Source)
    at org.apache.http.impl.io.SessionInputBufferImpl.streamRead(SessionInputBufferImpl.java:137)
    at org.apache.http.impl.io.SessionInputBufferImpl.fillBuffer(SessionInputBufferImpl.java:153)
    at org.apache.http.impl.io.SessionInputBufferImpl.readLine(SessionInputBufferImpl.java:280)
    at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:138)
    at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:56)
    at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:259)
    at org.apache.http.impl.DefaultBHttpClientConnection.receiveResponseHeader(DefaultBHttpClientConnection.java:163)
    at org.apache.http.impl.conn.CPoolProxy.receiveResponseHeader(CPoolProxy.java:157)
    at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:273)
    at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:125)
    at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:272)
    at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186)
    at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
    at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
    at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56)
    at org.apache.http.client.fluent.Request.internalExecute(Request.java:173)
    at org.apache.http.client.fluent.Executor.execute(Executor.java:262)
    at org.eclipse.epp.internal.mpc.core.transport.httpclient.HttpClientTransport.execute(HttpClientTransport.java:93)
    at org.eclipse.epp.internal.mpc.core.transport.httpclient.RequestTemplate.executeImpl(RequestTemplate.java:96)
    at org.eclipse.epp.internal.mpc.core.transport.httpclient.RequestTemplate.execute(RequestTemplate.java:55)
    at org.eclipse.epp.internal.mpc.core.transport.httpclient.HttpClientTransport.stream(HttpClientTransport.java:104)
    ... 11 more
Contains: Connection failed

This is most often caused by a problem with your internet connection. Please check your internet connection and retry.
java.net.SocketTimeoutException: Read timed out
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.socketRead(Unknown Source)
    at java.net.SocketInputStream.read(Unknown Source)
    at java.net.SocketInputStream.read(Unknown Source)
    at org.apache.http.impl.io.SessionInputBufferImpl.streamRead(SessionInputBufferImpl.java:137)
    at org.apache.http.impl.io.SessionInputBufferImpl.fillBuffer(SessionInputBufferImpl.java:153)
    at org.apache.http.impl.io.SessionInputBufferImpl.readLine(SessionInputBufferImpl.java:280)
    at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:138)
    at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:56)
    at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:259)
    at org.apache.http.impl.DefaultBHttpClientConnection.receiveResponseHeader(DefaultBHttpClientConnection.java:163)
    at org.apache.http.impl.conn.CPoolProxy.receiveResponseHeader(CPoolProxy.java:157)
    at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:273)
    at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:125)
    at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:272)
    at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186)
    at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
    at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
    at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56)
    at org.apache.http.client.fluent.Request.internalExecute(Request.java:173)
    at org.apache.http.client.fluent.Executor.execute(Executor.java:262)
    at org.eclipse.epp.internal.mpc.core.transport.httpclient.HttpClientTransport.execute(HttpClientTransport.java:93)
    at org.eclipse.epp.internal.mpc.core.transport.httpclient.RequestTemplate.executeImpl(RequestTemplate.java:96)
    at org.eclipse.epp.internal.mpc.core.transport.httpclient.RequestTemplate.execute(RequestTemplate.java:55)
    at org.eclipse.epp.internal.mpc.core.transport.httpclient.HttpClientTransport.stream(HttpClientTransport.java:104)
    at org.eclipse.epp.internal.mpc.core.util.FallbackTransportFactory$FallbackTransport.stream(FallbackTransportFactory.java:71)
    at org.eclipse.epp.internal.mpc.core.service.RemoteMarketplaceService.processRequest(RemoteMarketplaceService.java:165)
    at org.eclipse.epp.internal.mpc.core.service.RemoteMarketplaceService.processRequest(RemoteMarketplaceService.java:130)
    at org.eclipse.epp.internal.mpc.core.service.RemoteMarketplaceService.processRequest(RemoteMarketplaceService.java:117)
    at org.eclipse.epp.internal.mpc.core.service.DefaultMarketplaceService.news(DefaultMarketplaceService.java:788)
    at org.eclipse.epp.internal.mpc.core.service.DefaultMarketplaceService.news(DefaultMarketplaceService.java:1)
    at org.eclipse.epp.internal.mpc.core.service.CachingMarketplaceService.news(CachingMarketplaceService.java:405)
    at org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceDiscoveryStrategy.performNewsDiscovery(MarketplaceDiscoveryStrategy.java:947)
    at org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceCatalog.performNewsDiscovery(MarketplaceCatalog.java:584)
    at org.eclipse.epp.internal.mpc.ui.wizards.MarketplaceWizard.lambda$3(MarketplaceWizard.java:944)
    at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:122)

I have the same issue from Help->Marketplace and from the welcome menu.

Thx

UPDATE : I manage to make it work again by deleting all the . folder (.me2, .plguings ...)


问:
Jenkins job was poked by a GitHub webhook but didn't start
I am running GHE 2.3.1 in private mode (anonymous cloning and repo browsing is not allowed in my organization) and we use Jenkins for CI.  Before I put GHE into private mode I could have Jenkins fire jobs for repos when push events happen, using webhooks.  After I set private mode this no longer happens.

In Jenkins I see that the webhook was received but the job didn't start.

```<code>Sep 23, 2015 4:13:35 PM INFO org.jenkinsci.plugins.github.webhook.subscriber.DefaultPushGHEventSubscriber onEvent
Received POST for http://github.company.com/org/repo
Sep 23, 2015 4:13:35 PM INFO org.jenkinsci.plugins.github.webhook.subscriber.DefaultPushGHEventSubscriber$1 run
Poked Job Name - build master
</code>```

My job has no history of starting and failing.  This is true for all jobs relying on push hooks.  However, my jobs that run on pull request hooks are working, so I'm not sure what's wrong.

Any ideas?

答:
Add this trigger block in your Jenkinsfile then run your job once manually. </p>

```<code>pipeline {
    triggers {
       githubPush()
    }
}
</code>```

Body:
I am running GHE 2.3.1 in private mode (anonymous cloning and repo browsing is not allowed in my organization) and we use Jenkins for CI.  Before I put GHE into private mode I could have Jenkins fire jobs for repos when push events happen, using webhooks.  After I set private mode this no longer happens.

In Jenkins I see that the webhook was received but the job didn't start.

Sep 23, 2015 4:13:35 PM INFO org.jenkinsci.plugins.github.webhook.subscriber.DefaultPushGHEventSubscriber onEvent
Received POST for http://github.company.com/org/repo
Sep 23, 2015 4:13:35 PM INFO org.jenkinsci.plugins.github.webhook.subscriber.DefaultPushGHEventSubscriber$1 run
Poked Job Name - build master

My job has no history of starting and failing.  This is true for all jobs relying on push hooks.  However, my jobs that run on pull request hooks are working, so I'm not sure what's wrong.

Any ideas?

Body:
Add this trigger block in your Jenkinsfile then run your job once manually.

pipeline {
    triggers {
       githubPush()
    }
}


问:
Changing Namespaces in Entity Framework
I am trying to change the Namespace used by Entity Framework Generator of classes.

When I click the designer of my Entity, Model.edmx, I can see somewhere where I can change the namespace:

Namespace

under ConceptualEntityModel properties. Changed that namespace, but nothing happened. Didn't work. So, I read some help from this link:

http://weblogs.asp.net/zeeshanhirani/struggling-through-namespace-in-entity-framework

says that I have to change the property: Custom Tool Namespace

That's nice, when I click property of .edmx in console application, there property is there. But when  I am using the same thing in a Web Application, the property is not there. There is only a property file called Web File Properties that simply has 3 properties:

Custom Tool

File Name

Full Path

What am I missing here?

答: My issue was that I had to rename a solution and the default namespace and assembly name hadn't gotten changed to the new name. After making sure your namespace is correct in the EDMX designer, right click on your project to open properties and update the default namespace and assembly name and we were good.</p>

Title: Changing Namespaces in Entity Framework


问:
Exception: Unexpected error while getting the method or property getContactGroups on object ContactsApp
I am making a gmail addon in which i am trying to get the user's contact groups (labels) using the code:

var groups = ContactsApp.getContactGroups();

I already have added required scope : https://www.google.com/m8/feeds in manifest file (appsscript.json) but it returns "Exception: Unexpected error while getting the method or property getContactGroups on object ContactsApp". This method was working fine when it was a default apps script project. I started getting this expection after linking my apps script project with Google cloud project. I am also using People API in my project. When I add https://www.google.com/m8/feeds in scopes on consent screen of Google cloud platform it does
 not show up there. Instead, https://www.googleapis.com/auth/contacts is shown in the scopes list. It might be because I am using People api and both of these scopes are for read/write user's contacts. And My consent screen on Google cloud platform is still under verification.

Also,I am not able to use any of the methods provived by ContactsApp class. I am getting the same exception when I used var contact = ContactsApp.getContact("abc@gmail.com");

Any help would be appreciated.

Thanks

答:
When changing from a default Apps Script project to a GCP project, you need to enable the necessary APIs in your GCP console

In your particular case you need to enable the Contacts API in your GCP console - for the chosen project

Depending on the rest of your code, you might need to enable also other APIs (e.g. Gmail)

Follow those instructions to enable the requested APIs


问:
Delphi Embarcadero XE: tons of warnings with String and PAnsiChar
I'm trying to migrate from Delphi 2007 to Embarcadero RAD Studio XE.
I'm getting tons of warnings.
They all look like this: I have a procedure where I declare a "String":

```<code>procedure SendMail( ADestinataire,ASubject : String);
</code>```

And I'm trying to call Windows API like:

```<code>  Res := MAPIResolveName(Session, Application.Handle,
    PAnsiChar(ADestinataire), MAPI_LOGON_UI, 0, PRecip);
</code>```

So the warnings are:

W1044: Transtyping string into PAnsiChar suspect.

What am I doing wrong / how should I correct this (350 warnings...)?

Thank you very much

答:
Just write

```<code>Res := MAPIResolveName(Session, Application.Handle,
  PChar(ADestinataire), MAPI_LOGON_UI, 0, PRecip);
</code>```

If you have a string, that is, a Unicode string, that is, a pointer to a sequence of Unicode characters, you shouldn't cast it to PAnsiChar. PAnsiChar is a pointer to a sequence of non-Unicode characters. Indeed, a cast to a PSomethingChar type simply tells the compiler to interpret the thing inside the cast as a pointer of the specified type. It doesn't do any conversion. So, basically, right now you lie to the compiler: You have a Unicode string and instructs the compiler to interpret it as an ANSI (non-Unicode) string. That's bad.

Instead, you should cast it to PWideChar, a pointer to a sequence of Unicode characters. In Delphi 2009+, PChar is equivalent to PWideChar.

Of course, if you send a pointer to a sequence of Unicode characters to the function, then the function had better expect Unicode characters, but I am not sure if this is the case of the MAPIResolveName function. I suspect that it actually requires ANSI (that is, non-Unicode) characters. If this is the case, you need to convert the Unicode string to an ANSI (non-Unicode) string. This is easy, just write AnsiString(ADestinataire). Then you cast to a ANSI (non-Unicode) PAnsiChar:

```<code>Res := MAPIResolveName(Session, Application.Handle,
  PANsiChar(AnsiString(ADestinataire)), MAPI_LOGON_UI, 0, PRecip);
</code>```

Body:
I'm trying to migrate from Delphi 2007 to Embarcadero RAD Studio XE.
I'm getting tons of warnings.
They all look like this: I have a procedure where I declare a "String":

procedure SendMail( ADestinataire,ASubject : String);

And I'm trying to call Windows API like:

  Res := MAPIResolveName(Session, Application.Handle,
    PAnsiChar(ADestinataire), MAPI_LOGON_UI, 0, PRecip);

So the warnings are:

W1044: Transtyping string into PAnsiChar suspect.

What am I doing wrong / how should I correct this (350 warnings...)?

Thank you very much

Body:
Just write

Res := MAPIResolveName(Session, Application.Handle,
  PChar(ADestinataire), MAPI_LOGON_UI, 0, PRecip);

If you have a string, that is, a Unicode string, that is, a pointer to a sequence of Unicode characters, you shouldn't cast it to PAnsiChar. PAnsiChar is a pointer to a sequence of non-Unicode characters. Indeed, a cast to a PSomethingChar type simply tells the compiler to interpret the thing inside the cast as a pointer of the specified type. It doesn't do any conversion. So, basically, right now you lie to the compiler: You have a Unicode string and instructs the compiler to interpret it as an ANSI (non-Unicode) string. That's bad.

Instead, you should cast it to PWideChar, a pointer to a sequence of Unicode characters. In Delphi 2009+, PChar is equivalent to PWideChar.

Of course, if you send a pointer to a sequence of Unicode characters to the function, then the function had better expect Unicode characters, but I am not sure if this is the case of the MAPIResolveName function. I suspect that it actually requires ANSI (that is, non-Unicode) characters. If this is the case, you need to convert the Unicode string to an ANSI (non-Unicode) string. This is easy, just write AnsiString(ADestinataire). Then you cast to a ANSI (non-Unicode) PAnsiChar:

Res := MAPIResolveName(Session, Application.Handle,
  PANsiChar(AnsiString(ADestinataire)), MAPI_LOGON_UI, 0, PRecip);


问:
Qemu restarts if I add a while loop in my kernel
I wrote a while loop that hangs when the keyboard controller is not ready:

```<code>while(inb(0x64)!=0){

  }
</code>```

However now qemu restarts everytime I attempt to boot the kernel. Sometimes I can see the vga output for a really short time.
I tried to remove the inb, and it still restarts unless I remove it

EDIT:

Here's the complete code:

```<code>int *resolution_ptr;

void init_vbe(){
    regs16_t vberegister;
  vberegister.bx=0x4107;
  vberegister.ax=0x4f02;
  int32(0x10,&vberegister);

  *resolution_ptr=1280;
}

void kernel_main(void)
{

  resolution_ptr=(int*)0x2ff0; /*define the address of the resolution, so that the printstring function can draw the letter correctly*/

  init_vbe ();
    printstring("Kernel sucessfully loaded.");

  while(inb(0x64)!=0){ /*code that cause qemu to restart*/
  }

}
</code>```

bochs thrown this error when I try to run my kernel in it:

```<code>00096454180e[CPU0  ] exception(): 3rd (13) exception with no resolution, shutdown status is 00h, resetting
</code>```

Also INT32 is from here:https://gist.github.com/carlosascari/35dba95ee3118ebf61f4bd1625f4fa11

答: Works now by removing sti in int32.</p>

Body:
I wrote a while loop that hangs when the keyboard controller is not ready:

while(inb(0x64)!=0){

  }

However now qemu restarts everytime I attempt to boot the kernel. Sometimes I can see the vga output for a really short time.
I tried to remove the inb, and it still restarts unless I remove it

EDIT:

Here's the complete code:

int *resolution_ptr;

void init_vbe(){
    regs16_t vberegister;
  vberegister.bx=0x4107;
  vberegister.ax=0x4f02;
  int32(0x10,&vberegister);

  *resolution_ptr=1280;
}

void kernel_main(void)
{

  resolution_ptr=(int*)0x2ff0; /*define the address of the resolution, so that the printstring function can draw the letter correctly*/

  init_vbe ();
    printstring("Kernel sucessfully loaded.");

  while(inb(0x64)!=0){ /*code that cause qemu to restart*/
  }

}

bochs thrown this error when I try to run my kernel in it:

00096454180e[CPU0  ] exception(): 3rd (13) exception with no resolution, shutdown status is 00h, resetting

Also INT32 is from here:https://gist.github.com/carlosascari/35dba95ee3118ebf61f4bd1625f4fa11

Body: Works now by removing sti in int32.


问:
How can I set the focus (and display the keyboard) on my EditText programmatically
I have a layout which contains some views like this:

```<code><LinearLayout>
<TextView...>
<TextView...>
<ImageView ...>
<EditText...>
<Button...>
</linearLayout>
</code>```

How can I set the focus (display the keyboard) on my EditText programmatically?

I've tried this and it works only when I launch my Activity normally, but when I launch it in a TabHost, it doesn't work.

```<code>txtSearch.setFocusableInTouchMode(true);
txtSearch.setFocusable(true);
txtSearch.requestFocus();
</code>```

答:
```<code>editTxt.setOnFocusChangeListener { v, hasFocus ->
            val imm = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
            if (hasFocus) {
                imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY)
            } else {
                imm.hideSoftInputFromWindow(v.windowToken, 0)
            }
        }
</code>```

Body:
I have a layout which contains some views like this:

<LinearLayout>
<TextView...>
<TextView...>
<ImageView ...>
<EditText...>
<Button...>
</linearLayout>

How can I set the focus (display the keyboard) on my EditText programmatically?

I've tried this and it works only when I launch my Activity normally, but when I launch it in a TabHost, it doesn't work.

txtSearch.setFocusableInTouchMode(true);
txtSearch.setFocusable(true);
txtSearch.requestFocus();


问:
Get Multiple Toggle Button values on the basis of id in Angular?
I am trying to get value of toggle button as yes or no .. since there are so many questions coming dynamically .I want to get this of basis of item.id .. I am using Angular and Required to write the logic in TS file . Any help will be appreciated

My Html:-

```<code>                  <div class="form-group">
                     {{item.id}}.<label>{{item.question}}</label>
                      <label class="switch">
                      <input type="checkbox" id="togBtn" (change)="getToggleButtonValue($event)">
                      <div class="slider round">
                        <span class="on">ON</span>
                        <span class="off">OFF</span>
                      </div>
                    </label>
</code>```

答:
html:

```<code><div class="form-group">
             {{item.id}}.<label>{{item.question}}</label>
             <label class="switch">
            <input type="checkbox" id="togBtn" #toggles data-id="{{item.id}}">
            <div class="slider round" >
             <span class="on">ON</span>
             <span class="off">OFF</span>
             </div>
            </label>
            </div>
</code>```

ts:

```<code>@ViewChildren("toggles") toggles: QueryList<ElementRef>;

getToggleByID(id) {
  let value = null;
  this.toggles.forEach(item => {
      if(item.nativeElement.getAttribute('data-id') === id){
         value = item.nativeElement.value;
      }
    });
  return value;
}
</code>```

Body:
I am trying to get value of toggle button as yes or no .. since there are so many questions coming dynamically .I want to get this of basis of item.id .. I am using Angular and Required to write the logic in TS file . Any help will be appreciated

My Html:-

                     {{item.id}}.{{item.question}}

                      <input type="checkbox" id="togBtn" (change)="getToggleButtonValue($event)">

                        ON
                        OFF

Body:
html:

<div class="form-group">
             {{item.id}}.<label>{{item.question}}</label>
             <label class="switch">
            <input type="checkbox" id="togBtn" #toggles data-id="{{item.id}}">
            <div class="slider round" >
             <span class="on">ON</span>
             <span class="off">OFF</span>
             </div>
            </label>
            </div>

ts:

@ViewChildren("toggles") toggles: QueryList<ElementRef>;

getToggleByID(id) {
  let value = null;
  this.toggles.forEach(item => {
      if(item.nativeElement.getAttribute('data-id') === id){
         value = item.nativeElement.value;
      }
    });
  return value;
}


问:
XSL Move one level Element into other while last one is appearing
Given the input XML data:

```<code><Report_Entry>
    <Time_Off_Type_Group>
        <Time_Off_Type Descriptor="Sickness Full" />
    </Time_Off_Type_Group>
    <Time_Off_Type_Group>
        <Time_Off_Type Descriptor="Sickness Part" />
    </Time_Off_Type_Group>
    <Time_Off_Entry_ID>2d90199913fa9fae8</Time_Off_Entry_ID>
    <Request_or_Correction>Time Off Request</Request_or_Correction>
</Report_Entry>
</code>```

As a result, I expect the output data via the condition: "for-each Time_Off_Type_Group move Time_Off_Entry_ID and Request_or_Correction into the Time_Off_Type_Group"

Output example:

```<code><Report_Entry>
    <Time_Off_Type_Group>
        <Time_Off_Type Descriptor="Sickness Full" />
        <Time_Off_Entry_ID>2d90199913fa9fae8</Time_Off_Entry_ID>
        <Request_or_Correction>Time Off Request</Request_or_Correction>
    </Time_Off_Type_Group>
    <Time_Off_Type_Group>
        <Time_Off_Type Descriptor="Sickness Part" />
        <Time_Off_Entry_ID>2d90199913fa9fae8</Time_Off_Entry_ID>
        <Request_or_Correction>Time Off Request</Request_or_Correction>
    </Time_Off_Type_Group>
</Report_Entry>
</code>```

答:
Or shortly:</p>

```<code><xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>

<xsl:template match="/Report_Entry">
    <xsl:variable name="common" select="Time_Off_Entry_ID | Request_or_Correction" />
    <xsl:copy>
        <xsl:for-each select="Time_Off_Type_Group">
            <xsl:copy>
                <xsl:copy-of select="* | $common"/>
            </xsl:copy>
        </xsl:for-each>
    </xsl:copy>
</xsl:template>

</xsl:stylesheet>
</code>```

Body:
Given the input XML data:

<Report_Entry>
    <Time_Off_Type_Group>
        <Time_Off_Type Descriptor="Sickness Full" />
    </Time_Off_Type_Group>
    <Time_Off_Type_Group>
        <Time_Off_Type Descriptor="Sickness Part" />
    </Time_Off_Type_Group>
    <Time_Off_Entry_ID>2d90199913fa9fae8</Time_Off_Entry_ID>
    <Request_or_Correction>Time Off Request</Request_or_Correction>
</Report_Entry>

As a result, I expect the output data via the condition: "for-each Time_Off_Type_Group move Time_Off_Entry_ID and Request_or_Correction into the Time_Off_Type_Group"

Output example:

<Report_Entry>
    <Time_Off_Type_Group>
        <Time_Off_Type Descriptor="Sickness Full" />
        <Time_Off_Entry_ID>2d90199913fa9fae8</Time_Off_Entry_ID>
        <Request_or_Correction>Time Off Request</Request_or_Correction>
    </Time_Off_Type_Group>
    <Time_Off_Type_Group>
        <Time_Off_Type Descriptor="Sickness Part" />
        <Time_Off_Entry_ID>2d90199913fa9fae8</Time_Off_Entry_ID>
        <Request_or_Correction>Time Off Request</Request_or_Correction>
    </Time_Off_Type_Group>
</Report_Entry>

Body:
Or shortly:

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>

<xsl:template match="/Report_Entry">
    <xsl:variable name="common" select="Time_Off_Entry_ID | Request_or_Correction" />
    <xsl:copy>
        <xsl:for-each select="Time_Off_Type_Group">
            <xsl:copy>
                <xsl:copy-of select="* | $common"/>
            </xsl:copy>
        </xsl:for-each>
    </xsl:copy>
</xsl:template>

</xsl:stylesheet>


问:
Xamarin Forms to Xamarin.Android
I have some pages in Xamarin.Forms,since I need to build a custom camera,so I used Xamarin.Android.
now I need to go to Xamarin.Android/iOS from page of  Xamarin.Forms and  and back to Xamarin.Forms again. how can I do it?
pls help</p>

答:
You don't necessarily need to jump between Xamarin.Forms Views/Pages and Project Specific (iOS/Android) Views manually you can do it by using CustomRenderes which are part of Xamarin.Forms.

Basically you would create a Custom Page on Xamarin.Forms then specifying in each platform project how you want that page to look. You would attach this CustomRender to your Custom Page (the one you made in Xamarin.Forms) and the Framework would do the rest for you.

You can read about Custom Renderers here. And you can see a very similar example of what you are looking right in the Xamarin documentation here.

Hope this helps.-

Title: Xamarin Forms to Xamarin.Android


问:
Skip duplicates on field in a Elasticsearch search result
Is it possible to remove duplicates on a given field?

For example the following query:

```<code>{
  "query": {
    "term": {
      "name_admin": {
        "value": "nike"
      }
    }
  },
  "_source": [
    "name_admin",
    "parent_sku",
    "sku"
  ],
  "size": 2
}
</code>```

is retrieving

```<code>"hits" : [
      {
        "_index" : "product",
        "_type" : "_doc",
        "_id" : "central30603",
        "_score" : 4.596813,
        "_source" : {
          "parent_sku" : "SSP57",
          "sku" : "SSP57816401",
          "name_admin" : "NIKE U NSW PRO CAP NIKE AIR"
        }
      },
      {
        "_index" : "product",
        "_type" : "_doc",
        "_id" : "central156578",
        "_score" : 4.596813,
        "_source" : {
          "parent_sku" : "SSP57",
          "sku" : "SSP57816395",
          "name_admin" : "NIKE U NSW PRO CAP NIKE AIR"
        }
      }
    ]
</code>```

I'd like to skip duplicates on parent_sku so I only have one result per parent_sku like it's possible with suggestion by doing something like "skip_duplicates": true.

I know I cloud achieve this with an aggregation but I'd like to stick with a search, as my query is a bit more complicated and as I'm using the scroll API which doesn't work with aggregations.

答:
Field collapsing should help here

```<code>{
  "query": {
    "term": {
      "name_admin": {
        "value": "nike"
      }
    }
  },
  "collapse" : {
      "field" : "parent_sku",
      "inner_hits": {
          "name": "parent",
          "size": 1
      }
  },
  "_source": false,
  "size": 2
}
</code>```

The above query will return one document par parent_sku.

Body:
Is it possible to remove duplicates on a given field?

For example the following query:

{
  "query": {
    "term": {
      "name_admin": {
        "value": "nike"
      }
    }
  },
  "_source": [
    "name_admin",
    "parent_sku",
    "sku"
  ],
  "size": 2
}

is retrieving

"hits" : [
      {
        "_index" : "product",
        "_type" : "_doc",
        "_id" : "central30603",
        "_score" : 4.596813,
        "_source" : {
          "parent_sku" : "SSP57",
          "sku" : "SSP57816401",
          "name_admin" : "NIKE U NSW PRO CAP NIKE AIR"
        }
      },
      {
        "_index" : "product",
        "_type" : "_doc",
        "_id" : "central156578",
        "_score" : 4.596813,
        "_source" : {
          "parent_sku" : "SSP57",
          "sku" : "SSP57816395",
          "name_admin" : "NIKE U NSW PRO CAP NIKE AIR"
        }
      }
    ]

I'd like to skip duplicates on parent_sku so I only have one result per parent_sku like it's possible with suggestion by doing something like "skip_duplicates": true.

I know I cloud achieve this with an aggregation but I'd like to stick with a search, as my query is a bit more complicated and as I'm using the scroll API which doesn't work with aggregations.

Body:
Field collapsing should help here

{
  "query": {
    "term": {
      "name_admin": {
        "value": "nike"
      }
    }
  },
  "collapse" : {
      "field" : "parent_sku",
      "inner_hits": {
          "name": "parent",
          "size": 1
      }
  },
  "_source": false,
  "size": 2
}

The above query will return one document par parent_sku.


问:
'utf8' codec can't decode byte 0xb5 in position 0: invalid start byte error
I am trying to create a pdf file from an html with the WeasyPrint library, I am following this tutorial:

https://www.bedjango.com/blog/how-generate-pdf-django-weasyprint/

But is giving the error of the description. Could someone help me?

Edit:
debugging I realized that the error occurs when I apply the output.read ()

```<code>def termoPDFView(request, id):
    termo = TermoReferenciaPregao.objects.get(id=id)

    html_string = render_to_string('painel/report/termo-referencia-pdf.html', {'termo': termo})
    pdf = HTML(string=html_string).write_pdf()

    response = HttpResponse(content_type='application/pdf;')
    response['Content-Disposition'] = 'inline; filename=termo-referencia.pdf'
    response['Content-Transfer-Encoding'] = 'utf-8'

    with tempfile.NamedTemporaryFile(delete=True) as output:
        output.write(pdf)
        output.flush()
        output = open(output.name, 'r')
        response.write(output.read())

    return response
</code>```

答:
Thanks to anyone who saw the question and tried to resolve. Got it! The "b" mode was missing.</p>
```<code>output = open(output.name, 'rb')
</code>```

Body:
I am trying to create a pdf file from an html with the WeasyPrint library, I am following this tutorial:

https://www.bedjango.com/blog/how-generate-pdf-django-weasyprint/

But is giving the error of the description. Could someone help me?

Edit:
debugging I realized that the error occurs when I apply the output.read ()

def termoPDFView(request, id):
    termo = TermoReferenciaPregao.objects.get(id=id)

    html_string = render_to_string('painel/report/termo-referencia-pdf.html', {'termo': termo})
    pdf = HTML(string=html_string).write_pdf()

    response = HttpResponse(content_type='application/pdf;')
    response['Content-Disposition'] = 'inline; filename=termo-referencia.pdf'
    response['Content-Transfer-Encoding'] = 'utf-8'

    with tempfile.NamedTemporaryFile(delete=True) as output:
        output.write(pdf)
        output.flush()
        output = open(output.name, 'r')
        response.write(output.read())

    return response

Body:
Thanks to anyone who saw the question and tried to resolve. Got it! The "b" mode was missing.

output = open(output.name, 'rb')


问:
Selenium popup support
Please give me an example java code to open a popup and move RC control to popup.
is there any way to come back on main window after checking some element on popup window.

I have few questions on this as selenium always need windowid  to get control over popup.

1-What is the best way to get the windowid of any popup.

2-Should i have to search it in view sources of base page.

3-is it necessary that we must get the windowid of the each & every popup in the view source of the page. if not so what will be work-around.

4-Is window id present in any java-script function? if so ,there is one example
I didn’t get Window id of popup

script language="javascript"

begin

function popup(){

window.open('URL/to/popup.html','PopupName','toolbar=0,location=0,
status=0,menubar=0,scrollbars=0,resizable=0,width=345,height=400');
}

// end

/script

答:
This will definitely help you. Handling Popups

Hope this helps

Title: Selenium popup support


问:
Snowflake SSIS package failure Error Code 370001
We had an unusual failure last night where the SSIS package was loading data into Snowflake Database.
It failed with the error below:

We did not get any error message in the Snowflake itself  when we checked the history and when we re-ran the package it ran fine.
Could someone please advise on why it has occurred.

Thanks in advance.

Arti

答: It seems there was a transient issue on Cloud Service Layer. To get more detailed information about the internal error, you need to submit a support ticket to Snowflake.</p>


问:
LINQ - Will FirstOrDefault() always return the same record?
if I have the following 'User' table

```<code>UserName UserID
-------- ------
abc      1
xyz      2
pqr      2

</code>```

and the following linq query:

```<code>_context.User.OrderByDescending(x => x.UserID).FirstOrDefault();
</code>```

will the result always be consistent?

as in will I always get either user with UserName 'xyz' or user with UserName 'pqr' or will it be random?

答:
Caveat: I am assuming here that the UserId column on the User table is a PKID and is unique.

You are issuing an ordered query, so yes: it will always return the pqr record (until the data changes, obviously). The SQL will be something like:

select top 1 *
from User
order by UserId desc
```

but you can find out the actual SQL by checking with a SQL trace.

If you didn't have the OrderByDescending: there would be no guarantees.

Body:
if I have the following 'User' table

UserName UserID
-------- ------
abc      1
xyz      2
pqr      2

and the following linq query:

_context.User.OrderByDescending(x => x.UserID).FirstOrDefault();

will the result always be consistent?

as in will I always get either user with UserName 'xyz' or user with UserName 'pqr' or will it be random?

Body:
Caveat: I am assuming here that the UserId column on the User table is a PKID and is unique.

You are issuing an ordered query, so yes: it will always return the pqr record (until the data changes, obviously). The SQL will be something like:

select top 1 *
from User
order by UserId desc

but you can find out the actual SQL by checking with a SQL trace.

If you didn't have the OrderByDescending: there would be no guarantees.


问:
AAD B2C - Is a user authorized to change their own custom attributes?
I want to use custom attributes in AAD B2C as a shortcut for authorization. I would love to set values on users that I can use in my apis to know what they have access to do.

I see that I can create a User flow for a user to edit their own attributes, but that is the opposite of what I want.

If I don't create a user flow to edit the attribute, can I be confident that the user can't edit it on their own through Microsoft Graph or something like that? I tried doing it through graph but I can't tell if I did something wrong or if the user is not allowed to change it.

答: I don't think users can adjust their own attributes if they don't have the graph permissions in Azure. When signing in your users within your application you can allow them to access certain scopes. As long as they cant access these scopes they cannot perform any actions on the graph API. Updating user details would in this case require 'User.ReadWrite' scope assigned.</p>


问:
jQuery datatable - Select list within column
I am currently pulling data in a jQuery datatable which is grand! But I am having an issue with the Role column.

I am trying to inset a select list in that column which will have two options "admin" & "User" and whatever data is in the array set that value within the select list.

But I haven't been able to render select list into the table then set it to admin or user based on whats in the array.

jQuery(function($) {
  var data = [
    ["test1", "admin", "yes"],
    ["test2", "admin", "yes"],
    ["test3", "user", "no"],
    ["test4", "user", "no"]
  ]

  function authusers() {
    t = $('#authTable').DataTable({
      retrieve: true,
      paging: false,
      data: data,
      columns: [{
        "title": "Email",
        "render": function(data, type, row, meta) {
          return row[0];
        }
      }, {
        "title": "Role",
        "render": function(data, type, row, meta) {
          return row[1];
        }
      }, {
        "title": "Active",
        "render": function(data, type, row, meta) {
          var checkbox = $("<input/>", {
            "type": "checkbox"
          });
          checkbox.attr("checked", (row[2] === "yes"));
          checkbox.addClass((row[2] === "yes") ? "checkbox_checked" : "checkbox_unchecked")
          return checkbox.prop("outerHTML")
        }
      }, ],
      order: []
    });
  }

  //Passes value and if it was enabled or disabled value to serverside.
  $(document).on('click', '.checkbox_checked , .checkbox_unchecked', function() {
    if ($(this).is(':checked')) {
      var rowIndex = $(this).closest('tr').find('td:eq(0)').text();
      var status = 'yes';
    } else if ($(this).prop('checked', false)) {
      var rowIndex = $(this).closest('tr').find('td:eq(0)').text();
      var status = 'no';
    }
  });
  authusers();
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><link href="//cdn.datatables.net/1.10.11/css/jQuery.dataTables.min.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="//cdn.datatables.net/1.10.11/js/jquery.dataTables.min.js"></script>

<body>
  <table class="display" id="authTable" width="60%">
    <thead>
      <tr>
        <th>Email</th>
        <th>Active</th>
        <th>Role</th>
      </tr>
    </thead>
    <tbody>
    </tbody>
  </table>
</body></code>```

And also a JSfiddle

Any advice or recommendations are welcome!

答:
Here is how I've achieved something like this, May be helpful for someone :)</p>

```<code> {
    "title": "", "render": function (data, type, full, meta) {
        var html = '<div>';
        var $select = $("<select></select>", {
            "id": "EmployeeId_"+ full.Id,
            "value": full.Name
        });
        $select.append("<option value =''></option>");
        $.each(full.EmployeeList, function (index, element) {
            var $option = $("<option></option>", {
                "text": element.Id,
                "value": element.Name
            });

            if (full.Id === element.Id) {
                $option.attr("selected", "selected")
            }

            $select.append($option);
        });

        html += $select[0].outerHTML;
        html += '<a href="#" onclick="changeName(this,' + full.Id + ')" id="tag' + full.Id + '">Change</a>';
        html += '</div>';

        return html;
    }
}
</code>```

Body:
I am currently pulling data in a jQuery datatable which is grand! But I am having an issue with the Role column.

I am trying to inset a select list in that column which will have two options "admin" & "User" and whatever data is in the array set that value within the select list.

But I haven't been able to render select list into the table then set it to admin or user based on whats in the array.

jQuery(function($) {
  var data = [
    ["test1", "admin", "yes"],
    ["test2", "admin", "yes"],
    ["test3", "user", "no"],
    ["test4", "user", "no"]
  ]

  function authusers() {
    t = $('#authTable').DataTable({
      retrieve: true,
      paging: false,
      data: data,
      columns: [{
        "title": "Email",
        "render": function(data, type, row, meta) {
          return row[0];
        }
      }, {
        "title": "Role",
        "render": function(data, type, row, meta) {
          return row[1];
        }
      }, {
        "title": "Active",
        "render": function(data, type, row, meta) {
          var checkbox = $("<input/>", {
            "type": "checkbox"
          });
          checkbox.attr("checked", (row[2] === "yes"));
          checkbox.addClass((row[2] === "yes") ? "checkbox_checked" : "checkbox_unchecked")
          return checkbox.prop("outerHTML")
        }
      }, ],
      order: []
    });
  }

  //Passes value and if it was enabled or disabled value to serverside.
  $(document).on('click', '.checkbox_checked , .checkbox_unchecked', function() {
    if ($(this).is(':checked')) {
      var rowIndex = $(this).closest('tr').find('td:eq(0)').text();
      var status = 'yes';
    } else if ($(this).prop('checked', false)) {
      var rowIndex = $(this).closest('tr').find('td:eq(0)').text();
      var status = 'no';
    }
  });
  authusers();
});

<link href="//cdn.datatables.net/1.10.11/css/jQuery.dataTables.min.css" rel="stylesheet" />

        Email
        Active
        Role

And also a JSfiddle

Any advice or recommendations are welcome!

Body:
Here is how I've achieved something like this, May be helpful for someone :)

 {
    "title": "", "render": function (data, type, full, meta) {
        var html = '<div>';
        var $select = $("<select></select>", {
            "id": "EmployeeId_"+ full.Id,
            "value": full.Name
        });
        $select.append("<option value =''></option>");
        $.each(full.EmployeeList, function (index, element) {
            var $option = $("<option></option>", {
                "text": element.Id,
                "value": element.Name
            });

            if (full.Id === element.Id) {
                $option.attr("selected", "selected")
            }

            $select.append($option);
        });

        html += $select[0].outerHTML;
        html += '<a href="#" onclick="changeName(this,' + full.Id + ')" id="tag' + full.Id + '">Change</a>';
        html += '</div>';

        return html;
    }
}


问:
N1ql count distinct associated documents
I have a single bucket (Couchbase Community edition 6.5) consisting of the following documents:

```<code>employee {
    type: "Employee"
}
X {
    type: "X",
    employeeId: string,
    date: string
}
Y {
    type: "Y",
    employeeId: string,
    date: string
}
Z {
    type: "Z",
    employeeId: string,
    date: string
}
</code>```

I need to get the total number of documents (X,Y,Z) that are associated with each employee between two dates.

I have written the following query that works but with slow execution time:

```<code>CREATE INDEX `index_X` ON `bucket`(`type`,`date`, `employeeId`)
WHERE type = "X"
CREATE INDEX `index_Y` ON `bucket`(`type`,`date`, `employeeId`)
WHERE type = "Y"
CREATE INDEX `index_Z` ON `bucket`(`type`,`date`, `employeeId`)
WHERE type = "Z"

SELECT META(employee).id,
       x.totalX,
       y.totalY,
       z.totalZ,
FROM `bucket` employee
    LEFT JOIN (
    SELECT obj.employeeId,
           COUNT(obj.employeeId) AS totalX
    FROM `bucket` obj
    WHERE obj.type = "X"
        AND obj.date BETWEEN "startDate" AND "endDate"
    GROUP BY obj.employeeId) x ON x.employeeId = META(employee).id
    LEFT JOIN (
    SELECT obj.employeeId,
           COUNT(obj.employeeId) AS totalY
    FROM `bucket` obj
    WHERE obj.type = "Y"
        AND obj.date BETWEEN "startDate" AND "endDate"
    GROUP BY obj.employeeId) y ON y.employeeId = META(employee).id
    LEFT JOIN (
    SELECT obj.employeeId,
           COUNT(obj.employeeId) AS totalZ
    FROM `bucket` obj
    WHERE obj.type = "Z"
        AND obj.date BETWEEN "startDate" AND "endDate"
    GROUP BY obj.employeeId) z ON z.employeeId = META(employee).id
WHERE employee.type = "Employee"
</code>```

I also tried the following but this query times out completely!

```<code>CREATE INDEX `index_X` ON `bucket`(`type`,`date`, `employeeId`)
WHERE type = "X"
CREATE INDEX `index_Y` ON `bucket`(`type`,`date`, `employeeId`)
WHERE type = "Y"
CREATE INDEX `index_Z` ON `bucket`(`type`,`date`, `employeeId`)
WHERE type = "Z"

SELECT META(employee).id,
       COUNT(x.employeeId),
       COUNT(y.employeeId),
       COUNT(z.employeeId)
FROM `bucket` employee
    LEFT JOIN `bucket` x ON x.employeeId = META(employee).id
    AND x.type = "X"
    AND x.date BETWEEN "startDate" AND "endDate"
    LEFT JOIN `bucket` y ON y.employeeId = META(employee).id
    AND y.type = "Y"
    AND y.date BETWEEN "startDate" AND "endDate"
    LEFT JOIN `bucket` z ON z.employeeId = META(employee).id
    AND z.type = "Z"
    AND z.date BETWEEN "startDate" AND "endDate"
WHERE employee.type = "Employee"
GROUP BY META(employee).id
</code>```

Can anyone please advise on a more optimal route to follow?

With both queries I can see that my indexes are being used but I can also see in my query plan that for every join a "NestedLoopJoin" is being chained to the previous one. Could this possibly be the problem?

I am still new to writing n1ql queries and trying to figure out the most efficient methods so any advice will be welcome.

答:
```<code>CREATE INDEX `index_1` ON `agrigistics_dev`(`employeeId`, type, `date`) WHERE type IN ["X", "Y", "Z"];

SELECT META(employee).id,
       SUM(CASE x.type = "X" THEN 1 ELSE 0 END) xcount,
       SUM(CASE x.type = "Y" THEN 1 ELSE 0 END) ycount,
       SUM(CASE x.type = "Z" THEN 1 ELSE 0 END) zcount
FROM `bucket` employee
LEFT JOIN `bucket` x
           ON x.employeeId = META(employee).id AND x.type IN ["X", "Y", "Z"] AND x.date BETWEEN "startDate" AND "endDate"
WHERE employee.type = "Employee"
GROUP BY META(employee).id;
</code>```

To avoid case-cade nested-loop join or explosion of join use CTE(6.5) in this case

```<code>CREATE INDEX `index_1` ON `agrigistics_dev`(type, date, `employeeId`) WHERE type IN ["X", "Y", "Z"];

WITH etype AS (SELECT x.employeeId,
               SUM(CASE x.type = "X" THEN 1 ELSE 0 END) xcount,
               SUM(CASE x.type = "Y" THEN 1 ELSE 0 END) ycount,
               SUM(CASE x.type = "Z" THEN 1 ELSE 0 END) zcount
               FROM `bucket` x
               WHERE x.type IN ["X", "Y", "Z"] AND x.date BETWEEN "startDate" AND "endDate"
               GROUP BY x.employeeId)
SELECT META(employee).id,
       SUM(y.xcount) xcount,
       SUM(y.ycount) ycount,
       SUM(y.zcount) zcount
FROM `bucket` AS employee
LEFT JOIN etype AS y ON y.employeeId = META(employee).id
WHERE employee.type = "Employee"
GROUP BY META(employee).id;
</code>```

https://index-advisor.couchbase.com/indexadvisor/#1

https://blog.couchbase.com/create-right-index-get-right-performance/

Body:
I have a single bucket (Couchbase Community edition 6.5) consisting of the following documents:

employee {
    type: "Employee"
}
X {
    type: "X",
    employeeId: string,
    date: string
}
Y {
    type: "Y",
    employeeId: string,
    date: string
}
Z {
    type: "Z",
    employeeId: string,
    date: string
}

I need to get the total number of documents (X,Y,Z) that are associated with each employee between two dates.

I have written the following query that works but with slow execution time:

CREATE INDEX `index_X` ON `bucket`(`type`,`date`, `employeeId`)
WHERE type = "X"
CREATE INDEX `index_Y` ON `bucket`(`type`,`date`, `employeeId`)
WHERE type = "Y"
CREATE INDEX `index_Z` ON `bucket`(`type`,`date`, `employeeId`)
WHERE type = "Z"

SELECT META(employee).id,
       x.totalX,
       y.totalY,
       z.totalZ,
FROM `bucket` employee
    LEFT JOIN (
    SELECT obj.employeeId,
           COUNT(obj.employeeId) AS totalX
    FROM `bucket` obj
    WHERE obj.type = "X"
        AND obj.date BETWEEN "startDate" AND "endDate"
    GROUP BY obj.employeeId) x ON x.employeeId = META(employee).id
    LEFT JOIN (
    SELECT obj.employeeId,
           COUNT(obj.employeeId) AS totalY
    FROM `bucket` obj
    WHERE obj.type = "Y"
        AND obj.date BETWEEN "startDate" AND "endDate"
    GROUP BY obj.employeeId) y ON y.employeeId = META(employee).id
    LEFT JOIN (
    SELECT obj.employeeId,
           COUNT(obj.employeeId) AS totalZ
    FROM `bucket` obj
    WHERE obj.type = "Z"
        AND obj.date BETWEEN "startDate" AND "endDate"
    GROUP BY obj.employeeId) z ON z.employeeId = META(employee).id
WHERE employee.type = "Employee"

I also tried the following but this query times out completely!

CREATE INDEX `index_X` ON `bucket`(`type`,`date`, `employeeId`)
WHERE type = "X"
CREATE INDEX `index_Y` ON `bucket`(`type`,`date`, `employeeId`)
WHERE type = "Y"
CREATE INDEX `index_Z` ON `bucket`(`type`,`date`, `employeeId`)
WHERE type = "Z"

SELECT META(employee).id,
       COUNT(x.employeeId),
       COUNT(y.employeeId),
       COUNT(z.employeeId)
FROM `bucket` employee
    LEFT JOIN `bucket` x ON x.employeeId = META(employee).id
    AND x.type = "X"
    AND x.date BETWEEN "startDate" AND "endDate"
    LEFT JOIN `bucket` y ON y.employeeId = META(employee).id
    AND y.type = "Y"
    AND y.date BETWEEN "startDate" AND "endDate"
    LEFT JOIN `bucket` z ON z.employeeId = META(employee).id
    AND z.type = "Z"
    AND z.date BETWEEN "startDate" AND "endDate"
WHERE employee.type = "Employee"
GROUP BY META(employee).id

Can anyone please advise on a more optimal route to follow?

With both queries I can see that my indexes are being used but I can also see in my query plan that for every join a "NestedLoopJoin" is being chained to the previous one. Could this possibly be the problem?

I am still new to writing n1ql queries and trying to figure out the most efficient methods so any advice will be welcome.

Body:
CREATE INDEX `index_1` ON `agrigistics_dev`(`employeeId`, type, `date`) WHERE type IN ["X", "Y", "Z"];

SELECT META(employee).id,
       SUM(CASE x.type = "X" THEN 1 ELSE 0 END) xcount,
       SUM(CASE x.type = "Y" THEN 1 ELSE 0 END) ycount,
       SUM(CASE x.type = "Z" THEN 1 ELSE 0 END) zcount
FROM `bucket` employee
LEFT JOIN `bucket` x
           ON x.employeeId = META(employee).id AND x.type IN ["X", "Y", "Z"] AND x.date BETWEEN "startDate" AND "endDate"
WHERE employee.type = "Employee"
GROUP BY META(employee).id;

To avoid case-cade nested-loop join or explosion of join use CTE(6.5) in this case

CREATE INDEX `index_1` ON `agrigistics_dev`(type, date, `employeeId`) WHERE type IN ["X", "Y", "Z"];

WITH etype AS (SELECT x.employeeId,
               SUM(CASE x.type = "X" THEN 1 ELSE 0 END) xcount,
               SUM(CASE x.type = "Y" THEN 1 ELSE 0 END) ycount,
               SUM(CASE x.type = "Z" THEN 1 ELSE 0 END) zcount
               FROM `bucket` x
               WHERE x.type IN ["X", "Y", "Z"] AND x.date BETWEEN "startDate" AND "endDate"
               GROUP BY x.employeeId)
SELECT META(employee).id,
       SUM(y.xcount) xcount,
       SUM(y.ycount) ycount,
       SUM(y.zcount) zcount
FROM `bucket` AS employee
LEFT JOIN etype AS y ON y.employeeId = META(employee).id
WHERE employee.type = "Employee"
GROUP BY META(employee).id;

https://index-advisor.couchbase.com/indexadvisor/#1

https://blog.couchbase.com/create-right-index-get-right-performance/


问:
How to prevent spamming bullets in pygame
In my game, there is a problem with bullet spamming, because the player can shoot a lot of bullets in a short time. How can I prevent the player to do that? Should I use a clock? And how can I use the clock? Here it is some code:

```<code>class Player (Obj):
    def command (self, shoot):
        keys = pg.key.get_pressed()
        self.shoot = shoot
        if keys[shoot]:
            self.Shoot()
    def Shoot(self):
        global prts
        prts.append (Ammo(player.x, player.y, prt_img ))
        print (prts)

while True:
    window.fill(WHITE)
    player.blit()
    player.command(pg.K_SPACE)
    for ammo in prts:
        ammo.blit()
        ammo.Move(0.5)
        ammo.BordCheck()
    pg.display.update()
</code>```

Here it is an image of what happens

Sorry for any mistakes

答:
Pygame by default will trigger the key pressed event as fast as your computer can handle it (meaning the better the computer, the faster you will shoot). This has been a common issue in old video games that were only tested on one computer.

Adding a 'clock' is a good way of fixing the problem. For example if you want the player to shoot no faster than a bullet every half a second, you can get the current time when he shoots and then on the next shoot you check the time, if less than 1/2 second has passed you don t shoot, else you shoot and update the time with the time of the new bullet.

For more optimization, you might even want to completely block the keyboard input from firing a 'shooting key pressed' event while the player cannot shoot but that is a minor optimization that shouldn t be necessary in a small game.

To manipulate time in python, you can use the time and datetime default modules. I often suggest using arrow if you have a lot of times and dates to manipulate as it is a bit simpler I think.

Here is an example comparing seconds using datetime :

```<code>#!/usr/bin/env python3

from datetime import datetime

t1 = datetime.strptime("Feb 12 08:02:34 2015", "%b %d %H:%M:%S %Y")
t2 = datetime.strptime("Feb 12 08:02:32 2015", "%b %d %H:%M:%S %Y")

difference = t1 - t2

print(difference.seconds) # 2, in this case
</code>```

Does this solve your problem ?

Body:
In my game, there is a problem with bullet spamming, because the player can shoot a lot of bullets in a short time. How can I prevent the player to do that? Should I use a clock? And how can I use the clock? Here it is some code:

class Player (Obj):
    def command (self, shoot):
        keys = pg.key.get_pressed()
        self.shoot = shoot
        if keys[shoot]:
            self.Shoot()
    def Shoot(self):
        global prts
        prts.append (Ammo(player.x, player.y, prt_img ))
        print (prts)

while True:
    window.fill(WHITE)
    player.blit()
    player.command(pg.K_SPACE)
    for ammo in prts:
        ammo.blit()
        ammo.Move(0.5)
        ammo.BordCheck()
    pg.display.update()

Here it is an image of what happens

Sorry for any mistakes

Body:
Pygame by default will trigger the key pressed event as fast as your computer can handle it (meaning the better the computer, the faster you will shoot). This has been a common issue in old video games that were only tested on one computer.

Adding a 'clock' is a good way of fixing the problem. For example if you want the player to shoot no faster than a bullet every half a second, you can get the current time when he shoots and then on the next shoot you check the time, if less than 1/2 second has passed you don t shoot, else you shoot and update the time with the time of the new bullet.

For more optimization, you might even want to completely block the keyboard input from firing a 'shooting key pressed' event while the player cannot shoot but that is a minor optimization that shouldn t be necessary in a small game.

To manipulate time in python, you can use the time and datetime default modules. I often suggest using arrow if you have a lot of times and dates to manipulate as it is a bit simpler I think.

Here is an example comparing seconds using datetime :

#!/usr/bin/env python3

from datetime import datetime

t1 = datetime.strptime("Feb 12 08:02:34 2015", "%b %d %H:%M:%S %Y")
t2 = datetime.strptime("Feb 12 08:02:32 2015", "%b %d %H:%M:%S %Y")

difference = t1 - t2

print(difference.seconds) # 2, in this case

Does this solve your problem ?


问:
Orphaned Artifact iMessage Extension - iOS Bug
I have added an embedded iMessage extension to my app like so:

When I update my app via TestFlight or the App Store my iMessage extension is installed without uninstalling the old causing the iMessage Extension to become completely unusable:

"Messages Extension Plugin"

If I touch the switch of Messages Extension Plugin, two switches turn off and on because they have the same identifier or reference on the list. My app and "Messages Extension Plugin"

You can reproduce this error in a similar way by installing the Delta app that has an embedded iMessage Extension. Then delete the Delta app and reinstall, you will see an orphaned Messages Extension Plugin artifact.

答:
Not a developer here, but as a user, this is a bug I've dealt with for years on multiple phones, with multiple apps. Once an app updates if I want the image to show up in the iMessage share bar I have to:

Remove it from the share bar

Uninstall the app

Reinstall the app

Add it back to the share bar

Even this only has an 80% success rate (estimating obviously). I'm glad to hear some developers are reporting it as a bug, maybe it will finally get fixed. Reinstalling a couple of apps each time they update is very much a first-world problem, but annoying nonetheless.