问:
Translucent Databases
I am building an application with health information inside. This application will be consumer-facing with is new for me. I would like a method to put privacy concerns completely at ease. As I review methods for securing sensitive data in publicly accessible databases I have frequently come across the notion of database translucency. There is the original book on the subject and an excellent tutorial on the subject from Oriellynet.

My concern is that I have seen very little information regarding this idea on what I would consider very-modern programming sites (like this one). There does not seem to be an article about the idea on wikipedia. No questions on the subject here, and no very recent tutorials or articles on the subject. To be uber-brief, the idea is that certain data is clear to some users of the system, while other users a cryptographically prevented from accessing that data, even if they have administrator access.

I have done substantial work on a prototype database that provides translucent data access. I have run across a considerable problem: To be truly translucent, there can be no mechanism for password recovery. If an administrator can reset a users password, then they can briefly gain access to a users data. To be truly translucent, the user must never loose the password.

Those of us who use strong encryption to protect private data in our daily lives (technorati to be sure) are used to this problem when using these kinds of strong encryption systems. If the word "blowfish" is part of your daily lexicon that is one thing, but a website that is consumer focused? I am concerned that users will not be willing to wrap their mind around the "truly encrypted just for you" notion implicit with true database translucency. I am afraid of the support call that begins with "I lost my password" and ends with me saying "There is nothing that I can do for you".

My question: Should I implement this method in my application? Are there other open source applications that have gone down this route that I can compare database designs with (esp using php/MySQL)? I anyone else pursuing these kind of truly secure, but really inconvenient feature sets? Is there another database security model that is more popular and modern that I have missed? Was database translucency a fad or a legitimate database design method that I should embrace? While I always appreciate discussion I would prefer objective answers that I can leverage in my design.

答:
So, I've been looking at something similar to this recently, and hit upon the same issue. The solution I'm considering implementing is as follows:

Upon registration, create a unique, secure (long) key for the user and use this to encrypt their data.

Encrypt this key with the user's password using e.g. AES and store it in the database.

At this point, you're still in the situation where if the user forgets their password, they've had it.

Create a public/private key pair representing your organisation, and store the public key on the server.

Split the private portion of the key into several components and give each to people (e.g. directors of your company) who have a significant stake (preferably financial) in the continued success of your company. Do this such that any two, or any three people can get together and restore the full private key when required. Encrypt each person's key with their own password.

When a user registers, as well as encrypting their key with their password, encrypt it with the organisational public key and store it somewhere.

Create a password reset form which records a request to reset the password of a user, along with some proof that the user is who they say they are (e.g. challenge/response).

Record these reset requests (optionally encrypted using the public key again) in the database.

Once per hour/day/week/month, get the requisite key-holders together, and use their combined keys to process the accrued reset requests, decrypting the keys of users who successfully proved they are who they say they are.

There are lots of challenges and considerations in this. I've got a few thoughts on most of these, but would be interested in others opinions too:

How to split the key safely between multiple people so that no one person can decrypt the stored keys.

How to minimise the number of keys that would be exposed if the 'master keys' genuinely fell into the wrong hands.

How to make sure that if (heaven forbid) your key-holders lost their keys, then (a) there's no risk of exposure of the data, and (b) there's no risk that suddenly the ability to reset passwords is lost forever.

How to successfully validate that someone really is who they say they are without making this a glaring hole in your whole security approach.

Anything you implement in this area WILL reduce the security of the translucent database approach, without a doubt, but this may be a worthwhile compromise depending on the nature of your data.

Title: Translucent Databases


来源: stackexchange

问:
Best practice for executing large number of tasks
Below code creates large number of runnable object in loop, even only 5 treads are there to process the tasks. Is there any way so that at any moment only 5 runnable object will be present in memory not the total number of tasks( 100000).</p>

```<code>ExecutorService executor = Executors.newFixedThreadPool(5);
for (int i = 0; i < 10000; i++) {
    Runnable worker = new WorkerThread("" + i);
    System.out.println("ExecutorExample.main()");
    executor.execute(worker);
}
</code>```

答:
The requirement that at any moment only 5 runnable object will be present in memory is too restrictive. When a task finishes, there would be no next task to run, and some time would be spend to create another task. Better to have 5 runnung tasks and 5 waiting in a line. In order to restrict the number of the tasks in the queue, use a BlockingQueue of fixed size for runnables, e.g.

```<code>ThreadPoolExecutor executor = new ThreadPoolExecutor(
     5, 5,
     10L, TimeUnit.MILLISECONDS,
     new LinkedBlockingQueue<Runnable>(5)
)
</code>```

UPDT To avoid RejectedExecutionException, add RejectedExecutionHandler, as proposed in https://stackoverflow.com/a/3518588/1206301:

```<code>RejectedExecutionHandler block = new RejectedExecutionHandler() {
        @Override
        public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
            try {
                executor.getQueue().put(r);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    };
    executor.setRejectedExecutionHandler(block);
</code>```

ContentLicense: CC BY-SA 3.0

Body:
Below code creates large number of runnable object in loop, even only 5 treads are there to process the tasks. Is there any way so that at any moment only 5 runnable object will be present in memory not the total number of tasks( 100000).

ExecutorService executor = Executors.newFixedThreadPool(5);
for (int i = 0; i < 10000; i++) {
    Runnable worker = new WorkerThread("" + i);
    System.out.println("ExecutorExample.main()");
    executor.execute(worker);
}

Body:
The requirement that at any moment only 5 runnable object will be present in memory is too restrictive. When a task finishes, there would be no next task to run, and some time would be spend to create another task. Better to have 5 runnung tasks and 5 waiting in a line. In order to restrict the number of the tasks in the queue, use a BlockingQueue of fixed size for runnables, e.g.

ThreadPoolExecutor executor = new ThreadPoolExecutor(
     5, 5,
     10L, TimeUnit.MILLISECONDS,
     new LinkedBlockingQueue<Runnable>(5)
)

UPDT To avoid RejectedExecutionException, add RejectedExecutionHandler, as proposed in https://stackoverflow.com/a/3518588/1206301:

RejectedExecutionHandler block = new RejectedExecutionHandler() {
        @Override
        public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
            try {
                executor.getQueue().put(r);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    };
    executor.setRejectedExecutionHandler(block);


问:
How do i get a Picture bigger than the box arround it without deforming everything?
i have a project at school where im trying to make a flashgames website but im stuck with a problem.I want the picture be bigger than the gray box.The picture how i want it : https://prntscr.com/frvzyy

My html Code:

    *{
     margin: 0px;
     background-color:darkred;
    }
    ul {
        list-style-type: none;
        margin: 0;
        padding: 0;
        padding-left: 30%;
        padding-right: 30%;
        overflow: hidden;
        background-color: gray;
    }

    li {
        float: left;
    }

    li a {
        display: block;
        font-family: Verdana, Helvetica, sans-serif;
        color: white;
        text-align: center;
        padding: 14px 16px;
        text-decoration: none;
     background-color: darkred;
    }
    #logo {
        display: block;
        font-family: Verdana, Helvetica, sans-serif;
        background-color: black;
        text-align: center;
        padding: 10px 10px;
        text-decoration: none;
    }

    li a:hover {
        background-color: black;
    }

    }
    p{font-family:Tahoma;}```
<pre class="snippet-code-html lang-html prettyprint-override"><code>    <!DOCTYPE html>
    <html>
    <head>
        <title>Games</title>
        <link rel="stylesheet" href="css/nav.css">
    </head>
        <ul>
            <li>Games</li>
            <li>1vs1 Games</li>
            <li id="logo"><img src="src/flash%20games%20logo.png" style="width:250px;"></li>
            <li>Categories</li>
            <li>About us</li>

        </ul>
        <h1>Games</h1>
        <p>content bla bla</p>
    </html>   </code>```

答:
You need to make some changes to achieve this.

*{
    margin: 0px;
    background-color:darkred;
}
.nav{
    height: 100px;
}

ul {
    list-style-type: none;
    margin: 0;
    padding: 0;
    text-align: center;
    /*padding-left: 30%;
    padding-right: 30%;*/
    /*overflow: hidden;*/
    background-color: gray;
    height: 48px;
}

li {
    /*float: left;*/
    display: inline-block;
    vertical-align: top;
    margin: 0 -2px;

}

li a {
    display: block;
    font-family: Verdana, Helvetica, sans-serif;
    color: white;
    text-align: center;
    padding: 14px 16px;
    text-decoration: none;
    background-color: darkred;
}
#logo {
    /*display: block;*/
    font-family: Verdana, Helvetica, sans-serif;
    background-color: black;
    text-align: center;
    padding: 10px;
    text-decoration: none;
}
#logo img{
    display: block;
}

li a:hover {
    background-color: black;
}

}
p{font-family:Tahoma;}```
<pre class="snippet-code-html lang-html prettyprint-override"><code>    <div class="nav">
        <ul>
            <li>Games</li>
            <li>1vs1 Games</li>
            <li id="logo"><img src="https://s-media-cache-ak0.pinimg.com/originals/94/77/f9/9477f98e6d5154911c05467c4acb24c5.jpg" style="width:250px;"></li>
            <li>Categories</li>
            <li>About us</li>
        </ul>
    </div>
    <h1>Games</h1>
    <p>content bla bla</p></code>```

I hope it will helps you :)

Body:
i have a project at school where im trying to make a flashgames website but im stuck with a problem.I want the picture be bigger than the gray box.The picture how i want it : https://prntscr.com/frvzyy

