问:
No provider for Http! - migrating from angular 2 to 4
I have included HttpModule in my import as follows

app.module.ts

```<code>import { HttpModule, Http, XHRBackend, RequestOptions } from '@angular/Http';
import { ApiService } from '../services/api.service';
@NgModule({
imports: [
        BrowserModule,
        HttpModule,
        .........
    ]
providers: [
        ApiService,
        .......
    ]
    })
</code>```

ApiService is my custom Service .

app.component.ts

```<code>import { Component, OnInit,NgZone } from '@angular/core';
import { Platform, AlertController, Events } from 'ionic-angular';
import { HttpModule, Http, XHRBackend, RequestOptions } from '@angular/Http';
import { StatusBar, Splashscreen, OneSignal, Network, CodePush, SyncStatus } from 'ionic-native';
import { TabsPage } from '../pages/tabs/tabs';
import { EventsPage } from '../pages/events/events';
import { NewsPage } from '../pages/news/news';
import { RadioPage } from '../pages/radio/radio';
import { GalleryPage } from '../pages/gallery/gallery';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/fromEvent';
    declare var navigator: any;
    declare var Connection: any;

    @Component({
        templateUrl: 'app.html'

    })
    export class MyApp {

        rootPage = TabsPage;

        constructor(public platform: Platform, public alert: AlertController,
            private events: Events,
            public radioService: RadioPage,
            private codePush: CodePush,
            private ngZone: NgZone,
            public http:Http) { }

        ngOnInit() {

            this.platform.ready().then(() => {
                // My custom code
            });
        }
    }
</code>```

答:
It seems like you missed importing HttpModule.</p>

```<code>import { HttpModule } from '@angular/http';
</code>```

Body:
I have included HttpModule in my import as follows

app.module.ts

import { HttpModule, Http, XHRBackend, RequestOptions } from '@angular/Http';
import { ApiService } from '../services/api.service';
@NgModule({
imports: [
        BrowserModule,
        HttpModule,
        .........
    ]
providers: [
        ApiService,
        .......
    ]
    })

ApiService is my custom Service .

app.component.ts

import { Component, OnInit,NgZone } from '@angular/core';
import { Platform, AlertController, Events } from 'ionic-angular';
import { HttpModule, Http, XHRBackend, RequestOptions } from '@angular/Http';
import { StatusBar, Splashscreen, OneSignal, Network, CodePush, SyncStatus } from 'ionic-native';
import { TabsPage } from '../pages/tabs/tabs';
import { EventsPage } from '../pages/events/events';
import { NewsPage } from '../pages/news/news';
import { RadioPage } from '../pages/radio/radio';
import { GalleryPage } from '../pages/gallery/gallery';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/fromEvent';
    declare var navigator: any;
    declare var Connection: any;

    @Component({
        templateUrl: 'app.html'

    })
    export class MyApp {

        rootPage = TabsPage;

        constructor(public platform: Platform, public alert: AlertController,
            private events: Events,
            public radioService: RadioPage,
            private codePush: CodePush,
            private ngZone: NgZone,
            public http:Http) { }

        ngOnInit() {

            this.platform.ready().then(() => {
                // My custom code
            });
        }
    }

Body:
It seems like you missed importing HttpModule.

import { HttpModule } from '@angular/http';


来源: stackexchange

答:
You should use  import { Response, Http } from '@angular/http';in your component and service.

and as you posted above you are missing import { HttpModule } from '@angular/http';

EDIT:

Update your package.json to match the following dependencies, remove the existing node_modules directory, and then run npm instalL. Check this link.

ContentLicense: CC BY-SA 3.0

Title: No provider for Http! - migrating from angular 2 to 4


问:
disable "click" for a limited time
I made a simple Java Script game where you can flip cards and look for a match. Much resembling "Memory". My problem is when I click the elements (cards) you can still click the other elements (cards) therefore being able to flip more than 2 cards at a time, which would be cheating. I do have in place a setTimeout function that will automatically flip the cards all back over when the time runs out (after 2 cards have been flipped). Is there a way I could disable the clicking of the elements (cards) during the duration of the setTimeout and then re-allow the clicking after.

I tried $('body').on('click',(false)); cause I figured if you couldn't  click on anything that would work just the same, but it doesn't stop any clicks.

