问:
bundle exception in eclipse upgrade 4.5.2 to 4.10
I upgraded my eclipse RCP based application from 4.5.2 to 4.10. I setup target platform and pointed it to new eclipse plugin directory as well.
And when I try to launch the application, it shows below errors.
Can somebody suggest any check list which I should follow for eclipse based applications upgrade and what am I missing here?

!ENTRY org.eclipse.core.runtime 4 0 2019-05-30 06:33:32.513
  !MESSAGE FrameworkEvent ERROR
  !STACK 0
  org.osgi.framework.BundleException: Could not resolve module: org.eclipse.core.runtime [3]
    Unresolved requirement: Require-Bundle: javax.inject; bundle-version="1.0.0"; visibility:="reexport"; resolution:="optional"
    Unresolved requirement: Require-Bundle: org.eclipse.core.jobs; bundle-version="[3.10.0,4.0.0)"; visibility:="reexport"
  at org.eclipse.osgi.container.Module.start(Module.java:451)
      at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1783)
      at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1763)
      at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1725)
      at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1656)
      at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1)
      at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:233)
      at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:343)
  !ENTRY org.eclipse.core.runtime 2 0 2019-05-30 06:33:32.513
  !MESSAGE Could not resolve module: org.eclipse.core.runtime [3]
    Unresolved requirement: Require-Bundle: javax.inject; bundle-version="1.0.0"; visibility:="reexport"; resolution:="optional"
    Unresolved requirement: Require-Bundle: org.eclipse.core.jobs; bundle-version="[3.10.0,4.0.0)"; visibility:="reexport"
  !ENTRY org.eclipse.osgi 4 0 2019-05-30 06:33:32.529
  !MESSAGE Application error
  !STACK 1
  java.lang.IllegalStateException: Unable to acquire application service. Ensure that the org.eclipse.core.runtime bundle is resolved and started (see config.ini).
      at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:81)
      at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:400)
      at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:659)
      at org.eclipse.equinox.launcher.Main.basicRun(Main.java:595)
      at org.eclipse.equinox.launcher.Main.run(Main.java:1501)
      at org.eclipse.equinox.launcher.Main.main(Main.java:1474)

答:
Your log suggests problems with the javax.inject and org.eclipse.core.jobs plug-ins.

In the 'Run > Run Configurations...' dialog find your RCP in the 'Eclipse Application' section.

Use the 'Add Required Plug-ins' button to add all plug-ins your RCP uses. This will change between releases.

Use the 'Validate Plug-ins' button to validate that the selected plug-ins set is reasonable.


来源: stackexchange

问:
How to show each of the selected value from single select option in input tag
I am new to javascript and I want to use the select option to list each selected value in the input tag.

I have tried to use javascript to show the selected value but when I select for the second time the first value dismiss and show the second selected. I was expected to show each selected value in the input tag separately without dismissing other previous selected.

