text:
Q: MariaDB Galera Cluster over IPSec I am working on the expandation of my server infrastrucutre, so I orderd Servers in a second datacenter which I want to use as failover location.
For better identifiaction I will use "ffm1" for the primary datacenter and "ffm2" for the failover location.
On both locations I have an replicated pfSense Firewall which are connected via an IPSec Tunnel.
10.0.0.0/16 - ffm1 local subnet
10.3.0.0/16 - ffm2 local subnet
10.1.0.0/16 and 10.2.0.0/16 are reserved for other datacenters with interconnect.
Currently the most stuff is working fine with the IPSec Tunnel: I can use my internal repository, dns servers, ldap etc.
On ffm1 I have a HA Gelera Cluster with 4 MariaDB Nodes and two MaxScale Instances which are failover-balanced by my pfSense load balancers.
Now I want to extend the Cluster on ffm2. Both datacenters are connected with 2 x 100GBit and I have 2 x 10Gbit Uplink on both sides, so it should no problem.
So I installed a Node on ffm2 and set the Gelra Configuration:
#
# * Galera-related settings
#
[galera]
# Mandatory settings
wsrep_on=ON
wsrep_provider=/usr/lib64/galera/libgalera_smm.so
wsrep_cluster_address=gcomm://10.0.5.11,10.0.5.12,10.0.5.13,10.0.5.14,10.3.0.26
binlog_format=row
default_storage_engine=InnoDB
innodb_autoinc_lock_mode=2

