问:
how to update command of tkinter button?
I have a function fonc(a,b,c,bool1,bool2) which takes float (a,b,c) and boolean parameters.
This function can plot different types of graphics (with matplotlib) depending on the boolean value and these graphics depend on the float value.

I'm trying to make a "graphic interface" for this function in tkinter. In this interface I could change the value of the boolean with a checkbox and float with a spinbox and a button "launch" which launches the function with the current parameters and plots in the interface.

I'll try to make it first with one checkbox and here is the problem, the function put the part command of the button launch is static. I mean that it takes the default parameter that I put and never changes even if use my checkbox to change the value of the parameter.

Here is my code, the function is testpanneau.testpanneau1 and my boolean is toutedir2:

```<code>import tkinter as tk
import testpanneau
from functools import partial

"""constantes"""
latitude = 37.77
longitude = -122.42
j = 21
m = 12
a = 2016
timezone = -8
hauteurlieu = 0.282
costheta = False
toutedir1 = False
toutedir2 = True
infonord = False
cst = 32

"""definition de la fonction de changement de booleen"""
def chgtbool1():
    print("Button clicked")
    toutedir2 = True if is_checked.get() else False
    print(toutedir2)

"""creation de ma fenetre"""
mafenetre = tk.Tk()
mafenetre.title('Test irradiance')
mafenetre.geometry('600x200')

"""definition des boolen des checkbox"""
#toutedir2
is_checked = tk.BooleanVar()
#toutedir1
#costheta
#infonord

"""creation des checkbox"""
checkbox = tk.Checkbutton(mafenetre, variable=is_checked, command=chgtbool1)

"""Création d'un widget Button (bouton Quitter)"""
Bouton1 = tk.Button(mafenetre, text = 'Quitter', command = mafenetre.destroy)

""" Création d'un widget Button (bouton Lancer)"""
BoutonLancer = tk.Button(mafenetre, text ='generer', command = partial(testpanneau.testpanneau1,latitude,longitude,j,m,a,timezone,hauteurlieu,cst,costheta,toutedir1,toutedir2,infonord))

"""Positionnement du widget avec la méthode pack()"""
checkbox.pack(side = tk.LEFT, padx = 5, pady = 7)
Bouton1.pack()
BoutonLancer.pack(side = tk.RIGHT, padx = 5, pady = 0)

""" Lancement du gestionnaire d'événements"""
mafenetre.mainloop()
</code>```

答:
When you create your partial(), it is created with the values of the variables at the time it is created:

The partial() is used for partial function application which “freezes”
  some portion of a function’s arguments and/or keywords resulting in a
  new object with a simplified signature....

As shown in this simple example:

```<code>>>> from functools import partial
>>> i = 3
>>> def prt(a):
...     print a
...
>>> x = partial(prt, i)
>>> x()
3
>>> i = 5
>>> x()
3
</code>```

No amount of clicking your text box can change the value that is seen when you run your command.

What you need to do it pass in is_checked when you create the partial, and then inside your function testpanneau.testpanneau1, do the is_checked.get() to get at the boolean value. You can also do away with your chgtbool1() function.

This code works, I have replaced testpanneau.testpanneau1 with myfun(), and the value of the checkbox is correctly printed when the generer button is pressed.

```<code>import tkinter as tk
from functools import partial

"""constantes"""
latitude = 37.77
longitude = -122.42
j = 21
m = 12
a = 2016
timezone = -8
hauteurlieu = 0.282
costheta = False
toutedir1 = False
toutedir2 = True
infonord = False
cst = 32

def myfun(*args):
    print args[10].get()

"""creation de ma fenetre"""
mafenetre = tk.Tk()
mafenetre.title('Test irradiance')
mafenetre.geometry('600x200')

"""definition des boolen des checkbox"""
#toutedir2
is_checked = tk.BooleanVar()
#toutedir1
#costheta
#infonord

"""creation des checkbox"""
checkbox = tk.Checkbutton(mafenetre, variable=is_checked)

"""Creation d'un widget Button (bouton Quitter)"""
Bouton1 = tk.Button(mafenetre, text = 'Quitter', command = mafenetre.destroy)

""" Creation d'un widget Button (bouton Lancer)"""
BoutonLancer = tk.Button(mafenetre, text ='generer', command = partial(myfun,latitude,longitude,j,m,a,timezone,hauteurlieu,cst,costheta,toutedir1,is_checked,infonord))

"""Positionnement du widget avec la methode pack()"""
checkbox.pack(side = tk.LEFT, padx = 5, pady = 7)
Bouton1.pack()
BoutonLancer.pack(side = tk.RIGHT, padx = 5, pady = 0)

""" Lancement du gestionnaire d'evenements"""
mafenetre.mainloop()
</code>```

My apologies, I had to anglicize your comments as my Python 2.7 interpreter was complaining about the accented characters

Body:
I have a function fonc(a,b,c,bool1,bool2) which takes float (a,b,c) and boolean parameters.
This function can plot different types of graphics (with matplotlib) depending on the boolean value and these graphics depend on the float value.

I'm trying to make a "graphic interface" for this function in tkinter. In this interface I could change the value of the boolean with a checkbox and float with a spinbox and a button "launch" which launches the function with the current parameters and plots in the interface.

I'll try to make it first with one checkbox and here is the problem, the function put the part command of the button launch is static. I mean that it takes the default parameter that I put and never changes even if use my checkbox to change the value of the parameter.

Here is my code, the function is testpanneau.testpanneau1 and my boolean is toutedir2:

import tkinter as tk
import testpanneau
from functools import partial

"""constantes"""
latitude = 37.77
longitude = -122.42
j = 21
m = 12
a = 2016
timezone = -8
hauteurlieu = 0.282
costheta = False
toutedir1 = False
toutedir2 = True
infonord = False
cst = 32

"""definition de la fonction de changement de booleen"""
def chgtbool1():
    print("Button clicked")
    toutedir2 = True if is_checked.get() else False
    print(toutedir2)

"""creation de ma fenetre"""
mafenetre = tk.Tk()
mafenetre.title('Test irradiance')
mafenetre.geometry('600x200')

"""definition des boolen des checkbox"""
#toutedir2
is_checked = tk.BooleanVar()
#toutedir1
#costheta
#infonord

"""creation des checkbox"""
checkbox = tk.Checkbutton(mafenetre, variable=is_checked, command=chgtbool1)

"""Création d'un widget Button (bouton Quitter)"""
Bouton1 = tk.Button(mafenetre, text = 'Quitter', command = mafenetre.destroy)

""" Création d'un widget Button (bouton Lancer)"""
BoutonLancer = tk.Button(mafenetre, text ='generer', command = partial(testpanneau.testpanneau1,latitude,longitude,j,m,a,timezone,hauteurlieu,cst,costheta,toutedir1,toutedir2,infonord))

"""Positionnement du widget avec la méthode pack()"""
checkbox.pack(side = tk.LEFT, padx = 5, pady = 7)
Bouton1.pack()
BoutonLancer.pack(side = tk.RIGHT, padx = 5, pady = 0)

""" Lancement du gestionnaire d'événements"""
mafenetre.mainloop()

Body:
When you create your partial(), it is created with the values of the variables at the time it is created:

The partial() is used for partial function application which “freezes”
  some portion of a function’s arguments and/or keywords resulting in a
  new object with a simplified signature....

As shown in this simple example:

>>> from functools import partial
>>> i = 3
>>> def prt(a):
...     print a
...
>>> x = partial(prt, i)
>>> x()
3
>>> i = 5
>>> x()
3

No amount of clicking your text box can change the value that is seen when you run your command.

What you need to do it pass in is_checked when you create the partial, and then inside your function testpanneau.testpanneau1, do the is_checked.get() to get at the boolean value. You can also do away with your chgtbool1() function.

This code works, I have replaced testpanneau.testpanneau1 with myfun(), and the value of the checkbox is correctly printed when the generer button is pressed.

import tkinter as tk
from functools import partial

"""constantes"""
latitude = 37.77
longitude = -122.42
j = 21
m = 12
a = 2016
timezone = -8
hauteurlieu = 0.282
costheta = False
toutedir1 = False
toutedir2 = True
infonord = False
cst = 32

def myfun(*args):
    print args[10].get()

"""creation de ma fenetre"""
mafenetre = tk.Tk()
mafenetre.title('Test irradiance')
mafenetre.geometry('600x200')

"""definition des boolen des checkbox"""
#toutedir2
is_checked = tk.BooleanVar()
#toutedir1
#costheta
#infonord

"""creation des checkbox"""
checkbox = tk.Checkbutton(mafenetre, variable=is_checked)

"""Creation d'un widget Button (bouton Quitter)"""
Bouton1 = tk.Button(mafenetre, text = 'Quitter', command = mafenetre.destroy)

""" Creation d'un widget Button (bouton Lancer)"""
BoutonLancer = tk.Button(mafenetre, text ='generer', command = partial(myfun,latitude,longitude,j,m,a,timezone,hauteurlieu,cst,costheta,toutedir1,is_checked,infonord))

"""Positionnement du widget avec la methode pack()"""
checkbox.pack(side = tk.LEFT, padx = 5, pady = 7)
Bouton1.pack()
BoutonLancer.pack(side = tk.RIGHT, padx = 5, pady = 0)

""" Lancement du gestionnaire d'evenements"""
mafenetre.mainloop()

My apologies, I had to anglicize your comments as my Python 2.7 interpreter was complaining about the accented characters


来源: stackexchange

问:
How does the PopupWindow get notified of touched outside events?
The documentation states that PopupWindow will be informed of touch events outside of its window when
setOutsideTouchable(boolean touchable) is set to true.
How is popupwindow informed? I don't see any listener like setOnOutsideTouchListener etc to receive that information.

Example

```<code>PopupWindow popup = new PopupWindow();
popup.setOutsideTouchable(true);
//now what..how to receive those touch outside events?
</code>```

Thanks.

答:
When you touch outside the PopupWindow, OnDismissListener is triggered as touching outside window dismisses the window by default, so you can set OnDismissListener on popupWindow to listen to touch outside the window.</p>

```<code>popup.setOnDismissListener(new PopupWindow.OnDismissListener() {
    @Override
    public void onDismiss() {
         //Do Something here
    }
});
</code>```

ContentLicense: CC BY-SA 3.0

Body:
The documentation states that PopupWindow will be informed of touch events outside of its window when
setOutsideTouchable(boolean touchable) is set to true.
How is popupwindow informed? I don't see any listener like setOnOutsideTouchListener etc to receive that information.

Example

PopupWindow popup = new PopupWindow();
popup.setOutsideTouchable(true);
//now what..how to receive those touch outside events?

Thanks.

Body:
When you touch outside the PopupWindow, OnDismissListener is triggered as touching outside window dismisses the window by default, so you can set OnDismissListener on popupWindow to listen to touch outside the window.

popup.setOnDismissListener(new PopupWindow.OnDismissListener() {
    @Override
    public void onDismiss() {
         //Do Something here
    }
});


问:
How to use local docker images with Minikube?
I have several docker images that I want to use with minikube. I don't want to first have to upload and then download the same image instead of just using the local image directly. How do I do this?

Stuff I tried:

1. I tried running these commands (separately, deleting the instances of minikube both times and starting fresh)

```<code>kubectl run hdfs --image=fluxcapacitor/hdfs:latest --port=8989
kubectl run hdfs --image=fluxcapacitor/hdfs:latest --port=8989 imagePullPolicy=Never
</code>```

Output:

