问:
JS increase two counter where the 2nd as a relationship with the second
I'm trying to increment a counter by a specific % only when a certain condition is met. I don't have access to the other counter function but only the output which is numbers. Specifically.

I have a function countdown which its output is a number changing from 100 to 1.

I have a let size = 0.

When the countdown hit 10 (10 inclusive) let size get added by 5%.

```<code> 10 = +5%
    9 = +10%
    8 = + 15%
</code>```

etc.. until 1 = 50%

I'm trying to work with modulos and changing the base to work on (/0,05*100) but I could'nt get any result.

Also, for searching related resources what should I type into google? Is my title correct?

Thank you in advance

adding more accurate information

答:
You could take the difference of ten and multiply by five and add an offset of five.

var i = 10;

do {
    console.log(i, (10 - i) * 5 + 5);
} while (--i)```

Body:
I'm trying to increment a counter by a specific % only when a certain condition is met. I don't have access to the other counter function but only the output which is numbers. Specifically.

I have a function countdown which its output is a number changing from 100 to 1.

I have a let size = 0.

When the countdown hit 10 (10 inclusive) let size get added by 5%.

 10 = +5%
    9 = +10%
    8 = + 15%

etc.. until 1 = 50%

I'm trying to work with modulos and changing the base to work on (/0,05*100) but I could'nt get any result.

Also, for searching related resources what should I type into google? Is my title correct?

Thank you in advance

adding more accurate information


来源: stackexchange

问:
How to send an array with objects to next screen in react-native?
I want to sent atn array to next screen, this atn array is fine and all the item are easily accesible...I am new to react-native, okay this atn array is on ListM.js and I want to take this array to VenueD.js.... help thanks in advance.</p>

答:
You can pass data from a component to another by using props

It would be something like this:

```<code>//MyComponent.js
const myArr = [1, 2, 3];

<MyChild array={myArr} />

//MyChild.js - if statless component
const MyChild = (props) => {
  const receivedArray = props.myArr;
  // or const { myArr } = props;
}

