问:
How to update ag-grid versions?
Previously I used:

"ag-grid": "^18.1.2",

"ag-grid-angular": "^18.1.1"

"ag-grid-enterprise": "^18.1.1" version.

Since the licence was expired I got the new version licences.

And then I added:

"@ag-grid-community/angular": "^22.1.1",

"@ag-grid-community/core": "^22.1.1",

"@ag-grid-enterprise/all-modules": "^22.1.1",

"@ag-grid-enterprise/core": "^22.1.1",

"@ag-grid-community/client-side-row-model": "^22.1.1",

And also I added

```<code>@import "./node_modules/@ag-grid-enterprise/all-modules/dist/styles/ag-grid.scss";
@import "./node_modules/@ag-grid-enterprise/all-modules/dist/styles/ag-theme-balham/sass/ag-theme-balham.scss";
@import "../node_modules/@angular/material/prebuilt-themes/deeppurple-amber.css";
</code>```

to styles.css file.

But row lines are missed in ag-grid for an updated version.

If you can give me suggestions it will be a great help for me.

This is another image of ag-grid.

答:
Maybe this helps...my package.json looks slightly different than yours:</p>

```<code>"ag-grid-angular": "^22.1.1",
"ag-grid-community": "^22.1.1",
"ag-grid-enterprise": "^22.1.1",
</code>```

Title: How to update ag-grid versions?

Body:
Previously I used:

"ag-grid": "^18.1.2",

"ag-grid-angular": "^18.1.1"

"ag-grid-enterprise": "^18.1.1" version.

Since the licence was expired I got the new version licences.

And then I added:

"@ag-grid-community/angular": "^22.1.1",

"@ag-grid-community/core": "^22.1.1",

"@ag-grid-enterprise/all-modules": "^22.1.1",

"@ag-grid-enterprise/core": "^22.1.1",

"@ag-grid-community/client-side-row-model": "^22.1.1",

And also I added

@import "./node_modules/@ag-grid-enterprise/all-modules/dist/styles/ag-grid.scss";
@import "./node_modules/@ag-grid-enterprise/all-modules/dist/styles/ag-theme-balham/sass/ag-theme-balham.scss";
@import "../node_modules/@angular/material/prebuilt-themes/deeppurple-amber.css";

to styles.css file.

But row lines are missed in ag-grid for an updated version.

If you can give me suggestions it will be a great help for me.

This is another image of ag-grid.

Body:
Maybe this helps...my package.json looks slightly different than yours:

"ag-grid-angular": "^22.1.1",
"ag-grid-community": "^22.1.1",
"ag-grid-enterprise": "^22.1.1",


来源: stackexchange

问:
Tensorflow Object Detection AttributeError: module 'tensorflow._api.v1.compat' has no attribute 'v2'
Currently running TF 1.13.2

I'm trying to train my own object detection model. After trying to run this command:

```<code>python model_main.py --logtostderr --model_dir=training/ --pipeline_config_path=traini
ng/faster_rcnn_inception_v2_pets.config
</code>```

I get this error:

```<code>Traceback (most recent call last):
  File "model_main.py", line 26, in <module>
    from object_detection import model_lib
  File "C:\Users\Admin\Anaconda3\envs\object_detection\lib\site-packages\object_detection-0.1-py3.6.egg\object_detection\model_lib.py", line 28, in <module>
    from object_detection import exporter as exporter_lib
  File "C:\Users\Admin\Anaconda3\envs\object_detection\lib\site-packages\object_detection-0.1-py3.6.egg\object_detection\exporter.py", line 24, in <module>
    from object_detection.builders import model_builder
  File "C:\Users\Admin\Anaconda3\envs\object_detection\lib\site-packages\object_detection-0.1-py3.6.egg\object_detection\builders\model_builder.py", line 47, in <module>
    from object_detection.models.ssd_mobilenet_edgetpu_feature_extractor import SSDMobileNetEdgeTPUFeatureExtractor
  File "C:\Users\Admin\Anaconda3\envs\object_detection\lib\site-packages\object_detection-0.1-py3.6.egg\object_detection\models\ssd_mobilenet_edgetpu_feature_extractor.py", line
 19, in <module>
    from object_detection.models import ssd_mobilenet_v3_feature_extractor
  File "C:\Users\Admin\Anaconda3\envs\object_detection\lib\site-packages\object_detection-0.1-py3.6.egg\object_detection\models\ssd_mobilenet_v3_feature_extractor.py", line 25,
in <module>
    from nets.mobilenet import mobilenet
  File "C:\Users\Admin\Desktop\ObjectDetection\models\research\object_detection\nets\mobilenet\mobilenet.py", line 399, in <module>
    def global_pool(input_tensor, pool_op=tf.compat.v2.nn.avg_pool2d):
AttributeError: module 'tensorflow._api.v1.compat' has no attribute 'v2'
</code>```

