Q: Internet slowness upon upgrading to 15.04 Strangest problem upon upgrading to Ubuntu 15.04—The internet will work fine for a few seconds and then get extremely, noticably slow. Then it will come back after two minutes or so for a few seconds and go out again. It’s so slow and unreliable that speedtest.net does not function. Unplugging the router box fixes the problem but it comes back every time Ubuntu goes into sleep mode or suspends. Internet works normally (if anything a bit faster) at the same time on all other devices.
dmesg output:
[...]
[   11.392866] brcmsmac bcma0:1: mfg 4bf core 812 rev 24 class 0 irq 16
[   11.399611] input: HDA Intel PCH Front Mic as /devices/pci0000:00/0000:00:1b.0/sound/card0/input9
[   11.399675] input: HDA Intel PCH Rear Mic as /devices/pci0000:00/0000:00:1b.0/sound/card0/input10
[   11.399753] input: HDA Intel PCH Line as /devices/pci0000:00/0000:00:1b.0/sound/card0/input11
[   11.400382] input: HDA Intel PCH Line Out Front as /devices/pci0000:00/0000:00:1b.0/sound/card0/input12
[   11.400460] input: HDA Intel PCH Line Out Surround as /devices/pci0000:00/0000:00:1b.0/sound/card0/input13
[   11.400526] input: HDA Intel PCH Line Out CLFE as /devices/pci0000:00/0000:00:1b.0/sound/card0/input14
[   11.400587] input: HDA Intel PCH Line Out Side as /devices/pci0000:00/0000:00:1b.0/sound/card0/input15
[   11.400648] input: HDA Intel PCH Front Headphone as /devices/pci0000:00/0000:00:1b.0/sound/card0/input16
[   11.400686] input: HDA Intel PCH HDMI/DP,pcm=3 as /devices/pci0000:00/0000:00:1b.0/sound/card0/input17
[   11.416981] ieee80211 phy0: Selected rate control algorithm 'minstrel_ht'
[   11.417172] ieee80211 phy0: registered radio enabled led device: brcmsmac-phy0:radio gpio: 499
[   11.421227] cfg80211: World regulatory domain updated:
[   11.421229] cfg80211:  DFS Master region: unset
[   11.421229] cfg80211:   (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp), (dfs_cac_time)
[   11.421231] cfg80211:   (2402000 KHz - 2472000 KHz @ 40000 KHz), (300 mBi, 2000 mBm), (N/A)
[   11.421233] cfg80211:   (2457000 KHz - 2482000 KHz @ 40000 KHz), (300 mBi, 2000 mBm), (N/A)
[   11.421234] cfg80211:   (2474000 KHz - 2494000 KHz @ 20000 KHz), (300 mBi, 2000 mBm), (N/A)
[   11.421235] cfg80211:   (5170000 KHz - 5250000 KHz @ 40000 KHz), (300 mBi, 2000 mBm), (N/A)
[   11.421236] cfg80211:   (5735000 KHz - 5835000 KHz @ 40000 KHz), (300 mBi, 2000 mBm), (N/A)
[   11.476365] brcmsmac bcma0:1 wlan1: renamed from wlan0
[   11.594996] input: Wacom Intuos PT M Pen as /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3.4/2-1.3.4:1.0/0003:056A:0303.0002/input/input18
[   11.595076] wacom 0003:056A:0303.0002: hidraw3: USB HID v1.10 Device [Wacom Co.,Ltd. Intuos PTM] on usb-0000:00:1d.0-1.3.4/input0
[   11.595653] input: Wacom Intuos PT M Finger as /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3.4/2-1.3.4:1.1/0003:056A:0303.0003/input/input20
[   11.595714] input: Wacom Intuos PT M Pad as /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3.4/2-1.3.4:1.1/0003:056A:0303.0003/input/input21
[   11.595773] wacom 0003:056A:0303.0003: hidraw4: USB HID v1.10 Device [Wacom Co.,Ltd. Intuos PTM] on usb-0000:00:1d.0-1.3.4/input1
[   16.568325] usblp 2-1.4:1.0: usblp0: USB Bidirectional printer dev 4 if 0 alt 0 proto 2 vid 0x04F9 pid 0x0038
[   16.568346] usbcore: registered new interface driver usblp
[   16.705837] EXT4-fs (sda1): re-mounted. Opts: errors=remount-ro
[   16.868962] systemd-journald[334]: Received request to flush runtime journal from PID 1
[   17.032324] audit: type=1400 audit(1430669160.766:2): apparmor="STATUS" operation="profile_load" profile="unconfined" name="/usr/lib/lightdm/lightdm-guest-session" pid=743 comm="apparmor_parser"
[   17.032330] audit: type=1400 audit(1430669160.766:3): apparmor="STATUS" operation="profile_load" profile="unconfined" name="chromium" pid=743 comm="apparmor_parser"
[   17.033654] audit: type=1400 audit(1430669160.770:4): apparmor="STATUS" operation="profile_load" profile="unconfined" name="/sbin/dhclient" pid=743 comm="apparmor_parser"
[   17.033659] audit: type=1400 audit(1430669160.770:5): apparmor="STATUS" operation="profile_load" profile="unconfined" name="/usr/lib/NetworkManager/nm-dhcp-client.action" pid=743 comm="apparmor_parser"
[   17.033662] audit: type=1400 audit(1430669160.770:6): apparmor="STATUS" operation="profile_load" profile="unconfined" name="/usr/lib/NetworkManager/nm-dhcp-helper" pid=743 comm="apparmor_parser"
[   17.033665] audit: type=1400 audit(1430669160.770:7): apparmor="STATUS" operation="profile_load" profile="unconfined" name="/usr/lib/connman/scripts/dhclient-script" pid=743 comm="apparmor_parser"
[   17.039698] audit: type=1400 audit(1430669160.774:8): apparmor="STATUS" operation="profile_load" profile="unconfined" name="/usr/bin/evince" pid=743 comm="apparmor_parser"
[   17.039703] audit: type=1400 audit(1430669160.774:9): apparmor="STATUS" operation="profile_load" profile="unconfined" name="sanitized_helper" pid=743 comm="apparmor_parser"
[   17.039707] audit: type=1400 audit(1430669160.774:10): apparmor="STATUS" operation="profile_load" profile="unconfined" name="/usr/bin/evince-previewer" pid=743 comm="apparmor_parser"
[   17.039717] audit: type=1400 audit(1430669160.774:11): apparmor="STATUS" operation="profile_load" profile="unconfined" name="sanitized_helper" pid=743 comm="apparmor_parser"
[   17.211375] Adding 8370684k swap on /dev/mapper/cryptswap1.  Priority:-1 extents:1 across:8370684k FS
[   17.216998] cgroup: new mount options do not match the existing superblock, will be ignored
[   18.866408] brcmsmac bcma0:1: brcms_ops_bss_info_changed: qos enabled: false (implement)
[   18.866416] brcmsmac bcma0:1: brcms_ops_config: change power-save mode: false (implement)
[   19.138947] tg3 0000:03:00.0 eth1: Link is down
[   19.850816] wlan1: authenticate with 00:18:4d:22:98:c4
[   19.850883] wlan1: send auth to 00:18:4d:22:98:c4 (try 1/3)
[   19.852311] wlan1: authenticated
[   19.854198] wlan1: associate with 00:18:4d:22:98:c4 (try 1/3)
[   19.863902] wlan1: RX AssocResp from 00:18:4d:22:98:c4 (capab=0x411 status=0 aid=1)
[   19.864539] brcmsmac bcma0:1: brcmsmac: brcms_ops_bss_info_changed: associated
[   19.864541] brcmsmac bcma0:1: brcms_ops_bss_info_changed: qos enabled: true (implement)
[   19.864545] wlan1: associated
[   19.867640] brcmsmac bcma0:1: wl0: brcms_c_d11hdrs_mac80211:  txop exceeded phylen 159/256 dur 1778/1504
[   20.032655] brcmsmac bcma0:1: wl0: brcms_c_d11hdrs_mac80211:  txop exceeded phylen 137/256 dur 1602/1504
[   20.984454] brcmsmac bcma0:1: brcms_ops_bss_info_changed: arp filtering: 1 addresses (implement)
[   22.140314] tg3 0000:03:00.0 eth1: Link is up at 1000 Mbps, full duplex
[   22.140316] tg3 0000:03:00.0 eth1: Flow control is on for TX and on for RX
[   24.141219] tg3 0000:03:00.0 eth1: Link is down
[   26.142151] tg3 0000:03:00.0 eth1: Link is up at 1000 Mbps, full duplex
[   26.142153] tg3 0000:03:00.0 eth1: Flow control is on for TX and on for RX
[   35.520086] vboxdrv: module verification failed: signature and/or  required key missing - tainting kernel
[   35.522353] vboxdrv: Found 8 processor cores.
[   35.522514] vboxdrv: fAsync=0 offMin=0x22b offMax=0x138f
[   35.522586] vboxdrv: TSC mode is 'synchronous', kernel timer mode is 'normal'.
[   35.522587] vboxdrv: Successfully loaded version 4.3.26_Ubuntu (interface 0x001a000a).
[   35.531804] vboxpci: IOMMU not found (not registered)
[   67.888548] brcmsmac bcma0:1: brcmsmac: brcms_ops_bss_info_changed: disassociated
[   67.888553] brcmsmac bcma0:1: brcms_ops_bss_info_changed: arp filtering: 1 addresses (implement)
[   67.888554] brcmsmac bcma0:1: brcms_ops_bss_info_changed: qos enabled: false (implement)
[   67.904610] cfg80211: Calling CRDA to update world regulatory domain
[   67.906293] cfg80211: World regulatory domain updated:
[   67.906296] cfg80211:  DFS Master region: unset
[   67.906297] cfg80211:   (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp), (dfs_cac_time)
[   67.906298] cfg80211:   (2402000 KHz - 2472000 KHz @ 40000 KHz), (300 mBi, 2000 mBm), (N/A)
[   67.906300] cfg80211:   (2457000 KHz - 2482000 KHz @ 40000 KHz), (300 mBi, 2000 mBm), (N/A)
[   67.906301] cfg80211:   (2474000 KHz - 2494000 KHz @ 20000 KHz), (300 mBi, 2000 mBm), (N/A)
[   67.906302] cfg80211:   (5170000 KHz - 5250000 KHz @ 40000 KHz), (300 mBi, 2000 mBm), (N/A)
[   67.906303] cfg80211:   (5735000 KHz - 5835000 KHz @ 40000 KHz), (300 mBi, 2000 mBm), (N/A)
[   68.161479] tg3 0000:03:00.0 eth1: Link is down
[   71.162895] tg3 0000:03:00.0 eth1: Link is up at 1000 Mbps, full duplex
[   71.162898] tg3 0000:03:00.0 eth1: Flow control is on for TX and on for RX
[   79.166572] tg3 0000:03:00.0 eth1: Link is down
[   81.167558] tg3 0000:03:00.0 eth1: Link is up at 1000 Mbps, full duplex
[   81.167563] tg3 0000:03:00.0 eth1: Flow control is on for TX and on for RX
[  109.917835] wlan1: authenticate with 00:18:4d:22:98:c4
[  109.917938] wlan1: send auth to 00:18:4d:22:98:c4 (try 1/3)
[  109.921600] wlan1: authenticated
[  109.923497] wlan1: associate with 00:18:4d:22:98:c4 (try 1/3)
[  109.926844] wlan1: RX AssocResp from 00:18:4d:22:98:c4 (capab=0x411 status=0 aid=1)
[  109.927467] brcmsmac bcma0:1: brcmsmac: brcms_ops_bss_info_changed: associated
[  109.927471] brcmsmac bcma0:1: brcms_ops_bss_info_changed: qos enabled: true (implement)
[  109.927494] wlan1: associated
[  109.929216] brcmsmac bcma0:1: wl0: brcms_c_d11hdrs_mac80211:  txop exceeded phylen 159/256 dur 1778/1504
[  110.094408] brcmsmac bcma0:1: wl0: brcms_c_d11hdrs_mac80211:  txop exceeded phylen 137/256 dur 1602/1504
[  111.049663] brcmsmac bcma0:1: brcms_ops_bss_info_changed: arp filtering: 1 addresses (implement)
[  991.595324] wlan1: deauthenticating from 00:18:4d:22:98:c4 by local choice (Reason: 3=DEAUTH_LEAVING)
[  991.596347] brcmsmac bcma0:1: brcmsmac: brcms_ops_bss_info_changed: disassociated
[  991.596353] brcmsmac bcma0:1: brcms_ops_bss_info_changed: arp filtering: 1 addresses (implement)
[  991.596356] brcmsmac bcma0:1: brcms_ops_bss_info_changed: qos enabled: false (implement)
[  991.596916] cfg80211: Calling CRDA to update world regulatory domain
[  991.601429] cfg80211: World regulatory domain updated:
[  991.601433] cfg80211:  DFS Master region: unset
[  991.601434] cfg80211:   (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp), (dfs_cac_time)
[  991.601437] cfg80211:   (2402000 KHz - 2472000 KHz @ 40000 KHz), (300 mBi, 2000 mBm), (N/A)
[  991.601439] cfg80211:   (2457000 KHz - 2482000 KHz @ 40000 KHz), (300 mBi, 2000 mBm), (N/A)
[  991.601440] cfg80211:   (2474000 KHz - 2494000 KHz @ 20000 KHz), (300 mBi, 2000 mBm), (N/A)
[  991.601442] cfg80211:   (5170000 KHz - 5250000 KHz @ 40000 KHz), (300 mBi, 2000 mBm), (N/A)
[  991.601444] cfg80211:   (5735000 KHz - 5835000 KHz @ 40000 KHz), (300 mBi, 2000 mBm), (N/A)
[  991.623804] IPv6: ADDRCONF(NETDEV_UP): wlan1: link is not ready
[  991.736875] PM: Syncing filesystems ... done.
[  992.128457] PM: Preparing system for mem sleep
[  992.232697] Freezing user space processes ... (elapsed 0.001 seconds) done.
[  992.234356] Freezing remaining freezable tasks ... (elapsed 0.001 seconds) done.
[  992.235488] PM: Entering mem sleep
[  992.235534] Suspending console(s) (use no_console_suspend to debug)
[  992.235866] sd 0:0:0:0: [sda] Synchronizing SCSI cache
[  992.246520] sd 0:0:0:0: [sda] Stopping disk
[  993.734062] PM: suspend of devices complete after 1497.709 msecs
[  993.734515] PM: late suspend of devices complete after 0.449 msecs
[  993.735050] ehci-pci 0000:00:1d.0: System wakeup enabled by ACPI
[  993.735053] ehci-pci 0000:00:1a.0: System wakeup enabled by ACPI
[  993.735166] pcieport 0000:00:1c.3: System wakeup enabled by ACPI
[  993.750207] PM: noirq suspend of devices complete after 15.681 msecs
[  993.750792] ACPI: Preparing to enter system sleep state S3
[  993.751573] PM: Saving platform NVS memory
[  993.752089] Disabling non-boot CPUs ...
[  993.752153] intel_pstate CPU 1 exiting
[  993.753494] kvm: disabling virtualization on CPU1
[  993.753509] smpboot: CPU 1 is now offline
[  993.753878] intel_pstate CPU 2 exiting
[  993.755248] kvm: disabling virtualization on CPU2
[  993.755264] smpboot: CPU 2 is now offline
[  993.755648] intel_pstate CPU 3 exiting
[  993.756991] kvm: disabling virtualization on CPU3
[  993.757001] smpboot: CPU 3 is now offline
[  993.757379] intel_pstate CPU 4 exiting
[  993.758699] kvm: disabling virtualization on CPU4
[  993.759301] smpboot: CPU 4 is now offline
[  993.759682] intel_pstate CPU 5 exiting
[  993.759895] Broke affinity for irq 23
[  993.759899] Broke affinity for irq 27
[  993.760906] kvm: disabling virtualization on CPU5
[  993.760915] smpboot: CPU 5 is now offline
[  993.761203] intel_pstate CPU 6 exiting
[  993.762420] kvm: disabling virtualization on CPU6
[  993.762456] smpboot: CPU 6 is now offline
[  993.762798] intel_pstate CPU 7 exiting
[  993.764032] kvm: disabling virtualization on CPU7
[  993.764040] smpboot: CPU 7 is now offline
[  993.765682] ACPI: Low-level resume complete
[  993.765716] PM: Restoring platform NVS memory
[  993.766143] Enabling non-boot CPUs ...
[  993.766178] x86: Booting SMP configuration:
[  993.766179] smpboot: Booting Node 0 Processor 1 APIC 0x2
[  993.777415] kvm: enabling virtualization on CPU1
[  993.779785] CPU1 is up
[  993.779802] smpboot: Booting Node 0 Processor 2 APIC 0x4
[  993.790782] kvm: enabling virtualization on CPU2
[  993.793040] CPU2 is up
[  993.793057] smpboot: Booting Node 0 Processor 3 APIC 0x6
[  993.804036] kvm: enabling virtualization on CPU3
[  993.806297] CPU3 is up
[  993.806315] smpboot: Booting Node 0 Processor 4 APIC 0x1
[  993.817293] kvm: enabling virtualization on CPU4
[  993.819564] CPU4 is up
[  993.819583] smpboot: Booting Node 0 Processor 5 APIC 0x3
[  993.830560] kvm: enabling virtualization on CPU5
[  993.832846] CPU5 is up
[  993.832864] smpboot: Booting Node 0 Processor 6 APIC 0x5
[  993.843841] kvm: enabling virtualization on CPU6
[  993.846132] CPU6 is up
[  993.846149] smpboot: Booting Node 0 Processor 7 APIC 0x7
[  993.857127] kvm: enabling virtualization on CPU7
[  993.859439] CPU7 is up
[  993.865707] ACPI: Waking up from system sleep state S3
[  993.880028] ehci-pci 0000:00:1a.0: System wakeup disabled by ACPI
[  993.880253] ehci-pci 0000:00:1d.0: System wakeup disabled by ACPI
[  993.880325] PM: noirq resume of devices complete after 14.162 msecs
[  993.880548] PM: early resume of devices complete after 0.203 msecs
[  993.880626] rtc_cmos 00:02: System wakeup disabled by ACPI
[  993.880736] pcieport 0000:00:1c.3: System wakeup disabled by ACPI
[  993.883397] tg3 0000:03:00.0 eth1: Link is down
[  993.883615] sd 0:0:0:0: [sda] Starting disk
[  993.938342] [drm] enabling PCIE gen 2 link speeds, disable with radeon.pcie_gen2=0
[  993.940994] [drm] PCIE GART of 1024M enabled (table at 0x000000000025E000).
[  993.941068] radeon 0000:01:00.0: WB enabled
[  993.941069] radeon 0000:01:00.0: fence driver on ring 0 use gpu addr 0x0000000040000c00 and cpu addr 0xffff880035970c00
[  993.941070] radeon 0000:01:00.0: fence driver on ring 3 use gpu addr 0x0000000040000c0c and cpu addr 0xffff880035970c0c
[  993.941805] radeon 0000:01:00.0: fence driver on ring 5 use gpu addr 0x000000000005c418 and cpu addr 0xffffc9001171c418
[  993.957891] [drm] ring test on 0 succeeded in 1 usecs
[  993.957895] [drm] ring test on 3 succeeded in 2 usecs
[  994.153479] [drm] ring test on 5 succeeded in 1 usecs
[  994.153482] [drm] UVD initialized successfully.
[  994.153509] [drm] ib test on ring 0 succeeded in 0 usecs
[  994.153542] [drm] ib test on ring 3 succeeded in 0 usecs
[  994.231932] ata3: SATA link down (SStatus 0 SControl 300)
[  994.231963] ata5: SATA link down (SStatus 0 SControl 300)
[  994.231978] ata2: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
[  994.233059] ata2.00: configured for UDMA/100
[  994.239934] ata4: SATA link down (SStatus 0 SControl 300)
[  994.820317] [drm] ib test on ring 5 succeeded
[  994.982731] PM: resume of devices complete after 1101.684 msecs
[  994.982857] PM: Finishing wakeup.
[  994.982858] Restarting tasks ... done.
[  995.105824] IPv6: ADDRCONF(NETDEV_UP): eth1: link is not ready
[  995.980737] tg3 0000:03:00.0 eth1: Link is down
[  999.274215] ata1: link is slow to respond, please be patient (ready=0)
[ 1000.730879] ata1: SATA link up 3.0 Gbps (SStatus 123 SControl 300)
[ 1000.732979] ata1.00: configured for UDMA/133
[ 1000.936185] brcmsmac bcma0:1: brcms_ops_bss_info_changed: qos enabled: false (implement)
[ 1000.936194] brcmsmac bcma0:1: brcms_ops_config: change power-save mode: false (implement)
[ 1000.983971] tg3 0000:03:00.0 eth1: Link is down
[ 1001.802159] wlan1: authenticate with 00:18:4d:22:98:c4
[ 1001.802218] wlan1: send auth to 00:18:4d:22:98:c4 (try 1/3)
[ 1001.803727] wlan1: authenticated
[ 1001.807332] wlan1: associate with 00:18:4d:22:98:c4 (try 1/3)
[ 1001.810256] wlan1: RX AssocResp from 00:18:4d:22:98:c4 (capab=0x411 status=0 aid=1)
[ 1001.812349] brcmsmac bcma0:1: brcmsmac: brcms_ops_bss_info_changed: associated
[ 1001.812352] brcmsmac bcma0:1: brcms_ops_bss_info_changed: qos enabled: true (implement)
[ 1001.812358] wlan1: associated
[ 1001.812877] brcmsmac bcma0:1: wl0: brcms_c_d11hdrs_mac80211:  txop exceeded phylen 159/256 dur 1778/1504
[ 1001.973052] brcmsmac bcma0:1: wl0: brcms_c_d11hdrs_mac80211:  txop exceeded phylen 137/256 dur 1602/1504
[ 1002.062591] brcmsmac bcma0:1: brcms_ops_bss_info_changed: arp filtering: 1 addresses (implement)
[ 1003.985384] tg3 0000:03:00.0 eth1: Link is up at 1000 Mbps, full duplex
[ 1003.985387] tg3 0000:03:00.0 eth1: Flow control is on for TX and on for RX
[ 3424.067570] brcmsmac bcma0:1: brcmsmac: brcms_ops_bss_info_changed: disassociated
[ 3424.067576] brcmsmac bcma0:1: brcms_ops_bss_info_changed: arp filtering: 1 addresses (implement)
[ 3424.067578] brcmsmac bcma0:1: brcms_ops_bss_info_changed: qos enabled: false (implement)
[ 3424.083628] cfg80211: Calling CRDA to update world regulatory domain
[ 3424.085278] cfg80211: World regulatory domain updated:
[ 3424.085280] cfg80211:  DFS Master region: unset
[ 3424.085281] cfg80211:   (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp), (dfs_cac_time)
[ 3424.085283] cfg80211:   (2402000 KHz - 2472000 KHz @ 40000 KHz), (300 mBi, 2000 mBm), (N/A)
[ 3424.085284] cfg80211:   (2457000 KHz - 2482000 KHz @ 40000 KHz), (300 mBi, 2000 mBm), (N/A)
[ 3424.085285] cfg80211:   (2474000 KHz - 2494000 KHz @ 20000 KHz), (300 mBi, 2000 mBm), (N/A)
[ 3424.085286] cfg80211:   (5170000 KHz - 5250000 KHz @ 40000 KHz), (300 mBi, 2000 mBm), (N/A)
[ 3424.085288] cfg80211:   (5735000 KHz - 5835000 KHz @ 40000 KHz), (300 mBi, 2000 mBm), (N/A)
[ 3424.760724] tg3 0000:03:00.0 eth1: Link is down
[ 3427.762181] tg3 0000:03:00.0 eth1: Link is up at 1000 Mbps, full duplex
[ 3427.762184] tg3 0000:03:00.0 eth1: Flow control is on for TX and on for RX
[ 3435.765902] tg3 0000:03:00.0 eth1: Link is down
[ 3437.766903] tg3 0000:03:00.0 eth1: Link is up at 1000 Mbps, full duplex
[ 3437.766906] tg3 0000:03:00.0 eth1: Flow control is on for TX and on for RX
[ 3466.100704] wlan1: authenticate with 00:18:4d:22:98:c4
[ 3466.100773] wlan1: send auth to 00:18:4d:22:98:c4 (try 1/3)
[ 3466.102320] wlan1: authenticated
[ 3466.103362] wlan1: associate with 00:18:4d:22:98:c4 (try 1/3)
[ 3466.108442] wlan1: RX AssocResp from 00:18:4d:22:98:c4 (capab=0x411 status=0 aid=1)
[ 3466.110490] brcmsmac bcma0:1: brcmsmac: brcms_ops_bss_info_changed: associated
[ 3466.110504] brcmsmac bcma0:1: brcms_ops_bss_info_changed: qos enabled: true (implement)
[ 3466.110512] wlan1: associated
[ 3466.111024] brcmsmac bcma0:1: wl0: brcms_c_d11hdrs_mac80211:  txop exceeded phylen 159/256 dur 1778/1504
[ 3466.279150] brcmsmac bcma0:1: wl0: brcms_c_d11hdrs_mac80211:  txop exceeded phylen 137/256 dur 1602/1504
[ 3467.657450] brcmsmac bcma0:1: brcms_ops_bss_info_changed: arp filtering: 1 addresses (implement)
[ 5652.796360] brcmsmac bcma0:1: brcms_ops_bss_info_changed: arp filtering: 0 addresses (implement)
[ 5652.796372] wlan1: deauthenticating from 00:18:4d:22:98:c4 by local choice (Reason: 3=DEAUTH_LEAVING)
[ 5652.827750] brcmsmac bcma0:1: brcmsmac: brcms_ops_bss_info_changed: disassociated
[ 5652.827756] brcmsmac bcma0:1: brcms_ops_bss_info_changed: qos enabled: false (implement)
[ 5652.829772] cfg80211: Calling CRDA to update world regulatory domain
[ 5652.831652] cfg80211: World regulatory domain updated:
[ 5652.831655] cfg80211:  DFS Master region: unset
[ 5652.831656] cfg80211:   (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp), (dfs_cac_time)
[ 5652.831659] cfg80211:   (2402000 KHz - 2472000 KHz @ 40000 KHz), (300 mBi, 2000 mBm), (N/A)
[ 5652.831660] cfg80211:   (2457000 KHz - 2482000 KHz @ 40000 KHz), (300 mBi, 2000 mBm), (N/A)
[ 5652.831662] cfg80211:   (2474000 KHz - 2494000 KHz @ 20000 KHz), (300 mBi, 2000 mBm), (N/A)
[ 5652.831663] cfg80211:   (5170000 KHz - 5250000 KHz @ 40000 KHz), (300 mBi, 2000 mBm), (N/A)
[ 5652.831664] cfg80211:   (5735000 KHz - 5835000 KHz @ 40000 KHz), (300 mBi, 2000 mBm), (N/A)
[ 5652.851952] IPv6: ADDRCONF(NETDEV_UP): wlan1: link is not ready
[ 5652.935830] PM: Syncing filesystems ... done.
[ 5653.176158] PM: Preparing system for mem sleep
[ 5653.245757] Freezing user space processes ... (elapsed 0.001 seconds) done.
[ 5653.247328] Freezing remaining freezable tasks ... (elapsed 0.001 seconds) done.
[ 5653.248464] PM: Entering mem sleep
[ 5653.248509] Suspending console(s) (use no_console_suspend to debug)
[ 5653.248749] sd 0:0:0:0: [sda] Synchronizing SCSI cache
[ 5653.248881] sd 0:0:0:0: [sda] Stopping disk
[ 5654.756576] PM: suspend of devices complete after 1507.224 msecs
[ 5654.756952] PM: late suspend of devices complete after 0.374 msecs
[ 5654.757389] ehci-pci 0000:00:1d.0: System wakeup enabled by ACPI
[ 5654.757393] ehci-pci 0000:00:1a.0: System wakeup enabled by ACPI
[ 5654.757466] pcieport 0000:00:1c.3: System wakeup enabled by ACPI
[ 5654.772741] PM: noirq suspend of devices complete after 15.779 msecs
[ 5654.773025] ACPI: Preparing to enter system sleep state S3
[ 5654.773426] PM: Saving platform NVS memory
[ 5654.773689] Disabling non-boot CPUs ...
[ 5654.773729] intel_pstate CPU 1 exiting
[ 5654.774934] kvm: disabling virtualization on CPU1
[ 5654.774941] smpboot: CPU 1 is now offline
[ 5654.775207] intel_pstate CPU 2 exiting
[ 5654.776393] kvm: disabling virtualization on CPU2
[ 5654.776399] smpboot: CPU 2 is now offline
[ 5654.776627] intel_pstate CPU 3 exiting
[ 5654.777824] kvm: disabling virtualization on CPU3
[ 5654.777830] smpboot: CPU 3 is now offline
[ 5654.778072] intel_pstate CPU 4 exiting
[ 5654.779260] kvm: disabling virtualization on CPU4
[ 5654.779266] smpboot: CPU 4 is now offline
[ 5654.779508] intel_pstate CPU 5 exiting
[ 5654.780660] kvm: disabling virtualization on CPU5
[ 5654.780674] smpboot: CPU 5 is now offline
[ 5654.780926] intel_pstate CPU 6 exiting
[ 5654.782081] kvm: disabling virtualization on CPU6
[ 5654.782086] smpboot: CPU 6 is now offline
[ 5654.782352] intel_pstate CPU 7 exiting
[ 5654.783490] kvm: disabling virtualization on CPU7
[ 5654.783493] smpboot: CPU 7 is now offline
[ 5654.784715] ACPI: Low-level resume complete
[ 5654.784749] PM: Restoring platform NVS memory
[ 5654.785173] Enabling non-boot CPUs ...
[ 5654.785208] x86: Booting SMP configuration:
[ 5654.785209] smpboot: Booting Node 0 Processor 1 APIC 0x2
[ 5654.796190] kvm: enabling virtualization on CPU1
[ 5654.798449] CPU1 is up
[ 5654.798467] smpboot: Booting Node 0 Processor 2 APIC 0x4
[ 5654.809450] kvm: enabling virtualization on CPU2
[ 5654.811698] CPU2 is up
[ 5654.811716] smpboot: Booting Node 0 Processor 3 APIC 0x6
[ 5654.822696] kvm: enabling virtualization on CPU3
[ 5654.824944] CPU3 is up
[ 5654.824963] smpboot: Booting Node 0 Processor 4 APIC 0x1
[ 5654.835941] kvm: enabling virtualization on CPU4
[ 5654.838207] CPU4 is up
[ 5654.838225] smpboot: Booting Node 0 Processor 5 APIC 0x3
[ 5654.849203] kvm: enabling virtualization on CPU5
[ 5654.851474] CPU5 is up
[ 5654.851492] smpboot: Booting Node 0 Processor 6 APIC 0x5
[ 5654.862468] kvm: enabling virtualization on CPU6
[ 5654.864749] CPU6 is up
[ 5654.864766] smpboot: Booting Node 0 Processor 7 APIC 0x7
[ 5654.875745] kvm: enabling virtualization on CPU7
[ 5654.878058] CPU7 is up
[ 5654.884495] ACPI: Waking up from system sleep state S3
[ 5654.898324] ehci-pci 0000:00:1d.0: System wakeup disabled by ACPI
[ 5654.898332] ehci-pci 0000:00:1a.0: System wakeup disabled by ACPI
[ 5654.898602] PM: noirq resume of devices complete after 13.645 msecs
[ 5654.898817] PM: early resume of devices complete after 0.194 msecs
[ 5654.898874] rtc_cmos 00:02: System wakeup disabled by ACPI
[ 5654.899043] pcieport 0000:00:1c.3: System wakeup disabled by ACPI
[ 5654.901149] sd 0:0:0:0: [sda] Starting disk
[ 5654.901623] tg3 0000:03:00.0 eth1: Link is down
[ 5654.955194] [drm] enabling PCIE gen 2 link speeds, disable with radeon.pcie_gen2=0
[ 5654.957843] [drm] PCIE GART of 1024M enabled (table at 0x000000000025E000).
[ 5654.957919] radeon 0000:01:00.0: WB enabled
[ 5654.957920] radeon 0000:01:00.0: fence driver on ring 0 use gpu addr 0x0000000040000c00 and cpu addr 0xffff880035970c00
[ 5654.957921] radeon 0000:01:00.0: fence driver on ring 3 use gpu addr 0x0000000040000c0c and cpu addr 0xffff880035970c0c
[ 5654.958666] radeon 0000:01:00.0: fence driver on ring 5 use gpu addr 0x000000000005c418 and cpu addr 0xffffc9001171c418
[ 5654.974740] [drm] ring test on 0 succeeded in 1 usecs
[ 5654.974744] [drm] ring test on 3 succeeded in 2 usecs
[ 5655.170329] [drm] ring test on 5 succeeded in 1 usecs
[ 5655.170332] [drm] UVD initialized successfully.
[ 5655.170361] [drm] ib test on ring 0 succeeded in 0 usecs
[ 5655.170387] [drm] ib test on ring 3 succeeded in 0 usecs
[ 5655.234227] ata2: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
[ 5655.235338] ata2.00: configured for UDMA/100
[ 5655.246221] ata4: SATA link down (SStatus 0 SControl 300)
[ 5655.246238] ata3: SATA link down (SStatus 0 SControl 300)
[ 5655.254223] ata5: SATA link down (SStatus 0 SControl 300)
[ 5655.838607] [drm] ib test on ring 5 succeeded
[ 5656.001082] PM: resume of devices complete after 1101.722 msecs
[ 5656.001219] PM: Finishing wakeup.
[ 5656.001220] Restarting tasks ... done.
[ 5656.125228] IPv6: ADDRCONF(NETDEV_UP): eth1: link is not ready
[ 5656.999085] tg3 0000:03:00.0 eth1: Link is down
[ 5660.268693] ata1: link is slow to respond, please be patient (ready=0)
[ 5661.781469] ata1: SATA link up 3.0 Gbps (SStatus 123 SControl 300)
[ 5661.783815] ata1.00: configured for UDMA/133
[ 5661.942814] brcmsmac bcma0:1: brcms_ops_bss_info_changed: qos enabled: false (implement)
[ 5661.942822] brcmsmac bcma0:1: brcms_ops_config: change power-save mode: false (implement)
[ 5662.002550] tg3 0000:03:00.0 eth1: Link is down
[ 5662.823320] wlan1: authenticate with 00:18:4d:22:98:c4
[ 5662.823401] wlan1: send auth to 00:18:4d:22:98:c4 (try 1/3)
[ 5662.824903] wlan1: authenticated
[ 5662.825933] wlan1: associate with 00:18:4d:22:98:c4 (try 1/3)
[ 5662.829088] wlan1: RX AssocResp from 00:18:4d:22:98:c4 (capab=0x411 status=0 aid=1)
[ 5662.829734] brcmsmac bcma0:1: brcmsmac: brcms_ops_bss_info_changed: associated
[ 5662.829737] brcmsmac bcma0:1: brcms_ops_bss_info_changed: qos enabled: true (implement)
[ 5662.829743] wlan1: associated
[ 5662.832859] brcmsmac bcma0:1: wl0: brcms_c_d11hdrs_mac80211:  txop exceeded phylen 159/256 dur 1778/1504
[ 5662.997851] brcmsmac bcma0:1: wl0: brcms_c_d11hdrs_mac80211:  txop exceeded phylen 137/256 dur 1602/1504
[ 5663.079432] brcmsmac bcma0:1: brcms_ops_bss_info_changed: arp filtering: 1 addresses (implement)
[ 5665.004044] tg3 0000:03:00.0 eth1: Link is up at 1000 Mbps, full duplex
[ 5665.004047] tg3 0000:03:00.0 eth1: Flow control is on for TX and on for RX


