text:
Q: L2TP/IPsec VPN Debian/Ubuntu IPsec fails to negotiate or establish security associations I spent 2 days to configure and figure what's wrong with this setup of L2TP/IPsec VPN. I'm using Debian 8.6 on my VPS server and on my Virtual machine on laptop I'm using Ubuntu 14.04.5. On my VPS im using Strongswan for IKE, xl2tpd and ppp. I have error from Charon called "no shared key found for MY VPS IP ADDRESS - MY IP ADDRESS" which can u see on this logs from journal. Here are files and logs from my Debian, Ubuntu and files content, i don't know what's wrong. I think its small error or something is missing which i can't see here.
journalctl log http://i.imgur.com/TynjKk3.png
/etc/ipsec.conf
config setup
    # strictcrlpolicy=yes
    # uniqueids = no

# Add connections here.
conn vpnserver
        type=transport
        authby=secret
        pfs=no
        rekey=no
        keyingtries=1
        left=%any
        leftprotoport=udp/l2tp
        #leftid=@vpn.example.com
        right=%any
        rightprotoport=udp/%any
        auto=add

/etc/ipsec.secrets

MY VPS IP ADDRESS %any: PSK "testkeyy1234"

/etc/xl2tpd/xl2tpd.conf

[global]
listen-addr =
  access control = no
  debug avp = yes
  debug network = yes
  debug state = yes
   debug tunnel = yes
[lns default]
ip range = 192.168.200.100-192.168.200.110
  local ip = 192.168.200.10
refuse pap = yes
  refuse chap = no
  require authentication = yes
  name = l2tpd
  ppp debug = yes
  pppoptfile = /etc/ppp/xl2tpd-options
  length bit = yes

/etc/ipsec.d/l2tp-psk.conf

conn L2TP-PSK-NAT
  rightsubnet=vhost:%priv
  also=L2TP-PSK-noNAT
conn L2TP-PSK-noNAT
authby=secret
  pfs=no
  auto=add
  keyingtries=3
    rekey=no
  dpddelay=10
  dpdtimeout=90
  dpdaction=clear
  ikelifetime=8h
    keylife=1h
  type=transport
  left= GATEWAY IP
  leftprotoport=17/1701
right=%any
  rightprotoport=17/%any
conn passthrough-for-non-l2tp
    type=passthrough
    left=<MY VPS IP ADDRESS>
    leftnexthop=<MY VPS GATEWAY ADDRESS>
    right=0.0.0.0
    rightsubnet=0.0.0.0/0
    auto=route

/etc/ppp/xl2tpd-options

mru 1280
  mtu 1280
  require-mschap-v2
  auth
  nodefaultroute
  lock
  proxyarp
  require-chap
  ms-dns 8.8.8.8
  ms-dns 8.8.4.4

/etc/ppp/chap-secrets

user      l2tpd   password       *

Here are log from Ubuntu connection info i have Error 300 comunicate
Linux log http://i.imgur.com/ET2scWn.png
I checked ipsec verify command and it gives me no errors. Here is rest of ubuntu files content:
/etc/ipsec.secrets

%any MY VPS IP ADDRESS: PSK "testkeyy1234"

/etc/ipsec.conf

version 2.0
  config setup
    plutodebug=none
    strictcrlpolicy=no
    nat_traversal=yes
    interfaces=%defaultroute
    oe=off
    protostack=netkey

conn %default
    keyingtries=3
    pfs=no
    rekey=yes
    type=transport
    left=%defaultroute
    leftprotoport=17/1701
    rightprotoport=17/1701 conn test      authby=secret
    right=<MY VPS IP ADDRESS>
    rightid="<MY VPS IP ADDRESS>"
    auto=add

/etc/xl2tpd/xl2tpd.conf

[global]
debug avp = no
  debug network = no
  debug packet = no
  debug state = no
  debug tunnel = no
[lac test]
  lns = MY VPS IP ADDRESS
  pppoptfile = /etc/ppp/test.options.xl2tpd
  length bit = yes
  redial = no

/etc/ppp/test.options.xl2tpd

plugin passprompt.so
  ipcp-accept-local
  ipcp-accept-remote
  idle 72000
  ktune
  noproxyarp
  asyncmap 0
  noauth
  crtscts
  lock
  hide-password
  modem
  noipx
ipparam L2tpIPsecVpn-test
  promptprog "/usr/bin/L2tpIPsecVpn"
refuse-eap
  refuse-pap
remotename ""
  name "user"

A: It looks like you didn't put a space before the colon in %any: PSK. There must be at least one space character on both sides of the colon (unless the colon starts the line), otherwise strongSwan's stroke plugin won't be able to load the secret.


