问:
Getting memory leaks in Glib/GDBus code?
I'm using GDBus (via Glib) and I have code like:

```<code>  method_call_message = g_dbus_message_new_method_call(owner,
                                                       OBJECT_PATH,
                                                       INTERFACE_NAME,
                                                       "get_snmpv2_mib");

  GVariant *gv = g_variant_new("(sissi)", ip, port, mib, variable, instance);

  g_dbus_message_set_body(method_call_message, gv);
</code>```

I assume method_call_message is now a container for gv.

Before exiting I call:

```<code> g_object_unref(method_call_message);
</code>```

I assume this will then schedule BOTH method_call_message and gv for GC?

When is GC done?

I appear to be leaking some 4 bytes at a time as I watch the top updates on VIRT memory.

I have commented out pieces of code till I localized it (the leak) to my GDBus calls.

答:
Using some Valgrind magic:

```<code>libtool exec valgrind --tool=memcheck --leak-check=full --log-file=w <executable + args>
</code>```

I was able to winnow out the memory management obfuscation and get to a call-stack that showed the problem. The Valgrind output indicated that all my memory losses were associated with calls to g_variant_get(...):

```<code>at 0x4A06A2E: malloc (vg_replace_malloc.c:270)
==20088==    by 0x3F21E503B6: g_malloc (in /usr/lib64/libglib-2.0.so.0.4400.1)
==20088==    by 0x3F21E6860D: g_strdup (in /usr/lib64/libglib-2.0.so.0.4400.1)
==20088==    by 0x3F21E7FD01: ??? (in /usr/lib64/libglib-2.0.so.0.4400.1)
==20088==    by 0x3F21E7FA61: ??? (in /usr/lib64/libglib-2.0.so.0.4400.1)
==20088==    by 0x3F21E80348: g_variant_get_va (in /usr/lib64/libglib-2.0.so.0.4400.1)
==20088==    by 0x3F21E80585: g_variant_get (in /usr/lib64/libglib-2.0.so.0.4400.1)
==20088==    by 0x4C30555: server_gvariant (in /usr/lib64/libdrsnvc.so)
==20088==    by 0x40257B: NVCtimerCB(void*) (main.cc:73)
==20088==    by 0x3F21E48C3A: ??? (in /usr/lib64/libglib-2.0.so.0.4400.1)
==20088==    by 0x3F21E48519: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.4400.1)
==20088==    by 0x3F21E4A5A7: ??? (in /usr/lib64/libglib-2.0.so.0.4400.1)
</code>```

Obviously the call to g_variant_get(...) begats a call to g_strdup(...) (if your format_string includes an 's' for string). So, in my case, the code is:

```<code>g_variant_get(response, "(isi)", &od.stat, &od.msg, &od.i);
gchar *tmp = od.msg;
od.msg = strncpy(msg, od.msg, strlen(od.msg)); /* copy string */
g_free(tmp); /* free g_strdup allocated space */
</code>```

And a call to g_free(...) frees the allocated storage.

Now I get:

```<code>LEAK SUMMARY:
==6472==    definitely lost: 0 bytes in 0 blocks
==6472==    indirectly lost: 0 bytes in 0 blocks
==6472==      possibly lost: 9,841 bytes in 148 blocks
==6472==    still reachable: 106,376 bytes in 986 blocks
==6472==         suppressed: 0 bytes in 0 blocks
</code>```

Body:
I'm using GDBus (via Glib) and I have code like:

  method_call_message = g_dbus_message_new_method_call(owner,
                                                       OBJECT_PATH,
                                                       INTERFACE_NAME,
                                                       "get_snmpv2_mib");

  GVariant *gv = g_variant_new("(sissi)", ip, port, mib, variable, instance);

  g_dbus_message_set_body(method_call_message, gv);

I assume method_call_message is now a container for gv.

Before exiting I call:

 g_object_unref(method_call_message);

I assume this will then schedule BOTH method_call_message and gv for GC?

When is GC done?

I appear to be leaking some 4 bytes at a time as I watch the top updates on VIRT memory.

I have commented out pieces of code till I localized it (the leak) to my GDBus calls.

Body:
Using some Valgrind magic:

libtool exec valgrind --tool=memcheck --leak-check=full --log-file=w <executable + args>

I was able to winnow out the memory management obfuscation and get to a call-stack that showed the problem. The Valgrind output indicated that all my memory losses were associated with calls to g_variant_get(...):

at 0x4A06A2E: malloc (vg_replace_malloc.c:270)
==20088==    by 0x3F21E503B6: g_malloc (in /usr/lib64/libglib-2.0.so.0.4400.1)
==20088==    by 0x3F21E6860D: g_strdup (in /usr/lib64/libglib-2.0.so.0.4400.1)
==20088==    by 0x3F21E7FD01: ??? (in /usr/lib64/libglib-2.0.so.0.4400.1)
==20088==    by 0x3F21E7FA61: ??? (in /usr/lib64/libglib-2.0.so.0.4400.1)
==20088==    by 0x3F21E80348: g_variant_get_va (in /usr/lib64/libglib-2.0.so.0.4400.1)
==20088==    by 0x3F21E80585: g_variant_get (in /usr/lib64/libglib-2.0.so.0.4400.1)
==20088==    by 0x4C30555: server_gvariant (in /usr/lib64/libdrsnvc.so)
==20088==    by 0x40257B: NVCtimerCB(void*) (main.cc:73)
==20088==    by 0x3F21E48C3A: ??? (in /usr/lib64/libglib-2.0.so.0.4400.1)
==20088==    by 0x3F21E48519: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.4400.1)
==20088==    by 0x3F21E4A5A7: ??? (in /usr/lib64/libglib-2.0.so.0.4400.1)

Obviously the call to g_variant_get(...) begats a call to g_strdup(...) (if your format_string includes an 's' for string). So, in my case, the code is:

g_variant_get(response, "(isi)", &od.stat, &od.msg, &od.i);
gchar *tmp = od.msg;
od.msg = strncpy(msg, od.msg, strlen(od.msg)); /* copy string */
g_free(tmp); /* free g_strdup allocated space */

And a call to g_free(...) frees the allocated storage.

Now I get:

LEAK SUMMARY:
==6472==    definitely lost: 0 bytes in 0 blocks
==6472==    indirectly lost: 0 bytes in 0 blocks
==6472==      possibly lost: 9,841 bytes in 148 blocks
==6472==    still reachable: 106,376 bytes in 986 blocks
==6472==         suppressed: 0 bytes in 0 blocks


来源: stackexchange

问:
Char Point Memory Allocation to reference address of C++ String?
I would like to convert an array of Integers
2, 3, 4, 8
5, 7, 9, 12
1, 0, 6, 10

to a string with the entries of that matrix appended in clockwise order
 “2, 3, 4, 8, 12, 10, 6, 0, 1, 5, 7, 9”.

I have to keep declaration of int * Matrix and char * OutBuffer the way they are

```<code>int main()
{
    int matrixArray[rowCount][columnCount] =
    {   {2, 3, 4, 8},
        {5, 7, 9, 12},
        {1, 0, 6, 10}};

    int * matrix;
    string prebuffer;
    char  * outBuffer;

    outBuffer = new (nothrow) char[24];
    matrix = &matrixArray[0][0];

    BuildStringFromMatrix(matrix, rowCount, columnCount, outBuffer);
}
</code>```

I declare and address all my pointers before passing them in. However, I am not sure if I am going about allocating memory for the outBuffer to store the characters of prebuffer correctly?

```<code>void BuildStringFromMatrix(int* Matrix, int NumRows, int NumColumns, char * OutBuffer)
    {
        string prebuffer;
        bool stringLeft = true;
        int i = 0;

        while (stringLeft)
        {
            int clockwiseDir[12] = { 1,1,1,4,1,1,0,4,-4,-1,-1,-1 };

            prebuffer = to_string(Matrix[i]) + ", ";
            OutBuffer = new char [prebuffer.length() + 1];
            cout << prebuffer;
            i += clockwiseDir[i];

            if (i == 6)
            {
                prebuffer = to_string(Matrix[i]) + " ";
                cout << prebuffer;
                stringLeft = false;
            }
        }
    }
</code>```

**When I do not implement OutBuffer I have no trouble accessing and printing the matrix in clockwise format

But I how would I go about using OutBuffer to reference and print prebuffers contents??
I need numbers to display not unprintable symbols on the ASCII table

Thanks in advance :)
**

答:
Firstly, in your loop under BuildStringFromMatrix function you are not using your i value anywhere.
Second, matrix = matrixArray should do fine.

ContentLicense: CC BY-SA 3.0

Body:
I would like to convert an array of Integers
2, 3, 4, 8
5, 7, 9, 12
1, 0, 6, 10

to a string with the entries of that matrix appended in clockwise order
 “2, 3, 4, 8, 12, 10, 6, 0, 1, 5, 7, 9”.

I have to keep declaration of int * Matrix and char * OutBuffer the way they are

int main()
{
    int matrixArray[rowCount][columnCount] =
    {   {2, 3, 4, 8},
        {5, 7, 9, 12},
        {1, 0, 6, 10}};

    int * matrix;
    string prebuffer;
    char  * outBuffer;

    outBuffer = new (nothrow) char[24];
    matrix = &matrixArray[0][0];

    BuildStringFromMatrix(matrix, rowCount, columnCount, outBuffer);
}

I declare and address all my pointers before passing them in. However, I am not sure if I am going about allocating memory for the outBuffer to store the characters of prebuffer correctly?

void BuildStringFromMatrix(int* Matrix, int NumRows, int NumColumns, char * OutBuffer)
    {
        string prebuffer;
        bool stringLeft = true;
        int i = 0;

        while (stringLeft)
        {
            int clockwiseDir[12] = { 1,1,1,4,1,1,0,4,-4,-1,-1,-1 };

            prebuffer = to_string(Matrix[i]) + ", ";
            OutBuffer = new char [prebuffer.length() + 1];
            cout << prebuffer;
            i += clockwiseDir[i];

            if (i == 6)
            {
                prebuffer = to_string(Matrix[i]) + " ";
                cout << prebuffer;
                stringLeft = false;
            }
        }
    }

**When I do not implement OutBuffer I have no trouble accessing and printing the matrix in clockwise format

But I how would I go about using OutBuffer to reference and print prebuffers contents??
I need numbers to display not unprintable symbols on the ASCII table

Thanks in advance :)
**

ContentLicense: CC BY-SA 4.0


问:
Help with Apache .htaccess file
Trying to convert my .htaccess file to NGINX notation.

I've read the online help guides but am still struggling.

Would anyone mind helping. My .htaccess is:

```<code>Options -Indexes
Options +FollowSymLinks

# Enable ETag
FileETag none

# Set expiration header
ExpiresActive on
ExpiresDefault A2592000
Header append Cache-Control "public"

# Compress some text file types
AddOutputFilterByType DEFLATE text/html text/plain text/css text/xml application/x-javascript text/javascript application/javascript application/json

# Deactivate compression for buggy browsers
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

# Set header information for proxies
Header append Vary User-Agent

########################################################
# Rewrite Rules
########################################################

RewriteEngine on

# Require SSL (HTTPS) on the signup page
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} ^/signup/?
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]

# Redirect /signup/plan or /signup/plan/ ->  /signup/index.php?account_type=plan
RewriteRule ^signup/([A-Za-z]+)/?$ /signup/index.php?account_type=$1 [NC,L]

# Redirect /home/123 or /home/123/ ->  home.php?home_id=123
RewriteRule ^home/([0-9]+)/?$ home.php?home_id=$1 [NC,L]

# Redirect /homes/ in case someone made a typo when it should have been /home/
RewriteRule ^homes/([0-9]+)/?$ home.php?home_id=$1 [NC,L]

###########################################################
# Error Handling
###########################################################

#ErrorDocument 400 /
#ErrorDocument 401 /
#ErrorDocument 403 /
#ErrorDocument 404 /
#ErrorDocument 500 /

#################################################
# Default Settings
#################################################

# hide apache server signaute on apache generated pages (e.g. 404)
ServerSignature Off
</code>```

UPDATE:

For the GZIP compression, this appears to work. But I still haven't figured out how to my my HTTP Rewrites rules yet.

```<code> gzip             on;
  gzip_min_length  1000;
  gzip_proxied     expired no-cache no-store private auth;
  gzip_types       text/plain application/xml;
  gzip_disable     "MSIE [1-6]\.";
</code>```

UPDATE 2

