问:
How to use svg icon set package from node_modules in angular4?
I have found this open source icon package which I installed in my project featherIcons, and is listed inside my_modules directory. However Im trying to use it but I just cant seem to make it work.

The issue is, I think I have to be somehow importing the package but not sure how or where.

app-component.html

Platform

Stix/Taxi

Menu

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

<p><strong><code>app.module.ts</code></strong></p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';

import { RoutingModule } from './routing.module';
import { SharedModule } from './shared/shared.module';
import { CatService } from './services/cat.service';
import { UserService } from './services/user.service';
import { AuthService } from './services/auth.service';
import { AuthGuardLogin } from './services/auth-guard-login.service';
import { AuthGuardAdmin } from './services/auth-guard-admin.service';
import { AppComponent } from './app.component';
import { CatsComponent } from './cats/cats.component';
import { AboutComponent } from './about/about.component';
import { RegisterComponent } from './register/register.component';
import { LoginComponent } from './login/login.component';
import { LogoutComponent } from './logout/logout.component';
import { AccountComponent } from './account/account.component';
import { AdminComponent } from './admin/admin.component';
import { NotFoundComponent } from './not-found/not-found.component';

@NgModule({
  declarations: [
    AppComponent,
    CatsComponent,
    AboutComponent,
    RegisterComponent,
    LoginComponent,
    LogoutComponent,
    AccountComponent,
    AdminComponent,
    NotFoundComponent
  ],
  imports: [
    RoutingModule,
    SharedModule
  ],
  providers: [
    AuthService,
    AuthGuardLogin,
    AuthGuardAdmin,
    CatService,
    UserService
  ],
  schemas: [CUSTOM_ELEMENTS_SCHEMA],
  bootstrap: [AppComponent]
})

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

Any help would be appreciated

答:
Nevermind, I figured the solution, and I'll post the solution here so that it can help the rest.

So as the library states in the link provided, I had to install it like so

npm install feather-icons --save - the --save is very important because it will be referenced in my package.json. Once installed, you will be able to see it in node_modules directory.

Then in which ever component I want to use the library, all I had to do is import it the following way:

Since I wanted to use an icon from the library in app.component.ts:

app.component.ts

import {Component, OnInit} from '@angular/core';
import { AuthService } from './services/auth.service';

/*
- feather-icons is a directory installed in node_modules.
- I dont have to specify the whole path like '../node_modules/path/to/feather-icons'.
- Also rememeber to call the feather.replace() inside ngOnInit
- because it needs to first make sure the component loads first
*/
import * as feather from 'feather-icons';

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

  constructor (
    public auth: AuthService
  ) { }

  ngOnInit() {
    feather.replace();
  }

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

<p>Then in my <code>app.component.html</code>:</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="navbar__nav-container">
  <ul class="navbar__nav-container__nav-items">
    <li>Platform</li>
    <li>Stix/Taxi</li>
    <li>Menu</li>
    <li>
      <i data-feather="circle"></i>
    </li>
  </ul>
</div></code>```

This was all to it to be honest.

Hope this helps :)

Body:
I have found this open source icon package which I installed in my project featherIcons, and is listed inside my_modules directory. However Im trying to use it but I just cant seem to make it work.

The issue is, I think I have to be somehow importing the package but not sure how or where.

app-component.html

Platform

Stix/Taxi

Menu

app.module.ts

import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';

import { RoutingModule } from './routing.module';
import { SharedModule } from './shared/shared.module';
import { CatService } from './services/cat.service';
import { UserService } from './services/user.service';
import { AuthService } from './services/auth.service';
import { AuthGuardLogin } from './services/auth-guard-login.service';
import { AuthGuardAdmin } from './services/auth-guard-admin.service';
import { AppComponent } from './app.component';
import { CatsComponent } from './cats/cats.component';
import { AboutComponent } from './about/about.component';
import { RegisterComponent } from './register/register.component';
import { LoginComponent } from './login/login.component';
import { LogoutComponent } from './logout/logout.component';
import { AccountComponent } from './account/account.component';
import { AdminComponent } from './admin/admin.component';
import { NotFoundComponent } from './not-found/not-found.component';

@NgModule({
  declarations: [
    AppComponent,
    CatsComponent,
    AboutComponent,
    RegisterComponent,
    LoginComponent,
    LogoutComponent,
    AccountComponent,
    AdminComponent,
    NotFoundComponent
  ],
  imports: [
    RoutingModule,
    SharedModule
  ],
  providers: [
    AuthService,
    AuthGuardLogin,
    AuthGuardAdmin,
    CatService,
    UserService
  ],
  schemas: [CUSTOM_ELEMENTS_SCHEMA],
  bootstrap: [AppComponent]
})

export class AppModule { }

Any help would be appreciated

Body:
Nevermind, I figured the solution, and I'll post the solution here so that it can help the rest.

So as the library states in the link provided, I had to install it like so

npm install feather-icons --save - the --save is very important because it will be referenced in my package.json. Once installed, you will be able to see it in node_modules directory.

Then in which ever component I want to use the library, all I had to do is import it the following way:

Since I wanted to use an icon from the library in app.component.ts:

app.component.ts

import {Component, OnInit} from '@angular/core';
import { AuthService } from './services/auth.service';

/*
- feather-icons is a directory installed in node_modules.
- I dont have to specify the whole path like '../node_modules/path/to/feather-icons'.
- Also rememeber to call the feather.replace() inside ngOnInit
- because it needs to first make sure the component loads first
*/
import * as feather from 'feather-icons';

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

  constructor (
    public auth: AuthService
  ) { }

  ngOnInit() {
    feather.replace();
  }

}

Then in my app.component.html:

<div class="navbar__nav-container">
  <ul class="navbar__nav-container__nav-items">
    <li>Platform</li>
    <li>Stix/Taxi</li>
    <li>Menu</li>
    <li>
      <i data-feather="circle"></i>
    </li>
  </ul>
</div>

This was all to it to be honest.

Hope this helps :)


来源: stackexchange

问:
Display files in a directory list control
Is there a way for user to select a specific file using BrowseDlg? All i can find is that you can select only a folder!! I believe File selection is one of the "common" functionality in use.

Can anyone provide some suggestion on how this can be achieved.

Thanks!

Update

I am thinking of creating a C# custom aciton for this, as all other CA in project are in C#. But I am not sure about few things....

How can I sequence this CA dialog with my exsiting UI sequence.

How to trigger a CA on a button click from one of my custom dialog.

How to get the file path back from File Browse CA to be further used by WIX.

The other CAs that I have created does not have any UI associated.

Please advice.
Thanks!

答:
Actually, Windows Installer doesn't have anything built-in for the "Browse for file" dialog. Various vendors offer their custom solutions, like Advanced Installer and InstallShield.

Anyway, this all ends up in a custom dialog and custom action for Browse button. You can find an example of this here (search for "File Browse Dialog" on that page). The package you'll find contains the custom action, sample solution and some notes. It is based on InstallShield, but you can take at least custom action from there (creating a custom dialog in WiX is not that hard). As a last resort, you can try to implement this CA yourself.

ContentLicense: CC BY-SA 3.0

ContentLicense: CC BY-SA 2.5


问:
Angular2 Ionic2 Can't resolve all parameters for GameServiceProvider: (?)
```<code>Runtime Error
Can't resolve all parameters for GameServiceProvider: (?).