My code runs like this $("#Card1").on('click', function(){and each card is in a div (so that way the image is clickable).

Also please excuse any mistakes I've made here, I'm a bit of a novice and new to posting on forms.

答:
Try this:</p>

```<code>$("#Card1").off('click');
</code>```

Title: disable "click" for a limited time

Body:
Try this:

$("#Card1").off('click');


问:
Hide login/register button when logged in and hide logout button when logged out
i'm kinda new in PHP and I have some issues. When I'm logged in on my website I want to hide the 'Login' and 'Register' button, and when I'm logged out I want to hide the 'logout' button.

This is my login.php page:

```<code><?php
    include "navbar.php";
?>
<?php
    include_once "check.php";

    $error = ""; //Variable for storing our errors.
    if(isset($_POST["submit"]))
    {
        if(empty($_POST["username"]) || empty($_POST["password"]))
        {
            $error = "Both fields are required.";
        }else
        {
            // Define $username and $password
            $username=$_POST['username'];
            $password=$_POST['password'];

            // To protect from MySQL injection
            $username = stripslashes($username);
            $password = stripslashes($password);
            $username = mysqli_real_escape_string($db, $username);
            $password = mysqli_real_escape_string($db, $password);
            $password = md5($password);

            //Check username and password from database
            $sql="SELECT uid FROM users WHERE username='$username' and password='$password'";
            $result=mysqli_query($db,$sql);
            $row=mysqli_fetch_array($result,MYSQLI_ASSOC);

            //If username and password exist in our database then create a session.
            //Otherwise echo error.

            if(mysqli_num_rows($result) == 1)
            {
                $_SESSION['username'] = $username;
                header("location: index.php");
            }else
            {
                $error = "Incorrect username or password.";
            }

        }
    }

?>
<html>
    <head>
        <link rel="stylesheet" type="text/css" href="assets/css/acc.css">
        <link rel="stylesheet" type="text/css" href="assets/css/acc2.css">
        <link rel="stylesheet" type="text/css" href="assets/css/navbar.css">
        <title>Login | Peerbolte-ICT</title>
    </head>
    </body>
        <section>
        <p style="color:red;"><?php echo $error; ?> </p>
            <form method="POST" action="">
                <div class="accPanel">
                <h1 style="color: black; padding-bottom: 5%;">Login</h1>
                <form method="POST" action="">
                    <div class="login-input">
                        <label class="accLabel"><b>Username<span style="color:red;">*</span></b></label>
                        <input type="text" placeholder="Enter Username" name="username" required>

                        <label class="accLabel"><b>Password<span style="color:red;">*</span></b></label>
                        <input type="password" placeholder="Enter Password" name="password" required>

                        <button class="submitButton" type="submit" name="submit">Login</button>
                    </div>
                </form>
            </div>
        </section>
    </body>
</html>
</code>```

And this is my navbar.php where the buttons are:

```<code><ul>
  <li><a href="index.php">Home</a></li>
  <li><a href="#bannerTwo">Services</a></li>
  <li class="dropdown">
    <a href="javascript:void(0)" class="dropbtn">Our Work</a>
    <div class="dropdown-content">
      <a href="#">Link 1</a>
      <a href="#">Link 2</a>
      <a href="#">Link 3</a>
    </div>
  </li>
  <li class="dropdown">
    <a href="javascript:void(0)" class="dropbtn">Account</a>
    <div class="dropdown-content">
      <a href="login.php">Login</a>
      <a href="register.php">Register</a>
      <a href="logout.php">Logout</a>
    </div>
  </li>
</ul>
</code>```

Thanks

答:
You can use sessions to check if a user is logged in or logged out.

```<code>$_SESSION['status'] = 1;//if logged in
$_SESSION['status'] = 0;//if logged out
</code>```

To hide the links, you can use this:

```<code><a href="login.php" <?php echo ($_SESSION['status'] == 1) ? 'style="display:none;"' : '' ?> >Login</a>
<a href="register.php" <?php echo ($_SESSION['status'] == 1) ? 'style="display:none;"' : '' ?>>Register</a>
<a href="logout.php" <?php echo ($_SESSION['status'] == 0) ? 'style="display:none;"' : '' ?>>Logout</a>
</code>```

And don't forget to the put session_start() so that you can use sessions

Body:
i'm kinda new in PHP and I have some issues. When I'm logged in on my website I want to hide the 'Login' and 'Register' button, and when I'm logged out I want to hide the 'logout' button.

This is my login.php page:

<?php
    include "navbar.php";
?>
<?php
    include_once "check.php";

    $error = ""; //Variable for storing our errors.
    if(isset($_POST["submit"]))
    {
        if(empty($_POST["username"]) || empty($_POST["password"]))
        {
            $error = "Both fields are required.";
        }else
        {
            // Define $username and $password
            $username=$_POST['username'];
            $password=$_POST['password'];

            // To protect from MySQL injection
            $username = stripslashes($username);
            $password = stripslashes($password);
            $username = mysqli_real_escape_string($db, $username);
            $password = mysqli_real_escape_string($db, $password);
            $password = md5($password);

            //Check username and password from database
            $sql="SELECT uid FROM users WHERE username='$username' and password='$password'";
            $result=mysqli_query($db,$sql);
            $row=mysqli_fetch_array($result,MYSQLI_ASSOC);

            //If username and password exist in our database then create a session.
            //Otherwise echo error.

            if(mysqli_num_rows($result) == 1)
            {
                $_SESSION['username'] = $username;
                header("location: index.php");
            }else
            {
                $error = "Incorrect username or password.";
            }

        }
    }

?>

        <link rel="stylesheet" type="text/css" href="assets/css/acc.css">
        <link rel="stylesheet" type="text/css" href="assets/css/acc2.css">
        <link rel="stylesheet" type="text/css" href="assets/css/navbar.css">
        <title>Login | Peerbolte-ICT</title>

<?php echo $error; ?>

            <form method="POST" action="">

Login

                <form method="POST" action="">

                        Username*
                        <input type="text" placeholder="Enter Username" name="username" required>

                        Password*
                        <input type="password" placeholder="Enter Password" name="password" required>

                        <button class="submitButton" type="submit" name="submit">Login</button>

                </form>

And this is my navbar.php where the buttons are:

Home

Services

    Our Work

      Link 1
      Link 2
      Link 3

    Account

      Login
      Register
      Logout

Thanks

Body:
You can use sessions to check if a user is logged in or logged out.

$_SESSION['status'] = 1;//if logged in
$_SESSION['status'] = 0;//if logged out

To hide the links, you can use this:

<a href="login.php" <?php echo ($_SESSION['status'] == 1) ? 'style="display:none;"' : '' ?> >Login</a>
<a href="register.php" <?php echo ($_SESSION['status'] == 1) ? 'style="display:none;"' : '' ?>>Register</a>
<a href="logout.php" <?php echo ($_SESSION['status'] == 0) ? 'style="display:none;"' : '' ?>>Logout</a>

And don't forget to the put session_start() so that you can use sessions


问:
Setting a maximum size for vertical windows in vim
When working with split windows, I often make use of the command to size all windows equally. However, I also use mini buffer explorer in a vertical window, which I want to keep to a maximum width of 25. Is there any way I can configure vim so that either the mini buffer explorer window does not get re-sized or it stays at a maximum width of 25?

Thanks!

答:
You can do

```<code>:set winfixwidth
</code>```

in the window that you want to stay the same.

See

```<code>:help winfixheight
:help winfixwidth
</code>```

ContentLicense: CC BY-SA 2.5

Body:
You can do

:set winfixwidth

in the window that you want to stay the same.

See

:help winfixheight
:help winfixwidth


问:
Smooth Ring 3D in three.js
I want to draw a ring with the help of ExtrudeGeometry.

```<code>Ring3D = function(innerRadius, outerRadius, heigth, Segments) {

    var extrudeSettings = {
        amount: heigth,
        bevelEnabled: false,
        curveSegments: Segments
    };
    var arcShape = new THREE.Shape();
    arcShape.moveTo(outerRadius, 0);
    arcShape.absarc(0, 0, outerRadius, 0, Math.PI * 2, false);

    var holePath = new THREE.Path();
    holePath.moveTo(innerRadius, 0);
    holePath.absarc(0, 0, innerRadius, 0, Math.PI * 2, true);
    arcShape.holes.push(holePath);

    var geometry = new THREE.ExtrudeGeometry(arcShape, extrudeSettings);

    var material = new THREE.MeshPhongMaterial({
        color: 0x00ffff
    });

    var mesh = new THREE.Mesh(geometry, material);
    mesh.rotation.x = Math.PI / 2;
    mesh.position.y = heigth / 2;

    var object = new THREE.Object3D;
    object.add(mesh);

    return object;

}
</code>```

The resulting figure has visible scars. And the cylinder and torus such scars not. How to get rid of them? Example here.

with geometry.computeVertexNormals();

答:
```<code>        var shape = new THREE.Shape();
        shape.moveTo(0, 0);
        shape.lineTo(0, 10);
        shape.quadraticCurveTo(35, 30, 0, 50);
        shape.lineTo(0, 60);
        shape.quadraticCurveTo(48, 30, 0, 0);

        var extrudeSettings = {
            amount : 20,
            steps : 10,
            bevelEnabled: false,
            curveSegments: 8
        };

        var geometry = new THREE.ExtrudeGeometry( shape, extrudeSettings );
        var mesh = new THREE.Mesh( geometry, new THREE.MeshPhongMaterial( { color: '0x804000' ,transparent: true,opacity: 0.2} ) );
        scene.add( mesh );
</code>```

Title: Smooth Ring 3D in three.js

Body:
I want to draw a ring with the help of ExtrudeGeometry.

Ring3D = function(innerRadius, outerRadius, heigth, Segments) {

    var extrudeSettings = {
        amount: heigth,
        bevelEnabled: false,
        curveSegments: Segments
    };
    var arcShape = new THREE.Shape();
    arcShape.moveTo(outerRadius, 0);
    arcShape.absarc(0, 0, outerRadius, 0, Math.PI * 2, false);

    var holePath = new THREE.Path();
    holePath.moveTo(innerRadius, 0);
    holePath.absarc(0, 0, innerRadius, 0, Math.PI * 2, true);
    arcShape.holes.push(holePath);

    var geometry = new THREE.ExtrudeGeometry(arcShape, extrudeSettings);

    var material = new THREE.MeshPhongMaterial({
        color: 0x00ffff
    });

    var mesh = new THREE.Mesh(geometry, material);
    mesh.rotation.x = Math.PI / 2;
    mesh.position.y = heigth / 2;

    var object = new THREE.Object3D;
    object.add(mesh);

    return object;

}

The resulting figure has visible scars. And the cylinder and torus such scars not. How to get rid of them? Example here.

with geometry.computeVertexNormals();


问:
Laravel controller calling database transaction
Does calling a database transaction in the Controller a good practice?
if no where should i proper call a database transaction?</p>

答:
Or you can search for Command Bus pattern

https://github.com/tillkruss/laravel-tactician

This package implements the Command Bus pattern easily with Laravel. It comes with a database transaction middleware and Command Bus is good for a scalable application moving the logic from controllers to Command Handlers.


问:
How to open ppt in slideshow mode
I'm able to open foo.ppt with command "open -b com.microsoft.Powerpoint foo.ppt" on Mac Terminal. But it is opened in Edit mode, how can it be opened in Slideshow mode? Thanks.</p>

答:
You could also create a Service in Automater. There are Presentation actions (for PP). It's very easy:

Under the Presentations actions, add Open PowerPoint Presentation

Then, add Play PowerPoint Slide Shows

That's it. Save the Service in Automater. It should appear in your context menu (right-click menu) when you right-click on Powerpoint files.

Title: How to open ppt in slideshow mode


问:
How to load chat history on top of recycler view android
Hi I am developing a chat application like whatsapp. I have to load the chat history from the api when user scrolls down like in whatsapp. I get the data and set it to the adapter. But the history is loading at the bottom of recycler view. I need to add it on top for every scroll. This is my code. Please help me. Thanks in advance.</p>

```<code>                              if (Status.equals("1")) {
                                historyList = resp.getHistory();
                                Log.i("history size",String.valueOf(resp.getHistory().size()));
                                String historysize = String.valueOf(resp.getHistory().size());
                                Message message = new Message();
                                for (int i = 0; i < resp.getHistory().size(); i++) {
                                    String fromusertoken = String.valueOf(resp.getHistory().get(i).getFromUserToken());
                                    String txtmsg = resp.getHistory().get(i).getMessage();
                                    String username = String.valueOf(resp.getHistory().get(i).getFromUserName());

                                    if (fromusertoken.equals(user_token)) {
                                        Message messages = new Message();
                                        messages.setUser_token(fromusertoken);
                                        messages.setUsername(username);
                                        messages.setIsMine(true);
                                        messages.setMessage(txtmsg);
                                        messageAdapter.add(messages);

                                    }
                                    else {
                                        Message messages = new Message();
                                        messages.setUser_token(fromusertoken);
                                        messages.setUsername(username);
                                        messages.setIsMine(false);
                                        messages.setMessage(txtmsg);
                                        messageAdapter.add(messages);
                                    }
                                }

                                messageAdapter.notifyDataSetChanged();
                                onItemsLoadComplete();

                                Toast.makeText(Single_chat.this, msg, Toast.LENGTH_SHORT).show();
                            }

                        } else {
                            Toast.makeText(Single_chat.this, msg, Toast.LENGTH_SHORT).show();
                        }
                    }
                } else {
                    Toast.makeText(Single_chat.this, "No Response", Toast.LENGTH_SHORT).show();
                }

            }
</code>```

答:
you can insert the history message at the index 0

messageAdapter.add(0,messages);

every iteration it will replace the first message by the last inserted message.

Body:
Hi I am developing a chat application like whatsapp. I have to load the chat history from the api when user scrolls down like in whatsapp. I get the data and set it to the adapter. But the history is loading at the bottom of recycler view. I need to add it on top for every scroll. This is my code. Please help me. Thanks in advance.

                              if (Status.equals("1")) {
                                historyList = resp.getHistory();
                                Log.i("history size",String.valueOf(resp.getHistory().size()));
                                String historysize = String.valueOf(resp.getHistory().size());
                                Message message = new Message();
                                for (int i = 0; i < resp.getHistory().size(); i++) {
                                    String fromusertoken = String.valueOf(resp.getHistory().get(i).getFromUserToken());
                                    String txtmsg = resp.getHistory().get(i).getMessage();
                                    String username = String.valueOf(resp.getHistory().get(i).getFromUserName());

                                    if (fromusertoken.equals(user_token)) {
                                        Message messages = new Message();
                                        messages.setUser_token(fromusertoken);
                                        messages.setUsername(username);
                                        messages.setIsMine(true);
                                        messages.setMessage(txtmsg);
                                        messageAdapter.add(messages);

                                    }
                                    else {
                                        Message messages = new Message();
                                        messages.setUser_token(fromusertoken);
                                        messages.setUsername(username);
                                        messages.setIsMine(false);
                                        messages.setMessage(txtmsg);
                                        messageAdapter.add(messages);
                                    }
                                }

                                messageAdapter.notifyDataSetChanged();
                                onItemsLoadComplete();

                                Toast.makeText(Single_chat.this, msg, Toast.LENGTH_SHORT).show();
                            }

                        } else {
                            Toast.makeText(Single_chat.this, msg, Toast.LENGTH_SHORT).show();
                        }
                    }
                } else {
                    Toast.makeText(Single_chat.this, "No Response", Toast.LENGTH_SHORT).show();
                }

            }


