问:
Remove blur from message container
I applied blur for body but i want to remove it for message container. How can i do it ? please i need your help i lost too much time on finding a solution.
On close button the message disappears and the blur is removed for body.
My only problem is that blur property is applied for message container.
Before if success all the body is normal. All the change is after if success.</p>

```<code><!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>

</head>
<style>

#card  {
position: absolute;
top:30px;
width: 340px;
margin:-5px 0 0 -400px;

display: block;

text-align: center;
font-family: Arial;

 }

#upper-side {
padding: 2em;
background-color:  #3CB371;
display: block;
color: #fff;
border-top-right-radius: 8px;
border-top-left-radius: 8px;
 }

#checkmark {
 font-weight: lighter;
 fill: #fff;
 margin: -3.5em auto auto 20px;
  }

 #status {
font-weight: lighter;
text-transform: uppercase;
letter-spacing: 2px;
font-size: 1em;
margin-top: -.2em;
margin-bottom: 0;
 }

#lower-side {
padding: 2em 2em 5em 2em;
background: #F0F0F0;
display: block;
border-bottom-right-radius: 8px;
border-bottom-left-radius: 8px;
 }

#message {
font-family: Arial;
margin-top: -.5em;
color: #757575;
letter-spacing: 1px;
 }

.button {

background-color:#333;
font-family: Arial;
color: white;
padding-top: 14px;
padding-right: 32px;
padding-bottom: 14px;
padding-left: 32px;

text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: -5px 0 0 320px;
cursor: pointer;
font-weight: bold;
align-items:center;
-webkit-border-radius: 10px;
border:1px solid #333;
border-bottom-width: 3px;
box-shadow: 2px 2px 3px 2px #4747471;
}

h1{
font-weight: normal;
margin: 0;
font-size: 31px;
 }

.text{
padding: 20px 0;
float: left;

 }
.text p{
padding-left: 320px;
width:450px;
}
.text-img{
float: right;
    height: 470px;
width: 353px;
background: url("{% static 'landingpage.jpg'%}");
padding: 0 10px;
box-sizing: border-box;
font-family: Arial;
}
.text-img h2{
color: white;
margin: 0;
font-size: 14px;
margin-top: 100px;
  }

.text-img p{
color: white;
margin: 0;
font-size: 14px;
 }

.text-img input{
display: block;
width: 96%;
}

.text-img input[type="email"]{
background: #333;
border: 0;
padding: 5px;
border-radius: 5px;
margin-top: 5px;
color: white;
  }

 .text-img input[type="email"]::-webkit-input-placeholder{
color: #587974;
 }
 .text-img input[type="email"]:-moz-placeholder{
color: #587974;
 }
.text-img input[type="email"]::-moz-placeholder{
color: #587974;
 }
.text-img input[type="email"]:-ms-input-placeholder {
color: #587974;
 }
.text-img input[type="submit"]{
float: right;
margin-top: 30px;
width: 50%;
}
.clearfix{
clear: both;
 }

footer p{
    margin-top: 0px;
    margin-right: 0px;
    margin-bottom: 0px;
    margin-left: 0px;

    padding: 12px 0;
    font-size: 14px;
   }

 </style>

<body>
 <div>
  <center><img src="{% static 'Neoticlogo.png'%}" height="130px"  alt="Logo"></center>

 <h1 style="text-align: center;">
 <font face="Arial" color=" #587974">Beat the markets with AI </font>
 </h1>

 </div>
 <br/>
 <br/>
 <div class='row' style="background: #3CB371" >
  <div class="col-lg-4">

   <div class="text">
    <p style=" color:#EDEDED; font-family: Arial; font-size:12; " align="justify"> Neotic is a trading support platform that allows traders to test trading strategies and provides related trading recommendations leveraging artificial intelligence, without writing any single line of code.</p>

    <p style=" color:#EDEDED; font-family: Arial; font-size:12;" align="justify"> The artificial intelligence is based on a machine learning algorithm that incorporates corporate fundamentals, historical prices and financial news.</p>
    <b> <p style=" color:#EDEDED; font-family: Arial; font-size:14; " align="justify"> We are upgrading our services and revamping our brand</p> </b>

   <form>
  <input type='button' class='button' id='run' value= 'Access our old platform' onclick="window.location.href='http://www.dailystockselect.com/'" />
   </form>
  </div>

 <div class="text-img" >
 <h2>Trader or investment fund?</h2>
 <p>Leave your email to be notified when the new service is ready.</p>
  <form action="/subscribe/" method="POST">
  {% csrf_token %}
   <input name="email" type="email" placeholder="Your email" required/>
   <input type="submit" value="I am interested">
  </form>
  {% if success %}
  <body id="overlay" style="filter: blur(2px);" >

  <div id="messageContainer"  >
   <div id='card' class="animated fadeIn">
    <div id='upper-side'>
    <?xml version="1.0" encoding="utf-8"?>
     <!-- Generator: Adobe Illustrator 17.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0)  -->
    <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
    <svg version="1.1" id="checkmark" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" xml:space="preserve">
    <path d="M131.583,92.152l-0.026-0.041c-0.713-1.118-2.197-1.447-3.316-0.734l-31.782,20.257l-4.74-12.65
c-0.483-1.29-1.882-1.958-3.124-1.493l-0.045,0.017c-1.242,0.465-1.857,1.888-1.374,3.178l5.763,15.382
c0.131,0.351,0.334,0.65,0.579,0.898c0.028,0.029,0.06,0.052,0.089,0.08c0.08,0.073,0.159,0.147,0.246,0.209
c0.071,0.051,0.147,0.091,0.222,0.133c0.058,0.033,0.115,0.069,0.175,0.097c0.081,0.037,0.165,0.063,0.249,0.091
c0.065,0.022,0.128,0.047,0.195,0.063c0.079,0.019,0.159,0.026,0.239,0.037c0.074,0.01,0.147,0.024,0.221,0.027
c0.097,0.004,0.194-0.006,0.292-0.014c0.055-0.005,0.109-0.003,0.163-0.012c0.323-0.048,0.641-0.16,0.933-0.346l34.305-21.865
C131.967,94.755,132.296,93.271,131.583,92.152z" />
    <circle fill="none" stroke="#ffffff" stroke-width="5" stroke-miterlimit="10" cx="109.486" cy="104.353" r="32.53" />
  </svg>
  <h3 id='status'>
  Success
</h3>
</div>
<div id='lower-side'>
<p id='message'>
  Thank you for your interest in Neotic.
</p>
<div>
<a href="#" data-rel="back" class="ui-btn ui-corner-all ui-shadow ui-btn ui-icon-delete ui-btn-icon-notext ui-btn-right" onclick="$('#card').hide(); body.style.filter = 'none' ;">X</a>
</div>
</div>
</div>

{% endif %}

 </div>
 </div>

  </body>

  </html>
</code>```

答:
Simplest solution that I can think of:

```<code>{% if success %}
<body>

<div id="messageContainer">
<div  id="overlay" style="filter: blur(2px);">
<div id='card' class="animated fadeIn">
<div id='upper-side'>

...

  <h3 id='status'>
  Success
  </h3>
</div>
<div id='lower-side'>
<p id='message'>
  Thank you for your interest in Neotic.
</p>
<div>
<a href="#" data-rel="back" class="ui-btn ui-corner-all ui-shadow ui-btn ui-icon-delete ui-btn-icon-notext ui-btn-right" onclick="$('#card').hide(); body.style.filter = 'none' ;">X</a>
</div>
</div>
</code>```

What I'm doing: putting up another div so adding the blur attribute to that, thus protecting the messagecontainer from the overlay.

Title: Remove blur from message container

Body:
I applied blur for body but i want to remove it for message container. How can i do it ? please i need your help i lost too much time on finding a solution.
On close button the message disappears and the blur is removed for body.
My only problem is that blur property is applied for message container.
Before if success all the body is normal. All the change is after if success.

<!DOCTYPE html>

<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">

 Beat the markets with AI

 Neotic is a trading support platform that allows traders to test trading strategies and provides related trading recommendations leveraging artificial intelligence, without writing any single line of code.

 The artificial intelligence is based on a machine learning algorithm that incorporates corporate fundamentals, historical prices and financial news.

 We are upgrading our services and revamping our brand

   <form>
  <input type='button' class='button' id='run' value= 'Access our old platform' onclick="window.location.href='http://www.dailystockselect.com/'" />
   </form>

Trader or investment fund?

Leave your email to be notified when the new service is ready.

  <form action="/subscribe/" method="POST">
  {% csrf_token %}
   <input name="email" type="email" placeholder="Your email" required/>
   <input type="submit" value="I am interested">
  </form>
  {% if success %}

    <?xml version="1.0" encoding="utf-8"?>

    <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
    <svg version="1.1" id="checkmark" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" xml:space="preserve">
    <path d="M131.583,92.152l-0.026-0.041c-0.713-1.118-2.197-1.447-3.316-0.734l-31.782,20.257l-4.74-12.65
c-0.483-1.29-1.882-1.958-3.124-1.493l-0.045,0.017c-1.242,0.465-1.857,1.888-1.374,3.178l5.763,15.382
c0.131,0.351,0.334,0.65,0.579,0.898c0.028,0.029,0.06,0.052,0.089,0.08c0.08,0.073,0.159,0.147,0.246,0.209
c0.071,0.051,0.147,0.091,0.222,0.133c0.058,0.033,0.115,0.069,0.175,0.097c0.081,0.037,0.165,0.063,0.249,0.091
c0.065,0.022,0.128,0.047,0.195,0.063c0.079,0.019,0.159,0.026,0.239,0.037c0.074,0.01,0.147,0.024,0.221,0.027
c0.097,0.004,0.194-0.006,0.292-0.014c0.055-0.005,0.109-0.003,0.163-0.012c0.323-0.048,0.641-0.16,0.933-0.346l34.305-21.865
C131.967,94.755,132.296,93.271,131.583,92.152z" />
    <circle fill="none" stroke="#ffffff" stroke-width="5" stroke-miterlimit="10" cx="109.486" cy="104.353" r="32.53" />
  </svg>

  Success

  Thank you for your interest in Neotic.

X

{% endif %}

Body:
Simplest solution that I can think of:

{% if success %}
<body>

<div id="messageContainer">
<div  id="overlay" style="filter: blur(2px);">
<div id='card' class="animated fadeIn">
<div id='upper-side'>

...

  <h3 id='status'>
  Success
  </h3>
</div>
<div id='lower-side'>
<p id='message'>
  Thank you for your interest in Neotic.
</p>
<div>
<a href="#" data-rel="back" class="ui-btn ui-corner-all ui-shadow ui-btn ui-icon-delete ui-btn-icon-notext ui-btn-right" onclick="$('#card').hide(); body.style.filter = 'none' ;">X</a>
</div>
</div>

What I'm doing: putting up another div so adding the blur attribute to that, thus protecting the messagecontainer from the overlay.


来源: stackexchange

问:
Swift Terminated due to memory issue
I've noticed that after reloading the MapKit View in my app, the app crashes and I am given the error Message from debugger: Terminated due to memory issue I believe this is because I am initialising so many variables in viewDidLoad() such as:

```<code>    // LOCATIONS
    let windcoord: CLLocationCoordinate2D = CLLocationCoordinate2DMake(-39.055961,174.072288)
    let bcoord: CLLocationCoordinate2D = CLLocationCoordinate2DMake(-39.057487, 174.054154)
    let hatcoord: CLLocationCoordinate2D = CLLocationCoordinate2DMake(-39.069150, 174.081657)
    let halocoord: CLLocationCoordinate2D = CLLocationCoordinate2DMake(-39.058951, 174.073410)
    let rockcoord: CLLocationCoordinate2D = CLLocationCoordinate2DMake(-39.010627, 174.178184)
    let pixelcoord: CLLocationCoordinate2D = CLLocationCoordinate2DMake(-39.057265, 174.073791)
    let signcoord: CLLocationCoordinate2D = CLLocationCoordinate2DMake(-39.058316, 174.051954)
    let wheelcoord: CLLocationCoordinate2D = CLLocationCoordinate2DMake(-39.056593, 174.072684)
    let tukocoord: CLLocationCoordinate2D = CLLocationCoordinate2DMake(-39.056812, 174.072730)
    let faeocoord: CLLocationCoordinate2D = CLLocationCoordinate2DMake(-39.059038, 174.070527)
    let cloudcoord: CLLocationCoordinate2D = CLLocationCoordinate2DMake(-39.059515,174.073706)
    let snakecoord:CLLocationCoordinate2D = CLLocationCoordinate2DMake(-39.057154, 174.072670)
    let shinycoord:CLLocationCoordinate2D = CLLocationCoordinate2DMake(-39.05602950741741, 174.0699454416841)
    let doncoord: CLLocationCoordinate2D = CLLocationCoordinate2DMake(-39.009391, 174.178753)
    let anchorcoord: CLLocationCoordinate2D = CLLocationCoordinate2DMake(-39.055985, 174.072476)
    let catcoord: CLLocationCoordinate2D = CLLocationCoordinate2DMake(-39.066965, 174.079661)
    let colour_polecoord: CLLocationCoordinate2D = CLLocationCoordinate2DMake(-39.057508,174.072513)
    let collection_coord:CLLocationCoordinate2D = CLLocationCoordinate2DMake(-39.058208,174.070732)
</code>```

Along with many others. I thought, however viewDidLoad() only ran once when the app first loaded the respective view? Could I maybe put these declarations in a seperate class and create an object of that class and just keep reference to it? Or is there an easier way to do this. Picture below shows Memory usage (spikes are from returning to MapKit View.)

Memory Usage of app

答: Fixed using a Unwind Segue Used this for reference.</p>

ContentLicense: CC BY-SA 3.0

Title: Swift Terminated due to memory issue

Body:
I've noticed that after reloading the MapKit View in my app, the app crashes and I am given the error Message from debugger: Terminated due to memory issue I believe this is because I am initialising so many variables in viewDidLoad() such as:

    // LOCATIONS
    let windcoord: CLLocationCoordinate2D = CLLocationCoordinate2DMake(-39.055961,174.072288)
    let bcoord: CLLocationCoordinate2D = CLLocationCoordinate2DMake(-39.057487, 174.054154)
    let hatcoord: CLLocationCoordinate2D = CLLocationCoordinate2DMake(-39.069150, 174.081657)
    let halocoord: CLLocationCoordinate2D = CLLocationCoordinate2DMake(-39.058951, 174.073410)
    let rockcoord: CLLocationCoordinate2D = CLLocationCoordinate2DMake(-39.010627, 174.178184)
    let pixelcoord: CLLocationCoordinate2D = CLLocationCoordinate2DMake(-39.057265, 174.073791)
    let signcoord: CLLocationCoordinate2D = CLLocationCoordinate2DMake(-39.058316, 174.051954)
    let wheelcoord: CLLocationCoordinate2D = CLLocationCoordinate2DMake(-39.056593, 174.072684)
    let tukocoord: CLLocationCoordinate2D = CLLocationCoordinate2DMake(-39.056812, 174.072730)
    let faeocoord: CLLocationCoordinate2D = CLLocationCoordinate2DMake(-39.059038, 174.070527)
    let cloudcoord: CLLocationCoordinate2D = CLLocationCoordinate2DMake(-39.059515,174.073706)
    let snakecoord:CLLocationCoordinate2D = CLLocationCoordinate2DMake(-39.057154, 174.072670)
    let shinycoord:CLLocationCoordinate2D = CLLocationCoordinate2DMake(-39.05602950741741, 174.0699454416841)
    let doncoord: CLLocationCoordinate2D = CLLocationCoordinate2DMake(-39.009391, 174.178753)
    let anchorcoord: CLLocationCoordinate2D = CLLocationCoordinate2DMake(-39.055985, 174.072476)
    let catcoord: CLLocationCoordinate2D = CLLocationCoordinate2DMake(-39.066965, 174.079661)
    let colour_polecoord: CLLocationCoordinate2D = CLLocationCoordinate2DMake(-39.057508,174.072513)
    let collection_coord:CLLocationCoordinate2D = CLLocationCoordinate2DMake(-39.058208,174.070732)

Along with many others. I thought, however viewDidLoad() only ran once when the app first loaded the respective view? Could I maybe put these declarations in a seperate class and create an object of that class and just keep reference to it? Or is there an easier way to do this. Picture below shows Memory usage (spikes are from returning to MapKit View.)

Memory Usage of app


问:
app.component overrides app-routing.module in routing
I am trying to create routing for my Angular 2 project. Whatever route I use, the page always loads the app.component.ts.

In my app.module.ts I have:

```<code>import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule, JsonpModule } from '@angular/http';
import { RouterModule } from "@angular/router";

import { OrderModule } from 'ngx-order-pipe';

import { AppRoutingModule } from "./app-routing.module";
import { MovieSearchComponent } from "./movie_search/movie_search.component";
import { MovieAddComponent }         from "./movie_add/movie_add.component";
import { MovieDeleteComponent } from "./movie_delete/movie_delete.component";
import { A2tUiModule, Angular2TokenService} from "angular2-token";
import { HomeComponent } from './home/home.component';
import { AppComponent } from './app.component';

@NgModule({
  declarations: [
    MovieSearchComponent,
    MovieAddComponent,
    MovieDeleteComponent,
    HomeComponent,
    AppComponent,
  ],
  imports: [
    AppRoutingModule,
    BrowserModule,
    FormsModule,
    RouterModule,
    HttpModule,
    JsonpModule,
    OrderModule,
    A2tUiModule,
  ],
  providers: [
    Angular2TokenService
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }
</code>```

My app.component.ts:

```<code>import { Component }            from '@angular/core';

import { AppService }           from "./app.service";
import { Movie }                from './movie';
import { MovieDeleteService }   from "./movie_delete/movie_delete.service";
import { Angular2TokenService } from "angular2-token";

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css'],
  providers: [
    AppService,
    MovieDeleteService,
    Angular2TokenService
  ]
})

export class AppComponent {
  title = 'app works!';
  movies: Movie[] = [];

  constructor(
    private  appService: AppService
  ){}

  ngOnInit(){
    this.getMovies();
  }

  getMovies(){
    this.appService.getMovies()
      .subscribe((response)=>{
        this.movies = response;
      });
  }
}
</code>```

And finally the app-routing.module.ts:

```<code>import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';

import {HomeComponent} from "./home/home.component";

const routes: Routes = [
  {
    path: '',
    component: HomeComponent,
    pathMatch: 'full'
  },
  {
    path: 'home',
    component: HomeComponent
  }
];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule]
})

export class AppRoutingModule { }
</code>```

The routing does something. Because if I go to /home (which is added in the routing module) I don't get an error. But if I go to /homes I do get an error:

ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'homes'

This is my home.component.ts:

```<code>import { Component, OnInit } from '@angular/core';

@Component({
  selector: 'app-home',
  templateUrl: './home.component.html',
  styleUrls: ['./home.component.css']
})
export class HomeComponent implements OnInit {

  constructor() { }

  ngOnInit() {
    console.log('HomeComponent')
  }

}
</code>```

答: In order for your routing system to work. You need to add a router-outlet tag in your bootstrapped component. This way the current navigated component will be created dynamically in this tag.

Body:
I am trying to create routing for my Angular 2 project. Whatever route I use, the page always loads the app.component.ts.

In my app.module.ts I have:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule, JsonpModule } from '@angular/http';
import { RouterModule } from "@angular/router";

import { OrderModule } from 'ngx-order-pipe';

import { AppRoutingModule } from "./app-routing.module";
import { MovieSearchComponent } from "./movie_search/movie_search.component";
import { MovieAddComponent }         from "./movie_add/movie_add.component";
import { MovieDeleteComponent } from "./movie_delete/movie_delete.component";
import { A2tUiModule, Angular2TokenService} from "angular2-token";
import { HomeComponent } from './home/home.component';
import { AppComponent } from './app.component';

@NgModule({
  declarations: [
    MovieSearchComponent,
    MovieAddComponent,
    MovieDeleteComponent,
    HomeComponent,
    AppComponent,
  ],
  imports: [
    AppRoutingModule,
    BrowserModule,
    FormsModule,
    RouterModule,
    HttpModule,
    JsonpModule,
    OrderModule,
    A2tUiModule,
  ],
  providers: [
    Angular2TokenService
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }

My app.component.ts:

import { Component }            from '@angular/core';

import { AppService }           from "./app.service";
import { Movie }                from './movie';
import { MovieDeleteService }   from "./movie_delete/movie_delete.service";
import { Angular2TokenService } from "angular2-token";

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css'],
  providers: [
    AppService,
    MovieDeleteService,
    Angular2TokenService
  ]
})

export class AppComponent {
  title = 'app works!';
  movies: Movie[] = [];

  constructor(
    private  appService: AppService
  ){}

  ngOnInit(){
    this.getMovies();
  }

  getMovies(){
    this.appService.getMovies()
      .subscribe((response)=>{
        this.movies = response;
      });
  }
}

And finally the app-routing.module.ts:

import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';

import {HomeComponent} from "./home/home.component";

const routes: Routes = [
  {
    path: '',
    component: HomeComponent,
    pathMatch: 'full'
  },
  {
    path: 'home',
    component: HomeComponent
  }
];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule]
})

export class AppRoutingModule { }

The routing does something. Because if I go to /home (which is added in the routing module) I don't get an error. But if I go to /homes I do get an error:

ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'homes'

This is my home.component.ts:

import { Component, OnInit } from '@angular/core';

@Component({
  selector: 'app-home',
  templateUrl: './home.component.html',
  styleUrls: ['./home.component.css']
})
export class HomeComponent implements OnInit {

  constructor() { }

  ngOnInit() {
    console.log('HomeComponent')
  }

}


问:
How to represent functions in flowchart?
I define some function in my Ansi C Program (simple program). I don't known how to represent a function in flowchart. Anybody can help me?</p>

答: There is no direct symbol.. you can create your function with the basic input /output/process symbols </p>

ContentLicense: CC BY-SA 2.5


问:
Latest Docker update broken Heroku cli?
As the --email parameter is removed in docker login (version v17.06), I am unable to login with heroku container:login,

I get the following error:

unknown flag: --email
See 'docker login --help'.
 !    Error: docker login exited with 125

I am running latest heroku-cli version:
heroku-cli/6.12.0-a504409 (darwin-x64) node-v7.10.0

Any update coming to this, as now it seems I am unable to deploy any docker application to heroku?

答: The --email attribute was used in an earlier version of Heroku's Docker tools. Check the output of heroku plugins and see if you have heroku-container-tools listed, if you do then perform heroku plugins:uninstall heroku-container-tools and then run heroku plugins:install heroku-container-registry.

Title: Latest Docker update broken Heroku cli?


问:
How to pass multiple parameters into Label Template?
Is there a way to pass multiple parameters to Label Template function? It doesn't seem to work out of the box.

答:
You should be able to use multiple fields. For example:

{{prop1}} - {{prop2}}

in the label template should work. Not sure about your custom function though. Looking at the docs here: https://github.com/kgiszewski/ArchetypeManual/blob/master/02%20-%20Configuration.md it looks like you can pass multiple arguments maybe?