Error: Can't resolve all parameters for GameServiceProvider: (?).
    at syntaxError (http://localhost:8100/build/main.js:78899:34)
    at CompileMetadataResolver._getDependenciesMetadata (http://localhost:8100/build/main.js:92236:35)
    at CompileMetadataResolver._getTypeMetadata (http://localhost:8100/build/main.js:92104:26)
    at CompileMetadataResolver._getInjectableMetadata (http://localhost:8100/build/main.js:92090:21)
    at CompileMetadataResolver.getProviderMetadata (http://localhost:8100/build/main.js:92380:40)
    at http://localhost:8100/build/main.js:92309:49
    at Array.forEach (<anonymous>)
    at CompileMetadataResolver._getProvidersMetadata (http://localhost:8100/build/main.js:92270:19)
    at CompileMetadataResolver.getNonNormalizedDirectiveMetadata (http://localhost:8100/build/main.js:91700:30)
    at CompileMetadataResolver._getEntryComponentMetadata (http://localhost:8100/build/main.js:92357:45)
</code>```

I have two providers bot and game-service

This is my game-service provider inside providers/games-service/game-service.ts

import { Injectable } from '@angular/core';
import { Component } from '@angular/core';
import { BotProvider } from '../bot/bot';
@Component({
  providers: [BotProvider]
})
 @Injectable()
export class GameServiceProvider {
 ... vars i have to use some in Botprovider aswell ...
 constructor(public bot: BotProvider){
 }
 ... functions ...
}```
</div>
</div>
</p>

<p>this is my bot provider inside providers/bot/bot.ts</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>import { Injectable, Component } from '@angular/core';
import { GameServiceProvider } from '../game-service/game-service';
@Component({
  providers: [GameServiceProvider]
})
@Injectable()
export class BotProvider {
 constructor(public gs: GameServiceProvider) {}
 .. functions ..
}</code>```

Both where created via ionic generate provider {{NAME}}

My app.compoment.ts

import { Component } from '@angular/core';
import { Platform } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import { BotProvider } from '../providers/bot/bot';
import { GameServiceProvider } from '../providers/game-service/game-service';

import { LoginPage } from '../pages/login/login';
import { HomePage } from '../pages/home/home';
@Component({
  templateUrl: 'app.html',
  providers: [GameServiceProvider,BotProvider]
})
export class MyApp {
  rootPage:any = HomePage;

  constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen) {
    platform.ready().then(() => {
      // Okay, so the platform is ready and our plugins are available.
      // Here you can do any higher level native things you might need.
      statusBar.styleDefault();
      splashScreen.hide();
    });
  }```
</div>
</div>
</p>

<p>My app.module.ts</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>import { BrowserModule } from '@angular/platform-browser';
import { ErrorHandler, NgModule } from '@angular/core';
import { MaterialModule } from '@angular/material';
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
import { SplashScreen } from '@ionic-native/splash-screen';
import { StatusBar } from '@ionic-native/status-bar';
import { GooglePlus } from '@ionic-native/google-plus';

import { MyApp } from './app.component';
import { HomePage } from '../pages/home/home';
import { GamePage } from '../pages/game/game';
import { LoginPage } from '../pages/login/login';
import { BotProvider } from '../providers/bot/bot';
import { GameServiceProvider } from '../providers/game-service/game-service';

@NgModule({
  declarations: [
    MyApp,
    HomePage,
    GamePage,
    LoginPage
  ],
  imports: [
    BrowserModule,
    IonicModule.forRoot(MyApp),
    MaterialModule
  ],
  bootstrap: [IonicApp],
  entryComponents: [
    MyApp,
    HomePage,
    GamePage,
    LoginPage
  ],
  providers: [
    StatusBar,
    SplashScreen,
    GooglePlus,
    {provide: ErrorHandler, useClass: IonicErrorHandler},
    BotProvider,
    GameServiceProvider
  ]
})
export class AppModule {}</code>```

Should i write another Provider that contains just the stuff both Provider need or is it possible that one provider has a provider in its constructor and vise versa

Have a nice weekend!

答:
There are more than one references to GameServiceProvider viz.,

AppModule

BotProvider

MyApp

Remove the providers block in each files and have it globally in the AppModule

Body:
Runtime Error
Can't resolve all parameters for GameServiceProvider: (?).

Error: Can't resolve all parameters for GameServiceProvider: (?).
    at syntaxError (http://localhost:8100/build/main.js:78899:34)
    at CompileMetadataResolver._getDependenciesMetadata (http://localhost:8100/build/main.js:92236:35)
    at CompileMetadataResolver._getTypeMetadata (http://localhost:8100/build/main.js:92104:26)
    at CompileMetadataResolver._getInjectableMetadata (http://localhost:8100/build/main.js:92090:21)
    at CompileMetadataResolver.getProviderMetadata (http://localhost:8100/build/main.js:92380:40)
    at http://localhost:8100/build/main.js:92309:49
    at Array.forEach (<anonymous>)
    at CompileMetadataResolver._getProvidersMetadata (http://localhost:8100/build/main.js:92270:19)
    at CompileMetadataResolver.getNonNormalizedDirectiveMetadata (http://localhost:8100/build/main.js:91700:30)
    at CompileMetadataResolver._getEntryComponentMetadata (http://localhost:8100/build/main.js:92357:45)

I have two providers bot and game-service

This is my game-service provider inside providers/games-service/game-service.ts

import { Injectable } from '@angular/core';
import { Component } from '@angular/core';
import { BotProvider } from '../bot/bot';
@Component({
  providers: [BotProvider]
})
 @Injectable()
export class GameServiceProvider {
 ... vars i have to use some in Botprovider aswell ...
 constructor(public bot: BotProvider){
 }
 ... functions ...
}

this is my bot provider inside providers/bot/bot.ts

import { Injectable, Component } from '@angular/core';
import { GameServiceProvider } from '../game-service/game-service';
@Component({
  providers: [GameServiceProvider]
})
@Injectable()
export class BotProvider {
 constructor(public gs: GameServiceProvider) {}
 .. functions ..
}

Both where created via ionic generate provider {{NAME}}

My app.compoment.ts

import { Component } from '@angular/core';
import { Platform } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import { BotProvider } from '../providers/bot/bot';
import { GameServiceProvider } from '../providers/game-service/game-service';

import { LoginPage } from '../pages/login/login';
import { HomePage } from '../pages/home/home';
@Component({
  templateUrl: 'app.html',
  providers: [GameServiceProvider,BotProvider]
})
export class MyApp {
  rootPage:any = HomePage;

  constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen) {
    platform.ready().then(() => {
      // Okay, so the platform is ready and our plugins are available.
      // Here you can do any higher level native things you might need.
      statusBar.styleDefault();
      splashScreen.hide();
    });
  }

My app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { ErrorHandler, NgModule } from '@angular/core';
import { MaterialModule } from '@angular/material';
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
import { SplashScreen } from '@ionic-native/splash-screen';
import { StatusBar } from '@ionic-native/status-bar';
import { GooglePlus } from '@ionic-native/google-plus';

import { MyApp } from './app.component';
import { HomePage } from '../pages/home/home';
import { GamePage } from '../pages/game/game';
import { LoginPage } from '../pages/login/login';
import { BotProvider } from '../providers/bot/bot';
import { GameServiceProvider } from '../providers/game-service/game-service';

@NgModule({
  declarations: [
    MyApp,
    HomePage,
    GamePage,
    LoginPage
  ],
  imports: [
    BrowserModule,
    IonicModule.forRoot(MyApp),
    MaterialModule
  ],
  bootstrap: [IonicApp],
  entryComponents: [
    MyApp,
    HomePage,
    GamePage,
    LoginPage
  ],
  providers: [
    StatusBar,
    SplashScreen,
    GooglePlus,
    {provide: ErrorHandler, useClass: IonicErrorHandler},
    BotProvider,
    GameServiceProvider
  ]
})
export class AppModule {}

Should i write another Provider that contains just the stuff both Provider need or is it possible that one provider has a provider in its constructor and vise versa

Have a nice weekend!


问:
I am unable to understand below php Function code -
How it will print hello - If hello is true, then the function must print hello, but if the function doesn’t receive hello or hello is false the function must print bye.</p>

```<code><?php
function showMessage($hello=false){
  echo ($hello)?'hello':'bye';
}
?>
</code>```

答:
So if you don't want any condition you can add default value bye to para,eter. And simply echo it

```<code><?php

function showMessage($hello="bye"){
  echo $hello;
}
?>
</code>```

Body:
How it will print hello - If hello is true, then the function must print hello, but if the function doesn’t receive hello or hello is false the function must print bye.

<?php
function showMessage($hello=false){
  echo ($hello)?'hello':'bye';
}
?>

Body:
So if you don't want any condition you can add default value bye to para,eter. And simply echo it

<?php

function showMessage($hello="bye"){
  echo $hello;
}
?>


问:
Client-Server secure connection handshake
I would like to know if there are any security concerns regarding the way I want to create a secure client-server connection.

NOTE: I know the most obvious answer to these type of questions is to just use SSL/TLS, but I would appreciate an answer to my specific case.

My connection protocol is as follows (following communication is un-encrypted plain text):

client connects to server socket

server sends a 2048-bit public RSA key to client

client generates a 256-bit AES key, encrypts it with the received public RSA key, and sends it to server (server decrypts it and obtains the secret AES key)

client generates a 256-bit HMAC key, encrypts it a client-embedded public RSA key, and sends it to server (server decrypts it and obtains the secret HMAC key)

server sends to client the HMAC of the AES key, proving it possesses the private RSA key corresponding to the client-embedded public RSA key, and proving the authenticity of the server

All further communication is encrypted with AES and verified with HMAC.

答:
A man in the middle could easily send their own public key to the client and receive the original public key from the server.

It could then eavesdrop the conversation in both directions.


答:
The reason why showMessage('abc') now prints 'hello' is because the ($hello) will evaluate to true as a non-empty string.

I guess what you are looking for is the type comparison operator ===. It will check whether the argument passed is actually a boolean value.

```<code>function showMessage($hello=false) {
   echo ($hello === true)?'hello':'bye';
}
</code>```

Title: I am unable to understand below php Function code -

Body:
The reason why showMessage('abc') now prints 'hello' is because the ($hello) will evaluate to true as a non-empty string.

I guess what you are looking for is the type comparison operator ===. It will check whether the argument passed is actually a boolean value.

function showMessage($hello=false) {
   echo ($hello === true)?'hello':'bye';
}


问:
Edittext and error message
I have 9 edittext my question is when you type a number in an edittext I can not type another number in the other 8 edittext remaining For example if I type 5 in editext and 1 if I want to type another 5 in the 8 edittext restants does not put anything and an error message will be displayed.</p>

```<code>    et1.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {

        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {

        }

        @Override
        public void afterTextChanged(Editable s) {

            tester();
        }
    });
    et2.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(final CharSequence s, final int start, final int count, final int after) {

        }

        @Override
        public void onTextChanged(final CharSequence s, final int start, final int before, final int count) {

        }

        @Override
        public void afterTextChanged(final Editable s) {
            tester();

        }

    });
    et3.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(final CharSequence s, final int start, final int count, final int after) {

        }

        @Override
        public void onTextChanged(final CharSequence s, final int start, final int before, final int count) {

        }

        @Override
        public void afterTextChanged(final Editable s) {
            tester1();

        }

    });
    et4.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(final CharSequence s, final int start, final int count, final int after) {

        }

        @Override
        public void onTextChanged(final CharSequence s, final int start, final int before, final int count) {

        }

        @Override
        public void afterTextChanged(final Editable s) {

        }

    });
    et5.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(final CharSequence s, final int start, final int count, final int after) {

        }

        @Override
        public void onTextChanged(final CharSequence s, final int start, final int before, final int count) {

        }

        @Override
        public void afterTextChanged(final Editable s) {

        }
    });

    et6.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(final CharSequence s, final int start, final int count, final int after) {

        }

        @Override
        public void onTextChanged(final CharSequence s, final int start, final int before, final int count) {

        }

        @Override
        public void afterTextChanged(final Editable s) {

        }
    });
    et7.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(final CharSequence s, final int start, final int count, final int after) {

        }

        @Override
        public void onTextChanged(final CharSequence s, final int start, final int before, final int count) {

        }

        @Override
        public void afterTextChanged(final Editable s) {

        }
    });
    et8.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(final CharSequence s, final int start, final int count, final int after) {

        }

        @Override
        public void onTextChanged(final CharSequence s, final int start, final int before, final int count) {

        }

        @Override
        public void afterTextChanged(final Editable s) {
            tester();

        }
    });
    et9.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(final CharSequence s, final int start, final int count, final int after) {

        }

        @Override
        public void onTextChanged(final CharSequence s, final int start, final int before, final int count) {

        }

        @Override
        public void afterTextChanged(final Editable s) {

        }
    })