问:
Set input date and add it to list
Basically, i want to set dates and save it to a list. From my code below:

```<code>public List<RecordList> createRecord(BigDecimal yr){

    for (int index = 0; index <= 14; index++) {
        RecordList value = new RecordList();
        if(index == 0){
            value.setStartDt(toDate(("01-04-" + yr)));
            value.setEndDt(toDate(("30-04-" + yr)));
        }
        if(index == 1){
            value.setStartDt(toDate(("01-05-" + yr.add(new BigDecimal(1)))));
            value.setEndDt(toDate(("31-05-" + yr.add(new BigDecimal(1)))));
        }
        createRecord.add(newRecordValue);
    return createRecord;
}

private Date toDate(String date) {
    Date newDate = null;
    try {
        newDate = new SimpleDateFormat("dd-MM-YYYY").parse(date);
    }
    catch (ParseException e) {
        e.printStackTrace();
    }
    return newDate;
}
</code>```

what happens is, when I set the year to 2017, the output doesnt match with what I set:

```<code>"StartDate": "30-12-2017",
 "EndDate": "30-12-2017"
</code>```

and it doesnt increment to next year, instead it decrement to:

```<code>"StartDate": "30-12-2016",
 "EndDate": "30-12-2016"
</code>```

答:
The answer of @Jens is correct and should be accepted.

I add some proposals how to improve the error handling. As you can see, SimpleDateFormat is silent about what is wrong with your code. And I am sure that this behaviour has already caused many people to release tons of parsing code with sometimes "surprising" behaviour. Fortunately you have found just by accident that something is wrong.

Java-8

The new built-in library java.time (available since Java-8) would not parse but throw an exception

```<code>DateTimeFormatter dtf = DateTimeFormatter.ofPattern("dd-MM-YYYY");
LocalDate d = LocalDate.parse("30-12-2017", dtf);
</code>```

with following error message:

Exception in thread "main" java.time.format.DateTimeParseException:
  Text '30-12-2017' could not be parsed:  Unable to obtain LocalDate
  from TemporalAccessor:  {MonthOfYear=12,
  WeekBasedYear[WeekFields[MONDAY,4]]=2017, DayOfMonth=30}...

The existence of the field "WeekBasedYear" in the error message should enlighten you what is wrong so you go to the documentation to look for the right pattern symbol.

By the way, there is also a backport Threeten-BP available for Java-6+7. And I have now also tested the popular library Joda-Time:

```<code>DateTimeFormatter dtf = DateTimeFormat.forPattern("dd-MM-YYYY");
System.out.println(dtf.parseLocalDate("30-12-2017")); // 2017-12-30 (don't use it!)
</code>```

So Java-8 is also an improvement for Joda-Time which does not see any problem in your pattern.

My library Time4J

```<code>ChronoFormatter<PlainDate> cf =
    ChronoFormatter.ofDatePattern("dd-MM-YYYY", PatternType.CLDR, Locale.ROOT);
LocalDate d = cf.parse("30-12-2017").toTemporalAccessor(); // not even executed
</code>```

Here the construction of the parser fails with following message:

java.lang.IllegalArgumentException:

  Y as week-based-year requires a week-date-format: dd-MM-YYYY

Title: Set input date and add it to list

Body:
Basically, i want to set dates and save it to a list. From my code below:

public List<RecordList> createRecord(BigDecimal yr){

    for (int index = 0; index <= 14; index++) {
        RecordList value = new RecordList();
        if(index == 0){
            value.setStartDt(toDate(("01-04-" + yr)));
            value.setEndDt(toDate(("30-04-" + yr)));
        }
        if(index == 1){
            value.setStartDt(toDate(("01-05-" + yr.add(new BigDecimal(1)))));
            value.setEndDt(toDate(("31-05-" + yr.add(new BigDecimal(1)))));
        }
        createRecord.add(newRecordValue);
    return createRecord;
}

private Date toDate(String date) {
    Date newDate = null;
    try {
        newDate = new SimpleDateFormat("dd-MM-YYYY").parse(date);
    }
    catch (ParseException e) {
        e.printStackTrace();
    }
    return newDate;
}

what happens is, when I set the year to 2017, the output doesnt match with what I set:

"StartDate": "30-12-2017",
 "EndDate": "30-12-2017"

and it doesnt increment to next year, instead it decrement to:

"StartDate": "30-12-2016",
 "EndDate": "30-12-2016"

Body:
The answer of @Jens is correct and should be accepted.

I add some proposals how to improve the error handling. As you can see, SimpleDateFormat is silent about what is wrong with your code. And I am sure that this behaviour has already caused many people to release tons of parsing code with sometimes "surprising" behaviour. Fortunately you have found just by accident that something is wrong.

Java-8

The new built-in library java.time (available since Java-8) would not parse but throw an exception

DateTimeFormatter dtf = DateTimeFormatter.ofPattern("dd-MM-YYYY");
LocalDate d = LocalDate.parse("30-12-2017", dtf);

with following error message:

Exception in thread "main" java.time.format.DateTimeParseException:
  Text '30-12-2017' could not be parsed:  Unable to obtain LocalDate
  from TemporalAccessor:  {MonthOfYear=12,
  WeekBasedYear[WeekFields[MONDAY,4]]=2017, DayOfMonth=30}...

The existence of the field "WeekBasedYear" in the error message should enlighten you what is wrong so you go to the documentation to look for the right pattern symbol.

By the way, there is also a backport Threeten-BP available for Java-6+7. And I have now also tested the popular library Joda-Time:

DateTimeFormatter dtf = DateTimeFormat.forPattern("dd-MM-YYYY");
System.out.println(dtf.parseLocalDate("30-12-2017")); // 2017-12-30 (don't use it!)

So Java-8 is also an improvement for Joda-Time which does not see any problem in your pattern.

My library Time4J

ChronoFormatter<PlainDate> cf =
    ChronoFormatter.ofDatePattern("dd-MM-YYYY", PatternType.CLDR, Locale.ROOT);
LocalDate d = cf.parse("30-12-2017").toTemporalAccessor(); // not even executed

Here the construction of the parser fails with following message:

java.lang.IllegalArgumentException:

  Y as week-based-year requires a week-date-format: dd-MM-YYYY


问:
Allow Outlook 2007 to edit custom shared iCalendars
I have been working on some custom shared Internet calendar software. I currently have a webdav server setup using apache and my software (using python) and right now it works great with Thunderbird and the Lightning plugin, I can subscribe to an icalendar and edit events with no problem. However I've run into a snag with Outlook 2007. I can currently read an icalendar but it sets that calendar in Outlook 2007 to read only. Doing some searching I've come across some findings saying that setting up some webdav server stuff on a Windows machine I can get the machine to tell Outlook 2007 that the calendar can be editted as well (basically turn off the read only and allow that icalendar to be published). I'm currently trying to set the server up to work with but thought I might ask SO to speed up my research a bit.

My question basically is, is there some header information or something else that I can send in my response back to Outlook to let it know an Internet calendar has write privaleges? I know in general it is controlled by the client whether an icalendar can be written to since I can read and write these same calendars just fine in Thunderbird.

Additionally, I have heard this read/write problem with Internet calendars have been solved in Outlook 2010 but upgrading to that is not an option.

答: Microsoft Outlook 2007 seems to have no ability to allow writing to an Internet Calendar. Icalendars are set to read only. You can publish a calendar to a webdav to create your own icalendar but that calendar (in your Outlook '07) would never update if someone else were to somehow edit that calendar (on the server). It would always just overwrite it when it makes a 'PUT' to the server.</p>


问:
Visual Studio Professional with Microsoft Action Pack
Microsoft Action Pack is an annual subscription from Microsoft for Microsoft partners, and one of the advertised benefits is "three Visual Studio Professional licenses". When I log in, I can see some of the other software benefits, but I can not find out how to download VS Professional except as a 90 day trial. Any ideas?</p>

答:
If anyone is still looking for an answer:

At the time of this writing each Action Pack subscription grants
"a Visual Studio Professional subscription [...] to individuals that are assigned the role of technical contact"
(source: Partner Network Program Administrator Guide).
Meaning: the 3 Persons listed in the Partner Membership Center at the Program Contacts (Partner Membership Center > Requirements & Assets > Assign Contact Roles) section with the role of either
First-, Second-, or Third Technical Contact get a Visual Studio Professional subscription in their Microsoft Account.

These following steps get you there:

Make sure that every person which wants to use Visual Studio is associated with your Partner Organization ID.

If someone is missing, you can send out invitations with the form at Partner Membership Center > Requirements & Assets > Invite People to Associate > Add new People. You can already assign them the required Technical Contact role on that invitation form.

Alternatively you can give them your Organization Partner ID and they can request association with your company when they login to the Partner Membership Center.

Using the login link included in the invitation email each person has to accept the association to your organization.

If you haven't already assigned the Technical Contact role at the invitation form, you can assign (or change) that role at Partner Membership Center > Requirements & Assets > Assign Contact Roles.

After those steps the subscription will show up at the persons Visual Studio Subscriptions page. There might be some time between the association and the subscription showing up - in one of my cases it took several hours after the person was already successfully listed as technical contact.

Also in my experience the subscription only shows up when the persons mail address that is used for the Microsoft Account is the same address listed in the Partner Membership Center. While you can accept the invitation logged in with a different (i.e. private) account, the Visual Studio Professional subscription itself is only granted to a Microsoft account with the same email as the email to which the invitation was issued.


问:
How to compile C++ std::thread code with MinGW?
I would like to compile my c++11 project (recently moved to c++11) with MinGW. And I have compiling errors about c++11 code like "std::thread not found".

I used the last MinGW with gcc 5.3.0 (December 2015). A the end, I would like only to compile this example before to compile my big project :

```<code>#include <iostream>
#include <thread>
#include <chrono>

void foo()
{
    // simulate expensive operation
    std::this_thread::sleep_for(std::chrono::seconds(1));
}

void bar()
{
    // simulate expensive operation
    std::this_thread::sleep_for(std::chrono::seconds(1));
}

int main()
{
    std::cout << "starting first helper...\n";
    std::thread helper1(foo);

    std::cout << "starting second helper...\n";
    std::thread helper2(bar);

    std::cout << "waiting for helpers to finish..." << std::endl;
    helper1.join();
    helper2.join();

    std::cout << "done!\n";
}
</code>```

(source : http://en.cppreference.com/w/cpp/thread/thread/join)

I tried "g++ -std=c++11 main.cpp" and "g++ main.cpp -std=c++0x" but I have always those following errors :

```<code>main.cpp: In function 'void foo()':
main.cpp:8:10: error: 'std::this_thread' has not been declared
     std::this_thread::sleep_for(std::chrono::seconds(1));
          ^
main.cpp: In function 'void bar()':
main.cpp:14:10: error: 'std::this_thread' has not been declared
     std::this_thread::sleep_for(std::chrono::seconds(1));
          ^
main.cpp: In function 'int main()':
main.cpp:20:5: error: 'thread' is not a member of 'std'
     std::thread helper1(foo);
     ^
main.cpp:23:5: error: 'thread' is not a member of 'std'
     std::thread helper2(bar);
     ^
main.cpp:26:5: error: 'helper1' was not declared in this scope
     helper1.join();
     ^
main.cpp:27:5: error: 'helper2' was not declared in this scope
     helper2.join();
     ^
</code>```

答:
MinGW mostly does not have a port of glibc which supports pthreading or gthreading like in GCC.

For solving this, the  first solution can be installing library of thread headers.
The other solution can be working with GCC compiler.

Body:
I would like to compile my c++11 project (recently moved to c++11) with MinGW. And I have compiling errors about c++11 code like "std::thread not found".

I used the last MinGW with gcc 5.3.0 (December 2015). A the end, I would like only to compile this example before to compile my big project :

#include <iostream>
#include <thread>
#include <chrono>

void foo()
{
    // simulate expensive operation
    std::this_thread::sleep_for(std::chrono::seconds(1));
}

void bar()
{
    // simulate expensive operation
    std::this_thread::sleep_for(std::chrono::seconds(1));
}

int main()
{
    std::cout << "starting first helper...\n";
    std::thread helper1(foo);

    std::cout << "starting second helper...\n";
    std::thread helper2(bar);

    std::cout << "waiting for helpers to finish..." << std::endl;
    helper1.join();
    helper2.join();

    std::cout << "done!\n";
}

(source : http://en.cppreference.com/w/cpp/thread/thread/join)

I tried "g++ -std=c++11 main.cpp" and "g++ main.cpp -std=c++0x" but I have always those following errors :

main.cpp: In function 'void foo()':
main.cpp:8:10: error: 'std::this_thread' has not been declared
     std::this_thread::sleep_for(std::chrono::seconds(1));
          ^
main.cpp: In function 'void bar()':
main.cpp:14:10: error: 'std::this_thread' has not been declared
     std::this_thread::sleep_for(std::chrono::seconds(1));
          ^
main.cpp: In function 'int main()':
main.cpp:20:5: error: 'thread' is not a member of 'std'
     std::thread helper1(foo);
     ^
main.cpp:23:5: error: 'thread' is not a member of 'std'
     std::thread helper2(bar);
     ^
main.cpp:26:5: error: 'helper1' was not declared in this scope
     helper1.join();
     ^
main.cpp:27:5: error: 'helper2' was not declared in this scope
     helper2.join();
     ^


问:
Err: mappedBy reference an unknown target entity property:
I dont know where actually im going wrong can someone help to get rid of this error.

```<code>@Entity
@Table(name="nifty", catalog="portfolio")
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id",scope=NiftyDTO.class)
@JsonIgnoreProperties({"latestData","data"})

public class NiftyDTO implements Serializable {

private static final long serialVersionUID = 1L;

@Id
@Column(name="niftyid")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column(name="time")
private String time;

@Column(name="trdVolumesumMil")
private String trdVolumesumMil;

@Column(name="declines")
private int declines;

@Column(name="trdValueSum")
private String trdValueSum;

@Column(name="trdValueSumMil")
private String trdValueSumMil;

@Column(name="unchanged")
private int unchanged;

@Column(name="trdVolumesum")
private String trdVolumesum;

@Column(name="advances")
private int advances;

public Long getId() {
    return id;
}

public void setId(Long id) {
    this.id = id;
}

public String getTime() {
    return time;
}

public void setTime(String time) {
    this.time = time;
}

public String getTrdVolumesumMil() {
    return trdVolumesumMil;
}

public void setTrdVolumesumMil(String trdVolumesumMil) {
    this.trdVolumesumMil = trdVolumesumMil;
}

public int getDeclines() {
    return declines;
}

public void setDeclines(int declines) {
    this.declines = declines;
}

public String getTrdValueSum() {
    return trdValueSum;
}

public void setTrdValueSum(String trdValueSum) {
    this.trdValueSum = trdValueSum;
}

public String getTrdValueSumMil() {
    return trdValueSumMil;
}

public void setTrdValueSumMil(String trdValueSumMil) {
    this.trdValueSumMil = trdValueSumMil;
}

public int getUnchanged() {
    return unchanged;
}

public void setUnchanged(int unchanged) {
    this.unchanged = unchanged;
}

public String getTrdVolumesum() {
    return trdVolumesum;
}

public void setTrdVolumesum(String trdVolumesum) {
    this.trdVolumesum = trdVolumesum;
}

public int getAdvances() {
    return advances;
}

public void setAdvances(int advances) {
    this.advances = advances;
}

public NiftyDTO() {
    super();
}

@OneToMany(mappedBy = "nifty", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
private Set<NiftyDataDTO> niftyDataDTO;

public Set<NiftyDataDTO> getNiftyDataDTO() {
    return niftyDataDTO;
}

public void setNiftyDataDTO(Set<NiftyDataDTO> niftyDataDTO) {
    this.niftyDataDTO = niftyDataDTO;
}

public NiftyDTO(Long id, String trdVolumesumMil, String time, int declines, String trdValueSum, String trdValueSumMil, int unchanged, String trdVolumesum, int advances, Set<NiftyDataDTO> niftyDatumDTOS) {
    this.id = id;
    this.trdVolumesumMil = trdVolumesumMil;
    this.time = time;
    this.declines = declines;
    this.trdValueSum = trdValueSum;
    this.trdValueSumMil = trdValueSumMil;
    this.unchanged = unchanged;
    this.trdVolumesum = trdVolumesum;
    this.advances = advances;
    this.niftyDataDTO = niftyDataDTO;
}

}
</code>```

This is my another class

```<code>@Entity
@Table(name="NiftyDataDTO", catalog="portfolio")
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id", scope=NiftyDataDTO.class)

 @JsonIgnoreProperties({"ptsC","per","trdVol","trdVolM","ntP","mVal","wkhi","wklo","wkhicm_adj","wklocm_adj","xDt","cAct","previousClose","dayEndClose","yPC","mPC"})

public class NiftyDataDTO implements Serializable {

private static final long serialVersionUID = 1L;

@Id
@Column(name = "dataId")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column(name="symbol", nullable = false)
private String symbol;

@Column(name="open")
private float open;

@Column(name="high")
private float high;

@Column(name="low")
private float low;

@Column(name = "itp")
private float itp;

@XmlTransient
@ManyToOne(optional = true ,fetch = FetchType.LAZY)
@JoinColumn(name = "niftyid", referencedColumnName = "niftyid")
private NiftyDTO niftyDTO;

@JsonIgnore
public NiftyDTO getNiftyDTO() { return niftyDTO;}

public NiftyDataDTO(Long id, String symbol, float open, float high, float low, float itp, NiftyDTO niftyDTO) {
    super();
    this.id = id;
    this.symbol = symbol;
    this.open = open;
    this.high = high;
    this.low = low;
    this.itp = itp;
    this.niftyDTO = niftyDTO;
}

//Getter And Setter

public Long getId() {
    return id;
}

public void setId(Long id) {
    this.id = id;
}

public String getSymbol() {
    return symbol;
}

public void setSymbol(String symbol) {
    this.symbol = symbol;
}

public float getOpen() {
    return open;
}

public void setOpen(float open) {
    this.open = open;
}

public float getHigh() {
    return high;
}

public void setHigh(float high) {
    this.high = high;
}

public float getLow() {
    return low;
}

public void setLow(float low) {
    this.low = low;
}

public float getItp() {
    return itp;
}

public void setItp(float itp) {
    this.itp = itp;
}

public void setNiftyDTO(NiftyDTO niftyDTO) {
    this.niftyDTO = niftyDTO;
}

public NiftyDataDTO() {
    super();
    // TODO Auto-generated constructor stub
}

}
</code>```

Stack Trace:

```<code>org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1582) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1054) ~[spring-context-4.2.8.RELEASE.jar:4.2.8.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:829) ~[spring-context-4.2.8.RELEASE.jar:4.2.8.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538) ~[spring-context-4.2.8.RELEASE.jar:4.2.8.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) ~[spring-boot-1.3.8.RELEASE.jar:1.3.8.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:760) [spring-boot-1.3.8.RELEASE.jar:1.3.8.RELEASE]
at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:360) [spring-boot-1.3.8.RELEASE.jar:1.3.8.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:306) [spring-boot-1.3.8.RELEASE.jar:1.3.8.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1185) [spring-boot-1.3.8.RELEASE.jar:1.3.8.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1174) [spring-boot-1.3.8.RELEASE.jar:1.3.8.RELEASE]
at com.socgen.portfolio.PMSApplication.main(PMSApplication.java:17) [classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_92]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_92]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_92]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_92]
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147) [idea_rt.jar:na]
    Caused by: javax.persistence.PersistenceException: [PersistenceUnit:
    default] Unable to build Hibernate SessionFactory
atorg.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.persistenceException(EntityManagerFactoryBuilderImpl.java:1249) ~[hibernate-entitymanager-4.3.11.Final.jar:4.3.11.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.access$600(EntityManagerFactoryBuilderImpl.java:120) ~[hibernate-entitymanager-4.3.11.Final.jar:4.3.11.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:860) ~[hibernate-entitymanager-4.3.11.Final.jar:4.3.11.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:850) ~[hibernate-entitymanager-4.3.11.Final.jar:4.3.11.Final]
at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.withTccl(ClassLoaderServiceImpl.java:425) ~[hibernate-core-4.3.11.Final.jar:4.3.11.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:849) ~[hibernate-entitymanager-4.3.11.Final.jar:4.3.11.Final]
at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:60) ~[spring-orm-4.2.8.RELEASE.jar:4.2.8.RELEASE]
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:340) ~[spring-orm-4.2.8.RELEASE.jar:4.2.8.RELEASE]
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:319) ~[spring-orm-4.2.8.RELEASE.jar:4.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1641) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
... 21 common frames omitted
Caused by: org.hibernate.AnnotationException: mappedBy reference an unknown
target entity property: com.socgen.portfolio.domain.NiftyDataDTO.nifty in com.socgen.portfolio.domain.NiftyDTO.niftyDataDTO
at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:769) ~[hibernate-core-4.3.11.Final.jar:4.3.11.Final]
at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:729) ~[hibernate-core-4.3.11.Final.jar:4.3.11.Final]
at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:70) ~[hibernate-core-4.3.11.Final.jar:4.3.11.Final]
at org.hibernate.cfg.Configuration.originalSecondPassCompile(Configuration.java:1697) ~[hibernate-core-4.3.11.Final.jar:4.3.11.Final]
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1426) ~[hibernate-core-4.3.11.Final.jar:4.3.11.Final]
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1846) ~[hibernate-core-4.3.11.Final.jar:4.3.11.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:857) ~[hibernate-entitymanager-4.3.11.Final.jar:4.3.11.Final]
... 29 common frames omitted

2017-06-08 14:38:03.305  WARN 142244 --- [           main] o.s.boot.SpringApplication               : Error handling failed (Error creating bean with name 'delegatingApplicationListener' defined in class path resource [org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.class]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration': Initialization of bean failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'org.springframework.context.annotation.ConfigurationClassPostProcessor.importRegistry' is defined)

Process finished with exit code 1
</code>```

答:
mappedby must have a valid property name as value:

```<code>@OneToMany(mappedBy = "niftyDTO", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
private Set<NiftyDataDTO> niftyDataDTO;
</code>```

Body:
I dont know where actually im going wrong can someone help to get rid of this error.

@Entity
@Table(name="nifty", catalog="portfolio")
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id",scope=NiftyDTO.class)
@JsonIgnoreProperties({"latestData","data"})

public class NiftyDTO implements Serializable {

private static final long serialVersionUID = 1L;

@Id
@Column(name="niftyid")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column(name="time")
private String time;

@Column(name="trdVolumesumMil")
private String trdVolumesumMil;

@Column(name="declines")
private int declines;

@Column(name="trdValueSum")
private String trdValueSum;

@Column(name="trdValueSumMil")
private String trdValueSumMil;

@Column(name="unchanged")
private int unchanged;

@Column(name="trdVolumesum")
private String trdVolumesum;

@Column(name="advances")
private int advances;

public Long getId() {
    return id;
}

public void setId(Long id) {
    this.id = id;
}

public String getTime() {
    return time;
}

public void setTime(String time) {
    this.time = time;
}

public String getTrdVolumesumMil() {
    return trdVolumesumMil;
}

public void setTrdVolumesumMil(String trdVolumesumMil) {
    this.trdVolumesumMil = trdVolumesumMil;
}

public int getDeclines() {
    return declines;
}

public void setDeclines(int declines) {
    this.declines = declines;
}

public String getTrdValueSum() {
    return trdValueSum;
}

public void setTrdValueSum(String trdValueSum) {
    this.trdValueSum = trdValueSum;
}

public String getTrdValueSumMil() {
    return trdValueSumMil;
}

public void setTrdValueSumMil(String trdValueSumMil) {
    this.trdValueSumMil = trdValueSumMil;
}

public int getUnchanged() {
    return unchanged;
}

public void setUnchanged(int unchanged) {
    this.unchanged = unchanged;
}

public String getTrdVolumesum() {
    return trdVolumesum;
}

public void setTrdVolumesum(String trdVolumesum) {
    this.trdVolumesum = trdVolumesum;
}

public int getAdvances() {
    return advances;
}

public void setAdvances(int advances) {
    this.advances = advances;
}

public NiftyDTO() {
    super();
}

@OneToMany(mappedBy = "nifty", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
private Set<NiftyDataDTO> niftyDataDTO;

public Set<NiftyDataDTO> getNiftyDataDTO() {
    return niftyDataDTO;
}

public void setNiftyDataDTO(Set<NiftyDataDTO> niftyDataDTO) {
    this.niftyDataDTO = niftyDataDTO;
}

public NiftyDTO(Long id, String trdVolumesumMil, String time, int declines, String trdValueSum, String trdValueSumMil, int unchanged, String trdVolumesum, int advances, Set<NiftyDataDTO> niftyDatumDTOS) {
    this.id = id;
    this.trdVolumesumMil = trdVolumesumMil;
    this.time = time;
    this.declines = declines;
    this.trdValueSum = trdValueSum;
    this.trdValueSumMil = trdValueSumMil;
    this.unchanged = unchanged;
    this.trdVolumesum = trdVolumesum;
    this.advances = advances;
    this.niftyDataDTO = niftyDataDTO;
}

}

This is my another class

@Entity
@Table(name="NiftyDataDTO", catalog="portfolio")
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id", scope=NiftyDataDTO.class)

 @JsonIgnoreProperties({"ptsC","per","trdVol","trdVolM","ntP","mVal","wkhi","wklo","wkhicm_adj","wklocm_adj","xDt","cAct","previousClose","dayEndClose","yPC","mPC"})

public class NiftyDataDTO implements Serializable {

private static final long serialVersionUID = 1L;

@Id
@Column(name = "dataId")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column(name="symbol", nullable = false)
private String symbol;

@Column(name="open")
private float open;

@Column(name="high")
private float high;

@Column(name="low")
private float low;

@Column(name = "itp")
private float itp;

@XmlTransient
@ManyToOne(optional = true ,fetch = FetchType.LAZY)
@JoinColumn(name = "niftyid", referencedColumnName = "niftyid")
private NiftyDTO niftyDTO;

@JsonIgnore
public NiftyDTO getNiftyDTO() { return niftyDTO;}

public NiftyDataDTO(Long id, String symbol, float open, float high, float low, float itp, NiftyDTO niftyDTO) {
    super();
    this.id = id;
    this.symbol = symbol;
    this.open = open;
    this.high = high;
    this.low = low;
    this.itp = itp;
    this.niftyDTO = niftyDTO;
}

//Getter And Setter

public Long getId() {
    return id;
}

public void setId(Long id) {
    this.id = id;
}

public String getSymbol() {
    return symbol;
}

public void setSymbol(String symbol) {
    this.symbol = symbol;
}

public float getOpen() {
    return open;
}

public void setOpen(float open) {
    this.open = open;
}

public float getHigh() {
    return high;
}

public void setHigh(float high) {
    this.high = high;
}

public float getLow() {
    return low;
}

public void setLow(float low) {
    this.low = low;
}

public float getItp() {
    return itp;
}

public void setItp(float itp) {
    this.itp = itp;
}

public void setNiftyDTO(NiftyDTO niftyDTO) {
    this.niftyDTO = niftyDTO;
}

public NiftyDataDTO() {
    super();
    // TODO Auto-generated constructor stub
}

}

Stack Trace:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1582) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1054) ~[spring-context-4.2.8.RELEASE.jar:4.2.8.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:829) ~[spring-context-4.2.8.RELEASE.jar:4.2.8.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538) ~[spring-context-4.2.8.RELEASE.jar:4.2.8.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) ~[spring-boot-1.3.8.RELEASE.jar:1.3.8.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:760) [spring-boot-1.3.8.RELEASE.jar:1.3.8.RELEASE]
at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:360) [spring-boot-1.3.8.RELEASE.jar:1.3.8.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:306) [spring-boot-1.3.8.RELEASE.jar:1.3.8.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1185) [spring-boot-1.3.8.RELEASE.jar:1.3.8.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1174) [spring-boot-1.3.8.RELEASE.jar:1.3.8.RELEASE]
at com.socgen.portfolio.PMSApplication.main(PMSApplication.java:17) [classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_92]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_92]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_92]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_92]
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147) [idea_rt.jar:na]
    Caused by: javax.persistence.PersistenceException: [PersistenceUnit:
    default] Unable to build Hibernate SessionFactory
