问:
Passing params from alsa application to kernel driver
I try to follow the path of parameters setting from linux user space (arecord/aplay) down to kernel driver. Let's take arecords --period-size as an example.

It all starts in set_params function in aplay.c:

```<code>if (period_time > 0)
    err = snd_pcm_hw_params_set_period_time_near(handle, params, &period_time, 0);
else
    err = snd_pcm_hw_params_set_period_size_near(handle, params, &period_frames, 0);
</code>```

The function snd_pcm_hw_params_set_period_size_near() is defined in [pcm.c : 5186](alsa-lib https://github.com/alsa-project/alsa-lib/blob/master/src/pcm/pcm.c#L5186), and here my headache starts... This function starts a chain of calls to other functions which doesn't make much sense to me and doesn't seem to be leading to any end call of driver.

There is _end label so I skipped all calls like snd_pcm_hw_param_set_min() or snd_pcm_hw_param_set_max() and went to snd_pcm_hw_param_set_last() hoping for some driver invocation like:

```<code>drv->hw_params_set(...);
</code>```

but instead I found an end call to:

```<code>MASK_INLINE unsigned int snd_mask_min(const snd_mask_t *mask)
{
    int i;
    assert(!snd_mask_empty(mask));
    for (i = 0; i < MASK_SIZE; i++) {
        if (mask->bits[i])
            return ffs(mask->bits[i]) - 1 + (i << 5);
    }
    return 0;
}
</code>```

where return values shall be the parameter set.

So to summarize, I found alsa-lib to be very difficult to read and understand. Maybe I am lacking some knowledge though. My question is simple, how is user space parameter passed to kernel driver. Can you provide a software path showing interfaces called?

Thanks.

答:
The hw_params structure contains a configuration space, which is a description of all possible configurations that the device can support. Numeric parameters are described as intervals (i.e., min and max), access and format as bitmasks.

When you change one parameter, the library calls the kernel driver (SNDRV_PCM_IOCTL_HW_REFINE) to adjust all the other parameters in the hw_params structure that depend on the changed parameter.

After you have reduced the configuration space to the configuration you actually want, you call snd_pcm_hw_params() (→ SNDRV_PCM_IOCTL_HW_PARAMS) to actually configure the device for those parameters. (If some parameter has not been reduced to a single value, snd_pcm_hw_params() will choose a random one.)

snd_pcm_hw_params_set_xxx_near() is more complex because there is no SET_NEAR ioctl. This function tries to adjust the interval so that either its maximum or its minimum is the desired value, and then check whether the actual maximum or minimum is nearer.

For example, assume a device that supports period sizes of 1024, 2048, 4096, and 8192 frames. Initially, the interval is described as [1024, 8192]. When you call snd_pcm_hw_params_set_period_size_near(4000), the snd_pcm_hw_param_set_near() helper function calls set_min(4000) and set_max(4000) (on separate copies of the hw_params structure), so the intervals are [1024, 4000] and [4000, 8192]; after refining, the driver returns the intervals [1024, 2048] and [4096, 8192]. snd_pcm_hw_param_set_near() then sees that 4096 is nearest to the desired calue, so it then calls set_first on the second interval, which results in [4096, 4096].

Body:
I try to follow the path of parameters setting from linux user space (arecord/aplay) down to kernel driver. Let's take arecords --period-size as an example.

It all starts in set_params function in aplay.c:

if (period_time > 0)
    err = snd_pcm_hw_params_set_period_time_near(handle, params, &period_time, 0);
else
    err = snd_pcm_hw_params_set_period_size_near(handle, params, &period_frames, 0);

The function snd_pcm_hw_params_set_period_size_near() is defined in [pcm.c : 5186](alsa-lib https://github.com/alsa-project/alsa-lib/blob/master/src/pcm/pcm.c#L5186), and here my headache starts... This function starts a chain of calls to other functions which doesn't make much sense to me and doesn't seem to be leading to any end call of driver.

There is _end label so I skipped all calls like snd_pcm_hw_param_set_min() or snd_pcm_hw_param_set_max() and went to snd_pcm_hw_param_set_last() hoping for some driver invocation like:

drv->hw_params_set(...);

but instead I found an end call to:

MASK_INLINE unsigned int snd_mask_min(const snd_mask_t *mask)
{
    int i;
    assert(!snd_mask_empty(mask));
    for (i = 0; i < MASK_SIZE; i++) {
        if (mask->bits[i])
            return ffs(mask->bits[i]) - 1 + (i << 5);
    }
    return 0;
}

where return values shall be the parameter set.

So to summarize, I found alsa-lib to be very difficult to read and understand. Maybe I am lacking some knowledge though. My question is simple, how is user space parameter passed to kernel driver. Can you provide a software path showing interfaces called?

Thanks.


来源: stackexchange

问:
How to Append Arrray List Data Into Text File
Below is the code.

I want to add the Array List Data into Text File.At this time it Inserts the data but when i add new data it overwrites the previous data and just add new one so i want that it will ask that you want that the data already exists you want to overwrite or append if data do not exist it simply append to the file.

```<code>using (TextWriter writer = File.CreateText(@"C:\Users\Precision\Desktop\testing\data.txt"))
{
    foreach (var obj in dirList)
    {
        writer.WriteLine(obj);
    }
}

Console.WriteLine("Record Saved Successfully...");
</code>```

答:
call this function from foreach i.e. foreach (var obj in dirList){this.WriteToFile(obj.ToString());}

public void WriteToFile(string text)
        {

```<code>        string path = path\fileName.txt";
        using (StreamWriter writer = new StreamWriter(path, true))
        {
            writer.WriteLine(text);
            writer.Close();
        }
    }
</code>```

ContentLicense: CC BY-SA 4.0

Body:
Below is the code.

I want to add the Array List Data into Text File.At this time it Inserts the data but when i add new data it overwrites the previous data and just add new one so i want that it will ask that you want that the data already exists you want to overwrite or append if data do not exist it simply append to the file.

using (TextWriter writer = File.CreateText(@"C:\Users\Precision\Desktop\testing\data.txt"))
{
    foreach (var obj in dirList)
    {
        writer.WriteLine(obj);
    }
}

Console.WriteLine("Record Saved Successfully...");

Body:
call this function from foreach i.e. foreach (var obj in dirList){this.WriteToFile(obj.ToString());}

public void WriteToFile(string text)
        {

        string path = path\fileName.txt";
        using (StreamWriter writer = new StreamWriter(path, true))
        {
            writer.WriteLine(text);
            writer.Close();
        }
    }


问:
Split method and split on the ‘.’ character (without the csv extension)
Modify the constructor so that the name field is set to the filename
without the .csv extension. Hint: use the split method and split on
the ‘.’ character.

I used
filename.split('.');

```<code>public DataSet(String filename, color dataSetColor){

    name = filename;
    _dataSetColor = dataSetColor;
    _markList = new ArrayList<StudentMarks>();

    linesArray = loadStrings(filename);

    for(String l : linesArray){

        //Split the current line storing the values in csvArray
        csvArray = split(l, ',');
        if(csvArray.length == 3){
            String id = csvArray[0];
            int internalM = Integer.parseInt(csvArray[1]);
            int ExamM = Integer.parseInt(csvArray[2]);

            _markList.add(new StudentMarks(id,internalM,ExamM,_dataSetColor));
        } else {

            println("The length of the csvArray is not equal to 3");
        }
    }
}
</code>```

when I ran this, I want the result shows "dataSet", not the "dataSet.csv"

答: You can split a string by '.' using filename.split("\\.")

Body:
Modify the constructor so that the name field is set to the filename
without the .csv extension. Hint: use the split method and split on
the ‘.’ character.

I used
filename.split('.');

public DataSet(String filename, color dataSetColor){

    name = filename;
    _dataSetColor = dataSetColor;
    _markList = new ArrayList<StudentMarks>();

    linesArray = loadStrings(filename);

    for(String l : linesArray){

        //Split the current line storing the values in csvArray
        csvArray = split(l, ',');
        if(csvArray.length == 3){
            String id = csvArray[0];
            int internalM = Integer.parseInt(csvArray[1]);
            int ExamM = Integer.parseInt(csvArray[2]);

            _markList.add(new StudentMarks(id,internalM,ExamM,_dataSetColor));
        } else {

            println("The length of the csvArray is not equal to 3");
        }
    }
}

when I ran this, I want the result shows "dataSet", not the "dataSet.csv"


问:
How to emulate GPS location in the Android Emulator?
I want to get longitude and latitude in Android emulator for testing.

Can any one guide me how to achieve this?

How do I set the location of the emulator to a test position?

答:
Using the "geo" command in the emulator console

To send mock location data from the command line:

Launch your application in the Android emulator and open a terminal/console in your SDK's /tools directory.

Connect to the emulator console:

telnet localhost 5555 (Replace 5555 with whatever port your emulator is running on)

Send the location data:
      * geo fix to send a fixed geo-location.

This command accepts a longitude and latitude in decimal degrees, and an optional altitude in meters. For example:

```<code>geo fix -121.45356 46.51119 4392
</code>```

ContentLicense: CC BY-SA 3.0

Body:
Using the "geo" command in the emulator console

To send mock location data from the command line:

Launch your application in the Android emulator and open a terminal/console in your SDK's /tools directory.

Connect to the emulator console:

telnet localhost 5555 (Replace 5555 with whatever port your emulator is running on)

Send the location data:
      * geo fix to send a fixed geo-location.

This command accepts a longitude and latitude in decimal degrees, and an optional altitude in meters. For example:

geo fix -121.45356 46.51119 4392


问:
I have an SVG map with markers displayed randomly. I can I place them accurately to tell the actual location on the SVG map?
With the random markers I have on my SVG map, I want to place them accurately within the SVG map which is the actual location map.

const SVG_NS = 'http://www.w3.org/2000/svg';
// the number of random points on the map
let circlesLength = 30;
// the bounding box of the path
let bb = thePath.getBBox();
//set the svg viewBox attribute
svg.setAttributeNS(null,"viewBox",`${bb.x} ${bb.y} ${bb.width} ${bb.height}`)

// svg client rect
let cr = svg.getBoundingClientRect();

let n = 0;//a counter

for(let i = 0; i < 100; i++){
  // get a random point on the svg canvas
  let x = randomIntFromInterval(cr.x,(cr.x+cr.width));
  let y = randomIntFromInterval(cr.y,(cr.y+cr.height));

  //elementFromPoint returns the topmost Element at the specified coordinates (relative to the viewport).
  let elmt = document.elementFromPoint(x, y);
  // if the point is in path
  if(elmt.className.baseVal == "path"){
    //get the coordinates of the point on the svg
    let svgPoint = getPoint(x,y);
    //draw a circle with the center on the svg point
    drawCircle({cx:svgPoint.x,cy:svgPoint.y,r:.01}, svg)

    //incerase the counter
    n++

  };
  // if you have already 6 points break the loop
  if(n == circlesLength){break;}
}

// a function to get a random integer from an interval
function randomIntFromInterval(mn, mx) {
  return ~~(Math.random() * (mx - mn + 1) + mn);
}

// a function to get the svg coordinates of a point on the svg canvas
function getPoint(x,y){
      var p = svg.createSVGPoint();
      p.x = x;
      p.y = y;
      var ctm = svg.getScreenCTM().inverse();
      var p =  p.matrixTransform(ctm);
      return p;
}

// a function to draw a circle
function drawCircle(o, parent) {
  var circle = document.createElementNS(SVG_NS, 'circle');
  for (var name in o) {
    if (o.hasOwnProperty(name)) {
      circle.setAttributeNS(null, name, o[name]);
    }
  }
  parent.appendChild(circle);
  return circle;
}```
<pre class="snippet-code-css lang-css prettyprint-override"><code>svg{border:1px solid;overflow:visible;}
path{stroke:black;vector-effect:non-scaling-stroke;fill:gold;}
circle{fill:red;}</code>```

<svg height=200 width=200 fill="none" viewBox='.6 1.1 1 1'>
<defs>
   <symbol id="marker" viewBox="1.4 1.7 16 16">
   <g transform="translate(0.0625 0.0475)">
     <circle r="2" cx="8" cy="8" stroke="black" stroke-width="0.001" fill="red"/>
     </g>
   </symbol>
  </defs>

  <use id="theUse" xlink:href="#marker" width=".15" height=".15" x="1.05" y="1.55" />

 <path d='M 1.08583,1.84181 l 0.02003,0.00322 0.003917,-0.008192 0.001098,-0.00409 0.001925,-0.003735 0.003098,-0.007964 0.001112,-0.002924 0.000531,-0.003501 0.001664,-0.004677 0.001465,-0.004257 0.004778,-0.001624 0.004599,0.000546 0.003444,-2.8e-05 0.003444,-2.8e-05 0.003444,-2.8e-05 0.002289,-0.000602 0.005166,-4.2e-05 0.003443,-2.9e-05 0.001701,-0.001762 0.001105,-0.003507 -0.001184,-0.002905 -0.001198,-0.00407 -0.002346,-0.004061 -0.002339,-0.003479 -0.001633,-0.00216 -0.00245,-0.003053 -0.001757,-0.0029 -0.003488,-0.003469 -0.004053,-0.002881 -0.004047,-0.002299 -0.004628,-0.002877 -0.00231,-0.001147 -0.004054,-0.002881 -0.002891,-0.001726 -0.002885,-0.001142 -0.003465,-0.00172 -0.004039,-0.001716 -0.003466,-0.001721 -0.002318,-0.00173 -0.002331,-0.002895 -0.001766,-0.003483 0.000546,-0.002336 -0.000624,-0.004076 0.000538,-0.002918 -5.7e-05,-0.004663 0.001055,-0.007587 -0.000646,-0.005824 0.000516,-0.004667 0.000532,-0.003502 0.002216,-0.00643 0.006286,-0.002384 0.009184,-7.4e-05 0.00518,0.001123 0.005173,0.000541 0.004613,0.001711 0.004585,-0.00062 0.006881,-0.000639 0.005159,-0.000625 0.004003,-0.001199 0.003423,-0.001776 0.004011,-0.000616 0.00226,-0.002933 0.001105,-0.003507 0.001679,-0.003511 0.003968,-0.004113 0.002863,-0.000606 0.003487,0.003469 3.5e-05,0.002915 0.00061,0.002909 0.002892,0.001725 0.003465,0.001721 0.007512,0.004019 0.008079,0.003431 0.009844,0.006915 0.002339,0.003478 0.002346,0.004062 0.001929,0.004325 0.001601,0.002641 0.00635,0.002862 0.004613,0.001712 0.006903,0.001109 0.00805,0.0011 0.002877,0.00056 0.003451,0.000554 0.004606,0.001129 0.00404,0.001716 0.002325,0.002312 0.00175,0.002318 0.001184,0.002905 0.001765,0.003482 0.001758,0.002901 0.007505,0.003436 0.006888,-5.6e-05 0.004011,-0.000616 0.003429,-0.001194 0.059804,-0.085011 0.004557,-0.002951 0.005122,-0.003539 0.007391,-0.00589 0.002841,-0.002355 0.044101,0.019307 0.00433,-0.002215 0.001097,-0.004089
 0.004492,-0.008197 -0.00374,-0.003618 -0.005432,-0.002823 -0.001808,-0.001864 -0.003619,-0.002806 -0.004524,-0.002814 -0.007249,-0.001916 -0.003618,-0.002806 -0.003619,-0.002805 -0.004531,-0.000967 -0.002718,-0.00095 -0.003624,-0.000958 -0.003618,-0.002805 -0.002714,-0.001873 -0.00452,-0.004663 -0.000895,-0.003703 -0.003607,-0.006501 -0.003609,-0.005576 -0.004526,-0.002815 -0.00542,-0.006518 -0.006327,-0.006526 -0.001804,-0.002789 -0.001808,-0.001864 -0.003613,-0.004653 -0.004528,-0.001891 -0.003633,0.001814 -0.003636,0.002736 -0.005455,0.004568 -0.00454,0.001804 -0.002729,0.002746 -0.005459,0.005491 -0.004548,0.004576 -0.006363,0.004558 -0.009088,0.006381 -0.004531,-0.000967 -0.005441,-5.1e-05 -0.004537,0.000881 -0.00454,0.001804 -0.005437,-0.000975 -0.002712,-0.002797 -0.001793,-0.006484 2.1e-05,-0.006466 0.000927,-0.006458 0.002743,-0.007364 0.000949,-0.012924 -0.00175,-0.02034 -0.00086,-0.014789 -0.000862,-0.013865 -0.001767,-0.014797 -0.003539,-0.027747 -0.001779,-0.011103 -0.003601,-0.008348 -0.002702,-0.005568 -0.004523,-0.003738 -0.004513,-0.006509 -0.007219,-0.011154 -0.008105,-0.017629 -0.003604,-0.007424 -0.007223,-0.01023 -0.007218,-0.011154 -0.012646,-0.015824 -0.014491,-0.00568 -0.004171,-3.9e-05 -0.004022,0.010123 -0.001832,0.005526 -0.002746,0.008287 -0.002741,0.006441 -0.001828,0.004602 -0.000925,0.005534 -0.000918,0.003686 -0.000925,0.005534 -0.002741,0.006441 -0.005458,0.005491 -0.003645,0.005508 -0.003639,0.00366 -0.00545,0.00272 -0.005446,0.001796 -0.006353,0.001788 -0.007258,0.000855 -0.009989,0.004524 -0.009083,0.004533 -0.004543,0.002729 -0.003648,0.006431 -0.003644,0.005509 -0.004555,0.006423 -0.003644,0.005509 -0.002733,0.003668 -0.001825,0.003679 -0.005464,0.007338 -0.004543,0.002728 -0.004543,0.002729 -0.00272,-2.6e-05 -0.008155,-0.001925 -0.00906,-0.002857 -0.005431,-0.002823 -0.007261,0.001779 -0.009068,-8.6e-05 -0.002712,-0.002797
 -0.002702,-0.005568 -0.006336,-0.003755 -0.002729,0.002745 -0.004537,0.000881 -0.002712,-0.002797 -0.005431,-0.002823 -0.005438,-0.000975 -0.004537,0.000881 -0.007276,0.006397 -0.003644,0.005508 -0.004551,0.0055 -0.004547,0.003652 -0.00501,0.001292 -0.013143,0.004079 -0.00817,0.002694 -0.009083,0.004533 -0.006359,0.003635 -0.005455,0.004567 -0.005456,0.004568 -0.005261,0.004939 0.002906,0.002891 0.001772,0.004066 0.00292,0.004056 0.004642,0.004043 0.002328,0.003456 0.000621,0.002932 -0.000538,0.002919 -0.001119,0.00234 -0.001701,0.001763 -0.001679,0.003512 -0.001679,0.003511 -0.001119,0.002341 -0.000538,0.002919 0.001176,0.002321 0.001184,0.002905 -0.000545,0.002337 -0.000481,0.007582 0.001765,0.003483 0.004032,0.001132 0.004032,0.001133 0.005748,0.000536 0.004032,0.001133 0.003458,0.001138 0.0046,0.000545 0.005238,0.001713 0.004548,0.000539 0.002699,-0.000692 0.007066,0.001196 0.004025,0.000549 0.002877,0.00056 0.003451,0.000555 0.003452,0.000554 0.00231,0.001148 0.005819,0.006364 3.6e-05,0.002914 0.000609,0.00291 -0.000545,0.002336 -0.005704,0.002961 -0.002849,0.001772 -0.002246,0.004099 -0.001111,0.002924 3.5e-05,0.002914 5.1e-05,0.00408 0.002346,0.004061 0.001183,0.002905 0.001177,0.002322 -0.001119,0.002341 -0.002849,0.001772 -0.001657,0.00526 0.00061,0.002909 -0.004535,0.004701 -0.001119,0.00234 -0.000524,0.004085 0.002927,0.00464 0.001191,0.003487 0.001192,0.003488 0.000609,0.00291 0.001184,0.002905 0.00175,0.002317 0.002325,0.002313 0.001744,0.001734 0.003465,0.001721 0.002311,0.001147 3.5e-05,0.002914 4.3e-05,0.003497 -0.000545,0.002337 -0.002224,0.005846 -0.005719,0.001796 -0.003429,0.001194 -0.004004,0.001199 -0.005166,4.1e-05 -0.00287,2.4e-05 -0.005589,0.012287 -0.001105,0.003506 -0.001679,0.003512 -0.001672,0.004094 -0.005123,0.003539 0.000681,0.008738 0.002356,0.005182 0.001799,0.00586 5.7e-05,0.004662 0.001191,0.003489 0.005726,-0.001213 0.002855,-0.001189 0.00231,0.001147 0.002318,0.001729 0.001758,0.002901 0.001779,0.004648 0.002332,0.002896 0.002346,0.004061 0.003444,-2.8e-05 0.003444,-2.8e-05 0.004585,-0.00062 0.002289,-0.000602 0.005144,-0.001791 0.007477,0.001105 0.0021,0.000987 0.00887,0.00417 0.004082,0.005213 0.00409,0.005796 0.002331,0.002895 -0.000545,0.002336 0.00178,0.00465 0.000631,0.004657 0.001184,0.002906 0.002339,0.003478 0.004068,0.004047 0.002906,0.002891 0.004621,0.002294 0.002905,0.002891 0.005116,0.002664 0.050227,0.008073 z'></path>
</svg>```

Body:
With the random markers I have on my SVG map, I want to place them accurately within the SVG map which is the actual location map.

const SVG_NS = 'http://www.w3.org/2000/svg';
// the number of random points on the map
let circlesLength = 30;
// the bounding box of the path
let bb = thePath.getBBox();
//set the svg viewBox attribute
svg.setAttributeNS(null,"viewBox",`${bb.x} ${bb.y} ${bb.width} ${bb.height}`)

// svg client rect
let cr = svg.getBoundingClientRect();

let n = 0;//a counter

for(let i = 0; i < 100; i++){
  // get a random point on the svg canvas
  let x = randomIntFromInterval(cr.x,(cr.x+cr.width));
  let y = randomIntFromInterval(cr.y,(cr.y+cr.height));

  //elementFromPoint returns the topmost Element at the specified coordinates (relative to the viewport).
  let elmt = document.elementFromPoint(x, y);
  // if the point is in path
  if(elmt.className.baseVal == "path"){
    //get the coordinates of the point on the svg
    let svgPoint = getPoint(x,y);
    //draw a circle with the center on the svg point
    drawCircle({cx:svgPoint.x,cy:svgPoint.y,r:.01}, svg)

    //incerase the counter
    n++

  };
  // if you have already 6 points break the loop
  if(n == circlesLength){break;}
}

// a function to get a random integer from an interval
function randomIntFromInterval(mn, mx) {
  return ~~(Math.random() * (mx - mn + 1) + mn);
}

// a function to get the svg coordinates of a point on the svg canvas
function getPoint(x,y){
      var p = svg.createSVGPoint();
      p.x = x;
      p.y = y;
      var ctm = svg.getScreenCTM().inverse();
      var p =  p.matrixTransform(ctm);
      return p;
}

// a function to draw a circle
function drawCircle(o, parent) {
  var circle = document.createElementNS(SVG_NS, 'circle');
  for (var name in o) {
    if (o.hasOwnProperty(name)) {
      circle.setAttributeNS(null, name, o[name]);
    }
  }
  parent.appendChild(circle);
  return circle;
}

svg{border:1px solid;overflow:visible;}
path{stroke:black;vector-effect:non-scaling-stroke;fill:gold;}
circle{fill:red;}

<svg height=200 width=200 fill="none" viewBox='.6 1.1 1 1'>
<defs>
   <symbol id="marker" viewBox="1.4 1.7 16 16">
   <g transform="translate(0.0625 0.0475)">
     <circle r="2" cx="8" cy="8" stroke="black" stroke-width="0.001" fill="red"/>
     </g>
   </symbol>
  </defs>

  <use id="theUse" xlink:href="#marker" width=".15" height=".15" x="1.05" y="1.55" />

 <path d='M 1.08583,1.84181 l 0.02003,0.00322 0.003917,-0.008192 0.001098,-0.00409 0.001925,-0.003735 0.003098,-0.007964 0.001112,-0.002924 0.000531,-0.003501 0.001664,-0.004677 0.001465,-0.004257 0.004778,-0.001624 0.004599,0.000546 0.003444,-2.8e-05 0.003444,-2.8e-05 0.003444,-2.8e-05 0.002289,-0.000602 0.005166,-4.2e-05 0.003443,-2.9e-05 0.001701,-0.001762 0.001105,-0.003507 -0.001184,-0.002905 -0.001198,-0.00407 -0.002346,-0.004061 -0.002339,-0.003479 -0.001633,-0.00216 -0.00245,-0.003053 -0.001757,-0.0029 -0.003488,-0.003469 -0.004053,-0.002881 -0.004047,-0.002299 -0.004628,-0.002877 -0.00231,-0.001147 -0.004054,-0.002881 -0.002891,-0.001726 -0.002885,-0.001142 -0.003465,-0.00172 -0.004039,-0.001716 -0.003466,-0.001721 -0.002318,-0.00173 -0.002331,-0.002895 -0.001766,-0.003483 0.000546,-0.002336 -0.000624,-0.004076 0.000538,-0.002918 -5.7e-05,-0.004663 0.001055,-0.007587 -0.000646,-0.005824 0.000516,-0.004667 0.000532,-0.003502 0.002216,-0.00643 0.006286,-0.002384 0.009184,-7.4e-05 0.00518,0.001123 0.005173,0.000541 0.004613,0.001711 0.004585,-0.00062 0.006881,-0.000639 0.005159,-0.000625 0.004003,-0.001199 0.003423,-0.001776 0.004011,-0.000616 0.00226,-0.002933 0.001105,-0.003507 0.001679,-0.003511 0.003968,-0.004113 0.002863,-0.000606 0.003487,0.003469 3.5e-05,0.002915 0.00061,0.002909 0.002892,0.001725 0.003465,0.001721 0.007512,0.004019 0.008079,0.003431 0.009844,0.006915 0.002339,0.003478 0.002346,0.004062 0.001929,0.004325 0.001601,0.002641 0.00635,0.002862 0.004613,0.001712 0.006903,0.001109 0.00805,0.0011 0.002877,0.00056 0.003451,0.000554 0.004606,0.001129 0.00404,0.001716 0.002325,0.002312 0.00175,0.002318 0.001184,0.002905 0.001765,0.003482 0.001758,0.002901 0.007505,0.003436 0.006888,-5.6e-05 0.004011,-0.000616 0.003429,-0.001194 0.059804,-0.085011 0.004557,-0.002951 0.005122,-0.003539 0.007391,-0.00589 0.002841,-0.002355 0.044101,0.019307 0.00433,-0.002215 0.001097,-0.004089
 0.004492,-0.008197 -0.00374,-0.003618 -0.005432,-0.002823 -0.001808,-0.001864 -0.003619,-0.002806 -0.004524,-0.002814 -0.007249,-0.001916 -0.003618,-0.002806 -0.003619,-0.002805 -0.004531,-0.000967 -0.002718,-0.00095 -0.003624,-0.000958 -0.003618,-0.002805 -0.002714,-0.001873 -0.00452,-0.004663 -0.000895,-0.003703 -0.003607,-0.006501 -0.003609,-0.005576 -0.004526,-0.002815 -0.00542,-0.006518 -0.006327,-0.006526 -0.001804,-0.002789 -0.001808,-0.001864 -0.003613,-0.004653 -0.004528,-0.001891 -0.003633,0.001814 -0.003636,0.002736 -0.005455,0.004568 -0.00454,0.001804 -0.002729,0.002746 -0.005459,0.005491 -0.004548,0.004576 -0.006363,0.004558 -0.009088,0.006381 -0.004531,-0.000967 -0.005441,-5.1e-05 -0.004537,0.000881 -0.00454,0.001804 -0.005437,-0.000975 -0.002712,-0.002797 -0.001793,-0.006484 2.1e-05,-0.006466 0.000927,-0.006458 0.002743,-0.007364 0.000949,-0.012924 -0.00175,-0.02034 -0.00086,-0.014789 -0.000862,-0.013865 -0.001767,-0.014797 -0.003539,-0.027747 -0.001779,-0.011103 -0.003601,-0.008348 -0.002702,-0.005568 -0.004523,-0.003738 -0.004513,-0.006509 -0.007219,-0.011154 -0.008105,-0.017629 -0.003604,-0.007424 -0.007223,-0.01023 -0.007218,-0.011154 -0.012646,-0.015824 -0.014491,-0.00568 -0.004171,-3.9e-05 -0.004022,0.010123 -0.001832,0.005526 -0.002746,0.008287 -0.002741,0.006441 -0.001828,0.004602 -0.000925,0.005534 -0.000918,0.003686 -0.000925,0.005534 -0.002741,0.006441 -0.005458,0.005491 -0.003645,0.005508 -0.003639,0.00366 -0.00545,0.00272 -0.005446,0.001796 -0.006353,0.001788 -0.007258,0.000855 -0.009989,0.004524 -0.009083,0.004533 -0.004543,0.002729 -0.003648,0.006431 -0.003644,0.005509 -0.004555,0.006423 -0.003644,0.005509 -0.002733,0.003668 -0.001825,0.003679 -0.005464,0.007338 -0.004543,0.002728 -0.004543,0.002729 -0.00272,-2.6e-05 -0.008155,-0.001925 -0.00906,-0.002857 -0.005431,-0.002823 -0.007261,0.001779 -0.009068,-8.6e-05 -0.002712,-0.002797
 -0.002702,-0.005568 -0.006336,-0.003755 -0.002729,0.002745 -0.004537,0.000881 -0.002712,-0.002797 -0.005431,-0.002823 -0.005438,-0.000975 -0.004537,0.000881 -0.007276,0.006397 -0.003644,0.005508 -0.004551,0.0055 -0.004547,0.003652 -0.00501,0.001292 -0.013143,0.004079 -0.00817,0.002694 -0.009083,0.004533 -0.006359,0.003635 -0.005455,0.004567 -0.005456,0.004568 -0.005261,0.004939 0.002906,0.002891 0.001772,0.004066 0.00292,0.004056 0.004642,0.004043 0.002328,0.003456 0.000621,0.002932 -0.000538,0.002919 -0.001119,0.00234 -0.001701,0.001763 -0.001679,0.003512 -0.001679,0.003511 -0.001119,0.002341 -0.000538,0.002919 0.001176,0.002321 0.001184,0.002905 -0.000545,0.002337 -0.000481,0.007582 0.001765,0.003483 0.004032,0.001132 0.004032,0.001133 0.005748,0.000536 0.004032,0.001133 0.003458,0.001138 0.0046,0.000545 0.005238,0.001713 0.004548,0.000539 0.002699,-0.000692 0.007066,0.001196 0.004025,0.000549 0.002877,0.00056 0.003451,0.000555 0.003452,0.000554 0.00231,0.001148 0.005819,0.006364 3.6e-05,0.002914 0.000609,0.00291 -0.000545,0.002336 -0.005704,0.002961 -0.002849,0.001772 -0.002246,0.004099 -0.001111,0.002924 3.5e-05,0.002914 5.1e-05,0.00408 0.002346,0.004061 0.001183,0.002905 0.001177,0.002322 -0.001119,0.002341 -0.002849,0.001772 -0.001657,0.00526 0.00061,0.002909 -0.004535,0.004701 -0.001119,0.00234 -0.000524,0.004085 0.002927,0.00464 0.001191,0.003487 0.001192,0.003488 0.000609,0.00291 0.001184,0.002905 0.00175,0.002317 0.002325,0.002313 0.001744,0.001734 0.003465,0.001721 0.002311,0.001147 3.5e-05,0.002914 4.3e-05,0.003497 -0.000545,0.002337 -0.002224,0.005846 -0.005719,0.001796 -0.003429,0.001194 -0.004004,0.001199 -0.005166,4.1e-05 -0.00287,2.4e-05 -0.005589,0.012287 -0.001105,0.003506 -0.001679,0.003512 -0.001672,0.004094 -0.005123,0.003539 0.000681,0.008738 0.002356,0.005182 0.001799,0.00586 5.7e-05,0.004662 0.001191,0.003489 0.005726,-0.001213 0.002855,-0.001189 0.00231,0.001147 0.002318,0.001729 0.001758,0.002901 0.001779,0.004648 0.002332,0.002896 0.002346,0.004061 0.003444,-2.8e-05 0.003444,-2.8e-05 0.004585,-0.00062 0.002289,-0.000602 0.005144,-0.001791 0.007477,0.001105 0.0021,0.000987 0.00887,0.00417 0.004082,0.005213 0.00409,0.005796 0.002331,0.002895 -0.000545,0.002336 0.00178,0.00465 0.000631,0.004657 0.001184,0.002906 0.002339,0.003478 0.004068,0.004047 0.002906,0.002891 0.004621,0.002294 0.002905,0.002891 0.005116,0.002664 0.050227,0.008073 z'></path>
</svg>

Body:
If you need points placed accurately, this means you know where your points are on the map and you will need to save those points in an array of points, for example this:

let circlesArray = [
      {cx:1.11,cy:1.64,r:.01},
      {cx:1.23,cy:1.53,r:.01},
      {cx:1.03,cy:1.77,r:.01},
      {cx:1.18,cy:1.57,r:.01},
      {cx:0.99,cy:1.77,r:.01},
      {cx:1.25,cy:1.67,r:.01},
    ]

Once you have the array of points, for each one you draw the point on the map.

const SVG_NS = 'http://www.w3.org/2000/svg';
// the number of random points on the map
let circlesArray = [
  {cx:1.11,cy:1.64,r:.01},
  {cx:1.23,cy:1.53,r:.01},
  {cx:1.03,cy:1.77,r:.01},
  {cx:1.18,cy:1.57,r:.01},
  {cx:0.99,cy:1.77,r:.01},
  {cx:1.25,cy:1.67,r:.01},
]

circlesArray.forEach(c=>{
  drawCircle(c, svg)
})

// a function to draw a circle
function drawCircle(o, parent) {
  var circle = document.createElementNS(SVG_NS, 'circle');
  for (var name in o) {
    if (o.hasOwnProperty(name)) {
      circle.setAttributeNS(null, name, o[name]);
    }
  }
  parent.appendChild(circle);
  return circle;
}

svg{border:1px solid;overflow:visible;}
path{stroke:black;vector-effect:non-scaling-stroke;fill:gold;}
circle{fill:red;}

<svg id="svg" height=200 width=200 fill="none" viewBox='.6 1.1 1 1'>
 <path class="path" id="thePath" d='M 1.08583,1.84181 l 0.02003,0.00322 0.003917,-0.008192 0.001098,-0.00409 0.001925,-0.003735 0.003098,-0.007964 0.001112,-0.002924 0.000531,-0.003501 0.001664,-0.004677 0.001465,-0.004257 0.004778,-0.001624 0.004599,0.000546 0.003444,-2.8e-05 0.003444,-2.8e-05 0.003444,-2.8e-05 0.002289,-0.000602 0.005166,-4.2e-05 0.003443,-2.9e-05 0.001701,-0.001762 0.001105,-0.003507 -0.001184,-0.002905 -0.001198,-0.00407 -0.002346,-0.004061 -0.002339,-0.003479 -0.001633,-0.00216 -0.00245,-0.003053 -0.001757,-0.0029 -0.003488,-0.003469 -0.004053,-0.002881 -0.004047,-0.002299 -0.004628,-0.002877 -0.00231,-0.001147 -0.004054,-0.002881 -0.002891,-0.001726 -0.002885,-0.001142 -0.003465,-0.00172 -0.004039,-0.001716 -0.003466,-0.001721 -0.002318,-0.00173 -0.002331,-0.002895 -0.001766,-0.003483 0.000546,-0.002336 -0.000624,-0.004076 0.000538,-0.002918 -5.7e-05,-0.004663 0.001055,-0.007587 -0.000646,-0.005824 0.000516,-0.004667 0.000532,-0.003502 0.002216,-0.00643 0.006286,-0.002384 0.009184,-7.4e-05 0.00518,0.001123 0.005173,0.000541 0.004613,0.001711 0.004585,-0.00062 0.006881,-0.000639 0.005159,-0.000625 0.004003,-0.001199 0.003423,-0.001776 0.004011,-0.000616 0.00226,-0.002933 0.001105,-0.003507 0.001679,-0.003511 0.003968,-0.004113 0.002863,-0.000606 0.003487,0.003469 3.5e-05,0.002915 0.00061,0.002909 0.002892,0.001725 0.003465,0.001721 0.007512,0.004019 0.008079,0.003431 0.009844,0.006915 0.002339,0.003478 0.002346,0.004062 0.001929,0.004325 0.001601,0.002641 0.00635,0.002862 0.004613,0.001712 0.006903,0.001109 0.00805,0.0011 0.002877,0.00056 0.003451,0.000554 0.004606,0.001129 0.00404,0.001716 0.002325,0.002312 0.00175,0.002318 0.001184,0.002905 0.001765,0.003482 0.001758,0.002901 0.007505,0.003436 0.006888,-5.6e-05 0.004011,-0.000616 0.003429,-0.001194 0.059804,-0.085011 0.004557,-0.002951 0.005122,-0.003539 0.007391,-0.00589 0.002841,-0.002355 0.044101,0.019307 0.00433,-0.002215 0.001097,-0.004089 0.004492,-0.008197 -0.00374,-0.003618 -0.005432,-0.002823 -0.001808,-0.001864 -0.003619,-0.002806 -0.004524,-0.002814 -0.007249,-0.001916 -0.003618,-0.002806 -0.003619,-0.002805 -0.004531,-0.000967 -0.002718,-0.00095 -0.003624,-0.000958 -0.003618,-0.002805 -0.002714,-0.001873 -0.00452,-0.004663 -0.000895,-0.003703 -0.003607,-0.006501 -0.003609,-0.005576 -0.004526,-0.002815 -0.00542,-0.006518 -0.006327,-0.006526 -0.001804,-0.002789 -0.001808,-0.001864 -0.003613,-0.004653 -0.004528,-0.001891 -0.003633,0.001814 -0.003636,0.002736 -0.005455,0.004568 -0.00454,0.001804 -0.002729,0.002746 -0.005459,0.005491 -0.004548,0.004576 -0.006363,0.004558 -0.009088,0.006381 -0.004531,-0.000967 -0.005441,-5.1e-05 -0.004537,0.000881 -0.00454,0.001804 -0.005437,-0.000975 -0.002712,-0.002797 -0.001793,-0.006484 2.1e-05,-0.006466 0.000927,-0.006458 0.002743,-0.007364 0.000949,-0.012924 -0.00175,-0.02034 -0.00086,-0.014789 -0.000862,-0.013865 -0.001767,-0.014797 -0.003539,-0.027747 -0.001779,-0.011103 -0.003601,-0.008348 -0.002702,-0.005568 -0.004523,-0.003738 -0.004513,-0.006509 -0.007219,-0.011154 -0.008105,-0.017629 -0.003604,-0.007424 -0.007223,-0.01023 -0.007218,-0.011154 -0.012646,-0.015824 -0.014491,-0.00568 -0.004171,-3.9e-05 -0.004022,0.010123 -0.001832,0.005526 -0.002746,0.008287 -0.002741,0.006441 -0.001828,0.004602 -0.000925,0.005534 -0.000918,0.003686 -0.000925,0.005534 -0.002741,0.006441 -0.005458,0.005491 -0.003645,0.005508 -0.003639,0.00366 -0.00545,0.00272 -0.005446,0.001796 -0.006353,0.001788 -0.007258,0.000855 -0.009989,0.004524 -0.009083,0.004533 -0.004543,0.002729 -0.003648,0.006431 -0.003644,0.005509 -0.004555,0.006423 -0.003644,0.005509 -0.002733,0.003668 -0.001825,0.003679 -0.005464,0.007338 -0.004543,0.002728 -0.004543,0.002729 -0.00272,-2.6e-05 -0.008155,-0.001925 -0.00906,-0.002857 -0.005431,-0.002823 -0.007261,0.001779 -0.009068,-8.6e-05 -0.002712,-0.002797 -0.002702,-0.005568 -0.006336,-0.003755 -0.002729,0.002745 -0.004537,0.000881 -0.002712,-0.002797 -0.005431,-0.002823 -0.005438,-0.000975 -0.004537,0.000881 -0.007276,0.006397 -0.003644,0.005508 -0.004551,0.0055 -0.004547,0.003652 -0.00501,0.001292 -0.013143,0.004079 -0.00817,0.002694 -0.009083,0.004533 -0.006359,0.003635 -0.005455,0.004567 -0.005456,0.004568 -0.005261,0.004939 0.002906,0.002891 0.001772,0.004066 0.00292,0.004056 0.004642,0.004043 0.002328,0.003456 0.000621,0.002932 -0.000538,0.002919 -0.001119,0.00234 -0.001701,0.001763 -0.001679,0.003512 -0.001679,0.003511 -0.001119,0.002341 -0.000538,0.002919 0.001176,0.002321 0.001184,0.002905 -0.000545,0.002337 -0.000481,0.007582 0.001765,0.003483 0.004032,0.001132 0.004032,0.001133 0.005748,0.000536 0.004032,0.001133 0.003458,0.001138 0.0046,0.000545 0.005238,0.001713 0.004548,0.000539 0.002699,-0.000692 0.007066,0.001196 0.004025,0.000549 0.002877,0.00056 0.003451,0.000555 0.003452,0.000554 0.00231,0.001148 0.005819,0.006364 3.6e-05,0.002914 0.000609,0.00291 -0.000545,0.002336 -0.005704,0.002961 -0.002849,0.001772 -0.002246,0.004099 -0.001111,0.002924 3.5e-05,0.002914 5.1e-05,0.00408 0.002346,0.004061 0.001183,0.002905 0.001177,0.002322 -0.001119,0.002341 -0.002849,0.001772 -0.001657,0.00526 0.00061,0.002909 -0.004535,0.004701 -0.001119,0.00234 -0.000524,0.004085 0.002927,0.00464 0.001191,0.003487 0.001192,0.003488 0.000609,0.00291 0.001184,0.002905 0.00175,0.002317 0.002325,0.002313 0.001744,0.001734 0.003465,0.001721 0.002311,0.001147 3.5e-05,0.002914 4.3e-05,0.003497 -0.000545,0.002337 -0.002224,0.005846 -0.005719,0.001796 -0.003429,0.001194 -0.004004,0.001199 -0.005166,4.1e-05 -0.00287,2.4e-05 -0.005589,0.012287 -0.001105,0.003506 -0.001679,0.003512 -0.001672,0.004094 -0.005123,0.003539 0.000681,0.008738 0.002356,0.005182 0.001799,0.00586 5.7e-05,0.004662 0.001191,0.003489 0.005726,-0.001213 0.002855,-0.001189 0.00231,0.001147 0.002318,0.001729 0.001758,0.002901 0.001779,0.004648 0.002332,0.002896 0.002346,0.004061 0.003444,-2.8e-05 0.003444,-2.8e-05 0.004585,-0.00062 0.002289,-0.000602 0.005144,-0.001791 0.007477,0.001105 0.0021,0.000987 0.00887,0.00417 0.004082,0.005213 0.00409,0.005796 0.002331,0.002895 -0.000545,0.002336 0.00178,0.00465 0.000631,0.004657 0.001184,0.002906 0.002339,0.003478 0.004068,0.004047 0.002906,0.002891 0.004621,0.002294 0.002905,0.002891 0.005116,0.002664 0.050227,0.008073 z'></path>

</svg>


问:
doing xml replace operations in logic apps
How do we replace strings within an XML payload in logic apps?

input

```<code><root>
  <alexIsAwesome>yes he is</alexIsAwesome>
  <bytes>sdfsdfjijOIJOISJDFQPWORPJkjsdlfkjlksdf==</bytes>
  <bytes>SFSDFsdfsdgfjgjkfjsdlfkjlksdf==</bytes>
</root>
</code>```

desired result

```<code><root>
  <alexIsAwesome>yes he is</alexIsAwesome>
  <bytes>replacetext1</bytes>
  <bytes>replacetext2</bytes>
</root>
</code>```

How do we iterate through XML and replace text within nodes? Please keep in mind that the input  node might be 100mb in size!

答: You could use an Integration account with the Transform XML action, by pointing to a defined Map, either XSLT or Liquid type. logic apps enterprise integration maps</p>

Body:
How do we replace strings within an XML payload in logic apps?

input

<root>
  <alexIsAwesome>yes he is</alexIsAwesome>
  <bytes>sdfsdfjijOIJOISJDFQPWORPJkjsdlfkjlksdf==</bytes>
  <bytes>SFSDFsdfsdgfjgjkfjsdlfkjlksdf==</bytes>
</root>

desired result

<root>
  <alexIsAwesome>yes he is</alexIsAwesome>
  <bytes>replacetext1</bytes>
  <bytes>replacetext2</bytes>
</root>

How do we iterate through XML and replace text within nodes? Please keep in mind that the input  node might be 100mb in size!


问:
Grid design went wrong
So, my page is not what I wanted, although I followed instruction (which most of the time are not clear). I tried to find what went work but nothing...., I verified my code with the validator again nothing, everything looks ok. I even tried different browsers. Can some help me?

Also, I had to do this: Go to the Grid Spacing Styles section. Create a style rule to apply the Border Box model to the div elements belonging to the following classes: container, row, classes that begin with the column, cell, and elements nested within div elements belonging to the cell class. But unfortunately, I'm lost, any help here as well would be awesome!

This is how the page should look like I know that the image is kinda small but I couldn't upload a picture bigger than 2MB

```<code>    <!DOCTYPE html>
    <html>
    <head>
       <!--
       New Perspectives on HTML5 and CSS3, 7th Edition
       Tutorial 3
       Case Problem 2

       Costume Expressions Front Page
       Author: Martin Evtimov
       Date: 02-08-2018

       Filename: ce_front.html
       -->
       <meta charset="utf-8" />
       <title>Costume Expressions</title>
       <link href="ce_styles.css" rel="stylesheet" />
       <link href="ce_grids.css" rel="stylesheet" />
    </head>

    <body>
       <header>
          <nav>
             <ul>
                <li><a href="#">Enter Site</a></li>
                <li><a href="#">My Account</a></li>
                <li><a href="#">Track Orders</a></li>
                <li><a href="#">Contact Info</a></li>
             </ul>
          </nav>
       </header>
       <div id="container">
          <div class="row">
             <div class="column80">
                <div class="row">
                   <div class="column100 cell" id="logo">
                      <a href="#"><img src="ce_logo.png" alt="Costume Expressions" /></a>
                   </div>
                </div>
                <div class="row">
                   <div class="column50 cell">
                      <a href="#"><img src="ce_image04.png" alt="Birthday Party Costumes" /></a>
                   </div>
                   <div class="column25 cell">
                      <a href="#"><img src="ce_image05.png" alt="Makeup Sales"/></a>
                   </div>
                   <div class="column25 cell">
                      <a href="#"><img src="ce_image06.png" alt="Costume Specials"/></a>
                   </div>
                </div>
             </div>
             <div class="column20">
                <div class="row">
                   <div class="column100 cell">
                      <a href="#"><img src="ce_image01.png" alt="Find us on Facebook" /></a>
                   </div>
                </div>
                <div class="row">
                   <div class="column100 cell">
                      <a href="#"><img src="ce_image02.png" alt="Follow us on Twitter" /></a>
                   </div>
                </div>
                <div class="row">
                   <div class="column100 cell">
                      <a href="#"><img src="ce_image03.png" alt="Masks on Sale" /></a>
                   </div>
                </div>
                <div class="row">
                   <div class="column100 cell">
                      <a href="#"><img src="ce_image07.png" alt="Wig Specials" /></a>
                   </div>
                </div>
             </div>
          </div>
          <div class="row">
             <div class="column20">
                <div class="row">
                   <div class="column100 cell">
                      <a href="#"><img src="ce_image08.png" alt="Theater Costumes" /></a>
                   </div>
                </div>
                <div class="row">
                   <div class="column100 cell">
                      <a href="#"><img src="ce_image12.png" alt="Props for Sale" /></a>
                   </div>
                </div>
             </div>
             <div class="column80">
                <div class="row">
                   <div class="column50 cell">
                      <a href="#"><img src="ce_image09.png" alt="Sales on Super Hero Costumes" /></a>
                   </div>
                   <div class="column25 cell">
                      <a href="#"><img src="ce_image10.png" alt="Candy Sale" /></a>
                   </div>
                   <div class="column25 cell">
                      <a href="#"><img src="ce_image11.png" alt="Hats for Sale" /></a>
                   </div>
                </div>
                <div class="row">
                   <div class="column25 cell">
                      <a href="#"><img src="ce_image13.png" alt="Christmas Specials" /></a>
                   </div>
                   <div class="column75">
                      <div class="row">
                         <div class="column67 cell">
                            <a href="#"><img src="ce_image14.png" alt="Classic Costumes" /></a>
                         </div>
                         <div class="column33 cell">
                            <a href="#"><img src="ce_image15.png" alt="Shipping Fees" /></a>
                         </div>
                      </div>
                      <div class="row">
                         <div class="column33 cell">
                            <a href="#"><img src="ce_image16.png" alt="Halloween Costumes" /></a>
                         </div>
                         <div class="column33 cell">
                            <a href="#"><img src="ce_image17.png" alt="Halloween Costumes" /></a>
                         </div>
                         <div class="column33 cell">
                            <a href="#"><img src="ce_image18.png" alt="Halloween Costumes" /></a>
                         </div>
                      </div>
                   </div>
                </div>
             </div>
          </div>
          <div class="row">
             <div class="column20 cell">
                <a href="#"><img src="ce_image19.png" alt="Masks for Sale" /></a>
             </div>
             <div class="column40 cell">
                <a href="#"><img src="ce_image20.png" alt="Mardis Gras Specials" /></a>
             </div>
          </div>
       </div>
       <footer>
          Costume Expressions<br />
          3411 Torrence Dr.<br />
          Rockville, MD 20850
       </footer>
    </body>
    </html>

    @charset "utf-8";
    /*
       New Perspectives on HTML5 and CSS3, 7th Edition
       Tutorial 3
       Case Problem 2

       Style Sheet for Grids used in the Costume Expressions Front Page
       Author: Martin Evtimov
       Date: 02-08-2018

       Filename: ce_grids.css

    */

    /* Grid Rows Styles */
    div.row {
      position: relative;
      width: 100%;
      clear: both;
    }
    div.row {
      float: left;
    }

    /* Grid Columns Styles */
    div.column100 {
      width: 100%;
      float: left;
    }
    div.column50 {
      width: 50%;
      float: left;
    }
    div.column33 {
      width: 33.33%;
      float: left;
    }
    div.column67 {
      width: 66.67%;
      float: left;
    }
    div.column25 {
      width: 25%;
      float: left;
    }
    div.column75 {
      width: 75%;
      float: left;
    }
    div.column20 {
      width: 20%;
      float: left;
    }
    div.column40 {
      width: 40%;
      float: left;
    }
    div.column60 {
      width: 60%;
      float: left;
    }
    div.column80 {
      width: 80%;
      float: left;
    }
    /* Grid Spacing Styles */

@charset "utf-8";
/*
   New Perspectives on HTML5 and CSS3, 7th Edition
   Tutorial 3
   Case Problem 2

   Style Sheet for Costume Expressions Front Page
   Author: Martin Evtimov
   Date: 02-08-2018

   Filename: ce_styles.css
*/

/* Window and Body Styles */
html {
  background-color: rgb(101, 101, 101);
}
body {
  position: relative;
  background-color: white;
  font-family: Verdana, Geneva, Arial, sans-serif;
  margin-top: 20px;
  margin-bottom: 20px;
  margin-left: auto;
  margin-right: auto;
  width: 95%;
  min-width: 320px;
  max-width: 960px;
}
body img {
  display: block;
  width: 100%;
}
nav a {
  text-decoration: none;
}

/* Body Header Styles */
body>header {
  background-color: rgb(191, 168, 170);
  height: 40px;
}
body>header>nav un li {
  display: block;
  float: left;
  margin-right: 20px;
  padding-top: 10px;
  padding-bottom: 10px;
  padding-left: 0px;
  padding-right: 0px;
}
body>header>nav>ul>li {
  font-size: 0.9em;
  color: rgb(51, 51, 51);
}
nav a:link, nav a:visited {
  color: rgb(51, 51, 51);
}
nav a:hover, nav a:active {
 color: rgb(255, 211, 211);
}
/* DIV Container Styles */
div#container {
  padding-right: 8px;
  padding-bottom: 8px;
}
div[class^="cell"]>a {
  display: block;
  width: 100%;
  padding-left: 8px;
  padding-top: 8px;
}

/* Footer Styles */
footer {
  position: absolute;
  right: 8px;
  bottom: 8px;
  color: rgb(143, 33, 36);
  text-align: right;
  font-size: 2vmin;
}
</code>```

答:
This is how you insert it the border box model to the hw above. (I went through the exact same step)</p>

```<code>.container, .row, div.column, div.cell, div.a {
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
}
</code>```

Title: Grid design went wrong

Body:
So, my page is not what I wanted, although I followed instruction (which most of the time are not clear). I tried to find what went work but nothing...., I verified my code with the validator again nothing, everything looks ok. I even tried different browsers. Can some help me?

Also, I had to do this: Go to the Grid Spacing Styles section. Create a style rule to apply the Border Box model to the div elements belonging to the following classes: container, row, classes that begin with the column, cell, and elements nested within div elements belonging to the cell class. But unfortunately, I'm lost, any help here as well would be awesome!

This is how the page should look like I know that the image is kinda small but I couldn't upload a picture bigger than 2MB

    <!DOCTYPE html>

       <meta charset="utf-8" />
       <title>Costume Expressions</title>
       <link href="ce_styles.css" rel="stylesheet" />
       <link href="ce_grids.css" rel="stylesheet" />

Enter Site

My Account

Track Orders

Contact Info

          Costume Expressions

          3411 Torrence Dr.

          Rockville, MD 20850

    @charset "utf-8";
    /*
       New Perspectives on HTML5 and CSS3, 7th Edition
       Tutorial 3
       Case Problem 2

       Style Sheet for Grids used in the Costume Expressions Front Page
       Author: Martin Evtimov
       Date: 02-08-2018

       Filename: ce_grids.css

    */

    /* Grid Rows Styles */
    div.row {
      position: relative;
      width: 100%;
      clear: both;
    }
    div.row {
      float: left;
    }

    /* Grid Columns Styles */
    div.column100 {
      width: 100%;
      float: left;
    }
    div.column50 {
      width: 50%;
      float: left;
    }
    div.column33 {
      width: 33.33%;
      float: left;
    }
    div.column67 {
      width: 66.67%;
      float: left;
    }
    div.column25 {
      width: 25%;
      float: left;
    }
    div.column75 {
      width: 75%;
      float: left;
    }
    div.column20 {
      width: 20%;
      float: left;
    }
    div.column40 {
      width: 40%;
      float: left;
    }
    div.column60 {
      width: 60%;
      float: left;
    }
    div.column80 {
      width: 80%;
      float: left;
    }
    /* Grid Spacing Styles */

@charset "utf-8";
/*
   New Perspectives on HTML5 and CSS3, 7th Edition
   Tutorial 3
   Case Problem 2

   Style Sheet for Costume Expressions Front Page
   Author: Martin Evtimov
   Date: 02-08-2018

   Filename: ce_styles.css
*/

/* Window and Body Styles */
html {
  background-color: rgb(101, 101, 101);
}
body {
  position: relative;
  background-color: white;
  font-family: Verdana, Geneva, Arial, sans-serif;
  margin-top: 20px;
  margin-bottom: 20px;
  margin-left: auto;
  margin-right: auto;
  width: 95%;
  min-width: 320px;
  max-width: 960px;
}
body img {
  display: block;
  width: 100%;
}
nav a {
  text-decoration: none;
}

/* Body Header Styles */
body>header {
  background-color: rgb(191, 168, 170);
  height: 40px;
}
body>header>nav un li {
  display: block;
  float: left;
  margin-right: 20px;
  padding-top: 10px;
  padding-bottom: 10px;
  padding-left: 0px;
  padding-right: 0px;
}
body>header>nav>ul>li {
  font-size: 0.9em;
  color: rgb(51, 51, 51);
}
nav a:link, nav a:visited {
  color: rgb(51, 51, 51);
}
nav a:hover, nav a:active {
 color: rgb(255, 211, 211);
}
/* DIV Container Styles */
div#container {
  padding-right: 8px;
  padding-bottom: 8px;
}
div[class^="cell"]>a {
  display: block;
  width: 100%;
  padding-left: 8px;
  padding-top: 8px;
}

/* Footer Styles */
footer {
  position: absolute;
  right: 8px;
  bottom: 8px;
  color: rgb(143, 33, 36);
  text-align: right;
  font-size: 2vmin;
}

Body:
This is how you insert it the border box model to the hw above. (I went through the exact same step)

.container, .row, div.column, div.cell, div.a {
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
}


问:
SQL: parse the first, middle and last name from a fullname field
How do I parse the first, middle, and last name out of a fullname field with SQL?

I need to try to match up on names that are not a direct match on full name. I'd like to be able to take the full name field and break it up into first, middle and last name.

The data does not include any prefixes or suffixes. The middle name is optional. The data is formatted 'First Middle Last'.

I'm interested in some practical solutions to get me 90% of the way there.  As it has been stated, this is a complex problem, so I'll handle special cases individually.

答:
This query is working fine.</p>

```<code>SELECT name
    ,Ltrim(SubString(name, 1, Isnull(Nullif(CHARINDEX(' ', name), 0), 1000))) AS FirstName
    ,Ltrim(SUBSTRING(name, CharIndex(' ', name), CASE
                WHEN (CHARINDEX(' ', name, CHARINDEX(' ', name) + 1) - CHARINDEX(' ', name)) <= 0
                    THEN 0
                ELSE CHARINDEX(' ', name, CHARINDEX(' ', name) + 1) - CHARINDEX(' ', name)
                END)) AS MiddleName
    ,Ltrim(SUBSTRING(name, Isnull(Nullif(CHARINDEX(' ', name, Charindex(' ', name) + 1), 0), CHARINDEX(' ', name)), CASE
                WHEN Charindex(' ', name) = 0
                    THEN 0
                ELSE LEN(name)
                END)) AS LastName
FROM yourtableName
</code>```

OwnerDisplayName: TheOtherScott

LastEditorDisplayName: Andy Lester

Body:
This query is working fine.

SELECT name
    ,Ltrim(SubString(name, 1, Isnull(Nullif(CHARINDEX(' ', name), 0), 1000))) AS FirstName
    ,Ltrim(SUBSTRING(name, CharIndex(' ', name), CASE
                WHEN (CHARINDEX(' ', name, CHARINDEX(' ', name) + 1) - CHARINDEX(' ', name)) <= 0
                    THEN 0
                ELSE CHARINDEX(' ', name, CHARINDEX(' ', name) + 1) - CHARINDEX(' ', name)
                END)) AS MiddleName
    ,Ltrim(SUBSTRING(name, Isnull(Nullif(CHARINDEX(' ', name, Charindex(' ', name) + 1), 0), CHARINDEX(' ', name)), CASE
                WHEN Charindex(' ', name) = 0
                    THEN 0
                ELSE LEN(name)
                END)) AS LastName
FROM yourtableName


问:
Event-driven Travis build
I'm looking for an "event-driven" way to use travis, I need to notify him when something occurred but in the meanwhile the build should be in 'yellow' state, it may takes up to 2 hours.

Does anybody knows a way? or another CI supports that?

Thanks!

答:
You can trigger builds using travis API.

For example, to trigger a build for the most recent commit, you can send the following POST request:

```<code>body='{
"request": {
"branch":"master"
}}'

curl -s -X POST \
   -H "Content-Type: application/json" \
   -H "Accept: application/json" \
   -H "Travis-API-Version: 3" \
   -H "Authorization: token xxxxxx" \
   -d "$body" \
   https://api.travis-ci.com/repo/travis-ci%2Ftravis-core/requests
</code>```

Title: Event-driven Travis build

Body:
You can trigger builds using travis API.

For example, to trigger a build for the most recent commit, you can send the following POST request:

body='{
"request": {
"branch":"master"
}}'

curl -s -X POST \
   -H "Content-Type: application/json" \
   -H "Accept: application/json" \
   -H "Travis-API-Version: 3" \
   -H "Authorization: token xxxxxx" \
   -d "$body" \
   https://api.travis-ci.com/repo/travis-ci%2Ftravis-core/requests


问:
How to display a keyboard using Tone.js UI in Angular?
In an Angular 7 application I installed the Tone.js dependency:

```<code>npm install tone
npm install @tonejs/ui
</code>```

I can play notes and I would like to display a keyboard using the tone-keyboard element I saw at this fiddle

My synth.component.html file contains:

```<code><tone-demo autoplay>
  <tone-keyboard octaves="3"></tone-keyboard>
</tone-demo>
</code>```

My synth.component.ts file contains:

```<code>import { Component, OnInit } from '@angular/core';
import Tone from 'tone';
</code>```

But I get the following error:

```<code>Error: : 'tone-keyboard' is not a known element:
</code>```

Should I have some additional import statement in the synth.component.ts file ?

答:
```<code>var synth = new Tone.Synth().toMaster()

//play a 'C' for one 8th note
synth.triggerAttackRelease('C4', '8n')

var synth = new Tone.AMSynth().toMaster()

startNote = (event) => {
   synth.triggerAttack(event.target)
}

endNote = (event) => {
   synth.triggerRelease()
}

//Mouse click starts the note
<Button onMouseDown={this.startNote}/>

//Mouse click ends the note
<Button onMouseUp={this.endNote}/>

var jakeSynth = new Tone.Synth({
  oscillator : {
    type : 'fmsquare',
        modulationType : 'sawtooth',
        modulationIndex : 3,
        harmonicity: 3.4
  },
  envelope : {
    attack : 0.001,
        decay : 0.1,
        sustain: 0.1,
        release: 0.1
  }
}).toMaster()

jakeSynth.triggerAttackRelease('B2', '8n')

For more detail visit link:-
https://tonejs.github.io/
</code>```

Body:
In an Angular 7 application I installed the Tone.js dependency:

npm install tone
npm install @tonejs/ui

I can play notes and I would like to display a keyboard using the tone-keyboard element I saw at this fiddle

My synth.component.html file contains:

<tone-demo autoplay>
  <tone-keyboard octaves="3"></tone-keyboard>
</tone-demo>

My synth.component.ts file contains:

import { Component, OnInit } from '@angular/core';
import Tone from 'tone';

But I get the following error:

Error: : 'tone-keyboard' is not a known element:

Should I have some additional import statement in the synth.component.ts file ?


问:
Can I redistribute dao360.dll and acedao.dll?
In this and this, I know one can use direct DAO to manage Access database. Therefore, I just wonder if it is possible to redistribute acedao.dll and dao360.dll mentioned in the first and second article?

Thanks

答:
Yes.

Both dao360.dll and acedao.dll are included in the Microsoft Access Database Engine redistributable.

When writing this answer, the latest version is the 2016 version, downloadable here.


问:
Action Controller: Exception when refreshing page
I'm having a problem when refreshing the page to my custom controller action. Everytime I refresh the page after executing the action for the first time I get an ActiveRecord::RecordNotFound exception.

I wrote theses custom queries in actions in my controller, them I added the path to this actions in my routes.rb
This is the URL I'm accessing: http://localhost:3000/health_units/especialidades?specialty=ENFASE
It works fine when accessed from the index page, but if I try to refresh the page or even type it I get this error.

This is my controller:

class HealthUnitsController < ApplicationController
  before_action :set_health_unit, only: [:show, :edit, :update, :destroy]

  # GET /health_units
  # GET /health_units.json
  def index
    @health_units = HealthUnit.all
  end

  # GET /health_units/1
  # GET /health_units/1.json
  def show
  end

  # GET /health_units/new
  def new
    @health_unit = HealthUnit.new
  end

  # GET /health_units/1/edit
  def edit
  end

  # POST /health_units
  # POST /health_units.json
  def create
    @health_unit = HealthUnit.new(health_unit_params)

    respond_to do |format|
      if @health_unit.save
        format.html { redirect_to @health_unit, notice: 'Health unit was successfully created.' }
        format.json { render :show, status: :created, location: @health_unit }
      else
        format.html { render :new }
        format.json { render json: @health_unit.errors, status: :unprocessable_entity }
      end
    end
  end

  # PATCH/PUT /health_units/1
  # PATCH/PUT /health_units/1.json
  def update
    respond_to do |format|
      if @health_unit.update(health_unit_params)
        format.html { redirect_to @health_unit, notice: 'Health unit was successfully updated.' }
        format.json { render :show, status: :ok, location: @health_unit }
      else
        format.html { render :edit }
        format.json { render json: @health_unit.errors, status: :unprocessable_entity }
      end
    end
  end

  # DELETE /health_units/1
  # DELETE /health_units/1.json
  def destroy
    @health_unit.destroy
    respond_to do |format|
      format.html { redirect_to health_units_url, notice: 'Health unit was successfully destroyed.' }
      format.json { head :no_content }
    end
  end

  def basic_search
    if params[:keywords].empty?
      redirect_to health_units_path
    else
      @health_units = HealthUnit.where("specialties && :kw or
        treatments && :kw", kw: params[:keywords].split(' '))
      respond_to do |format|
        format.html { render template: "health_units/index.html.slim" }
        format.json { render template: "health_units/index.json.jbuilder"}
      end
    end
  end

  def list_by_specialties
    if params[:specialty].nil?
      redirect_to health_units_path
    else
      @specialty = params[:specialty]
      @health_units = HealthUnit.where("specialties && ARRAY[?]",
        @specialty)
      respond_to do |format|
        format.html { render template: "health_units/specialty.html.slim" }
        format.json { render template: "health_units/index.json.jbuilder"}
      end
    end
  end

  def list_by_treatments
    if params[:treatments].empty?
      redirect_to health_units_path
    else
      @health_unit = HealthUnit.where("treatments && ?",
        params[:treatments].split(' '))
      respond_to do |format|
        format.html { render template: "health_units/index.html.slim" }
        format.json { render template: "health_units/index.json.jbuilder"}
      end
    end
  end

  def search_by_neighborhood
    if params[:neighborhood].nil?
      redirect_to health_units_path
    else
      @health_units = HealthUnit.where(neighborhood: params[:neighborhood])
      respond_to do |format|
        format.html { render template: "health_units/index.html.slim" }
        format.json { render template: "health_units/index.json.jbuilder"}
      end
    end
  end

  def advanced_search
    @health_unit = HealthUnit.new
  end

  def advanced_search_results
  end

  private
    # Use callbacks to share common setup or constraints between actions.
    def set_health_unit
      @health_unit = HealthUnit.find(params[:id])
    end

    # Never trust parameters from the scary internet, only allow the white list through.
    def health_unit_params
      params.require(:health_unit).permit(:cnes, :name, :address, :neighborhood, :phone, :latitude, :longitude, :description)
    end

end

```

<p>This is my <code>routes.rb</code>:</p>

<pre class="lang-rb prettyprint-override"><code>  resources :health_units do
    collection do
      resources :comments, path: 'comentarios'
      post :basic_search, path: 'resultados'
      post :advanced_search, path: 'pesquisar'
      post :list_by_specialties, path: 'especialidades', as: :specialty
      post :list_by_treatments, path: 'atendimentos', as: :treatments
      post :search_by_neighborhood, path: 'bairro', as: :neighborhood
    end
</code>```

And this is the error I get in my console:

```<code>Started GET "/health_units/especialidades?specialty=ENFASE" for 127.0.0.1 at 2019-05-27 03:29:07 -0300
Processing by HealthUnitsController#show as HTML
  Parameters: {"specialty"=>"ENFASE", "id"=>"especialidades"}
  HealthUnit Load (0.5ms)  SELECT  "health_units".* FROM "health_units" WHERE "health_units"."id" = $1 LIMIT $2  [["id", 0], ["LIMIT", 1]]
  ↳ app/controllers/health_units_controller.rb:127
Completed 404 Not Found in 3ms (ActiveRecord: 0.5ms)

ActiveRecord::RecordNotFound (Couldn't find HealthUnit with 'id'=especialidades):

app/controllers/health_units_controller.rb:127:in `set_health_unit'
Started GET "/favicon.ico" for 127.0.0.1 at 2019-05-27 03:29:07 -0300

ActionController::RoutingError (No route matches [GET] "/favicon.ico"):

actionpack (5.2.3) lib/action_dispatch/middleware/debug_exceptions.rb:65:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
railties (5.2.3) lib/rails/rack/logger.rb:38:in `call_app'
railties (5.2.3) lib/rails/rack/logger.rb:26:in `block in call'
activesupport (5.2.3) lib/active_support/tagged_logging.rb:71:in `block in tagged'
activesupport (5.2.3) lib/active_support/tagged_logging.rb:28:in `tagged'
activesupport (5.2.3) lib/active_support/tagged_logging.rb:71:in `tagged'
railties (5.2.3) lib/rails/rack/logger.rb:26:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/request_id.rb:27:in `call'
rack (2.0.7) lib/rack/method_override.rb:22:in `call'
rack (2.0.7) lib/rack/runtime.rb:22:in `call'
activesupport (5.2.3) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/static.rb:127:in `call'
rack (2.0.7) lib/rack/sendfile.rb:111:in `call'
railties (5.2.3) lib/rails/engine.rb:524:in `call'
puma (3.12.1) lib/puma/configuration.rb:227:in `call'
puma (3.12.1) lib/puma/server.rb:660:in `handle_request'
puma (3.12.1) lib/puma/server.rb:474:in `process_client'
puma (3.12.1) lib/puma/server.rb:334:in `block in run'
puma (3.12.1) lib/puma/thread_pool.rb:135:in `block in spawn_thread'
</code>```

I would like to be able to refresh the page and get the same result as the first time I accessed it.

答:
This is because when you refresh the routes goes to show action assuming id as especialidades and it tries to look the HealthUnit with id="especialidades" and it does not find and raise error

so one way you can solve this is defining the constraints

```<code>class RandomConstraint
  def matches?(request)
    return false unless request.path_parameters[:id].present?
  end
end

get :list_by_specialties, path: 'especialidades', as: :specialty, constraints: RandomConstraint.new
</code>```

Body:
I'm having a problem when refreshing the page to my custom controller action. Everytime I refresh the page after executing the action for the first time I get an ActiveRecord::RecordNotFound exception.

I wrote theses custom queries in actions in my controller, them I added the path to this actions in my routes.rb
This is the URL I'm accessing: http://localhost:3000/health_units/especialidades?specialty=ENFASE
It works fine when accessed from the index page, but if I try to refresh the page or even type it I get this error.

This is my controller:

class HealthUnitsController < ApplicationController
  before_action :set_health_unit, only: [:show, :edit, :update, :destroy]

  # GET /health_units
  # GET /health_units.json
  def index
    @health_units = HealthUnit.all
  end

  # GET /health_units/1
  # GET /health_units/1.json
  def show
  end

  # GET /health_units/new
  def new
    @health_unit = HealthUnit.new
  end

  # GET /health_units/1/edit
  def edit
  end

  # POST /health_units
  # POST /health_units.json
  def create
    @health_unit = HealthUnit.new(health_unit_params)

    respond_to do |format|
      if @health_unit.save
        format.html { redirect_to @health_unit, notice: 'Health unit was successfully created.' }
        format.json { render :show, status: :created, location: @health_unit }
      else
        format.html { render :new }
        format.json { render json: @health_unit.errors, status: :unprocessable_entity }
      end
    end
  end

  # PATCH/PUT /health_units/1
  # PATCH/PUT /health_units/1.json
  def update
    respond_to do |format|
      if @health_unit.update(health_unit_params)
        format.html { redirect_to @health_unit, notice: 'Health unit was successfully updated.' }
        format.json { render :show, status: :ok, location: @health_unit }
      else
        format.html { render :edit }
        format.json { render json: @health_unit.errors, status: :unprocessable_entity }
      end
    end
  end

  # DELETE /health_units/1
  # DELETE /health_units/1.json
  def destroy
    @health_unit.destroy
    respond_to do |format|
      format.html { redirect_to health_units_url, notice: 'Health unit was successfully destroyed.' }
      format.json { head :no_content }
    end
  end

  def basic_search
    if params[:keywords].empty?
      redirect_to health_units_path
    else
      @health_units = HealthUnit.where("specialties && :kw or
        treatments && :kw", kw: params[:keywords].split(' '))
      respond_to do |format|
        format.html { render template: "health_units/index.html.slim" }
        format.json { render template: "health_units/index.json.jbuilder"}
      end
    end
  end

  def list_by_specialties
    if params[:specialty].nil?
      redirect_to health_units_path
    else
      @specialty = params[:specialty]
      @health_units = HealthUnit.where("specialties && ARRAY[?]",
        @specialty)
      respond_to do |format|
        format.html { render template: "health_units/specialty.html.slim" }
        format.json { render template: "health_units/index.json.jbuilder"}
      end
    end
  end

  def list_by_treatments
    if params[:treatments].empty?
      redirect_to health_units_path
    else
      @health_unit = HealthUnit.where("treatments && ?",
        params[:treatments].split(' '))
      respond_to do |format|
        format.html { render template: "health_units/index.html.slim" }
        format.json { render template: "health_units/index.json.jbuilder"}
      end
    end
  end

  def search_by_neighborhood
    if params[:neighborhood].nil?
      redirect_to health_units_path
    else
      @health_units = HealthUnit.where(neighborhood: params[:neighborhood])
      respond_to do |format|
        format.html { render template: "health_units/index.html.slim" }
        format.json { render template: "health_units/index.json.jbuilder"}
      end
    end
  end

  def advanced_search
    @health_unit = HealthUnit.new
  end

  def advanced_search_results
  end

  private
    # Use callbacks to share common setup or constraints between actions.
    def set_health_unit
      @health_unit = HealthUnit.find(params[:id])
    end

    # Never trust parameters from the scary internet, only allow the white list through.
    def health_unit_params
      params.require(:health_unit).permit(:cnes, :name, :address, :neighborhood, :phone, :latitude, :longitude, :description)
    end

end

This is my routes.rb:

  resources :health_units do
    collection do
      resources :comments, path: 'comentarios'
      post :basic_search, path: 'resultados'
      post :advanced_search, path: 'pesquisar'
      post :list_by_specialties, path: 'especialidades', as: :specialty
      post :list_by_treatments, path: 'atendimentos', as: :treatments
      post :search_by_neighborhood, path: 'bairro', as: :neighborhood
    end

And this is the error I get in my console:

Started GET "/health_units/especialidades?specialty=ENFASE" for 127.0.0.1 at 2019-05-27 03:29:07 -0300
Processing by HealthUnitsController#show as HTML
  Parameters: {"specialty"=>"ENFASE", "id"=>"especialidades"}
  HealthUnit Load (0.5ms)  SELECT  "health_units".* FROM "health_units" WHERE "health_units"."id" = $1 LIMIT $2  [["id", 0], ["LIMIT", 1]]
  ↳ app/controllers/health_units_controller.rb:127
Completed 404 Not Found in 3ms (ActiveRecord: 0.5ms)

ActiveRecord::RecordNotFound (Couldn't find HealthUnit with 'id'=especialidades):

app/controllers/health_units_controller.rb:127:in `set_health_unit'
Started GET "/favicon.ico" for 127.0.0.1 at 2019-05-27 03:29:07 -0300

ActionController::RoutingError (No route matches [GET] "/favicon.ico"):

actionpack (5.2.3) lib/action_dispatch/middleware/debug_exceptions.rb:65:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
railties (5.2.3) lib/rails/rack/logger.rb:38:in `call_app'
railties (5.2.3) lib/rails/rack/logger.rb:26:in `block in call'
activesupport (5.2.3) lib/active_support/tagged_logging.rb:71:in `block in tagged'
activesupport (5.2.3) lib/active_support/tagged_logging.rb:28:in `tagged'
activesupport (5.2.3) lib/active_support/tagged_logging.rb:71:in `tagged'
railties (5.2.3) lib/rails/rack/logger.rb:26:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/request_id.rb:27:in `call'
rack (2.0.7) lib/rack/method_override.rb:22:in `call'
rack (2.0.7) lib/rack/runtime.rb:22:in `call'
activesupport (5.2.3) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/static.rb:127:in `call'
rack (2.0.7) lib/rack/sendfile.rb:111:in `call'
railties (5.2.3) lib/rails/engine.rb:524:in `call'
puma (3.12.1) lib/puma/configuration.rb:227:in `call'
puma (3.12.1) lib/puma/server.rb:660:in `handle_request'
puma (3.12.1) lib/puma/server.rb:474:in `process_client'
puma (3.12.1) lib/puma/server.rb:334:in `block in run'
puma (3.12.1) lib/puma/thread_pool.rb:135:in `block in spawn_thread'

I would like to be able to refresh the page and get the same result as the first time I accessed it.

Body:
This is because when you refresh the routes goes to show action assuming id as especialidades and it tries to look the HealthUnit with id="especialidades" and it does not find and raise error

so one way you can solve this is defining the constraints

class RandomConstraint
  def matches?(request)
    return false unless request.path_parameters[:id].present?
  end
end

get :list_by_specialties, path: 'especialidades', as: :specialty, constraints: RandomConstraint.new


问:
How to see interaction between two connected servers?
Currently I am working on one work in which one nginx server is acting as front-end server and other nginx server is connected to this front end server to serve it what user has requested. Now, I can visualize the activities of user from the access log of front end server, but meanwhile, I want to know how this front-end server is interacting with that back-end server?
Is there any way to see, for example, by seeing some sort of log or any other procedure?</p>

答: Find where the second one stores its logs . access logs of back-end nginx is what the first one sends to it. </p>


问:
array is returning null and crashing
I have an array of objects in a class and trying to reference that array to a UIPickerView, but when the UITextField is tapped it crashes and comes back nil. When tapped on the countryInput text field it should show a pickerview with "Monaco, Japan" and so on...Any ideas on what I'm doing wrong? thank you in advance.

```<code>class SelectionViewController: UIViewController {

var lifeArr : [LifeClass] = []

let picker = UIPickerView()

    override func viewDidLoad() {
    super.viewDidLoad()

    let Monaco = LifeClass()
    Monaco.country = "Monaco"
    Monaco.male = 85.6
    Monaco.female = 93.5

    let Japan = LifeClass()
    Japan.country = "Japan"
    Japan.male = 81.9
    Japan.female = 88.8

    lifeArr = [Monaco, Japan]
  }

}

class SetupViewController: UIViewController, UIPickerViewDataSource, UIPickerViewDelegate {

@IBOutlet weak var birthDayInput: UITextField!
@IBOutlet weak var countryInput: UITextField!

var selectionData : SelectionViewController!
var picker = UIPickerView()

    override func viewDidLoad() {
    super.viewDidLoad()

        picker.dataSource = self
        picker.delegate = self

func numberOfComponents(in pickerView: UIPickerView) -> Int {
    return 1
}

func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
    return selectionData.lifeArr.count
}

func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
    return selectionData.lifeArr[row].country
}
func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
    countryInput.text = selectionData.lifeArr[row].country
}

}
</code>```

答:
Create a new class to keep this data in and use it from whichever VCs need to access it. E.g.

```<code>class LifeClassDatabase
{
  var lifeArr : [LifeClass] = []

  init()
  {
    let Monaco = LifeClass()
    Monaco.country = "Monaco"
    Monaco.male = 85.6
    Monaco.female = 93.5

    let Japan = LifeClass()
    Japan.country = "Japan"
    Japan.male = 81.9
    Japan.female = 88.8

    lifeArr = [Monaco, Japan]
  }

}
</code>```

Instantiate this from e.g. SetupViewController top level:-

```<code>private var lifeClassDatabase = LifeClassDatabase()
</code>```

Then use that in your datasource code, e.g.:

```<code>func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
    return lifeClassDatabase.lifeArr.count
}
</code>```

Title: array is returning null and crashing

Body:
I have an array of objects in a class and trying to reference that array to a UIPickerView, but when the UITextField is tapped it crashes and comes back nil. When tapped on the countryInput text field it should show a pickerview with "Monaco, Japan" and so on...Any ideas on what I'm doing wrong? thank you in advance.

class SelectionViewController: UIViewController {

var lifeArr : [LifeClass] = []

let picker = UIPickerView()

    override func viewDidLoad() {
    super.viewDidLoad()

    let Monaco = LifeClass()
    Monaco.country = "Monaco"
    Monaco.male = 85.6
    Monaco.female = 93.5

    let Japan = LifeClass()
    Japan.country = "Japan"
    Japan.male = 81.9
    Japan.female = 88.8

    lifeArr = [Monaco, Japan]
  }

}

class SetupViewController: UIViewController, UIPickerViewDataSource, UIPickerViewDelegate {

@IBOutlet weak var birthDayInput: UITextField!
@IBOutlet weak var countryInput: UITextField!

var selectionData : SelectionViewController!
var picker = UIPickerView()

    override func viewDidLoad() {
    super.viewDidLoad()

        picker.dataSource = self
        picker.delegate = self

func numberOfComponents(in pickerView: UIPickerView) -> Int {
    return 1
}

func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
    return selectionData.lifeArr.count
}

func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
    return selectionData.lifeArr[row].country
}
func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
    countryInput.text = selectionData.lifeArr[row].country
}

}

Body:
Create a new class to keep this data in and use it from whichever VCs need to access it. E.g.

class LifeClassDatabase
{
  var lifeArr : [LifeClass] = []

  init()
  {
    let Monaco = LifeClass()
    Monaco.country = "Monaco"
    Monaco.male = 85.6
    Monaco.female = 93.5

    let Japan = LifeClass()
    Japan.country = "Japan"
    Japan.male = 81.9
    Japan.female = 88.8

    lifeArr = [Monaco, Japan]
  }

}

Instantiate this from e.g. SetupViewController top level:-

private var lifeClassDatabase = LifeClassDatabase()

Then use that in your datasource code, e.g.:

func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
    return lifeClassDatabase.lifeArr.count
}


问:
Jetson TX2 multicast UDP stream with gstreamer
I'm trying to make a Jetson TX2 with Ubuntu 18.04 stream its CSI input encoded in H264 to UDP multicast with gstreamer. I've gone through (like) whole internet and tried all the codes and I'm unable to connect to it with VLC either by URL nor by SDP file. However I'm able to connect to it from same computer with another gstreamer instance. Target is to be able to connect to the stream from browser, but I guess it'd be easier to make it work with VLC.

Server code:

gst-launch-1.0 nvarguscamerasrc ! nvvidconv ! omxh264enc ! 'video/x-h264, stream-format=(string)byte-stream' ! h264parse ! rtph264pay mtu=1400 ! udpsink host=239.127.1.21 port=5000

Receiver code:
gst-launch-1.0 udpsrc port=5000 ! application/x-rtp,encoding-name=H264,payload=96 ! rtph264depay ! h264parse ! avdec_h264 ! xvimagesink

This works and the receiver code open window with the video. When I've tried to receive by VLC I've had some problems but basically nothing works and VLC is only connecting, I've tried:

vlc udp://:5000

vlc rtp://:5000 error: A description in SDP format is required to receive the RTP stream. Note that rtp:// URIs cannot work with dynamic RTP payload format (96).

vlc udp://239.127.1.21:5000

vlc rtp://239.127.1.21:5000 (same error as above for the rtp...)

vlc v.sdp with sdp file:

```<code>v=0
c=IN IP4 239.192.1.21
m=video 5000 RTP/AVP 96
a=rtpmap:96 H264/90000
</code>```

I've tried various IPs - server's IP, localhost, I've tried to connect from another computer and tried various combinations of client's IPs and server IPs. I was unable to connect also to unicast but I need to make multicast work.

So my question basically is: how to connect to gstreamer stream from browser.

答:
Could you try

```<code>gst-launch-1.0 nvarguscamerasrc ! nvvidconv ! omxh264enc ! 'video/x-h264, stream-format=(string)byte-stream' ! h264parse ! rtph264pay mtu=1400 config-interval=1 pt=96 ! udpsink host=239.127.1.21 port=5000
</code>```

with the sdp file

```<code>v=0
c=IN IP4 239.127.1.21
m=video 5000 RTP/AVP 96
a=rtpmap:96 H264/90000
</code>```

Body:
I'm trying to make a Jetson TX2 with Ubuntu 18.04 stream its CSI input encoded in H264 to UDP multicast with gstreamer. I've gone through (like) whole internet and tried all the codes and I'm unable to connect to it with VLC either by URL nor by SDP file. However I'm able to connect to it from same computer with another gstreamer instance. Target is to be able to connect to the stream from browser, but I guess it'd be easier to make it work with VLC.

Server code:

gst-launch-1.0 nvarguscamerasrc ! nvvidconv ! omxh264enc ! 'video/x-h264, stream-format=(string)byte-stream' ! h264parse ! rtph264pay mtu=1400 ! udpsink host=239.127.1.21 port=5000

Receiver code:
gst-launch-1.0 udpsrc port=5000 ! application/x-rtp,encoding-name=H264,payload=96 ! rtph264depay ! h264parse ! avdec_h264 ! xvimagesink

This works and the receiver code open window with the video. When I've tried to receive by VLC I've had some problems but basically nothing works and VLC is only connecting, I've tried:

vlc udp://:5000

vlc rtp://:5000 error: A description in SDP format is required to receive the RTP stream. Note that rtp:// URIs cannot work with dynamic RTP payload format (96).

vlc udp://239.127.1.21:5000

vlc rtp://239.127.1.21:5000 (same error as above for the rtp...)

vlc v.sdp with sdp file:

v=0
c=IN IP4 239.192.1.21
m=video 5000 RTP/AVP 96
a=rtpmap:96 H264/90000

I've tried various IPs - server's IP, localhost, I've tried to connect from another computer and tried various combinations of client's IPs and server IPs. I was unable to connect also to unicast but I need to make multicast work.

So my question basically is: how to connect to gstreamer stream from browser.

Body:
Could you try

gst-launch-1.0 nvarguscamerasrc ! nvvidconv ! omxh264enc ! 'video/x-h264, stream-format=(string)byte-stream' ! h264parse ! rtph264pay mtu=1400 config-interval=1 pt=96 ! udpsink host=239.127.1.21 port=5000

with the sdp file

v=0
c=IN IP4 239.127.1.21
m=video 5000 RTP/AVP 96
a=rtpmap:96 H264/90000


问:
Node - check existence of command in path
I have a unique problem where I need to use Node to iterate over several Unix-style commands and see if they exist in the path of a Windows installation.

For instance, Windows doesn't support ls natively. However, supposing someone installed git and checked to include Unix commands, it would.

I need to know whether or not ls and other commands are in the system path.

Right now, I'm using child_process to run help on each command. I then check the response of running it. This is messy and dangerous. I don't want to run 30 arbitrary commands from Node:

```<code>var spawnSync = require('child_process').spawnSync;
var out = spawnSync('ls', ['/?'], {encoding: 'utf8'});
</code>```

How else can I check for the existence of these commands?

答:
DON'T use child_process just for that, neither packages which use child_process internally. As Matt already answered, the most straightforward way is just checking under your Path.

Here is a NPM lookpath package which scans your $PATH or $Path.

```<code>const { lookpath } = require('lookpath');

const p = await lookpath('bash');
// "/bin/bash"
</code>```

This is a Node.js port of exec.LookPath from Go.

Hope it helps

Body:
I have a unique problem where I need to use Node to iterate over several Unix-style commands and see if they exist in the path of a Windows installation.

For instance, Windows doesn't support ls natively. However, supposing someone installed git and checked to include Unix commands, it would.

I need to know whether or not ls and other commands are in the system path.

Right now, I'm using child_process to run help on each command. I then check the response of running it. This is messy and dangerous. I don't want to run 30 arbitrary commands from Node:

var spawnSync = require('child_process').spawnSync;
var out = spawnSync('ls', ['/?'], {encoding: 'utf8'});

How else can I check for the existence of these commands?

Body:
DON'T use child_process just for that, neither packages which use child_process internally. As Matt already answered, the most straightforward way is just checking under your Path.

Here is a NPM lookpath package which scans your $PATH or $Path.

const { lookpath } = require('lookpath');

const p = await lookpath('bash');
// "/bin/bash"

This is a Node.js port of exec.LookPath from Go.

Hope it helps


问:
What are some good ways to delete files with blank(invisible) names?
I discovered some files with blank names in my code repository, but I don't know how to find them all and delete them.</p>

答:
Assuming you have access to the find command,

```<code>find . -regex ".*\/[[:space:]][[:space:]]*" -exec rm {} \;
</code>```

If you'd like to check before actually deleting,

```<code>$ mkdir -p c/d # make some empty filenames
$ touch " " " b" "a b"
$ touch "c/ " "c/ b" "c/a b"
$ touch "c/d/ "
$ touch "c/d/  "
# echo the filenames with markings
$ find . -regex ".*\/[[:space:]][[:space:]]*" -exec echo '{}<blank' \;
./ <blank
./c/ <blank
./c/d/ <blank
./c/d/  <blank
</code>```

Note: To my surprise, this even works with full-width spaces.

Body:
Assuming you have access to the find command,

find . -regex ".*\/[[:space:]][[:space:]]*" -exec rm {} \;

If you'd like to check before actually deleting,

$ mkdir -p c/d # make some empty filenames
$ touch " " " b" "a b"
$ touch "c/ " "c/ b" "c/a b"
$ touch "c/d/ "
$ touch "c/d/  "
# echo the filenames with markings
$ find . -regex ".*\/[[:space:]][[:space:]]*" -exec echo '{}<blank' \;
./ <blank
./c/ <blank
./c/d/ <blank
./c/d/  <blank

Note: To my surprise, this even works with full-width spaces.


问:
How remember that a React hooks component is unmounted, so can avoid state changes?
With old class based React.js code, I can do like this, to remember that a component has been unmounted:

```<code>  componentWillUnmount: function() {
    this.isGone = true;
  },

  loadUsers: function() {
    Server.loadUsers(..., (response) => {
      if (this.isGone) return;
      ...
    });
  }
</code>```

How can one do the same thing, with hooks based components?

Here's a sample hooks function component, where I'm unsure about how to remember that it's been unmounted, so I can return before calling any setSomeState:

```<code>export const GroupMembers = React.createFactory(function(props) {

  const [membersOrNull, setMembers] = React.useState(null);
  let isGone = false;  // ? (se [222] below

  React.useEffect(() => {
    Server.listGroupMembers(someGroupId, (response) => {
     if (/* is unmounted ?? */) return;
     setMembers(response.members);
    });
    return () => { /* how remember is unmounted?
                      would isGone = true; work? */ };
  }, []);

  ...

  return ..., Button({ title: "Remove all members", onClick: () => {
    Server.removeAllMembers(someGroupId, () => {
     if (/* is unmounted ?? */) return;
     setMembers([]);
    });
  }});
</code>```

I suppose I cannot use const [isGone, setGone] = useState(false) because I shouldn't try to access the state (read isGone) after has been unmounted. And if I [222] add a local let isGone = false inside the function, it seems to me that various callbacks created inside the function, will refer to different "instances" of this local variable, depending on in which different GroupMembers(..) invokation the different callbacks were created? or am I mistaken and this works? — Maybe I could create an outer wrapper function with a local let isGone = false, however, this adds another wrapping function and indentation :- /

答:
Since you are using the isGone flag outside of the useEffect method too, you can make use of useRef to store variables like

```<code>export const GroupMembers = React.createFactory(function(props) {

  const [membersOrNull, setMembers] = React.useState(null);
  const isGone = useRef(false);  // ? (se [222] below

  React.useEffect(() => {
    Server.listGroupMembers(someGroupId, (response) => {
     if (isGone.current) return;
     setMembers(response.members);
    });
    return () => {
       isGone.current = true;
    };
  }, []);

  ...

  return ..., Button({ title: "Remove all members", onClick: () => {
    Server.removeAllMembers(someGroupId, () => {
     if (isGone.current) return;
     setMembers([]);
    });
  }});
</code>```

PS: A better way to handle such things is to cancel the request when
  you are leaving the page instead of waiting for the response only to
  neglect it.

Body:
With old class based React.js code, I can do like this, to remember that a component has been unmounted:

  componentWillUnmount: function() {
    this.isGone = true;
  },

  loadUsers: function() {
    Server.loadUsers(..., (response) => {
      if (this.isGone) return;
      ...
    });
  }

How can one do the same thing, with hooks based components?

Here's a sample hooks function component, where I'm unsure about how to remember that it's been unmounted, so I can return before calling any setSomeState:

export const GroupMembers = React.createFactory(function(props) {

  const [membersOrNull, setMembers] = React.useState(null);
  let isGone = false;  // ? (se [222] below

  React.useEffect(() => {
    Server.listGroupMembers(someGroupId, (response) => {
     if (/* is unmounted ?? */) return;
     setMembers(response.members);
    });
    return () => { /* how remember is unmounted?
                      would isGone = true; work? */ };
  }, []);

  ...

  return ..., Button({ title: "Remove all members", onClick: () => {
    Server.removeAllMembers(someGroupId, () => {
     if (/* is unmounted ?? */) return;
     setMembers([]);
    });
  }});

I suppose I cannot use const [isGone, setGone] = useState(false) because I shouldn't try to access the state (read isGone) after has been unmounted. And if I [222] add a local let isGone = false inside the function, it seems to me that various callbacks created inside the function, will refer to different "instances" of this local variable, depending on in which different GroupMembers(..) invokation the different callbacks were created? or am I mistaken and this works? — Maybe I could create an outer wrapper function with a local let isGone = false, however, this adds another wrapping function and indentation :- /

Body:
Since you are using the isGone flag outside of the useEffect method too, you can make use of useRef to store variables like

export const GroupMembers = React.createFactory(function(props) {

  const [membersOrNull, setMembers] = React.useState(null);
  const isGone = useRef(false);  // ? (se [222] below

  React.useEffect(() => {
    Server.listGroupMembers(someGroupId, (response) => {
     if (isGone.current) return;
     setMembers(response.members);
    });
    return () => {
       isGone.current = true;
    };
  }, []);

  ...

  return ..., Button({ title: "Remove all members", onClick: () => {
    Server.removeAllMembers(someGroupId, () => {
     if (isGone.current) return;
     setMembers([]);
    });
  }});

PS: A better way to handle such things is to cancel the request when
  you are leaving the page instead of waiting for the response only to
  neglect it.


问:
AutoCompleteTextView - Get Id when select Name
I am getting the values from api(which list of Names with Id which i stored in model)- How to set this Name to AutoComplete and get both Name and Id on dropdown selection.
This will set a Name in autocomplete and getting name at onItemClick but how to get ID?

Model class

```<code>public class MeetingContactModel implements Serializable {

        private String id;
        private String text;

        public String getId() {
            return id;
        }

        public void setId(String id) {
            this.id = id;
        }

        public String getText() {
            return text;
        }

        public void setText(String text) {
            this.text = text;
        }
}
</code>```

MyActivity class
OnCreate :
calling autocomplete adapter

```<code>setMeetingContactAuto(autoContact, contactList);

autoContact.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                strContact =(String) parent.getItemAtPosition(position);
//                strContactCode = code.get(position);
            }
        });

private void setMeetingContactAuto(AutoCompleteTextView autoContact, final ArrayList<MeetingContactModel> xcontactList) {

        List<String> names = new AbstractList<String>() {
            @Override
            public int size() { return xcontactList.size(); }

            @Override
            public String get(int i) {
                code.clear();
                code.add(xcontactList.get(i).getText());
                return xcontactList.get(i).getText();
            }
        };
        autoContact.setThreshold(1);
        autoContact.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, names));
    }