function getSelectedValue() {
  var selectedValue = document.getElementById("list").value;
  document.getElementById("myValues").innerHTML = selectedValue;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><select name="" onchange="getSelectedValue();" class="form-control" id="list">
  <option value="Option1">Option1</option>
  <option value="Option2">Option2</option>
  <option value="Option3">Option3</option>
  <option value="Option4">Option4</option>
</select>
<input type="text" name="value[]" id="myValue" value=""></code>```

I expected the output of

<input type="text" name="value[]" id="myValue" value="Option1">

<input type="text" name="value[]" id="myValue" value="Option3">

thus in the input should show

Option1
  Option3

答:
You can add a new input to the div with the selected value

var selectedValues = [];
function getSelectedValue() {
  var selectedValue = document.getElementById("list").value;
  if( !selectedValues.includes(selectedValue) ){
    selectedValues.push(selectedValue);

    document.getElementById("myValues").innerHTML +=
    '<input type="text" name="value[]" id="myValue" value="' + selectedValue + '">
';
  }
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><select name="" onchange="getSelectedValue();" class="form-control" id="list">
  <option value="Option1">Option1</option>
  <option value="Option2">Option2</option>
  <option value="Option3">Option3</option>
  <option value="Option4">Option4</option>
</select>
<div id="myValues">
</div></code>```

ContentLicense: CC BY-SA 4.0

Body:
I am new to javascript and I want to use the select option to list each selected value in the input tag.

I have tried to use javascript to show the selected value but when I select for the second time the first value dismiss and show the second selected. I was expected to show each selected value in the input tag separately without dismissing other previous selected.

function getSelectedValue() {
  var selectedValue = document.getElementById("list").value;
  document.getElementById("myValues").innerHTML = selectedValue;
}

<select name="" onchange="getSelectedValue();" class="form-control" id="list">
  <option value="Option1">Option1</option>
  <option value="Option2">Option2</option>
  <option value="Option3">Option3</option>
  <option value="Option4">Option4</option>
</select>
<input type="text" name="value[]" id="myValue" value="">

I expected the output of

<input type="text" name="value[]" id="myValue" value="Option1">

<input type="text" name="value[]" id="myValue" value="Option3">

thus in the input should show

Option1
  Option3

Body:
You can add a new input to the div with the selected value

var selectedValues = [];
function getSelectedValue() {
  var selectedValue = document.getElementById("list").value;
  if( !selectedValues.includes(selectedValue) ){
    selectedValues.push(selectedValue);

    document.getElementById("myValues").innerHTML +=
    '<input type="text" name="value[]" id="myValue" value="' + selectedValue + '"></br>';
  }
}

<select name="" onchange="getSelectedValue();" class="form-control" id="list">
  <option value="Option1">Option1</option>
  <option value="Option2">Option2</option>
  <option value="Option3">Option3</option>
  <option value="Option4">Option4</option>
</select>
<div id="myValues">
</div>


问:
R Caret Package Error - At least one of the class levels is not a valid R variable name
I am receiving the following error in R when stacking using the caret package.

"Error: At least one of the class levels is not a valid R variable name; This will cause errors when class probabilities are generated because the variables names will be converted to  not5, X5sets . Please use factor levels that can be used as valid R variable names  (see ?make.names for help)."

The below is the code I am trying to run.

```<code>library(caretEnsemble)
control <- trainControl(method="repeatedcv", number=10, repeats=3, savePredictions=TRUE, classProbs=TRUE)
algorithmList <- c('rpart', 'knn', 'svmRadial')
set.seed(222)
models <- caretList(Tsets ~ MatchSurface + MatchRound + AgeDiff + SameHand + HeightDiff, data=up_sample, trControl=control, methodList=algorithmList)
results <- resamples(models)
</code>```

When I remove classProbs=TRUE, the code runs but I want to keep this as there is further code I am trying to run after this which requires it. All of my variables are factors or integers and I have changed all classes so they do not have "0"'s and "1"s. Therefore I cant figure out why the code wont run.

I have attached a picture of the data structure below. Would be great if anyone had some advice.

答:
When caretList() runs a tree-based model (here rpart, but also applies to random forests), it converts the factor levels into variables which are used to split the tree.
For these variables, names starting with a number are not allowed nor that they contain spaces.
So for each of these variables, you can convert the level names to valid labels with the following code.</p>

```<code>up_sample %>%
  mutate(Tsets = factor(Tsets,
                        labels = make.names(levels(Tsets))))
</code>```

Body:
I am receiving the following error in R when stacking using the caret package.

"Error: At least one of the class levels is not a valid R variable name; This will cause errors when class probabilities are generated because the variables names will be converted to  not5, X5sets . Please use factor levels that can be used as valid R variable names  (see ?make.names for help)."

The below is the code I am trying to run.

library(caretEnsemble)
control <- trainControl(method="repeatedcv", number=10, repeats=3, savePredictions=TRUE, classProbs=TRUE)
algorithmList <- c('rpart', 'knn', 'svmRadial')
set.seed(222)
models <- caretList(Tsets ~ MatchSurface + MatchRound + AgeDiff + SameHand + HeightDiff, data=up_sample, trControl=control, methodList=algorithmList)
results <- resamples(models)

When I remove classProbs=TRUE, the code runs but I want to keep this as there is further code I am trying to run after this which requires it. All of my variables are factors or integers and I have changed all classes so they do not have "0"'s and "1"s. Therefore I cant figure out why the code wont run.

I have attached a picture of the data structure below. Would be great if anyone had some advice.

Body:
When caretList() runs a tree-based model (here rpart, but also applies to random forests), it converts the factor levels into variables which are used to split the tree.
For these variables, names starting with a number are not allowed nor that they contain spaces.
So for each of these variables, you can convert the level names to valid labels with the following code.

up_sample %>%
  mutate(Tsets = factor(Tsets,
                        labels = make.names(levels(Tsets))))


问:
jQuery DataTables column definition for multiple data fields
I'm using jQuery DataTables with server side processing for my list.
But I have a problem: I want to display more than one column data from database in the same column (header). So, how can I define my column?

```<code><?php
$columns = array(
    array( 'db' => 'ass_id', 'dt' => 0 ),
    array( 'db' => 'ass_customer_id',  'dt' => 1 ),
    array( 'db' => 'ass_customer_id',   'dt' => 2 ),
    array( 'db' => 'ass_id', 'dt' => 3 ),
    array( 'db' => 'ass_id', 'dt' => 4 ),
    array( 'db' => 'ass_id', 'dt' => 5 ),
    array( 'db' => 'ass_id', 'dt' => 6 ),
    array( 'db' => 'ass_id', 'dt' => 7 ),
    array( 'db' => 'ass_rec_letter_sent', 'dt' => 8 )
);
?>
</code>```

In above code, I defined 8-th column as ass_rec_letter_sent but in this same column I have 2 more data fields to display, so I can't understand how can I do this.

答:
You may employ columns.render option for that purpose. It accepts your cell data, cell data type, entire row data source and row number/column number as arguments.

So, for your target column you may make up combined field that will contain as many fields as needed referred by corresponding property name.

For instance, if the source data for each row of your table is an object, like:

```<code>{id: 'someid', name: 'somename', phone: 'somephone', mail: 'somemail'}
</code>```

And you would like to merge phone and mail into combined column contacts, you may simply do:

```<code>$('#example').DataTable({
  ...
  columns: [
    {title: 'contacts', data: null, render: (data, type, row, meta) => `phone: ${row.phone}, e-mail: ${row.mail}`}
  ]
});
</code>```

Complete demo of this concept you may find below:

//data sample that mimic response from your back-end PHP script
const srcData = [
  {id: 1, name: 'Steve Rogers', phone: '+1987270123512', mail: 'cap@avengers.org'},
  {id: 2, name: 'Tony Stark', phone: '+1987987235143', mail: 'ironman@avengers.org'},
  {id: 3, name: 'Peter Parker', phone: '+1698701245121', mail: 'spidey@avengers.org'}
];

//datatables initialization
const dataTable = $('#example').DataTable({
  dom: 't',
  data: srcData,
  columns: [
    {title: 'id', data: 'id'},
    {title: 'name', data: 'name'},
    {title: 'contacts', data: null, render: (data, type, row, meta) => `phone: ${row.phone}, e-mail: ${row.mail}`}
  ]
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><!doctype html>
<html>
<head>
  <script type="application/javascript" src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
  <script type="application/javascript" src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>

  <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css">
</head>
<body>
  <table id="example"></table>
</body>
</html></code>```

Body:
I'm using jQuery DataTables with server side processing for my list.
But I have a problem: I want to display more than one column data from database in the same column (header). So, how can I define my column?

<?php
$columns = array(
    array( 'db' => 'ass_id', 'dt' => 0 ),
    array( 'db' => 'ass_customer_id',  'dt' => 1 ),
    array( 'db' => 'ass_customer_id',   'dt' => 2 ),
    array( 'db' => 'ass_id', 'dt' => 3 ),
    array( 'db' => 'ass_id', 'dt' => 4 ),
    array( 'db' => 'ass_id', 'dt' => 5 ),
    array( 'db' => 'ass_id', 'dt' => 6 ),
    array( 'db' => 'ass_id', 'dt' => 7 ),
    array( 'db' => 'ass_rec_letter_sent', 'dt' => 8 )
);
?>

In above code, I defined 8-th column as ass_rec_letter_sent but in this same column I have 2 more data fields to display, so I can't understand how can I do this.

Body:
You may employ columns.render option for that purpose. It accepts your cell data, cell data type, entire row data source and row number/column number as arguments.

So, for your target column you may make up combined field that will contain as many fields as needed referred by corresponding property name.

For instance, if the source data for each row of your table is an object, like:

{id: 'someid', name: 'somename', phone: 'somephone', mail: 'somemail'}

And you would like to merge phone and mail into combined column contacts, you may simply do:

$('#example').DataTable({
  ...
  columns: [
    {title: 'contacts', data: null, render: (data, type, row, meta) => `phone: ${row.phone}, e-mail: ${row.mail}`}
  ]
});

Complete demo of this concept you may find below:

//data sample that mimic response from your back-end PHP script
const srcData = [
  {id: 1, name: 'Steve Rogers', phone: '+1987270123512', mail: 'cap@avengers.org'},
  {id: 2, name: 'Tony Stark', phone: '+1987987235143', mail: 'ironman@avengers.org'},
  {id: 3, name: 'Peter Parker', phone: '+1698701245121', mail: 'spidey@avengers.org'}
];

//datatables initialization
const dataTable = $('#example').DataTable({
  dom: 't',
  data: srcData,
  columns: [
    {title: 'id', data: 'id'},
    {title: 'name', data: 'name'},
    {title: 'contacts', data: null, render: (data, type, row, meta) => `phone: ${row.phone}, e-mail: ${row.mail}`}
  ]
});

<!doctype html>
<html>
<head>
  <script type="application/javascript" src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
  <script type="application/javascript" src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>

  <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css">
</head>
<body>
  <table id="example"></table>
</body>
</html>


问:
Add widget on mouse pressed in gui - kivy python
I have problem with adding and showing image to the layout every time I press the screen using mouse.

class Myszka(ClickAndGo, Widget):

    def on_touch_down(self, touch):
        super().build()
        flaga_path = os.path.join(self.img_path, "test.png")
        x, y = touch.pos
        self.flaga = Image(source=flaga_path, size_hint=(None, None), size=(64, 64),
                           pos=(round(x, 1), round(y, 1)))
        self.camlayout.add_widget(self.flaga)
        print(touch.pos)
```

Actual results:
only touch position is printed, image has not been shown.

Expected results:
Image should have been shown, every time mouse down.

答:
@ikolim

from kivy.app import App
from kivy.uix.floatlayout import FloatLayout

class ClickAndGo(App):
    def build(self):
        self.camlayout = FloatLayout(size=(100,100))
        self.myszka = Myszka()

        self.camlayout.add_widget(self.myszka)

        return self.camlayout

class Myszka(ClickAndGo, Widget):

    def on_touch_down(self, touch):
        super().build()
        # test.png -> any image
        flaga_path = os.path.join(self.img_path, "test.png")
        x, y = touch.pos
        self.flaga = Image(source=flaga_path, size_hint=(None, None), size=(64, 64),
                           pos=(round(x, 1), round(y, 1)))
        self.camlayout.add_widget(self.flaga)
        print(touch.pos)

```

Body:
I have problem with adding and showing image to the layout every time I press the screen using mouse.

class Myszka(ClickAndGo, Widget):

    def on_touch_down(self, touch):
        super().build()
        flaga_path = os.path.join(self.img_path, "test.png")
        x, y = touch.pos
        self.flaga = Image(source=flaga_path, size_hint=(None, None), size=(64, 64),
                           pos=(round(x, 1), round(y, 1)))
        self.camlayout.add_widget(self.flaga)
        print(touch.pos)

Actual results:
only touch position is printed, image has not been shown.

Expected results:
Image should have been shown, every time mouse down.


问:
Have two different strings that represent dates in two different hive tables , and I want to use them to join
So I have two external tables in Hive, in my Hadoop cluster.

One table has a (date STRING) column, with this format '2019-05-24 11:16:31.0'

and the other one has (date STRING) column, with this format '23/May/2019:22:15:04', they are both strings. I need to transform them to the same type of date format and use them to join these two tables.

How would you aproach this problem solving it all within hive? Would it be possible?  I'm quite the rookie in Hadoop, And I'm not fully aware of the possibilities of hive.

Ps: My hive version does not support !hive --version command to check what version I'm working with, so I'm not pretty sure how to understand what version I'm working on. Not my cluster and I'm not a root user.

答:
You need to convert both strings to the same format before joining.

Converting non-standard format '23/May/2019:22:15:04'

Use unix_timestamp(string date, string pattern) to convert given date format to seconds passed from 1970-01-01. Then use from_unixtime() to convert to required format:

```<code>select from_unixtime(unix_timestamp('23/May/2019:22:15:04','dd/MMM/yyyy:HH:mm:ss'));
</code>```

returns:

```<code>2019-05-23 22:15:04
</code>```

If you want date only, specify date format 'yyyy-MM-dd' in the from_unixtime function:

```<code>select from_unixtime(unix_timestamp('23/May/2019:22:15:04','dd/MMM/yyyy:HH:mm:ss'),'yyyy-MM-dd');
</code>```

Returns:

```<code>2019-05-23
</code>```

Second table contains more standard format '2019-05-24 11:16:31.0' and you can do with simpler approach.

You can use simple substr, because the date is already in the Hive format 'yyyy-MM-dd':

```<code>select substr('2019-05-24 11:16:31.0',1,10);
</code>```

Returns:

```<code>2019-05-24
</code>```

Or if you want the same format as in the first example 'yyyy-MM-dd HH:mm:ss':

```<code>select substr('2019-05-24 11:16:31.0',1,19);
</code>```

Returns:

```<code>2019-05-24 11:16:31
</code>```

Also date_format (as of Hive 1.2.0) function can be used for the same:

```<code>select date_format('2019-05-24 11:16:31.0','yyyy-MM-dd HH:mm:ss');
</code>```

Returns:

```<code>2019-05-24 11:16:31
</code>```

And date portion only using date_format (as of Hive 1.2.0):

```<code>2019-05-23 22:15:04
</code>```0

Body:
You need to convert both strings to the same format before joining.

Converting non-standard format '23/May/2019:22:15:04'

Use unix_timestamp(string date, string pattern) to convert given date format to seconds passed from 1970-01-01. Then use from_unixtime() to convert to required format:

select from_unixtime(unix_timestamp('23/May/2019:22:15:04','dd/MMM/yyyy:HH:mm:ss'));

returns:

2019-05-23 22:15:04

If you want date only, specify date format 'yyyy-MM-dd' in the from_unixtime function:

select from_unixtime(unix_timestamp('23/May/2019:22:15:04','dd/MMM/yyyy:HH:mm:ss'),'yyyy-MM-dd');

Returns:

2019-05-23

Second table contains more standard format '2019-05-24 11:16:31.0' and you can do with simpler approach.

You can use simple substr, because the date is already in the Hive format 'yyyy-MM-dd':

select substr('2019-05-24 11:16:31.0',1,10);

Returns:

2019-05-24

Or if you want the same format as in the first example 'yyyy-MM-dd HH:mm:ss':

select substr('2019-05-24 11:16:31.0',1,19);

Returns:

2019-05-24 11:16:31

Also date_format (as of Hive 1.2.0) function can be used for the same:

select date_format('2019-05-24 11:16:31.0','yyyy-MM-dd HH:mm:ss');

Returns:

2019-05-24 11:16:31

And date portion only using date_format (as of Hive 1.2.0):

select date_format('2019-05-24 11:16:31.0','yyyy-MM-dd')


问:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock'
I installed MySQL on Mac OS X Mountain Lion with homebrew install mysql, but when I tried mysql -u root I got the following error:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

What does this error mean? How can I fix it?

答:
This problem related to /usr/local/var/mysql folder access, I remove this folder and reinstall mysql.

uninstall mysql with brew :

brew uninstall mysql

sudo rm -r /usr/local/var/mysql

brew install mysql@8.0

mysql -u root

This solution works fine for me!
BUT YOU LOST ALL YOUR DATABASES! WARNING!


问:
could anyone explain to me how to set date from datepicker
I 'm setting up a datepicker in my app and I have a problem, I don't know how to set public date in my ts file from datepicker.
The chosen date goes to html view and I can see it and it's ok but it should be added in public date =
I don't know how to connect this information with ts file

html file

```<code><mat-form-field class="justify-content-center">
  <input matInput [matDatepicker]="picker" placeholder="Choose a date">
  <mat-datepicker-toggle matSuffix [for]="picker">
    <mat-icon matDatepickerToggleIcon>keyboard_arrow_down</mat-icon>
  </mat-datepicker-toggle>
  <mat-datepicker #picker></mat-datepicker>
</mat-form-field>
</code>```

ts file
with a date added rigidly

```<code>public date = '2019-05-01';
</code>```

答:
Several ways you can do it.

change TS:

```<code>public date = new Date(2019, 4, 1); // 4 = May
</code>```

HTML:

```<code><mat-datepicker #picker [startAt]="date"></mat-datepicker>
</code>```

or you can add [(ngModel)]="date" to bind the datepicker to a ts variable

```<code><input matInput [(ngModel)]="date" [matDatepicker]="picker" placeholder="Choose a date">
</code>```

Body:
I 'm setting up a datepicker in my app and I have a problem, I don't know how to set public date in my ts file from datepicker.
The chosen date goes to html view and I can see it and it's ok but it should be added in public date =
I don't know how to connect this information with ts file

html file

<mat-form-field class="justify-content-center">
  <input matInput [matDatepicker]="picker" placeholder="Choose a date">
  <mat-datepicker-toggle matSuffix [for]="picker">
    <mat-icon matDatepickerToggleIcon>keyboard_arrow_down</mat-icon>
  </mat-datepicker-toggle>
  <mat-datepicker #picker></mat-datepicker>
</mat-form-field>

ts file
with a date added rigidly

public date = '2019-05-01';

Body:
Several ways you can do it.

change TS:

public date = new Date(2019, 4, 1); // 4 = May

HTML:

<mat-datepicker #picker [startAt]="date"></mat-datepicker>

or you can add [(ngModel)]="date" to bind the datepicker to a ts variable

<input matInput [(ngModel)]="date" [matDatepicker]="picker" placeholder="Choose a date">


问:
How can I update a calendar event using Microsoft Graph
I have managed to add new events in my Outlook calendar, but updating or deleting is not working. I think I do not use a correct key. From the API description I understood that the iCalUId - generated while creating a new event and returned in the response message - is the unique identifier of a calendar event, so I use this one.

JavaScript:

```<code>client
 .api('/me/calendars/xxxxxxxx (=my Calendar ID)/events/')
 .update ({
iCalUId: yyyyy (=the iCalUid I got from the creation of this event),
subject: "** Test Event Updated**",
body: {
contentType: "HTML",
content: "This is updated to 0800 .. 1000"
 },
start: {
dateTime: "2019-08-19T08:00:00",
timeZone: "UTC"
 },
 end: {
    dateTime: "2019-08-19T10:00:00",
     timeZone: "UTC"
},
location:{
     displayName:"Somewhere else"
 }
});
</code>```

This gives error "The OData request is not supported"

答: I already found it, use the id and not the iCalUid</p>

Body:
I have managed to add new events in my Outlook calendar, but updating or deleting is not working. I think I do not use a correct key. From the API description I understood that the iCalUId - generated while creating a new event and returned in the response message - is the unique identifier of a calendar event, so I use this one.

JavaScript:

client
 .api('/me/calendars/xxxxxxxx (=my Calendar ID)/events/')
 .update ({
iCalUId: yyyyy (=the iCalUid I got from the creation of this event),
subject: "** Test Event Updated**",
body: {
contentType: "HTML",
content: "This is updated to 0800 .. 1000"
 },
start: {
dateTime: "2019-08-19T08:00:00",
timeZone: "UTC"
 },
 end: {
    dateTime: "2019-08-19T10:00:00",
     timeZone: "UTC"
},
location:{
     displayName:"Somewhere else"
 }
});

This gives error "The OData request is not supported"


问:
How to align the bottom of two left- and right aligned texts with bottom of parent container?
Imagine you have this:

```<code><div class="parent_with_height200px">
  <div class="left">This is the left floated text, size 12px</div>
  <div class="right">This is the right floated text, size 40px</div>
</div>
</code>```

How can I make the two texts "stand" on the bottom of the parent div having their baseline aligned with each other?

It's perfectly ok to change the css/html, it's the result I want.

答:
As feeela says, using position is how you will accomplish this.

```<code>.parent_with_height200px {
    height: 200px;
    position: relative;
    background-color: #DDDDDD;
    }

.left {
    width: 50%;
    position: absolute;
    bottom: 0px;
    left: 0px;
    background-color: #999999;
    }

.right {
    width: 50%;
    position: absolute;
    bottom: 0px;
    right: 0px;
    background: #444444;
    }
</code>```

See the output here: Example

ContentLicense: CC BY-SA 3.0

Body:
Imagine you have this:

This is the left floated text, size 12px

This is the right floated text, size 40px

How can I make the two texts "stand" on the bottom of the parent div having their baseline aligned with each other?

It's perfectly ok to change the css/html, it's the result I want.

Body:
As feeela says, using position is how you will accomplish this.

.parent_with_height200px {
    height: 200px;
    position: relative;
    background-color: #DDDDDD;
    }

.left {
    width: 50%;
    position: absolute;
    bottom: 0px;
    left: 0px;
    background-color: #999999;
    }

.right {
    width: 50%;
    position: absolute;
    bottom: 0px;
    right: 0px;
    background: #444444;
    }

See the output here: Example


问:
How to style the color of the sort icon through a theme override for MUIDataTable?
I am needing to override the color of the sort icon in a MUIDataTable. I am currently able to override basically everything else except this.

Through the debugger view I have tried quite a bit and cannot seem to touch on this icon.

This is what I am currently trying to call to get to it

```<code>MuiTableSortLabel: {
  icon: {
    color: "#eee",
  },
  iconDirectionAsc: {
    color: "#eee",
  },
  iconDirectionDesc: {
    color: "#eee",
  },
},
</code>```

I have this called as well within the overrides -

```<code>MuiSvgIcon: {
  root: {
    color: "#eee",
  },
},
</code>```

The sort icon is currently the default color (black) as this code does nothing to style the icon.
enter image description here

Update work around: This does not satisfy the overrides but is called in styles-

'@global': {
    'div > span > svg > path': {
      fill: '#eee'
    },

},

答:
To override the sort icon color, try

```<code>overrides: {
  MuiTableSortLabel: {
    active: {
      color: 'green' // your color here
    }
  }
}
</code>```

If you need help with custom style overrides in general, you can check out the example here: https://github.com/gregnb/mui-datatables/blob/master/examples/customize-styling/index.js.

Body:
I am needing to override the color of the sort icon in a MUIDataTable. I am currently able to override basically everything else except this.

Through the debugger view I have tried quite a bit and cannot seem to touch on this icon.

This is what I am currently trying to call to get to it

MuiTableSortLabel: {
  icon: {
    color: "#eee",
  },
  iconDirectionAsc: {
    color: "#eee",
  },
  iconDirectionDesc: {
    color: "#eee",
  },
},

I have this called as well within the overrides -

MuiSvgIcon: {
  root: {
    color: "#eee",
  },
},

The sort icon is currently the default color (black) as this code does nothing to style the icon.
enter image description here

Update work around: This does not satisfy the overrides but is called in styles-

'@global': {
    'div > span > svg > path': {
      fill: '#eee'
    },

},

Body:
To override the sort icon color, try

overrides: {
  MuiTableSortLabel: {
    active: {
      color: 'green' // your color here
    }
  }
}

If you need help with custom style overrides in general, you can check out the example here: https://github.com/gregnb/mui-datatables/blob/master/examples/customize-styling/index.js.


问:
Plotting with years in python
I have data in my excel file as shown below which I have imported into python and trying to plot the same,

```<code>Year    Andhra Pradesh
1973-74 50.67
1977-78 69.66
1983    115.4
1993-94 288.7
1999-00 453.61
2004-05 603.82
2009-10 1233.76
2011-12 1753.96
</code>```

However, I am getting a blank plot whenever I run the command.

```<code>import pandas as pd
import matplotlib.pyplot as plt
data1= pd.read_excel('C:\\Users\\3004\\Desktop\\Variables.xlsx',2)
plt.plot(data1)
</code>```

I want the years on x axis and the values shown on a histogram or any other plot. However, I receive a blank plot.

答:
```<code>plt.plot(data1)
</code>```

returns

TypeError: unhashable type: 'numpy.ndarray'

You need to pass x and y separatly in plt.plot(x,y):

```<code>import pandas as pd
import matplotlib.pyplot as plt

data1 = pd.DataFrame([
    ['1973-74', 50.67],
    ['1977-78', 69.66],
    ['1983   ',115.4],
    ['1993-94',288.7],
    ['1999-00',453.61],
    ['2004-05',603.82],
    ['2009-10',1233.76],
    ['2011-12',1753.96]],
    columns=['Year','Andhra Pradesh'])

#data1= pd.read_excel('C:\\Users\\3004\\Desktop\\Variables.xlsx',2)

plt.plot(data1['Year'], data1['Andhra Pradesh'])
</code>```

Title: Plotting with years in python

Body:
I have data in my excel file as shown below which I have imported into python and trying to plot the same,

Year    Andhra Pradesh
1973-74 50.67
1977-78 69.66
1983    115.4
1993-94 288.7
1999-00 453.61
2004-05 603.82
2009-10 1233.76
2011-12 1753.96

However, I am getting a blank plot whenever I run the command.

import pandas as pd
import matplotlib.pyplot as plt
data1= pd.read_excel('C:\\Users\\3004\\Desktop\\Variables.xlsx',2)
plt.plot(data1)

I want the years on x axis and the values shown on a histogram or any other plot. However, I receive a blank plot.

Body:
plt.plot(data1)

returns

TypeError: unhashable type: 'numpy.ndarray'

You need to pass x and y separatly in plt.plot(x,y):

import pandas as pd
import matplotlib.pyplot as plt

data1 = pd.DataFrame([
    ['1973-74', 50.67],
    ['1977-78', 69.66],
    ['1983   ',115.4],
    ['1993-94',288.7],
    ['1999-00',453.61],
    ['2004-05',603.82],
    ['2009-10',1233.76],
    ['2011-12',1753.96]],
    columns=['Year','Andhra Pradesh'])

#data1= pd.read_excel('C:\\Users\\3004\\Desktop\\Variables.xlsx',2)

plt.plot(data1['Year'], data1['Andhra Pradesh'])


答:
You can do something like that if you want to use Jquery.

function getSelectedValue() {
  var selectedValue = document.getElementById("list").value;

  if(selectedValue) {

  var html ='<input type="text" name="value[]" id="myValue" value="'+selectedValue+'">
';

  $('.inp').append(html);
  $('.default').remove();

  }
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<select name="" onchange="getSelectedValue();" class="form-control" id="list">
  <option value="Option1">Option1</option>
  <option value="Option2">Option2</option>
  <option value="Option3">Option3</option>
  <option value="Option4">Option4</option>
</select>

<div class="inp">
<input type="text" name="value[]" id="myValue" value="" class="default">
</div></code>```

Title: How to show each of the selected value from single select option in input tag

Body:
I am new to javascript and I want to use the select option to list each selected value in the input tag.

I have tried to use javascript to show the selected value but when I select for the second time the first value dismiss and show the second selected. I was expected to show each selected value in the input tag separately without dismissing other previous selected.

function getSelectedValue() {
  var selectedValue = document.getElementById("list").value;
  document.getElementById("myValues").innerHTML = selectedValue;
}

<select name="" onchange="getSelectedValue();" class="form-control" id="list">
  <option value="Option1">Option1</option>
  <option value="Option2">Option2</option>
  <option value="Option3">Option3</option>
  <option value="Option4">Option4</option>
</select>
<input type="text" name="value[]" id="myValue" value="">

I expected the output of

<input type="text" name="value[]" id="myValue" value="Option1">

<input type="text" name="value[]" id="myValue" value="Option3">

thus in the input should show

Option1
  Option3

Body:
You can do something like that if you want to use Jquery.

function getSelectedValue() {
  var selectedValue = document.getElementById("list").value;

  if(selectedValue) {

  var html ='<input type="text" name="value[]" id="myValue" value="'+selectedValue+'"> <br>';

  $('.inp').append(html);
  $('.default').remove();

  }
}

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<select name="" onchange="getSelectedValue();" class="form-control" id="list">
  <option value="Option1">Option1</option>
  <option value="Option2">Option2</option>
  <option value="Option3">Option3</option>
  <option value="Option4">Option4</option>
</select>

<div class="inp">
<input type="text" name="value[]" id="myValue" value="" class="default">
</div>


问:
Get the last modification date of a file in git repo
Im trying to find the command to get the last modified date of a file in a local git repo.

Created the repo and have done one commit. Had to edit one file and will commit this file but was wondering what the last modification data of the file in the repo is (not the commit date).

Have no gui onl command line.

```<code>git log ./path/to/filename.php
</code>```

only gives me the commit date

答:
The correct way to do this is to use git log as follows.

git log -1 --pretty="format:%ci" /path/to/repo/anyfile.any

-1 restricts it to the very last time the file changed

%ci is just one of the date formats you can choose from others here at https://git-scm.com/docs/pretty-formats

Body:
Im trying to find the command to get the last modified date of a file in a local git repo.

Created the repo and have done one commit. Had to edit one file and will commit this file but was wondering what the last modification data of the file in the repo is (not the commit date).

Have no gui onl command line.

git log ./path/to/filename.php

only gives me the commit date


问:
Importing project from github to eclipse error
I have some troubles with importing my project (default android project) from github to eclipse.
Steps that I made:

Click import

Select Git => Projects from git => url

Paste https://github.com/ivanbordyug/TestProject.git to URL => Click next

Select maser brunch => click next

Select directory => click next

Recieve objects => click next

And in Import project I see message "No project found"

But when I import "Excisting code" from folder where imported files are stored, all is OK. Pls, help me with this, because I dont know what is wrong.

Thanks a lot!

答:
If you are the owner of repository then you can resolve it by following simple steps.
The eclipse is giving this error because it is trying to find .project and .classpath files in the project you are importing from git. If it is not found it gives error as no project found to import.

Steps to Resolve

open .gitignore file of your project

delete entry of .project and .classpath

push it to repository

now anyone can pull it and the error will be gone.


问:
Extract specific values from a file using shell script
How can I extract values from a file using shell-script (grep, awk or sed for example). I have the following structure (described below) and I want to get an output file with only the second column of the file.
I tried using grep:
grep -oP '\s*U238\s*\*\s+[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?' file >U238_out to extract all U238 values from the entire file and store it in an output file (U238_out).With this I get the following output:

```<code> U238     *  1.779265E+03
 U238     *  5.418484E-03
 U238     *  1.777156E+03
         ...
</code>```

but I want to obtain this structure:

```<code>1.779265E+03
5.418484E-03
1.777156E+03
</code>```

File Structure:

```<code>  PERIODICITY : 0
  SYMMETRY    : 0

  MATERIAL MFUEL
  MEDIUM   MFUEL    VOLUME  8.308106E+05

  *******************************************************
  * ISOTOPE  *   MASS (KG)   *   CIP    *    EQFMASS    *
  *******************************************************
  * U238     *  1.779265E+03 *   28.125 *  0.000000E+00 *
</code>```

Thanks in advance.

答:
you mean something like this?

```<code>sed '/\s*\*/!d;s/\s*[*][^*]*[*]\s*\([-+.E0-9]*\).*/\1/;/^$/d' file.txt
</code>```

explanation

```<code>/\s*\*/!d          # delete line not started with [blank]*
;                  # separator for next sed command
s/                 # substitute
\s*                # ignore leading blanks
[*]                # search first *
[^*]*[*]           # ignore everything until the next *
\s*                # ignore blanks
\([-+.E0-9]*\)     # save number into arg1 (\1)
.*                 # ignore rest of line
/\1/               # print only arg1
;                  # separator for next sed command
/^$/d              # ignore empty lines (first 3)
</code>```

output

```<code>3.099319E+02
1.274088E+01
1.779265E+03
3.789596E+02
1.760032E+02
5.049642E+01
5.002164E+01
4.777184E+00
2.594883E-19
2.594883E-19
</code>```

Body:
How can I extract values from a file using shell-script (grep, awk or sed for example). I have the following structure (described below) and I want to get an output file with only the second column of the file.
I tried using grep:
grep -oP '\s*U238\s*\*\s+[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?' file >U238_out to extract all U238 values from the entire file and store it in an output file (U238_out).With this I get the following output:

 U238     *  1.779265E+03
 U238     *  5.418484E-03
 U238     *  1.777156E+03
         ...

but I want to obtain this structure:

1.779265E+03
5.418484E-03
1.777156E+03

File Structure:

  PERIODICITY : 0
  SYMMETRY    : 0

  MATERIAL MFUEL
  MEDIUM   MFUEL    VOLUME  8.308106E+05

  *******************************************************
  * ISOTOPE  *   MASS (KG)   *   CIP    *    EQFMASS    *
  *******************************************************
  * U238     *  1.779265E+03 *   28.125 *  0.000000E+00 *

Thanks in advance.

Body:
you mean something like this?

sed '/\s*\*/!d;s/\s*[*][^*]*[*]\s*\([-+.E0-9]*\).*/\1/;/^$/d' file.txt

explanation

/\s*\*/!d          # delete line not started with [blank]*
;                  # separator for next sed command
s/                 # substitute
\s*                # ignore leading blanks
[*]                # search first *
[^*]*[*]           # ignore everything until the next *
\s*                # ignore blanks
\([-+.E0-9]*\)     # save number into arg1 (\1)
.*                 # ignore rest of line
/\1/               # print only arg1
;                  # separator for next sed command
/^$/d              # ignore empty lines (first 3)

output

3.099319E+02
1.274088E+01
1.779265E+03
3.789596E+02
1.760032E+02
5.049642E+01
5.002164E+01
4.777184E+00
2.594883E-19
2.594883E-19


问:
Firebase onAuthStateChanged error with React
I'm trying to check if a user is logged in or not on my React webpage using Firebase, however I keep getting an error TypeError: Cannot read property 'onAuthStateChanged' of undefined, the line of code it links to is as followed:

Login.js:

```<code>authListener() {
Fire.auth.onAuthStateChanged((user) => {
  if (user) {
    this.setState({ user })
  } else {
    this.setState({ user: null })
  }
})}
</code>```

Fire.js:

```<code>import firebase from 'firebase'

const config = {
    apiKey: "xxx",
    authDomain: "xxx",
    databaseURL: "xxx",
    projectId: "xxx",
    storageBucket: "xxx",
    messagingSenderId: "xxx",
    appId: "xxx"
};
const Fire = firebase.initializeApp(config);
export default Fire;
</code>```

** solved it, above is what my Fire.js and Login.js look like for those coming and having the same problem **

答:
You need to include firebase package

```<code>import firebase from "firebase";
</code>```

and then use auth() function of firebase

```<code>authListener() {
firebase.auth().onAuthStateChanged((user) => {
  if (user) {
    this.setState({ user })
  } else {
    this.setState({ user: null })
  }
})}
</code>```

if you are importing firebase from another file then configure it like this

```<code>import firebase from 'firebase/app';
import 'firebase/auth';
export const init = () => {
    let config = {
        apiKey: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
        authDomain: 'xxxxxxxxxxxxx'
    };
    firebase.initializeApp(config);
};

export const firebaseAuth = firebase.auth;
</code>```

Body:
I'm trying to check if a user is logged in or not on my React webpage using Firebase, however I keep getting an error TypeError: Cannot read property 'onAuthStateChanged' of undefined, the line of code it links to is as followed:

Login.js:

authListener() {
Fire.auth.onAuthStateChanged((user) => {
  if (user) {
    this.setState({ user })
  } else {
    this.setState({ user: null })
  }
})}

Fire.js:

import firebase from 'firebase'

const config = {
    apiKey: "xxx",
    authDomain: "xxx",
    databaseURL: "xxx",
    projectId: "xxx",
    storageBucket: "xxx",
    messagingSenderId: "xxx",
    appId: "xxx"
};
const Fire = firebase.initializeApp(config);
export default Fire;

** solved it, above is what my Fire.js and Login.js look like for those coming and having the same problem **

Body:
You need to include firebase package

import firebase from "firebase";

and then use auth() function of firebase

authListener() {
firebase.auth().onAuthStateChanged((user) => {
  if (user) {
    this.setState({ user })
  } else {
    this.setState({ user: null })
  }
})}

if you are importing firebase from another file then configure it like this

import firebase from 'firebase/app';
import 'firebase/auth';
export const init = () => {
    let config = {
        apiKey: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
        authDomain: 'xxxxxxxxxxxxx'
    };
    firebase.initializeApp(config);
};

export const firebaseAuth = firebase.auth;


问:
File not found exception while running DockerFile
Here my DockerFile :-

```<code>FROM openjdk:10
ENV AQUILA_HOME /data/config
#USER root
#VOLUME /tmp
ADD a2i-web-1.0.0-SNAPSHOT.jar app.jar
#RUN bash -c 'touch /app.jar'
ENTRYPOINT ["java","-jar","app.jar"]
</code>```

My jar is spring boot application which refers configuration file from some directory [/data/config/config.properties]
I am building DockerFile successfully by command

```<code>sudo docker build -t dockImgName/a2i-web:v1 .
</code>```

But while running it by command

```<code>sudo docker run -p 8080:8080 -t dockImgName/a2i-web:v1
</code>```

giving exception as :

```<code>Caused by: java.io.FileNotFoundException: /data/config/config.properties (No such file or directory)
</code>```

I am running this dcoker command from directory containing DockerFile and my jar
Do I need to set any configuration to get config file directory?

答:
The error message is quite clear. When the container tries to run it is not able to find properties file.

You need to add config.properties file to your docker image.

```<code>ADD path_to_config_file/config.properties /data/config/config.properties
</code>```

NOTE: path_to_config_file refers to the file path in your local where you are building the dockerfile

Body:
Here my DockerFile :-

FROM openjdk:10
ENV AQUILA_HOME /data/config
#USER root
#VOLUME /tmp
ADD a2i-web-1.0.0-SNAPSHOT.jar app.jar
#RUN bash -c 'touch /app.jar'
ENTRYPOINT ["java","-jar","app.jar"]

My jar is spring boot application which refers configuration file from some directory [/data/config/config.properties]
I am building DockerFile successfully by command

sudo docker build -t dockImgName/a2i-web:v1 .

But while running it by command

sudo docker run -p 8080:8080 -t dockImgName/a2i-web:v1

giving exception as :

Caused by: java.io.FileNotFoundException: /data/config/config.properties (No such file or directory)

I am running this dcoker command from directory containing DockerFile and my jar
Do I need to set any configuration to get config file directory?

Body:
The error message is quite clear. When the container tries to run it is not able to find properties file.

You need to add config.properties file to your docker image.

ADD path_to_config_file/config.properties /data/config/config.properties

NOTE: path_to_config_file refers to the file path in your local where you are building the dockerfile


问:
Error "Please enter a correct entity model." while Importing CSV in custom module in Magento 2
I receive this error when i'm trying to import a list of sellers (custom module). I want to know what is the meaning of this error? and where should I start to fix the problem?

PS: Please let me know if you need more info.

答:
a) Simply solution to reset the folder permission due to export/import file will be save in var/export or var/import folder.

```<code>chmod -R 0777 var/
</code>```

b) Check the exception.log file in var/log

Body:
a) Simply solution to reset the folder permission due to export/import file will be save in var/export or var/import folder.

