text:
Q: Check col1 if duplicate then check col2 if distinct Hey guys I've been struggling to get a simple query done in SnowFlake.
A sample of the data is explained below,

Number
ID

2559
23

2559
33

2559
55

2550
89

2499
14

2499
14

Based on the table above I would like to create a column that checks if (column Number) have duplicated values if yes; then check (column ID) if the values associated with that Number were duplicated or distinct. If values were duplicated then return 0 if values were distinct then return 1.
The desired outcome is as follows,

Number
ID
Check

2559
23
1

2559
33
1

2559
55
1

2550
89
0

2499
14
0

2499
14
0

and the last outcome should be on the Number column level (group by) and would be like the following table,

Number
Check

2559
1

2550
0

2499
0

Any suggestions are appreciated.

Edited tables
The scenario has changed based on new requirements
The original table have two IDs (ID1 and ID2) and those IDs must be linked to two different tables T-ID1 and T-ID2.

Number
ID1
ID2

2559
23
null

2559
33
null

2559
55
null

2550
89
null

2499
14
null

2499
14
null

2498
null
14

2498
null
50

2498
null
null

So the idea is if Number has duplicated IDs (in ID1 or ID2) then return 1, if Number has unique ID (in ID1 or ID2) then return ID1 or ID2. if Number have null values for ID1 and ID2 then ignore the entire row.
This is the query I am using - everything works based on solution provided below, but I am getting nulls along with ID values.
ID1 is linked to Supplier_ID_Ekuep and ID2 is linked to Supplier_ID_Qava.
select wbd.WAYBILL_ID, sup.WAYBILL_NO,
       sup.Supplier_ID_Qava, supq.Supplier_Qava, supq.Supllier_City_Qava, supq.Supplier_Qava_Add,
       sup.Supplier_ID_Ekuep, supc.Supplier_Ekuep, supc.Supllier_City_Ekuep, supc.Supplier_Ekuep_Add
from WAYBILL_PRODUCTS wbd
left join (select wb.WAYBILL_ID, ow.WAYBILL_NO,
       case when mult.multi_supp_qava = 1 then '1'
            when mult.multi_supp_qava = 0 then op.ID_Supplier_Qava
            else null end as Supplier_ID_Qava,
       case when mult.multi_supp_ekuep = 1 then '1'
            when mult.multi_supp_ekuep = 0 then op.ID_Supplier_Ekuep
            else null end as Supplier_ID_Ekuep
from WAYBILL_PRODUCTS wb
left join (select ID, ORDER_ID, WAYBILL_NO from ORDER_WAYBILLS) ow on wb.WAYBILL_ID = ow.id
left join (select opr.ID_ORDER, opr.ID_PRODUCT, ss.ID_Supplier_Ekuep, ss.ID_Supplier_Qava
          from ORDER_PRODUCTS opr
left join (select s.id, supc.*, supq.*
          from SUPPLIERS s
left join (select ID_SUPPLIER as ID_Supplier_Ekuep
from EKUEP_KSA_EKUEP_STAGING.PS_SUPPLIER where USED_SUPPLIER_ID is null) supc on supc.ID_Supplier_Ekuep = s.ID_SUPPLIER and s.STORE_ID = 1
left join (select ID_SUPPLIER as ID_Supplier_Qava
from QAVASHOP_KSA_QAVAISH_MAINSHOP.PS_SUPPLIER where USED_SUPPLIER_ID is null) supq on supq.ID_Supplier_Qava = s.ID_SUPPLIER and s.STORE_ID = 2) ss on opr.SUPPLIER_ID = ss.ID
group by opr.ID_ORDER, opr.ID_PRODUCT, ss.ID_Supplier_Ekuep, ss.ID_Supplier_Qava) op on op.ID_PRODUCT = wb.PRODUCT_ID and op.ID_ORDER = ow.ORDER_ID
------------------------------------------------------------------------------------------------------------------------
left join (select wb.WAYBILL_ID, ow.WAYBILL_NO,
       (count(distinct op.ID_Supplier_Qava) > 1)::int as multi_supp_qava,
       (count(distinct op.ID_Supplier_Ekuep) > 1)::int as multi_supp_ekuep
from WAYBILL_PRODUCTS wb
left join (select ID, ORDER_ID, WAYBILL_NO from ORDER_WAYBILLS) ow on wb.WAYBILL_ID = ow.id
left join (select opr.ID_ORDER, opr.ID_PRODUCT, ss.ID_Supplier_Ekuep, ss.ID_Supplier_Qava
          from ORDER_PRODUCTS opr
left join (select s.id, supc.ID_Supplier_Ekuep, supq.ID_Supplier_Qava
          from SUPPLIERS s
left join (select ID_SUPPLIER as ID_Supplier_Ekuep
from EKUEP_KSA_EKUEP_STAGING.PS_SUPPLIER where USED_SUPPLIER_ID is null) supc on supc.ID_Supplier_Ekuep = s.ID_SUPPLIER and s.STORE_ID = 1
left join (select ID_SUPPLIER as ID_Supplier_Qava
from QAVASHOP_KSA_QAVAISH_MAINSHOP.PS_SUPPLIER where USED_SUPPLIER_ID is null) supq on supq.ID_Supplier_Qava = s.ID_SUPPLIER and s.STORE_ID = 2
    ) ss on opr.SUPPLIER_ID = ss.ID
group by opr.ID_ORDER, opr.ID_PRODUCT, ss.ID_Supplier_Ekuep, ss.ID_Supplier_Qava) op on op.ID_PRODUCT = wb.PRODUCT_ID and op.ID_ORDER = ow.ORDER_ID
where _FIVETRAN_DELETED = 0
group by wb.WAYBILL_ID, ow.WAYBILL_NO) mult on mult.WAYBILL_NO = ow.WAYBILL_NO
------------------------------------------------------------------------------------------------------------------------
group by wb.WAYBILL_ID, ow.WAYBILL_NO, mult.multi_supp_qava, mult.multi_supp_ekuep, op.ID_Supplier_Qava, op.ID_Supplier_Ekuep) sup on wbd.WAYBILL_ID = sup.WAYBILL_ID

left join
(select ps.ID_SUPPLIER                  as ID_Supplier_Qava,
        ps.name                         as Supplier_Qava,
        listagg(distinct pa.CITY, ', ') as Supllier_City_Qava,
        ps.DATE_ADD                     as Supplier_Qava_Add
from QAVASHOP_KSA_QAVAISH_MAINSHOP.PS_SUPPLIER ps
left join (select * from QAVASHOP_KSA_QAVAISH_MAINSHOP.PS_ADDRESS) pa on pa.ID_SUPPLIER = ps.ID_SUPPLIER and pa._FIVETRAN_DELETED = 0
where ps.USED_SUPPLIER_ID is null and ps._FIVETRAN_DELETED = 0
group by ID_Supplier_Qava, Supplier_Qava, Supplier_Qava_Add) supq on supq.ID_Supplier_Qava = sup.Supplier_ID_Qava

left join
(select ps.ID_SUPPLIER                  as ID_Supplier_Ekuep,
        ps.name                         as Supplier_Ekuep,
        listagg(distinct pa.CITY, ', ') as Supllier_City_Ekuep,
        ps.DATE_ADD                     as Supplier_Ekuep_Add
from EKUEP_KSA_EKUEP_STAGING.PS_SUPPLIER ps
left join (select * from EKUEP_KSA_EKUEP_STAGING.PS_ADDRESS) pa on pa.ID_SUPPLIER = ps.ID_SUPPLIER and pa._FIVETRAN_DELETED = 0
where ps.USED_SUPPLIER_ID is null and ps._FIVETRAN_DELETED = 0
group by ID_Supplier_Ekuep, Supplier_Ekuep, Supplier_Ekuep_Add) supc on supc.ID_Supplier_Ekuep = sup.Supplier_ID_Ekuep
where _FIVETRAN_DELETED = 0
group by wbd.WAYBILL_ID, sup.WAYBILL_NO,
       sup.Supplier_ID_Qava, supq.Supplier_Qava, supq.Supllier_City_Qava, supq.Supplier_Qava_Add,
       sup.Supplier_ID_Ekuep, supc.Supplier_Ekuep, supc.Supllier_City_Ekuep, supc.Supplier_Ekuep_Add

The output I am getting for Waybill_No = 43265104 is as follows, I just want to get rid of the null row.

A: WITH data(num, id) AS (
    SELECT * FROM VALUES
      (2559,    23),
      (2559,    33),
      (2559,    55),
      (2550,    89),
      (2499,    14),
      (2499,    14)
)
SELECT
    num,
    id,
    count(*) over(partition by num) as num_dup,
    count(distinct id)over(partition by num) as id_dup,
    iff(num_dup > 1 AND num_dup = id_dup, 1, 0) as "check"
FROM data;

gives:

NUM
ID
NUM_DUP
ID_DUP
check

2559
23
3
3
1

2559
33
3
3
1

2559
55
3
3
1

2550
89
1
1
0

2499
14
2
1
0

2499
14
2
1
0

Extra Data:
WITH data(num, id) AS (
    SELECT * FROM VALUES
      (2559,    23),
      (2559,    33),
      (2559,    33),
      (2559,    55),
      (2550,    89),
      (2499,    14),
      (2499,    14)
)
SELECT
    num,
    id,
    count(*) over(partition by num) as num_dup,
    count(distinct id)over(partition by num) as id_dup,
    iff(num_dup > 1 AND num_dup = id_dup, 1, 0) as "check"
FROM data;

if we make 2559 have two 33's then it show change to 0/false

NUM
ID
NUM_DUP
ID_DUP
check

2559
23
4
3
0

2559
33
4
3
0

2559
33
4
3
0

2559
55
4
3
0

2550
89
1
1
0

2499
14
2
1
0

2499
14
2
1
0

Last Step:
WITH data(num, id) AS (
    SELECT * FROM VALUES
      (2559,    23),
      (2559,    33),
      (2559,    55),
      (2550,    89),
      (2499,    14),
      (2499,    14)
)
SELECT
    num,
    iff(count(*) > 1 AND count(*) = count(distinct id), 1, 0) as output
FROM data
GROUP BY 1;

gives:

NUM
OUTPUT

2559
1

2550
0

2499
0

A:     left join (
        select
            ID,
            ORDER_ID,
            WAYBILL_NO
        from ORDER_WAYBILLS
    ) ow
        on wb.WAYBILL_ID = ow.id

should just be:
    LEFT JOIN order_waybills AS ow
        ON wb.waybill_id = ow.id

Gaint Refactoing Starts Here
So I start refactoring this SQL, the first part was to ignore my prior "this could be simpler" and move that into a CTE ob_cte, so it was "just simple" then I notice the first two sections had large block you noted as op that where the same, so that becomes a CTE op_cte also then that gives us:
WITH ob_cte AS (
    SELECT
        id,
        order_id,
        waybill_no
    FROM order_waybills
), op_etc AS (
    SELECT
        opr.id_order,
        opr.id_product,
        ss.id_supplier_ekuep,
        ss.id_supplier_qava
    FROM order_products AS opr
    LEFT JOIN (
        SELECT
            s.id,
            supc.id_supplier_ekuep,
            supq.id_supplier_qava
        FROM suppliers AS s
        LEFT JOIN (
            SELECT
                id_supplier AS id_supplier_ekuep
            FROM ekuep_ksa_ekuep_staging.ps_supplier
            WHERE used_supplier_id IS NULL
        ) AS supc
            ON supc.id_supplier_ekuep = s.id_supplier
                AND s.store_id = 1
        LEFT JOIN (
            SELECT
                id_supplier AS id_supplier_qava
            FROM qavashop_ksa_qavaish_mainshop.ps_supplier
            WHERE used_supplier_id IS NULL
        ) AS supq
            ON supq.id_supplier_qava = s.id_supplier
                AND s.store_id = 2
    ) AS ss
        ON opr.SUPPLIER_ID = ss.ID
    GROUP BY opr.id_order, opr.id_product, ss.id_supplier_ekuep, ss.id_supplier_qava
)