Q: Can I connect a PCIe 2.5" SSD to a regular PCIe 3 slot? I'm looking to upgrade my server's storage. It currently has SATA SSD storage but I would like to add to it an even faster PCIe3 SSD. It's a full tower with a few empty PCIe3 slots but no PCIe3 backplane, the motherboard model is Supermicro X9DR3-F. 2.5" PCIe SSDs are significantly cheaper than SSDs with PCIe3 card form factor. Is there a way to add a 2.5" PCIe SSD despite this motherboard not having the right disk backplane?

A: Assuming you are buying U.2 form-factor NVMe SSDs, then you could get something like this PCI adapter card, which let's you fit a 2.5" NVMe SSD into a PCI-e slot.


Q: Calculate the coord of the center of a circle knowing 2 points
Hello, then I need to calculate the center of a circle O knowing 2 points A and B.
I made a drawing because I am not able to explain in english.
Thanks

A: It is impossible, You need at least 3 points to unambiguously define a circle.

A: Since you have 2 points. Randomly choose a third. Then calculate the circle center point.
This solution meets the criteria of the circle going through the original 2 points.


Q: Splitting two lists and assigning data from one list to values in the other and thank you in advance for the help. My problem concerns methods in Python and is as follows.
I have two lists. One list, x, is made up of rows that contain 2 values, x1 and x2, each. The second list, data is made up of rows that contain 3 values, x0, t, and r, each. I split each row accordingly:
for datum in data:
    x0, t, r = data.split()

