Dell M6600: "No internet access", can browse internet, can remote into it, cannot activate office 2013, cannot join domain

Question: Like the title says, I've got a Dell M6600, running Windows 7, that connects to the network just fine, I can use it to browse the web, including https://officesetup.getmicrosoftkey.com/, I can connect to it via RDP, it was joined to the domain (more below), no noticeable slowness in the network connection. The issue is that the active networks are reporting Access Type: No internet access, and I can't connect to some things, like I can't activate Office 2013 because "We are unable to connect right now. Please check your network and try again later". No software firewall is enabled.
Here's what I've tried:

ipconfig release & ipconfig renew
run netsh int ip reset c:\temp\resetlog.txt (the log never gets generated)
Connect with Wired Ethernet only
Connect with WiFi only
Uninstall/reinstall the network adapters using the management console
Wade through a swath of unhelpful google results like route delete 0.0.0.0 if 11
Attempt a domain rejoin, got as far as removing the computer from the domain, but can't readd, as "The network location cannot be reached" (I can still RDP to it at this point using local creds, there are gpupdate failure events that should've told me this would fail)
Check NCSI issues: navigation to http://www.msftncsi.com/ncsi.txt in IE results in a page with the text: "Microsoft NCSI", dns.msftncsi.com resolves correctly
Pinging the DNS server results in request timed out, but performing nslookup works just fine using said DNS server.
changed the IP address of the DHCP reservation to a known unused IP address to check for IP address conflicts
uninstalled AV software
changing switch port, switch for wired access had no effect, Dynamic Address Tables correctly updated when switched to a different port (the ports on the switches have the same configurations for most of the other successfully communicating computers on the network)
pinging DNS server works now, was failing, even though it was working fine with nslookup when pinging

(computer/domain names redacted in the following, some truncated for brevity)
ipconfig /all:

Windows IP Configuration

   Host Name . . . . . . . . . . . . : computer
   Primary Dns Suffix  . . . . . . . :
   Node Type . . . . . . . . . . . . : Hybrid
   IP Routing Enabled. . . . . . . . : No
   WINS Proxy Enabled. . . . . . . . : No
   DNS Suffix Search List. . . . . . : contoso.com

