text:
Q: How to create class diagram from source code using either Enterprise Architect or Rational Software Architect? I am not fluent in UML, but I would like to create a class diagram based on existing C++ code.  Other StackOverflow questions have indicated that two programs - Enterprise Architect and Rational Software Architect - are fairly good at "reverse engineering" C++ code (i.e., creating UML class diagrams based on existing C++ code).
I have downloaded the trial version for both of these applications.  However, I cannot make any headway into understanding what to do to create a class diagram in either of these applications.
In Rational Software Architect, I have created a UML project, but I cannot find any way within the program to select, and reverse engineer, my existing C++ code.
In Enterprise Architect, I was able to import my C++ code, but all the elements (classes) appeared in a useless, overlapping diagonal line within the diagram.  I attempted other settings, such as circle, but these were equally impossible to read because the diagrams were so large (due to the attributes and methods taking up alot of space) that no amount of panning and zooming was useful.  What I would like is to hide everything except the class names (i.e., not display any methods or attributes) so that all 20 classes appear conveniently and legibly in one screen.
However, I am unable to find a way to hide everything except the class names.  Rather, when I found an option (in Enterprise Architect) that seemed like it might hide everything but the class names, for some reason the elements all vanished in the class diagram, and no amount of repeating the steps & deleting and re-adding packages made the class diagram reappear.
Note: My C++ code (at least those files I selected for import into Enterprise Architect) amount to only about 20 classes.
Sadly, a very careful search of the documentation for both of these programs provides only generalities - no specific instructions are given regarding reverse engineering for either of these programs, so far as I could find.
I would be grateful if someone could tell me the basic steps to create a legible, easy-to-navigate diagram via. reverse engineering (i.e., C++-to-UML) that shows only the class names, so that about 20 classes fit (legibly) on one screen, using either Enterprise Architect, or Rational Software Architect - OR any other tool whatsoever that is capable of doing this (I suggest EA and Rational only because they have been highlighted in other StackOverflow answers as the best programs available for this purpose).

A: This answer applies to EA.
You can import individual files or whole directories, recursively or no. Directory import is by far the most common case; single file import does not allow you to create a diagram automatically.
When you import a source directory, you have the option of creating diagrams for each UML package, or no diagrams at all. You also decide whether to create packages for each source code directory, namespace (default) or file.
If your code constists of only 20 classes then it's likely they're in a single directory and/or namespace, so play around with that option (Package Structure in the Import Source dialog) to get the right number of diagrams.
In the same dialog, there's a button "New Diagram Options," which opens another config dialog where you can choose whether the diagrams should contain the classes' attributes and/or operations. You can also make the decision on a visibility basis, eg show public members only.
This dialog only affects what's shown in the diagrams when they are created. The members are still imported, just not displayed. This sounds like what you're after.
You can change the display options for any diagram by double-clicking an empty area of it, or right-clicking and selecting Properties. It sounds like you got into this dialog and changed something around, but I can't really tell what. The situation you describe, where you can't get the display back the way it was, is not one I've ever encountered in EA.
It is also possible to select display options on a per-class basis by right-clicking it in the diagram and selecting Feature Visibility. I don't recommend you use this in reverse-engineered diagrams, I'm just mentioning it for completeness.
The layout you describe, with all classes in a meaningless diagonal, suggests to me that the diagram isn't being laid out properly after creation. The diagram creation is a two-step process; first all the classes are dropped onto it, then the layout is applied.
This is strange, as EA automatically lays out generated diagrams and I haven't been able to find an option which allows you to deselect this behaviour. If this persists, send a bug report to Sparx Systems. You can always lay out the diagram by opening it and selecting Layout Diagram from the top-level Diagram menu.
If, finally, your classes are spread out among different packages and namespaces so that EA generates multiple diagrams for them, you'll have to merge them manually. Do this by opening both diagrams, selecting all (Ctrl-A) in one, copying (Ctrl-C) and pasting (Ctrl-V) into the other, then ask EA to Layout Diagram again.
So:

*

*Right-click an empty package in the project browser, select Code Engineering - Import Source Directory.

*In the dialog, select the root directory and source type.

*Tick "Create Logical Diagram for Each Package" and select the Package Structure which best fits your source structure.

*Click "New Diagram Options" and in the new dialog untick "Show Attributes," "Show Operations" and "Show Property Methods" if applicable.

*OK both dialogs.

*If multiple diagrams have been created, copy all classes into a single diagram.

*If the layout looks bad, select Diagram - Layout Diagram.

Hope this helps.