atorg.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.persistenceException(EntityManagerFactoryBuilderImpl.java:1249) ~[hibernate-entitymanager-4.3.11.Final.jar:4.3.11.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.access$600(EntityManagerFactoryBuilderImpl.java:120) ~[hibernate-entitymanager-4.3.11.Final.jar:4.3.11.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:860) ~[hibernate-entitymanager-4.3.11.Final.jar:4.3.11.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:850) ~[hibernate-entitymanager-4.3.11.Final.jar:4.3.11.Final]
at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.withTccl(ClassLoaderServiceImpl.java:425) ~[hibernate-core-4.3.11.Final.jar:4.3.11.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:849) ~[hibernate-entitymanager-4.3.11.Final.jar:4.3.11.Final]
at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:60) ~[spring-orm-4.2.8.RELEASE.jar:4.2.8.RELEASE]
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:340) ~[spring-orm-4.2.8.RELEASE.jar:4.2.8.RELEASE]
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:319) ~[spring-orm-4.2.8.RELEASE.jar:4.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1641) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
... 21 common frames omitted
Caused by: org.hibernate.AnnotationException: mappedBy reference an unknown
target entity property: com.socgen.portfolio.domain.NiftyDataDTO.nifty in com.socgen.portfolio.domain.NiftyDTO.niftyDataDTO
at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:769) ~[hibernate-core-4.3.11.Final.jar:4.3.11.Final]
at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:729) ~[hibernate-core-4.3.11.Final.jar:4.3.11.Final]
at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:70) ~[hibernate-core-4.3.11.Final.jar:4.3.11.Final]
at org.hibernate.cfg.Configuration.originalSecondPassCompile(Configuration.java:1697) ~[hibernate-core-4.3.11.Final.jar:4.3.11.Final]
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1426) ~[hibernate-core-4.3.11.Final.jar:4.3.11.Final]
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1846) ~[hibernate-core-4.3.11.Final.jar:4.3.11.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:857) ~[hibernate-entitymanager-4.3.11.Final.jar:4.3.11.Final]
... 29 common frames omitted