protected void tester()

{
    if (et1.getText().toString().equals(et2.getText().toString()) ||
            et1.getText().toString().equals(et3.getText().toString()) ||
            et1.getText().toString().equals(et4.getText().toString()) ||
            et1.getText().toString().equals(et5.getText().toString()) ||
            et1.getText().toString().equals(et6.getText().toString()) ||
            et1.getText().toString().equals(et7.getText().toString()) ||
            et1.getText().toString().equals(et8.getText().toString()) ||
            et1.getText().toString().equals(et9.getText().toString())) {
        Toast.makeText(this, "vous ne devez utiliser ce nombre deux fois ", Toast.LENGTH_SHORT).show();

    }
}
</code>```

答:
You can store the text in the edit text into an array. On every text change, you can check if it is in conflict. If yes, show a toast. Update the textInputs strings accordingly. Not sure if code works but hope you get the idea.

Declare a check array

```<code>String[] textInputs = new String[9];
</code>```

Check the input with the other inputs

```<code>void checkTextValid(String input){
   if (input.length > 0 && ArrayUtils.contains( textInputs, input ) ) {
       Toast.makeText(this, "vous ne devez utiliser ce nombre deux fois ", Toast.LENGTH_SHORT).show();
   }
}

void updateInputs(int id, String s){
    textInputs[id] = s;
}
</code>```

add checkTextValid(s.toString()); into each onTextChanged().

add updateInputs(0,e.toString()); into each afterTextChanged().

Title: Edittext and error message

Body:
I have 9 edittext my question is when you type a number in an edittext I can not type another number in the other 8 edittext remaining For example if I type 5 in editext and 1 if I want to type another 5 in the 8 edittext restants does not put anything and an error message will be displayed.

    et1.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {

        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {

        }

        @Override
        public void afterTextChanged(Editable s) {

            tester();
        }
    });
    et2.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(final CharSequence s, final int start, final int count, final int after) {

        }

        @Override
        public void onTextChanged(final CharSequence s, final int start, final int before, final int count) {

        }

        @Override
        public void afterTextChanged(final Editable s) {
            tester();

        }

    });
    et3.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(final CharSequence s, final int start, final int count, final int after) {

        }

        @Override
        public void onTextChanged(final CharSequence s, final int start, final int before, final int count) {

        }

        @Override
        public void afterTextChanged(final Editable s) {
            tester1();

        }

    });
    et4.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(final CharSequence s, final int start, final int count, final int after) {

        }

        @Override
        public void onTextChanged(final CharSequence s, final int start, final int before, final int count) {

        }

        @Override
        public void afterTextChanged(final Editable s) {

        }

    });
    et5.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(final CharSequence s, final int start, final int count, final int after) {

        }

        @Override
        public void onTextChanged(final CharSequence s, final int start, final int before, final int count) {

        }

        @Override
        public void afterTextChanged(final Editable s) {

        }
    });

    et6.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(final CharSequence s, final int start, final int count, final int after) {

        }

        @Override
        public void onTextChanged(final CharSequence s, final int start, final int before, final int count) {

        }

        @Override
        public void afterTextChanged(final Editable s) {

        }
    });
    et7.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(final CharSequence s, final int start, final int count, final int after) {

        }

        @Override
        public void onTextChanged(final CharSequence s, final int start, final int before, final int count) {

        }

        @Override
        public void afterTextChanged(final Editable s) {

        }
    });
    et8.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(final CharSequence s, final int start, final int count, final int after) {

        }

        @Override
        public void onTextChanged(final CharSequence s, final int start, final int before, final int count) {

        }

        @Override
        public void afterTextChanged(final Editable s) {
            tester();

        }
    });
    et9.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(final CharSequence s, final int start, final int count, final int after) {

        }

        @Override
        public void onTextChanged(final CharSequence s, final int start, final int before, final int count) {

        }

        @Override
        public void afterTextChanged(final Editable s) {

        }
    })
protected void tester()

{
    if (et1.getText().toString().equals(et2.getText().toString()) ||
            et1.getText().toString().equals(et3.getText().toString()) ||
            et1.getText().toString().equals(et4.getText().toString()) ||
            et1.getText().toString().equals(et5.getText().toString()) ||
            et1.getText().toString().equals(et6.getText().toString()) ||
            et1.getText().toString().equals(et7.getText().toString()) ||
            et1.getText().toString().equals(et8.getText().toString()) ||
            et1.getText().toString().equals(et9.getText().toString())) {
        Toast.makeText(this, "vous ne devez utiliser ce nombre deux fois ", Toast.LENGTH_SHORT).show();

    }
}

Body:
You can store the text in the edit text into an array. On every text change, you can check if it is in conflict. If yes, show a toast. Update the textInputs strings accordingly. Not sure if code works but hope you get the idea.

Declare a check array

String[] textInputs = new String[9];

Check the input with the other inputs

void checkTextValid(String input){
   if (input.length > 0 && ArrayUtils.contains( textInputs, input ) ) {
       Toast.makeText(this, "vous ne devez utiliser ce nombre deux fois ", Toast.LENGTH_SHORT).show();
   }
}

void updateInputs(int id, String s){
    textInputs[id] = s;
}

add checkTextValid(s.toString()); into each onTextChanged().

add updateInputs(0,e.toString()); into each afterTextChanged().


问:
how can i allow url fopen on .htaccess?
i want to allow the url_fopen on the php.ini settings set to ON, but i dnt have access to this on a shared server, how can i use the .htaccess file to allow this to hapen, thanks :))</p>

答: If your host disabled this for security reasons, then you likely cannot override it, as that would defeat the purpose of disabling it. </p>

Title: how can i allow url fopen on .htaccess?


问:
Python Extract Value from Json
I Need to Exact Value from Json response

Json Response:

```<code>{
"data": {
"plot": "Rudy has always been told that he was too small to play college football. But he is determined to overcome the odds and fulfill his dream of playing for Notre Dame.",
"name": "Rudy",
"rating": "7.5",
"genre": "Biography,Drama,Sport",
"poster_url": "https://images-na.ssl-images-amazon.com/images/M/MV5BZGUzMDU1YmQtMzBkOS00MTNmLTg5ZDQtZjY5Njk4Njk2MmRlXkEyXkFqcGdeQXVyNjc1NTYyMjg@._V1_UY268_CR5,0,182,268_AL_.jpg"
     }
}
</code>```

Python Code:

```<code>response = requests.get(
    "http://theapache64.xyz:8080/movie_db/search?keyword=Titanic")
json_data = json.loads(response.text)

print(json_data["plot"])
</code>```

Error:

```<code>KeyError: 'plot'
</code>```

I need to extract "plot" value

答:
plot is inside data:

```<code>print(json_data['data']['plot'])
</code>```

Title: Python Extract Value from Json

Body:
I Need to Exact Value from Json response

Json Response:

{
"data": {
"plot": "Rudy has always been told that he was too small to play college football. But he is determined to overcome the odds and fulfill his dream of playing for Notre Dame.",
"name": "Rudy",
"rating": "7.5",
"genre": "Biography,Drama,Sport",
"poster_url": "https://images-na.ssl-images-amazon.com/images/M/MV5BZGUzMDU1YmQtMzBkOS00MTNmLTg5ZDQtZjY5Njk4Njk2MmRlXkEyXkFqcGdeQXVyNjc1NTYyMjg@._V1_UY268_CR5,0,182,268_AL_.jpg"
     }
}

Python Code:

response = requests.get(
    "http://theapache64.xyz:8080/movie_db/search?keyword=Titanic")
json_data = json.loads(response.text)

print(json_data["plot"])

Error:

KeyError: 'plot'

I need to extract "plot" value

Body:
plot is inside data:

print(json_data['data']['plot'])


问:
how to trigger popads on click on the specific div
I have integrated popads to my site. it is working fine but the problem is that it triggers everywhere on the page. The thing I want is that when the user click on the certain div then popads should trigger but it is not working.

Here is my code.

```<code>$( document ).ready(function() {
  $("#player_embed").click(function(){
    alert('aaa');

   var pa = document.createElement('script'); pa.type = 'text/javascript'; pa.async = true;
      var s = document.getElementsByTagName('script')[0];
      pa.src = '//c1.popads.net/pop.js';
      pa.onerror = function() {
        var sa = document.createElement('script'); sa.type = 'text/javascript'; sa.async = true;
        sa.src = '//c2.popads.net/pop.js';
        s.parentNode.insertBefore(sa, s);
      };
      s.parentNode.insertBefore(pa, s);

});

});
</code>```

答:
I think that you do not handle the click. You can try with <code>.on</code> trigger function: </p>

```<code>$(document).ready(function() {
  $("#player_embed").on('click',function(){
    alert('aaa');
    //your code
  });
});
</code>```

Body:
I have integrated popads to my site. it is working fine but the problem is that it triggers everywhere on the page. The thing I want is that when the user click on the certain div then popads should trigger but it is not working.

Here is my code.

$( document ).ready(function() {
  $("#player_embed").click(function(){
    alert('aaa');

   var pa = document.createElement('script'); pa.type = 'text/javascript'; pa.async = true;
      var s = document.getElementsByTagName('script')[0];
      pa.src = '//c1.popads.net/pop.js';
      pa.onerror = function() {
        var sa = document.createElement('script'); sa.type = 'text/javascript'; sa.async = true;
        sa.src = '//c2.popads.net/pop.js';
        s.parentNode.insertBefore(sa, s);
      };
      s.parentNode.insertBefore(pa, s);

});

});

Body:
I think that you do not handle the click. You can try with .on trigger function:

$(document).ready(function() {
  $("#player_embed").on('click',function(){
    alert('aaa');
    //your code
  });
});


问:
In kubernetes How can I use metadata name from Replication Controller inside my pod?
In kubernetes How can I use metadata name from Replication Controller inside my pod?
Lets say I want to pass :

name: sparkworker1-rc

To my pods so I can use it as a parameter for log file, for example:

```<code>- name: "JAVA_OPTS"
  value: "-DMY_RC_NAME=$(MY_RC_NAME)"