```<code>NAME                    READY     STATUS              RESTARTS   AGE
hdfs-2425930030-q0sdl   0/1       ContainerCreating   0          10m
</code>```

It just gets stuck on some status but never reaches the ready state.

2. I tried creating a registry and then putting images into it but that didn't work either. I might've done that incorrectly but I can't find proper instructions to do this task.

Please provide instructions to use local docker images in local kubernetes instance.

OS: ubuntu 16.04

Docker : Docker version 1.13.1, build 092cba3

Kubernetes :

```<code>Client Version: version.Info{Major:"1", Minor:"5", GitVersion:"v1.5.3", GitCommit:"029c3a408176b55c30846f0faedf56aae5992e9b", GitTreeState:"clean", BuildDate:"2017-02-15T06:40:50Z", GoVersion:"go1.7.4", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"5", GitVersion:"v1.5.2", GitCommit:"08e099554f3c31f6e6f07b448ab3ed78d0520507", GitTreeState:"clean", BuildDate:"1970-01-01T00:00:00Z", GoVersion:"go1.7.1", Compiler:"gc", Platform:"linux/amd64"}
</code>```

If someone could help me get a solution that uses docker-compose to do this, that'd be awesome.

Edit:

Images loaded in eval $(minikube docker-env):

```<code>REPOSITORY                                            TAG                 IMAGE ID            CREATED             SIZE
fluxcapacitor/jupyterhub                              latest              e5175fb26522        4 weeks ago         9.59 GB
fluxcapacitor/zeppelin                                latest              fe4bc823e57d        4 weeks ago         4.12 GB
fluxcapacitor/prediction-pmml                         latest              cae5b2d9835b        4 weeks ago         973 MB
fluxcapacitor/scheduler-airflow                       latest              95adfd56f656        4 weeks ago         8.89 GB
fluxcapacitor/loadtest                                latest              6a777ab6167c        5 weeks ago         899 MB
fluxcapacitor/hdfs                                    latest              00fa0ed0064b        6 weeks ago         1.16 GB
fluxcapacitor/sql-mysql                               latest              804137671a8c        7 weeks ago         679 MB
fluxcapacitor/metastore-1.2.1                         latest              ea7ce8c5048f        7 weeks ago         1.35 GB
fluxcapacitor/cassandra                               latest              3cb5ff117283        7 weeks ago         953 MB
fluxcapacitor/apachespark-worker-2.0.1                latest              14ee3e4e337c        7 weeks ago         3.74 GB
fluxcapacitor/apachespark-master-2.0.1                latest              fe60b42d54e5        7 weeks ago         3.72 GB
fluxcapacitor/package-java-openjdk-1.8                latest              1db08965289d        7 weeks ago         841 MB
gcr.io/google_containers/kubernetes-dashboard-amd64   v1.5.1              1180413103fd        7 weeks ago         104 MB
fluxcapacitor/stream-kafka-0.10                       latest              f67750239f4d        2 months ago        1.14 GB
fluxcapacitor/pipeline                                latest              f6afd6c5745b        2 months ago        11.2 GB
gcr.io/google-containers/kube-addon-manager           v6.1                59e1315aa5ff        3 months ago        59.4 MB
gcr.io/google_containers/kubedns-amd64                1.9                 26cf1ed9b144        3 months ago        47 MB
gcr.io/google_containers/kube-dnsmasq-amd64           1.4                 3ec65756a89b        5 months ago        5.13 MB
gcr.io/google_containers/exechealthz-amd64            1.2                 93a43bfb39bf        5 months ago        8.37 MB
gcr.io/google_containers/pause-amd64
</code>```

答:
In addition to the accepted answer, you can also achieve what you originally wanted (creating a deployment using the run command) with the following command:

```<code>kubectl run hdfs --image=fluxcapacitor/hdfs:latest --port=8989 --generator=run-pod/v1
</code>```

I found the information about the generator on the Kubernetes-dev forum:

If you're using kubectl run, it generates a manifest for you that happens to have imagePullPolicy set to Always by default. You can use this command to get an imagePullPolicy of IfNotPresent, which will work for minikube:

kubectl run --image=<container> --generator=run-pod/v1

Dan Lorenc

https://groups.google.com/forum/#!topic/kubernetes-dev/YfvWuFr_XOM

ContentLicense: CC BY-SA 4.0

Body:
I have several docker images that I want to use with minikube. I don't want to first have to upload and then download the same image instead of just using the local image directly. How do I do this?

Stuff I tried:

1. I tried running these commands (separately, deleting the instances of minikube both times and starting fresh)

kubectl run hdfs --image=fluxcapacitor/hdfs:latest --port=8989
kubectl run hdfs --image=fluxcapacitor/hdfs:latest --port=8989 imagePullPolicy=Never

Output:

NAME                    READY     STATUS              RESTARTS   AGE
hdfs-2425930030-q0sdl   0/1       ContainerCreating   0          10m

It just gets stuck on some status but never reaches the ready state.

2. I tried creating a registry and then putting images into it but that didn't work either. I might've done that incorrectly but I can't find proper instructions to do this task.

Please provide instructions to use local docker images in local kubernetes instance.

OS: ubuntu 16.04

Docker : Docker version 1.13.1, build 092cba3

Kubernetes :

Client Version: version.Info{Major:"1", Minor:"5", GitVersion:"v1.5.3", GitCommit:"029c3a408176b55c30846f0faedf56aae5992e9b", GitTreeState:"clean", BuildDate:"2017-02-15T06:40:50Z", GoVersion:"go1.7.4", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"5", GitVersion:"v1.5.2", GitCommit:"08e099554f3c31f6e6f07b448ab3ed78d0520507", GitTreeState:"clean", BuildDate:"1970-01-01T00:00:00Z", GoVersion:"go1.7.1", Compiler:"gc", Platform:"linux/amd64"}

If someone could help me get a solution that uses docker-compose to do this, that'd be awesome.

Edit:

Images loaded in eval $(minikube docker-env):

REPOSITORY                                            TAG                 IMAGE ID            CREATED             SIZE
fluxcapacitor/jupyterhub                              latest              e5175fb26522        4 weeks ago         9.59 GB
fluxcapacitor/zeppelin                                latest              fe4bc823e57d        4 weeks ago         4.12 GB
fluxcapacitor/prediction-pmml                         latest              cae5b2d9835b        4 weeks ago         973 MB
fluxcapacitor/scheduler-airflow                       latest              95adfd56f656        4 weeks ago         8.89 GB
fluxcapacitor/loadtest                                latest              6a777ab6167c        5 weeks ago         899 MB
fluxcapacitor/hdfs                                    latest              00fa0ed0064b        6 weeks ago         1.16 GB
fluxcapacitor/sql-mysql                               latest              804137671a8c        7 weeks ago         679 MB
fluxcapacitor/metastore-1.2.1                         latest              ea7ce8c5048f        7 weeks ago         1.35 GB
fluxcapacitor/cassandra                               latest              3cb5ff117283        7 weeks ago         953 MB
fluxcapacitor/apachespark-worker-2.0.1                latest              14ee3e4e337c        7 weeks ago         3.74 GB
fluxcapacitor/apachespark-master-2.0.1                latest              fe60b42d54e5        7 weeks ago         3.72 GB
fluxcapacitor/package-java-openjdk-1.8                latest              1db08965289d        7 weeks ago         841 MB
gcr.io/google_containers/kubernetes-dashboard-amd64   v1.5.1              1180413103fd        7 weeks ago         104 MB
fluxcapacitor/stream-kafka-0.10                       latest              f67750239f4d        2 months ago        1.14 GB
fluxcapacitor/pipeline                                latest              f6afd6c5745b        2 months ago        11.2 GB
gcr.io/google-containers/kube-addon-manager           v6.1                59e1315aa5ff        3 months ago        59.4 MB
gcr.io/google_containers/kubedns-amd64                1.9                 26cf1ed9b144        3 months ago        47 MB
gcr.io/google_containers/kube-dnsmasq-amd64           1.4                 3ec65756a89b        5 months ago        5.13 MB
gcr.io/google_containers/exechealthz-amd64            1.2                 93a43bfb39bf        5 months ago        8.37 MB
gcr.io/google_containers/pause-amd64

Body:
In addition to the accepted answer, you can also achieve what you originally wanted (creating a deployment using the run command) with the following command:

kubectl run hdfs --image=fluxcapacitor/hdfs:latest --port=8989 --generator=run-pod/v1

I found the information about the generator on the Kubernetes-dev forum:

If you're using kubectl run, it generates a manifest for you that happens to have imagePullPolicy set to Always by default. You can use this command to get an imagePullPolicy of IfNotPresent, which will work for minikube:

kubectl run --image=<container> --generator=run-pod/v1

Dan Lorenc

https://groups.google.com/forum/#!topic/kubernetes-dev/YfvWuFr_XOM


问:
MassTransit: How to receive responses returned by multiple consumers
I'm going to use MassTransit with RabbitMQ, and creating Request-Response application. Then I look for how to receive responses returned by multiple consumers.
Is it possible? if it's possible, how can I achieve it?

Thanks.

答: You should use saga for this. Request/Reply nature is that the requester waits for reply and then does not wait any longer. All further replies will be ignored.</p>


问:
PHP Session Data Not Being Stored
I'm making a login system, but when a user logs in, it doesn't actually store any of the data i want it to in the session. I even checked the session's file, and it was empty. I have session_start(); on all the pages. what else could i be doing wrong. Heres the code for the two main pages.

the login code:

```<code><?
if ($DEBUG == true) {
    error_reporting(E_ALL);
}
require "header.php";

require_once "dbinterface.php";
require_once "user.class.php";
require_once "config.inc.php";

$db = new db($DB['host'], $DB['user'], $DB['pass'], $DB['database']);

$u_result = $db->run("select user_id from users where user_name = '" . $db->escape($_POST['user_name']) . "'");

if ($u_result == false) {
    $url = 'Location: error.php?id=8';
    header($url);
}

if (count($u_result) < 1) {
    $url = 'Location: error.php?id=3';
    header($url);
}

$user = new user($u_result[0]['user_id']);

if ($user->match_password($_POST['pass']) == true) {
    $_SESSION['authenticated'] = true;
    $_SESSION['user_id'] = $u_result[0]['user_id'];
    $_SESSION['user'] = $user;
} else {
    $url = 'Location: error.php?id=4';
    header($url);
}
session_write_close();
header('Location: index.php');

?>
</code>```

The header that gets included in every page:

```<code><?php
if (!session_start()) {
    $url = "Location: error.php?id=13";
    header($url);
}
?>
</code>```

A little background:

windows 7 (also tried on windows

server 2008, but currently on 7) PHP

5 localy hosted problem is present

for everyone problem exists in all

browsers

答: Disk space might be one of the problem too , remember to check your disk space , if it is full it cannot be written.</p>

ContentLicense: CC BY-SA 2.5

Title: PHP Session Data Not Being Stored

Body:
I'm making a login system, but when a user logs in, it doesn't actually store any of the data i want it to in the session. I even checked the session's file, and it was empty. I have session_start(); on all the pages. what else could i be doing wrong. Heres the code for the two main pages.

the login code:

<?
if ($DEBUG == true) {
    error_reporting(E_ALL);
}
require "header.php";

require_once "dbinterface.php";
require_once "user.class.php";
require_once "config.inc.php";

$db = new db($DB['host'], $DB['user'], $DB['pass'], $DB['database']);

$u_result = $db->run("select user_id from users where user_name = '" . $db->escape($_POST['user_name']) . "'");