2017-06-08 14:38:03.305  WARN 142244 --- [           main] o.s.boot.SpringApplication               : Error handling failed (Error creating bean with name 'delegatingApplicationListener' defined in class path resource [org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.class]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration': Initialization of bean failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'org.springframework.context.annotation.ConfigurationClassPostProcessor.importRegistry' is defined)

Process finished with exit code 1

Body:
mappedby must have a valid property name as value:

@OneToMany(mappedBy = "niftyDTO", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
private Set<NiftyDataDTO> niftyDataDTO;


问:
Minimum value on a 2d array python
I have an array of the following structure which is simplified for this question:

```<code>8 2 3 4 5 6
3 6 6 7 2 6
3 8 5 1 2 9
6 4 2 7 8 3
</code>```

I wish to find the minimum value in this 2D array however using the inbuilt min function returns a value error:

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

I have looked into the alternative of using np.argmin:

https://docs.scipy.org/doc/numpy/reference/generated/numpy.argmin.html

However it only evaluates along a single axis and returns the index of the minimum value along a single row/column whereas I wish to evaluate the whole array and return the lowest value not the indices.

If it is possible to return the index values of the lowest item in the array then that would be preferable also as from that the lowest value can easily be found.

EDIT: Thanks to the comments below np.min is the solution I was looking for and I was not aware of it existing so my answer is solved.

Title: Minimum value on a 2d array python

Body:
I have an array of the following structure which is simplified for this question:

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

I wish to find the minimum value in this 2D array however using the inbuilt min function returns a value error:

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

I have looked into the alternative of using np.argmin:

https://docs.scipy.org/doc/numpy/reference/generated/numpy.argmin.html

However it only evaluates along a single axis and returns the index of the minimum value along a single row/column whereas I wish to evaluate the whole array and return the lowest value not the indices.

If it is possible to return the index values of the lowest item in the array then that would be preferable also as from that the lowest value can easily be found.

EDIT: Thanks to the comments below np.min is the solution I was looking for and I was not aware of it existing so my answer is solved.

Body:
You can use np.min()

>>> arr = np.array([[8,2,3,4,5,6],
                    [3,6,6,7,2,6],
                    [3,8,5,1,2,9],
                    [6,4,2,7,8,3]])

>>> arr.min()
1


问:
Could not load [java.lang.Math]
i've upgraded my tomcat and jdk to apache-tomcat-8.5.12 and jdk1.8.0_121. but seems i hit error after start it.

Please refer my error below :

```<code>09-Jun-2017 00:37:31.776 INFO [Timer-0] org.apache.catalina.loader.WebappClassLoaderBase.checkStateForResourceLoading Illegal access: this web application instance has been stopped already. Could not load [java.lang.Math]. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.
 java.lang.IllegalStateException: Illegal access: this web application instance has been stopped already. Could not load [java.lang.Math]. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.
        at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForResourceLoading(WebappClassLoaderBase.java:1305)
        at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForClassLoading(WebappClassLoaderBase.java:1293)
        at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1158)
        at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1119)
        at org.apache.commons.pool.impl.GenericObjectPool.calculateDeficit(GenericObjectPool.java:1647)
        at org.apache.commons.pool.impl.GenericObjectPool.ensureMinIdle(GenericObjectPool.java:1621)
        at org.apache.commons.pool.impl.GenericObjectPool.access$700(GenericObjectPool.java:190)
        at org.apache.commons.pool.impl.GenericObjectPool$Evictor.run(GenericObjectPool.java:1758)
        at java.util.TimerThread.mainLoop(Timer.java:555)
        at java.util.TimerThread.run(Timer.java:505)

Exception in thread "Timer-0" java.lang.NoClassDefFoundError: java/lang/Math
        at org.apache.commons.pool.impl.GenericObjectPool.calculateDeficit(GenericObjectPool.java:1647)
        at org.apache.commons.pool.impl.GenericObjectPool.ensureMinIdle(GenericObjectPool.java:1621)
        at org.apache.commons.pool.impl.GenericObjectPool.access$700(GenericObjectPool.java:190)
        at org.apache.commons.pool.impl.GenericObjectPool$Evictor.run(GenericObjectPool.java:1758)
        at java.util.TimerThread.mainLoop(Timer.java:555)
        at java.util.TimerThread.run(Timer.java:505)
Caused by: java.lang.ClassNotFoundException: Illegal access: this web application instance has been stopped already. Could not load [java.lang.Math]. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.
        at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForClassLoading(WebappClassLoaderBase.java:1295)
        at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1158)
        at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1119)
        ... 6 more
Caused by: java.lang.IllegalStateException: Illegal access: this web application instance has been stopped already. Could not load [java.lang.Math]. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.
        at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForResourceLoading(WebappClassLoaderBase.java:1305)
        at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForClassLoading(WebappClassLoaderBase.java:1293)
        ... 8 more
</code>```

答:
This is a misleading error message by Tomcat and is not your root cause of the problem. Your instance has already stopped at this point due to something else going wrong.

Look in the Catalina (or any other) logs for something going wrong before this, which will be your root cause. This error message is just an annoying side-effect.

Lastly, a good rule when upgrading Tomcat is to remove the extracted webapp from the webapps folder to prevent caching issues and letting Tomcat do a fresh autodeploy the web archive.

Title: Could not load [java.lang.Math]

Body:
i've upgraded my tomcat and jdk to apache-tomcat-8.5.12 and jdk1.8.0_121. but seems i hit error after start it.

Please refer my error below :

09-Jun-2017 00:37:31.776 INFO [Timer-0] org.apache.catalina.loader.WebappClassLoaderBase.checkStateForResourceLoading Illegal access: this web application instance has been stopped already. Could not load [java.lang.Math]. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.
 java.lang.IllegalStateException: Illegal access: this web application instance has been stopped already. Could not load [java.lang.Math]. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.
        at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForResourceLoading(WebappClassLoaderBase.java:1305)
        at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForClassLoading(WebappClassLoaderBase.java:1293)
        at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1158)
        at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1119)
        at org.apache.commons.pool.impl.GenericObjectPool.calculateDeficit(GenericObjectPool.java:1647)
        at org.apache.commons.pool.impl.GenericObjectPool.ensureMinIdle(GenericObjectPool.java:1621)
        at org.apache.commons.pool.impl.GenericObjectPool.access$700(GenericObjectPool.java:190)
        at org.apache.commons.pool.impl.GenericObjectPool$Evictor.run(GenericObjectPool.java:1758)
        at java.util.TimerThread.mainLoop(Timer.java:555)
        at java.util.TimerThread.run(Timer.java:505)