//MyChild.js - if class component
class MyChild extends Component {
  constructor(props) {
    super(props)
  }
  render() {
    const receivedArray = this.props.myArr;
    return(

    );
  }
}
</code>```

Note that there might be typos, I wrote the code here in the comment.

I suggest you to check out the official docs for further information.

https://facebook.github.io/react-native/docs/props.html

https://facebook.github.io/react-vr/docs/components-props-and-state.html

Hope it helps

Edit:

According to the provided info in the comments below, make sure you have set up your navigation components in your root file.
If you are being able to navigate and just need to send params from a component to another, then you may call your navigate method like this navigate('RouteToVenuD', {atn}).
Then atn will be availble on VenuD as this.props.navigation.state.params.atn.

Hope it helps

ContentLicense: CC BY-SA 3.0

Body:
You can pass data from a component to another by using props

It would be something like this:

//MyComponent.js
const myArr = [1, 2, 3];

<MyChild array={myArr} />

//MyChild.js - if statless component
const MyChild = (props) => {
  const receivedArray = props.myArr;
  // or const { myArr } = props;
}

//MyChild.js - if class component
class MyChild extends Component {
  constructor(props) {
    super(props)
  }
  render() {
    const receivedArray = this.props.myArr;
    return(

    );
  }
}

Note that there might be typos, I wrote the code here in the comment.

I suggest you to check out the official docs for further information.

https://facebook.github.io/react-native/docs/props.html

https://facebook.github.io/react-vr/docs/components-props-and-state.html

Hope it helps

Edit:

According to the provided info in the comments below, make sure you have set up your navigation components in your root file.
If you are being able to navigate and just need to send params from a component to another, then you may call your navigate method like this navigate('RouteToVenuD', {atn}).
Then atn will be availble on VenuD as this.props.navigation.state.params.atn.

Hope it helps


问:
On the STM32F4, why does setting the main clock source as the PLL corrupt the rest of the program?
first question here, thank you for your patience.

I'm facing an issue with an STM32F446VET6-based board (the ST-B96B-F446VE from STMicroelectronics), using the StdPeriph library v1.8.0. I've narrowed down the issue to a str instruction in the SetSysClock function:

```<code>;722          RCC->CFGR |= RCC_CFGR_SW_PLL;
; RCC->CFGR = 0x9400
; RCC_CFGR_SW_PLL = 0x02
ldr r2, [pc, #36]   ; (0x80005a8 <SetSysClock+284>)
ldr r3, [pc, #36]   ; (0x80005a8 <SetSysClock+284>)
ldr r3, [r3, #8]
orr.w   r3, r3, #2
str r3, [r2, #8]    ; r2 = 0x40023800, r3 = 0x9402
</code>```

The instruction result should be that the second bit of RCC->CFGR (SW1) be set to 1, in order to set up the PLL as the main clock source.

Instead, the bit stays at 0, and a whole lot of code past 0x08000000 (in the flash) is overwritten. For instance, this line in SystemInit():

```<code>; SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */
ldr     r3, [pc, #12]   ; (0x8000484 <SystemInit+96>)
mov.w   r2, #134217728  ; 0x8000000
str     r2, [r3, #8]
</code>```

ends up rewritten as:

```<code>; SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */
bic.w   r3, r3, #262144 ; 0x40000
str     r3, [r2, #0]
ldr     r3, [pc, #24]   ; (0x8000494 <SetSysClock+8>)
</code>```

Letting the program run in this state and pausing it again shows some more overwriting happened, again at the same lines:

```<code>; SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */
b.n     0x8000476 <SystemInit+86>
subs    r0, #0
ands    r2, r0
</code>```

and it hangs in the subs and ands instructions.

Incidentally, replacing the line RCC->CFGR |= RCC_CFGR_SW_PLL; by RCC->CFGR |= RCC_CFGR_SW_HSE; resolves the issue. No corruption happens, and main() executes properly. But now it's using another clock source, with no idea what implications this carries.

Is there some way to revert to the default state of using the PLL as the main clock source, and avoid the flash corruption?

答:
I've narrowed down the issue to a str instruction in the SetSysClock function:

That usually means you forgot to set the flash wait states before. Flash memory ist rather slow - it tops usually at around 20 MHz without wait states for many MCUs. Trying to run it too fast result in reading garbage.

Reference Manual and datasheet should state how many wait states your target frequency requires for flash access. Note: It is safe (but slower) to run the flash at maximum wait states.

Body:
first question here, thank you for your patience.

I'm facing an issue with an STM32F446VET6-based board (the ST-B96B-F446VE from STMicroelectronics), using the StdPeriph library v1.8.0. I've narrowed down the issue to a str instruction in the SetSysClock function:

;722          RCC->CFGR |= RCC_CFGR_SW_PLL;
; RCC->CFGR = 0x9400
; RCC_CFGR_SW_PLL = 0x02
ldr r2, [pc, #36]   ; (0x80005a8 <SetSysClock+284>)
ldr r3, [pc, #36]   ; (0x80005a8 <SetSysClock+284>)
ldr r3, [r3, #8]
orr.w   r3, r3, #2
str r3, [r2, #8]    ; r2 = 0x40023800, r3 = 0x9402

The instruction result should be that the second bit of RCC->CFGR (SW1) be set to 1, in order to set up the PLL as the main clock source.

Instead, the bit stays at 0, and a whole lot of code past 0x08000000 (in the flash) is overwritten. For instance, this line in SystemInit():

; SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */
ldr     r3, [pc, #12]   ; (0x8000484 <SystemInit+96>)
mov.w   r2, #134217728  ; 0x8000000
str     r2, [r3, #8]

ends up rewritten as:

; SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */
bic.w   r3, r3, #262144 ; 0x40000
str     r3, [r2, #0]
ldr     r3, [pc, #24]   ; (0x8000494 <SetSysClock+8>)

Letting the program run in this state and pausing it again shows some more overwriting happened, again at the same lines:

; SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */
b.n     0x8000476 <SystemInit+86>
subs    r0, #0
ands    r2, r0

and it hangs in the subs and ands instructions.

Incidentally, replacing the line RCC->CFGR |= RCC_CFGR_SW_PLL; by RCC->CFGR |= RCC_CFGR_SW_HSE; resolves the issue. No corruption happens, and main() executes properly. But now it's using another clock source, with no idea what implications this carries.

Is there some way to revert to the default state of using the PLL as the main clock source, and avoid the flash corruption?


问:
How to take items in list and reform them into json
I have 4 SEPARATED json with 4 keys sum, min, max, count with list like below:

```<code>"sum" :  ["columnA", "columnB", "columnC", "columnD"]

"min" :  ["columnA", "columnC"]

"max" :  ["columnB", "columnC"]

"count" : ["columnA", "columnD"]
</code>```

How can I take them and repack into a json object like this:

```<code>{ "columnA" : ["sum", "min","count" ] , "columnB" : ["sum", "max"], "columnC" : ["sum", "min", "max"] }
</code>```

答:
For quick(development) result, try this:

```<code>>>> my_json = {"sum" :  ["columnA", "columnB", "columnC", "columnD"]
,"min" :  ["columnA", "columnC"]
,"max" :  ["columnB", "columnC"]
,"count" : ["columnA", "columnD"]}
>>> result = {}
>>> [result.setdefault(col,[]).append(key) for key,value in my_json.items() for col in value]
>>> result
{'columnD': ['count', 'sum'], 'columnA': ['count', 'sum', 'min'], 'columnC': ['max', 'sum', 'min'], 'columnB': ['max', 'sum']}
</code>```

A more readable version:

```<code>>>> result = {}
>>> for function, columns in my_json.items():
        for column in columns:
            result.setdefault(column, []).append(function)

>>> result
{'columnD': ['count', 'sum'], 'columnA': ['count', 'sum', 'min'], 'columnC': ['max', 'sum', 'min'], 'columnB': ['max', 'sum']}
</code>```

Body:
I have 4 SEPARATED json with 4 keys sum, min, max, count with list like below:

"sum" :  ["columnA", "columnB", "columnC", "columnD"]

"min" :  ["columnA", "columnC"]

"max" :  ["columnB", "columnC"]

"count" : ["columnA", "columnD"]

How can I take them and repack into a json object like this:

{ "columnA" : ["sum", "min","count" ] , "columnB" : ["sum", "max"], "columnC" : ["sum", "min", "max"] }

Body:
For quick(development) result, try this:

>>> my_json = {"sum" :  ["columnA", "columnB", "columnC", "columnD"]
,"min" :  ["columnA", "columnC"]
,"max" :  ["columnB", "columnC"]
,"count" : ["columnA", "columnD"]}
>>> result = {}
>>> [result.setdefault(col,[]).append(key) for key,value in my_json.items() for col in value]
>>> result
{'columnD': ['count', 'sum'], 'columnA': ['count', 'sum', 'min'], 'columnC': ['max', 'sum', 'min'], 'columnB': ['max', 'sum']}

A more readable version:

>>> result = {}
>>> for function, columns in my_json.items():
        for column in columns:
            result.setdefault(column, []).append(function)

>>> result
{'columnD': ['count', 'sum'], 'columnA': ['count', 'sum', 'min'], 'columnC': ['max', 'sum', 'min'], 'columnB': ['max', 'sum']}


问:
Get opposite structure field in C++
Let us suppose I have the following structs:

```<code>struct Point
{double _x, _y;};
struct Segment
{Point _p1, _p2;};
typedef Point Segment::* const SegmentEnd;
</code>```

And now I would like to introduce the function which would scale the segment with relation to the SegmentEnd provided. That means change coordinates of the opposite to the provided SegmentEnd. How can I do it?

Here is the code I made to change the provided SegmentEnd, but I need to change the opposite one:

```<code>void scale(Segment& segment, SegmentEnd end, const double& scaleVal)
{
    Point& p(segment.*end);
    p._x = scaleVal*p._x;
    p._y = scaleVal*p._y;
}
</code>```

答:
You can define a function that returns the other end:</p>

```<code>SegmentEnd opposite(SegmentEnd e)
{
    return e == &Segment::_p1 ? &Segment::_p2 : &Segment::_p1;
}

// ...
Point& one(segment.*end);
Point& other(segment.*opposite(end));
</code>```

Title: Get opposite structure field in C++

Body:
Let us suppose I have the following structs:

struct Point
{double _x, _y;};
struct Segment
{Point _p1, _p2;};
typedef Point Segment::* const SegmentEnd;

And now I would like to introduce the function which would scale the segment with relation to the SegmentEnd provided. That means change coordinates of the opposite to the provided SegmentEnd. How can I do it?

Here is the code I made to change the provided SegmentEnd, but I need to change the opposite one:

void scale(Segment& segment, SegmentEnd end, const double& scaleVal)
{
    Point& p(segment.*end);
    p._x = scaleVal*p._x;
    p._y = scaleVal*p._y;
}

Body:
You can define a function that returns the other end:

SegmentEnd opposite(SegmentEnd e)
{
    return e == &Segment::_p1 ? &Segment::_p2 : &Segment::_p1;
}

// ...
Point& one(segment.*end);
Point& other(segment.*opposite(end));


问:
Add randomly selected column to result
I'd like to know if there is a more optimal query to get what I want from the database.

My database schema is as follows :

Table1:
(NUM_T1C1;ID_T1C2)

Table2:
(ID_T2C1;RES_T2C2)

First, I want to get a random row defined as:

```<code>SELECT NUM_T1C1, ID_T2C1
FROM (
    SELECT T1.NUM_T1C1, T2.ID_T2C1, DBMS_RANDOM.VALUE
    FROM TABLE1 T1, TABLE2 T2
    WHERE T1.NUM_T1C1 IS NOT NULL
    AND T2.RES_T2C2 IS NOT NULL
    AND T1.ID_T1C2 = T2.ID_T2C1
    ORDER BY 3
) WHERE ROWNUM = 1
</code>```

I will call this query: QUERY1.

My question is as follows, I want to get a row as (random NUM_T1C1 != QUERY1.NUM_T1C1; ID_T2C1 == QUERY1.ID_T2C1), so I have tried:

```<code>SELECT NUM_T1C1, ID_T2C1
FROM (
    SELECT R2.NUM_T1C1, R1.ID_T2C1, DBMS_RANDOM.VALUE
    FROM (
        SELECT NUM_T1C1, ID_T2C1
        FROM (
            SELECT T1.NUM_T1C1, T2.ID_T2C1, DBMS_RANDOM.VALUE
            FROM TABLE1 T1, TABLE2 T2
            WHERE T1.NUM_T1C1 IS NOT NULL
            AND T2.RES_T2C2 IS NOT NULL
            AND T1.ID_T1C2 = T2.ID_T2C1
            ORDER BY 3
        ) WHERE ROWNUM = 1
    ) R1, TABLE1 R2
    WHERE R2.NUM_T1C1 <> R1.NUM_T1C1
    ORDER BY 3
) WHERE ROWNUM = 1
</code>```

It's working, but I think this is not the optimal way to do so.
Is there a better way to get the expected result?

EDIT:

I found another way to get those random rows but i still don't know if it's optimal:

```<code>SELECT NUM_T1C1, ID_T2C1
FROM (
    SELECT R1.NUM_T1C1, R2.ID_T2C1
    FROM
    (
        SELECT T1.NUM_T1C1, T2.ID_T2C1, DBMS_RANDOM.VALUE
        FROM TABLE1 T1, TABLE2 T2
        WHERE T1.NUM_T1C1 IS NOT NULL
        AND T2.T2C2 IS NULL
        AND T1.ID_T1C2 = T2.ID_T2C1
        ORDER BY 3
    ) R1,
    (
        SELECT T2.ID_T2C1, DBMS_RANDOM.VALUE
        FROM TABLE1 T1, TABLE2 T2
        WHERE T1.NUM_T1C1 IS NOT NULL
        AND T2.T2C2 IS NOT NULL
        AND T1.ID_T1C2 = T2.ID_T2C1
        ORDER BY 2
    ) R2
) WHERE ROWNUM = 1
</code>```

Here is an example :

```<code>        Table1                  Table2
+----------+---------+  +---------+----------+
| NUM_T1C1 | ID_T1C2 |  | ID_T2C1 | RES_T2C2 |
+----------+---------+  +---------+----------+
| 23       | 5       |  | 9       | NULL     |
| 521      | 4       |  | 4       | DG_513   |
| 71       | 7       |  | 7       | FN_731   |
| 97       | 9       |  | 5       | NULL     |
+----------+---------+  +---------+----------+
</code>```

Result would be one of those (select one randomly) :

```<code>+----------+---------+
| NUM_T1C1 | ID_T2C1 |
+----------+---------+
| 23       | 4       |
| 23       | 7       |
| 97       | 4       |
| 97       | 7       |
+----------+---------+
</code>```

答:
Here is one way with only a single (cross) join:

SQL Fiddle

Oracle 11g R2 Schema Setup:

```<code>CREATE TABLE Table1 ( NUM_T1C1, ID_T1C2 ) AS
SELECT  23, 5 FROM DUAL UNION ALL
SELECT 521, 4 FROM DUAL UNION ALL
SELECT  71, 7 FROM DUAL UNION ALL
SELECT  97, 9 FROM DUAL;

CREATE TABLE Table2 ( ID_T2C1, RES_T2C2 ) As
SELECT 9, NULL     FROM DUAL UNION ALL
SELECT 4, 'DG_513' FROM DUAL UNION ALL
SELECT 7, 'FN_731' FROM DUAL UNION ALL
SELECT 5, NULL     FROM DUAL;
</code>```

Query 1:

```<code>SELECT NUM_T1C1, ID_T2C1
FROM   (
  SELECT NUM_T1C1,
         ID_T2C1,
         COUNT( CASE WHEN T1.ID_T1C2 = T2.ID_T2C1 THEN 1 END )
           OVER ( PARTITION BY T1.NUM_T1C1 ) AS num_matches
  FROM   Table1 T1
         CROSS JOIN
         (
           SELECT *
           FROM   Table2
           WHERE  RES_T2C2 IS NOT NULL
         ) T2
  ORDER BY DBMS_RANDOM.VALUE
)
WHERE  num_matches = 0
--AND    ROWNUM = 1
</code>```

Results:

```<code>| NUM_T1C1 | ID_T2C1 |
|----------|---------|
|       23 |       7 |
|       97 |       4 |
|       97 |       7 |
|       23 |       4 |
</code>```

Title: Add randomly selected column to result

Body:
I'd like to know if there is a more optimal query to get what I want from the database.

My database schema is as follows :

Table1:
(NUM_T1C1;ID_T1C2)

Table2:
(ID_T2C1;RES_T2C2)

First, I want to get a random row defined as:

SELECT NUM_T1C1, ID_T2C1
FROM (
    SELECT T1.NUM_T1C1, T2.ID_T2C1, DBMS_RANDOM.VALUE
    FROM TABLE1 T1, TABLE2 T2
    WHERE T1.NUM_T1C1 IS NOT NULL
    AND T2.RES_T2C2 IS NOT NULL
    AND T1.ID_T1C2 = T2.ID_T2C1
    ORDER BY 3
) WHERE ROWNUM = 1

I will call this query: QUERY1.

My question is as follows, I want to get a row as (random NUM_T1C1 != QUERY1.NUM_T1C1; ID_T2C1 == QUERY1.ID_T2C1), so I have tried:

SELECT NUM_T1C1, ID_T2C1
FROM (
    SELECT R2.NUM_T1C1, R1.ID_T2C1, DBMS_RANDOM.VALUE
    FROM (
        SELECT NUM_T1C1, ID_T2C1
        FROM (
            SELECT T1.NUM_T1C1, T2.ID_T2C1, DBMS_RANDOM.VALUE
            FROM TABLE1 T1, TABLE2 T2
            WHERE T1.NUM_T1C1 IS NOT NULL
            AND T2.RES_T2C2 IS NOT NULL
            AND T1.ID_T1C2 = T2.ID_T2C1
            ORDER BY 3
        ) WHERE ROWNUM = 1
    ) R1, TABLE1 R2
    WHERE R2.NUM_T1C1 <> R1.NUM_T1C1
    ORDER BY 3
) WHERE ROWNUM = 1

It's working, but I think this is not the optimal way to do so.
Is there a better way to get the expected result?

EDIT:

I found another way to get those random rows but i still don't know if it's optimal:

SELECT NUM_T1C1, ID_T2C1
FROM (
    SELECT R1.NUM_T1C1, R2.ID_T2C1
    FROM
    (
        SELECT T1.NUM_T1C1, T2.ID_T2C1, DBMS_RANDOM.VALUE
        FROM TABLE1 T1, TABLE2 T2
        WHERE T1.NUM_T1C1 IS NOT NULL
        AND T2.T2C2 IS NULL
        AND T1.ID_T1C2 = T2.ID_T2C1
        ORDER BY 3
    ) R1,
    (
        SELECT T2.ID_T2C1, DBMS_RANDOM.VALUE
        FROM TABLE1 T1, TABLE2 T2
        WHERE T1.NUM_T1C1 IS NOT NULL
        AND T2.T2C2 IS NOT NULL
        AND T1.ID_T1C2 = T2.ID_T2C1
        ORDER BY 2
    ) R2
) WHERE ROWNUM = 1

Here is an example :

        Table1                  Table2
+----------+---------+  +---------+----------+
| NUM_T1C1 | ID_T1C2 |  | ID_T2C1 | RES_T2C2 |
+----------+---------+  +---------+----------+
| 23       | 5       |  | 9       | NULL     |
| 521      | 4       |  | 4       | DG_513   |
| 71       | 7       |  | 7       | FN_731   |
| 97       | 9       |  | 5       | NULL     |
+----------+---------+  +---------+----------+

Result would be one of those (select one randomly) :

+----------+---------+
| NUM_T1C1 | ID_T2C1 |
+----------+---------+
| 23       | 4       |
| 23       | 7       |
| 97       | 4       |
| 97       | 7       |
+----------+---------+

Body:
Here is one way with only a single (cross) join:

SQL Fiddle

Oracle 11g R2 Schema Setup:

CREATE TABLE Table1 ( NUM_T1C1, ID_T1C2 ) AS
SELECT  23, 5 FROM DUAL UNION ALL
SELECT 521, 4 FROM DUAL UNION ALL
SELECT  71, 7 FROM DUAL UNION ALL
SELECT  97, 9 FROM DUAL;

CREATE TABLE Table2 ( ID_T2C1, RES_T2C2 ) As
SELECT 9, NULL     FROM DUAL UNION ALL
SELECT 4, 'DG_513' FROM DUAL UNION ALL
SELECT 7, 'FN_731' FROM DUAL UNION ALL
SELECT 5, NULL     FROM DUAL;

Query 1:

SELECT NUM_T1C1, ID_T2C1
FROM   (
  SELECT NUM_T1C1,
         ID_T2C1,
         COUNT( CASE WHEN T1.ID_T1C2 = T2.ID_T2C1 THEN 1 END )
           OVER ( PARTITION BY T1.NUM_T1C1 ) AS num_matches
  FROM   Table1 T1
         CROSS JOIN
         (
           SELECT *
           FROM   Table2
           WHERE  RES_T2C2 IS NOT NULL
         ) T2
  ORDER BY DBMS_RANDOM.VALUE
)
WHERE  num_matches = 0
--AND    ROWNUM = 1

Results:

| NUM_T1C1 | ID_T2C1 |
|----------|---------|
|       23 |       7 |
|       97 |       4 |
|       97 |       7 |
|       23 |       4 |


问:
How to generate heatmap in ruby-on-rails?
I created a new application and added the gem 'heatmap' in gemfile of map. I then did a bundle install, but I do not know on how to write the heatmap code on which file.

This is what I tried:

```<code>map = Heatmap.new
map << Heatmap::Area.new(1, 10)
map << Heatmap::Area.new(5, 20)
map << Heatmap::Area.new(17, 10)
map << Heatmap::Area.new(25, 38)
map << Heatmap::Area.new(35, 70)
map << Heatmap::Area.new(15, 90)
map << Heatmap::Area.new(27, 60)
map.output('simple.png')
</code>```

答:
We made a gem to generate, save and display heatmap data. The gem uses famous js library to show the generated data.

https://github.com/Qbatch/heatmap-rails

Body:
I created a new application and added the gem 'heatmap' in gemfile of map. I then did a bundle install, but I do not know on how to write the heatmap code on which file.

This is what I tried:

map = Heatmap.new
map << Heatmap::Area.new(1, 10)
map << Heatmap::Area.new(5, 20)
map << Heatmap::Area.new(17, 10)
map << Heatmap::Area.new(25, 38)
map << Heatmap::Area.new(35, 70)
map << Heatmap::Area.new(15, 90)
map << Heatmap::Area.new(27, 60)
map.output('simple.png')


问:
How to perform case sensitive group by in MS Access
In MS Access database to find the mismatch (i.e. difference) records between two tables(Employee and Employee_PROD) I am using the UNION ALL. The query is as follows:

```<code>SELECT [COMPANY],[DEPT],[DOJ],[EMP_ID],[Name],[SUB_COMPANY] FROM

(SELECT '[Employee]' AS TableName,[COMPANY],[DEPT],[DOJ],[EMP_ID],[Name],[SUB_COMPANY] FROM [Employee]

UNION ALL

SELECT '[Employee_PROD]' AS TableName,[COMPANY],[DEPT],[DOJ],[EMP_ID],[Name],[SUB_COMPANY] FROM [Employee_PROD] )

GROUP BY [COMPANY],[DEPT],[DOJ],[EMP_ID],[Name],[SUB_COMPANY]
HAVING COUNT(*) = 1 AND MIN(TableName) = '[Employee]'
</code>```

The problem I am facing is that the GROUP BY is not considering the case sensitivity. For example "andrew" and "Andrew" is treated as same. I want to perform group by with case sensitive to find the difference records.

Is there any way to do the same in MS Access?

Is there any other approach to find the differences between two tables having same column names, data types and the number of records is 7,00, 000?

I have tried the following:

Load data to DataTable and then find the difference. Got out of memory exception due to huge amount of data.

Use NOT EXISTS to compare the rows. The query got hanged and the execution never completed.

The UNION ALL approach is working but the issue is that GROUP BY is not considering the case sensitivity.

答:
Can you not specify OPTION COMPARE BINARY in a module to perform a case sensitive search?

This thread https://access-programmers.co.uk/forums/showthread.php?t=33962 and this one How to write Case Sensitive Query for MS Access? both describe different methods.

Body:
In MS Access database to find the mismatch (i.e. difference) records between two tables(Employee and Employee_PROD) I am using the UNION ALL. The query is as follows:

SELECT [COMPANY],[DEPT],[DOJ],[EMP_ID],[Name],[SUB_COMPANY] FROM

(SELECT '[Employee]' AS TableName,[COMPANY],[DEPT],[DOJ],[EMP_ID],[Name],[SUB_COMPANY] FROM [Employee]

UNION ALL

SELECT '[Employee_PROD]' AS TableName,[COMPANY],[DEPT],[DOJ],[EMP_ID],[Name],[SUB_COMPANY] FROM [Employee_PROD] )

GROUP BY [COMPANY],[DEPT],[DOJ],[EMP_ID],[Name],[SUB_COMPANY]
HAVING COUNT(*) = 1 AND MIN(TableName) = '[Employee]'

The problem I am facing is that the GROUP BY is not considering the case sensitivity. For example "andrew" and "Andrew" is treated as same. I want to perform group by with case sensitive to find the difference records.

Is there any way to do the same in MS Access?

Is there any other approach to find the differences between two tables having same column names, data types and the number of records is 7,00, 000?

I have tried the following:

Load data to DataTable and then find the difference. Got out of memory exception due to huge amount of data.

Use NOT EXISTS to compare the rows. The query got hanged and the execution never completed.

The UNION ALL approach is working but the issue is that GROUP BY is not considering the case sensitivity.


问:
Ext JS Sencha 6.2 , Value to be selected from store as per Radio button value
back to stackoverflow for bothering you people. I have written one script containing one Radio Button Group and one Cartesian Chart. I want to get the data from the store for the particular selected value of zone through radio button. This value should only be displayed in chart. Values from rest service are being loaded properly in store Chartdata.js . How it can be achieved please.
BasicZone.js</p>

```<code>Ext.define('LICApp.view.charts.bar3d.BasicZone', {
    extend: 'Ext.form.Panel',
    xtype: 'bar-basic-zone',
    controller: 'bar-basic-3d',
    requires: [
        'Ext.chart.theme.Muted',
        'LICApp.store.Chartdata',
        'Ext.form.RadioManager'

    ],

    width: 1300,
    bind: '{Chartdata}',

    items: [{
        xtype: 'fieldcontainer',
        fieldLabel: 'Zone',
        defaultType: 'radiofield',
        isRadio: true,
        inputType: 'radio',
        ariaRole: 'radio',
        listeners: {
            selected: 'getGroupValue'
        },
        defaults: {
            flex: 1
        },
        layout: 'hbox',
        items: [{
            boxLabel: 'Central Office',
            name: 'zone',
            inputValue: 'Central Office',
            id: 'radio1'
        }, {
            boxLabel: 'Central Zone',
            name: 'zone',
            inputValue: 'Central Zone',
            id: 'radio2'
        }, {
            boxLabel: 'East-Central Zone',
            name: 'zone',
            inputValue: 'East-Central Zone',
            id: 'radio3'
        }, {
            boxLabel: 'Eastern Zone',
            name: 'zone',
            inputValue: 'Eastern Zone',
            id: 'radio4'
        }, {
            boxLabel: 'North-Central Zone',
            name: 'zone',
            inputValue: 'North-Central Zone',
            id: 'radio5'
        }, {
            boxLabel: 'Northern Zone',
            name: 'zone',
            inputValue: 'Northern Zone',
            id: 'radio6'
        }, {
            boxLabel: 'South-Central Zone',
            name: 'zone',
            inputValue: 'South-Central Zone',
            id: 'radio7'
        }, {
            boxLabel: 'Southern Zone',
            name: 'zone',
            inputValue: 'Southern Zone',
            id: 'radio8'
        }, {
            boxLabel: 'Western Zone',
            name: 'zone',
            inputValue: 'Western Zone',
            id: 'radio9'
        }]

    }, {
        xtype: 'cartesian',
        title: 'Zone - At a glance',
        reference: 'chart2',
        interactions: ['itemhighlight'],
        width: '100%',
        height: 600,
        insetPadding: 40,
        innerPadding: '0 3 0 0',
        theme: 'Muted',
        legend: {
            docked: 'bottom'
        },
        store: {
            type: 'chartdata',
            autoLoad: true
        },
        animation: Ext.isIE8 ? false : {
            easing: 'backOut',
            duration: 500
        },
        axes: [{
            type: 'numeric3d',
            position: 'left',
            grid: true,
            fields: ['data1', 'data2', 'data3', 'data4', 'data5', 'data6', 'data7'],
            renderer: 'onAxisLabelRender1',
            minimum: 0,
        }, {
            type: 'category3d',
            position: 'bottom',
            grid: true,

            fields: ['selected'],

            label: {
                rotate: {
                    degrees: -10
                }
            }
        }],
        series: [{
            type: 'bar3d',
            fullStack: false,
            title: ['Total Users', 'Biometric Enrolled ', 'Authorised Users', 'Devices Issued', 'User Confirmation', 'eFeap Enabled', 'Concurrencia Enabled'],
            xField: 'zone',
            yField: ['data1', 'data2', 'data3', 'data4', 'data5', 'data6', 'data7'],
            stacked: false,
            highlightCfg: {
                brightnessFactor: 1.2,
                saturationFactor: 1.5
            },
            tooltip: {
                trackMouse: true,
                renderer: 'onSeriesTooltipRender1'
            }
        }],
        sprites: [{
            type: 'text',
            text: '2FA Biometric Progress - Zonewise comparison',
            fontSize: 22,
            width: 100,
            height: 30,
            x: 40, // the sprite x position
            y: 20 // the sprite y position
        }, {
            type: 'text',
            text: 'Source: 2FA Data Server',
            fontSize: 10,
            x: 12,
            y: 520
        }]
    }]
});
</code>```

答:
You need to use load() or loadData() method of store on radiogroup change event.

In this FIDDLE, I have used your code and made some change as per your requirement. Hope this will help you or guide you to solve your problem.

```<code>var chartStore = Ext.create('Ext.data.Store', {
    fields: ['data1', 'data2', 'data3', 'data4', 'data5', 'data6', 'data7', 'zone'],
    data: []
});

function getRandomArbitrary() {
    var min = 10,
        max = 50;
    return Math.random() * (max - min) + min;
}

function doCreateData(newValue) {
    var obj = {
            zone: newValue.zone
        },
        key = 1;
    for (; key <= 7; key++) {
        obj[`data${key}`] = getRandomArbitrary();
    }
    return [obj];
}

Ext.create('Ext.form.Panel', {
    renderTo: Ext.getBody(),
    layout: 'vbox',
    items: [{
        xtype: 'radiogroup',
        fieldLabel: 'Zones',
        columns: 6,
        vertical: true,
        listeners: {
            change: function (cmp, newValue) {
                chartStore.loadData(doCreateData(newValue));
            }
        },
        defaults: {
            flex: 1,
            margin:'0 10'
        },
        items: [{
            boxLabel: 'Central Office',
            name: 'zone',
            inputValue: 'Central Office',
            id: 'radio1'
        }, {
            boxLabel: 'Central Zone',
            name: 'zone',
            inputValue: 'Central Zone',
            id: 'radio2'
        }, {
            boxLabel: 'East-Central Zone',
            name: 'zone',
            inputValue: 'East-Central Zone',
            id: 'radio3'
        }, {
            boxLabel: 'Eastern Zone',
            name: 'zone',
            inputValue: 'Eastern Zone',
            id: 'radio4'
        }, {
            boxLabel: 'North-Central Zone',
            name: 'zone',
            inputValue: 'North-Central Zone',
            id: 'radio5'
        }, {
            boxLabel: 'Northern Zone',
            name: 'zone',
            inputValue: 'Northern Zone',
            id: 'radio6'
        }, {
            boxLabel: 'South-Central Zone',
            name: 'zone',
            inputValue: 'South-Central Zone',
            id: 'radio7'
        }, {
            boxLabel: 'Southern Zone',
            name: 'zone',
            inputValue: 'Southern Zone',
            id: 'radio8'
        }, {
            boxLabel: 'Western Zone',
            name: 'zone',
            inputValue: 'Western Zone',
            id: 'radio9'
        }]
    }, {
        xtype: 'cartesian',
        title: 'Zone - At a glance',
        reference: 'chart2',
        interactions: ['itemhighlight'],
        width: '100%',
        height: 400,
        flex: 1,
        innerPadding: '0 3 0 0',
        legend: {
            docked: 'bottom'
        },
        store: chartStore,
        animation: Ext.isIE8 ? false : {
            easing: 'backOut',
            duration: 500
        },
        axes: [{
            type: 'numeric3d',
            position: 'left',
            grid: true,
            fields: ['data1', 'data2', 'data3', 'data4', 'data5', 'data6', 'data7', 'zone'],
            minimum: 0,
        }, {
            type: 'category3d',
            position: 'bottom',
            title: {
                text: 'Zone',
                fontSize: 15
            },
            grid: true,
            fields: 'zone'
        }],
        series: [{
            type: 'bar3d',
            fullStack: false,
            title: ['Total Users', 'Biometric Enrolled ', 'Authorised Users', 'Devices Issued', 'User Confirmation', 'eFeap Enabled', 'Concurrencia Enabled'],
            xField: 'zone',
            yField: ['data1', 'data2', 'data3', 'data4', 'data5', 'data6', 'data7'],
            stacked: false
        }]
    }]
});
</code>```

Body:
back to stackoverflow for bothering you people. I have written one script containing one Radio Button Group and one Cartesian Chart. I want to get the data from the store for the particular selected value of zone through radio button. This value should only be displayed in chart. Values from rest service are being loaded properly in store Chartdata.js . How it can be achieved please.
BasicZone.js

Ext.define('LICApp.view.charts.bar3d.BasicZone', {
    extend: 'Ext.form.Panel',
    xtype: 'bar-basic-zone',
    controller: 'bar-basic-3d',
    requires: [
        'Ext.chart.theme.Muted',
        'LICApp.store.Chartdata',
        'Ext.form.RadioManager'

    ],

    width: 1300,
    bind: '{Chartdata}',

    items: [{
        xtype: 'fieldcontainer',
        fieldLabel: 'Zone',
        defaultType: 'radiofield',
        isRadio: true,
        inputType: 'radio',
        ariaRole: 'radio',
        listeners: {
            selected: 'getGroupValue'
        },
        defaults: {
            flex: 1
        },
        layout: 'hbox',
        items: [{
            boxLabel: 'Central Office',
            name: 'zone',
            inputValue: 'Central Office',
            id: 'radio1'
        }, {
            boxLabel: 'Central Zone',
            name: 'zone',
            inputValue: 'Central Zone',
            id: 'radio2'
        }, {
            boxLabel: 'East-Central Zone',
            name: 'zone',
            inputValue: 'East-Central Zone',
            id: 'radio3'
        }, {
            boxLabel: 'Eastern Zone',
            name: 'zone',
            inputValue: 'Eastern Zone',
            id: 'radio4'
        }, {
            boxLabel: 'North-Central Zone',
            name: 'zone',
            inputValue: 'North-Central Zone',
            id: 'radio5'
        }, {
            boxLabel: 'Northern Zone',
            name: 'zone',
            inputValue: 'Northern Zone',
            id: 'radio6'
        }, {
            boxLabel: 'South-Central Zone',
            name: 'zone',
            inputValue: 'South-Central Zone',
            id: 'radio7'
        }, {
            boxLabel: 'Southern Zone',
            name: 'zone',
            inputValue: 'Southern Zone',
            id: 'radio8'
        }, {
            boxLabel: 'Western Zone',
            name: 'zone',
            inputValue: 'Western Zone',
            id: 'radio9'
        }]

    }, {
        xtype: 'cartesian',
        title: 'Zone - At a glance',
        reference: 'chart2',
        interactions: ['itemhighlight'],
        width: '100%',
        height: 600,
        insetPadding: 40,
        innerPadding: '0 3 0 0',
        theme: 'Muted',
        legend: {
            docked: 'bottom'
        },
        store: {
            type: 'chartdata',
            autoLoad: true
        },
        animation: Ext.isIE8 ? false : {
            easing: 'backOut',
            duration: 500
        },
        axes: [{
            type: 'numeric3d',
            position: 'left',
            grid: true,
            fields: ['data1', 'data2', 'data3', 'data4', 'data5', 'data6', 'data7'],
            renderer: 'onAxisLabelRender1',
            minimum: 0,
        }, {
            type: 'category3d',
            position: 'bottom',
            grid: true,

            fields: ['selected'],

            label: {
                rotate: {
                    degrees: -10
                }
            }
        }],
        series: [{
            type: 'bar3d',
            fullStack: false,
            title: ['Total Users', 'Biometric Enrolled ', 'Authorised Users', 'Devices Issued', 'User Confirmation', 'eFeap Enabled', 'Concurrencia Enabled'],
            xField: 'zone',
            yField: ['data1', 'data2', 'data3', 'data4', 'data5', 'data6', 'data7'],
            stacked: false,
            highlightCfg: {
                brightnessFactor: 1.2,
                saturationFactor: 1.5
            },
            tooltip: {
                trackMouse: true,
                renderer: 'onSeriesTooltipRender1'
            }
        }],
        sprites: [{
            type: 'text',
            text: '2FA Biometric Progress - Zonewise comparison',
            fontSize: 22,
            width: 100,
            height: 30,
            x: 40, // the sprite x position
            y: 20 // the sprite y position
        }, {
            type: 'text',
            text: 'Source: 2FA Data Server',
            fontSize: 10,
            x: 12,
            y: 520
        }]
    }]
});

Body:
You need to use load() or loadData() method of store on radiogroup change event.

In this FIDDLE, I have used your code and made some change as per your requirement. Hope this will help you or guide you to solve your problem.

var chartStore = Ext.create('Ext.data.Store', {
    fields: ['data1', 'data2', 'data3', 'data4', 'data5', 'data6', 'data7', 'zone'],
    data: []
});

function getRandomArbitrary() {
    var min = 10,
        max = 50;
    return Math.random() * (max - min) + min;
}

function doCreateData(newValue) {
    var obj = {
            zone: newValue.zone
        },
        key = 1;
    for (; key <= 7; key++) {
        obj[`data${key}`] = getRandomArbitrary();
    }
    return [obj];
}

Ext.create('Ext.form.Panel', {
    renderTo: Ext.getBody(),
    layout: 'vbox',
    items: [{
        xtype: 'radiogroup',
        fieldLabel: 'Zones',
        columns: 6,
        vertical: true,
        listeners: {
            change: function (cmp, newValue) {
                chartStore.loadData(doCreateData(newValue));
            }
        },
        defaults: {
            flex: 1,
            margin:'0 10'
        },
        items: [{
            boxLabel: 'Central Office',
            name: 'zone',
            inputValue: 'Central Office',
            id: 'radio1'
        }, {
            boxLabel: 'Central Zone',
            name: 'zone',
            inputValue: 'Central Zone',
            id: 'radio2'
        }, {
            boxLabel: 'East-Central Zone',
            name: 'zone',
            inputValue: 'East-Central Zone',
            id: 'radio3'
        }, {
            boxLabel: 'Eastern Zone',
            name: 'zone',
            inputValue: 'Eastern Zone',
            id: 'radio4'
        }, {
            boxLabel: 'North-Central Zone',
            name: 'zone',
            inputValue: 'North-Central Zone',
            id: 'radio5'
        }, {
            boxLabel: 'Northern Zone',
            name: 'zone',
            inputValue: 'Northern Zone',
            id: 'radio6'
        }, {
            boxLabel: 'South-Central Zone',
            name: 'zone',
            inputValue: 'South-Central Zone',
            id: 'radio7'
        }, {
            boxLabel: 'Southern Zone',
            name: 'zone',
            inputValue: 'Southern Zone',
            id: 'radio8'
        }, {
            boxLabel: 'Western Zone',
            name: 'zone',
            inputValue: 'Western Zone',
            id: 'radio9'
        }]
    }, {
        xtype: 'cartesian',
        title: 'Zone - At a glance',
        reference: 'chart2',
        interactions: ['itemhighlight'],
        width: '100%',
        height: 400,
        flex: 1,
        innerPadding: '0 3 0 0',
        legend: {
            docked: 'bottom'
        },
        store: chartStore,
        animation: Ext.isIE8 ? false : {
            easing: 'backOut',
            duration: 500
        },
        axes: [{
            type: 'numeric3d',
            position: 'left',
            grid: true,
            fields: ['data1', 'data2', 'data3', 'data4', 'data5', 'data6', 'data7', 'zone'],
            minimum: 0,
        }, {
            type: 'category3d',
            position: 'bottom',
            title: {
                text: 'Zone',
                fontSize: 15
            },
            grid: true,
            fields: 'zone'
        }],
        series: [{
            type: 'bar3d',
            fullStack: false,
            title: ['Total Users', 'Biometric Enrolled ', 'Authorised Users', 'Devices Issued', 'User Confirmation', 'eFeap Enabled', 'Concurrencia Enabled'],
            xField: 'zone',
            yField: ['data1', 'data2', 'data3', 'data4', 'data5', 'data6', 'data7'],
            stacked: false
        }]
    }]
});


问:
Persistence Migration for Ignite
There are some wal and other db files in my server's disk if I use ignite persistence in my application. I wonder if I can copy those files onto the other server and restart ignite instance to provide service as before.</p>

答:
I think it should be possible if you set the same consistent ID (org.apache.ignite.configuration.IgniteConfiguration#setConsistentId) every time.

More details could be found here and here

Title: Persistence Migration for Ignite


问:
How to retrieve value from callback response array in javascript
I tried to take id file from callback response of google drive uploader. The code I use is like this:

```<code>function handleFileSelect(evt) {
           document.getElementById("info_upload").innerHTML = "Sedang memproses file untuk diupload...";
         evt.stopPropagation();
         evt.preventDefault();
         var files = evt.dataTransfer.files; // FileList object.

         var output = [];
         for (var i = 0, f; f = files[i]; i++) {
             var uploader = new MediaUploader({
                 file: f,
                 token: accessToken,
                 onComplete: function(data) {
                    document.getElementById('result').value = data['id'];
                 }
             });
             uploader.upload();
         }
       }
</code>```

I've tried all the ways I know to take the id file but it's still not working. I have tried data.id or data[array index].

This is all of Callback response array value.

```<code>{
 "kind": "drive#file",
 "id": "1_EfEFzN4qppKGrcDK6T_SS5hdeAovFK-",
 "etag": "\"rOX0fJzgyZU36BYOEcGKIYxPCtI/MTUxMjU1MzQwMzA0Mw\"",
 "selfLink": "https://www.googleapis.com/drive/v2/files/1_EfEFzN4qppKGrcDK6T_SS5hdeAovFK-",
 "webContentLink": "https://drive.google.com/uc?id=1_EfEFzN4qppKGrcDK6T_SS5hdeAovFK-&export=download",
 "alternateLink": "https://drive.google.com/file/d/1_EfEFzN4qppKGrcDK6T_SS5hdeAovFK-/view?usp=drivesdk",
 "embedLink": "https://drive.google.com/file/d/1_EfEFzN4qppKGrcDK6T_SS5hdeAovFK-/preview?usp=drivesdk",
 "iconLink": "https://drive-thirdparty.googleusercontent.com/16/type/image/png",
 "thumbnailLink": "https://lh5.googleusercontent.com/D_wWrHgdhRw6fnLaG0w2_nczIHxP1_gzD1-0N47_nlLZk2dXCLPP1GPj6SN37TQHNvvsG54zJSQ=s220",
 "title": "1.png",
 "mimeType": "image/png",
 "labels": {
  "starred": false,
  "hidden": false,
  "trashed": false,
  "restricted": false,
  "viewed": true
 },
 "createdDate": "2017-12-06T09:43:23.043Z",
 "modifiedDate": "2017-12-06T09:43:23.043Z",
 "modifiedByMeDate": "2017-12-06T09:43:23.043Z",
 "lastViewedByMeDate": "2017-12-06T09:43:23.043Z",
 "markedViewedByMeDate": "1970-01-01T00:00:00.000Z",
 "version": "2",
 "parents": [
  {
   "kind": "drive#parentReference",
   "id": "0ALL4ishr4YNbUk9PVA",
   "selfLink": "https://www.googleapis.com/drive/v2/files/1_EfEFzN4qppKGrcDK6T_SS5hdeAovFK-/parents/0ALL4ishr4YNbUk9PVA",
   "parentLink": "https://www.googleapis.com/drive/v2/files/0ALL4ishr4YNbUk9PVA",
   "isRoot": true
  }
 ],
 "downloadUrl": "https://doc-04-28-docs.googleusercontent.com/docs/securesc/faqhpav83cnunr53av2ik9r00tmicagg/7fvl938cmksp83dk43pp0oo5qiseh3sr/1512547200000/13075436128251877983/13075436128251877983/1_EfEFzN4qppKGrcDK6T_SS5hdeAovFK-?e=download&gd=true",
 "userPermission": {
  "kind": "drive#permission",
  "etag": "\"rOX0fJzgyZU36BYOEcGKIYxPCtI/ZgAdmVNnouRC2sSB3efF5W7Fobk\"",
  "id": "me",
  "selfLink": "https://www.googleapis.com/drive/v2/files/1_EfEFzN4qppKGrcDK6T_SS5hdeAovFK-/permissions/me",
  "role": "owner",
  "type": "user"
 },
 "originalFilename": "1.png",
 "fileExtension": "png",
 "md5Checksum": "dd9b4aa37a7a35de368d73d002ba6bf9",
 "fileSize": "852232",
 "quotaBytesUsed": "852232",
 "ownerNames": [
  "Abdul Kahar"
 ],
 "owners": [
  {
   "kind": "drive#user",
   "displayName": "Abdul Kahar",
   "picture": {
    "url": "https://lh5.googleusercontent.com/-vsm5aHKmIJU/AAAAAAAAAAI/AAAAAAAAAY8/KIbhdHI1by4/s64/photo.jpg"
   },
   "isAuthenticatedUser": true,
   "permissionId": "13075436128251877983",
   "emailAddress": "abdulkaharumar@gmail.com"
  }
 ],
 "lastModifyingUserName": "Abdul Kahar",
 "lastModifyingUser": {
  "kind": "drive#user",
  "displayName": "Abdul Kahar",
  "picture": {
   "url": "https://lh5.googleusercontent.com/-vsm5aHKmIJU/AAAAAAAAAAI/AAAAAAAAAY8/KIbhdHI1by4/s64/photo.jpg"
  },
  "isAuthenticatedUser": true,
  "permissionId": "13075436128251877983",
  "emailAddress": "abdulkaharumar@gmail.com"
 },
 "capabilities": {
  "canCopy": true,
  "canEdit": true
 },
 "editable": true,
 "copyable": true,
 "writersCanShare": true,
 "shared": false,
 "explicitlyTrashed": false,
 "appDataContents": false,
 "headRevisionId": "0B7L4ishr4YNbRDRYRXZhVUJlM2VtSEh2ai9JVlR3NnFZbkJFPQ",
 "imageMediaMetadata": {
  "width": 1365,
  "height": 719,
  "rotation": 0
 },
 "spaces": [
  "drive"
 ]
}
</code>```

If I use data[0] then that appears only "{", the others such as data[1], data[2], and data[3] do not work.

答:
It looks like you need to deserialize the JSON response to convert it from a string into an object.</p>

```<code>onComplete: function(data) {
    data = JSON.parse(data);
    document.getElementById('result').value = data['id'];
}
</code>```

Body:
I tried to take id file from callback response of google drive uploader. The code I use is like this:

function handleFileSelect(evt) {
           document.getElementById("info_upload").innerHTML = "Sedang memproses file untuk diupload...";
         evt.stopPropagation();
         evt.preventDefault();
         var files = evt.dataTransfer.files; // FileList object.

         var output = [];
         for (var i = 0, f; f = files[i]; i++) {
             var uploader = new MediaUploader({
                 file: f,
                 token: accessToken,
                 onComplete: function(data) {
                    document.getElementById('result').value = data['id'];
                 }
             });
             uploader.upload();
         }
       }

I've tried all the ways I know to take the id file but it's still not working. I have tried data.id or data[array index].

This is all of Callback response array value.

{
 "kind": "drive#file",
 "id": "1_EfEFzN4qppKGrcDK6T_SS5hdeAovFK-",
 "etag": "\"rOX0fJzgyZU36BYOEcGKIYxPCtI/MTUxMjU1MzQwMzA0Mw\"",
 "selfLink": "https://www.googleapis.com/drive/v2/files/1_EfEFzN4qppKGrcDK6T_SS5hdeAovFK-",
 "webContentLink": "https://drive.google.com/uc?id=1_EfEFzN4qppKGrcDK6T_SS5hdeAovFK-&export=download",
 "alternateLink": "https://drive.google.com/file/d/1_EfEFzN4qppKGrcDK6T_SS5hdeAovFK-/view?usp=drivesdk",
 "embedLink": "https://drive.google.com/file/d/1_EfEFzN4qppKGrcDK6T_SS5hdeAovFK-/preview?usp=drivesdk",
 "iconLink": "https://drive-thirdparty.googleusercontent.com/16/type/image/png",
 "thumbnailLink": "https://lh5.googleusercontent.com/D_wWrHgdhRw6fnLaG0w2_nczIHxP1_gzD1-0N47_nlLZk2dXCLPP1GPj6SN37TQHNvvsG54zJSQ=s220",
 "title": "1.png",
 "mimeType": "image/png",
 "labels": {
  "starred": false,
  "hidden": false,
  "trashed": false,
  "restricted": false,
  "viewed": true
 },
 "createdDate": "2017-12-06T09:43:23.043Z",
 "modifiedDate": "2017-12-06T09:43:23.043Z",
 "modifiedByMeDate": "2017-12-06T09:43:23.043Z",
 "lastViewedByMeDate": "2017-12-06T09:43:23.043Z",
 "markedViewedByMeDate": "1970-01-01T00:00:00.000Z",
 "version": "2",
 "parents": [
  {
   "kind": "drive#parentReference",
   "id": "0ALL4ishr4YNbUk9PVA",
   "selfLink": "https://www.googleapis.com/drive/v2/files/1_EfEFzN4qppKGrcDK6T_SS5hdeAovFK-/parents/0ALL4ishr4YNbUk9PVA",
   "parentLink": "https://www.googleapis.com/drive/v2/files/0ALL4ishr4YNbUk9PVA",
   "isRoot": true
  }
 ],
 "downloadUrl": "https://doc-04-28-docs.googleusercontent.com/docs/securesc/faqhpav83cnunr53av2ik9r00tmicagg/7fvl938cmksp83dk43pp0oo5qiseh3sr/1512547200000/13075436128251877983/13075436128251877983/1_EfEFzN4qppKGrcDK6T_SS5hdeAovFK-?e=download&gd=true",
 "userPermission": {
  "kind": "drive#permission",
  "etag": "\"rOX0fJzgyZU36BYOEcGKIYxPCtI/ZgAdmVNnouRC2sSB3efF5W7Fobk\"",
  "id": "me",
  "selfLink": "https://www.googleapis.com/drive/v2/files/1_EfEFzN4qppKGrcDK6T_SS5hdeAovFK-/permissions/me",
  "role": "owner",
  "type": "user"
 },
 "originalFilename": "1.png",
 "fileExtension": "png",
 "md5Checksum": "dd9b4aa37a7a35de368d73d002ba6bf9",
 "fileSize": "852232",
 "quotaBytesUsed": "852232",
 "ownerNames": [
  "Abdul Kahar"
 ],
 "owners": [
  {
   "kind": "drive#user",
   "displayName": "Abdul Kahar",
   "picture": {
    "url": "https://lh5.googleusercontent.com/-vsm5aHKmIJU/AAAAAAAAAAI/AAAAAAAAAY8/KIbhdHI1by4/s64/photo.jpg"
   },
   "isAuthenticatedUser": true,
   "permissionId": "13075436128251877983",
   "emailAddress": "abdulkaharumar@gmail.com"
  }
 ],
 "lastModifyingUserName": "Abdul Kahar",
 "lastModifyingUser": {
  "kind": "drive#user",
  "displayName": "Abdul Kahar",
  "picture": {
   "url": "https://lh5.googleusercontent.com/-vsm5aHKmIJU/AAAAAAAAAAI/AAAAAAAAAY8/KIbhdHI1by4/s64/photo.jpg"
  },
  "isAuthenticatedUser": true,
  "permissionId": "13075436128251877983",
  "emailAddress": "abdulkaharumar@gmail.com"
 },
 "capabilities": {
  "canCopy": true,
  "canEdit": true
 },
 "editable": true,
 "copyable": true,
 "writersCanShare": true,
 "shared": false,
 "explicitlyTrashed": false,
 "appDataContents": false,
 "headRevisionId": "0B7L4ishr4YNbRDRYRXZhVUJlM2VtSEh2ai9JVlR3NnFZbkJFPQ",
 "imageMediaMetadata": {
  "width": 1365,
  "height": 719,
  "rotation": 0
 },
 "spaces": [
  "drive"
 ]
}

If I use data[0] then that appears only "{", the others such as data[1], data[2], and data[3] do not work.

Body:
It looks like you need to deserialize the JSON response to convert it from a string into an object.

onComplete: function(data) {
    data = JSON.parse(data);
    document.getElementById('result').value = data['id'];
}


问:
NSURLConnection requests from multiple methods - getting a callback to starter method
I have a few methods that are posting data to a server. I am using NSURLConnection asynchronously. I am using a class variable NSMutableData and this is created in the viewDidLoad.

I have one method connection created for login and one for registration. Both just return a success booleon in response.

My question is, when the connection is complete and I receive my response, is there anyway to know which method started the connection? I.e some kind of callback to say that the login method started the connection.

Thanks

答:
When you start the connection, store a reference to the NSURLConnection object. When the connection finishes it will pass you the connection object as a parameter, which you can check like so:

```<code>- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
    if (connection==loginConnection) {

    } else if (connection==regConnection) {

    }
}
</code>```

The other (possibly better) option is to offload all of the HTTP connection handling to a separate wrapper class. You can build your own from your existing code, or use a third-party one like ASIHTTPRequest or GTM HTTP Fetcher.

ContentLicense: CC BY-SA 2.5

Body:
When you start the connection, store a reference to the NSURLConnection object. When the connection finishes it will pass you the connection object as a parameter, which you can check like so:

- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
    if (connection==loginConnection) {

    } else if (connection==regConnection) {

    }
}

The other (possibly better) option is to offload all of the HTTP connection handling to a separate wrapper class. You can build your own from your existing code, or use a third-party one like ASIHTTPRequest or GTM HTTP Fetcher.


答:
If what you are asking for is to get access the other member (the one you did NOT provide as argument), you could probably do something with comparing addresses of the element you sent in with, say _p1, and if that matches you know you want to access _p2 instead etc. But you should really solve your problem in another way if you want the least bit of readability.

I have never come across a situation where the pointer-to-member access operators could have improved my code and I am confident that will not change by reading your post here.

Edit:
So the alternative answer is in the comments of the question (ninjad by Francois), use an enum or bool argument to tell which end to operate on.

Title: Get opposite structure field in C++


问:
Safely convert SIZE_T to WORD
In my C code, I want to convert SIZE_T WINAPI type, in either 32/64 bit system to a WORD WINAPI type.

```<code>#include <Windows.h>
SIZE_T nValueToConvert;
WORD wConvertedValue;
</code>```

In case that nValueToConvert is too big for WORD type I want to know abot it and raise an error. What is the best and safest way to do that?

答:
Conversion may not give a proper result. The type sizes are different. Check this:

Window Data Types

SIZE_T Unsigned integral type; defined as:

```<code>typedef ULONG_PTR SIZE_T;
</code>```

WORD   A 16-bit unsigned integer. The range is 0 through 65535 decimal.
This type is declared in WinDef.h as follows:

```<code>  typedef unsigned short WORD;
</code>```

But if you really want to compare them than

```<code>if( nValueToConvert > 65535 ) (
{
    DbgPrint("Conversion is not safe\n");
}
else
{
    DbgPrint("conversion is OK\n");
}
</code>```

Title: Safely convert SIZE_T to WORD

Body:
In my C code, I want to convert SIZE_T WINAPI type, in either 32/64 bit system to a WORD WINAPI type.

#include <Windows.h>
SIZE_T nValueToConvert;
WORD wConvertedValue;

In case that nValueToConvert is too big for WORD type I want to know abot it and raise an error. What is the best and safest way to do that?

Body:
Conversion may not give a proper result. The type sizes are different. Check this:

Window Data Types

SIZE_T Unsigned integral type; defined as:

typedef ULONG_PTR SIZE_T;

WORD   A 16-bit unsigned integer. The range is 0 through 65535 decimal.
This type is declared in WinDef.h as follows:

  typedef unsigned short WORD;

But if you really want to compare them than

if( nValueToConvert > 65535 ) (
{
    DbgPrint("Conversion is not safe\n");
}
else
{
    DbgPrint("conversion is OK\n");
}


问:
Caused by: android.view.InflateException: Binary XML file line #0: Error inflating class com.mapbox.mapboxsdk.maps.MapView
Application throws a view.InflateException while opening MapBox, in API 19. This is the error:

```<code>12-06 11:59:22.057 2906-2906/com.example.sabith.doortracker E/UncaughtException: java.lang.RuntimeException: Unable to
start activity ComponentInfo{com.example.sabith.doortracker/com.example.sabith.doortracker.view.admin.WorkPolylineActivity}:
android.view.InflateException: Binary XML file line #0: Error inflating class com.mapbox.mapboxsdk.maps.MapView
 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
 at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
 at android.app.ActivityThread.access$800(ActivityThread.java:135)
 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
 at android.os.Handler.dispatchMessage(Handler.java:102)
 at android.os.Looper.loop(Looper.java:136)
 at android.app.ActivityThread.main(ActivityThread.java:5017)
 at java.lang.reflect.Method.invokeNative(Native Method)
 at java.lang.reflect.Method.invoke(Method.java:515)
 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
 at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #0: Error inflating class com.mapbox.mapboxsdk.maps.MapView
 at android.view.LayoutInflater.createView(LayoutInflater.java:621)
 at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:697)
 at android.view.LayoutInflater.rInflate(LayoutInflater.java:756)
 at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
 at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
 at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
 at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
 at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
 at com.example.sabith.doortracker.view.admin.WorkPolylineActivity.onCreate(WorkPolylineActivity.java:71)
 at android.app.Activity.performCreate(Activity.java:5231)
 at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
 at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
 at android.app.ActivityThread.access$800(ActivityThread.java:135)
 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
 at android.os.Handler.dispatchMessage(Handler.java:102)
 at android.os.Looper.loop(Looper.java:136)
 at android.app.ActivityThread.main(ActivityThread.java:5017)
 at java.lang.reflect.Method.invokeNative(Native Method)
 at java.lang.reflect.Method.invoke(Method.java:515)
 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
 at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException
 at java.lang.reflect.Constructor.constructNative(Native Method)
 at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
 at android.view.LayoutInflater.createView(LayoutInflater.java:595)
 at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:697)
 at android.view.LayoutInflater.rInflate(LayoutInflater.java:756)
 at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
 at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
 at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
 at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
 at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
 at com.example.sabith.doortracker.view.admin.WorkPolylineActivity.onCreate(WorkPolylineActivity.java:71)
 at android.app.Activity.performCreate(Activity.java:5231)
 at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
 at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
 at android.app.ActivityThread.access$800(ActivityThread.java:135)
 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
 at android.os.Handler.dispatchMessage(Handler.java:102)
 at android.os.Looper.loop(Looper.java:136)
 at android.app.ActivityThread.main(ActivityThread.java:5017)
 at java.lang.reflect.Method.invokeNative(Native Method)
 at java.lang.reflect.Method.invoke(Method.java:515)
 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
 at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.VerifyError: com/mapbox/mapboxsdk/maps/widgets/MyLocationView
 at java.lang.reflect.Constructor.constructNative(Native Method)
 at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
 at android.view.LayoutInflater.createView(LayoutInflater.java:595)
 at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:697)
 at android.view.LayoutInflater.rInflate(LayoutInflater.java:756)
 at android.view.LayoutInflater.inflate(LayoutInflater.java:462)
 at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
 at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
 at com.mapbox.mapboxsdk.maps.MapView.initialise(MapView.java:125)
 at com.mapbox.mapboxsdk.maps.MapView.<init>(MapView.java:102)
</code>```

build.gradle :

```<code>implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:5.2.0@aar'
//Mapbox webkit Library
compile('com.mapbox.mapboxsdk:mapbox-android-sdk:4.2.1@aar') {
    transitive = true
}
</code>```

layout.xml:

```<code> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        xmlns:mapbox="http://schemas.android.com/apk/res-auto">
        <com.mapbox.mapboxsdk.maps.MapView
            android:id="@+id/mapViewPolyline"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            mapbox:mapbox_styleUrl="@string/mapbox_style_mapbox_streets"
            mapbox:mapbox_cameraZoomMin="6"
            mapbox:mapbox_uiRotateGestures="false"/>
 </RelativeLayout>
</code>```

But, application run smoothly on API greater than 19.

Please suggest a solution.

答:
OP issue was fixed via https://github.com/mapbox/mapbox-gl-native/pull/10579 and it'll be available in the upcoming release 5.2.1.

In the meantime, you could test this out with the 5.3.0-SNAPSHOT build which includes the fix.

To use snapshots, you'd need to add the snapshots repo in the root build.gradle file:

```<code>allprojects {
    repositories {
        jcenter()
        maven { url "http://oss.sonatype.org/content/repositories/snapshots/" }
    }
}
</code>```

In your app build.gradle you'd need to replace your current dependency with:

```<code>implementation(com.mapbox.mapboxsdk:mapbox-android-sdk:5.3.0-SNAPSHOT@aar) {
        transitive = true
}
</code>```

Hope that helps! Cheers!

Body:
Application throws a view.InflateException while opening MapBox, in API 19. This is the error:

12-06 11:59:22.057 2906-2906/com.example.sabith.doortracker E/UncaughtException: java.lang.RuntimeException: Unable to
start activity ComponentInfo{com.example.sabith.doortracker/com.example.sabith.doortracker.view.admin.WorkPolylineActivity}:
android.view.InflateException: Binary XML file line #0: Error inflating class com.mapbox.mapboxsdk.maps.MapView
 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
 at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
 at android.app.ActivityThread.access$800(ActivityThread.java:135)
 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
 at android.os.Handler.dispatchMessage(Handler.java:102)
 at android.os.Looper.loop(Looper.java:136)
 at android.app.ActivityThread.main(ActivityThread.java:5017)
 at java.lang.reflect.Method.invokeNative(Native Method)
 at java.lang.reflect.Method.invoke(Method.java:515)
 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
 at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #0: Error inflating class com.mapbox.mapboxsdk.maps.MapView
 at android.view.LayoutInflater.createView(LayoutInflater.java:621)
 at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:697)
 at android.view.LayoutInflater.rInflate(LayoutInflater.java:756)
 at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
 at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
 at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
 at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
 at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
 at com.example.sabith.doortracker.view.admin.WorkPolylineActivity.onCreate(WorkPolylineActivity.java:71)
 at android.app.Activity.performCreate(Activity.java:5231)
 at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
 at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
 at android.app.ActivityThread.access$800(ActivityThread.java:135)
 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
 at android.os.Handler.dispatchMessage(Handler.java:102)
 at android.os.Looper.loop(Looper.java:136)
 at android.app.ActivityThread.main(ActivityThread.java:5017)
 at java.lang.reflect.Method.invokeNative(Native Method)
 at java.lang.reflect.Method.invoke(Method.java:515)
 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
 at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException
 at java.lang.reflect.Constructor.constructNative(Native Method)
 at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
 at android.view.LayoutInflater.createView(LayoutInflater.java:595)
 at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:697)
 at android.view.LayoutInflater.rInflate(LayoutInflater.java:756)
 at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
 at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
 at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
 at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
 at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
 at com.example.sabith.doortracker.view.admin.WorkPolylineActivity.onCreate(WorkPolylineActivity.java:71)
 at android.app.Activity.performCreate(Activity.java:5231)
 at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
 at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
 at android.app.ActivityThread.access$800(ActivityThread.java:135)
 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
 at android.os.Handler.dispatchMessage(Handler.java:102)
 at android.os.Looper.loop(Looper.java:136)
 at android.app.ActivityThread.main(ActivityThread.java:5017)
 at java.lang.reflect.Method.invokeNative(Native Method)
 at java.lang.reflect.Method.invoke(Method.java:515)
 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
 at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.VerifyError: com/mapbox/mapboxsdk/maps/widgets/MyLocationView
 at java.lang.reflect.Constructor.constructNative(Native Method)
 at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
 at android.view.LayoutInflater.createView(LayoutInflater.java:595)
 at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:697)
 at android.view.LayoutInflater.rInflate(LayoutInflater.java:756)
 at android.view.LayoutInflater.inflate(LayoutInflater.java:462)
 at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
 at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
 at com.mapbox.mapboxsdk.maps.MapView.initialise(MapView.java:125)
 at com.mapbox.mapboxsdk.maps.MapView.<init>(MapView.java:102)

build.gradle :

implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:5.2.0@aar'
//Mapbox webkit Library
compile('com.mapbox.mapboxsdk:mapbox-android-sdk:4.2.1@aar') {
    transitive = true
}

layout.xml:

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        xmlns:mapbox="http://schemas.android.com/apk/res-auto">
        <com.mapbox.mapboxsdk.maps.MapView
            android:id="@+id/mapViewPolyline"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            mapbox:mapbox_styleUrl="@string/mapbox_style_mapbox_streets"
            mapbox:mapbox_cameraZoomMin="6"
            mapbox:mapbox_uiRotateGestures="false"/>
 </RelativeLayout>

But, application run smoothly on API greater than 19.

Please suggest a solution.

Body:
OP issue was fixed via https://github.com/mapbox/mapbox-gl-native/pull/10579 and it'll be available in the upcoming release 5.2.1.

In the meantime, you could test this out with the 5.3.0-SNAPSHOT build which includes the fix.

To use snapshots, you'd need to add the snapshots repo in the root build.gradle file:

allprojects {
    repositories {
        jcenter()
        maven { url "http://oss.sonatype.org/content/repositories/snapshots/" }
    }
}

In your app build.gradle you'd need to replace your current dependency with:

implementation(com.mapbox.mapboxsdk:mapbox-android-sdk:5.3.0-SNAPSHOT@aar) {
        transitive = true
}

Hope that helps! Cheers!


问:
Angular how to get the multiple checkbox values?
I m using a checkbox in Angular to select more than one element and I'm trying to get the value of that checkbox for submitting.

Instead I'm getting the value those values as an array of true-s.
That's what I've tried:

export class CreateSessionComponent implements OnInit {
  form : FormGroup ;

  constructor(private formBuilder: FormBuilder) {}

  ngOnInit() {
    this.form = this.formBuilder.group({
      userdata :  new FormArray([
        new FormControl('', Validators.required)
      ])
    })
  }
}
```
<p><code>userdata</code> is a dynamic array populated from a database.</p>
<pre class="lang-html prettyprint-override"><code><div formArrayName="useremail; let k = index">
  <div *ngFor="let data of userdata">
    <div>
      <input type="checkbox" name="useremail" formControlName ="{{k}}" [value]="data.email">{{data.email}}
    </div>
  </div>
</div>
</code>```

答:
I did this function at input for the load form auto select:

[checked]="this.selected? this.selected.type.includes(type) : false"

Full code:

```<code><label *ngFor="let type of this.entityType" class="checkbox-inline c-checkbox">
<input type="checkbox" [checked]="this.selected? this.selected.type.includes(type) : false" (change)="onChangeEntityType(type, $event.target.checked)"/>
<span class="fa fa-check"></span>{{type | translate}}</label>
</code>```

Where

this.selected

is my object and

this.selected.type.includes(type)

auto check if checkboxes will be checked.

ContentLicense: CC BY-SA 4.0

Body:
I m using a checkbox in Angular to select more than one element and I'm trying to get the value of that checkbox for submitting.

Instead I'm getting the value those values as an array of true-s.
That's what I've tried:

export class CreateSessionComponent implements OnInit {
  form : FormGroup ;

  constructor(private formBuilder: FormBuilder) {}

  ngOnInit() {
    this.form = this.formBuilder.group({
      userdata :  new FormArray([
        new FormControl('', Validators.required)
      ])
    })
  }
}

userdata is a dynamic array populated from a database.

      <input type="checkbox" name="useremail" formControlName ="{{k}}" [value]="data.email">{{data.email}}

Body:
I did this function at input for the load form auto select:

[checked]="this.selected? this.selected.type.includes(type) : false"

Full code:

<label *ngFor="let type of this.entityType" class="checkbox-inline c-checkbox">
<input type="checkbox" [checked]="this.selected? this.selected.type.includes(type) : false" (change)="onChangeEntityType(type, $event.target.checked)"/>
<span class="fa fa-check"></span>{{type | translate}}</label>

Where

this.selected

is my object and

this.selected.type.includes(type)

auto check if checkboxes will be checked.


问:
best practices in pulling data from paginated REST API, page size vs. number of calls?
I'm working on a project where I pull data from Github/Jira REST APIs where results are returned in pages. I'm new to the concept of pagination but I understand that it's better for the server side performance when the size of returned data is large.

my question is what's the reasonable page size if I want to make as less API calls as possible? and what's better for both client side and server side, to make more API calls or to pull more data per each call?

答:
I would suggest the following approach:

in case of  UI application you can request the amount of data that is enough to full the UI screen;

in case you want to make as less API calls as possible I can suggest following: three the biggest concerns of requesting big amount of data are response time, throughput and memory usage.
So if you have the requirement about supported requests per second and if you measure the required memory per request then you can calculate the maximum amount of data per one request. After that reduce that value to fit acceptable response time and throughput.


问:
Why Javascript innerHTML add quote automatically to my string?
I am trying to add some HTML code and text in a div. If I add just a text there isn't any problem. But if I add some text with HTML code, it automatically adds quotes to my text.

    <meta charset="utf-8" />
    <title></title>

<button onclick="test()">Test it</button>

```
</div>
</div>
</p>

<p>It looks like this </p>

<blockquote>
``` viewer1 content = text
 viever2 content ="text" Bold Text
```

I don't want the quotes. How can it be removed?

Take a look at the screenshot below:

答: The quotes will not shown in web page. it's just for chrome console node.</p>

Body:
I am trying to add some HTML code and text in a div. If I add just a text there isn't any problem. But if I add some text with HTML code, it automatically adds quotes to my text.

    <meta charset="utf-8" />
    <title></title>

<button onclick="test()">Test it</button>

It looks like this

 viewer1 content = text
 viever2 content ="text" Bold Text

I don't want the quotes. How can it be removed?

Take a look at the screenshot below:


问:
web site development best practices, design or code by first?
I'm using an MVC framework to develop a web site, I've to care about the design in the sense of look and feel (views) and the code (models, controllers).

I don't know what is the best way to proceed:

code and design iteratively by small chunks?

design first ?

you've got the point

答:
From my experience I would say you should always plan first.  (I even plan my planning phase).

I assume you’re doing something like a GUI wired up via .aspx using the MVC model, maybe even the Entity Framework?

Web development like this can very easily get complicated once you start to build it up.

It is important that before you do anything you know exactly what it is that you are trying to do, this way you know when you are undershooting or overshooting your goals and whether or not the code you are writing actually fulfils the requirements.

There are many models which you can base your project development on, all of which loosely follow a sensible System Development Life Cycle in one way or another.

If you haven’t read up on the different development methodologies, here’s a site that will give you a good overview : http://www.itinfo.am/eng/software-development-methodologies/


问:
The `]` and `}` are not metacharacters in Regex whereas ')' is
In Regular Expressions Quick Start, it states

Twelve characters have special meanings in regular expressions: the backslash \, the caret ^, the dollar sign $, the period or dot ., the vertical bar or pipe symbol |, the question mark ?, the asterisk or star *, the plus sign +, the opening parenthesis (, the closing parenthesis ), the opening square bracket [, and the opening curly brace {. These special characters are often called "metacharacters". Most of them are errors when used alone.

In its specification, (), [,{ are metacharacters whereas 'closing sqare bracket' and 'closing curly brace' are not.

Obviously,'[' and '{' unable to take an effect individually just like opening parenthesis ( should partners ')'.

What's the reason that causes ']' and } failing to be selected?

答:
There isn't a good reason why unmatched ] and } should be literals and ) shouldn't.

The reason ] and } are often (but not always) interpreted as literals when they don't come in pairs, and ) isn't, is probably a combination of "historical" and "because parentheses nest". (And as a consequence of both, as Casimir et Hippolyte pointed out, because parentheses are used to mean a bunch of things related to grouping, lookarounds, etc.)

In academia, regexes are simplified down to | (alternation), concatenation and * (Kleene-star), and parentheses are the first convenience syntax. If you were to make a recursive descent parser recognize [ as entering a state where the syntax is slightly different, and ] means leaving that state again, then recognizing ] outside of that state as being an error would not be a direct side-effect of recognizing [. So if the bug doesn't blow up, it's a feature!

Parentheses are unlike this: Since the regex parser must keep track of which level they're nested, recognizing unmatched )s in its primary state is a required part of such a parser, and giving an error rather than producing a literal ) is something the writer of such a parser is more inclined to do.

Notice that ( and ) can often come unescaped and unmatched inside character groups.


问:
PHP: white space between function name and parenthesis
I'm wondering if this is legal:

```<code><?php

is_null
(
    $var
);
</code>```

Or perhaps this:

```<code><?php
$items = array
(
    "Details" => array('controller' => 'event', 'action' => 'readall', 'tab' => 'details'),
    "Calendar" => array('controller' => 'event', 'action' => 'readall', 'tab' => 'calendar')
);
</code>```

Or will some interpreters choke?

I know the popular mixed style of classes and functions have the opening curly brace on a new line and control structures, such as "if", on the same line. However, I like all one or the other. Newline or no newline. It would be nice to extend the concept to function calls and their parenthesis as well. This is the reason for my question.

答: That is very legal. And there aren't many interpreters after all. :) I put parentheses on the next line too if I got a large amount of parameters or a large array declaration.</p>

Body:
I'm wondering if this is legal:

<?php

is_null
(
    $var
);

Or perhaps this:

<?php
$items = array
(
    "Details" => array('controller' => 'event', 'action' => 'readall', 'tab' => 'details'),
    "Calendar" => array('controller' => 'event', 'action' => 'readall', 'tab' => 'calendar')
);

Or will some interpreters choke?

I know the popular mixed style of classes and functions have the opening curly brace on a new line and control structures, such as "if", on the same line. However, I like all one or the other. Newline or no newline. It would be nice to extend the concept to function calls and their parenthesis as well. This is the reason for my question.


问:
Hide a specific product in Woocommerce product widget
In WooCommerce, I am trying hide a specific product in the Woocommerce product widget.

I found a solution to exclude it via category:

```<code>function exclude_widget_categories($args){
    $exclude = "11,10,8,7,9"; // IDs of excluded product categories
    $args["exclude"] = $exclude;
    return $args;
}
add_filter("widget_categories_args","exclude_widget_categories");
</code>```

But thats not what I want. I need it for a specific product with the id 2386.

How to hide a specific product in woocommerce product widget?

答:
You can use widget_post_args filter.</p>

```<code>add_filter('widget_posts_args', function(){
$params['post__not_in'] = array(2386);
   return $params;
});
</code>```

Body:
In WooCommerce, I am trying hide a specific product in the Woocommerce product widget.

I found a solution to exclude it via category:

function exclude_widget_categories($args){
    $exclude = "11,10,8,7,9"; // IDs of excluded product categories
    $args["exclude"] = $exclude;
    return $args;
}
add_filter("widget_categories_args","exclude_widget_categories");

But thats not what I want. I need it for a specific product with the id 2386.

How to hide a specific product in woocommerce product widget?

Body:
You can use widget_post_args filter.

add_filter('widget_posts_args', function(){
$params['post__not_in'] = array(2386);
   return $params;
});


问:
Count specific length of letter of the volume of words

I try to find in a text sentence words of more than 4 letters

I tried this:

```<code>fullsetence <- as.character(c("A test setence with test length","A second test for length"))
nchar(fullsetence)
</code>```

I expect to take as results, based for example in the previous example sentence/string one has 2 words with length greater than 4 letters and the second has 2 words.

Using nchar I take the full length of characters from the string.

What is the right way to make it?

答:
```<code>library(dplyr)
library(purrr)

# vector of sentences
fullsetence <- as.character(c("A test setence with test length","A second test for length"))

# get vector of counts for words with more than 4 letters
fullsetence %>%
  strsplit(" ") %>%
  map(~sum(nchar(.) > 4)) %>%
  unlist()

# [1] 2 2

# create a dataframe with sentence and the corresponding counts
# use previous code as a function within "mutate"
data.frame(fullsetence, stringsAsFactors = F) %>%
  mutate(Counts = fullsetence %>%
                   strsplit(" ") %>%
                   map(~sum(nchar(.) > 4)) %>%
                   unlist() )

#                       fullsetence Counts
# 1 A test setence with test length      2
# 2        A second test for length      2
</code>```

If you want to get the actual words with more than 4 letters you can use this in a similar way:

```<code>fullsetence %>%
  strsplit(" ") %>%
  map(~ .[nchar(.) > 4])

data.frame(fullsetence, stringsAsFactors = F) %>%
  mutate(Words = fullsetence %>%
                 strsplit(" ") %>%
                 map(~ .[nchar(.) > 4]))
</code>```

Body:
I try to find in a text sentence words of more than 4 letters

I tried this:

fullsetence <- as.character(c("A test setence with test length","A second test for length"))
nchar(fullsetence)

I expect to take as results, based for example in the previous example sentence/string one has 2 words with length greater than 4 letters and the second has 2 words.

Using nchar I take the full length of characters from the string.

What is the right way to make it?

Body:
library(dplyr)
library(purrr)

# vector of sentences
fullsetence <- as.character(c("A test setence with test length","A second test for length"))

# get vector of counts for words with more than 4 letters
fullsetence %>%
  strsplit(" ") %>%
  map(~sum(nchar(.) > 4)) %>%
  unlist()

# [1] 2 2

# create a dataframe with sentence and the corresponding counts
# use previous code as a function within "mutate"
data.frame(fullsetence, stringsAsFactors = F) %>%
  mutate(Counts = fullsetence %>%
                   strsplit(" ") %>%
                   map(~sum(nchar(.) > 4)) %>%
                   unlist() )

#                       fullsetence Counts
# 1 A test setence with test length      2
# 2        A second test for length      2

If you want to get the actual words with more than 4 letters you can use this in a similar way:

fullsetence %>%
  strsplit(" ") %>%
  map(~ .[nchar(.) > 4])

data.frame(fullsetence, stringsAsFactors = F) %>%
  mutate(Words = fullsetence %>%
                 strsplit(" ") %>%
                 map(~ .[nchar(.) > 4]))


问:
Realtime database on AWS

Hello, I'm using Google Firebase Real-time Database.

It was so good. On nodejs, react, react-native and etc,

it was nice to be able to handle changes in database values as event.

But I wish to develop with Amazon AWS
because I want to know why so many people love AWS and decisively, our company has been supported for 2 years to use AWS.

I wannna implement Realtime database on AWS but I couldn't find information on realtime database on AWS Console.

Question

For Realtime Database with AWS, I think I have to use several features(maybe lambda, dynamoDB). Is it right?

On React, NodeJS or etc, can I handle change on database's value?
(like google firebase cloud function, realtime database)

答:
Let me answer your questions inline.

For Realtime Database with AWS, I think I have to use several features(maybe lambda, dynamoDB). Is it right?

You can use the newly introduced feature AWS AppSync with different storage optionsthis (e.g DynamoDB or RDS Aurora) where it creates a GraphQL schema and query option making a layer on top of AWS databses for realtime communication with clients. However its still under preview so you need to request it from AWS filling the form.

The other approach is to use AWS APIGateway, Lambda, DynamoDB or Aurora with AWS IOT Websockets.

On React, NodeJS or etc, can I handle change on database's value? (like google firebase cloud function, realtime database)

Yes both DynamoDB and Aurora provides triggers for change sets to invoke Lambda code.

Title: Realtime database on AWS


问:
implementing operator * in C++
```<code>class Rational {

 const Rational operator*(const Rational& rhs) const

  ...
};

 Rational oneHalf(1,2);

 Rational result = oneHalf * 2;   // fine (with non-explicit ctor)
 result          = 2 * oneHalf;  // error! (even with non-explicit ctor)
</code>```

It was mentioned by scott meyers in Effective C++ book as below

Even when Rationl's constructor is not explicit, one compiles and one doesnot. Reason is given as below:

It turns out that parameters are eligible for implicit conversion "only if they are listed in the parameter list".

The implicit parameter corresponding to object on which member function is invoked -- the one  "this" points to -- is
 never eligible  for implicit conversions.  That's way first call compiles and the second one doesnot.

My question is what does author mean in above statment "only if they are listed in the parameter list" ? What is parameter list?

答:
My question is what does author mean
  in above statment "only if they are
  listed in the parameter list" ? What
  is parameter list?

What he meant is that the parameter list in your constructor(s):

```<code>class Rational
{
  public:
     Rational (int a);  // <-- here 'a'
     Rational (double b); //<-- here 'b'
};
</code>```

If you've these two constructors in your class, then you can write

```<code>Rational result1 = oneHalf * 2; //2 is int, so it converts into Rational(2)
Rational result2 = oneHalf * 2.9; //2.9 is double, so it converts into Rational(2.9)
</code>```

Title: implementing operator * in C++

Body:
class Rational {

 const Rational operator*(const Rational& rhs) const

  ...
};

 Rational oneHalf(1,2);

 Rational result = oneHalf * 2;   // fine (with non-explicit ctor)
 result          = 2 * oneHalf;  // error! (even with non-explicit ctor)

It was mentioned by scott meyers in Effective C++ book as below

Even when Rationl's constructor is not explicit, one compiles and one doesnot. Reason is given as below:

It turns out that parameters are eligible for implicit conversion "only if they are listed in the parameter list".

The implicit parameter corresponding to object on which member function is invoked -- the one  "this" points to -- is
 never eligible  for implicit conversions.  That's way first call compiles and the second one doesnot.

My question is what does author mean in above statment "only if they are listed in the parameter list" ? What is parameter list?

Body:
My question is what does author mean
  in above statment "only if they are
  listed in the parameter list" ? What
  is parameter list?

What he meant is that the parameter list in your constructor(s):

class Rational
{
  public:
     Rational (int a);  // <-- here 'a'
     Rational (double b); //<-- here 'b'
};

If you've these two constructors in your class, then you can write

Rational result1 = oneHalf * 2; //2 is int, so it converts into Rational(2)
Rational result2 = oneHalf * 2.9; //2.9 is double, so it converts into Rational(2.9)