问:
CSS margin issue with DIV ids
In my below code, I am facing below problems div expenses_div. I have added margin-top:3%; for it, but somehow its not working.

Also, expenses_div is inside container_input. but expenses_div width is more than the one set for container_input (60% of page width). I am not able to understand the issue with expenses_div.

Can someone please guide me here

.expenses_wrapper
{
 width:100%;
 text-align:center;
 margin:auto;
 margin-top:50px;
}

.expenses_banner
{
 width:100% !important;
 background-color:black;
 position: relative;
 text-align:center;
 color:white;
 padding:5px;
 overflow:hidden !important;
 font-family: "Montserrat",sans-serif !important;
 font-size:20px;
 position:fixed;
 z-index: 105 !important;
}

.container_input
{
width:100%;
margin-top:5%;
text-align:center;
margin:auto;
}

.expenses_main_head
{
 width:60%;
 text-align:center;
 padding-top:80px;
 margin:auto;
}

.expenses_div
{
width:100% !important;
margin:auto;
margin-top:3%;
}

.expenses_div_left
{
height:40px;
line-height:40px;
background-color:black;
float:left;
display: inline-block;
text-align:left;
padding-left:12px;
color:white;
width:48%;
font-size: 14px !important;
font-family : "Montserrat",sans-serif !important;
}

.expenses_div_right
{
height: 40px !important;
line-height: 40px !important;
width:48%;
float:left;
display: inline-block;
cursor:pointer;
background:transparent !important;
position:relative;/*Added (Because :after should be relative to this not whole page! )*/
}

.expenses_div_right select
{
font-family : "Montserrat",sans-serif !important;
background:transparent !important;
appearance:none !important;
-moz-appearance:none !important;
-webkit-appearance:none !important;
box-sizing: border-box !important;
border: 1px solid black !important;
width:100%!important;
color:black !important;
height:40px;
text-align:left !important;
font-size: 14px !important;
outline: none;
position: relative !important;
cursor:pointer;
padding-left:12px;
z-index:2;
}

.expenses_div_right:after
{
content: '< >';
font: 16px "Consolas", monospace;
font-weight:bold;
color: white;
background-color:black;
display:inline-block;
-webkit-transform: rotate(90deg);
-moz-transform: rotate(90deg);
-ms-transform: rotate(90deg);
transform: rotate(90deg);
position: absolute;/*Changed to absolute*/
top:0;/*Added*/
right:0;/*Added*/
width:40px;
height:40px;
text-align:center;
line-height:40px;
overflow:hidden !important;
cursor:pointer;
z-index :1 ;/*Added ( For Your 2nd Question )*/
}