for item in x:
    x1, x2 = x.split()

Values of x1 and x2 may be found within values of x0. If x1 corresponds to a value of x0, I would like to assign to x1 the values of t and r that also correspond to that x0. I would like to perform this for each x2 as well. The end result will be to make some calculation for each pair of x1 and x2 values using the values t and r.
For example: Say we have two lines from data (x0,t,r):
311 0 2
202 5 13
And we have one line from x (x1,x2):
311 202
In the end I'd like to assign the values 0 and 2 to x1 and 5 and 13 to x2 so that I can make an arbitrary calculation such as y=r1-r2+t1*t2, where r1 is the r value assigned to x1, etc. Note that I would like to be able to calculate this for every row in x.
Thanks again!

A: Build a dictionary from data with the key x0:
dataDictionary = {}
for datum in data:
    x0, t, r = datum.split()
    dataDictionary[x0] = t, r

This allows you to look up values from data based on x0.
Now, when you loop through x, you can get those values and do your calculations:
for item in x:
    x1, x2 = item.split()
    t1, r1 = dataDictionary[x1]
    t2, r2 = dataDictionary[x2]
    y = r1 - r2 + t1 * t2
    print(y)


Q: Showing percentage without decimal using billboardjs on pie chart I am using billboardjs to draw a pie chart .
When pie chart displayed it's shows percentage as 60.0% and  40.0% like that.
I want to display it as 60% and 40% . I don't want to display decimal part .
Any help .

A: You can use toFixed(x) function that allows you to chose the number of decimal after the comma
Source : https://www.w3schools.com/jsref/jsref_tofixed.asp
For example : (42.4).toFixed(0) === 42


Q: OpenLayers 4 hover popup delay I added a function to display a popup on hover to the feature layer but it doesn't work very well.
Here my code:
map.on('pointermove', function(evt) {
  if (evt.dragging) {
    return;
  }

  var info = $('#info');
  info.html("");
  var pixel = map.getEventPixel(evt.originalEvent);
  var feature = map.forEachLayerAtPixel(pixel, function(feature) { return true; }, null, function(layer) { return layer === pmfeatlayer; });
  var viewResolution = map.getView().getResolution();
  var coordinate = evt.coordinate;
  url = pmfeatlayer.getSource().getGetFeatureInfoUrl(coordinate, viewResolution, projection, {'INFO_FORMAT': 'text/html'});

  if (feature && url) {

    info.css({
      left: pixel[0] + 'px',
      top: pixel[1] + 'px'
    });
//    setTimeout(function() {
    var xhttp = new XMLHttpRequest();
    xhttp.open("GET", url, true);
    xhttp.send();
    xhttp.onreadystatechange = function (aEvt) {
      if (xhttp.readyState == 4 && xhttp.status == 200) {

          var parser = new window.DOMParser();
          var res = parser.parseFromString(xhttp.responseText, "text/xml");
          var myitems = res.getElementsByTagName('item');

          if(res.getElementsByTagName('item').length != 0){
            info.html("
" + hover(xhttp.responseText) + "
").delay( 1000 ).fadeIn( 400 );
          } else {
            info.html("");
          }

       } // end if 4 && 200
     }; // end onreadystatechange
 //}, 1000);
   } // end if (feature && url)
 }); // end pointermove

As you can see I'm using map.on('pointermove'... But it's not the exact event, What can I use to detect that the cursor is above the feature layer and it's not moving, for example, .5 seconds?
I tried to add a delay function but still, it doesn't work properly, it made a lot of requests and the popup display buggy due to the delay and the cursor can be on other parts of the map at the time is displayed.

A: You can try a debounce or throttle function to delay the calls for the popup.
A very simple way could look like this:
var stillMoving = [];
function delayPopup() {
    stillMoving.push(true);          // add my call to array

    setTimeout(function() {
        stillMoving.shift();         // remove my call from array

        // check if more calls are pending
        // if yes stop propagation
        if ( stillMoving[ 0 ] ) {
            return;
        }
        else {
            // load the popup here
            loadPopup();
        }
    }, 500);
}

A: There is a simpler method by canceling the delayed execution whenever the mouse is moved again.
var LastTimeoutRequest;
var LastLonLat;

function DisplayInfo(){
    console.log('executed now');
    document.getElementById("pointerposition").innerHTML = '' + LastLonLat + '';
}

map.on('pointermove', function(evt) {
    if (evt.dragging) return;

    if (typeof LastTimeoutRequest !== 'undefined') { // cancel timeout when the mouse moves
        clearTimeout(LastTimeoutRequest);
    }

    LastLonLat = ol.proj.transform(evt.coordinate, 'EPSG:3857', 'EPSG:4326');
    document.getElementById("pointerposition").innerHTML = LastLonLat ;

    LastTimeoutRequest = setTimeout(DisplayInfoAtPosition, 2000);
});

This example will display the mouse postition and turn it in bold it it does not move for 2000 ms.

A: I am doing something similar and found a way to delay based on mouse position:
    $.pixelDistance = 0.01;
    $.pastPixel = undefined;
    map.on('pointermove', function(evt) {
        if (evt.dragging) {
            return;
        }
        var pixel = map.getEventPixel(evt.originalEvent);
        $.pastPixel = pixel;
        setTimeout(function(){
            console.log((pixel=== $.pastPixel));
            if(pixel===$.pastPixel)
            {
                var feature1 = map.forEachLayerAtPixel( $.pastPixel, function(feature1) { return true; }, null, function(layer) { return layer === vector; });
                console.log(feature1); // end if (feature && url)
                console.log( $.pastPixel); // end if (feature && url)
            }
        }, 1000);

    }); // end pointermove


Q: System.Data.DataViewRow showing instead of value Whenever I try to run my program, after selecting dropdownList1 data, the dropdownlist2 populates with System.Data.DataViewRow text rather than populating the values.
I've tried 6 Hrs searching this but didn't find answer.

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
    string s1 = DropDownList1.SelectedValue.ToString();
    string perfectid = string.Empty;
    con.Open();
    SqlDataAdapter sda1 = new SqlDataAdapter("select [Id] from [Table] where movie_name='"+s1+"'",con);
    DataTable dt = new DataTable();
    sda1.Fill(dt);
    GridView g1 = new GridView();
    g1.DataSource = dt;
    g1.DataBind();
    foreach (GridViewRow dr in g1.Rows)
    {
        perfectid = dr.Cells[0].Text;

    }

    SqlDataAdapter sda = new SqlDataAdapter("select song_name from songs where id='" + perfectid + "'", con);
    DataTable dta = new DataTable();
    sda.Fill(dta);

    DropDownList2.DataSource = dta;
    DropDownList2.DataBind();

    con.Close();
}