I tried replacing my htaccess rewrite rules with the following NGINX rules but this doesn't appear to work. Any ideas what I'm doing wrong?

```<code># Redirect /signup/planname or /signup/planname/ ->  /signup/index.php?account_type=planname
rewrite  ^signup/([A-Za-z]+)/?$ /signup/index.php?account_type=$1  last;

# Redirect /home/123 or /home/123/ ->  home.php?home_id=123
rewrite  ^home/([0-9]+)/?$ home.php?home_id=$1  last;

# Redirect /homes/ in case someone made a typo when it should have been /home/
rewrite  ^homes/([0-9]+)/?$ home.php?home_id=$1  last;
</code>```

UPDATE 3

Per the comments below, I now have the following NGINX config but am still having problems

```<code># gzip
gzip             on;
gzip_min_length  1000;
gzip_proxied     expired no-cache no-store private auth;
gzip_types       text/plain application/xml;
gzip_disable     "MSIE [1-6]\.";

# Require SSL (HTTPS) on the signup page
# ====== THIS DOESN'T WORK AND BREAKS NGINX
# I obviously change "example.com" to be my actual domain
if (location /signup/) {
   rewrite ^ https://www.example.com$request_uri? permanent;
}

# Redirect /signup/planname or /signup/planname/ ->  /signup/index.php?account_type=planname
rewrite  ^signup/([A-Za-z] +)/?$ /signup/index.php?account_type=$1  last;

# Redirect /home/123 or /home/123/ ->  home.php?home_id=123
# Also, Redirect /homes/ in case someone made a typo when it should have been /home/
rewrite  ^/homes?/([0-9]+)/?$  /home.php?home_id=$1?  last;
</code>```

答:
As I see in documentation, your rules (not conds) should be like this:

A:

```<code> RewriteCond %{SERVER_PORT} 80
 RewriteCond %{REQUEST_URI} ^/signup/?
 RewriteRule ^(.*)$ https://www.example.com/$1
</code>```

N (see here for more info) :

```<code>if (location /signup) {
   rewrite ^ https://pma.clinicacgm.0$request_uri? permanent;
}
</code>```

A:

```<code>RewriteRule ^home/([0-9]+)/?$ home.php?home_id=$1
RewriteRule ^homes/([0-9]+)/?$ home.php?home_id=$1
</code>```

N:

```<code> rewrite  ^/homes?/([0-9]+)/?$  /home.php?home_id=$1?  last;
</code>```

ContentLicense: CC BY-SA 2.5

Title: Help with Apache .htaccess file

Body:
Trying to convert my .htaccess file to NGINX notation.

I've read the online help guides but am still struggling.

Would anyone mind helping. My .htaccess is:

Options -Indexes
Options +FollowSymLinks

# Enable ETag
FileETag none

# Set expiration header
ExpiresActive on
ExpiresDefault A2592000
Header append Cache-Control "public"

# Compress some text file types
AddOutputFilterByType DEFLATE text/html text/plain text/css text/xml application/x-javascript text/javascript application/javascript application/json

# Deactivate compression for buggy browsers
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

# Set header information for proxies
Header append Vary User-Agent

########################################################
# Rewrite Rules
########################################################

RewriteEngine on

# Require SSL (HTTPS) on the signup page
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} ^/signup/?
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]

# Redirect /signup/plan or /signup/plan/ ->  /signup/index.php?account_type=plan
RewriteRule ^signup/([A-Za-z]+)/?$ /signup/index.php?account_type=$1 [NC,L]

# Redirect /home/123 or /home/123/ ->  home.php?home_id=123
RewriteRule ^home/([0-9]+)/?$ home.php?home_id=$1 [NC,L]

# Redirect /homes/ in case someone made a typo when it should have been /home/
RewriteRule ^homes/([0-9]+)/?$ home.php?home_id=$1 [NC,L]

###########################################################
# Error Handling
###########################################################

#ErrorDocument 400 /
#ErrorDocument 401 /
#ErrorDocument 403 /
#ErrorDocument 404 /
#ErrorDocument 500 /

#################################################
# Default Settings
#################################################

# hide apache server signaute on apache generated pages (e.g. 404)
ServerSignature Off

UPDATE:

For the GZIP compression, this appears to work. But I still haven't figured out how to my my HTTP Rewrites rules yet.

 gzip             on;
  gzip_min_length  1000;
  gzip_proxied     expired no-cache no-store private auth;
  gzip_types       text/plain application/xml;
  gzip_disable     "MSIE [1-6]\.";

UPDATE 2

I tried replacing my htaccess rewrite rules with the following NGINX rules but this doesn't appear to work. Any ideas what I'm doing wrong?

# Redirect /signup/planname or /signup/planname/ ->  /signup/index.php?account_type=planname
rewrite  ^signup/([A-Za-z]+)/?$ /signup/index.php?account_type=$1  last;

# Redirect /home/123 or /home/123/ ->  home.php?home_id=123
rewrite  ^home/([0-9]+)/?$ home.php?home_id=$1  last;

# Redirect /homes/ in case someone made a typo when it should have been /home/
rewrite  ^homes/([0-9]+)/?$ home.php?home_id=$1  last;

UPDATE 3

Per the comments below, I now have the following NGINX config but am still having problems

# gzip
gzip             on;
gzip_min_length  1000;
gzip_proxied     expired no-cache no-store private auth;
gzip_types       text/plain application/xml;
gzip_disable     "MSIE [1-6]\.";

# Require SSL (HTTPS) on the signup page
# ====== THIS DOESN'T WORK AND BREAKS NGINX
# I obviously change "example.com" to be my actual domain
if (location /signup/) {
   rewrite ^ https://www.example.com$request_uri? permanent;
}

# Redirect /signup/planname or /signup/planname/ ->  /signup/index.php?account_type=planname
rewrite  ^signup/([A-Za-z] +)/?$ /signup/index.php?account_type=$1  last;

# Redirect /home/123 or /home/123/ ->  home.php?home_id=123
# Also, Redirect /homes/ in case someone made a typo when it should have been /home/
rewrite  ^/homes?/([0-9]+)/?$  /home.php?home_id=$1?  last;

Body:
As I see in documentation, your rules (not conds) should be like this:

A:

 RewriteCond %{SERVER_PORT} 80
 RewriteCond %{REQUEST_URI} ^/signup/?
 RewriteRule ^(.*)$ https://www.example.com/$1

N (see here for more info) :

if (location /signup) {
   rewrite ^ https://pma.clinicacgm.0$request_uri? permanent;
}

A:

RewriteRule ^home/([0-9]+)/?$ home.php?home_id=$1
RewriteRule ^homes/([0-9]+)/?$ home.php?home_id=$1

N:

 rewrite  ^/homes?/([0-9]+)/?$  /home.php?home_id=$1?  last;


问:
openstack CRITICAL keystonemiddleware.auth_token [-] Unable to validate
I'm installing Openstack Newton on Ubuntu 16.04 manually using the install documentation:
https://docs.openstack.org/newton/install-guide-ubuntu/glance-install.html

I missed a few bits in glance-registry.conf before populating the image service database.
I then went back and fixed everything, populated DB again (sudo su -s /bin/sh -c "glance-manage db_sync" glance)
Restarted service, loaded admin creds and tried creating Cirros image but keep getting the following errors:

```<code>user1@controller:~$ openstack image create "cirros" --file cirros-0.3.4-x86_64-disk.img --disk-format qcow2 --container-format bare --public
503 Service Unavailable
The server is currently unavailable. Please try again at a later time.
    (HTTP 503)
</code>```

glance-registry.log seems fine:
(Note not entire log)

```<code>2017-03-29 11:33:39.073 2084 INFO glance.common.wsgi [-] Starting 6 workers
2017-03-29 11:33:39.083 2084 INFO glance.common.wsgi [-] Started child 2119
2017-03-29 11:33:39.084 2119 INFO eventlet.wsgi.server [-] (2119) wsgi starting up on http://0.0.0.0:9191
2017-03-29 11:33:39.086 2084 INFO glance.common.wsgi [-] Started child 2120
2017-03-29 11:33:39.087 2120 INFO eventlet.wsgi.server [-] (2120) wsgi starting up on http://0.0.0.0:9191
2017-03-29 11:33:39.090 2084 INFO glance.common.wsgi [-] Started child 2121
2017-03-29 11:33:39.091 2121 INFO eventlet.wsgi.server [-] (2121) wsgi starting up on http://0.0.0.0:9191
2017-03-29 11:33:39.093 2084 INFO glance.common.wsgi [-] Started child 2122
2017-03-29 11:33:39.094 2122 INFO eventlet.wsgi.server [-] (2122) wsgi starting up on http://0.0.0.0:9191
2017-03-29 11:33:39.096 2084 INFO glance.common.wsgi [-] Started child 2123
2017-03-29 11:33:39.097 2123 INFO eventlet.wsgi.server [-] (2123) wsgi starting up on http://0.0.0.0:9191
2017-03-29 11:33:39.100 2084 INFO glance.common.wsgi [-] Started child 2124
2017-03-29 11:33:39.101 2124 INFO eventlet.wsgi.server [-] (2124) wsgi starting up on http://0.0.0.0:9191
</code>```

glance-api.log has some errors:
(Note not entire log)

```<code>2017-03-29 11:33:39.326 2088 INFO glance.common.wsgi [-] Started child 2127
2017-03-29 11:33:39.327 2127 INFO eventlet.wsgi.server [-] (2127) wsgi starting up on http://0.0.0.0:9292
2017-03-29 11:33:39.330 2088 INFO glance.common.wsgi [-] Started child 2128
2017-03-29 11:33:39.330 2128 INFO eventlet.wsgi.server [-] (2128) wsgi starting up on http://0.0.0.0:9292
2017-03-29 11:33:39.334 2088 INFO glance.common.wsgi [-] Started child 2129
2017-03-29 11:33:39.334 2129 INFO eventlet.wsgi.server [-] (2129) wsgi starting up on http://0.0.0.0:9292
2017-03-29 11:33:39.338 2088 INFO glance.common.wsgi [-] Started child 2130
2017-03-29 11:33:39.339 2130 INFO eventlet.wsgi.server [-] (2130) wsgi starting up on http://0.0.0.0:9292
2017-03-29 11:36:44.200 2126 WARNING keystonemiddleware.auth_token [-] Identity response: {"error": {"message": "The request you have made requires authentication.", "code": 401, "title": "Unauthorized"}}
2017-03-29 11:36:44.322 2126 WARNING keystonemiddleware.auth_token [-] Identity response: {"error": {"message": "The request you have made requires authentication.", "code": 401, "title": "Unauthorized"}}
2017-03-29 11:36:44.323 2126 CRITICAL keystonemiddleware.auth_token [-] Unable to validate token: Identity server rejected authorization necessary to fetch token data
2017-03-29 11:36:44.326 2126 INFO eventlet.wsgi.server [-] 192.168.10.11 - - [29/Mar/2017 11:36:44] "GET /v2/schemas/image HTTP/1.1" 503 259 2.551519
</code>```

admin-openrc

```<code>export OS_PROJECT_DOMAIN_NAME=Default
export OS_USER_DOMAIN_NAME=Default
export OS_PROJECT_NAME=admin
export OS_USERNAME=admin
export OS_PASSWORD=PASSWORDHERE
export OS_AUTH_URL=http://controller:35357/v3
export OS_IDENTITY_API_VERSION=3
export OS_IMAGE_API_VERSION=2
</code>```

Any suggestions?

/var/log/apache2/error.log

