问:
Logic app fails to find value from Parse JSON action
I have a logic app which is triggered by an HTTP call. With this call comes a set of headers, most of them used in different switch statements. Using the Parse JSON action I feed in the headers from the request, they successfully parse (image 1), but for one of the headers (searchType) the switch statement evaluates to null for some reason (image 2).
 I cannot for the life of me figure out why.

I have tried to remake the logic app from scratch, copy the app to a different environment entirely, and tried to use the expression to access the parsed value instead of dynamic content. When I try the expression I am told it is an invalid expression (image 3). This expression is a straight copy from what is used on the code view.

Any suggestions as to what i can do to solve this?

Successful parsing of headers

parsed header evaluates to null

expression invalid

JSON to replicate logic app

```<code>{
    "definition": {
        "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
        "actions": {
            "HeadersJson": {
                "inputs": {
                    "content": "@triggerOutputs()['headers']",
                    "schema": {
                        "properties": {
                            "APICallFor": {
                                "type": "string"
                            },
                            "Accept-Encoding": {
                                "type": "string"
                            },
                            "Accept-Language": {
                                "type": "string"
                            },
                            "Connection": {
                                "type": "string"
                            },
                            "Content-Length": {
                                "type": "string"
                            },
                            "Content-Type": {
                                "type": "string"
                            },
                            "Host": {
                                "type": "string"
                            },
                            "User-Agent": {
                                "type": "string"
                            },
                            "searchType": {
                                "type": "string"
                            },
                            "x-ms-action-tracking-id": {
                                "type": "string"
                            },
                            "x-ms-activity-vector": {
                                "type": "string"
                            },
                            "x-ms-client-request-id": {
                                "type": "string"
                            },
                            "x-ms-client-tracking-id": {
                                "type": "string"
                            },
                            "x-ms-correlation-id": {
                                "type": "string"
                            },
                            "x-ms-execution-location": {
                                "type": "string"
                            },
                            "x-ms-tracking-id": {
                                "type": "string"
                            },
                            "x-ms-workflow-id": {
                                "type": "string"
                            },
                            "x-ms-workflow-name": {
                                "type": "string"
                            },
                            "x-ms-workflow-operation-name": {
                                "type": "string"
                            },
                            "x-ms-workflow-resourcegroup-name": {
                                "type": "string"
                            },
                            "x-ms-workflow-run-id": {
                                "type": "string"
                            },
                            "x-ms-workflow-run-tracking-id": {
                                "type": "string"
                            },
                            "x-ms-workflow-subscription-id": {
                                "type": "string"
                            },
                            "x-ms-workflow-system-id": {
                                "type": "string"
                            },
                            "x-ms-workflow-version": {
                                "type": "string"
                            }
                        },
                        "type": "object"
                    }
                },
                "runAfter": {},
                "type": "ParseJson"
            },
            "Switch": {
                "cases": {
                    "Get_Departments": {
                        "actions": {
                            "Switch_3": {
                                "cases": {
                                    "Case": {
                                        "actions": {
                                            "Response_5": {
                                                "inputs": {
                                                    "body": "got to individual",
                                                    "statusCode": 200
                                                },
                                                "kind": "Http",
                                                "runAfter": {},
                                                "type": "Response"
                                            }
                                        },
                                        "case": "individual"
                                    },
                                    "Case_2": {
                                        "actions": {
                                            "Response": {
                                                "inputs": {
                                                    "body": "got to bulk",
                                                    "statusCode": 200
                                                },
                                                "kind": "Http",
                                                "runAfter": {},
                                                "type": "Response"
                                            }
                                        },
                                        "case": "bulk"
                                    }
                                },
                                "default": {
                                    "actions": {
                                        "Response_3": {
                                            "inputs": {
                                                "body": "the searchType parameter is not valid",
                                                "statusCode": 200
                                            },
                                            "kind": "Http",
                                            "runAfter": {},
                                            "type": "Response"
                                        }
                                    }
                                },
                                "expression": "@body('HeadersJson')?['serachType']",
                                "runAfter": {},
                                "type": "Switch"
                            }
                        },
                        "case": "departments"
                    }
                },
                "default": {
                    "actions": {
                        "Response_2": {
                            "inputs": {
                                "body": "the APICallFor header is not valid",
                                "statusCode": 500
                            },
                            "kind": "Http",
                            "runAfter": {},
                            "type": "Response"
                        }
                    }
                },
                "expression": "@body('HeadersJson')?['APICallFor']",
                "runAfter": {
                    "HeadersJson": [
                        "Succeeded"
                    ]
                },
                "type": "Switch"
            }
        },
        "contentVersion": "1.0.0.0",
        "outputs": {},
        "parameters": {},
        "triggers": {
            "manual": {
                "inputs": {
                    "schema": {
                        "properties": {
                            "searchString": {
                                "type": "string"
                            },
                            "searchType": {
                                "type": "string"
                            }
                        },
                        "type": "object"
                    }
                },
                "kind": "Http",
                "operationOptions": "EnableSchemaValidation",
                "type": "Request"
            }
        }
    }
}
</code>```

答:
Your expression is invalid is because the @ in your expression, the @ expression is used in Code view, it should just be body('HeadersJson')?['searchType'].

As for your searchType is null, it's probably the ParseJson schema is not correct, so please make sure the right schema as the doc way.

And if you want to use the header data, you don't need parse the header to json, cause the data is already in json format, however if you pass data with request body you will need to parse it. Also i have test it, it will work with triggerOutputs()['headers']['searchType'], so just paste it in the expression, if you use code view, it will be @triggerOutputs()['headers']['searchType'].

Body:
I have a logic app which is triggered by an HTTP call. With this call comes a set of headers, most of them used in different switch statements. Using the Parse JSON action I feed in the headers from the request, they successfully parse (image 1), but for one of the headers (searchType) the switch statement evaluates to null for some reason (image 2).
 I cannot for the life of me figure out why.

I have tried to remake the logic app from scratch, copy the app to a different environment entirely, and tried to use the expression to access the parsed value instead of dynamic content. When I try the expression I am told it is an invalid expression (image 3). This expression is a straight copy from what is used on the code view.

Any suggestions as to what i can do to solve this?

Successful parsing of headers

parsed header evaluates to null

expression invalid

JSON to replicate logic app

{
    "definition": {
        "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
        "actions": {
            "HeadersJson": {
                "inputs": {
                    "content": "@triggerOutputs()['headers']",
                    "schema": {
                        "properties": {
                            "APICallFor": {
                                "type": "string"
                            },
                            "Accept-Encoding": {
                                "type": "string"
                            },
                            "Accept-Language": {
                                "type": "string"
                            },
                            "Connection": {
                                "type": "string"
                            },
                            "Content-Length": {
                                "type": "string"
                            },
                            "Content-Type": {
                                "type": "string"
                            },
                            "Host": {
                                "type": "string"
                            },
                            "User-Agent": {
                                "type": "string"
                            },
                            "searchType": {
                                "type": "string"
                            },
                            "x-ms-action-tracking-id": {
                                "type": "string"
                            },
                            "x-ms-activity-vector": {
                                "type": "string"
                            },
                            "x-ms-client-request-id": {
                                "type": "string"
                            },
                            "x-ms-client-tracking-id": {
                                "type": "string"
                            },
                            "x-ms-correlation-id": {
                                "type": "string"
                            },
                            "x-ms-execution-location": {
                                "type": "string"
                            },
                            "x-ms-tracking-id": {
                                "type": "string"
                            },
                            "x-ms-workflow-id": {
                                "type": "string"
                            },
                            "x-ms-workflow-name": {
                                "type": "string"
                            },
                            "x-ms-workflow-operation-name": {
                                "type": "string"
                            },
                            "x-ms-workflow-resourcegroup-name": {
                                "type": "string"
                            },
                            "x-ms-workflow-run-id": {
                                "type": "string"
                            },
                            "x-ms-workflow-run-tracking-id": {
                                "type": "string"
                            },
                            "x-ms-workflow-subscription-id": {
                                "type": "string"
                            },
                            "x-ms-workflow-system-id": {
                                "type": "string"
                            },
                            "x-ms-workflow-version": {
                                "type": "string"
                            }
                        },
                        "type": "object"
                    }
                },
                "runAfter": {},
                "type": "ParseJson"
            },
            "Switch": {
                "cases": {
                    "Get_Departments": {
                        "actions": {
                            "Switch_3": {
                                "cases": {
                                    "Case": {
                                        "actions": {
                                            "Response_5": {
                                                "inputs": {
                                                    "body": "got to individual",
                                                    "statusCode": 200
                                                },
                                                "kind": "Http",
                                                "runAfter": {},
                                                "type": "Response"
                                            }
                                        },
                                        "case": "individual"
                                    },
                                    "Case_2": {
                                        "actions": {
                                            "Response": {
                                                "inputs": {
                                                    "body": "got to bulk",
                                                    "statusCode": 200
                                                },
                                                "kind": "Http",
                                                "runAfter": {},
                                                "type": "Response"
                                            }
                                        },
                                        "case": "bulk"
                                    }
                                },
                                "default": {
                                    "actions": {
                                        "Response_3": {
                                            "inputs": {
                                                "body": "the searchType parameter is not valid",
                                                "statusCode": 200
                                            },
                                            "kind": "Http",
                                            "runAfter": {},
                                            "type": "Response"
                                        }
                                    }
                                },
                                "expression": "@body('HeadersJson')?['serachType']",
                                "runAfter": {},
                                "type": "Switch"
                            }
                        },
                        "case": "departments"
                    }
                },
                "default": {
                    "actions": {
                        "Response_2": {
                            "inputs": {
                                "body": "the APICallFor header is not valid",
                                "statusCode": 500
                            },
                            "kind": "Http",
                            "runAfter": {},
                            "type": "Response"
                        }
                    }
                },
                "expression": "@body('HeadersJson')?['APICallFor']",
                "runAfter": {
                    "HeadersJson": [
                        "Succeeded"
                    ]
                },
                "type": "Switch"
            }
        },
        "contentVersion": "1.0.0.0",
        "outputs": {},
        "parameters": {},
        "triggers": {
            "manual": {
                "inputs": {
                    "schema": {
                        "properties": {
                            "searchString": {
                                "type": "string"
                            },
                            "searchType": {
                                "type": "string"
                            }
                        },
                        "type": "object"
                    }
                },
                "kind": "Http",
                "operationOptions": "EnableSchemaValidation",
                "type": "Request"
            }
        }
    }
}


来源: stackexchange

问:
Cassandra stops silently - no error
I have been testing cassandra through an AWS Community AMI, which was running Cassandra 2.0.5.

I tried to upgrade it to 2.1.2 (the latest available), following the steps here, but now when I try to start cassandra, nothing happens. Logs are also clean. Here is the output:

```<code>ubuntu@ip-10-156-158-215:~$ sudo cassandra -f
INFO  23:52:22 Hostname: ip-10-156-158-215.ec2.internal
INFO  23:52:22 Loading settings from file:/etc/cassandra/cassandra.yaml
INFO  23:52:22 Node configuration:[authenticator=AllowAllAuthenticator; authorizer=AllowAllAuthorizer; auto_snapshot=true; batch_size_warn_threshold_in_kb=5; batchlog_replay_throttle_in_kb=1024; cas_contention_timeout_in_ms=1000; client_encryption_options=<REDACTED>; cluster_name=Rematch Staging; column_index_size_in_kb=64; commit_failure_policy=stop; commitlog_directory=/mnt/cassandra/commitlog; commitlog_segment_size_in_mb=32; commitlog_sync=periodic; commitlog_sync_period_in_ms=10000; compaction_throughput_mb_per_sec=16; concurrent_counter_writes=32; concurrent_reads=32; concurrent_writes=32; counter_cache_save_period=7200; counter_cache_size_in_mb=null; counter_write_request_timeout_in_ms=5000; cross_node_timeout=false; data_file_directories=[/mnt/cassandra/data]; disk_failure_policy=stop; dynamic_snitch_badness_threshold=0.1; dynamic_snitch_reset_interval_in_ms=600000; dynamic_snitch_update_interval_in_ms=100; endpoint_snitch=SimpleSnitch; hinted_handoff_enabled=true; hinted_handoff_throttle_in_kb=1024; incremental_backups=false; index_summary_capacity_in_mb=null; index_summary_resize_interval_in_minutes=60; inter_dc_tcp_nodelay=false; internode_compression=all; key_cache_save_period=14400; key_cache_size_in_mb=null; listen_address=10.65.163.181; max_hint_window_in_ms=10800000; max_hints_delivery_threads=2; memtable_allocation_type=heap_buffers; native_transport_port=9042; num_tokens=256; partitioner=org.apache.cassandra.dht.Murmur3Partitioner; permissions_validity_in_ms=2000; range_request_timeout_in_ms=10000; read_request_timeout_in_ms=5000; request_scheduler=org.apache.cassandra.scheduler.NoScheduler; request_timeout_in_ms=10000; row_cache_save_period=0; row_cache_size_in_mb=0; rpc_address=localhost; rpc_keepalive=true; rpc_port=9160; rpc_server_type=sync; saved_caches_directory=/mnt/cassandra/saved_caches; seed_provider=[{class_name=org.apache.cassandra.locator.SimpleSeedProvider, parameters=[{seeds=10.65.163.181}]}]; server_encryption_options=<REDACTED>; snapshot_before_compaction=false; ssl_storage_port=7001; sstable_preemptive_open_interval_in_mb=50; start_native_transport=true; start_rpc=true; storage_port=7000; thrift_framed_transport_size_in_mb=15; tombstone_failure_threshold=100000; tombstone_warn_threshold=1000; trickle_fsync=false; trickle_fsync_interval_in_kb=10240; truncate_request_timeout_in_ms=60000; write_request_timeout_in_ms=2000]
INFO  23:52:22 DiskAccessMode 'auto' determined to be mmap, indexAccessMode is mmap
INFO  23:52:22 Global memtable on-heap threshold is enabled at 72MB
INFO  23:52:22 Global memtable off-heap threshold is enabled at 72MB
INFO  23:52:23 Loading settings from file:/etc/cassandra/cassandra.yaml
INFO  23:52:23 Node configuration:[authenticator=AllowAllAuthenticator; authorizer=AllowAllAuthorizer; auto_snapshot=true; batch_size_warn_threshold_in_kb=5; batchlog_replay_throttle_in_kb=1024; cas_contention_timeout_in_ms=1000; client_encryption_options=<REDACTED>; cluster_name=Rematch Staging; column_index_size_in_kb=64; commit_failure_policy=stop; commitlog_directory=/mnt/cassandra/commitlog; commitlog_segment_size_in_mb=32; commitlog_sync=periodic; commitlog_sync_period_in_ms=10000; compaction_throughput_mb_per_sec=16; concurrent_counter_writes=32; concurrent_reads=32; concurrent_writes=32; counter_cache_save_period=7200; counter_cache_size_in_mb=null; counter_write_request_timeout_in_ms=5000; cross_node_timeout=false; data_file_directories=[/mnt/cassandra/data]; disk_failure_policy=stop; dynamic_snitch_badness_threshold=0.1; dynamic_snitch_reset_interval_in_ms=600000; dynamic_snitch_update_interval_in_ms=100; endpoint_snitch=SimpleSnitch; hinted_handoff_enabled=true; hinted_handoff_throttle_in_kb=1024; incremental_backups=false; index_summary_capacity_in_mb=null; index_summary_resize_interval_in_minutes=60; inter_dc_tcp_nodelay=false; internode_compression=all; key_cache_save_period=14400; key_cache_size_in_mb=null; listen_address=10.65.163.181; max_hint_window_in_ms=10800000; max_hints_delivery_threads=2; memtable_allocation_type=heap_buffers; native_transport_port=9042; num_tokens=256; partitioner=org.apache.cassandra.dht.Murmur3Partitioner; permissions_validity_in_ms=2000; range_request_timeout_in_ms=10000; read_request_timeout_in_ms=5000; request_scheduler=org.apache.cassandra.scheduler.NoScheduler; request_timeout_in_ms=10000; row_cache_save_period=0; row_cache_size_in_mb=0; rpc_address=localhost; rpc_keepalive=true; rpc_port=9160; rpc_server_type=sync; saved_caches_directory=/mnt/cassandra/saved_caches; seed_provider=[{class_name=org.apache.cassandra.locator.SimpleSeedProvider, parameters=[{seeds=10.65.163.181}]}]; server_encryption_options=<REDACTED>; snapshot_before_compaction=false; ssl_storage_port=7001; sstable_preemptive_open_interval_in_mb=50; start_native_transport=true; start_rpc=true; storage_port=7000; thrift_framed_transport_size_in_mb=15; tombstone_failure_threshold=100000; tombstone_warn_threshold=1000; trickle_fsync=false; trickle_fsync_interval_in_kb=10240; truncate_request_timeout_in_ms=60000; write_request_timeout_in_ms=2000]
INFO  23:52:23 JVM vendor/version: Java HotSpot(TM) 64-Bit Server VM/1.7.0_51
INFO  23:52:23 Heap size: 301727744/302776320
INFO  23:52:23 Code Cache Non-heap memory: init = 2555904(2496K) used = 716288(699K) committed = 2555904(2496K) max = 50331648(49152K)
INFO  23:52:23 Eden Space Heap memory: init = 61341696(59904K) used = 61341696(59904K) committed = 61341696(59904K) max = 61341696(59904K)
INFO  23:52:23 Survivor Space Heap memory: init = 7602176(7424K) used = 7602176(7424K) committed = 7602176(7424K) max = 7602176(7424K)
INFO  23:52:23 CMS Old Gen Heap memory: init = 232783872(227328K) used = 1157576(1130K) committed = 232783872(227328K) max = 233832448(228352K)
INFO  23:52:23 CMS Perm Gen Non-heap memory: init = 21757952(21248K) used = 16970288(16572K) committed = 21757952(21248K) max = 85983232(83968K)
INFO  23:52:23 Classpath: /etc/cassandra:/usr/share/cassandra/lib/airline-0.6.jar:/usr/share/cassandra/lib/antlr-runtime-3.5.2.jar:/usr/share/cassandra/lib/commons-cli-1.1.jar:/usr/share/cassandra/lib/commons-codec-1.2.jar:/usr/share/cassandra/lib/commons-lang3-3.1.jar:/usr/share/cassandra/lib/commons-math3-3.2.jar:/usr/share/cassandra/lib/compress-lzf-0.8.4.jar:/usr/share/cassandra/lib/concurrentlinkedhashmap-lru-1.4.jar:/usr/share/cassandra/lib/disruptor-3.0.1.jar:/usr/share/cassandra/lib/guava-16.0.jar:/usr/share/cassandra/lib/high-scale-lib-1.0.6.jar:/usr/share/cassandra/lib/jackson-core-asl-1.9.2.jar:/usr/share/cassandra/lib/jackson-mapper-asl-1.9.2.jar:/usr/share/cassandra/lib/jamm-0.2.8.jar:/usr/share/cassandra/lib/javax.inject.jar:/usr/share/cassandra/lib/jbcrypt-0.3m.jar:/usr/share/cassandra/lib/jline-1.0.jar:/usr/share/cassandra/lib/jna-4.0.0.jar:/usr/share/cassandra/lib/json-simple-1.1.jar:/usr/share/cassandra/lib/libthrift-0.9.1.jar:/usr/share/cassandra/lib/logback-classic-1.1.2.jar:/usr/share/cassandra/lib/logback-core-1.1.2.jar:/usr/share/cassandra/lib/lz4-1.2.0.jar:/usr/share/cassandra/lib/metrics-core-2.2.0.jar:/usr/share/cassandra/lib/netty-all-4.0.23.Final.jar:/usr/share/cassandra/lib/reporter-config-2.1.0.jar:/usr/share/cassandra/lib/slf4j-api-1.7.2.jar:/usr/share/cassandra/lib/snakeyaml-1.11.jar:/usr/share/cassandra/lib/snappy-java-1.0.5.2.jar:/usr/share/cassandra/lib/stream-2.5.2.jar:/usr/share/cassandra/lib/stringtemplate-4.0.2.jar:/usr/share/cassandra/lib/super-csv-2.1.0.jar:/usr/share/cassandra/lib/thrift-server-0.3.7.jar:/usr/share/cassandra/apache-cassandra-2.1.2.jar:/usr/share/cassandra/apache-cassandra-thrift-2.1.2.jar:/usr/share/cassandra/apache-cassandra.jar:/usr/share/cassandra/cassandra-driver-core-2.0.5.jar:/usr/share/cassandra/netty-3.9.0.Final.jar:/usr/share/cassandra/stress.jar::/usr/share/cassandra/lib/jamm-0.2.8.jar
</code>```

I checked /var/log/cassandra/system.log as well, no clue there either.

I know the "version restriction" of Cassandra upgrade says:

Upgrade to Cassandra 2.1 from Cassandra 2.0.7 or later.

Cassandra 2.1 is not compatible with Cassandra 1.x SSTables. First
  upgrade the nodes to Cassandra 2.0.7 or later, start the cluster,
  upgrade the SSTables, stop the cluster, and then upgrade to Cassandra
  2.1.

Does it mean I messed up the instance and have to start from scratch again? any idea?

Thanks

答:
For some reasons commitlog got corrupted and now Cassandra cannot start. Remove all files from this directory:

C:\Program Files\DataStax Community\data\commitlog

ContentLicense: CC BY-SA 3.0

Title: Cassandra stops silently - no error

Body:
I have been testing cassandra through an AWS Community AMI, which was running Cassandra 2.0.5.

I tried to upgrade it to 2.1.2 (the latest available), following the steps here, but now when I try to start cassandra, nothing happens. Logs are also clean. Here is the output:

ubuntu@ip-10-156-158-215:~$ sudo cassandra -f
INFO  23:52:22 Hostname: ip-10-156-158-215.ec2.internal
INFO  23:52:22 Loading settings from file:/etc/cassandra/cassandra.yaml
INFO  23:52:22 Node configuration:[authenticator=AllowAllAuthenticator; authorizer=AllowAllAuthorizer; auto_snapshot=true; batch_size_warn_threshold_in_kb=5; batchlog_replay_throttle_in_kb=1024; cas_contention_timeout_in_ms=1000; client_encryption_options=<REDACTED>; cluster_name=Rematch Staging; column_index_size_in_kb=64; commit_failure_policy=stop; commitlog_directory=/mnt/cassandra/commitlog; commitlog_segment_size_in_mb=32; commitlog_sync=periodic; commitlog_sync_period_in_ms=10000; compaction_throughput_mb_per_sec=16; concurrent_counter_writes=32; concurrent_reads=32; concurrent_writes=32; counter_cache_save_period=7200; counter_cache_size_in_mb=null; counter_write_request_timeout_in_ms=5000; cross_node_timeout=false; data_file_directories=[/mnt/cassandra/data]; disk_failure_policy=stop; dynamic_snitch_badness_threshold=0.1; dynamic_snitch_reset_interval_in_ms=600000; dynamic_snitch_update_interval_in_ms=100; endpoint_snitch=SimpleSnitch; hinted_handoff_enabled=true; hinted_handoff_throttle_in_kb=1024; incremental_backups=false; index_summary_capacity_in_mb=null; index_summary_resize_interval_in_minutes=60; inter_dc_tcp_nodelay=false; internode_compression=all; key_cache_save_period=14400; key_cache_size_in_mb=null; listen_address=10.65.163.181; max_hint_window_in_ms=10800000; max_hints_delivery_threads=2; memtable_allocation_type=heap_buffers; native_transport_port=9042; num_tokens=256; partitioner=org.apache.cassandra.dht.Murmur3Partitioner; permissions_validity_in_ms=2000; range_request_timeout_in_ms=10000; read_request_timeout_in_ms=5000; request_scheduler=org.apache.cassandra.scheduler.NoScheduler; request_timeout_in_ms=10000; row_cache_save_period=0; row_cache_size_in_mb=0; rpc_address=localhost; rpc_keepalive=true; rpc_port=9160; rpc_server_type=sync; saved_caches_directory=/mnt/cassandra/saved_caches; seed_provider=[{class_name=org.apache.cassandra.locator.SimpleSeedProvider, parameters=[{seeds=10.65.163.181}]}]; server_encryption_options=<REDACTED>; snapshot_before_compaction=false; ssl_storage_port=7001; sstable_preemptive_open_interval_in_mb=50; start_native_transport=true; start_rpc=true; storage_port=7000; thrift_framed_transport_size_in_mb=15; tombstone_failure_threshold=100000; tombstone_warn_threshold=1000; trickle_fsync=false; trickle_fsync_interval_in_kb=10240; truncate_request_timeout_in_ms=60000; write_request_timeout_in_ms=2000]
INFO  23:52:22 DiskAccessMode 'auto' determined to be mmap, indexAccessMode is mmap
INFO  23:52:22 Global memtable on-heap threshold is enabled at 72MB
INFO  23:52:22 Global memtable off-heap threshold is enabled at 72MB
INFO  23:52:23 Loading settings from file:/etc/cassandra/cassandra.yaml
INFO  23:52:23 Node configuration:[authenticator=AllowAllAuthenticator; authorizer=AllowAllAuthorizer; auto_snapshot=true; batch_size_warn_threshold_in_kb=5; batchlog_replay_throttle_in_kb=1024; cas_contention_timeout_in_ms=1000; client_encryption_options=<REDACTED>; cluster_name=Rematch Staging; column_index_size_in_kb=64; commit_failure_policy=stop; commitlog_directory=/mnt/cassandra/commitlog; commitlog_segment_size_in_mb=32; commitlog_sync=periodic; commitlog_sync_period_in_ms=10000; compaction_throughput_mb_per_sec=16; concurrent_counter_writes=32; concurrent_reads=32; concurrent_writes=32; counter_cache_save_period=7200; counter_cache_size_in_mb=null; counter_write_request_timeout_in_ms=5000; cross_node_timeout=false; data_file_directories=[/mnt/cassandra/data]; disk_failure_policy=stop; dynamic_snitch_badness_threshold=0.1; dynamic_snitch_reset_interval_in_ms=600000; dynamic_snitch_update_interval_in_ms=100; endpoint_snitch=SimpleSnitch; hinted_handoff_enabled=true; hinted_handoff_throttle_in_kb=1024; incremental_backups=false; index_summary_capacity_in_mb=null; index_summary_resize_interval_in_minutes=60; inter_dc_tcp_nodelay=false; internode_compression=all; key_cache_save_period=14400; key_cache_size_in_mb=null; listen_address=10.65.163.181; max_hint_window_in_ms=10800000; max_hints_delivery_threads=2; memtable_allocation_type=heap_buffers; native_transport_port=9042; num_tokens=256; partitioner=org.apache.cassandra.dht.Murmur3Partitioner; permissions_validity_in_ms=2000; range_request_timeout_in_ms=10000; read_request_timeout_in_ms=5000; request_scheduler=org.apache.cassandra.scheduler.NoScheduler; request_timeout_in_ms=10000; row_cache_save_period=0; row_cache_size_in_mb=0; rpc_address=localhost; rpc_keepalive=true; rpc_port=9160; rpc_server_type=sync; saved_caches_directory=/mnt/cassandra/saved_caches; seed_provider=[{class_name=org.apache.cassandra.locator.SimpleSeedProvider, parameters=[{seeds=10.65.163.181}]}]; server_encryption_options=<REDACTED>; snapshot_before_compaction=false; ssl_storage_port=7001; sstable_preemptive_open_interval_in_mb=50; start_native_transport=true; start_rpc=true; storage_port=7000; thrift_framed_transport_size_in_mb=15; tombstone_failure_threshold=100000; tombstone_warn_threshold=1000; trickle_fsync=false; trickle_fsync_interval_in_kb=10240; truncate_request_timeout_in_ms=60000; write_request_timeout_in_ms=2000]
INFO  23:52:23 JVM vendor/version: Java HotSpot(TM) 64-Bit Server VM/1.7.0_51
INFO  23:52:23 Heap size: 301727744/302776320
INFO  23:52:23 Code Cache Non-heap memory: init = 2555904(2496K) used = 716288(699K) committed = 2555904(2496K) max = 50331648(49152K)
INFO  23:52:23 Eden Space Heap memory: init = 61341696(59904K) used = 61341696(59904K) committed = 61341696(59904K) max = 61341696(59904K)
INFO  23:52:23 Survivor Space Heap memory: init = 7602176(7424K) used = 7602176(7424K) committed = 7602176(7424K) max = 7602176(7424K)
INFO  23:52:23 CMS Old Gen Heap memory: init = 232783872(227328K) used = 1157576(1130K) committed = 232783872(227328K) max = 233832448(228352K)
INFO  23:52:23 CMS Perm Gen Non-heap memory: init = 21757952(21248K) used = 16970288(16572K) committed = 21757952(21248K) max = 85983232(83968K)
INFO  23:52:23 Classpath: /etc/cassandra:/usr/share/cassandra/lib/airline-0.6.jar:/usr/share/cassandra/lib/antlr-runtime-3.5.2.jar:/usr/share/cassandra/lib/commons-cli-1.1.jar:/usr/share/cassandra/lib/commons-codec-1.2.jar:/usr/share/cassandra/lib/commons-lang3-3.1.jar:/usr/share/cassandra/lib/commons-math3-3.2.jar:/usr/share/cassandra/lib/compress-lzf-0.8.4.jar:/usr/share/cassandra/lib/concurrentlinkedhashmap-lru-1.4.jar:/usr/share/cassandra/lib/disruptor-3.0.1.jar:/usr/share/cassandra/lib/guava-16.0.jar:/usr/share/cassandra/lib/high-scale-lib-1.0.6.jar:/usr/share/cassandra/lib/jackson-core-asl-1.9.2.jar:/usr/share/cassandra/lib/jackson-mapper-asl-1.9.2.jar:/usr/share/cassandra/lib/jamm-0.2.8.jar:/usr/share/cassandra/lib/javax.inject.jar:/usr/share/cassandra/lib/jbcrypt-0.3m.jar:/usr/share/cassandra/lib/jline-1.0.jar:/usr/share/cassandra/lib/jna-4.0.0.jar:/usr/share/cassandra/lib/json-simple-1.1.jar:/usr/share/cassandra/lib/libthrift-0.9.1.jar:/usr/share/cassandra/lib/logback-classic-1.1.2.jar:/usr/share/cassandra/lib/logback-core-1.1.2.jar:/usr/share/cassandra/lib/lz4-1.2.0.jar:/usr/share/cassandra/lib/metrics-core-2.2.0.jar:/usr/share/cassandra/lib/netty-all-4.0.23.Final.jar:/usr/share/cassandra/lib/reporter-config-2.1.0.jar:/usr/share/cassandra/lib/slf4j-api-1.7.2.jar:/usr/share/cassandra/lib/snakeyaml-1.11.jar:/usr/share/cassandra/lib/snappy-java-1.0.5.2.jar:/usr/share/cassandra/lib/stream-2.5.2.jar:/usr/share/cassandra/lib/stringtemplate-4.0.2.jar:/usr/share/cassandra/lib/super-csv-2.1.0.jar:/usr/share/cassandra/lib/thrift-server-0.3.7.jar:/usr/share/cassandra/apache-cassandra-2.1.2.jar:/usr/share/cassandra/apache-cassandra-thrift-2.1.2.jar:/usr/share/cassandra/apache-cassandra.jar:/usr/share/cassandra/cassandra-driver-core-2.0.5.jar:/usr/share/cassandra/netty-3.9.0.Final.jar:/usr/share/cassandra/stress.jar::/usr/share/cassandra/lib/jamm-0.2.8.jar

I checked /var/log/cassandra/system.log as well, no clue there either.

I know the "version restriction" of Cassandra upgrade says:

Upgrade to Cassandra 2.1 from Cassandra 2.0.7 or later.

Cassandra 2.1 is not compatible with Cassandra 1.x SSTables. First
  upgrade the nodes to Cassandra 2.0.7 or later, start the cluster,
  upgrade the SSTables, stop the cluster, and then upgrade to Cassandra
  2.1.

Does it mean I messed up the instance and have to start from scratch again? any idea?

Thanks

ContentLicense: CC BY-SA 4.0


问:
Why GCC refuses a const reference within a copy-assignment operation?
I want to overload a common copy-assignment operator normally.
At first I used a interface that only requires a const reference to the source,
and explicitly disabled the interface that accepts a modifiable reference,
but I can not pass the compilation.
The compiler reports "error: use of deleted function ‘ClassA& ClassA::operator=(ClassA&)"

Of course, I can get compiled if I don't expicitly delete the interface, but that is not my purpose.
I'd like to explicitly delete it, to avoid unexpected using it.

Why a copy-assignment operation needs a modifiable reference to the source, instead of a const reference?
The assignment operation just needs to access the source read-only!

There is a same question about the copy-constructor, I omit it for simplifying.

What's wrong with my code? or we can NOT delete it?

My sample code is following:

```<code>class ClassA {
public:
   ClassA() = default;
   ClassA( ClassA & ) = default;

   ClassA & operator=( ClassA & )
   = delete   // Must comment-out this, or we can't pass the compilation.
   // { cout << "ClassA & operator=( ClassA & ) executed." << endl; return *this; }
   ;

   ClassA & operator=( ClassA && ) {
      cout << "ClassA & operator=( ClassA && ) executed." << endl;
      return *this;
   };

   ClassA & operator=( const ClassA & ) {
      cout << "ClassA & operator=( const ClassA & ) executed." << endl;
      return *this;
   };
   ClassA & operator=( const ClassA && ) {
      cout << "ClassA & operator=( const ClassA && ) executed." << endl;
      return *this;
   };
};

int main() {
   ClassA oa, ob;
   ob = oa;

   return EXIT_SUCCESS;
};
</code>```

答:
If you explicity delete it, and you call:

```<code>ob = oa;
// The same as
ob.operator=(oa);
</code>```