text:
Q: Electrostatic energy of two point charges separated by a given distance Find an expression for the electrostatic energy between two point charges of charge $Q_1$ and $Q_2$ separated by a variable distance $z$ using the formula:
$W = \int_{V'}{\frac{1}{2}\epsilon_0 E^2 d\tau'}$
Separate this expression into a divergent part that doesn't depend on $z$, and a finite part that does depend on $z$.
My attempt:
I set $Q_1$ on the origin, and $Q_2$ a distance z away on the z-axis. The vector connecting $Q_1$ to $Q_2$ is given by:
$r = (0,0,z)$
The vector connecting $Q_1$ to the reference point is:
$r_1 = (x',y',z')$
The vector that connects $Q_2$ to the reference point is:
$r - r_1 = (x',y',z'-z)$
$E = \frac{kQ_1r_1}{|r_1|^3} +\frac{kQ_2(r-r_1)}{|r-r_1|^3}$
$|r_1|^3 = (x'^2 + y'^2 + z'^2)^{3/2}$
$|r-r_1|^3 = (x'^2 + y'^2 + (z'-z)^2)^{3/2}$
The volume integral is then evaluated over all of real space, but I'm really not sure how to evaluate it, if there's a simpler way, or if my line of reasoning is correct to begin with.
Edit: Following the suggestion in the comments to make the origin my reference point:
$r_1 = (0,0,0)$
$r_2 = (0,0,z)$
then,
$E = \frac{kQ_1}{|r_1|^3}r_1 + \frac{kQ_2}{|r_2|^3}r_2$
Where
$|r_1|^3 = 0$
$|r_2|^3 = z^3$
However, this causes the term involving $Q_1$ to be infinite, so I'm not sure how exactly to proceed.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Confused with PowerPC's Registers's Value(s)? So, I've been going along learning PowerPC for simple reversing projects for Xbox, but I always get tangled up on things like this.
    lwz       r11, 0(r29)   # Loads 0x34 from 0x10710 and stores in r11
    lwz       r10, 4(r29)   # Loads 0x64 from 0x10714 and stores in r10
    addi      r11, r11, 0x7F # r11 = 0x34 + 0x7F = r11 = 0xE3
    clrrwi    r10, r10, 7   # r10 = r10 (0x64) + 0xFFFFFF80
    clrrwi    r31, r11, 7   # r31 = r11 (0xE3) & 0xFFFFFF80

Anyways, what I'm having trouble understanding is the last two lines. How could a register have one value + another? And how could another register have one value & another? And if I were to have addition as the next line, what value would I add to? Sorry, this is a weird transition since my native languages are C++ and C# and I don't feel like giving up on this one as it's so much fun despite the troubles I'm having.

A: I don't understand the '+' in the comment "# r10 = r10 (0x64) + 0xFFFFFF80", and it could be a typo. But I understand the comment on the next line, "# r31 = r11 (0xE3) & 0xFFFFFF80".
If you look at the PowerPC 2.02 Book 1 documentation for 'Rotate Left Word Immediate then AND with Mask M-form', it shows what is actually done for clrrwi.
clrrwi Rx,Ry,n
is equivalent to
rlwinm Rx,Ry,0,0,31-n
For clrrwi, rlwinm rotates left the word 0 bits, so there is no rotate done for clrrwi instructions. It generates a mask with 1's in bits 0-24 and zero elsewhere (bits 25-31), so the mask generated for n=7 is 0xFFFFFF80. The rotated data are ANDed with the generated mask, so this is the reason that the comment for the second clrrwi makes sense. clrrwi is generating a mask to clear the right n bits in a word, and 0xFFFFFF80 is the mask used to do the clear.
By the way, 0x34+0x7F=0xB3.


text:
Q: Creating a dynamic 2D matrix in Java I want a dynamic matrix, number rows and columns unkonw, filling it by clicking on a button. Bu there is more: I don't want to add entire rows, but just one cell at the time, one click = one cell added. Of course not randomly : 1st cell of 1st row, 2nd cell of 1st row... and then the same of the 2nd row and so one...
I know about UJMP, ArrayList, but it's not quite what I'm looking for. Please be accurate on your answer, thank you in advance.

A: Use this:
List<List<Integer>> dynamicMatrix = new ArrayList<List<Integer>>();

dynamicMatrix.add(new ArrayList<Integer>());
dynamicMatrix.add(new ArrayList<Integer>());
dynamicMatrix.add(new ArrayList<Integer>());

dynamicMatrix.get(0).add(6);
dynamicMatrix.get(0).add(7);
dynamicMatrix.get(0).add(8);

System.out.println(dynamicMatrix.get(0).get(0)); // 6
System.out.println(dynamicMatrix.get(0).get(1)); // 7
System.out.println(dynamicMatrix.get(0).get(2)); // 8


text:
Q: eliminate the difference between captured bitmap data and filled FXG Paths? I am trying to find a way to avoid using FXG in one of my applications but run into a problem where the captured bitmap is not exactly the same as the original filled FXG paths.  Originally, let's say I have a 3 shapes that are adjacent to each other (you can imagine a pie chart with 3 slices).  I used "cutImage" function below to capture the filled bitmap data and display the 3 pictures.  However, we discovered that there is a 1 pixel gap on the side where each shape meets the other shapes.  Not sure if there is any relationship, but the captured bitmap is exactly the same as displaying the filled path directly but with "cacheAsBitmap" set to true.  If we just display the filled paths with cacheAsBitmap set to false, there are no gaps between the shapes.
Question:  Is there any way to capture 100% content from a path so that there are no gaps between the paths?
Thanks and Regards
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
                       xmlns:s="library://ns.adobe.com/flex/spark"
                       xmlns:mx="library://ns.adobe.com/flex/mx" >

    <fx:Script>
        <![CDATA[
            import mx.core.IVisualElement;
            import mx.core.IVisualElementContainer;
            import mx.core.UIComponent;
            import mx.events.FlexEvent;
            import mx.graphics.ImageSnapshot;
            import mx.graphics.codec.PNGEncoder;
            import mx.utils.ObjectUtil;

            [Bindable]
            private var cacheAsBitmap_Path:Boolean = false;

            protected function displayImg(event:MouseEvent):void
            {
                this.cutImage(collarGroup, collarImg);
                this.cutImage(zipperGroup, zipperImg);
                this.cutImage(bodyGroup, bodyImg);
                this.img.visible = true;
                this.path.visible = false;
                this.displayLabel.text = "Image";
            }

            private function cutImage(group:Group, image:Image):void
            {
                var bitmap:Bitmap = new Bitmap(new BitmapData(group.width, group.height,true, 0x00000000), PixelSnapping.NEVER, true);
                bitmap.bitmapData.draw(group);
                image.source = bitmap.bitmapData;
            }

            protected function displayPath(event:MouseEvent):void
            {
                this.path.visible = true;
                this.img.visible = false;
                this.cacheBitmapButton.visible = true;
                this.displayLabel.text = "Path : cacheAsBitmap = " + this.cacheAsBitmap_Path;
            }

        ]]>
    </fx:Script>
    <s:Rect width="2000" height="2000">
        <s:fill>
            <s:SolidColor color="0xff0000"/>
        </s:fill>
    </s:Rect>
    <s:Scroller width="1920" height="1000">
        <s:Group>
            <s:Group id="path" visible="true">
                <s:Group id="collarGroup" cacheAsBitmap="{cacheAsBitmap_Path}">
                    <s:Path data="M1017.6 331.35 1016.925 334.05Q1020.4527 333.99766 1020.15 336.025 1019.8408 338.05059 1018.45 337.5 1017.0688 336.94766 1016.65 336.925 1016.5514 336.91562 1016.55 340.075 1016.5404 343.24219 1014.85 342.25L1012.25 340.6Q1008.2932 340.85078 1002.9 340.6 1002.426 342.75781 1003.075 343.65 1003.727 344.55703 1005.65 351.575 1006.2492 353.75449 1006.675 357 1007.6303 364.18672 1008.75 375.6 1009.7586 402.7875 1010.125 430.975 1010.39 451.45723 1009.6 479.425 930.64258 455.95742 902.5 447.225 874.35664 438.49453 859.875 428.725 845.39551 418.95293 840.2 402.6 841.5 389.75 842.45 352.3 843.2 323.15 843.2 310.6 842.35 294.3 842.4 287.3 842.5 275.7 845.7 267.05 848.9 258.45 856.3 255.35 858.85 254.3 862.3 253.75 864.15 253.45 867.2 253.05L877.9 251.1Q891.65 248.95 906.85 247.7 955.5 243.7 1000.2 250.55 1028.5 251.85 1080.75 252.55 1117.3 253.05 1138.8 253.05 1157.25 252.15 1175.85 256.65 1197.5 261.85 1201.3 271.1 1201.05 280.05 1200.8 345.8 1200.5 408 1200.25 411.1    1193.71 429.60488 1175.2 437.875 1156.6883 446.15176 1125.55 455.625 1094.4193 465.08672 1028.9 481 1030.3559 444.82168 1032.35 418.85 1037.192 355.6877 1037.825 353.25 1038.4637 350.82031 1040.6 346.4 1042.6629 343.26719 1040.525 343.775 1038.3799 344.2752 1037.225 343.775 1036.0791 343.28086 1036.125 342.05 1036.1668 340.80566 1036.125 340.075 1036.0422 338.59707 1034.2 338.475 1032.3572 338.3584 1027.6 336.85L1027 341.45Q1024.3928 343.16445 1023.5 341.45L1022.75 332.1 1017.6 331.35">
                        <s:fill>
                            <s:SolidColor color="0xf0f000"/>
                        </s:fill>
                    </s:Path>
                </s:Group>
                <s:Group id="zipperGroup" cacheAsBitmap="{cacheAsBitmap_Path}">
                    <s:Path data="M1017.6 331.35 1022.75 332.1 1023.5 341.45Q1024.3928 343.16445 1027 341.45L1027.6 336.85Q1032.3572 338.3584 1034.2 338.475 1036.0422 338.59707 1036.125 340.075 1036.1668 340.80566 1036.125 342.05 1036.0791 343.28086 1037.225 343.775 1038.3799 344.2752 1040.525 343.775 1042.6629 343.26719 1040.6 346.4 1038.4637 350.82031 1037.825 353.25 1037.192 355.6877 1032.35 418.85 1030.3559 444.82168 1028.9 481 1027.942 532.35703 1028.575 604.45 1022.5139 649.55664 1023.75 677.65 1024.666 699.60176 1023.375 725.95 1022.9299 734.81934 1022.525 743.45 1014.8682 905.91426 1018.525 984 1019.4199 1003.0951 1020.175 1018.95 1020.9445 1034.8313 1020.425 1057.05 1019.9063 1079.2572 1019.425 1093.725 1018.9404 1108.2004 1020.25 1140.3L1025.225    1404.9 1022.75 1533.4 1019 1796.6 996.1 1795.3Q1001.2002 1651.6168 1004.95 1585.7 1008.7006 1519.7873 1005.95 1446.7 1003.1898 1373.6053 1003.375 1358.95 1003.7422 1332.3373 1004.15 1303.075 1006.5453 1131.1652 1003.525 808.45 1003.4641 801.98027 1003.4 795.45 1003.0996 764.24102 1004.75 737.65 1004.5584 702.23477 1004.025 679.75 1003.5002 657.26094 1005.075 637.95 1006.6557 618.63555 1007 598.1 1007.3416 577.56914 1007.275 560.75 1007.2055 543.92617 1008.85 501.55 1009.2984 489.95801 1009.6 479.425 1010.39 451.45723 1010.125 430.975 1009.7586 402.7875 1008.75 375.6 1007.6303 364.18672 1006.675 357 1006.2492 353.75449 1005.65 351.575 1003.727 344.55703 1003.075 343.65 1002.426 342.75781 1002.9 340.6 1008.2932 340.85078 1012.25 340.6L1014.85 342.25Q1016.5404 343.24219 1016.55 340.075 1016.5514 336.91562 1016.65 336.925 1017.0688 336.94766 1018.45 337.5 1019.8408 338.05059 1020.15 336.025 1020.4527 333.99766 1016.925 334.05L1017.6 331.35">
                        <s:fill>
                            <s:SolidColor color="0xf0f000"/>
                        </s:fill>
                    </s:Path>
                </s:Group>
                <s:Group id="bodyGroup" cacheAsBitmap="{cacheAsBitmap_Path}">
                    <s:Path  data="M1493.35 552.65Q1505.6 567.35 1530.05 611.35 1552.85 652.45 1560.35 671.2 1567 689.65 1597.5 757.35 1627.85 824.55 1632.85 832.2 1639.5 845.9 1670.85 925.6 1704.4 1010.85 1711.45 1034.75 1719.6 1057.35 1743.75 1133.35 1756.1 1172.05 1770.45             1217.3 1775.45 1232.3 1796 1305.35 1806.6 1342.85 1818.95 1387.35 1828.15 1414.2 1828.95 1422.35 1832.05 1438.45 1838.4 1484.4 1845.95 1539.15 1845.95 1555.4 1846.35 1562.65 1847.3 1574.5 1847.9 1584.55 1846.95 1593.05 1844.6 1614.8 1828.45                1656.9 1830.35 1667.3 1828.35 1676.05 1826.2 1685.15 1819.95 1691.4 1810.3 1696.35 1781.85 1709.9 1751.8 1724.2 1749.4 1725.4 1736.75 1730.6 1718.1 1730.7 1704.5 1730.8 1696.9 1728.9 1691.3 1724.05 1684.4 1707.85 1677.5 1691.65 1679.4 1687.9               1671.6 1684.35 1662.3 1666 1654.3 1650.3 1642.9 1618.9 1627.3 1582.2 1620.7 1565.55 1605.85 1528.15 1604.9 1517.9 1598.1 1493.35 1578.35 1433 1554.55 1360.2 1548.4 1351.8 1543.1 1335.6 1514.5 1266.3 1485.8 1196.85 1478.35 1182.3 1473.3 1172.9  1446.8 1117.05 1421.95 1064.65 1419.35 1060.75 1416.55 1049.8 1414.65 1043.95L1413.35 1040.25 1413.1 1113.65Q1412.6 1189.45 1411.35 1201.3 1412.8 1216.35 1420.65 1312 1427.75 1398.15 1428.85 1405.85 1428.95 1407.75 1434.75 1494.5 1439.85 1571.65   1439.85 1576.4 1439.85 1581.4 1443.05 1648 1445.65 1716.95 1442.85 1739.45 1442.5 1743.95 1442.1 1751.3 1441.6 1757 1440.1 1760.2 1436.5 1767.95 1420.85 1771.95 1404.55 1775.95 1352.45 1782.6 1297.55 1789.2 1284.8 1790.95 1257.65 1793.8 1205.1 1797.75 1149.7 1801.95 1136.25 1801.95 1123.55 1802.15 1078.65 1804.25 1041.5 1806 1038.25 1805.45 1030.45 1806.25 1025.2 1804.35 1019.6 1802.3 1019 1796.6L1022.75 1533.4 1025.225 1404.9 1020.25 1140.3Q1018.9404 1108.2004 1019.425 1093.725 1019.9063 1079.2572 1020.425 1057.05 1020.9445 1034.8313 1020.175 1018.95 1019.4199 1003.0951 1018.525 984 1014.8682 905.91426 1022.525 743.45 1022.9299 734.81934 1023.375 725.95 1024.666 699.60176 1023.75 677.65 1022.5139 649.55664 1028.575       604.45 1027.942 532.35703 1028.9 481 1094.4193 465.08672 1125.55 455.625 1156.6883 446.15176 1175.2 437.875 1193.71 429.60488 1200.25 411.1 1207.4 415.8 1229.55 421.6 1240.9 424.6 1254.3 427.6 1256.3 428.25 1274.45 433.7 1295.65 440.25 1315.2  447.05 1376.9 468.55 1411.8 488.65 1444.4 507.45 1464.95 524.6 1478.4 535.8 1493.35 552.65M859.875 428.725Q874.35664 438.49453 902.5 447.225 930.64258 455.95742 1009.6 479.425 1009.2984 489.95801 1008.85 501.55 1007.2055 543.92617 1007.275 560.75 1007.3416 577.56914 1007 598.1 1006.6557 618.63555 1005.075 637.95 1003.5002 657.26094 1004.025 679.75 1004.5584 702.23477 1004.75 737.65 1003.0996 764.24102 1003.4 795.45 1003.4641 801.98027 1003.525 808.45 1006.5453 1131.1652 1004.15 1303.075 1003.7422 1332.3373 1003.375 1358.95 1003.1898 1373.6053 1005.95 1446.7 1008.7006 1519.7873 1004.95 1585.7 1001.2002 1651.6168 996.1 1795.3L993.5 1799.35Q990.95 1802.1 989.7 1803.95 986.65 1804.6 972.1 1803.6 952.65 1802.15 941.85 1801.35 899.15 1798.1 893.2 1800.95 881.7 1800.15 811.25 1794.4 748.25 1789.25 740.2 1788.95 721.6 1788.5 657.95 1780.95 590.5 1772.95 575.65 1768.45 568.9 1753.7 567.6 1730.45 567.4 1707.45 566.65 1701.45 566.65 1689.2 571.55 1610.2 576.25 1533.65 577.15 1526.4 577.15 1474 577.2 1471 578.3 1419.05 583.65 1389.8 584.45 1378 586.55 1357.35 588.95 1333.35 589.85 1322.45 593.6 1277.15 592.65 1228.8 593.2 1220 595.65 1167.25 597.5 1127.35 598.65 1121.8 599.3 1112.7 599.3 1081 599.15 1050 599.15 1047.75 593.85 1063.35 563.7 1127.8 535.35 1188.4 534.65 1192.8 530.9 1202.05 495.65 1286 460.25 1372.4 450.6 1407.35 443.35 1428.6 428.9 1469.95 416.3 1508.9 406.1 1555.4 402.4 1564.95 385.9 1604.65 373.8 1633.8 372.1 1640.4 368.85 1645.65 365.1 1654.75 362.95 1659.9 358.8 1670.45 350.9 1689.35 342.1 1694.9 342.1 1704.1 340.55 1708.65 339.7 1711.1 335.6 1717.45 333.2 1721.2 330.05 1728.15 326.95 1734.9 325.6 1736.95 309.1 1740.9 291.35 1738.1 274.65 1734.2 269.1 1733.95  261.6 1731.25 234.7 1717.1 204.35 1701.1 204.05 1700.95 195.9 1697.9 192.85 1687.75 190.6 1680.15 191.05 1667.4 184.3 1647.15 180.1 1633.8 172.25 1608.65 172.55 1596.4 171.7 1576.8 174.95 1535.05 178.65 1486.95 185.55 1446.35 193.5 1408.8 220.3 1312.4 246.55 1218 252.05 1205.8 310.55 1020.25 317.05 1004.75 322.9 983.45 348.85 912.15 377.5 833.3 385.1 823.7 389.35 812.4 413.55 757.5 437.35 703.65 438.6 700.65 441.3 691.45 463.3 646.7 487.2 598 495.1 590.1 502.6 576.6 516.55 557 530.45 537.4 533.1 536.65 537.9 529.75 566.65 507.95 593.35 487.65 604.65 481.1 613.9 473.85 670.15 452.4 720.05 433.4 737.15 428.6 749.95 424.55 793.55 413.75 834.5 403.55 840.2 402.6 845.39551 418.95293 859.875 428.725">
                        <s:fill>
                            <s:SolidColor color="0xf0f000"/>
                        </s:fill>
                    </s:Path>
                </s:Group>
            </s:Group>
            <s:Group id="img">
                <s:Image id="collarImg"/>
                <s:Image id="zipperImg"/>
                <s:Image id="bodyImg"/>
            </s:Group>
        </s:Group>
    </s:Scroller>
    <s:HGroup width="100%" horizontalAlign="center" verticalAlign="middle" y="200">
        <s:Button id="displayImgButton" x="200" click="displayImg(event)" visible="true" label="Display Image"/>
        <s:Button id="displayPathButton" x="400"  click="displayPath(event)" visible="true" label="Display Path"/>
        <s:Button id="cacheBitmapButton" label="Change cacheAsBitmap" click="cacheAsBitmap_Path = !cacheAsBitmap_Path; this.displayLabel.text = 'Path : cacheAsBitmap = ' + this.cacheAsBitmap_Path;"/>
        <s:Label id="displayLabel"/>
    </s:HGroup>

</s:WindowedApplication>

A: Try using a matrix to move the bitmap away from its registration point by 1 px.  You can only capture to the right and below the registration point, so if any part of the graphic falls on the other side of it, it will be cut off.  Check out this link for code that demonstrates this technique http://flexdiary.blogspot.com/2009/12/riadventure-inspiration.html


text:
Q: Polynominal odd function If $f(x$) is an odd function and $x-y$ is a factor. show that $x^2-y^2$ is a factor as well
I'm having trouble to solve this

A: Assume that $f(x)=p(x)$ is a polynomial that is an odd function. If $x-a$ is a factor of $p(x)$ then we can write $p(x)=(x-a)q(x).$ Since $p$ is an odd function we have
$$p(-a)=-p(a)=(a-a)q(a)=0.$$ That is, $-a$ is a root of $p(x)$ and, so, $x+a$ is a factor of $p(x).$ In consequence $x-a$ and $x+a$ are factors of $p(x),$ from where we get that $(x-a)(x+a)$ is a factor of $p(x).$


text:
Q: ASP.net MVC C# Recaptcha on Identity Login I am trying to implement Googles reCaptcha on my MVC ASP.net project following the instructions found on the third to the top answer of this post, How to implement reCaptcha for ASP.NET MVC?. Currently I have downloaded and included the proper dependencies
using reCAPTCHA.MVC;

My login method looks like :
 // POST: /Account/Login
    [HttpPost]
    [AllowAnonymous]
    [ValidateAntiForgeryToken]
    [CaptchaValidator(
    PrivateKey = "your private reCaptcha Google Key",
    ErrorMessage = "Invalid input captcha.",
    RequiredMessage = "The captcha field is required.")]
    public async Task<ActionResult> Login(LoginViewModel model, string returnUrl)
    {
        if (!ModelState.IsValid)
        {
            return View(model);
        }

        // This doesn't count login failures towards account lockout
        // To enable password failures to trigger account lockout, change to shouldLockout: true
        var result = await SignInManager.PasswordSignInAsync(model.UserName, model.Password, model.RememberMe, shouldLockout: false);
        switch (result)
        {
            case SignInStatus.Success:
                return RedirectToLocal(returnUrl);
            case SignInStatus.LockedOut:
                return View("Lockout");
            case SignInStatus.RequiresVerification:
                return RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe });
            case SignInStatus.Failure:
            default:
                ModelState.AddModelError("", "Invalid login attempt.");
                return View(model);
        }
    }

And in my view I am adding the captcha inside my :
@html.beginform(){

        @Html.Recaptcha()
        @Html.ValidationMessage("ReCaptcha")
}

I also have my public and private keys added into my web.config file.
However when I run everything on the login page, the captcha box shows up, except there is no where to click and I get the error :

"ERROR for site owner: Invalid site key" where the box to click in the captcha box should be.

In addition I have tried to reset the keys but still no luck.

A: you can get the response in Controller

var response = Request["g-recaptcha-response"];

you can easily implement reCaptcha i have found an example in search, i hope this helps

https://www.codeproject.com/articles/874150/google-recaptcha-in-asp-net-mvc


text:
Q: sqlite3 and ruby query execution I'm having stupid problem executing a query. As I store integer in goals_num variable, I then intend to use it for another query but it won't run anything. However if instead of goals_num i insert 221 (which is what it contains anyway) the query is run i get result printed. Can anyone please tell me what is the problem?thanks!
 puts goals_num = db.execute("select MAX(goals) from EnglandTopScorers")

 db.execute("select * from EnglandTopScorers where goals='#{goals_num}' ") do |row|
     puts row
 end

A: I think the issue is the return value of db.execute. If I recall this will return an array. Therefore goals_num is an array. To retrieve the value, you probably want to change it to:
 goals_num = db.execute("select MAX(goals) from EnglandTopScorers").first
 db.execute("select * from EnglandTopScorers where goals='#{goals_num}' ") do |row|
     puts row
 end


text:
Q: ProgressDialog создается с запозданиями, а должен сразу Заметил недавно одну вещь. ProgressDialog появляется только по окончании работы onCreate, а мне надо, чтобы он появлялся сразу, как только я вызвал функцию его появления. В onCreate я  тексты устанавливаю в ProgressDialog и провожу работу. Если закомментирую finish(), то диалог появится, но не завершится активность. Как исправить эту проблему?
Вот пример кода, скопированный:
protected static ProgressDialog progressDialog(final Context context, final String name, final String podname){
    ProgressDialog pd = new ProgressDialog(context);
    pd.setTitle(name);
    pd.setMessage(podname);
    // меняем стиль на индикатор
    pd.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    // устанавливаем максимум
    pd.setMax(2148);
    // включаем анимацию ожидания
    pd.setIndeterminate(true);

    return pd;

}

А вот моя активность, которая должна запустить это окошко, показывая пользователю, что происходит работа, и закрыться...(код укроченный) (проверьте -увидите белый экран место диалога)
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    ProgressDialog pd= Dialoger.progressDialog(this, "Загрузка...", "Загружаю...");
    pd.show();

    pd.setMessage("Гружусь...");

    Voider.Sleep(5000); //ФУНКЦИЯ ОПИСАНА НИЖЕ
    //работа функций... которые тоже делают pd.setMessage
    finish();

в другом классе
public static Boolean Sleep(int sec){
    try {
        TimeUnit.MICROSECONDS.sleep(sec);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    return true;
}

//
Как мне улучшить код чтобы сразу после действия появилось это окошко? А не через время, не понятно когда...

A: Любые длительные задачи выполняйте в отдельном потоке, например, с помощью класса AsyncTask
class BackgroundTask extends AsyncTask<Void, Void, Void> {
    ProgressDialog pd=null;

    @Override
    protected void onPreExecute() {
        pd = new ProgressDialog(context);
        pd.setTitle(name);
        pd.setMessage(podname);
        // меняем стиль на индикатор
        pd.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        // устанавливаем максимум
        pd.setMax(2148);
        // включаем анимацию ожидания
        pd.setIndeterminate(true);
        pd.show();
    }

    @Override
    protected Void doInBackground(Void... params) {
        //Делаем длительную работу...

    }

    @Override
    protected void onPostExecute(Void result) {
        //скрываем диалог
        pd.dismiss();
    }
}


text:
Q: ASP.NET MVC Forcing Page Redirect After 5 Minutes (Different Pages) I am building a gallery website that allows visitors to view different photographs. I want to require visitors to register once they spend more than 5 minutes on the website. This includes page redirections. So, I am trying to come up with a way to redirect visitors to my registration page and disallow any further photography viewing until they make an account.
JS code like the following only keeps track of the currently active page:
var delay = 1000;
setTimeout(function(){ window.location = URL; }, delay);

Is there any way to keep track of the visitor's overall time-spent? And force a page redirection if the time exceeds 5 minutes?
Any guidance will be highly appreciated. Thanks.

A: window.setTimeout(window.location.href = "https://www.google.co.in",300000 );

Use the above code in page load or in window load.(5min=300000ms)


text:
Q: Which is the best way to check method arguments in Objective-C? When coding a method or function, is a good practice to check the input arguments to respond to any possible fail scenario.
For example:
-(void)insertNameInDictionary:(NSString*)nameString
{
    [myDictionary setObject:nameString forKey:@"Name"];
}

This looks ok, but if nameString is nil, the app will crash. So, we can check if it's nil, right?. We can also check if it is a NSString and not a NSNumber or if it is responds to the methods that our method needs to call.
So my question is: Which is the most complete and elegant way to check these arguments?

A: There are multiple ways to implement such protection:

*

*NSParameterAssert

*__attribute__((nonnull))

*and a simple if test.

[EDIT]
Since the latest Xcode versions (Xcode 6), Apple added nullability annotations which is another — and better — way to express if a parameter can be nil / null or not. You should migrate to that notation instead of using __attribute__((nonnull)) to make your APIs even more readable.

In details:

*

*NSParameterAssert is Apple's dedicated macro that checks a condition on a method parameter and throws a dedicated exception if it fails.

*

*This is a protection only at Runtime

*This macro still considers that passing nil as a parameter is a programmation/conception error, considering that due to your application workflow it should normally never happen (due to other conditions ensuring the param never being nil for example), and if it's not something really went wrong.

*It still thows an exception (that your calling code may @try/@catch if necessary), but it has the advantage that the exception thrown is more explicit (telling that the parameter was expected not to be nil instead of crashing with an ugly and hard-to-understand callstack/message).

*If you want to allow your code to call your method with nil but just do nothing in that case, you may simply if (!param) return at the beginning of the function/method.

*

*This considers that passing nil is NOT a programmation/conception error and thus can sometimes happen due to the workflow of your application, so that's an acceptable case that can happen and just shouldn't crash.

*Less commonly known, there is the __attribute__((nonnull)) GCC/LLVM attribute that is dedicated to tell the compiler that some parameters of a function/method are expected to be not-null. This way, if the compiler can detect at compile time that you try to call your method/function with a nil/NULL argument (like directly calling insertNameInDitionary:nil instead of using a variable which value can't be determined at compile time yet), it will emit a compilation error right away to let you fix it ASAP.

*[EDIT] Since latest Xcode 6, you can (and should) use nullability annotations instead of __attribute__((nonnull)). See examples in Apple's Blog post.

So in summary:
If you want to mark that your method EXPECT your parameter to be non-nil, thus indicating that calling it with nil is a logic error, you should do the following:
- (void)insertNameInDictionary:(NSString*)nameString __attribute__((nonnull))
{
    // __attribute__((nonnull)) allows to check obvious cases (directly passing nil) at compile time
    NSParameterAssert(nameString); // NSParameterAssert allows to check other cases (passing a variable that may or may not be nil) at runtime
    [myDictionary setObject:nameString forKey:@"Name"];
}

If you think that calling your method with nil can happen and is acceptable, and you just want to avoid a crash in those cases, simply do stuff like this:
-(BOOL)insertNameInDictionary:(NSString*)nameString
{
    if (nameString == nil) return NO;
    [myDictionary setObject:nameString forKey:@"Name"];
    return YES;
}

And if you think that you should be able to insert a nil object in your dictionary, you can convert the nil value to NSNull in that specific case so that it insert the NSNull singleton that is dedicated to such usage (I used the short form of the ?: ternary operator to make the code more compact):
-(void)insertNameInDictionary:(NSString*)nameString
{
    [myDictionary setObject:nameString?:[NSNull null] forKey:@"Name"];
}

And last case, if you want that passing nil in that particular example simply removes the Name from myDictionary, you can simply either do a simple if test and call removeObjectForKey:@"Name" if nameString is nil and call setObject:forKey: if it's not… or you could use KVC and the generic setValue:forKey: (KVC method, not specific to NSDictionary at all, so not to be confused with setObject:forKey:) that in the case of NSDictionary exactly has the same behavior (removing the key from the dictionary if we pass nil for the value parameter).

A: - (void)insertNameInDictionary:(NSString *)nameString
{
    if ([nameString isKindOfClass:[NSString class]]) {
        [myDictionary setObject:nameString forKey:@"Name"];
    }
}

A: Apple suggests using NSAssert for that:
NSAssert(nameString, @"nil nameString is not allowed");

This assertion would terminate your program, and produce an error message explaining what has happened.
Above, the != nil part is implicit, because Objective-C allows it. You can state it explicitly for somewhat better readability:
NSAssert(nameString != nil, @"nil nameString is not allowed");

Assertions are not limited to nil checking, because they can take arbitrarily complex conditions. You can check that an argument is of the expected type, that it responds to a particular selector, and so on. Assertions can be disabled in release code to save CPU cycles and the battery.

A: I see a couple problems here.  NSMutableDictionary doesn't have a "setObject" method.  You need to specify a key.
-(void)insertNameInDictionary:(NSString*)nameString
{
    if(nameString)
        [myDictionary setObject:nameString forKey: @"someKey"];
}

And you can also do a nil check via the "if(nameString)" bit there in my example.  If you want to have an empty string, use @"" and not nil.

A: it all depends on the semantics of what you want to happen, if you want the KV pair removed if the value is nil, then you can use setValue:forKey:
like:
-(void)insertNameInDictionary:(NSString*)nameString
{
    [myDictionary setValue:nameString forKey:@"Name"];
}

or if you want to store a value that represents a nil value you can use NSNull
-(void)insertNameInDictionary:(NSString*)nameString
{
    [myDictionary setObject:nameString? :[NSNull null] forKey:@"Name"];
}

-(NSString *)nameInDictionary
{
    NSString * retVal = [myDictionary objectForKey:@"Name"];
    return (retVal==[NSNull null]) ? nil : retVal;
}

or you may very well just want to log it.
-(void)insertNameInDictionary:(NSString*)nameString
{
    if(!nameString)
    {
        NSLog(@"expected nameString to be not null... silly me %s",__PRETTY_FUNCTION__);
        return;
    }
    [myDictionary setObject:nameString forKey:@"Name"];
}


text:
Q: Why are videos rendered by the cpu instead of the gpu? Well I know this might sound like a pretty stupid question, but I couldn't find an answer using google, so yeah ...
So, I know there are techniques like OpenCL and CUDA, but why is, by default, the processor used to render e.g. a video file out of a video editing software? Seems counterintuitive to me that the Graphics processing unit is not used to process, well, graphics. When playing a video game, the GPU is in charge of producing the image on my screen as well, isn't it?
Again, I know this may sound stupid to you. Please be gentle °A°
Edit: I was talking specificaly about the video output of a NLE software like Premiere Pro

A: Before HD was a thing, CPUs could handle video decoding easily. When HD became popular about 8 years ago, GPU manufacturers started to implement accelerated video decoding in their chips. You could easily find graphics cards marketed as supporting HD videos and some other slogans. Today any GPU supports accelerated video, even integrated GPUs like Intel HD Graphics or their predecessors, Intel GMA. Without that addition your CPU would have a hard time trying to digest 1080p video with acceptable framerate, not to mention increased energy consumption. So you're already using accelerated video everyday.
Now when GPUs have more and more general use computational power, they are widely used to accelerate video processing too. This trend started around the same time when accelerated decoding was introduced. Programs like Badaboom started to gain popularity as it turned out that GPUs are much better at (re)encoding video than CPUs. It couldn't be done before, though, because GPUs lacked generic computational abilities.
But GPUs could already scale, rotate and transform pictures since middle ages, so why weren't we able to use these features for video processing? Well, these features were never implemented to be used in such way, so they were suboptimal for various reasons.
When you program a game, you first upload all graphics, effects etc. to the GPU and then you just render polygons and map appropriate objects to them. You don't have to send textures each time they are needed, you can load them and reuse them. When it comes to video processing, you have to constantly feed frames to the GPU, process them and fetch them back to reencode them on CPU (remember, we're talking about pre-computational-GPU times). This wasn't how GPUs were supposed to work, so performance wasn't great.
Another thing is, GPUs aren't quality-oriented when it comes to image transformations. When you're playing a game at 40+ fps, you won't really notice slight pixel misrepresentations. Even if you would, game graphics weren't detailed enough for people to care. There are various hacks and tricks used to speed up rendering that can slightly affect quality. Videos are played at rather high framerates too, so scaling them dynamically at playback is acceptable, but reencoding or rendering has to produce results that are pixel-perfect or at least as close as possible at reasonable cost. You can't achieve that without proper features implemented directly in GPU.
Nowadays using GPUs to process videos is quite common because we have required technology in place. Why it's not the default choice is rather a question to program's publisher, not us - it's their choice. Maybe they believe that their clients have hardware oriented to process videos on CPU, so switching to GPU will negatively affect performance, but that's just my guess. Another possibility is that they still treat GPU rendering as experimental feature that's not stable enough to set it as a default yet. You don't want to waste hours rendering your video just to realize something is screwed up due to GPU rendering bug. If you decide to use it anyway, then you can't blame the software publisher - it was your decision.


text:
Q: Foundation - Top Bar and Icon Bar in one template I'm working on Foundation Zurb template and I'm trying to get it working.
I have Top Bar at the top of the screen (full width), Icon Bar at the left side (full height). I know that Foundation has 12 grid system.
According to Foundation:

The Foundation Top Bar gives you a great way to display a complex
  navigation bar on small, medium or large screens.

And:

An Icon Bar provides a menu to quickly navigate an app. Use the Icon
  Bar horizontally or vertically, with the labels below the icons or to
  the right. Have it your way.

Here is my template. I've took out div.large-9.columns etc.. Because they were braking the view.

LOGO PLACEHOLDER

Menu

 Go PRO

           My Account

Some Li's here

 ONE

 TWO

 THREE

      Home

      ONE

      TWO

      THREE

      FOUR

I want to achieve:

*

*Top Bar and Icon Bar the same

*Content Area to be fixed and have large-8 or large-9

*Sidebar to be fixed and have large-3
What I've already tried:

*

*Was separating all 3 bits with div.large-1/8/3, nothing happened

*Was nesting them into div.row

*I think I've tried almost everything, but have no idea, what is the problem.

A: i had done the changes in html and css. this what your expecting
html code

LOGO PLACEHOLDER

Menu

 Go PRO

           My Account

Some Li's here

 ONE

 TWO

 THREE

      Home

      ONE

      TWO

      THREE

      FOUR

content-area

columns sidebar

css code
.columns.content-area{border:1px solid #111;padding:0}
.columns.sidebar{border:1px solid #111;padding:0}
.columns.left-nav{padding:0}
.icon-bar.vertical.five-up{width:100%}

demo jsFiddle


text:
Q: I want my tkinter images to come up every 4 seconds not all at once Hey what I want is for the same image to pop up very 4 seconds at a different location. At thte moment all the photos just pop up at once. I have tried to add time.sleep to the for loop but all the photos pop up at once any ways. Please try out my code and virtually show me how to fix, as I'm very new to python. Thanks
from tkinter import *
from PIL import ImageTk, Image
from os import walk, getenv, system
from shutil import copyfile
import subprocess
import requests, subprocess, os, tempfile
import os
import tkinter.messagebox
import time

# This is the fuction that makes the original photo and is what root.after calls to later on in the code.
def ShowAnotherWin(i):
    win = Toplevel()
    image = ImageTk.PhotoImage(Image.open('C:/Users/capture.PNG'))
    win.geometry(i)
    canvas =Canvas(win, width=420, height=560)
    canvas.create_image(0, 0, image= image, anchor=NW)
    canvas.pack()
    win.overrideredirect(1)
    win.mainloop()

# This is the list it, it consists of different y and x interpects point and will be combined with the showanotherwin to makee a unique image pop up.

YourImageList = ['420x544+0+0',
  time.sleep(1)
 '420x544+200+600',
  time.sleep(88)
 '420x544+1300+100',
 '420x544+1500+800',
 '420x544+900+500',
 '420x544+500+75',

]

# this code right here takes all the elements in the list and combines it with the showanotherwin. It then displays on screen.
root = Tk()
for i in YourImageList:
    root.after(0, lambda i=i: ShowAnotherWin(i))
    # time.sleep(1)>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> leads to all the photos poping up with the only, effect being the duration of the photos poping up. Please help!!

# this right here is just making another photo by itself dont worry about it.
image = ImageTk.PhotoImage(Image.open('C:/Users/capture.PNG'))
root.geometry('420x544+750+200')
canvas = Canvas(root, width=420, height=560)
canvas.create_image(0, 0, image= image, anchor=NW)
canvas.pack()
root.overrideredirect(1)
root.mainloop()

A: You basically arm them all to show up after 0 milliseconds delay here root.after( 0 ,...
for i in YourImageList:
    root.after(0, lambda i=i: ShowAnotherWin(i))

A: The simple way is:
for i, x in enumerate(YourImageList):
    root.after(i*4000, lambda x=x: ShowAnotherWin(x))

Another way is call after() inside ShowAnotherWin():
def ShowAnotherWin(i=0):
    if i < len(YourImageList):
        win = Toplevel()
        image = ImageTk.PhotoImage(file='C:/Users/capture.PNG')
        win.geometry(YourImageList[i])
        canvas =Canvas(win, width=420, height=560)
        canvas.create_image(0, 0, image= image, anchor=NW)
        canvas.pack()
        canvas.image = image # need to keep a reference to image
        win.overrideredirect(1)
        #win.mainloop()  # no need to call mainloop() here
        root.after(4000, ShowAnotherWin, i+1)

...

ShowAnotherWin()


text:
Q: Running vert.x cluster backed by hazelcast cache in distributed mode We are using Vert.X library to develop REST service layer to receive messages from many sources. Part of the requirements is to run REST verticle(s) in High availability (HA) mode. We are following vert.x core manual for implementation of VertX cluster to run in distributed cluster (3 nodes to start with).
Based on the documentation we did the following

*

*Included hazelcast library in dependencies

    io.vertx
    vertx-hazelcast
    3.3.0

*Created a fat jar with the following manifest entries and added resources folder in classpath which has required configurations to load. We took hazelcast-default.xml from vertx-examples from github

            log4j.properties
            config.json
            hazelcast-default.xml

            io.vertx.core.Launcher
            com.msg.verticles.RootVerticle
            resources/

*Created a script file to trigger the launcher
java -jar -Xmx2048m -Xms512m message-1.0-SNAPSHOT.jar -ha -D config=resources/config.json
Launcher fails to to pickup hazelcast-default.xml from resurce folder and stops with the following exception. Not sure what I am missing here.
$>java -jar -Xmx2048m -Xms512m message-1.0-SNAPSHOT.jar -ha -D config=resources/config.json
Jul 16, 2017 7:20:26 PM io.vertx.core.impl.launcher.commands.RunCommand
INFO: Starting clustering...
Jul 16, 2017 7:20:27 PM io.vertx.core.impl.launcher.commands.RunCommand
INFO: No cluster-host specified so using address 127.0.0.1
Jul 16, 2017 7:20:28 PM io.vertx.spi.cluster.hazelcast.HazelcastClusterManager
WARNING: Cannot find cluster configuration on 'vertx.hazelcast.config' system property, on the classpath, or specified programmatically. Using default hazelcast configuration
Jul 16, 2017 7:20:28 PM com.hazelcast.config.XmlConfigLocator
INFO: Loading 'hazelcast-default.xml' from classpath.
Jul 16, 2017 7:20:28 PM com.hazelcast.config.AbstractXmlConfigHelper
WARNING: Name of the hazelcast schema location incorrect using default
Jul 16, 2017 7:20:28 PM io.vertx.core.impl.VertxImpl
SEVERE: Failed to join cluster
com.hazelcast.core.HazelcastException: org.xml.sax.SAXParseException; schema_reference.4: Failed to read schema document 'null', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.
        at com.hazelcast.util.ExceptionUtil.peel(ExceptionUtil.java:73)

A: According to the documentation of Hazelcast cluster manager you need to specify your Hazelcast configuration in a file named cluster.xml in your classpath (either embedded in the root of your fatjar or in a directory that is in your classpath).

A: Solved the issue by configuring zookeeper as co-ordination service. Which worked like a champ!!
https://github.com/vert-x3/vertx-zookeeper


text:
Q: How to sum time values in GridView column? This is an image of my GriView which is populated from a table in SQL database.
I want to run totals in the footer. I figured it out for the 'Quantity' column but I don't know how to proceed for the 'Time' column.
Here is what I have so far:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        TotalQuantity += Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "Quantity"));
    }
    else if (e.Row.RowType == DataControlRowType.Footer)
    {
        e.Row.Cells[0].Text = "TotalQuantity";
        e.Row.Cells[0].Font.Bold = true;

        e.Row.Cells[1].Text = TotalQuantity.ToString();
        e.Row.Cells[1].Font.Bold = true;
    }
}

A: You need to employ the System.TimeSpan data structure. It is likely that the value in the Time column is stored as string so you need to convert it a bit and sum the TimeSpans.
TimeSpan totalTime = new TimeSpan();

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        TotalQuantity += Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "Quantity"));
        var ts = DataBinder.Eval(e.Row.DataItem, "Time").ToString();
        var t = DateTime.Parse(ts).TimeOfDay;
        totalTime += t;
    }
    else if (e.Row.RowType == DataControlRowType.Footer)
    {
        e.Row.Cells[0].Text = "TotalQuantity";
        e.Row.Cells[0].Font.Bold = true;

        e.Row.Cells[1].Text = TotalQuantity.ToString();
        e.Row.Cells[1].Font.Bold = true;
    }
}