Ethernet adapter Local Area Connection:

   Connection-specific DNS Suffix  . : contoso.com
   Description . . . . . . . . . . . : Intel(R) 82579LM Gigabit Network Connection
   Physical Address. . . . . . . . . : D0-67-E5-2F-D2-20
   DHCP Enabled. . . . . . . . . . . : Yes
   Autoconfiguration Enabled . . . . : Yes
   IPv4 Address. . . . . . . . . . . : 172.17.2.240(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Lease Obtained. . . . . . . . . . : Wednesday, December 03, 2014 10:11:41 AM
   Lease Expires . . . . . . . . . . : Friday, December 05, 2014 10:14:57 AM
   Default Gateway . . . . . . . . . : 172.17.2.1
   DHCP Server . . . . . . . . . . . : 172.17.2.22
   DNS Servers . . . . . . . . . . . : 172.17.2.22
                                       172.17.2.21
   Primary WINS Server . . . . . . . : 172.17.2.22
   Secondary WINS Server . . . . . . : 172.17.2.24
   NetBIOS over Tcpip. . . . . . . . : Enabled

route print: (normal, removed to post wireshark)
wireshark with filter bootp.option.dhcp during ipconfig /renew & ipconfig /release & ipconfig /renew:

No.     Time           Source                Source Port Destination           Destination Port Protocol Length Info
   1265 54.049678000   172.17.2.100          68          172.17.2.22           67               DHCP     348    DHCP Request  - Transaction ID 0xd64657df

Frame 1265: 348 bytes on wire (2784 bits), 348 bytes captured (2784 bits) on interface 0
Ethernet II, Src: Dell_2f:d2:20 (d0:67:e5:2f:d2:20), Dst: Dell_5e:94:e3 (84:2b:2b:5e:94:e3)
Internet Protocol Version 4, Src: 172.17.2.100 (172.17.2.100), Dst: 172.17.2.22 (172.17.2.22)
User Datagram Protocol, Src Port: 68 (68), Dst Port: 67 (67)
Bootstrap Protocol (Request)
    Message type: Boot Request (1)
    Hardware type: Ethernet (0x01)
    Hardware address length: 6
    Hops: 0
    Transaction ID: 0xd64657df
    Seconds elapsed: 0
    Bootp flags: 0x0000 (Unicast)
        0... .... .... .... = Broadcast flag: Unicast
        .000 0000 0000 0000 = Reserved flags: 0x0000
    Client IP address: 172.17.2.100 (172.17.2.100)
    Your (client) IP address: 0.0.0.0 (0.0.0.0)
    Next server IP address: 0.0.0.0 (0.0.0.0)
    Relay agent IP address: 0.0.0.0 (0.0.0.0)
    Client MAC address: Dell_2f:d2:20 (d0:67:e5:2f:d2:20)
    Client hardware address padding: 00000000000000000000
    Server host name not given
    Boot file name not given
    Magic cookie: DHCP
    Option: (53) DHCP Message Type (Request)
        Length: 1
        DHCP: Request (3)
    Option: (61) Client identifier
        Length: 7
        Hardware type: Ethernet (0x01)
        Client MAC address: Dell_2f:d2:20 (d0:67:e5:2f:d2:20)
    Option: (12) Host Name
        Length: 11
        Host Name: computer
    Option: (81) Client Fully Qualified Domain Name
        Length: 14
        Flags: 0x00
        0000 .... = Reserved flags: 0x00
        .... 0... = Server DDNS: Some server updates
        .... .0.. = Encoding: ASCII encoding
        .... ..0. = Server overrides: No override
        .... ...0 = Server: Client
        A-RR result: 0
        PTR-RR result: 0
        Client name: computer
    Option: (60) Vendor class identifier
        Length: 8
        Vendor class identifier: MSFT 5.0
    Option: (55) Parameter Request List
        Length: 12
        Parameter Request List Item: (1) Subnet Mask
        Parameter Request List Item: (15) Domain Name
        Parameter Request List Item: (3) Router
        Parameter Request List Item: (6) Domain Name Server
        Parameter Request List Item: (44) NetBIOS over TCP/IP Name Server
        Parameter Request List Item: (46) NetBIOS over TCP/IP Node Type
        Parameter Request List Item: (47) NetBIOS over TCP/IP Scope
        Parameter Request List Item: (31) Perform Router Discover
        Parameter Request List Item: (33) Static Route
        Parameter Request List Item: (121) Classless Static Route
        Parameter Request List Item: (249) Private/Classless Static Route (Microsoft)
        Parameter Request List Item: (43) Vendor-Specific Information
    Option: (255) End
        Option End: 255

No.     Time           Source                Source Port Destination           Destination Port Protocol Length Info
   1268 54.050521000   172.17.2.22           67          172.17.2.100          68               DHCP     381    DHCP ACK      - Transaction ID 0xd64657df

Frame 1268: 381 bytes on wire (3048 bits), 381 bytes captured (3048 bits) on interface 0
Ethernet II, Src: Dell_5e:94:e3 (84:2b:2b:5e:94:e3), Dst: Dell_2f:d2:20 (d0:67:e5:2f:d2:20)
Internet Protocol Version 4, Src: 172.17.2.22 (172.17.2.22), Dst: 172.17.2.100 (172.17.2.100)
User Datagram Protocol, Src Port: 67 (67), Dst Port: 68 (68)
Bootstrap Protocol (ACK)
    Message type: Boot Reply (2)
    Hardware type: Ethernet (0x01)
    Hardware address length: 6
    Hops: 0
    Transaction ID: 0xd64657df
    Seconds elapsed: 0
    Bootp flags: 0x0000 (Unicast)
        0... .... .... .... = Broadcast flag: Unicast
        .000 0000 0000 0000 = Reserved flags: 0x0000
    Client IP address: 0.0.0.0 (0.0.0.0)
    Your (client) IP address: 172.17.2.100 (172.17.2.100)
    Next server IP address: 0.0.0.0 (0.0.0.0)
    Relay agent IP address: 0.0.0.0 (0.0.0.0)
    Client MAC address: Dell_2f:d2:20 (d0:67:e5:2f:d2:20)
    Client hardware address padding: 00000000000000000000
    Server host name not given
    Boot file name not given
    Magic cookie: DHCP
    Option: (53) DHCP Message Type (ACK)
        Length: 1
        DHCP: ACK (5)
    Option: (58) Renewal Time Value
        Length: 4
        Renewal Time Value: (86400s) 1 day
    Option: (59) Rebinding Time Value
        Length: 4
        Rebinding Time Value: (151200s) 1 day, 18 hours
    Option: (51) IP Address Lease Time
        Length: 4
        IP Address Lease Time: (172800s) 2 days
    Option: (54) DHCP Server Identifier
        Length: 4
        DHCP Server Identifier: 172.17.2.22 (172.17.2.22)
    Option: (1) Subnet Mask
        Length: 4
        Subnet Mask: 255.255.255.0 (255.255.255.0)
    Option: (81) Client Fully Qualified Domain Name
        Length: 3
        Flags: 0x00
        0000 .... = Reserved flags: 0x00
        .... 0... = Server DDNS: Some server updates
        .... .0.. = Encoding: ASCII encoding
        .... ..0. = Server overrides: No override
        .... ...0 = Server: Client
        A-RR result: 255
        PTR-RR result: 255
    Option: (15) Domain Name
        Length: 9
        Domain Name: contoso.com
    Option: (3) Router
        Length: 4
        Router: 172.17.2.1 (172.17.2.1)
    Option: (6) Domain Name Server
        Length: 8
        Domain Name Server: 172.17.2.22 (172.17.2.22)
        Domain Name Server: 172.17.2.21 (172.17.2.21)
    Option: (44) NetBIOS over TCP/IP Name Server
        Length: 8
        NetBIOS over TCP/IP Name Server: 172.17.2.22 (172.17.2.22)
        NetBIOS over TCP/IP Name Server: 172.17.2.24 (172.17.2.24)
    Option: (46) NetBIOS over TCP/IP Node Type
        Length: 1
        NetBIOS over TCP/IP Node Type: H-node (8)
    Option: (121) Classless Static Route
        Length: 8
        Subnet/MaskWidth-Router: 172.17.3.0/24-172.17.2.2
    Option: (249) Private/Classless Static Route (Microsoft)
        Length: 8
        Subnet/MaskWidth-Router: 172.17.3.0/24-172.17.2.2
    Option: (255) End
        Option End: 255

No.     Time           Source                Source Port Destination           Destination Port Protocol Length Info
   1280 54.115690000   172.17.2.100          68          172.17.2.22           67               DHCP     342    DHCP Release  - Transaction ID 0x18a9cba3

Frame 1280: 342 bytes on wire (2736 bits), 342 bytes captured (2736 bits) on interface 0
Ethernet II, Src: Dell_2f:d2:20 (d0:67:e5:2f:d2:20), Dst: Dell_5e:94:e3 (84:2b:2b:5e:94:e3)
Internet Protocol Version 4, Src: 172.17.2.100 (172.17.2.100), Dst: 172.17.2.22 (172.17.2.22)
User Datagram Protocol, Src Port: 68 (68), Dst Port: 67 (67)
Bootstrap Protocol (Release)
    Message type: Boot Request (1)
    Hardware type: Ethernet (0x01)
    Hardware address length: 6
    Hops: 0
    Transaction ID: 0x18a9cba3
    Seconds elapsed: 0
    Bootp flags: 0x0000 (Unicast)
        0... .... .... .... = Broadcast flag: Unicast
        .000 0000 0000 0000 = Reserved flags: 0x0000
    Client IP address: 172.17.2.100 (172.17.2.100)
    Your (client) IP address: 0.0.0.0 (0.0.0.0)
    Next server IP address: 0.0.0.0 (0.0.0.0)
    Relay agent IP address: 0.0.0.0 (0.0.0.0)
    Client MAC address: Dell_2f:d2:20 (d0:67:e5:2f:d2:20)
    Client hardware address padding: 00000000000000000000
    Server host name not given
    Boot file name not given
    Magic cookie: DHCP
    Option: (53) DHCP Message Type (Release)
        Length: 1
        DHCP: Release (7)
    Option: (54) DHCP Server Identifier
        Length: 4
        DHCP Server Identifier: 172.17.2.22 (172.17.2.22)
    Option: (61) Client identifier
        Length: 7
        Hardware type: Ethernet (0x01)
        Client MAC address: Dell_2f:d2:20 (d0:67:e5:2f:d2:20)
    Option: (255) End
        Option End: 255
    Padding

No.     Time           Source                Source Port Destination           Destination Port Protocol Length Info
   1372 59.175867000   0.0.0.0               68          255.255.255.255       67               DHCP     342    DHCP Discover - Transaction ID 0x97a2aa5c

Frame 1372: 342 bytes on wire (2736 bits), 342 bytes captured (2736 bits) on interface 0
Ethernet II, Src: Dell_2f:d2:20 (d0:67:e5:2f:d2:20), Dst: Broadcast (ff:ff:ff:ff:ff:ff)
Internet Protocol Version 4, Src: 0.0.0.0 (0.0.0.0), Dst: 255.255.255.255 (255.255.255.255)
User Datagram Protocol, Src Port: 68 (68), Dst Port: 67 (67)
Bootstrap Protocol (Discover)
    Message type: Boot Request (1)
    Hardware type: Ethernet (0x01)
    Hardware address length: 6
    Hops: 0
    Transaction ID: 0x97a2aa5c
    Seconds elapsed: 0
    Bootp flags: 0x0000 (Unicast)
        0... .... .... .... = Broadcast flag: Unicast
        .000 0000 0000 0000 = Reserved flags: 0x0000
    Client IP address: 0.0.0.0 (0.0.0.0)
    Your (client) IP address: 0.0.0.0 (0.0.0.0)
    Next server IP address: 0.0.0.0 (0.0.0.0)
    Relay agent IP address: 0.0.0.0 (0.0.0.0)
    Client MAC address: Dell_2f:d2:20 (d0:67:e5:2f:d2:20)
    Client hardware address padding: 00000000000000000000
    Server host name not given
    Boot file name not given
    Magic cookie: DHCP
    Option: (53) DHCP Message Type (Discover)
        Length: 1
        DHCP: Discover (1)
    Option: (61) Client identifier
        Length: 7
        Hardware type: Ethernet (0x01)
        Client MAC address: Dell_2f:d2:20 (d0:67:e5:2f:d2:20)
    Option: (50) Requested IP Address
        Length: 4
        Requested IP Address: 172.17.2.100 (172.17.2.100)
    Option: (12) Host Name
        Length: 11
        Host Name: computer
    Option: (60) Vendor class identifier
        Length: 8
        Vendor class identifier: MSFT 5.0
    Option: (55) Parameter Request List
        Length: 12
        Parameter Request List Item: (1) Subnet Mask
        Parameter Request List Item: (15) Domain Name
        Parameter Request List Item: (3) Router
        Parameter Request List Item: (6) Domain Name Server
        Parameter Request List Item: (44) NetBIOS over TCP/IP Name Server
        Parameter Request List Item: (46) NetBIOS over TCP/IP Node Type
        Parameter Request List Item: (47) NetBIOS over TCP/IP Scope
        Parameter Request List Item: (31) Perform Router Discover
        Parameter Request List Item: (33) Static Route
        Parameter Request List Item: (121) Classless Static Route
        Parameter Request List Item: (249) Private/Classless Static Route (Microsoft)
        Parameter Request List Item: (43) Vendor-Specific Information
    Option: (255) End
        Option End: 255
    Padding

No.     Time           Source                Source Port Destination           Destination Port Protocol Length Info
   1373 59.176223000   172.17.2.22           67          255.255.255.255       68               DHCP     376    DHCP Offer    - Transaction ID 0x97a2aa5c

Frame 1373: 376 bytes on wire (3008 bits), 376 bytes captured (3008 bits) on interface 0
Ethernet II, Src: Dell_5e:94:e3 (84:2b:2b:5e:94:e3), Dst: Broadcast (ff:ff:ff:ff:ff:ff)
Internet Protocol Version 4, Src: 172.17.2.22 (172.17.2.22), Dst: 255.255.255.255 (255.255.255.255)
User Datagram Protocol, Src Port: 67 (67), Dst Port: 68 (68)
Bootstrap Protocol (Offer)
    Message type: Boot Reply (2)
    Hardware type: Ethernet (0x01)
    Hardware address length: 6
    Hops: 0
    Transaction ID: 0x97a2aa5c
    Seconds elapsed: 0
    Bootp flags: 0x0000 (Unicast)
        0... .... .... .... = Broadcast flag: Unicast
        .000 0000 0000 0000 = Reserved flags: 0x0000
    Client IP address: 0.0.0.0 (0.0.0.0)
    Your (client) IP address: 172.17.2.100 (172.17.2.100)
    Next server IP address: 172.17.2.22 (172.17.2.22)
    Relay agent IP address: 0.0.0.0 (0.0.0.0)
    Client MAC address: Dell_2f:d2:20 (d0:67:e5:2f:d2:20)
    Client hardware address padding: 00000000000000000000
    Server host name not given
    Boot file name not given
    Magic cookie: DHCP
    Option: (53) DHCP Message Type (Offer)
        Length: 1
        DHCP: Offer (2)
    Option: (1) Subnet Mask
        Length: 4
        Subnet Mask: 255.255.255.0 (255.255.255.0)
    Option: (58) Renewal Time Value
        Length: 4
        Renewal Time Value: (86400s) 1 day
    Option: (59) Rebinding Time Value
        Length: 4
        Rebinding Time Value: (151200s) 1 day, 18 hours
    Option: (51) IP Address Lease Time
        Length: 4
        IP Address Lease Time: (172800s) 2 days
    Option: (54) DHCP Server Identifier
        Length: 4
        DHCP Server Identifier: 172.17.2.22 (172.17.2.22)
    Option: (15) Domain Name
        Length: 9
        Domain Name: contoso.com
    Option: (3) Router
        Length: 4
        Router: 172.17.2.1 (172.17.2.1)
    Option: (6) Domain Name Server
        Length: 8
        Domain Name Server: 172.17.2.22 (172.17.2.22)
        Domain Name Server: 172.17.2.21 (172.17.2.21)
    Option: (44) NetBIOS over TCP/IP Name Server
        Length: 8
        NetBIOS over TCP/IP Name Server: 172.17.2.22 (172.17.2.22)
        NetBIOS over TCP/IP Name Server: 172.17.2.24 (172.17.2.24)
    Option: (46) NetBIOS over TCP/IP Node Type
        Length: 1
        NetBIOS over TCP/IP Node Type: H-node (8)
    Option: (121) Classless Static Route
        Length: 8
        Subnet/MaskWidth-Router: 172.17.3.0/24-172.17.2.2
    Option: (249) Private/Classless Static Route (Microsoft)
        Length: 8
        Subnet/MaskWidth-Router: 172.17.3.0/24-172.17.2.2
    Option: (255) End
        Option End: 255

No.     Time           Source                Source Port Destination           Destination Port Protocol Length Info
   1374 59.176534000   0.0.0.0               68          255.255.255.255       67               DHCP     360    DHCP Request  - Transaction ID 0x97a2aa5c

Frame 1374: 360 bytes on wire (2880 bits), 360 bytes captured (2880 bits) on interface 0
Ethernet II, Src: Dell_2f:d2:20 (d0:67:e5:2f:d2:20), Dst: Broadcast (ff:ff:ff:ff:ff:ff)
Internet Protocol Version 4, Src: 0.0.0.0 (0.0.0.0), Dst: 255.255.255.255 (255.255.255.255)
User Datagram Protocol, Src Port: 68 (68), Dst Port: 67 (67)
Bootstrap Protocol (Request)
    Message type: Boot Request (1)
    Hardware type: Ethernet (0x01)
    Hardware address length: 6
    Hops: 0
    Transaction ID: 0x97a2aa5c
    Seconds elapsed: 0
    Bootp flags: 0x0000 (Unicast)
        0... .... .... .... = Broadcast flag: Unicast
        .000 0000 0000 0000 = Reserved flags: 0x0000
    Client IP address: 0.0.0.0 (0.0.0.0)
    Your (client) IP address: 0.0.0.0 (0.0.0.0)
    Next server IP address: 0.0.0.0 (0.0.0.0)
    Relay agent IP address: 0.0.0.0 (0.0.0.0)
    Client MAC address: Dell_2f:d2:20 (d0:67:e5:2f:d2:20)
    Client hardware address padding: 00000000000000000000
    Server host name not given
    Boot file name not given
    Magic cookie: DHCP
    Option: (53) DHCP Message Type (Request)
        Length: 1
        DHCP: Request (3)
    Option: (61) Client identifier
        Length: 7
        Hardware type: Ethernet (0x01)
        Client MAC address: Dell_2f:d2:20 (d0:67:e5:2f:d2:20)
    Option: (50) Requested IP Address
        Length: 4
        Requested IP Address: 172.17.2.100 (172.17.2.100)
    Option: (54) DHCP Server Identifier
        Length: 4
        DHCP Server Identifier: 172.17.2.22 (172.17.2.22)
    Option: (12) Host Name
        Length: 11
        Host Name: computer
    Option: (81) Client Fully Qualified Domain Name
        Length: 14
        Flags: 0x00
        0000 .... = Reserved flags: 0x00
        .... 0... = Server DDNS: Some server updates
        .... .0.. = Encoding: ASCII encoding
        .... ..0. = Server overrides: No override
        .... ...0 = Server: Client
        A-RR result: 0
        PTR-RR result: 0
        Client name: computer
    Option: (60) Vendor class identifier
        Length: 8
        Vendor class identifier: MSFT 5.0
    Option: (55) Parameter Request List
        Length: 12
        Parameter Request List Item: (1) Subnet Mask
        Parameter Request List Item: (15) Domain Name
        Parameter Request List Item: (3) Router
        Parameter Request List Item: (6) Domain Name Server
        Parameter Request List Item: (44) NetBIOS over TCP/IP Name Server
        Parameter Request List Item: (46) NetBIOS over TCP/IP Node Type
        Parameter Request List Item: (47) NetBIOS over TCP/IP Scope
        Parameter Request List Item: (31) Perform Router Discover
        Parameter Request List Item: (33) Static Route
        Parameter Request List Item: (121) Classless Static Route
        Parameter Request List Item: (249) Private/Classless Static Route (Microsoft)
        Parameter Request List Item: (43) Vendor-Specific Information
    Option: (255) End
        Option End: 255

No.     Time           Source                Source Port Destination           Destination Port Protocol Length Info
   1375 59.177078000   172.17.2.22           67          255.255.255.255       68               DHCP     381    DHCP ACK      - Transaction ID 0x97a2aa5c

Frame 1375: 381 bytes on wire (3048 bits), 381 bytes captured (3048 bits) on interface 0
Ethernet II, Src: Dell_5e:94:e3 (84:2b:2b:5e:94:e3), Dst: Broadcast (ff:ff:ff:ff:ff:ff)
Internet Protocol Version 4, Src: 172.17.2.22 (172.17.2.22), Dst: 255.255.255.255 (255.255.255.255)
User Datagram Protocol, Src Port: 67 (67), Dst Port: 68 (68)
Bootstrap Protocol (ACK)
    Message type: Boot Reply (2)
    Hardware type: Ethernet (0x01)
    Hardware address length: 6
    Hops: 0
    Transaction ID: 0x97a2aa5c
    Seconds elapsed: 0
    Bootp flags: 0x0000 (Unicast)
        0... .... .... .... = Broadcast flag: Unicast
        .000 0000 0000 0000 = Reserved flags: 0x0000
    Client IP address: 0.0.0.0 (0.0.0.0)
    Your (client) IP address: 172.17.2.100 (172.17.2.100)
    Next server IP address: 0.0.0.0 (0.0.0.0)
    Relay agent IP address: 0.0.0.0 (0.0.0.0)
    Client MAC address: Dell_2f:d2:20 (d0:67:e5:2f:d2:20)
    Client hardware address padding: 00000000000000000000
    Server host name not given
    Boot file name not given
    Magic cookie: DHCP
    Option: (53) DHCP Message Type (ACK)
        Length: 1
        DHCP: ACK (5)
    Option: (58) Renewal Time Value
        Length: 4
        Renewal Time Value: (86400s) 1 day
    Option: (59) Rebinding Time Value
        Length: 4
        Rebinding Time Value: (151200s) 1 day, 18 hours
    Option: (51) IP Address Lease Time
        Length: 4
        IP Address Lease Time: (172800s) 2 days
    Option: (54) DHCP Server Identifier
        Length: 4
        DHCP Server Identifier: 172.17.2.22 (172.17.2.22)
    Option: (1) Subnet Mask
        Length: 4
        Subnet Mask: 255.255.255.0 (255.255.255.0)
    Option: (81) Client Fully Qualified Domain Name
        Length: 3
        Flags: 0x00
        0000 .... = Reserved flags: 0x00
        .... 0... = Server DDNS: Some server updates
        .... .0.. = Encoding: ASCII encoding
        .... ..0. = Server overrides: No override
        .... ...0 = Server: Client
        A-RR result: 255
        PTR-RR result: 255
    Option: (15) Domain Name
        Length: 9
        Domain Name: contoso.com
    Option: (3) Router
        Length: 4
        Router: 172.17.2.1 (172.17.2.1)
    Option: (6) Domain Name Server
        Length: 8
        Domain Name Server: 172.17.2.22 (172.17.2.22)
        Domain Name Server: 172.17.2.21 (172.17.2.21)
    Option: (44) NetBIOS over TCP/IP Name Server
        Length: 8
        NetBIOS over TCP/IP Name Server: 172.17.2.22 (172.17.2.22)
        NetBIOS over TCP/IP Name Server: 172.17.2.24 (172.17.2.24)
    Option: (46) NetBIOS over TCP/IP Node Type
        Length: 1
        NetBIOS over TCP/IP Node Type: H-node (8)
    Option: (121) Classless Static Route
        Length: 8
        Subnet/MaskWidth-Router: 172.17.3.0/24-172.17.2.2
    Option: (249) Private/Classless Static Route (Microsoft)
        Length: 8
        Subnet/MaskWidth-Router: 172.17.3.0/24-172.17.2.2
    Option: (255) End
        Option End: 255

No.     Time           Source                Source Port Destination           Destination Port Protocol Length Info
   1431 62.210304000   172.17.2.100          68          255.255.255.255       67               DHCP     342    DHCP Inform   - Transaction ID 0xd46e0a9b

Frame 1431: 342 bytes on wire (2736 bits), 342 bytes captured (2736 bits) on interface 0
Ethernet II, Src: Dell_2f:d2:20 (d0:67:e5:2f:d2:20), Dst: Broadcast (ff:ff:ff:ff:ff:ff)
Internet Protocol Version 4, Src: 172.17.2.100 (172.17.2.100), Dst: 255.255.255.255 (255.255.255.255)
User Datagram Protocol, Src Port: 68 (68), Dst Port: 67 (67)
Bootstrap Protocol (Inform)
    Message type: Boot Request (1)
    Hardware type: Ethernet (0x01)
    Hardware address length: 6
    Hops: 0
    Transaction ID: 0xd46e0a9b
    Seconds elapsed: 0
    Bootp flags: 0x0000 (Unicast)
        0... .... .... .... = Broadcast flag: Unicast
        .000 0000 0000 0000 = Reserved flags: 0x0000
    Client IP address: 172.17.2.100 (172.17.2.100)
    Your (client) IP address: 0.0.0.0 (0.0.0.0)
    Next server IP address: 0.0.0.0 (0.0.0.0)
    Relay agent IP address: 0.0.0.0 (0.0.0.0)
    Client MAC address: Dell_2f:d2:20 (d0:67:e5:2f:d2:20)
    Client hardware address padding: 00000000000000000000
    Server host name not given
    Boot file name not given
    Magic cookie: DHCP
    Option: (53) DHCP Message Type (Inform)
        Length: 1
        DHCP: Inform (8)
    Option: (61) Client identifier
        Length: 7
        Hardware type: Ethernet (0x01)
        Client MAC address: Dell_2f:d2:20 (d0:67:e5:2f:d2:20)
    Option: (12) Host Name
        Length: 11
        Host Name: computer
    Option: (60) Vendor class identifier
        Length: 8
        Vendor class identifier: MSFT 5.0
    Option: (55) Parameter Request List
        Length: 13
        Parameter Request List Item: (1) Subnet Mask
        Parameter Request List Item: (15) Domain Name
        Parameter Request List Item: (3) Router
        Parameter Request List Item: (6) Domain Name Server
        Parameter Request List Item: (44) NetBIOS over TCP/IP Name Server
        Parameter Request List Item: (46) NetBIOS over TCP/IP Node Type
        Parameter Request List Item: (47) NetBIOS over TCP/IP Scope
        Parameter Request List Item: (31) Perform Router Discover
        Parameter Request List Item: (33) Static Route
        Parameter Request List Item: (121) Classless Static Route
        Parameter Request List Item: (249) Private/Classless Static Route (Microsoft)
        Parameter Request List Item: (43) Vendor-Specific Information
        Parameter Request List Item: (252) Private/Proxy autodiscovery
    Option: (255) End
        Option End: 255
    Padding

No.     Time           Source                Source Port Destination           Destination Port Protocol Length Info
   1432 62.210721000   172.17.2.22           67          172.17.2.100          68               DHCP     365    DHCP ACK      - Transaction ID 0xd46e0a9b

Frame 1432: 365 bytes on wire (2920 bits), 365 bytes captured (2920 bits) on interface 0
Ethernet II, Src: Dell_5e:94:e3 (84:2b:2b:5e:94:e3), Dst: Dell_2f:d2:20 (d0:67:e5:2f:d2:20)
Internet Protocol Version 4, Src: 172.17.2.22 (172.17.2.22), Dst: 172.17.2.100 (172.17.2.100)
User Datagram Protocol, Src Port: 67 (67), Dst Port: 68 (68)
Bootstrap Protocol (ACK)
    Message type: Boot Reply (2)
    Hardware type: Ethernet (0x01)
    Hardware address length: 6
    Hops: 0
    Transaction ID: 0xd46e0a9b
    Seconds elapsed: 0
    Bootp flags: 0x0000 (Unicast)
        0... .... .... .... = Broadcast flag: Unicast
        .000 0000 0000 0000 = Reserved flags: 0x0000
    Client IP address: 172.17.2.100 (172.17.2.100)
    Your (client) IP address: 0.0.0.0 (0.0.0.0)
    Next server IP address: 0.0.0.0 (0.0.0.0)
    Relay agent IP address: 0.0.0.0 (0.0.0.0)
    Client MAC address: Dell_2f:d2:20 (d0:67:e5:2f:d2:20)
    Client hardware address padding: 00000000000000000000
    Server host name not given
    Boot file name not given
    Magic cookie: DHCP
    Option: (53) DHCP Message Type (ACK)
        Length: 1
        DHCP: ACK (5)
    Option: (54) DHCP Server Identifier
        Length: 4
        DHCP Server Identifier: 172.17.2.22 (172.17.2.22)
    Option: (1) Subnet Mask
        Length: 4
        Subnet Mask: 255.255.255.0 (255.255.255.0)
    Option: (43) Vendor-Specific Information
        Length: 5
        Value: dc034e4150
    Option: (15) Domain Name
        Length: 9
        Domain Name: contoso.com
    Option: (3) Router
        Length: 4
        Router: 172.17.2.1 (172.17.2.1)
    Option: (6) Domain Name Server
        Length: 8
        Domain Name Server: 172.17.2.22 (172.17.2.22)
        Domain Name Server: 172.17.2.21 (172.17.2.21)
    Option: (44) NetBIOS over TCP/IP Name Server
        Length: 8
        NetBIOS over TCP/IP Name Server: 172.17.2.22 (172.17.2.22)
        NetBIOS over TCP/IP Name Server: 172.17.2.24 (172.17.2.24)
    Option: (46) NetBIOS over TCP/IP Node Type
        Length: 1
        NetBIOS over TCP/IP Node Type: H-node (8)
    Option: (121) Classless Static Route
        Length: 8
        Subnet/MaskWidth-Router: 172.17.3.0/24-172.17.2.2
    Option: (249) Private/Classless Static Route (Microsoft)
        Length: 8
        Subnet/MaskWidth-Router: 172.17.3.0/24-172.17.2.2
    Option: (255) End
        Option End: 255
Comment: Issue returned after machine rebooted in a non-clean fashion after driver installation. End result is now warranty repair/replacement of the machine.
Comment: Machine came back. Issue returned after installing the OEM provided WiFi driver. (Dell Precision M6600 with Intel WiFi) Installing the driver from Intel resulted in correct functionality.
Comment: Wow, this is broad.  I can only add a list of things to check off the top of my head: DHCP (the actual response, wireshark it), firewall (local and network), the switch (acls, switchport, etc), antivirus software, duplicate IPs on the subnet, your routing table, and the phase of the moon over Redmond.
Comment: If I'm not mistaken, nslookup uses it's own DNS resolver, so testing resolution of dns.msftncsi.com with nslookup may be a bit of a red herring. Flush the DNS server cache and flush your DNS client cache and ping dns.msftncsi.com and see if it resolves correctly.
Comment: Pinging dns.msftncsi.com resolves to 220.127.116.11
Comment: Can you add other machines to your domain successfully? Why does ping to your DNS server fail? Have you firewalled more ports than you should have to your domain controllers?
Comment: @mfinni, I don't know why ping was failing, it's working on other machines hooked up to the same switch, both before and after adding them to the domain. Testing again, ping is working fine now.
Comment: Is windows still activated? Try connecting to your volume activation server and verify everything is ok there. I assume you have more than this one computer in your domain and all the other ones are working. At this point I would reimage the machine.
Comment: Yeah, that's what I'm going to do. It's just annoying because I just imaged that machine 4 weeks ago and it hasn't gotten much use in the meantime.
Comment: Re-imaging the machine did restore network connectivity, but also exposed an issue with the CPU overheating. Cleaning out the heat sinks seems to have fixed that issue on this machine, though I have no idea if the thermal issues have anything to do with this or if they were purely coincidental.
Answer: Dealing specifically with the "No Internet Access" message, Windows uses NCSI (Network Connectivity Status Indicator) for this.  This checks two things:

A request for http://www.msftncsi.com/ncsi.txt -
Page called ncsi.txt containing the following line of text with no terminating new line or other non-printing characters:  Microsoft NCSI
A request for DNS name resolution of dns.msftncsi.com -
Resolution of the DNS name to: 126.96.36.199

If either of these fail, you get the "No Internet Access" message.  I would guess that Office isn't even trying to register at this stage, you're getting a stock message based on NCSI having failed.  I'd fix the NCSI issue first then try and register Office again.
Comment: Testing those two work as expected. Adding this to test steps.
Comment: Just to say, `dns.msftncsi.com` doesn't seem to respond to pings, so if you try `ping dns.msftncsi.com`, it should successfully resolve the IP if it's working properly, even if the actual pings fail.
Answer: We had a similar issue with a couple of users with admin rights on their machines (developers) who were setting up their machines, including installing Office 2013.  One connected to his home network and activated Office that way, while the other contacted me.
Our small office uses a Watchguard router that includes a proxy server that requires no settings on the user end.  I added "allow range requests through unmodified," to no avail.  I then told Watchguard not to proxy that user at all.  But because his install had previously failed, I had to wander around his hard drive and registry deleting stuff before I could get it to work.
I know you said in reply to one of Massimo's answers that there's no proxy for the network, but it might be worth double-checking if you're not 100% certain.
Comment: That's curious. We've got a Firebox XTM 515 serving as a gateway for this machine, as well as the other machines I've successfully added to the domain and activated Office 2013 on. The Firebox is set up to proxy HTTP(s) traffic only, and pass the rest through unmolested. When I try to activate office, I don't see any connection logs on the Firebox, but do when I browse the web. I'm guessing either the connection is never attempted or the activation service uses another port. It only logs connections that match policies.
Answer: The issue turned out to be driver related. (DOH! I forgot to try a different driver version when uninstalling and re-installing the drivers.)
The OEM drivers caused the machine to have the "no internet access" symptom, and using a driver straight from Intel resulted in the system functioning correctly. The system is a Dell M6600 with an Intel 6200 WiFi card. The issue returned after I installed the WiFi driver from Dell, and I had to do a system restore to get the issue to revert, then install the driver from Intel, and the WiFi worked, as well as everything else.
Thank you everyone for the excellent suggestions!
Comment: Well, that doesn't make much sense.  I suspect that in the course of reinstalling your drivers, something else was fixed.  In any case, glad to hear you got it working.
Comment: Right, but the issue reappeared after the system was reimaged and the mobo was replaced. There was nothing preserved from the previous configuration, nothing special done to this system, it's just that installing that particular driver caused the issue to happen. I even installed each driver one by one, restarting the system between each driver installation after putting a fresh image on the machine, (yes, a tedious process, but I wanted to prove that that was the issue and that the driver change wasn't just masking some other issue), and that was the best conclusion I could come up with.
Answer: A different answer, probably not your case, but it's worth a shot: you said "no software firewall is enabled", so I'm assuming this include Windows Firewall too; but how did you disable it?
If you by chance disabled it by actually stopping the Windows Firewall service, then you must re-enable it immediately. That's not the proper way to disable the system firewall, and leads to all sort of weird networking problems (see here for a discussion). You can configure it to not block anything, but you should never actually stop the Windows Firewall service, which is a critical component of the networking stack in 6.0 and later Windows systems.
Comment: Disabled it when it was connected to the domain by GPO, when off the domain by setting the firewall state to off in the Windows Firewall with Advanced Security console.
Comment: This is fine, but make sure the "Windows Firewall" service is running even if the firewall is actually disabled.
Comment: it's definitely running :)
Answer: As you mention that the computer is joined to a domain, it is possible that there is a group policy setting a custom NCSI server instead of the default one from Microsoft. You should be able to see if there is a custom server defined by looking under
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\NlaSvc\Parameters\Internet
with the registry editor. There are different values that specify the server to use (both for DNS and HTTP test) and the expected results. If there is nothing unexpected there, a possibility would be that when you request http://www.msftncsi.com/ncsi.txt with a browser, you're going through a proxy that has access to Internet, while the computer doesn't. A network capture (e.g., with Wireshark) is often very useful to figure out many types of connectivity problems. Try to do a capture for some minutes, and check if you see any NCSI-related traffic and what the outcome is.
Another possibility might be that the Network Location Awareness service (in charge of the NCSI testing) is not running, although in this case I would not expect the system to say "No Internet Access".
Comment: Nope, not using a custom NCSI server. Also, the machine isn't domain joined anymore, (I removed it from the domain for testing purposes and can't re-add it because of its issues). Checked the key, all the values are still at their defaults. Also, the Network Location Awareness service is running.
Answer: You don't mention anything about a proxy, thus I'm assuming your network doesn't need one for Internet access; if this is the case, make sure you have no proxy configured in Internet Explorer, and also make sure you have no proxy configured for the system services; you can check this using the command netsh winhttp dump, and you can reset those settings to default (direct Internet access) using the command netsh winhttp reset proxy.
Comment: That's correct, there is neither a proxy for the network, nor is there one configured in IE or netsh winhttp dump
Answer: Long shot answer but something to look at... I had a Windows Server 2012 VM that would say No Internet Connection, though I could browse the web just fine.  Could also ping and connect to M$ dns.msftcsi site without issue.
What I found cleared the No Internet message, was re-enabling IPv6, even though we only use v4.
Comment: Re-enabling as in it was disabled at the start of your troubleshooting? IPv6 was enabled on this machine at the start of my troubleshooting, and I disabled it as a troubleshooting step (that I forgot to record). I just re-enabled it now to test, but still have the same issues.
Answer: I've also seen weird things with mixed drivers. During the builds if your not using a deployment tool you can still install the Dell Driver packs directly from DOS and basically loop through the installation of all drivers. When you download the Driver Pack they also have a list on Dell's support site that lists if there's more current drivers available or known issues with devices. To install the driver pack from DOS check out the tutorial here: http://www.1337admin.org/tutorials/manual-installation-of-a-dell-driver-pack-on-a-local-machine/
Be sure to manually type the commands as certain characters get messed up between the clipboard and a webpage and DOS or PowerShell windows. I use this technique every time and it probably saves me a good 30-45 minutes each time.
Comment: For the copy/paste issues, I find it useful to copy/paste into a good text editor before copy/pasting into a command prompt, or just running the command as a script at that point. This allows me to catch the weird formatting issues (like " " instead of " and non-breaking spaces, etc) that can result from a web copy before execution, and reduces copy-by-typing errors resulting from sloppy keyboarding/reading.


date_popup element not working when the form is rendered with ajax

Question: How to attach javascripts to form rendered with ajax?
In particular, I have problem with popup calendars in my form. They are not showing, when my form is rendered with ajax.
I am rendering form with javascript as follows:
$.get('/event-form', {}, function(data) {
$('#event-popup-container').html(data);

This code calls ajax callback "/event-form". returned variable 'data' containes my form. This form is displayed on web page in HTML element $('#event-popup-container'). It works OK, just date_popup elements in form don't show popup calendars. Propably I  have to attach some javascripts somehow, when the form is not loaded with page load, but with ajax call. But I have no clue how.
I have such a code in my menu callback of path '/event-form':
<?php
  //...
  $event_form = drupal_get_form('ef_event__form', $event_id, NULL);
  $output .= drupal_render($event_form);
  drupal_json_output($output);
?>

Can anybody help, how to make work all needed javascripts, when the form is loaded with ajax?
Answer: The problem is that you are not using any of AJAX helpers provided by Drupal. When you are using Form API AJAX, for example, all behaviors are re-initialised and functionalities like calendar added to new elements.
If you are not using Drupal-provided AJAX functionality, you need to manually call all behaviors with a proper context after your request is finished and DOM tree updated, probably by calling
Drupal.attachBehaviors(element)

on added DOM element.
Comment: thanks. Now I know where I have to place additional code. But I don't know what I should place there. Is there any general method to ad dall needed javascripts for some form element or should  I study date_popup source code and find it there?
Comment: @tomas.teicher All functions you need to re-execute are attached to `Drupal.behaviors`. Just loop over them and call them all.
Comment: thank you. Your answer works. But I am not sure whether it is needed to call all behavior's functions. As it is written in this thread https://drupal.org/node/1015468#comment-4227872, it is enough to add just form object as parameter. It works for me, too.
Comment: @tomas.teicher answer updated a bit. That's the best you can get from me, my experience isn't much larger than that :(


Erro ao usar o file-type

Question: Eu tinha feito uma pergunta aqui ontem, e a Blogueira me ajudou, passando esse código:
const http = require('http');
const fileType = require('file-type');
const url = 'http://cdn.sstatic.net/stackexchange/img/logos/so/so-logo.png';

http.get(url, res => {
    res.once('data', chunk => {
      if (!(fileType(chunk).ext == "png")) {
    console.log("deu ruim");
    // aqui vem o seu return
}
        res.destroy();
        console.log(fileType(chunk));
    });
});

Mas, ao colocar uma URL em que não é uma imagem (e está em http) o erro a seguir é exibido:
      if (!(fileType(chunk).ext == "png")) {
                           ^

TypeError: Cannot read property 'ext' of null

Alguém poderia me ajudar? Desde já, agradeço.
Answer: Na pequena documentação, é indicado que se a URL não tiver uma imagem com formato compatível, ele retorna null:

fileType(input)
  Returns an Object with:
  •ext - One of the supported file types
  •mime - The MIME type
  Or null when no match.

Então para resolver a sua questão, acredito que baste antes de fazer a comparação, verificar se o retorno é null - se for, a função termina ali:
http.get(url, res => {
    res.once('data', chunk => {
        if (!fileType(chunk)) return;
        // ... comparação, resto do código
    });
});

Edit:
Para apenas não gerar o erro caso a URL não aponte para uma imagem, é só testar primeiro se o retorno é null, e caso não seja, segue com a comparação:
const http = require('http');
const fileType = require('file-type');
const url = 'http://www.google.com';
// const url = 'http://cdn.sstatic.net/stackexchange/img/logos/so/so-logo.png';

http.get(url, res => {
    res.once('data', chunk => {
        if (fileType(chunk)) {
            if (!(fileType(chunk).ext == "png")) {
                console.log("alguma outra imagem");
            } else {
                console.log("imagem em png!");
            }
        } else {
            console.log("url não contem imagem");
        }
        console.log("a função continua aqui, pois não demos return");
    });
});

Comment: Mas é geral, não? Eu só quero que não dê return quando não é um PNG.
Comment: @Gabriel Você pode usar o `if` só para impedir que ele dê erro - mas pode seguir com o programa ao invés de dar `return`.
Comment: @Gabriel Por favor veja minha edição na resposta (tentei deixar completa).

Erro ao usar o file-type


what's the name of the theorem:median of right-triangle hypotenuse is always half of it

Question: This question is related to one of my previous questions.
The answer to that question included a theorem: "The median on the hypotenuse of a right triangle equals one-half the hypotenuse".
When I wrote the answer out and showed it a friend of mine, he basically asked me how I knew that the theorem was true, and if the theorem had a name.
So, my question:
-Does this theorem have a name?
-If not, what would be the best way to describe it during a math test? Or is it better to write out the full prove every time?
Comment: I independently proved it in fifth grade and my math teacher organized a column in the school newspaper which referred to the theorem using my surname.
Comment: One could call it the converse of the [Theorem of Thales.](http://en.wikipedia.org/wiki/Thales%27_theorem)
Comment: If you inscribe a right angled triangle in a circle, namely it's circumcircle, the median is the same as the radius of the circle and the hypotenuse is the diameter.
Answer: Here is a proof without words:
Answer: If you are interested in seeing proofs: see these proofs. You'll actually find two proofs (and illustrations) of the following theorems:

If a triangle is a right triangle, the median drawn to the hypotenuse has the measure half the hypotenuse (from which it follows that the median drawn to the hypotenuse divides the triangle in two isosceles triangles); and
If in a triangle a median has the measure half the length of the side it is drawn, then the triangle is a right triangle.

The proofs are not at all elaborate, and utilize properties you already know, so they are easy enough to reconstruct, if necessity dictates that you do so. Understanding "why" these theorems hold is the important point; correctly "naming" them is a less important.
Comment: @Babak: you're worth ${\small\infty}^{\Large\infty}$
Comment: Very nice guidance +1
Comment: $\small{+1}^{\Large{\infty}}$
Comment: In the first proof, how can we make tge assumption that the line drawn from the midpoint of hypotenuese to the midpoint of the opposite side is paralled to the base side?
Answer: You could call it a special case of Apollonius's theorem, or of the parallelogram law.
Comment: This is exactly how I remember it - as a special case of Appolonius theorem :-)
Answer: Let us consider the right triangle ABC with the right angle  and let AD be the median drawn from the vertex A to the hypotenuse
BC. We need to prove that the length of the median AD is half the
length of the hypotenuse BC.
Draw the straight line DE passing through the midpoint D parallel to the
leg AC till the intersection with the other leg AB at the point E. The angle BAC is the right angle by the condition. The angles BED and BAC are congruent as they are corresponding angles at the parallel lines AC and ED and the transverse. AB Therefore, the angle BED is the right angle.
Now, since the straight line DE passes through the midpoint D and is parallel to AC, it cuts the side AB in two congruent segments of equal length: AE = EB
So, the triangles AED and BED are right triangles that have congruent  AE and EB and the common DE. Hence, these triangles are congruent in accordance to the postulate  (SAS)  It implies that the segments AD and DB are congruent as corresponding sides of these triangles.
Since DB has the length half the length of the hypotenuse BC, we have proved that the median AD has the length half the length of the hypotenuse.
Answer: In a circle, a triangle which has for side a diameter is rectangle. This means the center of the circle is the mean point of the diameter, and the median is a radius of the circle.
You can prove this as a corollary to the fact that inscribed angles are half of the center ones. So I guess that is a corollary to this corollary.


Error in loading SecondActivity after splashscreen

Question: I'm facing an issue regarding intent to my SecondActivity, the main activity is the splash screen which has a progressbar. The progressbar intervals loads fine and when it  comes to switching to the next part on moving on to the the secondactivity, i get some errors which are not traceable and are real hectic. Here's my Second Activity's code:
package com.example.waleedmalik.computerparts;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.ToggleButton;

public class SecondActivity extends AppCompatActivity {

ToggleButton tb;
Button btn;
public static boolean tbflag;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_second);
    tb = (ToggleButton)findViewById(R.id.toggleButton1);
    btn = (Button)findViewById(android.R.id.button1);

    btn.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            tbflag = tb.isChecked();
            Intent in = new Intent(getApplicationContext(),
       GameActivity.class);

     startActivity(in);

    }

    });

}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_second, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
        return true;
    }

    return super.onOptionsItemSelected(item);
   }
}

