问:
Issue with CodeIgniter redirect
Here i'm creating a login system. Once the user is verified the controller redirects the page to home.php.

There are 2 pages here login_registration.php and home.php

login_registration.php consists login and registration form from here the user is redirected to home.php. both the files are in path C:\wamp\www\CI-Project_1\application\views\login

The issue is it show 404 Page Not Found when redirected.

```<code> class Login extends CI_Controller {
    public function __construct(){
        parent::__construct();
                $this->load->helper('url');
        //LOAD MODELS HERE
        $this->load->model('Login_model');
    }

    public function index(){
        $this->load->view('login/login_registration.php');
    }

    function login_user(){
        $login_btn = $this->input->post('login_btn');

        if($login_btn == TRUE){
            $arr['login'] = array(
                'username'=>$this->input->post('username'),
                'password'=>$this->input->post('password')
            );

            $query = $this->Login_model->users_login($arr);

            if($query->num_rows() > 0 && $query->num_rows() == 1){
                $this->load->library('session');
                $this->session->set_userdata($arr['login']);
                redirect('login/home.php', 'location');
            }
            else
            {
                $this->index();
            }
        }
        else
        {
            $this->index();
        }
    }
}
</code>```

THANKS IN ADVANCE

答: To redirect on any function in CI can use redirect('controller n_name/function_name','refresh');

Title: Issue with CodeIgniter redirect

Body:
Here i'm creating a login system. Once the user is verified the controller redirects the page to home.php.

There are 2 pages here login_registration.php and home.php

login_registration.php consists login and registration form from here the user is redirected to home.php. both the files are in path C:\wamp\www\CI-Project_1\application\views\login

The issue is it show 404 Page Not Found when redirected.

 class Login extends CI_Controller {
    public function __construct(){
        parent::__construct();
                $this->load->helper('url');
        //LOAD MODELS HERE
        $this->load->model('Login_model');
    }

    public function index(){
        $this->load->view('login/login_registration.php');
    }

    function login_user(){
        $login_btn = $this->input->post('login_btn');

        if($login_btn == TRUE){
            $arr['login'] = array(
                'username'=>$this->input->post('username'),
                'password'=>$this->input->post('password')
            );

            $query = $this->Login_model->users_login($arr);

            if($query->num_rows() > 0 && $query->num_rows() == 1){
                $this->load->library('session');
                $this->session->set_userdata($arr['login']);
                redirect('login/home.php', 'location');
            }
            else
            {
                $this->index();
            }
        }
        else
        {
            $this->index();
        }
    }
}

THANKS IN ADVANCE


来源: stackexchange

问:
Reversing numbers in lines, have a regex already and need to modify it
I have a regex from a previous thread. This regex seems to only work in some numbers and I'm a total noob to regex and coding. Is there anyway to make all numbers in the text I have reversed? The max total of digits in my text is probably 10 digits in some lines, and in other maybe just 2, sometimes 3 or 4, but max is 10, I'll give examples.

```<code>goku144

r3apt0r

66958496

Veg3ta123
</code>```

The regex I have only makes some of the numbers reversed, not all, is there anyway to fix the regex provided by horucrux.

Regex below and link

How to make numbers backwards in notepad++

Step 1. Add a marker for the not-yet-inverted digits.

Find:

\b(\w+?)(\d+)\b

Replace:

$1§$2 You can choose other marker instead of §.

Step 2. Do Replace all enough times with these settings:

Find:

\b(\w+)§(\d*)(\d)\b

Replace:

$1$3§$2

Step 3. Delete all markers.

Find:

\b(\w+\d)§

Replace:

$1

答:
Same method as for the other question:

Step 1. Add a marker for the not-yet-inverted digits.

Find:

```<code>\d
</code>```

Replace:

```<code>§$0
</code>```

Step 2. Do Replace all enough times for inverting digits and, in the same time, removing markers:

Find:

```<code>§(\d)([^\n]*)§(\d)
</code>```

Replace:

```<code>$3$2$1
</code>```

Step 3. Delete remaining markers (the ones for central digits).

Find:

```<code>§(\d)
</code>```

Replace:

```<code>$1
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I have a regex from a previous thread. This regex seems to only work in some numbers and I'm a total noob to regex and coding. Is there anyway to make all numbers in the text I have reversed? The max total of digits in my text is probably 10 digits in some lines, and in other maybe just 2, sometimes 3 or 4, but max is 10, I'll give examples.

goku144

r3apt0r

66958496

Veg3ta123

The regex I have only makes some of the numbers reversed, not all, is there anyway to fix the regex provided by horucrux.

Regex below and link

How to make numbers backwards in notepad++

Step 1. Add a marker for the not-yet-inverted digits.

Find:

\b(\w+?)(\d+)\b

Replace:

$1§$2 You can choose other marker instead of §.

Step 2. Do Replace all enough times with these settings:

Find:

\b(\w+)§(\d*)(\d)\b

Replace:

$1$3§$2

Step 3. Delete all markers.

Find:

\b(\w+\d)§

Replace:

$1

Body:
Same method as for the other question:

Step 1. Add a marker for the not-yet-inverted digits.

Find:

\d

Replace:

§$0

Step 2. Do Replace all enough times for inverting digits and, in the same time, removing markers:

Find:

§(\d)([^\n]*)§(\d)

Replace:

$3$2$1

Step 3. Delete remaining markers (the ones for central digits).

Find:

§(\d)

Replace:

$1


问:
Velocity ResourceNotFoundException in IntelliJ IDEA
I have a Velocity template ValueTmpl.vm which can't be found by the Velocity ResourceManager. A minimal example:

```<code>package generate;

import java.io.File;
import java.io.FileWriter;
import java.io.Writer;
import org.apache.velocity.app.Velocity;
import org.apache.velocity.app.VelocityEngine;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;

public class Generate {
    public static void main(String[] args) throws Exception {
        VelocityContext context = new VelocityContext();
        context.put("key", "value");
        Writer writer = new FileWriter(new File("Result.java"));
        createTemplate("generate/templates/ValueTmpl.vm").merge(context, writer);
        writer.close();
    }