A: As mentioned in comment:
1] Don't use string concatenation for sql query, use parameterized queries. Check the below code for use of sqlcommand with use of parameters.
2] I've clubbed both the queries using subquery so you only need to connect to database once. [This will work only if there is 1 row returned from the subquery which it should in this case as you are using ID as reference, else use IN operator]
3] Mapping DropDownList2.DataSource = dta; is not sufficient, you need to map DataTextField and DataValueField too to inform exactly which column will be mapped, I've used column ref by index but you can give name too. According to me that's the reason that it's showing System.Data.DataViewRow in dropdown instead of the values.
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
    string s1 = DropDownList1.SelectedValue.ToString();
    string perfectid = string.Empty;
    con.Open();

    SqlCommand cmd = new SqlCommand("select song_name from songs where id=(select [Id] from [Table] where movie_name=@moviename",con);
    cmd.Parameters.AddWithValue("@moviewname", s1);

    SqlDataAdapter sda = new SqlDataAdapter(cmd);
    DataTable dta = new DataTable();
    sda.Fill(dta);
    con.Close();

    DropDownList2.DataSource = dta;
    DropDownList2.DataTextField = dta.Columns[0].ColumnName;
    DropDownList2.DataValueField = dta.Columns[0].ColumnName;
    DropDownList2.DataBind();
}


Q: ActiveRecords returning model object from a join table I have the following DB for a simple flash cards example i'm building:
create_table "card_associations", :force => true do |t|
  t.integer  "card_id"
  t.integer  "deck_id"
end

create_table "cards", :force => true do |t|
  t.string   "question"
  t.string   "answer"
end

create_table "decks", :force => true do |t|
  t.string   "name"
  t.string   "description"
end

I've setup the has_many through relationships in all my models.
Now I want to be able to return a list of all cards from the join table, given the deck id.
If I run the query:

CardAssociation.find_by_deck_id(3).card

It retruns the first card with the deck_id of 3. But when I try.

CardAssociation.find_all_by_deck_id(3).card

I get the error

NoMethodError: undefined method `card' for #

Can someone help me with this? I feel like i'm making a very simple mistake.
Thanks for the help

A: The find_all_* methods always return an Array (which could be empty)!
CardAssociation.find_all_by_deck_id(3) # => Array of results
CardAssociation.find_all_by_deck_id(3).first # => first result of the Array or nil if no result

I advise you to first read the Ruby on Rails Style Guide, and then use the Rails3 way of finding object with ActiveRecord:
CardAssociation.where(:deck_id => 3) # => Array of results
CardAssociation.where(:deck_id => 3).first # => first result of the Array if exists

In your case, a scope can be set up on the Card model:
You said: "Now I want to be able to return a list of all cards from the join table, given the deck id"
class Card < ActiveRecord::Base
  scope :for_deck, lambda { |deck| joins(:card_associations).where('card_associations.deck_id = ?', deck.try(:id) || deck) }
end

This scope can be used like following:
Card.for_deck(deck) # returns an Array of Card objects matching the deck.id

As defined in the scope, the parameter of Card.for_deck(deck) can be a deck object or a deck_id (type Integer)
Hope this helped!


Q: CS50 pset4 blur function - trouble figuring out why the tests fails on 3x3 and 4x4 images I've been working on the code for CS50 pset4 blur function.
the function is suppose to calculate the average RGB values of all neighboring pixels, and then apply it to the "middle" pixel (as the pixel can be located on the corners, edges, or anywhere in the middle)
I get no errors when compiling or running the code.
the output images all appear blurred, but when i run the code against check50, it fails on two tests:
:( blur correctly filters 3x3 image
    expected "70 85 95\n80 9...", not "70 85 95\n80 9..."
:( blur correctly filters 4x4 image
    expected "70 85 95\n80 9...", not "70 85 95\n80 9..."

The other tests pass (testing pixel on edge, corner and middle), so i'm having a hard time understanding what i'm doing wrong.
Here's my code:
// Blur image
void blur(int height, int width, RGBTRIPLE image[height][width])
{
    // creating a blank copy
    RGBTRIPLE blured[height][width];

    // upper left corner (anchored)
    for (int i = 0; i < 1; i++)
    {
        for (int j = 0; j < 1; j++)
        {
            float trackerRed = 0, trackerGreen = 0, trackerBlue = 0;
            for (int k = i; k <= i + 1; k++)
            {
                for (int l = j; l <= j + 1; l++)
                {
                    trackerRed += (float)image[k][l].rgbtRed;
                    trackerGreen += (float)image[k][l].rgbtGreen;
                    trackerBlue += (float)image[k][l].rgbtBlue;
                }
            }
            blured[i][j].rgbtRed = round(trackerRed / 4);
            blured[i][j].rgbtGreen = round(trackerGreen / 4);
            blured[i][j].rgbtBlue = round(trackerBlue / 4);
        }
    }
    // top middle row
    for (int i = 0; i < 1; i++)
    {
        for (int j = 1; j < width - 1; j++)
        {
            float trackerRed = 0, trackerGreen = 0, trackerBlue = 0;
            for (int k = i; k <= i + 1; k++)
            {
                for (int l = j - 1; l <= j + 1; l++)
                {
                    trackerRed += (float)image[k][l].rgbtRed;
                    trackerGreen += (float)image[k][l].rgbtGreen;
                    trackerBlue += (float)image[k][l].rgbtBlue;
                }
            }
            blured[i][j].rgbtRed = round(trackerRed / 6);
            blured[i][j].rgbtGreen = round(trackerGreen / 6);
            blured[i][j].rgbtBlue = round(trackerBlue / 6);
        }
    }
    // upper right corner (anchored)
    for (int i = 0; i < 1; i++)
    {
        for (int j = width - 1; j < width; j++)
        {
            float trackerRed = 0, trackerGreen = 0, trackerBlue = 0;
            for (int k = i; k <= i + 1; k++)
            {
                for (int l = j - 1; l <= j; l++)
                {
                    trackerRed += (float)image[k][l].rgbtRed;
                    trackerGreen += (float)image[k][l].rgbtGreen;
                    trackerBlue += (float)image[k][l].rgbtBlue;
                }
            }
            blured[i][j].rgbtRed = round(trackerRed / 4);
            blured[i][j].rgbtGreen = round(trackerGreen / 4);
            blured[i][j].rgbtBlue = round(trackerBlue / 4);
        }
    }
    // left middle column
    for (int i = 1; i < height - 1; i++)
    {
        for (int j = 0; j < 1; j++)
        {
            float trackerRed = 0, trackerGreen = 0, trackerBlue = 0;
            for (int k = i - 1; k <= i + 1; k++)
            {
                for (int l = j; l <= j + 1; l++)
                {
                    trackerRed += (float)image[k][l].rgbtRed;
                    trackerGreen += (float)image[k][l].rgbtGreen;
                    trackerBlue += (float)image[k][l].rgbtBlue;
                }
            }
            blured[i][j].rgbtRed = round(trackerRed / 6);
            blured[i][j].rgbtGreen = round(trackerGreen / 6);
            blured[i][j].rgbtBlue = round(trackerBlue / 6);
        }
    }
    // center
    for (int i = 1; i < height - 1; i++)
    {
        for (int j = 1; j < width - 1; j++)
        {
            float trackerRed = 0, trackerGreen = 0, trackerBlue = 0;
            for (int k = i - 1; k <= i + 1; k++)
            {
                for (int l = j - 1; l <= j + 1; l++)
                {
                    trackerRed += (float)image[k][l].rgbtRed;
                    trackerGreen += (float)image[k][l].rgbtGreen;
                    trackerBlue += (float)image[k][l].rgbtBlue;
                }
            }
            blured[i][j].rgbtRed = round(trackerRed / 9);
            blured[i][j].rgbtGreen = round(trackerGreen / 9);
            blured[i][j].rgbtBlue = round(trackerBlue / 9);
        }
    }
    // right middle column
    for (int i = 1; i < height - 1; i++)
    {
        for (int j = width - 1; j < width; j++)
        {
            float trackerRed = 0, trackerGreen = 0, trackerBlue = 0;
            for (int k = i - 1; k <= i + 1; k++)
            {
                for (int l = j; l <= j; l++)
                {
                    trackerRed += (float)image[k][l].rgbtRed;
                    trackerGreen += (float)image[k][l].rgbtGreen;
                    trackerBlue += (float)image[k][l].rgbtBlue;
                }
            }
            blured[i][j].rgbtRed = round(trackerRed / 6);
            blured[i][j].rgbtGreen = round(trackerGreen / 6);
            blured[i][j].rgbtBlue = round(trackerBlue / 6);
        }
    }
    // lower left corner (anchored)
    for (int i = height - 1; i < height; i++)
    {
        for (int j = 0; j < height; j++)
        {
            float trackerRed = 0, trackerGreen = 0, trackerBlue = 0;
            for (int k = i - 1; k <= i; k++)
            {
                for (int l = j; l <= j + 1; l++)
                {
                    trackerRed += (float)image[k][l].rgbtRed;
                    trackerGreen += (float)image[k][l].rgbtGreen;
                    trackerBlue += (float)image[k][l].rgbtBlue;
                }
            }
            blured[i][j].rgbtRed = round(trackerRed / 4);
            blured[i][j].rgbtGreen = round(trackerGreen / 4);
            blured[i][j].rgbtBlue = round(trackerBlue / 4);
        }
    }
    // bottom middle row
    for (int i = height - 1; i < height; i++)
    {
        for (int j = 1; j < width - 1; j++)
        {
            float trackerRed = 0, trackerGreen = 0, trackerBlue = 0;
            for (int k = i - 1; k <= i; k++)
            {
                for (int l = j - 1; l <= j + 1; l++)
                {
                    trackerRed += (float)image[k][l].rgbtRed;
                    trackerGreen += (float)image[k][l].rgbtGreen;
                    trackerBlue += (float)image[k][l].rgbtBlue;
                }
            }
            blured[i][j].rgbtRed = round(trackerRed / 6);
            blured[i][j].rgbtGreen = round(trackerGreen / 6);
            blured[i][j].rgbtBlue = round(trackerBlue / 6);
        }
    }
    // lower right corner (anchored)
    for (int i = height - 1; i < height; i++)
    {
        for (int j = width - 1; j < width; j++)
        {
            float trackerRed = 0, trackerGreen = 0, trackerBlue = 0;
            for (int k = i - 1; k <= i; k++)
            {
                for (int l = j - 1; l <= j; l++)
                {
                    trackerRed += (float)image[k][l].rgbtRed;
                    trackerGreen += (float)image[k][l].rgbtGreen;
                    trackerBlue += (float)image[k][l].rgbtBlue;
                }
            }
            blured[i][j].rgbtRed = round(trackerRed / 4);
            blured[i][j].rgbtGreen = round(trackerGreen / 4);
            blured[i][j].rgbtBlue = round(trackerBlue / 4);
        }
    }

    // copy blured image data back to the original image
    for (int i = 0; i < height; i++)
    {
        for (int j = 0; j < width; j++)
        {
            image[i][j].rgbtRed = blured[i][j].rgbtRed;
            image[i][j].rgbtGreen = blured[i][j].rgbtGreen;
            image[i][j].rgbtBlue = blured[i][j].rgbtBlue;
        }
    }
    return;
}

Any help is much appreciated

A: I'm also in the class so this might be completely wrong but this is what I saw:
// right middle column
for (int l = j; l <= j; l++)

Your for loop for the int l doesn't seem like it's correct. Shouldn't there be 2 columns?
// lower left corner (anchored)
for (int j = 0; j < height; j++)

j should be width but since its a corner based on your previous code I think it should be 1


Q: Java Streams Map, Get Value - List from Key (With filtering) Assuming I'm writing a method that takes in Map<String, List<Integer>> as shown below, and a String name to filter. My return type is Stream<Integer> how do I convert from a Stream<List<Integer>> to Stream<Integer>?
Map<String, List<Integer>> person = Map.of(
    "John", List.of(54, 18),
    "Alex", List.of(28), "Tom",
    List.of(78, 42)
);

My current implementation returns a Stream<List<Integer>>. Realistically, I would iterate through the list to retrieve all Integers in the list.
Code implementation:
return table.entrySet().stream()
    .filter(map -> map.getKey().equals(name))
    .map(map -> map.getValue());

A: As @Thomas has pointed out in the comments, iterating over the whole Map would be wasteful. And solution he proposed probably is the cleanest one:
map.getOrDefault(name, Collections.emptyList()).stream()

Alternatively, you can make use of flatMap() without performing redundant iteration through the whole map like that:
public static <K, V> Stream<V> getStreamByKey(Map<K, Collection<V>> map,
                                              K key) {

    return Stream.ofNullable(map.get(key))
        .flatMap(Collection::stream);
}

The same result can be achieved with Java 16 mapMulti():
public static <K, V> Stream<V> getStreamByKey(Map<K, Collection<V>> map,
                                              K key) {

    return Stream.ofNullable(map.get(key))
        .mapMulti(Iterable::forEach);
}

A: As others pointed out in comments, use flatMap instead of map in the last step to reduce the double nesting:
return table.entrySet().stream()
    .filter(map -> map.getKey().equals(name))
    .flatMap(entry -> entry.getValue().stream());


Q: Angle of reflection on 3d Object I am rasterizing some 3d objects (x,y,z) onto a 2d plane (x,y) and I want to color the rasterized cells based on the angle of reflection of an angle of incidence that comes from directly above the centroid (as seen in diagram).
How do I calculate the angle of reflection on the X,Y plane given a 3d line of incidence and a 3d polygon?
[


Q: Thevenin equivalent or mesh-current in a diode circuit I've been stuck on a problem for a couple days and many hours now and see no other option than to ask here and see if you can help me or give me a lead.
What I have been stuck on is this:

My initial solution for finding out the current through the diode has been to apply Thévenin equivalent where I first solve the Thévenin resistance according to:

The two resistors are in parallel where the voltage sources are shorted, the diode is open, and the Thévenin resistance is 10/7 kilo Ohm.
Then I got Thévenin voltage by taking 5V - 2V = 3V.
(Vth - Vt) / Rth = I (diode) -----> (3 - 0,7)/ (10/7) = 1.61 mA
The solution is supposed to be 1.5 mA. I am not sure what I did wrong here. I also tried the mesh-current method but I got strange numbers. What do you think?

A: The Thevenin voltage isn't \$3\:\text{V}\$, though it's not terribly far from it. There are a variety of ways to compute it but none of them look like what you did.
One way to think about solving for it is to just look at the current magnitude that would exist between the \$2\:\text{V}\$ and \$5\:\text{V}\$ sources, via the two series resistors. This current would be \$\frac{5\:\text{V}-2\:\text{V}}{2\:\text{k}\Omega+5\:\text{k}\Omega}=\frac37\:\text{mA}\$. That current, times \$2\:\text{k}\Omega\$, is the voltage that must be added to \$2\:\text{V}\$ to get the Thevenin voltage where the two resistors meet. This is \$2\:\text{V}+\frac37\:\text{mA}\cdot 2\:\text{k}\Omega=2\frac67\:\text{V}\$.
The Thevenin resistance is the two resistors taken in parallel, or \$1\frac37\:\text{k}\Omega\$, just as you said it is.
All you now need to do is subtract \$700\:\text{mV}\$ from your Thevenin voltage and then divide that result by the resistance to work out the current.
P.S. I use a different method to compute the Thevenin voltage in a divider like this: \$V_{_\text{TH}}=\frac{V_1\cdot R_2+V_2\cdot R_1}{R_1+R_2}\$. In your case, that would look like this: \$V_{_\text{TH}}=\frac{2\:\text{V}\,\cdot\, 5\:\text{k}\Omega+5\:\text{V}\,\cdot\, 2\:\text{k}\Omega}{2\:\text{k}\Omega+5\:\text{k}\Omega}=2\frac67\:\text{V}\$. It's just short-hand for the same process used, earlier.

A: The current through the diode is the sum of the currents through the two resistors.
ID = (2-0.7)/2k + (5-0.7)/5k = 1.51mA

A:
Well, let's make a mathematical closed solution. I know that this is maybe above the OP's knowledge, but I think it is important to show it in combination with the other answers given.

The Shockley diode equation, gives the relation between the voltage across and the current trough a diode:
$$\text{I}_\text{D}=\text{I}_\text{S}\left(\exp\left(\frac{\text{q}\text{V}_\text{D}}{\eta\text{k}\text{T}}\right)-1\right)\tag1$$
We are trying to analyze the following circuit:

simulate this circuit – Schematic created using CircuitLab
When we use and apply KCL, we can write the following set of equations:
$$\text{I}_3=\text{I}_1+\text{I}_2\tag2$$
When we use and apply Ohm's law, we can write the following set of equations:
$$
\begin{cases}
\text{I}_1=\frac{\text{V}_1-\text{V}_3}{\text{R}_1}\\
\\
\text{I}_2=\frac{\text{V}_2-\text{V}_3}{\text{R}_2}\\
\\
\text{I}_3=\text{I}_\text{S}\left(\exp\left(\frac{\text{q}\text{V}_3}{\eta\text{k}\text{T}}\right)-1\right)
\end{cases}\tag3
$$
Substitute \$(3)\$ into \$(2)\$, in order to get:
$$\text{I}_\text{S}\left(\exp\left(\frac{\text{q}\text{V}_3}{\eta\text{k}\text{T}}\right)-1\right)=\frac{\text{V}_1-\text{V}_3}{\text{R}_1}+\frac{\text{V}_2-\text{V}_3}{\text{R}_2}\tag4$$
For the LED, let's use parameters taken from a Luminus PT-121-B LED: \$\eta=8.37\$, and \$\text{I}_\text{S}=435.2\:\text{nA}\$. (Assume \$\text{V}_\text{T}:=\frac{\text{kT}}{\text{q}}=\frac{8094745087}{320435326800}\approx0.0252617\:\text{V}\$, of course.)
Using the known values, we find:

*

*$$\text{V}_3\approx1.60818\space\text{V}\tag5$$

*$$\text{I}_3\approx0.000874272\space\text{A}\tag6$$
I used Mathematica to find it, with the following code:
In[1]:=Clear["Global`*"];
q = ((1602176634/(10^9)))*10^(-19);
k = ((1380649/(10^6)))*10^(-23);
T = 20 + ((5463)/20);
Is = (4352/10)*10^(-9);
\[Eta] = 837/100;
V1 = 2;
V2 = 5;
R1 = 2*1000;
R2 = 5*1000;
FullSimplify[
 Solve[{I3 == I1 + I2, I1 == (V1 - V3)/R1, I2 == (V2 - V3)/R2,
   I3 == Is*(Exp[(q*V3)/(\[Eta]*k*T)] - 1),
   I1 > 0 && I2 > 0 && I3 > 0 && V3 > 0}, {I1, I2, I3, V3}]]