Comment: Did you add your second Activity in manifest file?
Comment: Post your log details.
Comment:
Comment: 08-31 15:39:06.934    2617-2617/com.example.waleedmalik.computerparts E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: com.example.waleedmalik.computerparts, PID: 2617
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.waleedmalik.computerparts/com.example.waleedmalik.computerparts.SecondActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Button.setOnClickListener(android.view.View$OnClickListener)' on a null object reference
Comment: please post your activity_second xml.
Answer: Change the button initialization like this:
as
btn = (Button)findViewById(android.R.id.button1);
line to
btn = (Button)findViewById(R.id.button1);

Comment: Thanks a lot friends especially maciej and Hassan Usman,  it worked after this change :-) really appreciate it!


Atualizacao e publicação de aplicativo android privadamente

Question: Tenho a necessidade de publicar um aplicativo de forma privada, onde só quem tem o endereço ou liberação possa fazer download e atualizações via appstore, é possível controlar dessa forma a aplicação?
Consigo ao menos fazer atualização automática de um aplicativo sem precisar copiar para o celular e instalar por cima da versão antiga?
Comment: tem como sim, já realizei alguns testes em app publicado, informei meu e-mail ao desenvolvedor ele me colocou como beta tester, tente pesquisar sobre isso, ou espere um pouco alguém aqui com certeza saberá :) ... Seja bem vindo.
Answer: Existe uma forma de você criar um grupo de testers, onde somente eles podem receber o aplicativo, mediante a convite, veja este exemplo do google, para testar em primeira mao seus apps em formato beta.
Nesta página oficinal do google(ptbr) ensina como criar um grupo de testers, basta seguir as orientações da página.
Caso tenha dúvidas, esta página abaixo tem um passo-a-passo tambem, mas na pagina oficinal do google é mais que suficiente.
http://wcabralti.blogspot.com.br/2014/06/android-beta-testing-no-google-play.html