My html Code:

    *{
     margin: 0px;
     background-color:darkred;
    }
    ul {
        list-style-type: none;
        margin: 0;
        padding: 0;
        padding-left: 30%;
        padding-right: 30%;
        overflow: hidden;
        background-color: gray;
    }

    li {
        float: left;
    }

    li a {
        display: block;
        font-family: Verdana, Helvetica, sans-serif;
        color: white;
        text-align: center;
        padding: 14px 16px;
        text-decoration: none;
     background-color: darkred;
    }
    #logo {
        display: block;
        font-family: Verdana, Helvetica, sans-serif;
        background-color: black;
        text-align: center;
        padding: 10px 10px;
        text-decoration: none;
    }

    li a:hover {
        background-color: black;
    }

    }
    p{font-family:Tahoma;}

    <!DOCTYPE html>

        <title>Games</title>
        <link rel="stylesheet" href="css/nav.css">

Games

1vs1 Games

Categories

About us

Games

content bla bla

Body:
You need to make some changes to achieve this.

*{
    margin: 0px;
    background-color:darkred;
}
.nav{
    height: 100px;
}

ul {
    list-style-type: none;
    margin: 0;
    padding: 0;
    text-align: center;
    /*padding-left: 30%;
    padding-right: 30%;*/
    /*overflow: hidden;*/
    background-color: gray;
    height: 48px;
}

li {
    /*float: left;*/
    display: inline-block;
    vertical-align: top;
    margin: 0 -2px;

}

li a {
    display: block;
    font-family: Verdana, Helvetica, sans-serif;
    color: white;
    text-align: center;
    padding: 14px 16px;
    text-decoration: none;
    background-color: darkred;
}
#logo {
    /*display: block;*/
    font-family: Verdana, Helvetica, sans-serif;
    background-color: black;
    text-align: center;
    padding: 10px;
    text-decoration: none;
}
#logo img{
    display: block;
}

li a:hover {
    background-color: black;
}

}
p{font-family:Tahoma;}

    <div class="nav">
        <ul>
            <li><a href="">Games</a></li>
            <li><a href="">1vs1 Games</a></li>
            <li id="logo"><img src="https://s-media-cache-ak0.pinimg.com/originals/94/77/f9/9477f98e6d5154911c05467c4acb24c5.jpg" style="width:250px;"></li>
            <li><a href="">Categories</a></li>
            <li><a href="">About us</a></li>
        </ul>
    </div>
    <h1>Games</h1>
    <p>content bla bla</p>

I hope it will helps you :)


问:
Odoo 10 adding field to sale order line
I am trying to code a module to provide a markup cell in each sale order line for quotes (Odoo 10). But I consistently get an error while loading the quote/sale order. Any help is welcomed.

This is the view:

```<code><?xml version="1.0"?>
<odoo>
    <record id="view_order_form_markup model" model="ir.ui.view">
        <field name="name">sale.order.form.markup</field>
        <field name="model">sale.order</field>
        <field name="inherit_id" ref="sale.view_order_form"/>
        <field name="arch" type="xml">
            <xpath expr='//field[@name="order_line"]/form/group/group/field[@name="price_unit"]' position="before">
                <label for="markup" string="Markup"/><field name="markup"/>
                <label for="markup_per" string="Markup (%)"/><field name="markup_per"/>
            </xpath>
            <xpath expr='//field[@name="order_line"]/tree/field[@name="price_unit"]' position="before">
                <label for="markup" string="Markup"/><field name="markup"/>
                <label for="markup_per" string="Markup (%)"/><field name="markup_per"/>
            </xpath>
        </field>
    </record>
</odoo>
</code>```

And the model:

```<code># -*- coding: utf-8 -*-

from odoo import api, fields, models
import odoo.addons.decimal_precision as dp

class SaleOrderLine(models.Model):
    _inherit = "sale.order.line"

    markup = fields.Float(compute='_compute_markup', digits=dp.get_precision('.2f%'), store=False, readonly=True)
    markup_per = fields.Float(compute='_compute_markup_per', digits=dp.get_precision('.2f%'), store=False, readonly=False)

    @api.depends('price_unit', 'purchase_price')
    def _compute_markup(self):
        for record in self:
            if record.price_unit and record.purchase_price:
                record.markup = record.price_unit - record.purchase_price

    @api.depends('price_unit', 'purchase_price')
    def _compute_markup_per(self):
        for record in self:
            if record.purchase_price > 0:
                record.markup_per = 100.0 * (record.price_unit - record.purchase_price) / record.purchase_price

    @api.onchange('markup_per')
    def _onchange_markup_per(self):
            if self.markup_per:
                if self.markup_per > -9999.99 and self.markup_per < 9999.99:
                    self.price_unit = self.purchase_price * (1 + self.markup_per / 100.0)
</code>```

But I am getting this error when I open a quote/sales order:

Uncaught TypeError: Type is not a constructor
  http://localhost:8369/web/content/365-ad86b81/web.assets_backend.js:2119
  Traceback: TypeError: Type is not a constructor
      at for_ (http://localhost:8369/web/content/365-ad86b81/web.assets_backend.js:2119:1208)
      at http://localhost:8369/web/content/365-ad86b81/web.assets_backend.js:2035:312
      at Function..map..collect (http://localhost:8369/web/content/319-32fb078/web.assets_common.js:13:270)
      at _.(anonymous function) [as map] (http://localhost:8369/web/content/319-32fb078/web.assets_common.js:69:526)
      at Class.setup_columns (http://localhost:8369/web/content/365-ad86b81/web.assets_backend.js:2035:261)
      at Class. (http://localhost:8369/web/content/365-ad86b81/web.assets_backend.js:2036:480)
      at http://localhost:8369/web/content/365-ad86b81/web.assets_backend.js:2099:11
      at Object. (http://localhost:8369/web/content/319-32fb078/web.assets_common.js:3202:136)
      at Object. (http://localhost:8369/web/content/319-32fb078/web.assets_common.js:547:681)
      at fire (http://localhost:8369/web/content/319-32fb078/web.assets_common.js:541:299)

答:
Just change your xml view like this.</p>

```<code><?xml version="1.0"?>
<odoo>
    <record id="view_order_form_markup model" model="ir.ui.view">
        <field name="name">sale.order.form.markup</field>
        <field name="model">sale.order</field>
        <field name="inherit_id" ref="sale.view_order_form"/>
        <field name="arch" type="xml">
            <xpath expr='//field[@name="order_line"]/form/group/group/field[@name="price_unit"]' position="before">
                <label for="markup" string="Markup"/><field name="markup"/>
                <label for="markup_per" string="Markup (%)"/><field name="markup_per"/>
            </xpath>
            <xpath expr='//field[@name="order_line"]/tree/field[@name="price_unit"]' position="before">
                <field name="markup" string="Markup"/>
                <field name="markup_per" string="Markup (%)"/>
            </xpath>
        </field>
    </record>
</odoo>
</code>```

Title: Odoo 10 adding field to sale order line

Body:
I am trying to code a module to provide a markup cell in each sale order line for quotes (Odoo 10). But I consistently get an error while loading the quote/sale order. Any help is welcomed.

This is the view:

<?xml version="1.0"?>
<odoo>
    <record id="view_order_form_markup model" model="ir.ui.view">
        <field name="name">sale.order.form.markup</field>
        <field name="model">sale.order</field>
        <field name="inherit_id" ref="sale.view_order_form"/>
        <field name="arch" type="xml">
            <xpath expr='//field[@name="order_line"]/form/group/group/field[@name="price_unit"]' position="before">
                <field name="markup"/>
                <field name="markup_per"/>
            </xpath>
            <xpath expr='//field[@name="order_line"]/tree/field[@name="price_unit"]' position="before">
                <field name="markup"/>
                <field name="markup_per"/>
            </xpath>
        </field>
    </record>
</odoo>

And the model:

# -*- coding: utf-8 -*-

from odoo import api, fields, models
import odoo.addons.decimal_precision as dp

class SaleOrderLine(models.Model):
    _inherit = "sale.order.line"

    markup = fields.Float(compute='_compute_markup', digits=dp.get_precision('.2f%'), store=False, readonly=True)
    markup_per = fields.Float(compute='_compute_markup_per', digits=dp.get_precision('.2f%'), store=False, readonly=False)

    @api.depends('price_unit', 'purchase_price')
    def _compute_markup(self):
        for record in self:
            if record.price_unit and record.purchase_price:
                record.markup = record.price_unit - record.purchase_price

    @api.depends('price_unit', 'purchase_price')
    def _compute_markup_per(self):
        for record in self:
            if record.purchase_price > 0:
                record.markup_per = 100.0 * (record.price_unit - record.purchase_price) / record.purchase_price

    @api.onchange('markup_per')
    def _onchange_markup_per(self):
            if self.markup_per:
                if self.markup_per > -9999.99 and self.markup_per < 9999.99:
                    self.price_unit = self.purchase_price * (1 + self.markup_per / 100.0)

But I am getting this error when I open a quote/sales order:

Uncaught TypeError: Type is not a constructor
  http://localhost:8369/web/content/365-ad86b81/web.assets_backend.js:2119
  Traceback: TypeError: Type is not a constructor
      at for_ (http://localhost:8369/web/content/365-ad86b81/web.assets_backend.js:2119:1208)
      at http://localhost:8369/web/content/365-ad86b81/web.assets_backend.js:2035:312
      at Function..map..collect (http://localhost:8369/web/content/319-32fb078/web.assets_common.js:13:270)
      at _.(anonymous function) [as map] (http://localhost:8369/web/content/319-32fb078/web.assets_common.js:69:526)
      at Class.setup_columns (http://localhost:8369/web/content/365-ad86b81/web.assets_backend.js:2035:261)
      at Class. (http://localhost:8369/web/content/365-ad86b81/web.assets_backend.js:2036:480)
      at http://localhost:8369/web/content/365-ad86b81/web.assets_backend.js:2099:11
      at Object. (http://localhost:8369/web/content/319-32fb078/web.assets_common.js:3202:136)
      at Object. (http://localhost:8369/web/content/319-32fb078/web.assets_common.js:547:681)
      at fire (http://localhost:8369/web/content/319-32fb078/web.assets_common.js:541:299)

Body:
Just change your xml view like this.

<?xml version="1.0"?>
<odoo>
    <record id="view_order_form_markup model" model="ir.ui.view">
        <field name="name">sale.order.form.markup</field>
        <field name="model">sale.order</field>
        <field name="inherit_id" ref="sale.view_order_form"/>
        <field name="arch" type="xml">
            <xpath expr='//field[@name="order_line"]/form/group/group/field[@name="price_unit"]' position="before">
                <label for="markup" string="Markup"/><field name="markup"/>
                <label for="markup_per" string="Markup (%)"/><field name="markup_per"/>
            </xpath>
            <xpath expr='//field[@name="order_line"]/tree/field[@name="price_unit"]' position="before">
                <field name="markup" string="Markup"/>
                <field name="markup_per" string="Markup (%)"/>
            </xpath>
        </field>
    </record>
</odoo>


问:
Chrome for Android showing Auto-fill even if autocomplete: off
I have a form with 4 fields where the user is supposed to enter two cities (From and To) and two dates (outbound and return date).

I have autocomplete:off, which works fine among most of the browsers. However, for Chrome on Android I get the annoying Auto-fill that overlaps my own suggestion drop-down list.

Trials

I have tried every single one of the suggested solutions from here and here, including:

1) Putting a hidden field before my fields in the form. Even with the same name as the first real field:

```<code><input type="text" style="display:none" name="same_name_as_1st_field"/>
</code>```

2) Hidding a div, instead of the input tag directly:

```<code><div style="display: none;">
    <input type="text" name="same_name_as_1st_field" />
</div>
</code>```

3) Changing from autocomplete="off" to autocomplete="false"

4) Browser autofill in by readonly-mode.

```<code><input type="password" readonly onfocus="this.removeAttribute('readonly');"/>
</code>```

5) autocomplete="new-password"

6) <form autocomplete="off" role="presentation">

7) With JQuery:

```<code>if ($.browser.webkit) {
    $('input[name="my_field_name"]').attr('autocomplete', 'off');
}
</code>```

8) JQuery:

```<code>$(window).ready(function () {
    $('#my_id').val(' ').val('');
});
</code>```

9) More complicated JQuery from here:

```<code>jQuery('body').on('mousedown keydown','[name="name"][autocomplete="off"],
[name="email"][autocomplete="off"]',function(e){
    e.stopImmediatePropagation();
    if(typeof this.currentName =="undefined")
        this.currentName=jQuery(this).attr('name');
    jQuery(this).attr('name','');
});
jQuery('body').on('blur keyup','[autocomplete="off"]',function(e){
    e.stopImmediatePropagation();
    if(typeof this.currentName !="undefined")
        jQuery(this).attr('name',this.currentName);
});
</code>```

Please notice that for Solution 1 and 2, I just took the cases where
    the input name is "name" and "email". For any other case where this
    attribute makes Chrome generate the dropdown you will have to add it
    in the selector for the mouse down event.

10) Own idea: I realized that by giving the field a default value, the auto-fill does not show up. Then, I tried giving a default value and clearing that value on focus with javascript...

```<code><script>
    $('#id_From').focus(function() {
        this.value = "";
    });
</script>
</code>```

And none works.

Any idea of how to solve this?

答:
Update (21-12-2017)

The old solution stopped working, so here is a new one.

The auto-fill is triggered with the following input tag:

```<code><input type="search" name="To"  id="id_To" placeholder="a" class="autocomplete-city form-inner-field-city ui-autocomplete-input" autocomplete="off" maxlength="50" required="">
</code>```

Key here are the fields name and id, which were the ones modified with the old solution.
Apparently, Chrome identifies it as a field for Auto-fill. Thus, changing the name and id to something Chrome cannot identify seems to do the trick (for the moment).

For instance:

```<code><input type="search" name="Dep"  id="id_Dep" placeholder="a" class="autocomplete-city form-inner-field-city ui-autocomplete-input" autocomplete="off" maxlength="50" required="">
</code>```

OLD

Finally a solution that worked, from here:

It removes "name" and "id" attributes from elements and assigns them
  back after 1ms. Put this in document get ready.

```<code>$(document).ready(function() {
    $('form[autocomplete="off"] input, input[autocomplete="off"]').each(function () {

                var input = this;
                var name = $(input).attr('name');
                var id = $(input).attr('id');

                $(input).removeAttr('name');
                $(input).removeAttr('id');

                setTimeout(function () {
                    $(input).attr('name', name);
                    $(input).attr('id', id);
                }, 1);
            });
});
</code>```

Body:
I have a form with 4 fields where the user is supposed to enter two cities (From and To) and two dates (outbound and return date).

I have autocomplete:off, which works fine among most of the browsers. However, for Chrome on Android I get the annoying Auto-fill that overlaps my own suggestion drop-down list.

Trials

I have tried every single one of the suggested solutions from here and here, including:

1) Putting a hidden field before my fields in the form. Even with the same name as the first real field:

<input type="text" style="display:none" name="same_name_as_1st_field"/>

2) Hidding a div, instead of the input tag directly:

    <input type="text" name="same_name_as_1st_field" />

3) Changing from autocomplete="off" to autocomplete="false"

4) Browser autofill in by readonly-mode.

<input type="password" readonly onfocus="this.removeAttribute('readonly');"/>

5) autocomplete="new-password"

6) <form autocomplete="off" role="presentation">

7) With JQuery:

if ($.browser.webkit) {
    $('input[name="my_field_name"]').attr('autocomplete', 'off');
}

8) JQuery:

$(window).ready(function () {
    $('#my_id').val(' ').val('');
});

9) More complicated JQuery from here:

jQuery('body').on('mousedown keydown','[name="name"][autocomplete="off"],
[name="email"][autocomplete="off"]',function(e){
    e.stopImmediatePropagation();
    if(typeof this.currentName =="undefined")
        this.currentName=jQuery(this).attr('name');
    jQuery(this).attr('name','');
});
jQuery('body').on('blur keyup','[autocomplete="off"]',function(e){
    e.stopImmediatePropagation();
    if(typeof this.currentName !="undefined")
        jQuery(this).attr('name',this.currentName);
});

Please notice that for Solution 1 and 2, I just took the cases where
    the input name is "name" and "email". For any other case where this
    attribute makes Chrome generate the dropdown you will have to add it
    in the selector for the mouse down event.

10) Own idea: I realized that by giving the field a default value, the auto-fill does not show up. Then, I tried giving a default value and clearing that value on focus with javascript...

And none works.

Any idea of how to solve this?

Body:
Update (21-12-2017)

The old solution stopped working, so here is a new one.

The auto-fill is triggered with the following input tag:

<input type="search" name="To"  id="id_To" placeholder="a" class="autocomplete-city form-inner-field-city ui-autocomplete-input" autocomplete="off" maxlength="50" required="">

Key here are the fields name and id, which were the ones modified with the old solution.
Apparently, Chrome identifies it as a field for Auto-fill. Thus, changing the name and id to something Chrome cannot identify seems to do the trick (for the moment).

For instance:

<input type="search" name="Dep"  id="id_Dep" placeholder="a" class="autocomplete-city form-inner-field-city ui-autocomplete-input" autocomplete="off" maxlength="50" required="">

OLD

Finally a solution that worked, from here:

It removes "name" and "id" attributes from elements and assigns them
  back after 1ms. Put this in document get ready.

$(document).ready(function() {
    $('form[autocomplete="off"] input, input[autocomplete="off"]').each(function () {

                var input = this;
                var name = $(input).attr('name');
                var id = $(input).attr('id');

                $(input).removeAttr('name');
                $(input).removeAttr('id');

                setTimeout(function () {
                    $(input).attr('name', name);
                    $(input).attr('id', id);
                }, 1);
            });
});


问:
Warning: a promise was created in a handler at but was not returned from it
```<code> Promise.map(response.orders.orders, function(order) {

                  if(order.order_destination == "OC"){
                        return searchOrdersBll.promisifyOrdersOC(order).then(function(order){
                          return searchOrdersBll.orderCommentHistory(order);
                          })
                    }else if(order.order_destination == "OB"){
                        return searchOrdersBll.promisifyOrdersOB(order).then(function(order){
                           return searchOrdersBll.orderCommentHistory(order);
                          })
                    }

                })
                .then(function(data) {
                    args.order = data;
                    args.track_orders = [];
                    htmlResponse(req, res, partials.orderedtemplate, args);
                })
</code>```

getting issues:

Warning: a promise was created in a handler at
  var/www/html/customerservice/server/apps/search/controller/search_bll.js:56:29
  but was not returned from it,
      at Function.Promise.map (/var/www/html/customerservice/node_modules/bluebird/js/release/map.js:164:12)

答:
You just need to return the promise returned by htmlResponse:

```<code>Promise.map(response.orders.orders, function(order) {

                  if(order.order_destination == "OC"){
                        return searchOrdersBll.promisifyOrdersOC(order).then(function(order){
                          return searchOrdersBll.orderCommentHistory(order);
                          })
                    }else if(order.order_destination == "OB"){
                        return searchOrdersBll.promisifyOrdersOB(order).then(function(order){
                           return searchOrdersBll.orderCommentHistory(order);
                          })
                    }

                })
                .then(function(data) {
                    args.order = data;
                    args.track_orders = [];
                    return htmlResponse(req, res, partials.orderedtemplate, args);
                })
</code>```

Body:
 Promise.map(response.orders.orders, function(order) {

                  if(order.order_destination == "OC"){
                        return searchOrdersBll.promisifyOrdersOC(order).then(function(order){
                          return searchOrdersBll.orderCommentHistory(order);
                          })
                    }else if(order.order_destination == "OB"){
                        return searchOrdersBll.promisifyOrdersOB(order).then(function(order){
                           return searchOrdersBll.orderCommentHistory(order);
                          })
                    }

                })
                .then(function(data) {
                    args.order = data;
                    args.track_orders = [];
                    htmlResponse(req, res, partials.orderedtemplate, args);
                })

getting issues:

Warning: a promise was created in a handler at
  var/www/html/customerservice/server/apps/search/controller/search_bll.js:56:29
  but was not returned from it,
      at Function.Promise.map (/var/www/html/customerservice/node_modules/bluebird/js/release/map.js:164:12)

Body:
You just need to return the promise returned by htmlResponse:

Promise.map(response.orders.orders, function(order) {

                  if(order.order_destination == "OC"){
                        return searchOrdersBll.promisifyOrdersOC(order).then(function(order){
                          return searchOrdersBll.orderCommentHistory(order);
                          })
                    }else if(order.order_destination == "OB"){
                        return searchOrdersBll.promisifyOrdersOB(order).then(function(order){
                           return searchOrdersBll.orderCommentHistory(order);
                          })
                    }

                })
                .then(function(data) {
                    args.order = data;
                    args.track_orders = [];
                    return htmlResponse(req, res, partials.orderedtemplate, args);
                })


问:
jsch - send special keys (CTRL-C, CTRL-D, etc.)
I need to send special keys to a remote terminal, how can I do that with JSCH?

Thanks,

Walter

答:
I switched to sshj and use the signal enumeration to send signals, if needed.

Walter

ContentLicense: CC BY-SA 2.5


问:
Passing parameters to stored procedure in OBIEE 12c rpd from OBIEE 12c dashboard
I am trying to create an OBIEE report using stored procedures.
I have created a function in SQL Developer which takes a parameter and returns refCursor as output.

I, then, set the following query as default initialization string in physical layer of rpd:
Select * from table(pipelined_emp(HR_DATA.GETCURSORS(parameter)))

GETCURSORS(parameter) is my function.

For now, in place of parameter, I am passing a constant value.
While, I wish to pass a value from the OBIEE dashboard, similar to a prompt, to this function in the physical layer of rpd.

Thanks!

答: Yes. Session variables in the RPD being written into by front-end request variables: https://gerardnico.com/wiki/dat/obiee/obis/request_variable</p>


问:
Read access violation when accessing shared memory
I implemented, based on the boost examples, a threadsafe queue-class in the shared memory. It works as expected for a simple producer/consumer model.

As a next step, I defined the interface IConcurrentIPCQueue which is implemented by the ConcurrentIPCQueue class. I need the interface so I can implement an adapter to the queue for another issue.

The only difference between my first version and the current one below is the following:

First version:

```<code>template <class T> class ConcurrentIPCQueue
</code>```

now adding the information, that I want to implement the interface like this:

Current version:

```<code>`template <class T> class ConcurrentIPCQueue :public IConcurrentIPCQueue<T>`
</code>```

results in a read access violation on the consumer side. On the producer side, I can easily push_back and pop_front data correctly on its own. But strangely on the consumer side, I cannot access the shared memory (although the pair from segment.find returns correctly an address and 1).
So the question is, why the version with implementing the interface makes a difference on the consumer side and results in this strange error. And how I can solve it?

To keep the example short, I present here a minimalistic model of the queue:

```<code>#include <boost/interprocess/allocators/allocator.hpp>
#include <boost/interprocess/containers/deque.hpp>
#include <boost/interprocess/managed_shared_memory.hpp>
#include <boost/interprocess/sync/interprocess_condition.hpp>
#include <boost/interprocess/sync/interprocess_mutex.hpp>
#include <boost/thread/lock_guard.hpp>
#include <sstream>

namespace boost_ipc = boost::interprocess;
static char const *SHMEMNAME= "SHMEM";
static char const *SHQUEUENAME= "MYQUEUE";

template <class T> class IConcurrentIPCQueue
{
public:
    virtual void push_back(T const & data) = 0;
    virtual bool pop_front(T & data) = 0;
virtual unsigned int size() = 0;
};

template <class T> class ConcurrentIPCQueue :public IConcurrentIPCQueue<T>
{
public:
    // allocator for allocating memory from the shared memory
    typedef boost_ipc::allocator<T, boost_ipc::managed_shared_memory::segment_manager> ShmemAlloc;
    typedef boost_ipc::interprocess_mutex IPC_Mutex;
    typedef boost_ipc::interprocess_condition IPC_Cond;
    typedef boost::lock_guard<IPC_Mutex> LockGuard;

    ConcurrentIPCQueue(ShmemAlloc salloc) : mQueue_(salloc) { }

    void push_back(T const & data)
    {
        {
            LockGuard lock(mMutex_);
            mQueue_.push_back(data);
        }
        mWait_.notify_one();
    }

    bool pop_front(T & data)
    {
        LockGuard lock(mMutex_);

        if (mQueue_.empty())
            return false;

        data = mQueue_.front(); // return reference to first element
        mQueue_.pop_front(); // remove the first element

        return true;
    }

unsigned int size()
{
    LockGuard lock(mMutex_);
    return mQueue_.size();
}

private:
    boost_ipc::deque<T, ShmemAlloc> mQueue_;
    IPC_Mutex mMutex_;
    IPC_Cond mWait_;
};

typedef ConcurrentIPCQueue<char> myqueue;

void consumer()
{
    boost_ipc::managed_shared_memory openedSegment(boost_ipc::open_only, SHMEMNAME);

    myqueue*openedQueue = openedSegment.find<myqueue>(SHQUEUENAME).first;
    char tmp;

    while (openedQueue->pop_front(tmp)) {
        std::cout << "Received " << tmp << "\n";
    }
}

void producer() {
    boost_ipc::shared_memory_object::remove(SHMEMNAME);

    boost_ipc::managed_shared_memory mysegment(boost_ipc::create_only, SHMEMNAME, 131072);

    myqueue::ShmemAlloc alloc(mysegment.get_segment_manager());
    myqueue*myQueue = mysegment.construct<myqueue>(SHQUEUENAME)(alloc);
char mychar='A';

    for (int i = 0; i < 10; ++i)
        myQueue->push_back(mychar);

    while (myQueue->size() > 0)
        continue;
}

int main()
{
    //producer(); // delete comment for creating producer process
    consumer();
    return 0;
}
</code>```

答:
UPDATE:

I could reproduce it with MSVC15.3 and Boost 1.64.

Turns out that the vtable pointers are the issue: they are different in each process, which leads to Undefined Behaviour as soon as you have runtime polymorphic types (std::is_polymorphic<T>).

It turns out the documentation forbids it clearly: Is it possible to store polymorphic class in shared memory?

Body:
I implemented, based on the boost examples, a threadsafe queue-class in the shared memory. It works as expected for a simple producer/consumer model.

As a next step, I defined the interface IConcurrentIPCQueue which is implemented by the ConcurrentIPCQueue class. I need the interface so I can implement an adapter to the queue for another issue.

The only difference between my first version and the current one below is the following:

First version:

template <class T> class ConcurrentIPCQueue

now adding the information, that I want to implement the interface like this:

Current version:

`template <class T> class ConcurrentIPCQueue :public IConcurrentIPCQueue<T>`

results in a read access violation on the consumer side. On the producer side, I can easily push_back and pop_front data correctly on its own. But strangely on the consumer side, I cannot access the shared memory (although the pair from segment.find returns correctly an address and 1).
So the question is, why the version with implementing the interface makes a difference on the consumer side and results in this strange error. And how I can solve it?

To keep the example short, I present here a minimalistic model of the queue:

#include <boost/interprocess/allocators/allocator.hpp>
#include <boost/interprocess/containers/deque.hpp>
#include <boost/interprocess/managed_shared_memory.hpp>
#include <boost/interprocess/sync/interprocess_condition.hpp>
#include <boost/interprocess/sync/interprocess_mutex.hpp>
#include <boost/thread/lock_guard.hpp>
#include <sstream>

namespace boost_ipc = boost::interprocess;
static char const *SHMEMNAME= "SHMEM";
static char const *SHQUEUENAME= "MYQUEUE";

template <class T> class IConcurrentIPCQueue
{
public:
    virtual void push_back(T const & data) = 0;
    virtual bool pop_front(T & data) = 0;
virtual unsigned int size() = 0;
};

template <class T> class ConcurrentIPCQueue :public IConcurrentIPCQueue<T>
{
public:
    // allocator for allocating memory from the shared memory
    typedef boost_ipc::allocator<T, boost_ipc::managed_shared_memory::segment_manager> ShmemAlloc;
    typedef boost_ipc::interprocess_mutex IPC_Mutex;
    typedef boost_ipc::interprocess_condition IPC_Cond;
    typedef boost::lock_guard<IPC_Mutex> LockGuard;

    ConcurrentIPCQueue(ShmemAlloc salloc) : mQueue_(salloc) { }

    void push_back(T const & data)
    {
        {
            LockGuard lock(mMutex_);
            mQueue_.push_back(data);
        }
        mWait_.notify_one();
    }

    bool pop_front(T & data)
    {
        LockGuard lock(mMutex_);

        if (mQueue_.empty())
            return false;

        data = mQueue_.front(); // return reference to first element
        mQueue_.pop_front(); // remove the first element

        return true;
    }

unsigned int size()
{
    LockGuard lock(mMutex_);
    return mQueue_.size();
}

private:
    boost_ipc::deque<T, ShmemAlloc> mQueue_;
    IPC_Mutex mMutex_;
    IPC_Cond mWait_;
};