Exception in thread "Timer-0" java.lang.NoClassDefFoundError: java/lang/Math
        at org.apache.commons.pool.impl.GenericObjectPool.calculateDeficit(GenericObjectPool.java:1647)
        at org.apache.commons.pool.impl.GenericObjectPool.ensureMinIdle(GenericObjectPool.java:1621)
        at org.apache.commons.pool.impl.GenericObjectPool.access$700(GenericObjectPool.java:190)
        at org.apache.commons.pool.impl.GenericObjectPool$Evictor.run(GenericObjectPool.java:1758)
        at java.util.TimerThread.mainLoop(Timer.java:555)
        at java.util.TimerThread.run(Timer.java:505)
Caused by: java.lang.ClassNotFoundException: Illegal access: this web application instance has been stopped already. Could not load [java.lang.Math]. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.
        at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForClassLoading(WebappClassLoaderBase.java:1295)
        at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1158)
        at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1119)
        ... 6 more
Caused by: java.lang.IllegalStateException: Illegal access: this web application instance has been stopped already. Could not load [java.lang.Math]. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.
        at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForResourceLoading(WebappClassLoaderBase.java:1305)
        at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForClassLoading(WebappClassLoaderBase.java:1293)
        ... 8 more


问:
Upgrading Selenium 2.53 to 3.4.0
What are all the steps I have to follow while upgrading to latest selenium version.

I am using Selenium 2.53 and configured the same in Eclipse. Changing just  selenium jar files will work? or any other process I have to follow?

答:
First of all you will have to upgrade your JDK from Java 7 to Java 8.

Once its done and environment variable and all things are properly configured for Java 8, then you can upgrade your Selenium related JAR files.

In addition to that you will also need latest geckodriver and latest version of Firefox browser(as older versions before 45 or so are not supported with geckodriver) to run your scripts properly in firefox browser.

Note : There is one known issue in Selenium 3,some interactions of actions class will not work in Firefox Browser. So If you don't have any problem with that then only upgrade to Selenium 3.

Title: Upgrading Selenium 2.53 to 3.4.0


问:
Checking row for duplicates in Sudoku
When i tried to check the rows of the Sudoku for duplicate elements, nothing is returned as result. Don't know whether the code is right or not. If the duplicate element found in a row, then need to print repetition found. Help me to reach the solution with using the method checkRow().

```<code>public class Sudoku {
 public static void main(String... args) throws Exception
{
    Scanner scanner = new Scanner(System.in);
    int[][] sudokuPuzzle = {
                         {8, 1, 0, 0, 0, 0, 0, 3, 9},
                         {0, 0, 0, 9, 0, 1, 0, 0, 0},
                         {3, 0, 5, 0, 0, 0, 4, 0, 1},
                         {0, 0, 9, 8, 0, 2, 7, 0, 0},
                         {0, 0, 0, 5, 0, 6, 0, 0, 0},
                         {0, 0, 4, 3, 0, 7, 1, 0, 0},
                         {1, 0, 8, 0, 0, 0, 9, 0, 2},
                         {0, 0, 0, 6, 0, 4, 0, 0, 0},
                         {2, 4, 0, 0, 0, 0, 0, 6, 5}
                    };
    printSudoku(sudokuPuzzle);
int count = countCellsToFill(sudokuPuzzle);
System.out.println("Number of cells have to filled: " + count);
}
 public static void printSudoku(int[][] sudokuPuzzle)
 {
  for (int i = 0; i < sudokuPuzzle.length; i++)
    {
        if (i == 3 || i == 6)
            System.out.println("------------------------");
        for (int j = 0; j < sudokuPuzzle[i].length; j++)
        {
            System.out.format("%-2s", sudokuPuzzle[i][j]);
            if (j == 2 || j == 5 )
                System.out.print(" | ");
        }
        System.out.println();
    }
}

 public static int countCellsToFill(int[][] sudokuPuzzle){
int count=0;
for(int[] sudokuPuzzle1 : sudokuPuzzle){
    for(int a: sudokuPuzzle1){
        if(a == 0){
            count++;
        }
    }
}
return count;
}
 public boolean checkRow(int[] sudokuPuzzle){
for (int row = 0; row < sudokuPuzzle.length; row++)
{
        int num = sudokuPuzzle[row];
            if (num == sudokuPuzzle[row])
            {
                return true;
            }
}
return false;
}
}
</code>```

答:
Modified your checkRow method to check for duplicates - </p>

```<code>public boolean checkRow(int[] sudokuPuzzle) {
    for (int row = 0; row < sudokuPuzzle.length; row++) {
        for (int i = 0; i < sudokuPuzzle.length; i++) {
            if (i == row) {
                continue;
            }
            if (sudokuPuzzle[i] == sudokuPuzzle[row]) {
                return true;
            }
        }
    }
    return false;
}
</code>```

Title: Checking row for duplicates in Sudoku

Body:
When i tried to check the rows of the Sudoku for duplicate elements, nothing is returned as result. Don't know whether the code is right or not. If the duplicate element found in a row, then need to print repetition found. Help me to reach the solution with using the method checkRow().

public class Sudoku {
 public static void main(String... args) throws Exception
{
    Scanner scanner = new Scanner(System.in);
    int[][] sudokuPuzzle = {
                         {8, 1, 0, 0, 0, 0, 0, 3, 9},
                         {0, 0, 0, 9, 0, 1, 0, 0, 0},
                         {3, 0, 5, 0, 0, 0, 4, 0, 1},
                         {0, 0, 9, 8, 0, 2, 7, 0, 0},
                         {0, 0, 0, 5, 0, 6, 0, 0, 0},
                         {0, 0, 4, 3, 0, 7, 1, 0, 0},
                         {1, 0, 8, 0, 0, 0, 9, 0, 2},
                         {0, 0, 0, 6, 0, 4, 0, 0, 0},
                         {2, 4, 0, 0, 0, 0, 0, 6, 5}
                    };
    printSudoku(sudokuPuzzle);
int count = countCellsToFill(sudokuPuzzle);
System.out.println("Number of cells have to filled: " + count);
}
 public static void printSudoku(int[][] sudokuPuzzle)
 {
  for (int i = 0; i < sudokuPuzzle.length; i++)
    {
        if (i == 3 || i == 6)
            System.out.println("------------------------");
        for (int j = 0; j < sudokuPuzzle[i].length; j++)
        {
            System.out.format("%-2s", sudokuPuzzle[i][j]);
            if (j == 2 || j == 5 )
                System.out.print(" | ");
        }
        System.out.println();
    }
}

 public static int countCellsToFill(int[][] sudokuPuzzle){
int count=0;
for(int[] sudokuPuzzle1 : sudokuPuzzle){
    for(int a: sudokuPuzzle1){
        if(a == 0){
            count++;
        }
    }
}
return count;
}
 public boolean checkRow(int[] sudokuPuzzle){
for (int row = 0; row < sudokuPuzzle.length; row++)
{
        int num = sudokuPuzzle[row];
            if (num == sudokuPuzzle[row])
            {
                return true;
            }
}
return false;
}
}

Body:
Modified your checkRow method to check for duplicates -