    private static Template createTemplate(String vmTemplateFile) {
        VelocityEngine ve = new VelocityEngine();
        ve.setProperty(Velocity.RESOURCE_LOADER, "class");
        ve.setProperty("class.resource.loader.class",
                "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
        ve.init();
        return ve.getTemplate(vmTemplateFile);
    }
}
</code>```

The generate folder is in the root of the src directory. I get the following error:

```<code>21.03.2011 13:09:01 org.apache.velocity.runtime.log.JdkLogChute log
SEVERE: ResourceManager : unable to find resource 'generate/templates/ValueTmpl.vm' in any resource loader.
Exception in thread "main" org.apache.velocity.exception.ResourceNotFoundException: Unable to find resource 'generate/templates/ValueTmpl.vm'
</code>```

Does someone know what the problem can be? Should I change something in the project settings?

Thanks in advance!

答:
https://stackoverflow.com/a/38812523/8113460

I put my .vm under the src/main/resources/templates, then the code is :

```<code>Properties p = new Properties();
p.setProperty("resource.loader", "class");
p.setProperty("class.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
Velocity.init( p );
VelocityContext context = new VelocityContext();
Template template = Velocity.getTemplate("templates/my.vm");
</code>```

this works in web project.

ContentLicense: CC BY-SA 2.5

Body:
I have a Velocity template ValueTmpl.vm which can't be found by the Velocity ResourceManager. A minimal example:

package generate;

import java.io.File;
import java.io.FileWriter;
import java.io.Writer;
import org.apache.velocity.app.Velocity;
import org.apache.velocity.app.VelocityEngine;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;

public class Generate {
    public static void main(String[] args) throws Exception {
        VelocityContext context = new VelocityContext();
        context.put("key", "value");
        Writer writer = new FileWriter(new File("Result.java"));
        createTemplate("generate/templates/ValueTmpl.vm").merge(context, writer);
        writer.close();
    }

    private static Template createTemplate(String vmTemplateFile) {
        VelocityEngine ve = new VelocityEngine();
        ve.setProperty(Velocity.RESOURCE_LOADER, "class");
        ve.setProperty("class.resource.loader.class",
                "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
        ve.init();
        return ve.getTemplate(vmTemplateFile);
    }
}

The generate folder is in the root of the src directory. I get the following error:

21.03.2011 13:09:01 org.apache.velocity.runtime.log.JdkLogChute log
SEVERE: ResourceManager : unable to find resource 'generate/templates/ValueTmpl.vm' in any resource loader.
Exception in thread "main" org.apache.velocity.exception.ResourceNotFoundException: Unable to find resource 'generate/templates/ValueTmpl.vm'

Does someone know what the problem can be? Should I change something in the project settings?

Thanks in advance!

Body:
https://stackoverflow.com/a/38812523/8113460

I put my .vm under the src/main/resources/templates, then the code is :

Properties p = new Properties();
p.setProperty("resource.loader", "class");
p.setProperty("class.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
Velocity.init( p );
VelocityContext context = new VelocityContext();
Template template = Velocity.getTemplate("templates/my.vm");

this works in web project.


问:
Handling "refresh" or "back" in AJAX to keep "parent" html
So I'm fairly new to AJAX, I have a simple 3 page project which I am using AJAX to transition between pages.

I have an index.html page which loads all the html / body / scripts etc:

```<code><!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Ajax practice</title>

    <link rel="stylesheet" href="styles/index.processed.css">
</head>
<body>

    <div class="" id="wrapper">
    <div class="overlay"></div>
        <header>
            <nav>
                <ul>
                    <li><a class="aboutBtn" href="main.html">Home</a></li>
                    <li><a class="aboutBtn" href="about.html">About</a></li>
                    <li><a class="aboutBtn" href="#">Menu</a></li>
                    <li><a class="aboutBtn" href="#">Contact</a></li>
                </ul>
            </nav>
        </header>

        <div class="page wrapper" id="page">
            <div class="circle" id="black"></div>
            <div class="circle" id="red"></div>
            <div class="circle" id="blue"></div>

            <section class="mainSplash main">

                <div class="mainSplash__content" id="content">

                </div>

            </section>
        </div> <!-- page -->
    </div> <!-- wrapper -->

    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
    <script src="scripts/index.js"></script>

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

and my 2 pages are:

main.html:

```<code><h1 class="mainSplash__header--h1">Main</h1>
</code>```

about.html:

```<code><h1 class="mainSplash__header--h1">About</h1>
</code>```

Here is the AJAX which transitions the pages:

```<code>    $(document).ready(function() {

  var pathname = window.location.pathname; // Returns path only

  console.log(pathname);

    // $('.mainSplash').css('height',$(window).height() - 60);

    $(".aboutBtn").click(function(e) {
        e.preventDefault();
        var pageTitle =  $(this).text();
        var pageUrl = $(this).attr('href');

        changePage(pageUrl, true, pageTitle);
    }); // click

    function changePage(url, bool, pageTitle){
        $('#page').addClass('fadeOut');

        loadContent(url, bool, pageTitle);
    }

    function loadContent(url, bool, pageTitle){
      $.ajax({
        url: './' + url,
        type: 'get',
        contentType: 'html',
        success: function(data){
          $('#page').one('animationend',
            function(e) {
            // load content
            $('#page').removeClass('fadeOut');
            $('#page').addClass('fadeIn');
            $('#content').html(data);
            //$("html").html(data);
            // Change url
            if(url != window.location){
              window.history.pushState({path: url}, pageTitle, url);
            }
          });
                }
        });
    }

  function removeAnimation(){
    $('#page').removeClass('animate');
  }

});
</code>```

So my transitions work fine when I have come from index.html, though when I refresh main.html or about.html, they do not keep the code from index.html (obviously).

My question is:

How do I handle a refresh or back button from my pages without losing the index.html content? Any help or advice is appreciated - thank you in advance.

PS: If anyone knows of any AJAX html page transition examples I would love to know so I can improve my code, as I'm looking for best practice for AJAX transitions!

答: On the load of the Site you need to add entry in the history with the command history.pushState and to go back to use the buttons of the browser you will need the EventListener onpopstate</p>

Body:
So I'm fairly new to AJAX, I have a simple 3 page project which I am using AJAX to transition between pages.

I have an index.html page which loads all the html / body / scripts etc:

<!DOCTYPE html>

    <meta charset="UTF-8">
    <title>Ajax practice</title>

    <link rel="stylesheet" href="styles/index.processed.css">

Home

About

Menu

Contact

and my 2 pages are:

main.html:

Main

about.html:

About

Here is the AJAX which transitions the pages:

    $(document).ready(function() {

  var pathname = window.location.pathname; // Returns path only

  console.log(pathname);

    // $('.mainSplash').css('height',$(window).height() - 60);

    $(".aboutBtn").click(function(e) {
        e.preventDefault();
        var pageTitle =  $(this).text();
        var pageUrl = $(this).attr('href');

        changePage(pageUrl, true, pageTitle);
    }); // click

    function changePage(url, bool, pageTitle){
        $('#page').addClass('fadeOut');

        loadContent(url, bool, pageTitle);
    }

    function loadContent(url, bool, pageTitle){
      $.ajax({
        url: './' + url,
        type: 'get',
        contentType: 'html',
        success: function(data){
          $('#page').one('animationend',
            function(e) {
            // load content
            $('#page').removeClass('fadeOut');
            $('#page').addClass('fadeIn');
            $('#content').html(data);
            //$("html").html(data);
            // Change url
            if(url != window.location){
              window.history.pushState({path: url}, pageTitle, url);
            }
          });
                }
        });
    }

  function removeAnimation(){
    $('#page').removeClass('animate');
  }

});

So my transitions work fine when I have come from index.html, though when I refresh main.html or about.html, they do not keep the code from index.html (obviously).

My question is:

How do I handle a refresh or back button from my pages without losing the index.html content? Any help or advice is appreciated - thank you in advance.

PS: If anyone knows of any AJAX html page transition examples I would love to know so I can improve my code, as I'm looking for best practice for AJAX transitions!


问:
How to achieve UILabel line breaks only on a specific separator character?
I have a string which has a separator character between words (Words with spaces) eg.

```<code>"Male • 89 • Senior Citizen • Side Lower Berth • Non Veg • Bedroll"
</code>```

So "•" is separator here. Now while assigning it to a multiline label I want line breaks only on this separator. Eg. I don't want line breaks in between "Side Lower Berth" so that some part of it rendered in the first line and remaining one in next line. It should draw it next line only by making the decision based on the defined separator "•" here.

答:
What if you jump lines when • appears? If you wanna try :

```<code>yourString.replacingOccurrences(of: "•", with: "\n")
</code>```

I don't know if that's what you want, if not, sorry.

Body:
I have a string which has a separator character between words (Words with spaces) eg.

"Male • 89 • Senior Citizen • Side Lower Berth • Non Veg • Bedroll"

So "•" is separator here. Now while assigning it to a multiline label I want line breaks only on this separator. Eg. I don't want line breaks in between "Side Lower Berth" so that some part of it rendered in the first line and remaining one in next line. It should draw it next line only by making the decision based on the defined separator "•" here.

Body:
What if you jump lines when • appears? If you wanna try :

yourString.replacingOccurrences(of: "•", with: "\n")

I don't know if that's what you want, if not, sorry.


问:
How can I extract the array of hashmap object from a hashmap object?
```<code>{
    "errorCode": 200,
    "opMessage": {
        "personalDetails": {
            "dob": {
                "mm": 2,
                "dd": 2,
                "yyyy": 1975
            },
            "name": {
                "fname": "sai gampa",
                "lName": "krishna"
            },
            "maritalStatus": "Single",
            "ssn": "123-45-7777"
        },
        "id": "0101",
        "contactDetails": {
            "address": [
                {
                    "isPrimary": true,
                    "id": "HOME;2017-06-30",
                    "type": "Home",
                    "addr": {
                        "country": "USA",
                        "addr2": "W 24th St",
                        "addr1": "518",
                        "city": "New York",
                        "postalCode": "11122",
                        "state": "NY"
                    }
                },
                {
                    "isPrimary": false,
                    "id": "BUSN;2017-07-04",
                    "type": "Work",
                    "addr": {
                        "country": "USA",
                        "addr2": "Agsuaiajs",
                        "addr1": "Qwertyy",
                        "city": "Shshshsjsj",
                        "postalCode": "71899",
                        "state": "CO"
                    }
                }
            ],
            "bestWayToContact": "Phone",
            "ph": [
                {
                    "isPrimary": false,
                    "num": "666-666-6666",
                    "id": "Work",
                    "type": "Work"
                },
                {
                    "isPrimary": false,
                    "num": "444-444-4444",
                    "id": "Cell",
                    "type": "Cell"
                },
                {
                    "isPrimary": true,
                    "num": "111-111-1111",
                    "id": "Home",
                    "type": "Home"
                }
            ],
            "eMail": [
                {
                    "isPrimary": true,
                    "id": "HOME",
                    "addr": "Shyam@gmail.con"
                }
            ]
        }
    }
}
</code>```

答: HashMap has a method called entrySet(). With entrySet() you can get all the entries in the hashmap.</p>


问:
Timing interval between GET and POST request in Node/Express
I am building a quiz website using Node/Express.

How do I ensure that users submit quiz within a specified period of time without using client-side javascript? That is, if the quiz takes 10 minutes, submission afterwards should marked as too late.

Both GET and POST requests are to the same url

答:
Dépends on the level of security and bad-connectivity-proofness you want, but what I would do is start a timer server-side when the quizz is served to the client, and reject it if the answer is submitted after a given period (10mn plus a little margin).

And to keep the client aware, you could code a client-side timer that would use as start time a value set directly in the client html by the server when serving the page.

Hope this helps !


问:
Application Project has not been registered
I am trying to run my react native app on my device .
So I am running react-native start
everything looks fine.

and when running react-native run-android I get this error

otherwise, I get this error in my device

答:
You need to export the class. Use the code below </p>

```<code> import React, { Component } from 'react'
import { AppRegistry, Text, View } from 'react-native'
export default class proj extends Component {
 render() {
return (
<View style={styles.container}> <Text > Welcome to PutainDeBiere! </Text> </View> )
}
}
 AppRegistry.registerComponent('proj', () => proj)
</code>```

Body:
You need to export the class. Use the code below

 import React, { Component } from 'react'
import { AppRegistry, Text, View } from 'react-native'
export default class proj extends Component {
 render() {
return (
<View style={styles.container}> <Text > Welcome to PutainDeBiere! </Text> </View> )
}
}
 AppRegistry.registerComponent('proj', () => proj)


问:
PHP => $_SESSION Array only keeps last variable
I'm building an interface for an online shop, where every item is a FORM and the BUY button is a submit,it submits the name and price of the clicked form and that data is displayed on a CONFIRM ORDER page. On that confirm order page I've created an array as follows

```<code>if (!isset($input_order_arr)) {
  $input_order_arr = array();
}
</code>```

After that I fetch the posted variables and push them into the array

```<code>if ($_SERVER['REQUEST_METHOD'] == 'POST') {
  if (!empty($_POST['item-title'])  && !empty($_POST['item-price'])) {
    $item_title = test_input($_POST['item-title']);
    $item_price = test_input($_POST['item-price']);
    array_push($input_order_arr,$item_title,$item_price);
  }
}

$_SESSION['chosen_item'] = $input_order_arr;
</code>```

*NOTE : test_input is a function that does striplashes , htmlspecialchars and htmltrim, for security purposes. (someone might edit the value of the item via the Chrome developer console? not sure if that holds any threat though)

And after that the value is displayed in a table like so

```<code>              <?php if (isset($_SESSION['chosen_item'])) {
                foreach ($_SESSION['chosen_item'] as $value) {
                  echo "<td>" . $value . "</td>";
                }
              }  ?>
</code>```

And here comes the problem.

If you order an item its price and name are displayed, but if u go back and you order another item, the previous item and its price are lost, as if its not adding new lines to the array,but replacing the old ones, or the session only saves data from one action, which wouldn't make any sense, since thats what $_SESSION is about, the code is presented with session_start(); in every page that is using the $_SESSION variable.

 Main Question - Why could it be that the $_SESSION Array is losing its older inputs?

答:
You could push directly into the session like this

```<code>if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    if (!empty($_POST['item-title'])  && !empty($_POST['item-price'])) {

        array_push($_SESSION['chosen_item'],
                    test_input($_POST['item-title']),
                    test_input($_POST['item-price'])
                  );
    }
}

//$_SESSION['chosen_item'] = $input_order_arr;
</code>```

Or as your test_input() is likely doing nothing useful

```<code>if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    if (!empty($_POST['item-title'])  && !empty($_POST['item-price'])) {

        array_push($_SESSION['chosen_item'],
                    $_POST['item-title'],
                    $_POST['item-price']
                  );
    }
}
</code>```

You might find this data easier to use later by doing

```<code>if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    if (!empty($_POST['item-title'])  && !empty($_POST['item-price'])) {

        array_push($_SESSION['chosen_item'],
                    array('title' => $_POST['item-title'],
                          'price' => $_POST['item-price']
                        )
                  );
    }
}
</code>```

Body:
I'm building an interface for an online shop, where every item is a FORM and the BUY button is a submit,it submits the name and price of the clicked form and that data is displayed on a CONFIRM ORDER page. On that confirm order page I've created an array as follows

if (!isset($input_order_arr)) {
  $input_order_arr = array();
}

After that I fetch the posted variables and push them into the array

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
  if (!empty($_POST['item-title'])  && !empty($_POST['item-price'])) {
    $item_title = test_input($_POST['item-title']);
    $item_price = test_input($_POST['item-price']);
    array_push($input_order_arr,$item_title,$item_price);
  }
}

$_SESSION['chosen_item'] = $input_order_arr;

*NOTE : test_input is a function that does striplashes , htmlspecialchars and htmltrim, for security purposes. (someone might edit the value of the item via the Chrome developer console? not sure if that holds any threat though)

And after that the value is displayed in a table like so

