8 – How can I avoid to return HTML markup for access denied?

I’ve developed a custom controller that serves as a simple endpoint, POST method.

This controller has custom access control.

Custom access is done by looking for a header in the HTTP request, by making the controller object a service as well.

Everything works great. Except that when I return AccessResult::forbidden() .. I get the HTML of the access denied page .. and I don’t really want that .. I’d like to return just a short bit of JSON.

What can I do to return something that is JSON, and not the Access Denied page HTML, for this particular route, when the access() method returns AccessResult::forbidden() ?

I’ve read that appending ?_format=json to the url works, and in my case it does. Is there anyway to achieve the same result without adding this url parameter?

8 – How can I avoid to return an access denied page?

I’ve developed a custom controller that serves as a simple endpoint, POST method.

This controller has custom access control.

Custom access is done by looking for a header in the HTTP request, by making the controller object a service as well.

Everything works great. Except that when I return AccessResult::forbidden() .. I get the HTML of the access denied page .. and I don’t really want that .. I’d like to return just a short bit of JSON.

What can I do to return something that is JSON, and not the Access Denied page HTML, for this particular route, when the access() method returns AccessResult::forbidden() ?

I’ve read that appending ?_format=json to the url works, and in my case it does. Is there anyway to achieve the same result without adding this url parameter?

performance – Python Avoid Loop with numpy

The problem is this:

I have a numpy array called “contour” of N coordinates (x,y) so of dimension (N , 2)

For each point in this table, I would like to create a square centered at that point and perform a test on the square formed.

I wanted to know if you had a way to solve my problem without using a for loop!

My version with a for loop:

def neighbour(point , mask  , n ): # Create the square around this point and count the number of neighbors.
      mask = mask(point(0) - int(n/2) : point(0) + int(n/2) + 1,point(1) - int(n/2):point(1) + int(n/2) + 1)
      return n**2 - np.count_nonzero(mask)



def max_neighbour(contour , mask=maske , n=ne): # Find the point with as many neighbors as possible
    t = np.zeros(len(contour)) # contour is the numpy array of dimension (2,N)
    for i in range(len(contour)):
        t(i) = neighbour(contour(i),mask,n)        
    return contour(np.argmax(t)) # t contains the list of neighbors for each contour point.

sony alpha – Filming welding – avoid highlight clipping

I’m filming TIG welding on Sony A7 III without a welding mask.

The best results with auto-focus and automatic exposure I was able to get are below – using PP10 HLG3 with Knee set to 75% slope -5 and exposure adjustment to -2 – as you see, highlights are still blown.

Is there any way I can preserve the highlights without using manual exposure? Many thanks.

DaVinci Resolve showing highlight clipping

mathematical optimization – NMinimize: How to avoid solutions that do not satisfy constraints within a certain tolerance?

Here’s how you can do it by adding some slack into the constraints and punishing slack in the objective:

SeedRandom(1);