问:
asp.net In a repeater is it possible to call a public function from another class?
Say I have this repeater which makes use of a public function called Test in the code-behind.

```<code><asp:Repeater  ID="Repeater1" runat="server">
<HeaderTemplate>
  <table>
</HeaderTemplate>

<ItemTemplate>
  <tr>
     <td><%# Eval("MyCol1")%></td>
     <td><%# Eval("MyCol2")%></td>
     <td><%# Test((int)Eval("MyCol1"))%></td>
  </tr>
</ItemTemplate>

<FooterTemplate>
  </table>
</FooterTemplate>
</asp:Repeater>
</code>```

In my code-behind, I have this function

```<code>public string Test (int Value)
{
   return "Test"+Value.ToString();
}
</code>```

This works fine but in my website I will have similar repeaters on various pages and most of them will need to call the Test function. Instead of having it in the code-behind of each web page would it be possible to put it in a public static class and call it directly from the repeater? Something like this (which does not work):

```<code><td><%# MyStaticClass.Test((int)Eval("MyCol1"))%></td>
</code>```

The only solution I've come up with would be to change the function in the code-behind to:

```<code>public string Test (int Value)
{
   return MyStaticClass.Test(Value);
}
</code>```

But it would be neater if I didn't have to put any code in the code-behind of each webpage (ie I would prefer the repeater to call the static function directly).

Any ideas or suggestions?

答:
The accepted answer, and other answers here, suggest that inheritance is necessary to solve this problem. This confused me, so I asked my own question - How to call functions in a Class file, when inside a Repeater, without inheritance - and thanks to @Walsharoo I found out I merely needed to add the Project Name and I could call a static function (in a Class) from inside a repeater:

<%# [ProjectName].ClassName.MyStaticFunction(Eval("MyColumnName"))%>

This may prove helpful to others, I hope, though I'm not suggesting you're all as daft as me for forgetting this simple trick.

Body:
Say I have this repeater which makes use of a public function called Test in the code-behind.

<asp:Repeater  ID="Repeater1" runat="server">
<HeaderTemplate>

</HeaderTemplate>

<ItemTemplate>

     <%# Eval("MyCol1")%>
     <%# Eval("MyCol2")%>
     <%# Test((int)Eval("MyCol1"))%>

</ItemTemplate>

<FooterTemplate>

</FooterTemplate>
</asp:Repeater>

In my code-behind, I have this function

public string Test (int Value)
{
   return "Test"+Value.ToString();
}

This works fine but in my website I will have similar repeaters on various pages and most of them will need to call the Test function. Instead of having it in the code-behind of each web page would it be possible to put it in a public static class and call it directly from the repeater? Something like this (which does not work):

<%# MyStaticClass.Test((int)Eval("MyCol1"))%>

The only solution I've come up with would be to change the function in the code-behind to:

public string Test (int Value)
{
   return MyStaticClass.Test(Value);
}

But it would be neater if I didn't have to put any code in the code-behind of each webpage (ie I would prefer the repeater to call the static function directly).

Any ideas or suggestions?

Body:
The accepted answer, and other answers here, suggest that inheritance is necessary to solve this problem. This confused me, so I asked my own question - How to call functions in a Class file, when inside a Repeater, without inheritance - and thanks to @Walsharoo I found out I merely needed to add the Project Name and I could call a static function (in a Class) from inside a repeater:

<td><%# [ProjectName].ClassName.MyStaticFunction(Eval("MyColumnName"))%></td>

This may prove helpful to others, I hope, though I'm not suggesting you're all as daft as me for forgetting this simple trick.


问:
Open a hyperlink in a new window or tab c#?
I have below which is C# string builder code and currrently when the user clicks the hyperlink it opens it in the background, I need it to open in a new tab or perhaps a window once hyperlink is clicked. Please advise</p>

```<code>sb.Append("<td><a href=\"" + baseMMPUrlConfigValue + "/profile/supplier/" + organisation.Id + "\">Profile Link</a></td>");
</code>```

答:
Replace the above line in your code with the line below and this should do the magic for you.</p>

```<code>sb.Append("<td><a target=\"_blank\" href=\"" + baseMMPUrlConfigValue + "/profile/supplier/" + organisation.Id + "\">Profile Link</a></td>");
</code>```

Body:
I have below which is C# string builder code and currrently when the user clicks the hyperlink it opens it in the background, I need it to open in a new tab or perhaps a window once hyperlink is clicked. Please advise

sb.Append("Profile Link	");

Body:
Replace the above line in your code with the line below and this should do the magic for you.

sb.Append("<td><a target=\"_blank\" href=\"" + baseMMPUrlConfigValue + "/profile/supplier/" + organisation.Id + "\">Profile Link</a></td>");


问:
Recover current value in checkBox during gridView Editing - WebForm C#
I have a simple checkBox in Editable gridView :

```<code><asp:TemplateField HeaderText="Editable">
  <ItemTemplate>
      <asp:Label runat="server" Text="<%# Item.IsEditable %>" />
  </ItemTemplate>
  <EditItemTemplate>
      <asp:CheckBox ID="CheckBoxEditable " runat="server" Text="Editable"></asp:CheckBox>
  </EditItemTemplate>
</asp:TemplateField>
</code>```

When I click on edit button in the row, I would like that checkBox is already checked if value is true. (IsEditable is a boolean)
Text Field is easy because I have a BindItem on Text property in EditItemTemplate. But it's not the same for checkBox or dropdownlist

GridView

I use a UpdateItem Method to update my data in database. I tried a small condition to check my checkBox but it does'nt work.

```<code>public void GridViewRisquesAggravants_UpdateItem(IndexViewModel item)
{
 try
   {
    if (ModelState.IsValid)
      {
       CheckBox chbEdit = (CheckBox)GridView.Rows[this.GridView.EditIndex].FindControl("CheckBoxEditable")
          if (item.IsEditable)
              chbEdit.Checked = true;

        new TypeService().Update(new Type
        {
          IsEditable = item.IsEditable,
        });
        this.GridView.DataBind();
      }
    }
    catch
    {
      throw;
    }
}
</code>```

It makes sense because I am not in the right function to declare this. But I just have 3 methods in my webform.

```<code>SelectMethod="GridView_GetData"
UpdateMethod="GridView_UpdateItem"
DeleteMethod="GridView_DeleteItem"
</code>```