              <?php if (isset($_SESSION['chosen_item'])) {
                foreach ($_SESSION['chosen_item'] as $value) {
                  echo "" . $value . "	";
                }
              }  ?>

And here comes the problem.

If you order an item its price and name are displayed, but if u go back and you order another item, the previous item and its price are lost, as if its not adding new lines to the array,but replacing the old ones, or the session only saves data from one action, which wouldn't make any sense, since thats what $_SESSION is about, the code is presented with session_start(); in every page that is using the $_SESSION variable.

 Main Question - Why could it be that the $_SESSION Array is losing its older inputs?

Body:
You could push directly into the session like this

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    if (!empty($_POST['item-title'])  && !empty($_POST['item-price'])) {

        array_push($_SESSION['chosen_item'],
                    test_input($_POST['item-title']),
                    test_input($_POST['item-price'])
                  );
    }
}

//$_SESSION['chosen_item'] = $input_order_arr;

Or as your test_input() is likely doing nothing useful

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    if (!empty($_POST['item-title'])  && !empty($_POST['item-price'])) {

        array_push($_SESSION['chosen_item'],
                    $_POST['item-title'],
                    $_POST['item-price']
                  );
    }
}

You might find this data easier to use later by doing

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    if (!empty($_POST['item-title'])  && !empty($_POST['item-price'])) {

        array_push($_SESSION['chosen_item'],
                    array('title' => $_POST['item-title'],
                          'price' => $_POST['item-price']
                        )
                  );
    }
}


问:
Idiom for resuming an async system call in Fortran 2008
If I make a system call, eg:

```<code>  call execute_command_line (slowcall1, wait=.false., exitstat=i)
  call execute_command_line (slowcall2, wait=.false., exitstat=j)
  call execute_command_line (slowcall3, wait=.false., exitstat=k)
  call execute_command_line (slowcall4, wait=.false., exitstat=l)
</code>```

I want to call these in parallel then to check on them as they progress, whether they have completed, and finally take some action.  However, polling exitstat doesn't give me that information.  What's the right idiom for checking whether my system call I am not waiting for has actually completed?

From here:
https://gcc.gnu.org/onlinedocs/gfortran/EXECUTE_005fCOMMAND_005fLINE.html

It does not appear any of the optional arguments:

EXITSTAT

CMDSTAT

CMDMSG

provide this information.

Is there a recommended modern Fortran procedure used involving writing lock files as part of the call?  Or a different asynchronous call?

答: No, there is no way. The command as you are using it is "fire and forget". If you want any finer control, use threads. Not for parallelism, but for concurency.</p>

Body:
If I make a system call, eg:

  call execute_command_line (slowcall1, wait=.false., exitstat=i)
  call execute_command_line (slowcall2, wait=.false., exitstat=j)
  call execute_command_line (slowcall3, wait=.false., exitstat=k)
  call execute_command_line (slowcall4, wait=.false., exitstat=l)

I want to call these in parallel then to check on them as they progress, whether they have completed, and finally take some action.  However, polling exitstat doesn't give me that information.  What's the right idiom for checking whether my system call I am not waiting for has actually completed?

From here:
https://gcc.gnu.org/onlinedocs/gfortran/EXECUTE_005fCOMMAND_005fLINE.html

It does not appear any of the optional arguments:

EXITSTAT

CMDSTAT

CMDMSG

provide this information.

Is there a recommended modern Fortran procedure used involving writing lock files as part of the call?  Or a different asynchronous call?


问:
If i login with a user it logs in with any password

<?php
require 'includes/common.php';
$email=$_POST['email'];
$password=$_POST['password'];
$email= mysqli_real_escape_string($con, $email);
$password= mysqli_real_escape_string($con, $password);
//md5($password);
 $select_user_query="select id , email from users where email='$email' and password= $password";
 //removed 'email' to email//
        $select_user_result= mysqli_query($con, $select_user_query) or die (mysqli_error($con));

               if (mysqli_num_rows($select_user_result==0))
               {
                   echo 'There no such user ';
               }

               else
               {
                   $row=mysqli_fetch_array($select_user_result);
                   $_SESSION['email']=$email;
                   $_SESSION['id']= $row[0];
                   header('location:products.php');
               }

?>           ```

 here is the code

**

here i am geting

email and password from post method

From my login page

i think most of the code is right

If i login with a user it logs in with any password

**

答:
Please verify this code:

I use this code for login:

if user provides the Correct Credentials-- If part will work,
if not then else part will be work

```<code><?php
 // Grab User submitted information
$user = $_POST["username"];
$pass = $_POST["password"];

//$uc_id=$_GET["user_check_id"];

// Connect to the database
$con = mysqli_connect("localhost","root","pass123");
// Make sure we connected successfully
if(! $con)
{
    die('Connection Failed'.mysql_error());
}
// Select the database to use
mysqli_select_db($con, "login");
//$query ="SELECT user_check_id from loginpage where username='$user' and password='$pass'";
$query ="SELECT * from loginpage where username='$user' and password='$pass'";

//echo $query;

if ($query)
{
    $result = mysqli_query($con,$query);
    $row = mysqli_fetch_array($result);
    if($row["username"]==$user && $row["password"]==$pass)
    {
            echo "Welcome Admin";
    }
else
        {
            echo"Please Enter the Correct Username/Password...!!";
}
}

?>
</code>```

Body:
<?php
require 'includes/common.php';
$email=$_POST['email'];
$password=$_POST['password'];
$email= mysqli_real_escape_string($con, $email);
$password= mysqli_real_escape_string($con, $password);
//md5($password);
 $select_user_query="select id , email from users where email='$email' and password= $password";
 //removed 'email' to email//
        $select_user_result= mysqli_query($con, $select_user_query) or die (mysqli_error($con));

               if (mysqli_num_rows($select_user_result==0))
               {
                   echo 'There no such user ';
               }

               else
               {
                   $row=mysqli_fetch_array($select_user_result);
                   $_SESSION['email']=$email;
                   $_SESSION['id']= $row[0];
                   header('location:products.php');
               }

?>

 here is the code

**

here i am geting

email and password from post method

From my login page

i think most of the code is right

If i login with a user it logs in with any password

**

Body:
Please verify this code:

I use this code for login:

if user provides the Correct Credentials-- If part will work,
if not then else part will be work

<?php
 // Grab User submitted information
$user = $_POST["username"];
$pass = $_POST["password"];

//$uc_id=$_GET["user_check_id"];

// Connect to the database
$con = mysqli_connect("localhost","root","pass123");
// Make sure we connected successfully
if(! $con)
{
    die('Connection Failed'.mysql_error());
}
// Select the database to use
mysqli_select_db($con, "login");
//$query ="SELECT user_check_id from loginpage where username='$user' and password='$pass'";
$query ="SELECT * from loginpage where username='$user' and password='$pass'";

//echo $query;

if ($query)
{
    $result = mysqli_query($con,$query);
    $row = mysqli_fetch_array($result);
    if($row["username"]==$user && $row["password"]==$pass)
    {
            echo "Welcome Admin";
    }
else
        {
            echo"Please Enter the Correct Username/Password...!!";
}
}

?>


问:
OSGi service not implementing interface
I am working on a project which uses OSGi which has below code

```<code>@Component(policy = ConfigurationPolicy.OPTIONAL, ds = true, immediate = true, metatype = false)
@Service(TestInterface.class)
public class TestInterface{
</code>```

Here the code doesn't implement the interface in which the service is going to exposed. Also I have verified everywhere this is not referenced anywhere with @Reference.
Does it really need to make it as service instead of only component? In case if i want to use it in another Component i have to make it as a service by implementing interface.
Does OSGI really mandates the service to be exposed should implements interface?

答: An OSGi service can be registered under any type name not just interfaces. Interfaces are highly recommended since they nicely separate the implementation class from consumers of the service. </p>

Title: OSGi service not implementing interface

Body:
I am working on a project which uses OSGi which has below code

@Component(policy = ConfigurationPolicy.OPTIONAL, ds = true, immediate = true, metatype = false)
@Service(TestInterface.class)
public class TestInterface{

Here the code doesn't implement the interface in which the service is going to exposed. Also I have verified everywhere this is not referenced anywhere with @Reference.
Does it really need to make it as service instead of only component? In case if i want to use it in another Component i have to make it as a service by implementing interface.
Does OSGI really mandates the service to be exposed should implements interface?


问:
Show Google Maps top left infowindow on click?
I am building a google map and I would like to have some information show when the mouse is over a marker and then more detailed information when the user clicks on the map. I have found a solution for it by adding two infowindows.

html

```<code><div id="map-canvas"></div>
</code>```

css

```<code>#map-canvas {
    height: 400px;
    width: 100%;
}
</code>```

js

```<code>"use strict";

        // variable to hold a map
        var map;

        // variable to hold current active InfoWindow
        var activeInfoWindow ;

        // ------------------------------------------------------------------------------- //
        // initialize function
        // ------------------------------------------------------------------------------- //
          function initialize() {

            // map options - lots of options available here
            var mapOptions = {
              zoom : 6,
              draggable: true,
              center : new google.maps.LatLng(43.637599, 1.319152),
              mapTypeId : google.maps.MapTypeId.ROADMAP
            };

            // create map in div called map-canvas using map options defined above
            map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);

            // define three Google Map LatLng objects representing geographic points
            var barca           = new google.maps.LatLng(41.387042, 2.181382);
            var toulouse    = new google.maps.LatLng(43.637599, 1.319152);
            var madrid  = new google.maps.LatLng(40.424803, -3.698083);

            // place markers
            fnPlaceMarkers(barca,"Barcelona");
            fnPlaceMarkers(toulouse,"Toulouse");
            fnPlaceMarkers(madrid,"Madrid");
          }

        // ------------------------------------------------------------------------------- //
        // create markers on the map
        // ------------------------------------------------------------------------------- //
        function fnPlaceMarkers(myLocation,myCityName){

            var marker = new google.maps.Marker({
                position : myLocation
            });

           //var lat_lng = {lat: 17.08672, lng: 78.42444};

            // Renders the marker on the specified map
            marker.setMap(map);

            // create an InfoWindow - for mouseover
            var infoWnd = new google.maps.InfoWindow();

            // create an InfoWindow -  for mouseclick
            var infoWnd2 = new google.maps.InfoWindow(
                {
                    //pixelOffset: new google.maps.Size(200,0)
                    //position: {40.424803, -3.698083}
                    //content: contentString
                }
            );

            // -----------------------
            // ON MOUSEOVER
            // -----------------------

            // add content to your InfoWindow
            infoWnd.setContent('<div class="scrollFix">' + 'Welcome to ' +  myCityName + ' This appears when you put your mouse over a marker</div>');

            // add listener on InfoWindow for mouseover event
            google.maps.event.addListener(marker, 'mouseover', function() {

                // Close active window if exists - [one might expect this to be default behaviour no?]
                if(activeInfoWindow != null) activeInfoWindow.close();

                // Close info Window on mouseclick if already opened
                infoWnd2.close();

                // Open new InfoWindow for mouseover event
                infoWnd.open(map, marker);

                // Store new open InfoWindow in global variable
                activeInfoWindow = infoWnd;
            });

            // on mouseout (moved mouse off marker) make infoWindow disappear
            google.maps.event.addListener(marker, 'mouseout', function() {
                infoWnd.close();
            });

            // --------------------------------
            // ON MARKER CLICK - (Mouse click)
            // --------------------------------

            // add content to InfoWindow for click event
            infoWnd2.setContent('<div class="scrollFix">' + 'Welcome to ' +  myCityName + '. <br/> This appears when you click on marker</div>');

            // add listener on InfoWindow for click event
            google.maps.event.addListener(marker, 'click', function() {

                //Close active window if exists - [one might expect this to be default behaviour no?]
                if(activeInfoWindow != null) activeInfoWindow.close();

                // Open InfoWindow - on click
                infoWnd2.open(map, marker);

                // Close "mouseover" infoWindow
                infoWnd.close();

                // Store new open InfoWindow in global variable
                activeInfoWindow = infoWnd2;
            });

        }

        // ------------------------------------------------------------------------------- //
        // initial load
        // ------------------------------------------------------------------------------- //
        google.maps.event.addDomListener(window, 'load', initialize);