</code>```

But instead of getting "sparkworker1-rc" I get the name of the pod that is running sparkworker1-rc-(name_of_the_pod).

This is my YAML:

```<code>kind: ReplicationController
apiVersion: v1
metadata:
  name: sparkworker1-rc
spec:
  replicas: 1
  selector:
    component: spark-worker1
  template:
    metadata:
      labels:
        component: spark-worker1
      annotations:
        pod.beta.kubernetes.io/hostname: worker1
</code>```

Does anyone knows how I can get the RC name and NOT the pod name?

答:
Not sure we can access the metadata value inside the container. other option is you can pass metadata as environment variable.

like this.

```<code>env:
        - name: METADATANAME
          value: sparkworker1-rc
</code>```

Body:
In kubernetes How can I use metadata name from Replication Controller inside my pod?
Lets say I want to pass :

name: sparkworker1-rc

To my pods so I can use it as a parameter for log file, for example:

- name: "JAVA_OPTS"
  value: "-DMY_RC_NAME=$(MY_RC_NAME)"

But instead of getting "sparkworker1-rc" I get the name of the pod that is running sparkworker1-rc-(name_of_the_pod).

This is my YAML:

kind: ReplicationController
apiVersion: v1
metadata:
  name: sparkworker1-rc
spec:
  replicas: 1
  selector:
    component: spark-worker1
  template:
    metadata:
      labels:
        component: spark-worker1
      annotations:
        pod.beta.kubernetes.io/hostname: worker1

Does anyone knows how I can get the RC name and NOT the pod name?

Body:
Not sure we can access the metadata value inside the container. other option is you can pass metadata as environment variable.

like this.

env:
        - name: METADATANAME
          value: sparkworker1-rc


问:
Constrained polymorphism: variable vs. function parameter
This is a very basic question. I have just started studying Haskell using a couple of different sources. There is something I can't currently decipher from these.

The following will naturally typecheck just fine.

```<code>g :: Num a => a -> a
g x = x + 2
h = g (1.0 :: Double)
</code>```

This example of constrained polymorphism makes complete sense to me when I interpret it as follows: as long as the parameter provided to g is of the type that has a Num instance, everything is ok.

So, consider the following.

```<code>x :: Num a => a
</code>```

If I interpret this as above, I get: x can take any value of a type that has a Num instance. However, the following will not typecheck.

```<code>x :: Num a => a
x = (1.0 :: Double)
</code>```

My question is: what is exactly the difference here?

I sort of get what might be happening: in the second example, x is defined so that it will evaluate to any Num, and  (1.0 :: Double) does not qualify.

But my vague idea is far from being a complete explanation, and I am looking for a better one.

答:
You should read the type g :: Num a => a -> a as follows:

the caller of g chooses a type a

the caller must prove that a is a numeric type

the caller must provide an argument value of type a

g must then answer with a result value of type a

Hence, x :: Num a => a becomes

the user of x chooses a type a

the user must prove that a is a numeric type

x must then answer with a result value of type a

So, x is not allowed to pick a = Double, the user of x gets to choose that.
Think e.g. of (x :: Int) + 4: this will type check, picking a=Int. The implementation of x must be general, so to work on all the numeric type.

Incidentally, note that numeric literals have the same type 42 :: Num a => a, this is why we are allowed to use them as Double, as Int, or any other numeric type.

Body:
This is a very basic question. I have just started studying Haskell using a couple of different sources. There is something I can't currently decipher from these.

The following will naturally typecheck just fine.

g :: Num a => a -> a
g x = x + 2
h = g (1.0 :: Double)

This example of constrained polymorphism makes complete sense to me when I interpret it as follows: as long as the parameter provided to g is of the type that has a Num instance, everything is ok.

So, consider the following.

x :: Num a => a

If I interpret this as above, I get: x can take any value of a type that has a Num instance. However, the following will not typecheck.

x :: Num a => a
x = (1.0 :: Double)

My question is: what is exactly the difference here?

I sort of get what might be happening: in the second example, x is defined so that it will evaluate to any Num, and  (1.0 :: Double) does not qualify.

But my vague idea is far from being a complete explanation, and I am looking for a better one.


问:
Compare latest record with previous record for updated columns from Audit log table
I am facing scenario where i need to get the data from audit log table and show Old and new value.

For eg. Below is audit_Log table for Person

```<code>AUDIT_ID       PERSON_ID       OPERATION       NAME       ADDRESS       AGE     DOY
    1           101             I           Prashant        Andheri     21      1991
    2           101             U           Prashant1       Santacruz   22      1990
    3           101             U           rashant2        Parle       23      1989
</code>```

I want the latest value and previous value for all the columns as below,

```<code>PERSON_ID       COLUMNS      OLD_VALUE       NEW_VALUE
101             OPERATION       U               U
101             NAME            PRASHANT1       PRASHANT2
101             ADDRESS         Santacruz       Parle
101             AGE             22              23
101             BIRTH_YEAR      1990            1989
</code>```

Can anyone please help me to get this result from above table.

Thanks,
Prashant

答:
```<code>SELECT PERSON_ID, [COLUMNS], OLD_VALUE, NEW_VALUE
FROM(
    SELECT TOP 2 PERSON_ID, ( CASE ( ROW_NUMBER() OVER( ORDER BY AUDIT_ID DESC )) WHEN 1 THEN 'NEW_VALUE' ELSE 'OLD_VALUE' END ) AS [Version],
        CAST( OPERATION AS VARCHAR( 100 )) AS OPERATION, CAST( NAME AS VARCHAR( 100 )) AS NAME,
        CAST( ADDRESS AS VARCHAR( 100 )) AS ADDRESS, CAST( AGE AS VARCHAR( 100 )) AS AGE, CAST( DOY AS VARCHAR( 100 )) AS DOY
    FROM audit_Log
    WHERE PERSON_ID = 101
    ORDER BY AUDIT_ID DESC ) AS SourceData
UNPIVOT(
    COL_VALUE FOR [COLUMNS] IN( NAME, ADDRESS, OPERATION, AGE, DOY )
    ) AS UnpivotColumns
PIVOT(
    MIN( COL_VALUE ) FOR [Version] IN( [NEW_VALUE], [OLD_VALUE] )
    ) AS PivotOldNew
</code>```

Notes:

You need to convert all of your audit column values to a common type. I
chose VARCHAR( 100 ) but you may need to choose something else.

This code also works when only one audit record exists. In this case it
will show NULL for OLD_VALUES

References:

http://mangalpardeshi.blogspot.com.au/2009/04/unpivot-multiple-columns.html
https://learn.microsoft.com/en-us/sql/t-sql/queries/from-using-pivot-and-unpivot

EDIT: excluded erroneous code at the end of the query

Body:
I am facing scenario where i need to get the data from audit log table and show Old and new value.

For eg. Below is audit_Log table for Person

AUDIT_ID       PERSON_ID       OPERATION       NAME       ADDRESS       AGE     DOY
    1           101             I           Prashant        Andheri     21      1991
    2           101             U           Prashant1       Santacruz   22      1990
    3           101             U           rashant2        Parle       23      1989

I want the latest value and previous value for all the columns as below,

PERSON_ID       COLUMNS      OLD_VALUE       NEW_VALUE
101             OPERATION       U               U
101             NAME            PRASHANT1       PRASHANT2
101             ADDRESS         Santacruz       Parle
101             AGE             22              23
101             BIRTH_YEAR      1990            1989

Can anyone please help me to get this result from above table.

Thanks,
Prashant

Body:
SELECT PERSON_ID, [COLUMNS], OLD_VALUE, NEW_VALUE
FROM(
    SELECT TOP 2 PERSON_ID, ( CASE ( ROW_NUMBER() OVER( ORDER BY AUDIT_ID DESC )) WHEN 1 THEN 'NEW_VALUE' ELSE 'OLD_VALUE' END ) AS [Version],
        CAST( OPERATION AS VARCHAR( 100 )) AS OPERATION, CAST( NAME AS VARCHAR( 100 )) AS NAME,
        CAST( ADDRESS AS VARCHAR( 100 )) AS ADDRESS, CAST( AGE AS VARCHAR( 100 )) AS AGE, CAST( DOY AS VARCHAR( 100 )) AS DOY
    FROM audit_Log
    WHERE PERSON_ID = 101
    ORDER BY AUDIT_ID DESC ) AS SourceData
UNPIVOT(
    COL_VALUE FOR [COLUMNS] IN( NAME, ADDRESS, OPERATION, AGE, DOY )
    ) AS UnpivotColumns
PIVOT(
    MIN( COL_VALUE ) FOR [Version] IN( [NEW_VALUE], [OLD_VALUE] )
    ) AS PivotOldNew

Notes:

You need to convert all of your audit column values to a common type. I
chose VARCHAR( 100 ) but you may need to choose something else.

This code also works when only one audit record exists. In this case it
will show NULL for OLD_VALUES

References:

http://mangalpardeshi.blogspot.com.au/2009/04/unpivot-multiple-columns.html
https://learn.microsoft.com/en-us/sql/t-sql/queries/from-using-pivot-and-unpivot

EDIT: excluded erroneous code at the end of the query


问:
iTunes Search API - HTTPS artworkUrl?
When I run a query against the iTunes Search API over SSL, most of the URL's returned are provided via HTTPS:

https://itunes.apple.com/search?term=rihanna

However, the artworkUrl results are served over HTTP and updating them manually throws an error since the SSL certificate doesn't match on the domain they're using.

Is there a way to grab these images over HTTPS instead of HTTP?

答:
You have to replace the sub domain:

```<code>http://is<n> with https://is<n>-ssl
</code>```

Example:

http://is5.mzstatic.com/image/thumb/Music117/v4/dd/48/4a/dd484afb-2313-0a1a-ccf1-ff28a02ae2ca/source/100x100bb.jpg

to

https://is5-ssl.mzstatic.com/image/thumb/Music117/v4/dd/48/4a/dd484afb-2313-0a1a-ccf1-ff28a02ae2ca/source/100x100bb.jpg

Title: iTunes Search API - HTTPS artworkUrl?

Body:
You have to replace the sub domain:

http://is<n> with https://is<n>-ssl

Example:

http://is5.mzstatic.com/image/thumb/Music117/v4/dd/48/4a/dd484afb-2313-0a1a-ccf1-ff28a02ae2ca/source/100x100bb.jpg

to

https://is5-ssl.mzstatic.com/image/thumb/Music117/v4/dd/48/4a/dd484afb-2313-0a1a-ccf1-ff28a02ae2ca/source/100x100bb.jpg


问:
Find progressively bigger elements in prolog list
Given a prolog list I want to create a second one containing the progressively bigger elements. For example,

```<code>L = [ 1, 5, 2, 3, 4, 10, 15, 11, 12, 13, 20 ]