text:
Q: geom_ribbon for multiple densities in ggplot2 I have a data frame (aa) with daily values of 7 variables and I want to create the density plot of all the variable in one plot using the ggplot in R.
date                1       2      3       4         5        6      7
1/1/1951 1:00   576.568 308.596 501.752 359.868 772.522 475.146 307.991
1/2/1951 1:00   722.986 461.295 652.33  525.561 1806.75 724.128 460.697
1/3/1951 1:00   859.542 582.949 910.248 642.133 2388.73 959.896 579.396
1/4/1951 1:00   1136.49 704.732 1047.04 1304.73 2619.04 1545.61 690.574
1/5/1951 1:00   1747.84 769.764 1099.24 1828.5  2695.6  2052.11 790.35
1/6/1951 1:00   1842.66 811.765 1130.44 2031.97 2747.14 2532.89 860.417
1/7/1951 1:00   2734.15 895.825 1158.42 2145.6  2772.58 2826.31 944.181
1/8/1951 1:00   2870.02 996.17  1159.5  2123.04 2773.86 3385.17 1055.53
1/9/1951 1:00   3687.38 1021.61 1150.51 2096.66 2812.93 3579.46 1064.43
1/10/1951 1:00  3704.4  1015.38 1133.83 2064.84 3338.98 3649.31 1183.86
1/11/1951 1:00  4270.37 1007.37 1121.8  2018.4  3299.18 3702.44 1459.35
1/12/1951 1:00  4477.54 990.477 1094.73 1985.98 3269.85 4044.5  1638.76
1/13/1951 1:00  4447.05 969.607 1068.21 1949.35 3179.74 4154.53 1726.56
1/14/1951 1:00  4400.13 985.999 1599    1944.67 3185.36 4216.58 1704.72
1/15/1951 1:00  4332.73 971.912 2050.99 2405.2  3274.99 4204.33 1698.51
1/16/1951 1:00  4249.38 944.5   2080.25 2578.95 3391.08 4142.77 1712.02
1/17/1951 1:00  4152.52 920.435 2054.55 2653.13 3541.91 4208.52 1678.24
1/18/1951 1:00  4127.45 893.521 2169.34 2732.53 3563.56 4303.28 1664.81
1/19/1951 1:00  4386.13 863.506 2138    2810.65 3551.63 4205.68 1635.35
1/20/1951 1:00  4266.45 833.389 2098.66 2918.06 3626.92 4542.01 1600.13
1/21/1951 1:00  4123.47 803.421 2054    2944.82 3602.07 4501.44 1589.96
1/22/1951 1:00  3985.95 773.803 2370.33 2988.91 3535.31 4395.38 1684.4
1/23/1951 1:00  4022.89 744.697 3314.27 2965.02 3482.09 4359.78 1758.83
1/24/1951 1:00  4081.97 716.225 3497.79 2924.84 3567.54 4564.74 1709.34
1/25/1951 1:00  4062.92 688.476 3472.63 2935.65 3502.1  4548.38 1680.46
1/26/1951 1:00  4365.36 661.515 3380.87 3481.96 3440.78 4987.91 1637.77
1/27/1951 1:00  4401.38 635.384 3287.63 3995.07 3437.95 5059.32 1604.2
1/28/1951 1:00  4269.47 610.107 3192.09 3945.04 3722.05 4953.97 1552.9
1/29/1951 1:00  4318.51 585.697 3094.34 3915.98 3702.45 4895.55 1502.28
1/30/1951 1:00  4298.75 562.154 2994.88 3880.55 3636.89 4766.2  1451.75
1/31/1951 1:00  4153.07 539.473 2894.43 3799.82 3565.1  4644.76 1531.08
2/1/1951 1:00   4003.85 517.64  2793.79 3710.46 3485.51 4580.68 1748.19
2/2/1951 1:00   3857.05 915.839 2693.67 3623.19 3398.42 4543.95 1858.94
2/3/1951 1:00   3713.03 902.46  2608.46 3519.39 3311    4452.38 1851.69
2/4/1951 1:00   3572.17 865.735 3865.87 3435.52 3231.97 4317.65 1814.48
2/5/1951 1:00   3434.84 1153.22 4238.76 3407.45 3129.51 4184.76 1775.47
2/6/1951 1:00   3301.26 1106.52 4103.02 3497.4  3055.22 4172.17 1756.6
2/7/1951 1:00   3172.63 1061.36 3956.05 3673.07 2968.45 4302.39 1716.4
2/8/1951 1:00   3079.31 1018.01 4103.28 3630.38 3435.38 4536.9  1669.38
2/9/1951 1:00   2959.4  980.38  4208.58 3518.13 3605.31 4451.53 1746.94
2/10/1951 1:00  2844.15 940.297 4190.15 3388.06 3468.35 4382.59 1691.15
2/11/1951 1:00  2732.83 901.835 4119.65 3292.29 3845.2  4349.97 1634.61
2/12/1951 1:00  2634.55 864.93  4204.1  3171.04 3858.71 4273.37 1597.97
2/13/1951 1:00  2540.9  830.727 4192.34 3047.67 4388.68 4170.63 2284.54
2/14/1951 1:00  2529.75 896.13  4094.57 2928.25 5056.55 4161.73 2458.95
2/15/1951 1:00  2483.45 1214.75 3977.09 2812.77 5601.96 4061.48 2382.13
2/16/1951 1:00  2384    1314.73 3859.21 2701.17 5968.48 3950.86 3140.67
2/17/1951 1:00  2288.75 1274.76 3740.11 2593.42 6033.75 3834.06 3194.2
2/18/1951 1:00  2196.63 1239.29 3620.01 2489.48 5938.22 3730.9  3097.74
2/19/1951 1:00  2108.71 1207.04 3510.97 2389.31 5807.13 3637.96 3174.11
2/20/1951 1:00  2029.62 1168.64 3434.68 2292.85 5671.36 3540.38 3080.33
2/21/1951 1:00  1953.52 1495.14 3404.76 2200.02 5612.84 3431.11 2977.1
2/22/1951 1:00  1877.59 2010.5  3344.68 2110.75 5475.63 3313.23 2875.18
2/23/1951 1:00  1804.35 2375.9  3251.89 2024.93 5329.19 3282.22 2774.5
2/24/1951 1:00  1732.6  2412.77 3150.66 2034.99 5179.73 3456.21 2675.38
2/25/1951 1:00  1701.74 2436.28 3088.83 2513.05 5239.82 3454.15 2578.02
2/26/1951 1:00  1727.88 2377.25 2999.05 2798.06 5264.78 3709.65 2482.93
2/27/1951 1:00  1669.38 2402.1  2903.54 2965.21 5553.4  3653.49 2390.28
2/28/1951 1:00  1608.28 2345.84 2830.42 2996.06 5478.35 3560.17 2300.54
3/1/1951 1:00   1574.09 2285.2  2738.14 3053.62 5352.85 3605.94 2216.72
3/2/1951 1:00   1568.13 2220.31 2644.64 2985.46 5227.08 3699.48 2129.27
3/3/1951 1:00   1647.75 2220.27 2631.15 2969.02 5213.33 3721.7  2044.68
3/4/1951 1:00   1719.77 2521.67 2670.33 3164.43 5160.05 3681.58 1964.03
3/5/1951 1:00   1704.79 2626.48 2704.3  3173.32 5399.89 3610.76 1889.66
3/6/1951 1:00   1639.59 2741.6  2668.98 3236.33 5554.96 3528.92 1818.41
3/7/1951 1:00   1575.53 2677.43 2704.18 3341.03 5592.91 3469.95 1750.35
3/8/1951 1:00   1513.84 3081.42 2750.38 3387.48 5541.88 3409.68 1680.34
3/9/1951 1:00   1454.16 3035.34 2764.71 3473.48 5517.83 3340.67 1612.23
3/10/1951 1:00  1396.52 2988.29 2711.31 3448.16 5614.53 3250.09 1549.71
3/11/1951 1:00  1340.85 3336.91 2698.67 3492.85 5522.72 3160.29 1504.31
3/12/1951 1:00  1287.2  3368.07 2663.92 3484.74 5410.01 3063.21 1467.34
3/13/1951 1:00  1235.86 3346.46 2599.99 3447.85 5289.24 2997.02 1435.41
3/14/1951 1:00  1192.06 3742.42 2533.14 3406.32 5154.86 2901.11 1417.03
3/15/1951 1:00  1167.73 4132.53 2463.68 3331.86 5014.21 2808.8  1405.8
3/16/1951 1:00  1295.27 4405.71 2391.41 3253.14 4868.89 2710.32 1392.99
3/17/1951 1:00  1618.42 4427.48 2316.29 3170.24 4732.69 2608.73 1373.93
3/18/1951 1:00  1559.84 4442.58 2239.86 3087.54 4608.15 2509.65 1348.4
3/19/1951 1:00  1502.9  4696.88 2162.9  3004.81 4457.99 2412.95 1327.24
3/20/1951 1:00  1447.55 4767.77 2086.49 2918.91 4299.06 2318.83 1272.94
3/21/1951 1:00  1393.54 4734    2019.74 2831.26 4142.57 2242.03 1276.85
3/22/1951 1:00  1341.04 4692.49 1959.31 2745.44 3991.74 2190    1245.43
3/23/1951 1:00  1289.98 4630.91 1895.69 2665.02 3841.69 2113.67 1200.63
3/24/1951 1:00  1240.42 4589.67 1826.32 2564.35 3695.19 2032.02 1151.92
3/25/1951 1:00  1195.7  4594.68 1758.67 2466.22 3552.06 1952.83 1108.28
3/26/1951 1:00  1159.06 4543.89 1690.77 2372.2  3436.21 1893.66 1072.04
3/27/1951 1:00  1145.87 4434.54 1623.81 2281.07 3308.64 1823.82 1053.01
3/28/1951 1:00  1158.77 4320.49 1559.12 2196.58 3178.24 1905.79 1071.73
3/29/1951 1:00  1144.67 4202.17 1496.77 2119.89 3056.39 1905.91 1202.11
3/30/1951 1:00  1169.91 4077.59 1436.54 2048.02 2938.67 1863.56 1227.16
3/31/1951 1:00  1812.98 3947.1  1378.53 1989.09 2824.59 1889.91 1177.6
4/1/1951 1:00   1865.61 3814.54 1322.83 1942.43 2714.82 1828.26 1130.36
4/2/1951 1:00   1880.82 3681.54 1270.61 1874.94 2610.78 1772.37 1085.31
4/3/1951 1:00   1875.71 3549.85 1219.25 1814.91 2515.79 1717.05 1064.22
4/4/1951 1:00   1852.95 3441.96 1174.54 1754.13 2424.83 1672.71 1148.52
4/5/1951 1:00   1823.04 3312.73 1150.92 1686.87 2346.9  1916.25 1175.51
4/6/1951 1:00   1788.45 3424.52 1107.59 1622.21 2274.12 2001.31 1327.16
4/7/1951 1:00   1755.09 3390.87 1064.25 1560.85 2202.44 1935.57 1300.41
4/8/1951 1:00   1723.22 3308.63 1035.33 1500.06 2132.47 1882.89 1725.13
4/9/1951 1:00   1689.11 3495.84 997.53  1440.55 2068.17 1898.3  1703.47
4/10/1951 1:00  1658.82 3431.23 1032.74 1383.38 1986.15 1964.13 1663.5
4/11/1951 1:00  1629.97 3964.34 1029.15 1329.29 1905.02 1902.88 1802.32
4/12/1951 1:00  1598.96 3958.32 1009.02 1285.82 1828.44 1838.5  1786.33
4/13/1951 1:00  1560.68 3836.09 1007.55 1234.12 1754.68 1783.13 1810.27
4/14/1951 1:00  1517.77 3715.66 997.538 1245.67 1685.86 1718.58 1803.11
4/15/1951 1:00  1476.25 3595.59 972.362 1235.17 1621.62 1655.1  1745.61
4/16/1951 1:00  1440.83 3475.52 947.23  1200.96 1560.92 1593.27 1684.32
4/17/1951 1:00  1404.89 3361.25 914.863 1160.45 1504.27 1533.62 1634.78
4/18/1951 1:00  1373.95 3245.87 882.695 1165.72 1450.55 1476.49 1587.29
4/19/1951 1:00  1346.33 3144.21 851.48  1222.47 1400.78 1425.16 1539.01
4/20/1951 1:00  1326.58 3070.07 825.579 1192.75 1352.88 1380.79 1496.15
4/21/1951 1:00  1313.58 2957.91 799.894 1279.43 1304.74 1375.75 1467.54
4/22/1951 1:00  1295.72 2858.02 780.357 1278.21 1257.36 1329.1  1447.8
4/23/1951 1:00  1290.81 2794.22 755.867 1692.37 1219.04 1296.83 1470.15
4/24/1951 1:00  1284.3  2731.48 741.104 1763.2  1213.48 1372.8  1496.9
4/25/1951 1:00  1312.79 2629.26 732.116 1764.69 1202.94 1411.4  1484.06
4/26/1951 1:00  1280.24 2547.8  734.836 1705.97 1423.37 1390.16 1479.25
4/27/1951 1:00  1231.06 2476.66 749.586 1648.91 1542.41 1341.19 1523.21
4/28/1951 1:00  1204.23 2401.36 769.556 1635.77 1494.66 1304.07 1568.9
4/29/1951 1:00  1256.4  2326.5  743.761 1700.3  1482.53 1277.8  1653.51
4/30/1951 1:00  1228.98 2366.87 723.332 1733.35 1599.09 1256.08 1655.35
5/1/1951 1:00   1232.3  2325.47 699.928 2318.56 1544    1232.58 1660.23
5/2/1951 1:00   1265.11 2234.34 681.914 2419.03 1482.98 1212.6  1675.77
5/3/1951 1:00   1248.22 2153.43 675.823 2379.94 1446.54 1185.34 1686.94
5/4/1951 1:00   1337.7  2079.83 670.847 2392.08 1395.88 1156.82 1698.45
5/5/1951 1:00   1306.61 2019.09 672.758 2466.25 1346.6  1136.58 1710.61
5/6/1951 1:00   1306.49 1970.78 700.209 2655.81 1295.43 1128.42 1698.08
5/7/1951 1:00   1309.95 1932.32 882.106 2674.44 1248.17 1129.06 1689.33
5/8/1951 1:00   1272.11 1889.79 909.731 2641.26 1206.5  1127.26 1676.88
5/9/1951 1:00   1244.76 1874.85 929.057 2723.38 1161.74 1133.94 1668.98
5/10/1951 1:00  1198.68 1882.87 906.422 2773.55 1142.75 1160.08 1658.15
5/11/1951 1:00  1160.28 1923.64 883.694 2729.87 1304.01 1193.74 1636.8
5/12/1951 1:00  1164.25 1890.92 880 2833.58 1261.43 1197.94 1596.65
5/13/1951 1:00  1259.59 1839.77 1006.3  3121.41 1221.17 1178.36 1569.62
5/14/1951 1:00  1214.37 1806.38 1139.01 3055.57 1339.85 1180.08 1531.61
5/15/1951 1:00  1183    1742.32 1514.41 2979.32 1382.48 1223.9  1561.12
5/16/1951 1:00  1159.61 1677.67 1709.11 2925.61 1333.32 1275.86 1599.04
5/17/1951 1:00  1149.81 1631.52 1804.58 2883.21 1298.32 1334.42 1643.99
5/18/1951 1:00  1128.56 1612.8  1780.06 2933.64 1269.32 1385.4  1741.65
5/19/1951 1:00  1115.82 1583.65 1749.24 2872.47 1259.52 1443.94 1814.02
5/20/1951 1:00  1116.03 1604.84 1767.84 2777.15 1236.89 1596.69 1825.09
5/21/1951 1:00  1134.75 1703.42 2013.04 2705.05 1268.37 1565.95 1853.67
5/22/1951 1:00  1122.38 1679.7  2049.85 2623.92 1327.74 1619.07 1806.14
5/23/1951 1:00  1108.9  1800.42 2032.87 2545.06 1459.69 1797.12 1748.84
5/24/1951 1:00  1086.38 1785.76 2031.06 2464.62 1451.84 1806.26 1686.03
5/25/1951 1:00  1074.68 1774.78 2061.98 2395.28 1418.96 1758.22 1624.42
5/26/1951 1:00  1167.38 1739.84 2156.03 2323.39 1390    1709.5  1568.7
5/27/1951 1:00  1166.05 1804.56 2339.12 2238.41 1609.57 1664.23 1515.6
5/28/1951 1:00  1166.96 1936.75 2323.81 2150.81 1638.19 1634.7  1463.76
5/29/1951 1:00  1150.97 1899.51 2329.38 2133.96 1610.33 1615.67 1410.4
5/30/1951 1:00  1171.27 1947.8  2536.99 2146.59 1624.47 1606.06 1361.94
5/31/1951 1:00  1166.67 2194.86 2508.85 2237.88 1575.08 1634.12 1320.08
6/1/1951 1:00   1141.49 2228.97 2434.56 2323.28 1526.3  1661.63 1284.83
6/2/1951 1:00   1120.47 2175.77 2371.56 2267.76 1487.86 1747.76 1256.68
6/3/1951 1:00   1093.94 2171.73 2318.04 2278.99 1474.29 1733.02 1250.33
6/4/1951 1:00   1065.52 2137.24 2263.77 2199.86 1497.28 1713.74 1209.63
6/5/1951 1:00   1041.89 2136.09 2190.93 2121.43 1457.82 1683.18 1201.05
6/6/1951 1:00   1011.35 2136.3  2129.71 2044.39 1444.52 1646.91 1178.4
6/7/1951 1:00   975.028 2145.79 2074.18 1971.57 1448.25 1618.44 1153.39
6/8/1951 1:00   940.422 2114.38 2026.68 1909.96 1458.49 1591.83 1115.06
6/9/1951 1:00   909.511 2060.67 1957.48 1874.84 1496.27 1663.22 1120.41
6/10/1951 1:00  881.323 2011.8  1890.22 1826.43 1534.7  1771.82 1111.26
6/11/1951 1:00  855.554 1962.46 1832.95 1777.2  1593.66 1868.05 1115.46
6/12/1951 1:00  828.964 1909.71 1778.42 1722.21 1636.95 1793.37 1075.06
6/13/1951 1:00  804.086 1859.22 1712    1670.6  1632.44 1722.44 1046.34
6/14/1951 1:00  778.927 1804.78 1651.35 1628.33 1660.17 1657.77 1106.06
6/15/1951 1:00  754.193 1751.86 1598.2  1762.41 1738.57 1609.42 1069.42
6/16/1951 1:00  731.139 1701.25 1555.76 1843.26 1765.32 1556.76 1035.4
6/17/1951 1:00  710.103 1659.92 1498.78 1791.43 1784.72 1579.74 1002.95
6/18/1951 1:00  703.879 1603.93 1603.34 1769.58 2015.57 1601.42 997.783
6/19/1951 1:00  691.781 1548.96 1559.46 1717.57 2050.61 1540.37 970.923
6/20/1951 1:00  1059.58 1494.3  1522.58 1671.23 2051.55 1481.78 939.208
6/21/1951 1:00  1110.68 1439.47 1536.86 1629.83 2045.69 1430.61 909.428
6/22/1951 1:00  1101.07 1386.08 1929    1579.34 2044.79 1384.03 881.96
6/23/1951 1:00  1077.87 1337.32 1953.41 1527.09 2050.25 1345.84 855.904
6/24/1951 1:00  1071.67 1288.9  1880.82 1476.88 2038.62 1376.26 827.653
6/25/1951 1:00  1078.04 1243.48 1862.96 1428.25 2016.73 1492.71 801.002
6/26/1951 1:00  1116.61 1199.91 1798.16 1383.56 1996.23 1438.23 774.804
6/27/1951 1:00  1214.1  1156.82 1961.49 1340.19 1986.9  1389.82 750.454
6/28/1951 1:00  1230.6  1114.48 1890.87 1297.42 1963.9  1366.01 727.893
6/29/1951 1:00  1376.2  1174.09 1820.57 1380.23 1929.55 1320.35 715.91
6/30/1951 1:00  1340.32 1144.34 1763.42 1355.39 1886.8  1278.97 881.508
7/1/1951 1:00   1292.18 1106.3  1739.17 1429.77 1834.12 1240.08 910.984
7/2/1951 1:00   1244.22 1070.49 1895.89 1453.19 1780.86 1254.12 875.708
7/3/1951 1:00   1199.22 1057.07 1895.1  1412.33 1732.32 1348.73 851.163
7/4/1951 1:00   1158.89 1028.51 1827.25 1396.07 1680.39 1295.46 832.093
7/5/1951 1:00   1259.61 994.971 1802.14 1411.81 1624.13 1249.98 851.646
7/6/1951 1:00   1227.98 962.17  1784.4  1377.75 1568.53 1208.88 822.595
7/7/1951 1:00   1197.16 931.445 1766.44 1373.47 1519.12 1182.29 792.594
7/8/1951 1:00   1164.45 909.444 1701.69 1325.09 1474.84 1244.96 763.652
7/9/1951 1:00   1135.29 898.986 1803.29 1281.39 1428.67 1322.78 738.863
7/10/1951 1:00  1094.83 875.32  1933.74 1240.38 1380.09 1582.96 712.016
7/11/1951 1:00  1055.46 847.625 1865    1200.46 1334.61 1612.94 689.9
7/12/1951 1:00  1016.67 818.958 1801.86 1163.41 1290.76 1619.86 702.886
7/13/1951 1:00  977.839 793.202 1745.62 1126.56 1247.5  1701.16 680.056
7/14/1951 1:00  941.782 771.035 1700.33 1090.64 1212.04 1716.81 658.393
7/15/1951 1:00  908.753 752.606 1662.62 1081.28 1183.16 1719.49 639.721
7/16/1951 1:00  877.51  935.476 1601.96 1056.69 1152.2  1676.24 622.633
7/17/1951 1:00  847.928 1330.68 1546.06 1039.49 1171.52 1635.67 631.078
7/18/1951 1:00  819.773 1311.03 1493.5  1047.16 1130.61 1639.27 613.98
7/19/1951 1:00  792.915 1265.12 1460.46 1011.69 1092.57 1588.82 603.208
7/20/1951 1:00  767.243 1222.03 1405.81 1100.74 1091.14 1535.05 584.897
7/21/1951 1:00  742.893 1204.46 1353.82 1383.01 1054.6  1494.58 569.675
7/22/1951 1:00  719.341 1162.33 1306.41 1797.51 1020.15 1543.84 575.738
7/23/1951 1:00  696.562 1123.31 1267.62 1830.11 988.19  1508.21 583.532
7/24/1951 1:00  675.924 1162.78 1223.88 1765.1  1027.7  1473.93 614.682
7/25/1951 1:00  661.057 1124.09 1182.63 1702.59 1014.29 1631.72 612.546
7/26/1951 1:00  679.961 1089.78 1144.22 1652.44 979.729 1584.5  605.722
7/27/1951 1:00  660.791 1102.66 1106.02 1646.82 947.145 1527.02 590.314
7/28/1951 1:00  642.725 1073.56 1070.31 1607.29 915.957 1533.29 596.444
7/29/1951 1:00  663.503 1037.36 1037.07 1550.32 1002.37 1543.77 581.582
7/30/1951 1:00  651.948 1001.29 1007.6  1495.34 1161.34 1490.13 577.83
7/31/1951 1:00  634.32  969.425 1021.05 1441.68 1130.55 1438.28 564.808
8/1/1951 1:00   618.891 947.812 986.323 1390.42 1168.49 1388.32 600.806
8/2/1951 1:00   608.039 938.736 953.7   1341.94 1126.99 1382.47 597.313
8/3/1951 1:00   667.646 923.228 922.387 1296.37 1086.23 1340.56 664.759
8/4/1951 1:00   659.323 893.933 893.014 1251.44 1048.46 1293.14 716.268
8/5/1951 1:00   648.488 1021.82 891.359 1209.35 1011.48 1248.58 703.447
8/6/1951 1:00   632.3   1095.96 1099.22 1170.11 976.161 1204.56 683.621
8/7/1951 1:00   618.085 1092.21 1060.47 1136.43 942.963 1173.48 667.491
8/8/1951 1:00   602.466 1202.22 1021.34 1120.45 968.045 1329.41 653.331
8/9/1951 1:00   587.453 1397.47 985.843 1084.1  1072.01 1292.29 641.894
8/10/1951 1:00  574.043 1354.74 952.957 1047.73 1075.4  1246.04 702.969
8/11/1951 1:00  562.144 1305.1  921.655 1013.37 1059.16 1205.38 683.65
8/12/1951 1:00  584.826 1262.65 893.031 1031.12 1043.81 1161.34 710.367
8/13/1951 1:00  580.844 1257.84 865.607 1112.42 1176.16 1121.24 764.236
8/14/1951 1:00  585.845 1421.38 842.275 1072.94 1140.94 1113.25 760.43
8/15/1951 1:00  1138.93 1392.95 816.628 1036.72 1101.78 1356.95 785.087
8/16/1951 1:00  1215.95 1347.1  792.186 1002.88 1078.93 1381.03 762.678
8/17/1951 1:00  1228.68 1400.36 776.859 974.684 1043.95 1406.93 741.7
8/18/1951 1:00  1202.03 1456.57 780.517 945.327 1004.95 1360.86 722.036
8/19/1951 1:00  1221.12 1497.04 1441.75 915.365 968.521 1315.16 709.169
8/20/1951 1:00  1177.16 1442.68 2503.59 885.85  934.568 1392.11 689.621
8/21/1951 1:00  1134.62 1430.34 3216.34 857.606 904.955 1389.83 669.421
8/22/1951 1:00  1107.93 1658.08 3205.78 828.599 878.469 1355.1  648.328
8/23/1951 1:00  1177.11 1849.94 3136.63 804.99  849.94  1307.36 628.98
8/24/1951 1:00  1210.75 1782.49 3568.05 778.814 821.994 1314.59 612.572
8/25/1951 1:00  1295.35 1717.66 3689.64 754.489 795.893 1300.39 597.613
8/26/1951 1:00  1251.68 1656.24 3549.93 730.701 770.1   1257.26 583.451
8/27/1951 1:00  1240.03 1599.26 3416.38 707.467 745.538 1221.4  569.435
8/28/1951 1:00  1197.23 1546.4  3293.43 683.328 722.857 1378.84 555.525
8/29/1951 1:00  1547.41 1545.26 3168.92 660.238 701.089 1333.38 542.849
8/30/1951 1:00  1728.28 1513.6  3047.83 639.119 680.118 1297.38 531.791
8/31/1951 1:00  1766.99 1480.93 2933.64 620.192 660.585 1497.7  572.11
9/1/1951 1:00   1704.01 1429.12 2824.59 603.568 667.87  1503.94 707.692
9/2/1951 1:00   1642.49 1381.48 2718.47 587.822 666.708 1590.17 691.175
9/3/1951 1:00   1584.37 1529.19 2616.22 573.659 646.888 1606.15 717.891
9/4/1951 1:00   1528.76 2435.63 2519.12 564.207 626.794 1553.98 690.693
9/5/1951 1:00   1477.91 2526.62 2427.44 548.366 607.768 1503.95 667.275
9/6/1951 1:00   1429.65 2460.48 2339.48 534.527 591.769 1455.35 644.975
9/7/1951 1:00   1379.68 2367.86 2251.4  520.936 635.32  1408.65 626.621
9/8/1951 1:00   1337.42 2279.57 2168.13 508.246 738.938 1363.39 610.864
9/9/1951 1:00   1310.15 2194.82 2182.55 496.326 717.112 1318.97 606.687
9/10/1951 1:00  1362.07 2114.32 2341.05 577.235 732.378 1275.26 589.341
9/11/1951 1:00  1311.19 2038.49 2250.21 613.572 891.413 1235.18 571.219
9/12/1951 1:00  1263.63 1988.93 2163.44 594.976 1165.41 1201.35 590.136
9/13/1951 1:00  1219.01 2015.34 2080.34 574.966 1137.85 1295.85 805.509
9/14/1951 1:00  1176    1947.52 2000.65 555.383 1345.26 1453.36 784.49
9/15/1951 1:00  1348.17 1986.12 1924.25 538.544 1373.03 1456.26 753.196
9/16/1951 1:00  1407.16 1987.67 1850.92 522.686 1341.85 1461.8  740.049
9/17/1951 1:00  1352.97 1918.3  1784.72 507.644 1381.03 1424.82 739.127
9/18/1951 1:00  1300.24 1851.96 1719.48 493.712 1332.81 1382.47 734.296
9/19/1951 1:00  1251.78 1818.41 1655.74 482.093 1279.92 1331.31 735.545
9/20/1951 1:00  1209.74 1773.63 1593.72 468.021 1261.64 1456.91 724.446
9/21/1951 1:00  1220.93 1720.97 1533.18 456.96  1448.94 1516.53 713.133
9/22/1951 1:00  1272.48 1665.41 1475.73 462.618 1417.41 1471.87 689.368
9/23/1951 1:00  1489.41 1610.21 1420.79 454.486 1399.06 1419.63 665.089
9/24/1951 1:00  1455.88 1565.02 1369.36 450.532 1365.79 1371.07 642.505
9/25/1951 1:00  1399.38 1825.42 1320.16 436.37  1312.99 1326.89 633.057
9/26/1951 1:00  1345.88 1821.28 1273.55 422.701 1262.5  1282.31 641.853
9/27/1951 1:00  1297.64 1798.47 1230.06 409.991 1215.59 1296.8  622.47
9/28/1951 1:00  1248.31 1737.43 1193.4  397.654 1173.54 1356.49 863.944
9/29/1951 1:00  1201.12 1671.34 1154.54 385.869 1130.01 1322.4  851.795
9/30/1951 1:00  1177.24 1609.89 1112.22 374.125 1322.27 1327.07 1037.18
10/1/1951 1:00  1337.03 1636.4  1072.15 363.148 1411.67 1325.62 1133.13
10/2/1951 1:00  1455.61 1686.06 1033.84 352.513 1357    1480.85 1097.19
10/3/1951 1:00  1401.26 1632.11 997.971 342.329 1304.07 1464.4  1060.2
10/4/1951 1:00  1349.36 1593.73 963.693 333.407 1252.96 1419.1  1041.37
10/5/1951 1:00  1304.61 1690.53 974.593 325.844 1204.73 1369.34 1040.46
10/6/1951 1:00  1503.73 1629.49 1083.65 332.883 1159.53 1390.17 1286.15
10/7/1951 1:00  1452.63 1572.53 1254.7  346.665 1116    1525.06 1349.93
10/8/1951 1:00  1397.48 1516.79 1295.12 343.283 1081.3  1475.07 1304.7
10/9/1951 1:00  1364.34 1465.18 1244.24 335.273 1042.57 1425.42 1282.22
10/10/1951 1:00 1345.87 1412.89 1201.85 326.427 1003.76 1378.69 1243.58
10/11/1951 1:00 1556.76 1365.28 1158.8  319.419 967.089 1334.19 1251.17
10/12/1951 1:00 1622.52 1435.35 1115.58 312.028 932.187 1330.35 1279.36
10/13/1951 1:00 1559.3  1740.66 1076.93 304.311 897.657 1285.1  1259.34
10/14/1951 1:00 1497.79 1797.2  1037.49 295.613 864.375 1240.01 1362.83
10/15/1951 1:00 1438.53 1754    996.624 286.976 832.293 1196.84 1311.05
10/16/1951 1:00 1381.39 1802.59 957.254 278.245 801.206 1227.81 1264.84
10/17/1951 1:00 1326.29 1977.78 919.354 269.129 771.326 1193.09 1349.7
10/18/1951 1:00 1273.49 2054.25 882.291 260.336 742.13  1152.31 1388.61
10/19/1951 1:00 1243.27 2213.24 846.809 283.518 716.694 1112.56 1604.88
10/20/1951 1:00 1196.73 2152.52 812.715 275.463 690.45  1094.78 1634.13
10/21/1951 1:00 1156.28 2088.35 780.482 265.571 664.076 1252.69 1980.99
10/22/1951 1:00 1181.52 2088.54 755.575 387.023 639.827 1303.77 2051.19
10/23/1951 1:00 1297.37 2194.13 1053.06 408.825 617.01  1496.38 2031
10/24/1951 1:00 1273.25 2254.23 1343.25 414.776 593.567 1565.93 1992.94
10/25/1951 1:00 1225.81 2303.93 1790.02 698.869 570.818 1514.79 1993.4
10/26/1951 1:00 1177.79 2314.86 1810.41 745.094 551.133 1466.51 1931.88
10/27/1951 1:00 1131.48 2305.49 1975.2  718.711 593.432 1417.75 1897.26
10/28/1951 1:00 1106.36 2266.15 1909.46 785.008 833.715 1370.91 1869.51
10/29/1951 1:00 1099.63 2192.32 1836.32 766.446 871.919 1326.11 1816.67
10/30/1951 1:00 1056.27 2122.89 1764.18 783.665 845.388 1281.74 1750.55
10/31/1951 1:00 1092.71 2049.84 1694.17 789.255 865.802 1239.33 1688.58
11/1/1951 1:00  1051.45 1976.98 1626.57 803.205 937.158 1198.95 1635.44
11/2/1951 1:00  1019.01 2536.04 1561.51 771.654 972.532 1162.09 1682.51
11/3/1951 1:00  992.959 3107.67 1503.1  740.178 1030.36 1122.17 1726.42
11/4/1951 1:00  957.823 3225.94 1446.05 773.057 1006.08 1079.55 1789.78
11/5/1951 1:00  923.327 3243.1  1388.93 932.497 974.112 1037.47 1724.05
11/6/1951 1:00  897.778 3194.96 1333.58 1241.24 937.399 1057.41 1675.15
11/7/1951 1:00  864.531 3095.29 1279.56 1647.36 902.049 1173.71 1615.02
11/8/1951 1:00  830.17  2992.27 1227.53 1896.88 872.061 1130.72 1645.28
11/9/1951 1:00  797.253 2905.56 1177.53 1877.63 886.442 1117.15 1811.13
11/10/1951 1:00 765.378 2812.67 1129.58 1901.74 892.396 1109.92 2016.75
11/11/1951 1:00 734.53  2765.89 1085.09 1919.89 859.156 1446.19 2098.54
11/12/1951 1:00 704.87  2825.4  1040.86 1900.5  825.958 1487.69 2145.75
11/13/1951 1:00 676.341 2870.66 998.998 2292.35 793.783 1531.13 2080.47
11/14/1951 1:00 648.983 2883.36 958.245 2366.7  762.704 1551.08 2025.29
11/15/1951 1:00 651.493 2786.74 961.035 2353.55 758.36  1512.65 1963.84
11/16/1951 1:00 669.712 2772.17 1069.32 2307.25 999.93  1508.32 1911.36
11/17/1951 1:00 642.692 2946.8  1093.54 2222.23 967.713 1664.88 1847.41
11/18/1951 1:00 643.678 3200.36 1316.71 2160.82 961.368 1614.95 1796.24
11/19/1951 1:00 854.424 3116.74 1320.69 2221.03 1012.97 1563.3  1832.8
11/20/1951 1:00 1563.03 3086.03 1292.69 2612.47 998.855 1525.98 2011.03
11/21/1951 1:00 1580.86 2992.23 1297.54 2621.91 1197.95 1568.79 2523.83
11/22/1951 1:00 1946.56 2898.49 1246.26 2519.94 1163.77 1727.64 2586.63
11/23/1951 1:00 2366.9  2955.77 1299.08 2424.59 1122.32 1900.13 2501.61
11/24/1951 1:00 2276.37 3049.61 1334.81 2330.12 1213.45 1873.76 2536.26
11/25/1951 1:00 3042.13 2996.7  1708.46 2238.45 1302.05 1817.76 2449.33
11/26/1951 1:00 3212.75 2902.17 1650.87 2155.63 1281.74 1756.32 2368.09
11/27/1951 1:00 3122.73 2835.81 1645.35 2108.78 1254.06 1697.16 2560.5
11/28/1951 1:00 3005.82 2961.7  1795.01 2110.4  1204.14 1637.38 2947.31
11/29/1951 1:00 2896.98 3338.51 1725.19 2159.07 1155.98 1578.4  3222.18
11/30/1951 1:00 2793.14 3585.05 1718.76 2072.74 1109.55 1520.36 3155.61
12/1/1951 1:00  2682.34 3605.96 1888.79 1991.87 1064.83 1466.63 3033.16
12/2/1951 1:00  2618.32 3579.53 2025.47 1912.11 1021.78 1505.62 3058.92
12/3/1951 1:00  2602.48 3645.49 2193.76 1951.67 980.367 1900.1  2941.42
12/4/1951 1:00  2663.44 3816.05 2232.83 2463.14 940.548 2062.67 2827.12
12/5/1951 1:00  2717.67 3823.21 2197.52 2533.36 925.483 2353.05 2753.95
12/6/1951 1:00  3022.4  4406.33 2133.36 2465.54 1144.38 2575.91 2840.68
12/7/1951 1:00  3179.75 4386.97 2055.55 2372.34 1125.92 2589.07 2929.75
12/8/1951 1:00  3100.24 4729.88 2055.87 3089.11 1109.17 2547.46 3161.26
12/9/1951 1:00  3231.01 5453.69 1973.78 3117.4  1222.15 2647.79 3443.13
12/10/1951 1:00 3256.51 6614.34 1907.34 3076.11 1503.71 2866.78 4016.1
12/11/1951 1:00 3138.92 6787.98 1856.45 3169.42 2656.42 3022.23 4447.15
12/12/1951 1:00 3117.41 6651.5  1800.68 3520.29 2550.13 2961.92 4500.56
12/13/1951 1:00 3027.87 6505.66 1728.61 3630.58 2446.94 2919.69 4406.75
12/14/1951 1:00 3039.63 6350.8  1660.3  3545.96 2358.74 2884.51 4256.61
12/15/1951 1:00 3054.06 6212.77 1603.51 3414.28 2263.33 2838.38 4112.3
12/16/1951 1:00 3163.15 6043.45 1539.93 3317.81 2171.81 2745.45 3969.58
12/17/1951 1:00 3085.46 5989.27 1477.64 3417.61 2248.6  2652.26 3825.81
12/18/1951 1:00 3075.28 5898.04 1417.82 4683.83 2316.71 2558.16 3684.78
12/19/1951 1:00 3001.68 6053.93 1361.19 4561.67 2675.05 2465.72 3696.66
12/20/1951 1:00 2897.28 6228.51 1308.71 4651.92 3015.03 2700.14 4045.15
12/21/1951 1:00 2792.85 6369.11 1273.93 4774.94 3716.48 3252.89 4617.42
12/22/1951 1:00 2692.7  6267.24 1291.26 4891.21 4441.43 3229.04 5033.28
12/23/1951 1:00 2627.38 6161.77 1252.94 4929.57 4742.74 3119.01 5110.36
12/24/1951 1:00 2529.66 6443.25 1436.21 5099.09 5476.79 3009.34 5307.5
12/25/1951 1:00 2438.99 6629.09 1392.34 4945.93 5313.57 2902.43 5134.8
12/26/1951 1:00 2396.05 6525.34 1407.56 4776.2  5106.1  2798.43 5000.11
12/27/1951 1:00 2305.59 6375.94 1550.93 4607.3  5178.79 2698.32 4825.11
12/28/1951 1:00 2221.16 6234.93 1902.01 4436.96 5160.45 2597.66 4891.27
12/29/1951 1:00 2138.89 6260.16 1871.37 4276.9  5020.48 2504.8  5638.67