</code>```

It works well and you can see it here:

https://codepen.io/anon/pen/JJLVNB

but I would like to improve this. I saw something that I really like. How can I add an html infowindow in the top left of the google maps like they do on booking.com (img below) on clicking the marker. When you are inside a location you can click on "Show on map" and it will show this feature that I like.

How can I create this feature of showing an infowindow on hover and then on click another one always placed at the top left?

答:
Since you said that your requirement is to place it on top:0 and left:0, there is a method to do that.

You display the content on a div with class=scrollFix. The entire div is it's 4th parent.

add the below code inside the eventlistener of marker -> click where you generate the info box.

1. jQuery

```<code>$(".scrollFix")[0].parentNode.parentNode.parentNode.parentNode.style.top="0px";
$(".scrollFix")[0].parentNode.parentNode.parentNode.parentNode.style.left="0";
</code>```

Snippet

"use strict";

  // variable to hold a map
  var map;

  // variable to hold current active InfoWindow
  var activeInfoWindow ;

  // ------------------------------------------------------------------------------- //
  // initialize function
  // ------------------------------------------------------------------------------- //
    function initialize() {

   // map options - lots of options available here
   var mapOptions = {
     zoom : 6,
     draggable: true,
     center : new google.maps.LatLng(43.637599, 1.319152),
     mapTypeId : google.maps.MapTypeId.ROADMAP
   };

   // create map in div called map-canvas using map options defined above
   map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);

   // define three Google Map LatLng objects representing geographic points
   var barca    = new google.maps.LatLng(41.387042, 2.181382);
   var toulouse  = new google.maps.LatLng(43.637599, 1.319152);
   var madrid  = new google.maps.LatLng(40.424803, -3.698083);

   // place markers
   fnPlaceMarkers(barca,"Barcelona");
   fnPlaceMarkers(toulouse,"Toulouse");
   fnPlaceMarkers(madrid,"Madrid");
    }

  // ------------------------------------------------------------------------------- //
  // create markers on the map
  // ------------------------------------------------------------------------------- //
  function fnPlaceMarkers(myLocation,myCityName){

   var marker = new google.maps.Marker({
    position : myLocation
   });

           //var lat_lng = {lat: 17.08672, lng: 78.42444};

   // Renders the marker on the specified map

   marker.setMap(map);

   // create an InfoWindow - for mouseover
   var infoWnd = new google.maps.InfoWindow();

   // create an InfoWindow -  for mouseclick
   var infoWnd2 = new google.maps.InfoWindow(
    {
     //pixelOffset: new google.maps.Size(200,0)
     //position: {40.424803, -3.698083}
     //content: contentString
    }
   );

   // -----------------------
   // ON MOUSEOVER
   // -----------------------

   // add content to your InfoWindow
   infoWnd.setContent('
' + 'Welcome to ' +  myCityName + ' This appears when you put your mouse over a marker
');

   // add listener on InfoWindow for mouseover event
   google.maps.event.addListener(marker, 'mouseover', function() {

    // Close active window if exists - [one might expect this to be default behaviour no?]
    if(activeInfoWindow != null) activeInfoWindow.close();

    // Close info Window on mouseclick if already opened
    infoWnd2.close();

    // Open new InfoWindow for mouseover event
    infoWnd.open(map, marker);

    // Store new open InfoWindow in global variable
    activeInfoWindow = infoWnd;
   });

   // on mouseout (moved mouse off marker) make infoWindow disappear
   google.maps.event.addListener(marker, 'mouseout', function() {
    infoWnd.close();
   });

   // --------------------------------
   // ON MARKER CLICK - (Mouse click)
   // --------------------------------

   // add content to InfoWindow for click event
   infoWnd2.setContent('
' + 'Welcome to ' +  myCityName + '.
 This appears when you click on marker
');

   // add listener on InfoWindow for click event
   google.maps.event.addListener(marker, 'click', function() {

    //Close active window if exists - [one might expect this to be default behaviour no?]
    if(activeInfoWindow != null) activeInfoWindow.close();

    // Open InfoWindow - on click
    infoWnd2.open(map, marker);
    $(".scrollFix")[0].parentNode.parentNode.parentNode.parentNode.style.top="0";
        $(".scrollFix")[0].parentNode.parentNode.parentNode.parentNode.style.left="0";

    // Close "mouseover" infoWindow
    infoWnd.close();

    // Store new open InfoWindow in global variable
    activeInfoWindow = infoWnd2;
   });

  }

  // ------------------------------------------------------------------------------- //
  // initial load
  // ------------------------------------------------------------------------------- //
  google.maps.event.addDomListener(window, 'load', initialize);```
<pre class="snippet-code-css lang-css prettyprint-override"><code>#map-canvas, #side-bar {
  height: 400px;
  width: 100%;
}</code>```

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

<h1>2. JavaScript</h1>

<hr>

```document.getElementsByClassName("scrollFix")[0].parentNode.parentNode.parentNode.parentNode.style.top="0";
document.getElementsByClassName("scrollFix")[0].parentNode.parentNode.parentNode.parentNode.style.left="0";
```

<h1>Snippet</h1>

<p><div class="snippet" data-lang="js" data-hide="true" data-console="true" data-babel="false">
<div class="snippet-code snippet-currently-hidden">
<pre class="snippet-code-js lang-js prettyprint-override"><code>"use strict";

  // variable to hold a map
  var map;

  // variable to hold current active InfoWindow
  var activeInfoWindow ;

  // ------------------------------------------------------------------------------- //
  // initialize function
  // ------------------------------------------------------------------------------- //
    function initialize() {

   // map options - lots of options available here
   var mapOptions = {
     zoom : 6,
     draggable: true,
     center : new google.maps.LatLng(43.637599, 1.319152),
     mapTypeId : google.maps.MapTypeId.ROADMAP
   };

   // create map in div called map-canvas using map options defined above
   map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);

   // define three Google Map LatLng objects representing geographic points
   var barca    = new google.maps.LatLng(41.387042, 2.181382);
   var toulouse  = new google.maps.LatLng(43.637599, 1.319152);
   var madrid  = new google.maps.LatLng(40.424803, -3.698083);

   // place markers
   fnPlaceMarkers(barca,"Barcelona");
   fnPlaceMarkers(toulouse,"Toulouse");
   fnPlaceMarkers(madrid,"Madrid");
    }

  // ------------------------------------------------------------------------------- //
  // create markers on the map
  // ------------------------------------------------------------------------------- //
  function fnPlaceMarkers(myLocation,myCityName){

   var marker = new google.maps.Marker({
    position : myLocation
   });

           //var lat_lng = {lat: 17.08672, lng: 78.42444};

   // Renders the marker on the specified map

   marker.setMap(map);

   // create an InfoWindow - for mouseover
   var infoWnd = new google.maps.InfoWindow();

   // create an InfoWindow -  for mouseclick
   var infoWnd2 = new google.maps.InfoWindow(
    {
     //pixelOffset: new google.maps.Size(200,0)
     //position: {40.424803, -3.698083}
     //content: contentString
    }
   );

   // -----------------------
   // ON MOUSEOVER
   // -----------------------

   // add content to your InfoWindow
   infoWnd.setContent('<div class="scrollFix">' + 'Welcome to ' +  myCityName + ' This appears when you put your mouse over a marker</div>');

   // add listener on InfoWindow for mouseover event
   google.maps.event.addListener(marker, 'mouseover', function() {

    // Close active window if exists - [one might expect this to be default behaviour no?]
    if(activeInfoWindow != null) activeInfoWindow.close();

    // Close info Window on mouseclick if already opened
    infoWnd2.close();

    // Open new InfoWindow for mouseover event
    infoWnd.open(map, marker);

    // Store new open InfoWindow in global variable
    activeInfoWindow = infoWnd;
   });

   // on mouseout (moved mouse off marker) make infoWindow disappear
   google.maps.event.addListener(marker, 'mouseout', function() {
    infoWnd.close();
   });

   // --------------------------------
   // ON MARKER CLICK - (Mouse click)
   // --------------------------------

   // add content to InfoWindow for click event
   infoWnd2.setContent('<div class="scrollFix">' + 'Welcome to ' +  myCityName + '. <br/> This appears when you click on marker</div>');

   // add listener on InfoWindow for click event
   google.maps.event.addListener(marker, 'click', function() {

    //Close active window if exists - [one might expect this to be default behaviour no?]
    if(activeInfoWindow != null) activeInfoWindow.close();

    // Open InfoWindow - on click
    infoWnd2.open(map, marker);
    document.getElementsByClassName("scrollFix")[0].parentNode.parentNode.parentNode.parentNode.style.top="0";
        document.getElementsByClassName("scrollFix")[0].parentNode.parentNode.parentNode.parentNode.style.left="0";

    // Close "mouseover" infoWindow
    infoWnd.close();

    // Store new open InfoWindow in global variable
    activeInfoWindow = infoWnd2;
   });

  }

  // ------------------------------------------------------------------------------- //
  // initial load
  // ------------------------------------------------------------------------------- //
  google.maps.event.addDomListener(window, 'load', initialize);</code>```

 #map-canvas, #side-bar {
  height: 400px;
  width: 100%;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maps.googleapis.com/maps/api/js"></script>