Answer = [ 1, 5, 10, 15, 20 ]
</code>```

My code:

```<code>local_max([],_,_).
local_max([XH|XT],Y,temp) :-
    ( XH =< temp ->
      local_max(XT,Y,temp)
      ;
      local_max(XT,[XH|Y],XH)
    ).
</code>```

I thought this should produce my answered simply reversed but it doesn't.
Just false.

The list contains only positive integers so I simply did

```<code>local_max([ 1, 5, 2, 3, 4, 10, 15, 11, 12, 13, 20 ],Answer,0).
</code>```

答:
You made several small mistakes:

temp is not a valid variable name, it needs to be Temp,

_ is not a correct result when the input list is empty, it needs to be [],

[XH|Y] construct is not what you unify with recursive invocation on extending the list. Pass a new variable, say, R, and then build Y by unifying Y = [XH|R]

Here is your program with the fixes applied:

```<code>local_max([],[],_).
local_max([XH|XT],Y,Temp) :-
    ( XH =< Temp ->
      local_max(XT,Y,Temp)
      ;
      local_max(XT,R,XH), Y = [XH|R]
    ).
</code>```

This produces your expected output (demo).

Body:
Given a prolog list I want to create a second one containing the progressively bigger elements. For example,

L = [ 1, 5, 2, 3, 4, 10, 15, 11, 12, 13, 20 ]

Answer = [ 1, 5, 10, 15, 20 ]

My code:

local_max([],_,_).
local_max([XH|XT],Y,temp) :-
    ( XH =< temp ->
      local_max(XT,Y,temp)
      ;
      local_max(XT,[XH|Y],XH)
    ).

I thought this should produce my answered simply reversed but it doesn't.
Just false.

The list contains only positive integers so I simply did

local_max([ 1, 5, 2, 3, 4, 10, 15, 11, 12, 13, 20 ],Answer,0).

Body:
You made several small mistakes:

temp is not a valid variable name, it needs to be Temp,

_ is not a correct result when the input list is empty, it needs to be [],

[XH|Y] construct is not what you unify with recursive invocation on extending the list. Pass a new variable, say, R, and then build Y by unifying Y = [XH|R]

Here is your program with the fixes applied:

local_max([],[],_).
local_max([XH|XT],Y,Temp) :-
    ( XH =< Temp ->
      local_max(XT,Y,Temp)
      ;
      local_max(XT,R,XH), Y = [XH|R]
    ).

This produces your expected output (demo).


问:
HTML sections overlapping
I have the following simple HTML layout

.section1 {
  background: red;
}

.section2 {
  background: green;
}

.section3 {
  background: yellow;
}

article {
  float: left;
  width: 33%;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><section class="section1">
  <p>
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse id eros vel ex porta viverra ac sit amet quam. Morbi quis consequat dolor. Vestibulum ultricies leo ac orci fringilla, et congue erat euismod. Donec vestibulum nisi eu orci commodo congue.
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus pretium consectetur mi quis vehicula. Donec ac velit id mi facilisis luctus. Vivamus placerat eros vel quam placerat, a varius quam malesuada. Proin nec lectus ac augue varius hendrerit.
    Curabitur mattis dolor non arcu faucibus, at viverra purus feugiat. Suspendisse potenti. Nunc non metus eget ipsum efficitur tincidunt id eget elit. Donec ac molestie libero. In hac habitasse platea dictumst. Morbi eget fermentum orci, nec volutpat
    enim. Proin ac leo urna. Nam facilisis ut arcu eget interdum. Ut vulputate massa ut pretium accumsan. Nullam eros diam, elementum ac feugiat eu, hendrerit in sapien. Nullam accumsan arcu quis ante aliquam lacinia.
  </p>
</section>

<section class="section2">
  <p>
    Section 2 content
  </p>
  <article>
    Sed eget magna sit amet turpis elementum finibus. Mauris commodo porttitor nisl. Praesent dignissim vel mi quis vestibulum. Suspendisse porttitor magna sit amet eros semper, volutpat interdum nisl ultrices. Pellentesque habitant morbi tristique senectus
    et netus et malesuada fames ac turpis egestas. </article>
  <article>
    Fusce pretium neque non lorem scelerisque iaculis. Etiam porta gravida est rutrum porta. Nullam venenatis elit nec ipsum volutpat pretium. Nunc ut hendrerit est, in euismod sapien. Aliquam non nulla auctor, scelerisque ipsum id, mattis ex. </article>
  <article>
    Curabitur porta tincidunt erat ac sollicitudin. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos
  </article>
</section>

<section class="section3">
  Section 3 content
</section></code>```

The second and third sections are overlapping, what am I doing wrong?

答:
This should work better than float:

```<code>article {
  display: inline-block;
  width:32%;
  vertical-align: top;
}
</code>```

Fiddle: https://jsfiddle.net/kbennu/7z7m92fv/

Title: HTML sections overlapping

Body:
I have the following simple HTML layout

.section1 {
  background: red;
}

.section2 {
  background: green;
}

.section3 {
  background: yellow;
}

article {
  float: left;
  width: 33%;
}

    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse id eros vel ex porta viverra ac sit amet quam. Morbi quis consequat dolor. Vestibulum ultricies leo ac orci fringilla, et congue erat euismod. Donec vestibulum nisi eu orci commodo congue.
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus pretium consectetur mi quis vehicula. Donec ac velit id mi facilisis luctus. Vivamus placerat eros vel quam placerat, a varius quam malesuada. Proin nec lectus ac augue varius hendrerit.
    Curabitur mattis dolor non arcu faucibus, at viverra purus feugiat. Suspendisse potenti. Nunc non metus eget ipsum efficitur tincidunt id eget elit. Donec ac molestie libero. In hac habitasse platea dictumst. Morbi eget fermentum orci, nec volutpat
    enim. Proin ac leo urna. Nam facilisis ut arcu eget interdum. Ut vulputate massa ut pretium accumsan. Nullam eros diam, elementum ac feugiat eu, hendrerit in sapien. Nullam accumsan arcu quis ante aliquam lacinia.

    Section 2 content

    Sed eget magna sit amet turpis elementum finibus. Mauris commodo porttitor nisl. Praesent dignissim vel mi quis vestibulum. Suspendisse porttitor magna sit amet eros semper, volutpat interdum nisl ultrices. Pellentesque habitant morbi tristique senectus
    et netus et malesuada fames ac turpis egestas.

    Fusce pretium neque non lorem scelerisque iaculis. Etiam porta gravida est rutrum porta. Nullam venenatis elit nec ipsum volutpat pretium. Nunc ut hendrerit est, in euismod sapien. Aliquam non nulla auctor, scelerisque ipsum id, mattis ex.

    Curabitur porta tincidunt erat ac sollicitudin. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos

  Section 3 content

The second and third sections are overlapping, what am I doing wrong?

Body:
This should work better than float:

article {
  display: inline-block;
  width:32%;
  vertical-align: top;
}

Fiddle: https://jsfiddle.net/kbennu/7z7m92fv/


问:
Laravel version: 5.4.28 api routes not working on localhost
I downloaded Laravel 5.4.28 and created one api route. Nothing works on localhost. I am using XAMPP on Windows 8.1 as local development.

But everything is working fine on server. I also notice one strange thing. It will work on localhost if I create virtual host on localhost. like below.

```<code>php artisan serve
</code>```

Is that true? or Am I missing anything?

My api routes are like this...

http://localhost:1234/adminapi/public/api/v1/authenticateuser

