问:
Odoo How to create Access Rule for Team Leader to visible all leads in team?
Do you know how to create the access rule for team leader to view all leads of members in team?

I try the following code but it doesn't work :(

Anyone have the solution for this already??

```<code><odoo>
  <data>
    <record model="ir.rule" id="saleman_visible_lead">
        <field name="name">Saleman visible own lead / Team Leader visible all lead in team</field>
        <field name="model_id" ref="base.model_res_partner"></field>
        <field name="groups" eval="[(4,ref('sales_team.group_sale_salesman'))]"></field>
        <field name="domain_force">['|','|',('user_id.team_id.user_id','=',user.id),('user_id','=',user.id),('user_id','=',False)]</field>
    </record>
  </data>
</odoo>
</code>```

答:
Feature you asked is already available in default odoo:

If you give User: Own Documents Only access user can see own lead only

If you give User: All Documents access user can see own ALL Lead

For more detail check below Screenshot:

Body:
Do you know how to create the access rule for team leader to view all leads of members in team?

I try the following code but it doesn't work :(

Anyone have the solution for this already??

<odoo>
  <data>
    <record model="ir.rule" id="saleman_visible_lead">
        <field name="name">Saleman visible own lead / Team Leader visible all lead in team</field>
        <field name="model_id" ref="base.model_res_partner"></field>
        <field name="groups" eval="[(4,ref('sales_team.group_sale_salesman'))]"></field>
        <field name="domain_force">['|','|',('user_id.team_id.user_id','=',user.id),('user_id','=',user.id),('user_id','=',False)]</field>
    </record>
  </data>
</odoo>


来源: stackexchange

问:
JShint config for exceptions?
I'm using a ternary operator in JS for a new player function in a game app:

```<code>function nextPlayer() {
activePlayer === 0 ? activePlayer = 1 : activePlayer = 0;
</code>```

and JSHint is giving me the "Expected an assignment or function call and instead saw an expression" error. Where can I configure JShint exceptions in the master file, rather than setting them for every individual JS file?

答:
jshint will look for this configuration in a number of locations,
  stopping at the first positive match:

The location specified with the --config flag