<div id="map-canvas"></div></code>```

Body:
I am building a google map and I would like to have some information show when the mouse is over a marker and then more detailed information when the user clicks on the map. I have found a solution for it by adding two infowindows.

html

css

#map-canvas {
    height: 400px;
    width: 100%;
}

js

"use strict";

        // variable to hold a map
        var map;

        // variable to hold current active InfoWindow
        var activeInfoWindow ;

        // ------------------------------------------------------------------------------- //
        // initialize function
        // ------------------------------------------------------------------------------- //
          function initialize() {

            // map options - lots of options available here
            var mapOptions = {
              zoom : 6,
              draggable: true,
              center : new google.maps.LatLng(43.637599, 1.319152),
              mapTypeId : google.maps.MapTypeId.ROADMAP
            };

            // create map in div called map-canvas using map options defined above
            map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);

            // define three Google Map LatLng objects representing geographic points
            var barca           = new google.maps.LatLng(41.387042, 2.181382);
            var toulouse    = new google.maps.LatLng(43.637599, 1.319152);
            var madrid  = new google.maps.LatLng(40.424803, -3.698083);

            // place markers
            fnPlaceMarkers(barca,"Barcelona");
            fnPlaceMarkers(toulouse,"Toulouse");
            fnPlaceMarkers(madrid,"Madrid");
          }

        // ------------------------------------------------------------------------------- //
        // create markers on the map
        // ------------------------------------------------------------------------------- //
        function fnPlaceMarkers(myLocation,myCityName){

            var marker = new google.maps.Marker({
                position : myLocation
            });

           //var lat_lng = {lat: 17.08672, lng: 78.42444};

            // Renders the marker on the specified map
            marker.setMap(map);

            // create an InfoWindow - for mouseover
            var infoWnd = new google.maps.InfoWindow();

            // create an InfoWindow -  for mouseclick
            var infoWnd2 = new google.maps.InfoWindow(
                {
                    //pixelOffset: new google.maps.Size(200,0)
                    //position: {40.424803, -3.698083}
                    //content: contentString
                }
            );

            // -----------------------
            // ON MOUSEOVER
            // -----------------------

            // add content to your InfoWindow
            infoWnd.setContent('
' + 'Welcome to ' +  myCityName + ' This appears when you put your mouse over a marker
');

            // add listener on InfoWindow for mouseover event
            google.maps.event.addListener(marker, 'mouseover', function() {

                // Close active window if exists - [one might expect this to be default behaviour no?]
                if(activeInfoWindow != null) activeInfoWindow.close();

                // Close info Window on mouseclick if already opened
                infoWnd2.close();

                // Open new InfoWindow for mouseover event
                infoWnd.open(map, marker);

                // Store new open InfoWindow in global variable
                activeInfoWindow = infoWnd;
            });

            // on mouseout (moved mouse off marker) make infoWindow disappear
            google.maps.event.addListener(marker, 'mouseout', function() {
                infoWnd.close();
            });

            // --------------------------------
            // ON MARKER CLICK - (Mouse click)
            // --------------------------------

            // add content to InfoWindow for click event
            infoWnd2.setContent('
' + 'Welcome to ' +  myCityName + '.
 This appears when you click on marker
');

            // add listener on InfoWindow for click event
            google.maps.event.addListener(marker, 'click', function() {

                //Close active window if exists - [one might expect this to be default behaviour no?]
                if(activeInfoWindow != null) activeInfoWindow.close();

                // Open InfoWindow - on click
                infoWnd2.open(map, marker);

                // Close "mouseover" infoWindow
                infoWnd.close();

                // Store new open InfoWindow in global variable
                activeInfoWindow = infoWnd2;
            });

        }

        // ------------------------------------------------------------------------------- //
        // initial load
        // ------------------------------------------------------------------------------- //
        google.maps.event.addDomListener(window, 'load', initialize);

It works well and you can see it here:

https://codepen.io/anon/pen/JJLVNB

but I would like to improve this. I saw something that I really like. How can I add an html infowindow in the top left of the google maps like they do on booking.com (img below) on clicking the marker. When you are inside a location you can click on "Show on map" and it will show this feature that I like.

How can I create this feature of showing an infowindow on hover and then on click another one always placed at the top left?

Body:
Since you said that your requirement is to place it on top:0 and left:0, there is a method to do that.

You display the content on a div with class=scrollFix. The entire div is it's 4th parent.

add the below code inside the eventlistener of marker -> click where you generate the info box.

1. jQuery

$(".scrollFix")[0].parentNode.parentNode.parentNode.parentNode.style.top="0px";
$(".scrollFix")[0].parentNode.parentNode.parentNode.parentNode.style.left="0";

Snippet

"use strict";

  // variable to hold a map
  var map;

  // variable to hold current active InfoWindow
  var activeInfoWindow ;

  // ------------------------------------------------------------------------------- //
  // initialize function
  // ------------------------------------------------------------------------------- //
    function initialize() {

   // map options - lots of options available here
   var mapOptions = {
     zoom : 6,
     draggable: true,
     center : new google.maps.LatLng(43.637599, 1.319152),
     mapTypeId : google.maps.MapTypeId.ROADMAP
   };

   // create map in div called map-canvas using map options defined above
   map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);

   // define three Google Map LatLng objects representing geographic points
   var barca    = new google.maps.LatLng(41.387042, 2.181382);
   var toulouse  = new google.maps.LatLng(43.637599, 1.319152);
   var madrid  = new google.maps.LatLng(40.424803, -3.698083);

   // place markers
   fnPlaceMarkers(barca,"Barcelona");
   fnPlaceMarkers(toulouse,"Toulouse");
   fnPlaceMarkers(madrid,"Madrid");
    }

  // ------------------------------------------------------------------------------- //
  // create markers on the map
  // ------------------------------------------------------------------------------- //
  function fnPlaceMarkers(myLocation,myCityName){

   var marker = new google.maps.Marker({
    position : myLocation
   });

           //var lat_lng = {lat: 17.08672, lng: 78.42444};

   // Renders the marker on the specified map

   marker.setMap(map);

   // create an InfoWindow - for mouseover
   var infoWnd = new google.maps.InfoWindow();

   // create an InfoWindow -  for mouseclick
   var infoWnd2 = new google.maps.InfoWindow(
    {
     //pixelOffset: new google.maps.Size(200,0)
     //position: {40.424803, -3.698083}
     //content: contentString
    }
   );

   // -----------------------
   // ON MOUSEOVER
   // -----------------------

   // add content to your InfoWindow
   infoWnd.setContent('<div class="scrollFix">' + 'Welcome to ' +  myCityName + ' This appears when you put your mouse over a marker</div>');

   // add listener on InfoWindow for mouseover event
   google.maps.event.addListener(marker, 'mouseover', function() {

    // Close active window if exists - [one might expect this to be default behaviour no?]
    if(activeInfoWindow != null) activeInfoWindow.close();

    // Close info Window on mouseclick if already opened
    infoWnd2.close();

    // Open new InfoWindow for mouseover event
    infoWnd.open(map, marker);

    // Store new open InfoWindow in global variable
    activeInfoWindow = infoWnd;
   });

   // on mouseout (moved mouse off marker) make infoWindow disappear
   google.maps.event.addListener(marker, 'mouseout', function() {
    infoWnd.close();
   });

   // --------------------------------
   // ON MARKER CLICK - (Mouse click)
   // --------------------------------

   // add content to InfoWindow for click event
   infoWnd2.setContent('<div class="scrollFix">' + 'Welcome to ' +  myCityName + '. <br/> This appears when you click on marker</div>');

   // add listener on InfoWindow for click event
   google.maps.event.addListener(marker, 'click', function() {

    //Close active window if exists - [one might expect this to be default behaviour no?]
    if(activeInfoWindow != null) activeInfoWindow.close();

    // Open InfoWindow - on click
    infoWnd2.open(map, marker);
    $(".scrollFix")[0].parentNode.parentNode.parentNode.parentNode.style.top="0";
        $(".scrollFix")[0].parentNode.parentNode.parentNode.parentNode.style.left="0";

    // Close "mouseover" infoWindow
    infoWnd.close();

    // Store new open InfoWindow in global variable
    activeInfoWindow = infoWnd2;
   });

  }

  // ------------------------------------------------------------------------------- //
  // initial load
  // ------------------------------------------------------------------------------- //
  google.maps.event.addDomListener(window, 'load', initialize);

#map-canvas, #side-bar {
  height: 400px;
  width: 100%;
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maps.googleapis.com/maps/api/js"></script>
<div id="map-canvas"></div>

2. JavaScript

document.getElementsByClassName("scrollFix")[0].parentNode.parentNode.parentNode.parentNode.style.top="0";
document.getElementsByClassName("scrollFix")[0].parentNode.parentNode.parentNode.parentNode.style.left="0";

Snippet

"use strict";

  // variable to hold a map
  var map;

  // variable to hold current active InfoWindow
  var activeInfoWindow ;

  // ------------------------------------------------------------------------------- //
  // initialize function
  // ------------------------------------------------------------------------------- //
    function initialize() {

   // map options - lots of options available here
   var mapOptions = {
     zoom : 6,
     draggable: true,
     center : new google.maps.LatLng(43.637599, 1.319152),
     mapTypeId : google.maps.MapTypeId.ROADMAP
   };

   // create map in div called map-canvas using map options defined above
   map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);

   // define three Google Map LatLng objects representing geographic points
   var barca    = new google.maps.LatLng(41.387042, 2.181382);
   var toulouse  = new google.maps.LatLng(43.637599, 1.319152);
   var madrid  = new google.maps.LatLng(40.424803, -3.698083);

   // place markers
   fnPlaceMarkers(barca,"Barcelona");
   fnPlaceMarkers(toulouse,"Toulouse");
   fnPlaceMarkers(madrid,"Madrid");
    }

  // ------------------------------------------------------------------------------- //
  // create markers on the map
  // ------------------------------------------------------------------------------- //
  function fnPlaceMarkers(myLocation,myCityName){

   var marker = new google.maps.Marker({
    position : myLocation
   });

           //var lat_lng = {lat: 17.08672, lng: 78.42444};

   // Renders the marker on the specified map

   marker.setMap(map);

   // create an InfoWindow - for mouseover
   var infoWnd = new google.maps.InfoWindow();

   // create an InfoWindow -  for mouseclick
   var infoWnd2 = new google.maps.InfoWindow(
    {
     //pixelOffset: new google.maps.Size(200,0)
     //position: {40.424803, -3.698083}
     //content: contentString
    }
   );

   // -----------------------
   // ON MOUSEOVER
   // -----------------------

   // add content to your InfoWindow
   infoWnd.setContent('<div class="scrollFix">' + 'Welcome to ' +  myCityName + ' This appears when you put your mouse over a marker</div>');

   // add listener on InfoWindow for mouseover event
   google.maps.event.addListener(marker, 'mouseover', function() {

    // Close active window if exists - [one might expect this to be default behaviour no?]
    if(activeInfoWindow != null) activeInfoWindow.close();

    // Close info Window on mouseclick if already opened
    infoWnd2.close();

    // Open new InfoWindow for mouseover event
    infoWnd.open(map, marker);

    // Store new open InfoWindow in global variable
    activeInfoWindow = infoWnd;
   });

   // on mouseout (moved mouse off marker) make infoWindow disappear
   google.maps.event.addListener(marker, 'mouseout', function() {
    infoWnd.close();
   });

   // --------------------------------
   // ON MARKER CLICK - (Mouse click)
   // --------------------------------

   // add content to InfoWindow for click event
   infoWnd2.setContent('<div class="scrollFix">' + 'Welcome to ' +  myCityName + '. <br/> This appears when you click on marker</div>');

   // add listener on InfoWindow for click event
   google.maps.event.addListener(marker, 'click', function() {

    //Close active window if exists - [one might expect this to be default behaviour no?]
    if(activeInfoWindow != null) activeInfoWindow.close();

    // Open InfoWindow - on click
    infoWnd2.open(map, marker);
    document.getElementsByClassName("scrollFix")[0].parentNode.parentNode.parentNode.parentNode.style.top="0";
        document.getElementsByClassName("scrollFix")[0].parentNode.parentNode.parentNode.parentNode.style.left="0";

    // Close "mouseover" infoWindow
    infoWnd.close();

    // Store new open InfoWindow in global variable
    activeInfoWindow = infoWnd2;
   });

  }

  // ------------------------------------------------------------------------------- //
  // initial load
  // ------------------------------------------------------------------------------- //
  google.maps.event.addDomListener(window, 'load', initialize);

 #map-canvas, #side-bar {
  height: 400px;
  width: 100%;
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maps.googleapis.com/maps/api/js"></script>
<div id="map-canvas"></div>


问:
GtkBox implicit margin between children
Is it possible to remove all margins between two widgets inside a GtkBox?

Tried: Set everything to zero

Result: Still 2px effective margin

GTK+ Version: 3.18.9

Widget properties:

Drawing code:

```<code>auto w_out=static_cast<double>( gtk_widget_get_allocated_width(widget) );
auto h_out=static_cast<double>( gtk_widget_get_allocated_height(widget) );