if ($u_result == false) {
    $url = 'Location: error.php?id=8';
    header($url);
}

if (count($u_result) < 1) {
    $url = 'Location: error.php?id=3';
    header($url);
}

$user = new user($u_result[0]['user_id']);

if ($user->match_password($_POST['pass']) == true) {
    $_SESSION['authenticated'] = true;
    $_SESSION['user_id'] = $u_result[0]['user_id'];
    $_SESSION['user'] = $user;
} else {
    $url = 'Location: error.php?id=4';
    header($url);
}
session_write_close();
header('Location: index.php');

?>

The header that gets included in every page:

<?php
if (!session_start()) {
    $url = "Location: error.php?id=13";
    header($url);
}
?>

A little background:

windows 7 (also tried on windows

server 2008, but currently on 7) PHP

5 localy hosted problem is present

for everyone problem exists in all

browsers


问:
cmake 2.8.12.2 AUTOUIC not working: bug or missing feature?
I'm building a Qt project with CMake.
With cmake-3.8.2 on macOS or Windows everything ok. On Ubuntu 14, where I have cmake-2.8.12.2, moc is run, but uic is not run.
In CMakeLists.txt I have:

```<code>set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
</code>```

and the .ui file is not specified anywhere (but has the same of a class, so I have SDFDialog.h, SDFDialog.cpp, SDFDialog.ui)

On Ubuntu 14 with cmake-2.8.12.2 this is the output:

```<code>$ cmake --build .
Scanning dependencies of target v_repExtSDF_automoc
[  4%] Automoc for target v_repExtSDF
Generating moc_SDFDialog.cpp
Generating moc_UIFunctions.cpp
Generating moc_UIProxy.cpp
[  4%] Built target v_repExtSDF_automoc
Scanning dependencies of target v_repExtSDF
[  8%] Building CXX object CMakeFiles/v_repExtSDF.dir/ImportOptions.cpp.o
[ 12%] Building CXX object CMakeFiles/v_repExtSDF.dir/SDFDialog.cpp.o
/home/user/Development/V-REP_PRO_EDU_V3_4_0_64_Linux.rev9/programming/v_repExtSDF/SDFDialog.cpp:4:26: fatal error: ui_SDFDialog.h: No such file or directory
 #include "ui_SDFDialog.h"
                          ^
compilation terminated.
make[2]: *** [CMakeFiles/v_repExtSDF.dir/SDFDialog.cpp.o] Error 1
make[1]: *** [CMakeFiles/v_repExtSDF.dir/all] Error 2
make: *** [all] Error 2
</code>```

while on macOS with cmake-3.8.2 uic is correctly run:

```<code>$ cmake --build .
Scanning dependencies of target v_repExtSDF_autogen
[  4%] Automatic MOC and UIC for target v_repExtSDF
Generating MOC source v_repExtSDF_autogen/EWIEGA46WW/moc_SDFDialog.cpp
Generating MOC source v_repExtSDF_autogen/EWIEGA46WW/moc_UIFunctions.cpp
Generating MOC source v_repExtSDF_autogen/EWIEGA46WW/moc_UIProxy.cpp
Generating MOC compilation v_repExtSDF_autogen/moc_compilation.cpp
Generating UIC header v_repExtSDF_autogen/include/ui_SDFDialog.h
[  4%] Built target v_repExtSDF_autogen
...
</code>```

Is this a bug or missing feature?
In case it is a missing feature, what's the minimum required cmake version ?
Is there some workaround to make uic run also on cmake-2.8.12.2 without changing the CMakeLists.txt too much?

答:
AUTOMOC feature has been introduced by CMake 2.8.6.
AUTOUIC feature has been introduced by CMake 3.0.x.

As a result, on Windows and macOS, you can use them since you have a CMake version including both features. On Ubuntu, your version 2.8.12 doesn't support AUTOUIC so you can't use it.

Source: https://cmake.org/cmake/help/v2.8.12/cmake.html

Since your Ubuntu version is very old, maybe it is a good idea to upgrade to the next LTS (16.04). Or, you could try to install a more recent CMake version:

either by using a PPA providing CMake 3 for your ubuntu 14.04. For example https://launchpad.net/~george-edison55/+archive/ubuntu/cmake-3.x

or by compiling it yourself: https://cmake.org/install/ In that case, you may have some issues regarding outdated dependencies.

Body:
I'm building a Qt project with CMake.
With cmake-3.8.2 on macOS or Windows everything ok. On Ubuntu 14, where I have cmake-2.8.12.2, moc is run, but uic is not run.
In CMakeLists.txt I have:

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)

and the .ui file is not specified anywhere (but has the same of a class, so I have SDFDialog.h, SDFDialog.cpp, SDFDialog.ui)

On Ubuntu 14 with cmake-2.8.12.2 this is the output:

$ cmake --build .
Scanning dependencies of target v_repExtSDF_automoc
[  4%] Automoc for target v_repExtSDF
Generating moc_SDFDialog.cpp
Generating moc_UIFunctions.cpp
Generating moc_UIProxy.cpp
[  4%] Built target v_repExtSDF_automoc
Scanning dependencies of target v_repExtSDF
[  8%] Building CXX object CMakeFiles/v_repExtSDF.dir/ImportOptions.cpp.o
[ 12%] Building CXX object CMakeFiles/v_repExtSDF.dir/SDFDialog.cpp.o
/home/user/Development/V-REP_PRO_EDU_V3_4_0_64_Linux.rev9/programming/v_repExtSDF/SDFDialog.cpp:4:26: fatal error: ui_SDFDialog.h: No such file or directory
 #include "ui_SDFDialog.h"
                          ^
compilation terminated.
make[2]: *** [CMakeFiles/v_repExtSDF.dir/SDFDialog.cpp.o] Error 1
make[1]: *** [CMakeFiles/v_repExtSDF.dir/all] Error 2
make: *** [all] Error 2

while on macOS with cmake-3.8.2 uic is correctly run:

$ cmake --build .
Scanning dependencies of target v_repExtSDF_autogen
[  4%] Automatic MOC and UIC for target v_repExtSDF
Generating MOC source v_repExtSDF_autogen/EWIEGA46WW/moc_SDFDialog.cpp
Generating MOC source v_repExtSDF_autogen/EWIEGA46WW/moc_UIFunctions.cpp
Generating MOC source v_repExtSDF_autogen/EWIEGA46WW/moc_UIProxy.cpp
Generating MOC compilation v_repExtSDF_autogen/moc_compilation.cpp
Generating UIC header v_repExtSDF_autogen/include/ui_SDFDialog.h
[  4%] Built target v_repExtSDF_autogen
...

Is this a bug or missing feature?
In case it is a missing feature, what's the minimum required cmake version ?
Is there some workaround to make uic run also on cmake-2.8.12.2 without changing the CMakeLists.txt too much?


问:
How to create Selector with parameters from string
I am writing a program using Swift 3.1 and Xcode 8.3.3. I want to create a class, responsible for moving entire view when keyboard appears and disappears. But I faced difficulties with creating custom Selector with parameters from string. To show or hide keyboard we need function:

```<code>func keyboardWillShow(notification: Notification) {
//Code moving view when keyboard appears
}
</code>```

I am trying to create a selector like this:

```<code>let selector = Selector(("keyboardWillShow")
NotificationCenter.default.addObserver(view, selector: selector, name: .UIKeyboardWillShow, object: anyView.view.window)
</code>```

It is compiling, but when keyboard appears, it crashes.
Because it is independent class I cannot use this construction:

```<code>#selector(keyboardWillShow)
</code>```

Because it transforms Swift function to Objective-C function (adding @objc).
So question is: how to create a Selector form with parameters string?

P. S. I can put the whole code there but I don't want question to be very big, so I will edit question if somebody asks...

答:
This way works,

```<code>override func viewDidLoad() {
    super.viewDidLoad()
// put it wherever you want
 NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(showKeyboard), name:UIKeyboardWillShowNotification, object: nil)
}

func showKeyboard(sender: NSNotification) {
    keyboardWillShow(sender, adjustHeight: 150)
}

func keyboardWillShow(sender: NSNotification, adjustHeight: CGFloat) {
    if let keyboardSize = (sender.userInfo?[UIKeyboardFrameEndUserInfoKey] as? NSValue)?.CGRectValue() {
        keyboardHeight = keyboardSize.height
 // do your calculations
    }
}
</code>```

This will helps you to achieve your expected result.

Body:
I am writing a program using Swift 3.1 and Xcode 8.3.3. I want to create a class, responsible for moving entire view when keyboard appears and disappears. But I faced difficulties with creating custom Selector with parameters from string. To show or hide keyboard we need function:

func keyboardWillShow(notification: Notification) {
//Code moving view when keyboard appears
}

I am trying to create a selector like this:

let selector = Selector(("keyboardWillShow")
NotificationCenter.default.addObserver(view, selector: selector, name: .UIKeyboardWillShow, object: anyView.view.window)

It is compiling, but when keyboard appears, it crashes.
Because it is independent class I cannot use this construction:

#selector(keyboardWillShow)

Because it transforms Swift function to Objective-C function (adding @objc).
So question is: how to create a Selector form with parameters string?

P. S. I can put the whole code there but I don't want question to be very big, so I will edit question if somebody asks...

Body:
This way works,

override func viewDidLoad() {
    super.viewDidLoad()
// put it wherever you want
 NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(showKeyboard), name:UIKeyboardWillShowNotification, object: nil)
}

func showKeyboard(sender: NSNotification) {
    keyboardWillShow(sender, adjustHeight: 150)
}

func keyboardWillShow(sender: NSNotification, adjustHeight: CGFloat) {
    if let keyboardSize = (sender.userInfo?[UIKeyboardFrameEndUserInfoKey] as? NSValue)?.CGRectValue() {
        keyboardHeight = keyboardSize.height
 // do your calculations
    }
}

This will helps you to achieve your expected result.


问:
neo4jclient fails to authenticate against neo4j database when TransactionalGraphClient is used
The following C# code implementing neo4jclient connects to the database correctly:

```<code>static readonly string dbConnection = "http://user:pass@localhost:7474/db/data";
GraphClient neoClient = new GraphClient(new Uri(dbConnection));
</code>```

However the same code fails when the client is cast as transactional.

```<code>static readonly string dbConnection = "http://user:pass@localhost:7474/db/data";
ITransactionalGraphClient neoClient = new GraphClient(new Uri(dbConnection));
</code>```

with the error

```<code>The response status was: 401 Unauthorized

The response from Neo4j (which might include useful detail!) was: {
  "errors" : [ {
    "code" : "Neo.ClientError.Security.Unauthorized",
    "message" : "No authentication header supplied."
  } ]
}
</code>```

I need to use transactions, is there a reason for this behavior or a way to get around it?

UPDATE: I've discovered that the initial database connection actually does work. The exception is thrown from my first Cypher query, so I've posted that query here as well in case that's the problem.

```<code>public void AddNode(NodeClass node)
{
    using (var transaction = neoClient.BeginTransaction())
    {
        var paramaters = new
        {
            Id = node.Id,
            Name = node.Name,
            ...
        };

        neoClient.Cypher
           .Create("(x:NodeLabel {paramaters})")
           .WithParam("paramaters", paramaters)
           .ExecuteWithoutResults();

        transaction.Commit();
    }
}
</code>```

答:
If you change your connection to be:

new GraphClient(new Uri("http://localhost:7474/db/data"), "user", "pass");

you will connect and execute your queries absolutely fine.