so far I have plotted the density with ggplot using the code below
library(reshape)
newaa <- melt(aa)
ggplot(data = newaa) + geom_density(aes(x = value, color = variable), alpha = 0.2)

This results in

However, I don't want to show all of them as it makes my plot crowded so I want only the minimum and maximum densities and show only them on my plot. I found that geom_ribbon with in ggplot2 does it so I tried to check with this code. geom_ribbon requires the min and max arguments. For this first I have to calculated the maximum and minimum densities values from each variable
for(i in 1:7){
    d <- density(aa[ , i + 1])
    xx[[i]] <- d$x
    yy[[i]] <- d$y}
k <- c()
g <- c()
l <- c()
for (j in 1: length(yy[[1]])){
    kk <- max(sapply(yy, "[", j)) ## maxm density
    gg <- min(sapply(yy, "[", j)) ## minm density
    ll <- max(sapply(xx,"[",j))   ## xaxis value of the density
    k <- rbind(k, as.numeric(kk))
    g <- rbind(g, as.numeric(gg))
    l <- rbind(l, as.numeric(ll))
}

minmax <- data.frame(cbind(g, k, l))
names(minmax) <- c("min", "max", "x")
ggplot(data=newaa) +
    geom_density(aes(x = value, color = variable), alpha = 0.2) +
    xlab(expression("flow  " ~~ (m^{3}~s^{-1}))) +
    ylab("Density") +
    ggtitle("PDF") +
    theme(plot.title = element_text(hjust =
0.5)) +
    geom_ribbon(data = minmax, aes(ymin = min, ymax = max, fill =
"violetred4",x = x), alpha = 0.3)