chmod -R 0777 var/

b) Check the exception.log file in var/log


问:
Counting the number of leaves in a JavaScript Object
I have an errors object in the following way and I want to count the total number of leaves, my object is as follows

I have tried using the object.keys() property but it only counts the direct children of the object and not the nested values

```<code>state = {
    driver: {
        user: {
            number: '1234',
            firstName: 'xyz',
            lastName: 'abc'
        },
        kyc: {
            name: 'kyc1',
            idNumber: 'kyc2'
        },
        license: {
            idNumber: '1234',
            issuedOn: '1991-05-12',
            validTill: '1991-12-12'
        }
    },
    vehicle: {
        vin: '4567',
        registrationNumber: '4567',
        dateBought: '1954-09-12',
        contractValidity: '1954-12-12',
        departments: [1, 2],
        vehicleType: 2
    },
    owner: {
        user: {
            number: '1234',
            firstName: 'lml',
            lastName: 'pqr',
            dateOfBirth: '2068-11-26'
        },
        kyc: {
            name: 'kyc2',
            idNumber: 'kyc123'
        },
        bank: {
            ifscCode: '1234',
            bankName: 'bank1',
            branchName: 'branch1',
            accountNumber: '1234',
            accountHolderName: 'holder1'
        },
        license: {
            idNumber: '12345',
            issuedOn: '1997-12-12',
            validTill: '1997-12-12'
        },
        insurance: {
            idNumber: '1234',
            issuedOn: '2909-12-12',
            validTill: '2909-12-12'
        }
    },
    errors: {},
    isSubmitable: false
}
</code>```