In terms of that case not being marked as fixed - that's mainly down to the fact that I usually wait for the bug reporter to mark it as so, but I probably should have a cleanup - in fact I have been, but haven't got there yet.

From a POV of the documentation being lacking - again I can only apologise. This is mostly down to the fact that unfortunately I have to work to live, and sometimes I feel I just want to relax when I get home :-o

Body:
The following C# code implementing neo4jclient connects to the database correctly:

static readonly string dbConnection = "http://user:pass@localhost:7474/db/data";
GraphClient neoClient = new GraphClient(new Uri(dbConnection));

However the same code fails when the client is cast as transactional.

static readonly string dbConnection = "http://user:pass@localhost:7474/db/data";
ITransactionalGraphClient neoClient = new GraphClient(new Uri(dbConnection));

with the error

The response status was: 401 Unauthorized

The response from Neo4j (which might include useful detail!) was: {
  "errors" : [ {
    "code" : "Neo.ClientError.Security.Unauthorized",
    "message" : "No authentication header supplied."
  } ]
}

I need to use transactions, is there a reason for this behavior or a way to get around it?

UPDATE: I've discovered that the initial database connection actually does work. The exception is thrown from my first Cypher query, so I've posted that query here as well in case that's the problem.

public void AddNode(NodeClass node)
{
    using (var transaction = neoClient.BeginTransaction())
    {
        var paramaters = new
        {
            Id = node.Id,
            Name = node.Name,
            ...
        };

        neoClient.Cypher
           .Create("(x:NodeLabel {paramaters})")
           .WithParam("paramaters", paramaters)
           .ExecuteWithoutResults();

        transaction.Commit();
    }
}


问:
I can't able to copy folder when i create NET USER using powershell script simultaneously
I can't able to copy folder from adminuser to Created NET USER's desktop(not public desktop) before first sign in.</p>

答:
The new users profile (including the Desktop) doesn't exist before the
first login.

With the first login the template (default) is copied to the new
profile.


问:
Python: How to pip install opencv2 with specific version 2.4.9?
I know that I could pip install opencv-python which installs opencv3, but is there a separate command or name for opencv specific version such as 2.4.9?

If not, how can I specify which version to install?

Thanks.

答:
If you are using windows os, you can download your desired opencv unofficial windows binary from here, and type
something like pip install opencv_python-2.4.13.2-cp27-cp27m-win_amd64.whl in the directory of binary file.


问:
Strongly typing a view to a class from the webservice?
Currently I use a webservice to call the database and pass back an object back to my MVC app. The purpose is to display the data on a table.

So would it better if I just type the View to the class from the webservice, or should it always be typed to a model inside the MVC app? If I type it to a model inside my app, then I would have to create a new instance of the class and copy all the information over, which seems like a waste of time.

Which one is considered best practice? Strongly typing to a class from the webservice or a class within the MVC app?

Cheers.

答: Best practice is to shield your application from external changes and your views from knowing the internals of the application. So I would just create a separate class and then map it to the web service class.  You can also use something like AutoMapper to do the mapping for you.</p>


问:
How to make the ajax 'data' that come with 2 values to get each value separately?
```<code><?
 function phpfunction(){

 //insert data to database //some codes work inside this.

$return_arr[] = array($arrResult,         // include only one value
                      $response_array['status'] );//success or not success value

return $return_arr;
}
?>
</code>```

This $return_arr[] value return to the javascript ajax file >>

```<code>                    $.ajax({
                            url: 'PHPMethodCalls_AL.php',
                            type: 'post',
                            data: {... post many values to php function..   },
                            success: function(data) {
                            alert(data);
</code>```

//data is successfully come as this format >> [[["Testing123"],"success"]]

```<code>                            var results = JSON.parse(data);
                            alert(results);
</code>```

// this alert got >> Testing123,success

```<code>                        },
</code>```

//this one is post value to function

```<code>$newCIarrayList = array();
$newCIarrayList = phpfunction(..data include );
echo json_encode($newCIarrayList);
</code>```

What should I do to get each value as "Testing123" and "success" value separately? I tried with split(",") function but it didn't work.

答:
You can seperate in php function before response to ajax like below .Then you can get easy

```<code><?
 function phpfunction(){

    //insert data to database //some codes work inside this.

    $return_arr = array("data"   =>$arrResult,         // include only one value
                        "status" =>$response_array['status'] );//success or not success value
    return $return_arr;
}
?>
</code>```

var results = JSON.parse(data);

alert(results.data || results.status);

Body:
<?
 function phpfunction(){

 //insert data to database //some codes work inside this.

$return_arr[] = array($arrResult,         // include only one value
                      $response_array['status'] );//success or not success value

return $return_arr;
}
?>

This $return_arr[] value return to the javascript ajax file >>

                    $.ajax({
                            url: 'PHPMethodCalls_AL.php',
                            type: 'post',
                            data: {... post many values to php function..   },
                            success: function(data) {
                            alert(data);

//data is successfully come as this format >> [[["Testing123"],"success"]]

                            var results = JSON.parse(data);
                            alert(results);

// this alert got >> Testing123,success

                        },

//this one is post value to function

$newCIarrayList = array();
$newCIarrayList = phpfunction(..data include );
echo json_encode($newCIarrayList);

What should I do to get each value as "Testing123" and "success" value separately? I tried with split(",") function but it didn't work.

Body:
You can seperate in php function before response to ajax like below .Then you can get easy

<?
 function phpfunction(){

    //insert data to database //some codes work inside this.

    $return_arr = array("data"   =>$arrResult,         // include only one value
                        "status" =>$response_array['status'] );//success or not success value
    return $return_arr;
}
?>

var results = JSON.parse(data);

alert(results.data || results.status);


问:
Writing this jquery code inline, bind function and callback
```<code>var callBack = function(event, ui) {
    setModel.call(this, ui);
};

this.renderer.$el.on("slide", callBack.bind(this));
</code>```

Hey I need help on how to write this without callback variable. How to define anonymous function directly in event handler without callBack variable, and bind it to this? thanks.

答:
You can do this </p>

```<code>this.renderer.$el.on("slide", function(event, ui) {
    setModel.call(this, ui);
});
</code>```

Body:
var callBack = function(event, ui) {
    setModel.call(this, ui);
};

this.renderer.$el.on("slide", callBack.bind(this));

Hey I need help on how to write this without callback variable. How to define anonymous function directly in event handler without callBack variable, and bind it to this? thanks.

Body:
You can do this

this.renderer.$el.on("slide", function(event, ui) {
    setModel.call(this, ui);
});


问:
UIWebView is not shown
WebView in Mainstoryboard is not shown anything. I wanna show yahoo page in my app.When I run my app in an emulator(that is not my real iPhone), it is like only　black screen.

Any error does not happen in that time, but
warning

In this part, I got a warning

"signal SIGABRT"

My code is like

```<code>import Foundation
import Alamofire
import UIKit

class webViewController: UIViewController {

    @IBOutlet var webBrowser: UIWebView! = nil

    var targetURL = "https://www.yahoo.co.jp"

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        //loadAddressURL()
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    func loadAddressURL() {
        let requestURL = NSURL(string: targetURL)
        let req = NSURLRequest(url: requestURL as! URL)
        webBrowser.loadRequest(req as URLRequest)
    }

}
</code>```

I think a connection of WebView & WebViewController is ok. I tried to do Add Exception Breakpoint,and find a point of this error.
The result is
result

My app dropped in

"Thread1:breakpoint4.1".

What is wrong with my app?

答:
CTRL + DRAG to create IBOutlet for UIWebView like mentioned in below image and it should be:

```<code>@IBOutlet weak var webBrowser: UIWebView!
</code>```

Initialize your targetURL like :

```<code>let targetURL = "https://www.yahoo.co.jp".addingPercentEncoding( withAllowedCharacters: .urlQueryAllowed)
</code>```

Then in your func loadAddressURL must be

```<code>func loadAddressURL() {

        if NSURL(string: targetURL!) != nil {

            let url = URL(string: targetURL!)!
            webBrowser.loadRequest(URLRequest(url: url))

        }

    }
</code>```

Title: UIWebView is not shown

Body:
WebView in Mainstoryboard is not shown anything. I wanna show yahoo page in my app.When I run my app in an emulator(that is not my real iPhone), it is like only　black screen.

Any error does not happen in that time, but
warning

In this part, I got a warning

"signal SIGABRT"

My code is like

import Foundation
import Alamofire
import UIKit

class webViewController: UIViewController {

    @IBOutlet var webBrowser: UIWebView! = nil

    var targetURL = "https://www.yahoo.co.jp"

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        //loadAddressURL()
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    func loadAddressURL() {
        let requestURL = NSURL(string: targetURL)
        let req = NSURLRequest(url: requestURL as! URL)
        webBrowser.loadRequest(req as URLRequest)
    }

}

I think a connection of WebView & WebViewController is ok. I tried to do Add Exception Breakpoint,and find a point of this error.
The result is
result

My app dropped in

"Thread1:breakpoint4.1".

What is wrong with my app?

Body:
CTRL + DRAG to create IBOutlet for UIWebView like mentioned in below image and it should be:

@IBOutlet weak var webBrowser: UIWebView!

Initialize your targetURL like :

let targetURL = "https://www.yahoo.co.jp".addingPercentEncoding( withAllowedCharacters: .urlQueryAllowed)

Then in your func loadAddressURL must be

func loadAddressURL() {

        if NSURL(string: targetURL!) != nil {

            let url = URL(string: targetURL!)!
            webBrowser.loadRequest(URLRequest(url: url))

        }

    }


问:
how can i reduce my App size with database in android
I have an android app with a Test sqlite database. my test database size is 386 KB.
when i run my app in phone using test database and go to setting->app , I see this:

```<code>Total ........ 3.44 MB
App...........3.01 MB
Data..........0.41 MB
</code>```

but when i use main database that has 34 MB size and i run my app in phone with main database and go to setting->app, I see this:

```<code>Total......69.86 MB
App.......20.6 MB
Data......49.26 MB
</code>```

Why does my app size increase when my database size increase?

My database size out of app is 34 MB...why when I use in App increase Up to 49 MB?

答:
The Data figure is measured by both Database size + Preference size.
Maybe your app is having some shared preference that contributes to the Data size as you see.</p>

Body:
I have an android app with a Test sqlite database. my test database size is 386 KB.
when i run my app in phone using test database and go to setting->app , I see this:

Total ........ 3.44 MB
App...........3.01 MB
Data..........0.41 MB

but when i use main database that has 34 MB size and i run my app in phone with main database and go to setting->app, I see this:

Total......69.86 MB
App.......20.6 MB
Data......49.26 MB

Why does my app size increase when my database size increase?

My database size out of app is 34 MB...why when I use in App increase Up to 49 MB?


问:
elasticsearch - create new mapping and transform data from old mapping data to new one
I have old index with old mapping. I need a new mapping. So I have to create new index cause mapping cannot be changed.

My question is  how to transfer and transform data from old index/mapping to new one?

For example I have a structure :

```<code>{
...
"a",
"b"
}
</code>```

but new mapping is :

```<code>{
 "c": {
      "a",
      "b"
    }
}
</code>```

I checked this article. but there is no info about data transformation.

答:
You could use reindex Api. This API support script to transform document. Example from the documentation:

```<code>{
    "source": {
        "index": "twitter"
    },
    "dest": {
        "index": "new_twitter"
    },
    "script": {
        "inline": "if (ctx._source.foo == 'bar') {ctx._version++; ctx._source.remove('foo')}",
        "lang": "painless"
    }
}
</code>```

In script you could transform source document as you want.

Body:
I have old index with old mapping. I need a new mapping. So I have to create new index cause mapping cannot be changed.

My question is  how to transfer and transform data from old index/mapping to new one?

For example I have a structure :

{
...
"a",
"b"
}

but new mapping is :

{
 "c": {
      "a",
      "b"
    }
}

I checked this article. but there is no info about data transformation.

Body:
You could use reindex Api. This API support script to transform document. Example from the documentation:

{
    "source": {
        "index": "twitter"
    },
    "dest": {
        "index": "new_twitter"
    },
    "script": {
        "inline": "if (ctx._source.foo == 'bar') {ctx._version++; ctx._source.remove('foo')}",
        "lang": "painless"
    }
}

In script you could transform source document as you want.


问:
MPMoviePlayer-Notification doesn´t get called
HI,

i want to play a movie using MPMoviePlayerViewController and listen to a MPMoviePlayerPlaybackDidFinishNotification, but it doesn´t get called. Any ideas on that?
Would be helpful to get any hints on that.. Thanks you
Here´s my code:

```<code>NSString *url   =   [[NSBundle mainBundle] pathForResource:[sender contentName] ofType:@"m4v"];
    MPMoviePlayerViewController* moviePlayerController = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL fileURLWithPath:url] ];

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackComplete:) name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayerController];

    moviePlayerController.moviePlayer.controlStyle = MPMovieControlStyleFullscreen;
    [self presentMoviePlayerViewControllerAnimated:moviePlayerController];
    [moviePlayerController.moviePlayer play];
}

- (void) moviePlayBackComplete:(NSNotification*) notification {
    NSLog(@"moviePlayBackComplete complete");

    MPMoviePlayerController* moviePlayerController = [notification object];
    [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayerController];

    [self dismissMoviePlayerViewControllerAnimated];
    [moviePlayerController release];
}
</code>```

答:
You're trying to get notifications from a MPMovePlayerViewController but I'm pretty sure only MPMoviePlayerController provides them. Try and change your notification setup

```<code>[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackComplete:) name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayerController.moviePlayer];
</code>```

Body:
HI,

i want to play a movie using MPMoviePlayerViewController and listen to a MPMoviePlayerPlaybackDidFinishNotification, but it doesn´t get called. Any ideas on that?
Would be helpful to get any hints on that.. Thanks you
Here´s my code:

NSString *url   =   [[NSBundle mainBundle] pathForResource:[sender contentName] ofType:@"m4v"];
    MPMoviePlayerViewController* moviePlayerController = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL fileURLWithPath:url] ];

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackComplete:) name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayerController];

    moviePlayerController.moviePlayer.controlStyle = MPMovieControlStyleFullscreen;
    [self presentMoviePlayerViewControllerAnimated:moviePlayerController];
    [moviePlayerController.moviePlayer play];
}

