问:
adehabitat KUD loop setting grid and extent
I'm calculating KUD and kernal area using the adehabitat package. I'm doing this for individual animals in my dataset, and as such I'm running a loop which calculates the KUD for each animal in a predefined list.

However, at the end of the loop I get warnings like this

```<code>Warning message:
In kernel.area(j, percent, unin, unout) :
  The grid is too small to allow the estimation of home-range
for the following value of percent: 50,95. You should rerun kernelUD with a larger extent parameter.
</code>```

My code for calculating the KUD and area in the loop is below

```<code>GRS_coa <- COA(tagdata = GRS_DAT, id="Transmitter.Name", timestep= 60)

  coordinates(GRS_coa) <- c("Longitude.coa", "Latitude.coa")
  proj4string(GRS_coa) <- CRS("+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0")

GRS_GDA <- spTransform(GRS_coa, CRSobj = CRS('+proj=utm +zone=42 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0'))

GRS_KUD <- kernelUD(GRS_GDA[,"Transmitter.Name"], h="href", grid=500, extent = 5) # grid value indicates output resolution

KUD_DAT <- as.data.frame(kernel.area(GRS_KUD, percent=c(50, 95), unin="m", unout="km2"))
</code>```

I know why I get the warnings, the grid I'm defining, for some of the animals, is too small, and as such, the vertices are outside the grid, as desribed well here.

I have the 'grid' and 'extent' arguments preset. Because I'm working with different animals, the correct grid and extent arguments will vary. Is there any way of calculating what these should be from my data and using those values for the 'grid' and 'extent' terms, rather than using preset values?

An example of the dataset I use for one animal is below should that be required.

```<code>structure(list(Date.and.Time = structure(c(1388557740, 1388558040,
1388558160, 1388558340, 1388558520, 1388558640, 1388558820, 1388559240,
1388631420, 1388648220, 1388648280, 1388648520, 1388648700, 1388728560,
1388737020, 1388823720, 1388893140, 1388893380, 1388981640, 1388983140,
1388983320, 1388983440, 1388983560, 1388983680, 1388983800, 1388983980,
1388984400, 1388984520, 1388984700, 1388984880, 1388985480, 1389068220,
1389068400, 1389068640, 1389068820, 1389071400, 1389071580, 1389071700,
1389071940, 1389075600, 1389075720, 1389075840, 1389075960, 1389076080,
1389076440, 1389076560, 1389076680, 1389076860, 1389077040, 1389077220,
1389077580, 1389077820, 1389077940, 1389155640, 1389264720, 1389264900,
1389265020, 1389337380, 1389430020, 1389496080, 1389496200, 1389496320,
1389496440, 1389496560, 1389496680, 1389511920, 1389548280, 1389553080,
1389558120, 1389558240, 1389558360, 1389558540, 1389567840, 1389568080,
1389568320, 1389568560, 1389568680, 1389679500, 1389679740, 1389680220,
1389695580, 1389695820, 1389778860, 1389781500, 1389781620, 1389782100,
1389782400, 1389783300, 1389783540, 1389784980, 1389785460, 1389785700,
1389786120, 1389787320, 1389788340, 1389858660, 1389860280, 1389861780,
1389923880, 1390032720, 1390038900, 1390039140, 1390039260, 1390126380,
1390126500, 1390194420, 1390353360, 1390353540, 1390353780, 1390353900,
1390376820, 1390377060, 1390377180, 1390433700, 1390433880, 1390440480,
1390479780, 1390543800, 1390544340, 1390544700, 1390544880, 1390602600,
1390638000, 1390730460, 1390730700, 1390800600, 1390801020, 1390809660,
1390883160, 1390883340, 1390883520, 1390883700, 1390985640, 1390985820,
1390985940, 1390986060, 1391073120, 1391145420, 1391146200, 1391146380,
1391146500, 1391146620), class = c("POSIXct", "POSIXt"), tzone = "UTC"),
    Latitude = c(-5.2662, -5.2662, -5.2662, -5.2662, -5.2662,
    -5.2662, -5.2662, -5.2662, -5.2662, -5.2662, -5.2662, -5.2662,
    -5.2662, -5.2662, -5.2662, -5.2662, -5.2662, -5.2662, -5.2662,
    -5.2662, -5.2662, -5.2662, -5.2662, -5.2662, -5.2662, -5.2662,
    -5.2662, -5.2662, -5.2662, -5.2662, -5.2662, -5.2662, -5.2662,
    -5.2662, -5.2662, -5.2662, -5.2662, -5.2662, -5.2662, -5.2662,
    -5.2662, -5.2662, -5.2662, -5.2662, -5.2662, -5.2662, -5.2662,
    -5.2662, -5.2662, -5.2662, -5.2662, -5.2662, -5.2662, -5.25671666666667,
    -5.2662, -5.2662, -5.2662, -5.2662, -5.2662, -5.2662, -5.2662,
    -5.2662, -5.2662, -5.2662, -5.2662, -5.2662, -5.2662, -5.2662,
    -5.2662, -5.2662, -5.2662, -5.2662, -5.2662, -5.2662, -5.2662,
    -5.2662, -5.2662, -5.2662, -5.2662, -5.2662, -5.2662, -5.2662,
    -5.25671666666667, -5.25671666666667, -5.25671666666667,
    -5.25671666666667, -5.25671666666667, -5.25671666666667,
    -5.25671666666667, -5.25671666666667, -5.25671666666667,
    -5.25671666666667, -5.25671666666667, -5.25671666666667,
    -5.25671666666667, -5.25671666666667, -5.25671666666667,
    -5.25671666666667, -5.2662, -5.25671666666667, -5.25671666666667,
    -5.25671666666667, -5.25671666666667, -5.2662, -5.2662, -5.2662,
    -5.2662, -5.2662, -5.2662, -5.2662, -5.25671666666667, -5.25671666666667,
    -5.25671666666667, -5.2662, -5.2662, -5.2662, -5.2662, -5.2662,
    -5.2662, -5.2662, -5.2662, -5.2662, -5.2662, -5.2662, -5.2662,
    -5.2662, -5.2662, -5.2662, -5.2662, -5.2662, -5.2662, -5.2662,
    -5.2662, -5.2662, -5.2662, -5.2662, -5.2662, -5.2662, -5.2662,
    -5.2662, -5.2662, -5.2662), Longitude = c(71.6748333333333,
    71.6748333333333, 71.6748333333333, 71.6748333333333, 71.6748333333333,
    71.6748333333333, 71.6748333333333, 71.6748333333333, 71.6748333333333,
    71.6748333333333, 71.6748333333333, 71.6748333333333, 71.6748333333333,
    71.6748333333333, 71.6748333333333, 71.6748333333333, 71.6748333333333,
    71.6748333333333, 71.6748333333333, 71.6748333333333, 71.6748333333333,
    71.6748333333333, 71.6748333333333, 71.6748333333333, 71.6748333333333,
    71.6748333333333, 71.6748333333333, 71.6748333333333, 71.6748333333333,
    71.6748333333333, 71.6748333333333, 71.6748333333333, 71.6748333333333,
    71.6748333333333, 71.6748333333333, 71.6748333333333, 71.6748333333333,
    71.6748333333333, 71.6748333333333, 71.6748333333333, 71.6748333333333,
    71.6748333333333, 71.6748333333333, 71.6748333333333, 71.6748333333333,
    71.6748333333333, 71.6748333333333, 71.6748333333333, 71.6748333333333,
    71.6748333333333, 71.6748333333333, 71.6748333333333, 71.6748333333333,
    71.6546833333333, 71.6748333333333, 71.6748333333333, 71.6748333333333,
    71.6748333333333, 71.6748333333333, 71.6748333333333, 71.6748333333333,
    71.6748333333333, 71.6748333333333, 71.6748333333333, 71.6748333333333,
    71.6748333333333, 71.6748333333333, 71.6748333333333, 71.6748333333333,
    71.6748333333333, 71.6748333333333, 71.6748333333333, 71.6748333333333,
    71.6748333333333, 71.6748333333333, 71.6748333333333, 71.6748333333333,
    71.6748333333333, 71.6748333333333, 71.6748333333333, 71.6748333333333,
    71.6748333333333, 71.6546833333333, 71.6546833333333, 71.6546833333333,
    71.6546833333333, 71.6546833333333, 71.6546833333333, 71.6546833333333,
    71.6546833333333, 71.6546833333333, 71.6546833333333, 71.6546833333333,
    71.6546833333333, 71.6546833333333, 71.6546833333333, 71.6546833333333,
    71.6546833333333, 71.6748333333333, 71.6546833333333, 71.6546833333333,
    71.6546833333333, 71.6546833333333, 71.6748333333333, 71.6748333333333,
    71.6748333333333, 71.6748333333333, 71.6748333333333, 71.6748333333333,
    71.6748333333333, 71.6546833333333, 71.6546833333333, 71.6546833333333,
    71.6748333333333, 71.6748333333333, 71.6748333333333, 71.6748333333333,
    71.6748333333333, 71.6748333333333, 71.6748333333333, 71.6748333333333,
    71.6748333333333, 71.6748333333333, 71.6748333333333, 71.6748333333333,
    71.6748333333333, 71.6748333333333, 71.6748333333333, 71.6748333333333,
    71.6748333333333, 71.6748333333333, 71.6748333333333, 71.6748333333333,
    71.6748333333333, 71.6748333333333, 71.6748333333333, 71.6748333333333,
    71.6748333333333, 71.6748333333333, 71.6748333333333, 71.6748333333333,
    71.6748333333333), Sensor.Unit = c(NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA), Sensor.Value = c(NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), Transmitter = c(NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA), Transmitter.Name = c("Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark"),
    Transmitter.Serial = structure(c(4L, 4L, 4L, 4L, 4L, 4L,
    4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
    4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
    4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
    4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
    4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
    4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
    4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
    4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
    4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
    4L), levels = c("2390", "13573", "13574", "13575", "13576",
    "19318", "19319", "19321", "19322", "19506", "19514", "19519",
    "19520", "19524", "25537", "25540", "25541", "25543", "25546",
    "25549", "25552", "25553", "27583", "27585", "27586", "27591",
    "27592", "27593", "27594", "27595", "27596", "27597", "27600",
    "27601", "27605", "27607", "27608", "27613", "27614", "27617",
    "27619", "27620", "27621", "27626", "27627", "27629", "27630",
    "27631", "27632", "28608", "28611", "28612", "28618", "28625",
    "28628", "28629", "28631", "28632", "28633", "28638", "28641",
    "28644", "28662", "28672", "28674", "52978", "54815", "54846",
    "54852", "54860", "54863", "54865", "54866", "54868", "54877",
    "54882", "54883", "54884", "54886", "54890", "54892", "54895",
    "54896", "54901", "54904", "54914", "54919", "54920", "54922",
    "54925", "54931", "54932", "54938", "54952", "54954", "54955",
    "54958", "54959", "54962", "59950", "59953", "59954", "59955",
    "59957", "59958", "59959", "59960", "59961", "59962", "59964",
    "59966", "59969", "59970", "59971", "59972", "59973", "59975",
    "59976", "59979", "59981", "59988"), class = "factor"), id = c("Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark")), row.names = c(NA,
-142L), class = "data.frame")
</code>```