```<code>[Wed Mar 29 09:09:24.843764 2017] [wsgi:warn] [pid 1689:tid 139998635640704] mod_wsgi: Compiled for Python/2.7.11.
[Wed Mar 29 09:09:24.852363 2017] [wsgi:warn] [pid 1689:tid 139998635640704] mod_wsgi: Runtime using Python/2.7.12.
[Wed Mar 29 09:09:24.855349 2017] [mpm_event:notice] [pid 1689:tid 139998635640704] AH00489: Apache/2.4.18 (Ubuntu) mod_wsgi/4.3.0 Python/2.7.12 configured -- resuming normal operations
[Wed Mar 29 09:09:24.855369 2017] [core:notice] [pid 1689:tid 139998635640704] AH00094: Command line: '/usr/sbin/apache2'
[Wed Mar 29 10:20:52.529214 2017] [mpm_event:notice] [pid 1689:tid 139998635640704] AH00491: caught SIGTERM, shutting down
[Wed Mar 29 10:22:50.037927 2017] [wsgi:warn] [pid 1571:tid 140332865791872] mod_wsgi: Compiled for Python/2.7.11.
[Wed Mar 29 10:22:50.068187 2017] [wsgi:warn] [pid 1571:tid 140332865791872] mod_wsgi: Runtime using Python/2.7.12.
[Wed Mar 29 10:22:50.070975 2017] [mpm_event:notice] [pid 1571:tid 140332865791872] AH00489: Apache/2.4.18 (Ubuntu) mod_wsgi/4.3.0 Python/2.7.12 configured -- resuming normal operations
[Wed Mar 29 10:22:50.071001 2017] [core:notice] [pid 1571:tid 140332865791872] AH00094: Command line: '/usr/sbin/apache2'
[Wed Mar 29 11:31:31.911160 2017] [mpm_event:notice] [pid 1571:tid 140332865791872] AH00491: caught SIGTERM, shutting down
[Wed Mar 29 11:33:34.967332 2017] [wsgi:warn] [pid 1559:tid 139850139666304] mod_wsgi: Compiled for Python/2.7.11.
[Wed Mar 29 11:33:34.979608 2017] [wsgi:warn] [pid 1559:tid 139850139666304] mod_wsgi: Runtime using Python/2.7.12.
[Wed Mar 29 11:33:34.982567 2017] [mpm_event:notice] [pid 1559:tid 139850139666304] AH00489: Apache/2.4.18 (Ubuntu) mod_wsgi/4.3.0 Python/2.7.12 configured -- resuming normal operations
[Wed Mar 29 11:33:34.982589 2017] [core:notice] [pid 1559:tid 139850139666304] AH00094: Command line: '/usr/sbin/apache2'
[Wed Mar 29 12:03:56.366665 2017] [mpm_event:notice] [pid 1559:tid 139850139666304] AH00491: caught SIGTERM, shutting down
[Thu Mar 30 13:10:43.749039 2017] [wsgi:warn] [pid 1682:tid 139702919534464] mod_wsgi: Compiled for Python/2.7.11.
[Thu Mar 30 13:10:43.764797 2017] [wsgi:warn] [pid 1682:tid 139702919534464] mod_wsgi: Runtime using Python/2.7.12.
[Thu Mar 30 13:10:43.768481 2017] [mpm_event:notice] [pid 1682:tid 139702919534464] AH00489: Apache/2.4.18 (Ubuntu) mod_wsgi/4.3.0 Python/2.7.12 configured -- resuming normal operations
[Thu Mar 30 13:10:43.768511 2017] [core:notice] [pid 1682:tid 139702919534464] AH00094: Command line: '/usr/sbin/apache2'
</code>```

/var/log/glance/glance-api.log

```<code>2017-03-29 11:33:39.326 2088 INFO glance.common.wsgi [-] Started child 2127
2017-03-29 11:33:39.327 2127 INFO eventlet.wsgi.server [-] (2127) wsgi starting up on http://0.0.0.0:9292
2017-03-29 11:33:39.330 2088 INFO glance.common.wsgi [-] Started child 2128
2017-03-29 11:33:39.330 2128 INFO eventlet.wsgi.server [-] (2128) wsgi starting up on http://0.0.0.0:9292
2017-03-29 11:33:39.334 2088 INFO glance.common.wsgi [-] Started child 2129
2017-03-29 11:33:39.334 2129 INFO eventlet.wsgi.server [-] (2129) wsgi starting up on http://0.0.0.0:9292
2017-03-29 11:33:39.338 2088 INFO glance.common.wsgi [-] Started child 2130
2017-03-29 11:33:39.339 2130 INFO eventlet.wsgi.server [-] (2130) wsgi starting up on http://0.0.0.0:9292
2017-03-29 11:36:44.200 2126 WARNING keystonemiddleware.auth_token [-] Identity response: {"error": {"message": "The request you have made requires authentication.", "code": 401, "title": "Unauthorized"}}
2017-03-29 11:36:44.322 2126 WARNING keystonemiddleware.auth_token [-] Identity response: {"error": {"message": "The request you have made requires authentication.", "code": 401, "title": "Unauthorized"}}
2017-03-29 11:36:44.323 2126 CRITICAL keystonemiddleware.auth_token [-] Unable to validate token: Identity server rejected authorization necessary to fetch token data
2017-03-29 11:36:44.326 2126 INFO eventlet.wsgi.server [-] 192.168.10.11 - - [29/Mar/2017 11:36:44] "GET /v2/schemas/image HTTP/1.1" 503 259 2.551519
</code>```

/var/log/glance/glance-registry.log

```<code>2017-03-29 11:33:39.073 2084 INFO glance.common.wsgi [-] Starting 6 workers
2017-03-29 11:33:39.083 2084 INFO glance.common.wsgi [-] Started child 2119
2017-03-29 11:33:39.084 2119 INFO eventlet.wsgi.server [-] (2119) wsgi starting up on http://0.0.0.0:9191
2017-03-29 11:33:39.086 2084 INFO glance.common.wsgi [-] Started child 2120
2017-03-29 11:33:39.087 2120 INFO eventlet.wsgi.server [-] (2120) wsgi starting up on http://0.0.0.0:9191
2017-03-29 11:33:39.090 2084 INFO glance.common.wsgi [-] Started child 2121
2017-03-29 11:33:39.091 2121 INFO eventlet.wsgi.server [-] (2121) wsgi starting up on http://0.0.0.0:9191
2017-03-29 11:33:39.093 2084 INFO glance.common.wsgi [-] Started child 2122
2017-03-29 11:33:39.094 2122 INFO eventlet.wsgi.server [-] (2122) wsgi starting up on http://0.0.0.0:9191
2017-03-29 11:33:39.096 2084 INFO glance.common.wsgi [-] Started child 2123
2017-03-29 11:33:39.097 2123 INFO eventlet.wsgi.server [-] (2123) wsgi starting up on http://0.0.0.0:9191
2017-03-29 11:33:39.100 2084 INFO glance.common.wsgi [-] Started child 2124
2017-03-29 11:33:39.101 2124 INFO eventlet.wsgi.server [-] (2124) wsgi starting up on http://0.0.0.0:9191
</code>```

答:
Your glance API and glance registry seem to be fine but both work in WSGI mode, so you need to have some Apache or other httpd server which will take API calls, send them over WSGI to your galnce servers, get response and send it back to client.
I would recommend looking into your apache/httpd server logs, you can probably find more info why you getting 500 error.</p>

Body:
I'm installing Openstack Newton on Ubuntu 16.04 manually using the install documentation:
https://docs.openstack.org/newton/install-guide-ubuntu/glance-install.html

I missed a few bits in glance-registry.conf before populating the image service database.
I then went back and fixed everything, populated DB again (sudo su -s /bin/sh -c "glance-manage db_sync" glance)
Restarted service, loaded admin creds and tried creating Cirros image but keep getting the following errors:

user1@controller:~$ openstack image create "cirros" --file cirros-0.3.4-x86_64-disk.img --disk-format qcow2 --container-format bare --public
503 Service Unavailable
The server is currently unavailable. Please try again at a later time.
    (HTTP 503)

glance-registry.log seems fine:
(Note not entire log)

2017-03-29 11:33:39.073 2084 INFO glance.common.wsgi [-] Starting 6 workers
2017-03-29 11:33:39.083 2084 INFO glance.common.wsgi [-] Started child 2119
2017-03-29 11:33:39.084 2119 INFO eventlet.wsgi.server [-] (2119) wsgi starting up on http://0.0.0.0:9191
2017-03-29 11:33:39.086 2084 INFO glance.common.wsgi [-] Started child 2120
2017-03-29 11:33:39.087 2120 INFO eventlet.wsgi.server [-] (2120) wsgi starting up on http://0.0.0.0:9191
2017-03-29 11:33:39.090 2084 INFO glance.common.wsgi [-] Started child 2121
2017-03-29 11:33:39.091 2121 INFO eventlet.wsgi.server [-] (2121) wsgi starting up on http://0.0.0.0:9191
2017-03-29 11:33:39.093 2084 INFO glance.common.wsgi [-] Started child 2122
2017-03-29 11:33:39.094 2122 INFO eventlet.wsgi.server [-] (2122) wsgi starting up on http://0.0.0.0:9191
2017-03-29 11:33:39.096 2084 INFO glance.common.wsgi [-] Started child 2123
2017-03-29 11:33:39.097 2123 INFO eventlet.wsgi.server [-] (2123) wsgi starting up on http://0.0.0.0:9191
2017-03-29 11:33:39.100 2084 INFO glance.common.wsgi [-] Started child 2124
2017-03-29 11:33:39.101 2124 INFO eventlet.wsgi.server [-] (2124) wsgi starting up on http://0.0.0.0:9191

glance-api.log has some errors:
(Note not entire log)

2017-03-29 11:33:39.326 2088 INFO glance.common.wsgi [-] Started child 2127
2017-03-29 11:33:39.327 2127 INFO eventlet.wsgi.server [-] (2127) wsgi starting up on http://0.0.0.0:9292
2017-03-29 11:33:39.330 2088 INFO glance.common.wsgi [-] Started child 2128
2017-03-29 11:33:39.330 2128 INFO eventlet.wsgi.server [-] (2128) wsgi starting up on http://0.0.0.0:9292
2017-03-29 11:33:39.334 2088 INFO glance.common.wsgi [-] Started child 2129
2017-03-29 11:33:39.334 2129 INFO eventlet.wsgi.server [-] (2129) wsgi starting up on http://0.0.0.0:9292
2017-03-29 11:33:39.338 2088 INFO glance.common.wsgi [-] Started child 2130
2017-03-29 11:33:39.339 2130 INFO eventlet.wsgi.server [-] (2130) wsgi starting up on http://0.0.0.0:9292
2017-03-29 11:36:44.200 2126 WARNING keystonemiddleware.auth_token [-] Identity response: {"error": {"message": "The request you have made requires authentication.", "code": 401, "title": "Unauthorized"}}
2017-03-29 11:36:44.322 2126 WARNING keystonemiddleware.auth_token [-] Identity response: {"error": {"message": "The request you have made requires authentication.", "code": 401, "title": "Unauthorized"}}
2017-03-29 11:36:44.323 2126 CRITICAL keystonemiddleware.auth_token [-] Unable to validate token: Identity server rejected authorization necessary to fetch token data
2017-03-29 11:36:44.326 2126 INFO eventlet.wsgi.server [-] 192.168.10.11 - - [29/Mar/2017 11:36:44] "GET /v2/schemas/image HTTP/1.1" 503 259 2.551519

admin-openrc

export OS_PROJECT_DOMAIN_NAME=Default
export OS_USER_DOMAIN_NAME=Default
export OS_PROJECT_NAME=admin
export OS_USERNAME=admin
export OS_PASSWORD=PASSWORDHERE
export OS_AUTH_URL=http://controller:35357/v3
export OS_IDENTITY_API_VERSION=3
export OS_IMAGE_API_VERSION=2

Any suggestions?

/var/log/apache2/error.log