But when I try to start mariadb, I got an error. I could find the following log entries:
Aug 24 09:37:44 ffcdb1 mysqld: 2019-08-24  9:37:44 0 [Note] WSREP: Read nil XID from storage engines, skipping position init
Aug 24 09:37:44 ffcdb1 mysqld: 2019-08-24  9:37:44 0 [Note] WSREP: wsrep_load(): loading provider library '/usr/lib64/galera/libgalera_smm.so'
Aug 24 09:37:44 ffcdb1 mysqld: 2019-08-24  9:37:44 0 [Note] WSREP: wsrep_load(): Galera 25.3.26(r3857) by Codership Oy <info@codership.com> loaded successfully.
Aug 24 09:37:44 ffcdb1 mysqld: 2019-08-24  9:37:44 0 [Note] WSREP: CRC-32C: using "slicing-by-8" algorithm.
Aug 24 09:37:44 ffcdb1 mysqld: 2019-08-24  9:37:44 0 [Note] WSREP: Found saved state: 00000000-0000-0000-0000-000000000000:-1, safe_to_bootstrap: 1
Aug 24 09:37:44 ffcdb1 mysqld: 2019-08-24  9:37:44 0 [Note] WSREP: Passing config to GCS: base_dir = /var/lib/mysql/; base_host = 10.3.0.26; base_port = 4567; cert.log_conflicts = no; cert.optimistic_pa = yes; debug = no; evs.auto_evict = 0; evs.delay_margin = PT1S; evs.delayed_keep_period = PT30S; evs.inactive_check_period = PT0.5S; evs.inactive_timeout = PT15S; evs.join_retrans_period = PT1S; evs.max_install_timeouts = 3; evs.send_window = 4; evs.stats_report_period = PT1M; evs.suspect_timeout = PT5S; evs.user_send_window = 2; evs.view_forget_timeout = PT24H; gcache.dir = /var/lib/mysql/; gcache.keep_pages_size = 0; gcache.mem_size = 0; gcache.name = /var/lib/mysql//galera.cache; gcache.page_size = 128M; gcache.recover = no; gcache.size = 128M; gcomm.thread_prio = ; gcs.fc_debug = 0; gcs.fc_factor = 1.0; gcs.fc_limit = 16; gcs.fc_master_slave = no; gcs.max_packet_size = 64500; gcs.max_throttle = 0.25; gcs.recv_q_hard_limit = 9223372036854775807; gcs.recv_q_soft_limit = 0.25; gcs.sync_donor = no; gmcast.segment = 0; gmcast.version = 0; pc.announce_timeout = PT3S; pc
Aug 24 09:37:44 ffcdb1 mysqld: 2019-08-24  9:37:44 0 [Note] WSREP: GCache history reset: 886e1511-9278-11e9-b808-5bf36b96cc3c:0 -> 00000000-0000-0000-0000-000000000000:-1
Aug 24 09:37:44 ffcdb1 mysqld: 2019-08-24  9:37:44 0 [Note] WSREP: Assign initial position for certification: -1, protocol version: -1
Aug 24 09:37:44 ffcdb1 mysqld: 2019-08-24  9:37:44 0 [Note] WSREP: wsrep_sst_grab()
Aug 24 09:37:44 ffcdb1 mysqld: 2019-08-24  9:37:44 0 [Note] WSREP: Start replication
Aug 24 09:37:44 ffcdb1 mysqld: 2019-08-24  9:37:44 0 [Note] WSREP: Setting initial position to 00000000-0000-0000-0000-000000000000:-1
Aug 24 09:37:44 ffcdb1 mysqld: 2019-08-24  9:37:44 0 [Note] WSREP: protonet asio version 0
Aug 24 09:37:44 ffcdb1 mysqld: 2019-08-24  9:37:44 0 [Note] WSREP: Using CRC-32C for message checksums.
Aug 24 09:37:44 ffcdb1 mysqld: 2019-08-24  9:37:44 0 [Note] WSREP: backend: asio
Aug 24 09:37:44 ffcdb1 mysqld: 2019-08-24  9:37:44 0 [Note] WSREP: gcomm thread scheduling priority set to other:0
Aug 24 09:37:44 ffcdb1 mysqld: 2019-08-24  9:37:44 0 [Warning] WSREP: access file(/var/lib/mysql//gvwstate.dat) failed(No such file or directory)
Aug 24 09:37:44 ffcdb1 mysqld: 2019-08-24  9:37:44 0 [Note] WSREP: restore pc from disk failed
Aug 24 09:37:44 ffcdb1 mysqld: 2019-08-24  9:37:44 0 [Note] WSREP: GMCast version 0
Aug 24 09:37:44 ffcdb1 mysqld: 2019-08-24  9:37:44 0 [Note] WSREP: (0f8b0c37, 'tcp://0.0.0.0:4567') listening at tcp://0.0.0.0:4567
Aug 24 09:37:44 ffcdb1 mysqld: 2019-08-24  9:37:44 0 [Note] WSREP: (0f8b0c37, 'tcp://0.0.0.0:4567') multicast: , ttl: 1
Aug 24 09:37:44 ffcdb1 mysqld: 2019-08-24  9:37:44 0 [Note] WSREP: EVS version 0
Aug 24 09:37:44 ffcdb1 mysqld: 2019-08-24  9:37:44 0 [Note] WSREP: gcomm: connecting to group 'my_wsrep_cluster', peer '10.0.5.11:,10.0.5.12:,10.0.5.13:,10.0.5.14:,10.3.0.26:'
Aug 24 09:37:44 ffcdb1 mysqld: 2019-08-24  9:37:44 0 [Note] WSREP: (0f8b0c37, 'tcp://0.0.0.0:4567') connection established to 0f8b0c37 tcp://10.3.0.26:4567
Aug 24 09:37:44 ffcdb1 mysqld: 2019-08-24  9:37:44 0 [Warning] WSREP: (0f8b0c37, 'tcp://0.0.0.0:4567') address 'tcp://10.3.0.26:4567' points to own listening address, blacklisting
Aug 24 09:37:44 ffcdb1 mysqld: 2019-08-24  9:37:44 0 [Note] WSREP: (0f8b0c37, 'tcp://0.0.0.0:4567') connection established to 2c2ef983 tcp://10.0.5.13:4567
Aug 24 09:37:44 ffcdb1 mysqld: 2019-08-24  9:37:44 0 [Note] WSREP: (0f8b0c37, 'tcp://0.0.0.0:4567') turning message relay requesting on, nonlive peers:
Aug 24 09:37:44 ffcdb1 mysqld: 2019-08-24  9:37:44 0 [Note] WSREP: (0f8b0c37, 'tcp://0.0.0.0:4567') connection established to d4b50fbb tcp://10.0.5.11:4567
Aug 24 09:37:44 ffcdb1 mysqld: 2019-08-24  9:37:44 0 [Note] WSREP: (0f8b0c37, 'tcp://0.0.0.0:4567') connection established to c241e84f tcp://10.0.5.12:4567
Aug 24 09:37:44 ffcdb1 mysqld: 2019-08-24  9:37:44 0 [Note] WSREP: (0f8b0c37, 'tcp://0.0.0.0:4567') connection established to 3f000499 tcp://10.0.5.14:4567
Aug 24 09:37:45 ffcdb1 mysqld: 2019-08-24  9:37:45 0 [Warning] WSREP: last inactive check more than PT1.5S ago (PT1.50881S), skipping check
Aug 24 09:37:46 ffcdb1 mysqld: 2019-08-24  9:37:46 0 [Note] WSREP: declaring 2c2ef983 at tcp://10.0.5.13:4567 stable
Aug 24 09:37:46 ffcdb1 mysqld: 2019-08-24  9:37:46 0 [Note] WSREP: declaring 3f000499 at tcp://10.0.5.14:4567 stable
Aug 24 09:37:46 ffcdb1 mysqld: 2019-08-24  9:37:46 0 [Note] WSREP: declaring c241e84f at tcp://10.0.5.12:4567 stable
Aug 24 09:37:46 ffcdb1 mysqld: 2019-08-24  9:37:46 0 [Note] WSREP: declaring d4b50fbb at tcp://10.0.5.11:4567 stable
Aug 24 09:37:47 ffcdb1 mysqld: 2019-08-24  9:37:47 0 [Note] WSREP: (0f8b0c37, 'tcp://0.0.0.0:4567') connection to peer 0f8b0c37 with addr tcp://10.3.0.26:4567 timed out, no messages seen in PT3S
Aug 24 09:37:47 ffcdb1 mysqld: 2019-08-24  9:37:47 0 [Note] WSREP: Node 2c2ef983 state prim
Aug 24 09:37:47 ffcdb1 mysqld: 2019-08-24  9:37:47 0 [Note] WSREP: view(view_id(PRIM,0f8b0c37,83) memb {
Aug 24 09:37:47 ffcdb1 mysqld: 0f8b0c37,0
Aug 24 09:37:47 ffcdb1 mysqld: 2c2ef983,0
Aug 24 09:37:47 ffcdb1 mysqld: 3f000499,0
Aug 24 09:37:47 ffcdb1 mysqld: c241e84f,0
Aug 24 09:37:47 ffcdb1 mysqld: d4b50fbb,0
Aug 24 09:37:47 ffcdb1 mysqld: } joined {
Aug 24 09:37:47 ffcdb1 mysqld: } left {
Aug 24 09:37:47 ffcdb1 mysqld: } partitioned {
Aug 24 09:37:47 ffcdb1 mysqld: })
Aug 24 09:37:47 ffcdb1 mysqld: 2019-08-24  9:37:47 0 [Note] WSREP: save pc into disk
Aug 24 09:37:47 ffcdb1 mysqld: 2019-08-24  9:37:47 0 [Note] WSREP: (0f8b0c37, 'tcp://0.0.0.0:4567') turning message relay requesting off
Aug 24 09:37:47 ffcdb1 mysqld: 2019-08-24  9:37:47 0 [Note] WSREP: gcomm: connected
Aug 24 09:37:47 ffcdb1 mysqld: 2019-08-24  9:37:47 0 [Note] WSREP: Changing maximum packet size to 64500, resulting msg size: 32636
Aug 24 09:37:47 ffcdb1 mysqld: 2019-08-24  9:37:47 0 [Note] WSREP: Shifting CLOSED -> OPEN (TO: 0)
Aug 24 09:37:47 ffcdb1 mysqld: 2019-08-24  9:37:47 0 [Note] WSREP: Opened channel 'my_wsrep_cluster'
Aug 24 09:37:47 ffcdb1 mysqld: 2019-08-24  9:37:47 0 [Note] WSREP: New COMPONENT: primary = yes, bootstrap = no, my_idx = 0, memb_num = 5
Aug 24 09:37:47 ffcdb1 mysqld: 2019-08-24  9:37:47 0 [Note] WSREP: Waiting for SST to complete.
Aug 24 09:37:47 ffcdb1 mysqld: 2019-08-24  9:37:47 0 [Note] WSREP: STATE_EXCHANGE: sent state UUID: 11a1a631-c642-11e9-9bf8-2a2f60544da4
Aug 24 09:37:47 ffcdb1 mysqld: 2019-08-24  9:37:47 0 [Note] WSREP: STATE EXCHANGE: sent state msg: 11a1a631-c642-11e9-9bf8-2a2f60544da4
Aug 24 09:37:47 ffcdb1 mysqld: 2019-08-24  9:37:47 0 [Note] WSREP: STATE EXCHANGE: got state msg: 11a1a631-c642-11e9-9bf8-2a2f60544da4 from 0 (ffcdb1.HOSTNAME.de)
Aug 24 09:37:47 ffcdb1 mysqld: 2019-08-24  9:37:47 0 [Note] WSREP: STATE EXCHANGE: got state msg: 11a1a631-c642-11e9-9bf8-2a2f60544da4 from 1 (db3.HOSTNAME.intern)
Aug 24 09:37:47 ffcdb1 mysqld: 2019-08-24  9:37:47 0 [Note] WSREP: STATE EXCHANGE: got state msg: 11a1a631-c642-11e9-9bf8-2a2f60544da4 from 2 (db4.HOSTNAME.intern)
Aug 24 09:37:47 ffcdb1 mysqld: 2019-08-24  9:37:47 0 [Note] WSREP: STATE EXCHANGE: got state msg: 11a1a631-c642-11e9-9bf8-2a2f60544da4 from 3 (db2.HOSTNAME.intern)
Aug 24 09:37:47 ffcdb1 mysqld: 2019-08-24  9:37:47 0 [Note] WSREP: STATE EXCHANGE: got state msg: 11a1a631-c642-11e9-9bf8-2a2f60544da4 from 4 (db1.HOSTNAME.intern)
Aug 24 09:37:47 ffcdb1 mysqld: 2019-08-24  9:37:47 0 [Note] WSREP: Quorum results:
Aug 24 09:37:47 ffcdb1 mysqld: version    = 4,
Aug 24 09:37:47 ffcdb1 mysqld: component  = PRIMARY,
Aug 24 09:37:47 ffcdb1 mysqld: conf_id    = 67,
Aug 24 09:37:47 ffcdb1 mysqld: members    = 4/5 (joined/total),
Aug 24 09:37:47 ffcdb1 mysqld: act_id     = 26678596,
Aug 24 09:37:47 ffcdb1 mysqld: last_appl. = -1,
Aug 24 09:37:47 ffcdb1 mysqld: protocols  = 0/9/3 (gcs/repl/appl),
Aug 24 09:37:47 ffcdb1 mysqld: group UUID = 886e1511-9278-11e9-b808-5bf36b96cc3c
Aug 24 09:37:47 ffcdb1 mysqld: 2019-08-24  9:37:47 0 [Note] WSREP: Flow-control interval: [36, 36]
Aug 24 09:37:47 ffcdb1 mysqld: 2019-08-24  9:37:47 0 [Note] WSREP: Trying to continue unpaused monitor
Aug 24 09:37:47 ffcdb1 mysqld: 2019-08-24  9:37:47 0 [Note] WSREP: Shifting OPEN -> PRIMARY (TO: 26678596)
Aug 24 09:37:47 ffcdb1 mysqld: 2019-08-24  9:37:47 2 [Note] WSREP: State transfer required:
Aug 24 09:37:47 ffcdb1 mysqld: Group state: 886e1511-9278-11e9-b808-5bf36b96cc3c:26678596
Aug 24 09:37:47 ffcdb1 mysqld: Local state: 00000000-0000-0000-0000-000000000000:-1
Aug 24 09:37:47 ffcdb1 mysqld: 2019-08-24  9:37:47 2 [Note] WSREP: New cluster view: global state: 886e1511-9278-11e9-b808-5bf36b96cc3c:26678596, view# 68: Primary, number of nodes: 5, my index: 0, protocol version 3
Aug 24 09:37:47 ffcdb1 mysqld: 2019-08-24  9:37:47 2 [Warning] WSREP: Gap in state sequence. Need state transfer.
Aug 24 09:37:47 ffcdb1 mysqld: 2019-08-24  9:37:47 0 [Note] WSREP: Running: 'wsrep_sst_rsync --role 'joiner' --address '10.3.0.26' --datadir '/var/lib/mysql/'   --parent '809'  ''  '''
Aug 24 09:37:47 ffcdb1 rsyncd[859]: rsyncd version 3.1.2 starting, listening on port 4444
Aug 24 09:37:47 ffcdb1 mysqld: 2019-08-24  9:37:47 2 [Note] WSREP: Prepared SST request: rsync|10.3.0.26:4444/rsync_sst
Aug 24 09:37:47 ffcdb1 mysqld: 2019-08-24  9:37:47 2 [Note] WSREP: wsrep_notify_cmd is not defined, skipping notification.
Aug 24 09:37:47 ffcdb1 mysqld: 2019-08-24  9:37:47 2 [Note] WSREP: REPL Protocols: 9 (4, 2)
Aug 24 09:37:47 ffcdb1 mysqld: 2019-08-24  9:37:47 2 [Note] WSREP: Assign initial position for certification: 26678596, protocol version: 4
Aug 24 09:37:47 ffcdb1 mysqld: 2019-08-24  9:37:47 0 [Note] WSREP: Service thread queue flushed.
Aug 24 09:37:47 ffcdb1 mysqld: 2019-08-24  9:37:47 2 [Warning] WSREP: Failed to prepare for incremental state transfer: Local state UUID (00000000-0000-0000-0000-000000000000) does not match group state UUID (886e1511-9278-11e9-b808-5bf36b96cc3c): 1 (Operation not permitted)
Aug 24 09:37:47 ffcdb1 mysqld: at galera/src/replicator_str.cpp:prepare_for_IST():482. IST will be unavailable.
Aug 24 09:37:47 ffcdb1 mysqld: 2019-08-24  9:37:47 0 [Note] WSREP: Member 0.0 (ffcdb1.HOSTNAME.de) requested state transfer from '*any*'. Selected 1.0 (db3.HOSTNAME.intern)(SYNCED) as donor.
Aug 24 09:37:47 ffcdb1 mysqld: 2019-08-24  9:37:47 0 [Note] WSREP: Shifting PRIMARY -> JOINER (TO: 26678596)
Aug 24 09:37:47 ffcdb1 mysqld: 2019-08-24  9:37:47 2 [Note] WSREP: Requesting state transfer: success, donor: 1
Aug 24 09:37:47 ffcdb1 mysqld: 2019-08-24  9:37:47 2 [Note] WSREP: GCache history reset: 00000000-0000-0000-0000-000000000000:0 -> 886e1511-9278-11e9-b808-5bf36b96cc3c:26678596
Aug 24 09:37:51 ffcdb1 rsyncd[891]: name lookup failed for 10.0.5.13: Name or service not known
Aug 24 09:37:51 ffcdb1 rsyncd[891]: connect from UNKNOWN (10.0.5.13)
Aug 24 09:37:51 ffcdb1 rsyncd[891]: rsync to rsync_sst/ from UNKNOWN (10.0.5.13)
Aug 24 09:37:51 ffcdb1 rsyncd[891]: receiving file list
Aug 24 09:37:51 ffcdb1 rsyncd[891]: sent 25 bytes  received 336 bytes  total size 0
Aug 24 09:37:51 ffcdb1 rsyncd[893]: name lookup failed for 10.0.5.13: Name or service not known
Aug 24 09:37:51 ffcdb1 rsyncd[893]: connect from UNKNOWN (10.0.5.13)
Aug 24 09:37:51 ffcdb1 rsyncd[893]: rsync to rsync_sst-data_dir/ from UNKNOWN (10.0.5.13)
Aug 24 09:37:51 ffcdb1 rsyncd[893]: receiving file list
Aug 24 09:37:52 ffcdb1 kernel: random: crng init done
Aug 24 09:38:09 ffcdb1 rsyncd[893]: sent 44 bytes  received 281087150 bytes  total size 281018368
Aug 24 09:38:09 ffcdb1 rsyncd[964]: name lookup failed for 10.0.5.13: Name or service not known
Aug 24 09:38:09 ffcdb1 rsyncd[964]: connect from UNKNOWN (10.0.5.13)
Aug 24 09:38:09 ffcdb1 rsyncd[964]: rsync to rsync_sst-log_dir/ from UNKNOWN (10.0.5.13)
Aug 24 09:38:09 ffcdb1 rsyncd[964]: receiving file list
Aug 24 09:38:16 ffcdb1 rsyncd[964]: sent 63 bytes  received 100688097 bytes  total size 100663296
Aug 24 09:38:16 ffcdb1 rsyncd[997]: name lookup failed for 10.0.5.13: Name or service not known
Aug 24 09:38:16 ffcdb1 rsyncd[998]: name lookup failed for 10.0.5.13: Name or service not known
Aug 24 09:38:16 ffcdb1 rsyncd[997]: connect from UNKNOWN (10.0.5.13)
Aug 24 09:38:16 ffcdb1 rsyncd[998]: connect from UNKNOWN (10.0.5.13)
Aug 24 09:38:16 ffcdb1 rsyncd[998]: rsync to rsync_sst/./test from UNKNOWN (10.0.5.13)
Aug 24 09:38:16 ffcdb1 rsyncd[997]: rsync to rsync_sst/./designeroutlet_live from UNKNOWN (10.0.5.13)
Aug 24 09:38:16 ffcdb1 rsyncd[998]: receiving file list
Aug 24 09:38:16 ffcdb1 rsyncd[997]: receiving file list
Aug 24 09:38:16 ffcdb1 rsyncd[998]: sent 48 bytes  received 225 bytes  total size 65
Aug 24 09:38:16 ffcdb1 rsyncd[1001]: name lookup failed for 10.0.5.13: Name or service not known
Aug 24 09:38:16 ffcdb1 rsyncd[1001]: connect from UNKNOWN (10.0.5.13)
Aug 24 09:38:16 ffcdb1 rsyncd[1001]: rsync to rsync_sst/./mysql from UNKNOWN (10.0.5.13)
Aug 24 09:38:16 ffcdb1 rsyncd[1001]: receiving file list
Aug 24 09:38:16 ffcdb1 rsyncd[1001]: sent 1739 bytes  received 1228736 bytes  total size 1222390
Aug 24 09:38:16 ffcdb1 rsyncd[1007]: name lookup failed for 10.0.5.13: Name or service not known
Aug 24 09:38:16 ffcdb1 rsyncd[1007]: connect from UNKNOWN (10.0.5.13)
Aug 24 09:38:16 ffcdb1 rsyncd[1007]: rsync to rsync_sst/./performance_schema from UNKNOWN (10.0.5.13)
Aug 24 09:38:17 ffcdb1 rsyncd[1007]: receiving file list
Aug 24 09:38:17 ffcdb1 rsyncd[1007]: sent 48 bytes  received 221 bytes  total size 61
Aug 24 09:38:45 ffcdb1 systemd: Created slice User Slice of root.
Aug 24 09:38:45 ffcdb1 systemd-logind: New session 1 of user root.
Aug 24 09:38:45 ffcdb1 systemd: Started Session 1 of user root.
Aug 24 09:39:14 ffcdb1 systemd: mariadb.service start operation timed out. Terminating.
Aug 24 09:39:14 ffcdb1 mysqld: Terminated
Aug 24 09:39:14 ffcdb1 mysqld: WSREP_SST: [INFO] Joiner cleanup. rsync PID: 859 (20190824 09:39:14.291)
Aug 24 09:39:14 ffcdb1 rsyncd[859]: sent 0 bytes  received 0 bytes  total size 0
Aug 24 09:39:14 ffcdb1 rsyncd[997]: rsync error: received SIGINT, SIGTERM, or SIGHUP (code 20) at io.c(504) [generator=3.1.2]
Aug 24 09:39:14 ffcdb1 rsyncd[997]: rsync error: received SIGINT, SIGTERM, or SIGHUP (code 20) at io.c(504) [receiver=3.1.2]
Aug 24 09:39:14 ffcdb1 mysqld: WSREP_SST: [INFO] Joiner cleanup done. (20190824 09:39:14.824)
Aug 24 09:40:44 ffcdb1 systemd: mariadb.service stop-final-sigterm timed out. Skipping SIGKILL. Entering failed mode.
Aug 24 09:40:44 ffcdb1 systemd: Failed to start MariaDB 10.3.16 database server.
Aug 24 09:40:44 ffcdb1 systemd: Unit mariadb.service entered failed state.
Aug 24 09:40:44 ffcdb1 systemd: mariadb.service failed.
Aug 24 09:40:44 ffcdb1 systemd: Reached target Multi-User System.
Aug 24 09:40:44 ffcdb1 systemd: Starting Update UTMP about System Runlevel Changes...
Aug 24 09:40:44 ffcdb1 systemd: Started Update UTMP about System Runlevel Changes.
Aug 24 09:40:44 ffcdb1 systemd: Startup finished in 579ms (kernel) + 916ms (initrd) + 3min 4.123s (userspace) = 3min 5.618s.
Aug 24 09:41:44 ffcdb1 rsyncd[1000]: rsync: [receiver] write error: Broken pipe (32)
Aug 24 09:41:44 ffcdb1 mysqld: 2019-08-24  9:41:44 0 [ERROR] WSREP: Process completed with error: wsrep_sst_rsync --role 'joiner' --address '10.3.0.26' --datadir '/var/lib/mysql/'   --parent '809'  ''  '': 3 (No such process)
Aug 24 09:41:44 ffcdb1 mysqld: 2019-08-24  9:41:44 0 [ERROR] WSREP: Failed to read uuid:seqno and wsrep_gtid_domain_id from joiner script.
Aug 24 09:41:44 ffcdb1 mysqld: 2019-08-24  9:41:44 0 [ERROR] WSREP: SST failed: 3 (No such process)
Aug 24 09:41:44 ffcdb1 mysqld: 2019-08-24  9:41:44 0 [ERROR] Aborting
Aug 24 09:41:44 ffcdb1 mysqld: 2019-08-24  9:41:44 0 [Warning] WSREP: 1.0 (db3.HOSTNAME.intern): State transfer to 0.0 (ffcdb1.HOSTNAME.de) failed: -255 (Unknown error 255)
Aug 24 09:41:44 ffcdb1 mysqld: 2019-08-24  9:41:44 0 [ERROR] WSREP: gcs/src/gcs_group.cpp:gcs_group_handle_join_msg():737: Will never receive state. Need to abort.

Any idea why?
SELinux is disabled and the required ports are open (tcp and udp, already tested!).
I can not explain that, why is that?
I know, I still have to do the DNS resolution! But that's not the mistake, is it?
Edit:
Maybe also important is the OS Version: I am using Centos7.
When I start the Mariadb Service in ffm2 and check the cluster size, I got the size of 5(which is correct), after the start command crashed, It goes back to 4.
So I think the communication is basically successful, isn't it?
Update 2:
When I remove the galera Stuff and starte the Mariadb service it's working and I also have all data avialible from the Cluster. Very strange...
No idea?

A: Fixed by setting a higher timeout limit for the systemd service. The first start process needs too much time for the first sync.


text:
Q: escaping @ in a string in quotes powershell I am trying run a curl command using powershell as follows:
$command=".\curl.exe -k -X POST --data @login.txt -H ""Content-Type:application/json;charset=utf-8""  https://myserversfqdn:4443/ControlPoint/api/v1/login"
$res= Invoke-Expression $command
It gives me an error saying the splatting operator @ cannot be used to refernce variables in an expression.. so I add the a backtick before @login.txt..
$command=".\curl.exe -k -X POST --data '@login.txt -H ""Content-Type:application/json;charset=utf-8""  https://myserversfqdn:4443/ControlPoint/api/v1/login"
$res= Invoke-Expression $command
Now it gives me an error saying the expression is missing a terminator ' (backtick)..
I am lost as to how to I pass the @ character in this command ?? Any  guidance is really appreciated

A: It looks more like you are using the single quote charac ter ' rather than the backtick:

`

(Note that the backtick is usually on the same key as the ~ character.)
But you are half way to your answer, you could also wrap the whole argument in single quotes to pass it as an unparsed string:
$command=".\curl.exe -k -X POST --data '@login.txt' -H ""Content-Type:application/json;charset=utf-8"" https://myserversfqdn:4443/ControlPoint/api/v1/login"

A: Have you tried simply:
.\curl.exe -k -X POST --data `@login.txt -H "Content-Type:application/json;charset=utf-8" https://myserversfqdn:4443/ControlPoint/api/v1/login

redpajama_set_name: RedPajamaStackExchange


text:
Q: Cassandra: rpc_timeout when inserting in a new table in a cluster I am using Cassandra 2.0.3 and I drop and recreate a simple table via cqlsh by loading a file (source command). In the same file, I insert some rows in the newly created table.
About once every 3-4 tries, I get rpc_timeout on some of the inserts.
When this is the case, I always have this exception on one node of the cluster:
 WARN [Thread-63] 2014-05-07 10:52:39,658 IncomingTcpConnection.java (line 83) UnknownColumnFamilyException reading from socket; closing
org.apache.cassandra.db.UnknownColumnFamilyException: Couldn't find cfId=15a8520e-bb08-3a79-82a0-f735287315bf
    at org.apache.cassandra.db.ColumnFamilySerializer.deserializeCfId(ColumnFamilySerializer.java:178)
    at org.apache.cassandra.db.ColumnFamilySerializer.deserialize(ColumnFamilySerializer.java:103)
    at org.apache.cassandra.db.RowMutation$RowMutationSerializer.deserializeOneCf(RowMutation.java:304)
    at org.apache.cassandra.db.RowMutation$RowMutationSerializer.deserialize(RowMutation.java:284)
    at org.apache.cassandra.db.RowMutation$RowMutationSerializer.deserialize(RowMutation.java:312)
    at org.apache.cassandra.db.RowMutation$RowMutationSerializer.deserialize(RowMutation.java:254)
    at org.apache.cassandra.net.MessageIn.read(MessageIn.java:99)
    at org.apache.cassandra.net.IncomingTcpConnection.receiveMessage(IncomingTcpConnection.java:153)
    at org.apache.cassandra.net.IncomingTcpConnection.handleModernVersion(IncomingTcpConnection.java:130)
    at org.apache.cassandra.net.IncomingTcpConnection.run(IncomingTcpConnection.java:74)

Even if I do the INSERT direcly in cqlsh, it fails also with rpc_timeout. Usually after about one minute, the insert is successful.
My nodes are time synchronized (I use 3 VMs on my PC) and the LAN is of course super fast on all VMs are running locally.
I created the cluster by adding 2 nodes to an existing Cassandra running on a single node.
My keyspace is not using replication:
CREATE KEYSPACE eras
  WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };

Here is the content of the file I use to reproduce the problem:
DROP TABLE IF EXISTS erasconfig;

CREATE TABLE erasconfig (
  name text,
  category text,
  description text,
  ismodifiablebyuser int,
  value text,
  format text,
  PRIMARY KEY (name, category)
);

INSERT INTO ErasConfig (isModifiableByUser, format, name, value, category, description) VALUES (1, '', 'RECORD_IN_BASE', 'garbage', 'Path', 'Absolute path used for RECORD INPUT files');

This INSERT goes into the 3rd node of the cluster which is the one failing sometimes during table creation with the exception above.

A: The issue is that schema replication is asynchronous to the create finishing.  So in a multinode cluster you need to verify that the schema changes have propagated to all the nodes before you try to use them.  The nodetool describecluster can be used to check if the schemas agree.  From a client you can check the system.peers table to verify that all the schema versions have updated.


text:
Q: how could i change the JSON structure..? the Response which i get from Back-end is below structure JSON.
[
{
"carrier": "Emirates",
"stops": "stops-0",
"date": "Jul 18",
"min": 1407,
"avg": 1407,
"max": 1407
},
  {
"carrier": "Ethiopian Airlines",
"stops": "stops-1",
"date": "Jul 19",
"min": 5151,
"avg": 5151,
"max": 5151
}
]

Need to change the structure as below
[
{
"carrier": "Emirates",
"stops": "stops-0",
"date": "Jul 18",
"min": 1407,
},
{
"carrier": "Emirates",
"stops": "stops-0",
"date": "Jul 18",
"avg": 1407,
},
{
"carrier": "Emirates",
"stops": "stops-0",
"date": "Jul 18",
"max": 1407
},
  {
"carrier": "Ethiopian Airlines",
"stops": "stops-1",
"date": "Jul 19",
"min": 5151,
},
 {
"carrier": "Ethiopian Airlines",
"stops": "stops-1",
"date": "Jul 19",
"avg": 5151,
},
 {
"carrier": "Ethiopian Airlines",
"stops": "stops-1",
"date": "Jul 19",
"max": 5151
}
]

the data which i need to convert as range, the ranges are min,avg,max .. is that possible to convert the data in javascript..?

A: There are of course many ways to do this, but I'll show you one:
You can replace each entry by three individual ones, flattening the array in the process.
function convert (arr) {
  return arr.flatMap(({ min, avg, max, ...commonFields }) => [
    { ...commonFields, min },
    { ...commonFields, avg },
    { ...commonFields, max }
  ])
}

The Array.prototype.flatMap function is like a combination of Array.prototype.map (with which you can map each element of an array to a newly calculated one, getting a new array with all elements mapped at the end) and Array.prototype.flat (to "flatten" nested arrays, i.e. turning [[a, b, c], [d, e, f]] into [a, b, c, d, e, f]).
We are hereby replacing each element with three elements, having the properties that you want. The ...commonFields syntax allows us to pass around all the remaining fields (carrier, stops, date in your case) as one object instead of listing them individually.
(Thanks to commenter adiga - I had a solution with map and flat and forgot that flatMap exists.)


text:
Q: Initializing global objects as a pointer is the only way that succeeds In a JNI .cpp file I have a struct with a SoundTouch* (SoundTouch is a C++ audio processing that I am wrapping for use in an Android project) and I initialize a vector of the structs as global objects like this:
struct SoundTouchExt
{
    SoundTouch* sTouch;
    queue<signed char>* fBufferOut;
    int channels;
    int sampleRate;
    float tempoChange;
    int pitchSemi;
    int bytesPerSample;

    SoundTouchExt()
    {
        sTouch = new SoundTouch();
        fBufferOut = new queue<signed char>();
    }
};

const int MAX_TRACKS = 16;

vector<SoundTouchExt> sProcessors(MAX_TRACKS);

This works, at least if I only use one of the SoundTouchExt objects at a time in my program (that's sort of a different story, but possibly related - with multiple instances in play causes distorted output).
However, if I declare it like this SoundTouch sTouch;, comment out the new and change the use of it accordingly ( -> to .), pointers to references, I compile fine but I get a FAULT 11 (seg fault) as soon as the program trys to use the object.
Here's where that happens:
...
    SoundTouchExt& soundTouch = sProcessors.at(track);
    setup(soundTouch, channels, samplingRate, bytesPerSample, tempo, pitchSemi);
}

static void setup(SoundTouchExt& soundTouch, int channels, int sampleRate, int bytesPerSample, float tempoChange, float pitchSemi)
{
    SoundTouch& sTouch = soundTouch.sTouch;

    soundTouch.channels = channels;
    soundTouch.sampleRate = sampleRate;
    soundTouch.bytesPerSample = bytesPerSample;
    soundTouch.tempoChange = tempoChange;
    soundTouch.pitchSemi = pitchSemi;

    sTouch.setSampleRate(sampleRate);
    sTouch.setChannels(channels);
...
}