A: There might be a better way to do this, but this will work as well.
Simply we add your time to a date e.g. 2000/01/01 and we get the seconds count, keep counting seconds and at the end we subtract
You can do the following:
static double count = 0;
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.DataRow)
    {

DateTime tmp = Convert.ToDateTime("2000/01/01 " + DataBinder.Eval(e.Row.DataItem, "Time").ToString());
     count += tmp.Subtract(Convert.ToDateTime("2000/01/01 00:00:00")).TotalSeconds;
}

And to get the result use:
if you want the total seconds just use count. if you want to display the total time at the bottom use the below:
Convert.ToDateTime("2000/01/01 00:00:00").AddSeconds(count).ToString("HH:mm:ss");


text:
Q: How to find out if an object is touching another object in JS (excuse my bad english, I am 13 years old)
alright, even though i just joined stackoverflow today, I have been coding for a while. I'm trying to make a simple game (and may make it something bigger later) and I want the hammer (the player sprite) not be able to go through the box toward the middle of the screen, but I don't know how. here is what I have:

var sq = document.getElementById("box");
  var posX = 0;
  var posY = 0;
  var rot = "rotate(0deg)";
var id = null;
  function move(object, pixels, xa){
    if(xa == true) {
      posX+=pixels;
      object.style.left = posX + 'px';
    }else{
      posY+=pixels;
      object.style.top = posY + 'px';
    }
  }
   OBJect.style.left = "200px";
  OBJect.style.top = "200px";