A file named package.json located in the current directory or any parent of the current directory (the configuration should be declared
  as the jshintConfig attribute of that file's JSON value)

A file named .jshintrc located in the current directory or any parent of the current directory

A file named .jshintrc located in the current user's "home" directory (where defined) If this search yields no results, jshint
  will lint the input code as if no linting rules had been enabled.

— the JS Hint documentation

ContentLicense: CC BY-SA 3.0

Title: JShint config for exceptions?

Body:
I'm using a ternary operator in JS for a new player function in a game app:

function nextPlayer() {
activePlayer === 0 ? activePlayer = 1 : activePlayer = 0;

and JSHint is giving me the "Expected an assignment or function call and instead saw an expression" error. Where can I configure JShint exceptions in the master file, rather than setting them for every individual JS file?


问:
update use notifications live with socket.io
hello i'm trying to use socket io to get user notification from db.
 here is how i'm trying to get data and send them back to user

```<code>    if(req.user) {
    req.io.sockets.on('connection', function(socket){
    setInterval(getNotf,1000)
    function getNotf() {
    User.findOne({email:req.user.email})
    .then(user=>{
        messages=(user.notifications);
        console.log(messages)
                   socket.emit('output', messages);
});
    }

});
</code>```

}
the problem with that way is that the message sent to all connected users.how can i send them only to the current user?

答:
You can emit the message to the socket having this connection using its Id:

```<code>io.to(socket.id).emit('output', messages)
</code>```

Within your connection event listener:

```<code>req.io.sockets.on('connection', function(socket){
    setInterval(getNotf,1000)
    function getNotf() {
    User.findOne({email:req.user.email})
    .then(user=>{
        messages=(user.notifications);
        console.log(messages)
                   io.to(socket.id).emit('output', messages)
});
</code>```

I am have a global instance for the connection like this:

```<code>var serverhttp = http.createServer(<optionshttp>, app).listen(<port>);
var io = require('socket.io').listen(serverhttp);
</code>```

As a test with 2 connections you can try this:

```<code>        var clients = [];

            req.io.sockets.on('connection', function(socket){
                clients.push(socket.id);
                setInterval(getNotf,1000)
                function getNotf() {
                User.findOne({email:req.user.email})
                .then(user=>{
                    messages=(user.notifications);
                    console.log(messages)
                    console.log("socket ID :",socket.id)
                    io.to(clients[0]).emit('output', "user1")
                    io.to(clients[1]).emit('output', "user2")
    //or
    //io.sockets.connected[clients[0]].emit('output', "user1")
    //io.sockets.connected[clients[1]].emit('output', "user2")

            });
</code>```

Body:
hello i'm trying to use socket io to get user notification from db.
 here is how i'm trying to get data and send them back to user

    if(req.user) {
    req.io.sockets.on('connection', function(socket){
    setInterval(getNotf,1000)
    function getNotf() {
    User.findOne({email:req.user.email})
    .then(user=>{
        messages=(user.notifications);
        console.log(messages)
                   socket.emit('output', messages);
});
    }

});

}
the problem with that way is that the message sent to all connected users.how can i send them only to the current user?

Body:
You can emit the message to the socket having this connection using its Id:

io.to(socket.id).emit('output', messages)

Within your connection event listener:

req.io.sockets.on('connection', function(socket){
    setInterval(getNotf,1000)
    function getNotf() {
    User.findOne({email:req.user.email})
    .then(user=>{
        messages=(user.notifications);
        console.log(messages)
                   io.to(socket.id).emit('output', messages)
});

I am have a global instance for the connection like this:

var serverhttp = http.createServer(<optionshttp>, app).listen(<port>);
var io = require('socket.io').listen(serverhttp);

As a test with 2 connections you can try this:

        var clients = [];

            req.io.sockets.on('connection', function(socket){
                clients.push(socket.id);
                setInterval(getNotf,1000)
                function getNotf() {
                User.findOne({email:req.user.email})
                .then(user=>{
                    messages=(user.notifications);
                    console.log(messages)
                    console.log("socket ID :",socket.id)
                    io.to(clients[0]).emit('output', "user1")
                    io.to(clients[1]).emit('output', "user2")
    //or
    //io.sockets.connected[clients[0]].emit('output', "user1")
    //io.sockets.connected[clients[1]].emit('output', "user2")

            });


问:
How to listen to scroll events in vue nuxtjs?
I've search for a solution and came up with this code

```<code>methods: {
  handleScroll () {
    console.log(window.scrollY)
  }
},
created () {
  window.addEventListener('scroll', this.handleScroll);
},
destroyed () {
  window.removeEventListener('scroll', this.handleScroll);
}
</code>```

Unfortunately, this doesn't work for me. I also tried to change window to document.body.

The error message was Window is not defined

答:
window is undefined because nuxt JS is server side rendered.

So try it using process.client variable

```<code>methods: {
  handleScroll () {
    console.log(window.scrollY)
  }
},
created () {
    if (process.client) {
        window.addEventListener('scroll', this.handleScroll);
    }
},
destroyed () {
    if (process.client) {
        window.removeEventListener('scroll', this.handleScroll);
    }
}
</code>```

See link for more info

Body:
I've search for a solution and came up with this code

methods: {
  handleScroll () {
    console.log(window.scrollY)
  }
},
created () {
  window.addEventListener('scroll', this.handleScroll);
},
destroyed () {
  window.removeEventListener('scroll', this.handleScroll);
}

Unfortunately, this doesn't work for me. I also tried to change window to document.body.

The error message was Window is not defined

Body:
window is undefined because nuxt JS is server side rendered.

So try it using process.client variable

methods: {
  handleScroll () {
    console.log(window.scrollY)
  }
},
created () {
    if (process.client) {
        window.addEventListener('scroll', this.handleScroll);
    }
},
destroyed () {
    if (process.client) {
        window.removeEventListener('scroll', this.handleScroll);
    }
}

See link for more info

ContentLicense: CC BY-SA 4.0


问:
Incrementing ratio button id in for loop
In a for loop i'm rendering radio buttons, but i need to increment the  radio button id to radio1,radio2 and so on. how can i do it ?

Please help.

            <input id="radio1" name="radio" [(ngModel)]="demandValue" [value]="demand.value" type="radio">
            {{demand.name}}
```

答:
You can set the id value using the attr.id attribute on input.

The index value can be extracted from the *ngFor. *ngFor="let item of items; let i = index"

```<code><span class="radio-radio-wrapper padding-radio" *ngFor="let demand of Demands; let i = index">
            <input attr.id={{'radio' + i}} name="radio" [(ngModel)]="demandValue" [value]="demand.value" type="radio">
            <span class="radioLabel"><label class="custom-control-description" for="radio1">{{demand.name}}</label></span>
</span>
</code>```

Body:
You can set the id value using the attr.id attribute on input.

The index value can be extracted from the *ngFor. *ngFor="let item of items; let i = index"

<span class="radio-radio-wrapper padding-radio" *ngFor="let demand of Demands; let i = index">
            <input attr.id={{'radio' + i}} name="radio" [(ngModel)]="demandValue" [value]="demand.value" type="radio">
            <span class="radioLabel"><label class="custom-control-description" for="radio1">{{demand.name}}</label></span>
</span>


答:
Here is another approach using "Matrix" and "igraph" packages.

First, we need to extract the information of which elements are connected. Using sparse matrices can, potetially, save a lot memory usage:

```<code>library(Matrix)
i = rep(1:length(mylist), lengths(mylist))
j = factor(unlist(mylist))
tab = sparseMatrix(i = i, j = as.integer(j), x = TRUE, dimnames = list(NULL, levels(j)))
#as.matrix(tab)  ## just to print colnames
#         7    10    11    12    13    15    16    17   211   215   216   225   446   469
#[1,]  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
#[2,] FALSE  TRUE  TRUE  TRUE FALSE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE  TRUE  TRUE
#[3,] FALSE  TRUE  TRUE  TRUE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
#[4,] FALSE FALSE  TRUE  TRUE  TRUE FALSE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE
#[5,] FALSE FALSE FALSE FALSE FALSE  TRUE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
#[6,] FALSE FALSE FALSE FALSE FALSE  TRUE FALSE  TRUE FALSE FALSE  TRUE  TRUE FALSE FALSE
</code>```

Find if each element is connected to each other:

```<code>connects = tcrossprod(tab, boolArith = TRUE)
#connects
#6 x 6 sparse Matrix of class "lsCMatrix"
#
#[1,] | . . . . .
#[2,] . | | | . .
#[3,] . | | | . .
#[4,] . | | | . .
#[5,] . . . . | |
#[6,] . . . . | |
</code>```

Then, using graphs, we can group the indices of "mylist":

```<code>library(igraph)
# 'graph_from_adjacency_matrix' seems to not work with the "connects" object directly.
# An alternative to coercing "connects" here would be to build it as 'tcrossprod(tab) > 0'

group = clusters(graph_from_adjacency_matrix(as(connects, "lsCMatrix")))$membership
#group
#[1] 1 2 2 2 3 3
</code>```

And, finally, concatenate:

```<code>tapply(mylist, group, function(x) sort(unique(unlist(x))))
#$`1`
#[1] 7
#
#$`2`
#[1]  10  11  12  13 211 215 446 469
#
#$`3`
#[1]  15  16  17 216 225

tapply(1:length(mylist), group, toString)
#        1         2         3
#      "1" "2, 3, 4"    "5, 6"
</code>```

Title: Merging list with common elements

Body:
I have a list

[[1]]
[1] 7

[[2]]
[1] 10 11 12 211 446 469

[[3]]
[1] 10 11 12 13

[[4]]
[1] 11 12 13 215

[[5]]
[1] 15 16

[[6]]
[1] 15 17 216 225

I want to merge list slices that have common elements, and index which list slices have been merged. My desired output is below.

$`1`
[1] 7

$`2`, `3`, `4`
[1] 10 11 12 13 211 215 446 469

$`5`,`6`
[1] 15 16 17 216 225

(I've put the original list slice indices as new list names, but any form of output is fine.)

Reproducible data:

mylist <- list(7, c(10, 11, 12, 211, 446, 469), c(10, 11, 12, 13), c(11,
12, 13, 215), c(15, 16), c(15, 17, 216, 225))

Body:
Here is another approach using "Matrix" and "igraph" packages.

First, we need to extract the information of which elements are connected. Using sparse matrices can, potetially, save a lot memory usage:

library(Matrix)
i = rep(1:length(mylist), lengths(mylist))
j = factor(unlist(mylist))
tab = sparseMatrix(i = i, j = as.integer(j), x = TRUE, dimnames = list(NULL, levels(j)))
#as.matrix(tab)  ## just to print colnames
#         7    10    11    12    13    15    16    17   211   215   216   225   446   469
#[1,]  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
#[2,] FALSE  TRUE  TRUE  TRUE FALSE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE  TRUE  TRUE
#[3,] FALSE  TRUE  TRUE  TRUE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
#[4,] FALSE FALSE  TRUE  TRUE  TRUE FALSE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE
#[5,] FALSE FALSE FALSE FALSE FALSE  TRUE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
#[6,] FALSE FALSE FALSE FALSE FALSE  TRUE FALSE  TRUE FALSE FALSE  TRUE  TRUE FALSE FALSE

Find if each element is connected to each other:

connects = tcrossprod(tab, boolArith = TRUE)
#connects
#6 x 6 sparse Matrix of class "lsCMatrix"
#
#[1,] | . . . . .
#[2,] . | | | . .
#[3,] . | | | . .
#[4,] . | | | . .
#[5,] . . . . | |
#[6,] . . . . | |

Then, using graphs, we can group the indices of "mylist":

library(igraph)
# 'graph_from_adjacency_matrix' seems to not work with the "connects" object directly.
# An alternative to coercing "connects" here would be to build it as 'tcrossprod(tab) > 0'

group = clusters(graph_from_adjacency_matrix(as(connects, "lsCMatrix")))$membership
#group
#[1] 1 2 2 2 3 3

And, finally, concatenate:

tapply(mylist, group, function(x) sort(unique(unlist(x))))
#$`1`
#[1] 7
#
#$`2`
#[1]  10  11  12  13 211 215 446 469
#
#$`3`
#[1]  15  16  17 216 225

tapply(1:length(mylist), group, toString)
#        1         2         3
#      "1" "2, 3, 4"    "5, 6"


问:
new sonata block : Object of class Symfony\Bundle\TwigBundle\TwigEngine could not be converted to string
I'm working with symfony 3.3 and sonata block bundle 3.2.
I have created a new block service

```<code>    namespace AppBundle\Block\Service;

    use Sonata\AdminBundle\Form\FormMapper;
    use Sonata\BlockBundle\Block\BlockContextInterface;
    use Sonata\BlockBundle\Model\BlockInterface;
    use Symfony\Component\HttpFoundation\Response;
    use Symfony\Component\OptionsResolver\OptionsResolver;
    use Sonata\BlockBundle\Block\Service\AbstractAdminBlockService;
    use Sonata\CoreBundle\Model\Metadata;

    class WysiwygBlockService extends AbstractAdminBlockService
    {
    /**
     * {@inheritdoc}
     */
    public function execute(BlockContextInterface $blockContext, Response $response = null)
    {
        return $this->renderResponse($blockContext->getTemplate(), [
            'block' => $blockContext->getBlock(),
            'settings' => $blockContext->getSettings(),
        ], $response);
    }

    /**
     * {@inheritdoc}
     */
    public function buildEditForm(FormMapper $formMapper, BlockInterface $block)
    {
        $formMapper->add('settings', 'sonata_type_immutable_array', [
            'keys' => [
                ['content', 'ckeditor', []],
            ],
        ]);
    }

    /**
     * {@inheritdoc}
     */
    public function configureSettings(OptionsResolver $resolver)
    {
        $resolver->setDefaults([
            'content' => 'Insert your custom content here',
            'template' => 'SonataBlockBundle:Block:block_core_text.html.twig',
        ]);
    }

    /**
     * {@inheritdoc}
     */
    public function getBlockMetadata($code = null)
    {
        return new Metadata($this->getName(), (!is_null($code) ? $code : $this->getName()), false, 'SonataBlockBundle', [
            'class' => 'fa fa-file-text-o',
        ]);
    }

}
</code>```

When I go to the composer page in the backoffice, I got this error:

An exception has been thrown during the rendering of a template ("Catchable Fatal Error: Object of class Symfony\Bundle\TwigBundle\TwigEngine could not be converted to string").

Any idea?

Thanks for your help

答:
I was missing an argument in my service declaration:</p>

```<code># Sonata block services
app.block.service.wysiwyg:
    class: AppBundle\Block\Service\WysiwygBlockService
    arguments:
        **- "Wysiwyg"**
        - "@templating"
    tags:
        - { name: sonata.block }
    public: true
</code>```

Body:
I'm working with symfony 3.3 and sonata block bundle 3.2.
I have created a new block service

    namespace AppBundle\Block\Service;

    use Sonata\AdminBundle\Form\FormMapper;
    use Sonata\BlockBundle\Block\BlockContextInterface;
    use Sonata\BlockBundle\Model\BlockInterface;
    use Symfony\Component\HttpFoundation\Response;
    use Symfony\Component\OptionsResolver\OptionsResolver;
    use Sonata\BlockBundle\Block\Service\AbstractAdminBlockService;
    use Sonata\CoreBundle\Model\Metadata;

    class WysiwygBlockService extends AbstractAdminBlockService
    {
    /**
     * {@inheritdoc}
     */
    public function execute(BlockContextInterface $blockContext, Response $response = null)
    {
        return $this->renderResponse($blockContext->getTemplate(), [
            'block' => $blockContext->getBlock(),
            'settings' => $blockContext->getSettings(),
        ], $response);
    }

    /**
     * {@inheritdoc}
     */
    public function buildEditForm(FormMapper $formMapper, BlockInterface $block)
    {
        $formMapper->add('settings', 'sonata_type_immutable_array', [
            'keys' => [
                ['content', 'ckeditor', []],
            ],
        ]);
    }

    /**
     * {@inheritdoc}
     */
    public function configureSettings(OptionsResolver $resolver)
    {
        $resolver->setDefaults([
            'content' => 'Insert your custom content here',
            'template' => 'SonataBlockBundle:Block:block_core_text.html.twig',
        ]);
    }

    /**
     * {@inheritdoc}
     */
    public function getBlockMetadata($code = null)
    {
        return new Metadata($this->getName(), (!is_null($code) ? $code : $this->getName()), false, 'SonataBlockBundle', [
            'class' => 'fa fa-file-text-o',
        ]);
    }

}

When I go to the composer page in the backoffice, I got this error:

An exception has been thrown during the rendering of a template ("Catchable Fatal Error: Object of class Symfony\Bundle\TwigBundle\TwigEngine could not be converted to string").

Any idea?

Thanks for your help

Body:
I was missing an argument in my service declaration:

# Sonata block services
app.block.service.wysiwyg:
    class: AppBundle\Block\Service\WysiwygBlockService
    arguments:
        **- "Wysiwyg"**
        - "@templating"
    tags:
        - { name: sonata.block }
    public: true


问:
Enable touch scrolling for mobile view, Bokeh app
I have a web app, created using Bokeh and hosted on Heroku. I recently created a mobile style for the app, viewable here:

https://btac-web-plots.herokuapp.com/avyview?style=snowpacktracker-mobile

However, when viewed on an iOS mobile device, the single-finger touch scrolling does not work. As a hack work-around, I set width: 95% in the .invcontent-wrapper tag of my html file (index.html). This exposes a vertical strip of the background on the right side where the touch scrolling is functional, acting like a traditional scroll bar. I also added up and down arrows to the vertical strip to direct users to use it as a scroll bar.

How can I enable touch scrolling for the entire screen? The issue may be that the returned Bokeh Document does not allow for touch scrolling interaction...?

I am using the directory format in Bokeh (utilizing the Bokeh server), where my index.html Jinja template file contains the following relevant sections:

css:

```<code>        {% if display_style|string() == "snowpacktracker-mobile" %}
          <style>
            html {
              width: 100%;
              height: 100%;
            }
            body {
              width: 100%;
              height: 100%;
              margin: auto;
              background-color: lightgray;
              overflow-y: scroll;
              -webkit-overflow-scrolling: touch;
              float: left;
            }
           .invcontent-wrapper {
             padding: 0px;
             min-height: 200px;
             width: 95%; /*allows for exposed background on the side*/
             position: relative;
            }
            container { /*this holds arrows so the user knows to scroll*/
              width: 100%;
              height: 100%;
            }
            .a { /*up arrow*/
              border-style: solid;
              border-width: 0 3px 3px 0;
              border-color: rgba(0,0,0,0.6);
              display: inline-block;
              padding: 3px;
              position: fixed;
              top: 20px;
              right: 1.5%;
              transform: rotate(-135deg);
              -webkit-transform: rotate(-135deg);
            }
            .b { /*down arrow*/
                border-style: solid;
                border-width: 0 3px 3px 0;
                border-color: rgba(0,0,0,0.6);
                display: inline-block;
                padding: 3px;
                position: fixed;
                top: 40px;
                right: 1.5%;
                transform: rotate(45deg);
                -webkit-transform: rotate(45deg);
            }
          </style>
        {% endif %}
</code>```

html:

```<code>        {% if display_style|string() == "snowpacktracker-mobile" %}
          <div class="invcontent-wrapper"  id="tbc-id">
            {{ plot_div|indent(8) }}
            {{ plot_script|indent(8) }}
          </div>
          <div id="container">
            <div class="a"></div>
            <div class="b"></div>
          </div>
        {% endif %}
</code>```

The id="tbc-id" is referring to the javascript loading spinner I am using (var target = document.getElementById('tbc-id');).

Although a secondary problem, I am also unable to zoom in using the two-finger pinch-out zoom gesture on iOS.

答:
The bug certainly comes from the -webkit-overflow-scrolling: touch; property. You are not the only one experiencing problems with it:

Since updating to IOS8, -webkit-overflow-scrolling: touch stops you being able to scroll whatsoever, and the only way I have been able to fix this so far is by removing -webkit-overflow-scrolling: touch

-webkit-overflow-scrolling: touch; breaks in Apple's iOS8

However, in the Safari CSS Reference, Apple seems to say that it is supported on iOs 5.0 and later:

Availability:

  Available in iOS 5.0 and later.

Support Level:

  Under development

But, we can see in the MDN reference:

Non-standard

  This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.

-webkit-overflow-scrolling - MDN

TL;DR

This is not a coding problem, it comes from this non-standard CSS style. Try removing it and see below on how to enhance scrolling.

Did I helped?

Here are some other references:

WebKit-only properties - MDN

-webkit-overflow-scrolling: touch; breaks in Apple's iOS8 - SO

The solution I found was to remove all the CSS that tricks the browser into using the GPU:

```<code> -webkit-transform: translateZ(0px);
 -webkit-transform: translate3d(0,0,0);
 -webkit-perspective: 1000;
</code>```

Body:
I have a web app, created using Bokeh and hosted on Heroku. I recently created a mobile style for the app, viewable here:

https://btac-web-plots.herokuapp.com/avyview?style=snowpacktracker-mobile

However, when viewed on an iOS mobile device, the single-finger touch scrolling does not work. As a hack work-around, I set width: 95% in the .invcontent-wrapper tag of my html file (index.html). This exposes a vertical strip of the background on the right side where the touch scrolling is functional, acting like a traditional scroll bar. I also added up and down arrows to the vertical strip to direct users to use it as a scroll bar.

How can I enable touch scrolling for the entire screen? The issue may be that the returned Bokeh Document does not allow for touch scrolling interaction...?

I am using the directory format in Bokeh (utilizing the Bokeh server), where my index.html Jinja template file contains the following relevant sections:

css:

        {% if display_style|string() == "snowpacktracker-mobile" %}

        {% endif %}

html:

        {% if display_style|string() == "snowpacktracker-mobile" %}

            {{ plot_div|indent(8) }}
            {{ plot_script|indent(8) }}

        {% endif %}

The id="tbc-id" is referring to the javascript loading spinner I am using (var target = document.getElementById('tbc-id');).

Although a secondary problem, I am also unable to zoom in using the two-finger pinch-out zoom gesture on iOS.

Body:
The bug certainly comes from the -webkit-overflow-scrolling: touch; property. You are not the only one experiencing problems with it:

Since updating to IOS8, -webkit-overflow-scrolling: touch stops you being able to scroll whatsoever, and the only way I have been able to fix this so far is by removing -webkit-overflow-scrolling: touch

-webkit-overflow-scrolling: touch; breaks in Apple's iOS8

However, in the Safari CSS Reference, Apple seems to say that it is supported on iOs 5.0 and later:

Availability:

  Available in iOS 5.0 and later.

Support Level:

  Under development

But, we can see in the MDN reference:

Non-standard

  This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.

-webkit-overflow-scrolling - MDN

TL;DR

This is not a coding problem, it comes from this non-standard CSS style. Try removing it and see below on how to enhance scrolling.

Did I helped?

Here are some other references:

WebKit-only properties - MDN

-webkit-overflow-scrolling: touch; breaks in Apple's iOS8 - SO

The solution I found was to remove all the CSS that tricks the browser into using the GPU:

 -webkit-transform: translateZ(0px);
 -webkit-transform: translate3d(0,0,0);
 -webkit-perspective: 1000;


问:
Android ViewModel with appCompat v27.0.0
I am trying to use the Android architecture components ViewModel in a project with the latest com.android.support:appcompat-v7:27.0.0. The appcompat already contains everything from android.arch.lifecycle:runtime:1.0.3 and android.arch.lifecycle:compiler:1.0.0. However it does not seem to contain for example android.arch.lifecycle:extensions:1.0.0which includes the ViewModel class. There still does not seem to be a version 1.0.3 of the extensions but if I try using 1.0.0 I get the following error:

Error:Execution failed for task ':app:preReleaseBuild'.
  Android dependency 'android.arch.lifecycle:runtime' has different version for the compile (1.0.0) and runtime (1.0.3) classpath. You should manually set the same version via DependencyResolution

I can fix this like that:

```<code>implementation ("android.arch.lifecycle:extensions:1.0.0"){
    exclude module: "runtime"
}
</code>```

but this can not be the final solution. What am I missing?

答:
LiveData , ViewModel , Room and Paging Library all of these libraries are part of android architecture components . None of these library are part of support library .

To add architecture components as a dependency on your gradle file you need to add them separately and their associate annotation processor like this

```<code>// Architecture Components
compile 'android.arch.persistence.room:runtime:1.0.0'
annotationProcessor 'android.arch.persistence.room:compiler:1.0.0'
compile 'android.arch.lifecycle:extensions:1.0.0'
annotationProcessor 'android.arch.lifecycle:compiler:1.0.0'
</code>```

for detail documentation please see the official documentation adding architecture components to your project

Body:
I am trying to use the Android architecture components ViewModel in a project with the latest com.android.support:appcompat-v7:27.0.0. The appcompat already contains everything from android.arch.lifecycle:runtime:1.0.3 and android.arch.lifecycle:compiler:1.0.0. However it does not seem to contain for example android.arch.lifecycle:extensions:1.0.0which includes the ViewModel class. There still does not seem to be a version 1.0.3 of the extensions but if I try using 1.0.0 I get the following error:

Error:Execution failed for task ':app:preReleaseBuild'.
  Android dependency 'android.arch.lifecycle:runtime' has different version for the compile (1.0.0) and runtime (1.0.3) classpath. You should manually set the same version via DependencyResolution

I can fix this like that:

implementation ("android.arch.lifecycle:extensions:1.0.0"){
    exclude module: "runtime"
}

but this can not be the final solution. What am I missing?

Body:
LiveData , ViewModel , Room and Paging Library all of these libraries are part of android architecture components . None of these library are part of support library .

To add architecture components as a dependency on your gradle file you need to add them separately and their associate annotation processor like this

// Architecture Components
compile 'android.arch.persistence.room:runtime:1.0.0'
annotationProcessor 'android.arch.persistence.room:compiler:1.0.0'
compile 'android.arch.lifecycle:extensions:1.0.0'
annotationProcessor 'android.arch.lifecycle:compiler:1.0.0'

for detail documentation please see the official documentation adding architecture components to your project


问:
How to serve static html files through express without explicit rendering
I have around 20+ HTML files. I would like to render them, when requested as host/filename.html, without having to use response.render for each file. If I simply move my views folder in public folder (and set views of express accordingly), the browser is not rendering these HTMLs. Rather, I see the code on the screen. Can someone please advice on this?

答:
You can try using something like this: </p>

```<code>'/someRoute': (req, res, next) => {
        res.status(200).sendFile(process.cwd() + '/views/index.html');
    }
</code>```

Body:
You can try using something like this:

'/someRoute': (req, res, next) => {
        res.status(200).sendFile(process.cwd() + '/views/index.html');
    }


问:
Move each div with same class into another div
I got 2 divs with the same class and I am trying to move each of the 2 divs into a different div.

setTimeout(function() {
  $(".pac-container").prependTo("#gp-content");
}, 500);```
<pre class="snippet-code-css lang-css prettyprint-override"><code>.pac-container {
  width: 50px;
  height: 100px;
  border: 1px solid black;
  padding: 5px;
  margin: 5px;
}

#wrapper1,
#wrapper2 {
  width: 25px;
  height: 75px;
  border: 1px dotted red;
  padding: 5px;
  margin: 5px;
}</code>```

```
</div>
</div>
</p>

<p>My goal is now to move the first <code>pac-container</code> into <code>#wrapper1</code> and the second <code>pac-container</code> into <code>#wrapper2</code>. The <code>pac-container</code> are sitting next to each other at the html-markup and each <code>#wrapper</code> sits on different positions at the html-markup.</p>

<hr>

<h2>Goal</h2>

```

```

答:
You can iterate .pac-container and move then individually.

Here in example, I have added wrapper class to use common selector and use .eq() to target the element.

$('.pac-container').each(function(i){
  $(this).appendTo($('.wrapper').eq(i))
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="pac-container">1</div>
<div class="pac-container">2</div>

<div class="wrapper" id="wrapper1"></div>
<div class="wrapper" id="wrapper2"></div></code>```

Body:
I got 2 divs with the same class and I am trying to move each of the 2 divs into a different div.

setTimeout(function() {
  $(".pac-container").prependTo("#gp-content");
}, 500);

.pac-container {
  width: 50px;
  height: 100px;
  border: 1px solid black;
  padding: 5px;
  margin: 5px;
}

#wrapper1,
#wrapper2 {
  width: 25px;
  height: 75px;
  border: 1px dotted red;
  padding: 5px;
  margin: 5px;
}

My goal is now to move the first pac-container into #wrapper1 and the second pac-container into #wrapper2. The pac-container are sitting next to each other at the html-markup and each #wrapper sits on different positions at the html-markup.

Goal

Body:
You can iterate .pac-container and move then individually.

Here in example, I have added wrapper class to use common selector and use .eq() to target the element.

$('.pac-container').each(function(i){
  $(this).appendTo($('.wrapper').eq(i))
});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="pac-container">1</div>
<div class="pac-container">2</div>

<div class="wrapper" id="wrapper1"></div>
<div class="wrapper" id="wrapper2"></div>


问:
How to output array in 2 columns
I have array with object's and I need to output this array in 2 column's. I tried to use filter, ng-switch-when. But always array output's in 1 col. There is my array:

Here is my last try outputting with ng-switch-when:

```<code><div ng-repeat="date in allDates">
                <div ng-switch="date.invited_date">
                    <table>
                        <thead>
                        </thead>
                        <tbody>
                        <tr>
                            <td ng-switch-when="1">{{date.project_name}}</td>
                            <td ng-switch-when="0">{{date.project_name}}</td>
                        </tr>
                        </tbody>
                    </table>
                </div>
                <div>
                </div>
            </div>
</code>```

Actual result is:

But i need to separate them by invited_date in 2 column's how can I do it?

I can do it in 2 tables, but then if project name will be long it will ruin structure

答:
You cant show in two rows with single iteration , try as two iteration</p>

```<code> <div ng-repeat="date in allDates">
            <div ng-switch="date.invited_date">
                <table>
                    <thead>
                    </thead>
                    <tbody>
                    <tr>
                        <td ng-switch-when="1">{{date.project_name}}</td>

                    </tr>
                    </tbody>
                </table>
            </div>
            <div>
            </div>
        </div>

     <div ng-repeat="date in allDates">
            <div ng-switch="date.invited_date">
                <table>
                    <thead>
                    </thead>
                    <tbody>
                    <tr>

                        <td ng-switch-when="0">{{date.project_name}}</td>
                    </tr>
                    </tbody>
                </table>
            </div>
            <div>
            </div>
        </div>
</code>```

Title: How to output array in 2 columns

Body:
I have array with object's and I need to output this array in 2 column's. I tried to use filter, ng-switch-when. But always array output's in 1 col. There is my array:

Here is my last try outputting with ng-switch-when:

                            {{date.project_name}}
                            {{date.project_name}}

Actual result is:

But i need to separate them by invited_date in 2 column's how can I do it?

I can do it in 2 tables, but then if project name will be long it will ruin structure

Body:
You cant show in two rows with single iteration , try as two iteration

 <div ng-repeat="date in allDates">
            <div ng-switch="date.invited_date">
                <table>
                    <thead>
                    </thead>
                    <tbody>
                    <tr>
                        <td ng-switch-when="1">{{date.project_name}}</td>

                    </tr>
                    </tbody>
                </table>
            </div>
            <div>
            </div>
        </div>

     <div ng-repeat="date in allDates">
            <div ng-switch="date.invited_date">
                <table>
                    <thead>
                    </thead>
                    <tbody>
                    <tr>

                        <td ng-switch-when="0">{{date.project_name}}</td>
                    </tr>
                    </tbody>
                </table>
            </div>
            <div>
            </div>
        </div>


问:
Pushing updates to a webpage using server-sent events
I would like to post data to my PHP page and then have it update the HTML page. I followed this example of using server-sent events to push updates to a webpage.
Here is what I have right now:

output.html:

```<code><!DOCTYPE html>
<html>
<head>
</head>
<body>

<div id="serverData"></div>

</body>

<script type="text/javascript">

//check for browser support
if(typeof(EventSource)!=="undefined") {
    //create an object, passing it the name and location of the server side script
    var eSource = new EventSource("send_sse.php");
    //detect message receipt
    eSource.onmessage = function(event) {
        //write the received data to the page
        document.getElementById("serverData").innerHTML = event.data;
    };
}
else {
    document.getElementById("serverData").innerHTML="Whoops! Your browser doesn't receive server-sent events.";
}
</script>
</html>
</code>```

send_sse.php:

```<code><?php
header('Content-Type: text/event-stream');
header('Cache-Control: no-cache');
$val = 0;
if (isset($_POST['msg'])){
    $val = $_POST['msg'];
}
echo "data: $val\n\n";
ob_flush();
?>
</code>```

form.html:

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

<form action="send_sse.php" method="post">
Message: <input type="text" name="msg"><br>
<input type="submit">
</form>

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

The problem is that when the form posts the value, it does not update the output.html. It does output "0" and will update whenever I manually change the value of $val and save the file. However, I want the value of $val to be determined outside of the PHP file. What am I doing wrong?

答:
The issue you are having here is that you have missed how SSE conceptually work. Your output.html page is making a GET request to your web server and executing the script send_sse.php and opening up a connection and HOLDING that connection open and waiting for updates.

When you are posting from form.html you are sending a POST request to your web server and executing the script send_sse.php on a completely different thread.

As you have not implemented any shared persistence between these two threads it will make no difference.

So to do what you want to do you will need to have code in send_sse.php that has some form of global persistence (e.g. database) and can detect new data and then flush that down to the browser.

I am not a PHP expert, but I have written an example in Node JS that uses REDIS pub/sub to provide said persistence.

I hope that helps.

Body:
I would like to post data to my PHP page and then have it update the HTML page. I followed this example of using server-sent events to push updates to a webpage.
Here is what I have right now:

output.html:

<!DOCTYPE html>

send_sse.php:

<?php
header('Content-Type: text/event-stream');
header('Cache-Control: no-cache');
$val = 0;
if (isset($_POST['msg'])){
    $val = $_POST['msg'];
}
echo "data: $val\n\n";
ob_flush();
?>

form.html:

<form action="send_sse.php" method="post">
Message: <input type="text" name="msg">

<input type="submit">
</form>

The problem is that when the form posts the value, it does not update the output.html. It does output "0" and will update whenever I manually change the value of $val and save the file. However, I want the value of $val to be determined outside of the PHP file. What am I doing wrong?


问:
Error:(61, 48) error: incompatible types: String cannot be converted to List<BarEntry> in mpandroidchart
there I am getting this error while showing the data from myTable.java.
Incompatible type is showing

```<code>BarChart chart = (BarChart) findViewById(R.id.datachart);

ArrayList<String> BarEntry = new ArrayList<>();

BarEntry.add(myTable.getPopulation_1980());

ArrayList<String> labels = new ArrayList<>();
labels.add("1980");
labels.add("1985");
labels.add("1990");

BarDataSet bardataset = new BarDataSet(BarEntry, "Cells");
BarData data = new BarData(labels, bardataset);
chart.setData(data);
</code>```

but it is showing error on Bardataset bardataset = new Bardadtaset(BarEntry, "cells")

please give me any suggestions

答:
incompatible types: String cannot be converted to List in
  mpandroidchart

```<code> BarDataSet bardataset = new BarDataSet(BarEntry, "Cells");
</code>```

The constructor for BarData has changed in v3.0.0

Read Setting Data.

```<code>public BarDataSet(List<BarEntry> yVals, String label) {
        super(yVals, label);

        ......
    }
</code>```

Body:
there I am getting this error while showing the data from myTable.java.
Incompatible type is showing

BarChart chart = (BarChart) findViewById(R.id.datachart);

ArrayList<String> BarEntry = new ArrayList<>();

BarEntry.add(myTable.getPopulation_1980());

ArrayList<String> labels = new ArrayList<>();
labels.add("1980");
labels.add("1985");
labels.add("1990");

BarDataSet bardataset = new BarDataSet(BarEntry, "Cells");
BarData data = new BarData(labels, bardataset);
chart.setData(data);

but it is showing error on Bardataset bardataset = new Bardadtaset(BarEntry, "cells")

please give me any suggestions

Body:
incompatible types: String cannot be converted to List in
  mpandroidchart

 BarDataSet bardataset = new BarDataSet(BarEntry, "Cells");

The constructor for BarData has changed in v3.0.0

Read Setting Data.

public BarDataSet(List<BarEntry> yVals, String label) {
        super(yVals, label);

        ......
    }


问:
How to make a subview automatically resize with its superview?
I have a view which contains one sub-view; this sub-view itself contains another sub-view, which is meant to be slightly smaller than its superview.

I am creating the first subview full-screen size then shrinking it to a very small size on the screen.  When the subview is tapped, I animate it from its small size to full-screen.

The problem is that my second subview never resizes itself during this animation - it is always rendered full-size and overflows the bounds of its superview.

Is there a simple way to get a subview to keep itself sized proportionally as its superview changes size?

答:
If you're using only [.flexibleWidth, .flexibleHeight] for your autoresizing mask, your subview will not get resized proportionally. The right answer is:</p>

```<code>autoresizingMask = [.flexibleWidth, .flexibleHeight, .flexibleTopMargin, .flexibleLeftMargin, .flexibleBottomMargin, .flexibleRightMargin]
</code>```

ContentLicense: CC BY-SA 2.5

Body:
If you're using only [.flexibleWidth, .flexibleHeight] for your autoresizing mask, your subview will not get resized proportionally. The right answer is:

autoresizingMask = [.flexibleWidth, .flexibleHeight, .flexibleTopMargin, .flexibleLeftMargin, .flexibleBottomMargin, .flexibleRightMargin]


问:
LibGit2Sharp Getting the last version of a remote repository
I want to track a project that uses git in my winforms project. I don't want to clone the full repository and the full history, I just want the latest version, and I want to be able to update to new revisions from the remote project.

I have tried this

```<code>co.CredentialsProvider = (_url, _user, _cred) => new UsernamePasswordCredentials { Username = userName, Password = passWord };

        Repository.Clone("Git/repo", @tmpRepoFolder, co);
</code>```

, but this creates a copy of the entire repository (huge file size), and tracking changes makes the disk space even bigger (100mb of files now takes up over 2gb).

I don't need the history and i don't need the tags. I just want the latest version .

答:
Basically you want a shallow clone (the equivalent of the git clone --depth command) which is not actually supported, there is an open issue for that

As an alternative you can launch a Process which do what you want using the git application.

Here an example:

```<code>using(System.Diagnostics.Process p = new Process())
{
    p.StartInfo = new ProcessStartInfo()
    {
        RedirectStandardInput = true,
        RedirectStandardOutput = true,
        UseShellExecute = false,
        FileName = @"C:\Program Files\Git\bin\git.exe",
        Arguments = "clone http://username:password@path/to/repo.git"  + " --depth 1"
    };

    p.Start();
    string output = p.StandardOutput.ReadToEnd();
    p.WaitForExit();
}
</code>```

Body:
I want to track a project that uses git in my winforms project. I don't want to clone the full repository and the full history, I just want the latest version, and I want to be able to update to new revisions from the remote project.

I have tried this

co.CredentialsProvider = (_url, _user, _cred) => new UsernamePasswordCredentials { Username = userName, Password = passWord };

        Repository.Clone("Git/repo", @tmpRepoFolder, co);

, but this creates a copy of the entire repository (huge file size), and tracking changes makes the disk space even bigger (100mb of files now takes up over 2gb).

I don't need the history and i don't need the tags. I just want the latest version .

Body:
Basically you want a shallow clone (the equivalent of the git clone --depth command) which is not actually supported, there is an open issue for that

As an alternative you can launch a Process which do what you want using the git application.

Here an example:

using(System.Diagnostics.Process p = new Process())
{
    p.StartInfo = new ProcessStartInfo()
    {
        RedirectStandardInput = true,
        RedirectStandardOutput = true,
        UseShellExecute = false,
        FileName = @"C:\Program Files\Git\bin\git.exe",
        Arguments = "clone http://username:password@path/to/repo.git"  + " --depth 1"
    };

    p.Start();
    string output = p.StandardOutput.ReadToEnd();
    p.WaitForExit();
}


问:
Is it absolutely correct that nil'ing a Firebase DatabaseReference does NOT stop the observation?
In the Awesome that is Firebase, you do this

```<code>    var r1: DatabaseReference? = nil
</code>```

and then this

```<code>    r1 = Database.database().reference(withPath: "score/bucks")
    r1!.observe(.childAdded) { snapshot in ... }
</code>```

and then have fun,

but eventually you must do something like this

```<code>private func clearObservations() { // call from viewDidDisappear

    if r1 != nil {

        r1?.removeAllObservers()
        r1 = nil
    }

    if r2 != nil {

        r2?.removeAllObservers()
        r2 = nil
    }

    .. etc etc etc etc etc etc :/ :/
}
</code>```

{ Critical aside: it's worth noting YOU CAN NOT do that in deinit, you MUST do it in viewDidDisappear }

It does seem pretty incredible that one cannot just

```<code>      r1 = nil // and this will remove the observor
</code>```

Is it honest to goodness the case that:

if you just nil a DatabaseReference,

i.e. you do NOT bother to removeAllObservors,

in fact the observation will just keep going?

Is that right?

I just want to absolutely clarify this and get it down on the record - it will probably help future googlers (interestingly, I couldn't really google up a clear marginalia on this anywhere).

I realize you can put them in a hokey array, etc, but it seems incredible that nil'ing one does not stop the observation?!

Footnote

One thing that's always disturbed me. If you carefully read the doco for removeAllObservors, really all it asserts is that it drops or terminates the closure you added.  It doesn't, really, say that removeAllObservors actually has the guts of Firebase in the iPhone, actually call home and stop doing the observation. I spend a lot of time worrying about that detail.

答:
As I explained in the comments, you must remove observers manually because Firebase hold references to your DatabaseReference and to your closures. If you nil the DatabaseReference it's not deallocating it, it has another reference to it.

I guess from the docs that this what's happening

Many times you'll see in the docs:

Use removeObserverWithHandle: to stop receiving updates.

So this is the way, and the only way.

Body:
In the Awesome that is Firebase, you do this

    var r1: DatabaseReference? = nil

and then this

    r1 = Database.database().reference(withPath: "score/bucks")
    r1!.observe(.childAdded) { snapshot in ... }

and then have fun,

but eventually you must do something like this

private func clearObservations() { // call from viewDidDisappear

    if r1 != nil {

        r1?.removeAllObservers()
        r1 = nil
    }

    if r2 != nil {

        r2?.removeAllObservers()
        r2 = nil
    }

    .. etc etc etc etc etc etc :/ :/
}

{ Critical aside: it's worth noting YOU CAN NOT do that in deinit, you MUST do it in viewDidDisappear }

It does seem pretty incredible that one cannot just

      r1 = nil // and this will remove the observor

Is it honest to goodness the case that:

if you just nil a DatabaseReference,

i.e. you do NOT bother to removeAllObservors,

in fact the observation will just keep going?

Is that right?

I just want to absolutely clarify this and get it down on the record - it will probably help future googlers (interestingly, I couldn't really google up a clear marginalia on this anywhere).

I realize you can put them in a hokey array, etc, but it seems incredible that nil'ing one does not stop the observation?!

Footnote

One thing that's always disturbed me. If you carefully read the doco for removeAllObservors, really all it asserts is that it drops or terminates the closure you added.  It doesn't, really, say that removeAllObservors actually has the guts of Firebase in the iPhone, actually call home and stop doing the observation. I spend a lot of time worrying about that detail.


答:
It was mentioned before, but I will rewrite it to be more visible for future users.

You have too narrow terminal to print all these values - just set width argument of Progbar constructor to smaller number or remove/rename some of the provided values.

Title: Keras verbose training progress bar writing a new line on each batch issue

Body:
running a Dense feed-forward neural net in Keras.
there are class_weights for two outputs, and sample_weights for a third output. fore some reason it prints the progress verbose display for each batch calculated, and not updating the print on the same line as its supposed to...
Did this ever happens to you?
How is it fixed?
From the shell:

42336/747322 [====>.........................] - ETA: 79s - loss: 20.7154 - x1_loss: 9.5913 - x2_loss: 10.0536 - x3_loss: 1.0705 - x1_acc: 0.6930 - x2_acc: 0.4433 - x3_acc: 0.6821
143360/747322 [====>.........................] - ETA: 78s - loss: 20.7387 - x1_loss: 9.6131 - x2_loss: 10.0555 - x3_loss: 1.0702 - x1_acc: 0.6930 - x2_acc: 0.4432 - x3_acc: 0.6820
144384/747322 [====>.........................] - ETA: 78s - loss: 20.7362 - x1_loss: 9.6067 - x2_loss: 10.0608 - x3_loss: 1.0687 - x1_acc: 0.6930 - x2_acc: 0.4429 - x3_acc: 0.6817
145408/747322 [====>.........................] - ETA: 78s - loss: 20.7257 - x1_loss: 9.5985 - x2_loss: 10.0571 - x3_loss: 1.0702 - x1_acc: 0.6929 - x2_acc: 0.4428 - x3_acc: 0.6815
146432/747322 [====>.........................] - ETA: 78s - loss: 20.7145 - x1_loss: 9.5849 - x2_loss: 10.0605 - x3_loss: 1.0691 - x1_acc: 0.6932 - x2_acc: 0.4429 - x3_acc: 0.6816
147456/747322 [====>.........................] - ETA: 78s - loss: 20.7208 - x1_loss: 9.5859 - x2_loss: 10.0662 - x3_loss: 1.0688 - x1_acc: 0.6931 - x2_acc: 0.4429 - x3_acc: 0.6815
148480/747322 [====>.........................] - ETA: 78s - loss: 20.7078 - x1_loss: 9.5762 - x2_loss: 10.0636 - x3_loss: 1.0680 - x1_acc: 0.6932 - x2_acc: 0.4430 - x3_acc: 0.6815
149504/747322 [=====>........................] - ETA: 77s - loss: 20.6987 - x1_loss: 9.5749 - x2_loss: 10.0555 - x3_loss: 1.0683 - x1_acc: 0.6931 - x2_acc: 0.4430 - x3_acc: 0.6817
150528/747322 [=====>........................] - ETA: 77s - loss: 20.9883 - x1_loss: 9.5688 - x2_loss: 10.3509 - x3_loss: 1.0686 - x1_acc: 0.6928 - x2_acc: 0.4428 - x3_acc: 0.6819
151552/747322 [=====>........................] - ETA: 77s - loss: 20.9721 - x1_loss: 9.5606 - x2_loss: 10.3435 - x3_loss: 1.0679 - x1_acc: 0.6927 - x2_acc: 0.4426 - x3_acc: 0.6821
152576/747322 [=====>........................] - ETA: 77s - loss: 20.9585 - x1_loss: 9.5558 - x2_loss: 10.3355 - x3_loss: 1.0672 - x1_acc: 0.6926 - x2_acc: 0.4425 - x3_acc: 0.6822
153600/747322 [=====>........................] - ETA: 77s - loss: 20.9409 - x1_loss: 9.5447 - x2_loss: 10.3300 - x3_loss: 1.0662 - x1_acc: 0.6925 - x2_acc: 0.4426 - x3_acc: 0.6822
154624/747322 [=====>........................] - ETA: 77s - loss: 20.9254 - x1_loss: 9.5341 - x2_loss: 10.3250 - x3_loss: 1.0663 - x1_acc: 0.6924 - x2_acc: 0.4425 - x3_acc: 0.6825
155648/747322 [=====>........................] - ETA: 77s - loss: 20.9189 - x1_loss: 9.5270 - x2_loss: 10.3249 - x3_loss: 1.0670 - x1_acc: 0.6925 - x2_acc: 0.4425 - x3_acc: 0.6825
156672/747322 [=====>........................] - ETA: 76s - loss: 20.9069 - x1_loss: 9.5155 - x2_loss: 10.3256 - x3_loss: 1.0658 - x1_acc: 0.6927 - x2_acc: 0.4423 - x3_acc: 0.6827
157696/747322 [=====>........................] - ETA: 76s - loss: 20.9275 - x1_loss: 9.5461 - x2_loss: 10.3163 - x3_loss: 1.0651 - x1_acc: 0.6927 - x2_acc: 0.4422 - x3_acc: 0.6828
158720/747322 [=====>........................] - ETA: 76s - loss: 21.4809 - x1_loss: 10.1018 - x2_loss: 10.3133 - x3_loss: 1.0659 - x1_acc: 0.6928 - x2_acc: 0.4422 - x3_acc: 0.6829
159744/747322 [=====>........................] - ETA: 76s - loss: 21.4617 - x1_loss: 10.0871 - x2_loss: 10.3093 - x3_loss: 1.0653 - x1_acc: 0.6928 - x2_acc: 0.4421 - x3_acc: 0.6830
160768/747322 [=====>........................] - ETA: 76s - loss: 21.5462 - x1_loss: 10.1705 - x2_loss: 10.3105 - x3_loss: 1.0652 - x1_acc: 0.6928 - x2_acc: 0.4420 - x3_acc: 0.6832
161792/747322 [=====>........................] - ETA: 76s - loss: 21.5642 - x1_loss: 10.1849 - x2_loss: 10.3138 - x3_loss: 1.0655 - x1_acc: 0.6928 - x2_acc: 0.4418 - x3_acc: 0.6832
162816/747322 [=====>........................] - ETA: 76s - loss: 21.5508 - x1_loss: 10.1739 - x2_loss: 10.3118 - x3_loss: 1.0651 - x1_acc: 0.6928 - x2_acc: 0.4418 - x3_acc: 0.6833
163840/747322 [=====>........................] - ETA: 76s - loss: 21.5323 - x1_loss: 10.1606 - x2_loss: 10.3057 - x3_loss: 1.0659 - x1_acc: 0.6927 - x2_acc: 0.4419 - x3_acc: 0.6833
164864/747322 [=====>........................] - ETA: 75s - loss: 21.5282 - x1_loss: 10.1607 - x2_loss: 10.3016 - x3_loss: 1.0659 - x1_acc: 0.6926 - x2_acc: 0.4418 - x3_acc: 0.6834
165888/747322 [=====>........................] - ETA: 75s - loss: 21.5321 - x1_loss: 10.1696 - x2_loss: 10.2963 - x3_loss: 1.0662 - x1_acc: 0.6927 - x2_acc: 0.4417 - x3_acc: 0.6834
166912/747322 [=====>........................] - ETA: 75s - loss: 21.5131 - x1_loss: 10.1554 - x2_loss: 10.2912 - x3_loss: 1.0664 - x1_acc: 0.6927 - x2_acc: 0.4416 - x3_acc: 0.6833
167936/747322 [=====>........................] - ETA: 75s - loss: 21.5211 - x1_loss: 10.1649 - x2_loss: 10.2886 - x3_loss: 1.0676 - x1_acc: 0.6929 - x2_acc: 0.4415 - x3_acc: 0.6835
168960/747322 [=====>........................] - ETA: 75s - loss: 21.5049 - x1_loss: 10.1504 - x2_loss: 10.2870 - x3_loss: 1.0676 - x1_acc: 0.6930 - x2_acc: 0.4414 - x3_acc: 0.6835
169984/747322 [=====>........................] - ETA: 75s - loss: 21.5171 - x1_loss: 10.1684 - x2_loss: 10.2818 - x3_loss: 1.0670 - x1_acc: 0.6931 - x2_acc: 0.4414 - x3_acc: 0.6832
171008/747322 [=====>........................] - ETA: 75s - loss: 21.5036 - x1_loss: 10.1541 - x2_loss: 10.2816 - x3_loss: 1.0678 - x1_acc: 0.6931 - x2_acc: 0.4413 - x3_acc: 0.6828
172032/747322 [=====>........................] - ETA: 75s - loss: 21.4870 - x1_loss: 10.1377 - x2_loss: 10.2816 - x3_loss: 1.0677 - x1_acc: 0.6931 - x2_acc: 0.4413 - x3_acc: 0.6827
173056/747322 [=====>........................] - ETA: 75s - loss: 21.4729 - x1_loss: 10.1210 - x2_loss: 10.2836 - x3_loss: 1.0683 - x1_acc: 0.6931 - x2_acc: 0.4413 - x3_acc: 0.6824
174080/747322 [=====>........................] - ETA: 74s - loss: 21.4512 - x1_loss: 10.1085 - x2_loss: 10.2742 - x3_loss: 1.0685 - x1_acc: 0.6931 - x2_acc: 0.4414 - x3_acc: 0.6821
175104/747322 [======>.......................] - ETA: 74s - loss: 21.4315 - x1_loss: 10.0977 - x2_loss: 10.2647 - x3_loss: 1.0690 - x1_acc: 0.6931 - x2_acc: 0.4414 - x3_acc: 0.6817
176128/747322 [======>.......................] - ETA: 74s - loss: 21.4231 - x1_loss: 10.0880 - x2_loss: 10.2656 - x3_loss: 1.0695 - x1_acc: 0.6932 - x2_acc: 0.4412 - x3_acc: 0.6813
177152/747322 [======>.......................] - ETA: 74s - loss: 21.4059 - x1_loss: 10.0732 - x2_loss: 10.2639 - x3_loss: 1.0688 - x1_acc: 0.6931 - x2_acc: 0.4412 - x3_acc: 0.6809
178176/747322 [======>.......................] - ETA: 74s - loss: 21.4289 - x1_loss: 10.0967 - x2_loss: 10.2634 - x3_loss: 1.0688 - x1_acc: 0.6930 - x2_acc: 0.4413 - x3_acc: 0.6807
179200/747322 [======>.......................] - ETA: 74s - loss: 21.4329 - x1_loss: 10.1092 - x2_loss: 10.2557 - x3_loss: 1.0681 - x1_acc: 0.6930 - x2_acc: 0.4414 - x3_acc: 0.6807
180224/747322 [======>.......................] - ETA: 74s - loss: 21.4277 - x1_loss: 10.1099 - x2_loss: 10.2503 - x3_loss: 1.0675 - x1_acc: 0.6930 - x2_acc: 0.4415 - x3_acc: 0.6807
181248/747322 [======>.......................] - ETA: 73s - loss: 21.4088 - x1_loss: 10.0975 - x2_loss: 10.2441 - x3_loss: 1.0671 - x1_acc: 0.6929 - x2_acc: 0.4416 - x3_acc: 0.6808
182272/747322 [======>.......................] - ETA: 73s - loss: 21.3909 - x1_loss: 10.0841 - x2_loss: 10.2405 - x3_loss: 1.0663 - x1_acc: 0.6929 - x2_acc: 0.4415 - x3_acc: 0.6811
183296/747322 [======>.......................] - ETA: 73s - loss: 21.3775 - x1_loss: 10.0699 - x2_loss: 10.2416 - x3_loss: 1.0660 - x1_acc: 0.6927 - x2_acc: 0.4415 - x3_acc: 0.6813
184320/747322 [======>.......................] - ETA: 73s - loss: 21.3682 - x1_loss: 10.0664 - x2_loss: 10.2355 - x3_loss: 1.0662 - x1_acc: 0.6928 - x2_acc: 0.4417 - x3_acc: 0.6818
185344/747322 [======>.......................] - ETA: 73s - loss: 21.4162 - x1_loss: 10.1213 - x2_loss: 10.2291 - x3_loss: 1.0658 - x1_acc: 0.6927 - x2_acc: 0.4417 - x3_acc: 0.6821
186368/747322 [======>.......................] - ETA: 73s - loss: 21.3981 - x1_loss: 10.1050 - x2_loss: 10.2259 - x3_loss: 1.0672 - x1_acc: 0.6928 - x2_acc: 0.4418 - x3_acc: 0.6825
187392/747322 [======>.......................] - ETA: 73s - loss: 21.3793 - x1_loss: 10.0909 - x2_loss: 10.2212 - x3_loss: 1.0673 - x1_acc: 0.6928 - x2_acc: 0.4417 - x3_acc: 0.6827
188416/747322 [======>.......................] - ETA: 73s - loss: 21.3614 - x1_loss: 10.0784 - x2_loss: 10.2163 - x3_loss: 1.0668 - x1_acc: 0.6930 - x2_acc: 0.4418 - x3_acc: 0.6830
189440/747322 [======>.......................] - ETA: 72s - loss: 21.3736 - x1_loss: 10.0909 - x2_loss: 10.2169 - x3_loss: 1.0659 - x1_acc: 0.6930 - x2_acc: 0.4417 - x3_acc: 0.6833
190464/747322 [======>.......................] - ETA: 72s - loss: 21.4615 - x1_loss: 10.0802 - x2_loss: 10.3165 - x3_loss: 1.0648 - x1_acc: 0.6930 - x2_acc: 0.4418 - x3_acc: 0.6836
191488/747322 [======>.......................] - ETA: 72s - loss: 21.4493 - x1_loss: 10.0653 - x2_loss: 10.3194 - x3_loss: 1.0646 - x1_acc: 0.6930 - x2_acc: 0.4417 - x3_acc: 0.6837
192512/747322 [======>.......................] - ETA: 72s - loss: 21.4863 - x1_loss: 10.0997 - x2_loss: 10.3207 - x3_loss: 1.0659 - x1_acc: 0.6927 - x2_acc: 0.4416 - x3_acc: 0.6837
193536/747322 [======>.......................] - ETA: 72s - loss: 21.4750 - x1_loss: 10.0895 - x2_loss: 10.3198 - x3_loss: 1.0657 - x1_acc: 0.6929 - x2_acc: 0.4416 - x3_acc: 0.6839
194560/747322 [======>.......................] - ETA: 72s - loss: 21.4577 - x1_loss: 10.0755 - x2_loss: 10.3168 - x3_loss: 1.0654 - x1_acc: 0.6929 - x2_acc: 0.4416 - x3_acc: 0.6839
195584/747322 [======>.......................] - ETA: 72s - loss: 21.4429 - x1_loss: 10.0627 - x2_loss: 10.3148 - x3_loss: 1.0655 - x1_acc: 0.6929 - x2_acc: 0.4417 - x3_acc: 0.6838
196608/747322 [======>.......................] - ETA: 71s - loss: 21.4307 - x1_loss: 10.0558 - x2_loss: 10.3089 - x3_loss: 1.0660 - x1_acc: 0.6929 - x2_acc: 0.4418 - x3_acc: 0.6834
197632/747322 [======>.......................] - ETA: 71s - loss: 21.4446 - x1_loss: 10.0669 - x2_loss: 10.3107 - x3_loss: 1.0670 - x1_acc: 0.6929 - x2_acc: 0.4418 - x3_acc: 0.6830
198656/747322 [======>.......................] - ETA: 71s - loss: 21.4287 - x1_loss: 10.0552 - x2_loss: 10.3071 - x3_loss: 1.0665 - x1_acc: 0.6930 - x2_acc: 0.4418 - x3_acc: 0.6827
199680/747322 [=======>......................] - ETA: 71s - loss: 21.4168 - x1_loss: 10.0474 - x2_loss: 10.3034 - x3_loss: 1.0660 - x1_acc: 0.6931 - x2_acc: 0.4417 - x3_acc: 0.6823
200704/747322 [=======>......................] - ETA: 71s - loss: 21.4064 - x1_loss: 10.0385 - x2_loss: 10.3015 - x3_loss: 1.0664 - x1_acc: 0.6931 - x2_acc: 0.4417 - x3_acc: 0.6819
201728/747322 [=======>......................] - ETA: 71s - loss: 21.3954 - x1_loss: 10.0320 - x2_loss: 10.2974 - x3_loss: 1.0659 - x1_acc: 0.6931 - x2_acc: 0.4416 - x3_acc: 0.6817
202752/747322 [=======>......................] - ETA: 71s - loss: 21.3870 - x1_loss: 10.0243 - x2_loss: 10.2965 - x3_loss: 1.0662 - x1_acc: 0.6931 - x2_acc: 0.4415 - x3_acc: 0.6816
203776/747322 [=======>......................] - ETA: 70s - loss: 21.3782 - x1_loss: 10.0155 - x2_loss: 10.2954 - x3_loss: 1.0673 - x1_acc: 0.6929 -

etc...


问:
upload image after crop in tinymce 4
I am working on tinymce and I have implemented imagetools. Now when image gets inserted in the text editor and then I edit/crop the image it changes the image src to something like blob:www.localhost/asdf-ghij.

What I want is after cropping I can send this url to my php script so that i can save this image on my server. But I have no idea of the event/function that i should use.

here is my code:

```<code>tinymce.init({
    selector:'textarea',
    plugins:[
        'advlist autolink lists link image imagetools charmap print preview anchor',
        'searchreplace visualblocks code fullscreen',
        'insertdatetime media table contextmenu paste code'
    ],
    toolbar:'insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image code',
    height:300,
    imagetools_toolbar: "rotateleft rotateright | flipv fliph | editimage imageoptions",
    automatic_uploads: false,
    remove_script_host : false,
    convert_urls : false,
    relative_urls : false,
    setup: function (editor) {
        editor.on('change', function () {
            editor.save();
        });
    },
    file_browser_callback_types: 'file image media',
    file_browser_callback: function(field_name, url, type, win) {
        tinymce.activeEditor.windowManager.open({
            title: 'Browse Image',
            file: '/admin/images/show-images',
            width: 1200,
            height:400,
            resizable : "yes",
            close_previous : "no",

            buttons: [{
                text: 'Insert',
                classes: 'widget btn primary first abs-layout-item',
                disabled: false,
                onclick: 'close'
            }, {
                text: 'Close',
                onclick: 'close',
                window : win,
                input : field_name
            }]
        }, {
            oninsert: function(url) {
                win.document.getElementById(field_name).value = url;
            }
        });
        return false;
    }
});
</code>```

Everything is working fine. except the problem I mentioned.

答:
Change automatic_uploads to true and add images_upload_url will do:

```<code>tinymce.init({
  selector:'textarea',
  automatic_uploads: true,
  images_upload_url: 'postAcceptor.php'
});
</code>```

The new created images will get file-names as 'imagetools0.jpg', 'imagetools1.jpg', etc.

N.B. The source for postAcceptor.php can be found at PHP Upload Handler  page of the TinyMCE website.

Title: upload image after crop in tinymce 4

Body:
I am working on tinymce and I have implemented imagetools. Now when image gets inserted in the text editor and then I edit/crop the image it changes the image src to something like blob:www.localhost/asdf-ghij.

What I want is after cropping I can send this url to my php script so that i can save this image on my server. But I have no idea of the event/function that i should use.

here is my code:

tinymce.init({
    selector:'textarea',
    plugins:[
        'advlist autolink lists link image imagetools charmap print preview anchor',
        'searchreplace visualblocks code fullscreen',
        'insertdatetime media table contextmenu paste code'
    ],
    toolbar:'insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image code',
    height:300,
    imagetools_toolbar: "rotateleft rotateright | flipv fliph | editimage imageoptions",
    automatic_uploads: false,
    remove_script_host : false,
    convert_urls : false,
    relative_urls : false,
    setup: function (editor) {
        editor.on('change', function () {
            editor.save();
        });
    },
    file_browser_callback_types: 'file image media',
    file_browser_callback: function(field_name, url, type, win) {
        tinymce.activeEditor.windowManager.open({
            title: 'Browse Image',
            file: '/admin/images/show-images',
            width: 1200,
            height:400,
            resizable : "yes",
            close_previous : "no",

            buttons: [{
                text: 'Insert',
                classes: 'widget btn primary first abs-layout-item',
                disabled: false,
                onclick: 'close'
            }, {
                text: 'Close',
                onclick: 'close',
                window : win,
                input : field_name
            }]
        }, {
            oninsert: function(url) {
                win.document.getElementById(field_name).value = url;
            }
        });
        return false;
    }
});

Everything is working fine. except the problem I mentioned.

Body:
Change automatic_uploads to true and add images_upload_url will do:

tinymce.init({
  selector:'textarea',
  automatic_uploads: true,
  images_upload_url: 'postAcceptor.php'
});

The new created images will get file-names as 'imagetools0.jpg', 'imagetools1.jpg', etc.

N.B. The source for postAcceptor.php can be found at PHP Upload Handler  page of the TinyMCE website.


问:
can't change my table data in angulars?
i posted a question before but no answer, maybe my code was too long, so i am having this problem, i have a table :

```<code>$scope.slides = [
   {"status":true},
   {"status":false},
   {"status":false},
]
</code>```

when i try to get the value of the first element or second or third element it works by using this :

```<code> var i = $scope.slides[0].status //1,2 for second and third
 alert(i) // it works fine
</code>```

but i want this data to change every second :

```<code> $scope.change = $interval(function($scope){
   if(condition){
      $scope.slides[0].status = false
    }else {
      $scope.slides[0].status = true
  }
   })
</code>```

I am puuting this value in my HTML in the ng-show directive, it seems         nothing is changing ..

Thank you

答:
You need to convert your objects to json. Currently they are stringified.

You need to do something like:

```<code>for(var i=0; i<=$scope.slides.length; i++){
    $scope.slides[i] = JSON.parse($scope.slides[i]);
}
</code>```

Then whatever you are doing above, should work.

Hope this helps :)

Title: can't change my table data in angulars?

Body:
i posted a question before but no answer, maybe my code was too long, so i am having this problem, i have a table :

$scope.slides = [
   {"status":true},
   {"status":false},
   {"status":false},
]

when i try to get the value of the first element or second or third element it works by using this :

 var i = $scope.slides[0].status //1,2 for second and third
 alert(i) // it works fine

but i want this data to change every second :

 $scope.change = $interval(function($scope){
   if(condition){
      $scope.slides[0].status = false
    }else {
      $scope.slides[0].status = true
  }
   })

I am puuting this value in my HTML in the ng-show directive, it seems         nothing is changing ..

Thank you

Body:
You need to convert your objects to json. Currently they are stringified.

You need to do something like:

for(var i=0; i<=$scope.slides.length; i++){
    $scope.slides[i] = JSON.parse($scope.slides[i]);
}

Then whatever you are doing above, should work.

Hope this helps :)


问:
How to get images from hidden folder in android
I am able to fetch all the images from any specified non hidden folder from device but how can I get all the images from a hidden specified folder.
As soon as I mention my hidden folder name in the query, cursor return null</p>

```<code>  public static List<MediaData> getAppScannedImages(Context context) {
    Cursor imagecursor = null;
    List<MediaData> gallerydata = new ArrayList<MediaData>();

    try {
        final String orderBy = Images.ImageColumns.DATE_TAKEN + " DESC";
        imagecursor = context.getContentResolver()
                .query(Images.Media.EXTERNAL_CONTENT_URI,
                        projectionImage,
                        Images.Media.BUCKET_DISPLAY_NAME + "='"
                                + ".myHiddenFolder" + "'", null,
                        orderBy);
        if (imagecursor != null) {
            imagecursor.moveToFirst();
            int count = imagecursor.getCount();
            for (int i = 0; i < count; i++) {
                MediaData galData = new MediaData();
                galData.setKey_id(i);
                galData.setId(imagecursor.getString(0));
                galData.setName(imagecursor.getString(1));
                galData.setPath(imagecursor.getString(2));
                galData.setDate(imagecursor.getString(3));
                gallerydata.add(galData);
                imagecursor.moveToNext();
            }
        }

    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        if (imagecursor != null) {
            imagecursor.close();
        }
    }
    return gallerydata;
}
</code>```

答:
```<code>String path = Environment.getExternalStorageDirectory().toString();
        File dir = new File(path);
          File listFile[] = dir.listFiles();
          for (int i = 0; i < listFile.length; i++) {
              if(listFile[i].getAbsolutePath().contains("your hidden folder name")){
                  File dirtest = new File(listFile[i].getAbsolutePath());
                  File listFiletest[] = dirtest.listFiles();
                  for (int j = 0; j < listFiletest.length; j++) {
                     get all images from hidden folder
                  }
              }
          }
</code>```

Body:
I am able to fetch all the images from any specified non hidden folder from device but how can I get all the images from a hidden specified folder.
As soon as I mention my hidden folder name in the query, cursor return null

  public static List<MediaData> getAppScannedImages(Context context) {
    Cursor imagecursor = null;
    List<MediaData> gallerydata = new ArrayList<MediaData>();

    try {
        final String orderBy = Images.ImageColumns.DATE_TAKEN + " DESC";
        imagecursor = context.getContentResolver()
                .query(Images.Media.EXTERNAL_CONTENT_URI,
                        projectionImage,
                        Images.Media.BUCKET_DISPLAY_NAME + "='"
                                + ".myHiddenFolder" + "'", null,
                        orderBy);
        if (imagecursor != null) {
            imagecursor.moveToFirst();
            int count = imagecursor.getCount();
            for (int i = 0; i < count; i++) {
                MediaData galData = new MediaData();
                galData.setKey_id(i);
                galData.setId(imagecursor.getString(0));
                galData.setName(imagecursor.getString(1));
                galData.setPath(imagecursor.getString(2));
                galData.setDate(imagecursor.getString(3));
                gallerydata.add(galData);
                imagecursor.moveToNext();
            }
        }

    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        if (imagecursor != null) {
            imagecursor.close();
        }
    }
    return gallerydata;
}


答:
You could do it by referencing the .pac-container elements explicitly by index using eq():

var $pac = $('.pac-container');
$pac.eq(0).prependTo('#wrapper1');
$pac.eq(1).prependTo('#wrapper2');```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="pac-container">PAC container 1</div>
<div class="pac-container">PAC container 2</div>

<div id="wrapper1">wrapper1 </div>
<div id="wrapper2">wrapper2</div></code>```

However, this is not very DRY. You could instead use a common class on the wrapper elements, then relate them to the containers by index, something like this:

$('.pac-container').each(function(i) {
  $(this).prependTo($('.wrapper').eq(i));
})  ```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="pac-container">PAC container 1</div>
<div class="pac-container">PAC container 2</div>

<div class="wrapper">wrapper1 </div>
<div class="wrapper">wrapper2</div></code>```

Title: Move each div with same class into another div

Body:
I got 2 divs with the same class and I am trying to move each of the 2 divs into a different div.

setTimeout(function() {
  $(".pac-container").prependTo("#gp-content");
}, 500);

.pac-container {
  width: 50px;
  height: 100px;
  border: 1px solid black;
  padding: 5px;
  margin: 5px;
}

#wrapper1,
#wrapper2 {
  width: 25px;
  height: 75px;
  border: 1px dotted red;
  padding: 5px;
  margin: 5px;
}

My goal is now to move the first pac-container into #wrapper1 and the second pac-container into #wrapper2. The pac-container are sitting next to each other at the html-markup and each #wrapper sits on different positions at the html-markup.

Goal

Body:
You could do it by referencing the .pac-container elements explicitly by index using eq():

var $pac = $('.pac-container');
$pac.eq(0).prependTo('#wrapper1');
$pac.eq(1).prependTo('#wrapper2');

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="pac-container">PAC container 1</div>
<div class="pac-container">PAC container 2</div>

<div id="wrapper1">wrapper1 </div>
<div id="wrapper2">wrapper2</div>

However, this is not very DRY. You could instead use a common class on the wrapper elements, then relate them to the containers by index, something like this:

$('.pac-container').each(function(i) {
  $(this).prependTo($('.wrapper').eq(i));
})

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="pac-container">PAC container 1</div>
<div class="pac-container">PAC container 2</div>

<div class="wrapper">wrapper1 </div>
<div class="wrapper">wrapper2</div>


问:
Free Rails 3 scaffold templates?
Does anyone know where I might be able to find free scaffold templates (i.e. .css files)? I'm doing a quick and dirty project, and I'm just looking for something generic, but a bit more visually appealing than the extremely generic default. Actually I'd be especially interested in something that look similar to the Django Admin section, but I'm not that picky, really.  </p>

答: I've used the Blueprint CSS Framework (http://www.blueprintcss.org/) for stuff like this in the past.</p>

Title: Free Rails 3 scaffold templates?


问:
How to send elements to a Source.actorRef or a Source.queue in Java
I'm currently working with Akka Streams (in Java) for a personal project and I'm having a hard time understanding how to send element to a Source.

The idea is to use a WebSocket to push content into the user's web browser. I've managed to use Akka Streams to create a request-response system, following the Akka HTTP documentation, but this is not what I want to do.

Looking into the Akka Streams documentation, I saw that there is Source.queue and Source.actorRef. But I don't understand how to put an element into the Source. Source.queue and Source.actorRef return a Source, which doesn't have the method offer (for Source.queue) or tell (for Source.actorRef).

My question is: how do I get the ActorRef for the Source created by Source.actorRef or the SourceQueueWithComplete for a Source created with Source.queue, to be able to send elements to my Source?

I searched the various Akka documentation but found no method to do that. And the majority of the code I found on the Internet is written in Scala, which doesn't seem to have the same problem.

答:
The actor and queue from Source.actorRef and Source.queue, respectively, are the materialized values of those sources, meaning that they can be obtained only if the stream is running. For example:

final ActorRef actor =
  Source.actorRef(Integer.MAX_VALUE, OverflowStrategy.fail())
        .to(Sink.foreach(m -> System.out.println(m)))
        .run(materializer);

actor.tell("do something", ActorRef.noSender());
```

<p>It's no different in Scala:</p>

<pre class="lang-scala prettyprint-override"><code>implicit val materializer = ActorMaterializer()

val actor =
  Source.actorRef(Int.MaxValue, OverflowStrategy.fail)
        .to(Sink.foreach(println))
        .run()

actor ! "do something"
</code>```

Body:
The actor and queue from Source.actorRef and Source.queue, respectively, are the materialized values of those sources, meaning that they can be obtained only if the stream is running. For example:

final ActorRef actor =
  Source.actorRef(Integer.MAX_VALUE, OverflowStrategy.fail())
        .to(Sink.foreach(m -> System.out.println(m)))
        .run(materializer);

actor.tell("do something", ActorRef.noSender());

It's no different in Scala:

implicit val materializer = ActorMaterializer()

val actor =
  Source.actorRef(Int.MaxValue, OverflowStrategy.fail)
        .to(Sink.foreach(println))
        .run()

actor ! "do something"


问:
Exiting an infinite loop with a key in c++ on linux
i have an infinite loop that should be ended if i pressed any key. The program runs in linux. I have stumbled upon a function Here is a bit of my code :

```<code>int main(){
      While(1){
        ParseData(); //writing data to a text file
      }
return 0;
}
</code>```

so i know that i can terminate the process by using ctrl + c in terminal, but it seems that it will interrupt the writing process so the datas are not written completely halfway through the process. I read that i need to use function from ncurses library , but i can't quite understand any.

Can someone help me with it? Thanks!

答:
The C way actually (include conio.h ):

```<code>char key;

while (1)
{
    key = _getch();

    // P to exit
    if (key == 'p' || key == 'P')
    {
        writer.close();
        exit(1);
    }
}
</code>```

Body:
i have an infinite loop that should be ended if i pressed any key. The program runs in linux. I have stumbled upon a function Here is a bit of my code :

int main(){
      While(1){
        ParseData(); //writing data to a text file
      }
return 0;
}

so i know that i can terminate the process by using ctrl + c in terminal, but it seems that it will interrupt the writing process so the datas are not written completely halfway through the process. I read that i need to use function from ncurses library , but i can't quite understand any.

Can someone help me with it? Thanks!

Body:
The C way actually (include conio.h ):

char key;

while (1)
{
    key = _getch();

    // P to exit
    if (key == 'p' || key == 'P')
    {
        writer.close();
        exit(1);
    }
}