Consider the non-homogeneous linear recurrence relations $a_n=2a_{n-1}+2^n$ find all solutions.

Question: I'm having a hard time understanding how to find all solutions of the form $a_n = a^{(h)}_n+a_n^{(p)}$
I show that $a_n=n2^n \to a_n=2(n-1)2^{n-1} +2^n=2^n(n-1+1)=n2^n$.
I can show that $a_n^{(h)}$ characteristic equation $r-2=0 \to a_n^{(h)}=\alpha2^n$
But I'm stuck on $a_n^{(p)}$ characteristic equation $C2^n=2C\cdot2^{n-1}+2^n$
Simplifies to $C \neq C+1$, Looking online I saw that the solution is $a_n=c\cdot2^n+n2^n$, but I'm not sure how to get there.
Answer: Your homogeneous solution has $2^n$ in it already. When this happens, for the particular solution part, we cannot just use $C2^n$ (you have seen what happens if we do). Instead, the rule in this scenario is to modify the guess by multiplying by $\boldsymbol{n}$, i.e. try $a_n^{(p)}=C\color{red}{n}\cdot 2^n$.
Answer: Here is another take.
Let $b_n=2^n$. Then
$$
a_n=2a_{n-1}+2b_{n-1}, \quad b_n=2b_{n-1}, \quad b_0=1
$$
and so
$$
\pmatrix{
a_n \\ b_n
}
=
\pmatrix{
2 & 2 \\ 0 & 2
}
\pmatrix{
a_{n-1} \\ b_{n-1}
}
=
2
\pmatrix{
1 & 1 \\ 0 & 1
}
\pmatrix{
a_{n-1} \\ b_{n-1}
}$$
which gives
$$
\pmatrix{
a_n \\ b_n
}
=
2^n
\pmatrix{
1 & 1 \\ 0 & 1
}^n
\pmatrix{
a_0 \\ b_0
}
=
2^n
\pmatrix{
1 & n \\ 0 & 1
}
\pmatrix{
a_0 \\ b_0
}
$$
Therefore,
$$
a_n = a_0 2^n + n 2^n
$$
Answer: Let $a_m=b_m+2^m(a_0+a_1m+a_2m^2+\cdots)$
$$2^n=a_n-2a_{n-1}$$
$$=ba_n-2b_{n-1}+2^n(a_0+a_1n+a_2n^2+\cdots)-2^n(a_0+a_1(n-1)+a_2(n-1)^2+\cdots)$$
$$=ba_n-2b_{n-1}+2^n[a_1+a_2\{n^2-(n-1)^2\}+a_3\{n^3-(n-1)^3\}+\cdots]$$
For $a_r,$ the highest exponent of $n$ is $r-1$
$a_r=0\ \forall r\ge2$ as the coefficient of $2^n$ in the left hand side is $1$
Set $a_1=1$ so that $b_n=2b_{n-1}=2^rb_{n-r}; 0\le r\le n$