document.addEventListener('keydown', logKey);
    function logKey(e) {
      if (`${e.code}` == "ArrowRight") {
        rot = "rotate(90deg)";
         sq.style.transform = rot;
     move(sq, 5, true);
                     if(posX > 470){
        posX = 5;
      }
      }
          if (`${e.code}` == "ArrowLeft") {
            rot = "rotate(270deg)";
            sq.style.transform = rot;
                    move(sq, -5, true);
                         if(posX < 0){
        posX = 465;
      }
      }
          if (`${e.code}` == "ArrowDown") {
            rot = "rotate(180deg)";
            sq.style.transform = rot;
         move(sq, 5, false);
                  if(posY > 465){
        posY = 5;
      }
      }
          if (`${e.code}` == "ArrowUp") {
            rot = "rotate(0deg)";
            sq.style.transform = rot;
        move(sq, -5, false);
                  if(posY < 0){
        posY = 470;
      }
      }
    }
setInterval(function(){
         xaxis.innerHTML = "x: " + posX;
      yaxis.innerHTML = "y: " + posY;
  rotate.innerHTML = rot;
},1);
#myContainer {
  width: 500px;
  height: 500px;
  position: relative;
  background: black;
 outline: red solid 10px;
}
#box {
  width: 30px;
  height: 30px;
  position: absolute;
  background-color: gray;
}
#OBJect {
  width: 30px;
  height: 30px;
  position: absolute;
  background-color: gray;
}
<!DOCTYPE html>

