text:
Q: Testing the performance of a C++ app I'm trying to find a way to test how long it takes a block of C++ code to run. I'm using it to compare the code with different algorithms and under different languages, so ideally I would like a time in seconds / milliseconds. In Java I'm using something like this:
long startTime = System.currentTimeMillis();

function();

long stopTime = System.currentTimeMillis();
long elapsedTime = stopTime - startTime;

Is there a good way to get an accurate time like that in C++ (Or should I use some other means of benchmarking)?

A: Use the best counter available on your platform, fall back to time() for portability.
I am using QueryPerformanceCounter, but see the comments in the other reply.
General advise:
The inner loop should run at least about 20 times the resolution of your clock, to make the resolution error < 5%. (so, when using time() your inner loop should run at least 20 seconds)
Repeat these measurements, to see if they are consistent.
I use an additional outer loop, running ten times, and ignoring the fastest and the slowest measurement for calculating average and deviation. Deviation comes handy when comparing two implementations: if you have one algorithm taking 2.0ms +/-.5, and the other 2.2 +/- .5, the difference is not significant to call one of them "faster".
(max and min should still be displayed). So IMHO a valid performance measurement should look something like this:
10000 x 2.0 +/- 0.2 ms (min = 1.2, , max=12.6), 10 repetitions

If you know what you are doing, purging the cache and setting thread affinity can make your measurements much more robust.
However, this is not without pifalls. The more "stable" the measurement is, the less realistic it is as well. Any implementation will vary strongly with time, depending on the state of data and instruction cache. I'm lazy here, useing the max= value to judge first run penalty, this might not be sufficient for some scenarios.

A: Execute the function a few thousand times to get an accurate measurement.
A single measurement might be dominated by OS events or other random noise.

A: In Windows, you can use high performance counters to get more accurate results:
You can use the QueryPerformanceFrequency() function to get the number of high frequency ticks per seconde and the user the QueryPerformanceCounter() before and after the function you want to time.
Of course, this method is not portable...

A: Have you considered actually using a profiler? Visual Studio Team System has one built in, but there are others available like VTune and GlowCode.
See also What's the best free C++ profiler for Windows?

A: What's wrong with clock() and CLOCKS_PER_SEC? They are standard C89.
Something like (nicked from MSDN):
   long i = 6000000L;
   clock_t start, finish;
   double  duration;

   // Measure the duration of an event.
   printf( "Time to do %ld empty loops is ", i );
   start = clock();
   while( i-- )
      ;
   finish = clock();
   duration = (double)(finish - start) / CLOCKS_PER_SEC;
   printf( "%2.1f seconds\n", duration );

A: You can use the time() function to get a timer with a resolution of one second. If you need more resolution, you could use gettimeofday(). The resolution of that depends on your operating system and runtime library.

A: I always use boost::timer or boost::progress_timer.
psudo-code:
#include <boost/timer.hpp>

boost::timer t;

func1();
cout << "fun1: " << t.elapsed();

t.restart();
func2();
cout << "func2(): " << t.elapsed();

A: If you want to check you performance, you should consider measuring used processor time, not the real time you are trying to measure now. Otherwise you might get quite inaccurate times if some other application running in background decides to do some heavy calculations at the same time.
Functions you want would be GetProcessTimes on Windows and getrusage on Linux.
Also you should consider using profilers, as other people suggested.

A: OVERVIEW
I have written a simple semantic hack for this.

*

*Easy to use

*Code looks neat.

MACRO
#include <time.h>

#ifndef SYSOUT_F
#define SYSOUT_F(f, ...)      _RPT1( 0, f, __VA_ARGS__ ) // For Visual studio
#endif

#ifndef speedtest__
#define speedtest__(data)   for (long blockTime = NULL; (blockTime == NULL ? (blockTime = clock()) != NULL : false); SYSOUT_F(data "%.9fs", (double) (clock() - blockTime) / CLOCKS_PER_SEC))
#endif

USAGE
speedtest__("Block Speed: ")
{
    // The code goes here
}

OUTPUT
Block Speed: 0.127000000s

A: You can simply use time() within your code to measure within accuracy of seconds. Thorough benchmarks should run many iterations for accuracy so seconds should be a large enough margin. If you are using linux, you can use the time utility as provided by the command line like so:
[john@awesome]$time ./loops.sh

real    0m3.026s
user    0m4.000s
sys     0m0.020s

A: On unix systems (Linux, Mac, etc.) you can use time utility like so:
$ time ./my_app

A: If your function is very fast, a good practice is to time the function in a loop and then subtract the loop overhead.
Something like this:
int i;
int limit=1000000;
int t0=getTime();
for(i=0; i < limit; ++i)
   ;
int t1=getTime();
int loopoverhead = t1-t0;
t0=getTime();
for(i=0; i < limit; ++i)
    function();
t1=getTime();
double tfunction = (1.0/limit)*((t1-t0)-loopoverhead);

A: Run it 1000 times as 100 iterations * 10 iterations, where you unroll the inner loop to minimize overhead. Then seconds translate to milliseconds.
As others have pointed out, this is a good way to measure how long it takes.
However, if you also want to make it take less time, that is a different goal, and needs a different technique. My favorite is this.

A: Your platform for deployment can have a serious impact on your clock precision. If you are sampling inside of a Virtual Machine, all bets are off.   The system clock in a VM floats in relation to the physical clock and has to be occasionally resynched.   It is almost a certainty that this will happen will happen, given the mischievous nature of Mr Murphy in the software universe


text:
Q: Distributing a shift evenly amongst employees For employee scheduling, I am writing a MIP. I am trying to distribute the shifts amongst the employees with the same skills as even as possible.
e.g.
=============================
Three employees with the same skill: Bob, Michel, Terry
Bob payroll 10\$/hour; Michel payroll 15\$/hour; Terry payroll 20\$/hour
Prefered Assigning: Monday: Bob -> 9 to 5; Tuesday: Michel -> 9 to 5; Wednesday: Terry  -> 9 to 5
=============================
In my MIP it is possible to count the hours that an employee is working.
Is it possible to write a constraint in order to evenly distribute the shifts?
Does this idea even make sense if my objective function is to target the minimization of costs or prioritization of some employees? I am not sure that in this case, multi-objective optimization would work properly.

A: Assuming your original objective is to minimize payroll costs, you could create constraints limiting the maximum discrepancy in hours between the most and least used workers, or you could create constraints limiting the absolute difference between the hours of any worker and the average hours per worker overall (total hours divided by number of workers). If neither of those alternatives appeals to you, you could combine some measure of inequality with the cost function, but that would require you to quantify the trade-off (e.g., getting one hour closer to equality in workloads is worth $K$ dollars in increased staffing cost).

redpajama_set_name: RedPajamaStackExchange


text:
Q: Is there a way to make a circle with my own picture with pygame? Hello i want to make a picture of type pygame.circle(something like get_rect() but circle). That's for an Billiard game and to be able to move them properly i think they would be circles. Here's the code:
import pygame
import pyautogui

width, height = pyautogui.size()

pygame.init()
screen = pygame.display.set_mode(pyautogui.size())
pygame.display.set_caption('Billiard')
background_image = pygame.image.load("Table.png")
background_image =  pygame.transform.scale(background_image, pyautogui.size())
ball_1 = pygame.image.load("Ball_1.png")
ball_1 = pygame.transform.scale(ball_1, (65, 65))
screen.blit(ball_1, [400, 400])
clock = pygame.time.Clock()
screen.blit(background_image, [0,0])

running = True

while running:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False

    pygame.display.flip()
    clock.tick(30)

I want to make the balls as circles
Thanks in advance

A: Create a transparent pygame.Surface object and use pygame.draw.circle to draw a circle on it:
radius = 20   # just for example
color = "red"

circle_surf = pygame.Surface((radius * 2, radius * 2), pygame.SRCALPHA)
pygame.draw.circle(circle_surf, color, (radius, radius), radius)


text:
Q: Select employees belong to both department in database I have a table
 EmpName   DeptID
-------------------------
   Sam        1
   John       2
   Sam        2
   Bill       3
   Mary       1

I want to select employees who belong to both DeptID '1' and DeptID '2'
For this table i want to show EmpID : sam
How can i write a query in MySql
Thanks in advance.

A: Another approach using sum
select EmpName
from demo
group by EmpName
having sum(DeptID = 1)
and sum(DeptID = 2)

DEMO

A: Use HAVING with GROUP BY.
Query
select EmpName from your_table_name
where DeptID in (1,2)
group by EmpName
having count(distinct DeptID) = 2;

A: You could use an having clause   on the filterd  rows
  select empname
  from my_table
  where dempId in (1,2)
  group by empname
  having count(distinct DeptID) = 2

A: Another method using self join
Select empname
From table t1
Join table t2
Using (empname)
Where t1.deptid = 1
  And t2.deptid = 2


text:
Q: How do I fix my internet on Ubuntu 12.04 server? I have Ubuntu Server 12.04 installed with no GUI. I installed ownCloud and webmin a few months ago with no problem, so I know my internet used to work. The power went out while the PC was on one day 2 months ago and I did not turn the PC back on until yesterday. Now I have no internet connection. Does anyone know how I can fix this, or should I just reinstall Ubuntu?
this is the output of ifconfig -a:
 eth0   link encap:Ethernet  HWaddr 00:06:4f:4a:66:f0
BROADCAST MULTICAST  MTU:1500  Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

eth1   link encap:Ethernet  HWaddr 00:16:ec:05:c8:9c
    BROADCAST MULTICAST  MTU:1500  Metric:1
    RX packets:0 errors:0 dropped:0 overruns:0 frame:0
    TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:1000
    RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

lo     Link encap:Local Loopback
    inet addr 127.0.0.1  Mask:255.0.0.0
    inet6 addr:  ::1/128 Scope:Host
    UP LOOPBACK RUNNING MTU:65536  Metric:1
    RX packets:1800 errors:0 dropped:0 overruns:0 frame:0
    Tx packets:1800 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:0
    RX bytes:143896 (143.b KB)  TX bytes:143896 (143.8 KB)

I have a wired connection.
 Here are the contents of etc/network/interfaces:
# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet dhcp

I tried assigning a static IP to eth2, which is a adapter I just added, and now when I run ifconfig it shows a inet addr of 192.168.1.100. So I have an ip now. When trying to add the default gateway, I typed route add default ge 192.168.1.1, and it said,
Usage: inet route [-vF] del {-host|-net} Target[/prefix] [gw GW] [metric M] [[dev] if]

There are 5 more lines of writing associated with this route error, but I do not want to type all that out unless it is needed. Does anyone know what to do?

A: Looking at your ifconfig output, I don't see any IP address assigned, there are many ways of troubleshooting this issue, assuming you have your cable connected to the first Ethernet port eth0 on your server.

*

*send new DHCP request
dhclient eth0

*Try and assign static IP if DHCP request failed.
 ifconfig eth0 192.168.1.100/24 up

then add default gw
route add default gw 192.168.1.1

*

*try and ping 8.8.8.8 and hopefully you will get a response.


text:
Q: Custom items for Menus When editing Menus, I find 5 typs of items that can be added:

*

*Custom Links

*Pages

*Posts

*Categories

*Tags

Would it be possible to add custom ones? Let's say for instance that I want to add an image, or a search bar, or whatever.
Could I somehow add new menu items types, that render the code that I choose for them?

A: Not in the menu management interface.
You can inject custom elements if you create a custom nav walker. This requires some coding skill as well as trial and error to figure out which parts of the code you need to use, and how to tweak them.
Or, if you're comfortable using JavaScript to change things after the menu is built (so some visitors and search engines might not see the change), you could use a document.ready script that identifies a "regular" menu item and then injects whatever image etc. you want to display in its place.

A: You will need a plugin for that.
For example, something like this one: https://wordpress.org/plugins/wp-megamenu/