答:
It depends on exactly how we define leaves, but something like this should work, using recursion:

function countLeaves(obj) {
    return Object.values(obj).reduce((count,v) => count += (typeof(v) === 'object') ? countLeaves(v): 1, 0);
}

let state = { driver: { user: { number: '1234', firstName: 'xyz', lastName: 'abc' }, kyc: { name: 'kyc1', idNumber: 'kyc2' }, license: { idNumber: '1234', issuedOn: '1991-05-12', validTill: '1991-12-12' } }, vehicle: { vin: '4567', registrationNumber: '4567', dateBought: '1954-09-12', contractValidity: '1954-12-12', departments: [1, 2], vehicleType: 2 }, owner: { user: { number: '1234', firstName: 'lml', lastName: 'pqr', dateOfBirth: '2068-11-26' }, kyc: { name: 'kyc2', idNumber: 'kyc123' }, bank: { ifscCode: '1234', bankName: 'bank1', branchName: 'branch1', accountNumber: '1234', accountHolderName: 'holder1' }, license: { idNumber: '12345', issuedOn: '1997-12-12', validTill: '1997-12-12' }, insurance: { idNumber: '1234', issuedOn: '2909-12-12', validTill: '2909-12-12' } }, errors: {}, isSubmitable: false };

console.log("Number of leaves: ", countLeaves(state));```

Body:
I have an errors object in the following way and I want to count the total number of leaves, my object is as follows

I have tried using the object.keys() property but it only counts the direct children of the object and not the nested values

state = {
    driver: {
        user: {
            number: '1234',
            firstName: 'xyz',
            lastName: 'abc'
        },
        kyc: {
            name: 'kyc1',
            idNumber: 'kyc2'
        },
        license: {
            idNumber: '1234',
            issuedOn: '1991-05-12',
            validTill: '1991-12-12'
        }
    },
    vehicle: {
        vin: '4567',
        registrationNumber: '4567',
        dateBought: '1954-09-12',
        contractValidity: '1954-12-12',
        departments: [1, 2],
        vehicleType: 2
    },
    owner: {
        user: {
            number: '1234',
            firstName: 'lml',
            lastName: 'pqr',
            dateOfBirth: '2068-11-26'
        },
        kyc: {
            name: 'kyc2',
            idNumber: 'kyc123'
        },
        bank: {
            ifscCode: '1234',
            bankName: 'bank1',
            branchName: 'branch1',
            accountNumber: '1234',
            accountHolderName: 'holder1'
        },
        license: {
            idNumber: '12345',
            issuedOn: '1997-12-12',
            validTill: '1997-12-12'
        },
        insurance: {
            idNumber: '1234',
            issuedOn: '2909-12-12',
            validTill: '2909-12-12'
        }
    },
    errors: {},
    isSubmitable: false
}


问:
Subscribe error: Property 'subscribe' does not exist on type 'void'.ts(2339)
I am learning to use Services in angular and I have problems to subscribe to my component. What am I doing wrong?

I poll with some amounts but none of them worked

Component

```<code>import { Component, OnInit } from '@angular/core';
import { Tweet } from '../Models/tweet';
import { TweetService } from '../Services/tweet.service';
import { HttpClient } from '@angular/common/http';

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

  tweet: Array<Tweet>;

  constructor( private tweetService : TweetService) {
    this.tweetService = tweetService;
   }

  ngOnInit() {
    this.tweetService.getListTweet()
      .subscribe((data : Array<Tweet>) => {
        this.tweet = data;
      },
      err => {
        console.log(err);
      });
  }

}