public boolean checkRow(int[] sudokuPuzzle) {
    for (int row = 0; row < sudokuPuzzle.length; row++) {
        for (int i = 0; i < sudokuPuzzle.length; i++) {
            if (i == row) {
                continue;
            }
            if (sudokuPuzzle[i] == sudokuPuzzle[row]) {
                return true;
            }
        }
    }
    return false;
}


问:
Space Complexity of an array?
I have an array of size N, and N is <=200.

What would be the space complexity here.

O(1) or (N) - considering the constraint N.

答:
Space complexity is usually only defined for Algorithms.

But let's be crafty and form an algorithm from your Question.

```<code>Input: N values, N <= 200
Algorithm: Store all values
Output: None
</code>```

Space complexity is the amount of memory you need to execute the algorithm, in relation to N.

When you store 1 number, you'll need one memory area. When you store 2 it doubles...
Your memory complexity is O(n) which means it grows linearly; Just like it would be for this algorithm:

```<code>Input: N values, N <= 18,446,744,073,709,551,616 (unsigned int 64).
Algorithm: Store all values
Output: None
</code>```

But 200 is a really small number, can't we just say O(1)?

Let's get crafty again, because we can make this O(1):

```<code>Input: N values, N <= 200
Algorithm: Store all values in an array of size 200
Output: None
</code>```

When you store 1 number you will need 200 memory areas. When you store 2 numbers you will need 200 memory areas. When you store 200 numbers you will need 200 memory areas. This means the memory is constant and independent from N. Thus the complexity is O(1).

It's important to note that O(1) doesn't mean the amount of memory you need is 1, it means that the amount of memory you need is not in any relation to N. And thus it doesn't grow when N grows.

But what if my objects are 50GB Blu-ray Discs?  O(1) should be very small but now it would be 10 Terabytes!

At this point we may finally realize that we don't always need to use Big O notations. We could just say that we need to store 10 Terabyte of Data and buy some Hard Disks.
If your Teacher makes a fuss about whether you write O(1) for very small N or O(n), then he is a very bad teacher. The answer to this Question is neither going to change your life nor your career. Big O Notation only makes sense for numbers that can grow incredible large.

Title: Space Complexity of an array?

Body:
Space complexity is usually only defined for Algorithms.

But let's be crafty and form an algorithm from your Question.

Input: N values, N <= 200
Algorithm: Store all values
Output: None

Space complexity is the amount of memory you need to execute the algorithm, in relation to N.

When you store 1 number, you'll need one memory area. When you store 2 it doubles...
Your memory complexity is O(n) which means it grows linearly; Just like it would be for this algorithm:

Input: N values, N <= 18,446,744,073,709,551,616 (unsigned int 64).
Algorithm: Store all values
Output: None

But 200 is a really small number, can't we just say O(1)?

Let's get crafty again, because we can make this O(1):

Input: N values, N <= 200
Algorithm: Store all values in an array of size 200
Output: None

When you store 1 number you will need 200 memory areas. When you store 2 numbers you will need 200 memory areas. When you store 200 numbers you will need 200 memory areas. This means the memory is constant and independent from N. Thus the complexity is O(1).

It's important to note that O(1) doesn't mean the amount of memory you need is 1, it means that the amount of memory you need is not in any relation to N. And thus it doesn't grow when N grows.

But what if my objects are 50GB Blu-ray Discs?  O(1) should be very small but now it would be 10 Terabytes!

At this point we may finally realize that we don't always need to use Big O notations. We could just say that we need to store 10 Terabyte of Data and buy some Hard Disks.
If your Teacher makes a fuss about whether you write O(1) for very small N or O(n), then he is a very bad teacher. The answer to this Question is neither going to change your life nor your career. Big O Notation only makes sense for numbers that can grow incredible large.


问:
Which files to edit for HTML/CSS in my application (ruby)
I made my application with the following introduction:
http://guides.rubyonrails.org/getting_started.html

Now I want to make it more colourful etc (CSS f.eg).
I found now the JavaScript and CSS files, but I dont know which file are responsible for the editing.

[![enter image description here][1]][1]

Which file should I use for editing the websites?

答:
If you want to do styling and some javascript you need to do it in
application.css under assets/stylesheets/ and for JS
application.js under asstes/javascripts/


问:
disable specific dates in specific month of every year jquery datepicker in jquery the date should be from database
disable specific dates in specific month of every year using datepicker in jquery.
the date should be from database.

For Example:
disable the date of auguest 15 th of every year and the date auguest-15th is getting from database with the formate of string.

答:
For disabling more than one date for all years In a calendar ,

Use:

return [!( (day ==15  && month == 8) ll (day ==2  && month == 10) ll (day ==26  && month == 1) ) , " "  ];


问:
jquery fixed table header on scroll
I have a data table this table read his data from mysql database

I use this jquery and css to fixed the header of the table on scroll

```<code>;(function($) {
   $.fn.fixMe = function() {
      return this.each(function() {
         var $this = $(this),
            $t_fixed;
         function init() {
            $this.wrap('<div class="table-responsive" />');
            $t_fixed = $this.clone();
            $t_fixed.find("tbody").remove().end().addClass("fixed").insertBefore($this);
            resizeFixed();
         }
         function resizeFixed() {
            $t_fixed.find("th").each(function(index) {
               $(this).css("width",$this.find("th").eq(index).outerWidth()+"px");
            });
         }
         function scrollFixed() {
            var offset = $(this).scrollTop(),
            tableOffsetTop = $this.offset().top,
            tableOffsetBottom = tableOffsetTop + $this.height() - $this.find("thead").height();
            if(offset < tableOffsetTop || offset > tableOffsetBottom)
               $t_fixed.hide();
            else if(offset >= tableOffsetTop && offset <= tableOffsetBottom && $t_fixed.is(":hidden"))
               $t_fixed.show();
         }
         $(window).resize(resizeFixed);
         $(window).scroll(scrollFixed);
         init();
      });
   };
})(jQuery);

$(document).ready(function(){
   $("table").fixMe();
   $(".up").click(function() {
      $('html, body').animate({
      scrollTop: 0
   }, 2000);
 });
});
</code>```

Html:

```<code><div class="table-responsive" >
    <table class='ol-md-12 table-bordered table-striped table-condensed cf table-bordered'>
        <thead class='cf'>
            <tr>
                <th rowspan='2'>#</th>
                <th rowspan='2'>Staff
                </th>
                <th rowspan='2'>MyTask</th>
                <th rowspan='2'>Status</th>
                <th rowspan='2'>Description</th>
                <th rowspan='2'>transfered</th>
                <th colspan='3'>Planning</th>
                <th rowspan='2'>Date
                </th>
                <th rowspan='2'>Project</th>
                <th rowspan='2'>Type</th>
                <th rowspan='2'>Frequency</th>
                <th rowspan='2'>Priority</th>
                <th rowspan='2'>Note</th>

            </tr>
            <tr>
                <th> Start Date</th>
                <th> Due Date</th>
                <th>Duration</th>
            </tr>
        </thead>
</code>```

The problem is when i scroll down the column width change and the title in the header don't match the content of the table body

you can check in the link below

this the code on https://fiddle.jshell.net/mhmd2991/oy764es6/12/

How Can i fixed ??!!

答:
Separating the content into 2 tables won't work correctly with the desired layout you want to have, because width of each cell is affected by the cell's content, and the whole table width gets its layout by each cell's width and height.

Look for different approach.

Title: jquery fixed table header on scroll

Body:
I have a data table this table read his data from mysql database

I use this jquery and css to fixed the header of the table on scroll

;(function($) {
   $.fn.fixMe = function() {
      return this.each(function() {
         var $this = $(this),
            $t_fixed;
         function init() {
            $this.wrap('
');
            $t_fixed = $this.clone();
            $t_fixed.find("tbody").remove().end().addClass("fixed").insertBefore($this);
            resizeFixed();
         }
         function resizeFixed() {
            $t_fixed.find("th").each(function(index) {
               $(this).css("width",$this.find("th").eq(index).outerWidth()+"px");
            });
         }
         function scrollFixed() {
            var offset = $(this).scrollTop(),
            tableOffsetTop = $this.offset().top,
            tableOffsetBottom = tableOffsetTop + $this.height() - $this.find("thead").height();
            if(offset < tableOffsetTop || offset > tableOffsetBottom)
               $t_fixed.hide();
            else if(offset >= tableOffsetTop && offset <= tableOffsetBottom && $t_fixed.is(":hidden"))
               $t_fixed.show();
         }
         $(window).resize(resizeFixed);
         $(window).scroll(scrollFixed);
         init();
      });
   };
})(jQuery);

$(document).ready(function(){
   $("table").fixMe();
   $(".up").click(function() {
      $('html, body').animate({
      scrollTop: 0
   }, 2000);
 });
});

Html:

                #
                Staff

                MyTask
                Status
                Description
                transfered
                Planning
                Date

                Project
                Type
                Frequency
                Priority
                Note

                 Start Date
                 Due Date
                Duration

The problem is when i scroll down the column width change and the title in the header don't match the content of the table body

you can check in the link below

this the code on https://fiddle.jshell.net/mhmd2991/oy764es6/12/

How Can i fixed ??!!