Call to weight in lm() within function doesn't evaluate properly

Question: I'm writing a function that requires a weighted regression. I've repeatedly been getting an error with the weights parameter, and I've created a minimal reproducible example you can find here:
wt_reg <- function(form, data, wts) {
  lm(formula = as.formula(form), data = data,
     weights = wts)
}

wt_reg(mpg ~ cyl, data = mtcars, wts = 1:nrow(mtcars))

This returns

Error in eval(extras, data, env) : object 'wts' not found

If you run this all separately, it works fine. I've dug into lm, and it appears the issue is a call to eval(mf, parent.frame()). Even though wts is in the parent.frame(), it doesn't appear to be evaluated correctly within the call. Here's a little more detail:
mf is assigned such that it's the same as
stats::model.frame(formula = as.formula(form), data = data, weights = wts,
    drop.unused.levels = TRUE)

When I run
parent.frame()$wts

it does return a numeric vector. But when I run
eval(stats::model.frame(formula = as.formula(form), data = data, weights = wts,
    drop.unused.levels = TRUE), parent.frame())

it doesn't.
I can run
stats::model.frame(formula = as.formula(parent.frame()$form),
    data = parent.frame()$data, weights = parent.frame()$wts,
    drop.unused.levels = TRUE)

and it works. You can test this yourself if you want using the example from the top.
Any thoughts? I really have no idea what's going on here...
Answer: Formulas are special in R in that they not only keep track of symbol/variable names, they also keep track of the environment where they were created. Check out
ff <- mpg ~ cyl
environment(ff)
# <environment: R_GlobalEnv>
foo <- function() {
  ff <- mpg ~ cyl
  environment(ff)
}
foo()
# <environment: 0x0000026172e505d8> private function environment (different each time)

The problem is that lm will try to use the data.frame you pass in and the environment where the formula was created to look up variables rather than the parent frame. Since you create the formula in the call to wt_reg, the formula holds on the the global scope. But wts only exists in the function scope. You can alter your function to change the environment on the formula to the local function environment then everything should work
wt_reg <- function(form, data, wts) {
  ff <- as.formula(form)
  environment(ff) <- environment()
  lm(formula = ff, data = data,
     weights = wts)
}

wt_reg(mpg ~ cyl, data = mtcars, wts = 1:nrow(mtcars))

The eval(mf, parent.frame) you are referring to in lm() is calling model.frame() with your formula. And from the description on the ?model.frame help page: "All the variables in formula, subset and in ... are looked for first in data and then in the environment of formula (see the help for formula() for further details) and collected into a data frame". So it again is looking in the environment of the formula, not the calling frame.
Alternatively, you could move the weights into the data object you are passing to lm itself. This would work
wt_reg <- function(form, data, wts) {
  lm(form, data = cbind(data, wts=wts),
     weights = wts)
}

wt_reg(mpg ~ cyl, data = mtcars, wts = 1:nrow(mtcars))

Comment: So then the call to `parent.frame()` in `eval(mf, parent.frame)` doesn't do what I think it's doing?
Comment: This still isn't working for me. See:

```
wt_reg <- function(form, data, wts) {
  form = as.formula(form)
  lm(formula = form, data = data,
     weights = wts)
}

wt_reg(mpg ~ cyl, data = mtcars, wts = 1:nrow(mtcars))
```
Comment: I'll also note that it's able to find the `data` and `form` arguments just fine! If I do this kind of thing with no weight argument it works.
Comment: What exactly do you mean by "still isn't working". Your code in the comment doesn't reassign the environment so it doesn't adrees the problem. `as.formula` will not change the environment for things that are already formulas. I added a bit about why `eval(mf, parent.frame())` doesn't do what you think it does. It works fine without the weights because all those objects are in the global environment.
Comment: Oh no, your version is working! I still don't understand why.
Comment: It struck me that I shouldn't need to explicitly call environment if I create the formula outside the function. Or that the data argument should break.
Comment: The thing that I just can't understand is why `ff <- as.formula(form , env = environment())` doesn't work.
Comment: Because `as.formula` is meant to coerce things that aren't already formulas. If you pass in something that is already a formula, it won't change it. That code would work if you passed in your formula as a string for example: `wt_reg("mpg ~ cyl", ...)`. Then the coercion to formula would use that environment.
Comment: Ah, I suppose I could have just looked at the source and figured that out. Thanks.