- (void) moviePlayBackComplete:(NSNotification*) notification {
    NSLog(@"moviePlayBackComplete complete");

    MPMoviePlayerController* moviePlayerController = [notification object];
    [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayerController];

    [self dismissMoviePlayerViewControllerAnimated];
    [moviePlayerController release];
}

Body:
You're trying to get notifications from a MPMovePlayerViewController but I'm pretty sure only MPMoviePlayerController provides them. Try and change your notification setup

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackComplete:) name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayerController.moviePlayer];


问:
Get tag description and display in WordPress
I've tried to get the tag description and display in WordPress but with no success. I've commented below what I've added to try and get the tag description.</p>

```<code>        <?php

        $q_categories = $_GET['categories'];
        $q_tags = $_GET['tags'];

            $term_id = 26;
            $taxonomy_name = 'tags';
            $termchildren = get_term_children( $term_id, $taxonomy_name);
            $description = tag_description(); //NOT WORKING
            foreach ( $termchildren as $child ) {
            $term = get_term_by( 'id', $child, $taxonomy_name, $description );
            $tag_image = get_field('tag_image', $term);
            $show_on_landing_page = get_field('show_on_landing_page', $term);

 if ( $show_on_landing_page) { ?>

                    <div class="box three columns">
                        <div class="box-content slidedown">
                            <? if( !empty($tag_image) ): ?><img src="<? echo the_field('tag_image', $term); ?>" class="cover cat-img" /><?php endif; ?>
                            <div class="details">
                                <div class="details-container">
                                    <h4><? echo $term->name; //NOT WORKING ?></h4>
                                    <p><? echo $term->description; ?></p>
                                    <a href="?tags=<? echo $term->slug; ?>" class="btn hvr-bounce-to-right">View Work</a>
                                </div>
                            </div>
                        </div>
                    </div>

                <? } ?>

            <? } ?>
</code>```

答:
Please try this for "tag description".

```<code> <?php

  $tags = get_tags();

  foreach ( $tags as $tag )
 {
    echo '```';
   //print_r($tag);
    echo $tag_name=$tag->name.'
';
    echo $tag_desc=$tag->description.'
';

 }

 ?>
```

Body:
I've tried to get the tag description and display in WordPress but with no success. I've commented below what I've added to try and get the tag description.

        <?php

        $q_categories = $_GET['categories'];
        $q_tags = $_GET['tags'];

            $term_id = 26;
            $taxonomy_name = 'tags';
            $termchildren = get_term_children( $term_id, $taxonomy_name);
            $description = tag_description(); //NOT WORKING
            foreach ( $termchildren as $child ) {
            $term = get_term_by( 'id', $child, $taxonomy_name, $description );
            $tag_image = get_field('tag_image', $term);
            $show_on_landing_page = get_field('show_on_landing_page', $term);

 if ( $show_on_landing_page) { ?>

                            <? if( !empty($tag_image) ): ?><img src="<? echo the_field('tag_image', $term); ?>" class="cover cat-img" /><?php endif; ?>

<? echo $term->name; //NOT WORKING ?>

<? echo $term->description; ?>

                                    <a href="?tags=<? echo $term->slug; ?>" class="btn hvr-bounce-to-right">View Work

                <? } ?>

            <? } ?>

Body:
Please try this for "tag description".

 <?php

  $tags = get_tags();

  foreach ( $tags as $tag )
 {
    echo '<pre>';
   //print_r($tag);
    echo $tag_name=$tag->name.'<br>';
    echo $tag_desc=$tag->description.'<br>';

 }

 ?>


问:
Transform a list to a string
What is the pythonic way to perform the below transformation?

[a, b, c] -> "'a', 'b', 'c'"

Where a, b, and c are all variables holding strings.

答:
use the `.join` method on a string

    ', '.join(['a', 'b', 'c'])

misunderstood the question

```<code>"'{}' '{}' '{}'".format(*[a, b, c])
</code>```

or if you don't know the length of the list

```<code> a, b, c = 'ehllo', 'sdf', 'sdflkj'
 d = [a,b,c]
 ("'{}', " * len(d))[:-2].format(*d).strip()
</code>```

outputs, it's pretty clunky but it'll work even if the list elements are not str

```<code>"'ehllo', 'sdf', 'sdflkj'"
</code>```

or in python 3.6

```<code>d = [a, b, c]
f"{d[0]} {d[1]} {d[2]}"
</code>```

Title: Transform a list to a string

Body:
use the `.join` method on a string

    ', '.join(['a', 'b', 'c'])

misunderstood the question

"'{}' '{}' '{}'".format(*[a, b, c])

or if you don't know the length of the list

 a, b, c = 'ehllo', 'sdf', 'sdflkj'
 d = [a,b,c]
 ("'{}', " * len(d))[:-2].format(*d).strip()

outputs, it's pretty clunky but it'll work even if the list elements are not str

"'ehllo', 'sdf', 'sdflkj'"

or in python 3.6

d = [a, b, c]
f"{d[0]} {d[1]} {d[2]}"


问:
/bin/sh: 1: ./configure: not found - dockerfile
I need to install Cosign filter for Apacher server.

I need to use this cosign-filter from Confluence, but when my installation hits ./configure it trow as error:

```<code>ERROR: Unknown instruction: --ENABLE-APACHE2=/PATH/TO/APACHE2/BIN/APXS
</code>```

Then i found out this installation for cosign filter with github repository, and because I use ubuntu16.04 in my Docker container I found it more useful, but in this installation I have a problem with autoconf so when he hits RUN autoconf it trows this error:

```<code>autoconf: error: no input file
ERROR: Service 'web' failed to build: The command '/bin/sh -c autoconf' returned a non-zero code: 1
</code>```

Second error will happen when he hits RUN ./configure --enable-apache2= which apx it will trow this error:

```<code>Step 19/35 : RUN ./configure --enable-apache2=`which apxs`
 ---> Running in 1e9f870df22f
/bin/sh: 1: ./configure: not found
ERROR: Service 'web' failed to build: The command '/bin/sh -c ./configure --enable-apache2=`which apxs`' returned a non-zero code: 127
</code>```

Dockerfile configuration:

```<code>FROM ubuntu:16.04
FROM python:3.5
ENV PYTHONUNBUFFERED 1

RUN cat /etc/passwd
RUN cat /etc/group

RUN apt-get update && apt-get install -y \
    apache2 \
    apache2-dev \
    libapache2-mod-wsgi-py3 \
    autoconf \
    libssl-dev
RUN apt-get install -y openssl
RUN mkdir /var/run/sshd

ENV APACHE_RUN_USER www-data
ENV APACHE_RUN_GROUP www-data
ENV APACHE_LOG_DIR /var/log/apache2
ENV APACHE_LOCK_DIR /var/lock/apache2
ENV APACHE_PID_FILE /var/run/apache2.pid

# The Umich IAM copy of Cosign includes Apache 2.4 support
RUN wget https://github.com/umich-iam/cosign/archive/master.tar.gz
RUN tar xfz master.tar.gz
RUN cd cosign-master
RUN autoconf
RUN ./configure --enable-apache2=`which apxs`
RUN make
RUN make isntall
RUN mkdir -p /var/cosign/filter
RUN chown www-data:www-data /var/cosign/filter

RUN mkdir /code
WORKDIR /code
ADD requirements.txt /code/
RUN pip install -r requirements.txt
ADD . /code

EXPOSE 80

# Update the default apache site with the config we created.
COPY 000-default.conf /etc/apache2/sites-enabled/000-default.conf

RUN chown -R root:www-data /var/www
RUN chmod u+rwx,g+rx,o+rx /var/www
RUN find /var/www -type d -exec chmod u+rwx,g+rx,o+rx {} +
RUN find /var/www -type f -exec chmod u+rw,g+rw,o+r {} +

#essentially: CMD ["/usr/sbin/apachectl", "-D", "FOREGROUND"]
CMD ["/tmp/start.sh"]
</code>```

So is there a way I can fix this so I can install and configure this filter, thanks.

答:
Dockerd will run a new container for every instruction except FROM in Dockerfile, so

```<code>RUN cd cosign-master
RUN autoconf
RUN ./configure --enable-apache2=`which apxs`
</code>```

three commands will be executed in three standalone containers, so cd cosign-master command can NOT change the PWD environment for next containers.
You can use the absolute path or execute the associated commands in ONE container, which means in ONE instruction.

```<code>RUN cd cosign-master \
    && autoconf \
    && ./configure --enable-apache2=`which apxs` \
    && make \
    && make install