答: When you do php artisan serve and load the URL returned by that command do you see laravels welcome page? If not then you haven't installed it correctly. https://laravel.com/docs/5.4

Body:
I downloaded Laravel 5.4.28 and created one api route. Nothing works on localhost. I am using XAMPP on Windows 8.1 as local development.

But everything is working fine on server. I also notice one strange thing. It will work on localhost if I create virtual host on localhost. like below.

php artisan serve

Is that true? or Am I missing anything?

My api routes are like this...

http://localhost:1234/adminapi/public/api/v1/authenticateuser


问:
Driver:com.mysql.jdbc.Driver@2b7374f8 returned null for URL
I am a beginner in JAVA.
I am trying to connect remote mySQL database to my Java code.

I am getting following error:

```<code>    2017-07-09 17:29:04.283 ERROR 38768 --- [lication.main()] org.hibernate.tool.hbm2ddl.SchemaUpdate  : HHH000319: Could not get database metadata

java.sql.SQLException: Driver:com.mysql.jdbc.Driver@2b7374f8 returned null for URL:jdbc:mysql:sg2plcpnl9557.produc.sin1.secure.net:3312/abc
    at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:326)
    at org.apache.tomcat.jdbc.pool.PooledConnection.connect(PooledConnection.java:200)
    at org.apache.tomcat.jdbc.pool.ConnectionPool.createConnection(ConnectionPool.java:699)
    at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:633)
    at org.apache.tomcat.jdbc.pool.ConnectionPool.init(ConnectionPool.java:484)
    at org.apache.tomcat.jdbc.pool.ConnectionPool.<init>(ConnectionPool.java:142)
    at org.apache.tomcat.jdbc.pool.DataSourceProxy.pCreatePool(DataSourceProxy.java:115)
    at org.apache.tomcat.jdbc.pool.DataSourceProxy.createPool(DataSourceProxy.java:102)
    at org.apache.tomcat.jdbc.pool.DataSourceProxy.getConnection(DataSourceProxy.java:126)
    at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:139)
    at org.hibernate.tool.hbm2ddl.SuppliedConnectionProviderConnectionHelper.prepare(SuppliedConnectionProviderConnectionHelper.java:51)
    at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:219)
    at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:203)
    at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:522)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1859)
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:857)
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:850)
    at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.withTccl(ClassLoaderServiceImpl.java:425)
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:849)
    at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:60)
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:343)
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:318)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1633)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1570)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:956)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:747)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:686)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:957)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:946)
    at com.home.Application.main(Application.java:10)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.springframework.boot.maven.RunMojo$LaunchRunner.run(RunMojo.java:418)
    at java.lang.Thread.run(Thread.java:745)

2017-07-09 17:29:04.284 ERROR 38768 --- [lication.main()] org.hibernate.tool.hbm2ddl.SchemaUpdate  : HHH000299: Could not complete schema update

java.sql.SQLException: Driver:com.mysql.jdbc.Driver@2b7374f8 returned null for URL:jdbc:mysql:sg2plcpnl9557.produc.sin1.secure.net:3312/abc
    at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:326)
    at org.apache.tomcat.jdbc.pool.PooledConnection.connect(PooledConnection.java:200)
    at org.apache.tomcat.jdbc.pool.ConnectionPool.createConnection(ConnectionPool.java:699)
    at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:633)
    at org.apache.tomcat.jdbc.pool.ConnectionPool.init(ConnectionPool.java:484)
    at org.apache.tomcat.jdbc.pool.ConnectionPool.<init>(ConnectionPool.java:142)
    at org.apache.tomcat.jdbc.pool.DataSourceProxy.pCreatePool(DataSourceProxy.java:115)
    at org.apache.tomcat.jdbc.pool.DataSourceProxy.createPool(DataSourceProxy.java:102)
    at org.apache.tomcat.jdbc.pool.DataSourceProxy.getConnection(DataSourceProxy.java:126)
    at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:139)
    at org.hibernate.tool.hbm2ddl.SuppliedConnectionProviderConnectionHelper.prepare(SuppliedConnectionProviderConnectionHelper.java:51)
    at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:219)
    at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:203)
    at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:522)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1859)
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:857)
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:850)
    at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.withTccl(ClassLoaderServiceImpl.java:425)
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:849)
    at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:60)
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:343)
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:318)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1633)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1570)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:956)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:747)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:686)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:957)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:946)
    at com.home.Application.main(Application.java:10)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.springframework.boot.maven.RunMojo$LaunchRunner.run(RunMojo.java:418)
    at java.lang.Thread.run(Thread.java:745)
</code>```

This is my properties file:

```<code>    server.port=8090
#Basic Spring Boot Config for Oracle
spring.datasource.url= jdbc:mysql:sg2plcpnl9557.produc.sin1.secure.net:3312/abc
spring.datasource.username=abc
spring.datasource.password=12345
spring.datasource.driverClassName=com.mysql.jdbc.Driver
#spring.datasource.driver-class-name=oracle.jdbc.OracleDriver
#spring.datasource.driver-class-name=com.mysql.jdbc.Driver

#hibernate config
#spring.jpa.database-platform=org.hibernate.dialect.Oracle10gDialect
spring.jpa.database-platform=org.hibernate.dialect.MySQLDialect
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=update
</code>```

and my dependency in pom.xml is:

```<code><dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
</dependency>
</code>```

答:
Your datasource URL is wrong. It should be like this:

```<code>spring.datasource.url=jdbc:mysql://sg2plcpnl9557.produc.sin1.secure.net:3312/abc
</code>```

You can read more about "Accessing data with MySQL" here.

Body:
I am a beginner in JAVA.
I am trying to connect remote mySQL database to my Java code.

I am getting following error:

    2017-07-09 17:29:04.283 ERROR 38768 --- [lication.main()] org.hibernate.tool.hbm2ddl.SchemaUpdate  : HHH000319: Could not get database metadata

java.sql.SQLException: Driver:com.mysql.jdbc.Driver@2b7374f8 returned null for URL:jdbc:mysql:sg2plcpnl9557.produc.sin1.secure.net:3312/abc
    at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:326)
    at org.apache.tomcat.jdbc.pool.PooledConnection.connect(PooledConnection.java:200)
    at org.apache.tomcat.jdbc.pool.ConnectionPool.createConnection(ConnectionPool.java:699)
    at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:633)
    at org.apache.tomcat.jdbc.pool.ConnectionPool.init(ConnectionPool.java:484)
    at org.apache.tomcat.jdbc.pool.ConnectionPool.<init>(ConnectionPool.java:142)
    at org.apache.tomcat.jdbc.pool.DataSourceProxy.pCreatePool(DataSourceProxy.java:115)
    at org.apache.tomcat.jdbc.pool.DataSourceProxy.createPool(DataSourceProxy.java:102)
    at org.apache.tomcat.jdbc.pool.DataSourceProxy.getConnection(DataSourceProxy.java:126)
    at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:139)
    at org.hibernate.tool.hbm2ddl.SuppliedConnectionProviderConnectionHelper.prepare(SuppliedConnectionProviderConnectionHelper.java:51)
    at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:219)
    at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:203)
    at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:522)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1859)
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:857)
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:850)
    at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.withTccl(ClassLoaderServiceImpl.java:425)
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:849)
    at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:60)
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:343)
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:318)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1633)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1570)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:956)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:747)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:686)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:957)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:946)
    at com.home.Application.main(Application.java:10)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.springframework.boot.maven.RunMojo$LaunchRunner.run(RunMojo.java:418)
    at java.lang.Thread.run(Thread.java:745)

2017-07-09 17:29:04.284 ERROR 38768 --- [lication.main()] org.hibernate.tool.hbm2ddl.SchemaUpdate  : HHH000299: Could not complete schema update

java.sql.SQLException: Driver:com.mysql.jdbc.Driver@2b7374f8 returned null for URL:jdbc:mysql:sg2plcpnl9557.produc.sin1.secure.net:3312/abc
    at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:326)
    at org.apache.tomcat.jdbc.pool.PooledConnection.connect(PooledConnection.java:200)
    at org.apache.tomcat.jdbc.pool.ConnectionPool.createConnection(ConnectionPool.java:699)
    at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:633)
    at org.apache.tomcat.jdbc.pool.ConnectionPool.init(ConnectionPool.java:484)
    at org.apache.tomcat.jdbc.pool.ConnectionPool.<init>(ConnectionPool.java:142)
    at org.apache.tomcat.jdbc.pool.DataSourceProxy.pCreatePool(DataSourceProxy.java:115)
    at org.apache.tomcat.jdbc.pool.DataSourceProxy.createPool(DataSourceProxy.java:102)
    at org.apache.tomcat.jdbc.pool.DataSourceProxy.getConnection(DataSourceProxy.java:126)
    at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:139)
    at org.hibernate.tool.hbm2ddl.SuppliedConnectionProviderConnectionHelper.prepare(SuppliedConnectionProviderConnectionHelper.java:51)
    at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:219)
    at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:203)
    at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:522)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1859)
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:857)
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:850)
    at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.withTccl(ClassLoaderServiceImpl.java:425)
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:849)
    at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:60)
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:343)
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:318)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1633)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1570)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:956)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:747)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:686)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:957)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:946)
    at com.home.Application.main(Application.java:10)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.springframework.boot.maven.RunMojo$LaunchRunner.run(RunMojo.java:418)
    at java.lang.Thread.run(Thread.java:745)

This is my properties file:

    server.port=8090
#Basic Spring Boot Config for Oracle
spring.datasource.url= jdbc:mysql:sg2plcpnl9557.produc.sin1.secure.net:3312/abc
spring.datasource.username=abc
spring.datasource.password=12345
spring.datasource.driverClassName=com.mysql.jdbc.Driver
#spring.datasource.driver-class-name=oracle.jdbc.OracleDriver
#spring.datasource.driver-class-name=com.mysql.jdbc.Driver