Of course ClassA & operator=( ClassA & ) is the best match as oa is a non-const lvalue. Since it is deleted, it will be an error.

If it is not declared at all, ClassA & operator=( const ClassA & ) now becomes the best match. So it will never try to use ClassA & operator=( ClassA & ) since it does not exist.

If you really wanted to, you could still have ClassA & operator=( ClassA & ) = delete;, and you would manually have to assign from const references:

```<code>ob = static_cast<const ClassA&>(oa);
// Will now select `ClassA & operator=( const ClassA & )`
</code>```

This shows that you don't need a non-const lvalue assignment operator. But there is really no point, as it will be used as a const reference anyways if ClassA & operator=( ClassA & ) is not declared.

Body:
I want to overload a common copy-assignment operator normally.
At first I used a interface that only requires a const reference to the source,
and explicitly disabled the interface that accepts a modifiable reference,
but I can not pass the compilation.
The compiler reports "error: use of deleted function ‘ClassA& ClassA::operator=(ClassA&)"

Of course, I can get compiled if I don't expicitly delete the interface, but that is not my purpose.
I'd like to explicitly delete it, to avoid unexpected using it.

Why a copy-assignment operation needs a modifiable reference to the source, instead of a const reference?
The assignment operation just needs to access the source read-only!

There is a same question about the copy-constructor, I omit it for simplifying.

What's wrong with my code? or we can NOT delete it?

My sample code is following:

class ClassA {
public:
   ClassA() = default;
   ClassA( ClassA & ) = default;

   ClassA & operator=( ClassA & )
   = delete   // Must comment-out this, or we can't pass the compilation.
   // { cout << "ClassA & operator=( ClassA & ) executed." << endl; return *this; }
   ;

   ClassA & operator=( ClassA && ) {
      cout << "ClassA & operator=( ClassA && ) executed." << endl;
      return *this;
   };

   ClassA & operator=( const ClassA & ) {
      cout << "ClassA & operator=( const ClassA & ) executed." << endl;
      return *this;
   };
   ClassA & operator=( const ClassA && ) {
      cout << "ClassA & operator=( const ClassA && ) executed." << endl;
      return *this;
   };
};

int main() {
   ClassA oa, ob;
   ob = oa;

   return EXIT_SUCCESS;
};

Body:
If you explicity delete it, and you call:

ob = oa;
// The same as
ob.operator=(oa);

Of course ClassA & operator=( ClassA & ) is the best match as oa is a non-const lvalue. Since it is deleted, it will be an error.

If it is not declared at all, ClassA & operator=( const ClassA & ) now becomes the best match. So it will never try to use ClassA & operator=( ClassA & ) since it does not exist.

If you really wanted to, you could still have ClassA & operator=( ClassA & ) = delete;, and you would manually have to assign from const references:

ob = static_cast<const ClassA&>(oa);
// Will now select `ClassA & operator=( const ClassA & )`

This shows that you don't need a non-const lvalue assignment operator. But there is really no point, as it will be used as a const reference anyways if ClassA & operator=( ClassA & ) is not declared.


问:
Visual Studio 2017 C#, debug async code, can't see local variables
I have a solution composed of 2 projects (business logic and tests). I run test in debug to check what is wrong with business logic.
The problem is that when I step through async method in business logic I can't see locals

But if I create the same method in my test class it works properly. So what's wrong with stepping thorough async method in referenced project?

Here is my test code

答: The problem is that you set the breakpoint at line 52. When the program reaches this line, it stops, but it does not execute it. So, myVar is not declared there. After running line 52 it will be declared and will be seen. Set your breakpoint at line 53.


问:
how to know if snort detects syn flood attacks since snort alert is not logging any thing
 I have snort running on Centos as IDS.  I am trying to test if snort can detect the syn flood attack. I am sending the attack from the same LAN network. I added this rule in local.rules alert tcp !$HOME_NET any -> $HOME_NET 80 (flags: S; msg:"Possible TCP DoS"; flow: stateless; threshold: type both, track by_src, count 70, seconds 10; sid:10001;rev:1;). Snort alert file is not logging when I run snort in fast  mode. It  was logging but now it is not . So I cannot see if it detects the attack or not . How can I make snort detects this attack ?

答:
```<code>alert tcp $HOME_NET any -> $HOME_NET 80 (flags: S; msg:"Syn Flood Detected"; flow: stateless; threshold: type both, track by_src, count 70, seconds 10; sid:1000003;rev:1;)
</code>```


问:
How to call one logic app from other logic app which currently located in different subscription
I have a requirement to call the logic app from other logic app which is located in a different subscription. how can I call?

I know how to call one logic app from other logic app when both are in the same subscription. How can I call if it is in different subscription?

答: You can use the HTTP trigger 'When a HTTP request is received'. With this you can define a schema. After the logic app is deployed you a link will be generated with a token in the url. Just call this URL from your first logic app. The URL will contain api-version,sp,sv and a sig. Hope it helps to get you started.


问:
Need to select values from a column using a list of strings using pandas.str()
Need to search a string column values from a list of strings. The strings in the search list are only a substring of the values in the column

```<code>df = pd.DataFrame(data={'text':['abc def', 'def ghi', 'poi opo', 'aswwf', 'abcs  sd'], 'id':[1, 2, 3, 4, 5]})

Out [1]:
    text     id
0   abc def  1
1   def ghi  2
2   poi opo  3
3   aswwf    4
4   abcs sd  5

search = ['abc', 'poi']
</code>```

Required:

```<code>
Out [2]:
    text     id
0   abc def  1
1   poi opo  3
2   abcs sd  5
</code>```

答:
Use Series.str.contains with boolean indexing - all values of list are joined by | for regex OR:

```<code>pat = '|'.join(search)
df1 = df[df['text'].str.contains(pat)]
print (df1)
       text  id
0   abc def   1
2   poi opo   3
4  abcs  sd   5
</code>```

Body:
Need to search a string column values from a list of strings. The strings in the search list are only a substring of the values in the column

df = pd.DataFrame(data={'text':['abc def', 'def ghi', 'poi opo', 'aswwf', 'abcs  sd'], 'id':[1, 2, 3, 4, 5]})

Out [1]:
    text     id
0   abc def  1
1   def ghi  2
2   poi opo  3
3   aswwf    4
4   abcs sd  5

search = ['abc', 'poi']

Required:

Out [2]:
    text     id
0   abc def  1
1   poi opo  3
2   abcs sd  5

Body:
Use Series.str.contains with boolean indexing - all values of list are joined by | for regex OR:

pat = '|'.join(search)
df1 = df[df['text'].str.contains(pat)]
print (df1)
       text  id
0   abc def   1
2   poi opo   3
4  abcs  sd   5


问:
Count of each column with non-null values in a table - Oracle
I have a table:

table1

```<code>col1        col2        col3        col4
a           b           (null)      c
a           b           (null)      c
a           (null)      (null)      c
(null)      b           (null)      (null)
a           b           (null)      (null)
a           b           (null)      (null)
</code>```

I have about 300 columns in the table. I need to find count of values for each column which are non-null without typing each column name in the table.

The output would be:

```<code>column_name         count_of_non_null
col1                5
col2                5
col3                0
col4                3
</code>```

Is there a way to do that?

答:
You need a dynamic PL/SQL to write conditional aggregation kind of queries:

```<code>select 'col1' col, count(case when col1 is null then 1 end) from table1
union all
select 'col2' col, count(case when col2 is null then 1 end) from table1
</code>```

Therefore, your PL/SQL code will be along these lines

```<code>declare
  v_cmd varchar2(10000);
begin
  for c_column in (select column_name from user_tab_columns where table_name = 'table1') loop
    v_counter := v_counter + 1;
    v_cmd := v_cmd || 'select ''' || c_column.column_name  || ''' col, count(case when ' || c_column.column_name || ' is null then 1 end) from table1 union all ';
  end loop;
  execute immediate left(v_cmd, length(v_cmd) - 11);
end;
/
</code>```

I did not tested it

Body:
I have a table:

table1

col1        col2        col3        col4
a           b           (null)      c
a           b           (null)      c
a           (null)      (null)      c
(null)      b           (null)      (null)
a           b           (null)      (null)
a           b           (null)      (null)

I have about 300 columns in the table. I need to find count of values for each column which are non-null without typing each column name in the table.

The output would be:

column_name         count_of_non_null
col1                5
col2                5
col3                0
col4                3

Is there a way to do that?

Body:
You need a dynamic PL/SQL to write conditional aggregation kind of queries:

select 'col1' col, count(case when col1 is null then 1 end) from table1
union all
select 'col2' col, count(case when col2 is null then 1 end) from table1

Therefore, your PL/SQL code will be along these lines

declare
  v_cmd varchar2(10000);