typedef ConcurrentIPCQueue<char> myqueue;

void consumer()
{
    boost_ipc::managed_shared_memory openedSegment(boost_ipc::open_only, SHMEMNAME);

    myqueue*openedQueue = openedSegment.find<myqueue>(SHQUEUENAME).first;
    char tmp;

    while (openedQueue->pop_front(tmp)) {
        std::cout << "Received " << tmp << "\n";
    }
}

void producer() {
    boost_ipc::shared_memory_object::remove(SHMEMNAME);

    boost_ipc::managed_shared_memory mysegment(boost_ipc::create_only, SHMEMNAME, 131072);

    myqueue::ShmemAlloc alloc(mysegment.get_segment_manager());
    myqueue*myQueue = mysegment.construct<myqueue>(SHQUEUENAME)(alloc);
char mychar='A';

    for (int i = 0; i < 10; ++i)
        myQueue->push_back(mychar);

    while (myQueue->size() > 0)
        continue;
}

int main()
{
    //producer(); // delete comment for creating producer process
    consumer();
    return 0;
}


问:
Why variable value is not showing in insert query
I have this code snippet

```<code>$taskAssignedCompleteId = $row["TaskAssignCompletionId"];
echo "taskAssignedCompleteId::".$taskAssignedCompleteId. "\n";

if($taskAssignedCompleteId == 0 || $taskAssignedCompleteId = null)
{
    echo "Currently no task assigned to you. If you are not doing a task on PMS and still receving this massage then, contact your team lead";
    return;
}

$sqlInsert = "INSERT INTO emp_task_finished_request (EmpTaskAssignCompletionId, RequestDateTime) VALUES (".$taskAssignedCompleteId.", '$date')";
echo "output : ".$sqlInsert;
$queryInsert = $connPDO->exec($sqlInsert);

    echo "\n output : ".$queryInsert;
</code>```

Surprisingly $taskAssignedCompleteId value is not showing in query when i echo my $queryInsert varaiable while it is perfectly showing when i directly echo $taskAssignedCompleteId. Why is the problem? it is very strange for me.
here is my output

```<code>taskAssignedCompleteId::13
sqlInsert full : INSERT INTO emp_task_finished_request (EmpTaskAssignCompletionId, RequestDateTime) VALUES (, '2017-07-05 16:53:45')
 output :
</code>```

答:
You need to correct your if statement. <code>$taskAssignedCompleteId = null</code> is not correct. Kindly replace it by following </p>

```<code>if($taskAssignedCompleteId == 0 || $taskAssignedCompleteId == null)
</code>```

Body:
I have this code snippet

$taskAssignedCompleteId = $row["TaskAssignCompletionId"];
echo "taskAssignedCompleteId::".$taskAssignedCompleteId. "\n";

if($taskAssignedCompleteId == 0 || $taskAssignedCompleteId = null)
{
    echo "Currently no task assigned to you. If you are not doing a task on PMS and still receving this massage then, contact your team lead";
    return;
}

$sqlInsert = "INSERT INTO emp_task_finished_request (EmpTaskAssignCompletionId, RequestDateTime) VALUES (".$taskAssignedCompleteId.", '$date')";
echo "output : ".$sqlInsert;
$queryInsert = $connPDO->exec($sqlInsert);

    echo "\n output : ".$queryInsert;

Surprisingly $taskAssignedCompleteId value is not showing in query when i echo my $queryInsert varaiable while it is perfectly showing when i directly echo $taskAssignedCompleteId. Why is the problem? it is very strange for me.
here is my output

taskAssignedCompleteId::13
sqlInsert full : INSERT INTO emp_task_finished_request (EmpTaskAssignCompletionId, RequestDateTime) VALUES (, '2017-07-05 16:53:45')
 output :

Body:
You need to correct your if statement. $taskAssignedCompleteId = null is not correct. Kindly replace it by following

if($taskAssignedCompleteId == 0 || $taskAssignedCompleteId == null)


问:
Extract filenames and ext. from cell array of strings
I want to remove the directory part from a cell array of strings with filenames. Of course one way would be to loop over the cell arrray and use fileparts but I have over 1e5 files and speed really matters.

My current approach is:

```<code>fns = {"/usr/local/foo.lib", "~/baz.m", "home/rms/eula.txt", "bar.m"}

filenames = cellfun (@(fn, s) fn(s+1:end), fns,
                     num2cell (rindex (fns, filesep())),
                     "UniformOutput", false)
</code>```

which gives the desired output:

```<code>fns =
{
  [1,1] = /usr/local/foo.lib
  [1,2] = ~/baz.m
  [1,3] = home/rms/eula.txt
  [1,4] = bar.m
}
filenames =
{
  [1,1] = foo.lib
  [1,2] = baz.m
  [1,3] = eula.txt
  [1,4] = bar.m
}
</code>```

and takes approx 2e-5s per file. Is there a better (faster, more readable) way to do this?

EDIT I've added Sardars solution and my previous attempt with regex and some benchmark results:

```<code>fns = {"/usr/local/foo.lib", "~/baz.m", "home/rms/eula.txt", "bar.m"};
fns = repmat (fns, 1, 1e4);

tic
f1 = cellfun (@(fn, s) fn(s+1:end), fns,
              num2cell (rindex (fns, "/")),
              "UniformOutput", false);
toc

tic
[~, ~, ~, M] = regexp (fns, "[^\/]+$", "lineanchors");
f2 = cell2mat (M);
toc

tic
## Asnwer from Sardar Usama
f3 = regexprep(fns, '.*/', '');
toc

assert (f1, f2)
assert (f1, f3)
</code>```

which gives

```<code>Elapsed time is 0.729995 seconds.  (Original code with cellfun)
Elapsed time is 0.67545 seconds.   (using regexp)
Elapsed time is 0.230487 seconds.  (using regexprep)
</code>```

答:
Use regexprep to search the strings till the last / and replace the occurrences with an empty string.

```<code>filenames = regexprep(fns, '.*/', '');
</code>```

Body:
I want to remove the directory part from a cell array of strings with filenames. Of course one way would be to loop over the cell arrray and use fileparts but I have over 1e5 files and speed really matters.

My current approach is:

fns = {"/usr/local/foo.lib", "~/baz.m", "home/rms/eula.txt", "bar.m"}

filenames = cellfun (@(fn, s) fn(s+1:end), fns,
                     num2cell (rindex (fns, filesep())),
                     "UniformOutput", false)

which gives the desired output:

fns =
{
  [1,1] = /usr/local/foo.lib
  [1,2] = ~/baz.m
  [1,3] = home/rms/eula.txt
  [1,4] = bar.m
}
filenames =
{
  [1,1] = foo.lib
  [1,2] = baz.m
  [1,3] = eula.txt
  [1,4] = bar.m
}

and takes approx 2e-5s per file. Is there a better (faster, more readable) way to do this?

EDIT I've added Sardars solution and my previous attempt with regex and some benchmark results:

fns = {"/usr/local/foo.lib", "~/baz.m", "home/rms/eula.txt", "bar.m"};
fns = repmat (fns, 1, 1e4);

tic
f1 = cellfun (@(fn, s) fn(s+1:end), fns,
              num2cell (rindex (fns, "/")),
              "UniformOutput", false);
toc

tic
[~, ~, ~, M] = regexp (fns, "[^\/]+$", "lineanchors");
f2 = cell2mat (M);
toc

tic
## Asnwer from Sardar Usama
f3 = regexprep(fns, '.*/', '');
toc

assert (f1, f2)
assert (f1, f3)

which gives

Elapsed time is 0.729995 seconds.  (Original code with cellfun)
Elapsed time is 0.67545 seconds.   (using regexp)
Elapsed time is 0.230487 seconds.  (using regexprep)

Body:
Use regexprep to search the strings till the last / and replace the occurrences with an empty string.

filenames = regexprep(fns, '.*/', '');


问:
How can we take more than one input values in python language by using comma or space between two numbers or character
How can we take more than one input values in python language by using comma or space between two numbers or character??</p>

答:
try this:

```<code>m, n = raw_input().strip().split(" ")
</code>```

In the above example, the two values need to be input separated by a space.

If you prefer using a comma for whatever reason, change the split(" ") to split(",")

note that the above example is for python2.

For use in python3, change the raw_input() to input()

Body:
try this:

m, n = raw_input().strip().split(" ")

In the above example, the two values need to be input separated by a space.

If you prefer using a comma for whatever reason, change the split(" ") to split(",")

note that the above example is for python2.

For use in python3, change the raw_input() to input()


答:
This outta do it:

```<code>#leftbutton { float: left; }
#rightbutton { float: right; }
</code>```

Working example here: http://jsfiddle.net/KvWT2/

Title: What CSS would get two buttons to line up, respectively, on the left and right side of a 3-colspan table cell?

Body:
I have a table like this:

    short text
    long long long text
    short text

      <button id='leftbutton'/>
      <button id='rightbutton'/>

What CSS styles should I apply to get my buttons to lay out like this:

-----------------------------------------------------------------
|short text       |      long long long text     |  short text  |
-----------------------------------------------------------------
| button left     |                              | button right |
-----------------------------------------------------------------

instead of their current layout:

-----------------------------------------------------------------
|short text       |      long long long text     |  short text  |
-----------------------------------------------------------------
|button left|button right|
-----------------------------------------------------------------

Body:
This outta do it:

#leftbutton { float: left; }
#rightbutton { float: right; }

Working example here: http://jsfiddle.net/KvWT2/


问:
Neo4j return nested JSON
My Neo4j database contains family tree relationships.

I would like to extract that data in a nested JSON format like so:

```<code>{
"firstname":"Jon",
"lastname":"Smith",
"parents":[
  {
     "firstname":"Anna",
     "lastname":"Smith",
     "parents":[
        {
           "furstname":"Peter",
           "lastname":"Doe",
           "parents":[
              {
                 "firstname":"Jessica",
                 "lastname":"Doe"
              },
              {
                 "firstname":"Clayton",
                 "lastname":"Doe"
              }
           ]
        },
        {
           "firstname":"Nell",
           "lastname":"Gordon",
           "parents":[
              {
                 "firstname":"Jessica",
                 "lastname":"Roberts"
              },
              {
                 "firstname":"Randy",
                 "lastname":"Roberts"
              }
           ]
        }
     ]
  }
]
}
</code>```

in order to visualize it.

I have tried the following query:

```<code>MATCH path = (p:Person)-[r:PARENT_OF*1..3]-(k:Person)
WHERE k.id = '1887'
UNWIND r as rel
RETURN StartNode(rel).firstname, rels(path), EndNode(rel).firstname
</code>```

with the py2neo library like so:

```<code>dumps(graph.run(query).data())
</code>```

but the JSON was not nested like I desired.

Is there a query that would help me achieve this or I should do the nesting in other programming language?

答:
As sayd in the comments, you can use the APOC Procedure apoc.convert.toTree. Look:

1 - Creating a sample data set based on your question:

```<code>CREATE (jonsmith:Person {firstname:"Jon", lastname:"Smith"})
CREATE (annasmith:Person {firstname:"Anna", lastname:"Smith"})
CREATE (peterdoe:Person {firstname:"Peter", lastname:"Doe"})
CREATE (jessicadoe:Person {firstname:"Jessica", lastname:"Doe"})
CREATE (claytondoe:Person {firstname:"Clayton", lastname:"Doe"})
CREATE (nellgordon:Person {firstname:"Nell", lastname:"Gordon"})
CREATE (jessicaroberts:Person {firstname:"Jessica", lastname:"Roberts"})
CREATE (randyroberts:Person {firstname:"Randy", lastname:"Roberts"})

CREATE (jonsmith)-[:PARENT_OF]->(annasmith)
CREATE (annasmith)-[:PARENT_OF]->(peterdoe)
CREATE (annasmith)-[:PARENT_OF]->(nellgordon)
CREATE (peterdoe)-[:PARENT_OF]->(jessicadoe)
CREATE (peterdoe)-[:PARENT_OF]->(claytondoe)
CREATE (nellgordon)-[:PARENT_OF]->(jessicaroberts)
CREATE (nellgordon)-[:PARENT_OF]->(randyroberts)
</code>```

2 - Running the query:

```<code>MATCH path = (jon:Person {firstname:'Jon', lastname:'Smith'})-[:PARENT_OF*]-(:Person)
WITH collect(path) as paths
CALL apoc.convert.toTree(paths) yield value
RETURN value;
</code>```

3 - As result:

```<code>{
  "_type": "Person",
  "_id": 9,
  "firstname": "Jon",
  "lastname": "Smith",
  "parent_of": [
    {
      "_id": 10,
      "_type": "Person",
      "firstname": "Anna",
      "lastname": "Smith",
      "parent_of": [
        {
          "_id": 11,
          "_type": "Person",
          "firstname": "Peter",
          "lastname": "Doe",
          "parent_of": [
            {
              "_id": 12,
              "_type": "Person",
              "firstname": "Jessica",
              "lastname": "Doe"
            },
            {
              "_id": 13,
              "_type": "Person",
              "firstname": "Clayton",
              "lastname": "Doe"
            }
          ]
        },
        {
          "_id": 14,
          "_type": "Person",
          "firstname": "Nell",
          "lastname": "Gordon",
          "parent_of": [
            {
              "_id": 15,
              "_type": "Person",
              "firstname": "Jessica",
              "lastname": "Roberts"
            },
            {
              "_id": 16,
              "_type": "Person",
              "firstname": "Randy",
              "lastname": "Roberts"
            }
          ]
        }
      ]
    }
  ]
}
</code>```

Remember to install APOC procedures according the version of Neo4j are you using. Take a look in the version compatibility matrix.

Title: Neo4j return nested JSON

Body:
My Neo4j database contains family tree relationships.

I would like to extract that data in a nested JSON format like so:

{
"firstname":"Jon",
"lastname":"Smith",
"parents":[
  {
     "firstname":"Anna",
     "lastname":"Smith",
     "parents":[
        {
           "furstname":"Peter",
           "lastname":"Doe",
           "parents":[
              {
                 "firstname":"Jessica",
                 "lastname":"Doe"
              },
              {
                 "firstname":"Clayton",
                 "lastname":"Doe"
              }
           ]
        },
        {
           "firstname":"Nell",
           "lastname":"Gordon",
           "parents":[
              {
                 "firstname":"Jessica",
                 "lastname":"Roberts"
              },
              {
                 "firstname":"Randy",
                 "lastname":"Roberts"
              }
           ]
        }
     ]
  }
]
}

in order to visualize it.

I have tried the following query:

MATCH path = (p:Person)-[r:PARENT_OF*1..3]-(k:Person)
WHERE k.id = '1887'
UNWIND r as rel
RETURN StartNode(rel).firstname, rels(path), EndNode(rel).firstname

with the py2neo library like so:

dumps(graph.run(query).data())

but the JSON was not nested like I desired.

Is there a query that would help me achieve this or I should do the nesting in other programming language?

Body:
As sayd in the comments, you can use the APOC Procedure apoc.convert.toTree. Look:

1 - Creating a sample data set based on your question:

CREATE (jonsmith:Person {firstname:"Jon", lastname:"Smith"})
CREATE (annasmith:Person {firstname:"Anna", lastname:"Smith"})
CREATE (peterdoe:Person {firstname:"Peter", lastname:"Doe"})
CREATE (jessicadoe:Person {firstname:"Jessica", lastname:"Doe"})
CREATE (claytondoe:Person {firstname:"Clayton", lastname:"Doe"})
CREATE (nellgordon:Person {firstname:"Nell", lastname:"Gordon"})
CREATE (jessicaroberts:Person {firstname:"Jessica", lastname:"Roberts"})
CREATE (randyroberts:Person {firstname:"Randy", lastname:"Roberts"})

CREATE (jonsmith)-[:PARENT_OF]->(annasmith)
CREATE (annasmith)-[:PARENT_OF]->(peterdoe)
CREATE (annasmith)-[:PARENT_OF]->(nellgordon)
CREATE (peterdoe)-[:PARENT_OF]->(jessicadoe)
CREATE (peterdoe)-[:PARENT_OF]->(claytondoe)
CREATE (nellgordon)-[:PARENT_OF]->(jessicaroberts)
CREATE (nellgordon)-[:PARENT_OF]->(randyroberts)

2 - Running the query:

MATCH path = (jon:Person {firstname:'Jon', lastname:'Smith'})-[:PARENT_OF*]-(:Person)
WITH collect(path) as paths
CALL apoc.convert.toTree(paths) yield value
RETURN value;

3 - As result:

{
  "_type": "Person",
  "_id": 9,
  "firstname": "Jon",
  "lastname": "Smith",
  "parent_of": [
    {
      "_id": 10,
      "_type": "Person",
      "firstname": "Anna",
      "lastname": "Smith",
      "parent_of": [
        {
          "_id": 11,
          "_type": "Person",
          "firstname": "Peter",
          "lastname": "Doe",
          "parent_of": [
            {
              "_id": 12,
              "_type": "Person",
              "firstname": "Jessica",
              "lastname": "Doe"
            },
            {
              "_id": 13,
              "_type": "Person",
              "firstname": "Clayton",
              "lastname": "Doe"
            }
          ]
        },
        {
          "_id": 14,
          "_type": "Person",
          "firstname": "Nell",
          "lastname": "Gordon",
          "parent_of": [
            {
              "_id": 15,
              "_type": "Person",
              "firstname": "Jessica",
              "lastname": "Roberts"
            },
            {
              "_id": 16,
              "_type": "Person",
              "firstname": "Randy",
              "lastname": "Roberts"
            }
          ]
        }
      ]
    }
  ]
}

Remember to install APOC procedures according the version of Neo4j are you using. Take a look in the version compatibility matrix.


问:
HTML table- Create pop up box for each  and display xml data
I am working on a project and I am trying to create a web application. So far, my code is like this example. I press the button and a table appears. As you can see in the example, this table contains data of an XML file. THE PROBLEM: I want by clicking each 'td', a popup box to appear. This box will contain different data for each 'td', from the same XML file. Specifically, it will contain an image and some text that refers to the 'td'. Actually, I want something like this. I tried adding this code to my code and I created a popup button in every 'td'. But clicking these buttons, nothing happens. It would be nice if you share your knowledge with me!

答:
you can assign a class to td , and by click of that id with jquery modle called by

$("#MyModal").modal("show");

checkout this example