Out[1]={{I1 -> (-46909 + (
    131741976290925 ProductLog[(
      387370706176 E^(1780583630706176/131741976290925))/
      131741976290925])/11393256064)/109375000,
  I2 -> 234307/546875000 + (
    752811293091 ProductLog[(
      387370706176 E^(1780583630706176/131741976290925))/
      131741976290925])/17801962600000000,
  I3 -> (17 (-1 + (
      131741976290925 ProductLog[(
        387370706176 E^(1780583630706176/131741976290925))/
        131741976290925])/387370706176))/39062500,
  V3 -> 312568/109375 - (
    752811293091 ProductLog[(
      387370706176 E^(1780583630706176/131741976290925))/
      131741976290925])/3560392520000}}

In[2]:=N[%1]

Out[2]={{I1 -> 0.000195909, I2 -> 0.000678363, I3 -> 0.000874272,
  V3 -> 1.60818}}

Note: when we use the voltage drop of \$0.7\space\text{V}\$ and the characteristics of the Luminus PT-121-B LED at room temperature on the Shockley diode equation, we get the following current flow trough the diode:
$$\text{I}_3=\text{I}_\text{S}\left(\exp\left(\frac{\text{q}\cdot\frac{7}{10}}{\eta\text{k}\text{T}}\right)-1\right)=$$
$$\frac{17}{39062500}\cdot\left(\exp\left(\frac{2492274764000}{752811293091}\right)-1\right)\approx0.0000114902\space\text{A}\tag7$$


Q: C++ Binary Read Write Files ok so im on the 2nd Semester on my unversity have done c and doing c++ now
doing the project in DevC.
Currently im making a program that will do the charging processes of a shop while having and editing the database.
Tried writing and reading a full struct but dosent work so i went down writing 2 int numbers and reading them but this also dosent work while getting random number when reading even though if i write txt the numbers seem ok.
//write and read are different fucntion only 1 is called .
//file creation code
int AccountNumber=0;
ofstream FileCreator("Database.dat",ios::binary);
FileCreator<<AccountNumber;
AccountNumber=1;
FileCreator<<AccountNumber;

and
//reading code

int AccountNumber=0;
ifstream FileCreator("Database.dat",ios::binary);
FileCreator.seekg(0,ios::beg);

FileCreator.read(reinterpret_cast<char*>(&AccountNumber), sizeof(AccountNumber));
cout<<AccountNumber<<endl;
FileCreator.read(reinterpret_cast<char*>(&AccountNumber), sizeof(AccountNumber));
cout<<AccountNumber<<endl;

I expect 0 and 1 at the output but get 12592 and 12592.

A: To complete the answer of @Thomas Matthews

but why does it matter ? does << write differently that .write in binary files ?

Out of windows you will not see a difference, under windows the \n are saved/read unchanged if the file open in binary mode, else a writting \n produces \r\n and reading \c\n returns \n. It like the difference between "r"/"rb" and "w"/"wb" for fopen.
You can mix the use of the operator <</>> and read/write in binary mode or not but you have to take care of the separators, for instance :
#include <iostream>
#include <fstream>

using namespace std;

int main()
{
  int AccountNumber = 123;

  {
    ofstream bin("bin",ios::binary);

    bin << AccountNumber << '\n'; // a \n to finish the number allowing to read it later
    bin.write((char *) &AccountNumber, sizeof(AccountNumber));
  }
  {
    ofstream txt("txt");

    txt << AccountNumber << '\n';
    txt.write((char *) &AccountNumber, sizeof(AccountNumber));
  }
  {
    ifstream bin("bin",ios::binary);

    AccountNumber = 0;
    bin >> AccountNumber;
    cout << AccountNumber << endl;

    // I have to read the \n with read() because >> bypass it.
    // Supposing I written '@' rather than '\n' `bin >> c;` can be used
    char c;

    bin.read(&c, 1);
    cout << (int) c << endl;

    AccountNumber = 0;
    bin.read((char *) &AccountNumber, sizeof(AccountNumber));
    cout << AccountNumber << endl;
  }

  return 0;
}

Compilation and execution (out of Windows) :
pi@raspberrypi:/tmp $ g++ -pedantic -Wextra -Wall f.cc
pi@raspberrypi:/tmp $ ./a.out
123
10
123
pi@raspberrypi:/tmp $ cmp txt bin
pi@raspberrypi:/tmp $

I am not under Windows so to use the binary mode or not changes nothing, the two files are identical

A: For writing binary files, use std::ostream::write() method, not operator<<:
FileCreator.write((char *) &AccountNumber, sizeof(AccountNumber));

The cast is necessary because there is no overload for writing integers to the stream.
Remember, read and write are paired for binary I/O.
Edit 1: Fixed length & variable length records
Be aware that you need the size of the item when writing and reading.  This will work for fixed size/length data items and structures.  However, it does not work well with variable length data, such as text.
For variable length records, you may want to write the length first followed by the data:
static const char hello[] = "Hello";
static const unsigned int data_size(sizeof(hello) - 1);
FileCreator.write((char *) &data_size, sizeof(data_size));
FileCreator.write(&hello[0], data_size);

In the above example, the "- 1" is there so that the terminating NUL character is not written to the file.  You don't need this for binary files, but YMMV (I use the idiom when writing to console and other human readable streams).


Q: Data Annotation MVC How can I add a required field ONLY if I have a value in my username model.
I have:
@Html.PasswordFor(
    model => model.Password,
    new { required = "This field is required" }
)

I want :
@Html.PasswordFor(
    model => model.Password,
    new { if (Model.UserName != null) {required = "This field is required"} }
)

Thank you

A: Well instead of using an if statement, you can always use the ternary operator ?:
@Html.PasswordFor(
    model => model.Password,
    new { required = Model.UserName != null ? "This field is required" : null }
)

Alternatively (if setting required as null does not work) then you could use it one level up:
@Html.PasswordFor(
    model => model.Password,
    Model.UserName != null
        ? new { required = "This field is required" }
        : new { }
)

A: You can simply use
if(Model.UserName != null)
{
    @Html.PasswordFor(model => model.Password, new { required = "This fiels is required"})
}
else
{
    @Html.PasswordFor(model => model.Password)
}

Why do you need to complicate thing?