text:
Q: Function with recursive CTE seems to be very slow I am currently working on a function in which I use a recursive CTE, but it seems that have poor performance. I need this to be in function (so no temp tables) so I can easily use it within stored procedures.
Here is the code:
CREATE FUNCTION [dbo].[Web_GetDailyLoadListUDF]
(
    @CustomerID INT
    , @StartDate DATETIME
    , @Days INT
    , @IncludeChildren BIT
)
RETURNS @TableOfValues TABLE
(
    RowID SMALLINT IDENTITY(1,1)
    , DailyLoadCount INT
    , DailyLoadDate VARCHAR(6)
    , FullDate DATETIME
)
AS
BEGIN
    DECLARE @MaxDate DATETIME;
    SET @MaxDate = DATEADD(dd, @Days * -1.7, DATEDIFF(dd, 0, @StartDate));

    WITH DateCTE AS
    (
        SELECT DATEADD(dd, 0, DATEDIFF(dd, 0, @StartDate)) AS DateValue
        UNION ALL
        SELECT DATEADD(DAY, -1, DateValue)
        FROM DateCTE
        WHERE DATEADD(DAY, -1, DateValue) > @MaxDate
    )
    INSERT INTO @TableOfValues
    SELECT * FROM
    (
        SELECT TOP (@Days)
            (
                SELECT COUNT(*)
                FROM dbo.[Load] l WITH (NOLOCK)
                JOIN dbo.LoadCustomer lc WITH (NOLOCK)
                    ON lc.LoadID = l.ID
                JOIN dbo.Customer c WITH (NOLOCK)
                    ON c.ID = lc.CustomerID
                WHERE DATEADD(dd, 0, DATEDIFF(dd, 0, l.LoadDate)) = dct.DateValue
                    AND l.StateType = 1
                    AND lc.Main = 1
                    AND (c.ID = @CustomerID OR (@IncludeChildren = 1 AND c.ParentCustomerID = @CustomerID))
            ) AS DailyLoadCount
            , CONVERT(VARCHAR(6), dct.DateValue, 107) AS DailyLoadDate
            , dct.DateValue
        FROM DateCTE dct
        WHERE
            DATEPART(DW, dct.DateValue) NOT IN (1, 7)
            AND dct.DateValue NOT IN
            (
                SELECT HolidayDate FROM Holiday
            )
        ORDER BY dct.DateValue DESC
    ) AS S
    ORDER BY s.DateValue ASC

    RETURN
END

What this SQL is supposed to retrieve is the number of loads per day, for the past @Days that are business days (no weekends/holidays).
I basically just need some help optimizing this so that it doesn't run so slow. (Takes up to 20 seconds per customer, and this will be called over thousands).

A: Your main problem is just here
WHERE DATEADD(dd, 0, DATEDIFF(dd, 0, l.LoadDate)) = dct.DateValue

It should be
WHERE l.LoadDate >= dct.DateValue
  AND l.LoadDate <  dct.DateValue +1

Create composite indexs on Load(LoadDate, ID) and Load(ID, LoadDate) and drop the one that does not get used in the query plan.
You should show the query plan whenever you are asking questions about performance.  To view the query plan, run the query inside the function on its own using variables for the input parameters.  From the menu in SSMS, enable the option "Query -> Include Actual Execution Plan"
Since you don't have enough rep to post images, you can reveal the text plan as follows.  Provide some sensible parameters in the first SELECT statement.
set showplan_text on;

Then, run the below in TEXT mode, i.e. press Ctrl-T then Ctrl-E.
DECLARE
      @CustomerID INT
    , @StartDate DATETIME
    , @Days INT
    , @IncludeChildren BIT

SELECT
      @CustomerID = 1
    , @StartDate = '20110201'
    , @Days = 10
    , @IncludeChildren = 1

DECLARE @TableOfValues TABLE
(
    RowID SMALLINT IDENTITY(1,1)
    , DailyLoadCount INT
    , DailyLoadDate VARCHAR(6)
    , FullDate DATETIME
)

    DECLARE @MaxDate DATETIME;
    SET @MaxDate = DATEADD(dd, @Days * -1.7, DATEDIFF(dd, 0, @StartDate));

    WITH DateCTE AS
    (
        SELECT DATEADD(dd, 0, DATEDIFF(dd, 0, @StartDate)) AS DateValue
        UNION ALL
        SELECT DATEADD(DAY, -1, DateValue)
        FROM DateCTE
        WHERE DATEADD(DAY, -1, DateValue) > @MaxDate
    )
    INSERT INTO @TableOfValues
    SELECT * FROM
    (
        SELECT TOP (@Days)
            (
                SELECT COUNT(*)
                FROM dbo.[Load] l WITH (NOLOCK)
                JOIN dbo.LoadCustomer lc WITH (NOLOCK)
                    ON lc.LoadID = l.ID
                JOIN dbo.Customer c WITH (NOLOCK)
                    ON c.ID = lc.CustomerID
                WHERE DATEADD(dd, 0, DATEDIFF(dd, 0, l.LoadDate)) = dct.DateValue
                    AND l.StateType = 1
                    AND lc.Main = 1
                    AND (c.ID = @CustomerID OR (@IncludeChildren = 1 AND c.ParentCustomerID = @CustomerID))
            ) AS DailyLoadCount
            , CONVERT(VARCHAR(6), dct.DateValue, 107) AS DailyLoadDate
            , dct.DateValue
        FROM DateCTE dct
        WHERE
            DATEPART(DW, dct.DateValue) NOT IN (1, 7)
            AND dct.DateValue NOT IN
            (
                SELECT HolidayDate FROM Holiday
            )
        ORDER BY dct.DateValue DESC
    ) AS S
    ORDER BY s.DateValue ASC

SELECT * FROM @TableOfValues

Edit the plan into your question

A: You should use an inline UDF instead (right now you are actually using a temp table)
See http://msdn.microsoft.com/en-us/library/ms189294.aspx
Or convert it into a view instead.

A: Correlated subqueries run row-by-row, do not use them. Use a join or a join to a derived table instead. You also need to make sure any where clauses can take advantage of the indexing.  Search on saragble queries to see what kinds of things cannot use indexes and what can be done to make it use an index.


text:
Q: Yet another repeated column in hibernate mapping Hibernate is giving me the following exception
 org.hibernate.MappingException: Repeated column in mapping for entity: Pricelist column: ID_OFFER (should be mapped with insert="false" update="false")

but I really cannot find the duplicate reference to ID_OFFER. Here they are the two mapping files involved.
Offer.hbm.xml
<hibernate-mapping>
 <class name="Offer" table="OFFERS">
  <id name="idOffer" type="java.lang.Long">
   <column name="ID_OFFER" not-null="true" precision="10" scale="0"
    sql-type="NUMBER" unique="true"/>
   <generator class="native">
    <param name="sequence">OFFERS_SEQ</param>
   </generator>
  </id>
  <property generated="never" lazy="false" name="name" type="string">
   <column name="name" not-null="true" sql-type="VARCHAR2" unique="true"/>
  </property>
  <set name="pricelists" sort="unsorted" table="PRICELISTS">
   <key not-null="true">
    <column name="ID_OFFER" not-null="true" precision="10" scale="0" sql-type="NUMBER"/>
   </key>
   <one-to-many class="Pricelist"/>
  </set>
 </class>
</hibernate-mapping>

Pricelist.hbm.xml
<hibernate-mapping>
 <class name="Pricelist" table="PRICELISTS">
  <id name="idPricelist" type="java.lang.Long">
   <column name="ID_PRICELIST" not-null="true" precision="10" scale="0" sql-type="NUMBER"/>
   <generator class="native">
    <param name="sequence">PRICELISTS_SEQ</param>
   </generator>
  </id>
  <property name="name" type="string">
   <column length="255" name="NAME" not-null="true" sql-type="VARCHAR2"/>
  </property>
  <property name="versionMajor" type="integer">
   <column name="VERSION_MAJOR" not-null="true" precision="5" scale="0" sql-type="NUMBER"/>
  </property>
  <property name="versionMinor" type="integer">
   <column name="VERSION_MINOR" not-null="true" precision="5" scale="0" sql-type="NUMBER"/>
  </property>
  <many-to-one class="Offer" name="offer">
   <column name="ID_OFFER" not-null="true" precision="10" scale="0" sql-type="NUMBER"/>
  </many-to-one>
  <many-to-one class="PricelistStatus" name="status">
   <column name="ID_STATUS_PRICELIST" not-null="true" precision="10"
    scale="0" sql-type="NUMBER"/>
  </many-to-one>
  <property name="validFrom" type="calendar">
   <column name="INIT_TIMESTAMP" not-null="true" scale="6" sql-type="TIMESTAMP"/>
  </property>
  <property name="validUntil" type="calendar">
   <column name="END_TIMESTAMP" not-null="false" scale="6" sql-type="TIMESTAMP"/>
  </property>
 </class>
</hibernate-mapping>

I am going crazy. Can anybody see where is it supposed to be duplicated the reference to the column ID_OFFER? Please note: two tables of my schema have a column named like that: OFFERS.ID_OFFER, which is the primary key of the table OFFERS and PRICELIST.ID_OFFER which has a foreign key constraint referencing, obviously, OFFERS.ID_OFFER.

A: You forgot about map this column as owning side (Offer.hbm.xml file)
<set name="pricelists" sort="unsorted" table="PRICELISTS">
   <key not-null="true">
      <column name="ID_OFFER" not-null="true" precision="10" scale="0" sql-type="NUMBER"/>
   </key>
   <one-to-many class="Pricelist"/>
</set>

it should look like (look at inverse="true"):
<set name="pricelists" sort="unsorted" table="PRICELISTS" inverse="true">
   <key not-null="true">
      <column name="ID_OFFER" not-null="true" precision="10" scale="0" sql-type="NUMBER"/>
   </key>
   <one-to-many class="Pricelist"/>
</set>

A: What @zxcf said, actually made the exception disappear, but made another question appear in my mind. Why doesn't the following mapping creates the same problem?
ServiceElement.hbm.xml
<hibernate-mapping>
 <class name="ServiceElement" table="SERVICE_ELEMENTS">
  <id name="idServiceElement" type="java.lang.Long">
   <column name="ID_SERVICE_ELEMENT" not-null="true" precision="10"
    scale="0" sql-type="NUMBER" unique="true"/>
   <generator class="native">
    <param name="sequence">SERVICE_ELEMENTS_SEQ</param>
   </generator>
  </id>
  <set name="prices" table="PRICES">
   <key>
    <column name="ID_SERVICE_ELEMENT" not-null="true" precision="10"
     scale="0" sql-type="NUMBER"/>
   </key>
   <one-to-many class="Price"/>
  </set>
 </class>
</hibernate-mapping>

Price.hbm.xml
<hibernate-mapping>
 <class name="Price" table="PRICES">
  <id name="idPrice" type="java.lang.Long">
   <column name="ID_PRICE" not-null="true" precision="10" scale="0"
    sql-type="NUMBER" unique="true"/>
   <generator class="native">
    <param name="sequence">PRICES_SEQ</param>
   </generator>
  </id>
  <many-to-one class="ServiceElement" name="serviceElement">
   <column name="ID_SERVICE_ELEMENT" not-null="true" precision="10"
    scale="0" sql-type="NUMBER"/>
  </many-to-one>
 </class>
</hibernate-mapping>

Isn't it the exact same mapping? But it does not throw any exception. Here they go the DDLs:
CREATE TABLE "CE_PRICELIST"."OFFERS"
(   "ID_OFFER" NUMBER(10,0),
"NAME" VARCHAR2(255 CHAR));
CREATE UNIQUE INDEX "CE_PRICELIST"."OFFERS_PK" ON "CE_PRICELIST"."OFFERS" ("ID_OFFER");
ALTER TABLE "CE_PRICELIST"."OFFERS" ADD CONSTRAINT "OFFERS_PK" PRIMARY KEY ("ID_OFFER");

CREATE TABLE "CE_PRICELIST"."PRICELISTS"
(   "ID_PRICELIST" NUMBER(10,0),
"ID_OFFER" NUMBER(10,0));
CREATE UNIQUE INDEX "CE_PRICELIST"."PRICELISTS_PK" ON "CE_PRICELIST"."PRICELISTS" ("ID_PRICELIST");
ALTER TABLE "CE_PRICELIST"."PRICELISTS" ADD CONSTRAINT "PRICELISTS_PK" PRIMARY KEY ("ID_PRICELIST");
ALTER TABLE "CE_PRICELIST"."PRICELISTS" ADD CONSTRAINT "PRICELISTS_OFFER_ID_FK" FOREIGN KEY ("ID_OFFER") REFERENCES "CE_PRICELIST"."OFFERS" ("ID_OFFER") ENABLE;

CREATE TABLE "CE_PRICELIST"."SERVICE_ELEMENTS"
(   "ID_SERVICE_ELEMENT" NUMBER(10,0));
CREATE UNIQUE INDEX "CE_PRICELIST"."SERVICE_ELEMENTS_PK" ON "CE_PRICELIST"."SERVICE_ELEMENTS" ("ID_SERVICE_ELEMENT");
ALTER TABLE "CE_PRICELIST"."SERVICE_ELEMENTS" ADD CONSTRAINT "SERVICE_ELEMENTS_PK" PRIMARY KEY ("ID_SERVICE_ELEMENT");