</code>```

This is my service, I do not know, if here is the problem or in the component

```<code>import { Injectable } from '@angular/core';
import { HttpClient } from 'selenium-webdriver/http';
import 'rxjs/add/operator/map';
import 'rxjs/add/observable/throw';

@Injectable({
  providedIn: 'root'
})
export class TweetService {

  baseUrl: string = "http://jsonplaceholder.typicode.com";

  constructor(private httpClient: HttpClient) {
    this.httpClient = httpClient;
   }

   getListTweet(){
    return this.httpClient.get(`${this.baseUrl}/posts`);
  }
}

</code>```

答:
```<code>import { Component, OnInit } from '@angular/core';
import { Tweet } from '../Models/tweet';
import { TweetService } from '../Services/tweet.service';
import { HttpClient } from '@angular/common/http';

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

  tweet: Array<Tweet>;

  constructor( private tweetService : TweetService) {
   }

  ngOnInit() {
    this.tweetService.getListTweet()
      .subscribe((data : Array<Tweet>) => {
        this.tweet = data;
      },
      err => {
        console.log(err);
      });
  }

}
</code>```

Service:

```<code> import { Injectable } from '@angular/core';
    import { HttpClient } from 'selenium-webdriver/http';
    import { Observable } from 'rxjs/observable';
    import 'rxjs/add/operator/map';
    import 'rxjs/add/observable/throw';

    @Injectable({
      providedIn: 'root'
    })
    export class TweetService {

      baseUrl: string = "http://jsonplaceholder.typicode.com";

      constructor(private httpClient: HttpClient) {
       }

       getListTweet(): Observable<any>{
        return this.httpClient.get(`${this.baseUrl}/posts`);
      }
    }
</code>```

Body:
I am learning to use Services in angular and I have problems to subscribe to my component. What am I doing wrong?

I poll with some amounts but none of them worked

Component

import { Component, OnInit } from '@angular/core';
import { Tweet } from '../Models/tweet';
import { TweetService } from '../Services/tweet.service';
import { HttpClient } from '@angular/common/http';

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

  tweet: Array<Tweet>;

  constructor( private tweetService : TweetService) {
    this.tweetService = tweetService;
   }

  ngOnInit() {
    this.tweetService.getListTweet()
      .subscribe((data : Array<Tweet>) => {
        this.tweet = data;
      },
      err => {
        console.log(err);
      });
  }

}

This is my service, I do not know, if here is the problem or in the component

import { Injectable } from '@angular/core';
import { HttpClient } from 'selenium-webdriver/http';
import 'rxjs/add/operator/map';
import 'rxjs/add/observable/throw';

@Injectable({
  providedIn: 'root'
})
export class TweetService {

  baseUrl: string = "http://jsonplaceholder.typicode.com";

  constructor(private httpClient: HttpClient) {
    this.httpClient = httpClient;
   }

   getListTweet(){
    return this.httpClient.get(`${this.baseUrl}/posts`);
  }
}

Body:
import { Component, OnInit } from '@angular/core';
import { Tweet } from '../Models/tweet';
import { TweetService } from '../Services/tweet.service';
import { HttpClient } from '@angular/common/http';

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

  tweet: Array<Tweet>;

  constructor( private tweetService : TweetService) {
   }

  ngOnInit() {
    this.tweetService.getListTweet()
      .subscribe((data : Array<Tweet>) => {
        this.tweet = data;
      },
      err => {
        console.log(err);
      });
  }

}

Service:

 import { Injectable } from '@angular/core';
    import { HttpClient } from 'selenium-webdriver/http';
    import { Observable } from 'rxjs/observable';
    import 'rxjs/add/operator/map';
    import 'rxjs/add/observable/throw';

    @Injectable({
      providedIn: 'root'
    })
    export class TweetService {

      baseUrl: string = "http://jsonplaceholder.typicode.com";

      constructor(private httpClient: HttpClient) {
       }

       getListTweet(): Observable<any>{
        return this.httpClient.get(`${this.baseUrl}/posts`);
      }
    }


答:
You don't need to use gridExtra::grid.arrange.

Here is a clean solution.

```<code>library(rstatix) # latest version
library(ggpubr)  # latest version
stat.test <- melted.df %>%
  group_by(Time) %>%
  tukey_hsd(Size ~ Samples)

ggboxplot(melted.df, x = "Samples", y = "Size", facet.by = "Time") +
  stat_pvalue_manual(
    stat.test, label = "p.adj",
    y.position = c(2, 2.5, 3, 3.5, 3.8, 4)
  )