Q: Derivative of a function $f({\bf X})$ w.r.t. matrix ${\bf X}$ when ${\bf X}^\prime {\bf X}$ is a diagonal matrix I wish to compute the derivative and the Hessian of the function ${\bf f}(X)$ where
$$ {\bf f}({\bf X}) = {\bf X} \, {\bf a}, $$
${\bf X}$ is an $(m \times n)$ matrix and ${\bf a}$ is a vector of constants of size $n$. From "Matrix Differential Calculus" by Magnus and Neudecker, it is relatively straightforward to obtain the derivative and the Hessian of ${\bf f}({\bf X})$ w.r.t. ${\bf X}$. For example, the first differential is
\begin{align}
\partial {\bf f}({\bf X}) &= (\partial {\bf X}) {\bf a} = {\rm vec} (\partial {\bf X}) {\bf a} = ({\bf a}^\prime \otimes {\bf I}_m) \,\partial {\rm vec}  {\bf X} \\
\end{align}
In my case however the matrix ${\bf X}$ has a special structure. Specifically, I know that that ${\bf X}^\prime {\bf X}$ is a diagonal matrix, say, ${\bf X}^\prime {\bf X} = {\rm diag}(d_1, \ldots, d_n)$, which is not necessarily equal to the identity matrix. In other words, I know that the columns of ${\bf X}$ are mutually orthogonal, but each column vector can be of any length. How do I compute the derivative and the Hessian of $f({\bf X})$ w.r.t. ${\bf X}$ to take this structure into account?
Any references on how to proceed would be greatly appreciated.
I could not find a similar question posted before. The closest I found was Hessian of $f(X)$ when $X$ is a symmetric matrix, but I was not able to apply it to my problem.

A: $\def\p{\partial}$
Use an orthogonal matrix $Q$ and a vector $y$ to construct $X$
$$\eqalign{
Y &= {\rm Diag}(y) &\;=\; \sqrt{X^TX} \\
X &= QY  &\implies X^TX = YQ^TQY = Y^2 \\
Q &= X(X^TX)^{-1/2} \\
}$$
Also define the diagonal matrix $\;A = {\rm Diag}(a)$.
Write the function in terms of these new variables
and calculate its gradient.
$$\eqalign{
f &= Xa = QYa = QAy\\
\p f &= QA\,\p y \\
\frac{\p f}{\p y} &= QA \\
}$$
This can be interpreted as a gradient wrt $X$ by using
$$\eqalign{
\p{\rm vec}(X) &= (I\otimes Q)\,{\rm vec}\Big({\rm Diag}(\p y)\Big) \\
}$$


Q: Call function only once after page load completely I want to call function one second after the page is completely loaded
$(window).bind("load", function() {
  window.setInterval(function(){ your_func(); }, 1000);
});

It calls every second. I want it to be executed only once

A: You can use $(document).ready();
$(document).ready(function() {
  setTimeout(function() { your_func(); }, 1000);
});

A: You may use $( document ).ready(); for that problem:
$( document ).ready(function() {
    setTimeout(function() { console.log( "ready!" ); }, 1000);

});

A: Your solution works well, don't need to change to document ready
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
    $(window).bind("load", function() {
        setTimeout(function() {
            console.log('Hey');
     }, 1000);
    });
</script>

Notice the differences between the events:
The ready event occurs after the HTML document has been loaded, while the onload event occurs later, when all content (e.g. images) also has been loaded.


Q: No se accede a la posición correcta del array en un bucle Estoy intentando hacer una función que tome el valor de x, donde x es la posición. Por ejemplo:

*

*1 = oro

*2 = plata

*3 = bronce

Y que en las demás posiciones sea 0 ó cualquier número posterior a 3 diga "nada". Éste es el código que tengo:

var array = ["oro", "plata", "bronce"]

function medallaSegunPuesto(x) {
  for (var i = 0; i < array.length; i++) {
    if (i == (x - 1)) {
      return array[i];
    } else {
      return "nada";
    }
  }
}

console.log(medallaSegunPuesto(3));

El problema es que al poner el else no me reconoce la posición 2 ni 3. ¿Sugerencias?

A: No necesitas un bucle.  Simplemente chequea que el valor se encuentre en el rango indicado, sino retornas "nada".  Algo asi:

var array = ["oro","plata", "bronce"]

function medallaSegunPuesto(x){
    if(x>0 && x<=array.length){
      return array[x-1];
    }else {return "nada";}
}
console.log(medallaSegunPuesto(3));

A: Me parece que es mas simple aún usando el o lógico ||.

var array = ["oro","plata", "bronce"]

const medallaSegunPuesto = (x)=>(array[x-1] || "nada");

console.log(medallaSegunPuesto(3));
console.log(medallaSegunPuesto(43));
console.log(medallaSegunPuesto(-1));

A: Aunque tienes ya soluciones correctas (y mejores que usar un bucle). Voy a poner la raíz del problema (aunque me imagino que ya la sabes) y una posible solución (aunque sería más sencillo y eficiente optar por otra de las respuestas).
El problema está en el if...else, que devuelve valores tanto en el if como en el else. Eso quiere decir que si el valor es 1 se va a devolver "oro", pero para cualquier otro valor, se va a entrar en el else y devolver "nada" sin siquiera comprobar el resto de los índices.
Para solucionar esto podrías quitar el else y mover el return "nada" justo después del bucle for:

var array = ["oro", "plata", "bronce"]

function medallaSegunPuesto(x) {
  for (var i = 0; i < array.length; i++) {
    if (i == (x - 1)) {
      return array[i];
    }
  }
  return "nada";
}

console.log(medallaSegunPuesto(3));

De nuevo, esta solución no es la mejor ni la manera rápida de resolver el problema. Pero podría ser útil si en lugar de iterar un array estuvieras iterando sobre los índices de un objeto (aunque seguramente también hay soluciones mejores en ese caso).


Q: A question on the basic properties of Thompson subgroup of a group For any finite group $P$ let $d(P)$ be the minimum number of generators of $P$. Let $m(P)$ be the maximum of the integers $d(A)$ as $A$ runs over all abelian subgroups of $P$. Define$J(P)=\langle A$ s.t. $A$ is an abelian subgroup of $P$ with $d(A)=m(P)\rangle$, called the Thompson subgroup of $P$. (Sec. 4.4, Ex. 20 of Abstract Algebra: Dummit & Foote)
For example, let $\operatorname{QDih}=\langle r,s$ s.t. $r^8=s^2=1, rs=sr^3\rangle$ be the quasidihedral group of order $16$. Then $d(\operatorname{QDih})=2$. All but three subgroups of $\operatorname{QDih}$ are abelian. They are $\langle s,r^2\rangle\cong \operatorname{Dih}(4)$ dihedral group, $\langle sr,r^2\rangle \cong \operatorname{Q}(8)$ quaternion group, and $\operatorname{QDih}$ itself. $d(\langle s,r^4\rangle)=d(\langle sr,r^4\rangle)=2$, the maximum possible, and so $m(\operatorname{QDih})=2$. $$J(\operatorname{QDih})=\langle\langle s,r^4\rangle,\langle sr,r^4\rangle\rangle=\langle s,r^2\rangle\cong \operatorname{Dih}(4)$$
If you're still confused, you may check that $J(\operatorname{Alt}(4))=\langle(12)(34),(13)(24)\rangle$, the unique subgroup of order $4$.
I want to :

-prove that $J(P)\unlhd^{\operatorname{char}} P$,
  -and that if $J(P)\le Q\le P$, then $J(P)=J(Q)$. Deduce that if $P\le G$ and $J(P)\le Q\le P$ s.t. $Q\unlhd G$, then $J(P)\unlhd G$.

There are only a few useful examples to illustrate these facts and give us useful information. In reality, $J(\operatorname{Q}(8))=\operatorname{Q}(8)$, $J(\operatorname{Dih}(4))=\operatorname{Dih}(4)$, and $J(\operatorname{Dih}(8))=\operatorname{Dih}(8)$. I call them 'useless' groups.
Regarding the first statement, what I think is that since for all $\sigma\in \mathrm A\mathrm u\mathrm t(P)$, $\sigma$ preserves the subgroup structure, and the min. no. of generators a subgroup has, if $A$ is an abelian subgroup of $P$ with $d(A)=m(P)$, then $d(\sigma(A))=m(P)$ also. So in some sense, $\sigma$ 'permutes' the abelian subgroups of $P$ which have max. of min. no. of generators possible. So $\sigma(J(P))=<\sigma(A)>=J(P)$. i.e. $J(P)\unlhd^{\operatorname{char}} P$(?)
Suppose it's true that if $J(P)\le Q\le P$, then $J(P)=J(Q)$.
If $P\le G$ and $J(P)\le Q\le P$ s.t. $Q\unlhd G$, then $J(Q)\unlhd^{\operatorname{char}}Q\unlhd G$. So $J(P)=J(Q)\unlhd G$.
But I couldn't prove the 'if $J(P)\le Q\le P$, then $J(P)=J(Q)$' in the first place since there's no 'useful' group for me to work with. Can somebody help?

A: Observe that $J(P) \subseteq Q$ is given. It means that it is generated by Abelian groups of $Q$ which has $d(A)=m(P)$. But what is $m(Q)$? $m(Q)=max \{\ d(A) |A $runs over all abelian subgroups of Q $ \}\ $. Also $m(P) \geq m(Q)$. This implies that those abelian subgroups that generate $J(P)$ for those we have $d(A)=m(Q)=m(P)$. Hence $J(P)$ and $J(Q)$ are generated by same Abelian subgroups of Q and hence $J(P)=J(Q)$.


Q: how can i add a slection model checkbox in angular-table Angular Table creation code with input type checkbox.

angular.module("tableApp",[]).controller('tableAppCtrl', ['$scope',
  function($scope) {
    $scope.titleString="Table Demo";
    $scope.prodDataTable = [{
      "productType": "A",
      "productName": "Aaaaaa"
    }, {
      "productType": "B",
      "productName": "Bbbbbb"
    }, {
      "productType": "C",
      "productName": "Cccccc"
    }];
  }
]);

{{titleString}}

    <input type="button" value="checkALL">
    Product Type
 Product Name

    <input type="checkbox">
    {{d.productType}}
    {{d.productName}}

I have been using angular-table and I have to include a selection model to it.
Please suggest ways or links to use it with table.

A: use this but you need to work on the duplicate value creation-

{{titleString}}

    <input type="button" value="{{(selectAllval==true) ? 'UncheckALL' : 'checkALL'}}" ng-click="selectAll(selectAllval)">
    Product Type
 Product Name

    <input type="checkbox" ng-checked="selectAllval" ng-click="setProductType(d.productType)">
    {{d.productType}}
    {{d.productName}}

{{setProductTypes}}

angular.module("tableApp",[]).controller('tableAppCtrl', ['$scope', function($scope) {
    $scope.titleString="Table Demo";
    $scope.selectAllval= false;
    $scope.setProductTypes= [];
    $scope.selectAll= function(val){
        if(val==false){
            $scope.selectAllval= true;
        } else{
            $scope.selectAllval= false;
        }
    };
    $scope.setProductType= function(type){
        $scope.setProductTypes.push(type);
    };
    $scope.prodDataTable = [{ "productType": "A", "productName": "Aaaaaa" }, { "productType": "B", "productName": "Bbbbbb" }, { "productType": "C", "productName": "Cccccc" }]; } ]);

A: try the below code -

angular.module("tableApp",[]).controller('tableAppCtrl', ['$scope',
 function($scope) {
  $scope.titleString="Table Demo";
  $scope.selectAllval= false;
  $scope.selectAll= function(val){
 if(val==false){
  $scope.selectAllval= true;
 } else{
  $scope.selectAllval= false;
 }
  };
  $scope.prodDataTable = [{
  "productType": "A",
  "productName": "Aaaaaa"
  }, {
  "productType": "B",
  "productName": "Bbbbbb"
  }, {
  "productType": "C",
  "productName": "Cccccc"
  }];
 }
]);

{{titleString}}

     <input type="button" value="{{(selectAllval==true) ? 'UncheckALL' : 'checkALL'}}" ng-click="selectAll(selectAllval)">
     Product Type
  Product Name

     <input type="checkbox" ng-checked="selectAllval" >
     {{d.productType}}
     {{d.productName}}


Q: Render image in mtlView with Metal Api help me figure out the metal api, I want to render the normal picture via mtlView, but it does not work for me, here's my code, what am I doing wrong? Next, I would like to use the UISlider and CIColorControls to change the contrast of this picture in 60fps, please explain.
import MetalKit

class ViewController: UIViewController, MTKViewDelegate {

    let device = MTLCreateSystemDefaultDevice()
    let colorSpace = CGColorSpaceCreateDeviceRGB()

    lazy var commandQueue: MTLCommandQueue = {
        [unowned self] in

        return self.device!.makeCommandQueue()
        }()!

    lazy var ciContext: CIContext = {
        [unowned self] in

        return CIContext(mtlDevice: self.device!)
        }()

    @IBOutlet weak var mtlView: MTKView!
    let filter = CIFilter(name: "CIPhotoEffectProcess" )
    let contrastFilter = CIFilter(name: "CIColorControls")
    var image = CIImage()

    @IBOutlet weak var slider: UISlider!

    override func viewDidLoad() {
        super.viewDidLoad()
        mtlView.delegate = self

        let img = UIImage(named: "picture")
        let ciImage = CIImage(image: img!)
        image = ciImage!
    }

    func mtkView(_ view: MTKView, drawableSizeWillChange size: CGSize) {

    }

    func draw(in view: MTKView) {
        guard let targetTexture = view.currentDrawable?.texture else {
            return
        }

        let commandBuffer = commandQueue.makeCommandBuffer()

        let bounds = CGRect(origin: CGPoint.zero, size: view.drawableSize)

        ciContext.render(image,
                         to: targetTexture,
                         commandBuffer: commandBuffer,
                         bounds: bounds,
                         colorSpace: colorSpace)

        commandBuffer?.present(view.currentDrawable!)
        commandBuffer?.commit()
    }
}

A: I don't see any code that would set device to the MTKView. An MTKView without a device would be returning empty drawable. I'd suggest adding this to the viewDidLoad:
mtlView.device = device


Q: Performing calculations on a set of values in a pandas data frame with respect to a certain attribute I have to find the year with the best average user rating. My approach is to find all the unique values in the Year column and then find the mean of all the values in the User Rating columns that correspond to those unique values.
I have managed to find unique occurrences in the Year column and have stored them in a list using:
import numpy as np