</code>```

PS:

should use one instruction to execute more commands to reduce the number of layers, because each instruction will generate a new layer.

should clean up the intermediate files or softwares to reduce the size of final image.

For examples:

```<code>FROM ubuntu:16.04
FROM python:3.5

ENV PYTHONUNBUFFERED=1 \
    APACHE_RUN_USER=www-data \
    APACHE_RUN_GROUP=www-data \
    APACHE_LOG_DIR=/var/log/apache2 \
    APACHE_LOCK_DIR=/var/lock/apache2 \
    APACHE_PID_FILE=/var/run/apache2.pid

RUN set -ex \
    && cat /etc/passwd \
    && cat /etc/group \
    && apt-get update \
    && export COMPILE_TOOLS="autoconf libssl-dev openssl" \
    && apt-get install -y \
               apache2 \
               apache2-dev \
               libapache2-mod-wsgi-py3 \
               ${COMPILE_TOOLS} \
    && wget https://github.com/umich-iam/cosign/archive/master.tar.gz -O /tmp/cosign-master.tar.gz \
    && tar xfz /tmp/cosign-master.tar.gz -C=/tmp \
    && cd /tmp/cosign-master \
    && autoconf \
    && ./configure --enable-apache2=$(which apxs) \
    && make \
    && make install \
    && mkdir -p /var/cosign/filter \
    && chown www-data:www-data /var/cosign/filter \
    && apt-get purge -y ${COMPILE_TOOLS} \
    && rm -rf /var/lib/apt/lists/* \
              /tmp/cosign-master.tar.gz \
              /tmp/cosign-master/*

WORKDIR /code

# The Umich IAM copy of Cosign includes Apache 2.4 support
COPY requirements.txt /code/
COPY . /code
# Update the default apache site with the config we created.
COPY 000-default.conf /etc/apache2/sites-enabled/000-default.conf

RUN mkdir /var/run/sshd \
    && pip install -r requirements.txt \
    && chown -R root:www-data /var/www \
    && chmod u+rwx,g+rx,o+rx /var/www \
    && find /var/www -type d -exec chmod u+rwx,g+rx,o+rx {} + \
    && find /var/www -type f -exec chmod u+rw,g+rw,o+r {} +

EXPOSE 80

#essentially: CMD ["/usr/sbin/apachectl", "-D", "FOREGROUND"]
CMD ["/tmp/start.sh"]
</code>```

This will:

reduce layers of your image from about 35 to just 9!

reduce the size of your image immensely, maybe only one third of your origin image.

maybe a little difficult to read :)

Hope this helps!

Body:
I need to install Cosign filter for Apacher server.

I need to use this cosign-filter from Confluence, but when my installation hits ./configure it trow as error:

ERROR: Unknown instruction: --ENABLE-APACHE2=/PATH/TO/APACHE2/BIN/APXS

Then i found out this installation for cosign filter with github repository, and because I use ubuntu16.04 in my Docker container I found it more useful, but in this installation I have a problem with autoconf so when he hits RUN autoconf it trows this error:

autoconf: error: no input file
ERROR: Service 'web' failed to build: The command '/bin/sh -c autoconf' returned a non-zero code: 1

Second error will happen when he hits RUN ./configure --enable-apache2= which apx it will trow this error:

Step 19/35 : RUN ./configure --enable-apache2=`which apxs`
 ---> Running in 1e9f870df22f
/bin/sh: 1: ./configure: not found
ERROR: Service 'web' failed to build: The command '/bin/sh -c ./configure --enable-apache2=`which apxs`' returned a non-zero code: 127

Dockerfile configuration:

FROM ubuntu:16.04
FROM python:3.5
ENV PYTHONUNBUFFERED 1

RUN cat /etc/passwd
RUN cat /etc/group

RUN apt-get update && apt-get install -y \
    apache2 \
    apache2-dev \
    libapache2-mod-wsgi-py3 \
    autoconf \
    libssl-dev
RUN apt-get install -y openssl
RUN mkdir /var/run/sshd

ENV APACHE_RUN_USER www-data
ENV APACHE_RUN_GROUP www-data
ENV APACHE_LOG_DIR /var/log/apache2
ENV APACHE_LOCK_DIR /var/lock/apache2
ENV APACHE_PID_FILE /var/run/apache2.pid

# The Umich IAM copy of Cosign includes Apache 2.4 support
RUN wget https://github.com/umich-iam/cosign/archive/master.tar.gz
RUN tar xfz master.tar.gz
RUN cd cosign-master
RUN autoconf
RUN ./configure --enable-apache2=`which apxs`
RUN make
RUN make isntall
RUN mkdir -p /var/cosign/filter
RUN chown www-data:www-data /var/cosign/filter

RUN mkdir /code
WORKDIR /code
ADD requirements.txt /code/
RUN pip install -r requirements.txt
ADD . /code

EXPOSE 80

# Update the default apache site with the config we created.
COPY 000-default.conf /etc/apache2/sites-enabled/000-default.conf

RUN chown -R root:www-data /var/www
RUN chmod u+rwx,g+rx,o+rx /var/www
RUN find /var/www -type d -exec chmod u+rwx,g+rx,o+rx {} +
RUN find /var/www -type f -exec chmod u+rw,g+rw,o+r {} +

#essentially: CMD ["/usr/sbin/apachectl", "-D", "FOREGROUND"]
CMD ["/tmp/start.sh"]

So is there a way I can fix this so I can install and configure this filter, thanks.

Body:
Dockerd will run a new container for every instruction except FROM in Dockerfile, so

RUN cd cosign-master
RUN autoconf
RUN ./configure --enable-apache2=`which apxs`

three commands will be executed in three standalone containers, so cd cosign-master command can NOT change the PWD environment for next containers.
You can use the absolute path or execute the associated commands in ONE container, which means in ONE instruction.

RUN cd cosign-master \
    && autoconf \
    && ./configure --enable-apache2=`which apxs` \
    && make \
    && make install

PS:

should use one instruction to execute more commands to reduce the number of layers, because each instruction will generate a new layer.

should clean up the intermediate files or softwares to reduce the size of final image.

For examples:

FROM ubuntu:16.04
FROM python:3.5

ENV PYTHONUNBUFFERED=1 \
    APACHE_RUN_USER=www-data \
    APACHE_RUN_GROUP=www-data \
    APACHE_LOG_DIR=/var/log/apache2 \
    APACHE_LOCK_DIR=/var/lock/apache2 \
    APACHE_PID_FILE=/var/run/apache2.pid

RUN set -ex \
    && cat /etc/passwd \
    && cat /etc/group \
    && apt-get update \
    && export COMPILE_TOOLS="autoconf libssl-dev openssl" \
    && apt-get install -y \
               apache2 \
               apache2-dev \
               libapache2-mod-wsgi-py3 \
               ${COMPILE_TOOLS} \
    && wget https://github.com/umich-iam/cosign/archive/master.tar.gz -O /tmp/cosign-master.tar.gz \
    && tar xfz /tmp/cosign-master.tar.gz -C=/tmp \
    && cd /tmp/cosign-master \
    && autoconf \
    && ./configure --enable-apache2=$(which apxs) \
    && make \
    && make install \
    && mkdir -p /var/cosign/filter \
    && chown www-data:www-data /var/cosign/filter \
    && apt-get purge -y ${COMPILE_TOOLS} \
    && rm -rf /var/lib/apt/lists/* \
              /tmp/cosign-master.tar.gz \
              /tmp/cosign-master/*

WORKDIR /code

# The Umich IAM copy of Cosign includes Apache 2.4 support
COPY requirements.txt /code/
COPY . /code
# Update the default apache site with the config we created.
COPY 000-default.conf /etc/apache2/sites-enabled/000-default.conf

RUN mkdir /var/run/sshd \
    && pip install -r requirements.txt \
    && chown -R root:www-data /var/www \
    && chmod u+rwx,g+rx,o+rx /var/www \
    && find /var/www -type d -exec chmod u+rwx,g+rx,o+rx {} + \
    && find /var/www -type f -exec chmod u+rw,g+rw,o+r {} +

EXPOSE 80

#essentially: CMD ["/usr/sbin/apachectl", "-D", "FOREGROUND"]
CMD ["/tmp/start.sh"]

This will:

reduce layers of your image from about 35 to just 9!

reduce the size of your image immensely, maybe only one third of your origin image.

maybe a little difficult to read :)

Hope this helps!


问:
mysql auto increment a character AA999 to AB001 with mysql
Is there a way to auto increment a character AA999 to AB001 with mysql?

table:test

ID   Name ---->  ID   NameId
1    Arun        15   AA999
2    Ram         30   AB001

答: Yes, this is possible. You need an int field to achieve this with auto_increment modifier and a stored function which can convert it into hexa varchar for representation. So, you cannot do this with a stored varchar-ish type, but you can do it with an int. If you really want to skip AB000, then it is more difficult, which involves the creation of a row just for this support, which seems too hacky for me.


问:
C# MVC Query String Encoding and Decoding
I want to encode and decode the url parameters.

calling function in javascript

```<code>var url = '/Demo/Demo?id=58';
$(location).attr('href', url)
</code>```

Current url parameter

www.example.com/Demo/Demo?id=58

code in Demo controller

```<code>public ActionResult Demo(int id)
{
   return view();
}
</code>```

i want the above url to be changed like the bolow line

www.example.com/Demo/Demo?id=Sff5f8ddg

So that the id value will be confidential. what is the best way to encode and decode.

Note: we calling method by anchor tag, ajax and jquery. Encoding and Decoding other than Base64

Is there any cryptography method other than Base64 enoding and decoding like encrypt in javascript and decrypt in C# method

答: Hello anand i think you want to create a temper proof Query string Download the code from github repository</p>

Body:
I want to encode and decode the url parameters.

calling function in javascript

var url = '/Demo/Demo?id=58';
$(location).attr('href', url)

Current url parameter

www.example.com/Demo/Demo?id=58

code in Demo controller

public ActionResult Demo(int id)
{
   return view();
}

i want the above url to be changed like the bolow line

www.example.com/Demo/Demo?id=Sff5f8ddg

So that the id value will be confidential. what is the best way to encode and decode.

Note: we calling method by anchor tag, ajax and jquery. Encoding and Decoding other than Base64

Is there any cryptography method other than Base64 enoding and decoding like encrypt in javascript and decrypt in C# method


问:
Java libGDX Game - Animation doesn't flip
I have a animation which i want to flip to the left if key LEFT is pressed, but it doesnt stay flipped. It only flips like 1 frame then turns back again.

Here is my GameScreen where i draw everything:

```<code>public class GameScreen extends ScreenManager{
    //For the view of the game and the rendering
    private SpriteBatch batch;
    private OrthographicCamera cam;

    //DEBUG
    private Box2DDebugRenderer b2dr;

    //World, Player and so on
    private GameWorld world;
    private Player player;
    private Ground ground;

    //player animations
    private TextureRegion currFrame;

    public static float w, h;

    public GameScreen(Game game) {
        super(game);
        //vars
        w = Gdx.graphics.getWidth();
        h = Gdx.graphics.getHeight();

        //view and rendering
        batch = new SpriteBatch();
        cam = new OrthographicCamera();
        cam.setToOrtho(false, w/2, h/2);

        //debug
        b2dr = new Box2DDebugRenderer();

        //world, bodies ...
        world = new GameWorld();
        player = new Player(world);
        ground = new Ground(world);

    }

    @Override
    public void pause() {

    }

    @Override
    public void show() {

    }

    @Override
    public void render(float delta) {
        //clearing the screen
        Gdx.gl.glClearColor(0, 0, 0, 1);
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

        //updating
        update(Gdx.graphics.getDeltaTime());
        player.stateTime += Gdx.graphics.getDeltaTime();

        //render
        batch.setProjectionMatrix(cam.combined);

        currFrame = Player.anim.getKeyFrame(Player.stateTime, true);

        batch.begin();
        batch.draw(currFrame, Player.body.getPosition().x * PPM - 64, Player.getBody().getPosition().y * PPM-  72);
        batch.end();

        //debug
        b2dr.render(GameWorld.getWorld(), cam.combined.scl(PPM));

    }

    @Override
    public void resize(int width, int height) {

    }

    @Override
    public void hide() {

    }

    @Override
    public void dispose() {

    }

    @Override
    public void onKlick(float delta) {

    }

    public void update(float delta){
        world.update(delta);
        updateCam(delta);
        Player.keyInput(delta);
        System.out.println("X-POS" + Player.getBody().getPosition().x);
        System.out.println("Y-POS" + Player.getBody().getPosition().y);
    }

    public void updateCam(float delta){
        Vector3 pos = cam.position;
        pos.x = Player.getBody().getPosition().x * PPM;
        pos.y = Player.getBody().getPosition().y * PPM;

        cam.position.set(pos);

        cam.update();
    }

}
</code>```

and this is the Player class where the animation is:

```<code>public class Player {
    public static Body body;
    public static BodyDef def;
    private FixtureDef fd;

    //textures
    public static Texture texture;
    public static Sprite sprite;
    public static TextureRegion[][] region;
    public static TextureRegion[] idle;
    public static Animation<TextureRegion> anim;
    public static float stateTime;

    //set form
    private PolygonShape shape;

    private GameScreen gs;

    public Player(GameWorld world){
        texture = new Texture(Gdx.files.internal("player/char_animation_standing.png"));
        region = TextureRegion.split(texture, texture.getWidth() / 3, texture.getHeight() / 2);
        idle = new TextureRegion[6];
        int index = 0;

        for(int i = 0; i < 2; i++){
            for(int j = 0; j < 3; j++){
                sprite = new Sprite(region[i][j]);
                idle[index++] = sprite;
            }
        }

        anim = new Animation<TextureRegion>(1 / 8f, idle);

        stateTime = 0f;

        def = new BodyDef();
        def.fixedRotation = true;
        def.position.set(gs.w / 4, gs.h / 4);
        def.type = BodyType.DynamicBody;

        body = world.getWorld().createBody(def);

        shape = new PolygonShape();
        shape.setAsBox(32 / 2 / PPM, 64/ 2 / PPM);

        fd = new FixtureDef();
        fd.shape = shape;
        fd.density = 30;

        body.createFixture(fd);
        shape.dispose();
    }

    public static Body getBody() {
        return body;
    }

    public static BodyDef getDef() {
        return def;
    }

    public static Texture getTexture() {
        return texture;
    }

    public static void keyInput(float delta){
        int horizonForce = 0;
        if(Gdx.input.isKeyJustPressed(Input.Keys.UP)){
            body.applyLinearImpulse(0, 300f, body.getWorldCenter().x, body.getWorldCenter().y, true);
            //body.applyForceToCenter(0, 1200f, true);
            System.out.println("PRESSED");
        }
        if(Gdx.input.isKeyPressed(Input.Keys.LEFT)){
            horizonForce -= 1;
            sprite.flip(!sprite.isFlipX(), sprite.isFlipY());
        }

        if(Gdx.input.isKeyPressed(Input.Keys.RIGHT)){
            horizonForce += 1;
        }

        body.setLinearVelocity(horizonForce * 20, body.getLinearVelocity().y);
    }

}
</code>```

thank you in advance and any answer is appreciated :D

答:
Your sprite variable contain only one frame at the time of pressing left key. So, it flip that current sprite of your animation frame.
To solve the Problem you have to flip all the animation frame on pressing the left key.</p>

Body:
I have a animation which i want to flip to the left if key LEFT is pressed, but it doesnt stay flipped. It only flips like 1 frame then turns back again.

Here is my GameScreen where i draw everything:

public class GameScreen extends ScreenManager{
    //For the view of the game and the rendering
    private SpriteBatch batch;
    private OrthographicCamera cam;

    //DEBUG
    private Box2DDebugRenderer b2dr;

    //World, Player and so on
    private GameWorld world;
    private Player player;
    private Ground ground;

    //player animations
    private TextureRegion currFrame;

    public static float w, h;

    public GameScreen(Game game) {
        super(game);
        //vars
        w = Gdx.graphics.getWidth();
        h = Gdx.graphics.getHeight();

        //view and rendering
        batch = new SpriteBatch();
        cam = new OrthographicCamera();
        cam.setToOrtho(false, w/2, h/2);

        //debug
        b2dr = new Box2DDebugRenderer();

        //world, bodies ...
        world = new GameWorld();
        player = new Player(world);
        ground = new Ground(world);

    }

    @Override
    public void pause() {

    }

    @Override
    public void show() {

    }

    @Override
    public void render(float delta) {
        //clearing the screen
        Gdx.gl.glClearColor(0, 0, 0, 1);
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

        //updating
        update(Gdx.graphics.getDeltaTime());
        player.stateTime += Gdx.graphics.getDeltaTime();

        //render
        batch.setProjectionMatrix(cam.combined);

        currFrame = Player.anim.getKeyFrame(Player.stateTime, true);

        batch.begin();
        batch.draw(currFrame, Player.body.getPosition().x * PPM - 64, Player.getBody().getPosition().y * PPM-  72);
        batch.end();

        //debug
        b2dr.render(GameWorld.getWorld(), cam.combined.scl(PPM));

    }

    @Override
    public void resize(int width, int height) {

    }

    @Override
    public void hide() {

    }

    @Override
    public void dispose() {

    }

    @Override
    public void onKlick(float delta) {

    }

    public void update(float delta){
        world.update(delta);
        updateCam(delta);
        Player.keyInput(delta);
        System.out.println("X-POS" + Player.getBody().getPosition().x);
        System.out.println("Y-POS" + Player.getBody().getPosition().y);
    }

    public void updateCam(float delta){
        Vector3 pos = cam.position;
        pos.x = Player.getBody().getPosition().x * PPM;
        pos.y = Player.getBody().getPosition().y * PPM;

        cam.position.set(pos);

        cam.update();
    }

}

and this is the Player class where the animation is:

public class Player {
    public static Body body;
    public static BodyDef def;
    private FixtureDef fd;

    //textures
    public static Texture texture;
    public static Sprite sprite;
    public static TextureRegion[][] region;
    public static TextureRegion[] idle;
    public static Animation<TextureRegion> anim;
    public static float stateTime;

    //set form
    private PolygonShape shape;

    private GameScreen gs;

    public Player(GameWorld world){
        texture = new Texture(Gdx.files.internal("player/char_animation_standing.png"));
        region = TextureRegion.split(texture, texture.getWidth() / 3, texture.getHeight() / 2);
        idle = new TextureRegion[6];
        int index = 0;

        for(int i = 0; i < 2; i++){
            for(int j = 0; j < 3; j++){
                sprite = new Sprite(region[i][j]);
                idle[index++] = sprite;
            }
        }

        anim = new Animation<TextureRegion>(1 / 8f, idle);

        stateTime = 0f;

        def = new BodyDef();
        def.fixedRotation = true;
        def.position.set(gs.w / 4, gs.h / 4);
        def.type = BodyType.DynamicBody;

        body = world.getWorld().createBody(def);

        shape = new PolygonShape();
        shape.setAsBox(32 / 2 / PPM, 64/ 2 / PPM);

        fd = new FixtureDef();
        fd.shape = shape;
        fd.density = 30;

        body.createFixture(fd);
        shape.dispose();
    }

    public static Body getBody() {
        return body;
    }

    public static BodyDef getDef() {
        return def;
    }

    public static Texture getTexture() {
        return texture;
    }

    public static void keyInput(float delta){
        int horizonForce = 0;
        if(Gdx.input.isKeyJustPressed(Input.Keys.UP)){
            body.applyLinearImpulse(0, 300f, body.getWorldCenter().x, body.getWorldCenter().y, true);
            //body.applyForceToCenter(0, 1200f, true);
            System.out.println("PRESSED");
        }
        if(Gdx.input.isKeyPressed(Input.Keys.LEFT)){
            horizonForce -= 1;
            sprite.flip(!sprite.isFlipX(), sprite.isFlipY());
        }

        if(Gdx.input.isKeyPressed(Input.Keys.RIGHT)){
            horizonForce += 1;
        }

        body.setLinearVelocity(horizonForce * 20, body.getLinearVelocity().y);
    }

}

thank you in advance and any answer is appreciated :D


问:
Upper case HTML tags in omni completion for vim
At the moment I have to write a lot of HTML stuff (unfortunately). Vim is my favorite editor/IDE for almost everything. I'm using the 'omni completion' plugin for code completion, which works really fine with python and php. It also works with HTML, however it uses upper case HTML tags which is really annoying.

Is there a way to tell vim or omni completion that upper case HTML are completely of limits.

答: I have just found why the same issue has occured in my setup. I used to believe that it must be one of the remote plugins. In fact, it was the ignorecase option. It does not matter if you have enabled smartcase. Simply run se noic or set noignorecase.


问:
Using base class methods to initialize derived class members
Is it legal? If so, do you consider it as good coding practice?

I want to do something like this (nonessential details are not shown):

```<code>class ItemStorage {
    int size() const;
};

class SpecialStorage : public ItemStorage  {
public:
    SpecialStorage (...) : ItemStorage(...), items(ItemStorage::size()) {...}
private:
    int items;
};
</code>```

I am pretty sure that it is OK if the method size is not virtual. What if it is virtual and the derived class doesn't overwrite it?

答:
The general rule is that, during initialization, you must not access uninitialized parts of the object. As ItemStorage is already initialized when items gets initialized, calling size is indeed fine.

Even if size was virtual, and even if it was overwritten, it still would be fine: it would just call the base version (i.e. virtual methods only bind to the level which is under construction).

Body:
Is it legal? If so, do you consider it as good coding practice?

I want to do something like this (nonessential details are not shown):

class ItemStorage {
    int size() const;
};

class SpecialStorage : public ItemStorage  {
public:
    SpecialStorage (...) : ItemStorage(...), items(ItemStorage::size()) {...}
private:
    int items;
};

I am pretty sure that it is OK if the method size is not virtual. What if it is virtual and the derived class doesn't overwrite it?


问:
Services in Angular
I'm quite new with Angular and I am trying to bring some structure in my website I am building with Angular.

Now I have a Controller where I have some functions which I use on multiple pages. I have heard that I could better make a service out of these functions. How am I able to do this?

This is my Controller in current state:
How can I make a service from $scope.city function and $scope.specials function?

```<code>app.controller('DataCtrl', function($scope,$http){
  $scope.city = function(){
    $scope.items = [];

    $http.get('/getdata').then(function(d){
      $scope.items = d.data;
      $scope.selectedItem = $scope.items[0];
    },function(err){
      console.log(err);
    });
  };

  /* Function for specialization data */
  $scope.specials = function(){
    $scope.special = [];

    $http.get('/specialdata').then(function(d){
      $scope.special = d.data[0];
    },function(err){
      console.log(err);
    });
  };
});
</code>```

答:
Define a service, Here is an example</p>

```<code>//Service.js
(function () {
    angular.module('myApp')
    .service('myService', service);

    service.$inject = ['$http']
    function service($http) {
        this.specialdata = function () {
            return $http.get('/specialdata')
        }
    }
})();