P.S. i have used bootstrap model for popup, but any other can be used with minimum change in code.

Title: HTML table- Create pop up box for each <td> and display xml data


问:
Error on inflating layout with navigation
When i inflate my layout with navigation drawer there is a error on inflating the layout.what is the problem in this layout.Please help me if someone can.
I am aded navigation_view in between drawer_layout but it cannot work and error on inflating layout

activity_main.xml

```<code><?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    app:actionViewClass="android.support.v7.widget.SearchView"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.techweblearn.musicplayer.MainActivity"
    android:id="@+id/drawer_layout">

<include layout="@layout/activity_main_view"
    android:layout_height="match_parent"
    android:layout_width="match_parent"/>

    <android.support.design.widget.NavigationView
        android:id="@+id/nav_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start" />

</android.support.v4.widget.DrawerLayout>
</code>```

activity_main_view.xml

```<code><android.support.design.widget.CoordinatorLayout  xmlns:android="http://schemas.android.com/apk/res/android"
app:actionViewClass="android.support.v7.widget.SearchView"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.design.widget.AppBarLayout
    android:id="@+id/appBar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <android.support.v7.widget.Toolbar
        android:id="@+id/my_toolbar"
        style="@style/MyAppTheme"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center_vertical" />

    <android.support.design.widget.TabLayout
        android:id="@+id/tab"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="top"
        android:background="#ffffff"
        app:tabIndicatorColor="@color/black" />

</android.support.design.widget.AppBarLayout>

<android.support.v4.view.ViewPager
    android:layout_marginBottom="?attr/actionBarSize"
    android:layout_marginTop="105dp"
    android:layout_below="@id/appBar"
    android:id="@+id/view_pager"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_alignParentLeft="true">

</android.support.v4.view.ViewPager>

<RelativeLayout
    android:elevation="16dp"
    android:id="@+id/design_bottom_sheet"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#ffffff"
    app:behavior_hideable="true"
    app:behavior_peekHeight="50dp"
    app:layout_behavior="@string/bottom_sheet_behavior">

    <fragment android:name="com.techweblearn.musicplayer.BottomPlayer"

        android:id="@+id/bottom_fragment"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

</RelativeLayout>
</code>```

Log

```<code>FATAL EXCEPTION: main
                                                                          Process: com.techweblearn.musicplayer, PID: 17999
                                                                          java.lang.RuntimeException: Unable to start activity ComponentInfo{com.techweblearn.musicplayer/com.techweblearn.musicplayer.MainActivity}: android.view.InflateException: Binary XML file line #12: Binary XML file line #12: Error inflating class android.support.design.widget.NavigationView
                                                                              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2665)
                                                                              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
                                                                              at android.app.ActivityThread.-wrap12(ActivityThread.java)
                                                                              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
                                                                              at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                              at android.os.Looper.loop(Looper.java:154)
                                                                              at android.app.ActivityThread.main(ActivityThread.java:6119)
                                                                              at java.lang.reflect.Method.invoke(Native Method)
                                                                              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
                                                                              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
                                                                           Caused by: android.view.InflateException: Binary XML file line #12: Binary XML file line #12: Error inflating class android.support.design.widget.NavigationView
                                                                           Caused by: android.view.InflateException: Binary XML file line #12: Error inflating class android.support.design.widget.NavigationView
                                                                           Caused by: java.lang.reflect.InvocationTargetException
                                                                              at java.lang.reflect.Constructor.newInstance0(Native Method)
                                                                              at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
                                                                              at android.view.LayoutInflater.createView(LayoutInflater.java:645)
                                                                              at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787)
                                                                              at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
                                                                              at android.view.LayoutInflater.rInflate(LayoutInflater.java:858)
                                                                              at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
                                                                              at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
                                                                              at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
                                                                              at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
                                                                              at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:292)
                                                                              at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
                                                                              at com.techweblearn.musicplayer.MainActivity.onCreate(MainActivity.java:116)
                                                                              at android.app.Activity.performCreate(Activity.java:6679)
                                                                              at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
                                                                              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
                                                                              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
                                                                              at android.app.ActivityThread.-wrap12(ActivityThread.java)
                                                                              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
                                                                              at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                              at android.os.Looper.loop(Looper.java:154)
                                                                              at android.app.ActivityThread.main(ActivityThread.java:6119)
                                                                              at java.lang.reflect.Method.invoke(Native Method)
                                                                              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
                                                                              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
                                                                           Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x0
                                                                              at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:190)
                                                                              at android.content.res.Resources.getColorStateList(Resources.java:992)
                                                                              at android.content.Context.getColorStateList(Context.java:542)
                                                                              at android.support.v7.content.res.AppCompatResources.getColorStateList(AppCompatResources.java:65)
                                                                              at android.support.design.widget.NavigationView.createDefaultColorStateList(NavigationView.java:422)
                                                                              at android.support.design.widget.NavigationView.<init>(NavigationView.java:148)
                                                                              at android.support.design.widget.NavigationView.<init>(NavigationView.java:100)
                                                                              at java.lang.reflect.Constructor.newInstance0(Native Method)
                                                                              at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
                                                                              at android.view.LayoutInflater.createView(LayoutInflater.java:645)
                                                                              at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787)
                                                                              at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
                                                                              at android.view.LayoutInflater.rInflate(LayoutInflater.java:858)
                                                                              at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
                                                                              at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
                                                                              at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
                                                                              at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
                                                                              at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:292)
                                                                              at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
                                                                              at com.techweblearn.musicplayer.MainActivity.onCreate(MainActivity.java:116)
                                                                              at android.app.Activity.performCreate(Activity.java:6679)
                                                                              at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
                                                                              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
                                                                              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
                                                                              at android.app.ActivityThread.-wrap12(ActivityThread.java)
                                                                              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
                                                                              at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                              at android.os.Looper.loop(Looper.java:154)
                                                                              at android.app.ActivityThread.main(ActivityThread.java:6119)
                                                                              at java.lang.reflect.Method.invoke(Native Method)
                                                                              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
                                                                              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
</code>```

答:
Solved the error by adding. </p>

```<code>app:itemTextColor="#000"
</code>```

<p>in navigationview </p>

```<code><android.support.design.widget.NavigationView
    android:id="@+id/nav_view"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    app:menu="@menu/nav_menu_item"
    app:headerLayout="@layout/nav_header"
    app:itemTextColor="#000"/>
</code>```

Body:
When i inflate my layout with navigation drawer there is a error on inflating the layout.what is the problem in this layout.Please help me if someone can.
I am aded navigation_view in between drawer_layout but it cannot work and error on inflating layout

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    app:actionViewClass="android.support.v7.widget.SearchView"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.techweblearn.musicplayer.MainActivity"
    android:id="@+id/drawer_layout">

<include layout="@layout/activity_main_view"
    android:layout_height="match_parent"
    android:layout_width="match_parent"/>

    <android.support.design.widget.NavigationView
        android:id="@+id/nav_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start" />

</android.support.v4.widget.DrawerLayout>

activity_main_view.xml

<android.support.design.widget.CoordinatorLayout  xmlns:android="http://schemas.android.com/apk/res/android"
app:actionViewClass="android.support.v7.widget.SearchView"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.design.widget.AppBarLayout
    android:id="@+id/appBar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <android.support.v7.widget.Toolbar
        android:id="@+id/my_toolbar"
        style="@style/MyAppTheme"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center_vertical" />

    <android.support.design.widget.TabLayout
        android:id="@+id/tab"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="top"
        android:background="#ffffff"
        app:tabIndicatorColor="@color/black" />

</android.support.design.widget.AppBarLayout>

<android.support.v4.view.ViewPager
    android:layout_marginBottom="?attr/actionBarSize"
    android:layout_marginTop="105dp"
    android:layout_below="@id/appBar"
    android:id="@+id/view_pager"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_alignParentLeft="true">

</android.support.v4.view.ViewPager>

<RelativeLayout
    android:elevation="16dp"
    android:id="@+id/design_bottom_sheet"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#ffffff"
    app:behavior_hideable="true"
    app:behavior_peekHeight="50dp"
    app:layout_behavior="@string/bottom_sheet_behavior">

    <fragment android:name="com.techweblearn.musicplayer.BottomPlayer"

        android:id="@+id/bottom_fragment"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

</RelativeLayout>

Log