With a little research, I'm thinking this could be an instance of the static intialization order fiasco. I don't see any global variables in the library source code, but I don't know enough about C++ to know what else to look for.
What can my observation suggest about the library (or maybe I'm not doing something correctly)?

A: I believe your SoundTouch struct/class has an issue in its copy constructor and/or assignment operator. Or you haven't even written those but need to.
Why do I say this when I can't even see the code for SoundTouch? Well...
Your SoundTouchExt has problems with how it manages its sTouch member (and fBufferOut as well). Each instance creates its own sTouch, but you don't have a copy constructor or assignment operator to deal with sTouch members whenever your objects get copied. The defaults provided by the compiler will simply do a shallow member-wise copy. So if one SoundTouchExt object ever gets assigned to another, then they will both end up with sTouch pointers pointering to the same SoundTouch. I doubt you ever intended for that to happen. However since you also don't have a destructor to clean up those allocations, you might get away with this situation for a while (since leaking memory would be easy to overlook).
And it looks like you are indeed get happening to get away with it while using vector<SoundTouchExt>. A vector manages an internal array. When you add entries to a vector, it may sometimes run out of room in its current array and thus need to create a new array to hold the additional entry. In doing so, it has to copy all the entries from the old array to the new one. So that uses the copy constructor and/or assignment operator of SoundTouchExt. You don't notice this because the situation of two SoundTouchExt instances using the same SoundTouch only exists briefly before the one in the old array gets destroyed. And because SoundTouchExt lacks a destructor, there's nothing to cause a problem.
Now consider how things change when the sTouch member is an actual SoundTouch instance rather than a pointer. In that case, when a SoundTouchExt object is copied and thus the sTouch member is copied, that means the compiler will use the SoundTouch copy constructor / assignment operator. And we know your vector can cause that to happen.
Since your SoundTouchExt has the issues I've described with copying, I suspect your SoundTouch also has issues. If that is the case, then by the time you get around to trying to use an sTouch member, it has presumably already been copied and thus caused some kind of problem. That problem then leads to your crash.
So to fix things, you have a few options:

*

*Make sure all the relevant objects act correctly when being copied. This probably means implementing copy constructors and assignment operators. And in that case you most likely should implement a destructor, as per the Rule of Three.

*Or disable their copy constructors and assignment operators (declare them as private but don't implement) so they can't accidentally be used. That then might require some other refactoring, such as your vector usage. Although if you have C++11 features available, you might be able to make use of move operators/constructors so that your objects can work in standard containers like they do now but properly transfer their members when appropriate. A destructor is probably still necessary either way.

*Or replace those raw pointers with certain kinds of smart pointers (like unique_ptr) which can automatically manage anything allocated with new without you having to write any additional code.


text:
Q: How to understand this formula in quantum field theory? In Condensed Matter Field Theory (page 288) by Altland and Simons, there is one mathematical formula:
\begin{equation}
\sum_\mathbf{p} \left(\mathbf{p}\boldsymbol{\cdot}\mathbf{v}\right)\left(\mathbf{p}\boldsymbol{\cdot}\mathbf{v}'\right)F\left(\mathbf{p}^2\right)\boldsymbol{=}\dfrac{\mathbf{v}\boldsymbol{\cdot}\mathbf{v}'}{d}\sum_\mathbf{p}\:\mathbf{p}^2F\left(\mathbf{p}^2\right)
\tag{01}\label{01}
\end{equation}
Here, $\mathbf{p}$ is the momentum, and $\mathbf{v}$ and $\mathbf{v}'$ are vectors. $F\left(\mathbf{p}^2\right)$ is a function of momentum which is invariant under rotational transformations; $d$ is the dimension considered (e.g., $d=3$ in $x,y,z$ coordinate system).
My question is how to arrive at this formula?
Mathematically, this formula seems not correct. For example, imagine a summation over only $\mathbf{p}\boldsymbol{=}\mathbf{p}_0$ and imagine $\mathbf{v}$ and $\mathbf{v}'$ being orthogonal: then the left hand side is $\left(\mathbf{p}_0\boldsymbol{\cdot}\mathbf{v}\right)\left(\mathbf{p}_0\boldsymbol{\cdot}\mathbf{v}'\right)F\left(\mathbf{p}_0^2\right)$ which can be non zero, while the right hand side is zero because $\left(\mathbf{v}\boldsymbol{\cdot}\mathbf{v}'\right)\boldsymbol{=}0$. I am wondering if there are some arguments in physics to "prove" this formula. For example, if the summation is replaced by an integration over the whole reciprocal space of momentum p with d dimension, will the formula stand?

A: The formula holds, because there is a sum over all ${\bf p}$.  After that sum is performed, ${\bf v}\cdot{\bf v}'$ is essentially the only vector structure that is consistent with rotation symmetry.
To prove the formula, first rewrite it so that the ${\bf v}$ and ${\bf v}$' are outside the sum:
$$\sum_{{\bf p}}({\bf p}\cdot{\bf v})({\bf p}\cdot{\bf v}')F(p^{2})=
\sum_{j=1}^{d}v_{j}\sum_{j=1}^{d}v_{k}'\sum_{{\bf p}}p_{j}p_{k}F(p^{2}).$$
Now look just at the final sum, $\sum_{{\bf p}}p_{j}p_{k}F(p^{2})$. Consider holding the index $j$ fixed (say $j=1$) and varying $k$. If $k\neq j$ (say $j=2$) then for every term
in the sum with ${\bf p}=(p_{j},p_{k},p_{3})$, there is another term in the sum with ${\bf p}'=(p_{j},-p_{k},p_{3})$. Since the sum terms $p_{j}p_{k}F(p^{2})$ and $p_{j}'p_{k}'F(p'^{2})$ are equal in magnitude but opposite in sign, they will cancel; and, if fact, every term in the sum will be canceled by a similar one with an inverted $p_{k}\rightarrow p_{k}'=-p_{k}$. Thus, the sum is $\sum_{{\bf p}}p_{j}p_{k}F(p^{2})=0$ if $j\neq k$.
The expression $\sum_{{\bf p}}p_{j}p_{k}F(p^{2})$ transforms like a two-index tensor.  (Any product of the components of two vectors ${\bf u}$ and ${\bf w}$ along with a scalar $\phi$—that is, $u_{j}w_{k}\phi$—transforms this way. The sum of interest is then just a sum of tensors that transform this way and so transforms this way itself.) The only two-tensor that has components that are nonzero only for $j=k$ is one that is proportional to the identity, with components $\delta_{jk}$.  [This is essentially just a long-winded way of saying that, since there is no preferred direction, $\sum_{{\bf p}}p_{1}p_{1}F(p^{2})
=\sum_{{\bf p}}p_{2}p_{2}F(p^{2})=\sum_{{\bf p}}p_{3}p_{3}F(p^{2})$.]  So we must have
$\sum_{{\bf p}}p_{j}p_{k}F(p^{2})$ be a scalar function times $\delta_{jk}$,
$$\sum_{{\bf p}}p_{j}p_{k}F(p^{2})=\delta_{jk}G,$$
which leaves us to find $G$.
To get the scalar $G$, we contract the tensor with another $\delta_{jk}$, or
$$\sum_{j=1}^{d}\sum_{k=1}^{d}\delta_{jk}\sum_{{\bf p}}p_{j}p_{k}F(p^{2})=\sum_{j=1}^{d}\sum_{k=1}^{d}\delta_{jk}\delta_{jk}G,$$
which reduces to
$$\sum_{{\bf p}}p^{2}F(p^{2})=dG,$$
since $\sum_{j=1}^{d}\sum_{k=1}^{d}\delta_{jk}\delta_{jk}$ is just the dimensionality of space $d$.
Then it is just a matter of inserting this expression into the earlier ones and working backwards. Solving for $G$, we have
$$\sum_{{\bf p}}p_{j}p_{k}F(p^{2})=\delta_{jk}G=\delta_{jk}\frac{1}{d}\sum_{{\bf p}}p^{2}F(p^{2}).$$  Then inserting this into the original expression with $v_{j}$ and $v_{k}'$ gives
$$\sum_{j=1}^{d}v_{j}\sum_{j=1}^{d}v_{k}'\sum_{{\bf p}}p_{j}p_{k}F(p^{2})=
\sum_{j=1}^{d}v_{j}\sum_{j=1}^{d}v_{k}'\delta_{jk}\frac{1}{d}\sum_{{\bf p}}p^{2}F(p^{2}),$$
and collecting this in component-free form gives the final expression
$$\sum_{{\bf p}}({\bf p}\cdot{\bf v})({\bf p}\cdot{\bf v}')F(p^{2})=\frac{1}{d}{\bf v}\cdot{\bf v}'\sum_{{\bf p}}p^{2}F(p^{2}).$$


text:
Q: How do I switch to the another Tab Screen? I want to switch to a another Screen, when i tap to the other icon on the tab bar but it does not work. I am always in HomeScreen() and I can´t switch to the HomeScreenMapView(). I think i have an issue at the return by the ListView.builder but i don´t know how i continue.
My Code:
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import '../screens/home_screen.dart';
import '../screens/home_screen_map_view.dart';

class TabBarTop extends StatefulWidget {
  @override
  _TabBarTopState createState() => _TabBarTopState();
}

class _TabBarTopState extends State<TabBarTop> with SingleTickerProviderStateMixin {
  bool _isAppbar = true;
      ScrollController _scrollController = new ScrollController();

      @override
      void initState() {
        super.initState();
        _scrollController.addListener(() {
          if (_scrollController.position.userScrollDirection ==
              ScrollDirection.reverse) {
            appBarStatus(false);
          }
          if (_scrollController.position.userScrollDirection ==
              ScrollDirection.forward) {
            appBarStatus(true);
          }
        });
      }

      void appBarStatus(bool status) {
        setState(() {
          _isAppbar = status;
        });
      }

      @override
      Widget build(BuildContext context) {
        return SafeArea(
          child: Scaffold(
            appBar: PreferredSize(
              preferredSize: Size.fromHeight(MediaQuery.of(context).size.height * 0.12),
              child: AnimatedContainer(
                height: _isAppbar ? MediaQuery.of(context).size.height * 1 : 0.0,
                duration: Duration(milliseconds: 200),
                child: CustomAppBar(),
              ),
            ),
            body: ListView.builder(
              controller: _scrollController,
              itemCount: 100,
              itemBuilder: (BuildContext context, int index) {
                return HomeScreen();
              },
            ),
          ),
        );
      }
    }

    class CustomAppBar extends StatefulWidget {
      @override
      AppBarView createState() => new AppBarView();
    }

    class AppBarView extends State<CustomAppBar> {
      @override
      Widget build(BuildContext context) {
        return DefaultTabController(
      length: 2,
      child: NestedScrollView(
        headerSliverBuilder: (context, value) {
          return [
            SliverAppBar(
              title: Center(
                heightFactor: 0,
                child: Padding(
                  padding: const EdgeInsets.only(top: 7),
                  child: Image.asset(
                    'assets/images/***.png',
                    fit: BoxFit.cover,
                    scale: MediaQuery.of(context).size.width * 0.007,
                    alignment: Alignment.bottomCenter,
                  ),
                ),
              ),
              expandedHeight: MediaQuery.of(context).size.height * 0.12,
              primary: true,
              floating: true,
              pinned: true,
              bottom: TabBar(
                indicatorColor: Color.fromRGBO(253, 166, 41, 1.0),
                tabs: <Widget>[
                  Tab(
                    icon: Icon(Icons.list),
                  ),
                  Tab(
                    icon: Icon(Icons.location_on),
                  ),
                ],
              ),
              forceElevated: false,
              flexibleSpace: Container(
                decoration: BoxDecoration(
                  gradient: LinearGradient(
                    begin: Alignment.topCenter,
                    end: Alignment.bottomCenter,
                    colors: <Color>[
                      Color.fromRGBO(107, 176, 62, 1.0),
                      Color.fromRGBO(153, 199, 58, 1.0),
                    ],
                  ),
                ),
              ),
            )
          ];
        },
        body: TabBarView(
          children: <Widget>[
            HomeScreen(),
            HomeScreenMapView(),
          ],
        ),
      ),
    );
      }
    }

Thanks :)

A: I think you don't need TabBarTop class to achieve so, you can only go with CustomAppBar class which provide that facility.
I don't know how much i currently understand your question and need but i am answering it.
Hope following code help you.
Directly call TabBarTop from your main.
   class TabBarTop extends StatefulWidget {
  @override
  _TabBarTopState createState() => _TabBarTopState();
}

class _TabBarTopState extends State<TabBarTop>
    with SingleTickerProviderStateMixin {
  @override
  Widget build(BuildContext context) {
    return SafeArea(
      child: Scaffold(
        body: DefaultTabController(
          length: 2,
          child: NestedScrollView(
            headerSliverBuilder:
                (BuildContext context, bool innerBoxIsScrolled) {
              return <Widget>[
                SliverAppBar(
                  expandedHeight: 50.0,
                  floating: true,
                  snap: true,
                  flexibleSpace: FlexibleSpaceBar(
                      centerTitle: true,
                      title: Text("Collapsing Toolbar",
                          style: TextStyle(
                            color: Colors.white,
                            fontSize: 16.0,
                          )),
                      background: Image.network(
                        "https://images.pexels.com/photos/396547/pexels-photo-396547.jpeg?auto=compress&cs=tinysrgb&h=350",
                        fit: BoxFit.cover,
                      )),
                ),
                SliverPersistentHeader(
                  delegate: _SliverAppBarDelegate(
                    TabBar(
                      labelColor: Colors.black87,
                      unselectedLabelColor: Colors.grey,
                      tabs: [
                        Tab(icon: Icon(Icons.info), text: "Tab 1"),
                        Tab(icon: Icon(Icons.lightbulb_outline), text: "Tab 2"),
                      ],
                    ),
                  ),
                  pinned: true,
                ),
              ];
            },
            body: TabBarView(
              children: <Widget>[
                HomeScreen(),
                Container(
                  child: Center(child: Text("cds2")),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}

class HomeScreen extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Container(
      child: ListView.builder(
        itemExtent: 150,
        itemCount: 10,
        itemBuilder: (_, index) {
          return Text("csca $index");
        },
      ),
    );
  }
}

class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate {
  _SliverAppBarDelegate(this._tabBar);

  final TabBar _tabBar;

  @override
  double get minExtent => _tabBar.preferredSize.height;
  @override
  double get maxExtent => _tabBar.preferredSize.height;

  @override
  Widget build(
      BuildContext context, double shrinkOffset, bool overlapsContent) {
    return new Container(
      color: Colors.white,
      child: _tabBar,
    );
  }

  @override
  bool shouldRebuild(_SliverAppBarDelegate oldDelegate) {
    return false;
  }
}


text:
Q: Reporte con rotativa no funciona en publicación con Azure Tengo mi proyecto .net framework publicado en Azure. Estoy utilizando Rotativa para generar un reporte y descargarlo en pdf. Esto funciona de forma local pero al publicarlo no lo descarga, queda cargando hasta que muestra error por exceso de tiempo. También me muestra un error en Visual Studio al realizar la publicación, pero no me especifica cual es el error.
Supongo que es un problema de permisos de Azure, pero no sé como solucionarlo. Alguna idea?
Método en el controlador:
public ActionResult ImprimirReporte(string nomProductor, string nomCultivo)
    {
        ViewBag.pdf = true;
        return new ViewAsPdf("ResultadoFiltros", repoCultProd.PorFiltros(nomProductor, nomCultivo))
        {
            PageSize = Rotativa.Options.Size.A4,
            FileName = "Reporte Cultivos Por Productor.pdf"
        };
    }

Error en Visual al publicar:

Pero en la salida no muestra ningún error:

Error en el navegador al intentar descargar el pdf:


text:
Q: Unir tablas SQL a partir de códigos distintos según los últimos dígitos del id Necesito obtener los datos de una tabla, a partir de otra, pero la clave en común no tiene el mismo código, son distintos, ejemplo:
Tengo en una tabla FACULTAD:
facu_codigo    facu_nombre
1              VICERRECTORIA
2              FACULTAD CS SOCIALES
3               .
4               .
.               .
.               .
10              .

y otra tabla UNIDADES ACADÉMICAS:
uaca_codigo

10

2001
2002
2003
.
.
2010

Entonces necesito obtener nombre_facu a partir de la unión entre facu_codigo y uaca_codigo, donde los últimos 2 dígitos de uaca_codigo da referencia al facu_codigo y de esa manera podría hacer la relación.
¿Cómo puedo hacer para que uaca_codigo se convierta en los últimos dígitos para igualarlo a facu_codigo y que me dé el nombre?
Ejemplo:
2001 ---->  1
2005 ---->  5
2010 ----> 10

A: Así de pronto se me ocurre que le restes 2000 al código de uaca_codigo, por ejemplo:
 SELECT * FROM FACULTAD F
 INNER JOIN UNIDADES_ACADEMICAS U ON F.FACU_CODIGO = (U.UACA_CODIGO -2000);

A: SELECT [uaca_codigo], CONVERT(INT, RIGHT([uaca_codigo], 2))
FROM [dbo].[UNIDADES ACADEMICAS]

Así cortarías por la derecha 2 caracteres y convertido en numérico para quitar el 0 de su izquierda.
Un saludo


text:
Q: google maps toggle layer starting off http://deepfrogphoto.com/Brett-Pelletier-Photography/Links/maps/wasatch/index07.html
My page above is working fine, but I would really like it if the black and white map kml layer would start as being off forcing the user to toggle it on.  I have a lot going on with this map and I'm pretty lost with all the code.  If you go to my site and click the layer button the first option is the BW MAP toggle.  I just want the page to load with the BW MAP kml layer off.  I've tried several of the options I found on this site, but still just trial and error with no luck.... I think this is most of the code you might need to help...
EDIT - it might be easier to 'not accept' the geolocation so you can see what is going on where I'm at. the map will load in the area without it enabled....
var map, GeoMarker;

function HomeControl(controlDiv, map) {
controlDiv.style.padding = '5px';
var controlUI = document.createElement('div');
controlUI.style.backgroundColor = 'white';
controlUI.style.borderStyle = 'solid';
controlUI.style.borderWidth = '1px';
controlUI.style.cursor = 'pointer';
controlUI.style.textAlign = 'center';
controlUI.title = 'Click to set the map to GPS Center';
controlDiv.appendChild(controlUI);
var controlText = document.createElement('div');
controlText.style.fontFamily = 'Arial,sans-serif';
controlText.style.fontSize = '11px';
controlText.style.paddingLeft = '4px';
controlText.style.paddingRight = '4px';
controlText.innerHTML = 'Home';
controlUI.appendChild(controlText);

google.maps.event.addDomListener(controlUI, 'click', function() {
recenterMapOnGeoLoc()
});
}

function toggleLayer(this_layer) {
if (this_layer.getMap()) {
this_layer.setMap(null)
} else {
this_layer.setMap(map);
}
}

function recenterMapOnGeoLoc() {
map.setCenter(GeoMarker.getPosition());
}

function initialize() {
var mapDiv = document.getElementById('map_canvas');
var mapOptions = {
zoom: 20,
center: new google.maps.LatLng(40.563855, -111.675426),
mapTypeId: google.maps.MapTypeId.TERRAIN
};

map = new google.maps.Map(mapDiv, mapOptions);

GeoMarker = new GeolocationMarker();
GeoMarker.setCircleOptions({
fillColor: '#EBF4FA'
});

google.maps.event.addListenerOnce(GeoMarker, 'position_changed', function() {
map.setCenter(this.getPosition());
map.fitBounds(this.getBounds());
});

google.maps.event.addListener(GeoMarker, 'geolocation_error', function(e) {
alert('There was an error obtaining your position. Message: ' + e.message);
});

GeoMarker.setMap(map);

trafficLayer = new google.maps.TrafficLayer();
trafficLayer.setMap(map);

layer1 = new google.maps.FusionTablesLayer({
map: map,
heatmap: {
enabled: false
},
query: {
select: "skilines",
from: "1R5pCEyNN74N8Dt9MkfNXA6A9D1HbQESzOR1fYFa7",
 where: ""
 },
options: {
styleId: 2,
templateId: 2
}
});

layer2 = new google.maps.FusionTablesLayer({
map: map,
heatmap: {
enabled: false
},
query: {
from: "19iu58FDFcBIZZ-wU1iZcf89AI5ABDJ7YTv355su5",
where: ""
},
options: {
styleId: 2,
templateId: 2
}
});

layer3 = new google.maps.FusionTablesLayer({
map: map,
heatmap: {
enabled: false
},
query: {
select: "summerhiking",
from: "1t1XNnG7J7Zu1p5mIUpm6qIGVYwzhkCgPy_je0IKr",
where: ""
},
options: {
styleId: 2,
templateId: 2
}
});

layer5 = new google.maps.KmlLayer('http://deepfrogphoto.com/Brett-Pelletier-            Photography/Links/maps/kml/topobwkml.kml',
              {
                  suppressInfoWindows: true,
                  map: map,
                  preserveViewport: true
              });

                                // Create the DIV to hold the control and
  // call the HomeControl() constructor passing
  // in this DIV.
  var homeControlDiv = document.createElement('div');
  var homeControl = new HomeControl(homeControlDiv, map);

  homeControlDiv.index = 1;
  map.controls[google.maps.ControlPosition.TOP_RIGHT].push(homeControlDiv);

}

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

if (!navigator.geolocation) {
alert('Your browser does not support geolocation');
}

  //////////////And the menu code is....

<input checked="checked" id="show_hide_layer5" onchange="toggleLayer(layer5)"      type="checkbox" value="ON" /> B+W Map

<input checked="checked" id="show_hide_layer1" onchange="toggleLayer(layer1)"   type="checkbox" value="ON" /> Backcountry Ski Lines

<input checked="checked" id="show_hide_layer2" onchange="toggleLayer(layer2)" type="checkbox" value="ON" /> Resort Lifts

<input checked="checked" id="show_hide_layer3" onchange="toggleLayer(layer3)" type="checkbox" value="ON" /> Summer Trails

<input checked="checked" id="show_hide_layer4" onchange="toggleLayer(layer4)" type="checkbox" value="ON" /> Snow Stations

<input checked="checked" id="show_hide_layer4" onchange="toggleLayer(trafficLayer)" type="checkbox" value="ON" /> Traffic
"

A: If you don't want your layers displayed when you create them, don't add them to the map (remove the {map: map} property (and don't set the checkboxes to "checked").

var map, GeoMarker, layer1, layer2, layer3, layer4, layer5;

function HomeControl(controlDiv, map) {
  controlDiv.style.padding = '5px';
  var controlUI = document.createElement('div');
  controlUI.style.backgroundColor = 'white';
  controlUI.style.borderStyle = 'solid';
  controlUI.style.borderWidth = '1px';
  controlUI.style.cursor = 'pointer';
  controlUI.style.textAlign = 'center';
  controlUI.title = 'Click to set the map to GPS Center';
  controlDiv.appendChild(controlUI);
  var controlText = document.createElement('div');
  controlText.style.fontFamily = 'Arial,sans-serif';
  controlText.style.fontSize = '11px';
  controlText.style.paddingLeft = '4px';
  controlText.style.paddingRight = '4px';
  controlText.innerHTML = 'Home';
  controlUI.appendChild(controlText);

  google.maps.event.addDomListener(controlUI, 'click', function() {
    recenterMapOnGeoLoc()
  });
}

function toggleLayer(this_layer) {
  if (this_layer.getMap()) {
    this_layer.setMap(null)
  } else {
    this_layer.setMap(map);
  }
}

function recenterMapOnGeoLoc() {
  map.setCenter(GeoMarker.getPosition());
}

function initialize() {
  var mapDiv = document.getElementById('map_canvas');
  var mapOptions = {
    zoom: 20,
    center: new google.maps.LatLng(40.563855, -111.675426),
    mapTypeId: google.maps.MapTypeId.TERRAIN
  };

  map = new google.maps.Map(mapDiv, mapOptions);

  GeoMarker = new GeolocationMarker();
  GeoMarker.setCircleOptions({
    fillColor: '#EBF4FA'
  });

  google.maps.event.addListenerOnce(GeoMarker, 'position_changed', function() {
    map.setCenter(this.getPosition());
    map.fitBounds(this.getBounds());
  });

  google.maps.event.addListener(GeoMarker, 'geolocation_error', function(e) {
    alert('There was an error obtaining your position. Message: ' + e.message);
  });

  GeoMarker.setMap(map);

  trafficLayer = new google.maps.TrafficLayer();
//  trafficLayer.setMap(map);

  layer1 = new google.maps.FusionTablesLayer({
//    map: map,
    heatmap: {
      enabled: false
    },
    query: {
      select: "skilines",
      from: "1R5pCEyNN74N8Dt9MkfNXA6A9D1HbQESzOR1fYFa7",
      where: ""
    },
    options: {
      styleId: 2,
      templateId: 2
    }
  });

  layer2 = new google.maps.FusionTablesLayer({
//    map: map,
    heatmap: {
      enabled: false
    },
    query: {
      from: "19iu58FDFcBIZZ-wU1iZcf89AI5ABDJ7YTv355su5",
      where: ""
    },
    options: {
      styleId: 2,
      templateId: 2
    }
  });

  layer3 = new google.maps.FusionTablesLayer({
//    map: map,
    heatmap: {
      enabled: false
    },
    query: {
      select: "summerhiking",
      from: "1t1XNnG7J7Zu1p5mIUpm6qIGVYwzhkCgPy_je0IKr",
      where: ""
    },
    options: {
      styleId: 2,
      templateId: 2
    }
  });

  layer5 = new google.maps.KmlLayer('http://deepfrogphoto.com/Brett-Pelletier-            Photography/Links/maps/kml/topobwkml.kml', {
    suppressInfoWindows: true,
//    map: map,
    preserveViewport: true
  });

  // Create the DIV to hold the control and
  // call the HomeControl() constructor passing
  // in this DIV.
  var homeControlDiv = document.createElement('div');
  var homeControl = new HomeControl(homeControlDiv, map);

  homeControlDiv.index = 1;
  map.controls[google.maps.ControlPosition.TOP_RIGHT].push(homeControlDiv);

}

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

if (!navigator.geolocation) {
  alert('Your browser does not support geolocation');
}

    <input id="show_hide_layer5" onchange="toggleLayer(layer5)" type="checkbox" value="ON" />B+W Map

    <input id="show_hide_layer1" onchange="toggleLayer(layer1)" type="checkbox" value="ON" />Backcountry Ski Lines

    <input id="show_hide_layer2" onchange="toggleLayer(layer2)" type="checkbox" value="ON" />Resort Lifts

    <input id="show_hide_layer3" onchange="toggleLayer(layer3)" type="checkbox" value="ON" />Summer Trails

    <input id="show_hide_layer4" onchange="toggleLayer(layer4)" type="checkbox" value="ON" />Snow Stations

    <input id="show_hide_layer4" onchange="toggleLayer(trafficLayer)" type="checkbox" value="ON" />Traffic


text:
Q: Prevent CEDET semantic from parsing certain file types I have to work with a C/C++ build environment that drops intermediate files all over the place:

*

*.i files containing the output of the C-preprocessor (roughly raw C)

*.s files containing the input of the C-assembler

CEDET (I assume the semantic analyzer) eventually finds these files and attempts to index them.  This results in jumping to .i files containing raw C for definitions and generally slowing down parsing and loading of the .semanticdb.
I never open these files in emacs, so they must be being loaded by the background analyser.
Is it possible to prevent the analyser from loading these files?  I can't find any configuration options that define the file-types that are parsed by the background analyser.

A: If you never need C mode for these files, here's a quick fix:
(add-to-list 'auto-mode-alist '("\\.i\\'" . fundamental-mode))
(add-to-list 'auto-mode-alist '("\\.s\\'" . fundamental-mode))

A: The answer from abo-abo gave me the clues I needed. The grep implementation (used by EDE) of semantic-symref-perform-search uses auto-mode-alist to find matching files for a given semantic mode (based on the current buffer's mode - eg `c-mode) when trying to resolve symbols.
The final fix I used is to specifically eliminate the default entries in the auto-mode-alist using:

(delete '("\\.i\\'" . c-mode) auto-mode-alist)
(delete '("\\.ii\\'" . c++-mode) auto-mode-alist)

Adding fundamental-mode entries as suggested by abo-abo seems to work also, however I was concerned that since the c-mode entries were still in the list a change in implementation could result in them being reactivated.


text:
Q: plotting missing values with nan I have a plot which looks like this
hours = [0 1 2 3 4 5 6 12 13 14 15];
y = [0 1 2 nan 3 4 5 6 7 8 9];
figure(1)
plot(hours, y, '-o');

As you can see, the x axis jumps from 6 to 12. Instead of having a straight line connecting these points, I would like to have a gap:
hours = [0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15];
y = [0 1 2 nan 3 4 5 nan nan nan nan nan 6 7 8 9];
figure(2)
plot(hours, y, '-o');

Can this be done in an elegant way without having to manually insert the nans and the new 'hours' values?

A: Try this -
hours_new = min(hours):max(hours)
nan_ind = ~ismember(hours_new,hours)
y_new(~nan_ind) = y
y_new(nan_ind) = NaN

Then, plot like this -
figure(2)
plot(hours_new, y_new, '-o');


text:
Q: Raspberry Pi DHT 11 sensor not working. I get None None Have integrated Raspberry pi4 with a DHT sensor.
The data pin is connected to pin GPIO 26
Have tried connecting the VCC to both 3.3V and 5V
Have tried with both Adafruit_DHT.DHT11 and Adafruit_DHT.DHT22 in the code for the same sensor but I get  None None
import Adafruit_DHT

# Sensor should be set to Adafruit_DHT.DHT11,
# Adafruit_DHT.DHT22, or Adafruit_DHT.AM2302.
sensor = Adafruit_DHT.DHT22
pin = 26

while True:
    humidity, temperature = Adafruit_DHT.read_retry(sensor, pin)
    print(temperature, humidity)

Output:
None None
Is the sensor broken??Should I replace it or is there any other solution??

A: from pigpio_dht import DHT11, DHT22

gpio = 4 # BCM Numbering

sensor = DHT11(gpio)
#sensor = DHT22(gpio)

result = sensor.read()
print(result)

This worked for me. Before running the code enter the below commands on the terminal
sudo pigpiod #Start daemon

pigs pud 4 u # Set internal pull up

If pigpio-dht is not installed enter pip3 install pigpio-dht and run the above program

A: After 3 days with the same issue and trying all of the above (even bought a new DHT11), the issue with just with the GPIO's. I manually had to "push" the pin GPIO-4 to make it contact with the recevier end of the DHT11 cable.
my code was simpler version:
import Adafruit_DHT
import sys

while True:
 humidity, temperature = Adafruit_DHT.read_retry(11,4)
 print(temperature, humidity)


text:
Q: Reloading agnularjs app htaccess issue I'm trying to set .htaccess file so after reload it will first load index.html and then change route so my routing will notice it.
I added
$locationProvider.html5Mode(true);

to angularjs .config
and my htaccess is:
RewriteEngine On
Options FollowSymLinks

RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /#/$1 [L]

the bahoviour is that my spa when I load index.html is working correctly but then when I navigate to some route and press refresh it say:

Cannot GET /mailbox

What's wrong with my htaccess file? It's in root directory of project.
I'm running my project by live-server.


text:
Q: Adding 2 years to the Current Date in Javascript If the software I am using asks for a javascript entry for an action, do I need to enter the entire javascript (function, brackets, etc.,) or just the syntax for what I'm trying to do?
I want to display the current date, except +2 years from "today's" date. Any Snippets I add don't seem to work (mostly, they return a "0")

A: Make use of getFullYear(), getMonth() and getDate() and then you can modify those values accordingly and create a new Date with those modified value:

function modifyDate(addYears){
  var date = new Date();
  var year = date.getFullYear();
  var month = date.getMonth();
  var day = date.getDate();
  var res = new Date(year + addYears, month, day)
  return res;
}

var addYears = 2
var res = modifyDate(addYears);
console.log(res);


text:
Q: create a report in mysql and store it in a log file, using triggers, and then analyze the log I need to create a report on a monthly or daily basis (whichever is more easy) for a specific table containing the number of records that got updated, inserted or deleted in this period.
The table contains a column named updatedate and another named deleted where the value 0 means it is not deleted, and the value 1 means it was deleted. Finally, there is the primary key column, named id.
The following code returns the records deleted for a certain period of time:
SELECT * FROM orders
    WHERE updateDate >='2019-01-01 00:00:00'
    AND updateDate <'2019-02-13 00:00:00' AND deleted = '1'

Which queries should one run also, in order to get a report of the newly created - inserted records?
I guess one should also somehow count the number of ids that exist in the starting date, and then the number of ids that exist in the end date, and then do the subtraction in order to get the number of the newly inserted records? Ideally i would like to have these reports in separate files
CREATE TABLE orders
(
  id INT PRIMARY KEY AUTO_INCREMENT,
  updatedate DATETIME,
  product_id INT,
  deleted INT,
  customer_id INT
);
INSERT INTO orders (updatedate, product_id, deleted, customer_id)
  VALUES
  ('2019-08-15 12:20:20', '1', '0', '123'),
  ('2019-08-15 12:20:20', '2', '0', '123'),
  ('2019-08-17 16:43:09', '4', '0', '456'),
  ('2019-08-18 09:21:43', '8', '0', '789'),
  ('2019-08-18 14:23:11', '12', '0', '123'),
  ('2019-08-21 08:34:21', '19', '0', '456');

example output of the updated records: (assuming the record ids are not new for the month under question)
date total_updates
2009-08-15  2
2009-08-17  1
2009-08-18  2
2009-08-21  1

Same table is needed for the records deleted and created in a month basis. This must be based only on the record ids that differ from the previous month.
ie if id 88 was not in the table orders in the last day of the previous month, then this is a newly inserted record. If id 13 was in the table orders in the last previous month's last day, and in this month's last day it is not, then this is a deleted record (something which may also occur from the column deleted combined with the updatedate column)
So this report could look like:
January:
123 records inserted
456 records deleted

EDIT: as was kindly spotted, in the comments, this approach is not totally safe, since we may loose some actions. Could you please elaborate on the solution
"A safer approach is to capture all events to a log using triggers and analyse that" given the fact that any change to the current scheme is not allowed, but we can store data in a new external scheme.


text:
Q: Play Framework 2.3 - Strange behaviour accessing server externally I have a Play app running in development, I was thinking that I would forward the 9000 port on my router to my development PC so that I could share the app with a few friends to ask for some input.
After forwarding the ports I was able to access the app using my external IP and port 9000. However after ~5 mins Play's server (just using the default one, Netty I think) started timing out and I was unable to get a response... I was still able to access the server normally locally (both using localhost and accessing through the router, but not externally to my home network).
I have checked my firewall and the router's firewall and there doesn't seem to be a problem. I can bind a different app to the port and it stays open and communicating.
If I restart the Play application then it is able to communicate for a further ~5 mins before beginning to fail again.
Is there any issues with Play that might somehow be able to prevent this? I'm so confused as the app runs locally as expected but I cannot see and firewall/router problems so I am left assuming that it MUST be the Play app (but that makes no sense right???)
I start the server using:
activator -jvm-debug 9999 run
... that I call from a batch file. I'm on windows 7.


text:
Q: InvalidArgumentError: 2 root error(s) found. (0) Invalid argument: indices[10,0] = 101102 is not in [0, 101102) I am trying to create a movie recommendation system by training the neural collaborative filtering (NCF) network on the MovieLens dataset. My implementation of NCF is
def NCF(num_users, num_items, gmf_embedding_dim, mlp_embedding_dim):
    # Define input vectors for embedding
    u_input = Input(shape = [1,])
    i_input = Input(shape = [1,])

    # GMF embedding
    u_embedding_gmf = Embedding(input_dim = num_users, output_dim = gmf_embedding_dim(u_input)
    u_vec_gmf = Flatten()(u_embedding_gmf)

    i_embedding_gmf = Embedding(input_dim = num_items, output_dim = gmf_embedding_dim(i_input)
    i_vec_gmf = Flatten()(i_embedding_gmf)

    # MLP embedding
    u_embedding_mlp = Embedding(input_dim = num_users, output_dim = mlp_embedding_dim(u_input)
    u_vec_mlp = Flatten()(u_embedding_mlp)

    i_embedding_mlp = Embedding(input_dim = num_items, output_dim = mlp_embedding_dim(i_input)
    i_vec_mlp = Flatten()(i_embedding_mlp)

    # GMF path
    gmf_output = Dot(axes = 1)([u_vec_gmf, i_vec_gmf])

    # MLP path
    mlp_input_concat = Concatenate()([u_vec_mlp, i_vec_mlp])

    mlp_dense_1 = Dense(units = 128, activation = "relu")(mlp_input_concat)
    mlp_bn_1 = BatchNormalization()(mlp_dense_1)
    mlp_drop_1 = Dropout(0.3)(mlp_bn_1)

    mlp_dense_2 = Dense(units = 64, activation = "relu")(mlp_drop_1)
    mlp_bn_2 = BatchNormalization()(mlp_dense_2)
    mlp_output = Dropout(0.3)(mlp_bn_2)

    # Concatenate GMF and MLP pathways
    paths_concat = Concatenate()([gmf_output, mlp_output])

    # Prediction
    output = Dense(units = 1, activation = "sigmoid")(paths_concat)

    # Create model

    return Model(inputs = [u_input, i_input], outputs = output)

I created a function to handle my training
def train(model, x_train, y_train, x_valid, y_valid, batch_size, epochs, save_name,
         checkpoint_path, history_path, lr = 0.001, lr_decay = True):

    if isfile(join(history_path, save_name)):
        return

    model.compile(loss = BinaryCrossentropy(), optimizer = Adam(learning_rate = lr),
                 metrics["accuracy"])

    best_checkpoint = ModelCheckpoint(filepath = join(checkpoint_path, save_name),
                                     monitor = "val_loss",
                                     save_best_only = True)

    history_csv = CSVLogger(join(history_path, save_name))

    early_stop = EarlyStopping(monitor = "val_loss",
                              patience = 30,
                              restore_best_weights = True)

    lr_decay_callback = ReduceLROnPlateau(monitor = "val_loss",
                                 patience = 10,
                                 factor = 0.5,
                                 min_lr = 0.000001)

    callback_list = [best_checkpoint, history_csv, early_stop]

    if lr_decay:
        callback_list.append(lr_decay_callback)

    model.fit(x = x_train, y = y_train, validation_data = (x_valid, y_valid),
           epochs = epochs, callbacks = callback_list, batch_size = batch_size)

Encoded the user_ID and movie_ID values ready for the embedding layers with
enc = LabelEncoder()
train_set["user_ID"] = enc.fit_transform(train_set["user_ID"].values)
enc = LabelEncoder()
train_set["movie_ID"] = enc.fit_transform(train_set["movie_ID"].values)

enc = LabelEncoder()
valid_set["user_ID"] = enc.fit_transform(valid_set["user_ID"].values)
enc = LabelEncoder()
valid_set["movie_ID"] = enc.fit_transform(valid_set["movie_ID"].values)

enc = LabelEncoder()
test_set["user_ID"] = enc.fit_transform(test_set["user_ID"].values)
enc = LabelEncoder()
test_set["movie_ID"] = enc.fit_transform(test_set["movie_ID"].values)

Then initiated the training with
train(model = NCF(num_users = train_set["user_ID"].nunique() + 1, num_items =
     train_set["movie_ID"].nunique() + 1, gmf_embedding_dim = 10, mlp_embedding_dim = 10),
     x_train = [train_set["user_ID"], train_set["movie_ID"]], y_train =
     train_set["interaction"],
     x_valid = [valid_set["user_ID"], valid_set["movie_ID"]], y_valid =
     valid_set["interaction"],
     batch_size = (train_set.shape[0])/10, epochs = 50, save_name = "NCF_1",
     checkpoint_path = "D:/Movie Recommendation System Project/model data/checkpoints",
     history_path = "D:/Movie Recommendation System Project/model data/training history")

The training appeared to go fine until the very last batch of the first epoch, where I received the error:
InvalidArgumentError: 2 root error(s) found.
(0) Invalid argument:  indices[10,0] = 101102 is not in [0, 101102)
[[node functional_9/embedding_16/embedding_lookup (defined at D:/Movie Recommendation System Project/architecture and training\training_and_evaluation.py:38) ]]
[[functional_9/embedding_18/embedding_lookup/_16]]
(1) Invalid argument:  indices[10,0] = 101102 is not in [0, 101102)
[[node functional_9/embedding_16/embedding_lookup (defined at D:/Movie Recommendation System Project/architecture and training\training_and_evaluation.py:38) ]]
0 successful operations.
0 derived errors ignored. [Op:__inference_test_function_529078]
This was a very similar error to that which I received at the end of my previous attempt, where the value was 101101 instead of 101102. As a naive solution, I tried adding 1 to my values for num_users and num_movies, but now the values in the error message appear to have simply increased by 1. I feel like I am missing something obvious or fundamental about embedding layers here. Could anyone help?

A: I believe this error occurred  as a result of the embedding layer encountering a value that it did not expect. When you are calling the NCF function you are passing the unique number of users of the train set. Instead calculate the unique number of users in the full data set and send it to the NCF function.
For example:
total_num_users = train_set["user_ID"].nunique() + valid_set["user_ID"].nunique() + test_set["user_ID"]..]nunique()

train(model = NCF(num_users = total_num_users, num_items =
     train_set["movie_ID"].nunique() + 1, gmf_embedding_dim = 10, mlp_embedding_dim = 10),
     x_train = [train_set["user_ID"], train_set["movie_ID"]], y_train =
     train_set["interaction"],
     x_valid = [valid_set["user_ID"], valid_set["movie_ID"]], y_valid =
     valid_set["interaction"],
     batch_size = (train_set.shape[0])/10, epochs = 50, save_name = "NCF_1",
     checkpoint_path = "D:/Movie Recommendation System Project/model data/checkpoints",
     history_path = "D:/Movie Recommendation System Project/model data/training history")

Make sure to follow the same approach to other categorical variables that you are embedding.


text:
Q: SQL Query NOT IN, EXIST Schemas
Movie(title, year, director, budget, earnings)
Actor(stagename, realname, birthyear)
ActedIn(stagename, title, year, pay)
CanWorkWith(stagename, director)

I need to find all the actors (stagename and realname) that have never worked in a movie that has made a profit (Earnings > budget). SO finding all the bad actors :P
SELECT A.stagename, A.realname
FROM Actor A
WHERE A.stagename NOT IN
   (SELECT B.stagename
    FROM ActedIN B
    WHERE EXIST
         (SELECT *
          FROM Movie M
          WHERE M.earnings > M.budget AND M.title = B.title AND M.year))

Would this find all the actors whose stagename does not appear in the second query? Second query will find all stagenames that acted in movies that made a profit.
Is this correct?

A: I think you could simplify it a bit, see below:
SELECT DISTINCT A.stagename, A.realname
FROM Actor A
WHERE NOT EXISTS
  (SELECT *
     FROM Actor B
        , Movie M
        , ActedIn X
    WHERE M.Title = X.Title
      AND X.StageName = B.StageName
      AND M.earnings > M.budget
      AND M.year = X.Year
      AND A.StageName = B.StageName)

A: Yes, you have the right idea for using NOT IN, but you're missing half a boolean condition in the second subquery's WHERE clause.  I think you intend to use AND M.year = B.year
WHERE M.earnings > M.budget AND M.title = B.title AND M.year = B.year

You can also do this with a few LEFT JOINs, looking for NULL in the right side of the join.  This may be faster than the subquery.
SELECT
  A.stagename,
  A.realname
FROM Actor A
  LEFT OUTER JOIN ActedIN B ON A.stagename = B.stagename
  LEFT OUTER JOIN Movie M ON B.title = M.title AND B.year = M.year AND M.earnings > M.budget
WHERE
  /* NULL ActedIN.stagename indicates the actor wasn't in this movie */
  B.stagename IS NULL

A: That will work, but just do a join between ActedIn and Movie rather than exist.
Possibly also an outer join may be faster rather than the NOT IN clause, but you would need to run explain plans to be sure.

A: That would do it. You could also write it like:
SELECT A.stagename, A.realname, SUM(B.pay) AS totalpay
FROM Actor A
INNER JOIN ActedIn B ON B.stagename = A.stagename
LEFT JOIN Movie M ON M.title = B.title AND M.year = B.year AND M.earnings > M.budget
WHERE M.title IS NULL
GROUP BY A.stagename, A.realname
ORDER BY totalpay DESC

It basically takes the movies that made a profit and uses that as a left join condition; when the left join is null it gets counted.
I've also added the total pay of said bad actors and ranked them from best to worst paid ;-)

A: SELECT
    a.stagename,
    a.realname
FROM
    Actor a
LEFT JOIN
    ActedIn b ON a.stagename = b.stagename
LEFT JOIN
    Movie c ON b.title = c.title
    AND a.year = b.year
    AND c.earnings >= c.budget
WHERE
    c.title IS NULL
GROUP BY
    a.stagename,
    a.realname

-No subqueries
-Accounts for actors who never acted in a movie yet
-Access to aggregate functions if needed.


text:
Q: Not Showing Data related to Last Date Below is the Query
SELECT
users.userName,
rechannel.channelName,
trschedule.ContentType,
trprogram.programName,
trschedule.Description,
trschedule.startTime,
trschedule.endTime,
TIMEDIFF(trschedule.startTime,trschedule.endTime) AS Difference,
LENGTH(trschedule.Description) AS Charcter_Count,
ROUND( LENGTH(trschedule.Description)/6) AS Word_Count,
ROUND( LENGTH(trschedule.Description)/65) AS Line_Count,
trschedule.ProvinceName,
trschedule.CityName,
trschedule.AreaName,
trschedule.ContentTone,
trschedule.searchText,
trschedule.CountryName,
trschedule.transmissionDate,
trschedule.insDate
FROM users
Inner Join trschedule ON users.userID = trschedule.insertID
Inner Join rechannel ON rechannel.channelID = trschedule.channelID
Inner Join trprogram ON trprogram.programID = trschedule.programID
WHERE (trschedule.insDate BETWEEN '2012-10-01' AND '2012-10-12')

But the result is showing from (insertDate)2012-10-01 to 2012-10-11 not showing the data of 2012-10-12.
What is the reason any idea???/

A: I think this should work, just change the last line:
WHERE (DATE(trschedule.insDate) BETWEEN '2012-10-01' AND '2012-10-12')

A: As you have not specified the time component of the date, mySQL is treating '2012-10-12' as the midnight between '2012-10-11' and '2012-10-12'.
Try replacing the between with :
trschedule.insDate >= '2012-10-01' AND trschedule.insDate < '2012-10-13'

A: Or try this:
WHERE (trschedule.insDate BETWEEN '2012-10-01 00:00:00' AND '2012-10-12 23:59:59')


text:
Q: Generate request in SOAPUI with ArrayOfArrayOfString type I have SOAP request like this. But I don't know how to generate request in in2 and in3 to array of array of string. Anyone know please give me an idea. Thanks
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
   <soapenv:Header/>
   <soapenv:Body>
      <rpc:imports soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
         <in0 xsi:type="xsd:string">abcd</in0>
         <in1 xsi:type="xsd:long">1234</in1>
         <in2 xsi:type="rpc:ArrayOf_xsd_string" soapenc:arrayType="xsd:string[6]">
                <item>test1</item>
                <item>test2</item>
                <item>test3</item>
                <item>test4</item>
                <item>test5</item>
                <item>test6</item>
         </in2>
         <in3 xsi:type="rpc:ArrayOfArrayOf_xsd_string" soapenc:arrayType="xsd:string[][]">
         </in3>
      </rpc:imports>
   </soapenv:Body>
</soapenv:Envelope>


text:
Q: Fourier transforms having compact support As we know, the fourier transform is a map $\mathcal{F}:L^1\rightarrow C_0$ (all with domain $\mathbb{R}$). Can one characterize the space of $f\in L^1$ such that $\mathcal{F}$ has compact support, i.e. is in $C_c\subset C_0$? In particular, is this space dense in $L^1$? I believe this should be true, but I find it hard to come up with nontrivial examples of such $f$. I guess the formula $\mathcal{F}(f\ast g)=\mathcal{F}(f)\mathcal{F}(g)$ should be useful?

A: One can characterize the space of integrable functions such that the Fourier transform has compact support via a Paley-Wiener sort of argument; in fact $\hat f$ has compact support if and only if $f$ is (almost everywhere) the restriction to $\Bbb R$ of an entire function $g$ with $$|g(x+iy)|\le ce^{A|y|}.$$
I don't see how this characterization helps in showing that the space is dense.  But that's not hard. Since the Fourier transform maps the Schwarz space to itself there exists a Schwarz function $\phi$ with $\int\phi=1$ such that $\hat\phi$ has compact support. (You can make $\hat\phi$ be any infinitely differentiable function with compact support.)
Define $$\phi_\delta(t)=\frac1\delta\phi\left(\frac t\delta\right).$$Then $\hat\phi_\delta$ has compact support, so if $f\in L^1$ then $\widehat{\phi_\delta*f}$ has compact support, and $||\phi_\delta*f-f||_1\to0$ as $\delta\to0$.
Edit: Come to think of it, it's even easier than this. For some reason I wanted a $\phi$ that gave pointwise convergence. All we need is convergence in norm, and that's much easier: We can let $\phi$ be any $L^1$ function such that $\hat \phi$ has compact support.
(So for example $\phi=\hat\psi$ where $\psi$ is just $C^2_c$, or where $\psi$ is the convolution of any two $L^2$ functions with compact support...)


text:
Q: jQuery DOM manipulation efficiency - building entire page with JavaScript I'm going to be starting off with a completely blank page (no elements other than html, head and body) and will then build the page using jQuery. The page contents will be in the form of JSON from an AJAX request. The contents from JSON will not have any HTML. The HTML with content will be built for different sections of the page depending on the structure of the JSON object.
This page will have various sliders, modals and other "dynamic" content.
My question is, will it be faster (lets take IE7 as the lowest common denominator) to build the HTML as one large string (using a string builder which is much faster than standard concatenation) and inject this into the body in a bulk fashion, i.e.
var html = "

All markup required for the page, built from the contents of the JSON object

...
...etc."
$("body").html(html)

And then when that is in the DOM, use jQuery to find and apply plugins to the various dynamic parts, i.e.
$("#slider").sliderPlugin(options);

OR
Would it be better to create each element (or some) as a variable, then append to the body? i.e.
var content = $('
', {id: "content"})
var slider =  $('
', {id: "slider", html="

...

"}).appendTo(content);
$('body').append(content)

then with this approach I don't have to query the DOM, I only have to do this:
slider.sliderPlugin(options);

A: I guess building the HTML once is the best way, I vaguely remember reading this somewhere
edit: I read It here with many more jQuery optimizations.  a nice and recommended read

A: The advice I've seen is that it is typically faster to supply a single large chunk of HTML to .html() and then rely on your browser's built-in parser to just do its thing.
However if you're going to be subsequently manipulating individual elements (e.g. adding event handlers, etc) then there's something to be said for creating those elements using the jQuery $('<element>') method.
Also, given an attribute value such as xx"xx (nb: embedded quote marks) it's far more reliable and secure to do:
$('
', { attr: foo })

than to do this:
html += '
';

Since if foo contains special HTML characters you'd have to escape them yourself.
Hence unless your content is really large I'd forget the performance concerns and go for large chunks of HTML when there's static HTML, but use the tag creation methods if you're interposing variable strings.

A: The templating features of KnockoutJS seem to be a really good fit for your application.


text:
Q: Simplification of $|a+b|^2$ for $a,b \in \mathbb{C}$ How do I simplify $|a+b|^2$, where $a,b \in \mathbb{C}$ and $|a|=|b|=1$? I know that the result is $4-|a-b|^2$, but I would like to be be explained how to do the simplification in the most elegant way.

A: It is
$$|a+b|^2=(a+b)\overline{(a+b)}=(a+b)(\overline{a}+\overline{b})=a\overline{a}+b\overline{b}+a\overline{b}+b\overline{a}=2+a\overline{b}+b\overline{a}$$
$$|a-b|^2=(a-b)\overline{(a-b)}=(a-b)(\overline{a}-\overline{b})=a\overline{a}+b\overline{b}-a\overline{b}-b\overline{a}=2-a\overline{b}-b\overline{a}$$
Now, if you add both equalities you get
$$|a+b|^2+|a-b|^2=4.$$


text:
Q: If...else statement to print different results from distances Does anyone know how I could make the result of this great fiddle read different things according to how big the distance result is?
I would like it to be printed an extra sentence saying different things according to if the distance is bigger than 10 km, 20 km, 30 km, etc.
I can't seem to figure out where to place the if...else in the existing code.
The JS:
var geocoder;
var map;
var polyline;
var markers = [];

function initialize() {
  map = new google.maps.Map(
    document.getElementById("map_canvas"), {
      center: new google.maps.LatLng(37.4419, -122.1419),
      zoom: 13,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    });
  calculateDistance();
  google.maps.event.addDomListener(document.getElementById('btn'), 'click', calculateDistance)
}

function calculateDistance() {
  if (polyline && polyline.setMap) {
    polyline.setMap(null);
  }
  for (var i = 0; i < markers.length; i++) {
    markers[i].setMap(null);
  }
  markers = [];
  var bounds = new google.maps.LatLngBounds();
  var path = [];
  var startPoint = $('#main_from_route_input').val();
  var endPoint = $('#main_to_route_input').val();
  var geocoderStart = new google.maps.Geocoder();
  var geocoderEnd = new google.maps.Geocoder();
  var coordsStart, coordsEnd;

  geocoderStart.geocode({
    'address': startPoint
  }, function(response, status) {
    if (status != google.maps.GeocoderStatus.OK) {
      alert('Geocode of first address failed: ' + status);
    }
    coordsStart = response[0].geometry.location;
    bounds.extend(coordsStart);
    var startMark = new google.maps.Marker({
      position: coordsStart,
      map: map,
      title: "start"
    });
    markers.push(startMark);
    path.push(coordsStart);
    geocoderEnd.geocode({
      'address': endPoint
    }, function(response, status) {
      if (status != google.maps.GeocoderStatus.OK) {
        alert('Geocode of second address failed: ' + status);
      }
      coordsEnd = response[0].geometry.location;
      bounds.extend(coordsEnd);
      var endMark = new google.maps.Marker({
        position: coordsEnd,
        map: map,
        title: "end"
      });
      markers.push(endMark);
      path.push(coordsEnd);
      polyline = new google.maps.Polyline({
        path: path,
        map: map
      });
      var distance = (google.maps.geometry.spherical.computeDistanceBetween(coordsStart, coordsEnd) / 1000).toFixed(2);
      $('#distance').val(distance);
      map.fitBounds(bounds);
    });
  });
}

google.maps.event.addDomListener(window, "load", initialize);

HTML:
<form>
  distance:
  <input id="distance" name="km">

  from
  <input id="main_from_route_input" value="Copenhagen, Denmark" />

  to
  <input id="main_to_route_input" value="Berlin, Germany" />
  <input id="btn" type="button" value="calculate distance" />
</form>

A: I believe that if you add an element inside the html like
distance:
  <input id="distance" name="km">

and then, after you can add in the js
$('#distance').val(distance);
$("#result").text(getCustomMessage(distance))

and you can add the function with all the if or switch you need like
function getCustomMessage(distance) {
    if (distance > 200) {
      return 'thats really far'
    }
   return `it's ${distance} miles away`
}

hope it helps! good luck :)


text:
Q: How to comparing the TPS of ReentrantLock and Synchronization I want to measure the TPS of ReentrantLock and Synchronization.At The same Time I want draw a chart to show the change as the count of thread goes on.
But Now,I can not find a satisfied tools to complete it.The result is like this picture:
The Example
Is there any tools or example that can help me achieve it?
Thank you!
I have write some code,But I am not good at collecting data elegantly.
private ReentrantLock lock = new ReentrantLock();

public synchronized void testSynchronized() {
    sleepRandomTime();
}

public void testReentrantLock() {
    lock.lock();
    try {
        sleepRandomTime();
    } finally {
        lock.unlock();
    }
}

private void sleepRandomTime() {
    long sleepTime = (int) (Math.random() * 100);
    try {
        Thread.sleep(sleepTime);
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
        throw new RuntimeException(e);
    }
}

public class ThreadTest1 extends Thread {
    @Override
    public void run() {
        testSynchronized();
    }
}

public class ThreadTest2 extends Thread {
    @Override
    public void run() {
        testReentrantLock();
    }
}

A: For micro benchmarking I use JMH.  Try it.  Btw a read - write lock is orders of magnitude faster than synchronised block in cases of contention, especially if you have read operations over lapping with write operations.


text:
Q: Create a cumulated sum between a range of rows
*

*First column cond contains either 1 or 0

*Second column event contains either 1 or 0

*I want to create a third column where each row is the (cumulated sum of cond  % 4) of the COND column between two rows where event==1 (first row where event==1 must be included in the cumulated sum but not the last row)

+------+-------+--------+
| cond | event | Result |
+------+-------+--------+
| 0    | 0     | 0      |
| 1    | 0     | 0      |
| 0    | 1     | 0      |
| 1    | 0     | 1      |
| 1    | 0     | 2      |
| 0    | 0     | 2      |
| 1    | 0     | 3      |
| 1    | 0     | 0      |
| 1    | 0     | 1      |
| 1    | 0     | 2      |
| 1    | 1     | 1      |
+------+-------+--------+

A: This can be easily tackles by pandas.groupby.transform and cumsum
event_cum = df['event'].cumsum()
result = df['cond'].groupby(event_cum).transform('cumsum').mod(4)
result[event_cum == 0] = 0  # rows before the first event

0     0
1     0
2     0
3     1
4     2
5     2
6     3
7     0
8     1
9     2
10    1
Name: cond, dtype: int64


text:
Q: Why did Dumbledore choose this verse for Kendra and Ariana's tomb?
She pointed to the dark stone. Harry stooped down and saw,
  upon the frozen, lichen-spotted granite, the words Kendra Dumbledore
  and, a short way below her dates of birth and death, and
  Her Daughter Ariana. There was also a quotation:
  Where your treasure is, there will your heart be also.
Deathly Hallows - Chapter 16: Godric's Hollow

Is there any reason why Dumbledore (presumably) chose this verse to place on his sister's tomb?

A: The quotation is from the Bible in Matthew 6:21:

19 Do not store up for yourselves treasures on earth, where moths and vermin destroy, and where thieves break in and steal. 20 But store up for yourselves treasures in heaven, where moths and vermin do not destroy, and where thieves do not break in and steal.
   21 For where your treasure is, there your heart will be also.
Matthew 6:19-21 NIV

The premise is that Jesus is telling his disciples that their focus should not be on worldly gain because the real treasure is elsewhere.
In Harry Potter, we know that Dumbledore feels great remorse over what happened to his sister, her death being one of the key reasons he never accepted the post of Minister of Magic. Placing this verse on her tombstone is his way of acknowledging that he missed out on the greater treasure due to his misplaced ambitions - as well as providing a warning along with some advice to any who may read it in the future.

A: I think that Dumbledore put this because he realized that his heart wasn't truly in to the goal i.e. the Deathly Hallows, which he was trying to attain alongsie Grindelwald. He might have been attracted to it only a little bit, of his own accord, rather he might have been blinded by his 'love' towards Grindelwald. He finally realized that his heart truly belongs to his family, this fact is even more true because we know that is what Dumbledore, like Harry, sees in the Mirror of Erised. He only realized the value of his family once they were all gone and seperated


text:
Q: how to compare enum values I have a question about enum C.
I defined an enum in the following way:
typedef enum
{
    Hello1 = 1,
    Hello2 = 2,
    Hello3 = 3
}Hello

Hello hello;

int value = 3;

then how to compare the value with the value in Hello?
for example:
if(value == Hello3)
{
}

or should I do it like the following:
if(value == Hello.Hello3)
{
}

A: enum is not a structure and the member names are just names of the corresponding constants.
These names defined in enum are not the data members of enum like in struct (as you are thinking).
So remember enum are used to define a list of named integer constants which we can do using #define also.
So here in your case:
if(value == Hello3)
{
}

This is the correct way to compare as it replaces Hello3 by the value 3 (which is nothing but int) at compile time.
For example you can do it also like this:
Hello hello=2;
if(hello == Hello2)
{
}

A: This way is correct:
 if (value == Hello3)
 {
 }

enum constants are of type int.
Your second construct is invalid.


text:
Q: Realm Database read data from Android I am new to realm database so need some help. When I kill my app then come back to the app again, I am unable to retrieve the data which was saved in retrofit. Insertion is working perfectly. Here is my code :
Insert Code inside callJson Method:
 realm.beginTransaction();
 realmCities = realm.copyToRealm(clientContactList);
 realm.commitTransaction();

Response after inserting when i am logging :
path :  /data/data/com.xyz.da/files/default.realm
response from realm : E/Output: ClientContact = proxy[{clientName:A},{email:mit@email.com},{address:Palava},{contactPerson:Amit},{numberMobile:9930182464},{numberLandline:25123456},{groupName:B},{tumbnailColor:0}]ClientContact = proxy[{clientName:A1},{email:abc@email.com},{address:MBP},{contactPerson:John},{numberMobile:9876543210},{numberLandline:25123456},{groupName:B1},{tumbnailColor:0}]ClientContact = proxy[{clientName:A10},{email:abc@email.com},{address:MBP},{contactPerson:John},{numberMobile:9876543210},{numberLandline:25123456},{groupName:E2},{tumbnailColor:0}]

In onCreateView I am doing like this : Here when i kill app and come back realmCities List coming null so it again hitting callJson()
if(realmCities!=null && realmCities.size()>0){
    Log.e("realmCities",""+realmCities.size());
}else{
    callJSON();
}

A: you have inserted data but when app is restart you have to get data from database
 realm.beginTransaction();
 realmCities = realm.copyToRealm(clientContactList);
 realm.commitTransaction();

when restart the app you have to get data from database like :
RealmResults<ClientContact> realmCities= realm.where(ClientContact.class).findAllAsync();
                        //fetching the data
        realmCities.load();

and after that you have to check condition
if(realmCities!=null && realmCities.size()>0){
    Log.e("realmCities",""+realmCities.size());
}else{
    callJSON();
}