yeah, yeah, I know. I could definetly improve, but I only know basic things,and some of these from either Stackoverflow or w3schools, and yes, I know there is a lot of solved answers with this problem, but I get confused by them because they are too complicated for me. I just request easy, simple code to understand (if it isn't, please label things so I know).
sorry if this is too much, I just need help :/

A: so to do this you need to know the 4 corners of each element then you need to check if the other object is within the players bounds
they're both rectangles and to be touching 1 of these statements have to be true

*

*the top left corner of the square is to the right of the top left corner of the player and the top left corner of the square is to the left of the top right corner of the player while the top left corner of the square is less than the y of the top side and higher than the y of the bottom side

*the top right corner of the square is to the left of the top right corner of the player and the top right corner of the square is to the right of the top left corner of the player while the top right corner of the square is less than the y of the top side and higher than the y of the bottom side

*same as 1 & 2 but with the bottom left and right corners

*if one of the corners has the same x and y as a corner on the other object or if the position of one object is the same as the other
a second way to do this is using Pythagoras theorem to get the distance between two points
a^2 + b^2 = c^2
how that would look in code
let c = Math.sqrt(Math.pow(Math.abs(x1 - x2), 2) + Math.pow(Math.abs(x2, y2), 2))

this is a little tricky but the distance between two points is a triangle in a sense so the distance on x and y form the two legs then to get the actual distance we need the hypotenuse which is what Pythagoras theorem gets us. So to get a and b we need to get the absolute value of the first minus second x and y to get the distance on x and y then we square them with Math.pow() and add them but that gives us c^2 and we just want c so we get the square root with Math.sqrt() which gives us the distance then the one other thing we have to do is get the center of the objects to use as a and b. Since you're working with javascript on a webpage the X and Y values are for the top left corner so you need to add half the width and height to x and y appropriately to get the center of the object, then you can use the distance formula. the only problem with this approach is that it works best for circles because every point around the edge is equally distant from the center which isn't true for a square.
So personally I would use the first method, you can get the other corners by using width and height to add to the position of the top left corner to get the other positions. it's more code but more precise than distance because you're checking the bounds of each object rather than checking distance from center

A: I also joined today and I am 12. since the hammer is an img, you can use css:
I think your question was that you want to move the hammer, if yes:

var left = 0; /*left and top can be edited in your code but*/
var top = 0;/*you have to reset them using the code below*/
var hammer = document.querySelector('#hammer');
hammer.style.left = left + 'px';
hammer.style.top = top + 'px';
#hammer {
  position: absolute;
  left: 0px;
  right: 0px;
}/*set left and right via js*/


text:
Q: Distcc with C++ undefined reference I having trouble configuring distcc to compile C++ files. I did a standard small "Hello, World" program in C++ and am trying to get distcc to compile it locally (before I get fancy with a larger project), but I am getting "undefined reference" errors.
My program, called "hello.cpp":
#include <iostream>

int main(){
  std::cout << "Hello World in c++" << std::endl;
  return 0;
}

My command:
$ distcc hello.cpp

Terminal output:
/tmp/cc5rZwhV.o: In function `main':

hello.cpp:(.text+0xa): undefined reference to `std::cout'

hello.cpp:(.text+0xf): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'

hello.cpp:(.text+0x14): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'

hello.cpp:(.text+0x1c): undefined reference to `std::ostream::operator<<(std::ostream& (*)(std::ostream&))'

/tmp/cc5rZwhV.o: In function `__static_initialization_and_destruction_0(int, int)':

hello.cpp:(.text+0x4a): undefined reference to `std::ios_base::Init::Init()'

hello.cpp:(.text+0x59): undefined reference to `std::ios_base::Init::~Init()'

collect2: error: ld returned 1 exit status

distcc[21053] ERROR: compile hello.cpp on localhost failed

Other information:
This program compiles just fine with g++ and C++. A similar program written in C using printf works with distcc.
Output of $ distcc --version:
distcc 3.2rc1 x86_64-unknown-linux-gnu
  (protocols 1, 2 and 3) (default port 3632)
  built Jul  7 2014 13:18:34
....(copyright stuff)

A: Add -lstdc++ to your linker command line (that is, add libstdc++ to your linked libraries explicitly, which normally g++ would do for you).
While you're at it, try icecc as well.  I personally prefer it.


text:
Q: Click on a submenu item in windows all.
I'm trying to do the following, using standard windows menus. I have a menu with a sub menu attached to it. I need to perform different actions when user clicks the menu item that opens a submenu, and user hovers over the menu item and submenu opens without a click.
As far as I could see WM_MENUCOMMAND is only sent when user clicks on a menu item that does not have a submenu attached. Also no mouse click messages are sent when I actually click an item that contains submenu.
So is this even possible?
Thanks.

A: I believe you can tell when the mouse moves over an item by watching for WM_MENUSELECT.  You would then have to start a timer, and if the timer expires before the cursor moves again, you'd have to manually pop open the submenu.  I'm not sure how to accomplish the second part.
And it's pretty non-standard behavior that might confuse users.  What are you trying to accomplish?  And how do you expect it to work for users with only keyboard access?


text:
Q: Splitting workbook into multiple files by sheet: how do I get the saved workbook name to be the sheet title? I am trying to create a macro that splits a given workbook into multiple files that are saved to the same folder with the titles=current sheet names. I currently have it working, but the saved titles come out as "Book67", "Book68", "Book69", etc. and not the sheet title.
Already tried various types of object titles for Worksheet Name (fourth line from the bottom) but to no avail. I that's still where I think the problem is.
Sub Splitbook()
MyPath = ThisWorkbook.Path
For Each sht In ThisWorkbook.Sheets
sht.Copy
ActiveSheet.Cells.Copy
ActiveSheet.Cells.PasteSpecial Paste:=xlPasteValues
ActiveSheet.Cells.PasteSpecial Paste:=xlPasteFormats
ActiveWorkbook.SaveAs
Filename = MyPath & "/" & "Worksheet.Name" & ".xlsx"
ActiveWorkbook.Close savechanges:=False
Next sht
End Sub

No error messages. Expected results listed above


text:
Q: Distribution of points in a 2d grid that minimize the average distance from all the other points of the grid to these points Let's consider a 2d array A with A(i,j)=0 whatever i and j initially.
Let's now add n points for which A(i,j)=1, i.e., sum(sum(A))=n
The question is:
What is the optimal spatial distribution of these n points that would minimize the average Euclidean distance map of 0 to 1.
with Matlab that would be:
A=zeros(10,10) % a grid of 10 by 10, only 0s
A(1:2)=1;
A(2,3)=1;
A(4,3)=1;
A(5,5)=1; %a guess: assign n=4 pixels to 1

dmap = bwdist(A) % Calculate Euclidean distance map (shortest distance from 0 to 1)
dmap(dmap==0)=[]; % Remove 0 distance (e.g., from A(5,5) to A(5,5))
average_min_distance_from_0_to_1 = mean(dmap)

So I want to find the optimal point distribution (i.e., this line A(1:2)=1; A(2,3)=1; A(4,3)=1; A(5,5)=1) so that average_min_distance_from_0_to_1  is the minimum among all the possible permutations.
I think it may be a variation of the geometric median problem (The point that minimizes the sum of euclidean distances to a set of n points), but in my case I try to find the optimal distribution of more than 1 point.
Thanks for any help.
Best.


text:
Q: Apache start script dumping core Operating system: Solaris / SunOS.
When starting Apache2.x using:
./apachectl start

the following error is printed to the terminal:
Illegal Instruction - core dumped
Any idea what could be causing this or are there any logs I can inspect?
More info::
out put from /bin/sh -x ./apachectl start  :
+ [ xstart = x ]
+ /path/path/apache2/bin/httpd -d /path/path/apache2/ -k start
Illegal Instruction - core dumped

from the core file:
$pflags core
  core 'core' of 19561:   /path/path/apache2/bin/httpd -d /path/path/apache2/ -k start
        data model = _ILP32  flags = MSACCT|MSFORK
   /1:    flags = 0
      sigmask = 0xffffbefc,0x0000ffff  cursig = SIGILL

A: The apachectl script itself is probably not crashing. More likely, a command that it calls is crashing.
Try running the script like this:
$ /bin/sh -x ./apachectl start

This will enable trace mode on the script and allow you to see the last thing it does before it bails out. If you run this and it's not obvious what's going on, please update your question with the last few lines of output.
Also, you mention that it dumps core. On Solaris, this may create a core file in your current directory or in /var/core, depending on your coreadm configuration. If you can find the core file, inspect it with the following commands:
$ pstack corefile
$ pflags corefile


text:
Q: Inequality from numerical optimization. Reminder dominated by the first order term There's the following lemma of which I don't get one specific step

If $x^*$ is a local solution of (12.1) then we have
$$
\nabla f(x^*)^T d \geq 0 \text{ for all } d \in T_{\Omega}(x^*)
$$

Here $T_\Omega(x^*)$ is the tangent cone at $x^*$.
The proof proceeds by contradiction, it is assumed that $\nabla f(x^*)^T d < 0$. Let  $\left\{z_k \right\}$ and $\left\{t_k\right\}$ be the sequence satisfying
$$
\lim_{k\to\infty} \frac{z_k - x^*}{t_k} = d
$$
So we can write
$$
f(z_k) = f(x^*) + (z_k - x^*)^T \nabla f(x^*) + o(\left\lVert z_k - x^* \right\rVert) = f(x^*) + t_k d^T \nabla f(x^*) + o(t_k)
$$
Here's the bit I don't get, or at least I cannot work out