CREATE TABLE "CE_PRICELIST"."PRICES"
(   "ID_PRICE" NUMBER(10,0),
"ID_SERVICE_ELEMENT" NUMBER(10,0));
CREATE UNIQUE INDEX "CE_PRICELIST"."PRICES_PK" ON "CE_PRICELIST"."PRICES" ("ID_PRICE");
ALTER TABLE "CE_PRICELIST"."PRICES" ADD CONSTRAINT "PRICES_SERVICE_ELEMENT_ID_FK" FOREIGN KEY ("ID_SERVICE_ELEMENT")
  REFERENCES "CE_PRICELIST"."SERVICE_ELEMENTS" ("ID_SERVICE_ELEMENT") ENABLE;

OFFERS has a PK on ID_OFFER, which is referenced by PRICELISTS.ID_OFFER; Offer has a Set< Pricelist >;
SERVICE_ELEMENTS has a PK on ID_SERVICE_ELEMENT, which is referenced by PRICES.ID_SERVICE_ELEMENT; ServiceElement has a Set< Price >;
So why is the inverse attribute needed in one case and not in another one?


text:
Q: Can * be used in sym tokens for more than one character? The example for sym shows * (WhateverCode) standing in for a single symbol
grammar Foo {
    token TOP { <letter>+ }
    proto token letter {*}
    token letter:sym<P> { <sym> }
    token letter:sym<e> { <sym> }
    token letter:sym<r> { <sym> }
    token letter:sym<l> { <sym> }
    token letter:sym<*> {   .   }
}.parse("I ♥ Perl", actions => class {
    method TOP($/) { make $<letter>.grep(*.<sym>).join }
}).made.say; # OUTPUT: «Perl␤»

It will, however, fail if we use it to stand in for a symbol composed of several letters:
grammar Foo {
    token TOP { <action>+ % " " }
    proto token action {*}
    token action:sym<come> { <sym> }
    token action:sym<bebe> { <sym> }
    token action:sym<*> { . }
}.parse("come bebe ama").say; # Nil

Since sym, by itself, does work with symbols with more than one character, how can we define a default sym token that matches a set of characters?

A:
Can * be used in sym tokens for more than one character? ... The example for sym shows * (WhateverCode) standing in for a single symbol

It's not a WhateverCode or Whatever.1
The <...> in foo:sym<...> is a quote words constructor, so the ... is just a literal string.
That's why this works:
grammar g { proto token foo {*}; token foo:sym<*> { <sym> } }
say g.parse: '*', rule => 'foo'; # matches

As far as P6 is concerned, the * in foo:sym<*> is just a random string. It could be abracadabra. I presume the writer chose * to represent the mental concept of "whatever" because it happens to match the P6 concept Whatever. Perhaps they were being too cute.
For the rest of this answer I will write JJ instead of * wherever the latter is just an arbitrary string as far as P6 is concerned.

The * in the proto is a Whatever. But that's completely unrelated to your question:
grammar g { proto token foo {*}; token foo:sym<JJ> { '*' } }
say g.parse: '*', rule => 'foo'; # matches

In the body of a rule (tokens and regexes are rules) whose name includes a :sym<...> part, you can write <sym> and it will match the string between the angles of the :sym<...>:
grammar g { proto token foo {*}; token foo:sym<JJ> { <sym> } }
say g.parse: 'JJ', rule => 'foo'; # matches

But you can write anything you like in the rule/token/regex body. A . matches a single character:
grammar g { proto token foo {*}; token foo:sym<JJ> { . } }
say g.parse: '*', rule => 'foo'; # matches

It will, however, fail if we use it to stand in for a symbol composed of several letters

No. That's because you changed the grammar.
If you change the grammar back to the original coding (apart from the longer letter:sym<...>s) it works fine:
grammar Foo {
  token TOP { <letter>+ }
  proto token letter {*}
  token letter:sym<come> { <sym> }
  token letter:sym<bebe> { <sym> }
  token letter:sym<JJ> { . }
}.parse(
   "come bebe ama",
   actions => class { method TOP($/) { make $<letter>.grep(*.<sym>).join } })
 .made.say; # OUTPUT: «comebebe␤»

Note that in the original, the letter:sym<JJ> token is waiting in the wings to match any single character -- and that includes a single space, so it matches those and they're dealt with.
But in your modification you added a required space between tokens in the TOP token. That had two effects:

*

*It matched the space after "come" and after "bebe";

*After the "a" was matched by letter:sym<JJ>, the lack of a space between the "a" and "m" meant the overall match failed at that point.

sym, by itself, does work with symbols with more than one character

Yes. All token foo:sym<bar> { ... } does is add:

*

*A multiple dispatch alternative to foo;

*A token sym, lexically scoped to the body of the foo token, that matches 'bar'.

how can we define a default sym token that matches a set of characters?