#hibernate config
#spring.jpa.database-platform=org.hibernate.dialect.Oracle10gDialect
spring.jpa.database-platform=org.hibernate.dialect.MySQLDialect
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=update

and my dependency in pom.xml is:

<dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
</dependency>

Body:
Your datasource URL is wrong. It should be like this:

spring.datasource.url=jdbc:mysql://sg2plcpnl9557.produc.sin1.secure.net:3312/abc

You can read more about "Accessing data with MySQL" here.


问:
jq: slicing array based on argument
I am trying to slice an array in jq where the end index is passed as an argument from the shell (bash):

```<code>end_index=7
cat obj.json | jq --arg eidx $end_index, '.arr[0:$eidx]'
</code>```

This works as expected when the index is hard-coded

```<code>cat obj.json | jq '.arr[0:7]'
</code>```

but in the example at the top, I get an error message

```<code>jq: error (at <stdin>:0): Start and end indices of an array slice must be numbers
</code>```

I suspect this might be to do with how jq handles variable substitution within the slice operator [:], but none of my attempts to solve the problem, e.g. by enclosing the variable name in curly braces .arr[0:${eidx}], has worked.

答:
You can convert a string to a number using tonumber, as in:

```<code>jq --arg eidx 1 '.arr[0:($eidx|tonumber)]'
</code>```

If your jq is sufficiently recent, you can use --argjson instead of --arg:

```<code>jq --argjson eidx 1 '.arr[0:$eidx]'
</code>```

Title: jq: slicing array based on argument

Body:
I am trying to slice an array in jq where the end index is passed as an argument from the shell (bash):

end_index=7
cat obj.json | jq --arg eidx $end_index, '.arr[0:$eidx]'

This works as expected when the index is hard-coded

cat obj.json | jq '.arr[0:7]'

but in the example at the top, I get an error message

jq: error (at <stdin>:0): Start and end indices of an array slice must be numbers

I suspect this might be to do with how jq handles variable substitution within the slice operator [:], but none of my attempts to solve the problem, e.g. by enclosing the variable name in curly braces .arr[0:${eidx}], has worked.

Body:
You can convert a string to a number using tonumber, as in:

jq --arg eidx 1 '.arr[0:($eidx|tonumber)]'

If your jq is sufficiently recent, you can use --argjson instead of --arg:

jq --argjson eidx 1 '.arr[0:$eidx]'


问:
How can I check a current logged in user security level so i can disable features?
PRE
I'm using SQLExpress to store information.

I have a very basic user set-up in my app. I have a Login table that contains only three fields, these are Username, Password and Security Level. There are only three security levels; High, Medium and Low.

On my login form, I have the following code to save the user that is logging into a Settings.Default[], so I can read it later.

```<code>private void Loginbtn_Click(object sender, EventArgs e)
{
    SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;Initial Catalog=MySupportHub;Integrated Security=True");
    SqlDataAdapter sda = new SqlDataAdapter(@"SELECT * FROM [dbo].[Login] Where Username='" + usernameTextBox.Text + "' and Password='" + passwordTextBox.Text + "'", con);
    DataTable dt = new DataTable();
    sda.Fill(dt);
    if (dt.Rows.Count == 1)
    {
        Settings.Default["CurrentUserName"] = usernameTextBox.Text;
        Settings.Default.Save();

        this.Hide();
        Home home = new Home();
        home.Show();
    }
    else
    {
        MessageBox.Show("Invalid Username and/or Password..!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
        Clearbtn_Click(sender, e);
    }
}
</code>```

Then on the Home page, I have the following code to get the value and display the current logged in user in the bottom status bar. On page load.

```<code>//Identify and display current logged in user

CurrentUser.Caption = Settings.Default["CurrentUserName"].ToString();
</code>```

What I would like to be able to do now is check the current logged in users security level (User value would be stored here "CurrentUser.Caption" on the main form) and be able to disable features like creating a new user etc.

So I would need to be able to read the CurrentUser.Caption value, check that against the (SQL Express) [dbo].[Login] table and find the user's security level and limit features based on the result.

Any help would be appreciated.

Thanks

Phil

答:
You are essentially implementing user authentication and authorization in WebForms.

What would happen in your scenario if a user types the following string for a username and password (without the quotes): "foo OR 1=1" ? You must never concatenate strings in database CRUID opearations to prevent SQL injections.

I could advise you to use FormsAuthentication and encrypted tickets containing user roles and not store passwords in plain text or even encrypted, but rather store hashes using PBKDF2 and cryptographic salts. But you might not be concerned about a production environment and this might be just a learning example. In this case you still don't want to practice what you will never use in a real world application, namely taking the value of a user control to match against permissions stored in a table. One can change the value at the client (browser)and trick the system.

Getting to grips with FormsAuthentication and using the User.Identity.IsInRole would be one way to proceed, you can check this on one of Microsoft Docs tutorials: https://support.microsoft.com/en-us/help/301240/how-to-implement-forms-based-authentication-in-your-asp.net-applicatio

I assume you would like to gain industry valid skills for implementing authentication and authorization in a asp.net web environment. If this is the objective behind your question, it would likely take you the time to learn all of this for the same time it would take you to learn asp.net Identity, which handles many things for you.

In either scenarios it will take you a long time to develop your app without using the Entity Framework and unless you use Identity you have to go a long way to implement your own security features, especially of high quality. Trust me I have been there, done that.

There will be a learning curve, but the best way forward is to use EF to save you tons of time, also ASP.NET Identity for nowadays relevant skills and also to save you tons of time. It's worth comparing Web Forms and MVC too, MVC is a better choice for a dynamic full featured modern application.

I wish there was a simpler answer to your question, but solving this problem the way you intend to will not help you at all in the future and it will not be used in a real application.

The answer is subjective, but in my opinion you can make a fresh start with MVC, EF and Identity, it will take you the same time to learn the right way to do what you intend to do now, but it will give you skills you can use in the future in a production environment and also concepts not only limited to ASP.NET. Take the learning curve.

Body:
PRE
I'm using SQLExpress to store information.

I have a very basic user set-up in my app. I have a Login table that contains only three fields, these are Username, Password and Security Level. There are only three security levels; High, Medium and Low.

On my login form, I have the following code to save the user that is logging into a Settings.Default[], so I can read it later.