years = df.['Year'].unique()
years = np.sort(years)
print(years)

Output: [2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019]

I have to find mean value of User Ratings for each of these year values and then display which year has the best average User Rating. Can anyone help?


Q: Array property in JSON object updated via foreach - updates all keys I'm kind of pulling my hair out on this one. I am trying to build an array of JSON objects via a foreach loop. It works great - except for one property. The property that I am having difficulty with - is an array that is updated during each loop. During the first loop, the array would be empty. At the end of the first loop, I add a value to prepare it for the next loop. During the next loop - create a new JSON object to add to the array. When I add the array property, it also updates the previous key. Kinda of strange. The end result, is for each array key (JSON Object), the 'excludedUsers' array is the same.
    ( function () {

    // Pre-populate User Permissions
    var userPermissions = $('.js-user-permissions').val();
    var numberOfSelects = 1;
    var count = 1;
    var arraySize;
    var viewHtml = '';
    var userSelects = [];
    var excludedUsers = [];

    if(userPermissions) {

        userPermissions = jQuery.parseJSON(userPermissions);
        // An array of JSON like:
        // [{ usersId=57, type="user"}, { usersId=58, type="user"}]

        arraySize = userPermissions.length;

        for(var idx = 0; idx < userPermissions.length; idx++) {

            userSelects[idx] = {};
            console.log("Loop #" + idx);

            // Set default value of select element
            userSelects[idx].usersId = userPermissions[idx].usersId;
            userSelects[idx].type = userPermissions[idx].type;
            userSelects[idx].disabled = arraySize == count ? null : 'disabled';
            userSelects[idx].excludedUsers = excludedUsers;
            userSelects[idx].count = numberOfSelects;
            userSelects[idx].name = "user" + numberOfSelects;
            numberOfSelects++;

            console.log("Before Array Push: " + JSON.stringify(userSelects));

            excludedUsers[idx] = userPermissions[idx].usersId;

            console.log("After Array Push: " + JSON.stringify(userSelects));

            count++;

        }

    }

})();

If you ran - this, I am finding the following output to the console. (NOTE: Watch the property 'excludedUsers').......
Loop #0
Before Array Push: [{"usersId":57,"type":"user","disabled":"disabled","excludedUsers":[],"count":1,"name":"user1"}]
After Array Push: [{"usersId":57,"type":"user","disabled":"disabled","excludedUsers":[57],"count":1,"name":"user1"}]
Loop #1
Before Array Push: [{"usersId":57,"type":"user","disabled":"disabled","excludedUsers":[57],"count":1,"name":"user1"},{"usersId":58,"type":"user","disabled":null,"excludedUsers":[57],"count":2,"name":"user2"}]
After Array Push: [{"usersId":57,"type":"user","disabled":"disabled","excludedUsers":[57,58],"count":1,"name":"user1"},{"usersId":58,"type":"user","disabled":null,"excludedUsers":[57,58],"count":2,"name":"user2"}]

A: You are referencing the same instance of the array in every object that you build.
userSelects[idx].excludedUsers = excludedUsers; does not copy the excludedUsers array into a new array for the object, it assigns a reference to the original array to userSelects[idx].excludedUsers.
If you want to clone the array you can use Array.slice() to do a shallow copy:
userSelects[idx].excludedUsers = excludedUsers.slice(0)


Q: Change default page in ASP.NET Core Razor Page from Index to Home I am changing Default Page
services.AddRazorPages(options =>
{
    //...
}).AddRazorPagesOptions(options =>
{
    options.Conventions.AddPageRoute("/Home", "");
});

but an exception occured
AmbiguousMatchException: The request matched multiple endpoints. Matches:
/Home
/Index

What can I do?

A: One option is to edit the @page directive in the Index.cshtml and Home.cshtml files to configure the routes:
/* Home.cshtml.cs */
@page "/"

/* Index.cshtml.cs */
@page "/Index"

This applies explicit routes for the two pages, so that the Home Razor Pages page becomes the root page, and the Index page maps only to /Index.

Note that with this approach, the call to AddPageRoute shown in your question is not needed.


Q: ORACLE Add new record if any field changes I'm trying to write an Oracle procedure.  I have a table and currently I'm using a merge statement.  When a record is changed, it updates it, if it is new, it adds it.
However, we want to keep track of changed records.  So I'm adding three fields: startdate, enddate, currentflag.  I don't want to update the record if there are any changes, I want to add a new record instead.  But I do want to add an enddate and change the flag on the old record.
So, if I have a table like this:
TableID
Field1
Field2
Field3
StartDate
EndDate
CurrentFlag

And it has data like this
TableID   Field1   Field2   Field3  StartDate   EndDate   CurrentFlag
001       DataA    Cow      Brown   3-Oct-18              Y
001       DataA    Cow      White   1-Sep-18    3-Oct-18  N
002       DataB    Horse    Dapple  3-Oct-18              Y

I want to merge in some data
TableID   Field1   Field2   Field3
001       NewData  Cow      Black
002       DataB    Horse    Dapple
005       Data3    Cat      Black

So that the final table looks like this
TableID   Field1   Field2   Field3  StartDate   EndDate   CurrentFlag
001       DataA    Cow      Brown   3-Oct-18    10-Oct-18 N
001       DataA    Cow      White   1-Sep-18    3-Oct-18  N
001       NewData  Cow      Black   10-Oct-18             Y
002       DataB    Horse    Dapple  3-Oct-18              Y
005       Data3    Cat      Black   10-Oct-18             Y

My pseudocode is
for each record in source file
   find current record in dest table (on ID and flag = Y)
   if any other fields do not match (Field1, Field2, Field3)
    then update current record, set enddate, current flag to n
        and add new record with startdate = sysdate, current flag is Y
   if no match found, then add new record with startdate = sysdate, current flag is Y

I'm not sure how to turn that pseudocode into Oracle SQL code.  Can I use the same MERGE statement, but in the WHEN MATCHED add a check to see if any of the other fields are different?
I will be doing this for several tables, a few of which have a lot of records and many fields.  So I need to figure out something that works and isn't as slow as molasses.
UPDATE
I have created a procedure as suggested, with some modifications, so it works:
CREATE OR REPLACE PROCEDURE TESTPROC AS

BEGIN
DECLARE
l_count NUMBER;
CURSOR TRN is
    SELECT * from sourceTable;

BEGIN
    FOR each_record IN TRN
    LOOP
        -- if a record found but fields differ ...
        l_count := 0;
        SELECT COUNT(*) INTO l_count
        FROM destTable DIM
        WHERE each_record.TableID = DIM.TableID
          and (each_record.Field1 <> DIM.Field1
          or each_record.Field2 <> DIM.Field2
          or each_record.Field13 <> DIM.Field3)
          AND DIM.CurrentFlag = 'Y';

        -- ... then update existing current record, and add with new data
        IF l_count > 0 THEN
            UPDATE destTable DIM
              SET EndDate = sysdate
                 ,CurrentFlag = 'N'
               WHERE each_record.TableID = DIM.TableID;

            INSERT INTO destTable
                     (TableID
                    , Field1
                    , Field2
                    , Field3
                    , StartDate
                    , CurrentFlag)
            VALUES (each_record.TableID
                    , each_record.Field1
                    , each_record.Field2
                    , each_record.Field3
                    , sysdate
                    , 'Y');
          COMMIT;
        END IF;

        -- if no record found with this key...
        l_count := 0;
        SELECT COUNT(*) INTO l_count
        FROM destTable DIM
        WHERE each_record.TableID = DIM.TableID;

        -- then add a new record
        IF l_count = 0 THEN
            INSERT INTO destTable
                     (TableID
                    , Field1
                    , Field2
                    , Field3
                    , StartDate
                    , CurrentFlag)
            VALUES (each_record.TableID
                    , each_record.Field1
                    , each_record.Field2
                    , each_record.Field3
                    , sysdate
                    , 'Y');
        END IF;
    END LOOP;
    COMMIT;
END;
END TESTPROC

And on my small table, it worked nicely.  Now I'm trying it on one of my larger tables (800k records, but by no means the largest table), and I'm updating this question while it runs.  It's been nearly an hour, and obviously that isn't acceptable.  Once my program comes back, I'll add indices on the TableID, and TableID and CurrentFlag.  If indices don't help, any suggestions for the slow as molasses aspect?

A: You can write a Simple procedure for the same:
DECLARE

l_count NUMBER;
CURSOR C1 is
-- YOUR DATA FROM SOURCE

BEGIN

 for each_record in c1
 l_count := 0;
   SELECT COUNT(*) into l_count from destination_table where field1=
  eachrecord.field1 and .... and flag = 'Y'; -- find current record in dest table (on ID and flag = Y)

--  if any other fields do not match (Field1, Field2, Field3)
IF L_COUNT > 0 THEN
   update current record, set enddate, current flag to n
END IF;
    INSERT new record with startdate = sysdate, current flag is Y
END;

Mod by OP: That led to the right direction.  The following code will do the trick, providing there is also an index on TableID and (TableID, CurrentFlag).
CREATE OR REPLACE PROCEDURE TESTPROC AS

BEGIN
DECLARE
l_count NUMBER;
CURSOR TRN is
    SELECT * from sourceTable;

BEGIN
    FOR each_record IN TRN
    LOOP
        -- if a record found but fields differ ...
        l_count := 0;
        SELECT COUNT(*) INTO l_count
        FROM destTable DIM
        WHERE each_record.TableID = DIM.TableID
          and (each_record.Field1 <> DIM.Field1
          or each_record.Field2 <> DIM.Field2
          or each_record.Field13 <> DIM.Field3)
          AND DIM.CurrentFlag = 'Y';

        -- ... then update existing current record, and add with new data
        IF l_count > 0 THEN
            UPDATE destTable DIM
              SET EndDate = sysdate
                 ,CurrentFlag = 'N'
               WHERE each_record.TableID = DIM.TableID;

            INSERT INTO destTable
                     (TableID
                    , Field1
                    , Field2
                    , Field3
                    , StartDate
                    , CurrentFlag)
            VALUES (each_record.TableID
                    , each_record.Field1
                    , each_record.Field2
                    , each_record.Field3
                    , sysdate
                    , 'Y');
          COMMIT;
        END IF;

        -- if no record found with this key...
        l_count := 0;
        SELECT COUNT(*) INTO l_count
        FROM destTable DIM
        WHERE each_record.TableID = DIM.TableID;

        -- then add a new record
        IF l_count = 0 THEN
            INSERT INTO destTable
                     (TableID
                    , Field1
                    , Field2
                    , Field3
                    , StartDate
                    , CurrentFlag)
            VALUES (each_record.TableID
                    , each_record.Field1
                    , each_record.Field2
                    , each_record.Field3
                    , sysdate
                    , 'Y');
        END IF;
    END LOOP;
    COMMIT;
END;
END TESTPROC

A: Maybe you could use triggers to perform that.
CREATE OR REPLACE TRIGGER insTableID
BEFORE INSERT OR UPDATE
ON tableID
FOR EACH ROW
DECLARE
    v_exists NUMBER := -1;
BEGIN
    SELECT COUNT(1) INTO v_exists FROM tableID t where t.Field1 = :new.Field1 and ... ;
    IF INSERTING THEN
        IF v_exist > 0 THEN
            null;--your DML update statement
        ELSE
            null;--your DML insert statement
        END;
    END IF;
    IF UPDATING THEN
        null;--your DML statement for update the old registry and a DML for insert the new registry.
    END IF;
END;

In this way, you can update the registry related to the old values and insert a new row with the new values.
I hope that this helps you to solve your problem.


Q: Plotting spheres around given coordinates in 3D in Matlab I am working on model of an object sliding on some rough surface consisting of spheres with a small random variance in position. In the graphics I want the spheres to be of a given radius, however when using scatter3 this wont work, the sizes of the circles change when I zoom in or out. I could easily solve this in 2D by using "rectangle"-function instead but for 3D this doesn't work.
Is there a better function for plotting spheres around points?
I have read this https://se.mathworks.com/matlabcentral/answers/101738-how-do-i-specify-the-size-of-the-markers-created-by-the-scatter-plot-in-units-proportional-to-the-da. But it either doesn't work for scatter3 or I do it wrong.

Sizes change when zooming in.
fig = figure(1);
hold on
daspect([1,1,1]);
surface.xnum = 16;
surface.znum = 16;
surface.r = 1;
circlenumber = 0;
for n = 1:surface.xnum
    for m = 1:surface.znum
        circlenumber = circlenumber + 1;
        surface.circlecentre(circlenumber,:) = [n + 0.1*surface.r*randn , 0, m + 0.1*surface.r*randn ];
        plt.surface = scatter3(surface.circlecentre(circlenumber, 1),surface.circlecentre(circlenumber, 2),surface.circlecentre(circlenumber, 3), 850*surface.r,'filled','r','MarkerEdgeColor','k');
    end
end

Relevant part of the code. Setting coordinates to center of the spheres and plotting spheres around them.

A: This was the solution i found by the hint from Ander Biguri. I used surf to plot spheres instead of scatter3.
fig = figure(1);
hold on
daspect([1,1,1]);
colormap summer
shading interp  % removes the lines in surfplot
surface.xnum = 8;
surface.znum = 8;
surface.r = 0.75;
circlenumber = 0;

for m = 1:surface.xnum
    for n = 1:surface.znum

        circlenumber = circlenumber + 1;
        surface.circlecentre(circlenumber,:) = [m + 0.1*surface.r*randn ,0 , n + 0.1*surface.r*randn ];
        [x,y,z] = sphere; surf(x*surface.r+m*2*surface.r+0.1*surface.r*randn, y*surface.r, z*surface.r+n*2*surface.r+0.1*surface.r*randn,'Edgecolor','none');

    end
end