[Wed Mar 29 09:09:24.843764 2017] [wsgi:warn] [pid 1689:tid 139998635640704] mod_wsgi: Compiled for Python/2.7.11.
[Wed Mar 29 09:09:24.852363 2017] [wsgi:warn] [pid 1689:tid 139998635640704] mod_wsgi: Runtime using Python/2.7.12.
[Wed Mar 29 09:09:24.855349 2017] [mpm_event:notice] [pid 1689:tid 139998635640704] AH00489: Apache/2.4.18 (Ubuntu) mod_wsgi/4.3.0 Python/2.7.12 configured -- resuming normal operations
[Wed Mar 29 09:09:24.855369 2017] [core:notice] [pid 1689:tid 139998635640704] AH00094: Command line: '/usr/sbin/apache2'
[Wed Mar 29 10:20:52.529214 2017] [mpm_event:notice] [pid 1689:tid 139998635640704] AH00491: caught SIGTERM, shutting down
[Wed Mar 29 10:22:50.037927 2017] [wsgi:warn] [pid 1571:tid 140332865791872] mod_wsgi: Compiled for Python/2.7.11.
[Wed Mar 29 10:22:50.068187 2017] [wsgi:warn] [pid 1571:tid 140332865791872] mod_wsgi: Runtime using Python/2.7.12.
[Wed Mar 29 10:22:50.070975 2017] [mpm_event:notice] [pid 1571:tid 140332865791872] AH00489: Apache/2.4.18 (Ubuntu) mod_wsgi/4.3.0 Python/2.7.12 configured -- resuming normal operations
[Wed Mar 29 10:22:50.071001 2017] [core:notice] [pid 1571:tid 140332865791872] AH00094: Command line: '/usr/sbin/apache2'
[Wed Mar 29 11:31:31.911160 2017] [mpm_event:notice] [pid 1571:tid 140332865791872] AH00491: caught SIGTERM, shutting down
[Wed Mar 29 11:33:34.967332 2017] [wsgi:warn] [pid 1559:tid 139850139666304] mod_wsgi: Compiled for Python/2.7.11.
[Wed Mar 29 11:33:34.979608 2017] [wsgi:warn] [pid 1559:tid 139850139666304] mod_wsgi: Runtime using Python/2.7.12.
[Wed Mar 29 11:33:34.982567 2017] [mpm_event:notice] [pid 1559:tid 139850139666304] AH00489: Apache/2.4.18 (Ubuntu) mod_wsgi/4.3.0 Python/2.7.12 configured -- resuming normal operations
[Wed Mar 29 11:33:34.982589 2017] [core:notice] [pid 1559:tid 139850139666304] AH00094: Command line: '/usr/sbin/apache2'
[Wed Mar 29 12:03:56.366665 2017] [mpm_event:notice] [pid 1559:tid 139850139666304] AH00491: caught SIGTERM, shutting down
[Thu Mar 30 13:10:43.749039 2017] [wsgi:warn] [pid 1682:tid 139702919534464] mod_wsgi: Compiled for Python/2.7.11.
[Thu Mar 30 13:10:43.764797 2017] [wsgi:warn] [pid 1682:tid 139702919534464] mod_wsgi: Runtime using Python/2.7.12.
[Thu Mar 30 13:10:43.768481 2017] [mpm_event:notice] [pid 1682:tid 139702919534464] AH00489: Apache/2.4.18 (Ubuntu) mod_wsgi/4.3.0 Python/2.7.12 configured -- resuming normal operations
[Thu Mar 30 13:10:43.768511 2017] [core:notice] [pid 1682:tid 139702919534464] AH00094: Command line: '/usr/sbin/apache2'

/var/log/glance/glance-api.log

2017-03-29 11:33:39.326 2088 INFO glance.common.wsgi [-] Started child 2127
2017-03-29 11:33:39.327 2127 INFO eventlet.wsgi.server [-] (2127) wsgi starting up on http://0.0.0.0:9292
2017-03-29 11:33:39.330 2088 INFO glance.common.wsgi [-] Started child 2128
2017-03-29 11:33:39.330 2128 INFO eventlet.wsgi.server [-] (2128) wsgi starting up on http://0.0.0.0:9292
2017-03-29 11:33:39.334 2088 INFO glance.common.wsgi [-] Started child 2129
2017-03-29 11:33:39.334 2129 INFO eventlet.wsgi.server [-] (2129) wsgi starting up on http://0.0.0.0:9292
2017-03-29 11:33:39.338 2088 INFO glance.common.wsgi [-] Started child 2130
2017-03-29 11:33:39.339 2130 INFO eventlet.wsgi.server [-] (2130) wsgi starting up on http://0.0.0.0:9292
2017-03-29 11:36:44.200 2126 WARNING keystonemiddleware.auth_token [-] Identity response: {"error": {"message": "The request you have made requires authentication.", "code": 401, "title": "Unauthorized"}}
2017-03-29 11:36:44.322 2126 WARNING keystonemiddleware.auth_token [-] Identity response: {"error": {"message": "The request you have made requires authentication.", "code": 401, "title": "Unauthorized"}}
2017-03-29 11:36:44.323 2126 CRITICAL keystonemiddleware.auth_token [-] Unable to validate token: Identity server rejected authorization necessary to fetch token data
2017-03-29 11:36:44.326 2126 INFO eventlet.wsgi.server [-] 192.168.10.11 - - [29/Mar/2017 11:36:44] "GET /v2/schemas/image HTTP/1.1" 503 259 2.551519

/var/log/glance/glance-registry.log

2017-03-29 11:33:39.073 2084 INFO glance.common.wsgi [-] Starting 6 workers
2017-03-29 11:33:39.083 2084 INFO glance.common.wsgi [-] Started child 2119
2017-03-29 11:33:39.084 2119 INFO eventlet.wsgi.server [-] (2119) wsgi starting up on http://0.0.0.0:9191
2017-03-29 11:33:39.086 2084 INFO glance.common.wsgi [-] Started child 2120
2017-03-29 11:33:39.087 2120 INFO eventlet.wsgi.server [-] (2120) wsgi starting up on http://0.0.0.0:9191
2017-03-29 11:33:39.090 2084 INFO glance.common.wsgi [-] Started child 2121
2017-03-29 11:33:39.091 2121 INFO eventlet.wsgi.server [-] (2121) wsgi starting up on http://0.0.0.0:9191
2017-03-29 11:33:39.093 2084 INFO glance.common.wsgi [-] Started child 2122
2017-03-29 11:33:39.094 2122 INFO eventlet.wsgi.server [-] (2122) wsgi starting up on http://0.0.0.0:9191
2017-03-29 11:33:39.096 2084 INFO glance.common.wsgi [-] Started child 2123
2017-03-29 11:33:39.097 2123 INFO eventlet.wsgi.server [-] (2123) wsgi starting up on http://0.0.0.0:9191
2017-03-29 11:33:39.100 2084 INFO glance.common.wsgi [-] Started child 2124
2017-03-29 11:33:39.101 2124 INFO eventlet.wsgi.server [-] (2124) wsgi starting up on http://0.0.0.0:9191


问:
Laravel Model - All ID's return 1
I want to get all the projects through a group. I got that working now, but I can't seem to get the right ID's. I keep getting 1 as the ID for all my posts. Am I doing something wrong?

ProjectController.php

```<code>public function index()
{
    $projects = \Auth::user()->projects;
    dd($projects);
    return view('projects.home', compact('projects'));
}
</code>```

User.php

```<code>public function projects()
{
    return $this->hasManyThrough(
        'App\Project', 'App\Group',
        'id', 'group_id', 'group_id'
    );
}
</code>```

Dump
(all items have the same attribute > id, all the other attributes are good)

```<code>Collection {#224 ▼
  #items: array:8 [▼
    0 => Project {#225 ▼
      #table: "projects"
      #connection: null
      #primaryKey: "id"
      #keyType: "int"
      +incrementing: true
      #with: []
      #perPage: 15
      +exists: true
      +wasRecentlyCreated: false
      #attributes: array:7 [▼
        "id" => 1
        "name" => "project.com"
        "display_name" => "Project 1"
        "group_id" => 1
        "active" => 0
        "created_at" => null
        "updated_at" => "2017-03-29 12:21:47"
      ]
      #original: array:7 [▶]
      #casts: []
      #dates: []
      #dateFormat: null
      #appends: []
      #events: []
      #observables: []
      #relations: []
      #touches: []
      +timestamps: true
      #hidden: []
      #visible: []
      #fillable: []
      #guarded: array:1 [▶]
    }
    1 => Project {#226 ▶}
</code>```

答:
You are using the same ids to get them. Try to change the code to:</p>

```<code>public function projects()
{
    return $this->hasManyThrough(
        'App\Project', 'App\Group',
        'id', 'user_id', 'group_id'
    );
}
</code>```

Title: Laravel Model - All ID's return 1

Body:
I want to get all the projects through a group. I got that working now, but I can't seem to get the right ID's. I keep getting 1 as the ID for all my posts. Am I doing something wrong?

ProjectController.php

public function index()
{
    $projects = \Auth::user()->projects;
    dd($projects);
    return view('projects.home', compact('projects'));
}

User.php

public function projects()
{
    return $this->hasManyThrough(
        'App\Project', 'App\Group',
        'id', 'group_id', 'group_id'
    );
}

Dump
(all items have the same attribute > id, all the other attributes are good)