private void Loginbtn_Click(object sender, EventArgs e)
{
    SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;Initial Catalog=MySupportHub;Integrated Security=True");
    SqlDataAdapter sda = new SqlDataAdapter(@"SELECT * FROM [dbo].[Login] Where Username='" + usernameTextBox.Text + "' and Password='" + passwordTextBox.Text + "'", con);
    DataTable dt = new DataTable();
    sda.Fill(dt);
    if (dt.Rows.Count == 1)
    {
        Settings.Default["CurrentUserName"] = usernameTextBox.Text;
        Settings.Default.Save();

        this.Hide();
        Home home = new Home();
        home.Show();
    }
    else
    {
        MessageBox.Show("Invalid Username and/or Password..!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
        Clearbtn_Click(sender, e);
    }
}

Then on the Home page, I have the following code to get the value and display the current logged in user in the bottom status bar. On page load.

//Identify and display current logged in user

CurrentUser.Caption = Settings.Default["CurrentUserName"].ToString();

What I would like to be able to do now is check the current logged in users security level (User value would be stored here "CurrentUser.Caption" on the main form) and be able to disable features like creating a new user etc.

So I would need to be able to read the CurrentUser.Caption value, check that against the (SQL Express) [dbo].[Login] table and find the user's security level and limit features based on the result.

Any help would be appreciated.

Thanks

Phil


问:
Alexa account linking - How to store more than access token
When I link an account with a third party they send an access token as well as the user's username.

Alexa automatically saves the access token and gives it with each request. How can I get it to save the username as well?

答:
This is intentionally not supported in order to protect the user's privacy. That is a good thing.

Alexa does provide a userID with each call. This id is specific to each user, and the same every time they use your skill. It doesn't give you any personal information, but it does allow you to save information for each user to your own database. You can associate that user's data with the userId and recall it every time they use your skill.

So for example, you can ask the user for a name, save it to your database keyed by the userId, and recall it at a later date using the userId.

Search on "alexa user information" for more info, for example this post.


问:
How to build vim80 from source with python2 and 3 support?
I want to compile vim80 following the instruction on the webpage.

build vim80 from source with python2 and 3 support

```<code>./configure --with-features=huge \
            --enable-multibyte \
            --enable-rubyinterp=yes \
            --enable-pythoninterp=yes \
            --with-python-config-dir=/usr/lib/python2.7/config \
            --enable-python3interp=yes \
            --with-python3-config-dir=/usr/lib/python3.5/config \
            --enable-perlinterp=yes \
            --enable-luainterp=yes \
            --enable-gui=gtk2 --enable-cscope --prefix=/usr
</code>```

How to customize it according to my environment?

1.For python2.7

```<code> ls /usr/lib/python2.7 |grep config
config-x86_64-linux-gnu
_sysconfigdata.py
_sysconfigdata.pyc
_sysconfigdata.pyo
sysconfig.py
sysconfig.pyc
sysconfig.pyo
</code>```

2.For python3

```<code>sudo find /  -name  'config' |grep python3
/home/debian8/anaconda3/lib/python3.6/site-packages/navigator_updater/config
/home/debian8/anaconda3/lib/python3.6/site-packages/anaconda_navigator/config
/home/debian8/anaconda3/lib/python3.6/site-packages/spyder/config
/home/debian8/anaconda3/lib/python3.6/site-packages/spyder/utils/help/js/mathjax/config
/home/debian8/anaconda3/lib/python3.6/site-packages/notebook/static/components/MathJax/config
/home/debian8/anaconda3/lib/python3.6/site-packages/notebook/services/config
/home/debian8/anaconda3/lib/python3.6/site-packages/astropy/config
/home/debian8/anaconda3/lib/python3.6/site-packages/traitlets/config
/home/debian8/anaconda3/pkgs/spyder-3.1.4-py36_0/lib/python3.6/site-packages/spyder/config
/home/debian8/anaconda3/pkgs/spyder-3.1.4-py36_0/lib/python3.6/site-packages/spyder/utils/help/js/mathjax/config
/home/debian8/anaconda3/pkgs/astropy-1.3.2-np112py36_0/lib/python3.6/site-packages/astropy/config
/home/debian8/anaconda3/pkgs/traitlets-4.3.2-py36_0/lib/python3.6/site-packages/traitlets/config
/home/debian8/anaconda3/pkgs/anaconda-navigator-1.6.2-py36_0/lib/python3.6/site-packages/anaconda_navigator/config
/home/debian8/anaconda3/pkgs/navigator-updater-0.1.0-py36_0/lib/python3.6/site-packages/navigator_updater/config
/home/debian8/anaconda3/pkgs/notebook-5.0.0-py36_0/lib/python3.6/site-packages/notebook/static/components/MathJax/config
/home/debian8/anaconda3/pkgs/notebook-5.0.0-py36_0/lib/python3.6/site-packages/notebook/services/config
</code>```

More concretely,how to change the three lines for my os?

```<code>            --with-python-config-dir=/usr/lib/python2.7/config \
            --enable-python3interp=yes \
            --with-python3-config-dir=/usr/lib/python3.5/config \
</code>```

Here is my try for python2 and 3 support.

```<code>./configure --with-features=huge \
            --enable-multibyte \
            --enable-rubyinterp=yes \
            --enable-pythoninterp=yes \
            --with-python-config-dir=/usr/lib/python2.7/config-x86_64-linux-gnu \
            --enable-python3interp=yes \
            --with-python3-config-dir=/home/debian8/anaconda3/lib/python3.6/site-packages/anaconda_navigator/config \
            --enable-perlinterp=yes \
            --enable-luainterp=yes \
            --enable-gui=gtk2 --enable-cscope --prefix=/usr
</code>```

It is unlucky that no support python2 or python3 for this configuration after make install.

```<code>vim --version|grep python
+cryptv          +linebreak       -python          +vreplace
+cscope          +lispindent      -python3         +wildignore
</code>```

答:
```<code>./configure   --prefix=/usr/local/           \
                       --with-features=huge  \
                       --enable-multibyte    \
                       --enable-cscope=yes   \
                       --enable-perlinterp=yes     \
                       --enable-rubyinterp=yes     \
                       --with-ruby-command=/usr/bin/ruby     \
                       --enable-luainterp=yes                \
                       --enable-pythoninterp=yes             \
                       --enable-python3interp=yes            \
                       --enable-tclinterp=yes                   \
                       --enable-gui=auto --enable-gnome-check   \
                       --enable-xim --enable-fontset            \
                        --with-x --with-compiledby=$USER
</code>```

Body:
I want to compile vim80 following the instruction on the webpage.

build vim80 from source with python2 and 3 support

./configure --with-features=huge \
            --enable-multibyte \
            --enable-rubyinterp=yes \
            --enable-pythoninterp=yes \
            --with-python-config-dir=/usr/lib/python2.7/config \
            --enable-python3interp=yes \
            --with-python3-config-dir=/usr/lib/python3.5/config \
            --enable-perlinterp=yes \
            --enable-luainterp=yes \
            --enable-gui=gtk2 --enable-cscope --prefix=/usr

How to customize it according to my environment?

1.For python2.7

 ls /usr/lib/python2.7 |grep config
config-x86_64-linux-gnu
_sysconfigdata.py
_sysconfigdata.pyc
_sysconfigdata.pyo
sysconfig.py
sysconfig.pyc
sysconfig.pyo

2.For python3

sudo find /  -name  'config' |grep python3
/home/debian8/anaconda3/lib/python3.6/site-packages/navigator_updater/config
/home/debian8/anaconda3/lib/python3.6/site-packages/anaconda_navigator/config
/home/debian8/anaconda3/lib/python3.6/site-packages/spyder/config
/home/debian8/anaconda3/lib/python3.6/site-packages/spyder/utils/help/js/mathjax/config
/home/debian8/anaconda3/lib/python3.6/site-packages/notebook/static/components/MathJax/config
/home/debian8/anaconda3/lib/python3.6/site-packages/notebook/services/config
/home/debian8/anaconda3/lib/python3.6/site-packages/astropy/config
/home/debian8/anaconda3/lib/python3.6/site-packages/traitlets/config
/home/debian8/anaconda3/pkgs/spyder-3.1.4-py36_0/lib/python3.6/site-packages/spyder/config
/home/debian8/anaconda3/pkgs/spyder-3.1.4-py36_0/lib/python3.6/site-packages/spyder/utils/help/js/mathjax/config
/home/debian8/anaconda3/pkgs/astropy-1.3.2-np112py36_0/lib/python3.6/site-packages/astropy/config
/home/debian8/anaconda3/pkgs/traitlets-4.3.2-py36_0/lib/python3.6/site-packages/traitlets/config
/home/debian8/anaconda3/pkgs/anaconda-navigator-1.6.2-py36_0/lib/python3.6/site-packages/anaconda_navigator/config
/home/debian8/anaconda3/pkgs/navigator-updater-0.1.0-py36_0/lib/python3.6/site-packages/navigator_updater/config
/home/debian8/anaconda3/pkgs/notebook-5.0.0-py36_0/lib/python3.6/site-packages/notebook/static/components/MathJax/config
/home/debian8/anaconda3/pkgs/notebook-5.0.0-py36_0/lib/python3.6/site-packages/notebook/services/config

More concretely,how to change the three lines for my os?

            --with-python-config-dir=/usr/lib/python2.7/config \
            --enable-python3interp=yes \
            --with-python3-config-dir=/usr/lib/python3.5/config \

Here is my try for python2 and 3 support.

./configure --with-features=huge \
            --enable-multibyte \
            --enable-rubyinterp=yes \
            --enable-pythoninterp=yes \
            --with-python-config-dir=/usr/lib/python2.7/config-x86_64-linux-gnu \
            --enable-python3interp=yes \
            --with-python3-config-dir=/home/debian8/anaconda3/lib/python3.6/site-packages/anaconda_navigator/config \
            --enable-perlinterp=yes \
            --enable-luainterp=yes \
            --enable-gui=gtk2 --enable-cscope --prefix=/usr

It is unlucky that no support python2 or python3 for this configuration after make install.

vim --version|grep python
+cryptv          +linebreak       -python          +vreplace
+cscope          +lispindent      -python3         +wildignore


问:
Filtering JSON to get specific results
I am using the Quotes on Design API  https://quotesondesign.com/api-v4-0/to show random quotes by designers on my site.

However, the idea is to show quotes but only by specific designers randomly.

My code below does not work. Any idea why and how should i go about it to get the desired results.

```<code>    $.ajaxSetup(
{  cache: false}
);

function newQuote(){
  $.getJSON('https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1&callback=', function(json,data){
 // Filter to return quotes by Steve Jobs only
    return json.filter(function(data){
      return (data[0].title == "Steve Jobs")
    });
    // add the quote(data[0].content) to my page.
    $('.quote_text').html(data[0].content);
  });

}
// get a new quote everytime i click the button (.message_btn)
$(document).ready(function(){
  newQuote();
  $('.message_btn').on('click',newQuote).fadeIn('slow');
});
</code>```

答:
Try this code. It appears that the server is using Wordpress legacy API. I've changed the request URL to randomly request for one of the titles in the array.</p>

```<code>function newQuote() {
    var titles = ["Steve Jobs", "Jonathan Ive", "Frank Zappa", "Kent Beck"];
    var index = Math.floor(Math.random() * titles.length);
    var url = "https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[name]=" + titles[index];

    $.getJSON(url, function(data) {

        console.log("data length: " + data.length);
        console.log("returned  title: " + data[0].title);

        if (data.length)
            $('.quote_text').html(data[0].content + " - " + data[0].title);
    });
}
</code>```

ContentLicense: CC BY-SA 4.0

Title: Filtering JSON to get specific results

Body:
I am using the Quotes on Design API  https://quotesondesign.com/api-v4-0/to show random quotes by designers on my site.

However, the idea is to show quotes but only by specific designers randomly.

My code below does not work. Any idea why and how should i go about it to get the desired results.

    $.ajaxSetup(
{  cache: false}
);

function newQuote(){
  $.getJSON('https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1&callback=', function(json,data){
 // Filter to return quotes by Steve Jobs only
    return json.filter(function(data){
      return (data[0].title == "Steve Jobs")
    });
    // add the quote(data[0].content) to my page.
    $('.quote_text').html(data[0].content);
  });

}
// get a new quote everytime i click the button (.message_btn)
$(document).ready(function(){
  newQuote();
  $('.message_btn').on('click',newQuote).fadeIn('slow');
});

Body:
Try this code. It appears that the server is using Wordpress legacy API. I've changed the request URL to randomly request for one of the titles in the array.

function newQuote() {
    var titles = ["Steve Jobs", "Jonathan Ive", "Frank Zappa", "Kent Beck"];
    var index = Math.floor(Math.random() * titles.length);
    var url = "https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[name]=" + titles[index];

    $.getJSON(url, function(data) {

        console.log("data length: " + data.length);
        console.log("returned  title: " + data[0].title);

        if (data.length)
            $('.quote_text').html(data[0].content + " - " + data[0].title);
    });
}