I need to stay below TF 2.x because 2.x does not yet allow for training your own model (according to Gilbert Tanner's object detection tutorial). I've bounced around between TF versions and I've gotten similar errors in different versions that some module has no attribute 'v1'. In either case, I'm not sure at all how to fix this.

Edit:
Here are the site-packages for my environment:

```<code>Package Version Latest Version
absl-py 0.9.0   0.8.1
astor   0.8.1   0.8.0
biwrap  0.1.6
bleach  1.5.0   3.1.0
certifi 2019.11.28  2019.11.28
gast    0.3.3   0.3.2
grpcio  1.27.0  1.16.1
h5py    2.10.0  2.10.0
html5lib    1.000000    1.0.1
keras-applications  1.0.8   1.0.8
keras-preprocessing 1.1.0   1.1.0
markdown    3.1.1   3.1.1
mock    3.0.5   3.0.5
numpy   1.18.1  1.18.1
object-detection    0.100000
pandas  1.0.0   1.0.0
pillow  7.0.0   7.0.0
pip 20.0.2  20.0.2
protobuf    3.11.3  3.11.2
pycocotools 2.000000
python  3.6.10  3.8.1
python-dateutil 2.8.1   2.8.1
pytz    2019.300000 2019.300000
setuptools  39.1.0  45.1.0
six 1.14.0  1.14.0
sqlite  3.31.1  3.31.1
tensorboard 1.9.0   2.0.0
tensorflow  1.9.0   2.0.0
tensorflow-estimator    1.13.0  2.0.0
tensorflow-plot 0.3.0
tensorflow-tensorboard  1.5.1
termcolor   1.1.0   1.1.0
vc  14.100000   14.100000
vs2015_runtime  14.16.27012 14.16.27012
werkzeug    0.16.1  0.16.1
wheel   0.34.2  0.34.2
wincertstore    0.200000    0.200000
</code>```

答:
EDIT: from experience you are using a TF2 designed model in a TF1 application.

Did you clone the models from Github? The repository is based on the latest TF

You can use the models designed for 1.13 specifically: https://github.com/tensorflow/models/archive/v1.13.0.zip

reboot to clear EXPORT PATH

cd models/models-1.13.0/research/

```<code>protoc object_detection/protos/*.proto --python_out=.

export PYTHONPATH=$PYTHONPATH:`pwd`:`pwd`/slim
</code>```

cd ../../..

```<code>python3 github/TensorFlow-object-detection-tutorial-master/5_part\ step\ by\ step\ custom\ object\ detection/train.py --logtostderr
--train_dir=training/ --pipeline_config_path=dataset/data1/faster_rcnn_inception_v2_coco_tf13.config
</code>```

Solved the issue
EDIT: made the TF training on GCP and on Edge (jetson nano) too, feel free to up if you need moar backup.

source

ContentLicense: CC BY-SA 4.0

Body:
Currently running TF 1.13.2

I'm trying to train my own object detection model. After trying to run this command:

python model_main.py --logtostderr --model_dir=training/ --pipeline_config_path=traini
ng/faster_rcnn_inception_v2_pets.config

I get this error:

Traceback (most recent call last):
  File "model_main.py", line 26, in <module>
    from object_detection import model_lib
  File "C:\Users\Admin\Anaconda3\envs\object_detection\lib\site-packages\object_detection-0.1-py3.6.egg\object_detection\model_lib.py", line 28, in <module>
    from object_detection import exporter as exporter_lib
  File "C:\Users\Admin\Anaconda3\envs\object_detection\lib\site-packages\object_detection-0.1-py3.6.egg\object_detection\exporter.py", line 24, in <module>
    from object_detection.builders import model_builder
  File "C:\Users\Admin\Anaconda3\envs\object_detection\lib\site-packages\object_detection-0.1-py3.6.egg\object_detection\builders\model_builder.py", line 47, in <module>
    from object_detection.models.ssd_mobilenet_edgetpu_feature_extractor import SSDMobileNetEdgeTPUFeatureExtractor
  File "C:\Users\Admin\Anaconda3\envs\object_detection\lib\site-packages\object_detection-0.1-py3.6.egg\object_detection\models\ssd_mobilenet_edgetpu_feature_extractor.py", line
 19, in <module>
    from object_detection.models import ssd_mobilenet_v3_feature_extractor
  File "C:\Users\Admin\Anaconda3\envs\object_detection\lib\site-packages\object_detection-0.1-py3.6.egg\object_detection\models\ssd_mobilenet_v3_feature_extractor.py", line 25,
in <module>
    from nets.mobilenet import mobilenet
  File "C:\Users\Admin\Desktop\ObjectDetection\models\research\object_detection\nets\mobilenet\mobilenet.py", line 399, in <module>
    def global_pool(input_tensor, pool_op=tf.compat.v2.nn.avg_pool2d):
AttributeError: module 'tensorflow._api.v1.compat' has no attribute 'v2'

I need to stay below TF 2.x because 2.x does not yet allow for training your own model (according to Gilbert Tanner's object detection tutorial). I've bounced around between TF versions and I've gotten similar errors in different versions that some module has no attribute 'v1'. In either case, I'm not sure at all how to fix this.

Edit:
Here are the site-packages for my environment:

Package Version Latest Version
absl-py 0.9.0   0.8.1
astor   0.8.1   0.8.0
biwrap  0.1.6
bleach  1.5.0   3.1.0
certifi 2019.11.28  2019.11.28
gast    0.3.3   0.3.2
grpcio  1.27.0  1.16.1
h5py    2.10.0  2.10.0
html5lib    1.000000    1.0.1
keras-applications  1.0.8   1.0.8
keras-preprocessing 1.1.0   1.1.0
markdown    3.1.1   3.1.1
mock    3.0.5   3.0.5
numpy   1.18.1  1.18.1
object-detection    0.100000
pandas  1.0.0   1.0.0
pillow  7.0.0   7.0.0
pip 20.0.2  20.0.2
protobuf    3.11.3  3.11.2
pycocotools 2.000000
python  3.6.10  3.8.1
python-dateutil 2.8.1   2.8.1
pytz    2019.300000 2019.300000
setuptools  39.1.0  45.1.0
six 1.14.0  1.14.0
sqlite  3.31.1  3.31.1
tensorboard 1.9.0   2.0.0
tensorflow  1.9.0   2.0.0
tensorflow-estimator    1.13.0  2.0.0
tensorflow-plot 0.3.0
tensorflow-tensorboard  1.5.1
termcolor   1.1.0   1.1.0
vc  14.100000   14.100000
vs2015_runtime  14.16.27012 14.16.27012
werkzeug    0.16.1  0.16.1
wheel   0.34.2  0.34.2
wincertstore    0.200000    0.200000

Body:
EDIT: from experience you are using a TF2 designed model in a TF1 application.

Did you clone the models from Github? The repository is based on the latest TF

You can use the models designed for 1.13 specifically: https://github.com/tensorflow/models/archive/v1.13.0.zip

reboot to clear EXPORT PATH

cd models/models-1.13.0/research/

protoc object_detection/protos/*.proto --python_out=.

export PYTHONPATH=$PYTHONPATH:`pwd`:`pwd`/slim

cd ../../..

python3 github/TensorFlow-object-detection-tutorial-master/5_part\ step\ by\ step\ custom\ object\ detection/train.py --logtostderr
--train_dir=training/ --pipeline_config_path=dataset/data1/faster_rcnn_inception_v2_coco_tf13.config

Solved the issue
EDIT: made the TF training on GCP and on Edge (jetson nano) too, feel free to up if you need moar backup.

source


问:
How to calculate the time spent when using got?
Example code:

```<code>const got = require('got');
async function timeSpent (){
   const time = new Date().getTime()
   await got('***')
   return new Date().getTime() - time
}
</code>```

I wonder if there is a better way?

答:
It's not required to implement your own timing logic when using got.

The response includes a timings object that collects all millis spent per phase.

You only need to read out timings.phases.total from the response object.

```<code>const path = "http://localhost:3000/authenticate";
const response = await got.post(path, {
  body: { username: "john_doe", password: "mypass" },
  json: true,
  headers: {
    Accept: "application/json",
    "Content-type": "application/json",
  },
});

logger.debug({type: 'performance', path, duration: response.timings.phases.total});
</code>```

Reference:

https://github.com/sindresorhus/got#timings

https://github.com/sindresorhus/got/pull/590

Body:
Example code:

const got = require('got');
async function timeSpent (){
   const time = new Date().getTime()
   await got('***')
   return new Date().getTime() - time
}

I wonder if there is a better way?

Body:
It's not required to implement your own timing logic when using got.

The response includes a timings object that collects all millis spent per phase.

You only need to read out timings.phases.total from the response object.

const path = "http://localhost:3000/authenticate";
const response = await got.post(path, {
  body: { username: "john_doe", password: "mypass" },
  json: true,
  headers: {
    Accept: "application/json",
    "Content-type": "application/json",
  },
});

logger.debug({type: 'performance', path, duration: response.timings.phases.total});

Reference:

https://github.com/sindresorhus/got#timings

https://github.com/sindresorhus/got/pull/590


问:
R: Sum specific columns grouped by a particular column
I have a data frame that looks like this:

```<code>Col1 Col2 Col3 Col4
10    A    5    4
10    A    6    3
30    B    2    7
45    C    5    1
45    C    2    1
</code>```

I want to sum columns 3 and 4 only grouped by Col2, such that my resulting data frame looks like

```<code>Col1 Col2 Col3 Col4
10    A    11    7
30    B    2     7
45    C    7     2
</code>```

Col1 is an identifier for Col2 so I want that to remain. Thanks

答:
1.Minimal reproducible example data:

```<code>df <- structure(list(Col1 = c(10L, 10L, 30L, 45L, 45L),
                     Col2 = c("A", "A", "B", "C", "C"),
                     Col3 = c(5L, 6L, 2L, 5L, 2L),
                     Col4 = c(4L, 3L, 7L, 1L, 1L)),
                row.names = c(NA, -5L), class = "data.frame")
</code>```

2.Solution using dplyr

```<code>library(dplyr)

df %>%
group_by(Col1, Col2) %>%
summarise(Col3 = sum(Col3),
          Col4 = sum(Col4))
</code>```

Returns:

```<code>   Col1 Col2   Col3  Col4
  <int> <chr> <int> <int>
1    10 A        11     7
2    30 B         2     7
3    45 C         7     2
</code>```

Body:
I have a data frame that looks like this:

Col1 Col2 Col3 Col4
10    A    5    4
10    A    6    3
30    B    2    7
45    C    5    1
45    C    2    1

I want to sum columns 3 and 4 only grouped by Col2, such that my resulting data frame looks like

Col1 Col2 Col3 Col4
10    A    11    7
30    B    2     7
45    C    7     2

Col1 is an identifier for Col2 so I want that to remain. Thanks

Body:
1.Minimal reproducible example data:

df <- structure(list(Col1 = c(10L, 10L, 30L, 45L, 45L),
                     Col2 = c("A", "A", "B", "C", "C"),
                     Col3 = c(5L, 6L, 2L, 5L, 2L),
                     Col4 = c(4L, 3L, 7L, 1L, 1L)),
                row.names = c(NA, -5L), class = "data.frame")

2.Solution using dplyr

library(dplyr)

df %>%
group_by(Col1, Col2) %>%
summarise(Col3 = sum(Col3),
          Col4 = sum(Col4))

Returns:

   Col1 Col2   Col3  Col4
  <int> <chr> <int> <int>
1    10 A        11     7
2    30 B         2     7
3    45 C         7     2


问:
STL container with a specific type as a generic argument
Is there any way that I can make a function which takes a container with a specific type (lets say std::string) as a parameter

```<code>void foo(const std::container<std::string> &cont)
{
   for(std::string val: cont) {
      std::cout << val << std::endl;
   }
}
</code>```

and call it for every type of stl container as input? like above?

```<code>std::set<std::string> strset;
std::vector<std::string> strvec;
std::list<std::string> strlist;

foo(strset);
foo(strvec);
foo(strlist);
</code>```

答:
Depending on if you want to overload foo for other cases or not

```<code>// Doesn't participate in overload resolution when not applicable
template<typename Container, typename = std::enable_if_t<std::is_same_v<typename Container::value_type, std::string>>>
void foo(const Container &cont) {
   for(std::string val: cont) {
      std::cout << val << std::endl;
   }
}

// simpler
template<typename Container>
void foo(const Container &cont) {
   static_assert(std::is_same_v<typename Container::value_type, std::string>, "Container must contain std::string")
   for(std::string val: cont) {
      std::cout << val << std::endl;
   }
}
</code>```

You might use a different test to std::is_same, such as std::is_convertible to allow

```<code>std::vector<char *> c_strings;
foo(c_strings);
</code>```

Body:
Is there any way that I can make a function which takes a container with a specific type (lets say std::string) as a parameter

void foo(const std::container<std::string> &cont)
{
   for(std::string val: cont) {
      std::cout << val << std::endl;
   }
}

and call it for every type of stl container as input? like above?

std::set<std::string> strset;
std::vector<std::string> strvec;
std::list<std::string> strlist;

foo(strset);
foo(strvec);
foo(strlist);

Body:
Depending on if you want to overload foo for other cases or not

// Doesn't participate in overload resolution when not applicable
template<typename Container, typename = std::enable_if_t<std::is_same_v<typename Container::value_type, std::string>>>
void foo(const Container &cont) {
   for(std::string val: cont) {
      std::cout << val << std::endl;
   }
}

// simpler
template<typename Container>
void foo(const Container &cont) {
   static_assert(std::is_same_v<typename Container::value_type, std::string>, "Container must contain std::string")
   for(std::string val: cont) {
      std::cout << val << std::endl;
   }
}

You might use a different test to std::is_same, such as std::is_convertible to allow

std::vector<char *> c_strings;
foo(c_strings);


问:
Powershell Get-EventLog find event with the matching string in its message
I need to look through eventLog security ID 4648, and find the last time the user connected to the machine.

Currently this is my code:

```<code>$Values = invoke-command  -ComputerName $ComputerName {Get-EventLog -LogName Security -InstanceID 4648 | Select-Object -ExpandProperty Message| ForEach-Object {if($_.Log -match "$String2"){
$_
Break }}}
$Values
</code>```

The aim was to go through each log until a log where the message has the previously defined username is found, and then stop going through EventLog and return that log.

This is working well, except its not matching the correct log with the specified string.

Is there a way to improve how the matching works? So it actually finds the correct log with the specified user?

答:
```<code># Fill in the regex for the userName
$userName = "userName"
$Values = @(invoke-command  -ComputerName $ComputerName {
    Get-EventLog -LogName Security -InstanceID 4648 |  Where-Object { $_.message -match $Using:userName } | Select-Object -First 1)
}

</code>```

Your above sample won't work since message is of type string, therefore it doesn't have a Log property. Since we want $userName to be avaiable for read access on the remote machine we can use the $Using: syntax. To break the pipeline "iteration" I'm using Select-Object -First 1 which will return the first object passing the Where-Objectclause.

Resulting from that $Values points to a collection of (deserialized) objects (using the @() operator) of type:

```<code> TypeName: System.Diagnostics.EventLogEntry#Security/Microsoft-Windows-Security-Auditing/4648
</code>```

Which means you can change the -First parameter to e.g. 10 and sort the result on the client machine:

```<code>$Values | sort TimeGenerated -Descending
</code>```

If you want to know which properties are available you can use:

```<code>> $Values | gm

   TypeName: System.Diagnostics.EventLogEntry#Security/Microsoft-Windows-Security-Auditing/4648

Name                      MemberType     Definition
----                      ----------     ----------
Disposed                  Event          System.EventHandler Disposed(System.Object, System.EventArgs)
CreateObjRef              Method         System.Runtime.Remoting.ObjRef CreateObjRef(type requestedType)
Dispose                   Method         void Dispose(), void IDisposable.Dispose()
Equals                    Method         bool Equals(System.Diagnostics.EventLogEntry otherEntry), bool Equals(System.Object obj)
GetHashCode               Method         int GetHashCode()
GetLifetimeService        Method         System.Object GetLifetimeService()
GetObjectData             Method         void ISerializable.GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
GetType                   Method         type GetType()
InitializeLifetimeService Method         System.Object InitializeLifetimeService()
ToString                  Method         string ToString()
Category                  Property       string Category {get;}
CategoryNumber            Property       int16 CategoryNumber {get;}
Container                 Property       System.ComponentModel.IContainer Container {get;}
Data                      Property       byte[] Data {get;}
EntryType                 Property       System.Diagnostics.EventLogEntryType EntryType {get;}
Index                     Property       int Index {get;}
InstanceId                Property       long InstanceId {get;}
MachineName               Property       string MachineName {get;}
Message                   Property       string Message {get;}
ReplacementStrings        Property       string[] ReplacementStrings {get;}
Site                      Property       System.ComponentModel.ISite Site {get;set;}
Source                    Property       string Source {get;}
TimeGenerated             Property       datetime TimeGenerated {get;}
TimeWritten               Property       datetime TimeWritten {get;}
UserName                  Property       string UserName {get;}
EventID                   ScriptProperty System.Object EventID {get=$this.get_EventID() -band 0xFFFF;}

</code>```

Hope that helps.

Body:
I need to look through eventLog security ID 4648, and find the last time the user connected to the machine.

Currently this is my code:

$Values = invoke-command  -ComputerName $ComputerName {Get-EventLog -LogName Security -InstanceID 4648 | Select-Object -ExpandProperty Message| ForEach-Object {if($_.Log -match "$String2"){
$_
Break }}}
$Values

The aim was to go through each log until a log where the message has the previously defined username is found, and then stop going through EventLog and return that log.

This is working well, except its not matching the correct log with the specified string.

Is there a way to improve how the matching works? So it actually finds the correct log with the specified user?

Body:
# Fill in the regex for the userName
$userName = "userName"
$Values = @(invoke-command  -ComputerName $ComputerName {
    Get-EventLog -LogName Security -InstanceID 4648 |  Where-Object { $_.message -match $Using:userName } | Select-Object -First 1)
}

Your above sample won't work since message is of type string, therefore it doesn't have a Log property. Since we want $userName to be avaiable for read access on the remote machine we can use the $Using: syntax. To break the pipeline "iteration" I'm using Select-Object -First 1 which will return the first object passing the Where-Objectclause.

Resulting from that $Values points to a collection of (deserialized) objects (using the @() operator) of type:

 TypeName: System.Diagnostics.EventLogEntry#Security/Microsoft-Windows-Security-Auditing/4648

Which means you can change the -First parameter to e.g. 10 and sort the result on the client machine:

$Values | sort TimeGenerated -Descending

If you want to know which properties are available you can use:

> $Values | gm

   TypeName: System.Diagnostics.EventLogEntry#Security/Microsoft-Windows-Security-Auditing/4648

Name                      MemberType     Definition
----                      ----------     ----------
Disposed                  Event          System.EventHandler Disposed(System.Object, System.EventArgs)
CreateObjRef              Method         System.Runtime.Remoting.ObjRef CreateObjRef(type requestedType)
Dispose                   Method         void Dispose(), void IDisposable.Dispose()
Equals                    Method         bool Equals(System.Diagnostics.EventLogEntry otherEntry), bool Equals(System.Object obj)
GetHashCode               Method         int GetHashCode()
GetLifetimeService        Method         System.Object GetLifetimeService()
GetObjectData             Method         void ISerializable.GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
GetType                   Method         type GetType()
InitializeLifetimeService Method         System.Object InitializeLifetimeService()
ToString                  Method         string ToString()
Category                  Property       string Category {get;}
CategoryNumber            Property       int16 CategoryNumber {get;}
Container                 Property       System.ComponentModel.IContainer Container {get;}
Data                      Property       byte[] Data {get;}
EntryType                 Property       System.Diagnostics.EventLogEntryType EntryType {get;}
Index                     Property       int Index {get;}
InstanceId                Property       long InstanceId {get;}
MachineName               Property       string MachineName {get;}
Message                   Property       string Message {get;}
ReplacementStrings        Property       string[] ReplacementStrings {get;}
Site                      Property       System.ComponentModel.ISite Site {get;set;}
Source                    Property       string Source {get;}
TimeGenerated             Property       datetime TimeGenerated {get;}
TimeWritten               Property       datetime TimeWritten {get;}
UserName                  Property       string UserName {get;}
EventID                   ScriptProperty System.Object EventID {get=$this.get_EventID() -band 0xFFFF;}

Hope that helps.


问:
Best practice for printing in flex?
I'm looking to print my view to an A5-printer but when I test the print functionality to pdf, I always get a narrow and long printout.

Is there a way to set the pageheight and width? According to adobe help it's read-only.

Does anyone have experience with printing in flex?

答:
Have a look on the following:
http://www.kalengibbons.com/blog/index.php/2009/04/custom-printing-with-flex-part-3-printing-data/

This may help.

ContentLicense: CC BY-SA 3.0

Title: Best practice for printing in flex?


问:
liquibase does not generate table DATABASECHANGELOG
I'm new to liquibase and I want to use it on an database in production.
It's a small application, but instead of creating schema by hand I would like to use something more professional like liquibase.

What I plan to do is to make a changelog between the current schema in production and the new schema ready for the new application. I've followed many tutorials but there is still something missing. The output changelog.xml always imports all the schema and doesn't make the difference with the existing. I saw that liquibase had to create the table DATABASECHANGELOG but I couldn't see them on my computer.

What I did :

dump of the current db in production and import on dev computer

from core project added liquibase.properties and launched the following command : mvn clean resources:resources liquibase:generateChangeLog

this generated a master.xml with all the schema, but didn't create the tables DATABASECHANGELOG in DB (the table DATABASECHANGELOGLOCK was created when commenting outputChangeLogFile, and the LOCKED value is 0)

created manually the DATABASECHANGELOG from http://www.liquibase.org/databases.html

rerun the command mvn liquibase:generateChangeLog. Still nothing

pom.xml :

```<code><dependencies>
    ...
    <dependency>
        <groupId>org.liquibase</groupId>
        <artifactId>liquibase-core</artifactId>
        <version>3.5.3</version>
    </dependency>
    <dependency>
        <groupId>org.yaml</groupId>
        <artifactId>snakeyaml</artifactId>
        <version>1.17</version>
    </dependency>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.6</version>
    </dependency>
</dependencies>

 <!-- edited build after 1st comment. Still got the problem -->
<build>
    <plugins>
        <plugin>
            <groupId>org.liquibase</groupId>
            <artifactId>liquibase-maven-plugin</artifactId>
            <version>${liquibase.version}</version>
            <configuration>
                <promptOnNonLocalDatabase>true</promptOnNonLocalDatabase>
                <changeLogFile>${project.build.directory}/classes/changelog/db.changelog-master.xml</changeLogFile>
                <propertyFile>src/main/resources/liquibase.properties</propertyFile>
            </configuration>
        </plugin>
    </plugins>
</build>

<!--- old section build, left for history purpose --->
<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.liquibase</groupId>
                <artifactId>liquibase-maven-plugin</artifactId>
                <version>${liquibase.version}</version>
                <configuration>
                    <promptOnNonLocalDatabase>true</promptOnNonLocalDatabase>
                    <changeLogFile>${project.build.directory}/classes/changelog/db.changelog-master.xml</changeLogFile>
                    <propertyFile>src/main/resources/liquibase.properties</propertyFile>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>
</build>
</code>```

liquibase.properties :

```<code>url=jdbc:mysql://localhost:3306/my_db
username=user
password=pass
driver=com.mysql.jdbc.Driver
outputChangeLogFile=src/main/resources/liquibase/master.xml
</code>```

NB : commenting outputChangeLogFile made liquibase create the table DATABASECHANGELOGLOCK, but only this one.

maven output :

```<code>[INFO] ------------------------------------------------------------------------
[INFO] Building -CORE 0.0.2
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- liquibase-maven-plugin:3.5.3:generateChangeLog (default-cli) @ EDI-CORE ---
[INFO] ------------------------------------------------------------------------
[INFO] Parsing Liquibase Properties File
[INFO]   File: src/main/resources/liquibase.properties
[INFO]   'classpath' in properties file is not being used by this task.
[INFO] ------------------------------------------------------------------------
[INFO] Executing on Database: jdbc:mysql://localhost:3306/my_db
[INFO] Generating Change Log from database root@localhost @ jdbc:mysql://localhost:3306/my_db (Default Schema: edi)
INFO 17/01/17 15:01: liquibase: src\main\resources\liquibase\master.xml exists, appending
WARNING 17/01/17 15:01: liquibase: MySQL does not support a timestamp precision of '19' - resetting to the maximum of '6'
WARNING 17/01/17 15:01: liquibase: MySQL does not support a timestamp precision of '19' - resetting to the maximum of '6'
WARNING 17/01/17 15:01: liquibase: MySQL does not support a timestamp precision of '19' - resetting to the maximum of '6'
[INFO] Output written to Change Log file, src/main/resources/liquibase/master.xml
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
</code>```

答:
Liquibase works via changelog and changesets. It first tries to locate master changelog file and the changesets which are mentioned in that file are executed in order. If you have specified any DB connection then Liquibase will use that credentials and if not then you can specify the liquibase DB credentails.

Please go the spring boot doc for liquibase for the list of properties - https://docs.spring.io/spring-boot/docs/current/reference/html/appendix-application-properties.html#data-migration-properties

Sample liquibase property

```<code>  liquibase:
    change-log: classpath:db/changelog/db.changelog-master.xml
    enabled: true
    drop-first: false
    liquibase-tablespace:
    liquibase-schema:
    default-schema:
</code>```

Body:
I'm new to liquibase and I want to use it on an database in production.
It's a small application, but instead of creating schema by hand I would like to use something more professional like liquibase.

What I plan to do is to make a changelog between the current schema in production and the new schema ready for the new application. I've followed many tutorials but there is still something missing. The output changelog.xml always imports all the schema and doesn't make the difference with the existing. I saw that liquibase had to create the table DATABASECHANGELOG but I couldn't see them on my computer.

What I did :

dump of the current db in production and import on dev computer

from core project added liquibase.properties and launched the following command : mvn clean resources:resources liquibase:generateChangeLog

this generated a master.xml with all the schema, but didn't create the tables DATABASECHANGELOG in DB (the table DATABASECHANGELOGLOCK was created when commenting outputChangeLogFile, and the LOCKED value is 0)

created manually the DATABASECHANGELOG from http://www.liquibase.org/databases.html

rerun the command mvn liquibase:generateChangeLog. Still nothing

pom.xml :

<dependencies>
    ...
    <dependency>
        <groupId>org.liquibase</groupId>
        <artifactId>liquibase-core</artifactId>
        <version>3.5.3</version>
    </dependency>
    <dependency>
        <groupId>org.yaml</groupId>
        <artifactId>snakeyaml</artifactId>
        <version>1.17</version>
    </dependency>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.6</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.liquibase</groupId>
            <artifactId>liquibase-maven-plugin</artifactId>
            <version>${liquibase.version}</version>
            <configuration>
                <promptOnNonLocalDatabase>true</promptOnNonLocalDatabase>
                <changeLogFile>${project.build.directory}/classes/changelog/db.changelog-master.xml</changeLogFile>
                <propertyFile>src/main/resources/liquibase.properties</propertyFile>
            </configuration>
        </plugin>
    </plugins>
</build>

<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.liquibase</groupId>
                <artifactId>liquibase-maven-plugin</artifactId>
                <version>${liquibase.version}</version>
                <configuration>
                    <promptOnNonLocalDatabase>true</promptOnNonLocalDatabase>
                    <changeLogFile>${project.build.directory}/classes/changelog/db.changelog-master.xml</changeLogFile>
                    <propertyFile>src/main/resources/liquibase.properties</propertyFile>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>
</build>

liquibase.properties :

url=jdbc:mysql://localhost:3306/my_db
username=user
password=pass
driver=com.mysql.jdbc.Driver
outputChangeLogFile=src/main/resources/liquibase/master.xml

NB : commenting outputChangeLogFile made liquibase create the table DATABASECHANGELOGLOCK, but only this one.

maven output :

[INFO] ------------------------------------------------------------------------
[INFO] Building -CORE 0.0.2
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- liquibase-maven-plugin:3.5.3:generateChangeLog (default-cli) @ EDI-CORE ---
[INFO] ------------------------------------------------------------------------
[INFO] Parsing Liquibase Properties File
[INFO]   File: src/main/resources/liquibase.properties
[INFO]   'classpath' in properties file is not being used by this task.
[INFO] ------------------------------------------------------------------------
[INFO] Executing on Database: jdbc:mysql://localhost:3306/my_db
[INFO] Generating Change Log from database root@localhost @ jdbc:mysql://localhost:3306/my_db (Default Schema: edi)
INFO 17/01/17 15:01: liquibase: src\main\resources\liquibase\master.xml exists, appending
WARNING 17/01/17 15:01: liquibase: MySQL does not support a timestamp precision of '19' - resetting to the maximum of '6'
WARNING 17/01/17 15:01: liquibase: MySQL does not support a timestamp precision of '19' - resetting to the maximum of '6'
WARNING 17/01/17 15:01: liquibase: MySQL does not support a timestamp precision of '19' - resetting to the maximum of '6'
[INFO] Output written to Change Log file, src/main/resources/liquibase/master.xml
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------

Body:
Liquibase works via changelog and changesets. It first tries to locate master changelog file and the changesets which are mentioned in that file are executed in order. If you have specified any DB connection then Liquibase will use that credentials and if not then you can specify the liquibase DB credentails.

Please go the spring boot doc for liquibase for the list of properties - https://docs.spring.io/spring-boot/docs/current/reference/html/appendix-application-properties.html#data-migration-properties

Sample liquibase property

  liquibase:
    change-log: classpath:db/changelog/db.changelog-master.xml
    enabled: true
    drop-first: false
    liquibase-tablespace:
    liquibase-schema:
    default-schema:


问:
How is click action implemented in appium for chrome android
I know that the click action in iOS Safari is implemented with javascript, unless nativeWebTap capability is set to true (as reported here), I cannot find a description of how the click action is implemented in chrome on a mobile device running android. Can somebody help gathering this information?</p>

答:
Appium uses WebDriver API to test Web applications on Android Chrome browser, so basically it is using Chromedriver to make calls to Chrome DevTools and interact with DOM.

It is not like pure JS commands by default, but WebDriver API still allows you to send JS code for execution.


问:
How can I find the count of semicolon separated values?
I have a list of all email ids which I have copied from the 'To' field, from an email I received in MS Outlook. These values (email ids) are separated by a semicolon. I have copied this big list of email ids into Excel. Now I want to find the number of email ids in this list; basically by counting the number of semi colons.

One way I can do this is by writing C code. i.e. store the big list as string buffer, and keep comparing the chars to ";" in a while(char == ';') loop.
But I want to do it quickly.

Is there any quick way to find that out using either:

1.) Regular expression (I use powergrep for processing the regexps)

2.) In excel itself (any excel macro/plugin for that?)

3.) DOS script method

4.) Any other quick way of getting it done?

答:
PowerShell:</p>

```<code>> $a = 'blah;blah;blah'
> $a.Split(';').Count
3
</code>```

OwnerDisplayName: goldenmean

ContentLicense: CC BY-SA 2.5

LastEditorDisplayName: Svante

Body:
PowerShell:

> $a = 'blah;blah;blah'
> $a.Split(';').Count
3

OwnerDisplayName: dangph


问:
how to crop some portion of scaled, rotated image-view
I am unable to crop he image from image view, which is scaled and rotated before cropping. used existing cropping methods.but its applicable only for image-view which is fixed.Hope code will helpful.</p>

答:
```<code>UIImage *myImage = [UIImage imageNamed:@"photo.png"];

CGRect cropRect = CGRectMake(0.0, 0.0, 320.0, 44.0));
CGImageRef croppedImage = CGImageCreateWithImageInRect([myImage CGImage], cropRect);

UIImageView *myImageView = [[UIImageView alloc] initWithFrame:cropRect];
[myImageView setImage:[UIImage imageWithCGImage:croppedImage]];

CGImageRelease(croppedImage);
</code>```

its for cropping particular height and width

Body:
UIImage *myImage = [UIImage imageNamed:@"photo.png"];

CGRect cropRect = CGRectMake(0.0, 0.0, 320.0, 44.0));
CGImageRef croppedImage = CGImageCreateWithImageInRect([myImage CGImage], cropRect);

UIImageView *myImageView = [[UIImageView alloc] initWithFrame:cropRect];
[myImageView setImage:[UIImage imageWithCGImage:croppedImage]];

CGImageRelease(croppedImage);

its for cropping particular height and width


问:
How to join table to itself when it references to itself
I have table which have two columns which references to itself.

```<code>select * from cgroups;
+----+--------------+-------------+-----------+----------+----------+
| id | title        | description | cunixperm | cgroup_1 | cgroup_2 |
+----+--------------+-------------+-----------+----------+----------+
| 1  | admin        | <null>      | 32        | 1        | <null>   |
| 2  | tag_mng      | <null>      | 32        | 1        | <null>   |
| 3  | tags         | <null>      | 32        | 1        | <null>   |
| 4  | exam_mng     | <null>      | 32        | 1        | <null>   |
| 5  | exam_writer  | <null>      | 32        | 1        | <null>   |
| 6  | exam_viewer  | <null>      | 32        | 1        | <null>   |
| 7  | exam_starter | <null>      | 32        | 1        | <null>   |
+----+--------------+-------------+-----------+----------+----------+
</code>```

here is its code:-

```<code>create table cgroups
(
    id int unsigned primary key auto_increment,
    title varchar(100) not null unique,
    description varchar(255),

    cunixperm  tinyint unsigned not null default 32 ,# r=2 w=1
    cgroup_1   int unsigned not null default 1 references cgroups (id) on delete cascade on update cascade,
    cgroup_2   int unsigned references cgroups (id) on delete cascade on update cascade

);
</code>```

I want to create views in which cgroup_1 column is replaced with actual title of of c_group

something like this:- http://sqlfiddle.com/#!9/7af382/1

```<code>select c.id, c.title, c.description, c.cunixperm, c1.title cgroup_1 from cgroups c , cgroups c1
                             where c.cgroup_1 = c1.id;
+----+--------------+-------------+-----------+----------+
| id | title        | description | cunixperm | cgroup_1 |
+----+--------------+-------------+-----------+----------+
| 1  | admin        | <null>      | 32        | admin    |
| 2  | tag_mng      | <null>      | 32        | admin    |
| 3  | tags         | <null>      | 32        | admin    |
| 4  | exam_mng     | <null>      | 32        | admin    |
| 5  | exam_writer  | <null>      | 32        | admin    |
| 6  | exam_viewer  | <null>      | 32        | admin    |
| 7  | exam_starter | <null>      | 32        | admin    |
+----+--------------+-------------+-----------+----------+
</code>```

problem with this approach is that it only works with 1 refereed column while I have two ( 8 in some other tables)

if I do following ,

```<code>select c.id, c.title, c.description, c.cunixperm, c1.title, c2.title
from cgroups c , cgroups c1, cgroups c2
where c.cgroup_1 = c1.id and c.cgroup_2 = c2.id;
</code>```

I get zero rows.http://sqlfiddle.com/#!9/7af382/4

答:
By modifying caisEdge, Answer have it working:-</p>

```<code> select c.id, c.title, c.description, c.cunixperm, c1.title cgroup_1 , c2.title cgroup_2
 from cgroups c
 INNER JOIN cgroups c1  ON c.cgroup_1 = c1.id
 INNER JOIN cgroups c2  ON c.cgroup_2 = c2.id;
</code>```

Body:
I have table which have two columns which references to itself.

select * from cgroups;
+----+--------------+-------------+-----------+----------+----------+
| id | title        | description | cunixperm | cgroup_1 | cgroup_2 |
+----+--------------+-------------+-----------+----------+----------+
| 1  | admin        | <null>      | 32        | 1        | <null>   |
| 2  | tag_mng      | <null>      | 32        | 1        | <null>   |
| 3  | tags         | <null>      | 32        | 1        | <null>   |
| 4  | exam_mng     | <null>      | 32        | 1        | <null>   |
| 5  | exam_writer  | <null>      | 32        | 1        | <null>   |
| 6  | exam_viewer  | <null>      | 32        | 1        | <null>   |
| 7  | exam_starter | <null>      | 32        | 1        | <null>   |
+----+--------------+-------------+-----------+----------+----------+

here is its code:-

create table cgroups
(
    id int unsigned primary key auto_increment,
    title varchar(100) not null unique,
    description varchar(255),

    cunixperm  tinyint unsigned not null default 32 ,# r=2 w=1
    cgroup_1   int unsigned not null default 1 references cgroups (id) on delete cascade on update cascade,
    cgroup_2   int unsigned references cgroups (id) on delete cascade on update cascade

);

I want to create views in which cgroup_1 column is replaced with actual title of of c_group

something like this:- http://sqlfiddle.com/#!9/7af382/1

select c.id, c.title, c.description, c.cunixperm, c1.title cgroup_1 from cgroups c , cgroups c1
                             where c.cgroup_1 = c1.id;
+----+--------------+-------------+-----------+----------+
| id | title        | description | cunixperm | cgroup_1 |
+----+--------------+-------------+-----------+----------+
| 1  | admin        | <null>      | 32        | admin    |
| 2  | tag_mng      | <null>      | 32        | admin    |
| 3  | tags         | <null>      | 32        | admin    |
| 4  | exam_mng     | <null>      | 32        | admin    |
| 5  | exam_writer  | <null>      | 32        | admin    |
| 6  | exam_viewer  | <null>      | 32        | admin    |
| 7  | exam_starter | <null>      | 32        | admin    |
+----+--------------+-------------+-----------+----------+

problem with this approach is that it only works with 1 refereed column while I have two ( 8 in some other tables)

if I do following ,

select c.id, c.title, c.description, c.cunixperm, c1.title, c2.title
from cgroups c , cgroups c1, cgroups c2
where c.cgroup_1 = c1.id and c.cgroup_2 = c2.id;

I get zero rows.http://sqlfiddle.com/#!9/7af382/4

Body:
By modifying caisEdge, Answer have it working:-

 select c.id, c.title, c.description, c.cunixperm, c1.title cgroup_1 , c2.title cgroup_2
 from cgroups c
 INNER JOIN cgroups c1  ON c.cgroup_1 = c1.id
 INNER JOIN cgroups c2  ON c.cgroup_2 = c2.id;


问:
Ehcache: unexpected behavior when evicting cache elements
I have two cached methods:

```<code>@Cacheable(value = CacheName.CACHE_STATIC, key="'getImageUserLayer'.concat(':').concat(#layerId)")
public byte[] getImageUserLayer(int layerId) {
</code>```

and

```<code>@Cacheable(value = CacheName.CACHE_STATIC, key="'getLastModifiedUserLayer'.concat(':').concat(#layerId)")
@Override
public String getLastModifiedUserLayer(int layerId) {
</code>```

also I have method for evicting of element:

```<code>@Caching(evict = {
        @CacheEvict(value = CacheName.CACHE_STATIC, key = "'getImageUserLayer'.concat(':').concat(#layerId)"),
        @CacheEvict(value = CacheName.CACHE_STATIC, key = "'getLastModifiedUserLayer'.concat(':').concat(#layerId)")
})
public void updateLayer(UserLayer layer, int layerId) {
</code>```

Why after calling updateLayer(5510461), I get next weird behavior:

```<code>2020-02-10 16:47:07.065 [http-nio-8080-exec-9] TRACE o.s.c.i.CacheInterceptor - Computed cache key 'getLastModifiedUserLayer:4900061' for operation Builder[public java.lang.String com.prognoz.smkoob.data.dao.ImageServiceImpl.getLastModifiedUserLayer(int)] caches=[cacheStatic] | key=''getLastModifiedUserLayer'.concat(':').concat(#layerId)' | keyGenerator='' | cacheManager='' | cacheResolver='' | condition='' | unless='' | sync='false'
2020-02-10 16:48:32.695 [http-nio-8080-exec-7] TRACE o.s.c.i.CacheInterceptor - Invalidating cache key [getImageUserLayer:5510461] for operation Builder[public void com.prognoz.smkoob.data.dao.meta.UserLayerServiceImpl.updateLayer(com.prognoz.smkoob.domain.UserLayer.UserLayer,int)] caches=[cacheStatic] | key=''getImageUserLayer'.concat(':').concat(#layerId)' | keyGenerator='' | cacheManager='' | cacheResolver='' | condition='',false,false on method public void com.prognoz.smkoob.data.dao.meta.UserLayerServiceImpl.updateLayer(com.prognoz.smkoob.domain.UserLayer.UserLayer,int)
2020-02-10 16:48:32.701 [http-nio-8080-exec-7] TRACE o.s.c.i.CacheInterceptor - Invalidating cache key [getLastModifiedUserLayer:5510461] for operation Builder[public void com.prognoz.smkoob.data.dao.meta.UserLayerServiceImpl.updateLayer(com.prognoz.smkoob.domain.UserLayer.UserLayer,int)] caches=[cacheStatic] | key=''getLastModifiedUserLayer'.concat(':').concat(#layerId)' | keyGenerator='' | cacheManager='' | cacheResolver='' | condition='',false,false on method public void com.prognoz.smkoob.data.dao.meta.UserLayerServiceImpl.updateLayer(com.prognoz.smkoob.domain.UserLayer.UserLayer,int)
2020-02-10 16:48:33.591 [http-nio-8080-exec-4] TRACE o.s.c.i.CacheInterceptor - Computed cache key 'getLastModifiedUserLayer:5510461' for operation Builder[public java.lang.String com.prognoz.smkoob.data.dao.ImageServiceImpl.getLastModifiedUserLayer(int)] caches=[cacheStatic] | key=''getLastModifiedUserLayer'.concat(':').concat(#layerId)' | keyGenerator='' | cacheManager='' | cacheResolver='' | condition='' | unless='' | sync='false'
2020-02-10 16:48:33.591 [http-nio-8080-exec-4] TRACE o.s.c.i.CacheInterceptor - No cache entry for key 'getLastModifiedUserLayer:5510461' in cache(s) [cacheStatic]
2020-02-10 16:48:33.909 [http-nio-8080-exec-3] TRACE o.s.c.i.CacheInterceptor - Computed cache key 'getLastModifiedUserLayer:4900061' for operation Builder[public java.lang.String com.prognoz.smkoob.data.dao.ImageServiceImpl.getLastModifiedUserLayer(int)] caches=[cacheStatic] | key=''getLastModifiedUserLayer'.concat(':').concat(#layerId)' | keyGenerator='' | cacheManager='' | cacheResolver='' | condition='' | unless='' | sync='false'
2020-02-10 16:48:33.909 [http-nio-8080-exec-3] TRACE o.s.c.i.CacheInterceptor - No cache entry for key 'getLastModifiedUserLayer:4900061' in cache(s) [cacheStatic]
2020-02-10 16:48:33.909 [http-nio-8080-exec-8] TRACE o.s.c.i.CacheInterceptor - No cache entry for key 'getLastModifiedUserLayer:5129071' in cache(s) [cacheStatic]
2020-02-10 16:48:33.910 [http-nio-8080-exec-8] TRACE o.s.c.i.CacheInterceptor - Computed cache key 'getLastModifiedUserLayer:5129071' for operation Builder[public java.lang.String com.prognoz.smkoob.data.dao.ImageServiceImpl.getLastModifiedUserLayer(int)] caches=[cacheStatic] | key=''getLastModifiedUserLayer'.concat(':').concat(#layerId)' | keyGenerator='' | cacheManager='' | cacheResolver='' | condition='' | unless='' | sync='false'
</code>```

Why it also invalidates another keys??? For example 4900061.

my ehcache.xml:

```<code><cache name="cacheStatic"
       maxBytesLocalHeap="128M"
       maxBytesLocalDisk="2G"
       eternal="false"
       timeToLiveSeconds="7200"
       memoryStoreEvictionPolicy="LFU"
       transactionalMode="off">
    <persistence strategy="localTempSwap"/>
</cache>
</code>```

答:
According to the logs, there are only two invalidatings made in thread http-nio-8080-exec-7:

```<code>2020-02-10 16:48:32.695 [http-nio-8080-exec-7] TRACE o.s.c.i.CacheInterceptor - Invalidating cache key [getImageUserLayer:5510461] for operation Builder[public void com.prognoz.smkoob.data.dao.meta.UserLayerServiceImpl.updateLayer(com.prognoz.smkoob.domain.UserLayer.UserLayer,int)] caches=[cacheStatic] | key=''getImageUserLayer'.concat(':').concat(#layerId)' | keyGenerator='' | cacheManager='' | cacheResolver='' | condition='',false,false on method public void com.prognoz.smkoob.data.dao.meta.UserLayerServiceImpl.updateLayer(com.prognoz.smkoob.domain.UserLayer.UserLayer,int)
2020-02-10 16:48:32.701 [http-nio-8080-exec-7] TRACE o.s.c.i.CacheInterceptor - Invalidating cache key [getLastModifiedUserLayer:5510461] for operation Builder[public void com.prognoz.smkoob.data.dao.meta.UserLayerServiceImpl.updateLayer(com.prognoz.smkoob.domain.UserLayer.UserLayer,int)] caches=[cacheStatic] | key=''getLastModifiedUserLayer'.concat(':').concat(#layerId)' | keyGenerator='' | cacheManager='' | cacheResolver='' | condition='',false,false on method public void com.prognoz.smkoob.data.dao.meta.UserLayerServiceImpl.updateLayer(com.prognoz.smkoob.domain.UserLayer.UserLayer,int)

</code>```

What's about actions with 4900061 in thread http-nio-8080-exec-3, it seems just like a attempt to find cached value made during a call of method getLastModifiedUserLayer:

```<code>2020-02-10 16:48:33.909 [http-nio-8080-exec-3] TRACE o.s.c.i.CacheInterceptor - Computed cache key 'getLastModifiedUserLayer:4900061' for operation Builder[public java.lang.String com.prognoz.smkoob.data.dao.ImageServiceImpl.getLastModifiedUserLayer(int)] caches=[cacheStatic] | key=''getLastModifiedUserLayer'.concat(':').concat(#layerId)' | keyGenerator='' | cacheManager='' | cacheResolver='' | condition='' | unless='' | sync='false'
2020-02-10 16:48:33.909 [http-nio-8080-exec-3] TRACE o.s.c.i.CacheInterceptor - No cache entry for key 'getLastModifiedUserLayer:4900061' in cache(s) [cacheStatic]
</code>```

Body:
I have two cached methods:

@Cacheable(value = CacheName.CACHE_STATIC, key="'getImageUserLayer'.concat(':').concat(#layerId)")
public byte[] getImageUserLayer(int layerId) {

and

@Cacheable(value = CacheName.CACHE_STATIC, key="'getLastModifiedUserLayer'.concat(':').concat(#layerId)")
@Override
public String getLastModifiedUserLayer(int layerId) {

also I have method for evicting of element:

@Caching(evict = {
        @CacheEvict(value = CacheName.CACHE_STATIC, key = "'getImageUserLayer'.concat(':').concat(#layerId)"),
        @CacheEvict(value = CacheName.CACHE_STATIC, key = "'getLastModifiedUserLayer'.concat(':').concat(#layerId)")
})
public void updateLayer(UserLayer layer, int layerId) {

Why after calling updateLayer(5510461), I get next weird behavior:

2020-02-10 16:47:07.065 [http-nio-8080-exec-9] TRACE o.s.c.i.CacheInterceptor - Computed cache key 'getLastModifiedUserLayer:4900061' for operation Builder[public java.lang.String com.prognoz.smkoob.data.dao.ImageServiceImpl.getLastModifiedUserLayer(int)] caches=[cacheStatic] | key=''getLastModifiedUserLayer'.concat(':').concat(#layerId)' | keyGenerator='' | cacheManager='' | cacheResolver='' | condition='' | unless='' | sync='false'
2020-02-10 16:48:32.695 [http-nio-8080-exec-7] TRACE o.s.c.i.CacheInterceptor - Invalidating cache key [getImageUserLayer:5510461] for operation Builder[public void com.prognoz.smkoob.data.dao.meta.UserLayerServiceImpl.updateLayer(com.prognoz.smkoob.domain.UserLayer.UserLayer,int)] caches=[cacheStatic] | key=''getImageUserLayer'.concat(':').concat(#layerId)' | keyGenerator='' | cacheManager='' | cacheResolver='' | condition='',false,false on method public void com.prognoz.smkoob.data.dao.meta.UserLayerServiceImpl.updateLayer(com.prognoz.smkoob.domain.UserLayer.UserLayer,int)
2020-02-10 16:48:32.701 [http-nio-8080-exec-7] TRACE o.s.c.i.CacheInterceptor - Invalidating cache key [getLastModifiedUserLayer:5510461] for operation Builder[public void com.prognoz.smkoob.data.dao.meta.UserLayerServiceImpl.updateLayer(com.prognoz.smkoob.domain.UserLayer.UserLayer,int)] caches=[cacheStatic] | key=''getLastModifiedUserLayer'.concat(':').concat(#layerId)' | keyGenerator='' | cacheManager='' | cacheResolver='' | condition='',false,false on method public void com.prognoz.smkoob.data.dao.meta.UserLayerServiceImpl.updateLayer(com.prognoz.smkoob.domain.UserLayer.UserLayer,int)
2020-02-10 16:48:33.591 [http-nio-8080-exec-4] TRACE o.s.c.i.CacheInterceptor - Computed cache key 'getLastModifiedUserLayer:5510461' for operation Builder[public java.lang.String com.prognoz.smkoob.data.dao.ImageServiceImpl.getLastModifiedUserLayer(int)] caches=[cacheStatic] | key=''getLastModifiedUserLayer'.concat(':').concat(#layerId)' | keyGenerator='' | cacheManager='' | cacheResolver='' | condition='' | unless='' | sync='false'
2020-02-10 16:48:33.591 [http-nio-8080-exec-4] TRACE o.s.c.i.CacheInterceptor - No cache entry for key 'getLastModifiedUserLayer:5510461' in cache(s) [cacheStatic]
2020-02-10 16:48:33.909 [http-nio-8080-exec-3] TRACE o.s.c.i.CacheInterceptor - Computed cache key 'getLastModifiedUserLayer:4900061' for operation Builder[public java.lang.String com.prognoz.smkoob.data.dao.ImageServiceImpl.getLastModifiedUserLayer(int)] caches=[cacheStatic] | key=''getLastModifiedUserLayer'.concat(':').concat(#layerId)' | keyGenerator='' | cacheManager='' | cacheResolver='' | condition='' | unless='' | sync='false'
2020-02-10 16:48:33.909 [http-nio-8080-exec-3] TRACE o.s.c.i.CacheInterceptor - No cache entry for key 'getLastModifiedUserLayer:4900061' in cache(s) [cacheStatic]
2020-02-10 16:48:33.909 [http-nio-8080-exec-8] TRACE o.s.c.i.CacheInterceptor - No cache entry for key 'getLastModifiedUserLayer:5129071' in cache(s) [cacheStatic]
2020-02-10 16:48:33.910 [http-nio-8080-exec-8] TRACE o.s.c.i.CacheInterceptor - Computed cache key 'getLastModifiedUserLayer:5129071' for operation Builder[public java.lang.String com.prognoz.smkoob.data.dao.ImageServiceImpl.getLastModifiedUserLayer(int)] caches=[cacheStatic] | key=''getLastModifiedUserLayer'.concat(':').concat(#layerId)' | keyGenerator='' | cacheManager='' | cacheResolver='' | condition='' | unless='' | sync='false'

Why it also invalidates another keys??? For example 4900061.

my ehcache.xml:

<cache name="cacheStatic"
       maxBytesLocalHeap="128M"
       maxBytesLocalDisk="2G"
       eternal="false"
       timeToLiveSeconds="7200"
       memoryStoreEvictionPolicy="LFU"
       transactionalMode="off">
    <persistence strategy="localTempSwap"/>
</cache>

Body:
According to the logs, there are only two invalidatings made in thread http-nio-8080-exec-7:

2020-02-10 16:48:32.695 [http-nio-8080-exec-7] TRACE o.s.c.i.CacheInterceptor - Invalidating cache key [getImageUserLayer:5510461] for operation Builder[public void com.prognoz.smkoob.data.dao.meta.UserLayerServiceImpl.updateLayer(com.prognoz.smkoob.domain.UserLayer.UserLayer,int)] caches=[cacheStatic] | key=''getImageUserLayer'.concat(':').concat(#layerId)' | keyGenerator='' | cacheManager='' | cacheResolver='' | condition='',false,false on method public void com.prognoz.smkoob.data.dao.meta.UserLayerServiceImpl.updateLayer(com.prognoz.smkoob.domain.UserLayer.UserLayer,int)
2020-02-10 16:48:32.701 [http-nio-8080-exec-7] TRACE o.s.c.i.CacheInterceptor - Invalidating cache key [getLastModifiedUserLayer:5510461] for operation Builder[public void com.prognoz.smkoob.data.dao.meta.UserLayerServiceImpl.updateLayer(com.prognoz.smkoob.domain.UserLayer.UserLayer,int)] caches=[cacheStatic] | key=''getLastModifiedUserLayer'.concat(':').concat(#layerId)' | keyGenerator='' | cacheManager='' | cacheResolver='' | condition='',false,false on method public void com.prognoz.smkoob.data.dao.meta.UserLayerServiceImpl.updateLayer(com.prognoz.smkoob.domain.UserLayer.UserLayer,int)

What's about actions with 4900061 in thread http-nio-8080-exec-3, it seems just like a attempt to find cached value made during a call of method getLastModifiedUserLayer:

2020-02-10 16:48:33.909 [http-nio-8080-exec-3] TRACE o.s.c.i.CacheInterceptor - Computed cache key 'getLastModifiedUserLayer:4900061' for operation Builder[public java.lang.String com.prognoz.smkoob.data.dao.ImageServiceImpl.getLastModifiedUserLayer(int)] caches=[cacheStatic] | key=''getLastModifiedUserLayer'.concat(':').concat(#layerId)' | keyGenerator='' | cacheManager='' | cacheResolver='' | condition='' | unless='' | sync='false'
2020-02-10 16:48:33.909 [http-nio-8080-exec-3] TRACE o.s.c.i.CacheInterceptor - No cache entry for key 'getLastModifiedUserLayer:4900061' in cache(s) [cacheStatic]


问:
ERROR 2006 (HY000): MySQL server has gone away
I get this error when I try to source a large SQL file (a big INSERT query).

```<code>mysql>  source file.sql
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id:    2
Current database: *** NONE ***

ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id:    3
Current database: *** NONE ***
</code>```

Nothing in the table is updated.  I've tried deleting and undeleting the table/database, as well as restarting MySQL.  None of these things resolve the problem.

Here is my max-packet size:

```<code>+--------------------+---------+
| Variable_name      | Value   |
+--------------------+---------+
| max_allowed_packet | 1048576 |
+--------------------+---------+
</code>```

Here is the file size:

```<code>$ ls -s file.sql
79512 file.sql
</code>```

When I try the other method...

```<code>$ ./mysql -u root -p my_db < file.sql
Enter password:
ERROR 2006 (HY000) at line 1: MySQL server has gone away
</code>```

答:
This error message also occurs when you created the SCHEMA with a different COLLATION than the one which is used in the dump. So, if the dump contains

```<code>CREATE TABLE `mytab` (
..
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
</code>```

you should also reflect this in the SCHEMA collation:

```<code>CREATE SCHEMA myschema COLLATE utf8_unicode_ci;
</code>```

I had been using utf8mb4_general_ci in the schema, cause my script came from a fresh V8 installation, now loading a DB on old 5.7 crashed and drove me nearly crazy.

So, maybe this helps you saving some frustating hours... :-)

(MacOS 10.3, mysql 5.7)

Body:
I get this error when I try to source a large SQL file (a big INSERT query).

mysql>  source file.sql
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id:    2
Current database: *** NONE ***

ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id:    3
Current database: *** NONE ***

Nothing in the table is updated.  I've tried deleting and undeleting the table/database, as well as restarting MySQL.  None of these things resolve the problem.

Here is my max-packet size:

+--------------------+---------+
| Variable_name      | Value   |
+--------------------+---------+
| max_allowed_packet | 1048576 |
+--------------------+---------+

Here is the file size:

$ ls -s file.sql
79512 file.sql

When I try the other method...

$ ./mysql -u root -p my_db < file.sql
Enter password:
ERROR 2006 (HY000) at line 1: MySQL server has gone away

Body:
This error message also occurs when you created the SCHEMA with a different COLLATION than the one which is used in the dump. So, if the dump contains

CREATE TABLE `mytab` (
..
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

you should also reflect this in the SCHEMA collation:

CREATE SCHEMA myschema COLLATE utf8_unicode_ci;

I had been using utf8mb4_general_ci in the schema, cause my script came from a fresh V8 installation, now loading a DB on old 5.7 crashed and drove me nearly crazy.

So, maybe this helps you saving some frustating hours... :-)

(MacOS 10.3, mysql 5.7)


问:
How to switch visibility GONE and VISIBLE in Swift
I want to switch between visibility GONE and VISIBLE.
This is really easy to achieve in Android development, but I don't know how to use the same approach in Swift

I tried this code to set a label as gone:

```<code>// set the width constraint to 0
let widthConstraint = NSLayoutConstraint(item:  self.labelShortDescription, attribute: NSLayoutAttribute.width, relatedBy: NSLayoutRelation.equal, toItem: nil, attribute: NSLayoutAttribute.notAnAttribute, multiplier: 1, constant: 0)
self.labelShortDescription.addConstraint(widthConstraint)

// set the height constraint to 0
let heightConstraint = NSLayoutConstraint(item:  self.labelShortDescription, attribute: NSLayoutAttribute.height, relatedBy: NSLayoutRelation.equal, toItem: nil, attribute: NSLayoutAttribute.notAnAttribute, multiplier: 1, constant: 0)
self.labelShortDescription.addConstraint(heightConstraint)
</code>```

答:
This is an elaboration of Farshid roohi's answer: https://stackoverflow.com/a/51130160/826946.

What you want to do is create a constraint in the Storyboard that defines the height of your field. If you're not using a fixed height, it will be more complicated, but you should get the idea from this answer.
So you create a height constraint for your field.
Then you create an IBOutlet for your constraint in your code that looks something like this:

```<code>@IBOutlet weak var myItemsHeight: NSLayoutConstraint!
</code>```

In Storyboard, you select your constraint, then connect its referencing outlet to the variable you just defined above. It's just like creating a referencing outlet for a view, but your selection in the Storyboard navigator on the left should be on the actual constraint, not the view you are constraining.

Now in your code, when you want the item to be GONE, you set:

```<code>myItemsHeight.constant = 0
</code>```

When you want it to be visible, you set its height to whatever the height should be.

If you want to be fancier and leave all your layout info in the Storyboard, you could create two height constraints, one whose value is 0 and one whose value is the height you want. Then in your code, when you want the item to be GONE, you would do something like:

```<code>myItemGoneConstraint.priority = 1000
myItemVisibleConstraint.priority = 0
</code>```

and do the reverse when you want it to be visible

Body:
I want to switch between visibility GONE and VISIBLE.
This is really easy to achieve in Android development, but I don't know how to use the same approach in Swift

I tried this code to set a label as gone:

// set the width constraint to 0
let widthConstraint = NSLayoutConstraint(item:  self.labelShortDescription, attribute: NSLayoutAttribute.width, relatedBy: NSLayoutRelation.equal, toItem: nil, attribute: NSLayoutAttribute.notAnAttribute, multiplier: 1, constant: 0)
self.labelShortDescription.addConstraint(widthConstraint)

// set the height constraint to 0
let heightConstraint = NSLayoutConstraint(item:  self.labelShortDescription, attribute: NSLayoutAttribute.height, relatedBy: NSLayoutRelation.equal, toItem: nil, attribute: NSLayoutAttribute.notAnAttribute, multiplier: 1, constant: 0)
self.labelShortDescription.addConstraint(heightConstraint)

Body:
This is an elaboration of Farshid roohi's answer: https://stackoverflow.com/a/51130160/826946.

What you want to do is create a constraint in the Storyboard that defines the height of your field. If you're not using a fixed height, it will be more complicated, but you should get the idea from this answer.
So you create a height constraint for your field.
Then you create an IBOutlet for your constraint in your code that looks something like this:

@IBOutlet weak var myItemsHeight: NSLayoutConstraint!

In Storyboard, you select your constraint, then connect its referencing outlet to the variable you just defined above. It's just like creating a referencing outlet for a view, but your selection in the Storyboard navigator on the left should be on the actual constraint, not the view you are constraining.

Now in your code, when you want the item to be GONE, you set:

myItemsHeight.constant = 0

When you want it to be visible, you set its height to whatever the height should be.

If you want to be fancier and leave all your layout info in the Storyboard, you could create two height constraints, one whose value is 0 and one whose value is the height you want. Then in your code, when you want the item to be GONE, you would do something like:

myItemGoneConstraint.priority = 1000
myItemVisibleConstraint.priority = 0

and do the reverse when you want it to be visible


问:
Change comma to dot for every cell in column
In my table I have column with numbers. These numbers uses a comma as the decimal separator. I would like a dot instead for the comma for every cell in this column.
This is what I have:

```<code>Col1    Col2    NumCol
Value 1 Value 2 12,3
Value 3 Value 4 1,23
Value 5 Value 6 99,8
</code>```

This is what I want:

```<code>Col1    Col2    NumCol
Value 1 Value 2 12.3
Value 3 Value 4 1.23
Value 5 Value 6 99.8
</code>```

I am familiar with the REPLACE-function. However I don't know how to use it when it involves a whole column. How would a function like that look like?

答:
Use replace()

```<code>select t.col1, t.col2, t.NumCol, replace(numcol, ',', '.') as NewNumCol
from table t;
</code>```

EDIT : As side noted by @barthofland if you have large value then only one replace() might fail. So, you need instead :

```<code>replace(replace(numcol, '.', ''), ',', '.')
</code>```

Body:
In my table I have column with numbers. These numbers uses a comma as the decimal separator. I would like a dot instead for the comma for every cell in this column.
This is what I have:

Col1    Col2    NumCol
Value 1 Value 2 12,3
Value 3 Value 4 1,23
Value 5 Value 6 99,8

This is what I want:

Col1    Col2    NumCol
Value 1 Value 2 12.3
Value 3 Value 4 1.23
Value 5 Value 6 99.8

I am familiar with the REPLACE-function. However I don't know how to use it when it involves a whole column. How would a function like that look like?

Body:
Use replace()

select t.col1, t.col2, t.NumCol, replace(numcol, ',', '.') as NewNumCol
from table t;

EDIT : As side noted by @barthofland if you have large value then only one replace() might fail. So, you need instead :

replace(replace(numcol, '.', ''), ',', '.')


问:
Is there a way to declare a class header in the same way a function header can be declared?
```<code>#include<iostream>

using namespace std;

class Colour
{
private:
    int _r, _g, _b;
public:
    Colour(int r = 0, int g = 0, int b = 0) : _r(r), _g(g), _b(b) {}
};
class Purevirtual
{
public:
    virtual int f(int x)  = 0;
    virtual void setColour(const Colour &c) = 0;
};

class Inherit : public Purevirtual
{
private :
    Colour _c;
public:
    Inherit(const Colour &c) : _c(c)
    {}
    int f(int x) override
    {
        return 2*x;
    }
    void setColour(const Colour &colour) override
    {
        _c = colour;
    }
};
int main()
{
    return 0;
}
</code>```

If I put the class Colour after Purevirtual at compile time it will generate an error. I don't know why. A solution is to create and include in the main file the header with the class Colour but for me, it seems it will complicate the code.

答:
The compiler starts compiling at the top and finish at the end of the file, so if you define something after you use it, the compiler will said it is not defined. You can forward-declare the class, without class body and after, define the class. Something like this:</p>

```<code>class Colour;

class PureVirtual
{
 .... the purevirtual body class doing reference to Colour class ....
};

class Colour
{
 .... the colour body class ...
}
</code>```

Body:
#include<iostream>

using namespace std;

class Colour
{
private:
    int _r, _g, _b;
public:
    Colour(int r = 0, int g = 0, int b = 0) : _r(r), _g(g), _b(b) {}
};
class Purevirtual
{
public:
    virtual int f(int x)  = 0;
    virtual void setColour(const Colour &c) = 0;
};

class Inherit : public Purevirtual
{
private :
    Colour _c;
public:
    Inherit(const Colour &c) : _c(c)
    {}
    int f(int x) override
    {
        return 2*x;
    }
    void setColour(const Colour &colour) override
    {
        _c = colour;
    }
};
int main()
{
    return 0;
}

If I put the class Colour after Purevirtual at compile time it will generate an error. I don't know why. A solution is to create and include in the main file the header with the class Colour but for me, it seems it will complicate the code.

Body:
The compiler starts compiling at the top and finish at the end of the file, so if you define something after you use it, the compiler will said it is not defined. You can forward-declare the class, without class body and after, define the class. Something like this:

class Colour;

class PureVirtual
{
 .... the purevirtual body class doing reference to Colour class ....
};

class Colour
{
 .... the colour body class ...
}