Body:
I'm calculating KUD and kernal area using the adehabitat package. I'm doing this for individual animals in my dataset, and as such I'm running a loop which calculates the KUD for each animal in a predefined list.

However, at the end of the loop I get warnings like this

Warning message:
In kernel.area(j, percent, unin, unout) :
  The grid is too small to allow the estimation of home-range
for the following value of percent: 50,95. You should rerun kernelUD with a larger extent parameter.

My code for calculating the KUD and area in the loop is below

GRS_coa <- COA(tagdata = GRS_DAT, id="Transmitter.Name", timestep= 60)

  coordinates(GRS_coa) <- c("Longitude.coa", "Latitude.coa")
  proj4string(GRS_coa) <- CRS("+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0")

GRS_GDA <- spTransform(GRS_coa, CRSobj = CRS('+proj=utm +zone=42 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0'))

GRS_KUD <- kernelUD(GRS_GDA[,"Transmitter.Name"], h="href", grid=500, extent = 5) # grid value indicates output resolution

KUD_DAT <- as.data.frame(kernel.area(GRS_KUD, percent=c(50, 95), unin="m", unout="km2"))

I know why I get the warnings, the grid I'm defining, for some of the animals, is too small, and as such, the vertices are outside the grid, as desribed well here.

I have the 'grid' and 'extent' arguments preset. Because I'm working with different animals, the correct grid and extent arguments will vary. Is there any way of calculating what these should be from my data and using those values for the 'grid' and 'extent' terms, rather than using preset values?

An example of the dataset I use for one animal is below should that be required.

structure(list(Date.and.Time = structure(c(1388557740, 1388558040,
1388558160, 1388558340, 1388558520, 1388558640, 1388558820, 1388559240,
1388631420, 1388648220, 1388648280, 1388648520, 1388648700, 1388728560,
1388737020, 1388823720, 1388893140, 1388893380, 1388981640, 1388983140,
1388983320, 1388983440, 1388983560, 1388983680, 1388983800, 1388983980,
1388984400, 1388984520, 1388984700, 1388984880, 1388985480, 1389068220,
1389068400, 1389068640, 1389068820, 1389071400, 1389071580, 1389071700,
1389071940, 1389075600, 1389075720, 1389075840, 1389075960, 1389076080,
1389076440, 1389076560, 1389076680, 1389076860, 1389077040, 1389077220,
1389077580, 1389077820, 1389077940, 1389155640, 1389264720, 1389264900,
1389265020, 1389337380, 1389430020, 1389496080, 1389496200, 1389496320,
1389496440, 1389496560, 1389496680, 1389511920, 1389548280, 1389553080,
1389558120, 1389558240, 1389558360, 1389558540, 1389567840, 1389568080,
1389568320, 1389568560, 1389568680, 1389679500, 1389679740, 1389680220,
1389695580, 1389695820, 1389778860, 1389781500, 1389781620, 1389782100,
1389782400, 1389783300, 1389783540, 1389784980, 1389785460, 1389785700,
1389786120, 1389787320, 1389788340, 1389858660, 1389860280, 1389861780,
1389923880, 1390032720, 1390038900, 1390039140, 1390039260, 1390126380,
1390126500, 1390194420, 1390353360, 1390353540, 1390353780, 1390353900,
1390376820, 1390377060, 1390377180, 1390433700, 1390433880, 1390440480,
1390479780, 1390543800, 1390544340, 1390544700, 1390544880, 1390602600,
1390638000, 1390730460, 1390730700, 1390800600, 1390801020, 1390809660,
1390883160, 1390883340, 1390883520, 1390883700, 1390985640, 1390985820,
1390985940, 1390986060, 1391073120, 1391145420, 1391146200, 1391146380,
1391146500, 1391146620), class = c("POSIXct", "POSIXt"), tzone = "UTC"),
    Latitude = c(-5.2662, -5.2662, -5.2662, -5.2662, -5.2662,
    -5.2662, -5.2662, -5.2662, -5.2662, -5.2662, -5.2662, -5.2662,
    -5.2662, -5.2662, -5.2662, -5.2662, -5.2662, -5.2662, -5.2662,
    -5.2662, -5.2662, -5.2662, -5.2662, -5.2662, -5.2662, -5.2662,
    -5.2662, -5.2662, -5.2662, -5.2662, -5.2662, -5.2662, -5.2662,
    -5.2662, -5.2662, -5.2662, -5.2662, -5.2662, -5.2662, -5.2662,
    -5.2662, -5.2662, -5.2662, -5.2662, -5.2662, -5.2662, -5.2662,
    -5.2662, -5.2662, -5.2662, -5.2662, -5.2662, -5.2662, -5.25671666666667,
    -5.2662, -5.2662, -5.2662, -5.2662, -5.2662, -5.2662, -5.2662,
    -5.2662, -5.2662, -5.2662, -5.2662, -5.2662, -5.2662, -5.2662,
    -5.2662, -5.2662, -5.2662, -5.2662, -5.2662, -5.2662, -5.2662,
    -5.2662, -5.2662, -5.2662, -5.2662, -5.2662, -5.2662, -5.2662,
    -5.25671666666667, -5.25671666666667, -5.25671666666667,
    -5.25671666666667, -5.25671666666667, -5.25671666666667,
    -5.25671666666667, -5.25671666666667, -5.25671666666667,
    -5.25671666666667, -5.25671666666667, -5.25671666666667,
    -5.25671666666667, -5.25671666666667, -5.25671666666667,
    -5.25671666666667, -5.2662, -5.25671666666667, -5.25671666666667,
    -5.25671666666667, -5.25671666666667, -5.2662, -5.2662, -5.2662,
    -5.2662, -5.2662, -5.2662, -5.2662, -5.25671666666667, -5.25671666666667,
    -5.25671666666667, -5.2662, -5.2662, -5.2662, -5.2662, -5.2662,
    -5.2662, -5.2662, -5.2662, -5.2662, -5.2662, -5.2662, -5.2662,
    -5.2662, -5.2662, -5.2662, -5.2662, -5.2662, -5.2662, -5.2662,
    -5.2662, -5.2662, -5.2662, -5.2662, -5.2662, -5.2662, -5.2662,
    -5.2662, -5.2662, -5.2662), Longitude = c(71.6748333333333,
    71.6748333333333, 71.6748333333333, 71.6748333333333, 71.6748333333333,
    71.6748333333333, 71.6748333333333, 71.6748333333333, 71.6748333333333,
    71.6748333333333, 71.6748333333333, 71.6748333333333, 71.6748333333333,
    71.6748333333333, 71.6748333333333, 71.6748333333333, 71.6748333333333,
    71.6748333333333, 71.6748333333333, 71.6748333333333, 71.6748333333333,
    71.6748333333333, 71.6748333333333, 71.6748333333333, 71.6748333333333,
    71.6748333333333, 71.6748333333333, 71.6748333333333, 71.6748333333333,
    71.6748333333333, 71.6748333333333, 71.6748333333333, 71.6748333333333,
    71.6748333333333, 71.6748333333333, 71.6748333333333, 71.6748333333333,
    71.6748333333333, 71.6748333333333, 71.6748333333333, 71.6748333333333,
    71.6748333333333, 71.6748333333333, 71.6748333333333, 71.6748333333333,
    71.6748333333333, 71.6748333333333, 71.6748333333333, 71.6748333333333,
    71.6748333333333, 71.6748333333333, 71.6748333333333, 71.6748333333333,
    71.6546833333333, 71.6748333333333, 71.6748333333333, 71.6748333333333,
    71.6748333333333, 71.6748333333333, 71.6748333333333, 71.6748333333333,
    71.6748333333333, 71.6748333333333, 71.6748333333333, 71.6748333333333,
    71.6748333333333, 71.6748333333333, 71.6748333333333, 71.6748333333333,
    71.6748333333333, 71.6748333333333, 71.6748333333333, 71.6748333333333,
    71.6748333333333, 71.6748333333333, 71.6748333333333, 71.6748333333333,
    71.6748333333333, 71.6748333333333, 71.6748333333333, 71.6748333333333,
    71.6748333333333, 71.6546833333333, 71.6546833333333, 71.6546833333333,
    71.6546833333333, 71.6546833333333, 71.6546833333333, 71.6546833333333,
    71.6546833333333, 71.6546833333333, 71.6546833333333, 71.6546833333333,
    71.6546833333333, 71.6546833333333, 71.6546833333333, 71.6546833333333,
    71.6546833333333, 71.6748333333333, 71.6546833333333, 71.6546833333333,
    71.6546833333333, 71.6546833333333, 71.6748333333333, 71.6748333333333,
    71.6748333333333, 71.6748333333333, 71.6748333333333, 71.6748333333333,
    71.6748333333333, 71.6546833333333, 71.6546833333333, 71.6546833333333,
    71.6748333333333, 71.6748333333333, 71.6748333333333, 71.6748333333333,
    71.6748333333333, 71.6748333333333, 71.6748333333333, 71.6748333333333,
    71.6748333333333, 71.6748333333333, 71.6748333333333, 71.6748333333333,
    71.6748333333333, 71.6748333333333, 71.6748333333333, 71.6748333333333,
    71.6748333333333, 71.6748333333333, 71.6748333333333, 71.6748333333333,
    71.6748333333333, 71.6748333333333, 71.6748333333333, 71.6748333333333,
    71.6748333333333, 71.6748333333333, 71.6748333333333, 71.6748333333333,
    71.6748333333333), Sensor.Unit = c(NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA), Sensor.Value = c(NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), Transmitter = c(NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA), Transmitter.Name = c("Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark"),
    Transmitter.Serial = structure(c(4L, 4L, 4L, 4L, 4L, 4L,
    4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
    4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
    4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
    4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
    4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
    4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
    4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
    4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
    4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
    4L), levels = c("2390", "13573", "13574", "13575", "13576",
    "19318", "19319", "19321", "19322", "19506", "19514", "19519",
    "19520", "19524", "25537", "25540", "25541", "25543", "25546",
    "25549", "25552", "25553", "27583", "27585", "27586", "27591",
    "27592", "27593", "27594", "27595", "27596", "27597", "27600",
    "27601", "27605", "27607", "27608", "27613", "27614", "27617",
    "27619", "27620", "27621", "27626", "27627", "27629", "27630",
    "27631", "27632", "28608", "28611", "28612", "28618", "28625",
    "28628", "28629", "28631", "28632", "28633", "28638", "28641",
    "28644", "28662", "28672", "28674", "52978", "54815", "54846",
    "54852", "54860", "54863", "54865", "54866", "54868", "54877",
    "54882", "54883", "54884", "54886", "54890", "54892", "54895",
    "54896", "54901", "54904", "54914", "54919", "54920", "54922",
    "54925", "54931", "54932", "54938", "54952", "54954", "54955",
    "54958", "54959", "54962", "59950", "59953", "59954", "59955",
    "59957", "59958", "59959", "59960", "59961", "59962", "59964",
    "59966", "59969", "59970", "59971", "59972", "59973", "59975",
    "59976", "59979", "59981", "59988"), class = "factor"), id = c("Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark",
    "Grey Reef Shark", "Grey Reef Shark", "Grey Reef Shark")), row.names = c(NA,
-142L), class = "data.frame")