//Controller.js
(function () {
    angular.module('myApp')
    .controller('DataCtrl', DataCtrl);

    DataCtrl.$inject = ['$scope', 'myService']
    function DataCtrl($scope, myService) {
        /* Function for specialization data */
        $scope.specials = function () {
            $scope.special = [];

            myService.specialdata().then(function (d) {
                $scope.special = d.data[0];
            }, function (err) {
                console.log(err);
            });
        };
    }
})();
</code>```

Title: Services in Angular

Body:
I'm quite new with Angular and I am trying to bring some structure in my website I am building with Angular.

Now I have a Controller where I have some functions which I use on multiple pages. I have heard that I could better make a service out of these functions. How am I able to do this?

This is my Controller in current state:
How can I make a service from $scope.city function and $scope.specials function?

app.controller('DataCtrl', function($scope,$http){
  $scope.city = function(){
    $scope.items = [];

    $http.get('/getdata').then(function(d){
      $scope.items = d.data;
      $scope.selectedItem = $scope.items[0];
    },function(err){
      console.log(err);
    });
  };

  /* Function for specialization data */
  $scope.specials = function(){
    $scope.special = [];

    $http.get('/specialdata').then(function(d){
      $scope.special = d.data[0];
    },function(err){
      console.log(err);
    });
  };
});

Body:
Define a service, Here is an example

//Service.js
(function () {
    angular.module('myApp')
    .service('myService', service);

    service.$inject = ['$http']
    function service($http) {
        this.specialdata = function () {
            return $http.get('/specialdata')
        }
    }
})();

//Controller.js
(function () {
    angular.module('myApp')
    .controller('DataCtrl', DataCtrl);

    DataCtrl.$inject = ['$scope', 'myService']
    function DataCtrl($scope, myService) {
        /* Function for specialization data */
        $scope.specials = function () {
            $scope.special = [];

            myService.specialdata().then(function (d) {
                $scope.special = d.data[0];
            }, function (err) {
                console.log(err);
            });
        };
    }
})();


问:
Handler processing failed; nested exception is java.lang.StackOverflowError
I created a service Restful With Spring framework , and I'm trying to include a method a call to Selenium Java, with the driver Google Chrome , but to create the object  WebDriver driver = new ChromeDriver ();

This me generates a exception :

```<code>org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.StackOverflowError
    org.springframework.web.servlet.DispatcherServlet.triggerAfterCompletionWithError(DispatcherServlet.java:1302)
    org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:977)
    org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:968)
    org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:859)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
    org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:844)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