Since $d^T \nabla f(x^*) < 0$ the reminder  term is eventually dominated by the first order term, that is
$$
f(z_k) < f(x^*) + \frac{1}{2} d^T \nabla f(x^*)
$$

I am not really sure how that inequality is derived.

A: The reminder $o(t_k)$ can be written as $t_k \varepsilon(t_k)$ where $\varepsilon$ is some function converging to $0$ as $t_k \to 0$.
So your in your right member you can factorize and obtain $t_k \left( d_k^\top \nabla f(x^*) + \varepsilon(t_k) \right)$. One hand $d_k^\top \nabla f(x^*) <0$, and on the other hand $\varepsilon(t_k) \to 0$, so for $k$ large enough you will have $\varepsilon(t_k)$ small enough so that $d_k^\top \nabla f(x^*) + \varepsilon(t_k) <0$. This concludes the proof.
To get exactly the inequality you want, you can make use of the argument that for $k$ large enough, you can ensure that $\varepsilon(t_k) \leq -(1/2) d_k^\top \nabla f(x^*)$, since the latter is a strictly positive number.


text:
Q: Проблема с ShareActionProvider Пытаюсь сделать кнопку «поделиться» через ShareActionProvider. Но когда запускается activity, выдает ошибку. Пробовал на Android 4.1 и Android 6.0
java.lang.UnsupportedOperationException: This is not supported, use MenuItemCompat.getActionProvider()
at android.support.v7.view.menu.MenuItemImpl.getActionProvider(MenuItemImpl.java:648)
at ru.sergey.test.AboutActivity.onCreateOptionsMenu(AboutActivity.java:26)
at android.app.Activity.onCreatePanelMenu(Activity.java:2476)
at android.support.v4.app.FragmentActivity.onCreatePanelMenu(FragmentActivity.java:362)
at android.support.v7.view.WindowCallbackWrapper.onCreatePanelMenu(WindowCallbackWrapper.java:92)
at android.support.v7.app.AppCompatDelegateImplBase$AppCompatWindowCallbackBase.onCreatePanelMenu(AppCompatDelegateImplBase.java:331)
at android.support.v7.app.AppCompatDelegateImplV9.preparePanel(AppCompatDelegateImplV9.java:1357)
at android.support.v7.app.AppCompatDelegateImplV9.doInvalidatePanelMenu(AppCompatDelegateImplV9.java:1637)
at android.support.v7.app.AppCompatDelegateImplV9$1.run(AppCompatDelegateImplV9.java:132)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)

Вот мой код
import android.content.Intent;
import android.support.v4.view.MenuItemCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.ShareActionProvider;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast;

public class AboutActivity extends AppCompatActivity {

    private ShareActionProvider mShareActionProvider;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_about);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.menu_main, menu);

        MenuItem shareItem = menu.findItem(R.id.action_share);
        mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(shareItem);

        return true;
    }

    public void doShare() {
        Intent intent = new Intent(Intent.ACTION_SEND);
        intent.setType("text/plain");
        intent.putExtra(Intent.EXTRA_TEXT, "Текст");
        mShareActionProvider.setShareIntent(intent);

    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        int id = item.getItemId();

        if (id == R.id.action_share) {
            doShare();
        }

        return super.onOptionsItemSelected(item);
    }
}


text:
Q: Car headlight voltage If I put a higher voltage bulb in my car headlight, what will happen?  I haven't tried it yet, but I'm wondering if it would matter.  The bulb has the same wattage but a different voltage.

A: A standard experiment in a Physics teaching laboratory is to find the current-voltage characteristics of an incandescent tungsten filament light bulb.
Results from such an experiment show that the resistance $(=\dfrac{\text{voltage across light bulb}}{\text{current through light bulb}}= \dfrac VI)$ of an incandescent light bulb is not constant.
Here is a graph of current against voltage from such an experiment which shows that as the voltage increases the resistance of the bulb increases.

If the resistance had been constant then the graph should have been a straight line through the origin.
This increase in resistance is due to the fact that the filament is made of tungsten whose resistance increases with the temperature of the filament.
The starting characteristics of a light bulb show this and the large current when the bulb is switch on is one of the reasons for the failure of a light bulb.

Performance characteristics from Beaty and Fink's Standard Handbook for Electrical Engineers (pages 26-8 to 26-9) show that for small variations from the working voltage the expected life time of a bulb is proportional to $\rm voltage ^{13}$ so if you connect a bulb with a working voltage of $12 \rm V$ to an $11 \rm V$ supply it would be expected to last approximately three times longer.
The Handbook also relates the current to be proportional to $\rm voltage ^{0.54}$ and the power dissipated by the bulb to be proportional to $\rm voltage ^{1.54}$.
Thus connecting your $12 \, V$ bulb to an $11 \rm V$ supply will reduce the power consumption to approximately $\frac 78$ of its working value.
The consequence of the reduced power dissipation is that the filament will be at a lower temperature and hence not emit as much visible light.
A unit for the measure of visible light emitted from a source is the lumen and the amount of visible light emitted by a bulb is proportional to $\rm voltage ^{3.38}$
Running your bulb at $11\rm V$ will reduce the number of lumens emitted by the bulb to
$\frac 34$ of its working value, in other words the bulb will appear to be dimmer.
As well as being dimmer the spectral composition (colour temperature) of the bulb will change.
This graph, copied from the Wikipedia article Color Temperature shows the effect on the visible part of the spectrum when the temperature of the source is changed.

$B_\lambda$ is a measure of the rate at which light is emitted over a range of wavelength from $\lambda$ to $\lambda + d\lambda$ so the area under the graph is proportional to the emitted power and the $\rm M$ is the micro reciprocal degree $(=\frac{10^6}{T(\rm K)})$.
Running at the lower voltage the colour temperature of the bulb will change in proportion to  $\rm voltage ^{0.42}$ of its original value which in this case will be approximately $96\%$.
The Handbook has a graph which may be of use?

I have assumed the it is an incandescent tungsten filament light which the OP was referring to.
What I find extremely interesting is that my reasonable new edition of the Handbook does not mention LED lighting once!

A: A bulb rated at a higher voltage means that the bulb has a higher resistance for the same power. If you run it at a lower voltage, you will get a lower power output so it will simply emit less light.
As an example, imagine a bulb rated at 1V with 1W. The two equations you need are Ohm's Law ($V=IR$) and $P=VI$. So from this, with a bit of algebra, you can get that:
$$
R=V^2/P
$$
and
$$
P=V^2/R
$$
So for this bulb $R=1^2/1=1\Omega$.
Now take another bulb rated at 2V and 1W. This means it gives 1W output when supplied by a 2V battery. So its resistance must be $R=2^2/1=4\Omega$.
If you run this second bulb off a 1V source (which is what you want to do), it's power is given by:
$$
P=V^2/R
$$
So $P = 1^2/4 =$ 0.25W. It gives out a quarter of the power it gave at 2V.
The point is that the thing that is fixed is the bulb resistance. The voltage is externally defined by the power source and the current and power are dependent on the resistance and voltage.

[I assume here we are dealing with incandescent, resistive bulbs. LEDs
  or fluorescents don't work the same way...]


text:
Q: Failed Fetch Error Notification I wanted to show an error notification when the it has it's internal error however this wasn't working I hope you can help me thanks.
   export const deleter = (url, params) => {
        return(dispatch, getState, api) => {
                api += 'api/';
            return fetch(`${api}${url}`, {
                method: 'DELETE',
                headers: {
                    'Content-Type': 'application/json'
                },
                body: JSON.stringify(params)
            })
            .then(response => response.json())
            .then(result => dispatch(departmentResult(result, types.DELETER)))
            .catch(err => {
                    const errStatus = err.response ? err.response.status : 500;
                    if (errStatus == 500 || errStatus == 404){
                      return (NotificationManager.error('Sorry but this has already been used', 'ERROR! '));
                    } else {
                       return (NotificationManager.error('Sorry but this has already been used', 'ERROR! '));
                    }
           });
        }
    }


text:
Q: How can I recreate the following image of a grid in TikZ? I would like to create the following image in TikZ for my latex file.
Can you give me an idea of how to do it? Thanks.

I have the following so far, which is very simple:
\begin{tikzpicture}
  \draw[step=5mm,gray,very thin] (0,0) grid (7.5,7.5);
  \draw[step=25mm,black,semithick] (0,0) grid (7.5,7.5);
\end{tikzpicture}

This creates the fine 15x15 grid and the coarse 3x3 grid.

A: Here you go, the coding is not pretty but it works.
\documentclass[]{article}

\usepackage{tikz}
\usepackage{bm}
\begin{document}

\begin{tikzpicture}
  \draw[step=5mm,gray,very thin] (0,0) grid (7.5,7.5);
  \draw[step=25mm,black,semithick] (0,0) grid (7.5,7.5);

  \fill[green!50!black,opacity=0.3] (0,7.5) rectangle (2.5,5);

  \fill[orange!60!black,opacity=0.3] (3.5,1) rectangle (6.5,4.0);
  \draw[dashed,blue!50!white,very thick] (0,1.25)-- (7.5,1.25);
  \draw[dashed,blue!50!white,very thick] (0,3.75)-- (7.5,3.75);
  \draw[dashed,blue!50!white,very thick] (0,6.25)-- (7.5,6.25);

  \draw[dashed,blue!50!white,very thick] (6.25,0)-- (6.25,7.5);
  \draw[dashed,blue!50!white,very thick] (3.75,0)-- (3.75,7.5);
  \draw[dashed,blue!50!white,very thick] (1.25,0)-- (1.25,7.5);

  \fill[red!80!black] (1.25,1.25) circle (4pt);
  \fill[red!80!black] (3.75,1.25) circle (4pt);
  \fill[red!80!black] (6.25,1.25) circle (4pt);

  \fill[red!80!black] (1.25,3.75) circle (4pt);
  \fill[red!80!black] (3.75,3.75) circle (4pt);
  \fill[red!80!black] (6.25,3.75) circle (4pt);

  \fill[red!80!black] (1.25,6.25) circle (4pt);
  \fill[red!80!black] (3.75,6.25) circle (4pt);
  \fill[red!80!black] (6.25,6.25) circle (4pt);

  \draw (1.75,6.75) node {$\bm{\Omega}^C$};
  \draw (5.75,3.25) node {$\bm{\Omega}^D$};

\end{tikzpicture}

\end{document}

Result:

A version using \foreach:
\documentclass{article}
\usepackage{tikz}
\usepackage{bm}
\begin{document}
\begin{tikzpicture}
  \draw[step=5mm,gray,very thin] (0,0) grid (7.5,7.5);
  \draw[step=25mm,black,semithick] (0,0) grid (7.5,7.5);

  \fill[green!50!black,opacity=0.3] (0,7.5) rectangle (2.5,5);
  \fill[orange!60!black,opacity=0.3] (3.5,1) rectangle (6.5,4.0);

  \foreach \x in {1.25,3.75,6.25} {
     \draw[dashed,blue!50!white,very thick] (0,\x)-- (7.5,\x);
     \draw[dashed,blue!50!white,very thick] (\x,0)-- (\x,7.5);
     \foreach \y in {1.25,3.75,6.25} {
          \fill[red!80!black] (\x,\y) circle (4pt);
     }
  }
  \draw (1.75,6.75) node {$\bm{\Omega}^C$};
  \draw (5.75,3.25) node {$\bm{\Omega}^D$};

\end{tikzpicture}

\end{document}

A: Here is thus a detailed answer (I copied the color references from Josh's answer), as suggested in my comment.
Note :

*

*The use of the shift option, for the blue dashed grid,

*The use of two nested \foreach loops, for drawing the nodes.

*The use of "round" coordinates (in order to have lighter, and more understandable code). If you need your picture to have specific dimensions, you can write add scale= xx as a global option (\begin{tikzpicture}[scale=0.1] so that 1 unit = 1mm)

Here is the MWE
\documentclass{standalone}
    \usepackage{tikz}
    \usepackage{xcolor}

\begin{document}
\begin{tikzpicture}
    \fill [green!50!black,opacity=0.3] (0,10) rectangle +(5,5);
    \fill [orange!60!black,opacity=0.3] (7,2) rectangle +(6,6);
    \draw [gray, thin, step = 1] (0,0) grid +(15,15);
    \draw [black, thick, step = 5] (0,0) grid +(15,15);
    \draw [blue, dashed, step = 5, shift = {(2.5,2.5)}] (-2.5,-2.5) grid +(15,15);
    \foreach \x in {2.5,7.5,12.5} {
        \foreach \y in {2.5,7.5,12.5} {
            \node [text=red] at (\x,\y) {$\bullet$};
        }
    }
    \node at (2.5,12.5) [above right] {$\Omega^C$};
    \node at (12.5,7.5) [below left] {$\Omega^C$};
\end{tikzpicture}
\end{document}

And the output:


text:
Q: Operator not followed by a character I am using the find and replace function and a vba code in Excel. I want to replace all strings like "/15" by ".15" but only if "/15" is not followed by any other characters. Is there an operator for my need?
For example if I replace all "/15" it also replaces this string if it is followed by other characters.
10/15/15 -> 10.15.15
But what I want is
10/15/15 -> 10/15.15
Cheers

A: You could use regular expressions, a wealth of stuff on the net about that.
Or something in VBA like so, no real need for a2, could grab the last of a1 before hand, but just to show you difference in the arrays in the locals window.
Function test(strInput As String)

Dim a1() As String
Dim a2() As String

a1 = Split(strInput, "/")
a2 = a1

ReDim Preserve a2(UBound(a1) - 1)

test = Join(a2, "/") & "." & a1(UBound(a1))

End Function

or it can be done using a formula
=SUBSTITUTE(A1,"/",".",(LEN(A1)-LEN(SUBSTITUTE(A1,"/",""))))

A: I think you should use the function Right for this, to avoid replacing the "/15" in the middle of the string.
Public Function ReplaceRight(strInput As String) As String
    If Right(strInput, 3) = "/15" Then
        ReplaceRight = Left(strInput, Len(strInput) - 3) & ".15"
    Else
        ReplaceRight = strInput
    End If
End Function

With Excel Formula:
=IF(RIGHT(F215,3)="/15",LEFT(F215,LEN(F215)-3)&".15",F215)


text:
Q: Thread getting locked at "www.protocol.http.HttpURLConnection" My threads are getting locked while calling
new URL(url).openConnection();

A part of thread dump is:
sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1195)
    - locked <0x00000007056a2498> (a sun.net.www.protocol.http.HttpURLConnection)
    at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:379)