FATAL EXCEPTION: main
                                                                          Process: com.techweblearn.musicplayer, PID: 17999
                                                                          java.lang.RuntimeException: Unable to start activity ComponentInfo{com.techweblearn.musicplayer/com.techweblearn.musicplayer.MainActivity}: android.view.InflateException: Binary XML file line #12: Binary XML file line #12: Error inflating class android.support.design.widget.NavigationView
                                                                              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2665)
                                                                              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
                                                                              at android.app.ActivityThread.-wrap12(ActivityThread.java)
                                                                              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
                                                                              at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                              at android.os.Looper.loop(Looper.java:154)
                                                                              at android.app.ActivityThread.main(ActivityThread.java:6119)
                                                                              at java.lang.reflect.Method.invoke(Native Method)
                                                                              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
                                                                              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
                                                                           Caused by: android.view.InflateException: Binary XML file line #12: Binary XML file line #12: Error inflating class android.support.design.widget.NavigationView
                                                                           Caused by: android.view.InflateException: Binary XML file line #12: Error inflating class android.support.design.widget.NavigationView
                                                                           Caused by: java.lang.reflect.InvocationTargetException
                                                                              at java.lang.reflect.Constructor.newInstance0(Native Method)
                                                                              at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
                                                                              at android.view.LayoutInflater.createView(LayoutInflater.java:645)
                                                                              at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787)
                                                                              at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
                                                                              at android.view.LayoutInflater.rInflate(LayoutInflater.java:858)
                                                                              at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
                                                                              at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
                                                                              at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
                                                                              at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
                                                                              at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:292)
                                                                              at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
                                                                              at com.techweblearn.musicplayer.MainActivity.onCreate(MainActivity.java:116)
                                                                              at android.app.Activity.performCreate(Activity.java:6679)
                                                                              at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
                                                                              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
                                                                              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
                                                                              at android.app.ActivityThread.-wrap12(ActivityThread.java)
                                                                              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
                                                                              at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                              at android.os.Looper.loop(Looper.java:154)
                                                                              at android.app.ActivityThread.main(ActivityThread.java:6119)
                                                                              at java.lang.reflect.Method.invoke(Native Method)
                                                                              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
                                                                              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
                                                                           Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x0
                                                                              at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:190)
                                                                              at android.content.res.Resources.getColorStateList(Resources.java:992)
                                                                              at android.content.Context.getColorStateList(Context.java:542)
                                                                              at android.support.v7.content.res.AppCompatResources.getColorStateList(AppCompatResources.java:65)
                                                                              at android.support.design.widget.NavigationView.createDefaultColorStateList(NavigationView.java:422)
                                                                              at android.support.design.widget.NavigationView.<init>(NavigationView.java:148)
                                                                              at android.support.design.widget.NavigationView.<init>(NavigationView.java:100)
                                                                              at java.lang.reflect.Constructor.newInstance0(Native Method)
                                                                              at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
                                                                              at android.view.LayoutInflater.createView(LayoutInflater.java:645)
                                                                              at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787)
                                                                              at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
                                                                              at android.view.LayoutInflater.rInflate(LayoutInflater.java:858)
                                                                              at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
                                                                              at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
                                                                              at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
                                                                              at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
                                                                              at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:292)
                                                                              at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
                                                                              at com.techweblearn.musicplayer.MainActivity.onCreate(MainActivity.java:116)
                                                                              at android.app.Activity.performCreate(Activity.java:6679)
                                                                              at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
                                                                              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
                                                                              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
                                                                              at android.app.ActivityThread.-wrap12(ActivityThread.java)
                                                                              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
                                                                              at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                              at android.os.Looper.loop(Looper.java:154)
                                                                              at android.app.ActivityThread.main(ActivityThread.java:6119)
                                                                              at java.lang.reflect.Method.invoke(Native Method)
                                                                              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
                                                                              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

Body:
Solved the error by adding.

app:itemTextColor="#000"

in navigationview

<android.support.design.widget.NavigationView
    android:id="@+id/nav_view"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    app:menu="@menu/nav_menu_item"
    app:headerLayout="@layout/nav_header"
    app:itemTextColor="#000"/>


问:
Angular Concatenate JSON result to scope
I have a search function that calls an external service that returns a JSON list, and i set this in scope.

I set the page number to this service, first time I send 1, when I want to search more items I pass 2, 3 and so on...

result contains the values that I expect, what I don't know is how to append to my scope the next pages.
I tried concat and push but it doesn't work.

CONTROLLER

tantoSvagoApp.controller("ricercaAttivita",

function ($scope, $http,  serviceRicercaAttivita) {

  function successCallBackAttivita(result) {
    if (page > 1){
        console.log("result " + JSON.stringify(result));
        $scope.elencoAttivita.concat(result);
    }else{
        $scope.elencoAttivita = result;
    }
  }

  serviceRicercaAttivita.getAttivita(parameters, successCallBackAttivita);

});
```

答:
Try This :</p>

```<code>tantoSvagoApp.controller("ricercaAttivita", function ($scope, $http,  serviceRicercaAttivita) {

function successCallBackAttivita(result) {

    if (page > 1){
        console.log("result " + JSON.stringify(result));

            $scope.elencoAttivita = $scope.elencoAttivita.concat(result);
    }else{
        $scope.elencoAttivita = result;
    }
}

serviceRicercaAttivita.getAttivita(parameters, successCallBackAttivita);

});
</code>```

Body:
Try This :

tantoSvagoApp.controller("ricercaAttivita", function ($scope, $http,  serviceRicercaAttivita) {

function successCallBackAttivita(result) {

    if (page > 1){
        console.log("result " + JSON.stringify(result));

            $scope.elencoAttivita = $scope.elencoAttivita.concat(result);
    }else{
        $scope.elencoAttivita = result;
    }
}

serviceRicercaAttivita.getAttivita(parameters, successCallBackAttivita);

});


问:
Python Brute Forcer?
I had a general idea in mind for a way to brute force a password, but being just a python novice, i'm not sure where to go from here...

So far I have the following:

```<code>password = "myPaSs123"

ll = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
ul = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]
n = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
s = ["!", "@", "#", "$", "%", "^", "&"]
full = ll+ul+n+s
crackedPass = []

def guesser():
    guess = 0
    for i in full:
        for x in range(len(password)):
            if i == password:
                crackedPass.append(i)
                print "Password found: " + str(crackedPass)

guesser()
</code>```

I now have no clue what to do from here. If someone has some insight to this topic, I would love any help. Thank you!

答:
This is what you wanted i belive, the problem is im just giving you answer for your problem and i belive you do not understand this code i have posted so let me explain in great detail!
Your code is ok but is just nasty in terms of reading this code i have posted is what you wanted to achieve but with a greater understanding of what you wanted to do...

(1st) we import the functions: itertools, math, and os

They give us a great amount of function for use in the program...
Then we have the alphabet which is simple enough it contains the alphabet or chars as i like to call them since they are chars after all.

The rest is up to you to read this is not a tutorial but reading through what i have gave you should give the lines to color in behind happy coding brother's/sister's !

```<code>import itertools, math
import os
Alphabet = ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890") # Add or     remove whatevs you think will be in the password you're cracking (example, [symbols])
counter = 1
CharLength = 1
range_num = int(raw_input("Enter range: "))
stopper = range_num + 1
filename = "bruteforce_%r.txt" % (range_num)
f = open(filename, 'a')
#n_1 = len(Alphabet)
#n_2 = n_1 - 1 # <-- total useless peice of garbage that could of been great in vurtual life
#n_3 = '0' * n_2
#n = '1' + n_3
x = range_num
y = len(Alphabet)
amount = math.pow(y, x)
total_items = math.pow(y, x)
for CharLength in range(range_num, stopper):
    passwords = (itertools.product(Alphabet, repeat = CharLength))

    for i in passwords:
        counter += 1
        percentage = (counter / total_items) * 100
        amount -= 1
        i = str(i)
        i = i.replace("[", "")
        i = i.replace("]", "")
        i = i.replace("'", "")
        i = i.replace(" ", "")
        i = i.replace(",", "")
        i = i.replace("(", "")
        i = i.replace(")", "")
        f.write(i)
        f.write('\n')
        print "Password: %r\tPercentage: %r/100\tAmount left: %r" % (i, int(percentage), amount)
        if i == '0'* range_num:
            print "*Done"
            f.close()
            exit(0)
        else:
            pass
</code>```

Title: Python Brute Forcer?

Body:
I had a general idea in mind for a way to brute force a password, but being just a python novice, i'm not sure where to go from here...

So far I have the following:

password = "myPaSs123"

ll = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
ul = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]
n = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
s = ["!", "@", "#", "$", "%", "^", "&"]
full = ll+ul+n+s
crackedPass = []

def guesser():
    guess = 0
    for i in full:
        for x in range(len(password)):
            if i == password:
                crackedPass.append(i)
                print "Password found: " + str(crackedPass)

guesser()

I now have no clue what to do from here. If someone has some insight to this topic, I would love any help. Thank you!

Body:
This is what you wanted i belive, the problem is im just giving you answer for your problem and i belive you do not understand this code i have posted so let me explain in great detail!
Your code is ok but is just nasty in terms of reading this code i have posted is what you wanted to achieve but with a greater understanding of what you wanted to do...

(1st) we import the functions: itertools, math, and os

They give us a great amount of function for use in the program...
Then we have the alphabet which is simple enough it contains the alphabet or chars as i like to call them since they are chars after all.

The rest is up to you to read this is not a tutorial but reading through what i have gave you should give the lines to color in behind happy coding brother's/sister's !

import itertools, math
import os
Alphabet = ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890") # Add or     remove whatevs you think will be in the password you're cracking (example, [symbols])
counter = 1
CharLength = 1
range_num = int(raw_input("Enter range: "))
stopper = range_num + 1
filename = "bruteforce_%r.txt" % (range_num)
f = open(filename, 'a')
#n_1 = len(Alphabet)
#n_2 = n_1 - 1 # <-- total useless peice of garbage that could of been great in vurtual life
#n_3 = '0' * n_2
#n = '1' + n_3
x = range_num
y = len(Alphabet)
amount = math.pow(y, x)
total_items = math.pow(y, x)
for CharLength in range(range_num, stopper):
    passwords = (itertools.product(Alphabet, repeat = CharLength))

    for i in passwords:
        counter += 1
        percentage = (counter / total_items) * 100
        amount -= 1
        i = str(i)
        i = i.replace("[", "")
        i = i.replace("]", "")
        i = i.replace("'", "")
        i = i.replace(" ", "")
        i = i.replace(",", "")
        i = i.replace("(", "")
        i = i.replace(")", "")
        f.write(i)
        f.write('\n')
        print "Password: %r\tPercentage: %r/100\tAmount left: %r" % (i, int(percentage), amount)
        if i == '0'* range_num:
            print "*Done"
            f.close()
            exit(0)
        else:
            pass