causa raíz

java.lang.StackOverflowError
    java.lang.Exception.<init>(Exception.java:102)
    java.lang.ReflectiveOperationException.<init>(ReflectiveOperationException.java:89)
    java.lang.reflect.InvocationTargetException.<init>(InvocationTargetException.java:72)
    sun.reflect.GeneratedMethodAccessor95.invoke(Unknown Source)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    java.lang.reflect.Method.invoke(Method.java:497)
    org.json.JSONObject.populateMap(JSONObject.java:1015)
    org.json.JSONObject.<init>(JSONObject.java:279)
    org.json.JSONObject.wrap(JSONObject.java:1527)
    org.json.JSONObject.populateMap(JSONObject.java:1017)
    org.json.JSONObject.<init>(JSONObject.java:279)
    org.json.JSONObject.wrap(JSONObject.java:1527)
    org.json.JSONObject.populateMap(JSONObject.java:1017)
    org.json.JSONObject.<init>(JSONObject.java:279)
    org.json.JSONObject.wrap(JSONObject.java:1527)
</code>```

Independent in a main class runs smoothly , but I require it from a service Restful

答:
I spent few hours struggling with stackoverflow error ... hope this helps someone

i made a silly mistake

please see below code snippet :-

Incorrect code :-

```<code>Map abcWithKey = new HashMap<>();

abcWithKey.put("key_1", abcWithKey);
</code>```

Correct Code :-

```<code>Map abcWithKey = new HashMap<>();

abcWithKey.put("key_1", abc);
</code>```

where abc is a map , so instead of adding abc(different map) i was adding same map recursively.

Body:
I created a service Restful With Spring framework , and I'm trying to include a method a call to Selenium Java, with the driver Google Chrome , but to create the object  WebDriver driver = new ChromeDriver ();

This me generates a exception :

org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.StackOverflowError
    org.springframework.web.servlet.DispatcherServlet.triggerAfterCompletionWithError(DispatcherServlet.java:1302)
    org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:977)
    org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:968)
    org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:859)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
    org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:844)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
causa raíz

java.lang.StackOverflowError
    java.lang.Exception.<init>(Exception.java:102)
    java.lang.ReflectiveOperationException.<init>(ReflectiveOperationException.java:89)
    java.lang.reflect.InvocationTargetException.<init>(InvocationTargetException.java:72)
    sun.reflect.GeneratedMethodAccessor95.invoke(Unknown Source)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    java.lang.reflect.Method.invoke(Method.java:497)
    org.json.JSONObject.populateMap(JSONObject.java:1015)
    org.json.JSONObject.<init>(JSONObject.java:279)
    org.json.JSONObject.wrap(JSONObject.java:1527)
    org.json.JSONObject.populateMap(JSONObject.java:1017)
    org.json.JSONObject.<init>(JSONObject.java:279)
    org.json.JSONObject.wrap(JSONObject.java:1527)
    org.json.JSONObject.populateMap(JSONObject.java:1017)
    org.json.JSONObject.<init>(JSONObject.java:279)
    org.json.JSONObject.wrap(JSONObject.java:1527)

Independent in a main class runs smoothly , but I require it from a service Restful

Body:
I spent few hours struggling with stackoverflow error ... hope this helps someone

i made a silly mistake

please see below code snippet :-

Incorrect code :-

Map abcWithKey = new HashMap<>();

abcWithKey.put("key_1", abcWithKey);

Correct Code :-

Map abcWithKey = new HashMap<>();

abcWithKey.put("key_1", abc);

where abc is a map , so instead of adding abc(different map) i was adding same map recursively.


问:
What are Promotional Text and Subtitle in iTunesConnection?
Promotional Text and Subtitle are the new feature in iTuneconnection which is available in iOS 11.0 or above. Subtitle is optional. But Promotional Text is not mentioned as optional. Which text we need to write as Promotional Text. Is it for only current app or any other apps using same developer account?</p>

答: It's important to note that the Promotional Text can be edited at any time, but, from now on, you are unable to change the App Description without submitting a new version of the app.</p>


问:
How to delete every third line on Notepad++?
I have text on new lines like so:

```<code>tom
tim
john
will
tod
hello
test
ttt
three
</code>```

I want to delete every third line so using the example above I want to remove: john,hello,three

I know this calls for some regex, but I am not the best with it!

What I tried:

```<code>Search: ([^\n]*\n?){3} //3 in my head to remove every third
Replace: $1
</code>```

The others I tried were just attempts with \n\r etc. Again, not the best with regex. The above attempt I thought was kinda close.

答:
Since the OP says Sahil's answer "worked like a charm" I'll assume the text in notepad++ ended with a newline character.  Otherwise, Sahil's and Toto's answers will fail to match the final set of words.

Sahil's pattern: (.*?)\n(.*?)\n(.*)\n takes 79 steps *if the text ends in \n; otherwise 112 steps and fails.

His replacement expression needlessly uses two capture group references.

Toto's pattern: ((?:[^\r\n]+\R){2})[^\r\n]+\R takes 39 steps *if the text ends in \n;  otherwise 173 steps and fails.
His replacement expression uses one capture group reference.

My suggested pattern will take only 25 steps and uses no capture groups.
Your text is a series of non-white characters followed by white characters and so the following is the shortest, most accurate pattern which provides maximum speed:

```<code>\S+\s+\S+\s+\K\S+\s*
</code>```

This pattern should be paired with an empty replacement.

\S means "non-white-space character"

\s means "white-space character"

+ means one or more of the preceding match

* means zero or more of the preceding match

\K means Keep the match starting from here

The * on the final \s allows the final 3 lines of text to conclude without a trailing newline character.  When doing this kind of operation on a big batch of text, it is important to be sure that the replacement is working properly on the whole text and no undesired substrings remain.

While I'm sure you've long forgotten about this regex task, it is important that future readers benefit from learning the best way to achieve the desired result.

Body:
I have text on new lines like so:

tom
tim
john
will
tod
hello
test
ttt
three

I want to delete every third line so using the example above I want to remove: john,hello,three

I know this calls for some regex, but I am not the best with it!

What I tried:

Search: ([^\n]*\n?){3} //3 in my head to remove every third
Replace: $1

The others I tried were just attempts with \n\r etc. Again, not the best with regex. The above attempt I thought was kinda close.

Body:
Since the OP says Sahil's answer "worked like a charm" I'll assume the text in notepad++ ended with a newline character.  Otherwise, Sahil's and Toto's answers will fail to match the final set of words.

Sahil's pattern: (.*?)\n(.*?)\n(.*)\n takes 79 steps *if the text ends in \n; otherwise 112 steps and fails.

His replacement expression needlessly uses two capture group references.

Toto's pattern: ((?:[^\r\n]+\R){2})[^\r\n]+\R takes 39 steps *if the text ends in \n;  otherwise 173 steps and fails.
His replacement expression uses one capture group reference.

My suggested pattern will take only 25 steps and uses no capture groups.
Your text is a series of non-white characters followed by white characters and so the following is the shortest, most accurate pattern which provides maximum speed:

\S+\s+\S+\s+\K\S+\s*

This pattern should be paired with an empty replacement.

\S means "non-white-space character"

\s means "white-space character"

+ means one or more of the preceding match

* means zero or more of the preceding match

\K means Keep the match starting from here

The * on the final \s allows the final 3 lines of text to conclude without a trailing newline character.  When doing this kind of operation on a big batch of text, it is important to be sure that the replacement is working properly on the whole text and no undesired substrings remain.

While I'm sure you've long forgotten about this regex task, it is important that future readers benefit from learning the best way to achieve the desired result.


问:
How to pass parameters to maven?
I am trying to call a parameter via maven command.
This is how the definition of it looks like:

```<code>/**
 *
 * @parameter default-value=false
 */
private boolean myBool;
</code>```

What would be the right way to set it via maven command line?

```<code><groupid>:<artifactid>:<version>:<goal> -myBool=true
</code>```

does not work

答:
You should be able to set it as a property (see Maven Command Line Options)

```<code>mvn -DmyBool=true <groupid>:<artifactid>:<version>:<goal>
</code>```

As noted by Diego Victor De Jesus in the comments:

if it is a boolean parameter that should be set to true, you can do:

```<code>mvn -DmyBool <groupid>:<artifactid>:<version>:<goal>
</code>```

Title: How to pass parameters to maven?

Body:
I am trying to call a parameter via maven command.
This is how the definition of it looks like:

/**
 *
 * @parameter default-value=false
 */
private boolean myBool;

What would be the right way to set it via maven command line?

<groupid>:<artifactid>:<version>:<goal> -myBool=true

does not work

Body:
You should be able to set it as a property (see Maven Command Line Options)

mvn -DmyBool=true <groupid>:<artifactid>:<version>:<goal>

As noted by Diego Victor De Jesus in the comments:

if it is a boolean parameter that should be set to true, you can do:

mvn -DmyBool <groupid>:<artifactid>:<version>:<goal>