Collection {#224 ▼
  #items: array:8 [▼
    0 => Project {#225 ▼
      #table: "projects"
      #connection: null
      #primaryKey: "id"
      #keyType: "int"
      +incrementing: true
      #with: []
      #perPage: 15
      +exists: true
      +wasRecentlyCreated: false
      #attributes: array:7 [▼
        "id" => 1
        "name" => "project.com"
        "display_name" => "Project 1"
        "group_id" => 1
        "active" => 0
        "created_at" => null
        "updated_at" => "2017-03-29 12:21:47"
      ]
      #original: array:7 [▶]
      #casts: []
      #dates: []
      #dateFormat: null
      #appends: []
      #events: []
      #observables: []
      #relations: []
      #touches: []
      +timestamps: true
      #hidden: []
      #visible: []
      #fillable: []
      #guarded: array:1 [▶]
    }
    1 => Project {#226 ▶}

Body:
You are using the same ids to get them. Try to change the code to:

public function projects()
{
    return $this->hasManyThrough(
        'App\Project', 'App\Group',
        'id', 'user_id', 'group_id'
    );
}


问:
Copying selection from last row
I have a table, with headers in the range A2:V2 and the data in the range A3:VXX, where XX is the last row number.

I am trying to write a macro which duplicates the values of the last row, but only for columns A:P. So Duplicating the values in AXX:PXX. I have no issues finding and copying the entire last row, however I cannot copy a limited range within it.

Apologies earlier for not including the code I have used.

```<code>With Activesheet
    .cells(.rows.count,1).end(xlup).entirerow.copy
End With
</code>```

答:
Instead of the entire row set the range:</p>

```<code>Dim lastRow as long

With Activesheet
    lastRow = .cells(.rows.count,1).end(xlup).Row
    .Range(.Cells(lastrow,"A"),.Cells(lastrow,"P")).copy
End With
</code>```

Title: Copying selection from last row

Body:
I have a table, with headers in the range A2:V2 and the data in the range A3:VXX, where XX is the last row number.

I am trying to write a macro which duplicates the values of the last row, but only for columns A:P. So Duplicating the values in AXX:PXX. I have no issues finding and copying the entire last row, however I cannot copy a limited range within it.

Apologies earlier for not including the code I have used.

With Activesheet
    .cells(.rows.count,1).end(xlup).entirerow.copy
End With

Body:
Instead of the entire row set the range:

Dim lastRow as long

With Activesheet
    lastRow = .cells(.rows.count,1).end(xlup).Row
    .Range(.Cells(lastrow,"A"),.Cells(lastrow,"P")).copy
End With


问:
Flex Component using global variable
I am using Flash Builder 4 Burrito Preview - builing a Mobile Application.  I have a custom component called footer.mxml.  That footer has 4 buttons, and one of them has a lable that is bound to cartValue.  I am trying to maintain a global variable called cartValue within all views and footer component.

footer.mxml

```<code><s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
   xmlns:s="library://ns.adobe.com/flex/spark"
   xmlns:mx="library://ns.adobe.com/flex/mx"
   width="100%" height="64" chromeColor="#000000" fontSize="10">
<fx:Declarations>
  <!-- Place non-visual elements (e.g., services, value objects) here -->
  <mx:CurrencyFormatter id="currencyFormatter"
     currencySymbol="$"
     useThousandsSeparator="true"
     precision="2" />
 </fx:Declarations>

<fx:Script>
  <![CDATA[
   [Bindable]
   public var cartValue:int;

  ]]>
</fx:Script>

 <s:HGroup width="100%" contentBackgroundColor="#000000" paddingBottom="0" paddingLeft="0"
 paddingRight="0" paddingTop="0">
 <s:Button x="0" y="624.5" width="25%" height="64" label="Account" chromeColor="#2259AA"
 enabled="true" fontSize="10" fontWeight="bold" icon="@Embed('assets/user.png')"/>
 <s:Button x="121" y="624.5" width="25%" height="64" label="Orders" chromeColor="#2259AA"
 fontSize="10" icon="@Embed('assets/doc_lines_stright.png')"/>
 <s:Button x="241" y="624.5" width="25%" height="64" label="Help" chromeColor="#2259AA"
 fontSize="10" icon="@Embed('assets/spechbubble.png')"/>
 <s:Button x="360" y="624.5" width="25%" height="64" label="{currencyFormatter.format(cartValue)}" chromeColor="#2259AA"
 fontSize="10" icon="@Embed('assets/shop_cart.png')"/>

 </s:HGroup>
    </s:Group>
</code>```

RincoTest.mxml

```<code> <s:MobileApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
  xmlns:s="library://ns.adobe.com/flex/spark"
  xmlns:mx="library://ns.adobe.com/flex/mx"
  backgroundColor="#000000" firstView="views.RincoTestHome"
  >
 <fx:Style source="RincoTest.css"/>
<fx:Declarations>
 <!-- Place non-visual elements (e.g., services, value objects) here -->
 </fx:Declarations>
 <fx:Script>
  <![CDATA[

   [Bindable]
   public var cartValue:int;
  ]]>
 </fx:Script>

 <s:titleContent>
  <s:Image left="1" top="3" width="173" height="75" backgroundAlpha="1.0" smooth="true"
 source="assets/iphone_large.png"/>
 </s:titleContent>
 <s:navigationContent>
  <mx:Spacer width="10" height="82"/>
 </s:navigationContent>

    </s:MobileApplication>
</code>```

And this is how I am implementing it

```<code><components:footer x="1.65" y="614.95" width="100%" height="64" cartValue="{cartValue}"/>
</code>```

I have tried to bind Application.application.cartValue and
MobileApplication.application.cartValue.  Neither of them work.

If there is a better way to maintain a cartValue across the entire application please let me know.  This is my first attempt with Flex.

Thanks,
Ernie

答:
Use a static variable in the component.

Reference it as ComponentName.staticVar. Usually, everything that needs to know about the global already knows about (e.g. imports) the component file.

Cheers

Title: Flex Component using global variable

Body:
I am using Flash Builder 4 Burrito Preview - builing a Mobile Application.  I have a custom component called footer.mxml.  That footer has 4 buttons, and one of them has a lable that is bound to cartValue.  I am trying to maintain a global variable called cartValue within all views and footer component.

footer.mxml

<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
   xmlns:s="library://ns.adobe.com/flex/spark"
   xmlns:mx="library://ns.adobe.com/flex/mx"
   width="100%" height="64" chromeColor="#000000" fontSize="10">
<fx:Declarations>

  <mx:CurrencyFormatter id="currencyFormatter"
     currencySymbol="$"
     useThousandsSeparator="true"
     precision="2" />
 </fx:Declarations>

<fx:Script>
  <![CDATA[
   [Bindable]
   public var cartValue:int;

  ]]>
</fx:Script>

 <s:HGroup width="100%" contentBackgroundColor="#000000" paddingBottom="0" paddingLeft="0"
 paddingRight="0" paddingTop="0">
 <s:Button x="0" y="624.5" width="25%" height="64" label="Account" chromeColor="#2259AA"
 enabled="true" fontSize="10" fontWeight="bold" icon="@Embed('assets/user.png')"/>
 <s:Button x="121" y="624.5" width="25%" height="64" label="Orders" chromeColor="#2259AA"
 fontSize="10" icon="@Embed('assets/doc_lines_stright.png')"/>
 <s:Button x="241" y="624.5" width="25%" height="64" label="Help" chromeColor="#2259AA"
 fontSize="10" icon="@Embed('assets/spechbubble.png')"/>
 <s:Button x="360" y="624.5" width="25%" height="64" label="{currencyFormatter.format(cartValue)}" chromeColor="#2259AA"
 fontSize="10" icon="@Embed('assets/shop_cart.png')"/>

 </s:HGroup>
    </s:Group>

RincoTest.mxml

 <s:MobileApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
  xmlns:s="library://ns.adobe.com/flex/spark"
  xmlns:mx="library://ns.adobe.com/flex/mx"
  backgroundColor="#000000" firstView="views.RincoTestHome"
  >
 <fx:Style source="RincoTest.css"/>
<fx:Declarations>

 </fx:Declarations>
 <fx:Script>
  <![CDATA[

   [Bindable]
   public var cartValue:int;
  ]]>
 </fx:Script>

 <s:titleContent>
  <s:Image left="1" top="3" width="173" height="75" backgroundAlpha="1.0" smooth="true"
 source="assets/iphone_large.png"/>
 </s:titleContent>
 <s:navigationContent>
  <mx:Spacer width="10" height="82"/>
 </s:navigationContent>

    </s:MobileApplication>

And this is how I am implementing it

<components:footer x="1.65" y="614.95" width="100%" height="64" cartValue="{cartValue}"/>

I have tried to bind Application.application.cartValue and
MobileApplication.application.cartValue.  Neither of them work.

If there is a better way to maintain a cartValue across the entire application please let me know.  This is my first attempt with Flex.

Thanks,
Ernie


问:
Is it possible to colour code the editor tabs in eclipse by project?
Background:

I'm working on multiple versions of a given project in eclipse. I want to be able to switch between different versions quickly as I fix bugs and prop-back changes to previous releases, so I have the different versions of the code open as different projects (e.g 4.5_Proj, 5.0_Proj). The problem is that when you have the same file open twice it's very easy to loose track of which one you are currently looking at.

Question:

Is it possible to colour code the editor tabs based on which project the file is from?

Alternatively are there any suggestions for other strategies to manage the above problem of needing to edit and test multiple versions of a codebase in eclipse?

Thanks,

Rob

答:
You can mark two files by Ctrl+clicking on it and compare them with right click --> Compare with --> Each other.
This opens a very useful perspective for projects like that.


问:
Passing environmental variables when deploying docker to remote host
I am having some trouble with my docker containers and environment variables.

Currently i have a docker-compose.yml with the following defined:

```<code>version: '2.1'
services:
  some-service:
    build:
      context: .
    image: image/replacedvalues
    ports:
      - 8080
    environment:
      - PROFILE=acc
      - ENVA
      - ENVB
      - TZ=Europe/Berlin

  some-service-acc:
    extends:
      service: some-service
    environment:
      - SERVICE_NAME=some-service-acc
</code>```

Now when i deploy this manually (via SSH command line directly) on server A, it will take the environmental variables from Server A and put them in my container. So i have the values of ENVA and ENVB from the host in my container. Using the following command (after building the image ofcourse): docker-compose up some-service-acc.

We are currently developing a better infrastructure and want to deploy services via Jenkins. Jenkins is up and running in a docker container on server B.

I can deploy the service via Jenkins (Job-DSL, setting DOCKER_HOST="tcp://serverA:2375"temporary). So it will run all docker (compose) commands on ServerA from the Jenkins Container on Server B. The service is up and running except that it doesn't have values for the ENVA and the ENVB.

Jenkins runs the following with the Job-DSL groovy script:

```<code>withEnv(["DOCKER_HOST=tcp://serverA:2375"]) {
    sh "docker-compose pull some-service-acc"
    sh "docker-compose -p some-service-acc up -d some-service-acc"
}
</code>```

I tried setting them in my Jenkins container and on Server B itself but neither worked. Only when i deploy manually directly on Server A it works.

When i use docker inspect to inspect the running container, i get the following output for the env block:

```<code>"Env": [
    "PROFILE=acc",
    "affinity:container==JADFG09gtq340iggIN0jg53ij0gokngfs",
    "TZ=Europe/Berlin",
    "SERVICE_NAME=some-service-acc",
    "ENVA",
    "ENVB",
    "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
    "LANG=C.UTF-8",
    "JAVA_VERSION=8",
    "JAVA_UPDATE=121",
    "JAVA_BUILD=13",
    "JAVA_PATH=e9e7ea248e2c4826b92b3f075a80e441",
    "JAVA_HOME=/usr/lib/jvm/default-jvm",
    "JAVA_OPTS="
]
</code>```

Where do i need to set the Environmental variables so that they will be passed to the container? I prefer to store the variables on Server A. But if this is not possible, can someone explain me how it could be done? It is not an option to hardcode the values in the compose file or anywhere else in the source as they contain sensitive data.

If i am asking this in the wrong place, please redirect me to where i should be.

Thanks!

答:
You need to set the environment variables in the shell that is running the docker-compose command line. In Jenkins, that's best done be inside your groovy script (Jenkins doesn't use the host environment within the build slave):

```<code>withEnv(["DOCKER_HOST=tcp://serverA:2375", "ENVA=hello", "ENVB=world"]) {
    sh "docker-compose pull some-service-acc"
    sh "docker-compose -p some-service-acc up -d some-service-acc"
}
</code>```

Edit: from the comments, you also want to pass secrets.

To do that, there are plugins like the Mask Password that would allow you to pass variables without them showing up in the logs or job configuration. (I'm fairly certain a determined intruder could still get to the values since Jenkins itself knows it and passes it to your script in clear text.)

The better option IMO is to use a secrets management tool inside of docker. Hashicorp has their Vault product which implements an encrypted K/V store where values are accessed with a time limited token and offers the ability to generate new passwords per request with integration into the target system. I'd consider this the highest level of security when fully configured, but you can configure this countless ways to suit your own needs. You'll need to write something to pull the secret and inject it into your container's environment (it's a rest protocol that you can add to your entrypoint).

The latest option from Docker itself is secrets management that requires the new Swarm Mode. You save your secret in the swarm and add it to the containers you want as a file using an entry in the docker-compose.yml version 3 format. If you already use Swarm Mode and can start your containers with docker stack deploy instead of docker-compose, this is a fairly easy solution to implement.

Body:
I am having some trouble with my docker containers and environment variables.

Currently i have a docker-compose.yml with the following defined:

version: '2.1'
services:
  some-service:
    build:
      context: .
    image: image/replacedvalues
    ports:
      - 8080
    environment:
      - PROFILE=acc
      - ENVA
      - ENVB
      - TZ=Europe/Berlin

  some-service-acc:
    extends:
      service: some-service
    environment:
      - SERVICE_NAME=some-service-acc

Now when i deploy this manually (via SSH command line directly) on server A, it will take the environmental variables from Server A and put them in my container. So i have the values of ENVA and ENVB from the host in my container. Using the following command (after building the image ofcourse): docker-compose up some-service-acc.

We are currently developing a better infrastructure and want to deploy services via Jenkins. Jenkins is up and running in a docker container on server B.

I can deploy the service via Jenkins (Job-DSL, setting DOCKER_HOST="tcp://serverA:2375"temporary). So it will run all docker (compose) commands on ServerA from the Jenkins Container on Server B. The service is up and running except that it doesn't have values for the ENVA and the ENVB.

Jenkins runs the following with the Job-DSL groovy script:

withEnv(["DOCKER_HOST=tcp://serverA:2375"]) {
    sh "docker-compose pull some-service-acc"
    sh "docker-compose -p some-service-acc up -d some-service-acc"
}

I tried setting them in my Jenkins container and on Server B itself but neither worked. Only when i deploy manually directly on Server A it works.

When i use docker inspect to inspect the running container, i get the following output for the env block:

"Env": [
    "PROFILE=acc",
    "affinity:container==JADFG09gtq340iggIN0jg53ij0gokngfs",
    "TZ=Europe/Berlin",
    "SERVICE_NAME=some-service-acc",
    "ENVA",
    "ENVB",
    "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
    "LANG=C.UTF-8",
    "JAVA_VERSION=8",
    "JAVA_UPDATE=121",
    "JAVA_BUILD=13",
    "JAVA_PATH=e9e7ea248e2c4826b92b3f075a80e441",
    "JAVA_HOME=/usr/lib/jvm/default-jvm",
    "JAVA_OPTS="
]

Where do i need to set the Environmental variables so that they will be passed to the container? I prefer to store the variables on Server A. But if this is not possible, can someone explain me how it could be done? It is not an option to hardcode the values in the compose file or anywhere else in the source as they contain sensitive data.

If i am asking this in the wrong place, please redirect me to where i should be.

Thanks!

Body:
You need to set the environment variables in the shell that is running the docker-compose command line. In Jenkins, that's best done be inside your groovy script (Jenkins doesn't use the host environment within the build slave):

withEnv(["DOCKER_HOST=tcp://serverA:2375", "ENVA=hello", "ENVB=world"]) {
    sh "docker-compose pull some-service-acc"
    sh "docker-compose -p some-service-acc up -d some-service-acc"
}

Edit: from the comments, you also want to pass secrets.

To do that, there are plugins like the Mask Password that would allow you to pass variables without them showing up in the logs or job configuration. (I'm fairly certain a determined intruder could still get to the values since Jenkins itself knows it and passes it to your script in clear text.)

The better option IMO is to use a secrets management tool inside of docker. Hashicorp has their Vault product which implements an encrypted K/V store where values are accessed with a time limited token and offers the ability to generate new passwords per request with integration into the target system. I'd consider this the highest level of security when fully configured, but you can configure this countless ways to suit your own needs. You'll need to write something to pull the secret and inject it into your container's environment (it's a rest protocol that you can add to your entrypoint).