Q: My computer freezes suddenly after 1 hour My laptop is Dell Vostro 5480 and it is running Ubuntu 16.04.
I don't know what is wrong but today after 1 hour running, my laptop freeze. I just listening to music and write some stuff.
I remember I upgrade something like ubuntu-core-launcher before this happen. Could this be the reason?
This is the output of lspci -k | grep -EA2 'VGA|3D|Display' :
00:02.0 VGA compatible controller: Intel Corporation Broadwell-U Integrated Graphics (rev 09)
    DeviceName:  Onboard IGD
    Subsystem: Dell Broadwell-U Integrated Graphics
--
08:00.0 3D controller: NVIDIA Corporation GM108M [GeForce 830M] (rev a2)
    Subsystem: Dell GM108M [GeForce 830M]
    Kernel modules: nvidiafb, nouveau

A: Did you got any error message then share it.
first follow these simple steps:

*

*Remove Battery and all other external devices power cable also.

*press the power button and hold it for 1min.

*then try to start.

A: You need to install Nvidia drivers. Run in terminal
sudo apt install nvidia-361 nvidia-prime

and reboot.
If you have UEFI, you need also to disable Secure Boot.


Q: WordPress submenu hover with gradient image background over the parent LI and children LI's (submenu UL) I have the next situation/menu: http://inturnets.com/test/
It is a WordPress generated menu structure.
Please hover your mouse over "Menu #1". When mouse is hovered, i need the Menu #1, Menu #1 - 1 and Menu #1 - 2 to look like http://inturnets.com/test/images/whatineed.jpg
It has a that background image with gradient effect on it. It should start from the top of the menu when hovered, from the top of Menu #1 and to end on the LI's of the submenu UL. When the bg image ends (no-repeat) should continue the colour from the last pixel of it's bottom. In our example for a better visual experience let's take the #ff0000 :)
Does anyone have any clue how to solve that?
For now I tried the next css code:
#menu-top-navigation ul:hover { background: url(images/bg-menutest.jpg) repeat-x center top; }

But as you can see, with this only the LI's are covered on hover. I mean the submenu UL. I think there we need a hover rule for the hovered LI, some rounded corners with radius and another hover rule for the submenu UL with a corner radius and to look with continuity from the top over the bottom, like it looks on the linked image.

A: try to specify background color with selector like this:
#menu-top-navigation > li:hover

This way, you should be able to specify one gradient for whole LI content (in your case UL and LI). Strongly reccomend to use CSS3 gradients.
If this wont help you might need to specify on gradient for
#menu-top-navigation > li:hover {gradient color of XXX to YYY}

and one for
#menu-top-navigation > li:hover > ul {gradient color of YYY to ZZZ}

Note: gradient spec is just an example, it is not the actual syntax. Just wanted to make easier to understand.
Let me know if you have any questions.


Q: Is there a way to show that $e^x=\lim_{n\to \infty }\left(1+\frac{x}{n}\right)^n$? I know that $$e:=\lim_{n\to \infty }\left(1+\frac{1}{n}\right)^n,$$
by definition. Knowing that, I proved successively that $$e^{k}=\lim_{n\to \infty }\left(1+\frac{k}{n}\right)^n,$$
when $k\in \mathbb N$, $k\in \mathbb Z$ and $k\in\mathbb Q$. Now, I was wondering : how can I extend this result over $\mathbb R$ ? I tried to prove that $f_n(x):=(1+\frac{x}{n})^n$ converge uniformly on $\mathbb R$ but unfortunately it failed (I'm not sure that it's even true). Any idea ?

My idea was to define the function $x\longmapsto e^x$ as $$e^x=\begin{cases}e^x& x\in \mathbb Q\\ \lim_{n\to \infty }e^{k_n}&\text{if }k_n\to x \text{ and }(k_n)\subset \mathbb Q\end{cases}.$$
But to conclude that $$e^x=\lim_{n\to \infty }\left(1+\frac{x}{n}\right)^n,$$
I need to prove that $f_n(x)=\left(1+\frac{x}{n}\right)^n$ converge uniformly on a neighborhood of $x$, but I can't do it. I set $$g_n(x)=f_n(x)-e^x,$$
but I can't find the maximum on a compact that contain $x$, and thus can't conclude.

A: It is not difficult to prove the result for real irrational $x$ if you have already proved the case for rational $x$. The only idea you need to establish first as a part of your definition of $e^x$ is that $f(x) =e^x$ is continuous everywhere. I leave this as an exercise for you (hint: show that $\lim_{x\to 0}e^x=1$ using your definition).
Now let $x$ be any irrational number. Given any $\epsilon>0$ there is $\delta>0$ such that $$e^x-\epsilon<e^t<e^x+\epsilon$$ whenever $|t-x|<\delta$. Consider two rationals $r, s$ with $x-\delta<r<x<s<x+\delta$ and then we have $$e^x-\epsilon <e^r<e^s<e^x+\epsilon$$ Now we have $$\left(1+\frac{r}{n}\right)^n<\left(1+\frac{x}{n}\right)^n<\left(1+\frac{s}{n}\right)^n$$ and taking limits as $n\to\infty$ we get $$e^x-\epsilon<e^r\leq \lim_{n\to\infty} \left(1+\frac{x}{n}\right)^n\leq e^s<e^x+\epsilon $$ (the above assumes that the limit in question exists for irrational $x$ also and you can prove it using the fact that a bounded monotone sequence is convergent, or better apply liminf/limsup to the above inequalities). Since $\epsilon$ is arbitrary it follows that $$e^x=\lim_{n\to\infty} \left(1+\frac{x}{n}\right)^n$$
Based on feedback from Mark Viola via comments I am giving a link to my blog posts which discuss various routes to the theory of exponential and logarithmic functions :

*

*logarithm as an integral

*exponential/logarithm as a limit : relevant to current question

*general real power as continuous extension of rational power

A: We can use that exists $p_n, q_n \in \mathbb{Q}$ such that $p_n,q_n \to x$ and $p_n\le x\le q_n$, therefore
$$\left(1+\frac{p_n}{n}\right)^n\le \left(1+\frac{x}{n}\right)^n\le \left(1+\frac{q_n}{n}\right)^n$$
and
$$\left(1+\frac{p_n}{n}\right)^n=\left[\left(1+\frac{p_n}{n}\right)^\frac{n}{p_n}\right]^{p_n}\to e^x$$
$$\left(1+\frac{q_n}{n}\right)^n=\left[\left(1+\frac{q_n}{n}\right)^\frac{n}{q_n}\right]^{q_n}\to e^x$$
indeed for $\frac{n}{p_n}\in (m,m+1)$ with $m\in \mathbb{N}$ we have
$$\left(1+\frac1{m+1}\right)^m\le \left(1+\frac{p_n}{n}\right)^\frac{n}{p_n}\le \left(1+\frac1m\right)^{m+1}$$
and therefore  $\left(1+\frac{p_n}{n}\right)^\frac{n}{p_n}\to e$.

A: To prove  $$e^x=\lim_{n\to \infty }\left(1+\frac{x}{n}\right)^n$$
Let $$ y=\left(1+\frac{x}{n}\right)^n$$
$$ \ln y=n \ln(1+x/n)$$
$$= \frac {\ln(1+x/n)}{(1/n)}$$
$$\lim_{n\to \infty }\ln y=\lim_{n\to \infty }\frac {\ln(1+x/n)}{(1/n)}=x$$
Thus $$\lim_{n\to \infty } y= e^x$$

A: $$\frac xn(\frac n{n+x})\le\int_1^{1+\frac xn}\frac1t dt\le\frac xn(1)\implies \frac x{n+x}\le\ln (1+\frac xn)\le\frac xn\implies e^{\frac x{n+x}}\le1+\frac xn\le e^{\frac xn}\implies e^{\frac{xn}{n+x}}\le(1+\frac xn)^n\le e^x\implies  e^x\le\lim_{n\to\infty}(1+\frac xn)^n\le e^x$$, by the squeeze or sandwich theorem...

A: Left side:
The exponential function may be written as a Taylor series:
$e^x=1+x+\frac{x^2}{2!}+\frac{x^3}{3!}+...$
Right side:
$(1+\frac{x}{n})^n$ is a binomial expansion like:
$(1+y)^n=\binom{n}{0}y^0+\binom{n}{1}y^1+\binom{n}{2}y^2+...+\binom{n}{n-1}y^{n-1}+\binom{n}{n}y^n$
Where $\binom{n}{k}$ is the Binomial coefficient given by the formula :
$\binom{n}{k}=\frac{n!}{k!(n-k)!}$
Some basic properties of $\binom{n}{k}$:
a)$\binom{n}{0}=1$ because $\frac{n!}{0!(n-0)!}=\frac{n!}{1*n!}$
b)$\binom{n}{1}=n$ because $\frac{n!}{1!(n-1)!}=\frac{(n-1)!*n}{(n-1)!}$
c)$\binom{n}{n-1}=n$ because $\frac{n!}{(n-1)!(n-(n-1))!}=\frac{(n-1)!*n}{(n-1)!*1!}$
d)$\binom{n}{n}=1$ because $\frac{n!}{n!(n-n)!}=\frac{1}{1!}$
e) The formula does exhibit a symmetry that is less evident from the multiplicative formula:
$\binom{n}{k}=\binom{n}{n-k}$
Returning:
$(1+\frac{x}{n})^n=1+n*\frac{x}{n}+\frac{n!}{2!(n-2)!}\frac{x^2}{n^2}+\frac{n!}{3!(n-3)!}\frac{x^3}{n^3}+...+\frac{n!}{3!(n-3)!}\frac{x^{n-3}}{n^{n-3}}+\frac{n!}{2!(n-2)!}\frac{x^{n-2}}{n^{n-2}}+n*\frac{x^{n-1}}{n^{n-1}}+\frac{x^n}{n^n}$
$(1+\frac{x}{n})^n=1+x+\frac{(n-1)n}{n^2}\frac{x^2}{2!}+\frac{(n-2)(n-1)n}{n^3}\frac{x^3}{3!}+...+\frac{(n-2)(n-1)n}{3!}\frac{x^{n-3}}{n^{n-3}}+\frac{(n-1)n}{2!}\frac{x^{n-2}}{n^{n-2}}+\frac{x^{n-1}}{n^{n-2}}+\frac{x^n}{n^n}$
$(1+\frac{x}{n})^n=1+x+\frac{n-1}{n}\frac{x^2}{2!}+\frac{(n-2)(n-1)}{n^2}\frac{x^3}{3!}+...+\frac{(n-2)(n-1)}{n^{n-4}}\frac{x^{n-3}}{3!}+\frac{n-1}{n^{n-3}}\frac{x^{n-2}}{2!}+\frac{x^{n-1}}{n^{n-2}}+\frac{x^n}{n^n}$
Let's analyze what happens for $n\rightarrow\infty$-here we have three types of limits:
-First type:
$\displaystyle\lim_{n \to \infty}\frac{n-1}{n}=\displaystyle\lim_{n \to \infty}[1+\frac{1}{n}]=1+0=1$
$\displaystyle\lim_{n \to \infty}\frac{(n-2)(n-1)}{n^2}=\displaystyle\lim_{n \to \infty}\frac{n^2-3n+2}{n^2}=\displaystyle\lim_{n \to \infty}[1-\frac{3}{n}+\frac{2}{n^2}]=1-0+0=1$
Hense $\displaystyle\lim_{n \to \infty}\Bigg(\frac{\displaystyle\prod_{i=1}^{k} (n-i)}{n^k}\Bigg)=1$
-Second type is
$\displaystyle\lim_{n \to \infty} \frac{x^{n-\alpha}}{n^{n-\beta}}$-Because ${n^{n-\beta}}$ grows much fasten than $x^{n-\alpha}$ hense: $\displaystyle\lim_{n \to \infty} \frac{x^{n-\alpha}}{n^{n-\beta}}=0$
-Third type:
$\displaystyle\lim_{n \to \infty}\Bigg(\frac{\displaystyle\prod_{i=1}^{k} (n-i)}{n^{n-k-1}}\frac{x^{n-k}}{k!}\Bigg)$
We have to show on the biggest power (similar to the first type) as the most relevant:
$\frac{\displaystyle\prod_{i=1}^{k} (n-i)}{n^{n-k-1}}\frac{x^{n-k}}{k!}\sim\frac{n^{k-1} }{n^{n-k-1}}\frac{x^{n-k}}{k!}=n^{k-1-(n-k-1)}\frac{x^{n-k}}{k!}=n^{2k-n}*\frac{x^{n-k}}{k!}=\frac{1}{k!}*\frac{x^{n-k}}{n^{n-2k}}$
Again: ${n^{n-\beta}}$ grows much faster than $x^{n-\alpha}$
Hense: $\displaystyle\lim_{n \to \infty}\Bigg(\frac{\displaystyle\prod_{i=1}^{k} (n-i)}{n^{n-k-1}}\frac{x^{n-k}}{k!}\Bigg)=0$
Our right side equals:
$\displaystyle\lim_{n \to \infty}(1+\frac{x}{n})^n=1+x+1*\frac{x^2}{2!}+1*\frac{x^3}{3!}+...+0+0+0+0$
$\displaystyle\lim_{n \to \infty}(1+\frac{x}{n})^n=1+x+\frac{x^2}{2!}+\frac{x^3}{3!}+...$
We got the same elements like in the Taylor series of $e^x$. Q.E.D.


Q: Is "break X at the seams" a metaphor, or something else?
The Mariana crow actually uses its bill to peck and break the shell at
the seams to extract the vulnerable crab.

https://corvidresearch.blog/tag/extinct-crow/
I was told it wasn't an idiom, so I am wondering if it's a valid metaphorical usage. I do see it often.

A: Break is literal in this context. It means

VERB broke, broken
1 Separate or cause to separate into pieces as a result of a blow, shock, or strain.
(Lexico, n. d.)

"At the seam" is an idiomatic way of saying "entirely".

at the seams
: ENTIRELY, COMPLETELY
falling apart at the seams
(Merriam-Webster, n. d.)