</code>```

Title: How to apply p-value for each group of dataframe in R using facet_wrap in ggpubr

Body:
I have a data that looks like this:

melted.df <- structure(list(Time = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 2L,
2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 1L, 1L,
1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L,
4L, 4L, 4L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 3L,
3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L,
2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L), .Label = c("24",
"36", "48", "72"), class = "factor"), id = c(1L, 2L, 3L, 4L,
5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L,
19L, 20L, 21L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L,
12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 1L, 2L, 3L,
4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L,
18L, 19L, 20L, 21L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L,
11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L), Samples = structure(c(1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L), .Label = c("WT_Ago2_800", "WT_Ago2_400", "WT_Ago2_200",
"WT_Ago4_800"), class = "factor"), Size = c(0, 0, 0, 0, 0, 0,
0.3, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0.5, 0.8, 0.5, 0, 0,
0, 0, 0, 0, 0.1, 0.65, 0.2, 0.85, 0.725, 0.575, 0.1, 1.1, 0.9,
1.325, 1, 0.8, 0.5, 2.2, 1.65, 0, 0, 0, 0, 0, 0, 0.825, 1.175,
0.1, 0.55, 0.85, 0.85, 1.1, 1.4, 0.6, 0.95, 1.15, 0.975, 2.35,
1.15, 2.1, 0, 0, 0, 0, 0, 0, 0.65, 1.4, 0.55, 0.1, 0.7, 1.1,
0.95, 1.85, 0.85, 0.1, 1.5, 1.25, 1.8, 1.75, 2.15)), row.names = c(NA,
-84L), class = "data.frame")

This data consists of 4 time frames (24, 36, 48 and 72 hours). I want to use the code below to paste the p values calculated as stat.test for each time.levels and apply that to each facet_wrap. If you check for i=1, there is no p-value so it's nothing you would want to apply to the figure, and if you do i=2, you would get p-values applied to the figure. The problem is that I couldn't get the p-value applied to its respective facets. It just applies same p-value in all facets. How can I get this resolved?

code:

library(devtools)
# install_github("https://github.com/kassambara/rstatix")
library(rstatix)  # https://github.com/kassambara/rstatix
library(stringi)
library(ggpubr)
time.levels <- levels(melted.df$Time)
stat.test <- NULL
for (i in 1:length(time.levels)){
  stat.test <- aov(Size ~ Samples, data = melted.df[melted.df$Time == time.levels[i],]) %>%
  tukey_hsd()
# stat.test <- rbind(stat.test, tmp.stat)
 bp <-  ggboxplot(melted.df, x = "Samples", y = "Size") +
    facet_wrap(vars(Time))+
    stat_pvalue_manual(
      stat.test, label = "p.adj",
      y.position = c(2, 2.5, 3, 3.5, 3.8, 4)
    )
 bp

}

Body:
You don't need to use gridExtra::grid.arrange.

Here is a clean solution.

library(rstatix) # latest version
library(ggpubr)  # latest version
stat.test <- melted.df %>%
  group_by(Time) %>%
  tukey_hsd(Size ~ Samples)

ggboxplot(melted.df, x = "Samples", y = "Size", facet.by = "Time") +
  stat_pvalue_manual(
    stat.test, label = "p.adj",
    y.position = c(2, 2.5, 3, 3.5, 3.8, 4)
  )


问:
Should we modify a function signature for unit testing?
Suppose we have a function add() as below:

```<code>void add(int a, int b) {
    int sum=a+b;
    cout<<sum;
    sendSumToStorage(sum);
}
</code>```

This simple function adds to input values, prints the sum to the console and also sends it to some external storage (say, a file).  This is how we ideally want it in the application (meaning, we don't want it to return anything).

For purposes of unit testing, is it valid (from a design perspective) if we modify the function signature so that it returns the sum?  We could then have a test like:

```<code>bool checkAdd() {
    int res=add(3, 4);
    if(res==7) return true;
    else return false;
}
</code>```

Better yet, is this (returning a value) the only way we could unit test it?  Is there some valid way in which we could unit test the add() function without changing the function signature?

答:
A function like the one in your example is considered really bad practice.

Why do I say this?

Well, you have a method called add which adds two numbers AND calls something else. Basically your method doesn't do one thing, but two, which violates the Single Responsibility Principle.

This makes things much harder to test because you can't test just the add method in isolation.

So you would separate that into two methods with good names which reflect what they do and test them separately.

If you don't want to have issues with state between your methods, you will have to start returning results where it makes sense.

Body:
Suppose we have a function add() as below:

void add(int a, int b) {
    int sum=a+b;
    cout<<sum;
    sendSumToStorage(sum);
}

This simple function adds to input values, prints the sum to the console and also sends it to some external storage (say, a file).  This is how we ideally want it in the application (meaning, we don't want it to return anything).

For purposes of unit testing, is it valid (from a design perspective) if we modify the function signature so that it returns the sum?  We could then have a test like:

bool checkAdd() {
    int res=add(3, 4);
    if(res==7) return true;
    else return false;
}

Better yet, is this (returning a value) the only way we could unit test it?  Is there some valid way in which we could unit test the add() function without changing the function signature?


问:
I am not able to Start Apache on XAMPP on my system windows 7 32 bit

I am not able to run/start Apache through XAMPP on my system windows 7 32 bit. The problem is after installing everything is working okay but Apache is not running or starting.

Getting the following error message:-

Initializing Control Panel    Windows Version: Windows 7 Ultimate  32-bit
      Initializing module...
      Checking for module existence...
      Checking for required tools...
      Checking for service (name="Apache2.4"): Service installed
  error message :     Apache Service detected with wrong path
  Change XAMPP Apache and Control Panel settings or
      Uninstall/disable the other service manually first
  Found Path: "C:\Apache24\bin\httpd.exe" -k runservice
  Expected Path: "c:\xampp\apache\bin\httpd.exe" -k

```<code>Checking default ports...
Executing "net start "Apache2.4""
Return code: 0
</code>```

I think my system is missing Port 80 which is used by Apache server to run - even I checked it on my system but there is no such port 80 on my system.

How to resolve this issue?

答:
I've encountered this issue on my Windows 10 environment. I've found that I've configured C:\xampp\apache\conf\extra\httpd-xampp.conf with a new SSLCertificateFile or SSLCertificateKeyFile in one of my virtual hosts that was not existing.

So in my httpd-xampp.conf I have the following:

```<code>## mywebsite.local config
<VirtualHost *:80>
    DocumentRoot "C:/xampp/htdocs/mywebsite.local"
    ServerName mywebsite.local
    ServerAlias *.mywebsite.local
</VirtualHost>
<VirtualHost *:443>
    DocumentRoot "C:/xampp/htdocs/mywebsite.local"
    ServerName mywebsite.local
    ServerAlias *.mywebsite.local
    ## these lines are for my local SSL, here is the issue
    SSLEngine on
    SSLCertificateFile "crt/mywebsite.local/server.crt" ## this path may not exist
    SSLCertificateKeyFile "crt/mywebsite.local/server.key" ## or even this line may not exist
</VirtualHost>
</code>```

I've found that the path from SSLCertificateFile and SSLCertificateKeyFile doesn't exist.

I've fixed it and not it's working.

All the best!

Body:
I am not able to run/start Apache through XAMPP on my system windows 7 32 bit. The problem is after installing everything is working okay but Apache is not running or starting.

Getting the following error message:-

Initializing Control Panel    Windows Version: Windows 7 Ultimate  32-bit
      Initializing module...
      Checking for module existence...
      Checking for required tools...
      Checking for service (name="Apache2.4"): Service installed
  error message :     Apache Service detected with wrong path
  Change XAMPP Apache and Control Panel settings or
      Uninstall/disable the other service manually first
  Found Path: "C:\Apache24\bin\httpd.exe" -k runservice
  Expected Path: "c:\xampp\apache\bin\httpd.exe" -k

Checking default ports...
Executing "net start "Apache2.4""
Return code: 0

I think my system is missing Port 80 which is used by Apache server to run - even I checked it on my system but there is no such port 80 on my system.

How to resolve this issue?

Body:
I've encountered this issue on my Windows 10 environment. I've found that I've configured C:\xampp\apache\conf\extra\httpd-xampp.conf with a new SSLCertificateFile or SSLCertificateKeyFile in one of my virtual hosts that was not existing.

So in my httpd-xampp.conf I have the following:

## mywebsite.local config
<VirtualHost *:80>
    DocumentRoot "C:/xampp/htdocs/mywebsite.local"
    ServerName mywebsite.local
    ServerAlias *.mywebsite.local
</VirtualHost>
<VirtualHost *:443>
    DocumentRoot "C:/xampp/htdocs/mywebsite.local"
    ServerName mywebsite.local
    ServerAlias *.mywebsite.local
    ## these lines are for my local SSL, here is the issue
    SSLEngine on
    SSLCertificateFile "crt/mywebsite.local/server.crt" ## this path may not exist
    SSLCertificateKeyFile "crt/mywebsite.local/server.key" ## or even this line may not exist
</VirtualHost>

I've found that the path from SSLCertificateFile and SSLCertificateKeyFile doesn't exist.

I've fixed it and not it's working.

All the best!


问:
Transferring Data From one DB2 database to other DB2 database
I have DB2 database installed on one server which contains all the data. Now I am trying to transfer all that data to another DB2 database which is on my local host. I have tried the following steps for this procedure.

On the server-

```<code>              db2 move DB_NAME export
</code>```

Copied the .lst and all files into my local host.

On my local host -

```<code>              db2 create database DB_NAME
              db2 -tvf DB_NAME.DDL
              db2 move DB_NAME import
</code>```

I have succeeded in moving the tables to my local host.

But somehow data was missing in my local host.
I am using DB2 version 10.5.1.
Any one please tell me the correct procedure for transferring the data.

Thanks in advance.

答:
For Single Table  to Move

db2move dbname export -tn tablename -u username -p password

For all tables in DB to Move

db2move dbname export -sn schema -u username -p password

tar , gzip and sftp to target directory

unzip , untar

for loading data to another database

db2move database load -io replace

Body:
I have DB2 database installed on one server which contains all the data. Now I am trying to transfer all that data to another DB2 database which is on my local host. I have tried the following steps for this procedure.

On the server-

              db2 move DB_NAME export

Copied the .lst and all files into my local host.

On my local host -

              db2 create database DB_NAME
              db2 -tvf DB_NAME.DDL
              db2 move DB_NAME import

I have succeeded in moving the tables to my local host.

But somehow data was missing in my local host.
I am using DB2 version 10.5.1.
Any one please tell me the correct procedure for transferring the data.

Thanks in advance.


问:
RabbitMQ - Need Channel per Machine?
We have multiple backend machines. The goal is to have each machine pick up each message sent to a single RabbitMQ exchange.

The FooExchange is set to fanout (so it sends a message to all the queues connected to it). FooExchange has one queue, FooQueue, which is bound to it. All our machines are consumers of FooQueue.

This works fine locally, but when we have multiple machines in play, it appears that only ONE machine picks up the message at a time. It picks up the message specifically 1 time / however many machines there are. This is corroborated by an old answer here.

I have several questions:

Is creating a queue per machine the best way to proceed?

The "machines" are actually going to be K8S pods - what should I use as a unique machine identifier in the queue name? Or just make instantiate a GUID and call it a day?

Finally, how do I handle pod restarts (if unfamiliar with K8S, think of a cloud load balancer spinning up new VM instances) - this will leave dead queue as the replacement pods/VMs create new ones to consume from.

答: There is no need to create FooQueue in every backend machine. RabbitMQ can support multiple connections. You can start a RabbitMQ consumer in each one of the backend machines. Make sure each consumer opens a new connection and consumes from the queue. If you want your consumer to consume one message at a time, set the basic.

Title: RabbitMQ - Need Channel per Machine?


问:
Javascript alert is not working in Update Panel in asp.net
I am working on asp.net web application.
I have one UpdatePanel and there is table inside table which has data in some TextBoxes.

I have one save button too inside this UpdatePanel
So I want to save this data into Database, when I click Save Button.

This is working fine till now.

But I want to show alert message to User that information saved successfully. I'm using javascript for this purpose, But Javascript is not working.
so is this possible to achieve the desired functionality using javascript, if yes then please guide me Or if there is any other alternative method except this please let me know.

Thanks,
Vivek

答:
Try this for popup sweetalert in asp vb.net

Dim message As String = " swal('Added!','Country Added Successfully.', 'success')"

ScriptManager.RegisterClientScriptBlock(TryCast(sender, Control), Me.GetType(), "sweetAlert", message, True)
```


问:
Plotting WordCloud for each Cluster in K Means Clustering
I have a set of BOW features and also I know the best n_clusters to be used.I need help in plotting a WordCloud per each cluster so that we can analyze the words in each cluster in one go.

Please refer any set of BOW features and take any n_cluster and I will relate it to my problem.

Consider below as features:

```<code>['aa', 'aahhhs', 'aback', 'abandon', 'abates', 'abbott', 'abby', 'abdominal', 'abiding', 'ability']
</code>```

and 3 as no of clusters.

答:
Lets say you fit your model:

```<code>from sklearn.cluster import KMeans
kmeans_bow = KMeans(n_clusters=3, n_jobs=-1).fit(X_train_bow)
</code>```

Your fitted model will have an attribute kmeans_bow.labels_. This basically tells you which datapoints have been assigned to which clusters. You might need to use  kmeans_bow.labels_.tolist()

So next step will be to use your bag of words vectorizer to get the feature names using features = bow_vect.get_feature_names() and assign them corresponding labels that you obtained above.

Using a for loop iterate over your data and make list[s] that contains words corresponding to each label. Just pass these list[s] as text to your WordCloud class with any customization that you may need.

Body:
I have a set of BOW features and also I know the best n_clusters to be used.I need help in plotting a WordCloud per each cluster so that we can analyze the words in each cluster in one go.

Please refer any set of BOW features and take any n_cluster and I will relate it to my problem.

Consider below as features:

['aa', 'aahhhs', 'aback', 'abandon', 'abates', 'abbott', 'abby', 'abdominal', 'abiding', 'ability']

and 3 as no of clusters.

Body:
Lets say you fit your model:

from sklearn.cluster import KMeans
kmeans_bow = KMeans(n_clusters=3, n_jobs=-1).fit(X_train_bow)

Your fitted model will have an attribute kmeans_bow.labels_. This basically tells you which datapoints have been assigned to which clusters. You might need to use  kmeans_bow.labels_.tolist()

So next step will be to use your bag of words vectorizer to get the feature names using features = bow_vect.get_feature_names() and assign them corresponding labels that you obtained above.

Using a for loop iterate over your data and make list[s] that contains words corresponding to each label. Just pass these list[s] as text to your WordCloud class with any customization that you may need.


问:
Count total user that subscribe and unsubscribe at the same day
I want to count total user that subscribe and unsubscribe the service at the same day.
The user will be the MSISDN and subscription will be OperationType.
If user subscribe, OperationType = 1, and if the user unsubscribe, OperationType = 2. The user can subscribe and unsubscribe the service on the same day.

Subscribe : OperationType = 1
Unsubscribe : OperationType = 2

Structure & Data of tbl_process
Refer to my data. I have two same user (which is MSISDN) that subscribe and later unsubscribe to the service.

This is my result based on query below. I somehow manage to get list of user that subscribe and unsubscribe on the same day. But now I want to count total user who got 2 OperationType, which is 1 & 2 (this is based on my query).

Below is my query:

SELECT DISTINCT(msisdn), operationType
FROM tbl_process
WHERE DATE(RequestTS) = '2019-03-14'
AND STATUS = 3
ORDER BY msisdn;```

答:
Try this</p>

```<code>select
  count(*)
from
  tbl_process t1
  inner join tbl_process t2 on DATE_FORMAT(t1.RequestTS, '%m-%d') = DATE_FORMAT(t2.RequestTS, '%m-%d')
  and t1.msisdn = t2.msisdn
  and t1.operationType = 1
  and t2.operationType = 2;
</code>```

Body:
Try this

select
  count(*)
from
  tbl_process t1
  inner join tbl_process t2 on DATE_FORMAT(t1.RequestTS, '%m-%d') = DATE_FORMAT(t2.RequestTS, '%m-%d')
  and t1.msisdn = t2.msisdn
  and t1.operationType = 1
  and t2.operationType = 2;


问:
Change color of line at runtime like microsoft paint in cocos2d
I have a scene where I have few colored buttons and upon clicking on that colored button's respective colored line should be drawn in cocos2d. Please help me out with this.

I have tried passing different colors in -(void)draw function but that doesn't work. What I want is like MS Paint where user can have different color selction whereas I have put few color buttons.

答:
While I can't think of answer for you directly you should take a look on the Cocos 2D forums for your answer.  I tried searching for "draw colored line" in the Cocos2D forums...

http://www.cocos2d-iphone.org/forum/search.php?q=draw+colored+line

Looks like it might be relevant to your situation.


问:
Wiremock Request Pattern Matching with Request Parameters
I am using spock and wiremock for functional testing in a Spring Boot 2.1.5 application. The incoming url is:

```<code>/mockedserver/v1/Items('1010873195')/Products?$format=json
</code>```

yes, its a pretty weird url, but I can't do anything about that.

I have set up a path matcher in JSON with:

```<code>{
  "request": {
    "method": "GET",
    "url": "/mockedserver/v1/Items('1010873195')/Products.*",
    "queryParams" : {
      "$format": "json"
    },
    "headers": {
      "x-csrf-token": "",
      "Accept": "application/json",
      "Content-Type": "application/json"
    }
  },
  "response": {
    "headers": {
      "Content-Type": "application/json"
    },
    "status": 200,
    "bodyFileName": "/../responses/mockedserver/get-products/1010873195-success-200.json"
  }
}
</code>```

As you might be able to see, I modelled the strange looking request parameter in the "queryParams" block. This didn't work, so I then put the regex, .*, on the end of the url.

Both gave me the result:

                                               Request was not matched
                                               =======================

-----------------------------------------------------------------------------------------------------------------------
| Closest stub                                             | Request                                                  |
-----------------------------------------------------------------------------------------------------------------------
                                                           |
GET                                                        | GET
/mockedserver/v1/Items('1010873195')/Produ                 | /mockedserver/v1/Items('1010873195')/Produ<<<<< URL does not match
cts                                                        | cts?$format=json
                                                           |
                                                           |
-----------------------------------------------------------------------------------------------------------------------

```

<p>As you can see, it matches, except the param part at the end, basically, I don't care about the param, so I was hoping to just wildcard it out.</p>

<p>One possibility is that the <code>$</code> sign is making a mess of things, should I be escaping it instead? if so, how?</p>

<p>The other is that its the question mark, <code>?</code>. I have tried escapting that with <code>\?</code> and <code>\\?</code>, both of which were unsuccessful.</p>

<p>Just concerning the part of the request block that looks important here:</p>

```    "method": "GET",
    "url": "/mockedserver/v1/Items('1010873195')/Products.*",
    "queryParams" : {
      "$format": "json"
    },
```

<p>I have seen it said elsewhere that if you use <code>urlPath</code> in place of <code>url</code> that WireMock treats extra headers or query parameters without match parameters as "don't care, match anyway". But this doesn't seem to be the case here as the error output shows.</p>

<p><strong>FURTHER DISCUSSION</strong>
I have since tried various combinations putting <code>urlPath</code>, <code>urlPattern</code> and even <code>urlPathPattern</code> as suggested, in place of <code>url</code>. All of these result in:</p>

<pre class="lang-sh prettyprint-override"><code>                                               Request was not matched
                                               =======================

-----------------------------------------------------------------------------------------------------------------------
| Closest stub                                             | Request                                                  |
-----------------------------------------------------------------------------------------------------------------------
                                                           |
GET                                                        | GET
                                                           | /mockedserver/v1/Items('1010873195')/Produ<<<<< URL does not match. URLs must start with a /
                                                           | cts?$format=json
                                                           |
                                                           |
-----------------------------------------------------------------------------------------------------------------------