Where can I do this?
(And I have the same problem with datas on dropdownList. I don't know where I recover current value during editing)

Thanks in advance
(Sorry I am beginner about webforms and my english is not perfect)

Evy

答:
use the following code instead for checkbox declaration in edit template</p>

```<code> <asp:CheckBox ID="CheckBox1" runat="server" Checked='<%# Convert.ToBoolean("true") %>' />
</code>```

Body:
I have a simple checkBox in Editable gridView :

<asp:TemplateField HeaderText="Editable">
  <ItemTemplate>
      <asp:Label runat="server" Text="<%# Item.IsEditable %>" />
  </ItemTemplate>
  <EditItemTemplate>
      <asp:CheckBox ID="CheckBoxEditable " runat="server" Text="Editable"></asp:CheckBox>
  </EditItemTemplate>
</asp:TemplateField>

When I click on edit button in the row, I would like that checkBox is already checked if value is true. (IsEditable is a boolean)
Text Field is easy because I have a BindItem on Text property in EditItemTemplate. But it's not the same for checkBox or dropdownlist

GridView

I use a UpdateItem Method to update my data in database. I tried a small condition to check my checkBox but it does'nt work.

public void GridViewRisquesAggravants_UpdateItem(IndexViewModel item)
{
 try
   {
    if (ModelState.IsValid)
      {
       CheckBox chbEdit = (CheckBox)GridView.Rows[this.GridView.EditIndex].FindControl("CheckBoxEditable")
          if (item.IsEditable)
              chbEdit.Checked = true;

        new TypeService().Update(new Type
        {
          IsEditable = item.IsEditable,
        });
        this.GridView.DataBind();
      }
    }
    catch
    {
      throw;
    }
}

It makes sense because I am not in the right function to declare this. But I just have 3 methods in my webform.

SelectMethod="GridView_GetData"
UpdateMethod="GridView_UpdateItem"
DeleteMethod="GridView_DeleteItem"

Where can I do this?
(And I have the same problem with datas on dropdownList. I don't know where I recover current value during editing)

Thanks in advance
(Sorry I am beginner about webforms and my english is not perfect)

Evy

Body:
use the following code instead for checkbox declaration in edit template

 <asp:CheckBox ID="CheckBox1" runat="server" Checked='<%# Convert.ToBoolean("true") %>' />


问:
PopupWindow how to change icon and background programmatically?
Have is xml file for PopupWindow:

How to programmatically replace the icon and Backgroud in this xml?

答:
You need to apply a theme style as following:

```<code><style name="PopupMenu" parent="@android:style/Widget.PopupMenu">
        <item name="android:popupBackground">@color/colorPrimary</item>
        <item name="android:background">@color/colorPrimary</item>
        <item name="android:textColorPrimary">@android:color/darker_gray</item>
    </style>
</code>```

Following code works for me:

```<code>public void showPopUpMenu(final Context context, View view) {
            Context wrapper = new ContextThemeWrapper(context, R.style.PopupMenu);
            PopupMenu popup = new PopupMenu(wrapper, view, Gravity.END);
            MenuInflater inflater = popup.getMenuInflater();
            inflater.inflate(R.menu.menu_options, popup.getMenu());
            popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
                @Override
                public boolean onMenuItemClick(MenuItem menuItem) {
                    switch (menuItem.getItemId()) {
                        case R.id.action_share:
                            shareWithFriends();
                            break;
                        default:
                            break;
                    }
                    return true;
                }
            });

            try {
                Field[] fields = popup.getClass().getDeclaredFields();
                for (Field field : fields) {
                    if ("mPopup".equals(field.getName())) {
                        field.setAccessible(true);
                        Object menuPopupHelper = field.get(popup);
                        Class<?> classPopupHelper = Class.forName(menuPopupHelper
                                .getClass().getName());
                        Method setForceIcons = classPopupHelper.getMethod(
                                "setForceShowIcon", boolean.class);
                        setForceIcons.invoke(menuPopupHelper, true);
                        break;
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
            }

            popup.show();
        }
</code>```

Body:
You need to apply a theme style as following:

<style name="PopupMenu" parent="@android:style/Widget.PopupMenu">
        <item name="android:popupBackground">@color/colorPrimary</item>
        <item name="android:background">@color/colorPrimary</item>
        <item name="android:textColorPrimary">@android:color/darker_gray</item>
    </style>

Following code works for me:

public void showPopUpMenu(final Context context, View view) {
            Context wrapper = new ContextThemeWrapper(context, R.style.PopupMenu);
            PopupMenu popup = new PopupMenu(wrapper, view, Gravity.END);
            MenuInflater inflater = popup.getMenuInflater();
            inflater.inflate(R.menu.menu_options, popup.getMenu());
            popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
                @Override
                public boolean onMenuItemClick(MenuItem menuItem) {
                    switch (menuItem.getItemId()) {
                        case R.id.action_share:
                            shareWithFriends();
                            break;
                        default:
                            break;
                    }
                    return true;
                }
            });

            try {
                Field[] fields = popup.getClass().getDeclaredFields();
                for (Field field : fields) {
                    if ("mPopup".equals(field.getName())) {
                        field.setAccessible(true);
                        Object menuPopupHelper = field.get(popup);
                        Class<?> classPopupHelper = Class.forName(menuPopupHelper
                                .getClass().getName());
                        Method setForceIcons = classPopupHelper.getMethod(
                                "setForceShowIcon", boolean.class);
                        setForceIcons.invoke(menuPopupHelper, true);
                        break;
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
            }

            popup.show();
        }


问:
Twilio startConferenceOnEnter set to true, but still ending up in the waitUrl
I've just made this TwiML test file.  I've set the Voice URL in my account to point to this file but when i'm calling my number, i hear the message but the user end up in a waiting room even if i've set the startConferenceOnEnter to true.  Anyone can explain me what i'm doing wrong?   I was expecting the user to end up in a room with no sound at all.

Thanks you

```<code>@{
    Response.ContentType = "text/xml";
}
<?xml version="1.0" encoding="UTF-8"?>
<Response>
    <Say voice="woman" language="FR">Bienvenue sur le pont de conférence Twilio.</Say>

    <Dial>
        <Conference startConferenceOnEnter="true" endConferenceOnExit="false" record="do-not-record">
        1234567
        </Conference>
    </Dial>
</Response>
</code>```

答:
Twilio developer evangelist here.

startConferenceOnEnter will still wait for more than one person to be on the conference before starting.

If you are looking to stop their being wait music while the caller waits for someone else to join, you can set the waitUrl to an empty string "", like so:

```<code>@{
    Response.ContentType = "text/xml";
}
<?xml version="1.0" encoding="UTF-8"?>
<Response>
    <Say voice="woman" language="FR">Bienvenue sur le pont de conférence Twilio.</Say>

    <Dial>
        <Conference startConferenceOnEnter="true" endConferenceOnExit="false" record="do-not-record" waitUrl="">
        1234567
        </Conference>
    </Dial>
</Response>
</code>```

Let me know if that helps at all.

Body:
I've just made this TwiML test file.  I've set the Voice URL in my account to point to this file but when i'm calling my number, i hear the message but the user end up in a waiting room even if i've set the startConferenceOnEnter to true.  Anyone can explain me what i'm doing wrong?   I was expecting the user to end up in a room with no sound at all.

Thanks you

@{
    Response.ContentType = "text/xml";
}
<?xml version="1.0" encoding="UTF-8"?>
<Response>
    <Say voice="woman" language="FR">Bienvenue sur le pont de conférence Twilio.</Say>

    <Dial>
        <Conference startConferenceOnEnter="true" endConferenceOnExit="false" record="do-not-record">
        1234567
        </Conference>
    </Dial>
</Response>

Body:
Twilio developer evangelist here.

startConferenceOnEnter will still wait for more than one person to be on the conference before starting.

If you are looking to stop their being wait music while the caller waits for someone else to join, you can set the waitUrl to an empty string "", like so:

@{
    Response.ContentType = "text/xml";
}
<?xml version="1.0" encoding="UTF-8"?>
<Response>
    <Say voice="woman" language="FR">Bienvenue sur le pont de conférence Twilio.</Say>

    <Dial>
        <Conference startConferenceOnEnter="true" endConferenceOnExit="false" record="do-not-record" waitUrl="">
        1234567
        </Conference>
    </Dial>
</Response>

Let me know if that helps at all.


问:
UIViewControllerAnimatedTransitioning: multiple calls to interruptibleAnimator?
I just spent the last few hours tracking down a bug that happened to be located in a transition driver object, where the interruptibleAnimator method was called several times, where:

a UIViewPropertyAnimator completion closure contained a reference to [unowned self] to complete the transition context passed by its transition controller with self.context.completeTransition(true)

the transition controller, which implements UIViewControllerAnimatedTransitioning and is a UINavigationControllerDelegate, passed the context via its animate method

```<code>extension NavigationTransitionController: UIViewControllerAnimatedTransitioning {

func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
    return transitionDuration
}

func animationEnded(_ transitionCompleted: Bool) {

    // Clean up our helper object and any additional state
    transitionDriver = nil
}

func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
    transitionDriver = TransitionDriver(context: transitionContext, duration: transitionDuration)
    interruptibleAnimator(using: transitionContext).startAnimation()
}

func interruptibleAnimator(using transitionContext: UIViewControllerContextTransitioning) -> UIViewImplicitlyAnimating {
    return transitionDriver!.transitionAnimator
}
</code>```

Unless I am missing something very basic here, I have no idea why the transition controller would make more than 1 call to the interruptibleAnimator method.

My structure was inspired by what Apple presented here in their WWDC 2016 talk; if you download, put a breakpoint and launch their Photo Transitioning app you can see for yourself that this method is called twice for the same transition in their case.

Could somebody enlighten me as to whether I am chasing a ghost or if this is a legit weird behavior?

答:
Apple states in the 'header docs' for UIViewControllerAnimatedTransitioning:

```<code>/// A conforming object implements this method if the transition it creates can
/// be interrupted. For example, it could return an instance of a
/// UIViewPropertyAnimator. It is expected that this method will return the same
/// instance for the life of a transition.
@available(iOS 10.0, *)
optional public func interruptibleAnimator(using transitionContext: UIViewControllerContextTransitioning) -> UIViewImplicitlyAnimating
</code>```

The same is stated at minute 29:34 in WWDC Session 2016. The sample implementation on the slide at minute 27:33 seems to be misleading / wrong.

The reason why it is called multiple times is beyond my knowledge.

Body:
I just spent the last few hours tracking down a bug that happened to be located in a transition driver object, where the interruptibleAnimator method was called several times, where:

a UIViewPropertyAnimator completion closure contained a reference to [unowned self] to complete the transition context passed by its transition controller with self.context.completeTransition(true)

the transition controller, which implements UIViewControllerAnimatedTransitioning and is a UINavigationControllerDelegate, passed the context via its animate method

extension NavigationTransitionController: UIViewControllerAnimatedTransitioning {

func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
    return transitionDuration
}

func animationEnded(_ transitionCompleted: Bool) {

    // Clean up our helper object and any additional state
    transitionDriver = nil
}

func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
    transitionDriver = TransitionDriver(context: transitionContext, duration: transitionDuration)
    interruptibleAnimator(using: transitionContext).startAnimation()
}

func interruptibleAnimator(using transitionContext: UIViewControllerContextTransitioning) -> UIViewImplicitlyAnimating {
    return transitionDriver!.transitionAnimator
}

Unless I am missing something very basic here, I have no idea why the transition controller would make more than 1 call to the interruptibleAnimator method.

My structure was inspired by what Apple presented here in their WWDC 2016 talk; if you download, put a breakpoint and launch their Photo Transitioning app you can see for yourself that this method is called twice for the same transition in their case.

Could somebody enlighten me as to whether I am chasing a ghost or if this is a legit weird behavior?

Body:
Apple states in the 'header docs' for UIViewControllerAnimatedTransitioning:

/// A conforming object implements this method if the transition it creates can
/// be interrupted. For example, it could return an instance of a
/// UIViewPropertyAnimator. It is expected that this method will return the same
/// instance for the life of a transition.
@available(iOS 10.0, *)
optional public func interruptibleAnimator(using transitionContext: UIViewControllerContextTransitioning) -> UIViewImplicitlyAnimating

The same is stated at minute 29:34 in WWDC Session 2016. The sample implementation on the slide at minute 27:33 seems to be misleading / wrong.

The reason why it is called multiple times is beyond my knowledge.


问:
What is a postgres superuser
I couldn't find the answer in the docs, what exactly is a superuser in postgres? </p>

<p>Does the superuser have all privileges? Is it per database? Per instance? </p>

答:
https://www.postgresql.org/docs/current/static/sql-createrole.html

These clauses determine whether the new role is a "superuser", who can
  override all access restrictions within the database.

yes - all privileges in all databases on the specified cluster

Title: What is a postgres superuser

Body:
I couldn't find the answer in the docs, what exactly is a superuser in postgres?

Does the superuser have all privileges? Is it per database? Per instance?


问:
Rails split sentence into separate words but substitute certain words
What the goal is

```<code><span>I</span>
<span>helped</span>
<span>the</span>
<span class="highlighted">Adidas</span>
<span class="highlighted">brand</span>
<span>rebuild</span>
<span>their</span>
<span>design</span>
<span>system</span>
</code>```

Got a Rails project I'm working on. I've got data that forms a sentence like so:

```<code>sentence = 'I helped Adidas rebuild their design system'
</code>```

I can separate the words with sentence.split(/\W+/) and I get:

```<code>[I] [helped] [Adidas] [rebuild] [their] [design] [system]
</code>```

But I would like to highlight the word Adidas by wrapping it in a class.

Sometimes that highlighted word can be a combination of words like Adidas brand

For that I tried doing:

```<code>sentence.sub(sentenceHighlight, "<span>#{sentenceHighlight}</span>")
</code>```

Which gives me:

```<code>I helped the <span>Adidas brand</span> rebuild their design system
</code>```

While that works fine I still need each of the words to be separate like in the example above.

Does anyone know how I can combine the two methods nicely in a clean code?

答:
you can use this method:

```<code>highlight('You searched for: rails', 'rails')
# => You searched for: <mark>rails</mark>

highlight('You searched for: rails', /for|rails/)
# => You searched <mark>for</mark>: <mark>rails</mark>

highlight('You searched for: ruby, rails, dhh', 'actionpack')
# => You searched for: ruby, rails, dhh

highlight('You searched for: rails', ['for', 'rails'], highlighter: '<em>\1</em>')
# => You searched <em>for</em>: <em>rails</em>

highlight('You searched for: rails', 'rails', highlighter: '<a href="search?q=\1">\1</a>')
# => You searched for: <a href="search?q=rails">rails</a>

highlight('You searched for: rails', 'rails') { |match| link_to(search_path(q: match, match)) }
# => You searched for: <a href="search?q=rails">rails</a>
</code>```

In your case:

```<code>highlight('I helped Adidas rebuild their design system', ['Adidas'], highlighter: '<span class="highlighted">\1 brand</span>')
 # => I helped the <span>Adidas brand</span> rebuild their design system
</code>```

Body:
What the goal is

I
helped
the
Adidas
brand
rebuild
their
design
system

Got a Rails project I'm working on. I've got data that forms a sentence like so:

sentence = 'I helped Adidas rebuild their design system'

I can separate the words with sentence.split(/\W+/) and I get:

[I] [helped] [Adidas] [rebuild] [their] [design] [system]

But I would like to highlight the word Adidas by wrapping it in a class.

Sometimes that highlighted word can be a combination of words like Adidas brand

For that I tried doing:

sentence.sub(sentenceHighlight, "#{sentenceHighlight}")

Which gives me:

I helped the Adidas brand rebuild their design system

While that works fine I still need each of the words to be separate like in the example above.

Does anyone know how I can combine the two methods nicely in a clean code?

Body:
you can use this method:

highlight('You searched for: rails', 'rails')
# => You searched for: <mark>rails</mark>

highlight('You searched for: rails', /for|rails/)
# => You searched <mark>for</mark>: <mark>rails</mark>

highlight('You searched for: ruby, rails, dhh', 'actionpack')
# => You searched for: ruby, rails, dhh

highlight('You searched for: rails', ['for', 'rails'], highlighter: '<em>\1</em>')
# => You searched <em>for</em>: <em>rails</em>

highlight('You searched for: rails', 'rails', highlighter: '<a href="search?q=\1">\1</a>')
# => You searched for: <a href="search?q=rails">rails</a>

highlight('You searched for: rails', 'rails') { |match| link_to(search_path(q: match, match)) }
# => You searched for: <a href="search?q=rails">rails</a>

In your case:

highlight('I helped Adidas rebuild their design system', ['Adidas'], highlighter: '<span class="highlighted">\1 brand</span>')
 # => I helped the <span>Adidas brand</span> rebuild their design system


问:
When I move a Wordpress custom option menu to the top level it stop saving input settings?
This code adds a menu in the Settings section of Wordpress' administrator

Right now add_options_page is declared, so the custom menu appears inside Settings

I changed add_options_page to add_menu_page in order to bring that menu to the top-level, but then it stopped working (when I click the custom menu opens, but can't save settings anymore).

What's the remaining code I have to change in order to make this work?

Thanks in advance!

```<code><?php

add_action('admin_menu', 'create_theme_options_page');
add_action('admin_init', 'register_and_build_fields');

function create_theme_options_page() {
   add_options_page('Theme Options', 'Theme Options', 'administrator', __FILE__, 'options_page_fn');
}

function register_and_build_fields() {
   register_setting('plugin_options', 'plugin_options', 'validate_setting');

   add_settings_section('main_section', 'Main Settings', 'section_cb', __FILE__);

   add_settings_field('color_scheme', 'Color Scheme:', 'color_scheme_setting', __FILE__, 'main_section');
   add_settings_field('logo', 'Logo:', 'logo_setting', __FILE__, 'main_section'); // LOGO
   add_settings_field('banner_heading', 'Banner Heading:', 'banner_heading_setting', __FILE__, 'main_section');
   add_settings_field('adverting_information', 'Advertising Info:', 'advertising_information_setting', __FILE__, 'main_section');

   add_settings_field('ad_one', 'Ad:', 'ad_setting_one', __FILE__, 'main_section'); // Ad1
   add_settings_field('ad_two', 'Second Ad:', 'ad_setting_two', __FILE__, 'main_section'); // Ad2
}

function options_page_fn() {
?>
<div id="theme-options-wrap" class="widefat">
<div class="icon32" id="icon-tools"></div>

<h2>My Theme Options</h2>
<p>Take control of your theme, by overriding the default settings with your own specific preferences.</p>

<form method="post" action="options.php" enctype="multipart/form-data">
<?php settings_fields('plugin_options'); ?>
<?php do_settings_sections(__FILE__); ?>
<p class="submit">
<input name="Submit" type="submit" class="button-primary" value="<?php esc_attr_e('Save Changes'); ?>" />
</p>
</form>
</div>
<?php
}

// Banner Heading
function banner_heading_setting() {
   $options = get_option('plugin_options');
   echo "<input name='plugin_options[banner_heading]' type='text' value='{$options['banner_heading']}' />";
}

// Color Scheme
function color_scheme_setting() {
   $options = get_option('plugin_options');
   $items = array("White", "Black", "#DDDDDD", "#444444");

   echo "<select name='plugin_options[color_scheme]'>";
   foreach ($items as $item) {
      $selected = ( $options['color_scheme'] === $item ) ? 'selected = "selected"' : '';
      echo "<option value='$item' $selected>$item</option>";
   }
   echo "</select>";
}

// Advertising info
function advertising_information_setting() {
   $options = get_option('plugin_options');
   echo "<textarea name='plugin_options[advertising_information]' rows='10' cols='60' type='textarea'>{$options['advertising_information']}</textarea>";
}

// Ad one
function ad_setting_one() {
   echo '<input type="file" name="ad_one" />';
}

// Ad two
function ad_setting_two() {
   echo '<input type="file" name="ad_two" />';
}

// Logo
function logo_setting() {
   echo '<input type="file" name="logo" />';
}

function validate_setting($plugin_options) {
   $keys = array_keys($_FILES);
   $i = 0;

   foreach ($_FILES as $image) {
      // if a files was upload
      if ($image['size']) {
         // if it is an image
         if (preg_match('/(jpg|jpeg|png|gif)$/', $image['type'])) {
            $override = array('test_form' => false);
            $file = wp_handle_upload($image, $override);

            $plugin_options[$keys[$i]] = $file['url'];
         } else {
            $options = get_option('plugin_options');
            $plugin_options[$keys[$i]] = $options[$logo];
            wp_die('No image was uploaded.');
         }
      }

      // else, retain the image that's already on file.
      else {
         $options = get_option('plugin_options');
         $plugin_options[$keys[$i]] = $options[$keys[$i]];
      }
      $i++;
   }

   return $plugin_options;
}

function section_cb() {}

// Add stylesheet
add_action('admin_head', 'admin_register_head');

function admin_register_head() {
   $url = get_bloginfo('template_directory') . '/functions/options_page.css';
   echo "<link rel='stylesheet' href='$url' />\n";
}
</code>```

答:
Supply a proper handle when registering the menu page(fourth parameter).

Add menu example

Add top level menu page

```<code>add_menu_page( 'Theme Options', 'Theme Options', 'manage_options', 'my-theme-options', 'options_page_fn' );
</code>```

Add submenu example

Add a submenu page to the new top level page

```<code>add_submenu_page( 'my-theme-options', 'Theme Sub1', 'Theme Sub1', 'manage_options', 'my-theme-options-subpage1', 'my_callback_function' );
</code>```

Hope that helps..

And please consider posting your future WordPress questions on the WordPress Stack Exchange.

Regarding your main problem though, try updating the do_settings_section call to..

```<code><?php do_settings_sections( 'main_section' ); ?>
</code>```

Body:
This code adds a menu in the Settings section of Wordpress' administrator

Right now add_options_page is declared, so the custom menu appears inside Settings

I changed add_options_page to add_menu_page in order to bring that menu to the top-level, but then it stopped working (when I click the custom menu opens, but can't save settings anymore).

What's the remaining code I have to change in order to make this work?

Thanks in advance!

<?php

add_action('admin_menu', 'create_theme_options_page');
add_action('admin_init', 'register_and_build_fields');

function create_theme_options_page() {
   add_options_page('Theme Options', 'Theme Options', 'administrator', __FILE__, 'options_page_fn');
}

function register_and_build_fields() {
   register_setting('plugin_options', 'plugin_options', 'validate_setting');

   add_settings_section('main_section', 'Main Settings', 'section_cb', __FILE__);

   add_settings_field('color_scheme', 'Color Scheme:', 'color_scheme_setting', __FILE__, 'main_section');
   add_settings_field('logo', 'Logo:', 'logo_setting', __FILE__, 'main_section'); // LOGO
   add_settings_field('banner_heading', 'Banner Heading:', 'banner_heading_setting', __FILE__, 'main_section');
   add_settings_field('adverting_information', 'Advertising Info:', 'advertising_information_setting', __FILE__, 'main_section');

   add_settings_field('ad_one', 'Ad:', 'ad_setting_one', __FILE__, 'main_section'); // Ad1
   add_settings_field('ad_two', 'Second Ad:', 'ad_setting_two', __FILE__, 'main_section'); // Ad2
}

function options_page_fn() {
?>

My Theme Options

Take control of your theme, by overriding the default settings with your own specific preferences.

<form method="post" action="options.php" enctype="multipart/form-data">
<?php settings_fields('plugin_options'); ?>
<?php do_settings_sections(__FILE__); ?>

<input name="Submit" type="submit" class="button-primary" value="<?php esc_attr_e('Save Changes'); ?>" />

</form>

<?php
}

// Banner Heading
function banner_heading_setting() {
   $options = get_option('plugin_options');
   echo "<input name='plugin_options[banner_heading]' type='text' value='{$options['banner_heading']}' />";
}

// Color Scheme
function color_scheme_setting() {
   $options = get_option('plugin_options');
   $items = array("White", "Black", "#DDDDDD", "#444444");

   echo "<select name='plugin_options[color_scheme]'>";
   foreach ($items as $item) {
      $selected = ( $options['color_scheme'] === $item ) ? 'selected = "selected"' : '';
      echo "<option value='$item' $selected>$item</option>";
   }
   echo "</select>";
}

// Advertising info
function advertising_information_setting() {
   $options = get_option('plugin_options');
   echo "<textarea name='plugin_options[advertising_information]' rows='10' cols='60' type='textarea'>{$options['advertising_information']}</textarea>";
}

// Ad one
function ad_setting_one() {
   echo '<input type="file" name="ad_one" />';
}

// Ad two
function ad_setting_two() {
   echo '<input type="file" name="ad_two" />';
}

// Logo
function logo_setting() {
   echo '<input type="file" name="logo" />';
}

function validate_setting($plugin_options) {
   $keys = array_keys($_FILES);
   $i = 0;

   foreach ($_FILES as $image) {
      // if a files was upload
      if ($image['size']) {
         // if it is an image
         if (preg_match('/(jpg|jpeg|png|gif)$/', $image['type'])) {
            $override = array('test_form' => false);
            $file = wp_handle_upload($image, $override);

            $plugin_options[$keys[$i]] = $file['url'];
         } else {
            $options = get_option('plugin_options');
            $plugin_options[$keys[$i]] = $options[$logo];
            wp_die('No image was uploaded.');
         }
      }

      // else, retain the image that's already on file.
      else {
         $options = get_option('plugin_options');
         $plugin_options[$keys[$i]] = $options[$keys[$i]];
      }
      $i++;
   }

   return $plugin_options;
}

function section_cb() {}

// Add stylesheet
add_action('admin_head', 'admin_register_head');

function admin_register_head() {
   $url = get_bloginfo('template_directory') . '/functions/options_page.css';
   echo "<link rel='stylesheet' href='$url' />\n";
}

Body:
Supply a proper handle when registering the menu page(fourth parameter).

Add menu example

Add top level menu page

add_menu_page( 'Theme Options', 'Theme Options', 'manage_options', 'my-theme-options', 'options_page_fn' );

Add submenu example

Add a submenu page to the new top level page

add_submenu_page( 'my-theme-options', 'Theme Sub1', 'Theme Sub1', 'manage_options', 'my-theme-options-subpage1', 'my_callback_function' );

Hope that helps..

And please consider posting your future WordPress questions on the WordPress Stack Exchange.

Regarding your main problem though, try updating the do_settings_section call to..

<?php do_settings_sections( 'main_section' ); ?>


问:
How to make localStorage and Cookies work like normal browsers in React Native?
Is there a way to configure localStorage and Cookies work like normal browsers in React Native?

Some websites or Web SDKs are using them to store login information.

The problem is that when I restart the React Native app, the user session is not recovered and I think it is because of the localStorage and Cookies
Any good solutions?

答:
First of all, storing "login information" in "local" might not be a good idea.

I don't have any information about how you are handling the authentication, or if you are only trying to use the local storage for in a "Remember me" way, for everytime user opens the app you will need to authenticate the user again. Using a 3rd party for this is your best and simplest bet. See auth0.com or similar services.

Also AsyncStorage is the equivalent of for localStorage in react-native.

See the documentation;

https://facebook.github.io/react-native/docs/asyncstorage.html


问:
Align vertical text next to the image
I'm trying to create exactly like what is shown in the picture below. So far, it's not looking good for me.

Here's the JSFiddle: https://jsfiddle.net/6o3nz6g9/

HTML:

```<code><h1>This is Sparta!</h1>
<div class="container">
<div class="row">
    <div class="col-xs-4">
        <div class="services__text">Title Text Here</div>
        <img src="https://image.ibb.co/hccDVF/sample.jpg" class="img-responsive" alt=""/>
    </div>
    <div class="col-xs-4">
        <div class="services__text">Title Text Here</div>
        <img src="https://image.ibb.co/hccDVF/sample.jpg" class="img-responsive" alt=""/>
    </div>
  <div class="col-xs-4">
        <div class="services__text">Title Text Here</div>
        <img src="https://image.ibb.co/hccDVF/sample.jpg" class="img-responsive" alt=""/>
    </div>
</div>
</div>
</code>```

CSS:

```<code>.services__text {
    -ms-transform: rotate(-90deg);
    -moz-transform: rotate(-90deg);
    -webkit-transform: rotate(-90deg);
    transform: rotate(-90deg);
    -ms-transform-origin: right top 0;
    -moz-transform-origin: right top 0;
    -webkit-transform-origin: right top 0;
    transform-origin: right top 0;
    padding: 10px;
    float: left;
}
</code>```

How do I do to get this desired effect? FYI: I'm working on Bootstrap framework.

答:
Hey Champ, You may solve your problem with following CSS

.services__text {
  position: absolute;
  text-align: right;
  -moz-transform: rotate(-90deg) translate(-100%, -100%);
  -webkit-transform: rotate(-90deg) translate(-100%, -100%);
  -o-transform: rotate(-90deg) translate(-100%, -100%);
  -ms-transform: rotate(-90deg) translate(-100%, -100%);
  transform: rotate(-90deg) translate(-100%, -100%);
  -ms-transform-origin: left top;
  -webkit-transform-origin: left top;
  transform-origin: left top;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<h1>This is Sparta!</h1>
<div class="container">
  <div class="row">
    <div class="col-xs-4">
      <div class="services__text">Title Text Here</div>
      <img src="https://image.ibb.co/hccDVF/sample.jpg" class="img-responsive" alt="" />
    </div>
    <div class="col-xs-4">
      <div class="services__text">Title Text Here</div>
      <img src="https://image.ibb.co/hccDVF/sample.jpg" class="img-responsive" alt="" />
    </div>
    <div class="col-xs-4">
      <div class="services__text">Title Text Here</div>
      <img src="https://image.ibb.co/hccDVF/sample.jpg" class="img-responsive" alt="" />
    </div>
  </div>
</div></code>```

Title: Align vertical text next to the image

Body:
I'm trying to create exactly like what is shown in the picture below. So far, it's not looking good for me.

Here's the JSFiddle: https://jsfiddle.net/6o3nz6g9/

HTML:

This is Sparta!

Title Text Here

Title Text Here

Title Text Here

CSS:

.services__text {
    -ms-transform: rotate(-90deg);
    -moz-transform: rotate(-90deg);
    -webkit-transform: rotate(-90deg);
    transform: rotate(-90deg);
    -ms-transform-origin: right top 0;
    -moz-transform-origin: right top 0;
    -webkit-transform-origin: right top 0;
    transform-origin: right top 0;
    padding: 10px;
    float: left;
}

How do I do to get this desired effect? FYI: I'm working on Bootstrap framework.

Body:
Hey Champ, You may solve your problem with following CSS

.services__text {
  position: absolute;
  text-align: right;
  -moz-transform: rotate(-90deg) translate(-100%, -100%);
  -webkit-transform: rotate(-90deg) translate(-100%, -100%);
  -o-transform: rotate(-90deg) translate(-100%, -100%);
  -ms-transform: rotate(-90deg) translate(-100%, -100%);
  transform: rotate(-90deg) translate(-100%, -100%);
  -ms-transform-origin: left top;
  -webkit-transform-origin: left top;
  transform-origin: left top;
}

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<h1>This is Sparta!</h1>
<div class="container">
  <div class="row">
    <div class="col-xs-4">
      <div class="services__text">Title Text Here</div>
      <img src="https://image.ibb.co/hccDVF/sample.jpg" class="img-responsive" alt="" />
    </div>
    <div class="col-xs-4">
      <div class="services__text">Title Text Here</div>
      <img src="https://image.ibb.co/hccDVF/sample.jpg" class="img-responsive" alt="" />
    </div>
    <div class="col-xs-4">
      <div class="services__text">Title Text Here</div>
      <img src="https://image.ibb.co/hccDVF/sample.jpg" class="img-responsive" alt="" />
    </div>
  </div>
</div>


问:
@aar' is not a valid maven coordinate
Android studio upgraded my gradle wrapper to gradle-4.1-milestone-1-all and seems to have broken the build. Getting the following error.

```<code>Gradle sync failed: java.lang.AssertionError: 'com.spotify.sdk:spotify-player-24-noconnect-2.20b:@aar' is not a valid maven coordinate.
</code>```

The dependancy is in my gradle script as an implementation and the arr is in my libs folder.

```<code>dependencies {
     implementation 'com.spotify.sdk:spotify-player-24-noconnect-2.20b@aar'
}
</code>```

Has anyone else come accross this error?

答: I am facing the same problem this morning. There's a Github issue that throws more light on the situation. It seems to be an Android Studio bug.</p>

Title: @aar' is not a valid maven coordinate

Body:
Android studio upgraded my gradle wrapper to gradle-4.1-milestone-1-all and seems to have broken the build. Getting the following error.

Gradle sync failed: java.lang.AssertionError: 'com.spotify.sdk:spotify-player-24-noconnect-2.20b:@aar' is not a valid maven coordinate.

The dependancy is in my gradle script as an implementation and the arr is in my libs folder.

dependencies {
     implementation 'com.spotify.sdk:spotify-player-24-noconnect-2.20b@aar'
}

Has anyone else come accross this error?


答:
I don't seem to understand why you would be splitting the sentence itself? Why not the other way around, you have the "highlights" as an array and you loop the highlight words, gsub'ing the sentence for each word, like:

```<code>sentence = 'I helped Adidas brand rebuild their design system'
highlights = ['adidas', 'brand']

highlights.each do |hl|
  sentence.gsub!(/\b#{hl}\b/i, "<span>#{hl}</span>")
end
puts sentence
  $ I helped <span>adidas</span> <span>brand</span> rebuild their design system
</code>```

If you need the case from the original sentence use:

```<code>sentence.gsub!(/\b#{hl}\b/i) { |w_capture| "<span>#{w_capture}</span>" }
</code>```

Since the highlights will be less words than the sentence itself it's also cheaper to loop them instead of all words in the sentence.

EDIT:

```<code>highlights = ['adidas', 'brand'] #lower case always
sentence = 'I helped Adidas brand rebuild their design system'
sentence.split(/\W+/).map { |w| highlights.include?(w.downcase) ? "<span class='class_1'>#{w} </span>" : "<span>#{w}</span>" }.join(' ') + "."
</code>```

outputs:

```<code>=> "<span>I</span> <span>helped</span> <span class='class_1'>Adidas</span> <span class='class_1'>brand</span> <span>rebuild</span> <span>their</span> <span>design</span> <span>system</span>."
</code>```

Title: Rails split sentence into separate words but substitute certain words

Body:
I don't seem to understand why you would be splitting the sentence itself? Why not the other way around, you have the "highlights" as an array and you loop the highlight words, gsub'ing the sentence for each word, like:

sentence = 'I helped Adidas brand rebuild their design system'
highlights = ['adidas', 'brand']

highlights.each do |hl|
  sentence.gsub!(/\b#{hl}\b/i, "<span>#{hl}</span>")
end
puts sentence
  $ I helped <span>adidas</span> <span>brand</span> rebuild their design system

If you need the case from the original sentence use:

sentence.gsub!(/\b#{hl}\b/i) { |w_capture| "<span>#{w_capture}</span>" }

Since the highlights will be less words than the sentence itself it's also cheaper to loop them instead of all words in the sentence.

EDIT:

highlights = ['adidas', 'brand'] #lower case always
sentence = 'I helped Adidas brand rebuild their design system'
sentence.split(/\W+/).map { |w| highlights.include?(w.downcase) ? "<span class='class_1'>#{w} </span>" : "<span>#{w}</span>" }.join(' ') + "."

outputs:

=> "<span>I</span> <span>helped</span> <span class='class_1'>Adidas</span> <span class='class_1'>brand</span> <span>rebuild</span> <span>their</span> <span>design</span> <span>system</span>."


问:
MySql - in one query how to get the Count of records by daywise, monthwise, yearwise and total records all time
i have a table where users enters data in every day basis

I need the query (in one query)  to the get the total number of records entered per day, per month, per year and all total group by user

any suggestions??

example output

```<code>username   count(today)   count(month)  count(year) count(*)
user1          10           100          1000       2300
user2           5           70            730        1240
</code>```

答:
Count, CASE and Group by will do it for you:

```<code>select user_name, sum(case when curdate()=date_time then 1 end) Today,
sum(case when Month(curdate())=Month(date_time) then 1 end) Month,
sum(case when year(curdate())=year(date_time) then 1 end) Year,
count(*)
from table1
group by user_name;
</code>```

REXTESTER

Body:
i have a table where users enters data in every day basis

I need the query (in one query)  to the get the total number of records entered per day, per month, per year and all total group by user

any suggestions??

example output

username   count(today)   count(month)  count(year) count(*)
user1          10           100          1000       2300
user2           5           70            730        1240

Body:
Count, CASE and Group by will do it for you:

select user_name, sum(case when curdate()=date_time then 1 end) Today,
sum(case when Month(curdate())=Month(date_time) then 1 end) Month,
sum(case when year(curdate())=year(date_time) then 1 end) Year,
count(*)
from table1
group by user_name;

REXTESTER


问:
WP7 dynamic controls
Is it possible to generate dynamic WP7 controls in code behind (.cs)  using  .xaml template (like inflating in Android) ,
 or should I generate it all manually? For example I need dynamic tabs (PivotItems)</p>

答:
You can definitely do this:

```<code>var newItem = new PivotItem { Header = "Added" };

MyPivot.Items.Add(newItem);
</code>```

Beware of potential performance implications of having lots of times though.

Title: WP7 dynamic controls

Body:
You can definitely do this:

var newItem = new PivotItem { Header = "Added" };

MyPivot.Items.Add(newItem);

Beware of potential performance implications of having lots of times though.


问:
Command line progress bar in Java
I have a Java program running in command line mode.
I would like to display a progress bar, showing the percentage of job done.
The same kind of progress bar you would see using wget under unix.
Is this possible?</p>

答:
```<code>public static void main(String[] argv) throws Exception{

    System.out.write("\r".getBytes());
    int percentage =10;
    while(percentage <= 100) {
        String temp =generateStars(percentage);
        System.out.write(temp.getBytes());
        System.out.print("\b\b\b");
        percentage = percentage+10;
        Thread.sleep(500);
    }
}

    public static String generateStars(int percentage)
    {
        int startsNum = percentage / 4;
        StringBuilder builder = new StringBuilder();
        while(startsNum >= 0)
        {
        builder.append("*");
        startsNum--;
        }
        builder.append(percentage+"%");
        return builder.toString();
    }
</code>```

Title: Command line progress bar in Java


问:
Dart strong mode: error on anonymous function return
I get the following error.
The argument type 'dynamic' can't be assigned to the parameter type '() -> dynamic'
The example is:

```<code>outerFunc(somevar) {
    return () {....}
}
anOtherFunction(func()) {....}

anOtherFunction(outerFunc('test'));
</code>```

These occurs when I return an anonymous function, in strong mode with the analysis_options.yaml on.

```<code>strong-mode:
  implicit-casts: false
</code>```

答:
outerFunc doesn't specify a return type, therefore dynamic is assumed.
You can create a typedef and use it as return type for outerFunc.
The function type can't be inferred from the return statement.

typedef dynamic F();

F outerFunc(somevar) {
  return () {};
}
```

<p>You can also write the function type in-line</p>

<pre class="lang-dart prettyprint-override"><code>dynamic Function() outerFunc(somevar) {
  return () {};
}
</code>```

Body:
I get the following error.
The argument type 'dynamic' can't be assigned to the parameter type '() -> dynamic'
The example is:

outerFunc(somevar) {
    return () {....}
}
anOtherFunction(func()) {....}

anOtherFunction(outerFunc('test'));

These occurs when I return an anonymous function, in strong mode with the analysis_options.yaml on.

strong-mode:
  implicit-casts: false

Body:
outerFunc doesn't specify a return type, therefore dynamic is assumed.
You can create a typedef and use it as return type for outerFunc.
The function type can't be inferred from the return statement.

typedef dynamic F();

F outerFunc(somevar) {
  return () {};
}

You can also write the function type in-line

dynamic Function() outerFunc(somevar) {
  return () {};
}


问:
Contact Form 7 Conditional fields with auto filling field
How to show conditional calculation in contact form 7 ?

For Example:
i have a form with two field such as student number and payment amount.

one student fee is $10.

so if user entering student count in the first field need to display student fee automatically into the payment field.

that is if student count is 2, then the second field want to display amount as $20.

its possible in contact form 7 plugin?
Thanks

答:
you can do this with jquery. For example cf7 shortcode like this

```<code>[text* qty id:qty ]
[text* price id:price readonly]  (Readonly for not editable fields)
[text subtotal id:total class:total readonly]
</code>```

jquery code: (Include in separate js file)

```<code>$(document).ready(function(){
    var qty=$("#qty");
    qty.keyup(function(){
        var total=isNaN(parseInt(qty.val() $("#price").val())) ? 0 :
        $(qty.val() $("#price").val())
        $("#total").val(total);
    });
});
</code>```

http://jsfiddle.net/ugPxf/

contact form 7 backend screenshot

Body:
you can do this with jquery. For example cf7 shortcode like this

[text* qty id:qty ]
[text* price id:price readonly]  (Readonly for not editable fields)
[text subtotal id:total class:total readonly]

jquery code: (Include in separate js file)

$(document).ready(function(){
    var qty=$("#qty");
    qty.keyup(function(){
        var total=isNaN(parseInt(qty.val() $("#price").val())) ? 0 :
        $(qty.val() $("#price").val())
        $("#total").val(total);
    });
});

http://jsfiddle.net/ugPxf/

contact form 7 backend screenshot


问:
Unit Testing Local Asp WebForm
I am new at unit testing. The tool I am using is Selenium webdriver in visual studio
For practice I initially redirected to different Urls and tested their controls to find that the working is correct. Then I created my own Asp webform for the testing purpose. So what I want now is to redirect to the localhost web form in the test method which I am not able to do.
even if I do so:

```<code>    [TestMethod]

    public void TestAspForm()
    {
        driverGC.Url = ("http://localhost:55311/AspForm.aspx");
     }
</code>```

The page never loads.I get the following:
 Can someone please guide me??

答:
First, you need to run server, then run test. It seems that you dont have server runned.

its navigating to your page.

```<code>ChromeDriver driver;
[TestMethod]
public void TestAspForm()
{
   driver.Navigate().GoToUrl("http://localhost:55311/AspForm.aspx");
}
</code>```

try driver.Navigate().GoToUrl("www.google.com"); and you will see that its navigating properly to page.

Title: Unit Testing Local Asp WebForm

Body:
I am new at unit testing. The tool I am using is Selenium webdriver in visual studio
For practice I initially redirected to different Urls and tested their controls to find that the working is correct. Then I created my own Asp webform for the testing purpose. So what I want now is to redirect to the localhost web form in the test method which I am not able to do.
even if I do so:

    [TestMethod]

    public void TestAspForm()
    {
        driverGC.Url = ("http://localhost:55311/AspForm.aspx");
     }

The page never loads.I get the following:
 Can someone please guide me??

Body:
First, you need to run server, then run test. It seems that you dont have server runned.

its navigating to your page.

ChromeDriver driver;
[TestMethod]
public void TestAspForm()
{
   driver.Navigate().GoToUrl("http://localhost:55311/AspForm.aspx");
}

try driver.Navigate().GoToUrl("www.google.com"); and you will see that its navigating properly to page.


问:
No need to cast the result of findViewById?
Recently I found that AndroidStudio reminds me to remove some class cast. I remember that in the old time, we have to cast the result of findViewById, but now it's not necessary.

The result of findViewById is still View, so i want to know why we don't need to cast the class?

I can't find any documents mentioned that, can anyone find any document?

答:
Android Studio reminds to remove casting, if you use common attributes from View class, like visibility or some common methods, like onClick()

For example:

```<code>((ImageView) findViewById(R.id.image_car)).setVisibility(View.VISIBLE);
</code>```

In this case you can simply write:

```<code>findViewById(R.id.image_car).setVisibility(View.VISIBLE);
</code>```

ContentLicense: CC BY-SA 4.0

Body:
Android Studio reminds to remove casting, if you use common attributes from View class, like visibility or some common methods, like onClick()

For example:

((ImageView) findViewById(R.id.image_car)).setVisibility(View.VISIBLE);

In this case you can simply write:

findViewById(R.id.image_car).setVisibility(View.VISIBLE);


问:
DataTables doesn't work in IE-8/below
I am using DataTables to display the data in a tabular form with some pagination and sorting. It is working perfectly fine in all browsers but in IE it doesn't work in 8 and below versions. According to the documentations here it should work form IE-6+.

The way I tested it, by just pressing the F12 key and change the browser versions. Not sure if this is the right way to test it but I would like to know if anyinw has faced the same issue. I am using the following CDNs. Please let me know if this is the right way to test Datatables in different versions of IE.

```<code><script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.15/css/jquery.dataTables.css">
<script type="text/javascript" charset="utf8" src="//cdn.datatables.net/1.10.15/js/jquery.dataTables.js"></script>
<script type="text/javascript" charset="utf8" src="//cdn.datatables.net/plug-ins/1.10.15/pagination/input.js"></script>
<link href="http://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">
</code>```

Thanks

答:
This is jQuery issue, not a dataTables issue...Downgrade your jQuery version from 3.2.1 to 1.2.x or below, and it will work.

The current jQuery version (3.2.1) does only support IE 9+. Support for 6-8 was actually dropped already in 2.x.

Personally I use 1.9.1 in all my projects. I Have no problems with older browsers or any mobile devices or tablets. I use latest version of dataTables along with latest Angular 1.x. If you not have any particular reason for using jQuery 2.x or 3.x, then 1.9.1 is as good as any version.

Title: DataTables doesn't work in IE-8/below

Body:
I am using DataTables to display the data in a tabular form with some pagination and sorting. It is working perfectly fine in all browsers but in IE it doesn't work in 8 and below versions. According to the documentations here it should work form IE-6+.

The way I tested it, by just pressing the F12 key and change the browser versions. Not sure if this is the right way to test it but I would like to know if anyinw has faced the same issue. I am using the following CDNs. Please let me know if this is the right way to test Datatables in different versions of IE.

<link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.15/css/jquery.dataTables.css">

<link href="http://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">

Thanks


问:
C#: how to use Microsoft.Win32.SafeHandles
Why does
using Microsoft.Win32.SafeHandles
cause the C# Compiler Error:

The type or namespace name
  'SafeHandles' does not exist in the
  namespace 'Microsoft.Win32'

This code is lifted from http://zachsaw.blogspot.com/2010/07/serialport-ioexception-workaround-in-c.html

答: The problem is that you're trying to use sample code written for the normal .Net Framework in a Compact Framework project. This class is not supported by the CF.</p>


问:
Jquery didn't identify the min max float number
I am Working on Two Select Box In which User Simply select Min & Max Value from Dropdown.

I am Simply Preventing a User to select Max Value which is less than Min Value.

I am Using Jquery to Prevent the user to select the "Max Value Which is Less then Min Value"

Case 1: Example If the user selects 4.6 from Min Select Box and If
  select option less then 4.6 then it gives an error message.  But
  Problem is that if User Select options 10, 11, 12+ then it gives
  an error.

$('body').on('change', '#exp_max', function() {

  var min_exp = $('#exp_min').val();
  var max_exp = $(this).val();
  if (max_exp < min_exp) {
    console.log('Max Experience Cannot be Less then Min Experience');
    // $.Notification.autoHideNotify('error', 'top right', 'Max Experience Cannot be Less then Min Experience.','Experience');
    $(this).prop('selectedIndex', 0);
  }
});```
<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>

<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>

<div class="col-lg-5">
  <select class="form-control" required data-parsley-minlength="1" id="exp_min" name="exp_min">
    <option value="">Min</option>
    <option value="-1">Last Year Student</option>
    <option value="0">Fresher</option>
    <option value="0.6" >0.6</option>
    <option value="1">1</option>
    <option value="1.6" >1.6</option>
    <option value="2">2</option>
    <option value="2.6">2.6</option>
    <option value="3">3</option>
    <option value="3.6">3.6</option>
    <option value="4">4</option>
    <option value="4.6">4.6</option>
    <option value="5">5</option>
    <option value="6">6</option>
    <option value="7">7</option>
    <option value="8">8</option>
    <option value="9">9</option>
    <option value="10">10</option>
    <option value="11">11</option>
    <option value="12">12+</option>
   </select>
</div>
<div class="col-lg-5">
  <select class="form-control" data-parsley-type="number" id="exp_max" name="exp_max">
    <option value="">Max</option>
    <option value="1">1</option>
    <option value="1.6">1.6</option>
    <option value="2">2</option>
    <option value="2.6">2.6</option>
    <option value="3">3</option>
    <option value="3.6">3.6</option>
    <option value="4">4</option>
    <option value="4.6">4.6</option>
    <option value="5">5</option>
    <option value="6">6</option>
    <option value="7">7</option>
    <option value="8">8</option>
    <option value="9">9</option>
    <option value="10">10</option>
    <option value="11">11</option>
    <option value="12">12+</option>
   </select>
</div></code>```

答:
You can use parseFloat, below is the updated code:

$('body').on('change', '#exp_max', function() {

  var min_exp = $('#exp_min').val();
  var max_exp = $(this).val();
  if (parseFloat(max_exp) < parseFloat(min_exp)) {
   console.log('Max Experience Cannot be Less then Min Experience');
    //$.Notification.autoHideNotify('error', 'top right', 'Max Experience Cannot be Less then Min Experience.', 'Experience');
    $(this).prop('selectedIndex', 0);
  }
});```
<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="col-lg-5">
  <select class="form-control" required data-parsley-minlength="1" id="exp_min" name="exp_min">
   <option value="">Min</option>
   <option value="-1">Last Year Student</option>
   <option value="0">Fresher</option>
   <option value="0.6" >0.6</option>
   <option value="1">1</option>
   <option value="1.6" >1.6</option>
   <option value="2">2</option>
   <option value="2.6">2.6</option>
   <option value="3">3</option>
   <option value="3.6">3.6</option>
   <option value="4">4</option>
   <option value="4.6">4.6</option>
   <option value="5">5</option>
   <option value="6">6</option>
   <option value="7">7</option>
   <option value="8">8</option>
   <option value="9">9</option>
   <option value="10">10</option>
   <option value="11">11</option>
   <option value="12">12+</option>
  </select>
</div>
<div class="col-lg-5">
  <select class="form-control" data-parsley-type="number" id="exp_max" name="exp_max">
   <option value="">Max</option>
   <option value="1">1</option>
   <option value="1.6">1.6</option>
   <option value="2">2</option>
   <option value="2.6">2.6</option>
   <option value="3">3</option>
   <option value="3.6">3.6</option>
   <option value="4">4</option>
   <option value="4.6">4.6</option>
   <option value="5">5</option>
   <option value="6">6</option>
   <option value="7">7</option>
   <option value="8">8</option>
   <option value="9">9</option>
   <option value="10">10</option>
   <option value="11">11</option>
   <option value="12">12+</option>
  </select>
</div></code>```

Body:
I am Working on Two Select Box In which User Simply select Min & Max Value from Dropdown.

I am Simply Preventing a User to select Max Value which is less than Min Value.

I am Using Jquery to Prevent the user to select the "Max Value Which is Less then Min Value"

Case 1: Example If the user selects 4.6 from Min Select Box and If
  select option less then 4.6 then it gives an error message.  But
  Problem is that if User Select options 10, 11, 12+ then it gives
  an error.

$('body').on('change', '#exp_max', function() {

  var min_exp = $('#exp_min').val();
  var max_exp = $(this).val();
  if (max_exp < min_exp) {
    console.log('Max Experience Cannot be Less then Min Experience');
    // $.Notification.autoHideNotify('error', 'top right', 'Max Experience Cannot be Less then Min Experience.','Experience');
    $(this).prop('selectedIndex', 0);
  }
});

  <select class="form-control" required data-parsley-minlength="1" id="exp_min" name="exp_min">
    <option value="">Min</option>
    <option value="-1">Last Year Student</option>
    <option value="0">Fresher</option>
    <option value="0.6" >0.6</option>
    <option value="1">1</option>
    <option value="1.6" >1.6</option>
    <option value="2">2</option>
    <option value="2.6">2.6</option>
    <option value="3">3</option>
    <option value="3.6">3.6</option>
    <option value="4">4</option>
    <option value="4.6">4.6</option>
    <option value="5">5</option>
    <option value="6">6</option>
    <option value="7">7</option>
    <option value="8">8</option>
    <option value="9">9</option>
    <option value="10">10</option>
    <option value="11">11</option>
    <option value="12">12+</option>
   </select>

  <select class="form-control" data-parsley-type="number" id="exp_max" name="exp_max">
    <option value="">Max</option>
    <option value="1">1</option>
    <option value="1.6">1.6</option>
    <option value="2">2</option>
    <option value="2.6">2.6</option>
    <option value="3">3</option>
    <option value="3.6">3.6</option>
    <option value="4">4</option>
    <option value="4.6">4.6</option>
    <option value="5">5</option>
    <option value="6">6</option>
    <option value="7">7</option>
    <option value="8">8</option>
    <option value="9">9</option>
    <option value="10">10</option>
    <option value="11">11</option>
    <option value="12">12+</option>
   </select>

Body:
You can use parseFloat, below is the updated code:

$('body').on('change', '#exp_max', function() {

  var min_exp = $('#exp_min').val();
  var max_exp = $(this).val();
  if (parseFloat(max_exp) < parseFloat(min_exp)) {
   console.log('Max Experience Cannot be Less then Min Experience');
    //$.Notification.autoHideNotify('error', 'top right', 'Max Experience Cannot be Less then Min Experience.', 'Experience');
    $(this).prop('selectedIndex', 0);
  }
});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<div class="col-lg-5">
  <select class="form-control" required data-parsley-minlength="1" id="exp_min" name="exp_min">
   <option value="">Min</option>
   <option value="-1">Last Year Student</option>
   <option value="0">Fresher</option>
   <option value="0.6" >0.6</option>
   <option value="1">1</option>
   <option value="1.6" >1.6</option>
   <option value="2">2</option>
   <option value="2.6">2.6</option>
   <option value="3">3</option>
   <option value="3.6">3.6</option>
   <option value="4">4</option>
   <option value="4.6">4.6</option>
   <option value="5">5</option>
   <option value="6">6</option>
   <option value="7">7</option>
   <option value="8">8</option>
   <option value="9">9</option>
   <option value="10">10</option>
   <option value="11">11</option>
   <option value="12">12+</option>
  </select>
</div>
<div class="col-lg-5">
  <select class="form-control" data-parsley-type="number" id="exp_max" name="exp_max">
   <option value="">Max</option>
   <option value="1">1</option>
   <option value="1.6">1.6</option>
   <option value="2">2</option>
   <option value="2.6">2.6</option>
   <option value="3">3</option>
   <option value="3.6">3.6</option>
   <option value="4">4</option>
   <option value="4.6">4.6</option>
   <option value="5">5</option>
   <option value="6">6</option>
   <option value="7">7</option>
   <option value="8">8</option>
   <option value="9">9</option>
   <option value="10">10</option>
   <option value="11">11</option>
   <option value="12">12+</option>
  </select>
</div>


问:
CATIA VBA Measure a user selected line(s)/spline
I am trying to get the length of user selected lines/splines

This is the code I'm using to have users select their lines:

```<code>Dim USel As Selection
Dim USelLB
Dim InputObject(0)

InputObject(0) = "AnyObject"
Set USel = CATIA.ActiveDocument.Selection
Set USelLB = USel

USel.Clear
USelLB.Clear

Linestomeasure = USelLB.SelectElement3(InputObject, "Select objects to list names", True, CATMultiSelTriggWhenUserValidatesSelection, False)
</code>```

Linestomeasure is a public variable, in the mainsub i've been trying to measure Linestomeasure using the following code:

```<code>Dim pd1 As PartDocument
Dim a As Object
Dim c As Reference

a = TrimLines.Item(1)
c = pd1.Part.CreateReferenceFromObject(a)

Dim Mea1 As Measurable
Dim TheSPAWorkbench As SPAWorkbench
Set TheSPAWorkbench = pd1.GetWorkbench("SPAWorkbench")
Set Mea1 = TheSPAWorkbench.GetMeasurable(c)
</code>```

But when I run the code a = trimLines.Item(1) gets highlighted in the debugger with the error message "Object Required".

Does anyone have an idea on how I can change my code so that I can get the length of the line as a variable that I can work with ? Or just a different way to go about what I'm trying to do?

答:
Edited answer to reflect comment bellow

Looks like you are assigning the wrong type of variable to the USelLB.SelectElement3 and also missunderstanding how it actually works.

The Selection.SelectElement3 returns a String that reflects whether the selection was sucessfull or not.

The Object retrieved from the Selection is inside the Selection.Item(Index)

Your code should be something like this:

```<code>Dim PD1 as PartDocument
Dim Sel 'as Selection 'Sometimes it is needed to comment the selection to use the .SelectElement3 method
Dim InputObjType(0)
Dim SelectionResult as string
Dim LineToMeasure as AnyObject
Dim I as Integer
Dim SpaWorkbench as SPAWorkbench
Dim Measurable as Measurable

InputObjType(0) = "AnyObject"

'set PD1 = Catia.ActiveDocument
set Sel = PD1.Selection
Set TheSPAWorkbench = pd1.GetWorkbench("SPAWorkbench")

Sel.Clear
SelectionResult= Sel.SelectElement3(InputObject, "Select objects to list names", True, CATMultiSelTriggWhenUserValidatesSelection, False)

If SelectionResult = "Ok" or SelectionResult = "Normal" then 'Check if user did not cancel the Selection
    For i = 1 to Selection.Count
        Set LineToMeasure = Sel.Item(i).Value
        set Measurable = SpaWorkbench.GetMeasurable(LineToMeasure)

        'Measure whatever you need here.
    Next
End If
</code>```

Keep in mind that using the AnyObject type filter may cause the user to select unwanted objects. You shoudl use a more specific filter.

Body:
I am trying to get the length of user selected lines/splines

This is the code I'm using to have users select their lines:

Dim USel As Selection
Dim USelLB
Dim InputObject(0)

InputObject(0) = "AnyObject"
Set USel = CATIA.ActiveDocument.Selection
Set USelLB = USel

USel.Clear
USelLB.Clear

Linestomeasure = USelLB.SelectElement3(InputObject, "Select objects to list names", True, CATMultiSelTriggWhenUserValidatesSelection, False)

Linestomeasure is a public variable, in the mainsub i've been trying to measure Linestomeasure using the following code:

Dim pd1 As PartDocument
Dim a As Object
Dim c As Reference

a = TrimLines.Item(1)
c = pd1.Part.CreateReferenceFromObject(a)

Dim Mea1 As Measurable
Dim TheSPAWorkbench As SPAWorkbench
Set TheSPAWorkbench = pd1.GetWorkbench("SPAWorkbench")
Set Mea1 = TheSPAWorkbench.GetMeasurable(c)

But when I run the code a = trimLines.Item(1) gets highlighted in the debugger with the error message "Object Required".

Does anyone have an idea on how I can change my code so that I can get the length of the line as a variable that I can work with ? Or just a different way to go about what I'm trying to do?

Body:
Edited answer to reflect comment bellow

Looks like you are assigning the wrong type of variable to the USelLB.SelectElement3 and also missunderstanding how it actually works.

The Selection.SelectElement3 returns a String that reflects whether the selection was sucessfull or not.

The Object retrieved from the Selection is inside the Selection.Item(Index)

Your code should be something like this:

Dim PD1 as PartDocument
Dim Sel 'as Selection 'Sometimes it is needed to comment the selection to use the .SelectElement3 method
Dim InputObjType(0)
Dim SelectionResult as string
Dim LineToMeasure as AnyObject
Dim I as Integer
Dim SpaWorkbench as SPAWorkbench
Dim Measurable as Measurable

InputObjType(0) = "AnyObject"

'set PD1 = Catia.ActiveDocument
set Sel = PD1.Selection
Set TheSPAWorkbench = pd1.GetWorkbench("SPAWorkbench")

Sel.Clear
SelectionResult= Sel.SelectElement3(InputObject, "Select objects to list names", True, CATMultiSelTriggWhenUserValidatesSelection, False)

If SelectionResult = "Ok" or SelectionResult = "Normal" then 'Check if user did not cancel the Selection
    For i = 1 to Selection.Count
        Set LineToMeasure = Sel.Item(i).Value
        set Measurable = SpaWorkbench.GetMeasurable(LineToMeasure)

        'Measure whatever you need here.
    Next
End If

Keep in mind that using the AnyObject type filter may cause the user to select unwanted objects. You shoudl use a more specific filter.


答:
I think you are looking for this:</p>

```<code>    sentence = 'I helped Adidas brand rebuild their design system'
    sentenceHighlight = 'Adidas brand'
    (sentence.split(/\W+/) - sentenceHighlight.split(/\W+/)).each{|s| sentence.sub!(s, "<span>#{s}</span>")}
    sentenceHighlight.split(/\W+/).each{|s| sentence.sub!(s, "<span class='highlighted'>#{s}</span>")}

sentence
#=> "<span>I</span> <span>helped</span> <span class='highlighted'>Adidas</span> <span class='highlighted'>brand</span>  <span>rebuild</span> <span>their</span> <span>design</span> <span>system</span>"
</code>```

Body:
What the goal is

I
helped
the
Adidas
brand
rebuild
their
design
system

Got a Rails project I'm working on. I've got data that forms a sentence like so:

sentence = 'I helped Adidas rebuild their design system'

I can separate the words with sentence.split(/\W+/) and I get:

[I] [helped] [Adidas] [rebuild] [their] [design] [system]

But I would like to highlight the word Adidas by wrapping it in a class.

Sometimes that highlighted word can be a combination of words like Adidas brand

For that I tried doing:

sentence.sub(sentenceHighlight, "#{sentenceHighlight}")

Which gives me:

I helped the Adidas brand rebuild their design system

While that works fine I still need each of the words to be separate like in the example above.

Does anyone know how I can combine the two methods nicely in a clean code?

Body:
I think you are looking for this:

    sentence = 'I helped Adidas brand rebuild their design system'
    sentenceHighlight = 'Adidas brand'
    (sentence.split(/\W+/) - sentenceHighlight.split(/\W+/)).each{|s| sentence.sub!(s, "<span>#{s}</span>")}
    sentenceHighlight.split(/\W+/).each{|s| sentence.sub!(s, "<span class='highlighted'>#{s}</span>")}

sentence
#=> "<span>I</span> <span>helped</span> <span class='highlighted'>Adidas</span> <span class='highlighted'>brand</span>  <span>rebuild</span> <span>their</span> <span>design</span> <span>system</span>"