SELECT
    wbd.waybill_id,
    sup.waybill_no,
    sup.supplier_id_qava,
    supq.supplier_qava,
    supq.supllier_city_qava,
    supq.supplier_qava_add,
    sup.supplier_id_ekuep,
    supc.supplier_ekuep,
    supc.supllier_city_ekuep,
    supc.supplier_ekuep_add
FROM waybill_products AS wbd
LEFT JOIN (
    SELECT
        wb.waybill_id,
        ow.waybill_no,
        CASE
            WHEN mult.multi_supp_qava = 1 THEN '1'
            WHEN mult.multi_supp_qava = 0 THEN op.ID_Supplier_Qava
            ELSE NULL
        end as supplier_id_qava,
        case
            WHEN mult.multi_supp_ekuep = 1 THEN '1'
            WHEN mult.multi_supp_ekuep = 0 THEN op.ID_Supplier_Ekuep
            ELSE NULL
        END AS supplier_id_ekuep
    FROM waybill_products AS wb
    LEFT JOIN ob_cte AS ow
        ON wb.waybill_id = ow.id
    LEFT JOIN op_etc AS op
        ON op.id_product = wb.product_id
            AND op.id_order = ow.order_id
    ------------------------------------------------------------------------------------------------------------------------
    left join (
        select
            wb.WAYBILL_ID,
            ow.WAYBILL_NO,
            (count(distinct op.ID_Supplier_Qava) > 1)::int as multi_supp_qava,
            (count(distinct op.ID_Supplier_Ekuep) > 1)::int as multi_supp_ekuep
        from WAYBILL_PRODUCTS wb
        LEFT JOIN ob_cte AS ow
            ON wb.waybill_id = ow.id
        left join op_etc AS op
            on op.ID_PRODUCT = wb.PRODUCT_ID
                and op.ID_ORDER = ow.ORDER_ID
        where _FIVETRAN_DELETED = 0
        group by wb.WAYBILL_ID, ow.WAYBILL_NO
    ) AS mult
        on mult.WAYBILL_NO = ow.WAYBILL_NO
    ------------------------------------------------------------------------------------------------------------------------
    group by wb.WAYBILL_ID, ow.WAYBILL_NO, mult.multi_supp_qava, mult.multi_supp_ekuep, op.ID_Supplier_Qava, op.ID_Supplier_Ekuep
) AS sup
    on wbd.WAYBILL_ID = sup.WAYBILL_ID
left join (
    select
        ps.id_supplier                  AS id_supplier_qava,
        ps.name                         AS supplier_qava,
        ps.date_add                     AS supplier_qava_add,
        LISTAGG(DISTINCT pa.CITY, ', ') AS supllier_city_qava
    from QAVASHOP_KSA_QAVAISH_MAINSHOP.PS_SUPPLIER ps
    left join (
        select *
        from QAVASHOP_KSA_QAVAISH_MAINSHOP.PS_ADDRESS
    ) pa
        ON pa.ID_SUPPLIER = ps.ID_SUPPLIER
            AND pa._fivetran_deleted = 0
    WHERE ps.USED_SUPPLIER_ID is null
        AND ps._fivetran_deleted = 0
    GROUP BY 1, 2, 3
) AS supq
    on supq.ID_Supplier_Qava = sup.Supplier_ID_Qava
left join (
    select
        ps.id_supplier                  AS id_supplier_ekuep,
        ps.name                         AS supplier_ekuep,
        ps.date_add                     AS supplier_ekuep_add,
        LISTAGG(DISTINCT pa.CITY, ', ') AS supllier_city_ekuep
    FROM ekuep_ksa_ekuep_staging.ps_supplier AS ps
    LEFT JOIN FROM ekuep_ksa_ekuep_staging.ps_address AS pa
        ON pa.id_supplier = ps.id_supplier
            and pa._fivetran_deleted = 0
    WHERE ps.used_supplier_id IS NULL
        and ps._fivetran_deleted = 0
    GROUP BY 1, 2, 4
) AS supc
    ON supc.id_supplier_ekuep = sup.supplier_id_ekuep
WHERE _fivetran_deleted = 0
GROUP BY wbd.waybill_id, sup.waybill_no,
       sup.supplier_id_qava, supq.supplier_qava,
       supq.supllier_city_qava, supq.supplier_qava_add,
       sup.supplier_id_ekuep, supc.supplier_ekuep,
       supc.supllier_city_ekuep, supc.supplier_ekuep_add;

Now op_etc itself, that GROUP BY at the end is really just a DISTINCT so we can swap that in. Also in ss of that op_cte
        SELECT
            s.id,
            supc.id_supplier_ekuep,
            supq.id_supplier_qava
        FROM suppliers AS s
        LEFT JOIN (
            SELECT
                id_supplier AS id_supplier_ekuep
            FROM ekuep_ksa_ekuep_staging.ps_supplier
            WHERE used_supplier_id IS NULL
        ) AS supc
            ON supc.id_supplier_ekuep = s.id_supplier
                AND s.store_id = 1
        LEFT JOIN (
            SELECT
                id_supplier AS id_supplier_qava
            FROM qavashop_ksa_qavaish_mainshop.ps_supplier
            WHERE used_supplier_id IS NULL
        ) AS supq
            ON supq.id_supplier_qava = s.id_supplier
                AND s.store_id = 2

those to left joins, keep only values that are NULL and then LEFT JOIN of two requirements which means we are get a row per suppliers the IS NULL can be moved to the ON with no impact, which means the rename can be moved higher up, and the sub-select dropped, so that section can become:
SELECT
    s.id,
    supc.id_supplier AS id_supplier_ekuep,
    supq.id_supplier AS id_supplier_qava
FROM suppliers AS s
LEFT JOIN ekuep_ksa_ekuep_staging.ps_supplier AS supc
    ON supc.id_supplier = s.id_supplier
        AND s.store_id = 1
        AND supc.used_supplier_id IS NULL
LEFT JOIN qavashop_ksa_qavaish_mainshop.ps_supplier AS supq
    ON supq.id_supplier = s.id_supplier
        AND s.store_id = 2
        AND supq.used_supplier_id IS NULL

thus the op_cte becomes:
), op_etc AS (
    SELECT DISTINCT
        opr.id_order,
        opr.id_product,
        ss.id_supplier_ekuep,
        ss.id_supplier_qava
    FROM order_products AS opr
    LEFT JOIN (
        SELECT
            s.id,
            supc.id_supplier AS id_supplier_ekuep,
            supq.id_supplier AS id_supplier_qava
        FROM suppliers AS s
        LEFT JOIN ekuep_ksa_ekuep_staging.ps_supplier AS supc
            ON supc.id_supplier = s.id_supplier
                AND s.store_id = 1
                AND supc.used_supplier_id IS NULL
        LEFT JOIN qavashop_ksa_qavaish_mainshop.ps_supplier AS supq
            ON supq.id_supplier = s.id_supplier
                AND s.store_id = 2
                AND supq.used_supplier_id IS NULL
    ) AS ss
        ON opr.SUPPLIER_ID = ss.ID
)

which actually means the ss can just be left joined as first order things like:
), op_etc AS (
    SELECT DISTINCT
        opr.id_order,
        opr.id_product,
        supc.id_supplier AS id_supplier_ekuep,
        supq.id_supplier AS id_supplier_qava
    FROM order_products AS opr
    LEFT JOIN suppliers AS s
        opr.SUPPLIER_ID = s.ID
    LEFT JOIN ekuep_ksa_ekuep_staging.ps_supplier AS supc
        ON supc.id_supplier = s.id_supplier
            AND s.store_id = 1
            AND supc.used_supplier_id IS NULL
    LEFT JOIN qavashop_ksa_qavaish_mainshop.ps_supplier AS supq
        ON supq.id_supplier = s.id_supplier
            AND s.store_id = 2
            AND supq.used_supplier_id IS NULL
)