</code>```

Not able to get Id - Please let me know to get it

答:
Implement toString() method in your model class </p>

```<code> public class MeetingContactModel implements Serializable {

    private String id;
    private String text;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    @Override
    public String toString() {
        return text;
    }

}

 // Fetch your selected model
 autoContact.setAdapter(new ArrayAdapter<>(requireContext(),  R.layout.spinner_item_ranking, contactList));
 autoContact.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
             MeetingContactModel m=(MeetingContactModel) parent.getItem(position);
             String name=m.getText();
             String id=m.getId();
            }
        });
</code>```

Body:
I am getting the values from api(which list of Names with Id which i stored in model)- How to set this Name to AutoComplete and get both Name and Id on dropdown selection.
This will set a Name in autocomplete and getting name at onItemClick but how to get ID?

Model class

public class MeetingContactModel implements Serializable {

        private String id;
        private String text;

        public String getId() {
            return id;
        }

        public void setId(String id) {
            this.id = id;
        }

        public String getText() {
            return text;
        }

        public void setText(String text) {
            this.text = text;
        }
}

MyActivity class
OnCreate :
calling autocomplete adapter

setMeetingContactAuto(autoContact, contactList);

autoContact.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                strContact =(String) parent.getItemAtPosition(position);
//                strContactCode = code.get(position);
            }
        });

private void setMeetingContactAuto(AutoCompleteTextView autoContact, final ArrayList<MeetingContactModel> xcontactList) {

        List<String> names = new AbstractList<String>() {
            @Override
            public int size() { return xcontactList.size(); }

            @Override
            public String get(int i) {
                code.clear();
                code.add(xcontactList.get(i).getText());
                return xcontactList.get(i).getText();
            }
        };
        autoContact.setThreshold(1);
        autoContact.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, names));
    }

Not able to get Id - Please let me know to get it

Body:
Implement toString() method in your model class

 public class MeetingContactModel implements Serializable {

    private String id;
    private String text;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    @Override
    public String toString() {
        return text;
    }

}

 // Fetch your selected model
 autoContact.setAdapter(new ArrayAdapter<>(requireContext(),  R.layout.spinner_item_ranking, contactList));
 autoContact.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
             MeetingContactModel m=(MeetingContactModel) parent.getItem(position);
             String name=m.getText();
             String id=m.getId();
            }
        });


问:
Nginx 301 Permanent Redirect For Language Support
I am now enabling language support for my web site.  I am including the language as part of the URL.  For example: domain.com/en/page  I need to setup 301 redirects for existing search engine indexing.

The following works in Nginx to redirect from domain.com/blog to domain.com/en/blog

```<code>location = /blog {
    return 301 /en/blog;
}
</code>```

I don't understand the redirect needed to go from domain.com/blog/read/# to domain.com/en/blog/read/# (where # is the sequence field in a postgres database table)

I have spent time looking, searching and reading docs to find this answer myself.  I am not understanding.

答:
To prefix the existing requested URI with /en you can use:

```<code>return 301 /en$request_uri;
</code>```

The above will add the three characters before the existing request and also include any arguments that may be present.

To match any URI that begins with /blog, use location /blog { ... }. To match any URI that begins with /blog/read/ use location /blog/read/ { ... }.

Nginx chooses a location to process a request based on a set of rules. So, you will need to consider the other location blocks present within your configuration.

Body:
I am now enabling language support for my web site.  I am including the language as part of the URL.  For example: domain.com/en/page  I need to setup 301 redirects for existing search engine indexing.

The following works in Nginx to redirect from domain.com/blog to domain.com/en/blog

location = /blog {
    return 301 /en/blog;
}

I don't understand the redirect needed to go from domain.com/blog/read/# to domain.com/en/blog/read/# (where # is the sequence field in a postgres database table)

I have spent time looking, searching and reading docs to find this answer myself.  I am not understanding.

Body:
To prefix the existing requested URI with /en you can use:

return 301 /en$request_uri;

The above will add the three characters before the existing request and also include any arguments that may be present.

To match any URI that begins with /blog, use location /blog { ... }. To match any URI that begins with /blog/read/ use location /blog/read/ { ... }.

Nginx chooses a location to process a request based on a set of rules. So, you will need to consider the other location blocks present within your configuration.