The latest option from Docker itself is secrets management that requires the new Swarm Mode. You save your secret in the swarm and add it to the containers you want as a file using an entry in the docker-compose.yml version 3 format. If you already use Swarm Mode and can start your containers with docker stack deploy instead of docker-compose, this is a fairly easy solution to implement.


问:
Java : Convert string to use in url as part of a get
Hello I shall get straight to the point, I am trying to use a EditText input to use in a php url i want the url to to be like thi when it runs.

```<code>http://www.free-map.org.uk/course/mad/ws/hits.php?artist=Oasis
</code>```

SO I tried

```<code> URL url = new URL("http://www.free-map.org.uk/course/mad/ws/hits.php?artist=",et1);
</code>```

but i get the error

Here is the main part of my code.

```<code> class MyTask extends AsyncTask<Void,Void,String>
{
    EditText et1 = (EditText)findViewById(R.id.et1);

    public String doInBackground(Void... unused)
    {
        HttpURLConnection conn = null;
        try
        {
            URL url = new URL("http://www.free-map.org.uk/course/mad/ws/hits.php?artist=",et1);
            conn = (HttpURLConnection) url.openConnection();
            InputStream in = conn.getInputStream();
            if(conn.getResponseCode() == 200)
            {
                BufferedReader br = new BufferedReader(new InputStreamReader(in));
                String result = "", line;
                while((line = br.readLine()) !=null)
                    result += line;
                return result;
            }
            else
                return "HTTP ERROR: " + conn.getResponseCode();
        }
        catch(IOException e)
        {
            return e.toString();
        }
        finally
        {
            if(conn!=null)
                conn.disconnect();
        }
    }
</code>```

答:
I'm not sure what are you trying to do.

If you want to add the content of the EditText to your URL try:

```<code>URL url = new URL("http://www.free-map.org.uk/course/mad/ws/hits.php?artist="+et1.getText().toString());
</code>```

Body:
Hello I shall get straight to the point, I am trying to use a EditText input to use in a php url i want the url to to be like thi when it runs.

http://www.free-map.org.uk/course/mad/ws/hits.php?artist=Oasis

SO I tried

 URL url = new URL("http://www.free-map.org.uk/course/mad/ws/hits.php?artist=",et1);

but i get the error

Here is the main part of my code.

 class MyTask extends AsyncTask<Void,Void,String>
{
    EditText et1 = (EditText)findViewById(R.id.et1);

    public String doInBackground(Void... unused)
    {
        HttpURLConnection conn = null;
        try
        {
            URL url = new URL("http://www.free-map.org.uk/course/mad/ws/hits.php?artist=",et1);
            conn = (HttpURLConnection) url.openConnection();
            InputStream in = conn.getInputStream();
            if(conn.getResponseCode() == 200)
            {
                BufferedReader br = new BufferedReader(new InputStreamReader(in));
                String result = "", line;
                while((line = br.readLine()) !=null)
                    result += line;
                return result;
            }
            else
                return "HTTP ERROR: " + conn.getResponseCode();
        }
        catch(IOException e)
        {
            return e.toString();
        }
        finally
        {
            if(conn!=null)
                conn.disconnect();
        }
    }

Body:
I'm not sure what are you trying to do.

If you want to add the content of the EditText to your URL try:

URL url = new URL("http://www.free-map.org.uk/course/mad/ws/hits.php?artist="+et1.getText().toString());


问:
How to apply styles to a component programatically angular 2?
I have a component with four different possible styles files that could be applied depending on some variable. How could I apply the styles of that component before it renders? </p>

```<code>@Component({
    selector: 'settings-editor',
    templateUrl: './settings-editor.component.html',
    styleUrls: [ './a.less', './b.less' , './c.less' ]
})
export class SettingsEditorComponent implements OnInit {
   @Input()
   public styleType: string;

   ngOnInit() {
     if (this.styleType === 'A') {
        // Apply styles  from a.less only

     }
   }

}
</code>```

答:
Styles are compiled by Angular and with AoT this is done before you deploy the app, therefore there is nothing you can do at runtime. Without AoT this might work but I don't know about that.

One way would be to just add them all and switch between them using selectors

:host(.style1) {
  ...
}

:host(.style1) {
  ...
}
```

<pre class="lang-ts prettyprint-override"><code>class MyComponent {
  style:string = 'style2';
  @HostBinding('class.style1') style1:boolean = style == 'style1';
  @HostBinding('class.style2') style2:boolean = style == 'style2';
}
</code>```

Body:
I have a component with four different possible styles files that could be applied depending on some variable. How could I apply the styles of that component before it renders?

@Component({
    selector: 'settings-editor',
    templateUrl: './settings-editor.component.html',
    styleUrls: [ './a.less', './b.less' , './c.less' ]
})
export class SettingsEditorComponent implements OnInit {
   @Input()
   public styleType: string;