来源: stackexchange

问:
How to transpose rows to column mysql 8.0.29 using phpadmin
```<code>SELECT Item,SUM(Qty) as Qty,Due_date,
(CASE WHEN (DATEDIFF(Due_date, CURRENT_DATE)<=-90) THEN '90+ Days'
WHEN (DATEDIFF(Due_date, CURRENT_DATE)>-90 and DATEDIFF(Due_date, CURRENT_DATE)<-60 ) THEN '61-90 days'
WHEN (DATEDIFF(Due_date, CURRENT_DATE)>=-60 and DATEDIFF(Due_date, CURRENT_DATE)<-30 ) THEN '31-60 days'
WHEN (DATEDIFF(Due_date, CURRENT_DATE)>=-30 and DATEDIFF(Due_date, CURRENT_DATE)<-15 ) THEN '16-30 days'
WHEN (DATEDIFF(Due_date, CURRENT_DATE)>-15 and DATEDIFF(Due_date, CURRENT_DATE)<-7 ) THEN '8-15 days'
WHEN (DATEDIFF(Due_date, CURRENT_DATE)>=-7 and DATEDIFF(Due_date, CURRENT_DATE)<=0 ) THEN '0-7 days'

WHEN (DATEDIFF(Due_date, CURRENT_DATE)>0 ) THEN WEEK(Due_date)
END ) AS Dues

FROM orderdata
GROUP by Item,Dues
ORDER BY Item,Due_date;
</code>```

Table 1

need dues to pivot and group by item

ContentLicense: CC BY-SA 4.0

Body:
SELECT Item,SUM(Qty) as Qty,Due_date,
(CASE WHEN (DATEDIFF(Due_date, CURRENT_DATE)<=-90) THEN '90+ Days'
WHEN (DATEDIFF(Due_date, CURRENT_DATE)>-90 and DATEDIFF(Due_date, CURRENT_DATE)<-60 ) THEN '61-90 days'
WHEN (DATEDIFF(Due_date, CURRENT_DATE)>=-60 and DATEDIFF(Due_date, CURRENT_DATE)<-30 ) THEN '31-60 days'
WHEN (DATEDIFF(Due_date, CURRENT_DATE)>=-30 and DATEDIFF(Due_date, CURRENT_DATE)<-15 ) THEN '16-30 days'
WHEN (DATEDIFF(Due_date, CURRENT_DATE)>-15 and DATEDIFF(Due_date, CURRENT_DATE)<-7 ) THEN '8-15 days'
WHEN (DATEDIFF(Due_date, CURRENT_DATE)>=-7 and DATEDIFF(Due_date, CURRENT_DATE)<=0 ) THEN '0-7 days'

WHEN (DATEDIFF(Due_date, CURRENT_DATE)>0 ) THEN WEEK(Due_date)
END ) AS Dues

FROM orderdata
GROUP by Item,Dues
ORDER BY Item,Due_date;

Table 1

need dues to pivot and group by item


问:
chrome strict-origin-when-cross-origin cross domain query
description of the problem:
I have a site which distribute the configurations
https://cliconf.aa.bb.cc/cgi-bin/get-config.cgi
it returns config json and some HTTP headers for cors:

vary: Origin
vary: Access-Control-Request-Method
vary: Access-Control-Request-Headers
access-control-allow-origin: *
access-control-allow-headers: *
```
<p>I have the app site
https://web.aa.bb.cc/</p>
<p>this two sites a one same domain zone, but app doesn't read config and return error "strict-origin-when-cross-origin"</p>
<p>the curl call</p>
<pre class="lang-bash prettyprint-override"><code>curl -v -H "Origin: https://web.aa.bb.cc/" --url "https://cliconf.aa.bb.cc/cgi-bin/get-config.cgi"
</code>```

is return 200

```<code>
     *   Trying x.x.x.x...
         * Connected to x.x.x.x (x.x.x.x) port 443 (#0)
         * ALPN, offering h2
         * ALPN, offering http/1.1
         *  CAfile: /etc/ssl/certs/xxxxxx.crt
         *  CApath: /etc/ssl/certs
         * TLSv1.0 (OUT), TLS header, Certificate Status (22):
         * TLSv1.3 (OUT), TLS handshake, Client hello (1):
         * TLSv1.2 (IN), TLS header, Certificate Status (22):
         * TLSv1.3 (IN), TLS handshake, Server hello (2):
         * TLSv1.2 (IN), TLS header, Certificate Status (22):
         * TLSv1.2 (IN), TLS handshake, Certificate (11):
         * TLSv1.2 (IN), TLS header, Certificate Status (22):
         * TLSv1.2 (IN), TLS handshake, Server key exchange (12):
         * TLSv1.2 (IN), TLS header, Certificate Status (22):
         * TLSv1.2 (IN), TLS handshake, Server finished (14):
         * TLSv1.2 (OUT), TLS header, Certificate Status (22):
         * TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
         * TLSv1.2 (OUT), TLS header, Finished (20):
         * TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
         * TLSv1.2 (OUT), TLS header, Certificate Status (22):
         * TLSv1.2 (OUT), TLS handshake, Finished (20):
         * TLSv1.2 (IN), TLS header, Finished (20):
         * TLSv1.2 (IN), TLS header, Certificate Status (22):
         * TLSv1.2 (IN), TLS handshake, Finished (20):
         * SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
         * ALPN, server accepted to use h2
         * Server certificate:
         *  subject: CN=*.x.x.x.x
         *  start date: Jun 15 00:00:00 2022 GMT
         *  expire date: Jul 14 23:59:59 2023 GMT
         *  subjectAltName: host "x.x.x.x" matched cert's "*.x.x.x.x"
         *  issuer: C=US; O=Amazon; OU=Server CA 1B; CN=Amazon
         *  SSL certificate verify ok.
         * Using HTTP2, server supports multiplexing
         * Connection state changed (HTTP/2 confirmed)
         * Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
         * TLSv1.2 (OUT), TLS header, Supplemental data (23):
         * TLSv1.2 (OUT), TLS header, Supplemental data (23):
         * TLSv1.2 (OUT), TLS header, Supplemental data (23):
         * Using Stream ID: 1 (easy handle 0x5573120e5e80)
         * TLSv1.2 (OUT), TLS header, Supplemental data (23):
         > GET /cgi-bin/config?environment=aws_dev HTTP/2
         > Host: x.x.x.x:443
         > user-agent: curl/7.81.0
         > accept: */*
         >
         * TLSv1.2 (IN), TLS header, Supplemental data (23):
         * Connection state changed (MAX_CONCURRENT_STREAMS == 128)!
         * TLSv1.2 (OUT), TLS header, Supplemental data (23):
         * TLSv1.2 (IN), TLS header, Supplemental data (23):
         * TLSv1.2 (IN), TLS header, Supplemental data (23):
         < HTTP/2 200
         < date: Thu, 12 Jan 2023 14:55:55 GMT
         < content-type: application/json
         < server: nginx/1.18.0 (Ubuntu)
         < vary: Origin
         < vary: Access-Control-Request-Method
         < vary: Access-Control-Request-Headers
         < access-control-allow-headers: *
         < access-control-allow-origin: *
         < access-control-max-age: 3600
         < access-control-expose-headers: Content-Length
         <
         {"logcollector": "https://x.x.x.x/gelf", "linkFrontend": "https://x.x.x.x", x.x.x.x, "name": "dev", "linkAdminApi": "https://x.x.x.x", "maintenance": false, "manifest_id": "x.x.x.x", "url_appsite": "https://x.x.x.x", "linkSupport": "https://x.x.x.x", "websocketPathFrontend": "wss://x.x.x.x/wsapi" }
         * TLSv1.2 (IN), TLS header, Supplemental data (23):
         * Connection #0 to host x.x.x.x left intact
</code>```

I found on article https://developer.chrome.com/blog/referrer-policy-new-chrome-default/

but it's still not clear to me which headers and / or on which side I have to create in order for it to work

all web servers are nginx

conf file of nginx from cliconf.aa.bb.cc

```<code>    server {

        listen *:80;

        add_header Access-Control-Allow-Headers *;
        add_header Access-Control-Allow-Origin *;
        add_header Access-Control-Max-Age 3600;
        add_header Access-Control-Expose-Headers Content-Length;

        location / {
                try_files $uri $uri/ =404;
        }
        include fcgiwrap.conf;

        access_log /var/log/nginx/cliconf.aa.bb.cc-access.log;
        error_log /var/log/nginx/cliconf.aa.bb.cc-error.log;
}
</code>```

I include at main index.html

```<code><meta name="referrer" content="unsafe-url" />
</code>```

but it still not working.

Body:
description of the problem:
I have a site which distribute the configurations
https://cliconf.aa.bb.cc/cgi-bin/get-config.cgi
it returns config json and some HTTP headers for cors:

vary: Origin
vary: Access-Control-Request-Method
vary: Access-Control-Request-Headers
access-control-allow-origin: *
access-control-allow-headers: *

I have the app site
https://web.aa.bb.cc/

this two sites a one same domain zone, but app doesn't read config and return error "strict-origin-when-cross-origin"

the curl call

curl -v -H "Origin: https://web.aa.bb.cc/" --url "https://cliconf.aa.bb.cc/cgi-bin/get-config.cgi"