(* the function you're trying to minimize *)
objective = ((e*(1 - Sqrt((g - e)^2 + (f - h)^2)) + (g - e)*(1 - 
          Sqrt(f^2 + e^2))) + (h*(1 - 
          Sqrt((g - e)^2 + (f - h)^2)) + (f - h)*(1 - 
          Sqrt(g^2 + h^2))))/((g + f)*
     Max(1 - Sqrt((g - e)^2 + (f - h)^2), 1 - Sqrt(g^2 + h^2)));

(* these are the hard constraints *)
constraints = {
   0 <= e <= 1,
   0 <= f <= 1,
   e^2 + f^2 == 1,
   e <= g <= 1,
   0 <= h <= f,
   Sqrt((g - e)^2 + (f - h)^2) <= 1,
   g^2 + h^2 <= 1
   };

(* these constraints are softer and allow for a bit of slack *)
slackedConstraints = {
   0 - se <= e <= 1 + se,
   0 - sf <= f <= 1 - sf,
   -sef1 < e^2 + f^2 - 1 < sef1,
   e <= g <= 1,
   0 - sh <= h <= f + sh,
   Sqrt((g - e)^2 + (f - h)^2) <= 1,
   g^2 + h^2 - 1 <= 0
   };
variables = {e, f, g, h};
slackterms = {se, sf, sh, sef1};

(* solve it and harshly punish too much total squared slack *)
sol = Last(
  NMinimize({objective + 10^10*Total(slackterms^2), 
    slackedConstraints}, Join(variables, slackterms)))

(* RESULT:
{e -> 0.25283, f -> 0.967511, g -> 0.944242, h -> 0.329154, 
 se -> 4.51664*10^-14, sf -> -2.52757*10^-13, sh -> 3.93093*10^-14, 
 sef1 -> 1.92914*10^-7} *)

objective /. sol
(* result: 0.304607 *)

(* Substitute back into the hard constraints to check if any violated *)
constraints /. sol
(* {True, True, False, True, True, True, True} *)

(* hard constraint #3 is violated, but only by a tiny amount: *)
e^2 + f^2 /. sol
(* result 1. *)

postgresql – Avoid duplicate WHERE clause on both sides of a LEFT JOIN, without changing semantics or impairing query optimization

I have a table recording the results of a web crawl. (Table
definition at the end of this question.) The relevant part of the data
stored in it looks like this:

 experiment_id | url_id | redirect_num | full_url_id | has_blockpage_regex | blockpage_reason_id
---------------+--------+--------------+-------------+---------------------+---------------------
            16 |   1312 |            0 |        1312 |                   f |
            16 |   1312 |            1 |        2311 |                   f |
            16 |   1312 |            2 |        2312 |                   f |
            16 |   1312 |            3 |        2313 |                   f |
            43 |   1320 |            0 |        1320 |                   f |
            43 |   1320 |            2 |        2312 |                   f |
            43 |   1320 |            1 |        2317 |                   t |                   1
            43 |   1320 |            3 |        2318 |                   f |

For each (experiment_id, url_id) pair, from a small set of experiment IDs, I want to query the full_url_id associated with the largest value of redirect_num, and the blockpage_reason_id associated with the smallest value of redirect_num for which has_blockpage_regex is true. (If there is no row satisfying the latter condition, blockpage_reason_id should come out null.) For the data above, the desired results would be like this:

 experiment_id | url_id | full_url_id | blockpage_reason_id
---------------+--------+-------------+---------------------
            16 |   1312 |        2313 |
            43 |   1320 |        2318 |                   1

I have a query that does what I want, but it’s extremely slow, involving multiple full table scans.
(EXPLAIN ANALYZE dump also at the end of the question.)

select x.experiment_id, x.url_id, x.full_url_id, y.blockpage_reason_id from (
  select bm.experiment_id, bm.url_id, b.full_url_id
    from blockpage b
    join (select experiment_id, url_id, max(redirect_num) as redirect_num
            from blockpage
           group by experiment_id, url_id) bm
      on b.experiment_id = bm.experiment_id
     and b.url_id = bm.url_id
     and b.redirect_num = bm.redirect_num
) x left join (
  select bm.experiment_id, bm.url_id,
         b.has_blockpage_regex, b.blockpage_reason_id
    from blockpage b
    join (select experiment_id, url_id, max(redirect_num) as redirect_num
            from blockpage
           where has_blockpage_regex
           group by experiment_id, url_id) bm
      on b.experiment_id = bm.experiment_id
     and b.url_id = bm.url_id
     and b.redirect_num = bm.redirect_num
) y on x.experiment_id = y.experiment_id
   and x.url_id = y.url_id
 where x.experiment_id in (16,43);

I can make it work efficiently by duplicating the WHERE clause at the very end into the subselects on both sides of the LEFT JOIN:

select x.experiment_id, x.url_id, x.full_url_id, y.blockpage_reason_id from (
  select bm.experiment_id, bm.url_id, b.full_url_id
    from blockpage b
    join (select experiment_id, url_id, max(redirect_num) as redirect_num
            from blockpage
           group by experiment_id, url_id) bm
      on b.experiment_id = bm.experiment_id
     and b.url_id = bm.url_id
     and b.redirect_num = bm.redirect_num
   where bm.experiment_id in (16,43)         -- DUPLICATED
) x left join (
  select bm.experiment_id, bm.url_id,
         b.has_blockpage_regex, b.blockpage_reason_id
    from blockpage b
    join (select experiment_id, url_id, max(redirect_num) as redirect_num
            from blockpage
           where has_blockpage_regex
           group by experiment_id, url_id) bm
      on b.experiment_id = bm.experiment_id
     and b.url_id = bm.url_id
     and b.redirect_num = bm.redirect_num
   where bm.experiment_id in (16,43)         -- DUPLICATED
) y on x.experiment_id = y.experiment_id
   and x.url_id = y.url_id;

But this will not work in practice, because the query (without the WHERE) is going to be used as a view definition, and people will select with WHEREs from the view, which is equivalent to applying a single WHERE to the outermost SELECT.

So my question is, how do I rewrite this query so that WHEREs on the outermost SELECT will be executed as efficiently as they are if I push them inside the LEFT JOIN manually? Change it as much as you want, as long as it still produces the same results as the example at the top.

Database is Postgres 12.2.


EXPLAIN ANALYZE for the original query:

 Nested Loop Left Join  (cost=1315730.90..3856617.09 rows=20 width=16) (actual time=36112.365..55406.053 rows=501 loops=1)
   Output: blockpage.experiment_id, blockpage.url_id, b.full_url_id, b_1.blockpage_reason_id
   Join Filter: ((blockpage.experiment_id = blockpage_1.experiment_id) AND (blockpage.url_id = blockpage_1.url_id))
   Rows Removed by Join Filter: 220714047
   ->  Nested Loop  (cost=1.14..88505.96 rows=20 width=12) (actual time=466.302..480.840 rows=501 loops=1)
         Output: b.full_url_id, blockpage.experiment_id, blockpage.url_id
         ->  GroupAggregate  (cost=0.57..15442.73 rows=8543 width=12) (actual time=466.267..470.146 rows=501 loops=1)
               Output: blockpage.experiment_id, blockpage.url_id, max(blockpage.redirect_num)
               Group Key: blockpage.experiment_id, blockpage.url_id
               ->  Index Only Scan using blockpage_experiment_id_url_id_redirect_num_blockpage_reason__ on iclab.blockpage  (cost=0.57..15293.19 rows=8547 width=12) (actual time=0.048..1.662 rows=803 loops=1)
                     Output: blockpage.experiment_id, blockpage.url_id, blockpage.full_url_id, blockpage.redirect_num, blockpage.html_tag_id
                     Index Cond: (blockpage.experiment_id = ANY ('{16,43}'::integer()))
                     Heap Fetches: 803
         ->  Index Only Scan using blockpage_experiment_id_url_id_redirect_num_blockpage_reason__ on iclab.blockpage b  (cost=0.57..8.53 rows=1 width=16) (actual time=0.016..0.018 rows=1 loops=501)
               Output: b.experiment_id, b.url_id, b.full_url_id, b.redirect_num, b.html_tag_id
               Index Cond: ((b.experiment_id = blockpage.experiment_id) AND (b.url_id = blockpage.url_id) AND (b.redirect_num = (max(blockpage.redirect_num))))
               Heap Fetches: 501
   ->  Materialize  (cost=1315729.77..3767691.70 rows=1207 width=12) (actual time=7.067..89.428 rows=440547 loops=501)
         Output: b_1.blockpage_reason_id, blockpage_1.experiment_id, blockpage_1.url_id
         ->  Hash Join  (cost=1315729.77..3767685.66 rows=1207 width=12) (actual time=3540.653..35478.463 rows=440547 loops=1)
               Output: b_1.blockpage_reason_id, blockpage_1.experiment_id, blockpage_1.url_id
               Inner Unique: true
               Hash Cond: ((b_1.experiment_id = blockpage_1.experiment_id) AND (b_1.url_id = blockpage_1.url_id) AND (b_1.redirect_num = (max(blockpage_1.redirect_num))))
               ->  Seq Scan on iclab.blockpage b_1  (cost=0.00..1757677.88 rows=88162288 width=16) (actual time=0.012..9535.931 rows=88164599 loops=1)
                     Output: b_1.id, b_1.url_id, b_1.full_url_id, b_1.experiment_id, b_1.blockpage_reason_id, b_1.html_tag_id, b_1.body_len, b_1.blockpage_diff, b_1.has_blockpage_regex, b_1.http_status, b_1.redirect_num, b_1.response_failure
               ->  Hash  (cost=1306621.31..1306621.31 rows=520483 width=12) (actual time=3538.005..3538.005 rows=440547 loops=1)
                     Output: blockpage_1.experiment_id, blockpage_1.url_id, (max(blockpage_1.redirect_num))
                     Buckets: 524288  Batches: 1  Memory Usage: 23026kB
                     ->  Finalize HashAggregate  (cost=1296211.65..1301416.48 rows=520483 width=12) (actual time=3325.126..3427.920 rows=440547 loops=1)
                           Output: blockpage_1.experiment_id, blockpage_1.url_id, max(blockpage_1.redirect_num)
                           Group Key: blockpage_1.experiment_id, blockpage_1.url_id
                           ->  Gather  (cost=1246069.28..1292868.83 rows=445710 width=12) (actual time=3029.657..3143.505 rows=441870 loops=1)
                                 Output: blockpage_1.experiment_id, blockpage_1.url_id, (PARTIAL max(blockpage_1.redirect_num))
                                 Workers Planned: 2
                                 Workers Launched: 2
                                 JIT for worker 0:
                                   Functions: 9
                                   Options: Inlining true, Optimization true, Expressions true, Deforming true
                                   Timing: Generation 1.136 ms, Inlining 51.049 ms, Optimization 73.089 ms, Emission 39.722 ms, Total 164.995 ms
                                 JIT for worker 1:
                                   Functions: 9
                                   Options: Inlining true, Optimization true, Expressions true, Deforming true
                                   Timing: Generation 2.075 ms, Inlining 72.675 ms, Optimization 70.854 ms, Emission 39.490 ms, Total 185.093 ms
                                 ->  Partial HashAggregate  (cost=1245069.28..1247297.83 rows=222855 width=12) (actual time=3004.908..3047.674 rows=147290 loops=3)
                                       Output: blockpage_1.experiment_id, blockpage_1.url_id, PARTIAL max(blockpage_1.redirect_num)
                                       Group Key: blockpage_1.experiment_id, blockpage_1.url_id
                                       Worker 0: actual time=2999.661..3042.358 rows=137916 loops=1
                                       Worker 1: actual time=2985.698..3026.195 rows=144767 loops=1
                                       ->  Parallel Seq Scan on iclab.blockpage blockpage_1  (cost=0.00..1243397.87 rows=222855 width=12) (actual time=115.822..2924.688 rows=177783 loops=3)
                                             Output: blockpage_1.id, blockpage_1.url_id, blockpage_1.full_url_id, blockpage_1.experiment_id, blockpage_1.blockpage_reason_id, blockpage_1.html_tag_id, blockpage_1.body_len, blockpage_1.blockpage_diff, blockpage_1.has_blockpage_regex, blockpage_1.http_status, blockpage_1.redirect_num, blockpage_1.response_failure
                                             Filter: blockpage_1.has_blockpage_regex
                                             Rows Removed by Filter: 29210417
                                             Worker 0: actual time=164.165..2922.106 rows=165851 loops=1
                                             Worker 1: actual time=183.286..2912.232 rows=173763 loops=1
 Planning Time: 1.013 ms
 JIT:
   Functions: 60
   Options: Inlining true, Optimization true, Expressions true, Deforming true
   Timing: Generation 11.387 ms, Inlining 132.486 ms, Optimization 415.860 ms, Emission 264.166 ms, Total 823.898 ms
 Execution Time: 55458.769 ms

EXPLAIN ANALYZE for the query with duplicate WHEREs:

 Merge Left Join  (cost=2.27..104247.90 rows=20 width=16) (actual time=40.938..44.044 rows=501 loops=1)
   Output: blockpage.experiment_id, blockpage.url_id, b.full_url_id, b_1.blockpage_reason_id
   Merge Cond: ((blockpage.experiment_id = blockpage_1.experiment_id) AND (blockpage.url_id = blockpage_1.url_id))
   ->  Nested Loop  (cost=1.14..88505.96 rows=20 width=12) (actual time=40.603..43.615 rows=501 loops=1)
         Output: b.full_url_id, blockpage.experiment_id, blockpage.url_id
         ->  GroupAggregate  (cost=0.57..15442.73 rows=8543 width=12) (actual time=40.561..41.298 rows=501 loops=1)
               Output: blockpage.experiment_id, blockpage.url_id, max(blockpage.redirect_num)
               Group Key: blockpage.experiment_id, blockpage.url_id
               ->  Index Only Scan using blockpage_experiment_id_url_id_redirect_num_blockpage_reason__ on iclab.blockpage  (cost=0.57..15293.19 rows=8547 width=12) (actual time=0.045..0.432 rows=803 loops=1)
                     Output: blockpage.experiment_id, blockpage.url_id, blockpage.full_url_id, blockpage.redirect_num, blockpage.html_tag_id
                     Index Cond: (blockpage.experiment_id = ANY ('{16,43}'::integer()))
                     Heap Fetches: 803
         ->  Index Only Scan using blockpage_experiment_id_url_id_redirect_num_blockpage_reason__ on iclab.blockpage b  (cost=0.57..8.53 rows=1 width=16) (actual time=0.004..0.004 rows=1 loops=501)
               Output: b.experiment_id, b.url_id, b.full_url_id, b.redirect_num, b.html_tag_id
               Index Cond: ((b.experiment_id = blockpage.experiment_id) AND (b.url_id = blockpage.url_id) AND (b.redirect_num = (max(blockpage.redirect_num))))
               Heap Fetches: 501
   ->  Materialize  (cost=1.14..15741.83 rows=1 width=12) (actual time=0.329..0.329 rows=0 loops=1)
         Output: b_1.blockpage_reason_id, blockpage_1.experiment_id, blockpage_1.url_id
         ->  Nested Loop  (cost=1.14..15741.82 rows=1 width=12) (actual time=0.326..0.326 rows=0 loops=1)
               Output: b_1.blockpage_reason_id, blockpage_1.experiment_id, blockpage_1.url_id
               ->  GroupAggregate  (cost=0.57..15294.10 rows=52 width=12) (actual time=0.325..0.325 rows=0 loops=1)
                     Output: blockpage_1.experiment_id, blockpage_1.url_id, max(blockpage_1.redirect_num)
                     Group Key: blockpage_1.experiment_id, blockpage_1.url_id
                     ->  Index Scan using blockpage_experiment_id_url_id_redirect_num_blockpage_reason__ on iclab.blockpage blockpage_1  (cost=0.57..15293.19 rows=52 width=12) (actual time=0.324..0.325 rows=0 loops=1)
                           Output: blockpage_1.id, blockpage_1.url_id, blockpage_1.full_url_id, blockpage_1.experiment_id, blockpage_1.blockpage_reason_id, blockpage_1.html_tag_id, blockpage_1.body_len, blockpage_1.blockpage_diff, blockpage_1.has_blockpage_regex, blockpage_1.http_status, blockpage_1.redirect_num, blockpage_1.response_failure
                           Index Cond: (blockpage_1.experiment_id = ANY ('{16,43}'::integer()))
                           Filter: blockpage_1.has_blockpage_regex
                           Rows Removed by Filter: 803
               ->  Index Scan using blockpage_experiment_id_url_id_redirect_num_blockpage_reason__ on iclab.blockpage b_1  (cost=0.57..8.59 rows=1 width=16) (never executed)
                     Output: b_1.id, b_1.url_id, b_1.full_url_id, b_1.experiment_id, b_1.blockpage_reason_id, b_1.html_tag_id, b_1.body_len, b_1.blockpage_diff, b_1.has_blockpage_regex, b_1.http_status, b_1.redirect_num, b_1.response_failure
                     Index Cond: ((b_1.experiment_id = blockpage_1.experiment_id) AND (b_1.url_id = blockpage_1.url_id) AND (b_1.redirect_num = (max(blockpage_1.redirect_num))))
 Planning Time: 1.004 ms
 JIT:
   Functions: 33
   Options: Inlining false, Optimization false, Expressions true, Deforming true
   Timing: Generation 6.438 ms, Inlining 0.000 ms, Optimization 1.856 ms, Emission 38.146 ms, Total 46.440 ms
 Execution Time: 50.745 ms

Table definition:

CREATE TABLE iclab.blockpage (
    id                          BIGSERIAL   PRIMARY KEY,
    url_id                      INTEGER     NOT NULL,
    full_url_id                 INTEGER     NOT NULL,
    experiment_id               INTEGER     NOT NULL,
    blockpage_reason_id         INTEGER,
    html_tag_id                 INTEGER     NOT NULL,
    body_len                    INTEGER,
    blockpage_diff              REAL,
    has_blockpage_regex         BOOLEAN,
    http_status                 INTEGER,
    redirect_num                INTEGER     NOT NULL,
    response_failure            INTEGER,
    FOREIGN KEY (experiment_id)         REFERENCES iclab.experiment_results(id),
    FOREIGN KEY(url_id)                 REFERENCES iclab.URL(id),
    FOREIGN KEY(url_id)                 REFERENCES iclab.URL(id),
    FOREIGN KEY(blockpage_reason_id)    REFERENCES iclab.blockpage_reason(id),
    FOREIGN KEY(html_tag_id)            REFERENCES iclab.html_tag(id)
);

CREATE UNIQUE INDEX blockpage_experiment_id_url_id_redirect_num_blockpage_reason__
    ON iclab.blockpage(experiment_id , url_id, full_url_id, redirect_num, html_tag_id);

macos – How can I avoid iTerm trying to scp a file when ⌘-clicking it?

I am working with a developer setup so that I run my code in a docker container and be able to edit it locally (via volume). Local path is e.g. /path/to/my/project while inside docker container it is /app/source.
Say I have a file relative to the project called app/models/team.rb.

On an error in the container I see an output like this:

/app/source/app/models/team.rb:13:in my_method...

iTerm seemed to be smart about the open on -click such that it underlined only the app/models/team.rb:13 (incl. line number) when I hover over the a of app (unfortunately only on the first character), and opened the local file in my editor (VSCode). That was already great.

I now added an iTerm profile that identifies when a session is running inside docker (greedy: auto profile switching checking for “&docker“) and sets the hostname and path via Triggers and regex (besides colors etc). This also works fine.

However now when I hover over the filename, the whole path is underlined and when I -click, iTerm tries to download via scp (which fails).

How can I avoid iTerm to try to scp the file and make it realize again how to load the local file?

I already tried not to set the hostname, but this results in iTerm not providing anything anymore for opening. When I don’t set the path then it’s working like before of course, but I’d like to have this information of the docker container in the status bar.

c# – What improvements can I do to avoid the virtual method call in the constructor?

I am trying to solve the warning, which avoids the call of a virtual method, I have seen different answers, but none of them seems to solve my doubt, I understand why this warning appears and is one of the ones you should not suppress. My code gets data from Matlab and uses a method to configure the limits in a usercontrol. Should I build another class to call from there the method?

abstract public class MatlabData:eSoundMaster
{
    //(sdon) changed to override from derived class
    public bool EQAMAvail = false;
    public readonly int numTonspuren = 32;
    public readonly int numSubgroups = 8;
    public readonly int numStandardTS = 22;
    public readonly int numPremiumTS = 10;
    public readonly int numOutputs = 2;
    public readonly int numSoundtrackLUTs = 124;

    public MatlabData(int nTonspuren, int nIntermediateMixerChannels, int nStandardTS, int nPremiumTS, int LimiterNumSettings)

    {
        //Override predefined vars with values from child class
        this.numTonspuren = nTonspuren;
        this.numSubgroups = nIntermediateMixerChannels;
        this.numStandardTS = nStandardTS;
        this.numPremiumTS = nPremiumTS;
        //this.ProjectType = ProjectType;
        this.LimiterNumSettings = LimiterNumSettings;
        ConfigLimiter();
    }
    
    public bool isEQAMAvailable()
    {
        return EQAMAvail;
    }

    public virtual void ConfigLimiter()
    {
        //Overwrite from derived class
    }
}

class MatlabData_MLBevo : MatlabData
{
    public new const int numTonspuren = 32;
    public new const int numSubgroups = 8;
    public new const int numStandardTS = 22;
    public new const int numPremiumTS = 10;
    public new const int LimiterNumSettings = 7;
    
    public MatlabData_MLBevo()
        :base(numTonspuren, numSubgroups, numStandardTS, numPremiumTS, LimiterNumSettings)
    {
        EQAMAvail = false;
    }

    //ConfigLimiter method in this class override method in base class automatically
    //parts of the label already configured in matlabconstants region of this class
    public override void ConfigLimiter()
    {
        LabelText = new string(LimiterNumSettings);
        LabelText(0) = "Threshold (dB)";
        LabelText(1) = "Out Gain (dB)";
        LabelText(2) = "Knee Depth (dB)";
        LabelText(3) = "Ratio (dB)";
        LabelText(4) = "Attack Time (ms)";
        LabelText(5) = "Decay Time (ms)";
        LabelText(6) = "Post Limiter Gain";

        LabelName = new string(LimiterNumSettings + 2);
        LabelName(0) = "LimiterCore1.threshold";
        LabelName(1) = "LimiterCore1.outputGain";
        LabelName(2) = "LimiterCore1.kneeDepth";
        LabelName(3) = "LimiterCore1.ratio";
        LabelName(4) = "LimiterCore1.attackTime";
        LabelName(5) = "LimiterCore1.decayTime";
        LabelName(6) = "PostLimGain.gainDB";
        LabelName(7) = "gsys.SYS.";
        LabelName(8) = "Limiter_Stereo.Limiter_CH";

        LabelMinimum = new double(LimiterNumSettings);
        LabelMinimum(0) = -60;      
        LabelMinimum(1) = 0;        
        LabelMinimum(2) = 0.1;      
        LabelMinimum(3) = 1;        
        LabelMinimum(4) = 0.009;    
        LabelMinimum(5) = 0.01;     
        LabelMinimum(6) = -100;     

        LabelMaximum = new double(LimiterNumSettings);
        LabelMaximum(0) = 0;        
        LabelMaximum(1) = 100;      
        LabelMaximum(2) = 60;       
        LabelMaximum(3) = 100;      
        LabelMaximum(4) = 1000;     
        LabelMaximum(5) = 1000;     
        LabelMaximum(6) = 20;   
    }
}

spfx – SiteBreadCrumbs- How to avoid Site Pages

I’m making use of the github code to display breadcrumbs in my site. The code uses pnp control to render the content. Is there a way we can modify this to avoid Site Pages appearing in the breadcrumb.
When i browse to my home page, the breadcrumb appears as (Site Name)>(Site Pages). I want to remove the ‘Site Page’ from the crumbs. I don’t want the logged in user to browse to the Site Pages library from the link.

Any help appreciated.
Thanks.

Javascript how to avoid two loop for array

I have a dataset and I want to search task name inside initialTasks array.

const stagesTasks = (
    {
      "dataTestID": "stage-0",
      "headerText": "Backlog",
      "initialTasks": ("task 1", "task 2", "task 3")
    },
    {
      "dataTestID": "stage-1",
      "headerText": "To Do",
      "initialTasks": ("task 4", "task 5", "task 6")
    },
    {
      "dataTestID": "stage-2",
      "headerText": "Ongoing",
      "initialTasks": ("task 7", "task 8")
    },
    {
      "dataTestID": "stage-3",
      "headerText": "Done",
      "initialTasks": ("task 9")
    }
  )

For example if I want to know dataTestID for “task 8”, I have to make two loops. Like below :-

getStageName = task => {
    for(let record of stagesTasks){
      for(let data of record.initialTasks){
        if(data === task){
          return record
        }
      }
    } 
    return null
  }

Just need your guidance to identify is there any way to avoid two loops?