begin
  for c_column in (select column_name from user_tab_columns where table_name = 'table1') loop
    v_counter := v_counter + 1;
    v_cmd := v_cmd || 'select ''' || c_column.column_name  || ''' col, count(case when ' || c_column.column_name || ' is null then 1 end) from table1 union all ';
  end loop;
  execute immediate left(v_cmd, length(v_cmd) - 11);
end;
/

I did not tested it


问:
Why are these bootstrap buttons touching each other?
These two bootstrap buttons touch each other. Do I need to add some custom CSS to get some space between them? The docs here https://getbootstrap.com/docs/4.1/components/buttons/ don't touch each other.

```<code><link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<div class="container-fluid">
  <form>
    <div class="btn-toolbar">
      <button type="submit" class="btn btn-primary">Submit</button>
      <button type="reset" class="btn btn-secondary">Reset</button>
    </div>
  </form>
</div>
</code>```

StackBlitz https://stackblitz.com/edit/js-u5zg9m

答:
You can add:

```<code>    <div class="btn-toolbar" style="display: inline">
</code>```

so that your code looks like this:

<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

  <form>

      <button type="submit" class="btn btn-primary">Submit</button>
      <button type="reset" class="btn btn-secondary">Reset</button>

  </form>

```

Body:
These two bootstrap buttons touch each other. Do I need to add some custom CSS to get some space between them? The docs here https://getbootstrap.com/docs/4.1/components/buttons/ don't touch each other.

<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

  <form>

      <button type="submit" class="btn btn-primary">Submit</button>
      <button type="reset" class="btn btn-secondary">Reset</button>

  </form>

StackBlitz https://stackblitz.com/edit/js-u5zg9m

Body:
You can add:

    <div class="btn-toolbar" style="display: inline">

so that your code looks like this:

<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<div class="container-fluid">
  <form>
    <div class="btn-toolbar" style="display: inline">
      <button type="submit" class="btn btn-primary">Submit</button>
      <button type="reset" class="btn btn-secondary">Reset</button>
    </div>
  </form>
</div>


问:
How to bind ObservableCollection<T> on Datagrid?
I'm David. I don`t know to bind collection to datagrid in XAML for a WPF application.

below are classes.

```<code>class TestSetting(): INotifyChanged
{
   private a
   public double A
   {
      get a;
      set a = value;
      Notify("A");
   }

   private b
   public double B
   {
      get b;
      set b = value;
      Notify("B");
   }

   private c
   public double C
   {
      get c;
      set c = value;
      Notify("C");
   }

}

class TestCollect():ObservableCollection<T> ,INotifyListener
{

}
</code>```

above code is Psedo code.

DataContext has 7 items. So the grid will have 7 columns. Could someone please help me with an example or a code snippet.

答: If the datacontext contains a TestCollection, all that is needed is Setting the ItemsSource to {Binding}

Body:
I'm David. I don`t know to bind collection to datagrid in XAML for a WPF application.

below are classes.

class TestSetting(): INotifyChanged
{
   private a
   public double A
   {
      get a;
      set a = value;
      Notify("A");
   }

   private b
   public double B
   {
      get b;
      set b = value;
      Notify("B");
   }

   private c
   public double C
   {
      get c;
      set c = value;
      Notify("C");
   }

}

class TestCollect():ObservableCollection<T> ,INotifyListener
{

}

above code is Psedo code.

DataContext has 7 items. So the grid will have 7 columns. Could someone please help me with an example or a code snippet.


问:
Module Tensorflow has no attribute KMeans
I'm using Tensorflow for calculating DELF features.
I'm using next example from tensorflow models:
github.

So there is a line here:

```<code>kmeans = tf.estimator.experimental.KMeans(...)
</code>```

But I have no such model:

AttributeError: module
  'tensorflow_estimator.python.estimator.api.estimator.experimental' has
  no attribute 'KMeans'

My configuration:
tensorboard               1.13.1           py37hf484d3e_0

tensorflow                1.13.1          gpu_py37hc158e3b_0

tensorflow-base           1.13.1          gpu_py37h8d69cac_0

tensorflow-estimator      1.13.0                     py_0

tensorflow-gpu            1.13.1               h0d30ee6_0

Looks like this model replaced, but I can't find where.

答:
The correct syntax to use KMeans from tensorflow is

```<code>tf.contrib.factorization.KMeansClustering()
</code>```

For parameters and more information, read this.

Body:
I'm using Tensorflow for calculating DELF features.
I'm using next example from tensorflow models:
github.

So there is a line here:

kmeans = tf.estimator.experimental.KMeans(...)

But I have no such model:

AttributeError: module
  'tensorflow_estimator.python.estimator.api.estimator.experimental' has
  no attribute 'KMeans'

My configuration:
tensorboard               1.13.1           py37hf484d3e_0

tensorflow                1.13.1          gpu_py37hc158e3b_0

tensorflow-base           1.13.1          gpu_py37h8d69cac_0

tensorflow-estimator      1.13.0                     py_0

tensorflow-gpu            1.13.1               h0d30ee6_0

Looks like this model replaced, but I can't find where.

Body:
The correct syntax to use KMeans from tensorflow is

tf.contrib.factorization.KMeansClustering()

For parameters and more information, read this.


问:
Uncaught (in promise): Error: Can't resolve all parameters for LocalStorageService
I try to upgrade to latest Angular, and I got the error on my component and going to URL /login

it something like this :
ERROR Error: "Uncaught (in promise): Error: Can't resolve all parameters for LocalStorageService: (?).

my pages/login/login.component something like this :

```<code>import { Component, OnInit } from "@angular/core";
import { LocalStorageService } from "ngx-webstorage";
import { Router } from "@angular/router";
import { NgForm } from "@angular/forms";
import {
  SnotifyService,
  SnotifyPosition,
  SnotifyToastConfig
} from "ng-snotify";

import { AuthenticationService }
  constructor(
    private authenticationService: AuthenticationService,
    private router: Router,
    private localStorageService: LocalStorageService,
    private snotifyService: SnotifyService
  ) {}
</code>```

and on pages/login/login.module

```<code>import { NgModule } from "@angular/core";
import { RouterModule, Routes } from "@angular/router";
import { CommonModule } from "@angular/common";
import { LoginComponent } from "./login.component";
import { AuthService } from "../../../services/base-services/auth.service";
import { AuthenticationService } from "../../../services/authentication.service";
import { SnotifyModule, SnotifyService, ToastDefaults } from "ng-snotify";
import { FormsModule } from "@angular/forms";
import { LocalStorageService } from "ngx-webstorage";

export const LoginRoutes: Routes = [
  {
    path: "",
    data: {
      breadcrumb: "Login"
    },
    children: [
      {
        path: "",
        component: LoginComponent,
        data: {
          breadcrumb: "Login"
        }
      }
    ]
  }
];

@NgModule({
  declarations: [LoginComponent],
  imports: [
    CommonModule,
    RouterModule.forChild(LoginRoutes),
    SnotifyModule,
    FormsModule
  ],
  providers: [
    LocalStorageService,
    AuthenticationService,
    AuthService,
    SnotifyService,
    { provide: "SnotifyToastConfig", useValue: ToastDefaults }
  ]
})
export class LoginModule {}
</code>```

and on my app.module is something like this

```<code>import { BrowserModule } from "@angular/platform-browser";
import { NgModule } from "@angular/core";
import { AuthComponent } from "./layout/auth/auth.component";
import { HttpClientModule } from "@angular/common/http";
import { AuthGuardService } from "./services/base-services/auth-guard.service";
import { AuthenticationService } from "./services/authentication.service";
import { BreadcrumbsComponent } from "./layout/admin/breadcrumbs/breadcrumbs.component";
import { FormsModule } from "@angular/forms";

import { AppRoutingModule } from "./app-routing.module";
import { AppComponent } from "./app.component";

@NgModule({
  declarations: [AppComponent, AuthComponent, BreadcrumbsComponent],
  imports: [BrowserModule, AppRoutingModule, FormsModule, HttpClientModule],
  providers: [AuthGuardService, AuthenticationService],
  bootstrap: [AppComponent]
})
export class AppModule {}
</code>```

is there something wrong for import and put services on my files ?? or any missing syntax on my component ??

my package.json

```<code>{
  "name": "kontrak-hukum-front-end",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@agm/core": "^1.0.0-beta.5",
    "@angular/animations": "^8.0.0-rc.4",
    "@angular/common": "^8.0.0-rc.4",
    "@angular/compiler": "^8.0.0-rc.4",
    "@angular/core": "^8.0.0-rc.4",
    "@angular/forms": "^8.0.0-rc.4",
    "@angular/platform-browser": "^8.0.0-rc.4",
    "@angular/platform-browser-dynamic": "^8.0.0-rc.4",
    "@angular/platform-server": "^8.0.0-rc.4",
    "@angular/router": "^8.0.0-rc.4",
    "@fortawesome/angular-fontawesome": "^0.3.0",
    "@ng-bootstrap/ng-bootstrap": "^4.1.3",
    "@ng-select/ng-select": "^2.20.0",
    "@nicky-lenaers/ngx-scroll-to": "^2.0.0",
    "@swimlane/ngx-datatable": "^14.0.0",
    "@types/googlemaps": "^3.36.0",
    "angular-2-local-storage": "^3.0.2",
    "angular-froala-wysiwyg": "^3.0.0-beta.1",
    "angular-io-slimscroll": "^2.3.3",
    "angular2-chartjs": "^0.5.1",
    "angular2-datatable": "^0.6.0",
    "angular2-material-datepicker": "^0.5.0",
    "angular2-notifications": "^2.0.0",
    "angular2-wizard": "^0.4.0",
    "bootstrap": "^4.3.1",
    "c3": "^0.7.0",
    "core-js": "^3.1.2",
    "css-animator": "^2.3.1",
    "d3": "^5.9.2",
    "echarts": "^4.2.1",
    "famfamfam-flags": "^1.0.0",
    "font-awesome": "^4.7.0",
    "jquery": "^3.4.1",
    "jquery-sparkline": "^2.4.0",
    "ng-auto-complete": "^4.1.7",
    "ng-click-outside": "^4.0.0",
    "ng-snotify": "^4.3.1",
    "ng2-auto-complete": "^0.12.0",
    "ng2-ckeditor": "^1.2.2",
    "ng2-currency-mask": "^5.3.1",
    "ng2-file-upload": "^1.3.0",
    "ng2-google-charts": "^4.0.0",
    "ng2-nvd3": "^2.0.0",
    "ng2-order-pipe": "^0.1.5",
    "ng2-search-filter": "^0.5.1",
    "ng2-toasty": "^4.0.3",
    "ng2-ui-switch": "^1.0.2",
    "ng2-validation": "^4.2.0",
    "ngx-bootstrap": "^4.3.0",
    "ngx-chips": "^2.0.0-beta.0",
    "ngx-color-picker": "^7.5.0",
    "ngx-echarts": "^4.1.1",
    "ngx-order-pipe": "^2.0.2",
    "ngx-pagination": "^3.2.1",
    "ngx-quill": "^5.1.0",
    "ngx-quill-editor": "^2.2.2",
    "ngx-webstorage": "^3.0.2",
    "npm": "^6.9.0",
    "peity": "^3.3.0",
    "rxjs": "^6.5.2",
    "screenfull": "^4.2.0",
    "squeezebox": "^1.4.1",
    "sweetalert2": "^8.11.4",
    "ti-icons": "^0.1.2",
    "tslib": "^1.9.0",
    "wijmo": "^5.20191.606",
    "zone.js": "~0.9.1"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.800.0-rc.4",
    "@angular/cli": "^8.0.0-rc.4",
    "@angular/compiler-cli": "^8.0.0-rc.4",
    "@angular/language-service": "^8.0.0-rc.4",
    "@types/jasmine": "~3.3.12",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~12.0.2",
    "codelyzer": "^5.0.1",
    "jasmine-core": "~3.4.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~4.1.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-jasmine": "~2.0.1",
    "karma-jasmine-html-reporter": "^1.4.2",
    "protractor": "~5.4.0",
    "ts-node": "~8.1.0",
    "tslint": "~5.11.0",
    "typescript": "3.4.5"
  }
}
</code>```

答:
Before using the localStorageService in any component you need to import its module into AppModule or LoginModule.</p>

```<code>  LocalStorageModule.forRoot({
     prefix: 'my-app',
     storageType: 'localStorage'
  })

</code>```

Body:
I try to upgrade to latest Angular, and I got the error on my component and going to URL /login

it something like this :
ERROR Error: "Uncaught (in promise): Error: Can't resolve all parameters for LocalStorageService: (?).

my pages/login/login.component something like this :

import { Component, OnInit } from "@angular/core";
import { LocalStorageService } from "ngx-webstorage";
import { Router } from "@angular/router";
import { NgForm } from "@angular/forms";
import {
  SnotifyService,
  SnotifyPosition,
  SnotifyToastConfig
} from "ng-snotify";

import { AuthenticationService }
  constructor(
    private authenticationService: AuthenticationService,
    private router: Router,
    private localStorageService: LocalStorageService,
    private snotifyService: SnotifyService
  ) {}

and on pages/login/login.module

import { NgModule } from "@angular/core";
import { RouterModule, Routes } from "@angular/router";
import { CommonModule } from "@angular/common";
import { LoginComponent } from "./login.component";
import { AuthService } from "../../../services/base-services/auth.service";
import { AuthenticationService } from "../../../services/authentication.service";
import { SnotifyModule, SnotifyService, ToastDefaults } from "ng-snotify";
import { FormsModule } from "@angular/forms";
import { LocalStorageService } from "ngx-webstorage";

export const LoginRoutes: Routes = [
  {
    path: "",
    data: {
      breadcrumb: "Login"
    },
    children: [
      {
        path: "",
        component: LoginComponent,
        data: {
          breadcrumb: "Login"
        }
      }
    ]
  }
];

@NgModule({
  declarations: [LoginComponent],
  imports: [
    CommonModule,
    RouterModule.forChild(LoginRoutes),
    SnotifyModule,
    FormsModule
  ],
  providers: [
    LocalStorageService,
    AuthenticationService,
    AuthService,
    SnotifyService,
    { provide: "SnotifyToastConfig", useValue: ToastDefaults }
  ]
})
export class LoginModule {}

and on my app.module is something like this

import { BrowserModule } from "@angular/platform-browser";
import { NgModule } from "@angular/core";
import { AuthComponent } from "./layout/auth/auth.component";
import { HttpClientModule } from "@angular/common/http";
import { AuthGuardService } from "./services/base-services/auth-guard.service";
import { AuthenticationService } from "./services/authentication.service";
import { BreadcrumbsComponent } from "./layout/admin/breadcrumbs/breadcrumbs.component";
import { FormsModule } from "@angular/forms";

import { AppRoutingModule } from "./app-routing.module";
import { AppComponent } from "./app.component";

@NgModule({
  declarations: [AppComponent, AuthComponent, BreadcrumbsComponent],
  imports: [BrowserModule, AppRoutingModule, FormsModule, HttpClientModule],
  providers: [AuthGuardService, AuthenticationService],
  bootstrap: [AppComponent]
})
export class AppModule {}

is there something wrong for import and put services on my files ?? or any missing syntax on my component ??

my package.json

{
  "name": "kontrak-hukum-front-end",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@agm/core": "^1.0.0-beta.5",
    "@angular/animations": "^8.0.0-rc.4",
    "@angular/common": "^8.0.0-rc.4",
    "@angular/compiler": "^8.0.0-rc.4",
    "@angular/core": "^8.0.0-rc.4",
    "@angular/forms": "^8.0.0-rc.4",
    "@angular/platform-browser": "^8.0.0-rc.4",
    "@angular/platform-browser-dynamic": "^8.0.0-rc.4",
    "@angular/platform-server": "^8.0.0-rc.4",
    "@angular/router": "^8.0.0-rc.4",
    "@fortawesome/angular-fontawesome": "^0.3.0",
    "@ng-bootstrap/ng-bootstrap": "^4.1.3",
    "@ng-select/ng-select": "^2.20.0",
    "@nicky-lenaers/ngx-scroll-to": "^2.0.0",
    "@swimlane/ngx-datatable": "^14.0.0",
    "@types/googlemaps": "^3.36.0",
    "angular-2-local-storage": "^3.0.2",
    "angular-froala-wysiwyg": "^3.0.0-beta.1",
    "angular-io-slimscroll": "^2.3.3",
    "angular2-chartjs": "^0.5.1",
    "angular2-datatable": "^0.6.0",
    "angular2-material-datepicker": "^0.5.0",
    "angular2-notifications": "^2.0.0",
    "angular2-wizard": "^0.4.0",
    "bootstrap": "^4.3.1",
    "c3": "^0.7.0",
    "core-js": "^3.1.2",
    "css-animator": "^2.3.1",
    "d3": "^5.9.2",
    "echarts": "^4.2.1",
    "famfamfam-flags": "^1.0.0",
    "font-awesome": "^4.7.0",
    "jquery": "^3.4.1",
    "jquery-sparkline": "^2.4.0",
    "ng-auto-complete": "^4.1.7",
    "ng-click-outside": "^4.0.0",
    "ng-snotify": "^4.3.1",
    "ng2-auto-complete": "^0.12.0",
    "ng2-ckeditor": "^1.2.2",
    "ng2-currency-mask": "^5.3.1",
    "ng2-file-upload": "^1.3.0",
    "ng2-google-charts": "^4.0.0",
    "ng2-nvd3": "^2.0.0",
    "ng2-order-pipe": "^0.1.5",
    "ng2-search-filter": "^0.5.1",
    "ng2-toasty": "^4.0.3",
    "ng2-ui-switch": "^1.0.2",
    "ng2-validation": "^4.2.0",
    "ngx-bootstrap": "^4.3.0",
    "ngx-chips": "^2.0.0-beta.0",
    "ngx-color-picker": "^7.5.0",
    "ngx-echarts": "^4.1.1",
    "ngx-order-pipe": "^2.0.2",
    "ngx-pagination": "^3.2.1",
    "ngx-quill": "^5.1.0",
    "ngx-quill-editor": "^2.2.2",
    "ngx-webstorage": "^3.0.2",
    "npm": "^6.9.0",
    "peity": "^3.3.0",
    "rxjs": "^6.5.2",
    "screenfull": "^4.2.0",
    "squeezebox": "^1.4.1",
    "sweetalert2": "^8.11.4",
    "ti-icons": "^0.1.2",
    "tslib": "^1.9.0",
    "wijmo": "^5.20191.606",
    "zone.js": "~0.9.1"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.800.0-rc.4",
    "@angular/cli": "^8.0.0-rc.4",
    "@angular/compiler-cli": "^8.0.0-rc.4",
    "@angular/language-service": "^8.0.0-rc.4",
    "@types/jasmine": "~3.3.12",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~12.0.2",
    "codelyzer": "^5.0.1",
    "jasmine-core": "~3.4.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~4.1.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-jasmine": "~2.0.1",
    "karma-jasmine-html-reporter": "^1.4.2",
    "protractor": "~5.4.0",
    "ts-node": "~8.1.0",
    "tslint": "~5.11.0",
    "typescript": "3.4.5"
  }
}

Body:
Before using the localStorageService in any component you need to import its module into AppModule or LoginModule.

  LocalStorageModule.forRoot({
     prefix: 'my-app',
     storageType: 'localStorage'
  })


问:
Global HashMap - Drools
Can someone let me know if it's possible to use global hashMap in drl file?

I am trying to implement a counter functionality to keep track of all the documents processed.

I want to declare the variable at rule file level (something like class variable in java).

答:
See the below example to use HashMap in drl file as global:</p>

```<code>global java.util.HashMap gifts;
rule "Platinum Customer"
    when
        $c: Customer(customerType == CustomerType.Platinum, discountUsed == false)
    then
        modify($c){setDiscountUsed(true)}
        PlatinumGift pg = new PlatinumGift($c);
        insert(pg);
        ArrayList cList = (ArrayList)gifts.get(CustomerType.Platinum); //You need to do explicit type casting here; Without this, Drools compiler thinks it is an Object
        cList.add($c);

end

Java code to Invoke the above:

Map<CustomerType, ArrayList<Customer>> gifts = new HashMap<>();
gifts.put(CustomerType.Platinum, new ArrayList<Customer>());
        gifts.put(CustomerType.Gold, new ArrayList<Customer>());
        gifts.put(CustomerType.Silver, new ArrayList<Customer>());
        kieSession.setGlobal("gifts", gifts);
</code>```

Title: Global HashMap - Drools

Body:
See the below example to use HashMap in drl file as global:

global java.util.HashMap gifts;
rule "Platinum Customer"
    when
        $c: Customer(customerType == CustomerType.Platinum, discountUsed == false)
    then
        modify($c){setDiscountUsed(true)}
        PlatinumGift pg = new PlatinumGift($c);
        insert(pg);
        ArrayList cList = (ArrayList)gifts.get(CustomerType.Platinum); //You need to do explicit type casting here; Without this, Drools compiler thinks it is an Object
        cList.add($c);

end

Java code to Invoke the above:

Map<CustomerType, ArrayList<Customer>> gifts = new HashMap<>();
gifts.put(CustomerType.Platinum, new ArrayList<Customer>());
        gifts.put(CustomerType.Gold, new ArrayList<Customer>());
        gifts.put(CustomerType.Silver, new ArrayList<Customer>());
        kieSession.setGlobal("gifts", gifts);


问:
how to replace proto2 extension with proto3 any when extend different number of field?
I'm trying to learn proto3, and have some questions with any.

I use extension quite much, if my proto is like this:

```<code>message base {
    extensions 1 to 100;
}

// a.proto
extend base {
   optional int32 a = 1;
   optional int32 b = 2;
}

// b.proto
extend base {
   optional string c = 1;
   optional string d = 2;
   optional string e = 3;
   optional string f = 4;
}

</code>```

then how to replace these extensions with any ? should i must write like

```<code>import google/protobuf/any.proto
message base {
    any a = 1;
    any b = 2;
    any c = 3;
    any d = 4;
}
</code>```

?

may so many proto has extended base.proto and I cannot make sure the max extension number of these protos. then how can I replace these extensions with any?

If I have to write any from 1 to 100 in message base ... oh, that will be too terrible ！

答:
You would typically structure it like this:

```<code>message base {
    any submsg = 1;
}

// a.proto
message submsg_a {
   optional int32 a = 1;
   optional int32 b = 2;
}

// b.proto
message submsg_b {
   optional string c = 1;
   optional string d = 2;
   optional string e = 3;
   optional string f = 4;
}
</code>```

And then put either submsg_a or submsg_b inside the any field.

Body:
I'm trying to learn proto3, and have some questions with any.

I use extension quite much, if my proto is like this:

message base {
    extensions 1 to 100;
}

// a.proto
extend base {
   optional int32 a = 1;
   optional int32 b = 2;
}

// b.proto
extend base {
   optional string c = 1;
   optional string d = 2;
   optional string e = 3;
   optional string f = 4;
}

then how to replace these extensions with any ? should i must write like

import google/protobuf/any.proto
message base {
    any a = 1;
    any b = 2;
    any c = 3;
    any d = 4;
}

?

may so many proto has extended base.proto and I cannot make sure the max extension number of these protos. then how can I replace these extensions with any?

If I have to write any from 1 to 100 in message base ... oh, that will be too terrible ！

Body:
You would typically structure it like this:

message base {
    any submsg = 1;
}

// a.proto
message submsg_a {
   optional int32 a = 1;
   optional int32 b = 2;
}

// b.proto
message submsg_b {
   optional string c = 1;
   optional string d = 2;
   optional string e = 3;
   optional string f = 4;
}

And then put either submsg_a or submsg_b inside the any field.


问:
How to identify users which are connected to a windows server via remote desktop
At my workplace, we have lab machines that we use to do our testing.

The standard procedure to reserve a machine for testing was to walk around the office to make sure that no one was using the machine.

This is highly inefficient and time consuming.

At first, I set up a web page where people could reserve the lab machine but nobody was keeping the page updated so that turned up to be useless.

I finally found a solution using Microsoft log parser and wanted to share it to the stack overflow community.

It is a batch file that runs on the machine so the user can identify the last users that use the machine and easily IM them to ask if the machine is free.

Is there a better solution to do this?

答:
Totally out of the box:

You can install the Software Testing Automation Framework (STAF) on your servers and desktops to manage your tests. It's written in Java, so you can use it on Windows and Unix/Linux desktops and servers.

Using STAF, you can create a resource pool of test servers on which you conduct tests, then write STAX jobs (STAX is a STAF execution framework) to conduct the tests. The job can grab the first available server from the resource pool, run the test, monitor the test status, log results, notify the submitter, then release the server back into the pool when done. If you have multiple people submitting jobs for tests, STAF will manage the queue of requests and satisfy them as they came in. Users can either monitor the job from their desktop, or you can set up email alerts to notify them when the test is complete.

OwnerDisplayName: Julien Nephtali

ContentLicense: CC BY-SA 2.5

LastEditorDisplayName: sqook

OwnerDisplayName: Patrick Cuff


问:
Specific file name changes en masse
I need some regular expressions help. The scope of this is changing file names. Here is the pattern.

```<code>Super subject - Subject - Subsubject - Extra History - #number--hash.mp4
</code>```

As you can see in the following two examples, the super subject is not always present. I would like to move the #number after the subject and remove the hash at the end.

I need a bash command or script that will accomplish this.

```<code>Africa - Zulu Empire - Diamonds in South Africa - Extra History - #3--JG-5otw0O8.mp4
Simón Bolívar - Defeat is Not Surrender - Extra History - #4-Ie0IoiQQFKA.mp4
</code>```

I am looking for the output of:

```<code>Africa - Zulu Empire 3 - Diamonds in South Africa - Extra History.mp4
Simón Bolívar 4 - Defeat is Not Surrender - Extra History.mp4
</code>```

I ask this question this way because I know that regex is very specific and I have not learned regex. If there is a specific tool that I can solve this myself, please let me know. This tool needs to be easy to use, please.

答:
you mean something like this?

```<code>sed 's/\([^-]*\) - \([^-]*\)\([^#]*\) - #\([0-9]*\)[^.]*\(.*\)$/\1 \4 - \2\3\5/' testdata.txt
</code>```

testdata.txt

```<code>Africa - Zulu Empire - Diamonds in South Africa - Extra History - #3--JG-5otw0O8.mp4
Simón Bolívar - Defeat is Not Surrender - Extra History - #4-Ie0IoiQQFKA.mp4
</code>```

output

```<code>Africa 3 - Zulu Empire - Diamonds in South Africa - Extra History.mp4
Simón Bolívar 4 - Defeat is Not Surrender - Extra History.mp4
</code>```

explanation

```<code>sed 's/            # use sed substitution
\([^-]*\)          # store all characters unequal - in arg1 (\2)
 -                 # ignore separator
\([^-]*\)          # store all characters unequal - in arg2 (\2)
\([^#]*\)          # store all characters unequal # in arg1 (\3)
 - #               # ignore separator
\([0-9]*\)         # store number in arg4 (\4)
[^.]*              # ignore all chars unequal .
\(.*\)             # store suffix in arg5 (\5)
/\1 \4 - \2\3\5/'  # create output
</code>```

Script to rename files in local directory

```<code>#!/bin/bash
for file in *.mp4; do
    newname=$(sed 's/\([^-]*\) - \([^-]*\)\([^#]*\) - #\([0-9]*\)[^.]*\(.*\)$/\1 \4 - \2\3\5/' <<<"$file")
    mv "$file" "$newname"
done
</code>```

Title: Specific file name changes en masse

Body:
I need some regular expressions help. The scope of this is changing file names. Here is the pattern.

Super subject - Subject - Subsubject - Extra History - #number--hash.mp4

As you can see in the following two examples, the super subject is not always present. I would like to move the #number after the subject and remove the hash at the end.

I need a bash command or script that will accomplish this.

Africa - Zulu Empire - Diamonds in South Africa - Extra History - #3--JG-5otw0O8.mp4
Simón Bolívar - Defeat is Not Surrender - Extra History - #4-Ie0IoiQQFKA.mp4

I am looking for the output of:

Africa - Zulu Empire 3 - Diamonds in South Africa - Extra History.mp4
Simón Bolívar 4 - Defeat is Not Surrender - Extra History.mp4

I ask this question this way because I know that regex is very specific and I have not learned regex. If there is a specific tool that I can solve this myself, please let me know. This tool needs to be easy to use, please.

Body:
you mean something like this?

sed 's/\([^-]*\) - \([^-]*\)\([^#]*\) - #\([0-9]*\)[^.]*\(.*\)$/\1 \4 - \2\3\5/' testdata.txt

testdata.txt

Africa - Zulu Empire - Diamonds in South Africa - Extra History - #3--JG-5otw0O8.mp4
Simón Bolívar - Defeat is Not Surrender - Extra History - #4-Ie0IoiQQFKA.mp4

output

Africa 3 - Zulu Empire - Diamonds in South Africa - Extra History.mp4
Simón Bolívar 4 - Defeat is Not Surrender - Extra History.mp4

explanation

sed 's/            # use sed substitution
\([^-]*\)          # store all characters unequal - in arg1 (\2)
 -                 # ignore separator
\([^-]*\)          # store all characters unequal - in arg2 (\2)
\([^#]*\)          # store all characters unequal # in arg1 (\3)
 - #               # ignore separator
\([0-9]*\)         # store number in arg4 (\4)
[^.]*              # ignore all chars unequal .
\(.*\)             # store suffix in arg5 (\5)
/\1 \4 - \2\3\5/'  # create output

Script to rename files in local directory

#!/bin/bash
for file in *.mp4; do
    newname=$(sed 's/\([^-]*\) - \([^-]*\)\([^#]*\) - #\([0-9]*\)[^.]*\(.*\)$/\1 \4 - \2\3\5/' <<<"$file")
    mv "$file" "$newname"
done


问:
How can I include a header file that contains `>` in its name?
This is quite a contrived problem, I admit, but here it is.

Suppose you have a file with the > character in its name. This is possible on most Unix systems afaik:

```<code>$ touch 'weird>name'
$ ls -l
-rw-r--r--  1 user  user   0 28 Mag 11:05 weird>name
</code>```

Now, suppose this file contains C/C++ code and you want to include it as an header:

```<code>#include <weird>name>

int main() {
  return weird_function();
}
</code>```

Clang gives me the following error:

```<code>test.cpp:1:10: fatal error: 'weird' file not found
#include <weird>name>
</code>```

Of course, since the preprocessor parses the directive up to the first > and looks for the weird file. But, I wonder if some escaping mechanism exists to allow me to include the right file.

So, in C and/or C++, is there a way to include an header file which has the > character in its name?

Edit: Many suggested me why not to use #include "weird>name". I admit that my mind slipped over the quotes syntax while writing the question, but it remains valid because the two syntaxes may ask the compiler to search in different paths (theoretically at least). So is there any escaping mechanism to let me include weird>name using the #include <> syntax?

答:
So, in C and/or C++, is there a way to include an header file which has the > character in its name?

Yes:

```<code>#include "weird>name"
</code>```

So is there any escaping mechanism to let me include weird>name using the #include <> syntax?

No. The characters between the < and > must be "any member of the source character set except new-line and >" ([lex.header]). Any escaped form of > would still be a way to represent the > character, which is not allowed. Edit: Implementations are allowed to support implementation-defined escape sequences there though (see [lex.header] p2 and its footnote).

The #include " q-char-sequence " form does allow the > character to appear, even though it might get reprocessed as #include <...> if searching as "..." fails ([cpp.include] p3).

The preprocessor also allows another form ([cpp.include] p4](http://eel.is/c++draft/cpp.include#4)), but its effect are implementation-defined, and the implementations I tried do not allow joining weird and > and name into a single preprocessor-token that can then be included

Body:
This is quite a contrived problem, I admit, but here it is.

Suppose you have a file with the > character in its name. This is possible on most Unix systems afaik:

$ touch 'weird>name'
$ ls -l
-rw-r--r--  1 user  user   0 28 Mag 11:05 weird>name

Now, suppose this file contains C/C++ code and you want to include it as an header:

#include <weird>name>

int main() {
  return weird_function();
}

Clang gives me the following error:

test.cpp:1:10: fatal error: 'weird' file not found
#include <weird>name>

Of course, since the preprocessor parses the directive up to the first > and looks for the weird file. But, I wonder if some escaping mechanism exists to allow me to include the right file.

So, in C and/or C++, is there a way to include an header file which has the > character in its name?

Edit: Many suggested me why not to use #include "weird>name". I admit that my mind slipped over the quotes syntax while writing the question, but it remains valid because the two syntaxes may ask the compiler to search in different paths (theoretically at least). So is there any escaping mechanism to let me include weird>name using the #include <> syntax?

Body:
So, in C and/or C++, is there a way to include an header file which has the > character in its name?

Yes:

#include "weird>name"

So is there any escaping mechanism to let me include weird>name using the #include <> syntax?

No. The characters between the < and > must be "any member of the source character set except new-line and >" ([lex.header]). Any escaped form of > would still be a way to represent the > character, which is not allowed. Edit: Implementations are allowed to support implementation-defined escape sequences there though (see [lex.header] p2 and its footnote).

The #include " q-char-sequence " form does allow the > character to appear, even though it might get reprocessed as #include <...> if searching as "..." fails ([cpp.include] p3).

The preprocessor also allows another form ([cpp.include] p4](http://eel.is/c++draft/cpp.include#4)), but its effect are implementation-defined, and the implementations I tried do not allow joining weird and > and name into a single preprocessor-token that can then be included


问:
How can I find the maximum string type sublists(non-duplicate) with the maximum number of elements?
I want to get the sublists with the maximum number of strings that are not duplicate.

The code below says sets are not hashable which makes sense(TypeError: unhashable type: 'set'), but I can't find a way around this.

```<code>from collections import Counter
mylist = [{'task'}, {'task', 'time', 'element'}, {'task', 'current', 'time', 'element'}, {'task', 'element'}, {'task'}, {'task'}, {'task', 'element'}, {'task', 'element'}, {'task', 'element'}, {'task', 'push', 'stack', 'element'}]
find_max_lists = max(k for k,v in Counter(mylist).items() if v>1)
</code>```

Input

```<code>[{'task'}, {'task', 'time', 'element'}, {'task', 'current', 'time', 'element'}, {'task', 'element'}, {'task'}, {'task'}, {'task', 'element'}, {'task', 'element'}, {'task', 'element'}, {'task', 'push', 'stack', 'element'}]
</code>```

Output

```<code>[{'task', 'current', 'time', 'element'},{'task', 'push', 'stack', 'element'}]
</code>```

Input

```<code>[{'task'}, {'task', 'time', 'element'}, {'task', 'current', 'time', 'element'}, {'task', 'element'}, {'task'}, {'task'}, {'task', 'element'}, {'task', 'element'}, {'task', 'element'}, {'task', 'current', 'time', 'element'}]
</code>```

Output

```<code>[{'task', 'current', 'time', 'element'}]
</code>```

答:
You can do it without Counter. As your list contains set, and sets don't contain duplicate items inside them, you can just check the set-item inside the input list with highest length and create another list with items whose length matches with the highest length.

Here it is :

```<code>max_len = len(sorted(mylist, key = lambda x: len(x), reverse = True)[0])
output = [k for k in mylist if len(k)==max_len]
# For the second case where the final list may contain same set-item
uniq_list = [set(x) for x in set(tuple(x) for x in output)]
</code>```

Output :

```<code>[{'time', 'task', 'current', 'element'}, {'task', 'push', 'stack', 'element'}]
</code>```

Body:
I want to get the sublists with the maximum number of strings that are not duplicate.

The code below says sets are not hashable which makes sense(TypeError: unhashable type: 'set'), but I can't find a way around this.

from collections import Counter
mylist = [{'task'}, {'task', 'time', 'element'}, {'task', 'current', 'time', 'element'}, {'task', 'element'}, {'task'}, {'task'}, {'task', 'element'}, {'task', 'element'}, {'task', 'element'}, {'task', 'push', 'stack', 'element'}]
find_max_lists = max(k for k,v in Counter(mylist).items() if v>1)

Input

[{'task'}, {'task', 'time', 'element'}, {'task', 'current', 'time', 'element'}, {'task', 'element'}, {'task'}, {'task'}, {'task', 'element'}, {'task', 'element'}, {'task', 'element'}, {'task', 'push', 'stack', 'element'}]

Output

[{'task', 'current', 'time', 'element'},{'task', 'push', 'stack', 'element'}]

Input

[{'task'}, {'task', 'time', 'element'}, {'task', 'current', 'time', 'element'}, {'task', 'element'}, {'task'}, {'task'}, {'task', 'element'}, {'task', 'element'}, {'task', 'element'}, {'task', 'current', 'time', 'element'}]

Output

[{'task', 'current', 'time', 'element'}]

Body:
You can do it without Counter. As your list contains set, and sets don't contain duplicate items inside them, you can just check the set-item inside the input list with highest length and create another list with items whose length matches with the highest length.

Here it is :

max_len = len(sorted(mylist, key = lambda x: len(x), reverse = True)[0])
output = [k for k in mylist if len(k)==max_len]
# For the second case where the final list may contain same set-item
uniq_list = [set(x) for x in set(tuple(x) for x in output)]

Output :

[{'time', 'task', 'current', 'element'}, {'task', 'push', 'stack', 'element'}]


问:
Running behat tests in parallel (in two browser windows)
I followed this blog as an example and read the ParallerRunner info. When I call bin/behat command, one browser window opens and runs all the tests successfully with the setting below.

symfony/behat.yml

```<code>default:
    context:
        class: Site\CommonBundle\Features\Context\FeatureContext
    extensions:
        Behat\Symfony2Extension\Extension:
            mink_driver: true
            kernel:
                env: test
                debug: true
        Behat\MinkExtension\Extension:
            base_url: 'http://symfony.local/app_test.php/'
            javascript_session: selenium2
            browser_name: firefox
            goutte: ~
            selenium2: ~
    paths:
        features: %behat.paths.base%/src
        bootstrap: %behat.paths.features%/Context
</code>```

I modified the behay.yml (as shown below) to run some tests in one browser window and some in another window, however it doesn't do that. What it does is, it opens two browser windows but they both run same tests! How can I overcome this issue?

symfony/behat.yml

```<code>default:
    context:
        class: Site\CommonBundle\Features\Context\FeatureContext
        parameters:
            output_path: %behat.paths.base%/build/behat/output/
            screen_shot_path: %behat.paths.base%/build/behat/screenshot/
    extensions:
        Behat\Symfony2Extension\Extension:
            mink_driver: true
            kernel:
                env: test
                debug: true
        Behat\MinkExtension\Extension:
            base_url: 'http://symfony.local/app_test.php/'
            files_path: %behat.paths.base%/build/dummy/
            javascript_session: selenium2
            browser_name: firefox
            goutte: ~
            selenium2: ~
        shvetsgroup\ParallelRunner\Extension:
            process_count:  2
    paths:
        features: %behat.paths.base%/src
        bootstrap: %behat.paths.features%/Context

F1:
    filters:
        tags: "@backend"
F2:
    filters:
        tags: "@frontend"
</code>```

BEHAT TESTS:

This should run in one window:

```<code>@frontend
Feature: User Login

  @javascript
  Scenario: I can login to the system
    Given I am on "/login"
    And I login as "user"
</code>```

This should run in another window:

```<code>@backend
Feature: Admin Login

  @javascript
  Scenario: I can login to the system
    Given I am on "/login"
    And I login as "admin"
</code>```

答:
```<code>find ./features -name "*.feature" |
  parallel --gnu --halt-on-error=0 -j 3 --keep-order vendor/bin/behat -c src/my_directory/behat.yml
</code>```

--halt-on-error possibilities are :

0 Do not halt if a job fails. Exit status will be the number of jobs
failed. This is the default.

1 Do not start new jobs if a job fails, but complete the running
jobs including cleanup. The exit status will be the exit status from
the last failing job.

2 Kill off all jobs immediately and exit without cleanup. The exit
status will be the exit status from the failing job.

-j 3 : Run 3 jobs in parallel

It work perfectly with selenium.

Body:
I followed this blog as an example and read the ParallerRunner info. When I call bin/behat command, one browser window opens and runs all the tests successfully with the setting below.

symfony/behat.yml

default:
    context:
        class: Site\CommonBundle\Features\Context\FeatureContext
    extensions:
        Behat\Symfony2Extension\Extension:
            mink_driver: true
            kernel:
                env: test
                debug: true
        Behat\MinkExtension\Extension:
            base_url: 'http://symfony.local/app_test.php/'
            javascript_session: selenium2
            browser_name: firefox
            goutte: ~
            selenium2: ~
    paths:
        features: %behat.paths.base%/src
        bootstrap: %behat.paths.features%/Context

I modified the behay.yml (as shown below) to run some tests in one browser window and some in another window, however it doesn't do that. What it does is, it opens two browser windows but they both run same tests! How can I overcome this issue?

symfony/behat.yml

default:
    context:
        class: Site\CommonBundle\Features\Context\FeatureContext
        parameters:
            output_path: %behat.paths.base%/build/behat/output/
            screen_shot_path: %behat.paths.base%/build/behat/screenshot/
    extensions:
        Behat\Symfony2Extension\Extension:
            mink_driver: true
            kernel:
                env: test
                debug: true
        Behat\MinkExtension\Extension:
            base_url: 'http://symfony.local/app_test.php/'
            files_path: %behat.paths.base%/build/dummy/
            javascript_session: selenium2
            browser_name: firefox
            goutte: ~
            selenium2: ~
        shvetsgroup\ParallelRunner\Extension:
            process_count:  2
    paths:
        features: %behat.paths.base%/src
        bootstrap: %behat.paths.features%/Context

F1:
    filters:
        tags: "@backend"
F2:
    filters:
        tags: "@frontend"

BEHAT TESTS:

This should run in one window:

@frontend
Feature: User Login

  @javascript
  Scenario: I can login to the system
    Given I am on "/login"
    And I login as "user"

This should run in another window:

@backend
Feature: Admin Login

  @javascript
  Scenario: I can login to the system
    Given I am on "/login"
    And I login as "admin"

Body:
find ./features -name "*.feature" |
  parallel --gnu --halt-on-error=0 -j 3 --keep-order vendor/bin/behat -c src/my_directory/behat.yml

--halt-on-error possibilities are :

0 Do not halt if a job fails. Exit status will be the number of jobs
failed. This is the default.

1 Do not start new jobs if a job fails, but complete the running
jobs including cleanup. The exit status will be the exit status from
the last failing job.

2 Kill off all jobs immediately and exit without cleanup. The exit
status will be the exit status from the failing job.

-j 3 : Run 3 jobs in parallel

It work perfectly with selenium.


问:
Can't seem to update to sklearn 0.19 with pip?
First I tried to update the package according to the documentation using the commands below:

```<code>pip install -U scikit-learn
</code>```

or

```<code>conda install scikit-learn
</code>```

But the version is still 0.18 in PyCharm. Then I tried to run the update in "Settings--Project Interpreter", but failed with this error:

InstallError: Error: one or more of the packages already installed
  depend on 'conda' and should only be installed in the root
  environment: conda conda-env. These packages need to be removed before
  conda can proceed.

I'm totally stuck now. Appreciate any help in advance!

答:
You can use use virtualenv in pip and install scikit-learn inside the venv. With that solution you dont have to remove sci-kit from conda.

Install virtualenv using pip3

```<code>sudo pip3 install virtualenv
</code>```

** Create a virtual environment**

```<code>virtualenv venv
</code>```

Active your virtual environment:

```<code>source venv/bin/activate
</code>```

Then you can install now anything you want.

```<code>pip install -U scikit-learn
</code>```

Body:
First I tried to update the package according to the documentation using the commands below:

pip install -U scikit-learn

or

conda install scikit-learn

But the version is still 0.18 in PyCharm. Then I tried to run the update in "Settings--Project Interpreter", but failed with this error:

InstallError: Error: one or more of the packages already installed
  depend on 'conda' and should only be installed in the root
  environment: conda conda-env. These packages need to be removed before
  conda can proceed.

I'm totally stuck now. Appreciate any help in advance!

Body:
You can use use virtualenv in pip and install scikit-learn inside the venv. With that solution you dont have to remove sci-kit from conda.

Install virtualenv using pip3

sudo pip3 install virtualenv

** Create a virtual environment**

virtualenv venv

Active your virtual environment:

source venv/bin/activate

Then you can install now anything you want.

pip install -U scikit-learn


问:
How crop image by diagonally?
I want crop image by diagonally. My image dimension 1000x1000. I create blank image and try add cropped part to it. But output.png is empty.

```<code>Bitmap bmp1 = new Bitmap("input.png");
GraphicsPath gp = new GraphicsPath();

Point[] P = new Point[]
{
   new Point { X = 0, Y = 0 },
   new Point { X = 1000, Y = 0 },
   new Point { X = 0, Y = 1000 }
};

gp.AddPolygon(P.ToArray());

using (Bitmap bmp0 = (Bitmap)Bitmap.FromFile("output.png"))
using (Graphics G = Graphics.FromImage(bmp1))
{
  G.Clip = new Region(gp);
  G.DrawImage(bmp0, 0, 0);
  G.Save();
}
gp.Dispose();
</code>```

答:
you can use nested for loop.
pseudo code can be like this:</p>

```<code>for(int i=1; i<=1000;i++){
    for(int j=1;j<= i;i++){
        newImage[i][j] = image[i][j];
    }
}
</code>```

Title: How crop image by diagonally?

Body:
I want crop image by diagonally. My image dimension 1000x1000. I create blank image and try add cropped part to it. But output.png is empty.

Bitmap bmp1 = new Bitmap("input.png");
GraphicsPath gp = new GraphicsPath();

Point[] P = new Point[]
{
   new Point { X = 0, Y = 0 },
   new Point { X = 1000, Y = 0 },
   new Point { X = 0, Y = 1000 }
};

gp.AddPolygon(P.ToArray());

using (Bitmap bmp0 = (Bitmap)Bitmap.FromFile("output.png"))
using (Graphics G = Graphics.FromImage(bmp1))
{
  G.Clip = new Region(gp);
  G.DrawImage(bmp0, 0, 0);
  G.Save();
}
gp.Dispose();

Body:
you can use nested for loop.
pseudo code can be like this:

for(int i=1; i<=1000;i++){
    for(int j=1;j<= i;i++){
        newImage[i][j] = image[i][j];
    }
}


答:
```<code><link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T"
crossorigin="anonymous">
<div class="container-fluid">
    <form>
       <div class="btn-toolbar">
           <button type="submit" class="btn btn-primary mr-1">Submit</button>
           <button type="reset" class="btn btn-secondary">Reset</button>
       </div>
    </form>
</div>
</code>```

just add a margin using mr-1 on the submit button or ml-1 to the reset button

Title: Why are these bootstrap buttons touching each other?

Body:
These two bootstrap buttons touch each other. Do I need to add some custom CSS to get some space between them? The docs here https://getbootstrap.com/docs/4.1/components/buttons/ don't touch each other.

<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

  <form>

      <button type="submit" class="btn btn-primary">Submit</button>
      <button type="reset" class="btn btn-secondary">Reset</button>

  </form>

StackBlitz https://stackblitz.com/edit/js-u5zg9m

Body:
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T"
crossorigin="anonymous">
<div class="container-fluid">
    <form>
       <div class="btn-toolbar">
           <button type="submit" class="btn btn-primary mr-1">Submit</button>
           <button type="reset" class="btn btn-secondary">Reset</button>
       </div>
    </form>
</div>

just add a margin using mr-1 on the submit button or ml-1 to the reset button