</code>```

I have also tried this with and without the queryParams block, just in case this contributed to the matching, but it does not seem to have any effect.
I am beginning to wonder if there is some other flag i need to set in the stubFor call?

答:
I believe that you need to try "urlPathPattern" or "urlPath" instead of "url" in your mapping as the following:</p>

```<code>"urlPathPattern": "/mockedserver/v1/Items('1010873195')/Products.*"
</code>```

Body:
I am using spock and wiremock for functional testing in a Spring Boot 2.1.5 application. The incoming url is:

/mockedserver/v1/Items('1010873195')/Products?$format=json

yes, its a pretty weird url, but I can't do anything about that.

I have set up a path matcher in JSON with:

{
  "request": {
    "method": "GET",
    "url": "/mockedserver/v1/Items('1010873195')/Products.*",
    "queryParams" : {
      "$format": "json"
    },
    "headers": {
      "x-csrf-token": "",
      "Accept": "application/json",
      "Content-Type": "application/json"
    }
  },
  "response": {
    "headers": {
      "Content-Type": "application/json"
    },
    "status": 200,
    "bodyFileName": "/../responses/mockedserver/get-products/1010873195-success-200.json"
  }
}

As you might be able to see, I modelled the strange looking request parameter in the "queryParams" block. This didn't work, so I then put the regex, .*, on the end of the url.

Both gave me the result:

                                               Request was not matched
                                               =======================

-----------------------------------------------------------------------------------------------------------------------
| Closest stub                                             | Request                                                  |
-----------------------------------------------------------------------------------------------------------------------
                                                           |
GET                                                        | GET
/mockedserver/v1/Items('1010873195')/Produ                 | /mockedserver/v1/Items('1010873195')/Produ<<<<< URL does not match
cts                                                        | cts?$format=json
                                                           |
                                                           |
-----------------------------------------------------------------------------------------------------------------------

As you can see, it matches, except the param part at the end, basically, I don't care about the param, so I was hoping to just wildcard it out.

One possibility is that the $ sign is making a mess of things, should I be escaping it instead? if so, how?

The other is that its the question mark, ?. I have tried escapting that with \? and \\?, both of which were unsuccessful.

Just concerning the part of the request block that looks important here:

    "method": "GET",
    "url": "/mockedserver/v1/Items('1010873195')/Products.*",
    "queryParams" : {
      "$format": "json"
    },

I have seen it said elsewhere that if you use urlPath in place of url that WireMock treats extra headers or query parameters without match parameters as "don't care, match anyway". But this doesn't seem to be the case here as the error output shows.

FURTHER DISCUSSION
I have since tried various combinations putting urlPath, urlPattern and even urlPathPattern as suggested, in place of url. All of these result in:

                                               Request was not matched
                                               =======================

-----------------------------------------------------------------------------------------------------------------------
| Closest stub                                             | Request                                                  |
-----------------------------------------------------------------------------------------------------------------------
                                                           |
GET                                                        | GET
                                                           | /mockedserver/v1/Items('1010873195')/Produ<<<<< URL does not match. URLs must start with a /
                                                           | cts?$format=json
                                                           |
                                                           |
-----------------------------------------------------------------------------------------------------------------------

I have also tried this with and without the queryParams block, just in case this contributed to the matching, but it does not seem to have any effect.
I am beginning to wonder if there is some other flag i need to set in the stubFor call?

Body:
I believe that you need to try "urlPathPattern" or "urlPath" instead of "url" in your mapping as the following:

"urlPathPattern": "/mockedserver/v1/Items('1010873195')/Products.*"


问:
Cannot connect to the Docker daemon at unix:/var/run/docker.sock. Is the docker daemon running?
I have applied every solution available on internet but still I cannot run Docker.

I want to use Scrapy Splash on my server.

Here is history of commands I ran.

```<code>docker run -p 8050:8050 scrapinghub/splash
sudo docker run -p 8050:8050 scrapinghub/splash
sudo usermod -aG docker $(whoami)
sudo docker run -p 8050:8050 scrapinghub/splash
newgrp docker
sudo docker run -p 8050:8050 scrapinghub/splash
reboot
sudo docker run -p 8050:8050 scrapinghub/splash
docker run -p 8050:8050 scrapinghub/splash
</code>```

You can see I tried to restart my server as well, but it didnt help.

see output of ps -aux | grep docker

```<code>root@mani:/var/www/html# ps aux | grep docker
root      8524  0.0  0.8 127904 13964 ?        Ssl  17:21   0:00 /usr/bin/dockerd --raw-logs
root      8534  0.0  0.3  90588  5012 ?        Ssl  17:21   0:00 docker-containerd -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --metrics-interval=0 --start-timeout 2m --state-dir /var/run/docker/libcontainerd/containerd --shim docker-containerd-shim --runtime docker-runc
root      8543  0.0  0.0   8812   764 pts/1    S+   17:21   0:00 grep --color=auto docker
root     16356  0.0  0.0  17200   964 pts/1    S    17:14   0:00 newgrp docker
root     20080  0.0  0.0  17200   964 pts/1    S    17:06   0:00 newgrp docker
root     30221  0.0  0.0  17200   964 pts/1    S    17:09   0:00 newgrp docker
</code>```

but it gives the error:

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.

答:
This issue can be resolved permanently by running
1. systemctl enable docker
2. service docker start</p>

Body:
I have applied every solution available on internet but still I cannot run Docker.

I want to use Scrapy Splash on my server.

Here is history of commands I ran.

docker run -p 8050:8050 scrapinghub/splash
sudo docker run -p 8050:8050 scrapinghub/splash
sudo usermod -aG docker $(whoami)
sudo docker run -p 8050:8050 scrapinghub/splash
newgrp docker
sudo docker run -p 8050:8050 scrapinghub/splash
reboot
sudo docker run -p 8050:8050 scrapinghub/splash
docker run -p 8050:8050 scrapinghub/splash

You can see I tried to restart my server as well, but it didnt help.

see output of ps -aux | grep docker

root@mani:/var/www/html# ps aux | grep docker
root      8524  0.0  0.8 127904 13964 ?        Ssl  17:21   0:00 /usr/bin/dockerd --raw-logs
root      8534  0.0  0.3  90588  5012 ?        Ssl  17:21   0:00 docker-containerd -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --metrics-interval=0 --start-timeout 2m --state-dir /var/run/docker/libcontainerd/containerd --shim docker-containerd-shim --runtime docker-runc
root      8543  0.0  0.0   8812   764 pts/1    S+   17:21   0:00 grep --color=auto docker
root     16356  0.0  0.0  17200   964 pts/1    S    17:14   0:00 newgrp docker
root     20080  0.0  0.0  17200   964 pts/1    S    17:06   0:00 newgrp docker
root     30221  0.0  0.0  17200   964 pts/1    S    17:09   0:00 newgrp docker

but it gives the error:

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.


问:
Can I make Wordpress searchbar filter to give only articles from blog and not from woocommerce?
When using the searchbar in the "news" page of my Wordpress, it displays posts from the blog but also posts that are products from Woocommerce, or other pages / content. I would like it to display only blog posts.

I haven't found any solution yet. Also, Wordpress won't let me update the php files of the theme, so I think I need on-site settings / plugins.

Here is the news page : https://champagne-oudart.com/actualites/
The client wanted the news categories to be years.

答:
function modify_search_query( $query ) {
    // Make sure this isn't the admin or is the main query
    if( is_admin() || ! $query->is_main_query() ) {
      return;
    }

    // Make sure this isn't the WooCommerce product search form
    if( isset($_GET['post_type']) && ($_GET['post_type'] == 'product') ) {
      return;
    }

    if( $query->is_search() ) {
      $in_search_post_types = get_post_types( array( 'exclude_from_search' => false ) );

      // The post types you're removing (example: 'product' and 'page')
      $post_types_to_remove = array( 'product', 'page' );

      foreach( $post_types_to_remove as $post_type_to_remove ) {
        if( is_array( $in_search_post_types ) && in_array( $post_type_to_remove, $in_search_post_types ) ) {
          unset( $in_search_post_types[ $post_type_to_remove ] );
          $query->set( 'post_type', $in_search_post_types );
        }
      }
    }

  }
  add_action( 'pre_get_posts', 'modify_search_query' );```

add these lines to your functions.php

Body:
function modify_search_query( $query ) {
    // Make sure this isn't the admin or is the main query
    if( is_admin() || ! $query->is_main_query() ) {
      return;
    }

    // Make sure this isn't the WooCommerce product search form
    if( isset($_GET['post_type']) && ($_GET['post_type'] == 'product') ) {
      return;
    }

    if( $query->is_search() ) {
      $in_search_post_types = get_post_types( array( 'exclude_from_search' => false ) );

      // The post types you're removing (example: 'product' and 'page')
      $post_types_to_remove = array( 'product', 'page' );

      foreach( $post_types_to_remove as $post_type_to_remove ) {
        if( is_array( $in_search_post_types ) && in_array( $post_type_to_remove, $in_search_post_types ) ) {
          unset( $in_search_post_types[ $post_type_to_remove ] );
          $query->set( 'post_type', $in_search_post_types );
        }
      }
    }

  }
  add_action( 'pre_get_posts', 'modify_search_query' );

add these lines to your functions.php


问:
Can't find the redirect 'configuration file'
I am working on a website, it uses addon domain egcourse.id, and I want to develop it in different domain test.egcourse.com (egcourse.com is the main domain). So the result will be like this:

public_html

egcourse.id

test.egcourse.com

but when I try to access test.egcourse.com it redirects me (301 moved permanently) back to egcourse.id.

I have looked in cPanel and it has no redirects configured.
Ok, maybe it's the .htaccess, but everything looks normal:

```<code># BEGIN LSCACHE
# END LSCACHE
# BEGIN NON_LSCACHE
# END NON_LSCACHE

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
</code>```

Maybe I missed somewhere... but I don't know where to look. Any help will be appreciated.

(and sorry for bad English)

答:
Your cpanel must have an option to create sub-domain. Please have a look for that option within the cpanel. Clicking to that option you will have the option to create a sub-domain and list down the root directory of your project under public_html that will be in sync to that specific sub-domain. Regarding the redirects, you might also find a redirects option where you will able to do 301 permanent redirects for your sud-domain. Also, you can do the redirects using the htaccess. </p>

```<code>RewriteEngine On
RewriteCond %{HTTP_HOST} ^sub\.domain\.com$ [NC]
RewriteRule ^(.*) http://newsub.domain.com/ [L,R]
</code>```

Body:
I am working on a website, it uses addon domain egcourse.id, and I want to develop it in different domain test.egcourse.com (egcourse.com is the main domain). So the result will be like this:

public_html

egcourse.id

test.egcourse.com

but when I try to access test.egcourse.com it redirects me (301 moved permanently) back to egcourse.id.

I have looked in cPanel and it has no redirects configured.
Ok, maybe it's the .htaccess, but everything looks normal:

# BEGIN LSCACHE
# END LSCACHE
# BEGIN NON_LSCACHE
# END NON_LSCACHE

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

Maybe I missed somewhere... but I don't know where to look. Any help will be appreciated.

(and sorry for bad English)

Body:
Your cpanel must have an option to create sub-domain. Please have a look for that option within the cpanel. Clicking to that option you will have the option to create a sub-domain and list down the root directory of your project under public_html that will be in sync to that specific sub-domain. Regarding the redirects, you might also find a redirects option where you will able to do 301 permanent redirects for your sud-domain. Also, you can do the redirects using the htaccess.

RewriteEngine On
RewriteCond %{HTTP_HOST} ^sub\.domain\.com$ [NC]
RewriteRule ^(.*) http://newsub.domain.com/ [L,R]


问:
LayoutResult more one page in Itext7
i ask this: Remove the first and last lines properties in the paper Itext7

and if i do it:

```<code> PdfWriter pdfWriter = new PdfWriter(dest);

    PdfDocument pdfDoc = new PdfDocument(pdfWriter);
    Div div = new Div();
    Document doc = new Document(pdfDoc, PageSize.A5);
    doc.setMargins(0,0,0,36);

    for (int i = 0; i <50 ; i++) {
        ListItem listItem = new ListItem();
        String s= "hello "+i;
        Paragraph p = new Paragraph();
        for (int j = 0; j <s.length() ; j++) {

            p.add("HELLO " +I);

        }

  LayoutResult result = div.createRendererSubTree().setParent(doc.getRenderer()).layout(new LayoutContext(new LayoutArea(0,PageSize.A5)));

List<IRenderer> childRendererParagraph = result.getSplitRenderer().getChildRenderers();
</code>```

childRendererParagraph contain Paragraphs only from first page.And i don't know how many pages well be in pdf

答:
As I mentioned in the answer to your previous question,

split renderer represent the part of the content which iText can place on the area, overflow - the content which overflows.

So if you want to layout the rest of the content, you can perform the same operation (layout) on your overflowRenderer.

The code is as follows:

```<code>    LayoutResult firstPageResult = div.createRendererSubTree().setParent(doc.getRenderer()).layout(new LayoutContext(new LayoutArea(0, PageSize.A5)));
    LayoutResult secondPageResult  = firstPageResult.getOverflowRenderer().layout(new LayoutContext(new LayoutArea(1, PageSize.A5)));
</code>```

Once the content has been fully placed, the overflowRenderer will be null.

Title: LayoutResult more one page in Itext7

Body:
i ask this: Remove the first and last lines properties in the paper Itext7

and if i do it:

 PdfWriter pdfWriter = new PdfWriter(dest);

    PdfDocument pdfDoc = new PdfDocument(pdfWriter);
    Div div = new Div();
    Document doc = new Document(pdfDoc, PageSize.A5);
    doc.setMargins(0,0,0,36);

    for (int i = 0; i <50 ; i++) {
        ListItem listItem = new ListItem();
        String s= "hello "+i;
        Paragraph p = new Paragraph();
        for (int j = 0; j <s.length() ; j++) {

            p.add("HELLO " +I);

        }

  LayoutResult result = div.createRendererSubTree().setParent(doc.getRenderer()).layout(new LayoutContext(new LayoutArea(0,PageSize.A5)));

List<IRenderer> childRendererParagraph = result.getSplitRenderer().getChildRenderers();

childRendererParagraph contain Paragraphs only from first page.And i don't know how many pages well be in pdf

Body:
As I mentioned in the answer to your previous question,

split renderer represent the part of the content which iText can place on the area, overflow - the content which overflows.

So if you want to layout the rest of the content, you can perform the same operation (layout) on your overflowRenderer.

The code is as follows:

    LayoutResult firstPageResult = div.createRendererSubTree().setParent(doc.getRenderer()).layout(new LayoutContext(new LayoutArea(0, PageSize.A5)));
    LayoutResult secondPageResult  = firstPageResult.getOverflowRenderer().layout(new LayoutContext(new LayoutArea(1, PageSize.A5)));

Once the content has been fully placed, the overflowRenderer will be null.