cairo_set_source_rgba(cr,self->m_background.red,self->m_background.green
    ,self->m_background.blue,self->m_background.alpha);
cairo_rectangle(cr,0,0,w_out,h_out);
cairo_fill(cr);

auto img=self->r_img;
if(img!=nullptr)
    {
    //...
    }
</code>```

The actual size is 22 x 22 as expected.

Rendered result:

It appears that this is not a theming issue, since all themes behaves the same.

答: I found the solution. I had a non-zero spacing for the GtkBox.</p>

Title: GtkBox implicit margin between children

Body:
Is it possible to remove all margins between two widgets inside a GtkBox?

Tried: Set everything to zero

Result: Still 2px effective margin

GTK+ Version: 3.18.9

Widget properties:

Drawing code:

auto w_out=static_cast<double>( gtk_widget_get_allocated_width(widget) );
auto h_out=static_cast<double>( gtk_widget_get_allocated_height(widget) );

cairo_set_source_rgba(cr,self->m_background.red,self->m_background.green
    ,self->m_background.blue,self->m_background.alpha);
cairo_rectangle(cr,0,0,w_out,h_out);
cairo_fill(cr);

auto img=self->r_img;
if(img!=nullptr)
    {
    //...
    }

The actual size is 22 x 22 as expected.

Rendered result:

It appears that this is not a theming issue, since all themes behaves the same.


问:
React, Redux and Axios - trying to make API call
It's my first experience with React, Redux and I am totally lost. The problem is my action :

```<code>import axios from 'axios';
import { FETCH_MOVIE } from '../constants/actionTypes';
const API_KEY = <API_KEY>;
const ROOT_URL = `<API_URL>`;

export function fetchMovies(pop){

  const url = `${ROOT_URL}?api_key=${API_KEY}&sort_by=${pop}`;
  axios.get(url)
  .then(function (response) {
    console.log("response is",response)
  })
  .catch(function (error) {
    console.log(error);
  });

  return{
    type:  FETCH_MOVIE,
    payload: response.data
  };
}
</code>```

On Console.log it seems just fine - I can see the response has the data I need. But when I am trying to send response.data to payload it returns the error -  response is not defined. What am I doing wrong?

P.s. I also tried to create  const result = [] and than result = [...response.data]. The error was - SyntaxError: "result" is read-only

答:
The issue with your code is that by the time you return, response is still undefined because this code run synchronously till the return statement.
 As you can see response is defined in console.log("response is",response)
 So this is where you need to do your actual magic return but in another way.

You can use redux-thunk to do these thing because this is redux async. but as I feel you are a beginner from the code I have seen, Just use the simpler way and read redux-thunk or redux-promise. if you feel your project needs this then go one.

```<code>//try to make the caller pass this.props.dispatch as param
export function fetchMovies(dispatch, pop){
  const url = `${ROOT_URL}?api_key=${API_KEY}&sort_by=${pop}`;
  axios.get(url)
  .then(function (response) {
    // only here is response define so use dispatch to triger another action (fetched data with response)
    dispatch({
        type:  FETCH_MOVIE,
        payload: response.data
    })
  })
  .catch(function (error) {
    //if you had a loader state, you call also toggle that here with erro status
    console.log(error);
  });
}

//now on the caller (onClick for instance) do this instead
fetchMovies(this.props.dispatch, pop)
</code>```

As you can see from @loelsonk answer down. if you use redux-thunk then you won't need to pass dispatch from the caller redux-thunk for you. But also notice how you would return and anonymous arrow function which accept dispatch as a parameter.

Body:
It's my first experience with React, Redux and I am totally lost. The problem is my action :

import axios from 'axios';
import { FETCH_MOVIE } from '../constants/actionTypes';
const API_KEY = <API_KEY>;
const ROOT_URL = `<API_URL>`;

export function fetchMovies(pop){

  const url = `${ROOT_URL}?api_key=${API_KEY}&sort_by=${pop}`;
  axios.get(url)
  .then(function (response) {
    console.log("response is",response)
  })
  .catch(function (error) {
    console.log(error);
  });

  return{
    type:  FETCH_MOVIE,
    payload: response.data
  };
}

On Console.log it seems just fine - I can see the response has the data I need. But when I am trying to send response.data to payload it returns the error -  response is not defined. What am I doing wrong?

P.s. I also tried to create  const result = [] and than result = [...response.data]. The error was - SyntaxError: "result" is read-only

Body:
The issue with your code is that by the time you return, response is still undefined because this code run synchronously till the return statement.
 As you can see response is defined in console.log("response is",response)
 So this is where you need to do your actual magic return but in another way.

You can use redux-thunk to do these thing because this is redux async. but as I feel you are a beginner from the code I have seen, Just use the simpler way and read redux-thunk or redux-promise. if you feel your project needs this then go one.

//try to make the caller pass this.props.dispatch as param
export function fetchMovies(dispatch, pop){
  const url = `${ROOT_URL}?api_key=${API_KEY}&sort_by=${pop}`;
  axios.get(url)
  .then(function (response) {
    // only here is response define so use dispatch to triger another action (fetched data with response)
    dispatch({
        type:  FETCH_MOVIE,
        payload: response.data
    })
  })
  .catch(function (error) {
    //if you had a loader state, you call also toggle that here with erro status
    console.log(error);
  });
}

//now on the caller (onClick for instance) do this instead
fetchMovies(this.props.dispatch, pop)

As you can see from @loelsonk answer down. if you use redux-thunk then you won't need to pass dispatch from the caller redux-thunk for you. But also notice how you would return and anonymous arrow function which accept dispatch as a parameter.


问:
How to store execution status of a specflow scenario when executed using Command Prompt
I'm trying to initiate the execution in a remote machine for which i want to get the execution status of a specflow scenario when executed using Command Prompt.
Note: I'm achieving this using TCPClient & TCPListener approach.

In this approach, i would like to pass the scenario tag like testcase id as - @1234 via TcpClient and in TCPListener i will listen to that tag number and will pass down such that i will execute via command prompt.

Here, i would like to get the Scenario execution status like Pass, failed, pending... such that i can pass it back to TcpClient and i can complete end to end testing...

Thank You in Advance.

答: Since you are running the testing using command prompt you can check for the error level. Following link might be helpful for the same:Batch Files - Error Handling</p>


问:
QwtPicker: disable movement of cursor via arrow keys
According to the Qwt documentation of QwtPicker (which is a superclas of QwtPlotZoomer, the class I'm using) the cursor can be moved using the arrow keys:

```<code>The cursor can be moved using the arrow keys
</code>```

However, I wan't to disable this, as the arrow keys have different purposes in my application.

Is this possible via the API? Otherwise I need to subclass my QwtPlotZoomer..

答:
Ok, just ended up overriding the relevant functions of QwtPicker, this works fine.</p>

```<code>class MyQwtPlotZoomer : public QwtPlotZoomer
{
    public:
        MyQwtPlotZoomer(int xAxis, int yAxis,  QwtPlotCanvas* canvas, bool doReplot = true) : QwtPlotZoomer(xAxis, yAxis, canvas, doReplot){ }

        virtual ~MyQwtPlotZoomer(){ }

    protected:
        virtual void widgetKeyPressEvent(QKeyEvent* ke)
        {
            if ( !isActive() )
            {
                if ( keyMatch( KeyUndo, ke ) )
                    zoom( -1 );
                else if ( keyMatch( KeyRedo, ke ) )
                    zoom( +1 );
                else if ( keyMatch( KeyHome, ke ) )
                    zoom( 0 );
            }
        }

        virtual void widgetKeyReleaseEvent(QKeyEvent*){ }
};
</code>```

Body:
According to the Qwt documentation of QwtPicker (which is a superclas of QwtPlotZoomer, the class I'm using) the cursor can be moved using the arrow keys:

The cursor can be moved using the arrow keys

However, I wan't to disable this, as the arrow keys have different purposes in my application.

Is this possible via the API? Otherwise I need to subclass my QwtPlotZoomer..

Body:
Ok, just ended up overriding the relevant functions of QwtPicker, this works fine.

class MyQwtPlotZoomer : public QwtPlotZoomer
{
    public:
        MyQwtPlotZoomer(int xAxis, int yAxis,  QwtPlotCanvas* canvas, bool doReplot = true) : QwtPlotZoomer(xAxis, yAxis, canvas, doReplot){ }

        virtual ~MyQwtPlotZoomer(){ }

    protected:
        virtual void widgetKeyPressEvent(QKeyEvent* ke)
        {
            if ( !isActive() )
            {
                if ( keyMatch( KeyUndo, ke ) )
                    zoom( -1 );
                else if ( keyMatch( KeyRedo, ke ) )
                    zoom( +1 );
                else if ( keyMatch( KeyHome, ke ) )
                    zoom( 0 );
            }
        }

        virtual void widgetKeyReleaseEvent(QKeyEvent*){ }
};


问:
Update trigger to add data from two different tables onto audit table
I've created a after update trigger and would like to add data from two different tables(GORADID and SPRIDEN) when the update fires. The both of the tables are connected by one column(PIDM), so therefore is it possible to also collect data from table 2 ? so far i been getting errors such as ORA: no bind variables..
I also tried doing a select statements. But also no luck. Any suggestions would help.</p>

```<code>error: psl-00049: bad bind variable ':new.spriden_id'
error: psl-00049: bad bind variable ':new.spriden_first_name'
error: psl-00049: bad bind variable ':new.spriden_last_name'
</code>```

答:
Try below code for your trigger. Please note that you can use :new and :old only for columns of the table GORADID as you are writing trigger ON GORADID table.

You are selecting USER INTO SZRGORA_AUDIT_USER_BANNER_ID. So you should use SZRGORA_AUDIT_USER_BANNER_ID in your next queries instead of saying USER. Directly saying USERNAME = USER will not work I think.

```<code>CREATE OR REPLACE TRIGGER AUDIT_USER.GORADID_UPDT_TRG1
AFTER UPDATE OF GORADID_ADDITIONAL_ID
ON GORADID
FOR EACH ROW
  DECLARE
    v_SZRGORA_AUDIT_USER_BANNER_ID VARCHAR2(150 CHAR);
    v_SZRGORA_AUDIT_STUDENT_BANNER VARCHAR2(9 CHAR);
    v_SZRGORA_AUDIT_USER_FIRST_NAME VARCHAR2(150 CHAR);
    v_SZRGORA_AUDIT_USER_LAST_NAME VARCHAR2(150 CHAR);
  BEGIN
    SELECT USER INTO v_SZRGORA_AUDIT_USER_BANNER_ID FROM DUAL;

    SELECT SPRIDEN_ID
     INTO v_SZRGORA_AUDIT_STUDENT_BANNER
    FROM SATURN.SPRIDEN
     WHERE SPRIDEN_PIDM = :new.GORADID_PIDM
      AND GORADID_ADDITIONAL_ID = :new.GORADID_ADDITIONAL_ID;

    SELECT SPRIDEN_FIRST_NAME, SPRIDEN_LAST_NAME
     INTO v_SZRGORA_AUDIT_USER_FIRST_NAME, v_SZRGORA_AUDIT_USER_LAST_NAME
    FROM SATURN.SPRIDEN
     WHERE SPRIDEN_PIDM =
     (SELECT PIDM FROM SATURN.IDM_STAFF_AFF_ST
       WHERE USERNAME = v_SZRGORA_AUDIT_USER_BANNER_ID);

    INSERT INTO AUDIT_USER.SZRGORA_AUDIT VALUES
    ( v_SZRGORA_AUDIT_STUDENT_BANNER,
     :new.GORADID_ADDITIONAL_ID,
     :old.GORADID_ADDITIONAL_ID,
     v_SZRGORA_AUDIT_USER_FIRST_NAME,
     v_SZRGORA_AUDIT_USER_LAST_NAME,
     v_SZRGORA_AUDIT_USER_BANNER_ID,
     'UPDATE',
     SYSDATE,
     :new.GORADID_SURROGATE_ID,
     :new.GORADID_VERSION,
     :new.GORADID_VPDI_CODE);
  END;