is return 200

     *   Trying x.x.x.x...
         * Connected to x.x.x.x (x.x.x.x) port 443 (#0)
         * ALPN, offering h2
         * ALPN, offering http/1.1
         *  CAfile: /etc/ssl/certs/xxxxxx.crt
         *  CApath: /etc/ssl/certs
         * TLSv1.0 (OUT), TLS header, Certificate Status (22):
         * TLSv1.3 (OUT), TLS handshake, Client hello (1):
         * TLSv1.2 (IN), TLS header, Certificate Status (22):
         * TLSv1.3 (IN), TLS handshake, Server hello (2):
         * TLSv1.2 (IN), TLS header, Certificate Status (22):
         * TLSv1.2 (IN), TLS handshake, Certificate (11):
         * TLSv1.2 (IN), TLS header, Certificate Status (22):
         * TLSv1.2 (IN), TLS handshake, Server key exchange (12):
         * TLSv1.2 (IN), TLS header, Certificate Status (22):
         * TLSv1.2 (IN), TLS handshake, Server finished (14):
         * TLSv1.2 (OUT), TLS header, Certificate Status (22):
         * TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
         * TLSv1.2 (OUT), TLS header, Finished (20):
         * TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
         * TLSv1.2 (OUT), TLS header, Certificate Status (22):
         * TLSv1.2 (OUT), TLS handshake, Finished (20):
         * TLSv1.2 (IN), TLS header, Finished (20):
         * TLSv1.2 (IN), TLS header, Certificate Status (22):
         * TLSv1.2 (IN), TLS handshake, Finished (20):
         * SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
         * ALPN, server accepted to use h2
         * Server certificate:
         *  subject: CN=*.x.x.x.x
         *  start date: Jun 15 00:00:00 2022 GMT
         *  expire date: Jul 14 23:59:59 2023 GMT
         *  subjectAltName: host "x.x.x.x" matched cert's "*.x.x.x.x"
         *  issuer: C=US; O=Amazon; OU=Server CA 1B; CN=Amazon
         *  SSL certificate verify ok.
         * Using HTTP2, server supports multiplexing
         * Connection state changed (HTTP/2 confirmed)
         * Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
         * TLSv1.2 (OUT), TLS header, Supplemental data (23):
         * TLSv1.2 (OUT), TLS header, Supplemental data (23):
         * TLSv1.2 (OUT), TLS header, Supplemental data (23):
         * Using Stream ID: 1 (easy handle 0x5573120e5e80)
         * TLSv1.2 (OUT), TLS header, Supplemental data (23):
         > GET /cgi-bin/config?environment=aws_dev HTTP/2
         > Host: x.x.x.x:443
         > user-agent: curl/7.81.0
         > accept: */*
         >
         * TLSv1.2 (IN), TLS header, Supplemental data (23):
         * Connection state changed (MAX_CONCURRENT_STREAMS == 128)!
         * TLSv1.2 (OUT), TLS header, Supplemental data (23):
         * TLSv1.2 (IN), TLS header, Supplemental data (23):
         * TLSv1.2 (IN), TLS header, Supplemental data (23):
         < HTTP/2 200
         < date: Thu, 12 Jan 2023 14:55:55 GMT
         < content-type: application/json
         < server: nginx/1.18.0 (Ubuntu)
         < vary: Origin
         < vary: Access-Control-Request-Method
         < vary: Access-Control-Request-Headers
         < access-control-allow-headers: *
         < access-control-allow-origin: *
         < access-control-max-age: 3600
         < access-control-expose-headers: Content-Length
         <
         {"logcollector": "https://x.x.x.x/gelf", "linkFrontend": "https://x.x.x.x", x.x.x.x, "name": "dev", "linkAdminApi": "https://x.x.x.x", "maintenance": false, "manifest_id": "x.x.x.x", "url_appsite": "https://x.x.x.x", "linkSupport": "https://x.x.x.x", "websocketPathFrontend": "wss://x.x.x.x/wsapi" }
         * TLSv1.2 (IN), TLS header, Supplemental data (23):
         * Connection #0 to host x.x.x.x left intact

I found on article https://developer.chrome.com/blog/referrer-policy-new-chrome-default/

but it's still not clear to me which headers and / or on which side I have to create in order for it to work

all web servers are nginx

conf file of nginx from cliconf.aa.bb.cc

    server {

        listen *:80;

        add_header Access-Control-Allow-Headers *;
        add_header Access-Control-Allow-Origin *;
        add_header Access-Control-Max-Age 3600;
        add_header Access-Control-Expose-Headers Content-Length;

        location / {
                try_files $uri $uri/ =404;
        }
        include fcgiwrap.conf;

        access_log /var/log/nginx/cliconf.aa.bb.cc-access.log;
        error_log /var/log/nginx/cliconf.aa.bb.cc-error.log;
}

I include at main index.html

<meta name="referrer" content="unsafe-url" />

but it still not working.


问:
Why are members from multiple inheritances of same class template ambiguous?
When inheriting from a class template multiple times, there is the problem that multiple inheritance of these template classes makes member functions ambiguous (also here), because apparently it is defined that way in the standard.

Question: Why is this defined ambiguous?

Example:

#include <iostream>

template <typename T>
class Base
{
    T val;

public:
    Base(T val) : val(val) {}

    void print(T v)
    {
        std::cout << val << " " << v << std::endl;
    }
};

class Child : public Base<int>, public Base<std::string>
{
public:
    Child() : Base<int>(0), Base<std::string>("0"){}

    // Necessary for successful compilation
//     using Base<int>::print;
//     using Base<std::string>::print;

};

int main()
{
    Child c;

    c.print(1);
    c.print(std::string("1"));

    return 0;
}
```
<p>produces</p>
```error: request for member ‘print’ is ambiguous
   38 |     c.print(1);
      |       ^~~~~
   39 |     c.print(std::string("1"));
      |       ^~~~~
note: candidates are: ‘void Base<T>::print(T) [with T = std::__cxx11::basic_string<char>]’
note:                 ‘void Base<T>::print(T) [with T = int]’

```
<p>Instead of manually spelling out, as suggested here and here,</p>
<pre class="lang-cpp prettyprint-override"><code>using Base<int>::print;
using Base<std::string>::print;
</code>```

I can just create a template:

template<typename T>
void print(T v)
{
    this->Base<T>::print(v);
}
```

I understand that with this template I tell the compiler in which base class to look, but I fail to understand why that would be necessary in the first place.

Body:
When inheriting from a class template multiple times, there is the problem that multiple inheritance of these template classes makes member functions ambiguous (also here), because apparently it is defined that way in the standard.

Question: Why is this defined ambiguous?

Example:

#include <iostream>

template <typename T>
class Base
{
    T val;

public:
    Base(T val) : val(val) {}

    void print(T v)
    {
        std::cout << val << " " << v << std::endl;
    }
};

class Child : public Base<int>, public Base<std::string>
{
public:
    Child() : Base<int>(0), Base<std::string>("0"){}

    // Necessary for successful compilation
//     using Base<int>::print;
//     using Base<std::string>::print;

};

int main()
{
    Child c;

    c.print(1);
    c.print(std::string("1"));

    return 0;
}

produces

error: request for member ‘print’ is ambiguous
   38 |     c.print(1);
      |       ^~~~~
   39 |     c.print(std::string("1"));
      |       ^~~~~
note: candidates are: ‘void Base<T>::print(T) [with T = std::__cxx11::basic_string<char>]’
note:                 ‘void Base<T>::print(T) [with T = int]’

Instead of manually spelling out, as suggested here and here,

using Base<int>::print;
using Base<std::string>::print;

I can just create a template:

template<typename T>
void print(T v)
{
    this->Base<T>::print(v);
}

I understand that with this template I tell the compiler in which base class to look, but I fail to understand why that would be necessary in the first place.


问:
Rust: How to capture a variable and its referring dependants in a closure?
Code:

#[derive(Clone)]
struct S {
    i: i32,
}

fn f1<'a>(s: &'a mut S) -> &'a mut S {
    s.i += 1;
    s
}

fn k<'a>(v: &'a mut Vec<S>) -> impl FnMut() -> i32 + 'a {
    // if I remove this line it's compile
    let mut v = v.clone();

    let v2: Vec<_> = v.iter_mut().map(|s| f1(s)).map(|s| f1(s)).collect();

    move || v2.iter().fold(0, move |accu, value| accu + value.i)
}

fn main() {
    let mut v = vec![S { i: 2 }, S { i: 3 }];
    let mut f = k(&mut v);
    assert_eq!(9, f())
}
```
<p>The compiler complains with:</p>
<pre class="lang-none prettyprint-override"><code>error[E0515]: cannot return value referencing local variable `v`
  --> src/main.rs:17:5
   |
15 |     let v2: Vec<_> = v.iter_mut().map(|s| f1(s)).map(|s| f1(s)).collect();
   |                      ------------ `v` is borrowed here
16 |
17 |     move || v2.iter().fold(0, move |accu, value| accu + value.i)
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ returns a value referencing data owned by the current function
</code>```

Normally I can capture locally created new variables. But in this case I have dependencies between the clone of v and v2.

I thought the compiler can remember this dependency relation and move both in the closure. But he didn't. How can I solve this problem? (Without removing the line. I have a similar problem where I cannot just remove the line, this is the reduced one.)

Body:
Code:

#[derive(Clone)]
struct S {
    i: i32,
}

fn f1<'a>(s: &'a mut S) -> &'a mut S {
    s.i += 1;
    s
}

fn k<'a>(v: &'a mut Vec<S>) -> impl FnMut() -> i32 + 'a {
    // if I remove this line it's compile
    let mut v = v.clone();

    let v2: Vec<_> = v.iter_mut().map(|s| f1(s)).map(|s| f1(s)).collect();

    move || v2.iter().fold(0, move |accu, value| accu + value.i)
}

fn main() {
    let mut v = vec![S { i: 2 }, S { i: 3 }];
    let mut f = k(&mut v);
    assert_eq!(9, f())
}

The compiler complains with:

error[E0515]: cannot return value referencing local variable `v`
  --> src/main.rs:17:5
   |
15 |     let v2: Vec<_> = v.iter_mut().map(|s| f1(s)).map(|s| f1(s)).collect();
   |                      ------------ `v` is borrowed here
16 |
17 |     move || v2.iter().fold(0, move |accu, value| accu + value.i)
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ returns a value referencing data owned by the current function

Normally I can capture locally created new variables. But in this case I have dependencies between the clone of v and v2.

I thought the compiler can remember this dependency relation and move both in the closure. But he didn't. How can I solve this problem? (Without removing the line. I have a similar problem where I cannot just remove the line, this is the reduced one.)


问:
How can I correctly use the pinia store located in composables directory in my Nuxt.js app with Vue Composition API?
I am trying to use the pinia store, defined in /composables/pinia.ts, in my App.vue file. When I try to use it like this: const userStore = useUserStore(), the app does not crash, but a component I created with the Iconify library (which shows icons) is getting disabled. This means that I am not using the definition correctly. What is the correct way of using the store without disabling my Iconify component?
Here is my user store defined in /composables/pinia.ts :

```<code>export const useUserStore = defineStore('userStore', {
  state: () => ({
    user: {} as User,
  }),
  getters: {},
  actions: {},
})
</code>```

Same thing also happens when i try to use a function located in composables directory. It just removes the Icons in the webisite and does not even throws an error or anything. I assume that i am using wrong, that's why nuxt throws an error and stop rendering the icons. In addition here is my BaseIcon component:

```<code><template lang="pug">
Icon(:icon="props.name" :style="styles")
</template>

<script setup lang="ts">
import { Icon, addCollection } from '@iconify/vue'

// @ts-ignore
const Icons = await import('@/assets/icons/icons.auto-generated.json')

addCollection(coolIcons)

interface Props {
  name: string
  size?: string
  color?: string
}
const props = withDefaults(defineProps<Props>(), {
  size: '1em',
  color: 'currentColor',
})

const styles = ref({
  fontSize: props.size,
  color: props.color,
  lineHeight: 1,
})
</script>

</code>```

Body:
I am trying to use the pinia store, defined in /composables/pinia.ts, in my App.vue file. When I try to use it like this: const userStore = useUserStore(), the app does not crash, but a component I created with the Iconify library (which shows icons) is getting disabled. This means that I am not using the definition correctly. What is the correct way of using the store without disabling my Iconify component?
Here is my user store defined in /composables/pinia.ts :

export const useUserStore = defineStore('userStore', {
  state: () => ({
    user: {} as User,
  }),
  getters: {},
  actions: {},
})

Same thing also happens when i try to use a function located in composables directory. It just removes the Icons in the webisite and does not even throws an error or anything. I assume that i am using wrong, that's why nuxt throws an error and stop rendering the icons. In addition here is my BaseIcon component:

<template lang="pug">
Icon(:icon="props.name" :style="styles")
</template>


问:
How to setup bone hierarchy for SCNSkinner from glb data?
I'm trying to show a 3d model of a human body scan in SceneKit. The model is stored in a glb file. Because SceneKit does not support the import of that file format I manually read the file in. I'm trying to use the SCNSkinner from SceneKit to rig the model with the Mixamo-rig included in the glb file. The model is correctly shown as long as I don't apply any bone positions unequal (0, 0, 0), rotations or set boneInverseBindTransforms unequal the Identity matrix. But as soon as I apply any of the afore mentioned properties, the model starts to look unnatural.

Here is the code to create the SCNSkinner object:

```<code>private func createSCNSkinnerFrom(bgArmature: BgArmature, baseGeometry: SCNGeometry) -> SCNSkinner? {
        var joints: [UInt8] = bgArmature.mesh.joints.joined().map { element in UInt8(element) }
        var weights: [Float] = bgArmature.mesh.weights.joined().map { element in element }

        let bones: [SCNNode] = self.createBoneNodesList(bgRig: bgArmature.rig!)

        let boneIndicesData = Data(bytesNoCopy: &joints, count: joints.count * MemoryLayout<UInt8>.size, deallocator: .none)
        let boneIndicesGeometrySource = SCNGeometrySource(data: boneIndicesData, semantic: .boneIndices, vectorCount: joints.count/4, usesFloatComponents: false, componentsPerVector: 4, bytesPerComponent: MemoryLayout<UInt8>.size, dataOffset: 0, dataStride: MemoryLayout<UInt8>.size * 4)

        let boneWeightsData = Data(bytesNoCopy: &weights, count: weights.count * MemoryLayout<Float>.size, deallocator: .none)
        let boneWeightsGeometrySource = SCNGeometrySource(data: boneWeightsData, semantic: .boneWeights, vectorCount: weights.count/4, usesFloatComponents: true, componentsPerVector: 4, bytesPerComponent: MemoryLayout<Float>.size, dataOffset: 0, dataStride: MemoryLayout<Float>.size * 4)

        let boneInverseBindTransforms: [NSValue]? = self.createListOfBoneInverseBindTransforms(bgBones: bgArmature.rig!.bones)

        let skinner = SCNSkinner(baseGeometry: baseGeometry,
                                 bones: bones,
                                 boneInverseBindTransforms: boneInverseBindTransforms,
                                 boneWeights: boneWeightsGeometrySource,
                                 boneIndices: boneIndicesGeometrySource)
        return skinner
    }
</code>```

Here the function to create a bone node and the list of bones:

```<code>private func createBoneNodeWithoutChildren(bgBone: BgBone) -> SCNNode {
        let bone = SCNNode()
        if let name = bgBone.name {
            bone.name = name
        }
        if let translation = bgBone.translation {
            bone.simdPosition = SIMD3<Float>(translation[0]!, translation[1]!, translation[2]!)
        }
        if let rotation = bgBone.rotation {
            bone.simdOrientation = simd_quatf(ix: rotation[0]!, iy: rotation[1]!, iz: rotation[2]!, r: rotation[3]!)
        }
        if let scale = bgBone.scale {
            bone.simdScale = SIMD3<Float>(scale[0]!, scale[1]!, scale[2]!)
        }
        return bone
    }

private func createBoneNodesList(bgRig: BgRig) -> [SCNNode] {
        var bonesList: [SCNNode] = []
        for bone in bgRig.bones {
            bonesList.append(self.createBoneNodeWithoutChildren(bgBone: bone))
        }
        return bonesList
    }
</code>```

The function to create the boneInverseTransforms:

```<code>private func createListOfBoneInverseBindTransforms(bgBones: [BgBone]!) -> [NSValue]? {
        var boneInverseBindTransforms: [NSValue]? = []
        for bone in bgBones {
            boneInverseBindTransforms?.append(NSValue(scnMatrix4: bone.inverseBindMatrix!.getSCNMatrix4()))
        }
        return boneInverseBindTransforms
    }
</code>```

And the BgBone class with the BgMat4 struct:

```<code>class BgBone {
    var index: Int?
    var children: [Int?]?
    var name: String?
    var rotation: [Float?]?
    var scale: [Float?]?
    var translation: [Float?]?
    var inverseBindMatrix: BgMat4?

    init(index: Int? = nil, children: [Int?]? = nil, name: String? = nil, rotation: [Float?]? = nil, scale: [Float?]? = nil, translation: [Float?]? = nil) {
        self.index = index
        self.children = children
        self.name = name
        self.rotation = rotation
        self.scale = scale
        self.translation = translation
    }
}

struct BgMat4: sizeable {
    var r1c1: Float
    var r2c1: Float
    var r3c1: Float
    var r4c1: Float

    var r1c2: Float
    var r2c2: Float
    var r3c2: Float
    var r4c2: Float

    var r1c3: Float
    var r2c3: Float
    var r3c3: Float
    var r4c3: Float

    var r1c4: Float
    var r2c4: Float
    var r3c4: Float
    var r4c4: Float

    init(fromData: Data) {
        /// Accessors of matrix type have data stored in column-major order; start of each column MUST be aligned to 4-byte boundaries.
        /// Specifically, when ROWS * SIZE_OF_COMPONENT (where ROWS is the number of rows of the matrix) is not a multiple of 4,
        /// then (ROWS * SIZE_OF_COMPONENT) % 4 padding bytes MUST be inserted at the end of each column.
        self.r1c1 = fromData.withUnsafeBytes { rawBuffer in rawBuffer.load(fromByteOffset: 0, as: Float32.self) }
        self.r2c1 = fromData.withUnsafeBytes { rawBuffer in rawBuffer.load(fromByteOffset: 4, as: Float32.self) }
        self.r3c1 = fromData.withUnsafeBytes { rawBuffer in rawBuffer.load(fromByteOffset: 8, as: Float32.self) }
        self.r4c1 = fromData.withUnsafeBytes { rawBuffer in rawBuffer.load(fromByteOffset: 12, as: Float32.self) }
        self.r1c2 = fromData.withUnsafeBytes { rawBuffer in rawBuffer.load(fromByteOffset: 16, as: Float32.self) }
        self.r2c2 = fromData.withUnsafeBytes { rawBuffer in rawBuffer.load(fromByteOffset: 20, as: Float32.self) }
        self.r3c2 = fromData.withUnsafeBytes { rawBuffer in rawBuffer.load(fromByteOffset: 24, as: Float32.self) }
        self.r4c2 = fromData.withUnsafeBytes { rawBuffer in rawBuffer.load(fromByteOffset: 28, as: Float32.self) }
        self.r1c3 = fromData.withUnsafeBytes { rawBuffer in rawBuffer.load(fromByteOffset: 32, as: Float32.self) }
        self.r2c3 = fromData.withUnsafeBytes { rawBuffer in rawBuffer.load(fromByteOffset: 36, as: Float32.self) }
        self.r3c3 = fromData.withUnsafeBytes { rawBuffer in rawBuffer.load(fromByteOffset: 40, as: Float32.self) }
        self.r4c3 = fromData.withUnsafeBytes { rawBuffer in rawBuffer.load(fromByteOffset: 44, as: Float32.self) }
        self.r1c4 = fromData.withUnsafeBytes { rawBuffer in rawBuffer.load(fromByteOffset: 48, as: Float32.self) }
        self.r2c4 = fromData.withUnsafeBytes { rawBuffer in rawBuffer.load(fromByteOffset: 52, as: Float32.self) }
        self.r3c4 = fromData.withUnsafeBytes { rawBuffer in rawBuffer.load(fromByteOffset: 56, as: Float32.self) }
        self.r4c4 = fromData.withUnsafeBytes { rawBuffer in rawBuffer.load(fromByteOffset: 60, as: Float32.self) }
    }

    func getSCNMatrix4() -> SCNMatrix4 {
        return SCNMatrix4(m11: self.r1c1,
                          m12: self.r2c1,
                          m13: self.r3c1,
                          m14: self.r4c1,
                          m21: self.r1c2,
                          m22: self.r2c2,
                          m23: self.r3c2,
                          m24: self.r4c2,
                          m31: self.r1c3,
                          m32: self.r2c3,
                          m33: self.r3c3,
                          m34: self.r4c3,
                          m41: self.r1c4,
                          m42: self.r2c4,
                          m43: self.r3c4,
                          m44: self.r4c4)
    }
}
</code>```

With this code the model looks like this:

With Positions==(0, 0, 0), Rotation(0, 0, 0), bindInverseTransformation=Identity it looks like this:

But with the Positions, Rotations and bindInverseTransformations applied I expect the model to be in the A-Pose (similar to the following image):

What am I doing wrong with my bones (SCNNodes) or skinner (SCNSkinner) object?

Body:
I'm trying to show a 3d model of a human body scan in SceneKit. The model is stored in a glb file. Because SceneKit does not support the import of that file format I manually read the file in. I'm trying to use the SCNSkinner from SceneKit to rig the model with the Mixamo-rig included in the glb file. The model is correctly shown as long as I don't apply any bone positions unequal (0, 0, 0), rotations or set boneInverseBindTransforms unequal the Identity matrix. But as soon as I apply any of the afore mentioned properties, the model starts to look unnatural.

Here is the code to create the SCNSkinner object:

private func createSCNSkinnerFrom(bgArmature: BgArmature, baseGeometry: SCNGeometry) -> SCNSkinner? {
        var joints: [UInt8] = bgArmature.mesh.joints.joined().map { element in UInt8(element) }
        var weights: [Float] = bgArmature.mesh.weights.joined().map { element in element }

        let bones: [SCNNode] = self.createBoneNodesList(bgRig: bgArmature.rig!)

        let boneIndicesData = Data(bytesNoCopy: &joints, count: joints.count * MemoryLayout<UInt8>.size, deallocator: .none)
        let boneIndicesGeometrySource = SCNGeometrySource(data: boneIndicesData, semantic: .boneIndices, vectorCount: joints.count/4, usesFloatComponents: false, componentsPerVector: 4, bytesPerComponent: MemoryLayout<UInt8>.size, dataOffset: 0, dataStride: MemoryLayout<UInt8>.size * 4)

        let boneWeightsData = Data(bytesNoCopy: &weights, count: weights.count * MemoryLayout<Float>.size, deallocator: .none)
        let boneWeightsGeometrySource = SCNGeometrySource(data: boneWeightsData, semantic: .boneWeights, vectorCount: weights.count/4, usesFloatComponents: true, componentsPerVector: 4, bytesPerComponent: MemoryLayout<Float>.size, dataOffset: 0, dataStride: MemoryLayout<Float>.size * 4)

        let boneInverseBindTransforms: [NSValue]? = self.createListOfBoneInverseBindTransforms(bgBones: bgArmature.rig!.bones)

        let skinner = SCNSkinner(baseGeometry: baseGeometry,
                                 bones: bones,
                                 boneInverseBindTransforms: boneInverseBindTransforms,
                                 boneWeights: boneWeightsGeometrySource,
                                 boneIndices: boneIndicesGeometrySource)
        return skinner
    }

Here the function to create a bone node and the list of bones:

private func createBoneNodeWithoutChildren(bgBone: BgBone) -> SCNNode {
        let bone = SCNNode()
        if let name = bgBone.name {
            bone.name = name
        }
        if let translation = bgBone.translation {
            bone.simdPosition = SIMD3<Float>(translation[0]!, translation[1]!, translation[2]!)
        }
        if let rotation = bgBone.rotation {
            bone.simdOrientation = simd_quatf(ix: rotation[0]!, iy: rotation[1]!, iz: rotation[2]!, r: rotation[3]!)
        }
        if let scale = bgBone.scale {
            bone.simdScale = SIMD3<Float>(scale[0]!, scale[1]!, scale[2]!)
        }
        return bone
    }

private func createBoneNodesList(bgRig: BgRig) -> [SCNNode] {
        var bonesList: [SCNNode] = []
        for bone in bgRig.bones {
            bonesList.append(self.createBoneNodeWithoutChildren(bgBone: bone))
        }
        return bonesList
    }

The function to create the boneInverseTransforms:

private func createListOfBoneInverseBindTransforms(bgBones: [BgBone]!) -> [NSValue]? {
        var boneInverseBindTransforms: [NSValue]? = []
        for bone in bgBones {
            boneInverseBindTransforms?.append(NSValue(scnMatrix4: bone.inverseBindMatrix!.getSCNMatrix4()))
        }
        return boneInverseBindTransforms
    }

And the BgBone class with the BgMat4 struct:

class BgBone {
    var index: Int?
    var children: [Int?]?
    var name: String?
    var rotation: [Float?]?
    var scale: [Float?]?
    var translation: [Float?]?
    var inverseBindMatrix: BgMat4?

    init(index: Int? = nil, children: [Int?]? = nil, name: String? = nil, rotation: [Float?]? = nil, scale: [Float?]? = nil, translation: [Float?]? = nil) {
        self.index = index
        self.children = children
        self.name = name
        self.rotation = rotation
        self.scale = scale
        self.translation = translation
    }
}

struct BgMat4: sizeable {
    var r1c1: Float
    var r2c1: Float
    var r3c1: Float
    var r4c1: Float

    var r1c2: Float
    var r2c2: Float
    var r3c2: Float
    var r4c2: Float

    var r1c3: Float
    var r2c3: Float
    var r3c3: Float
    var r4c3: Float

    var r1c4: Float
    var r2c4: Float
    var r3c4: Float
    var r4c4: Float

    init(fromData: Data) {
        /// Accessors of matrix type have data stored in column-major order; start of each column MUST be aligned to 4-byte boundaries.
        /// Specifically, when ROWS * SIZE_OF_COMPONENT (where ROWS is the number of rows of the matrix) is not a multiple of 4,
        /// then (ROWS * SIZE_OF_COMPONENT) % 4 padding bytes MUST be inserted at the end of each column.
        self.r1c1 = fromData.withUnsafeBytes { rawBuffer in rawBuffer.load(fromByteOffset: 0, as: Float32.self) }
        self.r2c1 = fromData.withUnsafeBytes { rawBuffer in rawBuffer.load(fromByteOffset: 4, as: Float32.self) }
        self.r3c1 = fromData.withUnsafeBytes { rawBuffer in rawBuffer.load(fromByteOffset: 8, as: Float32.self) }
        self.r4c1 = fromData.withUnsafeBytes { rawBuffer in rawBuffer.load(fromByteOffset: 12, as: Float32.self) }
        self.r1c2 = fromData.withUnsafeBytes { rawBuffer in rawBuffer.load(fromByteOffset: 16, as: Float32.self) }
        self.r2c2 = fromData.withUnsafeBytes { rawBuffer in rawBuffer.load(fromByteOffset: 20, as: Float32.self) }
        self.r3c2 = fromData.withUnsafeBytes { rawBuffer in rawBuffer.load(fromByteOffset: 24, as: Float32.self) }
        self.r4c2 = fromData.withUnsafeBytes { rawBuffer in rawBuffer.load(fromByteOffset: 28, as: Float32.self) }
        self.r1c3 = fromData.withUnsafeBytes { rawBuffer in rawBuffer.load(fromByteOffset: 32, as: Float32.self) }
        self.r2c3 = fromData.withUnsafeBytes { rawBuffer in rawBuffer.load(fromByteOffset: 36, as: Float32.self) }
        self.r3c3 = fromData.withUnsafeBytes { rawBuffer in rawBuffer.load(fromByteOffset: 40, as: Float32.self) }
        self.r4c3 = fromData.withUnsafeBytes { rawBuffer in rawBuffer.load(fromByteOffset: 44, as: Float32.self) }
        self.r1c4 = fromData.withUnsafeBytes { rawBuffer in rawBuffer.load(fromByteOffset: 48, as: Float32.self) }
        self.r2c4 = fromData.withUnsafeBytes { rawBuffer in rawBuffer.load(fromByteOffset: 52, as: Float32.self) }
        self.r3c4 = fromData.withUnsafeBytes { rawBuffer in rawBuffer.load(fromByteOffset: 56, as: Float32.self) }
        self.r4c4 = fromData.withUnsafeBytes { rawBuffer in rawBuffer.load(fromByteOffset: 60, as: Float32.self) }
    }

    func getSCNMatrix4() -> SCNMatrix4 {
        return SCNMatrix4(m11: self.r1c1,
                          m12: self.r2c1,
                          m13: self.r3c1,
                          m14: self.r4c1,
                          m21: self.r1c2,
                          m22: self.r2c2,
                          m23: self.r3c2,
                          m24: self.r4c2,
                          m31: self.r1c3,
                          m32: self.r2c3,
                          m33: self.r3c3,
                          m34: self.r4c3,
                          m41: self.r1c4,
                          m42: self.r2c4,
                          m43: self.r3c4,
                          m44: self.r4c4)
    }
}

With this code the model looks like this:

With Positions==(0, 0, 0), Rotation(0, 0, 0), bindInverseTransformation=Identity it looks like this:

But with the Positions, Rotations and bindInverseTransformations applied I expect the model to be in the A-Pose (similar to the following image):

What am I doing wrong with my bones (SCNNodes) or skinner (SCNSkinner) object?


问:
Acumatica - How to show column header filter above grid
I have a grid on a process screen in Acumatica ERP. When column header filters are selected on the grid, I would like the descriptions of all the selected filters to show above the grid as they do on generic inquiries (see photo below).

I haven't found a way to do this on a regular (non-generic inquiry) screen, neither in the code nor in the ASPX. I'm not sure if there even is a way to do it, but if anyone has any suggestions I'd appreciate it.


问:
I want no NULL values in CASE
I'm using PL/SQL Developer and I want the column NEW_UPDATED to only display 'New in Last 30 Days' or 'Updated in Last 30 Days'
I have NULL values for records that fall outside that range and are not NEW or UPDATED and I don't want these records</p>
```<code>CASE
    WHEN live_date >= SYSDATE - 30 THEN
    'New in Last 30 Days'
    WHEN release_date >= SYSDATE - 30 THEN
    'Updated in Last 30 Days'
END AS NEW_UPDATED
</code>```

Title: I want no NULL values in CASE

Body:
I'm using PL/SQL Developer and I want the column NEW_UPDATED to only display 'New in Last 30 Days' or 'Updated in Last 30 Days'
I have NULL values for records that fall outside that range and are not NEW or UPDATED and I don't want these records

CASE
    WHEN live_date >= SYSDATE - 30 THEN
    'New in Last 30 Days'
    WHEN release_date >= SYSDATE - 30 THEN
    'Updated in Last 30 Days'
END AS NEW_UPDATED


问:
Calendly iframe, no event listener for updateEvent
So I'm working with Calendly iframe and I'm having an unexpected problem, I searched the docs so much and couldn't find a solution.

So Calendly offers a decent iframe with some event listeners for specific use-cases.
I have a single use scheduling url that the iframe receives, when the event is scheduled I fetch a reschedule-url and provide the iframe with it.
The problem is, the event listener for schedule an event is not the same as for update event, and a listener isn't provided for such event... which is so weird for me.

I have no indication when a user updates an event, I can't refresh information from my back-end and display the user with new data.

I guess I'm not the first one with that kind of problem.
Any suggestions?


问:
Pytorch "RuntimeError: Trying to backward through the graph a second time" when increasing the dataset size mid model forward-pass
I am trying to increase the dataset size within model forward passes. My (resnet) model has 6 layers and my dataset is split into batches. Each batch iteration, I forward pass the data through model's first 4 layers (model parameter pass_part = 'first') and take the output. Then, I increase the size of that output by creating synthetic instances (method mixup_data) so that the out size increases from batch_size to 8*batch_size. After that, I split the resulting out into additional batches of batch_size and try to forward them through the last 2 layers my model (pass_part = 'second'). The second iteration of inner loop causes an error: RuntimeError: Trying to backward through the graph a second time, but the saved intermediate results have already been freed. Specify retain_graph=True when calling backward the first time.

What am I doing wrong? The code is below.

```<code>for batch_idx, (data, target, _) in enumerate(train_loader):
        data = data.to(device)
        target_ohe = F.one_hot(target, args.num_classes)
        target_ohe = target_ohe.to(device)

        # Forward pass first part
        out = model(data, depth = args.depth, pass_part = 'first')
        # Mixup data
        out, target_ohe_full, _ = mixup_data.mixup_data(args.method, out, target_ohe, epoch, batch_idx, args.n_fraction, args.g_fraction, args.betaf_alpha, device)
        # Forward pass second part
        ### slice the resulting out into sizes of batch_size
        num_batch_mixup = int(np.ceil(out.shape[0]/args.batch_size))
        for batch_mixup_idx in range(num_batch_mixup):
            out_bm = out[args.batch_size*batch_mixup_idx : args.batch_size*(batch_mixup_idx+1)]
            output = model(out_bm, depth = args.depth, pass_part = 'second')
            target_ohe = target_ohe_full[args.batch_size*batch_mixup_idx : args.batch_size*(batch_mixup_idx+1)]

            loss = criterion(output, target_ohe)

            # Backward
            loss.backward()
            # Gradient clipping
            if args.grad_clip:
                nn.utils.clip_grad_value_(parameters = model.parameters(), clip_value = args.grad_clip)
            # Optimize
            optimizer.step()
            optimizer.zero_grad()
            scheduler.step()
</code>```

Note that if the batch size is not increased (meaning the inner loop will only iterate once), the code works as expected. I do not understand why the error says it is making a second .backward() pass after only one .forward() pass if I cleary send each out_bm though the second part of my model, and calculate loss again (loss = criterion(output, target_ohe)).

Additionally, when setting retain_graph to True (even though I do not understand why that is necessary in my case) I get the following error: RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.cuda.FloatTensor [512]], which is output 22 of BroadcastBackward, is at version 2; expected version 1 instead. Hint: enable anomaly detection to find the operation that failed to compute its gradient, with torch.autograd.set_detect_anomaly(True). The [512] in my case is the number of filters of the out data.

Body:
I am trying to increase the dataset size within model forward passes. My (resnet) model has 6 layers and my dataset is split into batches. Each batch iteration, I forward pass the data through model's first 4 layers (model parameter pass_part = 'first') and take the output. Then, I increase the size of that output by creating synthetic instances (method mixup_data) so that the out size increases from batch_size to 8*batch_size. After that, I split the resulting out into additional batches of batch_size and try to forward them through the last 2 layers my model (pass_part = 'second'). The second iteration of inner loop causes an error: RuntimeError: Trying to backward through the graph a second time, but the saved intermediate results have already been freed. Specify retain_graph=True when calling backward the first time.

What am I doing wrong? The code is below.

for batch_idx, (data, target, _) in enumerate(train_loader):
        data = data.to(device)
        target_ohe = F.one_hot(target, args.num_classes)
        target_ohe = target_ohe.to(device)

        # Forward pass first part
        out = model(data, depth = args.depth, pass_part = 'first')
        # Mixup data
        out, target_ohe_full, _ = mixup_data.mixup_data(args.method, out, target_ohe, epoch, batch_idx, args.n_fraction, args.g_fraction, args.betaf_alpha, device)
        # Forward pass second part
        ### slice the resulting out into sizes of batch_size
        num_batch_mixup = int(np.ceil(out.shape[0]/args.batch_size))
        for batch_mixup_idx in range(num_batch_mixup):
            out_bm = out[args.batch_size*batch_mixup_idx : args.batch_size*(batch_mixup_idx+1)]
            output = model(out_bm, depth = args.depth, pass_part = 'second')
            target_ohe = target_ohe_full[args.batch_size*batch_mixup_idx : args.batch_size*(batch_mixup_idx+1)]

            loss = criterion(output, target_ohe)

            # Backward
            loss.backward()
            # Gradient clipping
            if args.grad_clip:
                nn.utils.clip_grad_value_(parameters = model.parameters(), clip_value = args.grad_clip)
            # Optimize
            optimizer.step()
            optimizer.zero_grad()
            scheduler.step()

Note that if the batch size is not increased (meaning the inner loop will only iterate once), the code works as expected. I do not understand why the error says it is making a second .backward() pass after only one .forward() pass if I cleary send each out_bm though the second part of my model, and calculate loss again (loss = criterion(output, target_ohe)).

Additionally, when setting retain_graph to True (even though I do not understand why that is necessary in my case) I get the following error: RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.cuda.FloatTensor [512]], which is output 22 of BroadcastBackward, is at version 2; expected version 1 instead. Hint: enable anomaly detection to find the operation that failed to compute its gradient, with torch.autograd.set_detect_anomaly(True). The [512] in my case is the number of filters of the out data.


问:
Auditing @OneToMany parent child relation with composite key and owner on single side not working
I have a parent child @OneToMany relation with the one side as owner. The relation is bidirectional.

The reference table ParentChild has a composite key (parentId, childId) and has an additional attribute name. All changes should be audited by envers, therefore we have chosen the owner side on the parent side that adding and removing a child creates a revision of the parent.

But generating the DDL throws the following exception:

```<code>rg.hibernate.MappingException: Repeated column in mapping for entity: com.comfone.audit.test.audittest.data.ParentChild_AUD column: parent_id (should be mapped with insert="false" update="false")
</code>```

Envers tries to generate the ParentChild_AUD table containing the composite key and the audited fields but it also tries to add two columns parent_id and child_id which conflicts with the composite key.

Is this a bug or do I something wrong?

Thanks for your help!

Cheers Andy

Generated DDL:

<?xml version="1.0" encoding="UTF-8"?>
<hibernate-mapping auto-import="false">
 <class entity-name="com.comfone.audit.test.audittest.data.ParentChild_AUD" discriminator-value="ParentChild" table="parent_child_AUD" abstract="false">
  <composite-id name="originalId">
   <key-property name="childId" type="long">
    <column name="child_id" length="255" scale="2" precision="19"/>
   </key-property>
   <key-property name="parentId" type="long">
    <column name="parent_id" length="255" scale="2" precision="19"/>
   </key-property>
   <key-many-to-one type="integer" class="org.hibernate.envers.DefaultRevisionEntity" name="REV">
    <column name="REV"/>
   </key-many-to-one>
  </composite-id>
  <property insert="true" update="false" name="REVTYPE" type="org.hibernate.envers.internal.entities.RevisionTypeType"/>
  <property insert="true" update="false" name="name" type="string">
   <column name="name" length="255" scale="2" precision="19"/>
  </property>
  <property insert="false" update="false" name="child_id" type="long">
   <column name="child_id" length="255" scale="2" precision="19"/>
  </property>
  <property insert="true" update="false" name="parent_id" type="long">
   <column name="parent_id" length="255" scale="2" precision="19"/>
  </property>
 </class>
</hibernate-mapping>
```
<p>Parent.java:</p>
<pre class="lang-java prettyprint-override"><code>Entity
@Audited
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
@EqualsAndHashCode(of = {"id"})
public class Parent implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    private String name;

    @AuditMappedBy(mappedBy = "parent")
    @Builder.Default
    @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
    @JoinColumn(name = "PARENT_ID", insertable = false, updatable = false)
    private Set<ParentChild> parentChildren = new HashSet<>();

    @Version
    @Setter(AccessLevel.NONE)
    private Long version;

    public void addParentChild(ParentChild parentChild) {
        parentChild.setParent(this);
        this.parentChildren.add(parentChild);
    }

    public void removeParentChild(ParentChild parentChild) {
        parentChild.setParent(null);
        this.parentChildren.remove(parentChild);
    }
}
</code>```

ParentChild.java:

@Entity
@Audited
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
@EqualsAndHashCode(of = {"parentChildId"})
public class ParentChild implements Serializable {

    @EmbeddedId
    private final ParentChildId parentChildId = new ParentChildId();

    private String name;

    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    @MapsId("parentId")
    @JoinColumn(insertable = false, updatable = false)
    private Parent parent;

    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    @MapsId("childId")
    @JoinColumn(insertable = false, updatable = false)
    private Child child;

    @Version
    @Setter(AccessLevel.NONE)
    private Long version;
}
```
<p>Child.java:</p>
```@Entity
@Audited
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
@EqualsAndHashCode(of = {"id"})
public class Child {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    private String name;
}
```
<p>Test project:
https://github.com/hotkeeper/jpa-envers-test</p>
<p>It should not generate the two additional columns:</p>
<pre class="lang-xml prettyprint-override"><code><?xml version="1.0" encoding="UTF-8"?>
<hibernate-mapping auto-import="false">
 <class entity-name="com.comfone.audit.test.audittest.data.ParentChild_AUD" discriminator-value="ParentChild" table="parent_child_AUD" abstract="false">
  <composite-id name="originalId">
   <key-property name="childId" type="long">
    <column name="child_id" length="255" scale="2" precision="19"/>
   </key-property>
   <key-property name="parentId" type="long">
    <column name="parent_id" length="255" scale="2" precision="19"/>
   </key-property>
   <key-many-to-one type="integer" class="org.hibernate.envers.DefaultRevisionEntity" name="REV">
    <column name="REV"/>
   </key-many-to-one>
  </composite-id>
  <property insert="true" update="false" name="REVTYPE" type="org.hibernate.envers.internal.entities.RevisionTypeType"/>
  <property insert="true" update="false" name="name" type="string">
   <column name="name" length="255" scale="2" precision="19"/>
  </property>
 </class>
</hibernate-mapping>
</code>```

Body:
I have a parent child @OneToMany relation with the one side as owner. The relation is bidirectional.

The reference table ParentChild has a composite key (parentId, childId) and has an additional attribute name. All changes should be audited by envers, therefore we have chosen the owner side on the parent side that adding and removing a child creates a revision of the parent.

But generating the DDL throws the following exception:

rg.hibernate.MappingException: Repeated column in mapping for entity: com.comfone.audit.test.audittest.data.ParentChild_AUD column: parent_id (should be mapped with insert="false" update="false")

Envers tries to generate the ParentChild_AUD table containing the composite key and the audited fields but it also tries to add two columns parent_id and child_id which conflicts with the composite key.

Is this a bug or do I something wrong?

Thanks for your help!

Cheers Andy

Generated DDL:

<?xml version="1.0" encoding="UTF-8"?>
<hibernate-mapping auto-import="false">
 <class entity-name="com.comfone.audit.test.audittest.data.ParentChild_AUD" discriminator-value="ParentChild" table="parent_child_AUD" abstract="false">
  <composite-id name="originalId">
   <key-property name="childId" type="long">
    <column name="child_id" length="255" scale="2" precision="19"/>
   </key-property>
   <key-property name="parentId" type="long">
    <column name="parent_id" length="255" scale="2" precision="19"/>
   </key-property>
   <key-many-to-one type="integer" class="org.hibernate.envers.DefaultRevisionEntity" name="REV">
    <column name="REV"/>
   </key-many-to-one>
  </composite-id>
  <property insert="true" update="false" name="REVTYPE" type="org.hibernate.envers.internal.entities.RevisionTypeType"/>
  <property insert="true" update="false" name="name" type="string">
   <column name="name" length="255" scale="2" precision="19"/>
  </property>
  <property insert="false" update="false" name="child_id" type="long">
   <column name="child_id" length="255" scale="2" precision="19"/>
  </property>
  <property insert="true" update="false" name="parent_id" type="long">
   <column name="parent_id" length="255" scale="2" precision="19"/>
  </property>
 </class>
</hibernate-mapping>

Parent.java:

Entity
@Audited
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
@EqualsAndHashCode(of = {"id"})
public class Parent implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    private String name;

    @AuditMappedBy(mappedBy = "parent")
    @Builder.Default
    @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
    @JoinColumn(name = "PARENT_ID", insertable = false, updatable = false)
    private Set<ParentChild> parentChildren = new HashSet<>();

    @Version
    @Setter(AccessLevel.NONE)
    private Long version;

    public void addParentChild(ParentChild parentChild) {
        parentChild.setParent(this);
        this.parentChildren.add(parentChild);
    }

    public void removeParentChild(ParentChild parentChild) {
        parentChild.setParent(null);
        this.parentChildren.remove(parentChild);
    }
}

ParentChild.java:

@Entity
@Audited
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
@EqualsAndHashCode(of = {"parentChildId"})
public class ParentChild implements Serializable {

    @EmbeddedId
    private final ParentChildId parentChildId = new ParentChildId();

    private String name;

    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    @MapsId("parentId")
    @JoinColumn(insertable = false, updatable = false)
    private Parent parent;

    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    @MapsId("childId")
    @JoinColumn(insertable = false, updatable = false)
    private Child child;

    @Version
    @Setter(AccessLevel.NONE)
    private Long version;
}

Child.java:

@Entity
@Audited
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
@EqualsAndHashCode(of = {"id"})
public class Child {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    private String name;
}

Test project:
https://github.com/hotkeeper/jpa-envers-test

It should not generate the two additional columns:

<?xml version="1.0" encoding="UTF-8"?>
<hibernate-mapping auto-import="false">
 <class entity-name="com.comfone.audit.test.audittest.data.ParentChild_AUD" discriminator-value="ParentChild" table="parent_child_AUD" abstract="false">
  <composite-id name="originalId">
   <key-property name="childId" type="long">
    <column name="child_id" length="255" scale="2" precision="19"/>
   </key-property>
   <key-property name="parentId" type="long">
    <column name="parent_id" length="255" scale="2" precision="19"/>
   </key-property>
   <key-many-to-one type="integer" class="org.hibernate.envers.DefaultRevisionEntity" name="REV">
    <column name="REV"/>
   </key-many-to-one>
  </composite-id>
  <property insert="true" update="false" name="REVTYPE" type="org.hibernate.envers.internal.entities.RevisionTypeType"/>
  <property insert="true" update="false" name="name" type="string">
   <column name="name" length="255" scale="2" precision="19"/>
  </property>
 </class>
</hibernate-mapping>


问:
Accessibility issue: AXIsProcessTrusted() returns false on TestFlight release (debug/release builds are ok)
Even if Accessibility is trusted function AXIsProcessTrusted() returns false on TestFlight release

This behaviour can be reproduced ONLY on TestFlight release

(In local debug and release builds all works well)

What can be reason?

upd: tried another way with same results:

```<code>fileprivate func checkIsTrusted() -> Bool {
    let prompt = kAXTrustedCheckOptionPrompt.takeUnretainedValue() as String
    let options: NSDictionary = [prompt: true]
    let appHasPermission = AXIsProcessTrustedWithOptions(options)

    return AXIsProcessTrusted() || appHasPermission
}

</code>```

PC restart also din't help

Environment information:

Xcode: Version 14.2 (14C18)

MacOs: Ventura 13.1 (22C65)

Build type: TestFlight release (local debug and release versions works well, issue in TestFlight release only)

Body:
Even if Accessibility is trusted function AXIsProcessTrusted() returns false on TestFlight release

This behaviour can be reproduced ONLY on TestFlight release

(In local debug and release builds all works well)

What can be reason?

upd: tried another way with same results:

fileprivate func checkIsTrusted() -> Bool {
    let prompt = kAXTrustedCheckOptionPrompt.takeUnretainedValue() as String
    let options: NSDictionary = [prompt: true]
    let appHasPermission = AXIsProcessTrustedWithOptions(options)

    return AXIsProcessTrusted() || appHasPermission
}

PC restart also din't help

Environment information:

Xcode: Version 14.2 (14C18)

MacOs: Ventura 13.1 (22C65)

Build type: TestFlight release (local debug and release versions works well, issue in TestFlight release only)


问:
Unexpected behaviour of an igraph object with append function
I use igraph library in R to create graphs, then put them into a list. To this I am trying to append a new graph. Though the new element appends, it gets "unlisted".
Please advise how to prevent this behaviour. Expected is a list of graph objects.

```<code>library(igraph)

m1 <- matrix(c(1:3,2:4), ncol=2)
m2 <- matrix(c(1:4,2:5), ncol=2)

g1 <- graph.edgelist(m1)
g2 <- graph.edgelist(m2)

g_l <- list(g1)
(g_l <- append(g_l, g2))

> [[1]]
> IGRAPH eadfb20 D--- 4 3 --
> edges from eadfb20:
> [1] 1->2 2->3 3->4
>
> [[2]]
> [1] 5
>
> [[3]]
> [1] TRUE
>
> [[4]]
> [1] 0 1 2 3
>
> [[5]]
> [1] 1 2 3 4
>
> [[6]]
> [1] 0 1 2 3
>
> [[7]]
> [1] 0 1 2 3
>
> [[8]]
> [1] 0 1 2 3 4 4
>
> [[9]]
> [1] 0 0 1 2 3 4
>
> [[10]]
> [[10]][[1]]
> [1] 1 0 1
>
> [[10]][[2]]
> named list()
>
> [[10]][[3]]
> list()
>
> [[10]][[4]]
> list()
>
>
> [[11]]
> <environment: 0x000002d578c2eb70>
</code>```

Here is an expected output:

```<code>> [[1]]
> IGRAPH eadfb20 D--- 4 3 --
> edges from eadfb20:
> [1] 1->2 2->3 3->4
>
> [[2]]
> IGRAPH eadfe8b D--- 5 4 --
> edges from eadfe8b:
> [1] 1->2 2->3 3->4 4->5
</code>```

Body:
I use igraph library in R to create graphs, then put them into a list. To this I am trying to append a new graph. Though the new element appends, it gets "unlisted".
Please advise how to prevent this behaviour. Expected is a list of graph objects.

library(igraph)

m1 <- matrix(c(1:3,2:4), ncol=2)
m2 <- matrix(c(1:4,2:5), ncol=2)

g1 <- graph.edgelist(m1)
g2 <- graph.edgelist(m2)

g_l <- list(g1)
(g_l <- append(g_l, g2))

> [[1]]
> IGRAPH eadfb20 D--- 4 3 --
> edges from eadfb20:
> [1] 1->2 2->3 3->4
>
> [[2]]
> [1] 5
>
> [[3]]
> [1] TRUE
>
> [[4]]
> [1] 0 1 2 3
>
> [[5]]
> [1] 1 2 3 4
>
> [[6]]
> [1] 0 1 2 3
>
> [[7]]
> [1] 0 1 2 3
>
> [[8]]
> [1] 0 1 2 3 4 4
>
> [[9]]
> [1] 0 0 1 2 3 4
>
> [[10]]
> [[10]][[1]]
> [1] 1 0 1
>
> [[10]][[2]]
> named list()
>
> [[10]][[3]]
> list()
>
> [[10]][[4]]
> list()
>
>
> [[11]]
> <environment: 0x000002d578c2eb70>

Here is an expected output:

> [[1]]
> IGRAPH eadfb20 D--- 4 3 --
> edges from eadfb20:
> [1] 1->2 2->3 3->4
>
> [[2]]
> IGRAPH eadfe8b D--- 5 4 --
> edges from eadfe8b:
> [1] 1->2 2->3 3->4 4->5


问:
Blazor custom element in a razor page. WebAssemblyPrerendered?
In a Razor page, I can instance a Blazor web assembly component with pre-render enabled like this:

```<code><component type="typeof(MyThing)" param-one param-two render-mode="WebAssemblyPrerendered" />
</code>```

When defining rules like this:

```<code>builder.RootComponents.RegisterCustomElement<MyThing>("my-thing");

</code>```

the following works fine in a razor page (cleaner, nicer syntax):

```<code><my-thing one="one" two="2" />
</code>```

The thing is, I see no way to configure it to be pre-rendered.
Perhaps it isn't possible at all to accomplish this, but I'm asking just in case.

Thanks

Body:
In a Razor page, I can instance a Blazor web assembly component with pre-render enabled like this:

<component type="typeof(MyThing)" param-one param-two render-mode="WebAssemblyPrerendered" />

When defining rules like this:

builder.RootComponents.RegisterCustomElement<MyThing>("my-thing");

the following works fine in a razor page (cleaner, nicer syntax):

<my-thing one="one" two="2" />

The thing is, I see no way to configure it to be pre-rendered.
Perhaps it isn't possible at all to accomplish this, but I'm asking just in case.

Thanks


问:
How to get 0 if no such entry in a related table in Ecto?
I have three tables: location, product, and stock.

In the stock table, the fields product_id, location_id, and quantity are present. However, when a location is created (or a product, for that matter), no stock entry is created automatically. This is because, by default, to represent 'no stock', a either a stock entry with quantity '0' is used, or no entry at all. This is to prevent having to add many entries to this table when creating a new location or product.

However, I am having trouble with querying the stock of products in each location.

What I want to do is this:

Get all locations

For each location, if there is an entry in the stock table with the specific product ID we're looking for, return the quantity.

If not, return 0.

This sounds simple, but I'd prefer to do this with as few queries as possible (ideally just the one).

My original idea was:

```<code>Repo.all(Location) |> Enum.map(fn loc ->
  if Repo.exists?(from l in Location,
    left_join: s in Stock,
    where: l.id == ^loc.id and s.product_id == ^product_id) then
    Repo.one(from l in Location, left_join: s in Stock, select: s.quantity, where: l.id == ^loc.id and s.product_id == ^product_id)
  else
    0
  end
end)
</code>```

but as you can see, this is very cumbersome, and makes many queries, especially with many locations.

Thanks in advance!

Body:
I have three tables: location, product, and stock.

In the stock table, the fields product_id, location_id, and quantity are present. However, when a location is created (or a product, for that matter), no stock entry is created automatically. This is because, by default, to represent 'no stock', a either a stock entry with quantity '0' is used, or no entry at all. This is to prevent having to add many entries to this table when creating a new location or product.

However, I am having trouble with querying the stock of products in each location.

What I want to do is this:

Get all locations

For each location, if there is an entry in the stock table with the specific product ID we're looking for, return the quantity.

If not, return 0.

This sounds simple, but I'd prefer to do this with as few queries as possible (ideally just the one).

My original idea was:

Repo.all(Location) |> Enum.map(fn loc ->
  if Repo.exists?(from l in Location,
    left_join: s in Stock,
    where: l.id == ^loc.id and s.product_id == ^product_id) then
    Repo.one(from l in Location, left_join: s in Stock, select: s.quantity, where: l.id == ^loc.id and s.product_id == ^product_id)
  else
    0
  end
end)

but as you can see, this is very cumbersome, and makes many queries, especially with many locations.

Thanks in advance!