You can write such a sym token but, to be clear, because you don't want it to match a fixed string it can't use the <sym> in the body.(Because a <sym> has to be a fixed string.) If you still want to capture under the key sym then you could write $<sym>= in the token body as Håkon showed in a comment under their answer. But it could also be letter:whatever with $<sym>= in the body.
I'm going to write it as a letter:default token to emphasize that it being :sym<something> doesn't make any difference. (As explained above, the :sym<something> is just about being an alternative, along with other :baz<...>s and :bar<...>s, with the only addition being that if it's :sym<something>, then it also makes a <sym> subrule available in the body of the associated rule, which, if used, matches the fixed string 'something'.)
The winning dispatch among all the rule foo:bar:baz:qux<...> alternatives is chosen according to LTM logic among the rules starting with foo. So you need to write such a token that does not win as a longest token prefix but only matches if nothing else matches.
To immediately go to the back of the pack in an LTM race, insert a {} at the start of the rule body2:
token letter:default { {} \w+ }

Now, from the back of the pack, if this rule gets a chance it'll match with the \w+ pattern, which will stop the token when it hits a non-word character.
The bit about making it match if nothing else matches may mean listing it last. So:
grammar Foo {
  token TOP { <letter>+ % ' ' }
  proto token letter {*}
  token letter:sym<come> { <sym> }    # matches come
  token letter:sym<bebe> { <sym> }    # matches bebe
  token letter:boo       { {} \w**6 } # match 6 char string except eg comedy
  token letter:default   { {} \w+ }   # matches any other word
}.parse(
   "come bebe amap",
   actions => class { method TOP($/) { make $<letter>.grep(*.<sym>).join } })
 .made.say; # OUTPUT: «comebebe␤»

that just can't be the thing causing it ... "come bebe ama" shouldn't work in your grammar

The code had errors which I've now fixed and apologize for. If you run it you'll find it works as advertised.
But your comment prodded me to expand my answer. Hopefully it now properly answers your question.
Footnote
1 Not that any of this has anything to do with what's actually going on but... In P6 a * in "term position" (in English, where a noun belongs, in general programming lingo, where a value belongs) is a Whatever, not a WhateverCode. Even when * is written with an operator, eg. +* or * + *, rather than on its own, the *s are still just Whatevers, but the compiler automatically turns most such combinations of one or more *s with one or more operators into a sub-class of Code called a WhateverCode. (Exceptions are listed in a table here.)
2 See footnote 2 in my answer to SO "perl6 grammar , not sure about some syntax in an example".

A: The :sym<...> contents are for the reader of your program, not for the compiler, and are used to distinguish multi tokens of otherwise identical names.
It just so happened that programmers started to write grammars like this:
token operator:sym<+> { '+' }
token operator:sym<-> { '-' }
token operator:sym</> { '/' }

To avoid duplicating the symbols (here +, -, /), a special rule <sym> was introduced that matches whatever is inside :sym<...> as a literal, so you can write the above tokens as
token operator:sym<+> { <sym> }
token operator:sym<-> { <sym> }
token operator:sym</> { <sym> }

If you don't use <sym> inside the regex, you are free to write anything you want inside :sym<...>, so you can write something like
token operator:sym<fallback> { . }

A: Maybe like this:
grammar Foo {
    token TOP { <action>+ % " " }
    proto token action {*}
    token action:sym<come> { <sym> }
    token action:sym<bebe> { <sym> }
    token action:sym<default> { \w+ }
}.parse("come bebe ama").say;

Output:
「come bebe ama」
 action => 「come」
  sym => 「come」
 action => 「bebe」
  sym => 「bebe」
 action => 「ama」


text:
Q: How to grant system permission I am just trying to clear the app data and getting below error
java.lang.SecurityException: Neither user 10028 nor current process has
android.permission.CLEAR_APP_USER_DATA.

I am using some hidden apis
How can i grant this permission
Thanks in Advance.

A: You will not get that permission in a normal device unless you are developing system app.
Refer to this article. You can add that to your manifest, adding this permission will not cause any compile error or warning. But it will simply not work in run time.
By the way, if you really need to clear the data of your application, why don't you one by one clear the files/preferences you are generating from your application for purpose of "data"?

A: You need to set a uses-permission in a AndroidManifest.xml file
The permission will look like this:
<uses-permission android:name="android.permission.CLEAR_APP_USER_DATA"/>

And will be placed within the manifest element of the xml file.
You can set it using manifest designer in eclipse by opening the AndroidManifest.xml file, then clicking on the Permissions tab (at the bottom). Then click Add and select "Uses Permission". You will find the permission you are looking for in the list.
You will not be able to clear the user data from the app without this permission.
See more information on permissions here and here

A: go to manifest-> permissions tab-> add permission-> select uses-permissions-> select specific permission-> save.


text:
Q: Java String into Array I converted a string to an array and made it into an integer array. I also multiplied all the values in the array by 3 and it works. My question is how do I make it so that the the output only shows [3,6,9,15] instead of what was shown in the block below.
public static void main(String[] args) {
    String arr = "1,2,3,5";

    String[] items = arr.split(",");

    int[] results = new int[items.length];

    for (int i = 0; i < items.length; i++) {
            results[i] = Integer.parseInt(items[i]);
            results[i] *= 3;
            System.out.println(java.util.Arrays.toString(results));

    }

   }

OUTPUT:
[3, 0, 0, 0]
[3, 6, 0, 0]
[3, 6, 9, 0]
[3, 6, 9, 15]

A: Move the printing to outside the loop
for (int i = 0; i < items.length; i++) {
        results[i] = Integer.parseInt(items[i]);
        results[i] *= 3;
}

System.out.println(java.util.Arrays.toString(results));

A: In Java 8+ you could use a lambda and stream the tokens (and I'd add \\s* to support optional whitespace around the comma to the regular expression) and then use a pair of map functions. Something like,
String arr = "1,2,3,5";
int[] results = Stream.of(arr.split("\\s*,\\s*")).mapToInt(Integer::parseInt)
        .map(x -> x * 3).toArray();
System.out.println(Arrays.toString(results));

Output is (as requested)
[3, 6, 9, 15]


text:
Q: Linear Operator with finite dimension I'm involved with this exercise. I would greatly appreciate your help

Let $V$ be a vector space of dimension $n$ over a field $F$. Let $T: V
\rightarrow V$ a linear transformation whose image and kernel are the
  same subspace of $V$. proves that $n$ is even

A: If $T:V\rightarrow W$ then $\text{dim}(V)=\text{dim}(K)+\text{dim}(T(V))$, where $K$ is the kernel of $T$.  In your case those two terms on the right hand side are equal.  So the LHS must be divisible by two.

A: Linear transformation $ T $ induces a isomorphism
$V/Ker(T) \cong Im(T)$
Hence $dim(V/Ker(T)) = dim(Im(T))$
$dim(V/Ker(T)) = dim(V)-dim(Ker(T))$ and  $dim(Ker(T)) = dim(Im(T))$
Conclude that  $dim(V) = 2dim(Im(T))$ which means $n$ is even.
$ $
And in the question : "Kernel and image  are same ", may be a typo .
"Kernel and image are isomorphic" is a sufficient hypothesis.
(If you say kernel=image , that means $V = {0} \Rightarrow n =0$)


text:
Q: Dynamically "gluing" with {glue} Is there any way to supply a vector to {glue} to dynamically choose which columns get "glued"? desired here is what would I am hoping to see but I just want to be able to provide vars to a glue statement.
library(glue)
library(dplyr)

vars <- c("Sepal.Length", "Species")

iris %>%
  head() %>% ## just for less data
  # mutate(glue_string = glue_data("{vars}")) %>%
  mutate(desired = glue("{Sepal.Length}{Species}"))

#>   Sepal.Length Sepal.Width Petal.Length Petal.Width Species   desired
#> 1          5.1         3.5          1.4         0.2  setosa 5.1setosa
#> 2          4.9         3.0          1.4         0.2  setosa 4.9setosa
#> 3          4.7         3.2          1.3         0.2  setosa 4.7setosa
#> 4          4.6         3.1          1.5         0.2  setosa 4.6setosa
#> 5          5.0         3.6          1.4         0.2  setosa   5setosa
#> 6          5.4         3.9          1.7         0.4  setosa 5.4setosa

A: We may either use .data to extract the column from each element of 'vars' and glue it
library(dplyr)
library(glue)
iris %>%
   head() %>% ## just for less data
     mutate(desired = glue("{.data[[vars[1]]]}{.data[[vars[2]]]}"))

-output
Sepal.Length Sepal.Width Petal.Length Petal.Width Species   desired
1          5.1         3.5          1.4         0.2  setosa 5.1setosa
2          4.9         3.0          1.4         0.2  setosa 4.9setosa
3          4.7         3.2          1.3         0.2  setosa 4.7setosa
4          4.6         3.1          1.5         0.2  setosa 4.6setosa
5          5.0         3.6          1.4         0.2  setosa   5setosa
6          5.4         3.9          1.7         0.4  setosa 5.4setosa

Or loop across all_of the elements in 'vars' to subset the data, invoke str_c to paste the columns by row
library(stringr)
library(purrr)
iris %>%
  head() %>% ## just for less data
    mutate(desired = invoke(str_c, across(all_of(vars))))


text:
Q: QTextBrowser shows markdown on Mac but not on Windows I'm building an app with Qt (pyside6) and packaging it with Pyinstaller. Everything works great on mac when running it through pycharm or when packaged, but the QTextBrowser doesn't render the sourced markdown file when it's running on my windows 10 machine.
I'm including a link to a github repo that I put together which is an extremely boiled down version of my app. It is simply a Qt interface displaying only a QTextBrowser which displays a markdown file located in a data folder. This is reproducing the same problem as my actual app. What am I missing to get the markdown file to show up when executing the app on a windows machine?
I did verify that the file paths were correct (I think), and when I get the source type from self.education_textbox.sourceType() it successfully prints out markdown resource. This leads me to believe it's not strictly a path issue because it would say UnknownResource if it wasn't getting the markdown file.
https://github.com/BigMoonTech/problem_reproduction.git
Here is the app.py:
import sys

from PySide6.QtWidgets import QMainWindow, QApplication

from MainWindow import UiMainWindow
from infrastructure.PathResolver import resolve_path

class MainWindow(QMainWindow, UiMainWindow):
    def __init__(self):
        super(MainWindow, self).__init__()
        self.setup_ui(self)
        self.education_textbox.setSource(resolve_path('data/edu/FecalPositiveRoundworm.md'))

if __name__ == "__main__":
    app = QApplication(sys.argv)
    app.setApplicationDisplayName('MyApp')
    main_window = MainWindow()
    main_window.setWindowTitle('MyApp')
    main_window.show()
    sys.exit(app.exec())

Here is the MainWindow.py:
from PySide6.QtCore import QSize
from PySide6.QtWidgets import QWidget, QVBoxLayout, QStackedWidget, QGridLayout, QTextBrowser

class UiMainWindow(object):
    def setup_ui(self, MainWindow):
        if not MainWindow.objectName():
            MainWindow.setObjectName(u"MainWindow")
        MainWindow.resize(720, 515)
        MainWindow.setMinimumSize(QSize(720, 515))

        self.centralwidget = QWidget(MainWindow)
        self.centralwidget.setObjectName(u"centralwidget")

        self.verticalLayout = QVBoxLayout(self.centralwidget)
        self.verticalLayout.setObjectName(u"verticalLayout")

        self.stackedWidget = QStackedWidget(self.centralwidget)
        self.stackedWidget.setObjectName(u"stackedWidget")

        self.page = QWidget()
        self.page.setObjectName(u"page")
        self.verticalLayout2 = QVBoxLayout(self.page)
        self.verticalLayout2.setObjectName(u"verticalLayout2")
        self.education_textbox = QTextBrowser(self.page)
        self.education_textbox.setObjectName(u"education_textbox")
        self.verticalLayout2.addWidget(self.education_textbox)

        self.education_textbox.setOpenLinks(False)

        self.stackedWidget.addWidget(self.page)
        self.verticalLayout.addWidget(self.stackedWidget)

        MainWindow.setCentralWidget(self.centralwidget)

        self.stackedWidget.setCurrentIndex(0)

And here is the utility script to resolve file paths, PathResolver.py:
import os
import sys

def resolve_path(path: str) -> str:
    if getattr(sys, "frozen", False):
        # If the 'frozen' flag is set, we are in bundled-app mode!
        resolved_path = os.path.abspath(os.path.join(sys._MEIPASS, path))
    else:
        # Normal development mode. Use os.getcwd() or __file__ as appropriate in your case...
        resolved_path = os.path.abspath(os.path.join(os.getcwd(), path))

    return resolved_path

A: The .setSource() method accepts a QUrl as its first parameter.

void QTextBrowser::setSource(const QUrl &url, QTextDocument::ResourceType type = QTextDocument::UnknownResource)
Attempts to load the document at the given url with the specified type.

While it's accepting the string, this is being interpreted as an Url. This is likely fine on non-Windows platforms, since the path separators are correct.
To make it work cross-platform you should first create a QUrl object from the local file path, and pass that to setSource, i.e.
from PySide6.QtCore import QUrl

url = QUrl.fromLocalFile(path)
self.education_textbox.setSource(url)

Adding this step, the file loads correctly.


text:
Q: RDS Webpage Display Delays I have built a Windows Server 2012 with RDS for testing purposes.
When logged on as any user (Administrator or standard user), opening multiple Internet Explorer (or even Firefox) pages experience a very long delay in loading. What I mean with that is I open another tab (with a webpage link), and there a multiple second delay in the Internet Explorer program "hanging". After that time, it loads correctly.
All other programs on the server operate fine (Word, Excel, Outloook, etc), it is just in web browser programs.
Any help would be greatly appreciated.

A: I have found the issue - it was a strange one that I should have thought of much sooner...
I was testing some Wyse TCX software and after removing it - everything came good...


text:
Q: Custom directive not firing up I have a directive that makes some value prices validation, and I thought that it was working well, until I notice a bug, for example if the next value price I'm validating in the input is the same of the previous one, the next one is not validated, I don't understand why, if it was different value it worked with no issues, but if the value is the same of the previous, the directive is not fired up, I have no idea if there is any relation with the '$asyncValidators', above I leave my custom directive.
Directive:
(function() {
  'use strict';

  angular
    .module('myApp')
    .directive('priceValidator', priceValidator);

  priceValidator.$inject = ['$q', 'ServerValidatorService'];

  /* @ngInject */
  function priceValidator($q, ServerValidatorService) {
    var directive = {
      link: link,
      restrict: 'A',
      require: 'ngModel',
      scope: {
        costPrice: '=',
        currentPvp: '='
      }
    };
    return directive;

    function link(scope, element, attrs, ctrl) {
      ctrl.$asyncValidators.costPrice = function(costPrice) {
        var pvp = scope.currentPvp;

        scope.currentPrice = costPrice;

        var cost = String(costPrice).replace(",", ".");

        return ServerValidatorService.validateCostPrice(pvp, cost)
          .then(function() {
              return true;
            },
            function(response) {
              ctrl.$setDirty();
              if (response.data.errors.maximum[0])
                scope.costPrice = response.data.errors.maximum[0];
              return $q.reject(response.data.message);
            });
      };
    }
  }
})();

// Controller function that fill form with each product info:

function getMainProduct(productLine) {

  if (typeof productLine !== "undefined") {

    vm.discountId = productLine.discount_id;
    vm.discountPercentage = productLine.discount_percentage;
    vm.valuePrice = productLine.value_price;

  }

}

HTML
<input type="text" class="form-control"
name="discount" ng-model="form.discPrice"
ng-model-options="{updateOn: 'default blur', debounce: {'default': 300, 'blur': 0} }"
ng-required="formCtrl.isP()" cost-price="form.maxP"
current-pvp="form.pvp" num-type="decimal"
ng-change="formCtrl.check()" price-validator>


text:
Q: pandas multiIndex.from_product and append a column? I have the following:
input df -
fruit  uniqueid
apple   1123
appless 321
banana  623
mango   739
mangos  889

code -
df.loc[:,'fruit_copy'] = df['fruit']
## comparing values from one column to each other
compare = pd.MultiIndex.from_product([df['fruit'],df['fruit_copy']]).to_series()

def metrics(tup):
    return pd.Series([fuzz.ratio(*tup),
                      fuzz.token_sort_ratio(*tup)],
                     ['ratio', 'token'])

compare = compare.apply(metrics)
## only keep higher matches
compare_80 = compare[(compare['ratio'] >=80) & (compare['token'] >=80)]

current output -
                ratio   token
apple   apple   100     100
        appless 83      83
appless apple   83      83
        appless 100     100
banana  banana  100     100
mango   mango   100     100
        mangos  91      91
mangos  mango   91      91
        mangos  100     100

expected outcome first goal -
        index1  index2          ratio token uniqueid
        apple   1123   apple    100   100   1123
                       appless  83    83    321
        appless 321    apple    83    83    1123
                       appless  100   100   321
        banana  623    banana   100   100   632
        mango   739    mango    100   100   739
                       mangos   91    91    889
        mangos  889    mango    91    91    739
                       mangos   100   100   889

expected outcome second goal -
        index1  index2          ratio token uniqueid
        apple   1123   appless  83    83    321
        mango   739    mangos   91    91    889

Can I achieve this by appending the uniqueid to the multivalue index?

A: You can try doing this with a cross merge and applying a fuzz ratio later:
s = df['fruit'].str[:2] #if you know how many start char should atleast match(assume 2)

u = df.assign(k=1,s=s).merge(df.drop('uniqueid',1).assign(k=1,s=s)
    ,on=['k','s'],suffixes=('','_y')).drop(['k','s'],1)

u = u[u['fruit'].ne(u['fruit_y'])].copy() #removing same combinations

u = (u.assign(Ratio=[fuzz.ratio(*i) for i in zip(u['fruit'],u['fruit_y'])])
       .sort_values('Ratio',ascending=False).drop_duplicates('fruit')).sort_index()

out = (u[pd.DataFrame(np.sort(u[['fruit','fruit_y']],axis=1),index=u.index)
      .duplicated(keep='last')])

print(out)

   fruit  uniqueid  fruit_y  Ratio
1  apple      1123  appless     83
6  mango       739   mangos     91


text:
Q: Why mysql_secure_installation isn't working? I tried to find answers but none of them is working. I installed mariadb on centos7 Linux. Then I try to run mysql_secure_installation and received error: command not found. The problem is that I already did it one time and it worked and I tried to do it few days later it isn't working. What should I do?

A: Try:
mariadb-secure-installation


text:
Q: Toad for Oracle- Reshape Wide to Long I am trying to transpose a data set from wide to long.  Ive done this is SAS but am new to this. Ideally I want one unique row per ID and code.  Not sure if it can be done in one step or multiple, either way would be fine with me.  My data looks something like this.
ID   code1   code2   code3
1     abc     def     ghi
1     abc     xyz     def
2     zyx     abc     mno

AND I want it to look like
ID  Code_concat
1   abc
1   def
1   ghi
1   xyz
2   zyx
2   abc
2   mno

Any advice would be greatly appreciated, thanks!

A: The simplest method given that you want to remove duplicates is union:
select id, code1 as code_concat from t union
select id, code2 as code_concat from t union
select id, code3 as code_concat from t;


text:
Q: realloc a struct pointer inner struct pointer in c context: https://stackoverflow.com/a/34528438/15603477
The original post left some realloc code unfinished in read_solidfunction, inside if(strcmp("endfacet", line) == 0) {}. trying to finish this part. but failed.
Almost the same as original post code.
Problem:
In if((*sol)->nfacets == (*sol)->maxfacets) {} code block, I need realloc a struct inner struct.
if I set FACETS = 3 then a single solid struct pointer can only hold 3 facet pointer. Now I want to resize/reallocated to make it can hold more facets pointers.
/*
https://stackoverflow.com/questions/34522831/scanf-stops-working-abruptly/34528438#34528438
gcc \
-Wpointer-arith  -Werror=vla -Wendif-labels \
-Wimplicit-fallthrough -Wmissing-format-attribute  \
-Wcast-function-type -Wshadow=compatible-local \
-Wformat-security -Wno-format-truncation -Wno-stringop-truncation \
array_struct96.c  &&./a.out dat/solid.txt
valgrind ./a.out  dat/solid.txt

*/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>
#include<errno.h>
#include<math.h>
/* constants - num dimensions, initial facets
 * allocated within each solid, and the max
 * chars per-line for fgets to read
 */
enum{NDIM = 3, FACETS = 3, MAXC= 256};
/* facets struct - declared as pointer member of
 * struct solid allowing additional allocation to
 * hold as many normal/vertexes as required.
 */
typedef struct facet{
    double normal[NDIM];
    double vertex[NDIM][NDIM];
}facet;

/* struct solid holds the solid's name,
 * a pointer to an array of stuct facet,
 * the number of facets containing data, and
 * the maximum presently allocated.
 */
typedef struct solid{
    char *name;
    facet *facets;
    size_t nfacets;
    size_t maxfacets;
}solid;
/* function prototypes */
solid *create_solid();
solid *read_solid(solid **sol, FILE *fp);
void print_solid(solid *sol);
void free_solid(solid *sol);
double xstrtod(char *str, char **ep);

/* simple allocate/initialize function
 * return must be assigned to pointer
 */
solid *create_solid()
{
    size_t i;
    solid *sol = calloc(1,sizeof *sol);
    sol->facets = calloc(FACETS, sizeof *(sol->facets));
    sol->nfacets = 0;
    sol->maxfacets = FACETS;
    for(i = 0; i < FACETS; i++){
        memset((sol->facets)[i].normal, 0,NDIM * sizeof(double));
        memset((sol->facets)[i].vertex, 0,NDIM * NDIM * sizeof(double));
    }
    return sol;
}

/*  simple print of normals & vertexes to stdout    */
void print_solid(solid *sol)
{
    if(!sol){
        fprintf(stderr,"printf_solid() error: invalid parameter 'sol'.\n");
        return;
    }
    size_t i,j;
    printf("Normal and vertexes for solid: %s\n", sol->name);
    printf("Total size of faces=%ld\n", sol->nfacets);

    for(i = 0; i < 5; i++){
        printf("record %ld: ", i+1);
        printf(
            "\nnormal[%3zu]:%10.4f\t%10.4f\t%10.4f\n",i
            ,sol->facets[i].normal[0]
            ,sol->facets[i].normal[1]
            ,sol->facets[i].normal[2]
        );
        for(j = 0; j < NDIM; j++)
            printf("vertex[%3zu]:%10.4f\t%10.4f\t%10.4f\n"
                ,j
                ,sol->facets[i].vertex[j][0]
                ,sol->facets[i].vertex[j][1]
                ,sol->facets[i].vertex[j][2]
            );
    }
}

void free_solid(solid *sol)
{
    if(sol->name) free(sol->name);
    if(sol->facets) free(sol->facets);
    if(sol) free(sol);
}

/* string to double with error checking. */
double xstrtod(char *str, char **ep)
{
    errno = 0;
    double val = strtod(str,ep);
    /* Check for various possible errors */
    if((errno == ERANGE  && (val == HUGE_VAL || val == HUGE_VALL)) ||
        (errno != 0 && val == 0)){
            perror("strtod");
            exit(EXIT_FAILURE);
    }
    if(ep && *ep == str){
        fprintf(stderr,"No double were found.\n");
        exit(EXIT_FAILURE);
    }
    return val;
}

int main (int argc, char **argv) {
    solid *sol = NULL;  /* pointer to hold values */
    FILE *fp = argc > 1 ? fopen (argv[1], "r") : stdin;

    if (!fp) {  /* validate file open */
        fprintf (stderr, "error: file open failed '%s'\n", argv[1]);
        return 1;
    }

    if (read_solid (&sol, fp)) {    /* read data from file  */
        print_solid (sol);          /* print data read      */
        free_solid (sol);           /* free all memory      */
    }
    if (fp != stdin) fclose (fp);   /* close if not stdin   */

    return 0;
}

/* read_solid takes the poiner address for a struct solid,
 * and will read all normal and vertexes into the struct,
 * updating 'nfacets' with the number of facets for which
 * there is data, and will validate each read and conversion
 * of values from string to double. retuns filled struct on
 * success, NULL otherwise
 */
solid *read_solid(solid **sol, FILE *fp)
{
    char line[MAXC] = {0};  /*  temporary line buffer */
    size_t idx = 0, vidx = 0;   /* line & vertex indexes */
    if(!*sol) *sol = create_solid();     /* allocate & initialize struct */

    while(fgets(line,MAXC,fp))   /* read each line in file */
    {
        size_t len = 0;
        char *p, *ep;
        p = ep = line;
        len = strlen(line);  /* get length & remove '\n' */
        if(line[len - 1] == '\n')
            line[--len] = 0;

        if(!(ep = strchr(line,' ')))    /* test if space in line */
        {   /* if endfacet, update nfacets */
            if(strcmp("endfacet", line) == 0)
            {
                (*sol)->nfacets++;
                if((*sol)->nfacets == (*sol)->maxfacets)
                {
                    fprintf(stderr,"read_solid() warning: limit readed\n");
                    printf("(*sol)->nfacets=%ld\n", (*sol)->nfacets);
                    // sol->facets = calloc(FACETS, sizeof *(sol->facets));
                    printf("2 * ((*sol)->maxfacets:%ld\n",2 * (*sol)->maxfacets);

                    void *tmp = realloc ( (*sol)->facets, 2 * ( (*sol)->maxfacets ) * sizeof *(*sol)->facets);
                        if (!tmp) { /* if realloc fails, original pointer still valid */
                            perror ("realloc-sales");   /* throw error */
                            return (*sol);              /* return current pointer      */
                        }                               /* (don't exit or return NULL) */
                        (*sol)->facets = tmp;    /* assign reallocated block to (*sol)->facets  */
                        /* (optional) zero newly allocated memory */
                        // memset ((*sol)->facets + (*sol)->nfacets, 0, ((*sol)->maxfacets) * sizeof *((*sol)->facets));
                    (*sol)->maxfacets *= 2;  /* update (*sol)->maxfacets to new size */
                    printf("this part do called\n");
                    break;
                }
            }
            goto processed;
        }
        if(strncmp("solid",line,ep - p) == 0)
        {
            (*sol)->name = strdup(ep + 1);
            goto processed;
        }else if(strncmp("facet",line, ep - p) == 0)
        {
            size_t i;
            while(*ep &&(*ep < '0' || *ep > '9')) ep++; /* skip no digit value */
            if(!*ep){
                fprintf(stderr,"read_solid() error: facet normal no values\n");
                return NULL;
            }
            p = ep;
            for(i = 0; i < NDIM; i++){   /* convert to double & validate */
                /* for which sol index.
                for a specific index of sol
                then assign double to normal.*/
                (*sol)->facets[(*sol)->nfacets].normal[i] = xstrtod(p,&ep);
                p = ep;
            }
            goto processed;
        }else if(strncmp("vertex", line, ep - p) == 0)
        { /* read vertex values */
            size_t i;
            p = ep + 1;
            for(i = 0; i< NDIM; i++){/* convert to double & validate */
                (*sol)->facets[(*sol)->nfacets].vertex[vidx][i] = xstrtod(p,&ep);
                p = ep;
            }
            vidx = vidx < 2 ? vidx + 1 : 0; /* update/reset vertex index */
            goto processed;
        }else if(strncmp("outer",line,ep - p) == 0){ /* skip line begin with outer*/
            goto processed;
        }else if(strncmp("endsolid",line, ep - p) == 0){ /* skip line begin with endsolid*/
            goto processed;
        }else{
            fprintf(stderr,"read_solid() warning: invalid line at '%3zu'\n",idx);
        }
    processed:
        idx++;
    }

    if(!(*sol)->nfacets){
        fprintf(stderr,"read_solid() error: no data read.\n");
        free_solid(*sol);
        return NULL;
    }
    printf("idx=%ld\n", idx);
    return *sol;
}

In print_sold function. for(i = 0; i < 5; i++) 0,1,2 is ok. but 3,4 print
record 4:
normal[  3]:    0.0000      0.0000          0.0000
vertex[  0]:    0.0000      0.0000          0.0000
vertex[  1]:    0.0000      0.0000          0.0000
vertex[  2]:    0.0000      0.0000          0.0000
record 5:
normal[  4]:    0.0000      0.0000          0.0000
vertex[  0]:    0.0000      0.0000          0.0000
vertex[  1]:    0.0000      0.0000          0.0000
vertex[  2]:    0.0000      0.0000          0.0000

I modified dat/solid.txt file, so all print should be no zero value. Which mean the realloc part failed.

A: Here is some heavily amended code that works without any obvious memory faults.
It has several major modifications, and umpteen minor ones (not all of which will be mentioned here):

*

*Using a for loop instead of a while loop in read_solid(), which gets rid of the processed label.

*Using multiple subfunctions to make it easier to read the body of the processing loop.

*Since the xstrtod() function exits on error (in your code and this code), I've made the code "fail fast" in other places too.

*The code reading the 'normal' data no longer skips over '+' or '-' signs.

*The function directive() splits the line, isolating the directive from the data after it.  This makes it easier to write the list of comparisons, and the code can use strcmp() instead of strncmp().

*There's a fairly simple if / else if / … / else chain in the loop, mostly just calling functions that do a task.

*I renamed the structure types with an initial capital (Facet, Solid).

*The read_solid() function is passed a pre-allocated Solid structure, which simplifies the code.

*Because the reading loop breaks when it encounters the endsolid line, it is possible for it to read multiple solids from a single file.

Code:
/* SO 7456-2825 */
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

enum { NDIM = 3, FACETS = 3, MAXC = 256 };

typedef struct Facet
{
    double normal[NDIM];
    double vertex[NDIM][NDIM];
} Facet;

typedef struct Solid
{
    char *name;
    Facet *facets;
    size_t nfacets;
    size_t maxfacets;
} Solid;

static Solid *create_solid(void);
static int read_solid(Solid *sol, FILE *fp);
static void print_solid(Solid *sol);
static void free_solid(Solid *sol);
static double xstrtod(char *str, char **ep);

static Solid *create_solid(void)
{
    Solid *sol;
    if ((sol = calloc(1, sizeof(*sol))) == NULL ||
        (sol->facets = calloc(FACETS, sizeof(sol->facets[0]))) == NULL)
    {
        free(sol);
        return NULL;
    }
    sol->nfacets = 0;
    sol->maxfacets = FACETS;
    return sol;
}

static void print_solid(Solid *sol)
{
    if (!sol)
    {
        fprintf(stderr, "%s error: invalid parameter\n", __func__);
        return;
    }

    printf("Normal and vertexes for solid: %s\n", sol->name);
    printf("Total size of faces=%zu\n", sol->nfacets);

    for (size_t i = 0; i < sol->nfacets; i++)
    {
        printf("Facet %zu: ", i + 1);
        printf(
            "\nNormal[%3zu]:%10.4f\t%10.4f\t%10.4f\n", i,
            sol->facets[i].normal[0],
            sol->facets[i].normal[1],
            sol->facets[i].normal[2]
            );
        for (size_t j = 0; j < NDIM; j++)
        {
            printf("Vertex[%3zu]:%10.4f\t%10.4f\t%10.4f\n",
                   j,
                   sol->facets[i].vertex[j][0],
                   sol->facets[i].vertex[j][1],
                   sol->facets[i].vertex[j][2]
                   );
        }
    }
}

static void free_solid(Solid *sol)
{
    if (sol)
    {
        free(sol->name);
        free(sol->facets);
        free(sol);
    }
}

static double xstrtod(char *str, char **ep)
{
    errno = 0;
    double val = strtod(str, ep);

    if ((errno == ERANGE  && (val == HUGE_VAL || val == HUGE_VALL)) ||
        (errno != 0 && val == 0))
    {
        perror("strtod");
        exit(EXIT_FAILURE);
    }
    if (ep && *ep == str)
    {
        fprintf(stderr, "No double were found.\n");
        exit(EXIT_FAILURE);
    }
    return val;
}

/* exits on failure */
static void more_facets(Solid *sol)
{
    fprintf(stderr, "%s() warning: limit reached (sol->nfacets = %zu)\n",
            __func__, sol->nfacets);

    size_t new_facets = 2 * sol->maxfacets;
    printf("new_facets = %zu\n", new_facets);

    void *tmp = realloc(sol->facets, new_facets * sizeof(sol->facets[0]));
    if (tmp == NULL)
    {
        perror(__func__);
        exit(EXIT_FAILURE);
    }
    sol->facets = tmp;
    sol->maxfacets = new_facets;
}

static void read_name(Solid *sol, char *name)
{
    sol->name = strdup(name);
    if (sol->name == NULL)
    {
        perror(__func__);
        exit(EXIT_FAILURE);
    }
}

static void read_normal(Facet *fp, char *ep)
{
    while (*ep && !isdigit((unsigned char)*ep) && *ep != '+' && *ep != '-')
        ep++;
    if (!*ep)
    {
        fprintf(stderr, "%s(): error: facet normal no values\n", __func__);
        return;
    }
    for (size_t i = 0; i < NDIM; i++)
    {
        char *p = ep;
        fp->normal[i] = xstrtod(p, &ep);
    }
}

static void read_vertex(Facet *facet, char *ep, size_t vidx)
{
    assert(vidx < NDIM);
    char *p = ep;
    for (size_t i = 0; i < NDIM; i++)
    {
        facet->vertex[vidx][i] = xstrtod(p, &ep);
        p = ep;
    }
}

/* Isolate directive into null-terminated string */
/* Return pointer to data after blank after directive, or null byte */
static char *directive(char *line)
{
    char *ep = strchr(line, ' ');
    if (ep != NULL)
        *ep++ = '\0';
    else
        ep += strlen(line);
    return ep;
}

/*
** Note that the scanning does not enforce the correct sequencing of
** facet, outer, vertex, vertex, vertex, endloop, endfacet
** There are other infelicities that are not detected.
*/
static int read_solid(Solid *sol, FILE *fp)
{
    char line[MAXC];
    size_t vidx = 0;

    for (size_t lineno = 0; fgets(line, sizeof(line), fp) != NULL; lineno++)
    {
        line[strcspn(line, "\n")] = '\0';
        char *ep = directive(line);

        if (strcmp("endfacet", line) == 0)
            continue;
        else if (strcmp("endloop", line) == 0)
            continue;
        else if (strcmp("outer", line) == 0)
            vidx = 0;
        else if (strcmp("endsolid", line) == 0)
            break;
        else if (strcmp("solid", line) == 0)
            read_name(sol, ep);
        else if (strcmp("facet", line) == 0)
        {
            assert(sol->nfacets <= sol->maxfacets);
            if (sol->nfacets == sol->maxfacets)
                more_facets(sol);
            read_normal(&sol->facets[sol->nfacets++], ep);
        }
        else if (strcmp("vertex", line) == 0)
            read_vertex(&sol->facets[sol->nfacets - 1], ep, vidx++);
        else
        {
            fprintf(stderr, "%s() warning: invalid directive '%s' at '%3zu' ignored\n",
                    __func__, line, lineno);
        }
    }

    if (!sol->nfacets)
    {
        fprintf(stderr, "read_solid() error: no data read.\n");
        free_solid(sol);
        return -1;
    }
    printf("idx=%zu\n", sol->nfacets);
    return 0;
}

int main(int argc, char **argv)
{
    FILE *fp = argc > 1 ? fopen(argv[1], "r") : stdin;

    if (fp == NULL)
    {
        fprintf(stderr, "%s: error: file open failed '%s'\n", argv[0], argv[1]);
        return 1;
    }

    Solid *sol = create_solid();
    if (sol == NULL)
    {
        fprintf(stderr, "%s: error: failed to create solid\n", argv[0]);
    }

    if (read_solid(sol, fp) == 0)
    {
        print_solid(sol);
        free_solid(sol);
    }
    if (fp != stdin)
        fclose(fp);

    return 0;
}

When run on the full-size (24-facet) data file from the prior question, it produces the output:
more_facets() warning: limit reached (sol->nfacets = 3)
more_facets() warning: limit reached (sol->nfacets = 6)
more_facets() warning: limit reached (sol->nfacets = 12)
new_facets = 6
new_facets = 12
new_facets = 24
idx=24
Normal and vertexes for solid: Untitled-56807ca1
Total size of faces=24
Facet 1:
Normal[  0]:    0.0000      0.0000     -1.0000
Vertex[  0]:  100.0000     50.0000      0.0000
Vertex[  1]:    0.0000      0.0000      0.0000
Vertex[  2]:    0.0000     50.0000      0.0000
Facet 2:
Normal[  1]:    0.0000      0.0000     -1.0000
Vertex[  0]:    0.0000      0.0000      0.0000
Vertex[  1]:  100.0000     50.0000      0.0000
Vertex[  2]:  100.0000      0.0000      0.0000
Facet 3:
Normal[  2]:   -1.0000      0.0000      0.0000
Vertex[  0]:    0.0000     50.0000     67.8050
Vertex[  1]:    0.0000      0.0000      0.0000
Vertex[  2]:    0.0000      0.0000     67.8050
Facet 4:
Normal[  3]:   -1.0000      0.0000      0.0000
Vertex[  0]:    0.0000      0.0000      0.0000
Vertex[  1]:    0.0000     50.0000     67.8050
Vertex[  2]:    0.0000     50.0000      0.0000
Facet 5:
Normal[  4]:   -0.0000      1.0000      0.0000
Vertex[  0]:    0.0000     50.0000     67.8050
Vertex[  1]:  100.0000     50.0000      0.0000
Vertex[  2]:    0.0000     50.0000      0.0000
Facet 6:
Normal[  5]:   -0.0000      1.0000      0.0000
Vertex[  0]:  100.0000     50.0000      0.0000
Vertex[  1]:    0.0000     50.0000     67.8050
Vertex[  2]:  100.0000     50.0000     67.8050
Facet 7:
Normal[  6]:    1.0000      0.0000      0.0000
Vertex[  0]:  100.0000     50.0000      0.0000
Vertex[  1]:  100.0000      0.0000     67.8050
Vertex[  2]:  100.0000      0.0000      0.0000
Facet 8:
Normal[  7]:    1.0000      0.0000      0.0000
Vertex[  0]:  100.0000      0.0000     67.8050
Vertex[  1]:  100.0000     50.0000      0.0000
Vertex[  2]:  100.0000     50.0000     67.8050
Facet 9:
Normal[  8]:   -0.0000     -1.0000     -0.0000
Vertex[  0]:  100.0000      0.0000     67.8050
Vertex[  1]:    0.0000      0.0000      0.0000
Vertex[  2]:  100.0000      0.0000      0.0000
Facet 10:
Normal[  9]:   -0.0000     -1.0000     -0.0000
Vertex[  0]:    0.0000      0.0000      0.0000
Vertex[  1]:  100.0000      0.0000     67.8050
Vertex[  2]:    0.0000      0.0000     67.8050
Facet 11:
Normal[ 10]:    0.8394      0.0000      0.5436
Vertex[  0]:  100.0000     50.0000     67.8050
Vertex[  1]:   69.0000     15.5000    115.6740
Vertex[  2]:  100.0000      0.0000     67.8050
Facet 12:
Normal[ 11]:    0.8394      0.0000      0.5436
Vertex[  0]:   69.0000     15.5000    115.6740
Vertex[  1]:  100.0000     50.0000     67.8050
Vertex[  2]:   69.0000     34.5000    115.6740
Facet 13:
Normal[ 12]:   -0.8394     -0.0000      0.5436
Vertex[  0]:   31.0000     15.5000    115.6740
Vertex[  1]:    0.0000     50.0000     67.8050
Vertex[  2]:    0.0000      0.0000     67.8050
Facet 14:
Normal[ 13]:   -0.8394     -0.0000      0.5436
Vertex[  0]:    0.0000     50.0000     67.8050
Vertex[  1]:   31.0000     15.5000    115.6740
Vertex[  2]:   31.0000     34.5000    115.6740
Facet 15:
Normal[ 14]:   -0.0000     -0.9514      0.3081
Vertex[  0]:   69.0000     15.5000    115.6740
Vertex[  1]:    0.0000      0.0000     67.8050
Vertex[  2]:  100.0000      0.0000     67.8050
Facet 16:
Normal[ 15]:   -0.0000     -0.9514      0.3081
Vertex[  0]:    0.0000      0.0000     67.8050
Vertex[  1]:   69.0000     15.5000    115.6740
Vertex[  2]:   31.0000     15.5000    115.6740
Facet 17:
Normal[ 16]:    0.0000      0.9514      0.3081
Vertex[  0]:   31.0000     34.5000    115.6740
Vertex[  1]:  100.0000     50.0000     67.8050
Vertex[  2]:    0.0000     50.0000     67.8050
Facet 18:
Normal[ 17]:    0.0000      0.9514      0.3081
Vertex[  0]:  100.0000     50.0000     67.8050
Vertex[  1]:   31.0000     34.5000    115.6740
Vertex[  2]:   69.0000     34.5000    115.6740
Facet 19:
Normal[ 18]:    0.0000     -0.8820      0.4713
Vertex[  0]:   50.0000     25.0000    133.4520
Vertex[  1]:   31.0000     15.5000    115.6740
Vertex[  2]:   69.0000     15.5000    115.6740
Facet 20:
Normal[ 19]:    0.6832      0.0000      0.7302
Vertex[  0]:   69.0000     34.5000    115.6740
Vertex[  1]:   50.0000     25.0000    133.4520
Vertex[  2]:   69.0000     15.5000    115.6740
Facet 21:
Normal[ 20]:   -0.6832      0.0000      0.7302
Vertex[  0]:   50.0000     25.0000    133.4520
Vertex[  1]:   31.0000     34.5000    115.6740
Vertex[  2]:   31.0000     15.5000    115.6740
Facet 22:
Normal[ 21]:   -0.0000     -0.0000      1.0000
Vertex[  0]:   69.0000     15.5000    115.6740
Vertex[  1]:   31.0000     34.5000    115.6740
Vertex[  2]:   31.0000     15.5000    115.6740
Facet 23:
Normal[ 22]:   -0.0000     -0.0000      1.0000
Vertex[  0]:   31.0000     34.5000    115.6740
Vertex[  1]:   69.0000     15.5000    115.6740
Vertex[  2]:   69.0000     34.5000    115.6740
Facet 24:
Normal[ 23]:   -0.0000      0.8820      0.4713
Vertex[  0]:   50.0000     25.0000    133.4520
Vertex[  1]:   69.0000     34.5000    115.6740
Vertex[  2]:   31.0000     34.5000    115.6740

I think that the break you have in the code after allocating more facets was the main cause of your trouble.
If I were working on it further, I'd have a code structure that insisted on the correct sequencing.  With the functions in place, it is fairly easy to see how to do this.  This would eliminate the vidx in the main loop, which is still pretty ugly.  I'd also consider making a structure type for the 3 numbers (struct Point { double x; double y; double z; }; or struct Point { double value[3]; }; or similar, and using that in the Facet structure.  It would simplify the argument handling.


text:
Q: rvalue references and constructor arguments Lets consider a simple class
template< typename T >
class Wrapper {
public:
  // Constructors?
private:
  T wrapped;
};

What constructors should it use to be effective?

Before C++0x there would be a constructor that takes either:

*

*const reference (T const&) - if type T is "heavy",

*or value (T) - if type T is "light".

Determining whether type T is "heavy" or "light" is not easy.
One could assume only build-in types (ints/floats/...) are "light". But that is not fully correct since our own Wrapper<int> most likely should be considered a "light" type as well.
Libraries like boost::call_traits provide some means to overcome this difficulty by allowing type creator to mark the type as "light" (by providing proper call_traits specialization). Otherwise it will be treated as "heavy". Seems acceptable.

But C++0x makes it worse. Because now you have also rvalue reference (T&&) which allows to efficiently take (some) "heavy" objects.
And because of this now you have to chose among:

*

*just const reference (T const&) - if type T is "heavy" and does not support move semantics (because either there is none - like with large PODs - or none was written and you have no influence on that),

*both const reference (T const&) and rvalue reference (T&&) - if type T is "heavy" and does support move semantics,

*just value (T) - if type T is "light" or if it is "heavy" but supports move semantics (even if copy is made it doesn't bother use since otherwise we would have to copy from T const& ourselves anyway...).

Still its not easy to tell which types are "heavy" and which are "light" (as previously). But now you are also unable to tell whether type T supports move semantics or not (or are you?).

This becomes even more annoying once you wrap more than one value since number of possible constructor overloads grows exponentially.
Is there any solution to that problem?
I though about some template constructors for forwarding (perfect forwarding) arguments but I wasn't sure whether that would work as desired. And also it would allow to provide values of different type that would be just forwarded to T constructor. This might be considered a feature but does not have to.

A: On the contrary, C++11 makes it easier thanks to universal references:
template <typename T> struct Wrapper
{
    T value;

    template <typename U> Wrapper(U && u)
    : value(std::forward<U>(u))
    {  }
};

As an extra nice touch, you should add a defaulted second argument that only exists when T is constructible from U, so as to not make your class itself appear constructible from unmatching types. And make it variadic, too:
template <typename ...Args>
Wrapper(Args &&... args,
        typename std::enable_if<std::is_constructible<T, Args...>::value, int>::type = 0)
: value(std::forward<Args>(args)...)
{  }

Make sure to #include <utility> for forward and #include <type_traits> for the traits.

A: If you are going to copy your T anyway, it might be better to pass the parameter by value and let the compiler figure out the copying. Whatever you do, there is going to be at least one copy anyway.
template< typename T >
class Wrapper {
public:
  Wrapper(T value) : wrapped(std::move(value))
  { }
private:
  T wrapped;
};

See Want speed? Pass by value by Dave Abrahams.


text:
Q: What are vector norms used for? I'm currently working with a computer science problem that requires me to build vectors that can return their own norms. Based on Wolfram Alpha's description, I think I have an idea of how this is accomplished for the simple $L^2$ norm ($\sqrt{a^2+b^2+c^2}$, and so on) required by the exercise, but I've no notion of what this is actually useful for or why I would want to find it, outside of it being required by the exercise.
Any insight is appreciated!

A: Norms are a measure of distance. One has different ways to define what is the distance between points in multiple dimensions, which collapse to the usual notion of the absolute value in 1D.
in particular, Euclidean distance is defined by the 2-norm,
$$
\left\| \begin{pmatrix} x_1 \\ \vdots \\ x_k \end{pmatrix} \right\|_2
 = \sqrt{\sum_{i=1}^k x_i^2}
$$
There are others, of which the 1-norm
$$
\left\| \begin{pmatrix} x_1 \\ \vdots \\ x_k \end{pmatrix} \right\|_1
 = \sum_{i=1}^k \left|x_i\right|
$$
and the infinity norm
$$
\left\| \begin{pmatrix} x_1 \\ \vdots \\ x_k \end{pmatrix} \right\|_\infty
 = \max_{1 \le i \le k} \left\{|x_i|\right\}
$$
are the most useful.
You are welcome to read up more on Wikipedia, lecture notes.


text:
Q: Calculate $\lim_{n\rightarrow +\infty}$$\sum_{k=1}^{n}\frac{I_{k+1}}{k}$ Calculate $\lim_{n\rightarrow +\infty}$$\sum_{k=1}^{n}\frac{I_{k+1}}{k}$ with I$_{n}$ = $\int_{0}^{1}x^{n}e^{x}dx$ .
Any help or other methods. Thank you in advance.

A: $\newcommand{\+}{^{\dagger}}
 \newcommand{\angles}[1]{\left\langle #1 \right\rangle}
 \newcommand{\braces}[1]{\left\lbrace #1 \right\rbrace}
 \newcommand{\bracks}[1]{\left\lbrack #1 \right\rbrack}
 \newcommand{\ceil}[1]{\,\left\lceil #1 \right\rceil\,}
 \newcommand{\dd}{{\rm d}}
 \newcommand{\down}{\downarrow}
 \newcommand{\ds}[1]{\displaystyle{#1}}
 \newcommand{\equalby}[1]{{#1 \atop {= \atop \vphantom{\huge A}}}}
 \newcommand{\expo}[1]{\,{\rm e}^{#1}\,}
 \newcommand{\fermi}{\,{\rm f}}
 \newcommand{\floor}[1]{\,\left\lfloor #1 \right\rfloor\,}
 \newcommand{\half}{{1 \over 2}}
 \newcommand{\ic}{{\rm i}}
 \newcommand{\iff}{\Longleftrightarrow}
 \newcommand{\imp}{\Longrightarrow}
 \newcommand{\isdiv}{\,\left.\right\vert\,}
 \newcommand{\ket}[1]{\left\vert #1\right\rangle}
 \newcommand{\ol}[1]{\overline{#1}}
 \newcommand{\pars}[1]{\left( #1 \right)}
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\pp}{{\cal P}}
 \newcommand{\root}[2][]{\,\sqrt[#1]{\vphantom{\large A}\,#2\,}\,}
 \newcommand{\sech}{\,{\rm sech}}
 \newcommand{\sgn}{\,{\rm sgn}}
 \newcommand{\totald}[3][]{\frac{{\rm d}^{#1} #2}{{\rm d} #3^{#1}}}
 \newcommand{\ul}[1]{\underline{#1}}
 \newcommand{\verts}[1]{\left\vert\, #1 \,\right\vert}$
\begin{align}
\color{#00f}{\large\sum_{k = 1}^{\infty}{1 \over k}\,
\int_{0}^{1}x^{k + 1}\expo{x}\,\dd x}
&=\int_{0}^{1}\expo{x}\
\overbrace{\sum_{k = 1}^{\infty}{x^{k + 1} \over k}}^{-x\ln\pars{1 - x}}\
\,\dd x
=-\int_{0}^{1}x\ln\pars{1 - x}\expo{x}\,\dd x = \color{#00f}{\Large\expo{} - 1}
\end{align}

\begin{align}
&\color{#f00}{-\int_{0}^{1}x\ln\pars{1 - x}\expo{x}\,\dd x}=
-\int_{x = 0}^{x = 1}\ln\pars{1 - x}\,\dd\bracks{\expo{x}\pars{x - 1}}=
\int_{x = 0}^{x = 1}\expo{x}\pars{x - 1}\,{-1 \over 1 - x}\,\dd x
\\[3mm]&=\int_{0}^{1}\expo{x}\,\dd x = \color{#f00}{\expo{} - 1}
\end{align}

A: Interchanging the order of summation and integration (unproblematic, since everything is non-negative), we get
$$\sum_{k=1}^\infty \frac{I_{k+1}}{k} = \int_0^1 xe^x\sum_{k=1}^\infty \frac{x^k}{k}\,dx = -\int_0^1 xe^x\log (1-x)\,dx.$$
Now integrating by parts is feasible,
$$-\int_0^1 xe^x\log (1-x)\,dx = \left[(1-x)e^x\log(1-x)\right]_0^1 + \int_0^1 \frac{1-x}{1-x}e^x\,dx.$$


text:
Q: Which stackage snapshot does stack install use? Trying to run
stack install git-mediate

(per git-mediate's instructions)
I get an error message regarding dependent package versions:
Error: While constructing the build plan, the following exceptions were encountered:

In the dependencies for git-mediate-1.0.8:
    Diff-0.3.4 from stack configuration does not match >=0.4  (latest matching version is 0.4.0)
needed since git-mediate is a build target.

Some different approaches to resolving this:

  * Set 'allow-newer: true' in /Users/yairchu/.stack/config.yaml to ignore all version constraints and build anyway.

  * Recommended action: try adding the following to your extra-deps in /Users/yairchu/.stack/global-project/stack.yaml:

- Diff-0.4.0@sha256:b5cfbeed498f555a18774ffd549bbeff7a24bdfe5984154dcfc9f4328a3c2847,1275

Plan construction failed.

It's odd that the stack configuration has Diff-0.3.4, as currently both LTS and nightly stackage snapshots currently contain Diff-0.4.0 (lts-16.8 and nightly-2020-10-13).
What is this stack configuration thing and why is it pinned to old versions of libraries?

A: stack is implicitly using it's "global project" defined in ~/.stack/global-project/stack.yaml. To control the stackage snapshot being used this file can be edited (or just deleted to use the latest LTS)

A: stack install is an alias for stack build --copy-bins, so it's really just stack build plus the additional step of copying the built executables to ~/.local/bin.
So, the real question is "how does stack build decide what resolver to use?"  Well, if you provide it on the command line, it uses that one, as in:
stack install --resolver lts-16.18 git-mediate

If you don't give an explicit resolver, the default depends on where the build command is run.  If you run it inside a stack project, it'll default to the resolver specified in the project's stack.yaml file.  For example:
stack new --resolver lts-16.0 exampleproject  # create project with lts-16.0 resolver
cd exampleproject
stack build git-mediate   # this will build git-mediate using lts-16.0

If you build it outside of any project, then it uses the global project setting, which will be whatever resolver is set in ~/.stack/global-project/stack.yaml, as mentioned in the comments / other answer.
Note that the stack install alias will always copy the executable into the "global" ~/.local/bin, regardless of where it was built.  So, if you run stack install git-mediate in the exampleproject directory, as above, you'll get the version built with lts-16.0 as the globally installed version.
Soooo...  be careful where you run stack install!
Note that, with respect to git-mediate specfically, there was recently a buggy version published to Stackage, as documented here.  The error message is slightly different than the one you got, but the underlying problem might have been the same.  So, it's possible that just running stack update without having to modify the resolver setting would work to fix your build problem, if you haven't already fixed it.


text:
Q: APNS not working with Adhoc build I am using an application with Adhoc Provisioning profile and certificate. The application is not yet published. But the APNS is giving an error 8-Invalid Token
Following things are already checked.

*

*Application has the entitlement key <aps_environment>production<aps_environment>, checked from the mobile.embeddedprovision

*APNS SSL Certificate was generated by selecting an option Create Sandbox or Production SSL Certificate

*The certificate itself can connect to Production

*The APNS url used in Php script is
ssl://gateway.push.apple.com:2195

*All the old tokens from cleared from the db and the test was done with the new token
What else should I check I am really running out of ideas...
Could this happen because the Application is not published to the App Store?


text:
Q: calculating the volume using cylinderical coordinates. I have an example in my assignment which says that:

The cylinderical coordinates are just polar coordinates on $(x,y)$ -plane and the $z-$ coordinate.
    $$\phi(r,\theta,z)=(rcos\theta,rsin\theta,z)$$.To get one-one mapping we must have $r\gt 0$ and restrict $\theta$ to $(0,2\pi]$ .Also det$J_\phi(r,\theta,z)=r.$
  Thus if $S=\phi(U),then$
  $\int_U f(x,y,z)dx~dy~dz=\int_Sf(\phi(r,\theta,z))~r~dr~d\theta ~dz$.
Find the volume of region $U$ bounded by surfaces $(\frac{x^2+y^2}{a^2})^2+\frac{z}{b}=1$ ,$z=0$ where $a,b\gt 0$ .
solution :$\gamma(U)=\int_u1$ .Changing to cylindrical coordinates :
                     $$\gamma(U)=\int_{\phi(U)}r~dr~d\theta~ dz=\int_0^a \int_0^{2\pi}\int_0^{b(1-(r/a)^4)}dz~dr~d\theta=\frac {2}{3} \pi a^2b.$$

I can't understand where did $r$ disappear and how did we jump to $\int_0^a\int_0^{2\pi}\int_0^{b(1-(r/a)^4)}dz~dr~d\theta$ after $\int_{\phi(U)}r~dr~d\theta~ dz$

A: The missing $r$ is a mistake, probably a typo, but the final answer is correct.  The integral is also not written clearly in terms of the order of variables; I accept that there are different conventions, but here there is no consistency, so I suspect that is another typo.  It should be
$$\int_0^a \int_0^{2\pi}\int_0^{b(1-(r/a)^4)}r\,dz\,d\theta\,dr.$$
or
$$\int_0^{2\pi} \int_0^a\int_0^{b(1-(r/a)^4)}r\,dz\,dr\,d\theta.$$
The equation $\left(\frac{x^2+y^2}{a^2}\right)^2+\frac{z}{b}=1$ becomes $\left(\frac{r}{a}\right)^4+\frac{z}{b}=1$.  There is no dependence on $\theta$ in either of the bounding surfaces, which explains the limits of integration for $\theta$.  Rearranging the equation to $z=b(1-(r/a)^4)$ shows where the limits on $r$ and $z$ come from.  For each $r$ from $0$ to $a$, $z$ must be between $0$ and $b(1-(r/a)^4)$.


text:
Q: Solr: document boosting - can it be disabled at query time? If I've given a boost value for documents at index time, can I disable/ignore that boost value with a query parameter?
I have one type of query where I explicitly want to ignore the document boost value, but the rest should utilize it.

A: You can define multiple request handler with different boost and invoke the same depending upon the Query.
This handling needs to be done at client side before querying Solr.


text:
Q: iphone - UIButton with inner glow I want to create a rectangular rounded corner button with an inner glow.  I hear some recommendations about adding subviews, but i'm worried subviews will cover the text in my button.
How do I achieve inner glow without blocking out the text or background icon image?

A: Make an image of what you want, then import it into your project. Set the type of your button to custom, and then set the image to the glowing image you made.

A: You can do this(it's not exactly a glow on the button but on the label of the button). The effect is very similar.
First
#import <QuartzCore/QuartzCore.h>
and then
UIColor *color = button.currentTitleColor;
theButton.titleLabel.layer.shadowColor = [color CGColor];
theButton.titleLabel.layer.shadowRadius = 4.0f;
theButton.titleLabel.layer.shadowOpacity = .9;
theButton.titleLabel.layer.shadowOffset = CGSizeZero;
theButton.titleLabel.layer.masksToBounds = NO;


text:
Q: Trying to add bmp image to ScrolledText widget and it says it does not exist (Tkinter) I'm trying to add a program icon I got as a bmp image to a ScrolledText widget. I'm getting this error:

_tkinter.TclError: image "<PIL.BmpImagePlugin.BmpImageFile image mode=RGB size=32x32 at 0x19B2FA18EB0>" doesn't exist

Here's the relevant code:
def get_icon(exe):
    ico_x = win32api.GetSystemMetrics(win32con.SM_CXICON)
    ico_y = win32api.GetSystemMetrics(win32con.SM_CYICON)

    large, small = win32gui.ExtractIconEx(exe, 0)
    win32gui.DestroyIcon(small[0])

    hdc = win32ui.CreateDCFromHandle(win32gui.GetDC(0))
    hbmp = win32ui.CreateBitmap()
    hbmp.CreateCompatibleBitmap(hdc, ico_x, ico_y)
    hdc = hdc.CreateCompatibleDC()

    hdc.SelectObject(hbmp)
    hdc.DrawIcon((0, 0), large[0])

    hbmp.SaveBitmapFile(hdc, 'icon.bmp')

    img = Image.open("icon.bmp")

    return img

text_area = ScrolledText(root,
                            width = 40,
                            height = 40,
                            font = ("Times New Roman",
                                    25))

img = get_icon("C:\Program Files\BraveSoftware\Brave-Browser\Application\Brave.exe")
text_area.image_create("current", padx=5, pady=5, image=ImageTk.PhotoImage(img))
text_area.place(relx=0.2, rely=0.1, relwidth=0.5, relheight=0.5, anchor='s')

Any ideas?


text:
Q: How to find $plusargs with same string in different locations Very general issue in large integration of verification environment.
Our verification development involves large group across different time zone.
Group has preference to use $plusargs instead factory mechanism.
Probably main reason it is hard to set factory from command line processor,
we have more layers of scripts to start simulation.
Recently i found that same string been used in different environment to control behavior of environment. In this case two different score board used same string to disable some checking and test pass. Both those environment some time created at run time. Also some time it is OK to re-use same string, and it will require owner to be involved.
Is there any way to find duplication like this from final elaborated model, and provide locations in code as a warning?
I thought create our own wrapper, but problem that we are integrating some code that we are not owners as in this case was.
Thanks,

A: This is a perfect example of how people think they can get things done quicker by not following the recommended UVM methodology and instead create time consuming complexity later on.
I see at least two possible options.

*

*Write a script that searches the source code for $plusargs and hopefully they have used string literals for you to trace for duplicates.

*You can override $plusargs with PLI code and have it trace duplicates.

The choice depends on wether you are better at writing Perl/Python or C code.


text:
Q: Create a PostgreSQL query with possibility of a Null relation Suppose I have the following tables where id in each are primary keys and actors in the second is a foreign key of the first.
 table: actors
 id |              name
----+--------------------------------
  1 | Paul Rudd
  2 | Danny Devito
  3 | Mark Ruffalo
  4 | David Allen Grier

table: movies
 id |     name      | actors
----+---------------+----------------
  1 | So this is 40 |              1
  2 | Avengers      |              3
  3 | Twins         |              2

I need to write a single sql query that will select all movie names with and their actors and actors without movies
This is what I have:
SELECT IFNULL(m.name, 'none'), a.name
FROM actors a
JOIN movies m
ON m.id = a.id;

I get:
ERROR:  function ifnull(character varying, unknown) does not exist
LINE 1: SELECT IFNULL(n.name, 'none'), l.name

HINT:  No function matches the given name and argument types. You might need
to add explicit type casts.

A: It is working fine for me, check it out here. You are not using the correct single quote ' in your query.
SELECT
    coalesce(m.name, 'none'), a.name
FROM actors a
JOIN movies m
ON m.id = a.id;

A: Postgresql:
 SELECT m.name, a.name
 FROM movies m
 RIGHT OUTER JOIN actors a
 ON m.actors = a.id;


text:
Q: How to detect if a user received new apprequest I'd like to detect if a user receives an apprequest during being in my app's canvas. Is this possible via FB.Event.subscribe?
Thanks

A: FB.Event.subscribe has no function for that as facebook described. But you can accomplish it with Comet.


text:
Q: How to tween entrance/exit with Meteor? With the Meteor library, it handles the "reactive"/"two way binding" interaction styles quite well, if using their (Spacebars) template to generate HTML. However, I'm wanting to do some animated entrances/exits when data changes, and having difficulty getting that to work.
The use case is I have a dashboard gauge widget rendered as an SVG element. When the data driving the gauge updates, I want the needle to animate to its new position, not just snap there.
To have the needle just snap to the new position, I can do something like:
template.html
<template name="gauge">
  <svg>
    <path id="needle" {{ needleAttrs }} d="..." />
  </svg>
</template>

client.js
Template.gauge.helpers({
  needleAttrs: function() {
    return {
      x: 50,
      y: MyCollection.findOne().needleValue
    };
  }
});

This is effectively the same technique used by the SVG clock example that comes with Meteor.
But how can I transition that animation? I was thinking about pushing the new value from the collection into the Session collection such that a separate animate() method could find it, and some use of Tracker.autorun() to make it Reactive, but I haven't been able to get it to trigger properly.


text:
Q: Passing a url with search parameters to an android app I am making an android app and doing pretty well atm. What I want is when a user presses a url with variable search parameters attached to it, that the entire url is sent to my app.
The app opens well, but I don't know how to get the search parameters in there as well.
Btw. the app has a webview of the internet page in it, which works fine. I am opening the app itself as well as clicking on the links sent to whatsapp and messenger from within my app.
E.g. the url could be https://www.sendamap.com/index.php?g=100&z=200
Standard the https://www.sendamap.com is opened. I would like the whole url to be passed to the app.
In android studio I am struggling with the following in the MainActivity;
Intent intent = getIntent();
Uri data = intent.getData();
String url = data.toString();
webView.loadUrl(url);

Okay, it works now. It was mainly in my code (duh).
AndroidManifest.xml; "https" is important (besides everything else).
 <intent-filter>
   <action android:name="android.intent.action.VIEW" />
   <category android:name="android.intent.category.DEFAULT" />
   <category android:name="android.intent.category.BROWSABLE" />
   <data android:scheme="https"
         android:host="www.sendamap.com" />
 </intent-filter>

MainActivity.java; "this." was added before "getIntent().getData().
Uri uri = this.getIntent().getData();
if (uri != null) {
    url = uri.toString();
}
webView.loadUrl(url);


text:
Q: JS Date GMT + or - seems to work the wrong way round...? Please see the code example below from Google Chrome:
new Date('Thu Jul 27 2017 13:10:42 GMT-0500')
Result: Thu Jul 27 2017 19:10:42 GMT+0100 (BST)

new Date('Thu Jul 27 2017 13:10:42 GMT+0500')
Result: Thu Jul 27 2017 09:10:42 GMT+0100 (BST)

I would read the first date current time as being 13:10 which is -0500 hours off from GMT but the result it gives is +5 hours in the future +1 hour BST. In a similar vein the second date works the opposite way being +0500 hours off but returning -5 hours in the past +1 BST.
Firefox works in a similar way but it seems without the BST:
new Date('Thu Jul 27 2017 13:10:42 GMT-0500');
Date 2017-07-27T18:10:42.000Z

new Date('Thu Jul 27 2017 13:10:42 GMT+0500')
Date 2017-07-27T08:10:42.000Z

IE Edge gives me these results:
new Date('Thu Jul 27 2017 13:10:42 GMT-0500')
Thu Jul 27 2017 19:10:42 GMT+0100 (GMT Summer Time)

new Date('Thu Jul 27 2017 13:10:42 GMT+0500')
Thu Jul 27 2017 09:10:42 GMT+0100 (GMT Summer Time)

Can anyone help throw some light on this please?
EDIT - this is not a duplicate of 'Why does Date.parse give incorrect results?' because I am not using the parse() method explicitly.
Please note: I am trying to create a date object that is not in the same timezone as my browser.
If this is not possible I might have to solve my current problem with some basic math (current time +/- the timezone required) - shame if I cannot do this with a native JS Date object.

A: The default conversion of a Date instance to a string gives you the date and time in terms of the local timezone. If you're doing it in the browser console, you can't even rely on that, because the console itself is free to do whatever it wants. Firefox's console seems to extract the UTC representation; if you call
new Date('Thu Jul 27 2017 13:10:42 GMT-0500').toString()

instead you get the local time.
Dates are based on the idea of UTC timestamps and the notion that local time is generally important. Creating a date from a string gives you a timestamp meaningful (well, as meaningful as possible) for the string, but subsequently the Date instance is by default treated as something relevant to the local context. You can always use the UTC APIs to extract the UTC time if you want.

A: This question seems to stem from unfamiliarity either with how date strings are parsed by the built–in parser or with how they are formatted by various built–in toString methods.
The same parser is used by Date.parse and the Date constructor, it doesn't matter which is used in terms of how the string is parsed to a time value. The only difference between the two is that Date.parse returns the time value as a number, whereas the Date constructor uses the time value to create a Date instance (which is the only value that a Date instance holds).
The time value itself is milliseconds since 1970-01-01T00:00:00Z, so has no time zone (and means Date instances are effectively UTC). The value returned by getTimezoneOffset and the timezone displayed in toString methods (if there is one) is from the host system, it's not a property of Date instances or the Date constructor.
The timestamp pairs in your question represent exactly the same moment in time, but in different time zones.
Thu Jul 27 2017 13:10:42 GMT-0500 is Thu Jul 27 2017 18:10:42 GMT.
Thu Jul 27 2017 19:10:42 GMT+0100 (BST) is also Thu Jul 27 2017 18:10:42 GMT.

The value returned by Date.prototype.toString is entirely implementation dependent. When you send a date to output, the host may use any method it likes to represent the Date and may format it any way it wants. In the above, it seems the host timezone (UTC+0100) has been used with the default toString, which may return a differently formatted string in different implementations.
However, recent browsers seem to have settled on RFC 2822 format. Other methods that typically return different formats are toISOString and toLocaleString (noting that all three methods could return an ISO 8601 format string and be consistent with the ECMA-262, though I don't know of any implementations that do).
The next two dates also represent exactly the same moment in time:
Thu Jul 27 2017 13:10:42 GMT+0500 is Thu Jul 27 2017 08:10:42 GMT
Thu Jul 27 2017 09:10:42 GMT+0100 (BST) is also  Thu Jul 27 2017 08:10:42 GMT

Again, the host timezone has been used to generate the output string.
As for "Firefox works in a similar way but it seems without the BST", see above. ECMA-262 only requires the the format be convenient and human readable.  In this case, the browser developers have chosen to use an ISO 8601 format with no offset (i.e. UTC+0000).
So:
Thu Jul 27 2017 13:10:42 GMT-0500 is Thu Jul 27 2017 18:10:42 GMT+0000
2017-07-27T18:10:42.000Z is also Thu Jul 27 2017 18:10:42 GMT+0000

The choice not to use a timezone offset is entirely up to the browser developers and is consistent with ECMA-262.
If your issue is with how date strings are parsed, the duplicate is Why does Date.parse give incorrect results?. If it's with how dates are formatted, the duplicate is Where can I find documentation on formatting a date in JavaScript? The answers to those two questions should answer any issue raised in the OP.