.expenses_input
{
height:40px !important;
line-height: 40px !important;
border: 1px solid black !important;
font-family : "Montserrat",sans-serif !important;
outline: none !important;
width:100%!important;
text-align:right;
display: inline-block;
font-size: 14px !important;
cursor:pointer;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box !important;
-moz-appearance: none;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div id="expenses_wrapper" class="expenses_wrapper" >
<div id="expenses_banner" class="expenses_banner" >Tracker</div>

<div class="container_input" id="container_input"  >
 <div class="expenses_main_head">
  <div class="expenses_div_left" >How to Proceed</div>
  <div id="expenses_div_right" class="expenses_div_right" >
   <select name="expense_main_selection"  id="expense_main_selection" >
    <option selected value="">Select an option</option>
    <option value="new_data">New Data</option>
    <option value="analize_data">Analyze Data</option>
    <option value="refresh_data">Refresh Data</option>
   </select>
  </div>
 </div>

 <div id="expenses_input_date" class="expenses_div" >
  <div class="expenses_div_left" >Date</div>
  <div class="expenses_div_right" ><input type="text" class="expenses_input" id="expenses_input_date" name="expenses_input_date" autocomplete="off"></div>
 </div>

 <div id ="expenses_select_account" class="expenses_div" >
  <div class="expenses_div_left" >Select Account</div>
  <div id="expenses_div_right" class="expenses_div_right" >
   <select name="select_account" id="select_account_select">
    <option selected value="">Select Account</option>
    <option value="Opt1">Opt1</option>
    <option value="Opt2">Opt2</option>
   </select>
  </div>
 </div>

</div>

</div></code>```

答:
if you can change the width of the .container_input to 60% it should work.

.expenses_wrapper {
 width:100%;
 text-align:center;
 margin:auto;
 margin-top:50px;
}

.expenses_banner {
 width:100% !important;
 background-color:black;
 position: relative;
 text-align:center;
 color:white;
 padding:5px;
 overflow:hidden !important;
 font-family: "Montserrat",sans-serif !important;
 font-size:20px;
 position:fixed;
 z-index: 105 !important;
}

.container_input {
  width: 60%;
  margin-top:5%;
  text-align:center;
  margin:auto;
}

.expenses_main_head {
 width:60%;
 text-align:center;
 padding-top:80px;
 margin:auto;
}

.expenses_div {
  width:100% !important;
  margin:auto;
  margin-top:3%;
}

.expenses_div_left {
  height: 40px;
  line-height: 40px;
  background-color: black;
  float: left;
  display: inline-block;
  text-align:left;
  padding-left:12px;
  color:white;
  width:48%;
  font-size: 14px !important;
  font-family : "Montserrat",sans-serif !important;
}

.expenses_div_right {
  height: 40px !important;
  line-height: 40px !important;
  width: 48%;
  float: left;
  display: inline-block;
  cursor: pointer;
  background: transparent !important;
  position: relative;/*Added (Because :after should be relative to this not whole page! )*/
}

.expenses_div_right select  {
  font-family : "Montserrat",sans-serif !important;
  background:transparent !important;
  appearance:none !important;
  -moz-appearance:none !important;
  -webkit-appearance:none !important;
  box-sizing: border-box !important;
  border: 1px solid black !important;
  width:100%!important;
  color:black !important;
  height:40px;
  text-align:left !important;
  font-size: 14px !important;
  outline: none;
  position: relative !important;
  cursor:pointer;
  padding-left:12px;
  z-index:2;
}

.expenses_div_right:after {
  content: '< >';
  font: 16px "Consolas", monospace;
  font-weight:bold;
  color: white;
  background-color:black;
  display:inline-block;
  -webkit-transform: rotate(90deg);
  -moz-transform: rotate(90deg);
  -ms-transform: rotate(90deg);
  transform: rotate(90deg);
  position: absolute;/*Changed to absolute*/
  top:0;/*Added*/
  right:0;/*Added*/
  width:40px;
  height:40px;
  text-align:center;
  line-height:40px;
  overflow:hidden !important;
  cursor:pointer;
  z-index :1 ;/*Added ( For Your 2nd Question )*/
}

.expenses_input {
  height:40px !important;
  line-height: 40px !important;
  border: 1px solid black !important;
  font-family : "Montserrat",sans-serif !important;
  outline: none !important;
  width:100%!important;
  text-align:right;
  display: inline-block;
  font-size: 14px !important;
  cursor:pointer;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box !important;
  -moz-appearance: none;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <link rel="stylesheet" href="styles.css">
</head>
<body>
  <div id="expenses_wrapper" class="expenses_wrapper">
    <div id="expenses_banner" class="expenses_banner">Tracker</div>
    <div class="container_input" id="container_input">
      <div class="expenses_main_head">
        <div class="expenses_div_left" >How to Proceed</div>
        <div id="expenses_div_right" class="expenses_div_right">
          <select name="expense_main_selection"  id="expense_main_selection" >
            <option selected value="">Select an option</option>
            <option value="new_data">New Data</option>
            <option value="analize_data">Analyze Data</option>
            <option value="refresh_data">Refresh Data</option>
          </select>
        </div>
      </div>

      <div id="expenses_input_date" class="expenses_div" >
        <div class="expenses_div_left" >Date</div>
        <div class="expenses_div_right" ><input type="text" class="expenses_input" id="expenses_input_date" name="expenses_input_date" autocomplete="off"></div>
      </div>

      <div id ="expenses_select_account" class="expenses_div" >
        <div class="expenses_div_left" >Select Account</div>
        <div id="expenses_div_right" class="expenses_div_right" >
            <select name="select_account" id="select_account_select">
                <option selected value="">Select Account</option>
                <option value="Opt1">Opt1</option>
                <option value="Opt2">Opt2</option>
            </select>
        </div>
      </div>
    </div>
  </div>
</body>
</html></code>```

Title: CSS margin issue with DIV ids

Body:
In my below code, I am facing below problems div expenses_div. I have added margin-top:3%; for it, but somehow its not working.

Also, expenses_div is inside container_input. but expenses_div width is more than the one set for container_input (60% of page width). I am not able to understand the issue with expenses_div.

Can someone please guide me here

.expenses_wrapper
{
 width:100%;
 text-align:center;
 margin:auto;
 margin-top:50px;
}

.expenses_banner
{
 width:100% !important;
 background-color:black;
 position: relative;
 text-align:center;
 color:white;
 padding:5px;
 overflow:hidden !important;
 font-family: "Montserrat",sans-serif !important;
 font-size:20px;
 position:fixed;
 z-index: 105 !important;
}

.container_input
{
width:100%;
margin-top:5%;
text-align:center;
margin:auto;
}

.expenses_main_head
{
 width:60%;
 text-align:center;
 padding-top:80px;
 margin:auto;
}

.expenses_div
{
width:100% !important;
margin:auto;
margin-top:3%;
}

.expenses_div_left
{
height:40px;
line-height:40px;
background-color:black;
float:left;
display: inline-block;
text-align:left;
padding-left:12px;
color:white;
width:48%;
font-size: 14px !important;
font-family : "Montserrat",sans-serif !important;
}

.expenses_div_right
{
height: 40px !important;
line-height: 40px !important;
width:48%;
float:left;
display: inline-block;
cursor:pointer;
background:transparent !important;
position:relative;/*Added (Because :after should be relative to this not whole page! )*/
}

.expenses_div_right select
{
font-family : "Montserrat",sans-serif !important;
background:transparent !important;
appearance:none !important;
-moz-appearance:none !important;
-webkit-appearance:none !important;
box-sizing: border-box !important;
border: 1px solid black !important;
width:100%!important;
color:black !important;
height:40px;
text-align:left !important;
font-size: 14px !important;
outline: none;
position: relative !important;
cursor:pointer;
padding-left:12px;
z-index:2;
}

.expenses_div_right:after
{
content: '< >';
font: 16px "Consolas", monospace;
font-weight:bold;
color: white;
background-color:black;
display:inline-block;
-webkit-transform: rotate(90deg);
-moz-transform: rotate(90deg);
-ms-transform: rotate(90deg);
transform: rotate(90deg);
position: absolute;/*Changed to absolute*/
top:0;/*Added*/
right:0;/*Added*/
width:40px;
height:40px;
text-align:center;
line-height:40px;
overflow:hidden !important;
cursor:pointer;
z-index :1 ;/*Added ( For Your 2nd Question )*/
}

.expenses_input
{
height:40px !important;
line-height: 40px !important;
border: 1px solid black !important;
font-family : "Montserrat",sans-serif !important;
outline: none !important;
width:100%!important;
text-align:right;
display: inline-block;
font-size: 14px !important;
cursor:pointer;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box !important;
-moz-appearance: none;
}

Tracker

How to Proceed

   <select name="expense_main_selection"  id="expense_main_selection" >
    <option selected value="">Select an option</option>
    <option value="new_data">New Data</option>
    <option value="analize_data">Analyze Data</option>
    <option value="refresh_data">Refresh Data</option>
   </select>

Date

<input type="text" class="expenses_input" id="expenses_input_date" name="expenses_input_date" autocomplete="off">

Select Account

   <select name="select_account" id="select_account_select">
    <option selected value="">Select Account</option>
    <option value="Opt1">Opt1</option>
    <option value="Opt2">Opt2</option>
   </select>

Body:
if you can change the width of the .container_input to 60% it should work.

.expenses_wrapper {
 width:100%;
 text-align:center;
 margin:auto;
 margin-top:50px;
}

.expenses_banner {
 width:100% !important;
 background-color:black;
 position: relative;
 text-align:center;
 color:white;
 padding:5px;
 overflow:hidden !important;
 font-family: "Montserrat",sans-serif !important;
 font-size:20px;
 position:fixed;
 z-index: 105 !important;
}

.container_input {
  width: 60%;
  margin-top:5%;
  text-align:center;
  margin:auto;
}

.expenses_main_head {
 width:60%;
 text-align:center;
 padding-top:80px;
 margin:auto;
}

.expenses_div {
  width:100% !important;
  margin:auto;
  margin-top:3%;
}

.expenses_div_left {
  height: 40px;
  line-height: 40px;
  background-color: black;
  float: left;
  display: inline-block;
  text-align:left;
  padding-left:12px;
  color:white;
  width:48%;
  font-size: 14px !important;
  font-family : "Montserrat",sans-serif !important;
}

.expenses_div_right {
  height: 40px !important;
  line-height: 40px !important;
  width: 48%;
  float: left;
  display: inline-block;
  cursor: pointer;
  background: transparent !important;
  position: relative;/*Added (Because :after should be relative to this not whole page! )*/
}

.expenses_div_right select  {
  font-family : "Montserrat",sans-serif !important;
  background:transparent !important;
  appearance:none !important;
  -moz-appearance:none !important;
  -webkit-appearance:none !important;
  box-sizing: border-box !important;
  border: 1px solid black !important;
  width:100%!important;
  color:black !important;
  height:40px;
  text-align:left !important;
  font-size: 14px !important;
  outline: none;
  position: relative !important;
  cursor:pointer;
  padding-left:12px;
  z-index:2;
}

.expenses_div_right:after {
  content: '< >';
  font: 16px "Consolas", monospace;
  font-weight:bold;
  color: white;
  background-color:black;
  display:inline-block;
  -webkit-transform: rotate(90deg);
  -moz-transform: rotate(90deg);
  -ms-transform: rotate(90deg);
  transform: rotate(90deg);
  position: absolute;/*Changed to absolute*/
  top:0;/*Added*/
  right:0;/*Added*/
  width:40px;
  height:40px;
  text-align:center;
  line-height:40px;
  overflow:hidden !important;
  cursor:pointer;
  z-index :1 ;/*Added ( For Your 2nd Question )*/
}

.expenses_input {
  height:40px !important;
  line-height: 40px !important;
  border: 1px solid black !important;
  font-family : "Montserrat",sans-serif !important;
  outline: none !important;
  width:100%!important;
  text-align:right;
  display: inline-block;
  font-size: 14px !important;
  cursor:pointer;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box !important;
  -moz-appearance: none;
}

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <link rel="stylesheet" href="styles.css">
</head>
<body>
  <div id="expenses_wrapper" class="expenses_wrapper">
    <div id="expenses_banner" class="expenses_banner">Tracker</div>
    <div class="container_input" id="container_input">
      <div class="expenses_main_head">
        <div class="expenses_div_left" >How to Proceed</div>
        <div id="expenses_div_right" class="expenses_div_right">
          <select name="expense_main_selection"  id="expense_main_selection" >
            <option selected value="">Select an option</option>
            <option value="new_data">New Data</option>
            <option value="analize_data">Analyze Data</option>
            <option value="refresh_data">Refresh Data</option>
          </select>
        </div>
      </div>

      <div id="expenses_input_date" class="expenses_div" >
        <div class="expenses_div_left" >Date</div>
        <div class="expenses_div_right" ><input type="text" class="expenses_input" id="expenses_input_date" name="expenses_input_date" autocomplete="off"></div>
      </div>

      <div id ="expenses_select_account" class="expenses_div" >
        <div class="expenses_div_left" >Select Account</div>
        <div id="expenses_div_right" class="expenses_div_right" >
            <select name="select_account" id="select_account_select">
                <option selected value="">Select Account</option>
                <option value="Opt1">Opt1</option>
                <option value="Opt2">Opt2</option>
            </select>
        </div>
      </div>
    </div>
  </div>
</body>
</html>


来源: stackexchange

问:
Trying to plot stacked barplot from percentages
I'm trying to plot a stacked barplot of the rate of computer used in different departments with details on what type of PC in each bar( so that for each department type1+type2+type3=tot_rate) . I've got a dataframe that looks like this :

```<code>dat=read.table(text = "Tot_rate   Type1   Type2   Type3
DPT1 72 50 12 10
DPT2 80 30 20 30
DPT3 92 54 14 24", header = TRUE)

</code>```

I tried to plot my barplot with raw data but now it's very important that i get the one with percentages and i can't seem to understand how i can do that.

This is how i thought i could that, but it just doesn't work

```<code>p<-ggplot(dat, aes(x=row.names(dat), y=dat$Tot_rate, fill=data[,2:ncol(dat)])) + geom_bar(stat="identity")+theme_minimal()+xlab("") + ylab("PC rate")+geom_abline(slope=0, intercept=90,  col = "red",lty=2) + theme(axis.text.x = element_text(angle = 90, hjust = 1))
p

</code>```

When i try the code above i get :

```<code>Don't know how to automatically pick scale for object of type data.frame. Defaulting to continuous.
Error: Aesthetics must be either length 1 or the same as the data (9): fill

</code>```

Can you please help ?
Thank you,
Liana

答:
```<code>library(reshape2)

dat=read.table(text = "Department Tot_rate   Type1   Type2   Type3
DPT1 72 50 12 10
DPT2 80 30 20 30
DPT3 92 54 14 24", header = TRUE)

long_dat <- dat[-2] %>% gather(type,number,Type1:Type3,-c("Department"))
</code>```

First I reshaped the data you had : I put the department in a column and reshaped your data from wide to long format (dropped tot_rate which isn't needed here).

```<code>p <- ggplot(data=long_dat,aes(x=Department,y=number,fill=type)) +
  geom_bar(position = "fill",stat = "identity")

p
</code>```

To scale the barplot in percantages, we use the position argument of geom_barset to position=fill.

ContentLicense: CC BY-SA 4.0

Body:
I'm trying to plot a stacked barplot of the rate of computer used in different departments with details on what type of PC in each bar( so that for each department type1+type2+type3=tot_rate) . I've got a dataframe that looks like this :

dat=read.table(text = "Tot_rate   Type1   Type2   Type3
DPT1 72 50 12 10
DPT2 80 30 20 30
DPT3 92 54 14 24", header = TRUE)

I tried to plot my barplot with raw data but now it's very important that i get the one with percentages and i can't seem to understand how i can do that.

This is how i thought i could that, but it just doesn't work

p<-ggplot(dat, aes(x=row.names(dat), y=dat$Tot_rate, fill=data[,2:ncol(dat)])) + geom_bar(stat="identity")+theme_minimal()+xlab("") + ylab("PC rate")+geom_abline(slope=0, intercept=90,  col = "red",lty=2) + theme(axis.text.x = element_text(angle = 90, hjust = 1))
p

When i try the code above i get :

Don't know how to automatically pick scale for object of type data.frame. Defaulting to continuous.
Error: Aesthetics must be either length 1 or the same as the data (9): fill

Can you please help ?
Thank you,
Liana

Body:
library(reshape2)

dat=read.table(text = "Department Tot_rate   Type1   Type2   Type3
DPT1 72 50 12 10
DPT2 80 30 20 30
DPT3 92 54 14 24", header = TRUE)

long_dat <- dat[-2] %>% gather(type,number,Type1:Type3,-c("Department"))

First I reshaped the data you had : I put the department in a column and reshaped your data from wide to long format (dropped tot_rate which isn't needed here).

p <- ggplot(data=long_dat,aes(x=Department,y=number,fill=type)) +
  geom_bar(position = "fill",stat = "identity")

p

To scale the barplot in percantages, we use the position argument of geom_barset to position=fill.


问:
Making a chat room in Rails hosted on Heroku
I'm trying to make a pretty basic chat room in rails. I'd love to use juggernaut/node.js but heroku doesn't currently support it. I'm thinking I should just use the heroku addon "pusher." Does anyone recommend this solution or any other alternatives?</p>

答:
I would suggest you to watch this http://railscasts.com/episodes/260-messaging-with-faye

It is a more Evented I/O way.

some successful implement in heroku , but it is advised to host it own self , according to this
http://groups.google.com/group/faye-users/browse_thread/thread/ade91b737e495bdf

ContentLicense: CC BY-SA 2.5

ContentLicense: CC BY-SA 3.0


问:
What is the difference between module and table in Lua?
Is a module just a table that can be required in Lua?

What is the real difference between the two?

答:
The module is a library. A collection of functions, and possibly some global data.

It is implemented using tables. The table would store the module's functions and/or data, but the module is not a table. It's a concept, a logical construct.

For a table to be considered a "module", it must participate in the modules system. To be registered/referenced within the modules system, be found when user require it, etc...


问:
Is there a way to use spring integration tcp udp adapter with tibco rv?
I have a legacy app which uses Tibco RV to publish and subscribe. I am rewriting the app to spring boot app. Now, I am trying to remove Tibco RV dependency. Is there a way to use spring integration UDP adapter to publish and subscribe to/from Tibco RV subjects.</p>

答:
You can use a standard UDP adapter to receive TibRV messages, but they will be presented to you just as byte buffers. You won't have an API to see the individual fields. How exactly Tibco chose to pack fields into the UDP buffer is part of a proprietary (unpublished) protocol.

So your best bet is probably to use the Tibrv Java API from your Spring project and port your publishers/subscribers one to one to Kafka. Another, smoother, transition might be to port all your Apps to JMS and then use a JMS Wrapper around TibRv and later Apache Kafka.


问:
Assign an image dynamically in flutter
How can I assign an image dynamically in flutter ? For example:

    final topContent = Stack(
      children: <Widget>[
        Container(
            padding: EdgeInsets.only(left: 10.0),
            height: MediaQuery.of(context).size.height * 0.5,
            decoration: new BoxDecoration(
              image: new DecorationImage(
                image: new AssetImage(lesson.imagePath),
                fit: BoxFit.cover,
              ),
            )),
        Container(
          height: MediaQuery.of(context).size.height * 0.5,
          padding: EdgeInsets.all(40.0),
          width: MediaQuery.of(context).size.width,
          decoration: BoxDecoration(color: Color.fromRGBO(58, 66, 86, .9)),
          child: SingleChildScrollView(
            controller: _scrollController,
            child: Center(
              child: topContentText,
            ),
          ),
        ),
        Positioned(
          left: 8.0,
          top: 60.0,
          child: InkWell(
            onTap: () {
              Navigator.pop(context);
            },
            child: Icon(Icons.arrow_back, color: Colors.white),
          ),
        )
      ],
    );
```

<p>Now the image at the start <code>lesson.imagePath</code> is what I want to change dynamically. I tried to use <code>setState()</code> but it gives me an error:</p>

<blockquote>
  <p>The expression here is a type of void and cannot be used</p>
</blockquote>

<pre class="lang-dart prettyprint-override"><code>image: setState ((){
 if (someCondition) {
 return new AssetImage(lesson.imagePath);
 }
}),
</code>```

答:
Your setState call is wrong! The most simple way is make your image as state of your widget and update this image inside a setState call. setState method does not returns nothing it just rebuilds your widget.

In your _WidgetState class you declare as member:

```<code>AssetImage _imageToShow;
</code>```

You can provider a initial image inside initState method.

```<code>@override
initState(){
   _imageToShow = AssetImage('youAssetImage');
}
</code>```

Your Container widget should be declared as:

```<code>Container(
            padding: EdgeInsets.only(left: 10.0),
            height: MediaQuery.of(context).size.height * 0.5,
            decoration: new BoxDecoration(
              image: new DecorationImage(
                image: _imageToShow,
                fit: BoxFit.cover,
              ),
            )),
 ),
</code>```

And to update your image with setState call you just need:

```<code>void updateImage() {
   setState ((){
      if (someCondition) {
        _imageToShow = new AssetImage(lesson.imagePath);
      }
    });
}
</code>```

But remember that something has to call updateImage method.

Title: Assign an image dynamically in flutter

Body:
How can I assign an image dynamically in flutter ? For example:

    final topContent = Stack(
      children: <Widget>[
        Container(
            padding: EdgeInsets.only(left: 10.0),
            height: MediaQuery.of(context).size.height * 0.5,
            decoration: new BoxDecoration(
              image: new DecorationImage(
                image: new AssetImage(lesson.imagePath),
                fit: BoxFit.cover,
              ),
            )),
        Container(
          height: MediaQuery.of(context).size.height * 0.5,
          padding: EdgeInsets.all(40.0),
          width: MediaQuery.of(context).size.width,
          decoration: BoxDecoration(color: Color.fromRGBO(58, 66, 86, .9)),
          child: SingleChildScrollView(
            controller: _scrollController,
            child: Center(
              child: topContentText,
            ),
          ),
        ),
        Positioned(
          left: 8.0,
          top: 60.0,
          child: InkWell(
            onTap: () {
              Navigator.pop(context);
            },
            child: Icon(Icons.arrow_back, color: Colors.white),
          ),
        )
      ],
    );

Now the image at the start lesson.imagePath is what I want to change dynamically. I tried to use setState() but it gives me an error:

The expression here is a type of void and cannot be used

image: setState ((){
 if (someCondition) {
 return new AssetImage(lesson.imagePath);
 }
}),

Body:
Your setState call is wrong! The most simple way is make your image as state of your widget and update this image inside a setState call. setState method does not returns nothing it just rebuilds your widget.

In your _WidgetState class you declare as member:

AssetImage _imageToShow;

You can provider a initial image inside initState method.

@override
initState(){
   _imageToShow = AssetImage('youAssetImage');
}

Your Container widget should be declared as:

Container(
            padding: EdgeInsets.only(left: 10.0),
            height: MediaQuery.of(context).size.height * 0.5,
            decoration: new BoxDecoration(
              image: new DecorationImage(
                image: _imageToShow,
                fit: BoxFit.cover,
              ),
            )),
 ),

And to update your image with setState call you just need:

void updateImage() {
   setState ((){
      if (someCondition) {
        _imageToShow = new AssetImage(lesson.imagePath);
      }
    });
}

But remember that something has to call updateImage method.


问:
How to execute event from another event?
I have a datagridview bound to Table. Table's columns are IDTransaction Amount TransactionType.

I want to change color of Amount cells based on TransactionType.

```<code>if (transactiontype==1)
    cell.backgroundcolor=red;
else
    cell.backgroundcolor=white;
</code>```

Where do you recommend to me to do it?(In which event)

Thank you

答:
For Windows Forms you would typically put this code in the CellFormatting Event</p>

```<code>private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{

 if (this.dataGridView1.Columns[e.ColumnIndex].Name = "TransactionType")
 {

    if (e.Value != null)
    {
        if (e.Value == 1)
        {
            e.CellStyle.BackColor = Color.Red;
        }
        else
        {
            e.CellStyle.BackColor = Color.White;
         }
     }
  }
}
</code>```

Body:
I have a datagridview bound to Table. Table's columns are IDTransaction Amount TransactionType.

I want to change color of Amount cells based on TransactionType.

if (transactiontype==1)
    cell.backgroundcolor=red;
else
    cell.backgroundcolor=white;

Where do you recommend to me to do it?(In which event)

Thank you

Body:
For Windows Forms you would typically put this code in the CellFormatting Event

private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{

 if (this.dataGridView1.Columns[e.ColumnIndex].Name = "TransactionType")
 {

    if (e.Value != null)
    {
        if (e.Value == 1)
        {
            e.CellStyle.BackColor = Color.Red;
        }
        else
        {
            e.CellStyle.BackColor = Color.White;
         }
     }
  }
}


问:
Two different partial view using asp.net core 2.2 ,java script model ajax
How to implement this using Ajax? i got data in JSON format but not appear on pop up model. i have two partcial view and one main controller
IT HAS NOT SHOW MODEL ONLY POP UP BLACK SCREEN
Thanks in advance

model :

```<code>public class OnboardModel
{
    //public string Userid { get; set; }

    public string NodeIdx { get; set; }

    public string Name{ get; set; }

    public string Address { get; set; }
}
</code>```

controller:  Dashboard/Getinfo

```<code> public IActionResult Getxyzinfo(string nodeid = "7", string userid = "1" ,   string languageid = "1")
        {
            var RecentInfo = Buildxyzinfo(nodeidx, useridx, languageidx);

            return Json(new { success = true, recentinfoData = RecentInfo });
        }
</code>```

html _index.cshtml  one partial view

How to create new partial with call using ajax

how to call partial view

JavaScript :

```<code>  <script type="text/javascript">
                            $(document).ready(function () {
                                $('#showGoogle').click(function () {
                                    var url = $('#myModal').data('url');

                                    $.get(url, function (data) {
                                        $('#googleContainer').html(data);

                                        $('#myModal').modal('show');

                                    });
                                });
                            });
                        </script>
</code>```

_index.cshtml partcial view

```<code>                            <div id='googleContainer'>
                            </div>
                        </div>

                        <a href="#" id="showGoogle">Invitation Business</a>
                    </div>
</code>```

other _getinfo.cshtml  partial view

```<code><div class="container">
    <!-- Modal -->
    <div class="modal fade" id="googleContainer" role="dialog">
        <div class="modal-dialog">
            <!-- Modal content-->
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal">
                        ×
                    </button>
                    <h4 class="modal-title">
                        Serial Numbers
                    @*</h4>*@
                </div>
                <div class="modal-body">
                    <span id="test"></span>

    <p>Some text in the modal.</p>
                         @Html.LabelFor(model => model.Googlename, new { @class = "control-label col-md-2" })
 <span class"control-label col-md-3">@Html.DisplayFor(model => model.xyzitem.Googlename)</span>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">
                        Close
                    </button>
                </div>
            </div>
        </div>
    </div>
</div>
</code>```

答:
```<code>$(document).on("click", "#showmodal", function (nodeIdx) {

                $.ajax({
                    async: true,
                    url: '@Url.Action("Getxyzinfo", "Dashboard")',
                    data: { nodeIdx: nodeIdx },
                    type: 'GET',
                    traditional: true,
                    success: function (response) {
                        $("#googlecontanier").html(response.recentInfoData);

                        $("#myModal").modal("show");
                    },
                    error: function (xhr, status, error) {
                        console.log("Result: " + status + " " + error + " " + xhr.status + " " + xhr.statusText)
                    }
                });
            });
</code>```

Body:
How to implement this using Ajax? i got data in JSON format but not appear on pop up model. i have two partcial view and one main controller
IT HAS NOT SHOW MODEL ONLY POP UP BLACK SCREEN
Thanks in advance

model :

public class OnboardModel
{
    //public string Userid { get; set; }

    public string NodeIdx { get; set; }

    public string Name{ get; set; }

    public string Address { get; set; }
}

controller:  Dashboard/Getinfo

 public IActionResult Getxyzinfo(string nodeid = "7", string userid = "1" ,   string languageid = "1")
        {
            var RecentInfo = Buildxyzinfo(nodeidx, useridx, languageidx);

            return Json(new { success = true, recentinfoData = RecentInfo });
        }

html _index.cshtml  one partial view

How to create new partial with call using ajax

how to call partial view

JavaScript :

_index.cshtml partcial view

                        Invitation Business

other _getinfo.cshtml  partial view

                    <button type="button" class="close" data-dismiss="modal">
                        ×
                    </button>

                        Serial Numbers
                    @*
*@

Some text in the modal.

                         @Html.LabelFor(model => model.Googlename, new { @class = "control-label col-md-2" })
 @Html.DisplayFor(model => model.xyzitem.Googlename)

                    <button type="button" class="btn btn-default" data-dismiss="modal">
                        Close
                    </button>


问:
Error: unable to spawn process (Argument list too long) Xcode 10.1

Error Log:
  PhaseScriptExecution [CP]\ Check\ Pods\ Manifest.lock /Users/../Script-A..B8.sh (in target: C..r)
      cd /Projects/...
      /bin/sh -c /Users/../Script-A..B8.sh
  error: unable to spawn process (Argument list too long)**

I am getting this error while creating an Archive from Xcode (10.1).  My build succeeds. I encountered this error after installing below mentioned pods,

pod 'Firebase/Analytics'

pod 'Firebase/Messaging'

My Xcode project is a multi target and multi configuration project managed using xconfig file.

I tried disintegrating, installing, updating pod again and again, but no luck.

答: Enable Legacy System for workspace setting


问:
Create an array out of several arrays
I have an array containing namespace information:

```<code>$array = [
    ['App', 'Classes', 'Auth'],
    ['App', 'Classes', 'Auth'],
    ['App', 'Classes', 'Middleware'],
    ['App', 'Classes', 'Phone'],
    ['App', 'Classes', 'Auth'],
    ['App', 'Mail'],
    ['App', 'Mail', 'Sender'],
    ['App', 'Box'],
];
</code>```

Now I want to build a single array or object that should show the namespace information in an hirachic way:

```<code>$result = [
    ['App' =>
        ['Classes' =>
            [
                'Auth',
                'Middleware',
                'Phone',
            ]
        ],
        ['Mail' =>
            ['Sender']
        ],
        ['Box'] => []
    ]
]
</code>```

I have tried some recursive functions, but all I get is a flat array...

```<code>private function createNamespaceHirachy( $namespaces ) {

        foreach ($namespaces as $index => $namespace) {
            $namespaces[$namespace] = [];
            $namespaces[$namespace] = $this->createNamespaceHirachy($namespaces[$namespace]);
        }

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

Sorry, it may be much more simple, but I'm brainstuck :-/

答:
```<code><?php

$array = [
    ['App', 'Classes', 'Auth'],
    ['App', 'Classes', 'Auth'],
    ['App', 'Classes', 'Middleware'],
    ['App', 'Classes', 'Phone'],
    ['App', 'Classes', 'Auth'],
    ['App', 'Mail'],
    ['App', 'Mail', 'Sender'],
    ['App', 'Box'],
];

$hierarchy = [];

foreach($array as $each_data){
    $curr_hierarchy = &$hierarchy;
    foreach($each_data as $each_namespace){
        if(!isset($curr_hierarchy[$each_namespace])){
            $curr_hierarchy[$each_namespace] = [];
        }

        $curr_hierarchy = &$curr_hierarchy[$each_namespace];
    }
}

print_r($hierarchy);
</code>```

Demo: https://3v4l.org/AVVZI

We loop over each hierarchical data in $array one by one.

We initialize the final resulting array as $hierarchy in the above code.

Now, inside the inner foreach loop, we maintain a current hierarchy stage. In other words, $curr_hierarchy contains the current level we are in.

As we loop over inside the inner foreach loop, if the current stage does not have the namespace as it's key, we assign it and go one level further deep by passing it as the new current hierarchy.

Note that the pass by reference & is necessary to reflect changes overall to the array, else, it creates a new clone keeping your final array empty.

You may also notice the child elements itself being an array as well. I think that's fine for your current context, but do let me know if that wasn't what you desired.

Title: Create an array out of several arrays

Body:
I have an array containing namespace information:

$array = [
    ['App', 'Classes', 'Auth'],
    ['App', 'Classes', 'Auth'],
    ['App', 'Classes', 'Middleware'],
    ['App', 'Classes', 'Phone'],
    ['App', 'Classes', 'Auth'],
    ['App', 'Mail'],
    ['App', 'Mail', 'Sender'],
    ['App', 'Box'],
];

Now I want to build a single array or object that should show the namespace information in an hirachic way:

$result = [
    ['App' =>
        ['Classes' =>
            [
                'Auth',
                'Middleware',
                'Phone',
            ]
        ],
        ['Mail' =>
            ['Sender']
        ],
        ['Box'] => []
    ]
]

I have tried some recursive functions, but all I get is a flat array...

private function createNamespaceHirachy( $namespaces ) {

        foreach ($namespaces as $index => $namespace) {
            $namespaces[$namespace] = [];
            $namespaces[$namespace] = $this->createNamespaceHirachy($namespaces[$namespace]);
        }

    return $namespaces;
}

Sorry, it may be much more simple, but I'm brainstuck :-/

Body:
<?php

$array = [
    ['App', 'Classes', 'Auth'],
    ['App', 'Classes', 'Auth'],
    ['App', 'Classes', 'Middleware'],
    ['App', 'Classes', 'Phone'],
    ['App', 'Classes', 'Auth'],
    ['App', 'Mail'],
    ['App', 'Mail', 'Sender'],
    ['App', 'Box'],
];

$hierarchy = [];

foreach($array as $each_data){
    $curr_hierarchy = &$hierarchy;
    foreach($each_data as $each_namespace){
        if(!isset($curr_hierarchy[$each_namespace])){
            $curr_hierarchy[$each_namespace] = [];
        }

        $curr_hierarchy = &$curr_hierarchy[$each_namespace];
    }
}

print_r($hierarchy);

Demo: https://3v4l.org/AVVZI

We loop over each hierarchical data in $array one by one.

We initialize the final resulting array as $hierarchy in the above code.

Now, inside the inner foreach loop, we maintain a current hierarchy stage. In other words, $curr_hierarchy contains the current level we are in.

As we loop over inside the inner foreach loop, if the current stage does not have the namespace as it's key, we assign it and go one level further deep by passing it as the new current hierarchy.

Note that the pass by reference & is necessary to reflect changes overall to the array, else, it creates a new clone keeping your final array empty.

You may also notice the child elements itself being an array as well. I think that's fine for your current context, but do let me know if that wasn't what you desired.


问:
How to extract lower and upper bound in numeric format from a confidence interval string?
Suppose a vector including some confidence intervals as below

```<code>confint <- c("[0.741 ; 2.233]", "[263.917 ; 402.154]", "[12.788 ; 17.975]", "[0.680 ; 2.450]", "[0.650 ; 1.827]", "[0.719 ; 2.190]")
</code>```

I want to have two new vectors one including the lower Limits in numeric format as

```<code>lower <- c(0.741, 263.917, 12.788, 0.680, 0.650 , 0.719)
</code>```

and othe including the upper Limits in numeric format like

```<code>upper <- c(2.233, 402.154, 17.975, 2.450, 1.827, 2.190)
</code>```

答:
A different base R possibility could be:

```<code>sapply(strsplit(confint, " ; ", fixed = TRUE), function(x) gsub("[^0-9.-]+", "\\1", x) [1])
sapply(strsplit(confint, " ; ", fixed = TRUE), function(x) gsub("[^0-9.-]+", "\\1", x) [2])

[1] "0.741"   "263.917" "12.788"  "0.680"   "0.650"   "0.719"
[1] "2.233"   "402.154" "17.975"  "2.450"   "1.827"   "2.190"
</code>```

If you need it as a numeric vector:

```<code>sapply(strsplit(confint, " ; ", fixed = TRUE), function(x) as.numeric(gsub("[^0-9.-]+", "\\1", x)) [1])
sapply(strsplit(confint, " ; ", fixed = TRUE), function(x) as.numeric(gsub("[^0-9.-]+", "\\1", x)) [2])
</code>```

Body:
Suppose a vector including some confidence intervals as below

confint <- c("[0.741 ; 2.233]", "[263.917 ; 402.154]", "[12.788 ; 17.975]", "[0.680 ; 2.450]", "[0.650 ; 1.827]", "[0.719 ; 2.190]")

I want to have two new vectors one including the lower Limits in numeric format as

lower <- c(0.741, 263.917, 12.788, 0.680, 0.650 , 0.719)

and othe including the upper Limits in numeric format like

upper <- c(2.233, 402.154, 17.975, 2.450, 1.827, 2.190)

Body:
A different base R possibility could be:

sapply(strsplit(confint, " ; ", fixed = TRUE), function(x) gsub("[^0-9.-]+", "\\1", x) [1])
sapply(strsplit(confint, " ; ", fixed = TRUE), function(x) gsub("[^0-9.-]+", "\\1", x) [2])

[1] "0.741"   "263.917" "12.788"  "0.680"   "0.650"   "0.719"
[1] "2.233"   "402.154" "17.975"  "2.450"   "1.827"   "2.190"

If you need it as a numeric vector:

sapply(strsplit(confint, " ; ", fixed = TRUE), function(x) as.numeric(gsub("[^0-9.-]+", "\\1", x)) [1])
sapply(strsplit(confint, " ; ", fixed = TRUE), function(x) as.numeric(gsub("[^0-9.-]+", "\\1", x)) [2])


问:
Get website's contents from a list of URLs in a text-file
I have a list of URLs in a text file as below:

File URL.txt

```<code>https://url2.html
https://url3.html
...
https://urln.html
</code>```

I want to get content of those URLs into a text file line by line as shown below

Expected file Content.txt:

```<code>Content of web from url2.html
Content of web from url3.html
...
Content of web from urln.html
</code>```

Please help me to find a solution for my problem, can I use Python or Java code for this.

Thank you for consideration!

答:
Thank you everyone for helping, I got an answer from my friend, this is what exactly what I want.

I am happy to receive your supports
Best regards.

```<code>import requests, sys, webbrowser, bs4
import codecs

def get_content(link):
  page = requests.get(link)
  soup = bs4.BeautifulSoup(page.content, 'html.parser')
  all_p = soup.find_all('p')
  content = ''
  for p in all_p:
    content += p.get_text().strip('\n')
  return content

in_path = "link.txt"
out_path = "outputData.txt"

with open(in_path, 'r') as fin:
  links = fin.read().splitlines()
with open(out_path, 'w') as fout:
  for i, link in enumerate(links):
     fout.write(get_content(link) + '\n')
</code>```

Body:
I have a list of URLs in a text file as below:

File URL.txt

https://url2.html
https://url3.html
...
https://urln.html

I want to get content of those URLs into a text file line by line as shown below

Expected file Content.txt:

Content of web from url2.html
Content of web from url3.html
...
Content of web from urln.html

Please help me to find a solution for my problem, can I use Python or Java code for this.

Thank you for consideration!

Body:
Thank you everyone for helping, I got an answer from my friend, this is what exactly what I want.

I am happy to receive your supports
Best regards.

import requests, sys, webbrowser, bs4
import codecs

def get_content(link):
  page = requests.get(link)
  soup = bs4.BeautifulSoup(page.content, 'html.parser')
  all_p = soup.find_all('p')
  content = ''
  for p in all_p:
    content += p.get_text().strip('\n')
  return content

in_path = "link.txt"
out_path = "outputData.txt"

with open(in_path, 'r') as fin:
  links = fin.read().splitlines()
with open(out_path, 'w') as fout:
  for i, link in enumerate(links):
     fout.write(get_content(link) + '\n')


问:
how to detect if a file operation is currently done on a file on linux
How can i detect if a file is open and a file operation is being done on it by another process on linux by using c or c++? I know lsof lists all open files but i dont how it gets that information.

Thx

答: Why don't you look at the lsof source code? It's probably a bit intimidating, but I'm sure you can isolate the two or three interesting syscalls that give it all the relevant information.</p>


问:
Detect when UIView changes size during animation for shadow to move
In a UIView subclass, I have the following property override for override var bounds: CGRect:

```<code>@IBDesignable
class GEView: UIView {

    private var shadowView: UIView? {
        didSet {
            guard let superview = superview else { return }
            guard let shadowView = self.shadowView else { return }

            // Add the shadow to the superview, as the shadow cannot
            // also allow rounded corners simultaneously
            superview.addSubview(shadowView)
            shadowView.layer.zPosition = layer.zPosition - 1
            shadowView.edges(to: self)
        }
    }

    // CALLED WHEN SETTING @IBInspectable PROPERTIES
    /// Creates a shadow if one has not yet been created.
    private func createShadowIfNeeded() {
        guard shadowView == nil else { return }

        shadowView = UIView()

        shadowView?.layer.shadowPath = UIBezierPath(roundedRect:    bounds,
                                                    cornerRadius:   cornerRadius).cgPath
        shadowView?.layer.shouldRasterize = true
    }

    // THE PROPERTY TO ATTEMPT THE SHADOW MOVING
    override var bounds: CGRect {
        didSet {
            shadowView?.layer.shadowPath = UIBezierPath(roundedRect:    bounds,
                                                        cornerRadius:   cornerRadius).cgPath
        }
    }
}
</code>```

The attempt was to re-draw the shadow many times as the bounds change when the view constraints are animated (leading to the view changing size).

However, the bounds change instantly, as the animation is just visual. Is there a way I can get this shadow to follow the view as it animates? It would be better if this can be in the UIView subclass instead of the animation block, which is UIView.animate.

Here is what the problem looks like:

I want the shadow to follow along whilst the view moves. At the end of the gif, the shadow position and view position are correct, because the override ignores animations and pretends it has already animated.

How can I fix this?

答:
Try updating the shadow in layoutSubviews() of CustomView, i.e.

```<code>class CustomView: UIView {
    override func layoutSubviews() {
        super.layoutSubviews()

        self.layer.shadowRadius = 10.0
        self.layer.shadowOpacity = 1.0
        self.layer.shadowColor = UIColor.black.cgColor

        let oldPath = self.layer.shadowPath
        let newPath = UIBezierPath(roundedRect: self.bounds, cornerRadius: 0.0).cgPath
        if oldPath != nil {
            let shadowPathAnimation: CABasicAnimation = CABasicAnimation(keyPath: "shadowPath")
            shadowPathAnimation.fromValue = oldPath
            shadowPathAnimation.toValue = newPath
            self.layer.add(shadowPathAnimation, forKey: "shadowAnimation")
            self.layer.shadowPath = newPath
        }
    }
}

class ViewController: UIViewController {
    @IBOutlet weak var customView: CustomView!
    @IBOutlet weak var trailingConstraint: NSLayoutConstraint!

    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)

        UIView.animate(withDuration: 3.0) {
            self.trailingConstraint.constant = 200.0
            self.view.layoutIfNeeded()
        }
    }
}
</code>```

Body:
In a UIView subclass, I have the following property override for override var bounds: CGRect:

@IBDesignable
class GEView: UIView {

    private var shadowView: UIView? {
        didSet {
            guard let superview = superview else { return }
            guard let shadowView = self.shadowView else { return }

            // Add the shadow to the superview, as the shadow cannot
            // also allow rounded corners simultaneously
            superview.addSubview(shadowView)
            shadowView.layer.zPosition = layer.zPosition - 1
            shadowView.edges(to: self)
        }
    }

    // CALLED WHEN SETTING @IBInspectable PROPERTIES
    /// Creates a shadow if one has not yet been created.
    private func createShadowIfNeeded() {
        guard shadowView == nil else { return }

        shadowView = UIView()

        shadowView?.layer.shadowPath = UIBezierPath(roundedRect:    bounds,
                                                    cornerRadius:   cornerRadius).cgPath
        shadowView?.layer.shouldRasterize = true
    }

    // THE PROPERTY TO ATTEMPT THE SHADOW MOVING
    override var bounds: CGRect {
        didSet {
            shadowView?.layer.shadowPath = UIBezierPath(roundedRect:    bounds,
                                                        cornerRadius:   cornerRadius).cgPath
        }
    }
}

The attempt was to re-draw the shadow many times as the bounds change when the view constraints are animated (leading to the view changing size).

However, the bounds change instantly, as the animation is just visual. Is there a way I can get this shadow to follow the view as it animates? It would be better if this can be in the UIView subclass instead of the animation block, which is UIView.animate.

Here is what the problem looks like:

I want the shadow to follow along whilst the view moves. At the end of the gif, the shadow position and view position are correct, because the override ignores animations and pretends it has already animated.

How can I fix this?

Body:
Try updating the shadow in layoutSubviews() of CustomView, i.e.

class CustomView: UIView {
    override func layoutSubviews() {
        super.layoutSubviews()

        self.layer.shadowRadius = 10.0
        self.layer.shadowOpacity = 1.0
        self.layer.shadowColor = UIColor.black.cgColor

        let oldPath = self.layer.shadowPath
        let newPath = UIBezierPath(roundedRect: self.bounds, cornerRadius: 0.0).cgPath
        if oldPath != nil {
            let shadowPathAnimation: CABasicAnimation = CABasicAnimation(keyPath: "shadowPath")
            shadowPathAnimation.fromValue = oldPath
            shadowPathAnimation.toValue = newPath
            self.layer.add(shadowPathAnimation, forKey: "shadowAnimation")
            self.layer.shadowPath = newPath
        }
    }
}

class ViewController: UIViewController {
    @IBOutlet weak var customView: CustomView!
    @IBOutlet weak var trailingConstraint: NSLayoutConstraint!

    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)

        UIView.animate(withDuration: 3.0) {
            self.trailingConstraint.constant = 200.0
            self.view.layoutIfNeeded()
        }
    }
}


问:
CKEditor UI Space not being defined
editor.ui.space is being set to null when I try to run the ckeditor function.

Im pulling in my content with ajax, on success or done, I then insert the html into the dom, then straight after that I try to bind my editors with default options.

Example:

```<code>$.get('url', function(data){
    $('body').html(data.content);
    $('textarea.content').ckeditor();
});
</code>```

This dies straight away because ui-spaces aren't being set. I have no idea why, but if I set a timeout, of say 500, and the run the ckeditor function, it works fine.

```<code>$.get('url', function(data){
    $('body').html(data.content);
    var t = setTimeout(function() {
        // This does work fine with no problems, why?
        $('textarea.content').ckeditor();
        clearTimeout(t);
    }, 500);
});
</code>```

Why does this not work after it's inserted into the dom...

答:
I had the same problem today.

In my case I just change:

```<code><script src="{{ asset('js/app.js') }}"defer></script>
</code>```

to:

```<code><script src="{{ asset('js/app.js') }}"></script>
</code>```

Title: CKEditor UI Space not being defined

Body:
editor.ui.space is being set to null when I try to run the ckeditor function.

Im pulling in my content with ajax, on success or done, I then insert the html into the dom, then straight after that I try to bind my editors with default options.

Example:

$.get('url', function(data){
    $('body').html(data.content);
    $('textarea.content').ckeditor();
});

This dies straight away because ui-spaces aren't being set. I have no idea why, but if I set a timeout, of say 500, and the run the ckeditor function, it works fine.

$.get('url', function(data){
    $('body').html(data.content);
    var t = setTimeout(function() {
        // This does work fine with no problems, why?
        $('textarea.content').ckeditor();
        clearTimeout(t);
    }, 500);
});

Why does this not work after it's inserted into the dom...

Body:
I had the same problem today.

In my case I just change:

<script src="{{ asset('js/app.js') }}"defer></script>

to:

<script src="{{ asset('js/app.js') }}"></script>


问:
Find all duplicate ids and add unique key
how to find all duplicate ids when the page is relaod:

Let's say we have html like this:

```<code><input type="radio" id="name" />
<input type="radio" id="name" />
<input type="radio" id="name" />
<input type="radio" id="last" />
<input type="radio" id="last" />
</code>```

The idea is to find duplicate ids and add +1 or something like that:

What I want to achieve is:

```<code><input type="radio" id="name1" />
<input type="radio" id="name2" />
<input type="radio" id="name3" />
<input type="radio" id="last1" />
<input type="radio" id="last2" />
</code>```

JS

```<code> $('[id]').each(function(){
  var ids = $('[id="'+this.id+'"]');
  if(ids.length>1 && ids[0]==this)
      $(this).attr('id', $(this).attr('id') + i);
 });
</code>```

Any ideas? Thank you all.

答:
I would strongly recommend you serve valid HTML rather than manipulating Ids.

However, You are were close as attribute value selector may return multiple elements, You need to iterate the matching elements

var handled = [];
$('[id]').each(function() {
  if (handled.includes(this.id)) {
    return;
  }
  var elemets = $('[id="' + this.id + '"]');
  if (elemets.length > 1) {
    handled.push(elemets.attr('id'));
    elemets.attr('id', function(index, v) {
      return v + (index+1);
    });
  }
});

//For Readablity
$('[id]').each(function(){
  console.log(this.outerHTML)
})```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type="radio" id="name" />
<input type="radio" id="name" />
<input type="radio" id="name" />
<input type="radio" id="last" />
<input type="radio" id="last" /></code>```

Body:
how to find all duplicate ids when the page is relaod:

Let's say we have html like this:

<input type="radio" id="name" />
<input type="radio" id="name" />
<input type="radio" id="name" />
<input type="radio" id="last" />
<input type="radio" id="last" />

The idea is to find duplicate ids and add +1 or something like that:

What I want to achieve is:

<input type="radio" id="name1" />
<input type="radio" id="name2" />
<input type="radio" id="name3" />
<input type="radio" id="last1" />
<input type="radio" id="last2" />

JS

 $('[id]').each(function(){
  var ids = $('[id="'+this.id+'"]');
  if(ids.length>1 && ids[0]==this)
      $(this).attr('id', $(this).attr('id') + i);
 });

Any ideas? Thank you all.

Body:
I would strongly recommend you serve valid HTML rather than manipulating Ids.

However, You are were close as attribute value selector may return multiple elements, You need to iterate the matching elements

var handled = [];
$('[id]').each(function() {
  if (handled.includes(this.id)) {
    return;
  }
  var elemets = $('[id="' + this.id + '"]');
  if (elemets.length > 1) {
    handled.push(elemets.attr('id'));
    elemets.attr('id', function(index, v) {
      return v + (index+1);
    });
  }
});

//For Readablity
$('[id]').each(function(){
  console.log(this.outerHTML)
})

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type="radio" id="name" />
<input type="radio" id="name" />
<input type="radio" id="name" />
<input type="radio" id="last" />
<input type="radio" id="last" />


问:
Creating pedestrians at random after every simulation in a given area
I would like to know if it is possible to create a random distribution of pedestrians at a given area each time I begin my simulation?

enter image description here

答:
Create a Collection named allLocations of type AreaNode that contains all of your possible initialisation areas:

Use a process flow like the following with a PedSource:

Set the Area property in the PedSource to the following:

allLocations.get(uniform_discr(0, allLocations.size()-1))
```

This code randomly assigns one of the areas in the list to each agent as a start. You can modify this to fit your needs, with other distributions for example.

You can now see how Agents pop up randomly at the different locations:

The example model can be run and downloaded here.

Body:
Create a Collection named allLocations of type AreaNode that contains all of your possible initialisation areas:

Use a process flow like the following with a PedSource:

Set the Area property in the PedSource to the following:

allLocations.get(uniform_discr(0, allLocations.size()-1))

This code randomly assigns one of the areas in the list to each agent as a start. You can modify this to fit your needs, with other distributions for example.

You can now see how Agents pop up randomly at the different locations:

The example model can be run and downloaded here.


问:
In jQuery uploadify show the images as thumbnails BEFORE the upload by the user's filepath
I'd like to make an uploadify upload to my server, and make thumbnails from the user's images on the fly.

I just need the filepath for each upload. However the only parameter i found in the Javascript is the substringed filename.

Instead of ohmygoditsantaclaus.jpg I want the full path like C:/Etc/Etcetera/Daddy/ohmygoditsantaclaus.jpg. If i have this, i can make a div container easily put the image to it, and resize it with CSS.

Thanks for the help. PS: I used Uploadify v1.6.2

Here is the jQuery Uploadify v.1.6.2 and the Uploader.FLA i currently using.

答:
You can't access the full path with either JavaScript or Flash, like:

C:/Etc/Etcetera/Daddy/ohmygoditsantaclaus.jpg

It's a security thing.

Also, even if you could, you sure as heck can't do the next thing you want to do:

If i have this, i can make a div
  container easily put the image to it,
  and resize it with CSS.

You can't access random images on the user's hard disk using a file:// URI and place them on your webpage.

You can instead use something like http://www.plupload.com/ - once the user has selected their images to upload, you can resize images client side.

If you want to show thumbnails before uploading, I know Flash can do it. I'm not sure if anything else can.


问:
Render an ActiveReccord:relationship with specific cat value
My title is not really clear, I don't know how to formulate it, if you have suggestions, I can edit it.

I would like to render all the missions form my user_facturation. But I don't know how to do it with current db structure.

My relations :

```<code>mission has_many :mission_facturations
mission_facturation belongs_to :mission
</code>```

Mission_facturation can be linked with many element facturation (user, partner, etc ...). So to save this relation I'm saving a fact_cat and a fact_id column. (A little bit has polymorphic relations)

Example, if I want to link my mission_facturation with the first user_facturation, I reccord :

```<code>mission_facturation.update(fact_cat: 8, fact_id: UserFacturation.first.id)
</code>```

Now, I would like to access to all the missions directly from my user_facturation model. Initially, I was using that method into the model user_facturation.rb

```<code>def missions
  MissionFacturation.where(fact_cat: 8, fact_id: self.id).where.not(mission_id: nil).map(&:mission)
end
</code>```

But this is not rendering an ActiveReccord::Relation, so when I use it for a loop, it's not working well

Do you have any solutions to render a collection of missions into my user_facturation model ?

答:
Start the query with the Mission model, something like this:

```<code>Mission.joins(:mission_facturations).where(mission_facturations: {fact_cat: 8, fact_id: self.id)
</code>```

Or you can even set a relationship on the User class so AR handles the joins for you:

```<code>has_many :mission_facturations, -> { where(fact_cat: 8) }, :foreign_key => "fact_id"
has_many :missions, through: :mission_facturations
</code>```

Body:
My title is not really clear, I don't know how to formulate it, if you have suggestions, I can edit it.

I would like to render all the missions form my user_facturation. But I don't know how to do it with current db structure.

My relations :

mission has_many :mission_facturations
mission_facturation belongs_to :mission

Mission_facturation can be linked with many element facturation (user, partner, etc ...). So to save this relation I'm saving a fact_cat and a fact_id column. (A little bit has polymorphic relations)

Example, if I want to link my mission_facturation with the first user_facturation, I reccord :

mission_facturation.update(fact_cat: 8, fact_id: UserFacturation.first.id)

Now, I would like to access to all the missions directly from my user_facturation model. Initially, I was using that method into the model user_facturation.rb

def missions
  MissionFacturation.where(fact_cat: 8, fact_id: self.id).where.not(mission_id: nil).map(&:mission)
end

But this is not rendering an ActiveReccord::Relation, so when I use it for a loop, it's not working well

Do you have any solutions to render a collection of missions into my user_facturation model ?

Body:
Start the query with the Mission model, something like this:

Mission.joins(:mission_facturations).where(mission_facturations: {fact_cat: 8, fact_id: self.id)

Or you can even set a relationship on the User class so AR handles the joins for you:

has_many :mission_facturations, -> { where(fact_cat: 8) }, :foreign_key => "fact_id"
has_many :missions, through: :mission_facturations


答:
Here is snippet for your scenario

```<code>$results = json_decode(json_encode($array)); // converting to object to play
$tree    = null;
foreach ($results as $result) {
    // checking first getting address of it to play
    $thisref                          = &$refs->{$result[0]};
    $tree->{$result[0]}               = &$thisref;
    // checking for level 1 if not empty
    $thisref                          = &$refs->{$result[1]};
    $tree->{$result[0]}->{$result[1]} = &$thisref;
    // checking for level 2 if not empty
    if (!empty($result[2])) {
        $thisref                                        = &$refs->{$result[2]};
        $refs->{$result[0]}->{$result[1]}[] = $result[2];//&$thisref;
        $refs->{$result[0]}->{$result[1]} = array_unique($refs->{$result[0]}->{$result[1]});
    }

}
// finally converting back to array
print_r(json_decode(json_encode($tree), true));
</code>```

Working demo.

Title: Create an array out of several arrays

Body:
Here is snippet for your scenario

$results = json_decode(json_encode($array)); // converting to object to play
$tree    = null;
foreach ($results as $result) {
    // checking first getting address of it to play
    $thisref                          = &$refs->{$result[0]};
    $tree->{$result[0]}               = &$thisref;
    // checking for level 1 if not empty
    $thisref                          = &$refs->{$result[1]};
    $tree->{$result[0]}->{$result[1]} = &$thisref;
    // checking for level 2 if not empty
    if (!empty($result[2])) {
        $thisref                                        = &$refs->{$result[2]};
        $refs->{$result[0]}->{$result[1]}[] = $result[2];//&$thisref;
        $refs->{$result[0]}->{$result[1]} = array_unique($refs->{$result[0]}->{$result[1]});
    }

}
// finally converting back to array
print_r(json_decode(json_encode($tree), true));

Working demo.


问:
What to watch out for when converting a std::string to a char* for C function?
I have read many posts asking the question on how to convert a C++ std::string or const std::string& to a char* to pass it to a C function and it seems there is quite a few caveat's in regards to doing this.  One has to beware about the string being contiguous and a lot of other things.  The point is that I've never really understood all the points one needs to be aware of and why?

I wondered if someone could sum up the caveats and downfalls about doing a conversion from a std::string to a char* that is needed to pass to a C function?

This when the std::string is a const reference and when it's just a non-const reference, and when the C function will alter the char* and when it will not alter it.

答:
When the C function does not alter the string behind the char*, you can use std::string::c_str() for both const and non-const std::string instances.  Ideally it would be a const char*,  but if it's not (because of a legacy API) you may legally use a const_cast.
But you may only use the pointer from c_str() as long as you're not modifying the string!

When the C function does alter the string behind the char*, your only safe and portable way to use the std::string is to copy it to a temporary buffer yourself (for example from c_str())! Make sure you free the temporary memory afterwards -- or use std::vector, which is guaranteed to have continuous memory.


问:
Python : Joining separated numeric characters in text but leave alphabetic texts
I've some sample strings like :

```<code>sample_lt1 = 'CANCEL Bitcoin kev 1 96 35 2 0 5 7 5 6'
sample_lt2 = 'CANCEL Bitcoln key 1 6 3 5 20 5 7 56 Cash 2 9 00'
sample_lt3 = 'CANCEL Bitcein key 0 1 5 0 0 4 4 1 6 Cash '
</code>```

I'm trying to join the numbers separated by spaces in the string but leave the chunk of alphabetic characters. The desired output for those sample inputs would be :

```<code>sample_out1 = 'CANCEL Bitcoin kev 19635205756'
sample_out2 = 'CANCEL Bitcoln key 1635205756 Cash 2900'
sample_out3 = 'CANCEL Bitcein key 015004416 Cash ' # Removal of last space is ok.
</code>```

Till now, I have done this :

```<code>def ReForm(lt):
    lts = lt.split()
    c = 0
    new = []
    temp = []
    while c<len(lts):
        if lts[c].isnumeric():
            temp.append(lts[c])
        else:
            if temp:
                s = ''.join(temp)
                new.append(s)
            new.append(lts[c])
        c += 1
    ret = ' '.join(new)
    return ret
</code>```

The output given by my code is :

```<code>CANCEL Bitcoin kev
CANCEL Bitcoln key 1635205756 Cash
CANCEL Bitcein key 015004416 Cash
</code>```

It fails to join the space separated numbers in the first and second case. What am I doing wrong?

答:
The following fixes your program:

```<code>def ReForm(lt):
    lts = lt.split()
    c = 0
    new = []
    temp = []
    while c<len(lts):
        if lts[c].isnumeric():
            temp.append(lts[c])
        else:
            if temp:
                s = ''.join(temp)
                new.append(s)
                temp = []
            new.append(lts[c])
        c += 1
    if temp:
        s = ''.join(temp)
        new.append(s)
    ret = ' '.join(new)
    return ret
</code>```

What your loop was missing was a fallback case for when the last character was a number. In that case your temp list was not appended to new.
Another thing that was missing was catching the case where temp was added to the overall string but the string would continue with different content. This can be achieved by reinitializing temp in the loop.

Body:
I've some sample strings like :

sample_lt1 = 'CANCEL Bitcoin kev 1 96 35 2 0 5 7 5 6'
sample_lt2 = 'CANCEL Bitcoln key 1 6 3 5 20 5 7 56 Cash 2 9 00'
sample_lt3 = 'CANCEL Bitcein key 0 1 5 0 0 4 4 1 6 Cash '

I'm trying to join the numbers separated by spaces in the string but leave the chunk of alphabetic characters. The desired output for those sample inputs would be :

sample_out1 = 'CANCEL Bitcoin kev 19635205756'
sample_out2 = 'CANCEL Bitcoln key 1635205756 Cash 2900'
sample_out3 = 'CANCEL Bitcein key 015004416 Cash ' # Removal of last space is ok.

Till now, I have done this :

def ReForm(lt):
    lts = lt.split()
    c = 0
    new = []
    temp = []
    while c<len(lts):
        if lts[c].isnumeric():
            temp.append(lts[c])
        else:
            if temp:
                s = ''.join(temp)
                new.append(s)
            new.append(lts[c])
        c += 1
    ret = ' '.join(new)
    return ret

The output given by my code is :

CANCEL Bitcoin kev
CANCEL Bitcoln key 1635205756 Cash
CANCEL Bitcein key 015004416 Cash

It fails to join the space separated numbers in the first and second case. What am I doing wrong?

Body:
The following fixes your program:

def ReForm(lt):
    lts = lt.split()
    c = 0
    new = []
    temp = []
    while c<len(lts):
        if lts[c].isnumeric():
            temp.append(lts[c])
        else:
            if temp:
                s = ''.join(temp)
                new.append(s)
                temp = []
            new.append(lts[c])
        c += 1
    if temp:
        s = ''.join(temp)
        new.append(s)
    ret = ' '.join(new)
    return ret

What your loop was missing was a fallback case for when the last character was a number. In that case your temp list was not appended to new.
Another thing that was missing was catching the case where temp was added to the overall string but the string would continue with different content. This can be achieved by reinitializing temp in the loop.


问:
How to console.log number in the following format?
I'm trying to display numbers in the following format can you please tell me what is wrong?
Can not use div. As i'm printing this in the console.

I for n = 5:

```<code>           1

         1 2 1

       1 2 3 2 1

     1 2 3 4 3 2 1

   1 2 3 4 5 4 3 2 1
</code>```

I have tried the following code:

```<code>n = 10
for (var i = 1; i <= n; i++) {
  for (var j = 1; j <= i; j++) {
    console.log("0" + j + " ");
  }
  console.log("<br />");
}
</code>```

n = 10
for (var i = 1; i <= n; i++) {
  for (var j = 1; j <= i; j++) {
    console.log("0" + j + " ");
  }
  console.log("
");
}```
</div>
</div>
</p>

<p>But it displays something like this:</p>

```1

1 2

1 2 3

1 2 3 4

1 2 3 4 5

1 2 3 4 5 6

1 2 3 4 5 6 7

1 2 3 4 5 6 7 8

1 2 3 4 5 6 7 8 9

1 2 3 4 5 6 7 8 9 10
```

答:
for the algorithm point of view you have the forward loop but you missed the downward loop

adding it more the indentation from your first version of the question :

var n = 10

for (var i = 1; i <= n; i++) {
  for (var j = 0; j < n - i; j++) {
    document.write("   ");
  }
  for (var j = 1; j <= i; j++) {
    document.write(" " + j + " ");
  }
  for (var j = i - 1; j >= 1; j--) {
    document.write(" " + j + " ");
  }
  document.write("
");
}```

P.S. It is the very first time I write code in javascript ;-)

Body:
I'm trying to display numbers in the following format can you please tell me what is wrong?
Can not use div. As i'm printing this in the console.

I for n = 5:

           1

         1 2 1

       1 2 3 2 1

     1 2 3 4 3 2 1

   1 2 3 4 5 4 3 2 1

I have tried the following code:

n = 10
for (var i = 1; i <= n; i++) {
  for (var j = 1; j <= i; j++) {
    console.log("0" + j + " ");
  }
  console.log("
");
}

n = 10
for (var i = 1; i <= n; i++) {
  for (var j = 1; j <= i; j++) {
    console.log("0" + j + " ");
  }
  console.log("
");
}

But it displays something like this:

1

1 2

1 2 3

1 2 3 4

1 2 3 4 5

1 2 3 4 5 6

1 2 3 4 5 6 7

1 2 3 4 5 6 7 8

1 2 3 4 5 6 7 8 9

1 2 3 4 5 6 7 8 9 10

Body:
for the algorithm point of view you have the forward loop but you missed the downward loop

adding it more the indentation from your first version of the question :

var n = 10

for (var i = 1; i <= n; i++) {
  for (var j = 0; j < n - i; j++) {
    document.write("&nbsp;&nbsp;&nbsp;");
  }
  for (var j = 1; j <= i; j++) {
    document.write(" " + j + " ");
  }
  for (var j = i - 1; j >= 1; j--) {
    document.write(" " + j + " ");
  }
  document.write("<br />");
}

P.S. It is the very first time I write code in javascript ;-)