Dump a linux process's memory to file

Question: Is it possible to dump the current memory allocated for a process (by PID) to a file? Or read it somehow?
Comment: You might also want to read http://superuser.com/questions/236390/how-do-i-recover-a-form-in-firefox-without-installing-a-plugin and use gcore instead.
Comment: You can use my [proof-of-concept script](http://unix.stackexchange.com/questions/6267/how-to-unswap-my-desktop/6271#6271) that reads [`/proc/$pid/mem`](http://unix.stackexchange.com/questions/6301/how-do-i-read-from-proc-pid-mem-under-linux/6302#6302).
Answer: I've made a script that accomplishes this task.
The idea commes from James Lawrie's answer and this post: https://web.archive.org/web/20190921091546/http://www.linuxforums.org/forum/programming-scripting/52375-reading-memory-other-processes-post287195.html#post287195
#!/bin/bash

grep rw-p /proc/$1/maps \
| sed -n 's/^\([0-9a-f]*\)-\([0-9a-f]*\) .*$/\1 \2/p' \
| while read start stop; do \
    gdb --batch --pid $1 -ex \
        "dump memory $1-$start-$stop.dump 0x$start 0x$stop"; \
done

put this in a file (eg. "dump-all-memory-of-pid.sh") and make it executable
usage: ./dump-all-memory-of-pid.sh [pid]
The output is printed to files with the names: pid-startaddress-stopaddress.dump
Dependencies: gdb
Comment: Awesome! Just used it to discover which script a mysterious bash instance was running.
Comment: @mxmlnkn That's data (`rw-p`), the other ranges are for code (`r-xp`). If you want a dump of both, then go ahead and exchange `grep` for e.g. `cat`.
Comment: Why are you only grepping for and dumpying ranges with `rw-p` permissions?
Comment: This won't give a consistent picture unless you pause the process. Getting a core file would be much more appropriate.
Answer: I'm not sure how you dump all the memory to a file without doing this repeatedly (if anyone knows an automated way to get gdb to do this please let me know), but the following works for any one batch of memory assuming you know the pid:
$ cat /proc/[pid]/maps

This will be in the format (example):
00400000-00421000 r-xp 00000000 08:01 592398                             /usr/libexec/dovecot/pop3-login
00621000-00622000 rw-p 00021000 08:01 592398                             /usr/libexec/dovecot/pop3-login
00622000-0066a000 rw-p 00622000 00:00 0                                  [heap]
3e73200000-3e7321c000 r-xp 00000000 08:01 229378                         /lib64/ld-2.5.so
3e7341b000-3e7341c000 r--p 0001b000 08:01 229378                         /lib64/ld-2.5.so

Pick one batch of memory (so for example 00621000-00622000) then use gdb as root to attach to the process and dump that memory:
$ gdb --pid [pid]
(gdb) dump memory /root/output 0x00621000 0x00622000

Then analyse /root/output with the strings command, less you want the PuTTY all over your screen.
Comment: Is there a way of doing this in just bash/sh without gdb?
Comment: @Programming4life [gcore(1)](http://man7.org/linux/man-pages/man1/gcore.1.html)
Comment: So reading /proc//mem directly isn't an option? I get a read error if I try and open the 'file' in an editor.
Comment: The docs on kernel.org say that what `/proc/PID/maps` shows is specifically ["Memory maps to executables and library files (2.4)"](https://www.kernel.org/doc/html/latest/filesystems/proc.html#process-specific-subdirectories). Is that not accurate?
Answer: try
    gcore $pid

where $pid is the actual number of the pid; for more info see: info gcore
may take some time for the dump to happen, and some memory may not be readable, but is good enough... be aware also that it can create big files, I just created a 2GB file that way..
Comment: @CMCDragonkai use `gcore -a PID`
Comment: Is `gcore` dumping  a sparse file?
Answer: Pure bash solution:
procdump()
(
    cat /proc/$1/maps | grep "rw-p" | awk '{print $1}' | ( IFS="-"
    while read a b; do
        dd if=/proc/$1/mem bs=$( getconf PAGESIZE ) iflag=skip_bytes,count_bytes \
           skip=$(( 0x$a )) count=$(( 0x$b - 0x$a )) of="$1_mem_$a.bin"
    done )
)

Usage: procdump PID
for a cleaner dump filter out *.so memory mapped shared libraries and empty memory ranges:
procdump()
(
    cat /proc/$1/maps | grep -Fv ".so" | grep " 0 " | awk '{print $1}' | ( IFS="-"
    while read a b; do
        dd if=/proc/$1/mem bs=$( getconf PAGESIZE ) iflag=skip_bytes,count_bytes \
           skip=$(( 0x$a )) count=$(( 0x$b - 0x$a )) of="$1_mem_$a.bin"
    done )
)

Comment: One issue I have with this script is that the blocksize of 1 leads to a bandwidth of unacceptably slow ~30kB/s compared to using a blocksize equal to the page size (4096 for me) for which I get ~100MB/s! See [here](https://gist.github.com/mxmlnkn/05e1cd03a4102e353d792bd17687aed3). `getconf PAGESIZE` is used to get the page size and then the addresses and counts are divided by it.
Comment: So, from what I understand, the idea behind the cleaner dump is that only in-memory files have a size attached to the memory region in contrast to actual application memory, which has size 0 (as the size actually used size is unknown by the OS).
Comment: @mxmlnkn that was lazy of me, feel free to correct my answer.
Comment: Ok, will do. Note also that the count calculation is wrong because it is done with bd-ad but bd and ad are calculated only thereafter in the first bash snippet.
Answer: I made my own program to dump the entire process memory as well, it's in C so it can be cross-compiled to Android, which is what I needed.
You can also specify IP address and tcp port. Source code here.
Answer: man proc says :

/proc/[pid]/mem
                This  file  can  be used to access the pages of a process's
  memory through open(2), read(2), and lseek(2).

Maybe it can help you
Comment: That's not sufficient, reading another process needs a combination of /proc//{mem,*maps}, ptrace, and some signal handling to avoid hanging the target process.
Comment: @Tobu [Indeed](http://unix.stackexchange.com/questions/6301/how-do-i-read-from-proc-pid-mem-under-linux/6302#6302). I wrote a [proof-of-concept script](http://unix.stackexchange.com/questions/6267/how-to-unswap-my-desktop/6271#6271).
Answer: Tool to dump process to standard output, pcat/memdump:

http://manpages.ubuntu.com/manpages/gutsy/man1/pcat.1.html
http://www.porcupine.org/forensics/tct.html
Comment: This one is obsolete (removed at maintainer's request); I installed the old package anyway and it failed with "Input/output error; did you use GCC with another machine's header files?".
Answer: You can now use procdump from SysInternals suite on Linux:
https://github.com/Microsoft/ProcDump-for-Linux
Answer: If you want to dump a separate memory segment of the running process without creating huge core file (say with gcore), you can use a small tool from here.
There is also one-liner in README if you wish to dump all readable segments into separate files.

Dump a linux process's memory to file


Infinite-dimensional inner product spaces: if $A^3 = A^2$ for a normal operator $A$, then $A^2 = A$

Question: Paul R. Halmos, Finite-Dimensional Vector Spaces, sec. 80, p.162, exercise 5(c):

If $A$ is normal and $A^3 = A^2$, then $A$ is idempotent.

The finite-dimensional case has been asked before, but our $A$ here is a linear operator on a possibly infinite-dimensional inner product space. The underlying field may be real or complex.

My attempt so far: I see that the finite-dimensional version of this problem (over a complex field) is easy to address using the Spectral Theorem for normal operators (on complex inner product spaces). To prove the assertion in infinite dimensions, my attempts so far have been around showing that the "distance" between the vectors $A^2x$ and $Ax$ (if $x$ is an arbitrary vector) is zero, i.e., $\Vert A^2x-Ax\Vert = 0$. Haven't been successful. Would appreciate help. Thanks.
Comment: Yes, so far I've only found the [version](https://math.stackexchange.com/q/2994498/721644) on a finite-dimensional complex inner product space. Maybe [this link](https://www.google.com/search?q=%22idempotent+normal+operator%22+AND+%22infinite+dimensional%22&client=ms-android-samsung-ga-rev1&sxsrf=ALeKk01YqnihAULq0rGZyaDRCHfgrg-afA:1591861559851&filter=0&biw=1173&bih=2206&dpr=2.63) will be of some use.
Comment: Thanks. Will study the material on the link.
Answer: In general, if $T^\ast T=0$ for some linear operator $T$, then $\langle Tx,Tx\rangle=\langle T^\ast Tx,x\rangle=0$ for all $x$. Hence $Tx=0$ for all $x$, i.e. $T=0$.
Now, since $A$ is normal, $B=A^2-A$ is normal. As $A^2=A^3$, we have $A^2=A^3=A(A^2)=A(A^3)=A^4$. Therefore $B^2=0$. It follows that $(B^\ast B)^\ast(B^\ast B)=(B^\ast)^2B^2=0$. Hence $B^\ast B=0$. In turn, $B=0$, i.e. $A^2=A$.
Comment: Looks good! Thanks :-)
Answer: This is going to sound familiar :)
Let $v$ be any vector, form the subspace generated from $v,Av,A^2v$; it is $A$-invariant since $A^3=A^2$. So, from the finite-dimensional case, it follows that $A^2v=Av$.
Comment: No, a normal operator that satisfies $A^2(A-I)=0$ can have only 0 and/or 1 as eigenvalues, so it is diagonalisable over the reals as well.
Comment: That's an elegant method indeed! However, it seems to me that this method won't work in case the underlying field is real. That's because, the Spectral Theorem for normal operators (in finite dimensions) holds if and only if the underlying field is complex, not real. Accordingly, an arbitrary normal operator on a finite-dimensional real inner product space is not guaranteed to be diagonalizable. Thus, we can't really conclude "$A^2v = Av$", in the finite-dimensional subspace suggested by you. Am I missing something here?
Comment: Yes, that's right! It was a subtle point that I missed ...


How to create a Notification system in D7?

Question: I am new to Drupal and was wondering if there is a module that can serve as a Notification system for logged-in users on my site?
Since my nodes consist mainly of images generated by users, I would like for logged in users to be able to see how many members liked their images, made a comment, followed them, etc.
P.S. I read almost all similar posts here and none of them provided any clear explanation. Pointing to active sites that already use "these module(s)" would be of great help.
Thanks in advance,
Milos
Comment: Start off with the Flag module. This will allow users to individually mark content. Next, add the Views module, and if there's a views-related flag sub module, enable that. Views will allow you to query the flag data. Create a block via Views, and assign this to a template region via the Block admin UI. The core statistics module can also be enabled to track page impressions, and this data can also be queried via Views. This forum is better suited to specific questions, your questions are pretty generic and answers can be easily found online.
Comment: @ murraybiscuit - Could you please point me to online answers, I had no luck in the last two days, hence posting here. Will also check your solution proposal. Thanks in advance!
Answer: In the Drupal community, "notifications" are usually referring to email notifications sent to users.
Messages sent to users to indicate "likes", etc. are usually called "messages". So you should probably search for "messages" and "messaging" (instead of "notifications") to locate stuff about this type of user interaction.
One of the most popular Drupal modules for messages is HeartBeat:

Heartbeat displays user activity on a website. This module is an API to log activity. The logged data contains message structures, attributes and variables. Once the activity messages exist in the database, they will be parsed and build into activity streams.

However, the maintainer of Heatbeat has recently announced:

This project will be deprecated. The future would be in the module Message. It's much smaller and it cannot be compared to heartbeat when it comes to features. However the possibilities as API would be the same.

At the time of writing, Message is an API that you can use to build the required flagging and messaging by combining it with other modules in the message stack. As for social messaging functions, you need to  add those. The Heartbeat API already has all the necessary functionality built-in.  Today, it will take much less effort to get something working with Heartbeat than with Message, but maybe Message is still a better option than putting efforts into working with a module about to be depreciated,
Comment: Thanks @Free Radical but according to the author of Heartbeat, this module will be deprecated. I will check the [Message](https://www.drupal.org/project/message) module to see if it can meet my needs.
Comment: @mikabajic - I wasn't aware of that.  I've updated the answer to describe **Heartbeat** vs. **Message**.


link to create a user relationship type in views

Question: I have user relationship, statuses and views installed. I created a view which shows "users online". I need to add a link to the view, that would allow other users to "create a relationship" with other online users via the view.
The user relationship I created is a one way relationship and there is no need for approval.
Thank you.
Comment: Hello. Is your problem on the link generation side, or relationship creation in code side?
Comment: I have not done any custom coding. I assumed this was taken care of via the user relationship module. Based on your question, I believe I need help with both. Thanks.
Comment: Looks like answer below shows that 1) it is already partially provided by relationships (how did I miss that?) and 2) how to code missing parts :) Try it, but looks solid on first glance or two.
Answer: Hope this will help  you,
In Drupal 7, after configuration User relationship

Create a php field using views php module and after enabling, add below code in OUTPUT CODE within PHP tags.
  global $user;
  $opt = '';
  $requestee_id = $row->uid;
  $requester_id = $user->uid;
  if (user_is_logged_in()) {
    if ($requestee_id != $requester_id) {
      //for friend request button
      $relationships = user_relationships_load(array('between' => array($requester_id, $requestee_id)));
      if (empty($relationships)) {
        $opt = l(t('Add Friend') , "relationship/$requestee_id/request/2", array('html' => TRUE, 'absolute' => TRUE, 'query' => array('destination' => 'user/' . $requestee_id), 'attributes' => array('class' => array('ur-link add-friend-btn user_relationships_popup_link'))));
      }
      else {
        foreach ($relationships as $relationship) {
          if ($relationship->approved == 1 && user_relationships_ui_check_access('view', NULL, $relationship)) {
            $opt = t('Friends');
          }
        }
      }
    }
  }
  print $opt;

Note

2 is the default USER relationship.
Requester ID - Who requested and Requestee ID - to whome the user is requested.

Make changes as per your requirement.
Comment: Thanks. I will need time to digest and implement this. (Not yet proficient at coding).
Comment: OK, ill give a brief explanation, user_relationships_load is a function which is used to load the relationship between requester and the Requestee. If relationship exist means there is a relationship between. If there is a relationship then     outputting the FRIEND text else returning the ADD FRIEND link.
Comment: For some reason, the actual code is being output. Am thinking its because nothing related to relationship is among the "available variables". Kindly assist further.
Comment: Hello, am still not able to get it to work. Please can you walk me through the steps? I added the above code as directed but did not get the desired result. Thanks.
Comment: First check the default relationship(friend) ID is 2 or not. Go to admin/config/people/relationships and hover edit link you will get the default relationship(friend) ID. And remove * from the "Add friend" link, I have given it for highlighting the default relationship ID. And also check the USER IDs($row->uid).
Comment: Thank you. I can now see the link in the view. The default is 1. However I am informed that " this user does not exist" when I select 'add friend'. Please what do you mean by "also check the USER IDs($row->uid)". Thanks.


Epimorphisms and Algebras

Question: Just a quick question. Suppose a monad on $\mathbf{Set}$ (in particular monad's endofunctor preserves epimorphisms), are epimorphisms in the category of algebras also surjective?
Thanks
Answer: No. A well-known example is the category of rings, in which epimorphisms may fail to be surjective (e.g. $\mathbb{Z} \to \mathbb{Q}$).
What is true is that, for any monad on $\mathbf{Set}$, the regular epimorphisms in the category of algebras are precisely the surjective homomorphisms.

Epimorphisms and Algebras


Proving maxima for a combinatorial function

Question: I have the following function :
$$f(k)={n\choose k}(1+e^{-k})^n$$
Here $k$ can vary from $0$ to $n$. I plotted this function for different $n$ on wolfram alpha, like here (for n=20), an found that this function attains maximum value at $k=0$, but I am not able to prove it formally.
Can somebody give a hint how to prove it formally?
Comment: Domain is integers from 0 to n,  where n is some positive integer.
Answer: Hint : compute the discrete derivative $$  f(k+1)-f(k)= \frac{n!}{(n-k-1)!k!}\bigg(\frac{(1+e^{-k-1})^n}{k+1} -\frac{(1+e^{-k})^n}{n-k}\bigg) $$
and you can then study the function
$$ x\mapsto \frac{(1+e^{-x-1})^n}{x+1}-\frac{(1+e^{-x})^n}{n-x}$$
to determine the sign of it (when $x\in[0,n)$).


ADODB RecordSet as Access Report RecordSource

Question: I have a simple form, a query and a report in Access 2003.  I have to manipulate the results from the query in a recordset using VBA and then pass it on to the report as its RecordSource.
If I declare the recordset as RecordSet and use its Name property as the RecordSource of the report then it is working. However, because I need to edit the recordset, I though it would be easier to use an ADODB RecordSet as below.
The records set is declared as Dim rs As ADODB.RecordSet in a global module.
The rest of the code is;
Dim db As Database
Set db = CurrentDb
Dim con As ADODB.Connection
Set con = CurrentProject.Connection
Set rs = New ADODB.Recordset
Set rs.ActiveConnection = con
rs.Source = "Select * from XXX"
rs.LockType = adLockOptimistic
rs.CursorType = adOpenKeyset
rs.Open

'manipulate rs here....'

I used to pass the RecordSource of the report as myReport.RecordSource = rs.Name.
But the ADODB doesn't have a Name property.
How can I pass this recordset to the report as its RecordSource?
Thanks
Comment: I'm saying don't use a recordset -- just set the SQL of the Recordsource property to be the SQL you're using to open your recordset. If there's some reason that won't work, I don't see it. That's the standard way to do this, instead of setting the report's Recordset (which is something I've never needed to do in all my years of programming Access for a living).
Comment: Why do you think you have to do this? Why can't you just set the Recordsource in the report's OnOpen event?
Comment: I am actually setting the RecordSource property of the report at the report's open event, but it requires the name of the record set and ADODB Recordset doesn't have a name property.
Comment: @David-W-Fenton for what it's worth there are times you might like to do this - if you need to build a TSQL pass through query (to call a stored procedure) and set the recordset of the report to that.
Answer: You cannot bind a report to an ADO recordset in an mdb, only in an adp: http://support.microsoft.com/?id=287437
Comment: Yep, not possible with an ADODB.  So I just created a make table query and manipulated the data within that.  Then just bound the report to that table.
Answer: I don't have a copy of access 2003 to hand but from memory you just do
Set Me.Recordset = rs

Just had a look on the Microsoft KB and it looks like my memory is still working!
http://support.microsoft.com/kb/281998


Piano music with two treble clefs, and notes between staves

Question: I do not understand why there are two treble cleff staves and why there are music notes in the middle of the two staves. Which hand should I play those notes with and why are there two treble cleff staffs? Thanks for any help! :)
Here is a picture of what I am talking about just in case someone needs clarification.
Comment: Good question. The sheet music for the song 'Steppin Out' by Joe Jackson has two treble clefs just like this and I was wondering how that was to be played.
Answer:
The top staff is the (vocal) melody.  In principle this could be given to the vocal performer by itself for him/her to sing from in a vocalist+pianist type of situation; as the pianist, you do not play these.
The lower two staves comprise the grand staff common to piano music.  As indicated in other answers this is organized so as to show the right vs. left hand parts to be played on the instrument.  In principle, the grand staff by itself could be provided to the piano player in a vocalist+pianist type of situation.
Answer: The two staffs on a piano grand staff are primarily used to differentiate between your left and right hands. Sometimes, the left hand will need to play notes in the treble clef range, and sometimes the right hand will be playing notes in the bass clef range. In those cases, you will have two treble or bass clefs. In this case, however, the piano music is only in the two staffs with the brace around them at the left. The treble staff at the top of the page is only for a singer.
When you have notes between two staffs, you will still be able to tell which staff the notes are associated with based on where the ledger lines come from and where the note stems go.
In this case, the notes in the middle of the grand staff are on ledger lines that extend from the treble clef, and the stems are pointing down, indicating they are in the lower voice of the treble clef. In your example, they are As and C#s.
Answer: Notice that on the middle stave, the notes with up tails are exactly the same as the notes on the top stave.This is because the right hand, playing the middle stave, is producing the melody line.
On the middle line are also notes with down tails.These are part of the  accompaniment, played with right hand. The bottom line is standard bass, played with left hand.
The top line in songs written out in this way will always be the melody line, to go with the words printed above.
The other part of your question is answered with - the notes on LEDGER LINES are too low to fit on the middle stave, but too high to be played using the left hand. So they are written like that to make the tune playable.  As in the second bar, the A and middle C# can be reached using the right hand, while the left hand plays a low F#.You wouldn't reach the A/C# with your left hand, whilst holding the low F#.
Also note that with ordinary music, written in standard form using treble/bass clefs, the tails are generally put up or down to keep it all looking tidy, so it's not going to be the same format as your example.
Comment: The top voice of the accompaniment does not have to be *identical* to the sung melody; in this case it is 99% the same, but there are other songs where the top piano voice diverges more from the sung melody.
Comment: Actually, in the second bar, there should be a note to represent the word 'the' shown on the 'middle' stave.
Comment: that would indicate that the note is to be sung, but is not included as part of the accompaniment.
Comment: All the other notes are included in the top of the right hand tune, why not that one?
Comment: @Tim: If pianist uses the right thumb and index finger to play the lower A's and C#'s in the treble clef, the distances between the fingers will be reasonable, but adding a "D" to the mix would require that it be played with the middle finger--quite a stretch from the upper "A".  That having been said, I'm surprised the fourth beat doesn't omit the C# so as to free up the index finger for the E.  Otherwise, playing that beat smoothly would seem to require six fingers.
Comment: @Tim: here's the composer's recording of the song, make of it what you will as to what the piano is supposed to be playing and what's with that word "the". I think this sheet music has been mucked about with, but it could certainly work to sing it without playing it ;-) https://www.youtube.com/watch?v=J5pECaW-VMI
Comment: @Tim there is no "rule" that says the accompaniment must play exactly the same notes that are sung the soloist. In fact that is very rarely the case. In the example, the soloist is unlikely to sing in strict rhythm, and a inconsistent timing between the soloist and piano playing a note on "the" would sound poor. The pianist can use the soloist's "the" as a cue to play the following 16th-notes in time with the singer. Quite likely, the pitch of the note sung to "the" would not be an accurate D either, so a piano D would make the singer sound "out of tune" for no good musical reason..
Answer: I know this is wrong in a pure sense.  BUT think of the three staves as a lead sheet.  The top G clef is the melody line and the both two staves are the chords.  This assumes a piano solo.
Answer: May this not be counted as a complete answer for I unfortunately do not have enough reputation to comment.
A few possibilities:

the top staff is for another instrument or vocals (in which case I
think it would possibly be smaller);
I think the piece might be written for an organ as
well.(see Bach's Toccata and Fugue example);
as others have stated, the two lower staves are the grand staff;
the player might play the first staff with the right hand, and the two lower ones with the left hand; I've encountered such a piece once.


Marginalizing a high-dimensional multivariate Gaussian distribution

Question: I have an 11-dimensional multivariate Gaussian, with a covariance matrix with non-zero values in every element. My goal is to marginalize this down to 4 dimensions, but I'm having some computational issues running these 7 integrals over the 11D Gaussian (time and accuracy - I have a lot of runs to make, and it needs to be accurate).
I've seen in various sources that to marginalize over a Gaussian, you simply need to take the subset of the covariance matrix / mean vector corresponding to which variables you want to end up with. For example, if you wanted to marginalize a 4d gaussian over $x_2$ and $x_4$, your new covariance matrix would be:
$\Sigma'=\pmatrix{\Sigma_{11} & \Sigma_{13}\\\Sigma_{31} & \Sigma_{33}}$
Which could then be used to generate a new 2-dimensional Gaussian over $x_1$ and $x_3$.
Is this true? I'm not exactly seeing how this is possible, unless of course there are no covariances between variables you want to keep, and variables you are marginalizing over. I ran a quick example, using the following 4d covariance matrix:
$\Sigma=\pmatrix{2 &0&3&0\\0&4&0&0\\0&0&3&0\\6&0&0&5}$
If I want to marginalize again over $x_2$ and $x_4$, my new covariance matrix is then:
$\Sigma'=\pmatrix{2&3\\0&3}$
(Note we lose all information about the 6 in the lower left corner!) Now, I can compare this new Gaussian over $x_1$ and $x_3$ to my same result as if I had integrated along $x_2$ and $x_4$, rather than just taking a subset of the covariance matrix, and here are the 90% contours:

They definitely do not agree, as some on the internet claim they might! However if I redo the example using a covariance matrix that only has covariances among $x_1$ and $x_3$, the results are identical..
So am I right in my guess that the "covariance matrix subset" rule is only valid for covariance matrices with covariances among the resulting variables?
And if so, are there any other simple methods to marginalize over high-dimensional gaussians that won't kill my time or precision?
Thanks so much in advance!
Answer: Your 4D covariance matrix is actually not a covariance matrix firstly because it is not symmetric. That is why you lose $6$ in the lower left corner. It also should be in the upper right corner. Replicate your experiments with this in mind. Also, keep your covariance matrix positive semi-definite.
Due to the definition of MV Gaussian, every subset of the Gaussian RVs inside are multivariate, and you can construct the covariance and mean as you read in your sources,  or here.
Comment: Doh! You are 100% right. In that case, I apologize for the silly question! I tried my example again with a positive-semidefinite symmetric matrix, and it worked perfectly. Oops! Thank you so much


Finding the remainder of a large multiplication in C++

Question: I would like to ask some help concerning the following problem. I need to create a function that will multiply two integers and extract the remainder of this multiplication divided by a certain number (in short, (x*y)%A).
I am using unsigned long long int for this problem, but A = 15! in this case, and both x and y have been calculated modulo A previously. Thus, x*y can be greater than 2^64 - 1, therefore overflowing.
I did not want to use external libraries. Could anyone help me designing a short algorithm to solve this problem?
Thanks in advance.
Answer: If you already have mod A of x and y, why not use them? something like,
if,
x = int_x*A + mod_x
y = int_y*A + mod_y

then
(x*y)%A = ((int_x*A + mod_x)(int_y*A + mod_y))%A = (mod_x*mod_y)%A

mod_x*mod_y should be much smaller, right?
EDIT:
If you are trying to find the modulus wrt a large number like 10e11, I guess you would have to use another method. But while not really efficient, something like this would work
const int MAX_INT = 10e22 // get max int

int larger = max(mod_x, mod_y) // get the larger number
int smaller = max(mod_x, mod_y)
int largest_part = floor(MAX_INT/smaller)
if (largest_part > larger):
    // no prob of overflow. use normal routine
else:
    int larger_array = []
    while(largest_part < larger):
        larger_array.append(largest_part)
        larger -= largest_part
        largest_part = floor(MAX_INT/smaller)

   // now use the parts array to calculate the mod by going through each elements mod and adding them etc

If you understand this code and the setup, you should be able to figure out the rest
Comment: I use them, but in a bad scenario they could be like 10^11 and 10^10, and in this case their multiplication overflows.

I tried the following:

`ll big_num_mult(ll x, ll y)
{
 if (y != 0 && x > C / y)
 {
  ll h[4], res = 0;
  h[0] = x >> 48;
  h[1] = (x & 0xFFFFFFFFFFFF) >> 32;
  h[2] = (x & 0xFFFFFFFF) >> 16;
  h[3] = (x & 0xFFFF);
  for (int i = 0; i < 4; i++)
  {
   res = (res + y*h[i])%A;
  }
  return res;
 }
 return (x*y)%A;
}`
Comment: forgot to say that I actually edited so that it would work with large numbers like you said.


Finding area via double integrals, transformation and change of variables.

Question: Find the area of the closed region D formed by the lines $x + y = c$ ,
$x + y = d$, $y = ax$, and $y = bx$ where $(0 < c < d, 0 < a < b)$ by first transforming it into a rectangle with area D' with sides d - c and b - a in the u-v plane and then via double integration.
Attempt at a solution: I found the variable relationship to be $x=\frac{u}{1+v}$ and $y=\frac{\left(u\cdot v\right)}{1+v}$ but am unable to form the double integral as the closed region D seems to be neither horizontally nor vertically simple.
Answer: If the region is neither horizontally nor vertically simple, you have not succeeded in transforming it into a rectangle.
Start with $(x,y)$

Transform $(x,u=y+x)$

We'd like to map the red and green lines to vertical lines, say to $v=c$ and $v=d$ respectively, so transform $(v=\frac{(d-c) \left(x-\frac{u}{a+1}\right)}{\frac{u}{b+1}-\frac{u}{a+1}}+c , u)$
Comment: How do we translate that complex expression into a double integral format?
Comment: @bishopqpalzm An area is of the form $\int_S dx dy$ for a set $S$, so compute the Jacobian as a function of $u,\,v$ to rewrite the integral as $\int_S |J|dudv$. If in this new coordinate system $S$ isn't a rectangle, the transformation is inappropriate; but Wouter took care of that.
Answer: Put
$$u:=x+y,\quad v:={y\over x}\ ,$$
and solve for $x$ and $y$:
$$x(u,v)={u\over1+v}, \quad y(u,v)={uv\over 1+v}\ .$$Inspection of the figure then shows that
$$\psi:\quad (u,v)\mapsto \bigl(x(u,v),y(u,v)\bigr)$$
maps the rectangle $R:=[c,d]\times[a,b]$ in the $(u,v)$-plane bijectively onto your domain $D$ in the $(x,y)$-plane. One computes
$$[d\psi(u,v)]=\left[\matrix{{1\over 1+v}&-{u\over(1+v)^2}\cr{v\over1+v}&{u\over(1+v)^2}\cr}\right]\ ,$$
so that we obtain the Jacobian
$$J_\psi(u,v)={\rm det}[d\psi(u,v)]={u\over(1+v)^2}\ .$$
This leads to
$${\rm area}(D)=\int_D1\>{\rm d}(x,y)=\int_R1\> J_\psi(u,v)\>{\rm d}(u,v)=\int_c^d\int_a^b {u\over(1+v)^2}\>dv\>du\ ,$$
which I may leave to you.


D8 Prepopulate webform full_address value field from url?

Question: I am able to prepopulate the name, date, body etc they are single value elements.  The full_address.value field wont accept the address city state value in the url.
from views rewrite link I have tried full_address.value (changes to full_address_value in url), full_address by itself and full_address-value.
None of those work. I see the value in the url however, it doesn't prepopulate the full_address.value element.  Ideas? Syntax issue in rewrite?
Answer: Thru trial and error I made the composite element full_address prepopulate using
&full_address[value]= {{ field_address }} as the receiving field/element name.
putting the brackets in made it work. Ahhh...


change path for file to copy in other path

Question: I use the following API to copy file to specific folder (which is working)
ncp(folderPath,__dirname + "/newfolder", function (err) {
....

https://github.com/AvianFlu/ncp

c:\Users\WebstormProjects\NodeParent\node_modules\samplenodeapp\controller

The problem is that this create for me a folder inside the controller of   samplenodeapp(since the above code inside the controller) and I want it to create it one level up I mean
instead
samplenodeapp
 -controller
   -newFolder

I want
samplenodeapp
 -controller
 -newFoler

That the new folder will be in the same level of the controller,how its recommended to do it ?
of course I can split the value but there is better way to do it?
I mean if there is better way then the following
var localPath = __dirname;

localPath = localPath.substr(0, localPath.lastIndexOf("\\"));

Answer: You can use path.join
var path = require('path');
var destination = path.join(__dirname,'../newfolder');
ncp(folderPath,destination, function (err) {
...


reposition autocomplete .pac.container on mobile window resize

Question: I've spent a day trying to solve a problem. When a user zooms in on a page, the google places autocomplete .pac-container is no longer displayed under the corresponding input field. I have spent a day testing and the thing I found was this from Google: https://code.google.com/p/gmaps-api-issues/issues/detail?id=3416.
Let me explain in more detail. When I load a page with an initial scale of 1 on the viewport, and click on the search input field, the autocomplete suggestion box drops down exactly where it should. However, when I zoom in or out on that page on a mobile device, the .pac-container loses its position:

As you can see, the container is now gapped below the input field. I have tried a bunch of stuff, such as clearing the style of the .pac-container when the input field has focus. Nothing works. Does anyone have a solution?
Answer: I have just managed to fix this issue in my use case by simply adding 'height: auto' to the body css. Fixed the problem and now the .pac-container positions exactly where the input is required.


Converter String em Array - Java/Groovy

Question: Preciso converter uma variável string em um array, tentei fazer da seguinte forma, possuo a variável string conteudoLote, onde seu valor é:
[["4","SCAB171301BF5","Vazio","Lexmark International","50F0Z00",null,null,"2017-10-27 08:54:56",false,"ROMUALDO SANTOS"]]

Tentei converter a mesma para array da seguinte forma:
def array = conteudoLote.toCharArray()
for (List listaTeste : array){
    logger.info("NÚMERO DE SÉRIE: "+listaTeste.get(1).toString()) //Aqui serve somente para visualizar o conteúdo do index 1 do meu array
}

Porém ocorreu o seguinte erro:
Cannot cast object '[' with class 'java.lang.Character' to class 'java.util.List'

Como posso converter essa string para array então? Minha necessidade é conseguir pegar essa parte da string SCAB171301BF5 que seria o index 1 no caso.
Comment: Você já transformou a String em um array de char. No seu `for` você deve trocar `List` por `char`.
Comment: @LeonardoLima, como posso acessa o conteúdo desse meu `array` assim? Pois preciso por exemplo pegar isso da minha string `SCAB171301BF5` que seria o index 1 do meu array
Answer: Se sua variavel é uma string e que é um array:
def arrayString = '''[["4","SCAB171301BF5","Vazio","Lexmark International","50F0Z00",null,null,"2017-10-27 08:54:56",false,"ROMUALDO SANTOS"]]'''

Você pode dar um Eval.me()
def lista = Eval.me(arrayString)

lista[0].each{
    println it
}

Pode testar aqui, no groovy console
Answer: Não sei se é isto que tu queria fazer, mas dá uma olhada no código que gerei a partir da tua pergunta:
public static void main(String[] args) {
    //teu vetor tem valores null e false (boolean) que não podem estar no vetor
    String[] vetor= {"4","SCAB171301BF5","Vazio","Lexmark International","50F0Z00","2017-10-27 08:54:56","ROMUALDO SANTOS"};

    for (String palavra : vetor) {
        char []letras = palavra.toCharArray();

        for (char letra : letras) {
            System.out.println(letra);
        }
    }
}

Converter String em Array - Java/Groovy