/
</code>```

Body:
I've created a after update trigger and would like to add data from two different tables(GORADID and SPRIDEN) when the update fires. The both of the tables are connected by one column(PIDM), so therefore is it possible to also collect data from table 2 ? so far i been getting errors such as ORA: no bind variables..
I also tried doing a select statements. But also no luck. Any suggestions would help.

error: psl-00049: bad bind variable ':new.spriden_id'
error: psl-00049: bad bind variable ':new.spriden_first_name'
error: psl-00049: bad bind variable ':new.spriden_last_name'

Body:
Try below code for your trigger. Please note that you can use :new and :old only for columns of the table GORADID as you are writing trigger ON GORADID table.

You are selecting USER INTO SZRGORA_AUDIT_USER_BANNER_ID. So you should use SZRGORA_AUDIT_USER_BANNER_ID in your next queries instead of saying USER. Directly saying USERNAME = USER will not work I think.

CREATE OR REPLACE TRIGGER AUDIT_USER.GORADID_UPDT_TRG1
AFTER UPDATE OF GORADID_ADDITIONAL_ID
ON GORADID
FOR EACH ROW
  DECLARE
    v_SZRGORA_AUDIT_USER_BANNER_ID VARCHAR2(150 CHAR);
    v_SZRGORA_AUDIT_STUDENT_BANNER VARCHAR2(9 CHAR);
    v_SZRGORA_AUDIT_USER_FIRST_NAME VARCHAR2(150 CHAR);
    v_SZRGORA_AUDIT_USER_LAST_NAME VARCHAR2(150 CHAR);
  BEGIN
    SELECT USER INTO v_SZRGORA_AUDIT_USER_BANNER_ID FROM DUAL;

    SELECT SPRIDEN_ID
     INTO v_SZRGORA_AUDIT_STUDENT_BANNER
    FROM SATURN.SPRIDEN
     WHERE SPRIDEN_PIDM = :new.GORADID_PIDM
      AND GORADID_ADDITIONAL_ID = :new.GORADID_ADDITIONAL_ID;

    SELECT SPRIDEN_FIRST_NAME, SPRIDEN_LAST_NAME
     INTO v_SZRGORA_AUDIT_USER_FIRST_NAME, v_SZRGORA_AUDIT_USER_LAST_NAME
    FROM SATURN.SPRIDEN
     WHERE SPRIDEN_PIDM =
     (SELECT PIDM FROM SATURN.IDM_STAFF_AFF_ST
       WHERE USERNAME = v_SZRGORA_AUDIT_USER_BANNER_ID);

    INSERT INTO AUDIT_USER.SZRGORA_AUDIT VALUES
    ( v_SZRGORA_AUDIT_STUDENT_BANNER,
     :new.GORADID_ADDITIONAL_ID,
     :old.GORADID_ADDITIONAL_ID,
     v_SZRGORA_AUDIT_USER_FIRST_NAME,
     v_SZRGORA_AUDIT_USER_LAST_NAME,
     v_SZRGORA_AUDIT_USER_BANNER_ID,
     'UPDATE',
     SYSDATE,
     :new.GORADID_SURROGATE_ID,
     :new.GORADID_VERSION,
     :new.GORADID_VPDI_CODE);
  END;
/


问:
Android Activity transition from left to right with ease in and out curve
I'm trying to add a transition animation between Activities in Android. As I'm coming from iOS I really like the transition slide from right to left when entering a new UIViewController/Activity (and left to right when leaving). I been trying to mock this animation but all I succeeded to do is to add a linear transition between Activities. This through getActivity().overridePendingTransition(R.anim.enter, R.anim.exit); where R.anim.exit and R.anim.enter is the animation files for entering and exiting a view. This is how R.anim.enter looks like:

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

<set
xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">

<translate
    android:duration="225"
    android:fromXDelta="100%"
    android:fromYDelta="0%"
    android:toXDelta="0%"
    android:toYDelta="0%" />
</set>
</code>```

As I can see there is no way to add curved transitions in this file and I haven't found how to add curved transition to Activities online either.

Is there anyone who knows how to add a curved transitions between Activities similar to iOS curveEaseInOut animation in Android?

答:
I solved this by adding the android:interpolator="@android:anim/accelerate_decelerate_interpolator" key in the anim XML.

Final code could look something like this:

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

<set
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:interpolator="@android:anim/accelerate_decelerate_interpolator">
    <translate
        android:duration="225"
        android:fromXDelta="0%"
        android:fromYDelta="100%"
        android:toXDelta="0%"
        android:toYDelta="0%" />
</set>
</code>```

Body:
I'm trying to add a transition animation between Activities in Android. As I'm coming from iOS I really like the transition slide from right to left when entering a new UIViewController/Activity (and left to right when leaving). I been trying to mock this animation but all I succeeded to do is to add a linear transition between Activities. This through getActivity().overridePendingTransition(R.anim.enter, R.anim.exit); where R.anim.exit and R.anim.enter is the animation files for entering and exiting a view. This is how R.anim.enter looks like:

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

<set
xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">

<translate
    android:duration="225"
    android:fromXDelta="100%"
    android:fromYDelta="0%"
    android:toXDelta="0%"
    android:toYDelta="0%" />
</set>

As I can see there is no way to add curved transitions in this file and I haven't found how to add curved transition to Activities online either.

Is there anyone who knows how to add a curved transitions between Activities similar to iOS curveEaseInOut animation in Android?

Body:
I solved this by adding the android:interpolator="@android:anim/accelerate_decelerate_interpolator" key in the anim XML.

Final code could look something like this:

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

<set
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:interpolator="@android:anim/accelerate_decelerate_interpolator">
    <translate
        android:duration="225"
        android:fromXDelta="0%"
        android:fromYDelta="100%"
        android:toXDelta="0%"
        android:toYDelta="0%" />
</set>


问:
HTTP POST with LibCurl
Sending POST request using libcurl C++. I have tried almost all combination except the right one which I could not figure out.

```<code>curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, FALSE);  /*Not Recommended to use but since certificates are not available this is a workaround added*/
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, FALSE);  /*Not Recommended to use but since certificates are not available this is a workaround added*/

curl_easy_setopt(curl, CURLOPT_HTTPPOST, TRUE);  //CURLOPT_POST does not work as well
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, sJson);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, bytesCallback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);
curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, bytesCallback);
curl_easy_setopt(curl, CURLOPT_HEADERDATA, &headBuffer);
</code>```

sJson is a std::string which has the body that is created by pb2json.

I cannot figure out why the body is not sent ?
Is there some API i am missing if libcurl, any lead is appreciated !

答:
I would prefer using custom request here CURLOPT_CUSTOMREQUEST below is the code snippet that works fine!
When you use custom requests nothing implies and you have to explicitly define the CURLOPT_HTTPHEADER

Use a list here, for brevity I have used the minimal code here.

Also when you pass sJson pass it as a c type string using c_str() and remember to use +1 while passing the content length (which I somehow missed initially) as in C, strings are just char arrays which, by convention, end with a NULL byte.

```<code>struct curl_slist* slist = NULL;
slist = curl_slist_append(slist, "Content-Type: application/json");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, slist);