This results in

However the figure shifts and its not overlapping with the original density graphs. I think that this happens due to the scaling effect in the x axis(I am here plotting the max and min densities with max value of the variable(l) , which is why the graphs are shifted and elongated). There are other easier options like scaling, I don't want every thing to scale between 0-1, as it will loose the spread of the distribution (since some of the variable has small higher tail and others have high tails). I just want the polygon/Area with min and maxm density. Could any one of you take a look and help me with this. The code I wrote is very inefficient. could you please help me optimize the code in terms of computing time and memory?

A: You can use density to calculate y-values over a predefined domain for each vector. Using purrr::map_df to assemble the results into a data.frame, you can then extract the highest and lowest row easily with apply or pmax/pmin:
library(tidyverse)

df[-1] %>%    # exclude `date` column
    map_df(~density(.x, from = 0, to = 7000)$y) %>%    # extract y values of densities over defined domain
    transmute(ymax = apply(., 1, max),    # or do.call(pmax, .)
              ymin = apply(., 1, min),    # or do.call(pmin, .)
              x = seq(0, 7000, length = 512)) %>%    # re-add domain
    ggplot() +
    geom_ribbon(aes(x, ymin = ymin, ymax = ymax), alpha = 0.3) +
    geom_density(data = gather(df, var, val, -date), aes(val, color = var))

If you don't want to hard-code the domain, you could replace 7000 with max(df[-1]) if you like.

redpajama_set_name: RedPajamaStackExchange


text:
Q: How can I checkout a file from a changelist on perforce server using Perforce Python API's (p4python) Originally I am trying to implement a customized python based linter to help me out with the lexical code analysis. This linter requires me to point to the directory where the scripts or code files (which needed to be analyzed) resides. The original code (which needed to be analyzed) is present on a perforce server.
What I want to do is to be able to get all the files shelved by a user on perforce. How can i use the change-list number to get these shelved files from perforce server to my local machine and i want to do that in my python based application preferably using p4python api's.
All help is appreciated. Thanks

A: There are two options for getting files from a shelved changelist; one is easy but requires managing more persistent state on the server, and the other is more stateless but requires more logic on the client side.

The standard workflow (i.e. what most human Perforce users would do) is to unshelve the files into your client workspace:
p4 unshelve -s CHANGE

The files in the shelved changelist will be automatically synced to your workspace (according to your client view) and opened in your default changelist.  This is the easy option because you just have to run that one command to have all the files in a predefined local location.  From there you can modify them freely, and either submit them or reshelve them to a different changelist (or the same changelist if you modify it to make yourself the owner).
This requires that you have a workspace already set up, and that the files are not already open there, so if you're doing this in a script, the script will need to be configured ahead of time with a suitable workspace and it will need to make sure that at some point it either submits or reverts the changes, or it will need to know how to create its own workspace by running p4 client, picking a unique client root, etc.

The stateless option is to use p4 print to get the contents of the shelved changelist:
p4 print @=CHANGE

This will stream the files to stdout, with headers in between giving the depot path.  If your linter can handle streaming data, this may be the easy option; if it needs to read files from disk, you'll have to implement the logic required to put the files in a suitable location, and clean them up when you're done.

Translating either of the above to p4python is pretty straightforward (I'd try to whip up a code sample but the p4python installer is currently broken on Windows so I haven't been able to use p4python in a while), but my recommendation is to familiarize yourself with the above commands at the terminal in a test environment first so you can better understand the interface and the requirements around workspace setup, authentication, etc. before you implement that logic in a script.


text:
Q: Segmentation fault during pthread_create() Okay so I'm trying to bubble sort two files in a separate threads(main thread and the secondary thread in which I created using pthread_create). My bubble sort works perfectly, I tested it several times so I didn't included here, my problem it is giving me segmentation fault during the line pthread_create.
I have a bubble sort functions which reads the file and sorts it. Works perfect.
void *bubblesortCars(char *filename)
THE PROBLEM THIS IS GIVING ME SEGMENTATION FAULT
pthread_create(&one, NULL, (void*)&bubblesortCars, (char *)&("FirstHalf.txt"));
bubblesortCars("SecondHalf.txt");
pthread_join(one, NULL);

HOWEVER, if I put it this way it will work perfectly, but I do not want to do it this way, because I want both threads to bubble sort simultaneously:
bubblesortCars("SecondHalf.txt");
pthread_create(&one, NULL, (void*)&bubblesortCars, (char *)&("FirstHalf.txt"));
pthread_join(one, NULL);


text:
Q: How to send an email to user with the attached secure CSV file and email should be non-reply I am working in spring batch where I have the requirement to create CSV file with some business logic and it should be noneditable. I want to send the file with the domain name where the user can not reply(no-reply@domain.com).
I implemented Java mail service by using Spring-Boot starter mail. In application properties, I have set the authentication and server port. After that, I have implemented Email service and send the used JavaMailSender.
Now I want to send an email with a secure CSV file. But right now email received into the Junk box.
Application.yml

 mail:
    host: smtp.gmail.com
    port: 587
    username:
    password:
    properties:
      mail:
        smtp:
          auth: true
          starttls:
            enable: true

MailService:

public class EmailServiceImpl implements EmailService {

    @Autowired
    private JavaMailSender mailSender;

    /**
     * Send email.
     *
     * @param to the to
     * @param subject the subject
     * @param text the text
     */
    @Override
    public void sendEmail(String to, String subject, String text) {

        try {
            SimpleMailMessage message = new SimpleMailMessage();
            message.setTo(to);
            message.setSubject(subject);
            message.setText(text);

            mailSender.send(message);
        } catch (MailException e) {
            log.info("Mail Exception {}", e);
        }

    }

so I have only two questions:
Q1: how can I make secure CSV file?
Q2: is it possible to send an email from a domain like(no-reply@domain.com)
Q3: how to send the email into the inbox instead of junk folder

A: Answering your queries:
Q1: how can I make secure CSV file?
CSV files are generally text files. If by secure, you mean readonly, then thats simple. All you need to do is to mark that file a readonly. But remember that, this is not full proof. The user/application receiving this file can make that file writable. If you are working about accidental modification, then making readonly should be ok.
Q2: is it possible to send an email from a domain like(no-reply@domain.com)
All you need to set the desired email in SimpleMailMessage (Check here)
Q3: how to send the email into the inbox instead of junk folder
This is a little difficult to control from the Sender Side. The email server at the receiver side decides which email domains are whitelisted (non-junk). Best you can do is to request the email receiver to whitelist your domain so that your email does not go in junk folder.

A: A1) You can't make an CSV file "secure" in general
A2) message.setReplyTo("no-reply@domain.com");
A3) This is not in your hand. This is the responsibility of the receivers email provider and their spam rules. You can't influence this.


text:
Q: FullCalendar display events on dayClick The dayClick in fullCalendar is defined as:
dayClick: function (start, allDay, jsEvent, view) {
    alert('You clicked me!');
}