ah thats much more refreshing..
in the sub-select sup` I am worried, that you are grouping by values that are not in you output set, so you will get duplicate rows
in this case block
CASE
    WHEN mult.multi_supp_qava = 1 THEN '1'
    WHEN mult.multi_supp_qava = 0 THEN op.ID_Supplier_Qava
    ELSE NULL
end as supplier_id_qava,

you are group not by the output supplier_id_qava or it's position 3 but mult.multi_supp_qava, op.ID_Supplier_Qava
so if op.ID_Supplier_Qava is not null when mult.multi_supp_qava = 1 and can have different values, the supplier_id_qava will output 1 on both rows, but they will not merge, as op.ID_Supplier_Qava is different. This is the root of my strong dislike for using the input to the SELECT section as the grouping clauses of the aggregation of those values. because through transformation, they can become the same on the output, but remain different on the input, and produce hard to debug deuplicates. And if the flip case that they are alway safe/null/constant in the odd case, this is not clear to the SQL reader. (on this point I have to say a strong thank you for have used the aliases on select etc, as that alway confidance of where those values are coming from).
So again the GROUP BY on sup has no agration of values so this is a hidden DISTINCT, but it not giving distinct values perhaps in all cases.
So after moving some sub-selects into CTE's as I find it makes each select layer show, just what it is doing, with have to leap over smaller details we get SQL like this:
WITH ob_cte AS (
    SELECT
        id,
        order_id,
        waybill_no
    FROM order_waybills
), op_etc AS (
    SELECT DISTINCT
        opr.id_order,
        opr.id_product,
        supc.id_supplier AS id_supplier_ekuep,
        supq.id_supplier AS id_supplier_qava
    FROM order_products AS opr
    LEFT JOIN suppliers AS s
        opr.SUPPLIER_ID = s.ID
    LEFT JOIN ekuep_ksa_ekuep_staging.ps_supplier AS supc
        ON supc.id_supplier = s.id_supplier
            AND s.store_id = 1
            AND supc.used_supplier_id IS NULL
    LEFT JOIN qavashop_ksa_qavaish_mainshop.ps_supplier AS supq
        ON supq.id_supplier = s.id_supplier
            AND s.store_id = 2
            AND supq.used_supplier_id IS NULL
), mult_cte AS (
    SELECT
        wb.waybill_id,
        ow.waybill_no,
        (COUNT(DISTINCT op.id_supplier_qava) > 1)::int AS multi_supp_qava,
        (COUNT(DISTINCT op.id_supplier_ekuep) > 1)::int AS multi_supp_ekuep
    FROM waybill_products AS wb
    LEFT JOIN ob_cte AS ow
        ON wb.waybill_id = ow.id
    LEFT JOIN op_etc AS op
        ON op.id_product = wb.product_id
            AND op.id_order = ow.order_id
    WHERE _fivetran_deleted = 0
    GROUP BY wb.waybill_id, ow.waybill_no
), supq_cte AS (
    SELECT
        ps.id_supplier                  AS id_supplier_qava,
        ps.name                         AS supplier_qava,
        ps.date_add                     AS supplier_qava_add,
        LISTAGG(DISTINCT pa.city, ', ') AS supllier_city_qava
    FROM qavashop_ksa_qavaish_mainshop.ps_supplier AS ps
    LEFT JOIN qavashop_ksa_qavaish_mainshop.ps_address AS pa
        ON pa.id_supplier = ps.id_supplier
            AND pa._fivetran_deleted = 0
    WHERE ps.used_supplier_id is null
        AND ps._fivetran_deleted = 0
    GROUP BY 1, 2, 3
), supc_cte AS (
    SELECT
        ps.id_supplier                  AS id_supplier_ekuep,
        ps.name                         AS supplier_ekuep,
        ps.date_add                     AS supplier_ekuep_add,
        LISTAGG(DISTINCT pa.city, ', ') AS supllier_city_ekuep
    FROM ekuep_ksa_ekuep_staging.ps_supplier AS ps
    LEFT JOIN FROM ekuep_ksa_ekuep_staging.ps_address AS pa
        ON pa.id_supplier = ps.id_supplier
            AND pa._fivetran_deleted = 0
    WHERE ps.used_supplier_id IS NULL
        AND ps._fivetran_deleted = 0
    GROUP BY 1, 2, 4
), sup_cte AS (
    SELECT DISTINCT
        wb.waybill_id,
        ow.waybill_no,
        CASE
            WHEN mult.multi_supp_qava = 1 THEN '1'
            WHEN mult.multi_supp_qava = 0 THEN op.ID_Supplier_Qava
            ELSE NULL
        end as supplier_id_qava,
        case
            WHEN mult.multi_supp_ekuep = 1 THEN '1'
            WHEN mult.multi_supp_ekuep = 0 THEN op.ID_Supplier_Ekuep
            ELSE NULL
        END AS supplier_id_ekuep
    FROM waybill_products AS wb
    LEFT JOIN ob_cte AS ow
        ON wb.waybill_id = ow.id
    LEFT JOIN op_etc AS op
        ON op.id_product = wb.product_id
            AND op.id_order = ow.order_id
    ------------------------------------------------------------------------------------------------------------------------
    LEFT JOIN mult_cte AS mult
        on mult.WAYBILL_NO = ow.WAYBILL_NO
    ------------------------------------------------------------------------------------------------------------------------
)

SELECT
    wbd.waybill_id,
    sup.waybill_no,
    sup.supplier_id_qava,
    supq.supplier_qava,
    supq.supllier_city_qava,
    supq.supplier_qava_add,
    sup.supplier_id_ekuep,
    supc.supplier_ekuep,
    supc.supllier_city_ekuep,
    supc.supplier_ekuep_add
FROM waybill_products AS wbd
LEFT JOIN sup_cte AS sup
    ON wbd.WAYBILL_ID = sup.WAYBILL_ID
LEFT JOIN supq_cte AS supq
    ON supq.id_supplier_qava = sup.supplier_id_qava
LEFT JOIN supc_cte AS supc
    ON supc.id_supplier_ekuep = sup.supplier_id_ekuep
WHERE _fivetran_deleted = 0
GROUP BY wbd.waybill_id, sup.waybill_no,
       sup.supplier_id_qava, supq.supplier_qava,
       supq.supllier_city_qava, supq.supplier_qava_add,
       sup.supplier_id_ekuep, supc.supplier_ekuep,
       supc.supllier_city_ekuep, supc.supplier_ekuep_add;

And at the end we see again you are suffering from duplicate data, that you are trying to clean away with yet another GROUP BY.. so we will switch to a DISTINCT
SELECT DISTINCT
    wbd.waybill_id,
    sup.waybill_no,
    sup.supplier_id_qava,
    supq.supplier_qava,
    supq.supllier_city_qava,
    supq.supplier_qava_add,
    sup.supplier_id_ekuep,
    supc.supplier_ekuep,
    supc.supllier_city_ekuep,
    supc.supplier_ekuep_add
FROM waybill_products AS wbd
LEFT JOIN sup_cte AS sup
    ON wbd.WAYBILL_ID = sup.WAYBILL_ID
LEFT JOIN supq_cte AS supq
    ON supq.id_supplier_qava = sup.supplier_id_qava
LEFT JOIN supc_cte AS supc
    ON supc.id_supplier_ekuep = sup.supplier_id_ekuep
WHERE _fivetran_deleted = 0

Right so what was your question again?
you want to get rid of all the nulls... if this is so "why so many left joins" or returning null from CASE statements..
Right so in the picture to show a waybill_no with values, and another where supplier_id_qava is null, given the later comes from
LEFT JOIN sup_cte AS sup
    ON wbd.WAYBILL_ID = sup.WAYBILL_ID

and everything else connect via sup you should change that from a LEFT JOIN to just a JOIN


text:
Q: Modifying Python objects while constructing tensorflow graph I'm trying to make a data augmentation that depends on the kind of input I'm receiving, specifically I want to use the filename to decide which kind of augmentation will be used.
For this I'm using Tensorflow's Object Detection API and I'm modifying the augment_input_data function. I've added the following code to the beginning of the function:
my_data_augmentation_options = data_augmentation_options.copy()

@tf.function
def filter_supervised(data_aug_options):
  for opt in data_aug_options:
    if opt[0].__name__ in ['random_vertical_flip', 'random_horizontal_flip']:
      data_aug_options.remove(opt)

@tf.function
def filter_unsupervised(data_aug_options):
  for opt in data_aug_options:
    if opt[0].__name__ in ['random_distort_color']:
      data_aug_options.remove(opt)

tf.cond(tf.strings.regex_full_match(tensor_dict['filename'], '\Scrop\S'), filter_unsupervised(my_data_augmentation_options), filter_supervised(my_data_augmentation_options))

Unfortunately this raises the following error:
ValueError: filter_unsupervised() should not modify its Python input arguments. Check if it modifies any lists or dicts passed as arguments. Modifying a copy is allowed.

Is there a way to modify a python object? Or do I need to search for where it stops executing eagerly and try to maintain the eager execution till this part?
Thanks in advance.
One minimal example that reproduces the error I'm facing would be
def custom_augment_input_data(tensor_dict, data_augmentation_options):
  my_data_augmentation_options = data_augmentation_options.copy()
  @tf.function
  def filter_supervised(data_aug_options):
    for opt in data_aug_options:
      if opt[0].__name__ in ['random_horizontal_flip']:
        data_aug_options.remove(opt)

  @tf.function
  def filter_unsupervised(data_aug_options):
    for opt in data_aug_options:
      if opt[0].__name__ in ['random_distort_color']:
        data_aug_options.remove(opt)
  tf.cond(tf.strings.regex_full_match(tensor_dict['filename'], '\Scrop\S'),
          filter_unsupervised(my_data_augmentation_options), filter_supervised(my_data_augmentation_options))
  # Continue doing stuff below

from object_detection.core.preprocessor import random_horizontal_flip, random_distort_color
data_augmentation_options = [(random_horizontal_flip, {'keypoint_flip_permutation': None, 'probability':0.5}),
                             (random_distort_color, {})]

dummy_dict = {fields.InputDataFields.filename: './crop_32412.jpg'}
custom_augment_input_data(dummy_dict, data_augmentation_options)

redpajama_set_name: RedPajamaStackExchange


text:
Q: Exception: Invalid instance in App.root in kivy when returning 2 values I'm new to Kivy. I'm trying to create a background image with a TextInput on it. This is my code:
import kivy
from kivy.app import App
from kivy.uix.label import Label
from kivy.uix.image import Image
from kivy.core.window import Window
from kivy.config import Config
from kivy.uix.button import Button
from kivy.uix.textinput import TextInput
from kivy.uix.widget import Widget

class EmailInput(Widget):
    pass

class Minor(App):
    def build(self):

        img = Image(source = "cont/bg/bg.png")
        Window.size = (1920, 1080)
        Window.fullscreen = True
        return img, EmailInput()

Minor().run()

Everytime I run it, it throws a critical error:
[CRITICAL] App.root must be an _instance_ of Widget
 Traceback (most recent call last):
   File "", line 32, in <module>
     Minor().run()
   File "", line 949, in run
     self._run_prepare()
   File "", line 925, in _run_prepare
     raise Exception('Invalid instance in App.root')
 Exception: Invalid instance in App.root

This is my .kv file:
<EmailInput>:
    TextInput:

I wonder if someone could help me...

A: build must return an instance of Widget or one of its subclasses, but you are returning a tuple of two widgets.
It sounds like you want to do something more along the lines of putting the TextInput on top of an Image, e.g. by adding them both to a parent FloatLayout.

A: When using kivy you should connect Widget instances together.
Image and Label(the text you are willing to input) are subclasses of Widget, then you can conclude you should embed your image inside your label (background image).
As long as you embed the subclasses into each other, it should work.
Simple example :
<Screen>:
   orientation: "vertical"
   Label:
        text: "Example.."
        Image:
            source: 'kivy.png'
            y: self.parent.y + self.parent.height - 180
            x: self.parent.x


text:
Q: Website links behaving abnormally I have made this website: http://manojpandey.tk/ implementing Bootstrap v.3
In the Contact section, I have added some social buttons.

         Twitter

         Facebook

They are showing some abnormal behaviour that I don't get. When someone clicks on the button directly, a blank webpage with same url opens. Opening in new tab does good.
But, why does the former does not work. Any help will be appreciated.

A:  Twitter

Works for me. So just add:
target="_top"

to the a-Tags.
Is there a reason why you are using frames?
Edit:
The Frames are causing the problem. Without adding target, the link usually will open within the frame. But if you add target="_top", then it will be loaded in the full window, ignoring the frames.
More detailed explanation here: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a


text:
Q: I'm building a simple lottery contract with help of react but getting error in the webpage I'm getting an error in my webpage:

Returned values aren't valid, did it run Out of Gas? You might also
see this error if you are not using the correct ABI for the contract
you are retrieving data from, requesting data from a block number.

App.js
import React, {
    Component
}
from 'react';
import logo from './logo.svg';
import './App.css';
import web3 from './web3';
import lottery from './lottery';

class App extends Component {

    constructor(props) {
        super(props);

        this.state = {
            manager: ''
        };
    }

    async componentDidMount() {
        const manager = await lottery.methods.manager().call();

        this.setState({
            manager
        });
    }

    render() {
        return (

 Lottery contract

this contract if managed by {this.state.manager}

        );
    }
}

export default App;

Lottery.js
import web3 from './web3';

const address = '0xB722A2E673c55F8cD0B781f0683FDa70c46e3183';

const abi = [
    {"constant":true,"inputs":[],"name":"manager","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"pickWinner","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"getPlayers","outputs":[{"name":"","type":"address[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"enter","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"players","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"}];

export default new web3.eth.Contract(abi, address);

node deploy.js
  attmepting to deploy
 [{"constant":true,"inputs":[],"name":"manager","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"pickWinner","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"getPlayers","outputs":[{"name":"","type":"address[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"enter","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"players","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"}]
 deployed to  0xB722A2E673c55F8cD0B781f0683FDa70c46e3183

A: I had the same error message and it was because my metamask wasn't on the Rinkeby network....once I switched over, it worked.


text:
Q: Disabling a startup service I am using insserv -r nfs-common to disable RPC. How do I know if it worked? Is there a way to list the services starting up? Is it supposed to disappear from /etc/init.d (because it still there)?

A:
How do I know if it worked?

After rebooting, look at ps auxw | grep rpc.statd, if you see it as a running process it's still running.

is there a way to list the services starting up?

This is one way...
[mpenning@tsunami ~]$ grep initdefault /etc/inittab
id:2:initdefault:
[mpenning@tsunami ~]$

From this, I know run-level 2 is the level the machine boots into... now look at /etc/rc2.d
[mpenning@tsunami ~]$ ls /etc/rc2.d
K01gdm3            S02dbus           S03apache2          S06bootlogs
README             S02fail2ban       S04avahi-daemon     S06samba
S01binfmt-support  S02loadcpufreq    S04bluetooth        S14portmap
S01fancontrol      S02lwresd         S04cpufrequtils     S15nfs-common
S01rsyslog         S02ntp            S04cron             S16nfs-kernel-server
S01sudo            S02openbsd-inetd  S04exim4            S17rc.local
S02acpid           S02smartmontools  S04kerneloops       S17rmnologin
S02anacron         S02snmpd          S04network-manager  S17stop-bootlogd
S02atd             S02ssh            S05cups
S02bind9           S02winbind        S05saned
[mpenning@tsunami ~]$

Anything that has an "S" at the beginning is started at boot. Anything with a "K" at the beginning does not start at boot.

Is it supposed to disappear from /etc/init.d (because it still there)?

All the startup scripts symlink to /etc/init.d, so the rpc startup script should still be there.  Look at /etc/rcX.d to know for sure

A: You could try installing rcconf via aptitude. It lists services that are started on boot. Rcconf will list all installed services -- services that start on boot are clearly marked. To run rcconf simply run rcconf as root.

A: chkconfig method
For the height of laziness / efficiency, you can also use chkconfig
To see how portmap, nfs-common, and nfs-kernel-server are used at all runlevels...
[mpenning@tsunami ~]$ sudo chkconfig --list | grep -Ei "nfs|portmap"
mountkernfs.sh            0:off  1:off  2:off  3:off  4:off  5:off  6:off  S:on
mountnfs-bootclean.sh     0:off  1:off  2:off  3:off  4:off  5:off  6:off  S:on
mountnfs.sh               0:off  1:off  2:off  3:off  4:off  5:off  6:off  S:on
nfs-common                0:off  1:off  2:off  3:off  4:off  5:off  6:off
nfs-kernel-server         0:off  1:off  2:off  3:off  4:off  5:off  6:off
portmap                   0:off  1:off  2:off  3:off  4:off  5:off  6:off
umountnfs.sh              0:off  1:off  2:off  3:off  4:off  5:off  6:off
[mpenning@tsunami ~]$

To disable portmap, nfs-common, and nfs-kernel-server at all runlevels...
sudo chkconfig portmap off nfs-common off nfs-kernel-server off


text:
Q: Auto generate models on creation of other models in Ruby on Rails I have a model called Video that has many statuses. I want to create a status of each kind and add it to @video.statuses in the def create of VideosController.
In VideosController, I have:
 def create
    @video = Video.new(params[:video])
    Kind.all.each do |f|
      @video.statuses.new(:kind =>f, :kind_id=>f.id,:comment =>"", :time_comp => nil, :completed =>false, :video_id =>@video.id)
    end
    respond_to do |format|
      if @video.save
        format.html { redirect_to @video, notice: 'Video was successfully created.' }
        format.json { render json: @video, status: :created, location: @video }
      else
        format.html { render action: "new" }
        format.json { render json: @video.errors, status: :unprocessable_entity }
      end
    end
  end

However, this returns an error that says that the video could not be saved because the Statuses were invalid. The only validation in my entire project is in status and it merely checks that there is a video_id.
I'm very confused why I'm getting this error and would appreciate any help!
https://github.com/ninajlu/videos

A: Since Status depends on video already existing, you probably want to create the statuses after video is created.
You can either do this in a video callback, or in the controller. Something like:
def create
  @video = Video.new(params[:video])
  respond_to do |format|
    if @video.save
      Kind.all.each do |f|
        @video.statuses.create(:kind =>f, :kind_id=>f.id,:comment =>"", :time_comp => nil, :completed =>false, :video_id =>@video.id)
      end
      # respond as before

If you went the callback route, it would be:
class Video < ActiveRecord::Base
  after_create :create_statuses

  def create_statuses
    Kind.all.each do |f|
      statuses.create(:kind =>f, :kind_id=>f.id,:comment =>"", :time_comp => nil, :completed =>false, :video_id => self.id)
    end
  end

And then you would not mention statuses in your controller -- you'd save as normally.
A final solution would be to use a Service object that coordinates the saving of statuses after creating the video. More at this RailsCast

A: You are trying to create the statuses before saving the @video, so it has no @video.id and thus is invalid following your validation rule


text:
Q: Calculating $\lim_{n\to \infty} \left(1+\frac{x}{\sqrt{n}}\right)^n\exp(-x\sqrt{n})$ I've encountered the following limit while verifying the Central Limit Theorem for the sum of several exponential random variables:
    $$\lim_{n\to \infty} \left(1+\frac{x}{\sqrt{n}}\right)^n\exp(-x\sqrt{n})$$
  I know the answer, which is $\exp(-x^2/2)$. Can anyone help in computing the limit?

A: Hint: take the logarithm, and use the Maclaurin series for $\log(1+u)$.

A: Let $A=\lim_{n\to \infty} \left(1+\frac{x}{\sqrt{n}}\right)^n\exp(-x\sqrt{n})$, therefore $\log A=\lim_{n\to \infty} n\log (1+\frac{x}{\sqrt{n}})-x\sqrt{n}$.Now take $y=1/n$ gives $\log A=\lim_{y\to 0^+} \frac{\log (1+ x\sqrt{y})}{y}-\frac{x}{\sqrt{y}}=\lim_{y\to 0^+} \frac{\log (1+ x\sqrt{y})-x\sqrt{y}}{y}$.Now using L'Hopital's Rule $\log A=-x^2/2\implies A=e^{-x^2/2}$.


text:
Q: Paste multiple lines with sun vi All machines in my university are all solaris, various updates and various hardware.
Mission was to copy and paste a line in vi say 500 times. I tried the
usual yy, to copy the line I wanted, then 500p
It only pasted one line. Tried a bunch of other machines, no dice.
Had another person try the same task, they failed as well and were like
WTF is going on here.
Talked to the programmers, they only use vim, where this does work.
Is there a reason this pretty basic behavior doens't work on the sun
standard vi, or is there something that would make it not work?


text:
Q: Customize AsciiMath math delimiters I want to use AsciiMath to render math formula on my page.
I followed the AsciiMath getting started and put the scripts in head tag:

and this is my paragraph:

some sample text `sqrt{3x-1}+(1+x)^2` some sample text $\sqrt{3x-1}+(1+x)^2$ some sample text

it only renders sqrt{3x-1}+(1+x)^2 part which surrounds with backticks, although I changed the MathJax config to use $ as delimiters.
I'm not sure what am I missing here.

A: Your MathJax configuration file is AM_CHTML, which only includes that AsciiMath input processor, not the the TeX input processor, so that is why you are not getting the TeX expression typeset. You would need to use one that contains both AsciiMath and TeX input (say, TeX-MML-AM_CHTML, which also includes MathML), or configure MathJax to load the TeX input processor separately via

Note also that you are using version 2 of MathJax, but a version 3 configuration.  For version 2, you need to configure the inlineMath in the tex2jax configuration block, not tex (as you do in version 3).
Finally, you do not need the line

at all, as AsciiMath is included in the MathJax configuration that you are using, and including it here would just interfere with MathJax's processing of the AsciiMath (note that ASCIIMathML.js would convert the math to MathML, which may not display in all browsers, notably Microsoft Edge and Google Chrome).


text:
Q: How can a graphql subgraph forward query to another subgraph There is a graphql api in a subgraph owned by another team
type Query {
  user: UserInfo
}

Our team wants to create a new graphql api in our subgraph that return the same data type as a proxy.
type Query {
  specialUser(encryptedUserId: ID): UserInfo
}

In our proxy, we will first decode the user id, then check if valid, then call the other team's api to get UserInfo, then do some modification to the result then return it.
Note the UserInfo object is very complicated, so we don't want to re-create resolver for each field.
I didn't find a way to extract the query then pass to the other team's api. We're using https://netflix.github.io/dgs/ and apollo in backend.


text:
Q: What word describes a person who signs an official document? For example, I have a document that has the signatures of three people, all public servants: a tax collector,an inspector, and a school principal. How could I collectively describe these three people?
This entry offers signatory but it implies a party to a contract.

A: Why not signers, as in the signers of the Declaration of Independence?

A: (Props to @JLG for making me look this up.) Signatory need not refer simply to a party in a contract. While some dictionaries define it that way:

NOAD: a party that has signed an agreement, esp. a country that has signed a treaty
Collins English Dictionary (via Dictionary.com): person who has signed a document such as a treaty or contract or an organization, state, etc, on whose behalf such a document has been signed
Cambridge Dictionaries Online: a person, organization or country which has signed an agreement
Oxford Dictionaries Online: a party that has signed an agreement, especially a state that has signed a treaty: Britain is a signatory to the convention

Others define it more broadly.

M-W: a signer with another or others signatories to a petition; especially : a government bound with others by a signed convention
Random House Dictionary (via Dictionary.com): a signer, or one of the signers, of a document: France and Holland were among the signatories of the treaty.
Wikipedia: The writer of a signature is a signatory.

Notice, however, that these last three seem to be more layman's dictionaries than comprehensive ones. In light of this, it would seem that it is all right to use signatory in informal or non-official usage, but that a better word might be needed for official use.
Disclaimer: I am not a lawyer.

A: Many dictionaries suggest the use of signee.

NOAD and Oxford Dictionaries Online: a person who has signed a contract or other official document.
M-W (sign): a : to affix a signature to : ratify or attest by hand or seal sign a bill into law, sign a confession b : to assign or convey formally signed over his property to his brother c : to write down (one's name) d : to affix one's name to a signed review
Dictionary.com (quoting the Random House Dictionary): a person who signs  a document, register, etc.; signer; signatory: a signee of the declaration of independence.

Disclaimer: I am not a lawyer.

A: Notary is possibly what you seek. From Chambers,

Notary - An official authorized to certify deeds, contracts, copies of documents, affidavits, etc (generally notary public)

EDIT: If you are in India, you are possibly referring to a gazetted officer. I do not know if the same term is used elsewhere. Wiki does not say so.

A: In the context you're describing, a term like "authorized person", "official", "appropriate official", etc might be what you're looking for.


text:
Q: Calculate the square in m2 and total curve lenght of the object(Mesh) loaded from svgLoader Im loading svg via svgLoader. Then im doing all like the docs says. And at the end i got the object in my scene.
But now i need to calculate the total curve lenght of the object. And also i need to calculate Total front area of object(m2) Without blank spaces.
Also its like 3d configurator.
So ppl can change width and height.
This is how i get width and height and connect it with scale.
 var bbox = new THREE.Box3().setFromObject(svgGroup);
    var size = bbox.getSize(new THREE.Vector3());
    var desiredWidth = 10;
    var desiredHeight = 10;
    var aspectRatio = size.x / size.y;
    var adjustedWidth = aspectRatio * desiredHeight;
    var adjustedHeight = desiredWidth / aspectRatio;
    var scaleX = adjustedWidth / size.x;
    var scaleY = adjustedHeight / size.y;
    var scale = Math.min(scaleX, scaleY);
    svgGroup.scale.set(scale, -scale, 0.1);
    svgGroupAcrylic.scale.set(scale, -scale, 0.1);
    var sizeInMillimeters = new THREE.Vector3(size.x * scale, size.y * scale, size.z * scale);

So i think when ppl change width -> Total front area of object(m2) should also change, like curve length
I tryed to calculate total curve length like that
 object.children.forEach(obj => {
    if (obj.isMesh){
      shapeLength += obj.geometry.parameters.shapes.getLength();
    }
  })

But result is not even close to the coralDraw result.
also i tryed to calculate total front are like that
function getFrontalArea(mesh, scaleX,scaleY) {
  const xCoords = [];
  const yCoords = [];

  const positionAttr = mesh.geometry.attributes.position;
  for (let i = 0; i < positionAttr.count; i++) {
    const x = positionAttr.getX(i) * (scaleX/ oldScale);
    const y = positionAttr.getY(i) * (scaleY/ oldScael);
    xCoords.push(x);
    yCoords.push(y);
  }

  const xMin = Math.min(...xCoords);
  const xMax = Math.max(...xCoords);
  const yMin = Math.min(...yCoords);
  const yMax = Math.max(...yCoords);

  const width = xMax - xMin;
  const height = yMax - yMin;

  const area = width * height;

  return area / 1000000; // Round to 2 decimal places
}

But it looks totally wrong. And the result is just too small
Help me plz. Maybe not code, but with understanding how can i do it.
And how it should be connected with mm or scale.


text:
Q: Is there a way to use reader.onload return to set my state in react? I'm trying to compress an image that was uploaded using the react-images-upload component. After the compression step I need to convert the file to Base64 and use it to update my state.
The code looks like this:
    const ImageUpload: React.FC<ImageUploadProps> = ({ setImgUrl }) => {
  const handleChange = useCallback(
    (files: File[], pictures: string[]) => {
      const options = {
        maxSizeMB: 1,
        useWebWorker: true
      }

      getBase64(files[0], options).then(function(result) {
        setImgUrl(result);
      });
    },
    [setImgUrl],
  );

  function getBase64(file: File, options: any){
    return new Promise(function(resolve, reject) {
      Compress(file, options).then(compressedBlob => {
        const convertedBlobFile = new File([compressedBlob], file.name, {type: file.type, lastModified: Date.now()})
        let reader = new FileReader();

        reader.readAsDataURL(convertedBlobFile);
        reader.onerror = reject;
        reader.onload = function() { resolve(reader.result); };
      })
  });
  }

But I'm facing problems in the setImgUrl(result) part... I keep receiving the error:

Argument of type 'unknown' is not assignable to parameter of type 'SetStateAction'.
Type 'unknown' is not assignable to type '(prevState: string) => string'.

Can someone help me please?

A: I believe you can resolve the typescript error by casting the unknown result type to a string. The setImgUrl expects a string, but typescript does not know what is being returned in the promise from getBase64. So either type the getBase64 function to return a Promise<string> or simply use:
  getBase64(files[0], options).then(function(result) {
    setImgUrl(result as string);
  });


text:
Q: Silverght 5 system.unauthorizedaccessexception Hi i am trying obtain the content of a text file on C:\pruebas\datos.txt
I have a project of Silverlight 5, inside the project i've a button and a TextBlock. In the buttonclick event handler I put the following code and never work. I check IntelliTrace and tells me which a system.unauthorizedaccessexception  occurs.
    private void Button_Click_1(object sender, RoutedEventArgs e)
    {
        WebClient client;
        client = new WebClient();
        client.DownloadStringCompleted += (s, a) =>
        {
            if (a.Error == null )
            {
                Result = a.Result;
                txtDownloadedText.Text = Result;
            }
        };

        client.BaseAddress = "";
        client.DownloadStringAsync(
            new Uri(@"C:\pruebas\datos.txt"));
    }


text:
Q: How to change parent after opacity of the selected child? Hello I'm looking a way using css to change the parent opacity value, on after, if it's contains a selected child class.
What I have accomplished so far is only the hover state. On hover I'm adding a background color to the parent on ::after. Here is my code
HTML

Item 1

Item 2

Item 3

Item 4

Item 5

CSS
.slider-thumbs .reason-item{position: relative;vertical-align: top;}
.slider-thumbs .reason-item::after {content: '\A';position: absolute;width: 100%; height:100%;top:0; left:0;background:rgba(252,194,38,0.9);opacity: 0;transition: all 1s;-webkit-transition: all 1s;}
.slider-thumbs .reason-item:hover::after, .slider-thumbs .reason-item:after + a.selected{opacity: 1;}

So when the user selected one of the available items I want to change the opacity value of the parent (::after) which contains a class selected, in order for the end user to see what he/she selected when the page loads.
Here is my code working with the hover state.
Fiddle: https://jsfiddle.net/giwrgos/0vLmkhr2/1/

A: You need to remove :after from the last rule, because after the ::after pseudo element doesn't exist a.selected.
So your final code will be:

.slider-thumbs .reason-item{
  position: relative;
  vertical-align: top;
}
.slider-thumbs .reason-item::after {
  content: '\A';
  position: absolute;
  width: 100%;
  height:100%;
  top:0;
  left:0;
  background:rgba(252,194,38,0.9);
  opacity: 0;
  transition: all 1s;
  -webkit-transition: all 1s;
}
.slider-thumbs .reason-item:hover::after,
.slider-thumbs .reason-item + a.selected{
  opacity: 1;
}

Item 1

Item 2

Item 3

Item 4

Item 5

See your edited fiddle:
https://jsfiddle.net/0vLmkhr2/3/

A: You will not be able to only use css by traversing back up the DOM as its not built that way.
If you have the class selected you could use jQuery to :-
$(".selected").find().parent("li").css("color", "red");

A: I have changed the style to apply on the a instead of the li so now it's working. here is the code
.slider-thumbs li{position: relative; }
.slider-thumbs a {vertical-align: top; display:block; word-break: break-word;}
.slider-thumbs a::after {
  content: '\A';
  position: absolute;
  width: 100%;
  height:100%;
  top:0;
  left:0;
  background:rgba(252,194,38,0.9);
  opacity: 0;
  transition: all 1s;
  -webkit-transition: all 1s;
}
.slider-thumbs a:hover::after,
.slider-thumbs a.selected{
  opacity: 1;
}


text:
Q: Get the 11.04 Ubuntu icon back I really liked the Ubuntu icon on 11.04.  Is there any way I can get that back in 11.10?

A: I don't think you can do that (move the main lens icon from the launcher to the panel) because it's location is (like everything else in the unity desktop environment) hard-coded.


text:
Q: Export from RDBMS to Hadoop Compatible Format I need to move a large amount of data from an Oracle Database to Hadoop without connecting the two systems. Is it possible to export data from Oracle via Sqoop directly to the local filesystem without importing to HDFS. I'd like to export to ORC and then just move the files via external disks to the Hadoop cluster.

A: You can not use SQOOP in your case. SQOOP ("SQL to Hadoop") runs in hadoop and uses, by default, JDBC to connect with the DB (as i explain in this answer, you can change it using --direct option). If hadoop nodes can not connect with the DB server, then you can not use it.
ORC is a very specific format used by Hive, you will require to find how use hive libraries to create the ORC files outside hadoop clustes, if it is possible.
By your constrains I will suggest to export DB using DB´s dump capabilities into a CSV file, compress the file and then copy it into HDFS.
If you are planning to use Hive, then you can LOAD the text file into a table configured to store the data using ORC.


text:
Q: Customizing Wordpress parent/child comments? Here is what I'm trying to do, and I understand the way that wordpress has it already set up, but I rely heavily on being able to modify and basically change whatever I need too, and in core files as well. However, I am using multisite so changing the core file's is now not an option.
The image below is somewhat how I am wanting the final product to appear, but I noticed other than using wordpress's ul, ol & li styles, I need to be able to customize it more than what has been provided by that, just in case you are wondering why I'm taking the hard way.
Anyways, looking at the image below, where the white rectangle is, I'm wanting to be able to change the color and ultimately allow myself to change the formatting to whatever I want that is different for all user replies. I have no idea how I'd write it, but more than likely it'll have to be an if/else statement. Basically, it'll say:
If parent (depth 0) comment, display this formatting, else (depth of 1 or greater, which would be a child reply), this display it this. Any idea's?
Here is my functions theme file and my comments theme file. AND just in case, the comment-template file under the wp-includes that says how to display and label the comments as parents/children.

I'd also like to point out, that I'm looking for help and suggestions, not criticism. If I knew the answer, I wouldn't be asking for help.

A: Based off of what BDHorrigan said, I came up with the following:
blockquote {
  background: #292929;
  border-left: 7px solid #00D9FF;
color: #A3B808;
  margin: 1.5em 10px;
  padding: 0.5em 10px;
}

blockquote:nth-child(1) {
    border-left: 7px solid #FFBE40;
}

This allowed every child reply to be the same because they would be all at a nth-child of 1. Thank you!

A: If it's just colour you want to change, is there any reason you can't just use CSS? E.g. make a rule for li.depth-1, another for li.depth-2, etc.?


text:
Q: C++ multi-dimensional array initialization in C++ I want to initialize a double matrix (2-dimensional double array) like I would normally do without pointers like so:
    double data[4][4] = {
    1,0,0,0,
    0,1,0,0,
    0,0,1,0,
    0,0,0,1
};

However, since I want to return and pass it to functions, I need it as a double** pointer. So, basically I need to initialize data in a nice way (as above), but then afterwards I need to save the pointer to the 2D-array without losing the data when the function exits.
Any help on this? :-)

A: Are all your matrices 4x4? Then I would simply define a class with a double[4][4] member and pass objects of that class around:
class Matrix
{
    double m[4][4];
    // ...
};

void function(const Matrix& matrix)
{
    // ...
}

If you need matrices of various dimensions, but they are known at compile time, use a template:
template <size_t n>
class Matrix
{
    double m[n][n];
    // ...
};

template <size_t n>
void function(const Matrix<n,n>& matrix)
{
    // ...
}

This saves you from dealing with array-to-pointer decay and makes the code more readable IMHO.

A: First, declaration of the double dimensional array is not correct. It needs to be done as follows:
double data[4][4] = {
        {1.0,0,0,0},
        {0,1,0,0},
        {0,0,1,0},
        {0,0,0,1}
    };

Second, for passing it in a function you can do it like
show(data);

In the function declaration, you need to give the argument as an array with giving all dimensions except the first. So the declaration would look like:
void show(double arr[][4])
{
   ...
   ...
}

This passes the array as a reference wihout you needing to use a pointer.
Hope this helped.

A: double (*)[4] is very different from double **
Just sketch the layout of your doubles in the memory for both and you should understand why you can't use them interchangeably.

A: Unless you are particular about pointers, I would prefer a reference here
void init( double (&r)[4][4]){
    // do assignment
    r[0][0] = 1;
}

int main(){
    double data[4][4] = {
        1,0,0,0,
        0,1,0,0,
        0,0,1,0,
        0,0,0,1
    };

    init(data);
}

By the way, if you pass it to a function in this manner, you would be "assigning" rather than "initializing".

A: Initialize temporary variable in this way and then copy it to the dynamically allocated memory.

A: How about this (with pointers, and does what you asked for)
#include <iostream>

using namespace std;

int refer(double (*a)[4])
{
   cout<<"First value is "<<(*a)[0];
   (*a)[0] = 37;
   cout<<"changed value is "<<(*a)[0];
}

int main()
{
   double data[4][4] = {
    1.0,0,0,
    0,1,0,0,
    0,0,1,0,
    0,0,0,1
   };
   refer(data);
   return 0;
}

A: late to the party, but.... c++ is meant to work with c++ stl. (At least according to Bjarne Stroustrup if you're using raw pointers in c++ then you're doing something wrong.)
#include <array> // on top
// ..

std::array<std::array<int, 4>, 4> data {{
    {1,0,0,0},
    {0,1,0,0},
    {0,0,1,0},
    {0,0,0,1}
}};

// access it normally

data[1][2] = 123;
std::cout << data[0][0]; // prints 1. (#include <iostream>)

// You can return std::array from a function as a normal return value, don't worry it is not going to be reallocated, or missing.

std::array<std::array<int, 4>, 4> give_me_data() {
  std::array<std::array<int, 4>, 4> data {{
    {1,0,0,0},
    {0,1,0,0},
    {0,0,1,0},
    {0,0,0,1}
  }};
  return data;
}

(works with Mac's XCode, also gcc supports it https://stackoverflow.com/a/12616826/1031191)
What's the benetif?
It works nicely with std algorithms, knows its size, same performance, etc.
ref: std::array vs array performance


text:
Q: How to reactively set a  class I have 2 themes: 'light-theme', 'dark-theme'
I would like to set the  according to a value i have in my vuex store. Like darkMode: true
How can i set the  class reactively like that?
(using vue3)

A: According to Vue docs, there are following ways to do this.
1.Binding to Objects

The above syntax means the presence of the 'active-class' class will be determined by the truthiness of the data property isActive.
2.Binding to Arrays

This will always apply errorClass, but activeClass will only be applied when isActive is truthy.

A: You can use simple javascript for it.
Just add a button or toggle for theme change like:
<button @click="changeTheme">Change Theme</button>

and inside this component add changeTheme method inside methods:
document.getElementsByTagName("html")[0].setAttribute( 'class', 'newThemeClass' );

Or just add watcher to your store value and change according to it:
computed:{
    ...mapGetters(["yourGetterName"])
 },
watch: {
    darkMode(value) {
      document.getElementsByTagName("html")[0].setAttribute( 'class', value );
    },
  }


text:
Q: What does "set the grab on something" mean? There's a function in the Python programming language, in particular in its tkinter module, that is called grab_set, which basically allows a Toplevel window to take complete control over the keyword and mouse events, so that these events are not sent to wrong windows. If you are interested, you can find more information in this article:

http://effbot.org/tkinterbook/tkinter-dialog-windows.htm

Now, someone told me that the correct expression related to this method was "setting the grab on a window", but it is not completely clear what it means, even if from the context I can imagine more or less its meaning.
See this article for context:

https://stackoverflow.com/questions/32259518/efficient-way-to-create-a-child-window-with-access-to-main-window-disabled/32259971#32259971

Is this a common expression? What exactly does it mean? In which contexts can I use it?
Examples are appreciated.

A: This is technical jargon and does not sound natural in English except in the very specific context it came from.
Window systems (GUIs) have the concept of "focus", i.e., the part of the screen that you are currently interacting with (where your keystrokes go). Sometimes people say that a particular window or UI element "has focus".
Usually focus is controlled by the user, but sometimes the program wants to direct the user's interaction to a particular thing. This is sometimes called "grabbing (the) focus", especially in X Window system environments (where Tkinter originated).
The "grab_set" methods sets a flag on the dialog window, requesting that it grab focus away from its parent window.
So, "setting the grab" here is a very shorthand way of saying "setting the flag/attribute that requests the window system to grab focus for this window when it is displayed".


text:
Q: Intrasite Messaging/EMail application in ASP.net Are they any framework or applications in asp.net to send/view messages for the users with in a site. It can be like email client application (like SharpWebMail), but it should not use SMTP server to send email. It should store messages in the database and the application should retrieve messages from the database
Basically want to setup the application in IIS and storing the messages in a database. I am looking in asp.net.


text:
Q: General bulk update for admin panel? I'm using my own admin panel for my website and would like to introduce some bulk actions using http://railscasts.com/episodes/52-update-through-checkboxes. First of all, is this still best practice to do bulk actions?
Secondly, how can I generalize this piece of code so every controller in the admin panel can use it?
Looking forward to hearing your ideas!


text:
Q: How to enforce unique column with unique value postgresql Is it possible to enforce unique value coupled with a unique column in postgres? I am using v. 11.
It would be something like this:
status = 0 | store = 5
unique(store, status = 0)
That way, I can have any value for store, but for each value, it can only have one record that's status is 0, and the rest can be any value?
I am sure this question has been asked before but it seems to be specific to certain frameworks like django:
how to enforce a conditional uniqueness constraint
Or I just cannot find the right answer.
I am using loopback4 and there does not seem to be a way to specify it in the framework so I want to specify it in the database.
Update: To be more explanative:
I have a user who can only have ONE shopping cart with a store, not more than one. Each cart has a user_id, store_id, and status. When status is 0, the cart is in progress, when status is 1, the cart is ordered, and when status is 2, it is delivered by store.
So I have a table:
id | user_id | store_id | status
...|   1     |   1      | 0
...|   1     |   1      | 1
...|   1     |   1      | 1

Above, is fine and should be allowed, but :
id | user_id | store_id | status
...|   1     |   1      | 0
...|   1     |   1      | 0   <--- Not allowed
...|   1     |   1      | 1

This is not allowed, because one use has more than one shopping cart for a store. So status = 0 and store_id should be unique.

A: You can create a partial unique index:
create unique index on the_table (store)
where status = 0;


text:
Q: Property or indexer 'IdentityUser.Roles' cannot be assigned to -- it is read only I'm working on MVC5 with Identity 1.0 Entity Framework web application. In my seed method I'm trying to assign roles to my user during the first migration.
I get an error when I put
Role = "Admin"

Property or Indexer 'IdentityUserApplicationUserLogin,ApplicationUserRole,ApplicationUserClaim>.Roles' cannot be assigned to -- it is read only

Does this mean I have to assign the role manually on the website when I run the application?
Configuration.cs
     var roles = new List<ApplicationRole>
        {
            new ApplicationRole { Id = 1,  Name = "Admin"},
            new ApplicationRole { Id = 2,  Name = "User"},

        };
        roles.ForEach(s => context.Roles.AddOrUpdate(p => p.Name, s));
        context.SaveChanges();

        var passwordHash = new PasswordHasher();
        string password = passwordHash.HashPassword("Password@123");

        var users = new List<ApplicationUser>
        {

            new ApplicationUser { UserName = "jackie@hotmail.com", FirstMidName = "Jackie", LastName = "Chan", Email="jasonw@rs.kiwi.nz",PasswordHash = password, Roles = "Admin",
                EnrollmentDate = DateTime.Parse("2016-02-18"), DepartmentID = 1,DepotID = 1,IsAdministrator = true,SecurityStamp = Guid.NewGuid().ToString()},

        users.ForEach(s => context.Users.AddOrUpdate(p => p.UserName, s));
        context.SaveChanges();

IdentityModel.cs
namespace RecreationalServicesTicketingSystem.Models
{
    public class ApplicationUserLogin : IdentityUserLogin<int> { }
    public class ApplicationUserClaim : IdentityUserClaim<int> { }
    public class ApplicationUserRole : IdentityUserRole<int> { }

    public class ApplicationRole : IdentityRole<int, ApplicationUserRole>, IRole<int>
    {
        public string Description { get; set; }

        public ApplicationRole() : base() { }
        public ApplicationRole(string name)
            : this()
        {
            this.Name = name;
        }

        public ApplicationRole(string name, string description)
            : this(name)
        {
            this.Description = description;
        }
    }

    public class ApplicationUser : IdentityUser<int, ApplicationUserLogin, ApplicationUserRole, ApplicationUserClaim>, IUser<int>
    {
        public async Task<ClaimsIdentity>
            GenerateUserIdentityAsync(UserManager<ApplicationUser, int> manager)
        {
            var userIdentity = await manager
                .CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
            return userIdentity;
        }

        public bool IsAdministrator { get; set; }
        [StringLength(50, MinimumLength = 1)]

        public string LastName { get; set; }
        [StringLength(50, MinimumLength = 1, ErrorMessage = "First name cannot be longer than 50 characters.")]

        [Column("FirstName")]
        public string FirstMidName { get; set; }

        public string FullName
        {
            get { return FirstMidName + " " + LastName; }
        }
        [DataType(DataType.Date)]
        [DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true)]
        public DateTime EnrollmentDate { get; set; }
        public int DepartmentID { get; set; }
        [ForeignKey("DepartmentID")]
        public virtual Department Department { get; set; }
        public int DepotID { get; set; }
        [ForeignKey("DepotID")]
        public virtual Depot Depot { get; set; }
        public virtual ICollection<Ticket> Tickets { get; set; }

    }

    public class ApplicationDbContext
        : IdentityDbContext<ApplicationUser, ApplicationRole, int,
        ApplicationUserLogin, ApplicationUserRole, ApplicationUserClaim>
    {
         public ApplicationDbContext()
            : base("DefaultConnection")
        {
        }

        static ApplicationDbContext()
        {
            Database.SetInitializer<ApplicationDbContext>(new ApplicationDbInitializer());
        }

        public static ApplicationDbContext Create()
        {
            return new ApplicationDbContext();
        }

        public DbSet<Ticket> Tickets { get; set; }
        public DbSet<Category> Categories { get; set; }
        public DbSet<Department> Departments { get; set; }
        public DbSet<Depot> Depots { get; set; }

    }

    public class ApplicationUserStore :
    UserStore<ApplicationUser, ApplicationRole, int,
    ApplicationUserLogin, ApplicationUserRole, ApplicationUserClaim>, IUserStore<ApplicationUser, int>, IDisposable
    {
        public ApplicationUserStore()
            : this(new IdentityDbContext())
        {
            base.DisposeContext = true;
        }

        public ApplicationUserStore(DbContext context)
            : base(context)
        {
        }
    }

    public class ApplicationRoleStore
    : RoleStore<ApplicationRole, int, ApplicationUserRole>,
    IQueryableRoleStore<ApplicationRole, int>,
    IRoleStore<ApplicationRole, int>, IDisposable
    {
        public ApplicationRoleStore()
            : base(new IdentityDbContext())
        {
            base.DisposeContext = true;
        }

        public ApplicationRoleStore(DbContext context)
            : base(context)
        {
        }
    }

}

Roles Controller
namespace RecreationalServicesTicketingSystem.Controllers
{
    //[Authorize(Roles = "Admin")]
    public class RolesAdminController : Controller
    {

         public RolesAdminController()
        {

        }

        public RolesAdminController(ApplicationUserManager userManager,
            ApplicationRoleManager roleManager)
        {
            UserManager = userManager;
            RoleManager = roleManager;
        }

        private ApplicationUserManager _userManager;
        public ApplicationUserManager UserManager
        {
            get
            {
                return _userManager ?? HttpContext.GetOwinContext().GetUserManager<ApplicationUserManager>();
            }
            set
            {
                _userManager = value;
            }
        }

        private ApplicationRoleManager _roleManager;
        public ApplicationRoleManager RoleManager
        {
            get
            {
                return _roleManager ?? HttpContext.GetOwinContext().Get<ApplicationRoleManager>();
            }
            private set
            {
                _roleManager = value;
            }
        }

        //
        // GET: /Roles/
        public ActionResult Index()
        {
            return View(RoleManager.Roles);
        }

        //
        // GET: /Roles/Details/5
        public async Task<ActionResult> Details(int id)
        {
            if (id > 0)
            {
                var role = await RoleManager.FindByIdAsync(id);
                // Get the list of Users in this Role
                var users = new List<ApplicationUser>();

                // Get the list of Users in this Role
                foreach (var user in UserManager.Users.ToList())
                {
                    if (await UserManager.IsInRoleAsync(user.Id, role.Name))
                    {
                        users.Add(user);
                    }
                }

                ViewBag.Users = users;
                ViewBag.UserCount = users.Count();
                return View(role);
            }
            return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
        }

        //
        // GET: /Roles/Create
        public ActionResult Create()
        {
            return View();
        }

        //
        // POST: /Roles/Create
        [HttpPost]
        public async Task<ActionResult> Create(RoleViewModel roleViewModel)
        {
            if (ModelState.IsValid)
            {
                // Use ApplicationRole, not IdentityRole:
                var role = new ApplicationRole(roleViewModel.Name);
                var roleresult = await RoleManager.CreateAsync(role);
                if (!roleresult.Succeeded)
                {
                    ModelState.AddModelError("", roleresult.Errors.First());
                    return View();
                }
                return RedirectToAction("Index");
            }
            return View();
        }

        //
        // GET: /Roles/Edit/Admin
        public async Task<ActionResult> Edit(int id)
        {
            if (id > 0)
            {
                var role = await RoleManager.FindByIdAsync(id);
                if (role == null)
                {
                    return HttpNotFound();
                }
                RoleViewModel roleModel = new RoleViewModel { Id = role.Id, Name = role.Name };
                return View(roleModel);
            }
            return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
        }

        //
        // POST: /Roles/Edit/5
        [HttpPost]

        [ValidateAntiForgeryToken]
        public async Task<ActionResult> Edit([Bind(Include = "Name,Id")] RoleViewModel roleModel)
        {
            if (ModelState.IsValid)
            {
                var role = await RoleManager.FindByIdAsync(roleModel.Id);
                role.Name = roleModel.Name;
                await RoleManager.UpdateAsync(role);
                return RedirectToAction("Index");
            }
            return View();
        }

        //
        // GET: /Roles/Delete/5
        public async Task<ActionResult> Delete(int id)
        {
            if (id > 0)
            {
                var role = await RoleManager.FindByIdAsync(id);
                if (role == null)
                {
                    return HttpNotFound();
                }
                return View(role);
            }
            return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
        }

        //
        // POST: /Roles/Delete/5
        [HttpPost, ActionName("Delete")]
        [ValidateAntiForgeryToken]
        public async Task<ActionResult> DeleteConfirmed(int id, string deleteUser)
        {
            if (ModelState.IsValid)
            {
                if (id > 0)
                {
                    var role = await RoleManager.FindByIdAsync(id);
                    if (role == null)
                    {
                        return HttpNotFound();
                    }
                    IdentityResult result;
                    if (deleteUser != null)
                    {
                        result = await RoleManager.DeleteAsync(role);
                    }
                    else
                    {
                        result = await RoleManager.DeleteAsync(role);
                    }
                    if (!result.Succeeded)
                    {
                        ModelState.AddModelError("", result.Errors.First());
                        return View();
                    }
                    return RedirectToAction("Index");
                }
                else
                {
                    return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
                }
            }
            return View();
        }
    }
}

A: The roles property of your new ApplicationUser object expects an iCollection of ApplicationUserRole items. See example below.
new ApplicationUser
{
    UserName = "jackie@hotmail.com",
    FirstMidName = "Jackie",
    LastName = "Chan",
    Email = "jasonw@rs.kiwi.nz",
    PasswordHash = password,
    Roles =
    {
        new ApplicationUserRole
        {
            RoleId = 1
        }
    },
    EnrollmentDate = DateTime.Parse("2016-02-18"),
    DepartmentID = 1,
    DepotID = 1,
    IsAdministrator = true,
    SecurityStamp = Guid.NewGuid().ToString()
}


text:
Q: Python Equivalent to Ruby's chunk_while? I have some interesting using cases in my Ruby code that I want to convert to Python. I think we can leverage in any lib, I mainly use pandas and numpy.
For instance, imagine that you have an array of timed events, these events have a timestamp and another properties (an object or a tuple).
I want a list/array of groups, where these groups are "contiguous" events, with a grace period of g units (in this case, time units).
In my Ruby code I use something like this:
grouped_events = events.chunk_while do |previous_event, next_event|
   next_event.timestamp <= previous_event.timestamp + grace_period
end

Since I'm not using only in timed events, but with anything that I can sort (so they're comparable somehow), I ask: there's a generic way, or a known lib that does this?

A: Python doesn't have an equivalent function. You'll have to write your own.
Here's my implementation, using an iterator and the yield statement:
def chunk_while(iterable, predicate):
    itr = iter(iterable)

    try:
        prev_value = next(itr)
    except StopIteration:
        # if the iterable is empty, yield nothing
        return

    chunk = [prev_value]
    for value in itr:
        # if the predicate returns False, start a new chunk
        if not predicate(prev_value, value):
            yield chunk
            chunk = []

        chunk.append(value)
        prev_value = value

    # don't forget to yield the final chunk
    if chunk:
        yield chunk

Which can be used like so:
>>> list(chunk_while([1, 3, 2, 5, 5], lambda prev, next_: next_ <= prev + 2))
[[1, 3, 2], [5, 5]]


text:
Q: Assigning binary to src isn't calling binary function The below code is what is happening behind code
Dim test1 As HtmlGenericControl = CType(e.Item.FindControl("test1"), HtmlGenericControl)
        Dim image As HtmlGenericControl = CType(e.Item.FindControl("imgFullImage"), HtmlGenericControl)
        hypImageProduct.Attributes.Add("onMouseOver",
                                       "ShowContent('" + test1.ClientID + "');document.getelementbyid('" + image.ClientID + "').src ='binary('" + Convert.ToBase64String(New DataClass().getProductStockPhoto(image.Attributes("alt"), 40, 40)) + "')';")

Then the following is the function that is used onpage for the binary but for some reason it seems that it isn't being called
function binary(d) {
        var o = '';
        for (var i=0; i<d.length; i=i+2) o+=String.fromCharCode(eval('0x'+(d.substring(i,i+2)).toString(16)));
        return o;
    }

I am probably doing something stupid and not noticing but i thought that it should work properly.

A: You have extra apostrophes around the function call. Change this:
... +"').src ='binary('" + ... + "')';")

into:
... +"').src = binary('" + ... + "');")


text:
Q: a NSManagedObject inherited class doesn't respond to addition I have a NSManagedObject model name A for which I create an addition A+Additions
But when I call a method from A+Additions the app crashes with unknown selector sent to object of class NSManagedObject.

A: found out that if you don't create the A.m from the editor menu,  the object in the xdatamodeld is not updated with the class name 'A' and defaults to 'NSManagedObject'.
So you have to manually set it and everythings works again.


text:
Q: JavaFX searchable combobox (like js select2) I am looking for a component like select2 for JavaFX.
A ComboBox which will have a searchable TextField when the popup appears and filtered ListView below.
Any ideas or something that is done already?

A: I implemented this myself a couple of months ago. The idea is basically that you wrap the ComboBox drop-down list in a FilteredList, and then you add a listener to the ComboBox#textProperty() that changes the predicate for the FilteredList.
My class contains a lot of extra functionality such as the option to transform lower case input to upper case and restricting the length of the input. You can just remove those parts if you don't need them.
import javafx.application.Application;
import javafx.application.Platform;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.collections.transformation.FilteredList;
import javafx.scene.Scene;
import javafx.scene.control.ComboBox;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;

public class MCVE extends Application {

    @Override
    public void start(Stage stage) {
        ComboBox<String> box = new ComboBox<String>();
        box.setEditable(true);

        // For the combo box filter to work properly we need to create the item
        // list and wrap it in a FilteredList.
        ObservableList<String> items = FXCollections.observableArrayList("One", "Two", "Three", "OneTwo", "ThreeTwo",
                "OneTwoThree");
        FilteredList<String> filteredItems = new FilteredList<String>(items);

        // Then you need to provide the InputFilter with the FilteredList in the
        // constructor call.
        box.getEditor().textProperty().addListener(new InputFilter(box, filteredItems, false));

        box.setItems(filteredItems);

        BorderPane view = new BorderPane();
        view.setCenter(box);

        stage.setScene(new Scene(view));
        stage.show();
    }

    public static void main(String[] args) {
        launch();
    }

    /**
     *
     * @author Jonatan Stenbacka
     *
     */
    class InputFilter implements ChangeListener<String> {

        private ComboBox<String> box;
        private FilteredList<String> items;
        private boolean upperCase;
        private int maxLength;
        private String restriction;

        /**
         * @param box
         *            The combo box to whose textProperty this listener is
         *            added.
         * @param items
         *            The {@link FilteredList} containing the items in the list.
         */
        public InputFilter(ComboBox<String> box, FilteredList<String> items, boolean upperCase, int maxLength,
                String restriction) {
            this.box = box;
            this.items = items;
            this.upperCase = upperCase;
            this.maxLength = maxLength;
            this.restriction = restriction;
        }

        public InputFilter(ComboBox<String> box, FilteredList<String> items, boolean upperCase, int maxLength) {
            this(box, items, upperCase, maxLength, null);
        }

        public InputFilter(ComboBox<String> box, FilteredList<String> items, boolean upperCase) {
            this(box, items, upperCase, -1, null);
        }

        public InputFilter(ComboBox<String> box, FilteredList<String> items) {
            this(box, items, false);
        }

        @Override
        public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
            StringProperty value = new SimpleStringProperty(newValue);

            // If any item is selected we save that reference.
            String selected = box.getSelectionModel().getSelectedItem() != null
                    ? box.getSelectionModel().getSelectedItem() : null;

            String selectedString = null;
            // We save the String of the selected item.
            if (selected != null) {
                selectedString = (String) selected;
            }

            if (upperCase) {
                value.set(value.get().toUpperCase());
            }

            if (maxLength >= 0 && value.get().length() > maxLength) {
                value.set(oldValue);
            }

            if (restriction != null) {
                if (!value.get().matches(restriction + "*")) {
                    value.set(oldValue);
                }
            }

            // If an item is selected and the value in the editor is the same
            // as the selected item we don't filter the list.
            if (selected != null && value.get().equals(selectedString)) {
                // This will place the caret at the end of the string when
                // something is selected.
                Platform.runLater(() -> box.getEditor().end());
            } else {
                items.setPredicate(item -> {
                    String itemString = item;
                    if (itemString.toUpperCase().contains(value.get().toUpperCase())) {
                        return true;
                    } else {
                        return false;
                    }
                });
            }

            // If the popup isn't already showing we show it.
            if (!box.isShowing()) {
                // If the new value is empty we don't want to show the popup,
                // since
                // this will happen when the combo box gets manually reset.
                if (!newValue.isEmpty() && box.isFocused()) {
                    box.show();
                }
            }
            // If it is showing and there's only one item in the popup, which is
            // an
            // exact match to the text, we hide the dropdown.
            else {
                if (items.size() == 1) {
                    // We need to get the String differently depending on the
                    // nature
                    // of the object.
                    String item = items.get(0);

                    // To get the value we want to compare with the written
                    // value, we need to crop the value according to the current
                    // selectionCrop.
                    String comparableItem = item;

                    if (value.get().equals(comparableItem)) {
                        Platform.runLater(() -> box.hide());
                    }
                }
            }

            box.getEditor().setText(value.get());
        }
    }
}


text:
Q: TTS Android removing addSpeech item? I have used
mTts.addSpeech(text, filename.getAbsolutePath() );

to map an audio file to a particular string of text.
The problem is that if the used deletes the file, which is possible/likely in my case, I need to remove the addSpeech  mapping from mTts (using removeSpeech() which does not exist) so that it reverts to computerised voice.
is this possible?
This is the stack trace I am getting after I add a file using addSpeech, then remove the file and attempt to speak again.
12-17 15:41:45.016: ERROR/MediaPlayer(361): error (1, -2147483648)
12-17 15:41:45.056: DEBUG/MediaPlayer(361): create failed:
12-17 15:41:45.056: DEBUG/MediaPlayer(361): java.io.IOException: Prepare failed.: status=0x1
12-17 15:41:45.056: DEBUG/MediaPlayer(361):     at android.media.MediaPlayer.prepare(Native Method)
12-17 15:41:45.056: DEBUG/MediaPlayer(361):     at android.media.MediaPlayer.create(MediaPlayer.java:611)
12-17 15:41:45.056: DEBUG/MediaPlayer(361):     at android.media.MediaPlayer.create(MediaPlayer.java:588)
12-17 15:41:45.056: DEBUG/MediaPlayer(361):     at android.tts.TtsService.processSpeechQueue(TtsService.java:1098)
12-17 15:41:45.056: DEBUG/MediaPlayer(361):     at android.tts.TtsService.speak(TtsService.java:507)
12-17 15:41:45.056: DEBUG/MediaPlayer(361):     at android.tts.TtsService.access$1900(TtsService.java:58)
12-17 15:41:45.056: DEBUG/MediaPlayer(361):     at android.tts.TtsService$1.speak(TtsService.java:1256)
12-17 15:41:45.056: DEBUG/MediaPlayer(361):     at android.speech.tts.ITts$Stub.onTransact(ITts.java:86)
12-17 15:41:45.056: DEBUG/MediaPlayer(361):     at android.os.Binder.execTransact(Binder.java:288)
12-17 15:41:45.056: DEBUG/MediaPlayer(361):     at dalvik.system.NativeStart.run(Native Method)

A: From API:
public int addSpeech (String text, String filename)
Adds a mapping between a string of text and a sound file. Using this, it is possible to add custom pronounciations for a string of text. After a call to this method, subsequent calls to
speak(String, int, HashMap)
will play the specified sound resource if it is available, or synthesize the text it is missing.
so, it's possible
I write simple method. It works.
private void speak(String text) {
    if(text != null) {
        HashMap<String, String> myHashAlarm = new HashMap<String, String>();
        myHashAlarm.put(TextToSpeech.Engine.KEY_PARAM_STREAM, String.valueOf(AudioManager.STREAM_ALARM));
        myHashAlarm.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, "end of message - "+text);
        mTts.speak(text, TextToSpeech.QUEUE_FLUSH, myHashAlarm);
    }
}


text:
Q: PHP en esta variable $sql me da errores de sintaxis Tengo esta sentencia :
    $sql = "INSERT INTO usuarios (nombre,apellidos,usuario,email,password)
    VALUES ('$datos['nombre']', '$datos['apellidos']', '$datos['usuario']', '$datos['email']', '$datos['password']')";

Esta variable la tengo en la siguiente funcion:
public function insertar($datos){

    $conexion = $this->c->conectar();

    // $sql = "INSERT INTO usuarios (nombre,apellidos,usuario,email,password)
    //      VALUES('$datos['nombre']','$datos['apellidos']','$datos['usuario']','$datos['email']','$datos['password']')";

    $sql = "INSERT INTO usuarios (nombre,apellidos,usuario,email,password)
    VALUES ('$datos['nombre']', '$datos['apellidos']', '$datos['usuario']', '$datos['email']', '$datos['password']')";

    // return $result = mysqli_query($conexion,$sql);
    return $result = $conexion->query($sql);

}

Me suelta el siguiente error : Parse error: syntax error, unexpected ''.
Pero tengo que poner las comillas si no no puedo usar mi array asociativo de $datos

A: El problema es que hay una ambigüedad de comillas dentro del string que forma el query y en este caso PHP no puede evaluar los valores del array.
Puedes resolverlo así:
$sql = "INSERT INTO usuarios (nombre,apellidos,usuario,email,password)
    VALUES ('".$datos['nombre']."', '".$datos['apellidos']."', '".$datos['usuario']."', '".$datos['email']."', '".$datos['password']."')";

O también
$nombre = $datos['nombre'];
$apellidos = $datos['apellidos'];
$usuario = $datos['usuario'];
$email = $datos['email'];
$password = $datos['password'];
$sql = "INSERT INTO usuarios (nombre,apellidos,usuario,email,password)
    VALUES ('$nombre', '$apellidos', '$usuario', '$email', '$password')";

A: Saludos puedes realizar lo siguiente:
public function insertar($datos){

    $conexion = $this->c->conectar();

    $nombre = $datos['nombre'];
    $apellidos = $datos['apellidos'];
    $usuario = $datos['usuario'];
    $email = $datos['email'];
    $password = $datos['password'];

    $sql = "INSERT INTO usuarios (nombre,apellidos,usuario,email,password)
    VALUES ('$nombre', '$apellidos', '$usuario', '$email', '$password')";

    return $result = $conexion->query($sql);

}

Si te fijas asigno en variables el cotenido de $datos, espero te sirva..!!

A: Tienes un problema con las comillas con la cadena que asignas a la variable $sql, las comillas sencillas de los nombres de variables ($datos['apellidos']), rompen la cadena con las comillas de los valores de la consulta ('{$datos['apellidos']}').
Una forma para evitar eso es incluyendo las variables de esta forma:
$sql = "INSERT INTO usuarios (nombre,apellidos,usuario,email,password) VALUES ('{$datos['nombre']}', '{$datos['apellidos']}', '{$datos['usuario']}', '{$datos['email']}', '{$datos['password']}')";


text:
Q: new locale in android (urdu/pakistan)
Possible Duplicate:
Set Locale programatically

I am a beginner in android. making my first app, all i want to do is localize my app to urdu language/pakistan. what should i do.
Where I can get the list of all android locale?

A: This post may be helpful, code of Urdu - Pakistan is ur-PK, which may not be present for your use. List of all android locale can be found here or here. Also take a look at localization tutorial

If you want to use urdu font for showing text in a view(say TextView) then:

Code for setting custom font to TextView:
Assuming you have a urdu ttf font say(URDU.ttf) font in fonts folder under assets folder:
 Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/URDU.ttf");
    TextView tv = (TextView) findViewById(R.id.txtview);
    tv.setTypeface(tf);

A: You might want to look this question. Also for urdu-pakistan you might get the code from here


text:
Q: Boundary is a union of orbits with strictly lower dimension I'm stuck on the proof of the following propsition in Humphreys Linear Algebraic Groups:

Let $G$ be an algebraic group acting morphically on a variety $X$.  Then each orbit is a smooth, locally closed subset of $X$, whose boundary is a union of orbits of strictly lower dimension.

Proof: Let $Y$ be an orbit in $X$.  As the continuous image of a closed set, $Y$ is constructible, and hence contains an open dense subset of $\overline{Y}$.  But $G$ acts transitively on $Y$ (and hence stablizes $\overline{Y}$), so $Y$ is smooth and contains a neighborhood in $\overline{Y}$ of each of its points, i.e. $Y$ is open in $\overline{Y}$.  Therefore, $\overline Y \setminus Y$ is closed and of strictly lower dimension than $\overline{Y}$.  Being $G$-stable, this boundary is just a union of other orbits.
Two questions: first, why is $Y$ is open in $\overline{Y}$?  I don't understand why each point in $Y$ admits an open neighborhood in $\overline{Y}$.  Second, why is $\overline{Y} \setminus Y$ of strictly lower dimension than $\overline{Y}$?

A: Let $x\in X$ with $Y=G\cdot x$. There is a subset $U\subseteq Y$, which is open and dense in $\bar{Y}$, so you can write the orbit as union of open sets
$$G\cdot x=\bigcup_{g\in G} g\cdot U, $$
where $g\cdot U$ is open as isomorphic image of an open set.
$\overline{G\cdot x}\setminus G\cdot x$ is a closed subset and every irreducible component of it is a proper subset of a irreducible component of $\overline{G\cdot x}$, because $G\cdot x$ is dense in $\overline{G\cdot x}$. So by definition of krull dimension it has stricly lower dimension.


text:
Q: Modifying dropdownlist inside jquery popup affects after re-opening popup I have a dropdownlist, which with its selectedindexchanged event it populates a second dropdownlist. they are hosted in a jquery popup and they are all parts of a user control which all of its contenttemplate is surrounded with an updatepanel.
My problem is that population of the second dropdownlist is happened after closing and re-opening the popup.
Can you please guide me on what can be the source of the problem?


text:
Q: website open delay in mobile application i am trying to convert my website to a mobile application, i just need from the application to open my website nothing more.
i am using visual studio 2015 using ionic
the website takes about 17 seconds to open, i don't know why, and another thing is that the alert in case there is no internet is not appearing.
this is my code:
app.js
angular.module('starter', ['ionic'])

.run(function ($ionicPlatform) {

//----------------------------------------------------------------------------
    document.addEventListener("deviceready", onDeviceReady, false);

    function onDeviceReady() {
        // Now safe to use the Codova API
        if (navigator.onLine)
            window.location = "http://mywebsite.com";
           // toast.show("Welcome to mywebsite,connect to internet to see our products");
        else
            navigator.notification.alert(
     'please connect to internet!',  // message
     alertDismissed,         // callback
     '',            // title
     'Done'                  // buttonName
 );

    }

//-----------------------------------------------------------------------------------

    $ionicPlatform.ready(function() {
        if (cordova.platformId === "ios" && window.cordova && window.cordova.plugins.Keyboard) {
            // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
            // for form inputs)
            cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);

            // Don't remove this line unless you know what you are doing. It stops the viewport
            // from snapping when text inputs are focused. Ionic handles this internally for
            // a much nicer keyboard experience.
            cordova.plugins.Keyboard.disableScroll(true);
        }
        if(window.StatusBar) {
            StatusBar.styleDefault();
        }

    });
})


text:
Q: Regular Expression in php, compilation failed $string = '/product/list.html?a=b';
$regex = '#^^/(?P[\w]+)/(?P[\w]+)(?P[^\.]*)\.*(?P[html|xml|json]*)(?P[\?.*]*)$$#';
$count = preg_match($regex, $string, $matches);

When i run above code, it raises this warning:
Warning: preg_match(): Compilation failed: unrecognized character after (?P at offset 6 in php shell code on line 1

I couldn't see where is the problem?

A: (?P is used to start a named capturing group. The syntax is:
(?P<name>regexp)

When you use this syntax, the part of the string that matches the regexp will be found in $matches['name'].
You're missing <name> from your regexp.

A: New solution ;)
This works as: //someurl/index.php/controller/action
    if (array_key_exists('PATH_INFO', $_SERVER)) {
        $parts = explode('/', trim($_SERVER['PATH_INFO'], ' /'));

        @list($controller, $action) = $parts;
        $params = array_slice($parts, 2);

        $controller = empty($controller) ? 'default' : ucfirst(strtolower($controller));
        $action = empty($action) ? 'default' : strtolower($action);
    } else {
        $params = array();
        $controller = 'default';
        $action = 'default';
    }

Wouldn't this be more simple? (Change 'default' into anything you desire)

A: Your regex seems a little bit wrong, maybe you were trying to get this:
#^/(?P<folder>[\w]+)/(?P<name>[\w]+)\.(?P<ext>html|xml|json)\?(?P<query>.*)$#

Example
Result:
0 -> /product/list.html?a=b
folder -> product
name -> list
ext -> html
query -> a=b


text:
Q: EADDRNOTAVAIL even after using IP_FREEBIND? I was under the impression that under Linux you could bind to a non-local address as long as you set the IP_FREEBIND socket option, but that's not the behavior I'm seeing:
$ sudo strace -e 'trace=%network' ...
...
socket(AF_INET, SOCK_RAW, IPPROTO_UDP)  = 5
setsockopt(5, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
setsockopt(5, SOL_SOCKET, SO_NO_CHECK, [1], 4) = 0
setsockopt(5, SOL_IP, IP_HDRINCL, [1], 4) = 0
setsockopt(5, SOL_IP, IP_FREEBIND, [1], 4) = 0
bind(5, {sa_family=AF_INET, sin_port=htons(abcd), sin_addr=inet_addr("w.x.y.z")}, 16) = -1 EADDRNOTAVAIL (Cannot assign requested address)
...

I also set the ip_nonlocal_bind setting, just to be certain, and I get the same results.
$ sysctl net.ipv4.ip_nonlocal_bind
net.ipv4.ip_nonlocal_bind = 1

A: Unfortunately, it seems that it is not possible to bind a raw IP socket to a non-local, non-broadcast and non-multicast address, regardless of IP_FREEBIND. Since I see inet_addr("w.x.y.z") in your strace output, I assume that this is exactly what you're trying to do and w.x.y.z is a non-local unicast address, thus your bind syscall fails.
This seems in accordance with man 7 raw:

A raw socket can be bound to a specific local  address  using  the
bind(2)  call.   If it isn't bound, all packets with the specified
IP protocol are received.  In addition, a raw socket can be  bound
to a specific network device using SO_BINDTODEVICE; see socket(7).

Indeed, looking at the kernel source code, in raw_bind() we can see the following check:
    ret = -EADDRNOTAVAIL;
    if (addr->sin_addr.s_addr && chk_addr_ret != RTN_LOCAL &&
        chk_addr_ret != RTN_MULTICAST && chk_addr_ret != RTN_BROADCAST)
        goto out;

Also, note that .sin_port must be 0. The .sin_port field for raw sockets is used to select a sending/receiving IP protocol (not a port, since we are at level 3 and ports do not exist). As the manual states, from Linux 2.2 onwards you cannot select a sending protocol through .sin_port anymore, the sending protocol is the one set when creating the socket.


text:
Q: Better Way to Write Regular Expression So, I've been trying to write out a regular expression for something like a resistance value, which contains a certain amount of digits and at most one letter, but is always a certain amount of characters total (let's use the example of a four-character resistance code).
First I could do '\d*[RKM]\d*' but that would allow something like 'R'.
Also, I could do something like '[\dRKM]{4}', but this will allow things like 'RRR4' which is not a value that I would want.
'\d{1,4}[Rr]\d{0,3} | ([RKM]\d{3}) | (\d{4})', though more specific, would still allow '1234R567' which is not four characters.
So basically, is there a more compact way of writing '[RKM]\d\d\d | \d[RKM]\d\d | \d\d[RKM]\d | \d\d\d[RKM] | \d\d\d\d'?

A: Depending on your regex flavor, you can use a lookahead:
^(?!(?:\d*\D){2})[\dRKM]{4}$

*

*(?!(?:\d*\D) - Assert that there aren't two non-digit characters.

Or:
^(?=.{4}$)\d*(?:[RKM]\d*)?$

*

*(?=.{4}$) - Assert that the length of the string is 4.

See also: Regular Expressions: Is there an AND operator?