curl_easy_setopt(curl, CURLOPT_POSTFIELDS, sJson.c_str()); /* data goes here */
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, sJson.length() + 1); /* data goes here */
</code>```

EDIT: Use of curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST"); might create problems in redirection, use it according to your use case.

Title: HTTP POST with LibCurl

Body:
Sending POST request using libcurl C++. I have tried almost all combination except the right one which I could not figure out.

curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, FALSE);  /*Not Recommended to use but since certificates are not available this is a workaround added*/
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, FALSE);  /*Not Recommended to use but since certificates are not available this is a workaround added*/

curl_easy_setopt(curl, CURLOPT_HTTPPOST, TRUE);  //CURLOPT_POST does not work as well
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, sJson);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, bytesCallback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);
curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, bytesCallback);
curl_easy_setopt(curl, CURLOPT_HEADERDATA, &headBuffer);

sJson is a std::string which has the body that is created by pb2json.

I cannot figure out why the body is not sent ?
Is there some API i am missing if libcurl, any lead is appreciated !

Body:
I would prefer using custom request here CURLOPT_CUSTOMREQUEST below is the code snippet that works fine!
When you use custom requests nothing implies and you have to explicitly define the CURLOPT_HTTPHEADER

Use a list here, for brevity I have used the minimal code here.

Also when you pass sJson pass it as a c type string using c_str() and remember to use +1 while passing the content length (which I somehow missed initially) as in C, strings are just char arrays which, by convention, end with a NULL byte.

struct curl_slist* slist = NULL;
slist = curl_slist_append(slist, "Content-Type: application/json");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, slist);

curl_easy_setopt(curl, CURLOPT_POSTFIELDS, sJson.c_str()); /* data goes here */
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, sJson.length() + 1); /* data goes here */

EDIT: Use of curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST"); might create problems in redirection, use it according to your use case.


问:
Invalid default value for 'create_date' timestamp field
I have the following sql create statement

```<code>mysql> CREATE  TABLE IF NOT EXISTS `erp`.`je_menus` (
    ->   `id` INT(11) NOT NULL AUTO_INCREMENT ,
    ->   `name` VARCHAR(100) NOT NULL ,
    ->   `description` VARCHAR(255) NOT NULL ,
    ->   `live_start_date` DATETIME NULL DEFAULT NULL ,
    ->   `live_end_date` DATETIME NULL DEFAULT NULL ,
    ->   `notes` VARCHAR(255) NULL ,
    ->   `create_date` TIMESTAMP NOT NULL DEFAULT  '0000-00-00 00:00:00',
    ->   `created_by` INT(11) NOT NULL ,
    ->   `update_date` TIMESTAMP NOT NULL DEFAULT  CURRENT_TIMESTAMP  ,
    ->   `updated_by` INT(11) NOT NULL ,
    ->   `status` VARCHAR(45) NOT NULL ,
    ->   PRIMARY KEY (`id`) )
    -> ENGINE = InnoDB;
</code>```

giving following error

ERROR 1067 (42000): Invalid default value for 'create_date'

What is the error here?

答:
I was able to resolve this issue on OS X by installing MySQL from Homebrew

```<code>brew install mysql
</code>```

by adding the following to /usr/local/etc/my.cnf

```<code>sql_mode=ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
</code>```

and restarting MySQL

```<code>brew tap homebrew/services
brew services restart mysql
</code>```

Body:
I have the following sql create statement

mysql> CREATE  TABLE IF NOT EXISTS `erp`.`je_menus` (
    ->   `id` INT(11) NOT NULL AUTO_INCREMENT ,
    ->   `name` VARCHAR(100) NOT NULL ,
    ->   `description` VARCHAR(255) NOT NULL ,
    ->   `live_start_date` DATETIME NULL DEFAULT NULL ,
    ->   `live_end_date` DATETIME NULL DEFAULT NULL ,
    ->   `notes` VARCHAR(255) NULL ,
    ->   `create_date` TIMESTAMP NOT NULL DEFAULT  '0000-00-00 00:00:00',
    ->   `created_by` INT(11) NOT NULL ,
    ->   `update_date` TIMESTAMP NOT NULL DEFAULT  CURRENT_TIMESTAMP  ,
    ->   `updated_by` INT(11) NOT NULL ,
    ->   `status` VARCHAR(45) NOT NULL ,
    ->   PRIMARY KEY (`id`) )
    -> ENGINE = InnoDB;

giving following error

ERROR 1067 (42000): Invalid default value for 'create_date'

What is the error here?

Body:
I was able to resolve this issue on OS X by installing MySQL from Homebrew

brew install mysql

by adding the following to /usr/local/etc/my.cnf

sql_mode=ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

and restarting MySQL

brew tap homebrew/services
brew services restart mysql


问:
remove a instance from memory after doing "add" into a list
the code is very simple:

```<code>  myKpi = "a";
  Data.add(myKpi);
</code>```

and then I want to remove myKpi from memory because it has been saved in the list Data.

I have read that I can do sth like myKpi=null, but I don´t know if it will afect the value of Data.

答:
First, myKpi is just a reference to the instance. That means you can't "remove" myKpi from memory (at least not the instance it references).

Second, since the instance that is referenced by myKpi is added to Data you can't remove that instance since both references refer to the same instance.

Third, you can't manually remove an instance from the heap. All you can do is remove all references and then "ask" the JVM to do garbage collection (via System.gc()) which it will probably do but there's no guarantee it will be done (and what will actually be deleted).

Body:
the code is very simple:

  myKpi = "a";
  Data.add(myKpi);

and then I want to remove myKpi from memory because it has been saved in the list Data.

I have read that I can do sth like myKpi=null, but I don´t know if it will afect the value of Data.


问:
Hide div while scrolling down
I just want to hide an image when scroll down and show another image. When scroll to top of the page, first image needs to show and other image needs to be hide.

I tried with this code.

```<code>//This is the image I just want to show at first
<img src="images/logo-wh.png" alt="" class="logo-white">

//This is the image I just want to show when scroll down
<img src="images/logo.png" alt="" class="logo-default">

.logo-default{
  display:none;
}

$(window).scroll(function() {
    if ($(this).scrollTop() > 0) {
        $('.logo-white').hide();
    } else {
        $('.logo-default').show();
    }
 });
</code>```

But it isn't working as I expected. Any suggestions?

答:
CSS: </p>

```<code>height: x;
overflow: hidden;
</code>```

Title: Hide div while scrolling down

Body:
I just want to hide an image when scroll down and show another image. When scroll to top of the page, first image needs to show and other image needs to be hide.

I tried with this code.

//This is the image I just want to show at first

//This is the image I just want to show when scroll down

.logo-default{
  display:none;
}

$(window).scroll(function() {
    if ($(this).scrollTop() > 0) {
        $('.logo-white').hide();
    } else {
        $('.logo-default').show();
    }
 });

But it isn't working as I expected. Any suggestions?

Body:
CSS:

height: x;
overflow: hidden;


问:
Conditional statement- compare to values store in array
Need help figuring out working perl code to put in place of "any of the elements in @array" </p>

```<code>%hash = (key1 => 'value1',key2 => 'value2',key3 => 'value3',);

@array= ('value3','value4','value6');

if ($hash{ 'key1' } ne <<any of the elements in @array>>) {print "YAY!";}
</code>```

答:
You could use the grep function.  Here's a basic example:

```<code>print "YAY!" if grep { $hash{'key1'} eq $_ } @array;
</code>```

In a scalar context like this grep will give you the number of matching entries in @array.  If that's non-zero, you have a match.

Body:
Need help figuring out working perl code to put in place of "any of the elements in @array"

%hash = (key1 => 'value1',key2 => 'value2',key3 => 'value3',);

@array= ('value3','value4','value6');

if ($hash{ 'key1' } ne <<any of the elements in @array>>) {print "YAY!";}

Body:
You could use the grep function.  Here's a basic example:

print "YAY!" if grep { $hash{'key1'} eq $_ } @array;

In a scalar context like this grep will give you the number of matching entries in @array.  If that's non-zero, you have a match.


问:
GemFire getRegion() returns null whereas OQL query gives result
I am using Pivotal GemFire 9.0.0 with 1 Locator and 1 Server. The Server has a Region called "submissions", like below -

```<code><gfe:replicated-region id="submissionsRegion" name="submissions"
statistics="true" template="replicateRegionTemplate">
...
</gfe:replicated-region>
</code>```

I am getting Region as null when executing the following code -

```<code>Region<K, V> region = clientCache.getRegion("submissions");
</code>```

Surprisingly, the same ClientCache returns all the records when I query using OQL and QueryService as shown below -

```<code>String queryString = "SELECT * FROM /submissions";
QueryService queryService = clientCache.getQueryService();
Query query = queryService.newQuery(queryString);
SelectResults results = (SelectResults) query.execute();
</code>```

I am initializing my ClientCache like this -

```<code>ClientCache clientCache = new ClientCacheFactory()
            .addPoolLocator("localhost", 10479)
            .set("name", "MyClientCache")
            .set("log-level", "error")
            .create();
</code>```

I am really baffled by this. Any pointer or help would be great.

答:
You need to configure your ClientCache (either through a cache.xml or pure GemFire API) with the regions as well. Using your example:

```<code>ClientRegionFactory regionFactory = clientCache.createClientRegionFactory(ClientRegionShortcut.PROXY);
Region region = regionFactory.create("submissions");
</code>```

The ClientRegionShortcut.PROXY is used just for the sake of simplicity, you should use the shortcut that meets your needs.

The OQL works as expected because you are obtaining the QueryService through the ClientCache.getQueryService() method (instead of ClientCache.getLocalQueryService()), so the query is actually executed on Server Side.

You can get more information about how to configure the Client/Server topology in
Client/Server Configuration.

Hope this helps.

Cheers.

Body:
I am using Pivotal GemFire 9.0.0 with 1 Locator and 1 Server. The Server has a Region called "submissions", like below -

<gfe:replicated-region id="submissionsRegion" name="submissions"
statistics="true" template="replicateRegionTemplate">
...
</gfe:replicated-region>

I am getting Region as null when executing the following code -

Region<K, V> region = clientCache.getRegion("submissions");

Surprisingly, the same ClientCache returns all the records when I query using OQL and QueryService as shown below -

String queryString = "SELECT * FROM /submissions";
QueryService queryService = clientCache.getQueryService();
Query query = queryService.newQuery(queryString);
SelectResults results = (SelectResults) query.execute();

I am initializing my ClientCache like this -

ClientCache clientCache = new ClientCacheFactory()
            .addPoolLocator("localhost", 10479)
            .set("name", "MyClientCache")
            .set("log-level", "error")
            .create();

I am really baffled by this. Any pointer or help would be great.

Body:
You need to configure your ClientCache (either through a cache.xml or pure GemFire API) with the regions as well. Using your example:

ClientRegionFactory regionFactory = clientCache.createClientRegionFactory(ClientRegionShortcut.PROXY);
Region region = regionFactory.create("submissions");

The ClientRegionShortcut.PROXY is used just for the sake of simplicity, you should use the shortcut that meets your needs.

The OQL works as expected because you are obtaining the QueryService through the ClientCache.getQueryService() method (instead of ClientCache.getLocalQueryService()), so the query is actually executed on Server Side.

You can get more information about how to configure the Client/Server topology in
Client/Server Configuration.

Hope this helps.

Cheers.


问:
pathinfo() expects parameter 1 to be string array given codeigniter
Here is my code

```<code>$filename = $_FILES[$file_element_name]['name'];

$ext = pathinfo($filename, PATHINFO_EXTENSION);
</code>```

Why this line throws an error

pathinfo() expects parameter 1 to be string array given

答:
This worked for me.

```<code>$all_files = $_FILES['all_files'];
$temp_name = $all_files["name"];
$file_name = pathinfo($temp_name,PATHINFO_FILENAME);
echo $file_name;
</code>```

Hope this will work.

Body:
Here is my code

$filename = $_FILES[$file_element_name]['name'];

$ext = pathinfo($filename, PATHINFO_EXTENSION);

Why this line throws an error

pathinfo() expects parameter 1 to be string array given

Body:
This worked for me.

$all_files = $_FILES['all_files'];
$temp_name = $all_files["name"];
$file_name = pathinfo($temp_name,PATHINFO_FILENAME);
echo $file_name;

Hope this will work.