which appears to be locked at
"JakartaHttpHandler-http-timeout-pool-12-thread-1" daemon prio=10 tid=0x0000000046bb6800 nid=0x162 waiting on condition [0x00000000431b7000]
   java.lang.Thread.State: WAITING (parking)
    at sun.misc.Unsafe.park(Native Method)
    - parking to wait for  <0x00000007521c68b8> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)

In the end heap details say,
compacting perm gen  total 41408K, used 41295K [0x00000007fae00000, 0x00000007fd670000, 0x0000000800000000)
   the space 41408K,  99% used [0x00000007fae00000, 0x00000007fd653e58, 0x00000007fd654000, 0x00000007fd670000)

Threads do not proceed without throwing any exception.
Firstly, I am planning to change the -XX:MaxPermSize. Is there any other thing I can do?
I am sure, people must have faced this exception.
Thanks in advance.

A: Is it possible you're actually stuck at a "connect()" call further down?
The code you're looking for is probably closer to:
    HttpURLConnection connection = new URL(url).openConnection();
    connection.setConnectTimeout(10000);
    connection.setReadTimeout(10000);
    connection.connect();

This will create the connection object, set it to a 10s connect timeout (trying to make a connection to the remote host) and a 10s read timeout (the amount of time it can spend waiting for a response).  The first could conceivably need to be higher if you're on a very slow network.  The second might need to be bumped up if your service takes awhile to respond due to long operations on some resources.  In any case, the default is infinity and that's probably not a good idea for any production system.

A: Go a bit up in the stack trace. Your application is probably opening a connection an external website like for example SpringFramework.org possibly to get XSDs.
See what those websites are and check if they can be accessed from that machine where your application is deployed using wget.


text:
Q: developing Facebook paid application without fb credits? is it possible to create my FB app in Fb iframe and on pay button it directs to Paypal for payment and returns back to my fb app for further processing without using Fb credits ?
In Facebook payment terms and policies i have read:
NOTE: Per the Facebook Credits Terms, all games on the Facebook Platform (including mobile web apps) must exclusively process payments through Facebook Credits.
Plus if you know any app on FB using payment method without FB credits please specify the names of the apps . thanks

A: What part of

All games on the Facebook Platform (including mobile web apps) must exclusively process payments through Facebook Credits

is unclear to you?

A: If the Facebook terms of use say you have to use facebook credits i don't think your app will be enabled if you don't respect that rule.
so even if it might be possible to use paypal directly, it will be a lot of work for nothing.


text:
Q: Constructing a triangle given 2 sides and the inscribed circle's radius A Triangle has 2 sides of length 4 and 9. The largest circle than can be drawn in the triangle so as to touch all 3 sides has radius 1 cm. Find the length of the 3rd side.

A: We know that the area of a circle equals its radius times its semiperimeter; i.e., $\| \triangle ABC \| = rs$.  We also know that the area of a triangle is equal to one half of the product of two adjacent sides and the sine of the included angle; i.e., $\|\triangle ABC\| = \frac{1}{2}ab \sin C$.  Without loss of generality, suppose $a = 4, b = 9$.  Then $$13 + c = 36 \sin C.$$  But by the Law of Cosines, $$c^2 = 4^2 + 9^2 - 2(4)(9) \cos C,$$ so eliminating $\angle C$ gives $$c^4-190c^2+104c+4901 = (c + 13)(c^3 - 13c^2 - 21c + 377) = 0.$$  There are actually two distinct admissible solutions, corresponding to the positive roots of the cubic $$c^3 - 13c^2 - 21c + 377 = 0,$$ which are approximately $$c \approx 5.9855223908884664799, \quad c \approx 12.183991470265712190.$$

Since this question has been modified and bountied to ask whether the triangle is constructible--an entirely different matter that was neither asked by the OP nor mathematically related to the original problem--I will go ahead and furnish an answer.
First, we can see that the cubic for $c$ is irreducible over $\mathbb Q$ by the rational root theorem, since if $$p(c) = c^3 - 13c^2 - 21c + 377$$ admits a factorization of the form $g(c)h(c)$ over $\mathbb Q$, one of $g$ or $h$ has degree $1$, but no such rational root exists (simply check $c \in \{\pm 1, \pm 13, \pm 29, \pm 377\}$).  Therefore, $p(c)$ is the minimal polynomial of its roots over $\mathbb Q$, and since $p$ has degree $3$ which is not an integer power of $2$, none of the roots is constructible.
And since there were complaints about "numeric" values for $c$ implying a "loss of generality," the exact value of the two positive roots is readily obtained via Cardano's formula for the casus irreducibilis as:
$$c = \frac{1}{3} \left( 13 + \frac{29 (2^{2/3}) (-1 + i \sqrt{3})}{\sqrt[3]{-104 + 3i\sqrt{4218}}} - 2^{1/3} (1 + i\sqrt{3})\sqrt[3]{-104 + 3i\sqrt{4218} } \right), \\
c = \frac{1}{3} \left( 13 + \frac{58 (2^{2/3})}{\sqrt[3]{-104 + 3i\sqrt{4218}}} - 2^{4/3} \sqrt[3]{-104 + 3i\sqrt{4218} } \right),$$ or equivalently, using the trigonometric solution,
$$c = \frac{1}{3}\left(13 + 4 \sqrt{58} \sin \left(\tfrac{1}{3} \arcsin \left(\tfrac{52 \sqrt{58}}{29^2}\right) \right) \right), \\
c = \frac{1}{3}\left(13 + 4 \sqrt{58} \cos \left(\tfrac{1}{3} \arccos \left(-\tfrac{52 \sqrt{58}}{29^2}\right) \right) \right).$$
I will not entertain demands to show the calculation step by step, as this is clearly not in the spirit of the original question, nor even the question about constructibility, and the method has been established for hundreds of years--the reader who wants to see the calculation should do it for themselves.

A: There is one and only one circle that touches all 3 sides in a triangle, called the incircle. In fact, it is the largest circle that can be drawn within the triangle.
There is a simple area formula for a triangle, $A=rs$, where $s$ is the semiperimeter, and $r$ is the inradius [which in this case is $1$], which when combined with the Heron's formula gives:
$$r=1=\sqrt{\frac{(s-a)(s-b)(s-c)}{s}}$$
$$\text{So,  } s = (s-a)(s-b)(s-c)$$
Now we have $s=\frac{4+9+c}{2}=6.5+\frac{c}{2}$. Let us dentone $\frac{c}{2}$ by $x$. So substituting:
$$6.5+x = (6.5+x-4)(6.5+x-9)(6.5+x-c)$$
$$6.5+x = (x+2.5)(x-2.5)(6.5-x)$$
$$6.5+x = -x^3+6.5x^2+6.25x-40.625$$
Thus we have a cubic equation in $x=\frac{c}{2}$. In the next step, we multiply by $8$ to get it in terms of $c$:
$$x^3-6.5 x^2-5.25 x+47.125 = 0$$
$$c^3−13c^2−21c+377= 0$$
Which upon solving, we get three real roots, but only two positive, of which any can be a possible value of $c$, the remaining side:
$$c \approx 5.985522390888466479868150 \text{ or } c \approx 12.18399147026571219021056 $$

A:
(1) $F=r s = r\dfrac{a+b+c}{2} =\dfrac12 ab \sin(\gamma)
~\Leftrightarrow~
\sin(\gamma) =\dfrac{r(a+b+c)}{ab}$
(2) $c^2=a^2+b^2-2ab\cos(\gamma)
~\Leftrightarrow~
\cos(\gamma) =\dfrac{a^2+b^2-c^2}{2ab}$
(3) $\sin^2(x)+\cos^2(x)=1$

$\Rightarrow~ \dfrac{r^2(a+b+c)^2}{a^2b^2}
+\dfrac{(a^2+b^2-c^2)^2}{4a^2b^2} =1$

$\begin{array}{l l l}
\Leftrightarrow & 4r^2(a+b+c)^2 +(a^2+b^2-c^2)^2  &=4a^2b^2 \\
\Leftrightarrow
  & 4r^2(a+b+c)^2+(a^2+b^2)^2 -2(a^2+b^2)c^2 +c^4
                        &=4a^2b^2 \\
\Leftrightarrow
  & 4r^2(a+b+c)^2+a^4+b^4+2a^2b^2
                            -2a^2c^2 -2b^2c^2 +c^4
                        &=4a^2b^2 \\
\Leftrightarrow
  & 4r^2(a+b+c)^2 +(a^4+b^4-2a^2b^2)
                            -2a^2c^2 -2b^2c^2 +c^4
                        &=0 \\
\Leftrightarrow
  & 4r^2(a+b+c)^2+(a^2-b^2)^2
                            -2a^2c^2 -2b^2c^2 +c^4
                        &=0 \\
\Leftrightarrow
  & 4r^2(a+b+c)^2+(a^2-b^2)^2
                            -c^2( 2a^2 +2b^2)  +c^4
                        &=0 \\
\Leftrightarrow
  & 4r^2(a+b+c)^2+(a^2-b^2)^2
                            -c^2\bigl( (a-b)^2 +(a+b)^2 \bigr) +c^4
                        &=0 \\
\Leftrightarrow
  & 4r^2(a+b+c)^2+(a^2-b^2)^2
                            -c^2(a-b)^2  -c^2(a+b)^2  +c^4
                        &=0 \\
\Leftrightarrow
  & 4r^2(a+b+c)^2+(a-b)^2 (a+b)^2
                            -c^2(a-b)^2  -c^2(a+b)^2  +c^4
                        &=0 \\
\Leftrightarrow
  & 4r^2(a+b+c)^2
                    +\bigl( (a-b)^2 -c^2 \bigr) \bigl( (a+b)^2 -c^2 \bigr)
                        &=0 \\
\Leftrightarrow
  & 4r^2(a+b+c)^2
                    +\bigl( (a-b)^2 -c^2 \bigr)
                        (a+b-c)  (a+b+c)
                        &=0