   ngOnInit() {
     if (this.styleType === 'A') {
        // Apply styles  from a.less only

     }
   }

}

Body:
Styles are compiled by Angular and with AoT this is done before you deploy the app, therefore there is nothing you can do at runtime. Without AoT this might work but I don't know about that.

One way would be to just add them all and switch between them using selectors

:host(.style1) {
  ...
}

:host(.style1) {
  ...
}

class MyComponent {
  style:string = 'style2';
  @HostBinding('class.style1') style1:boolean = style == 'style1';
  @HostBinding('class.style2') style2:boolean = style == 'style2';
}


问:
problem with hudson
I am using Hudson for 6 projects, and most all of them are configured as a continious integration. I have a problem with one of the continious integration is not working;
when somebody checks in the code in the perforce, it's not triggering the build. I restarted it twice and its works good but again I have the same problem.

Please can any one help us

Thanks

答:
Check your perforce polling log for the job in question to see if it's having some trouble. You can get to it through the link on the left hand side of the job page.

Common pitfalls when dealing with polling with this plugin include:

Incorrect "Path to perforce executable" specified in the job config.

Workspace spec is incorrect, so no files, and thus no changes, are found.

Sharing client workspaces between jobs. In short: don't do it.

The use of on-demand slaves. The plugin needs access to a node that is used to build the project in order to get polling information. If no nodes are available, polling doesn't work correctly.

The incorrect use of the "View Mask" option can cause polling to stop working entirely. If you aren't sure how to use this option correctly, then you probably don't need to use it.

There is a known issue (HUDSON-2062) related to clogging/leaked pipes on certain operating systems (it seems restricted to CentOS/RedHat). If it works after a restart, but stops working after a few hours or days, then this is likely your problem.

You may want to contact the developer of the plugin directly, their contact info is on the link Sagar provided in his comment: http://wiki.hudson-ci.org/display/HUDSON/Perforce+Plugin, or file an issue here. Remember to include your Perforce Plugin and Hudson version numbers in either case.

Title: problem with hudson


问:
Using the SearchBox in Office UI Fabric React CommandBar
I'm trying to work out how to use the built in search box component on the CommandBar within Office UI Fabric React

The documentation at http://dev.office.com/fabric#/components/commandbar doesn't seem to cover it.

Specifically I'd like to know how to get the search term entered and to execute a search

答:
I've checked the source: https://github.com/OfficeDev/office-ui-fabric-react/blob/master/packages/office-ui-fabric-react/src/components/CommandBar/CommandBar.tsx

The searchbox is implemented as a simple input element:

```<code>if (isSearchBoxVisible) {
  searchBox = (
    <div className={ css('ms-CommandBarSearch', styles.search) } ref='searchSurface'>
      <input className={ css('ms-CommandBarSearch-input', styles.searchInput) } type='text' placeholder={ searchPlaceholderText } />
      <div className={ css(
        'ms-CommandBarSearch-iconWrapper ms-CommandBarSearch-iconSearchWrapper',
        styles.searchIconWrapper, styles.searchIconSearchWrapper) }>
        <i className={ css('ms-Icon ms-Icon--Search') }></i>
      </div>
      <div className={ css(
        'ms-CommandBarSearch-iconWrapper ms-CommandBarSearch-iconClearWrapper ms-font-s',
        styles.searchIconWrapper,
        styles.searchIconClearWrapper
      ) }>
        <i className={ css('ms-Icon ms-Icon--Cancel') }></i>
      </div>
    </div>
  );
}
</code>```

It can be accessed with the refs property:

```<code>  public refs: {
    [key: string]: React.ReactInstance;
    commandSurface: HTMLElement;
    farCommandSurface: HTMLElement;
    commandBarRegion: HTMLElement;
    searchSurface: HTMLElement;
    focusZone: FocusZone;
  };
</code>```

Now you could try to use the standard properties and events of an input element. (I haven't tried.)

Body:
I've checked the source: https://github.com/OfficeDev/office-ui-fabric-react/blob/master/packages/office-ui-fabric-react/src/components/CommandBar/CommandBar.tsx

The searchbox is implemented as a simple input element:

if (isSearchBoxVisible) {
  searchBox = (
    <div className={ css('ms-CommandBarSearch', styles.search) } ref='searchSurface'>
      <input className={ css('ms-CommandBarSearch-input', styles.searchInput) } type='text' placeholder={ searchPlaceholderText } />
      <div className={ css(
        'ms-CommandBarSearch-iconWrapper ms-CommandBarSearch-iconSearchWrapper',
        styles.searchIconWrapper, styles.searchIconSearchWrapper) }>
        <i className={ css('ms-Icon ms-Icon--Search') }></i>
      </div>
      <div className={ css(
        'ms-CommandBarSearch-iconWrapper ms-CommandBarSearch-iconClearWrapper ms-font-s',
        styles.searchIconWrapper,
        styles.searchIconClearWrapper
      ) }>
        <i className={ css('ms-Icon ms-Icon--Cancel') }></i>
      </div>
    </div>
  );
}

It can be accessed with the refs property:

  public refs: {
    [key: string]: React.ReactInstance;
    commandSurface: HTMLElement;
    farCommandSurface: HTMLElement;
    commandBarRegion: HTMLElement;
    searchSurface: HTMLElement;
    focusZone: FocusZone;
  };

Now you could try to use the standard properties and events of an input element. (I haven't tried.)


问:
VS2017 Metadata file '.dll' could not be found
After upgrading to Visual Studio 2017, I am unable to build my project. Visual Studio 2015 still works when pointing at the exact same project.

this is the build errors I get Metadata file '******.dll' could not be found

I've already tried https://stackoverflow.com/a/17723774/3511012 with no success

答:
I tracked the issue down to a specific NuGet package that has not yet been updated for visual studio 2017. (Baseclass.Contrib)

It isn't yet registered as having updates available through the nuget package manager, but you can manually update using the nuget console and running this command Install-Package Baseclass.Contrib.Nuget.Output -Version 2.3.0-vs20172


问:
Is there a way to crack the password on an Excel VBA Project?
I've been asked to update some Excel 2003 macros, but the VBA projects are password protected, and it seems there's a lack of documentation... no-one knows the passwords.

Is there a way of removing or cracking the password on a VBA project?

答:
Colin Pickard is mostly correct, but don't confuse the "password to open" protection for the entire file with the VBA password protection, which is completely different from the former and is the same for Office 2003 and 2007 (for Office 2007, rename the file to .zip and look for the vbaProject.bin inside the zip). And that technically the correct way to edit the file is to use a OLE compound document viewer like CFX to open up the correct stream. Of course,  if you are just replacing bytes, the plain old binary editor may work.

BTW, if you are wondering about the exact format of these fields, they have it documented now:

http://msdn.microsoft.com/en-us/library/dd926151%28v=office.12%29.aspx


问:
Position of Seaborn heatmap annotations in cells
The annotations in a Seaborn heatmap are centered in the middle of each cell by default.
Is it possible to move the annotations to "top left".</p>

答:
A good idea may be to use the annotations from the heatmap, which are produces by the annot=True argument and later shift them half a pixel width upwards and half a pixel width left.
In order for this shifted position to be the top left corner of the text itself, the ha and va keyword arguments need to set as annot_kws.
The shift itself can be done using a translation transform.

```<code>import seaborn as sns
import numpy as np; np.random.seed(0)
import matplotlib.pylab as plt
import matplotlib.transforms

data = np.random.randint(100, size=(5,5))
akws = {"ha": 'left',"va": 'top'}
ax = sns.heatmap(data,  annot=True, annot_kws=akws)

for t in ax.texts:
    trans = t.get_transform()
    offs = matplotlib.transforms.ScaledTranslation(-0.48, 0.48,
                    matplotlib.transforms.IdentityTransform())
    t.set_transform( offs + trans )

plt.show()
</code>```

The behaviour is a bit counterintuitive as +0.48 in the transform shifts the label upwards (against the direction of the axes). This behaviour seems to be corrected in seaborn version 0.8; for plots in seaborn 0.8 or higher use the more intuitive transform

```<code>offs = matplotlib.transforms.ScaledTranslation(-0.48, -0.48,
                    matplotlib.transforms.IdentityTransform())
</code>```

Body:
A good idea may be to use the annotations from the heatmap, which are produces by the annot=True argument and later shift them half a pixel width upwards and half a pixel width left.
In order for this shifted position to be the top left corner of the text itself, the ha and va keyword arguments need to set as annot_kws.
The shift itself can be done using a translation transform.

import seaborn as sns
import numpy as np; np.random.seed(0)
import matplotlib.pylab as plt
import matplotlib.transforms

data = np.random.randint(100, size=(5,5))
akws = {"ha": 'left',"va": 'top'}
ax = sns.heatmap(data,  annot=True, annot_kws=akws)

for t in ax.texts:
    trans = t.get_transform()
    offs = matplotlib.transforms.ScaledTranslation(-0.48, 0.48,
                    matplotlib.transforms.IdentityTransform())
    t.set_transform( offs + trans )

plt.show()

The behaviour is a bit counterintuitive as +0.48 in the transform shifts the label upwards (against the direction of the axes). This behaviour seems to be corrected in seaborn version 0.8; for plots in seaborn 0.8 or higher use the more intuitive transform

offs = matplotlib.transforms.ScaledTranslation(-0.48, -0.48,
                    matplotlib.transforms.IdentityTransform())


问:
Remove an array depending its values
I have this array :

```<code>Array
(
[0] => Array
    (
        [complet_title] => test1
        [have_background] => 0
        [condition_type] => 1
        [state] => 1
    )

[1] => Array
    (
        [complet_title] => test2
        [have_background] => 1
        [condition_type] => 1
        [state] => 0
    )
)
</code>```

My php code :

```<code>foreach($a_sliders as $k => $slider){
        switch($slider['condition_type']){
            case 1:
                if($slider['state'] == 1){
                    if(Test::check($id, $server)){
                        unset($a_sliders[$k]);
                    }else{

                    }
                }
        }
    }
</code>```

In the else I want to delete the sub-array with the condition_type = 1 and state = 0. It's possible to do that whitout a suplimentaire foreach ? Can you help me please ? Thx in advance and sorry for my english

答:
Use it like this,</p>

```<code>foreach($a_sliders as $k => $slider){
        switch($slider['condition_type']){
            case 1:
                if($slider['state'] == 1){
                    if(Test::check($id, $server)){
                        unset($a_sliders[$k]);
                    }
                }
           // your conditions are likely to be met here
                else if ($slider['state'] == 0 && $slider['condition_type'] == 1){
                        unset($a_sliders[$k]);
            }
        }
    }
</code>```

Title: Remove an array depending its values

Body:
I have this array :

Array
(
[0] => Array
    (
        [complet_title] => test1
        [have_background] => 0
        [condition_type] => 1
        [state] => 1
    )

[1] => Array
    (
        [complet_title] => test2
        [have_background] => 1
        [condition_type] => 1
        [state] => 0
    )
)

My php code :

foreach($a_sliders as $k => $slider){
        switch($slider['condition_type']){
            case 1:
                if($slider['state'] == 1){
                    if(Test::check($id, $server)){
                        unset($a_sliders[$k]);
                    }else{

                    }
                }
        }
    }

In the else I want to delete the sub-array with the condition_type = 1 and state = 0. It's possible to do that whitout a suplimentaire foreach ? Can you help me please ? Thx in advance and sorry for my english

Body:
Use it like this,

foreach($a_sliders as $k => $slider){
        switch($slider['condition_type']){
            case 1:
                if($slider['state'] == 1){
                    if(Test::check($id, $server)){
                        unset($a_sliders[$k]);
                    }
                }
           // your conditions are likely to be met here
                else if ($slider['state'] == 0 && $slider['condition_type'] == 1){
                        unset($a_sliders[$k]);
            }
        }
    }


问:
Are JS imports immutable or non-writable?
From what I can tell, an import binding is immutable

```<code>import { foo } from './foo';
...
foo.bar = 23; // works
...
foo = { bar: 23 }; // syntax error
</code>```

However, I've read elsewhere that JS imports are actually non-writable (not immutable)...in which case wouldn't the first assignment statement, foo.bar = 23; also throw a syntax error?

UPDATE (how I understand it now)

...to paraphrase the excellent answer by @FelixKing...

JS imports are immutable bindings to the exported thing (variable, function, etc).

For non-primitive imports, this does not mean the properties on the imported object are necessarily immutable or non-writable.

答:
in which case wouldn't the first assignment statement, foo.bar = 23; also throw a syntax error?

Non-writable refers to the value of the variable, where as mutable (immutable) describes whether the value itself can be changed in place or not.

Imports are not writable as you have found out. But if the value of an import is mutable then you can update the value (in place).

```<code>foo.bar = 23;
</code>```

does not assign a new value to foo. It is reading the value of foo and then modifying it (by adding or overwriting a property). If you did

```<code>var oldFoo = foo;
foo.bar = 23;
oldFoo === foo; // true
</code>```

you would get true. That indicates that foo has still the same value assigned to it. It only updated the value (an object) in place.

All objects are mutable (unless passed to Object.freeze or similar functions), whereas primitive values (String, Number, etc) are all immutable.

Body:
From what I can tell, an import binding is immutable

import { foo } from './foo';
...
foo.bar = 23; // works
...
foo = { bar: 23 }; // syntax error

However, I've read elsewhere that JS imports are actually non-writable (not immutable)...in which case wouldn't the first assignment statement, foo.bar = 23; also throw a syntax error?

UPDATE (how I understand it now)

...to paraphrase the excellent answer by @FelixKing...

JS imports are immutable bindings to the exported thing (variable, function, etc).

For non-primitive imports, this does not mean the properties on the imported object are necessarily immutable or non-writable.

Body:
in which case wouldn't the first assignment statement, foo.bar = 23; also throw a syntax error?

Non-writable refers to the value of the variable, where as mutable (immutable) describes whether the value itself can be changed in place or not.

Imports are not writable as you have found out. But if the value of an import is mutable then you can update the value (in place).

foo.bar = 23;

does not assign a new value to foo. It is reading the value of foo and then modifying it (by adding or overwriting a property). If you did

var oldFoo = foo;
foo.bar = 23;
oldFoo === foo; // true

you would get true. That indicates that foo has still the same value assigned to it. It only updated the value (an object) in place.

All objects are mutable (unless passed to Object.freeze or similar functions), whereas primitive values (String, Number, etc) are all immutable.


问:
How to pass items to bash for loop on multiple lines?
I can do this in bash:

```<code>for n in a b c d e ; do
  echo $n
done
</code>```

If a, b, c, d, e turn out to be long lines, without using a separate variable, how do I put them each on a separate line in the for loop syntax?

答:
I'd use a "here document":

```<code>while read n; do
  echo $n
done <<EOF
some detailed stuff here
other things on the next line, blah blah blah
EOF
</code>```

Of course in this particular example you can replace the entire while loop with cat but I suppose your real code is more involved.

Body:
I can do this in bash:

for n in a b c d e ; do
  echo $n
done

If a, b, c, d, e turn out to be long lines, without using a separate variable, how do I put them each on a separate line in the for loop syntax?

Body:
I'd use a "here document":

while read n; do
  echo $n
done <<EOF
some detailed stuff here
other things on the next line, blah blah blah
EOF

Of course in this particular example you can replace the entire while loop with cat but I suppose your real code is more involved.


答:
you can put a b c d e in a file and run a loop over that file.

```<code>while read line
do
    echo "$line \n"
done < file
</code>```

Title: How to pass items to bash for loop on multiple lines?

Body:
you can put a b c d e in a file and run a loop over that file.

while read line
do
    echo "$line \n"
done < file


问:
Should DocumentDB OfferThroughput be set in Code?
One of the most difficult things with DocumentDB is figuring out how many Request Units per Second (RUs/s) you need to run your application day to day but also during usage spikes. When you get this wrong, the DocumentDB client will throw exceptions, which is a terrible usage model.

I have seen the OfferThroughput value hard coded to 400 (which seems to be the lowest RUs/s) when creating a new collection in the DocumentDB samples. I would have thought that setting it in the Azure portal would be best, so it can be changed dynamically without having to do code changes.

What is the scenario for setting it in code and which value takes precedence?

答:
I have to agree, the provisioning model for buying throughput on DocumentDB seems very un-cloud-y. In effect, you're either pre-provisioning to the highest level a spike would ever need, or you're coding something on your own to raise and lower the throughput via the Azure SDK (which becomes a nightmare when there is more than one source of spike against that collection).

The pricing model is ridiculous. Since the underlying architecture (most especially at the 250GB tier) seems meant to scale well anyway, we should simply be charged per-use.

Side note, for it to be dynamic, you are writing code, since there doesn't seem to be any rules-oriented solution under Azure to help.


问:
MaxMind API how to parse array?
My MaxMind API Call receives this array:

```<code>object(MaxMind\MinFraud\Model\Score)#5 (8) {
  ["disposition":protected]=>
  object(MaxMind\MinFraud\Model\Disposition)#33 (3) {
    ["action":protected]=>
    NULL
    ["reason":protected]=>
    NULL
    ["rawResponse"]=>
    NULL
  }
  ["fundsRemaining":protected]=>
  float(4.94)
  ["id":protected]=>
  string(36) "604DE3C0-13DE-11E7-B630-507824A72470"
  ["ipAddress":protected]=>
  object(MaxMind\MinFraud\Model\ScoreIpAddress)#36 (2) {
    ["risk":protected]=>
    float(0.01)
    ["rawResponse"]=>
    array(1) {
      ["risk"]=>
      float(0.01)
    }
  }
</code>```

How I get this value ["risk"]=>float(0.01) ?

Thanks in advance!

答: Per the documentation, you can access the IP risk score with $resp->ipAddress->risk or the overall risk score with $resp->riskScore.

Title: MaxMind API how to parse array?

Body:
My MaxMind API Call receives this array:

object(MaxMind\MinFraud\Model\Score)#5 (8) {
  ["disposition":protected]=>
  object(MaxMind\MinFraud\Model\Disposition)#33 (3) {
    ["action":protected]=>
    NULL
    ["reason":protected]=>
    NULL
    ["rawResponse"]=>
    NULL
  }
  ["fundsRemaining":protected]=>
  float(4.94)
  ["id":protected]=>
  string(36) "604DE3C0-13DE-11E7-B630-507824A72470"
  ["ipAddress":protected]=>
  object(MaxMind\MinFraud\Model\ScoreIpAddress)#36 (2) {
    ["risk":protected]=>
    float(0.01)
    ["rawResponse"]=>
    array(1) {
      ["risk"]=>
      float(0.01)
    }
  }

How I get this value ["risk"]=>float(0.01) ?

Thanks in advance!


问:
Addition of two integer in binary representation
I would like to implement code which will add two integers by their binary representation.

For instance:

```<code>a = [1 1 1 0];
</code>```

and

```<code>b = [1 0 1 1];
</code>```

So I implemented the following algorithm:

```<code>function s=add_binary(a,b)
  m=length(a);
  s=zeros(m+1,0);
  n=length(a);
  c=0;
  for ii=n:-1:1
    d=floor((a(ii)+b(ii)+c)/2);
    s(ii)=a(ii)+b(ii)+c-2*d;
    c=d;
  end
  s(1)=c;
end
</code>```

However, it returns this as a result:

```<code>s=add_binary(a,b)

s =

     1     0     0     1
</code>```

Here, there should be an additional 1 on the left, such that it would read:

```<code>1 1 0 0 1
</code>```

Where am I making a mistake?

答:
Use num2str to convert a and b to strings and use bin2dec to convert them to decimal. Then add them and convert the sum back to binary using dec2bin. Use num2cell to split the string and finally use  str2double to get the desired result.

```<code>s=str2double(num2cell(dec2bin(bin2dec(num2str(a))+bin2dec(num2str(b)))))

% Output for given a and b
%---------------------------
% s =
%   1     1     0     0     1
</code>```

Body:
I would like to implement code which will add two integers by their binary representation.

For instance:

a = [1 1 1 0];

and

b = [1 0 1 1];

So I implemented the following algorithm:

function s=add_binary(a,b)
  m=length(a);
  s=zeros(m+1,0);
  n=length(a);
  c=0;
  for ii=n:-1:1
    d=floor((a(ii)+b(ii)+c)/2);
    s(ii)=a(ii)+b(ii)+c-2*d;
    c=d;
  end
  s(1)=c;
end

However, it returns this as a result:

s=add_binary(a,b)

s =