This is triggered when the user clicks on a day.
I wanted to access data of events when a user clicks on a particular day. Sort of merging the eventClick function in dayClick so that when I click on a particular day, I get the event title, starttime, endtime of all events occurring that particular day.

A: I hope this help  you
$('#calendar').fullCalendar({
        dayClick: function(date, allDay, jsEvent, view) {
                var startDate = new Date(date.getFullYear(), date.getMonth(), date.getDay(), 0, 0, 0).getTime();
                var endDate = new Date(date.getFullYear(), date.getMonth(), date.getDay(), 23, 59, 59).getTime();
                var cache = new Date().getTime();
                $.getJSON("/json-events.php?start="+startDate+"&end="+endDate+"&_="+cache,
                    function(data) {
                        // do stuff with the JSOn data
                    }
        }
    });

A: You can try this:
eventClick: function(xEvent, jsEvent, view) {
    alert("Title: " + xEvent.title             //Get the event title
          + "\n StartTime: " + xEvent.start    //Get the event start date
          + "\n EndTime: " + xEvent.end        //Get the event end date
    );

    console.log(xEvent); //See your console for all event properties/objects
}

xEvent properties/object lists.

A: dayClick: function(date, allDay, jsEvent, view) {
    var startDate = new Date(date.getFullYear(), date.getMonth(), date.getDay(), 0, 0, 0).getTime();
    var endDate = new Date(date.getFullYear(), date.getMonth(), date.getDay(), 23, 59, 59).getTime();
    var cache = new Date().getTime();
    $.getJSON("/json-events.php?start="+startDate+"&end="+endDate+"&_="+cache,
        function(data) {
            // do stuff with the JSOn data
    });
    alert('ENTROU!');
},

now it works
it opens a alert, you just have to put the information wanted.

A: I think this is what you are looking for.
dayClick: function(date, allDay, jsEvent, view) {
  var date2 = new Date(date.getFullYear(), date.getMonth(), date.getDate()+1);
  //This gives the next day of the clicked day('date' contains the clicked day)

  var todaysEvents = $('#calendar').fullCalendar('clientEvents', function(event) {
    // Below statement returns the EVENT OBJECT of the clicked day after comparing the two dates
    return event.start >= date && event.start < date2;
  });
  // You can now access the returned object & extract what you want
  // console.log(todaysEvents); --> returns the complete object
  // console.log(todaysEvents[0].title); --> returns that day's event title
},

I Hope this helped.


text:
Q: How to swipe ListView nested in SwipeRefreshLayout I have a ListView nested inside a SwipeRefreshLayout.
I want to swipe from anywhere in the ListView, down to an element at the bottom of the layout, such that a swipe event occurs, and the little refresh icon is observed.

I have tried this
new TouchAction(mUser.mDriver)
    .longPress(listView)
    .moveTo(bottomElement)
    .release()
    .perform();

and this
new TouchAction(mUser.mDriver)
    .longPress(swipeView)
    .moveTo(bottomElement)
    .release()
    .perform();

And neither appear to work.
How do I swipe a list view with appium using Java Client?

A: This seems to work
WebElement swipeView = myDriver.findElementById(myId);

new TouchAction(mUser.mDriver)
       .press(getXMiddle(swipeView), getYUp(swipeView))
       .moveTo(getXMiddle(swipeView), getYDown(swipeView))
       .release()
       .perform();

and the helper methods
// x locations

public int getXLeft(WebElement el)
{
  return el.getLocation().getX();
}

public int getXRight(WebElement el)
{
  return getXLeft(el) + el.getSize().getWidth();
}

public int getXMiddle(WebElement el)
{
  return (getXRight(el) + getXLeft(el)) / 2;
}

// y locations

public int getYUp(WebElement el)
{
  return el.getLocation().getY();
}

public int getYDown(WebElement el)
{
  return getYUp(el) + el.getSize().getHeight();
}

public int getYMiddle(WebElement el)
{
  return (getYUp(el) + getYDown(el)) / 2;
}


text:
Q: mod_auth_kerberos "Unspecified GSS failure" I did an apache 2.4 fresh install. I'd like to use kerberos authentication. I compiled and install mod_auth_kerb modules. here is my config
<location "/restriced/">
SSLRequireSSL
AuthName "Kerberos login"
AuthType Kerberos
KrbMethodNegotiate On
KrbMethodK5Passwd Off
KrbVerifyKDC Off
KrbServiceName HTTPS
KrbAuthRealms ******.***
Krb5KeyTab /etc/krb5.keytab
KrbLocalUserMapping On
require valid-user
</location>

When I try to access "restricted" location I got this error :
[Mon Sep 30 10:21:18.782978 2013] [authz_core:debug] [pid 2219:tid 140278178531072] mod_authz_core.c(802): [client xx.xx.xx.xx:61773] **AH01626: authorization result of Require valid-user : denied (no authenticated user yet)**
[Mon Sep 30 10:21:18.783004 2013] [authz_core:debug] [pid 2219:tid 140278178531072] mod_authz_core.c(802): [client xx.xx.xx.xx:61773] **AH01626: authorization result of <RequireAny>: denied (no authenticated user yet)**
[Mon Sep 30 10:21:18.783042 2013] [auth_kerb:debug] [pid 2219:tid 140278178531072] src/mod_auth_kerb.c(1643): [client xx.xx.xx.xx:61773] kerb_authenticate_user entered with user (NULL) and auth_type Kerberos
[Mon Sep 30 10:21:18.783099 2013] [auth_kerb:debug] [pid 2219:tid 140278178531072] src/mod_auth_kerb.c(1255): [client xx.xx.xx.xx:61773] Acquiring creds for HTTPS@**********.***
[Mon Sep 30 10:21:18.786080 2013] [auth_kerb:debug] [pid 2219:tid 140278178531072] src/mod_auth_kerb.c(1116): [client xx.xx.xx.xx:61773] GSS-API major_status:000d0000, minor_status:000186a4
[Mon Sep 30 10:21:18.786127 2013] [auth_kerb:error] [pid 2219:tid 140278178531072] [client xx.xx.xx.xx:61773] gss_acquire_cred() failed: Unspecified GSS failure. Minor code may provide more information (, )

Thanks for any help.

A: The message "minor_status:000186a4" means that apache can't read the keyfile.
The most likely reasons are that the file has got the wrong permissions, or it's not in the proper format.


text:
Q: string format notation For the code below:
double j1;

j1=7000000    //example
ItemE[5]=[NSString stringWithFormat:@"@1. total inc = %g", j1];

ItemE[5] is returned as "1.total inc = 7e +06"
How do I prevent the scientific notation and have "1.total inc = 7000000" instead?

A: Use %f:
ItemE[5]=[NSString stringWithFormat:@"@1. total inc = %f", j1];

Edit:
If you don't want decimal places you should use:
ItemE[5]=[NSString stringWithFormat:@"@1. total inc = %.f", j1];

To elaborate, you were using wrong specifier in format string.%g instructs to create string representation of floating-point variable in scientific notation. Normally you should use %f to represent double and float variable. By default, this specifier will result in number with 6 decimal places. In order to change that you can modify that specifier, for example:
%5.3f means that string should have 3 decimal places and should be 5 characters long. That means that if representation would be shorter than 5 chars, string will have additional spaces in front of number to give 5 chars total. Note that if you will have large number, it'll not be truncated. Consider code:
double pi = 3.14159265358979323846264338327950288;
NSLog(@"%f", pi);
NSLog(@"%.3f", pi);
NSLog(@"%8.3f", pi);
NSLog(@"%8f", pi);
NSLog(@"%.f", pi);

will give result:
3.141593
3.142
   3.142
3.141593
3

A: please, try to use this one:
double j1 = 7000000.f;
NSLog(@"1. total inc = %.f", j1);

the result will be:
1. total inc = 7000000

I hope it helps.


text:
Q: How to update all Youtube videos description in a playlist? I have created a client_secrets.json file and written all the required fields that I got from Google API's console. Now I have a test playlist which have same description on all the videos in that playlist and I want to update that playlist with changing the description of it using Python code.
I have copied the code from this link https://developers.google.com/youtube/v3/docs/playlists/update#usage provided by developers google and now I don't know what are the next steps to continue as I am new to Python programming. Can anyone guide me to run this program and update the playlists description.
Thanks in Advance
Here is the code that I have copied
import os

import google.oauth2.credentials

import google_auth_oauthlib.flow
from googleapiclient.discovery import build
from googleapiclient.errors import HttpError
from google_auth_oauthlib.flow import InstalledAppFlow

CLIENT_SECRETS_FILE = "client_secrets.json"

SCOPES = ['https://www.googleapis.com/auth/youtube.force-ssl']
API_SERVICE_NAME = 'youtube'
API_VERSION = 'v3'

def get_authenticated_service():
  flow = InstalledAppFlow.from_client_secrets_file(CLIENT_SECRETS_FILE, SCOPES)
  credentials = flow.run_console()
  return build(API_SERVICE_NAME, API_VERSION, credentials = credentials)

def print_response(response):
  print(response)

def build_resource(properties):
  resource = {}
  for p in properties:
    prop_array = p.split('.')
    ref = resource
    for pa in range(0, len(prop_array)):
      is_array = False
      key = prop_array[pa]

      if key[-2:] == '[]':
        key = key[0:len(key)-2:]
        is_array = True

      if pa == (len(prop_array) - 1):
        if properties[p]:
          if is_array:
            ref[key] = properties[p].split(',')
          else:
            ref[key] = properties[p]
      elif key not in ref:
        ref[key] = {}
        ref = ref[key]
      else:
        ref = ref[key]
  return resource

def remove_empty_kwargs(**kwargs):
  good_kwargs = {}
  if kwargs is not None:
    for key, value in kwargs.iteritems():
      if value:
        good_kwargs[key] = value
  return good_kwargs

def playlists_update(client, properties, **kwargs):
  resource = build_resource(properties)

  kwargs = remove_empty_kwargs(**kwargs)

  response = client.playlists().update(
    body=resource,
    **kwargs
  ).execute()

  return print_response(response)

if __name__ == '__main__':
  os.environ['OAUTHLIB_INSECURE_TRANSPORT'] = '1'
  client = get_authenticated_service()

  playlists_update(client,
    {'id': '',
     'snippet.title': '',
     'snippet.description': '',
     'snippet.tags[]': '',
     'status.privacyStatus': ''},
    part='snippet,status',
    onBehalfOfContentOwner='')

A: I was unable to find a direct solution.
But after some research i can give you following pointers.

*

*The snippet mentioned above is used to manage only the playlist data and not the videos within the playlist. You can change the data of the playlist only as mentioned in the docs.

*Here are few things that you can try to get the result.

*

*Try using these methods instead PlaylistItems to get the Items in the playlist i.e. the videos.

*Then you can use Videos to change the property of a given video like in your case description.

According to me the map looks like this

*

*Get the list of items from the required playlist

*Iterate over the list

*Select each video and update its data

It seems like there is no direct way as far as my knowledge.


text:
Q: get key value pairs out from the string javascript If my string looks like this
"<First key="ab" value="qwerty"/>
<First key="cd" value="asdfg"/>
<First key="ef" value="zxcvb"/>"

and I want to get data out in the format
ab:"qwerty"
cd:"asdfg"
ef:"zxcvb"
How should I write the JS ?

A: It would be useful to see the code you've attempted, but here's a way you could achieve it:
Use a regex to pick out the relevant parts of the string.
var regex = /key="([a-zA-Z]+)" value="([0-9a-zA-Z\-\.]+)"/;

Function to remove empty elements.
var notEmpty = function (el) { return el !== ''; };

split the string into an array on the carriage return and use reduce to build the new object by applying the regex to each array element.
var out = str.split('\n').filter(notEmpty).reduce(function(p, c) {
  var match = c.match(regex);
  p[match[1]] = match[2];
  return p;
}, {});

OUTPUT
{
  "ab": "qwerty",
  "cd": "asdfg",
  "ef": "zxcvb"
}

DEMO

A: Please, make your question more clear(What result data type would you like to get?), or try these functions:
var string = '<First key="ab" value="qwerty"/><First key="cd" value="asdfg"/><First key="ef" value="zxcvb"/>'

var ParseMyString1 = function(str){
var arr = str.split(/[</>]+/); //"
//console.log(arr);
var result = [];

for (var i =0; i<arr.length; i++) {
    var subStr=arr[i];
    if (subStr.length!==0) {
        var subArr = subStr.split(/[\s"=]+/);    //"
        //console.log(subArr);
        var currObj = {};
        var currKey = "";
        var currVal = "";
        for (var j =0; j<arr.length; j++) {
            if (subArr[j]=="key"){
                currKey = subArr[++j];
            }else if (subArr[j]=="value"){
                currVal = subArr[++j];
            }
        };
        currObj[currKey] = currVal;
        result.push(currObj);
    };
};
console.log("ParseMyString1:");
console.log(result);
};

var ParseMyString2 = function(str){
var arr = str.split(/[</>]+/); //"
//console.log(arr);
var resultObj = {};
for (var i =0; i<arr.length; i++) {
    var subStr=arr[i];
    if (subStr.length!==0) {
        var subArr = subStr.split(/[\s"=]+/);    //"
        //console.log(subArr);

        var currKey = "";
        var currVal = "";
        for (var j =0; j<arr.length; j++) {
            if (subArr[j]=="key"){
                currKey = subArr[++j];
            }else if (subArr[j]=="value"){
                currVal = subArr[++j];
            }
        };
        resultObj[currKey] = currVal;

    };
};
console.log("ParseMyString2:");
console.log(resultObj);
};

$(document).ready(function(){
  ParseMyString1(string);
  ParseMyString2(string);
});

These functions return results as below (array of objects):
ParseMyString1:
[{ab:"qwerty"},{cd:"asdfg"},{ef:"zxcvb"}]
ParseMyString2:
{ab:"qwerty",cd:"asdfg",ef:"zxcvb"}

A: First, your string is not valid (double quotes within double quotes). You'd either need to escape the inner quotes with \" or just replace the inner quotes with single quotes.
But, assuming that your data was always going to be in the format you show, this simple code will extract the data the way you want:

var data = "<First key='ab' value='qwerty'/><First key='cd' value='asdfg'/><First key='ef' value='zxcvb'/>";
data = data.replace(/<First /g, " ").replace(/\/>/g, "").replace(/key=/g, "").replace(/value=/g, "").trim();

var ary = data.split(" ");

var iteration = "";
var result = "";
for(var i = 0; i < ary.length; i+=2){

  iteration = ary[i].replace(/'/g, "") + ":" + ary[i+1].replace(/'/g, "\"");
  alert(iteration);
  result += " " + iteration;
}

alert("Final result: " + result);

A: Your input is a kind of XML. The best way is to treat it as such. We will parse it as XML, but to do so, we need to first wrap it in a root element:
var str = "<Root>" + input + "</Root>"

We parse it with
var parser = new DOMParser();
var dom = parser.parseFromString(str, "text/xml");

Get the document element (Root):
var docelt = dom.documentElement;

Now we can loop over its children and build our result, using standard DOM access interfaces like getAttribute:
var result = {};
var children = docelt.children;
for (var i = 0; i < children.length; i++) {
  var child = children[i];
  result[child.getAttribute('key')] = child.getAttribute('value');
}

> result
< Object {ab: "qwerty", cd: "asdfg", ef: "zxcvb"}

You can replace the above looping logic with reduce or something else as you prefer.
This approach has the advantage that it takes advantage of the built-in parser, so we don't end up making assumptions about the syntax of XML. For instance, the regexp suggested in another answer would fail if the attributes had spaces before or after the equal sign. It would fail if the values contained Unicode characters. It would fail in odd ways if the XML was malformed. And so on.


text:
Q: JQuery Ajax - Order works on 1 field lesser I am new beginer in jquery/ajax, working on a simple Ajax / Jquery html table - MySql. Everything works except 'Click to order' a field. Upon clicking a column heading (expecting to get ordered on this field), it gets ordered on the previous column/field. I made some adjustments, but still the same. The original codes were received from phpzag.com.
<?php
include('inc/header.php');
?>

<title>phpzag.com : Demo Live Add Edit Delete datatables Records with Ajax, PHP and MySQL</title>

<?php //include('inc/container.php');
    $Col0 = "id";
    $Col1 = "Topic";
    $Col2 = "FileName";
    $Col3 = "Size";
    $Col4 = "Created";
    $Col5 = "Modified";
    $Col6 = "Folder";
?>

Example: Live Add Edit Delete datatables Records with Ajax, PHP and MySQL

                    <button type="button" name="add" id="addRtf" class="btn btn-success">Add New WordPad</button>

                        <?php echo $Col1; ?>
                        <?php echo $Col2; ?>
                        <?php echo $Col3; ?>
                        <?php echo $Col4; ?>
                        <?php echo $Col5; ?>
                        <?php echo $Col6; ?>
                        #

            <form method="post" id="recordForm">

                        <button type="button" class="close" data-dismiss="modal">×</button>

 Edit Record

                            <label for="<?php echo $Col0; ?>" class="control-label"><?php echo $Col0; ?>
                            <input type="text" class="form-control" id="<?php echo $Col0; ?>" name="<?php echo $Col0; ?>" placeholder="<?php echo $Col0; ?>" required>

                            <label for="<?php echo $Col1; ?>" class="control-label"><?php echo $Col1; ?>
                            <input type="text" class="form-control" id="<?php echo $Col1; ?>" name="<?php echo $Col1; ?>" placeholder="<?php echo $Col1; ?>" required>

                            <label for="<?php echo $Col2; ?>" class="control-label"><?php echo $Col2; ?>
                            <input type="number" class="form-control" id="<?php echo $Col2; ?>" name="<?php echo $Col2; ?>" placeholder="<?php echo $Col2; ?>">

                            <label for="<?php echo $Col3; ?>" class="control-label"><?php echo $Col3; ?>
                            <input type="text" class="form-control"  id="<?php echo $Col3; ?>" name="<?php echo $Col3; ?>" placeholder="<?php echo $Col3; ?>" required>

                            <label for="<?php echo $Col4; ?>" class="control-label"><?php echo $Col4; ?>
                            <textarea class="form-control" rows="5" id="<?php echo $Col4; ?>" name="<?php echo $Col4; ?>"></textarea>

                            <label for="<?php echo $Col5; ?>" class="control-label"><?php echo $Col5; ?>
                            <input type="text" class="form-control" id="<?php echo $Col5; ?>" name="<?php echo $Col5; ?>" placeholder="<?php echo $Col5; ?>">

                            <label for="<?php echo $Col6; ?>" class="control-label"><?php echo $Col6; ?>
                            <input type="text" class="form-control" id="<?php echo $Col6; ?>" name="<?php echo $Col6; ?>" placeholder="<?php echo $Col6; ?>">

                        <input type="hidden" name="id" id="id" />
                        <input type="hidden" name="action" id="action" value="" />
                        <input type="submit" name="save" id="save" class="btn btn-info" value="Save" />
                        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>

            </form>

<?php include('inc/footer.php');?>

Ajax_action.php
<?php
include_once 'config/Database.php';
include_once 'class/Records.php';

$database = new Database();
$db = $database->getConnection();

$record = new Records($db);

if(!empty($_POST['action']) && $_POST['action'] == 'listRecords') {
    $record->listRecords();
}?>

Database.php
<?php
class Database{

    private $host  = 'localhost';
    private $user  = 'root';
    private $password   = "dd";
    private $database  = "dd";

    public function getConnection(){
        $conn = new mysqli($this->host, $this->user, $this->password, $this->database);
        if($conn->connect_error){
            die("Error failed to connect to MySQL: " . $conn->connect_error);
        } else {
            return $conn;
        }
    }
}

Ajax.js
$(document).ready(function(){

    var dataRecords = $('#recordListing').DataTable({
        "lengthChange": false,
        "processing":true,
        "serverSide":true,
        'processing': true,
        'serverSide': true,
        'serverMethod': 'post',
        "order":[],
        "ajax":{
            url:"ajax_action.php",
            type:"POST",
            data:{action:'listRecords'},
            dataType:"json"
        },
        /*"columnDefs":[
            {
                "targets":[0, 6, 7],
                "orderable":false,
            },
        ],*/
        "pageLength": 100
    });

Records.php
class Records {

    private $recordsTable = 'files';
    public $id;
    public $Topic;
    public $FileName;
    public $Size;
    public $Created;
    public $Modified;
    public $Folder;
    private $conn;

    public function __construct($db){
        $this->conn = $db;
    }

    public function listRecords(){
        $Col0 = "id";
        $Col1 = "Topic";
        $Col2 = "FileName";
        $Col3 = "Size";
        $Col4 = "Created";
        $Col5 = "Modified";
        $Col6 = "Folder";

        $sqlQuery = "SELECT * FROM ".$this->recordsTable." ";
        if(!empty($_POST["search"]["value"])){
            $sqlQuery .= 'where('.$Col0.' LIKE "%'.$_POST["search"]["value"].'%" ';
            $sqlQuery .= ' OR '.$Col1 .' LIKE "%'.$_POST["search"]["value"].'%" ';
            $sqlQuery .= ' OR '.$Col2 .' LIKE "%'.$_POST["search"]["value"].'%" ';
            $sqlQuery .= ' OR '.$Col3 .' LIKE "%'.$_POST["search"]["value"].'%" ';
            $sqlQuery .= ' OR '.$Col4 .' LIKE "%'.$_POST["search"]["value"].'%" ';
            $sqlQuery .= ' OR '.$Col5 .' LIKE "%'.$_POST["search"]["value"].'%" ';
            $sqlQuery .= ' OR '.$Col6 .' LIKE "%'.$_POST["search"]["value"].'%") ';
        }

        if(!empty($_POST["order"])){
            $sqlQuery .= 'ORDER BY '.$_POST['order']['0']['column'].' '.$_POST['order']['0']['dir'].' ';
        } else {
            $sqlQuery .= 'ORDER BY id DESC ';
        }

        if($_POST["length"] != -1){
            $sqlQuery .= 'LIMIT ' . $_POST['start'] . ', ' . $_POST['length'];
        }

        $stmt = $this->conn->prepare($sqlQuery);
        $stmt->execute();
        $result = $stmt->get_result();

        $stmtTotal = $this->conn->prepare("SELECT * FROM ".$this->recordsTable);
        $stmtTotal->execute();
        $allResult = $stmtTotal->get_result();
        $allRecords = $allResult->num_rows;

        $displayRecords = $result->num_rows;
        $records = array();
        while ($record = $result->fetch_assoc()) {
            $rows = array();

            //$rows[] = ucfirst($record[$Col1]);//original
            $rows[] = $record[$Col1];//manoj as order not working properly, test
            $rows[] = $record[$Col2];
            $rows[] = $record[$Col3];
            $rows[] = $record[$Col4];
            $rows[] = $record[$Col5];
            $rows[] = $record[$Col6];
            $rows[] = $record[$Col0];
            //$rows[] = '<button type="button" name="update" id="'.$record["id"].'" class="btn btn-warning btn-xs update">Update</button>'; //original
            //$rows[] = '<button type="button" name="delete" id="'.$record["id"].'" class="btn btn-danger btn-xs delete" >Delete</button>'; //Original
            $rows[] = '<button type="button" name="open" id="'.$record["id"].'" class="btn btn-warning btn-xs open" >Open</button>';
            $records[] = $rows;
        }

        $output = array(
            "draw"  =>  intval($_POST["draw"]),
            "iTotalRecords" =>  $displayRecords,
            "iTotalDisplayRecords"  =>  $allRecords,
            "data"  =>  $records
        );

        echo json_encode($output);
    }


text:
Q: C/C++: How to create matlab like structure array I am wondering if it's possible to write a code for creating structure array in C/C++ just like Matlab.
For instance, in Matlab, I can di:
patient.name = 'John Doe';
patient.billing = 127.00;
patient.test = [79, 75, 73; 180, 178, 177.5; 220, 210, 205];

without defining struct as a separate piece of code. What I like is that I can add any field later on.
I have no idea how to write a piece of code in C/C++ which can do the same thing. Some guidance would be appreciated.

A: I don't know Matlab, by considering your piece of code as requirement we can do as follows in C++.
struct patient{
 std::string name;
 double billing;
 std::vector<float> test;
}

std::vector<patient> patients;


text:
Q: what is the different between scalar difference equations and difference equations? What is the different between scalar difference equations and difference equations? What the scalar here means?

A: In general, if we talk about a scalar difference equation/scalar differential equation, it implies that we only have one function that we are trying to find.
Example $a(n+2)=a(n+1)+a(n)$ or $y'(t)=y(t)$.
A (system) of difference equations or differential equations consists of at least two equations (which should not be linearly independent) and in most cases the number of equations is equal to the number of unknown functions.
Example $a_1(n+2)=a_1(n+1)+a_2(n+1)+a_1(n)$ and $a_2(n+2)=2a_2(n+2)$ or $y_1'(t)=y_1(t)+2y_2(t)$
$y_2'(t)=y_1(t)y_2(t)$.


text:
Q: Is there a way to validate related documents in mongoose that is more efficient than .populate() and aggregate it together Given these models:
Products:
const productSchema = new Schema({
    name: String,
    description: String,
    price: Number,
    steps: [{
        type: Schema.Types.ObjectId,
        ref: 'steps'
    }]
});

Steps:
const stepSchema = new Schema({
    name: String,
    minimum: Number,
    maximum: Number,
    items: [
        {
            name: String,
            price: Number
        }
    ]
});

Is there a better way to query an object that has N number of Products and not all products.steps selected without using .populate() (because it will make a request for each value inside the products.steps array) and a for loop to sum all prices included in productSchema and stepSchema?
Exemple of use:
On my documents I've got product collection like this:
[{
    id: 1
    name: Pizza,
    description: "Medium (3 flavors)",
    price: 10,
    steps: [{
        "1",
        "2"

    }]
},
{
    id: 2
    name: Pizza,
    description: "small (1 flavors)",
    price: 10,
    steps: [{
        "1",

    }]
}]

And steps like:
[{
    id: 1
    name: "Flavor",
    minimum: 0,
    maximum: 1,
    items: [
        {
            id: 1
            name: "mozzarella",
            price: 4
        },
        {
            id: 2
            name: "pepperoni",
            price: 5
        }
    ]
},
{
    id: 2
    name: "Border",
    minimum: 0,
    maximum: 0,
    items: [
        {
            id: 3
            name: "With normal cheese",
            price: 0
        },
        {
            id: 4
            name: "With special cheese",
            price: 3
        }
    ]
}]

So is there a better way to validade an object like this in my BD with less query and without a for loop?
products: [
    {
        productId: 1,
        price: 30,
        quantity: 3,
        steps: [{
            stepId: 1
            items: [
                {
                    itemId: 1,
                    price: 4
                },
                {
                    itemId: 2,
                    price: 5
                }
            ]
        }]

    }
]

A: I think below steps should be followed:

*

*$lookup(aggregation) or populate

*$project(aggregation)


text:
Q: Extract Host name, timestamp, HTTP request method, URI and protocol I want to extract Host name, timestamp, HTTP request method, URI and protocol from below responses
unicomp6.unicomp.net - - [01/Jul/1995:00:00:06 -0400] "GET /shuttle/countdown/ HTTP/1.0" 200 3985
199.120.110.21 - - [01/Jul/1995:00:00:09 -0400] "GET /shuttle/missions/sts-73/mission-sts-73.html HTTP/1.0" 200 4085

using regular expressions. Please let me know how can I do this

A: I tried the below code
timestamp - r"\[\d+/\D+/.*\]
host name - (\d+\.\d+\.\d+\.\d+)\s* |(.+)\.(com|info|biz|tv|net)
status code - "\s\d{3}

but not getting the desired result. It says expecting string or byte size
regex = r'\b(\d+\.\d+\.\d+\.\d+)\s* |(.+)\.(com|info|biz|tv|net)'

sample_text = ("[unicomp6.unicomp.net - - [01/Jul/1995:00:00:06 -0400] "GET /shuttle/countdown/ HTTP/1.0" 200 3985, 199.120.110.21 - - [01/Jul/1995:00:00:09 -0400] "GET /shuttle/missions/sts-73/mission-sts-73.html HTTP/1.0" 200 4085]")

matches = re.findall(regex, sample_text)
hosts = []
for matchNum, match in enumerate(matches, start=1):
    hosts.append(match.group()[1:27])
print(hosts)


text:
Q: populate blank columns using update statment I need some help writing update statement. My objective is to populate any blank EQ_ID and ORDERID  by copying the EQ_ID and ORDERID from a row that has the same A_NUMBER, C_CD, and PERSONID
I require the update statement to scan the EST (name of the table) table:

*

*For a certain period of time eg.  1st May 2015 to 10th May 2015

*Look for a row with blank EQ_ID and ORDER_ID

*populate any blank EQ_ID and ORDERID  by copying the EQ_ID and ORDERID of a row that has the same A_NUMBER, C_CD, and PERSONID

Can you please let me know how to do this the best way?
Attached is a screenshot of data from EST table

A: You can do this using update and a correlated subquery.  Oracle allows you to set multiple columns from the same subquery:
update est
    set (eq_id, order_id) = (select est2.eq_id, est2.order_id
                             from est est2
                             where est2.a_number = est.a_number and
                                   est2.c_cd = est.c_cd and
                                   est2.personid = est.personid and
                                   rownum = 1
                            )
    where eq_id = 0 and orderid = 0;

You say "blank" in the text but the data shows 0.  The outer where clause may need to be modified to suit your actual data.

A: Psuedo Code:
Select distinct A_NUMBER, C_CD, PERSONID
     into temp_table from TableName
     where EQ_ID = 0 and Order_ID = 0

-- Choose correct data types
declare @Current_ANumber varchar(100)
declare @Current_C_CD varchar(100)
declare @Current_PERSONID varchar(100)
declare @Current_EQ_ID varchar(100)
declare @Current_Order_ID varchar(100)

select @Current_ANumber = A_NUMBER, @Current_C_CD= C_CD, @Current_PERSONID= PERSONID from temp_table
while (@Current_ANumber is not null)
begin
     select distinct @Current_EQ_ID = EQ_ID, @Current_Order_ID = Order_ID where EQ_ID > 0 and Order_ID > 0
     update table_name set EQ_ID = @Current_EQ_ID, Order_ID = @Current_Order_ID
          where A_NUMBER = @Current_ANumber
               and C_CD = @Current_C_CD
               and PERSONID = @Current_PERSONID
               and EQ_ID = 0
               and Order_ID = 0

     delete from temp_table
          where A_NUMBER = @Current_ANumber
               and C_CD = @Current_C_CD
               and PERSONID = @Current_PERSONID

     set @Current_ANumber = null
     set @Current_C_CD = null
     set @Current_PERSONID= null
     select @Current_ANumber = A_NUMBER, @Current_C_CD= C_CD, @Current_PERSONID= PERSONID from temp_table
end

I work with SQL Server, so while this code may not work out of the box for Oracle, it should put you on the right path.


text:
Q: Detectar alias dentro de script El objetivo de mi script es borrar los alias que introduzca como parámetro. Para ello he de comprobar si el parámetro introducido es un alias o no y tengo que pedir tantos parámetros como se diga inicialmente.
echo "Escribe el numero de alias que quieras eliminar"
read -n 1 cantidad
echo ""
for ((i=1; i<=$cantidad; i++))
    do
    echo "Introduce un alias"
    read alias1
    if [[ $(type -t $alias1) == "alias" ]]
    then
        unalias $alias1
        echo "El alias se ha borrado correctamente"
    else
        echo "El alias no existe"
    fi
done

El problema de mi código es que al ejecutarlo, si introduzco un alias siempre me lo detecta como que no lo es y por lo tanto se va al else siempre.

A: Tenes que ejecutar el script.sh con source en lugar del script únicamente
source tu_script.sh

Cuando corres tu script en una sh, el script se ejecuta en un nueva shell en un subproceso, por eso al momento de definir el alias, no es detectada como tal en la nueva.


text:
Q: Placing Shiny render outputs inside other functions So I am making a shiny app that takes multiple inputs and produces multiple plots and tables of those inputs.
Sample RenderTable code to make one table is below:
output$Table1 <-
      renderTable(data.frame(Shape = c("\u25CF", "\u25B2", "\u25FC", ""),
                             "Genes" = c(input$custom_genes1, "Mean"),
                              Analysed_values = c(t(analysis1()), mean(analysis1()))),
                              striped = TRUE, bordered = TRUE, hover = TRUE)

Where Shape is the symbol on the plot, "Genes" are the genes selected using a selectizeInput, and analysis1() is the result of a reactive calculation defined earlier in the code.
However I have 8-9 tables that need to be displayed depending on various checkboxes etc. Rather than copy-pasting the code out and replacing all the relevant values, I wanted to make a function that I could use to quickly display all the tables, and if I needed to change the formatting or add anything later I can just edit the function rather than each table individually.
I tried making a re-usable function using the code below:
construct_table <- function(genes_select, dataset){
    renderTable(data.frame(Shape = c("\u25CF", "\u25B2", "\u25FC", ""),
                          "Genes" = genes_select,
                           Analysed_values = c(t(dataset), mean(dataset))),
                           striped = TRUE, bordered = TRUE, hover = TRUE)
  }

And then making it easier to call each table directly:
output$Table1 <- construct_table(input$custom_genes1, analysis1())

This works in that is creates the table using the initial input values, but doesn't make the table reactive.
How can I call the renderTable reactive function inside a normal function, or is there another reactive function that I have overlooked that I can nest the renderTable function inside of that works the same way as the normal function does?

A: Simply adding a output$Table1 <- construct_table(input$custom_genes1, analysis1()) call anywhere will not work because analysis() is a reactive variable depending on other inputs the user can change. Hence analysis() can be used from a reactive context. ie. from inside observe, observeEvent, reactive, eventReactive or inside any renderXXX call ex: renderTable, renderPlot...
When we call output$Table1 <- construct_table(input$custom_genes1, analysis1()),
we are using analysis1() from outside a reactive context which will cause an error. The solution is Shiny Modules which is specifically designed to modularize code, which seems to be the goal here.

https://shiny.rstudio.com/articles/modules.html

Here is an example,
dataset = mtcars

generatePlot = function(input,output,session,data){
  output$plot = renderPlot({
    plot(data()$hp,data()$mpg)
    })
}

generateUI = function(id){
  ns = NS(id)
  plotOutput(ns("plot"))
}

shinyApp(
  ui = {
    fluidPage(
      sliderInput("slider","MPG filter",min(dataset$mpg),max(dataset$mpg),dataset$mpg),
      generateUI("mod1"),
      generateUI("mod2")
    )
  },
  server = function(input,output,session){

    data = eventReactive(input$slider,{
      dataset%>%
        dplyr::filter(between(mpg,input$slider[[1]],input$slider[[2]]))%>%
        return(.)
    })

    callModule(generatePlot,"mod1",data = data)
    callModule(generatePlot,"mod2",data = data)

  }
)

You can add many more identical plots by simply adding a new generateUI and a new callModule call.


text:
Q: Apply connections to a gauge transformation? I'm reading Donaldson's book, Floer homology groups in Yang-Mills theory. On page 82, he considers a trivial bundle $P$ over a $4$-manifold $X$ with tubular ends which is equipped with a connection $A_0$ and this connection is flat on each ends. (This is called an adapted bundle in the book.) He writes the covariant derivative induced by $A_0$ as $\nabla_0$ and on page 84, he apply this $\nabla_0$ to a gauge transformation $g$. My question is that since he defines the gauge transformation group as Aut($P$), how we can apply $\nabla_0$ to such an element? I only know how to apply $\nabla_0$ to sections of those vector bundles associated to $P$. And I don't know how I can regard elements in Aut($P$) as such sections? In short, what is $\nabla_0 g$ for $g \in$ Aut($P$)?
Thank you.

A: If I understand correctly, $A_0$ is a connection on a principal bundle $P \to X$, while $\nabla_0$ is the corresponding connection on some associated vector bundle $E \to X$.
The connection $\nabla_0$ induces a connection (denoted, say, $\nabla'$) on the vector bundle $\text{End}(E) \to X$.  Meanwhile, I'm imagining that the gauge transformation $g \in \text{Aut}(P)$ induces vector bundle morphism $E \to E$, which gives a morphism $\Gamma(E) \to \Gamma(E)$, and hence an element $g' \in \text{End}(\Gamma(E)) \cong \Gamma(\text{End}(E))$.
So, I'm speculating that $\nabla_0 g$ means $\nabla' g'$.


text:
Q: proving convergence of a sequence and then finding its limit For every $n$ in $\mathbb{N}$, let: $$a_{n}=n\sum_{k=n}^{\infty }\frac{1}{k^{2}}$$
Show that the sequence $\left \{ a_{n} \right \}$ is convergent and then calculate its limit.
To prove it is convergent, I was thinking of using theorems like the monotone convergence theorem. Obviously, all the terms $a_{n}$ are positive. So, if I prove that the sequence is decreasing, then by the monotone convergence theorem it follows that the sequence itself is convergent. $a_{n+1}-a_{n}=-\frac{1}{n}+\sum_{k=n+1}^{\infty }\frac{1}{k^{2}}$. But, I can't tell from this that the difference $a_{n+1}-a_{n}$ is negative.
If anybody knows how to solve this problem, please share.

A: [Edit: the first proof or convergence wasn't quite right, so I removed it.]
It is useful to find some estimates first (valid for $n>1$):
$$\sum_{k=n}^{\infty }\frac{1}{k^{2}}<\sum_{k=n}^{\infty }\frac{1}{k(k-1)}=\sum_{k=n}^{\infty }\left(\frac1{k-1}-\frac1k\right)=\frac1{n-1}\\\sum_{k=n}^{\infty }\frac{1}{k^{2}}>\sum_{k=n}^{\infty }\frac{1}{k(k+1)}=\sum_{k=n}^{\infty }\left(\frac1{k}-\frac1{k+1}\right)=\frac1{n}$$
The last equality in each of these lines holds because those are telescoping series.
This gives us the estimate: $1<a_n<\frac{n}{n-1}$. By the squeeze theorem, we can conclude that our sequence converges and $\lim_{n\to\infty}a_n=1$.

A: $$
n\sum_{k=n}^\infty\frac1{k^2}=\sum_{k=n}^\infty\frac{n^2}{k^2}\frac1n\tag{1}
$$
is a Riemann sum ($x=\frac{k}{n}$ and $\mathrm{d}x=\frac1n$) for
$$
\int_1^\infty\frac1{x^2}\mathrm{d}x=1\tag{2}
$$
Although $(2)$ is an improper Riemann integral, because $\frac1{x^2}$ is decreasing, we can still use the rectangular upper and lower approximations to $(2)$:
$$
\sum_{k=n+1}^\infty\frac{n^2}{k^2}\frac1n<\int_1^\infty\frac1{x^2}\mathrm{d}x< \sum_{k=n}^\infty\frac{n^2}{k^2}\frac1n\tag{3}
$$
where the sums in $(3)$ differ by $\frac1n$. Therefore, combining $(1)$-$(3)$ yields
$$
1<n\sum_{k=n}^\infty\frac{1}{k^2}<1+\frac1n\tag{4}
$$
which by the sandwich theorem gives
$$
\lim_{n\to\infty}n\sum_{k=n}^\infty\frac{1}{k^2}=1\tag{5}
$$

A: This series, (set the first term aside for now) can be pictured as rectangles of width $1$ and heights $\frac1{n^2}$ placed side to side.
The sum of the areas of the rectangle is the integral of the function $\displaystyle\frac1{\lceil x\rceil^2}$ over $(1,\infty)$. Which is clearly bounded by the integral of $\displaystyle\frac1{x^2}$ over $(1,\infty)$ which in turn is bounded. Now add back the first term. Boundedness remains.
(Similarly you can find an integral which binds it below.)


text:
Q: Represent an integer as a sum of n non-consecutive squares Is it possible to decompose an integer into a sum of n unique squares ,even though they are not necessarily consecutive.
For instance, How would I obtain the sequence 1*1 + 7*7 + 14*14 + 37*37 given the integer 1615
or 11*11 + 15*15 + 29*29 + 43*43 + 69*69 given the integer 7797.

A: OEIS A001422 gives the full list of
natural numbers not expressible as the sum of distinct squares:
$$
\begin{array}{c}
2, 3, 6, 7, 8, 11, 12, 15, 18, 19, 22, 23, 24, 27, 28, 31, 32, 33,
\\
43, 44, 47, 48, 60, 67, 72, 76, 92, 96, 108, 112, 128.
\end{array}
$$
The reference is

R. Sprague, Über Zerlegungen in ungleiche Quadratzahlen,
  Math. Z. 51 (1948), 289$-$290.

(This two-page paper
is several decades before Halter-Koch 1982, which concerns
decompositions into exactly $5$ distinct squares.)
Added later: The Sprague paper is elementary and constructive,
thus also answering the OP's question "How would I obtain
[a sum-of-distinct-squares representation] given the integer".
Basically, starting from $n$, subtract the first square larger than $n/2$,
and repeat until you first reach a number less than $300$.
That number will still exceed $128$, so to finish consult
a table with a distinct-square representation of each of the
integers in $(128,300)$.  Such a table was routine to compute
even in 1948, and is basically trivial with the computer.
For example, applying this technique to the OP's $1615$ yields
$1615 = 29^2 + 20^2 + 14^2 + 178$, and then for instance $178 = 13^2 + 3^2$
or $178 = 12^2 + 5^2 + 3^2$.
If we read "even though they are not consecutive" in the strict sense
that no pair of consecutive squares is allowed in the sum, then
much the same technique must still work, though with thresholds
somewhat larger than $128$ and $300$, and subtracting from $n$
the smallest $k$ such that $n-k^2 < (k-1)^2$ (not just less than $k^2$).

A: Yes, by Lagrange's four-square theorem. More generally, for any $k$ there is an $s$ such that any natural number is the sum of $s$ $k$-th powers, see Waring's problem.
Added 1. Halter-Koch proved in 1982 that any integer greater than 245 is the sum of 5 distinct squares, see Satz 4 here. He also determined which numbers are not the sum of 4 distinct squares (there infinitely many exceptions, but only finitely many exceptions that are not divisible by 4), see Satz 3 here.
Added 2. For representability as a sum of more distinct squares, see the paper by Bateman, Hildebrand, Purdy here. For example, Table I in this paper tells us that any integer greater than 343296 is the sum of 100 distinct squares.
Added 3. It is straightforward to show that for any $d>0$, every sufficiently large $n$ is the sum of squares of 5 natural numbers whose minimal distance is at least $d$. This is because, by the circle method, the number of representations $n=n_1^2+\dots +n_5^2$ is $\gg n^{3/2}$, while the number of representations with $|n_i-n_j|<d$ for some $1\leq i<j\leq 5$ is $\ll_{d,\epsilon} n^{1+\epsilon}$ for any $\epsilon>0$.

A: John Thompson and I proved in a paper about character theory of the Alternating group that for $m > 1922$, it is possible to express $m$ as a sum of at most $11$ distinct odd squares.

A: I do not know the answer, but I suspect for every n greater than 3, all but finitely many
positive integers will have a representation as a sum of n distinct and
nonconsecutive squares, and of those, only finitely many will have only one such
representation.
Here is a method to search for a representation.  Given integers n and s, you know
that if there is a representation, the largest summand is greater than s/n.  Now
for each square q from s/n to some limit less than s, consider the subproblem
(s-q, n-1, q), which is to represent s-q as the sum of n-1 distinct and nonconsecutive
squares, all less than the largest square less than q.  A program which searches for such
representations and values of n less than 10 should be able to find one or more
representations when they exist for s less than a billion quite quickly.  You may find
a good upper bound for non representable numbers fairly quickly, and from that
conjecture a general bound depending only on n greater than 3.


text:
Q: Modifying a table a cursor is declared on So I've created a cursor on a temp table in a stored proc. However, in the @@fetch_status while loop, this temporary table is changed. I would expect that the cursor will see the new entries in the table it was declared on and will continue looping on them. Is this actually the case or does SQL take a snapshot of the table when you declare a cursor?

A: If you declare the cursor as being DYNAMIC it should see any changes made to a row when you enter and fetch that row.  Any changes made post-fetch will, of course, not be visible to you.  I don't remember if the default cursor behavior is STATIC or DYNAMIC, so you're just best off declaring it the way you want it to act to be safe.
Note that there are some limitations on what other options can go into a DYNAMIC cursor, see the MSDN page for all the nitty gritty.


text:
Q: !: (bang colon) notation in Angular I found !: notation being used in Angular Deprecation docs.
@Input() tpl !: TemplateRef<any>;
@ContentChild(TemplateRef) inlineTemplate !: TemplateRef<any>;

Found the same here as well.
@Input() id !: string;

I'm not sure what is the terminology (or concept behind) for !: notation in Angular. Googling didn't help me much. Tried SymbolHound and Angular Docs for the same, but all in vain.
It'd be helpful if someone could shed some light on it, like how does it function, or share the doc link at the very least.

A: If you have strictNullChecks on then anything you decorate with @Input will usually complain.  For example...
public class MyComponent {

  @Input()
  public myField: string;

  constructor() {}

}

This will lead to TS complaining.  This is because myField has not be declared nullable so it should never be set to null or undefined.  At the same time, it is not initialized in the constructor, so it will get an initial value of undefined.
Normally, this is fine.  We know that Angular will set the value shortly after construction.  If we mark the field nullable public myField: string? then we will have to deal with this field may be null errors all over the place when we try and use it.
So, as a compromise, we throw a ! on the field declaration to tell Typescript "I know this looks like it is getting initialized to null/undefined but trust me, I will take care of it".

A: The exclamation mark ! tells, that the field is non-null non-undefined (see Microsoft's TypeScript documentation).
The colon : is just the separator between field name and type.


text:
Q: error in predict glmer object I am trying to predict a glmer object with an argument newparams like this:
library(lme4)

    set.seed(123)
    df<-data.frame(id=sample(LETTERS[1:10], 50, T),
                   y=rbinom(50, 1, 0.3),
                   x1=rbinom(50, 1, 0.5),
                   x2=as.integer(rnorm(50, 40, 5)))
    df<-df[order(df$id),]

    fit<-glmer(y~x1+x2+(1|id), data=df, binomial)
    predict(fit, newparams=list(theta=getME(fit, "theta"), beta=fixef(fit)))
    Error in predict(fit, newparams = list(theta = getME(fit, "theta"),
unused argument (newparams = list(theta = getME(fit, "theta"), beta = fixef(fit)))

May somebody here know what's the reason?

A: I think you should set newdata argument. This works fine :
predict(fit, newdata=df,
  newparams=list(theta=getME(fit, "theta"), beta=fixef(fit)))

PS
using your code I get a different error:
Error: inherits(fr, "data.frame") is not TRUE


text:
Q: NgController scope inherit after update 0.9.9 I have error after update to Angular 0.9.10.
=== index.html ====
...

Wait ...

  ...

=== main.dart ===
@NgController(
  selector: '[main-controller]',
  publishAs: 'ctrl'
)
class MainController {
  ...
  MainController (Scope scope) {
  scope.context['msg'] = "abc";
  }
}

=== other.dart ===
@NgController(
  selector: '[other-controller]',
  publishAs: 'ctrl'
)
class OtherController {
  ...
  Scope scope;
  OtherController (Scope _scope) {
  this.scope = _scope;
  print("msg => $this.scope.context['msg']"); // I want print msg => abc here
  }
}

On angular version < 0.9.8 it print msg => abc but after update to 0.9.10 it is null.
I know new notice of NgController : Controllers create a new scope at the element. Is it a new on 0.9.9 ?
Does scope of controller like component ? Because I read AngularDart tutorial ch03 : "Components create their own scope hierarchy that is invisible from the outside world. They don't have direct access to the app's scope, nor does the app have direct access to a component's scope."

A: You need to add some curly braces
 print("msg => $this.scope.context['msg']");  // wrong
 print("msg => ${this.scope.context['msg']}"); // evaluates the entire expression not only `this`


text:
Q: how to return a Point in this example I am trying to return a Point from a circle.java class that extends a shape class. i keep getting a null pointer exception at the moment. i need to retrun the center point using the inherited getPoints(); method but the inhereted method returns a array and value to be returned from circle is not an array. how would i return the center point without makeing a seperate return method.
my Shape class is as follows
import java.awt.Point;

public abstract class Shape {
private String  name;
private Point[] points;
protected Shape(){};
protected Shape(String aName) {
    name = aName;
}

public final String getName() {
    // TODO Implement method
    return name;
}

protected final void setPoints(Point[] thePoints) {
    points = thePoints;
}

public final Point[] getPoints() {
    // TODO Implement method
    return points;
}

public abstract double getPerimeter();

public static double getDistance(Point one, Point two) {
    double x = one.getX();
    double y = one.getY();
    double x2 = two.getX();
    double y2 = two.getY();
    double x3 = x - x2;
    double y3 = y - y2;
    double ypow = Math.pow(y3, 2);
    double xpow = Math.pow(x3, 2);
    double added = xpow + ypow;
    double distance = Math.sqrt(added);
    return distance;
}
}

my circle class is a follows
import java.awt.Point;

public class Circle extends Shape{

private double radius;

public Circle(Point center, int aradius) {
super("Circle");

radius = aradius;
if(radius < 0){
    radius = 0;
}
else{
radius = aradius;
}

}

@Override
public double getPerimeter() {
double perim = 2 * Math.PI * radius;
return perim;
}
  public double getRadius(){
  return radius;
}

}

A: The simplest solution I can think of is simply to use the setPoints method from the Shape  class...
public Circle(Point center, int aradius) {
    super("Circle");
    //...
    setPoints(new Point[]{center});
}

A: The reason you're getting a NullPointerException is because you never setPoints of Shape.
I'm not sure what points is supposed to contain but the only thing that would kind of make sense to me is all the points within the shape. Which IMO gets a bit tricky to determine with shapes like circles and determining a center point seems even trickier (although I guess for a circle it would pretty much be the middle point of the array depending on the order?).
(On second thought points could also contain whatever the subclass decides it should, like 1 center point for a circle and 4 points for a rectangle..)
Anyway you will have to fill the points array of Shape (by calling setPoints) with some data before you can use getPoints.


text:
Q: How much history will be saved in iTerm2 Shell Integration's Toolbelt? Background:
I installed shell integration in iTerm2 and enabled saving all command history to disk so it persists between sessions (Preferences > General > Save copy/paste and command history to disk).
Questions:
A)    Is there is a limit to how much history will be stored?  Does it follow the value assigned to the HISTFILESIZE environment variable, or is it controlled some other way, or limited by default?
B)   The history in the toolbelt contains additional information like the working directory at the time the command was executed (printed on the cli when you option+double click the history item). Where does this information come from?
The documentation doesn't address this at all and I couldn't find any answers on google.  Does anyone know?  Thanks in advance!


text:
Q: Ruby/Rails worker to create or update record if exists - avoid DRY I've got worker to store data from incoming webhooks. Now I want to use this worker to update existing data if this data already exists.
class StoreActivityWorker
  include Sidekiq::Worker

  def perform(webhook)
    Activity.create!(
      cms_activity_id: webhook.dig('entity', 'id').to_i,
      is_separate_activity: webhook.dig('entity', 'attributes', 'is_separate_activity'),
      content_full: retrieve_full_content(webhook),
      content_basic: retrieve_basic_content(webhook),
    )
  end
end

Because the webhook does not show which records have been updated the UpdateActivityWorker will be the same (update all fields):
class UpdateActivityWorker
  include Sidekiq::Worker

  def perform(webhook)
    Activity.where(cms_activity_id: webhook[:entity][:id]).update(
      cms_activity_id: webhook.dig('entity', 'id').to_i,
      is_separate_activity: webhook.dig('entity', 'attributes', 'is_separate_activity'),
      content_full: retrieve_full_content(webhook),
      content_basic: retrieve_basic_content(webhook),
    )
  end
end

As you see it's not inline with DRY. Is there any way to avoid repeats that code?

A: Take a look at find_or_initialize_by method:
class StoreActivityWorker
  include Sidekiq::Worker

  def perform(webhook)
    entity = webhook.dig 'entity'

    activity = Activity.find_or_initialize_by(cms_activity_id: entity['id'])

    activity.update!(
      is_separate_activity: entity.dig('attributes', 'is_separate_activity'),
      content_full: retrieve_full_content(webhook),
      content_basic: retrieve_basic_content(webhook),
    )
  end
end