\end{array}$
$\begin{array}{l l l}
\Leftrightarrow
  & (a+b+c) \bigl\lgroup  4r^2(a+b+c)
                    +\bigl( (a-b)^2 -c^2 \bigr)
                        (a+b-c)     \bigr\rgroup
                        &=0 \\[1em]
\Leftrightarrow
  & (a+b+c) \bigl\lgroup  4r^2(a+b) +4r^2c
                    +(a-b)^2(a+b) -(a-b)^2 c
                        -(a+b)c^2 +c^3     \bigr\rgroup
                        &=0 \\[1em]
\Leftrightarrow
  & (a+b+c) \bigl\lgroup c^3  -(a+b)c^2
                         +\bigl(  4r^2 -(a-b)^2  \bigr)c
                             +4r^2(a+b) +(a-b)^2(a+b)
                    \bigr\rgroup
                        &=0 \\[1em]
\Leftrightarrow
  & (a+b+c) \bigl\lgroup c^3  -(a+b)c^2
                         +\bigl(  4r^2 -(a-b)^2  \bigr)c
                    +\bigl( 4r^2 +(a-b)^2 \bigr)(a+b)
                    \bigr\rgroup
                        &=0 \\[1em]
\end{array}$
To solve:
$c^3 +uc^2 +vc +w=0$, where
$u=-(a+b)$,
$v=4r^2 -(a-b)^2$,
$w=\bigl( 4r^2  +(a-b)^2 \bigr)(a+b)$
either according to Cardanos formula or in an approximation method.
Annotation:


text:
Q: 'NoneType' object has no attribute 'get' error using SQLAlchemy I've been trying to map an object to a database using SQLAlchemy but have run into a snag.
Edit: Basically changed a whole bunch of stuff.

Version info if handy: [OS: Mac OSX 10.5.8 | Python: 2.6.4 | SQLAlchemy: 0.5.8]
The class I'm going to map:
class Student(object):
    def __init__(self, id, name):
        self.id = id
        self.name = name

    def __repr__(self):
        return str(self)

    def __str__(self):
        return "%s %s" %(self.id, self.name)

Background:
Now, I've got a function that reads in the necessary information from a text database into these objects. The function more or less works and I can easily access the information from the objects.
Before the SQLAlchemy code runs, the function will read in the necessary info and store it into the Class. There is a dictionary called students which stores this as such:
students = {}
students[id] = Student(<all the info from the various "reader" functions>)

Afterwards, there is an "allocation" algorithm that will allocate projects to student. It does that well enough. The allocated_project remains as None if a student is unsuccessful in getting a project.
SQLAlchemy bit:
So after all this happens, I'd like to map my object to a database table.
from sqlalchemy import *
from sqlalchemy.orm import *

engine = create_engine('sqlite:///:memory:', echo=False)
metadata = MetaData()
students_table = Table('studs', metadata,
    Column('id', Integer, primary_key=True),
    Column('name', String)
)
metadata.create_all(engine)
mapper(Student, students_table)

Now after that, I was curious to see if I could print out all the students from my students dictionary.
for student in students.itervalues():
    print student

What do I get but an error. This error only takes place if try to print as I am, after calling the mapper:
Traceback (most recent call last):
  File "~/FYP_Tests/FYP_Tests.py", line 140, in <module>
    print student
  File "~/FYP_Tests/Parties.py", line 30, in __str__
    return "%s %s" %(self.id, self.name)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/SQLAlchemy-0.5.8-py2.6.egg/sqlalchemy/orm/attributes.py", line 158, in __get__
  return self.impl.get(instance_state(instance), instance_dict(instance))
AttributeError: 'NoneType' object has no attribute 'get'

I'm at a loss as to how to resolve this issue, if it is an issue. If more information is required, please ask and I will provide it.
Questions:

*

*Does the SQLAlchemy mapper change anything about the original Class/dictionary?

*Does this have anything specific to way the get works with dictionaries?

A: You are creating Student instances before mapping class which modifies class to SQLAlchemy needs. So your instance is not properly initialized. Just put the lines creating Student instances after calling mapper(Student, students_table) and everything will work as expected.

A: It looks like you might have a name shadowing conflict where Column('id'...) hides Student.id. Changing Student.__init__.id to Student._init__.sid would be a quick test to confirm or refute this conjecture.
There is mention of this connection in the third code block of the SQLAlchemy tutorial on mappings.
For example, replacing your first code snippet with this fragement:
class Student(object):
    def __init__(self, name, id):
        self.sid = id
        self.name = name
        # and so on

Obviously other references to Student.id would have to change as well.


text:
Q: I am new in java in my code here is an error "cannot find symbol " I am following a Book in this book the code is given i tried to compile it  but it shows errors here is the Code-
  class TapeDeck {
    boolean canRecord = false;

    void playTape() {
        System.out.println("tape recording");
    }

    void recording() {
        System.out.println("tape recording");
    }
}
class TapeDeckTestDrive {
    public static void main (String [] args) {
        TapeDeck t = new TapeDeck( );
        t.canRecord = true;
        t.play();

        if (t.canRecord == true) {
            t.recordTape();
        }
    }
}

and an error is....
    TapeDeck.java:16: error: cannot find symbol
                t.play();
                 ^
  symbol:   method play()
  location: variable t of type TapeDeck
TapeDeck.java:19: error: cannot find symbol
                        t.recordTape();
                         ^
  symbol:   method recordTape()
  location: variable t of type TapeDeck
2 errors

A: It's because play() is not a method of class TapeDeck. However, you do have the following method:
void playTape() {
    System.out.println("tape recording");
}

If this is the method that you meant, then change t.play() to t.playTape(). If not, you will need to create play() in TapeDeck.

A: You're getting this because you're trying to call methods that TapeDeck doesn't have: play() and recordTape(). Most likely the book you're referring to just didn't show the implementation for the sake of size.
You can just add those methods to your TapeDeck class, or change the methods you're calling from your main method to the ones already in your TapeDeck class (playTape() and recording()).


text:
Q: Python Kivy error: 'kivy.properties.ObjectProperty' object has no attribute text I've just started to learn Python Kivy and want to output text from TextInput
Error in console: AttributeError: 'kivy.properties.ObjectProperty' object has no attribute text
My Python Code:
class SearchField(AnchorLayout):
    search_field = ObjectProperty(None)
    result = search_field.text
class MyApp(App):
    def build(self):
        return SearchField()
if __name__ == "__main__":
    MyApp().run()

My .kv code:
<SearchField>
    search_field: search_field
    anchor_x: "center"
    anchor_y: 'top'
    padding: (0, 20)
    BoxLayout:
        size_hint: (None, None)
        size: (600, 30)
        TextInput:
            id: search_field
            multiline: False
        Button:
            size_hint: (None, None)
            size: (50, 30)
            text: "Search"
            on_release: search_result.text = root.result
    Label:
         id: search_result
         text: ""
         font_size: 30

A: Several errors are made in this program.
1- the text attribute is applied to the search_field variable directly after its declaration as ObjectProperty. So, it's an ObjectProperty instance and dont have the attribute text.
2- The indentation of the program is badly done.
3- The properties are not well declared in the .kv file.
Although I haven't fully understood the purpose of the program, here is a safe version:
from kivy.app import App
from kivy.uix.anchorlayout import AnchorLayout
from kivy.properties import ObjectProperty

class SearchField(AnchorLayout):
    search_field = ObjectProperty(None)
    result = ""

    def btn(self):
        self.result = self.search_field.text
        print(self.result)

class TestApp(App):
    def build(self):
        return SearchField()

if __name__ == "__main__":
    TestApp().run()

And here is the kv file:
<SearchField>
    search_field: search_field
    anchor_x: "center"
    anchor_y: 'top'
    padding: (0, 20)
    search_result: search_result
    search_field: search_field
    BoxLayout:
        size_hint: (None, None)
        size: (600, 30)
        TextInput:
            id: search_field
            multiline: False
        Button:
            size_hint: (None, None)
            size: (50, 30)
            text: "Search"
            on_release: root.btn()
    Label:
        id: search_result
        text: ""
        font_size: 30


text:
Q: Declaring and Consuming User Defined Table Types in SQL I am trying to use User Defined Table Types in SQL, but am hitting problems I didn't expect. Relevant sections of code are as follows:
declare @customer varchar(10), @prodgroup varchar(10)

SET @customer = 'CUST123'
SET @prodgroup = 'AA9A3'

declare @pctn  prices_ctn --User defined table type
declare @ppck  prices_pck --User defined table type
declare @psin  prices_sin --User defined table type

declare @sqlctn varchar(8000), @sqlpck varchar(8000), @sqlsin varchar(8000)
SET @sqlctn = 'insert into @pctn select product_code, price FROM pricing_table with (nolock) WHERE price_list  = ''CTN'' AND product_code like ''' + @prodgroup + ''''
SET @sqlpck = 'insert into @ppck select product_code, price FROM pricing_table with (nolock) WHERE price_list  = ''PCK'' AND product_code like ''' + @prodgroup + ''''
SET @sqlsin = 'insert into @psin select product_code, price FROM pricing_table with (nolock) WHERE price_list  = ''SIN'' AND product_code like ''' + @prodgroup + ''''

exec(@sqlctn)
exec(@sqlpck)
exec(@sqlsin)

However, when I execute the code, I am getting 'Must declare the table variable' error for each of my user-defined table types.
Table types are all created and show in 'User-Defined Table Types' in SSMS. SQL version is 12.0.2000.8.
What am I doing wrong?

A: A table variable cannot be used in a dynamic SQL query because it only exists in the current session just like any other variable.
EXEC creates a second session where none of you variables exist unless you pass them as a parameter.
In those queries, the table variables  are out of the dynamic SQL scope.
Table type and variable are used to pass a table to a stored procedure (READ ONLY table) or get a table from a procedure or function.
There are 2 ways to make it work:

*

*Insert into
declare @params = N'@prodgroup varchar(10)';
SET @sqlctn = 'select product_code, price FROM pricing_table with (nolock) WHERE price_list  = ''CTN'' AND product_code like @prodgroup; '

declare @pctn  prices_ctn --User defined table type
insert into @pctn
exec sp_executesql @sqlctn, @params, @prodgroup = @prodgroup;

*Temp Table
create table  #pctn  (...)
declare @params = N'@prodgroup varchar(10)';
SET @sqlctn = 'insert into #pctn select product_code, price FROM pricing_table with (nolock) WHERE price_list  = ''CTN'' AND product_code like @prodgroup '
exec sp_executesql @sqlctn, @params, @prodgroup = @prodgroup;

Note that I am using sp_executesql and a paramter variable. This is the best way to call dynamic SQL. EXEC alone and string concatenation for parameters should be avoided.


text:
Q: specific argument was out of range of valid value parameter name : index Error : specific argument was out of range of valid value parameter name : index
This error message occurred every 2min in design time!!
what should i do?

A: The designer executes code from controls on the design surface at design time.  This error is probably coming from code in one of your UserControls, or possibly a buggy third party control.
Things you can do to help prevent code being executed at Design Time:

*

*Avoid putting such code in the constructor of your UserControl.

*Use if (this.DesignMode) to conditionally suppress the code at design-time.  It's common to do this in the OnLoad method.

*Mark properties in your usercontrol that should not be evaluated at design-time with appropriate attributes, e.g.:
[
Browsable(false),
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)
]
public MyType MyRuntimeOnlyProperty
{
    ...
}

If all else fails, you can start a second instance of Visual Studio, and attach its debugger to your instance that's running the Designer.  Then break on the appropriate exception.


text:
Q: Calling JavaScript from Kotlin I have ReactNative project and I'm trying to call simple JS function from Kotlin (calling Kotlin from JS works fine). My project directory looks like this:

"shared" module is compiled as commonjs module.
In Main.kt I have (shortened):
external fun myFun()

In App.js I have (shortened):
import * as shared from './shared/build/classes/kotlin/main/shared.js'
export function myFun(){
    console.log("Hello")
}

So I'm trying to call myFun() from Kotlin to get console log in JS. But I get exception:
myFun is not defined

I was looking to this docs:
https://kotlinlang.org/docs/reference/js-interop.html
https://kotlinlang.org/docs/reference/js-modules.html#applying-jsmodule-to-packages
But I not sure how to use those annotations (if they are needed?).
Thanks for help.

A: I think you should annotate your kotlin declaration with
@JsModule("<module_name>") // seems like it is App
external fun myFun()

and setup module kind to umd in gradle sript like this
compileKotlin2Js.kotlinOptions.moduleKind = "umd"