     1     0     0     1

Here, there should be an additional 1 on the left, such that it would read:

1 1 0 0 1

Where am I making a mistake?

Body:
Use num2str to convert a and b to strings and use bin2dec to convert them to decimal. Then add them and convert the sum back to binary using dec2bin. Use num2cell to split the string and finally use  str2double to get the desired result.

s=str2double(num2cell(dec2bin(bin2dec(num2str(a))+bin2dec(num2str(b)))))

% Output for given a and b
%---------------------------
% s =
%   1     1     0     0     1


问:
Process n objects each time by condition
I have next object struct:

```<code>{
1698452536:Object {url: "1", isProcessed: false}
1701673991:Object {url: "2", isProcessed: false}
1717724454:Object {url: "3", isProcessed: false}
1756233961:Object {url: "4", isProcessed: false}
1797093325:Object {url: "5", isProcessed: false}
1857721095:Object {url: "6", isProcessed: false}
2095153396:Object {url: "7", isProcessed: false}
2098466246:Object {url: "8", isProcessed: false}
2131427779:Object {url: "9", isProcessed: false}
89975:Object {url: "10", isProcessed: false}
21591836:Object {url: "11", isProcessed: false}
80794211:Object {url: "12", isProcessed: false}
116460496:Object {url: "13", isProcessed: false}
159798435:Object {url: "14", isProcessed: false}
223366448:Object {url: "15", isProcessed: false}
361352239:Object {url: "16", isProcessed: false}
498790092:Object {url: "17", isProcessed: false}
508072650:Object {url: "18", isProcessed: false}
514973525:Object {url: "19", isProcessed: false}
560440401:Object {url: "20", isProcessed: false}
}
</code>```

I need to process five inner objects each time and only after first five is completed take another five.
Is there is a way to do such implementation?

UPDATE:

I`d tried next code in order to transform object to chunked array, but how to call bulk by bulk async and only after full bulk is succeed take another?

```<code>chunkArray(Object.values(images),5).forEach((array)=>{});
function chunkArray(array, groupsize) {
var sets = [],
    chunks, i = 0;
chunks = array.length / groupsize;

while (i < chunks) {
    sets[i] = array.splice(0, groupsize);
    i++;
}
return sets;
</code>```

}

答:
Use Object.keys to get all the object's keys as an array, and then you can do your solution for array:</p>

```<code>var objs = {
    1698452536:Object {url: "1", isProcessed: false}
    1701673991:Object {url: "2", isProcessed: false}
    1717724454:Object {url: "3", isProcessed: false}
    1756233961:Object {url: "4", isProcessed: false}
    1797093325:Object {url: "5", isProcessed: false}
    1857721095:Object {url: "6", isProcessed: false}
    2095153396:Object {url: "7", isProcessed: false}
    2098466246:Object {url: "8", isProcessed: false}
    2131427779:Object {url: "9", isProcessed: false}
    89975:Object {url: "10", isProcessed: false}
    21591836:Object {url: "11", isProcessed: false}
    80794211:Object {url: "12", isProcessed: false}
    116460496:Object {url: "13", isProcessed: false}
    159798435:Object {url: "14", isProcessed: false}
    223366448:Object {url: "15", isProcessed: false}
    361352239:Object {url: "16", isProcessed: false}
    498790092:Object {url: "17", isProcessed: false}
    508072650:Object {url: "18", isProcessed: false}
    514973525:Object {url: "19", isProcessed: false}
    560440401:Object {url: "20", isProcessed: false}
};

var keys = Object.keys(objs);

for (var i = 0; i < keys.length; i += 5) {
    // Do something on every five keys
}
</code>```

Body:
I have next object struct:

{
1698452536:Object {url: "1", isProcessed: false}
1701673991:Object {url: "2", isProcessed: false}
1717724454:Object {url: "3", isProcessed: false}
1756233961:Object {url: "4", isProcessed: false}
1797093325:Object {url: "5", isProcessed: false}
1857721095:Object {url: "6", isProcessed: false}
2095153396:Object {url: "7", isProcessed: false}
2098466246:Object {url: "8", isProcessed: false}
2131427779:Object {url: "9", isProcessed: false}
89975:Object {url: "10", isProcessed: false}
21591836:Object {url: "11", isProcessed: false}
80794211:Object {url: "12", isProcessed: false}
116460496:Object {url: "13", isProcessed: false}
159798435:Object {url: "14", isProcessed: false}
223366448:Object {url: "15", isProcessed: false}
361352239:Object {url: "16", isProcessed: false}
498790092:Object {url: "17", isProcessed: false}
508072650:Object {url: "18", isProcessed: false}
514973525:Object {url: "19", isProcessed: false}
560440401:Object {url: "20", isProcessed: false}
}

I need to process five inner objects each time and only after first five is completed take another five.
Is there is a way to do such implementation?

UPDATE:

I`d tried next code in order to transform object to chunked array, but how to call bulk by bulk async and only after full bulk is succeed take another?

chunkArray(Object.values(images),5).forEach((array)=>{});
function chunkArray(array, groupsize) {
var sets = [],
    chunks, i = 0;
chunks = array.length / groupsize;

while (i < chunks) {
    sets[i] = array.splice(0, groupsize);
    i++;
}
return sets;

}

Body:
Use Object.keys to get all the object's keys as an array, and then you can do your solution for array:

var objs = {
    1698452536:Object {url: "1", isProcessed: false}
    1701673991:Object {url: "2", isProcessed: false}
    1717724454:Object {url: "3", isProcessed: false}
    1756233961:Object {url: "4", isProcessed: false}
    1797093325:Object {url: "5", isProcessed: false}
    1857721095:Object {url: "6", isProcessed: false}
    2095153396:Object {url: "7", isProcessed: false}
    2098466246:Object {url: "8", isProcessed: false}
    2131427779:Object {url: "9", isProcessed: false}
    89975:Object {url: "10", isProcessed: false}
    21591836:Object {url: "11", isProcessed: false}
    80794211:Object {url: "12", isProcessed: false}
    116460496:Object {url: "13", isProcessed: false}
    159798435:Object {url: "14", isProcessed: false}
    223366448:Object {url: "15", isProcessed: false}
    361352239:Object {url: "16", isProcessed: false}
    498790092:Object {url: "17", isProcessed: false}
    508072650:Object {url: "18", isProcessed: false}
    514973525:Object {url: "19", isProcessed: false}
    560440401:Object {url: "20", isProcessed: false}
};

var keys = Object.keys(objs);

for (var i = 0; i < keys.length; i += 5) {
    // Do something on every five keys
}


问:
Haskell, List as input for a function, How?
I've been given the following question in my coursework;

Define a function

```<code>flatten :: [(Char,Int)] -> String
</code>```

that flattens a list of pairs of characters and digits to a string. For example:

```<code>flatten [('a',5),('b',4),('c',2)]
"a5b4c2"
flatten [('d',9),('d',3)]
"d9d3"
</code>```

My problem is that whenever I attempt to define this function i get a type error relating the the [(Char, Int)] input. For example;

```<code>Couldn't match type '(Char, Int)' with '[Char]'
Expected type: [[Char]]
Actual type: [(Char, Int)]
</code>```

I've tried more ways of writing this definition in more ways than I can count, so I don't have any particular code to show, or any particular error ( I kept getting different ones...so many). All i have so far is;

```<code>flatten :: [(Char, Int)] -> String
flatten [] = []
</code>```

i figure my next line should go something like;

```<code>flatten ???? = concat (????)
</code>```

but I have no idea what to put in place of these question marks and Google search/class notes give no examples to follow.
any ideas?

答:
First of all, we try to create a String from a (Char, Int). If we can do that we've almost done, since we can do that for all (Char, Int). So let's transform a single (Char, Int):

```<code>flattenSingle :: (Char, Int) -> String
flattenSingle (c, i) = c : show i
</code>```

Now, we need to do that for all entries:

```<code>flattenAll :: [(Char, Int)] -> [String]
flattenAll xs = map flattenSingle xs
</code>```

And last, but not least, we need to concat the [String] (which is a [[Char]]) to a String (which is a [Char]):

```<code>flatten :: [(Char, Int)] -> String
flatten xs = concat (flattenAll xs)
</code>```

And we're done. How did we do that? Well, we've started with a much easier problem, namely how to get a single String from a (Char, Int), and used that to get our result.

Here's everything in a single function:

```<code>flatten = concat . map flattenSingle
  where
    flattenSingle (c, i) = c : show i
</code>```

Since concat . map f is often used, there's a function for that, called concatMap:

```<code>flatten :: [(Char, Int)] -> String
flatten = concatMap flattenSingle
  where
    flattenSingle (c, i) = c : show i
</code>```

Body:
I've been given the following question in my coursework;

Define a function

flatten :: [(Char,Int)] -> String

that flattens a list of pairs of characters and digits to a string. For example:

flatten [('a',5),('b',4),('c',2)]
"a5b4c2"
flatten [('d',9),('d',3)]
"d9d3"

My problem is that whenever I attempt to define this function i get a type error relating the the [(Char, Int)] input. For example;

Couldn't match type '(Char, Int)' with '[Char]'
Expected type: [[Char]]
Actual type: [(Char, Int)]

I've tried more ways of writing this definition in more ways than I can count, so I don't have any particular code to show, or any particular error ( I kept getting different ones...so many). All i have so far is;

flatten :: [(Char, Int)] -> String
flatten [] = []

i figure my next line should go something like;

flatten ???? = concat (????)

but I have no idea what to put in place of these question marks and Google search/class notes give no examples to follow.
any ideas?

Body:
First of all, we try to create a String from a (Char, Int). If we can do that we've almost done, since we can do that for all (Char, Int). So let's transform a single (Char, Int):

flattenSingle :: (Char, Int) -> String
flattenSingle (c, i) = c : show i

Now, we need to do that for all entries:

flattenAll :: [(Char, Int)] -> [String]
flattenAll xs = map flattenSingle xs

And last, but not least, we need to concat the [String] (which is a [[Char]]) to a String (which is a [Char]):

flatten :: [(Char, Int)] -> String
flatten xs = concat (flattenAll xs)

And we're done. How did we do that? Well, we've started with a much easier problem, namely how to get a single String from a (Char, Int), and used that to get our result.

Here's everything in a single function:

flatten = concat . map flattenSingle
  where
    flattenSingle (c, i) = c : show i

Since concat . map f is often used, there's a function for that, called concatMap:

flatten :: [(Char, Int)] -> String
flatten = concatMap flattenSingle
  where
    flattenSingle (c, i) = c : show i


问:
Url is not showing any information
I am developing a web application that should be open to all attacks of owasp list. Most of the attacks are using url to get information but in my web application nothing is showed in url except name of file. Although i have set session variable. Anyone knows how can I show these values in url?</p>

答:
You can see variables in URL only when you use a GET protocol:
Your url will be :

```<code>site.com/file.php?param1=value1&param2=value2
</code>```

Else, you can use POST protocol, and your url will be

```<code>site.com/file.php
</code>```

It's not a secure way to send datas, but it just hide them.
It's more simple to change a variable with GET than POST, but you can change/add every variables with POST protocol too.

Title: Url is not showing any information

Body:
You can see variables in URL only when you use a GET protocol:
Your url will be :

site.com/file.php?param1=value1&param2=value2

Else, you can use POST protocol, and your url will be

site.com/file.php

It's not a secure way to send datas, but it just hide them.
It's more simple to change a variable with GET than POST, but you can change/add every variables with POST protocol too.


问:
Oracle Webcenter sites perspective buttons are not working in eclipse [ Developer Tools: Reading all asset types returned status: Forbidden ]
I've installed the com.fatwire.EclipseCSDT_11.1.1.v8_0_r181775.zip (CSDT) plugin to eclipse (mars) for webcenter sites.

But when I click on create new template or any CSDT buttons it shows below error in error log window.

If I open it, it shows as below:

Can someone please help to resolve it.

答:
Found user configured for webcenter sites was not assigned in the REST Security group.

Assign the User to the REST Security group and restart your eclipse.

It will start working :)

Happy coding!!