问:
Quick Smooth Resizing of Bitmaps
I am trying to write my own quick resampler which allows to scale image down by 2,3,4 etc.
I compared it with StretchBlt and my resampler is about 2 times slower.

My code:

```<code> type TRGBA = record
   B,G,R: Byte;
   A: Byte;
 end;

 PRGBAArray = ^TRGBAArray;
 TRGBAArray = array[0..32767] of TRGBA;

procedure DownsampleSys(Src, Dst: TBitmap; Times: Integer);
var ARect: TRect;
    dc:HDC;
    p:TPoint;
begin
  Dst.Width := Src.Width div Times;
  Dst.Height := Src.Height div Times;

  ARect := Rect(0,0, Dst.Width, Dst.Height);

  dc := Dst.Canvas.Handle;
  GetBrushOrgEx(dc,p);
  SetStretchBltMode(dc,HALFTONE);
  SetBrushOrgEx(dc,p.x,p.y,@p);
  StretchBlt(dc,
    ARect.Left, ARect.Top,
    ARect.Right- ARect.Left, ARect.Bottom- ARect.Top,
    Src.Canvas.Handle,0,0,Src.Width,Src.Height,Dst.Canvas.CopyMode);
end;

procedure Downsample2(Src, Dst: TBitmap; Times: Integer);
var x,y: Integer;
    xx,yy: Integer;
    FromP, ToP: PRGBAArray;
    SumR, SumG, SumB: Cardinal;
    Times2: Integer;
    xTimes, yTimes: Integer;
    xxxTimes: Integer;
    MarginL, MarginT: Integer;
begin
  Dst.Width := floor(Src.Width/ Times);
  Dst.Height := floor(Src.Height / Times);
  Times2 := Times * Times;
  MarginL := (Src.Width - (Dst.Width * Times)) div 2;
  MarginT := (Src.Height - (Dst.Height * Times)) div 2;

  for y:=0 to Dst.Height-1 do begin
    ToP := Dst.Scanline[y];

    yTimes := MarginT + y*Times;

    for x:=0 to Dst.Width-1 do begin

      SumR := 0;
      SumG := 0;
      SumB := 0;

      xTimes := MarginL + x*Times;

      for yy:=0 to Times-1 do begin
        FromP := Src.Scanline[yy + yTimes];

        for xx:=0 to Times-1 do begin
          xxxTimes := xx + xTimes;
          SumR := SumR + FromP[xxxTimes].R;
          SumG := SumG + FromP[xxxTimes].G;
          SumB := SumB + FromP[xxxTimes].B;
        end;
      end;

      ToP[x].R := SumR div Times2;
      ToP[x].G := SumG div Times2;
      ToP[x].B := SumB div Times2;
    end;
  end;
end;
</code>```

Usage:

```<code>InB := TBitmap.Create;
OutB := TBitmap.Create;

InB.LoadFromFile('2.bmp');
InB.PixelFormat := pf32bit;

OutB.PixelFormat := pf32bit;

Downsample2(InB, OutB, 4);
</code>```

How can I make it even faster?

答:
If you are still interested in an answer, you could give this thumbnail-routine a try. It's the result of a discussion way back on the Borland newsgroups. On my system it runs a bit faster than Stretch_Halftone, but the box-rescaling is a bit too foggy for my taste. I've abandoned all box-rescaling myself, because the system-rescaling, on my graphics at least, looks better; almost as if it was using bicubic scaling behind the scenes.

The speed gain is by use of lookup-tables, pointer- and integer-math.

```<code>// procedure MakeThumbnailMod
// Original source: Roy Magne Klever
// Altered to avoid division by 0
// and tried to make it a bit faster (RS)
//Integer math courtesy of Hagen Redmann

type
  PRGB32 = ^TRGB32;

  TRGB32 = packed record
    b: byte;
    g: byte;
    r: byte;
    a: byte;
  end;

  TLine32 = array [0 .. maxint div SizeOf(TRGB32) - 1] of TRGB32;
  PLine32 = ^TLine32;

  TIntArray = array of integer;
  TDeltaArray = array of array of integer;

procedure MakeStepsAndWeights(xscale, yscale: Single; xw, yh: integer;
  var dxmin, dymin: integer; var Weights: TDeltaArray;
  var xsteps, ysteps: TIntArray);
var
  i, j: integer;
  x1, x2: integer;
  dxmax, dymax, intscale: integer;
  fact: Single;
begin
  SetLength(xsteps, xw);
  SetLength(ysteps, yh);
  intscale := round(xscale * $10000);
  // won't work if xcale > $10000/2, because then intscale
  // exceeds 32bit integer. I don't see that happening.
  x1 := 0;
  x2 := intscale shr 16;
  for i := 0 to xw - 1 do
  begin
    xsteps[i] := x2 - x1;
    x1 := x2;
    x2 := (i + 2) * intscale shr 16;
  end;
  dxmin := Ceil(xscale - 1);
  dxmax := trunc(xscale + 1);

  intscale := round(yscale * $10000);
  x1 := 0;
  x2 := intscale shr 16;
  for i := 0 to yh - 1 do
  begin
    ysteps[i] := x2 - x1;
    x1 := x2;
    x2 := (i + 2) * intscale shr 16;
  end;
  dymin := Ceil(yscale - 1);
  dymax := trunc(yscale + 1);
  SetLength(weights, dxmax - dxmin + 1, dymax - dymin + 1);
  for i := 0 to dxmax - dxmin do
  begin
    fact := 1 / (dxmin + i);
    for j := 0 to dymax - dymin do
      weights[i, j] := round(fact / (dymin + j) * $10000);
  end;
end;

procedure MakeThumbNailMod(const Src, Dest: TBitmap;
  NewWidth, NewHeight: integer);
var
  xscale, yscale: Single;
  x1: integer;
  ix, iy: integer;
  totalRed, totalGreen, totalBlue: integer;
  ratio: integer;
  p: PRGB32;
  pt1: PRGB32;
  ptrD, ptrS: integer;
  x, y: integer;
  r1, r2: TRect;
  x3: integer;
  RowDest, RowSource, RowSourceStart: integer;
  weights: TDeltaArray;
  xsteps, ysteps: TIntArray;
  w, h, dxmin, dymin: integer;
  dx, dy: integer;

begin
  Dest.PixelFormat := pf32bit;
  Src.PixelFormat:=pf32bit; //to be on the safe side
  Dest.Width := NewWidth;
  Dest.Height := NewHeight;
  if (Dest.Width >= Src.Width) or (Dest.Height >= Src.Height) then
  begin  //we don't do upsampling
    r1 := rect(0, 0, Src.Width, Src.Height);
    r2 := r1;
    OffsetRect(r2, (Dest.Width - Src.Width) div 2,
      (Dest.Height - Src.Height) div 2);
    Dest.Canvas.CopyRect(r2, Src.Canvas, r1);
    exit;
  end;
  w := Dest.Width;
  h := Dest.Height;
  ptrD := (w * 32 + 31) and not 31;
  ptrD := ptrD div 8; // BytesPerScanline
  ptrS := (Src.Width * 32 + 31) and not 31;
  ptrS := ptrS div 8;

  xscale := Src.Width / w;
  yscale := Src.Height / h; // turns div into mults
  MakeStepsAndWeights(xscale, yscale, w, h, dxmin, dymin, weights, xsteps, ysteps);
  // Make 3 lookup tables for the steps and the ratios

  w := w - 1;
  h := h - 1;
  RowDest := integer(Dest.Scanline[0]);
  RowSourceStart := integer(Src.Scanline[0]);
  RowSource := RowSourceStart;
  for y := 0 to h do
  begin
    dy := ysteps[y];
    x1 := 0;
    x3 := 0;
    for x := 0 to w do
    begin
      dx := xsteps[x];
      totalRed := 0;
      totalGreen := 0;
      totalBlue := 0;
      RowSource := RowSourceStart;
      for iy := 1 to dy do
      begin
        p := PRGB32(RowSource + x1);
        for ix := 1 to dx do
        begin
          totalRed := totalRed + p^.r;
          totalGreen := totalGreen + p^.g;
          totalBlue := totalBlue + p^.b; //maybe add the alpha-channel optionally
          inc(p);
        end;
        RowSource := RowSource - ptrS;
      end;
      pt1 := PRGB32(RowDest + x3);
      ratio := weights[dx - dxmin, dy - dymin];
      pt1^.r := (totalRed * ratio) shr 16;  //"rounding"
      pt1^.g := (totalGreen * ratio) shr 16;
      pt1^.b := (totalBlue * ratio) shr 16;
      x1 := x1 + 4 * dx;
      x3 := x3 + 4;
    end;
    RowDest := RowDest - ptrD;
    RowSourceStart := RowSource;
  end;
  //SharpenMod(Work, Dest, min(1 + 0.4 * (xscale - 1), 2.5));
  //The sharpening makes the thumb look nicer, but is omitted here
end;
</code>```

Title: Quick Smooth Resizing of Bitmaps

Body:
I am trying to write my own quick resampler which allows to scale image down by 2,3,4 etc.
I compared it with StretchBlt and my resampler is about 2 times slower.

My code:

 type TRGBA = record
   B,G,R: Byte;
   A: Byte;
 end;

 PRGBAArray = ^TRGBAArray;
 TRGBAArray = array[0..32767] of TRGBA;

procedure DownsampleSys(Src, Dst: TBitmap; Times: Integer);
var ARect: TRect;
    dc:HDC;
    p:TPoint;
begin
  Dst.Width := Src.Width div Times;
  Dst.Height := Src.Height div Times;

  ARect := Rect(0,0, Dst.Width, Dst.Height);

  dc := Dst.Canvas.Handle;
  GetBrushOrgEx(dc,p);
  SetStretchBltMode(dc,HALFTONE);
  SetBrushOrgEx(dc,p.x,p.y,@p);
  StretchBlt(dc,
    ARect.Left, ARect.Top,
    ARect.Right- ARect.Left, ARect.Bottom- ARect.Top,
    Src.Canvas.Handle,0,0,Src.Width,Src.Height,Dst.Canvas.CopyMode);
end;

procedure Downsample2(Src, Dst: TBitmap; Times: Integer);
var x,y: Integer;
    xx,yy: Integer;
    FromP, ToP: PRGBAArray;
    SumR, SumG, SumB: Cardinal;
    Times2: Integer;
    xTimes, yTimes: Integer;
    xxxTimes: Integer;
    MarginL, MarginT: Integer;
begin
  Dst.Width := floor(Src.Width/ Times);
  Dst.Height := floor(Src.Height / Times);
  Times2 := Times * Times;
  MarginL := (Src.Width - (Dst.Width * Times)) div 2;
  MarginT := (Src.Height - (Dst.Height * Times)) div 2;

  for y:=0 to Dst.Height-1 do begin
    ToP := Dst.Scanline[y];

    yTimes := MarginT + y*Times;

    for x:=0 to Dst.Width-1 do begin

      SumR := 0;
      SumG := 0;
      SumB := 0;

      xTimes := MarginL + x*Times;

      for yy:=0 to Times-1 do begin
        FromP := Src.Scanline[yy + yTimes];

        for xx:=0 to Times-1 do begin
          xxxTimes := xx + xTimes;
          SumR := SumR + FromP[xxxTimes].R;
          SumG := SumG + FromP[xxxTimes].G;
          SumB := SumB + FromP[xxxTimes].B;
        end;
      end;

      ToP[x].R := SumR div Times2;
      ToP[x].G := SumG div Times2;
      ToP[x].B := SumB div Times2;
    end;
  end;
end;

Usage:

InB := TBitmap.Create;
OutB := TBitmap.Create;

InB.LoadFromFile('2.bmp');
InB.PixelFormat := pf32bit;

OutB.PixelFormat := pf32bit;

Downsample2(InB, OutB, 4);

How can I make it even faster?

Body:
If you are still interested in an answer, you could give this thumbnail-routine a try. It's the result of a discussion way back on the Borland newsgroups. On my system it runs a bit faster than Stretch_Halftone, but the box-rescaling is a bit too foggy for my taste. I've abandoned all box-rescaling myself, because the system-rescaling, on my graphics at least, looks better; almost as if it was using bicubic scaling behind the scenes.

The speed gain is by use of lookup-tables, pointer- and integer-math.

// procedure MakeThumbnailMod
// Original source: Roy Magne Klever
// Altered to avoid division by 0
// and tried to make it a bit faster (RS)
//Integer math courtesy of Hagen Redmann

type
  PRGB32 = ^TRGB32;

  TRGB32 = packed record
    b: byte;
    g: byte;
    r: byte;
    a: byte;
  end;

  TLine32 = array [0 .. maxint div SizeOf(TRGB32) - 1] of TRGB32;
  PLine32 = ^TLine32;

  TIntArray = array of integer;
  TDeltaArray = array of array of integer;

procedure MakeStepsAndWeights(xscale, yscale: Single; xw, yh: integer;
  var dxmin, dymin: integer; var Weights: TDeltaArray;
  var xsteps, ysteps: TIntArray);
var
  i, j: integer;
  x1, x2: integer;
  dxmax, dymax, intscale: integer;
  fact: Single;
begin
  SetLength(xsteps, xw);
  SetLength(ysteps, yh);
  intscale := round(xscale * $10000);
  // won't work if xcale > $10000/2, because then intscale
  // exceeds 32bit integer. I don't see that happening.
  x1 := 0;
  x2 := intscale shr 16;
  for i := 0 to xw - 1 do
  begin
    xsteps[i] := x2 - x1;
    x1 := x2;
    x2 := (i + 2) * intscale shr 16;
  end;
  dxmin := Ceil(xscale - 1);
  dxmax := trunc(xscale + 1);

  intscale := round(yscale * $10000);
  x1 := 0;
  x2 := intscale shr 16;
  for i := 0 to yh - 1 do
  begin
    ysteps[i] := x2 - x1;
    x1 := x2;
    x2 := (i + 2) * intscale shr 16;
  end;
  dymin := Ceil(yscale - 1);
  dymax := trunc(yscale + 1);
  SetLength(weights, dxmax - dxmin + 1, dymax - dymin + 1);
  for i := 0 to dxmax - dxmin do
  begin
    fact := 1 / (dxmin + i);
    for j := 0 to dymax - dymin do
      weights[i, j] := round(fact / (dymin + j) * $10000);
  end;
end;

procedure MakeThumbNailMod(const Src, Dest: TBitmap;
  NewWidth, NewHeight: integer);
var
  xscale, yscale: Single;
  x1: integer;
  ix, iy: integer;
  totalRed, totalGreen, totalBlue: integer;
  ratio: integer;
  p: PRGB32;
  pt1: PRGB32;
  ptrD, ptrS: integer;
  x, y: integer;
  r1, r2: TRect;
  x3: integer;
  RowDest, RowSource, RowSourceStart: integer;
  weights: TDeltaArray;
  xsteps, ysteps: TIntArray;
  w, h, dxmin, dymin: integer;
  dx, dy: integer;

begin
  Dest.PixelFormat := pf32bit;
  Src.PixelFormat:=pf32bit; //to be on the safe side
  Dest.Width := NewWidth;
  Dest.Height := NewHeight;
  if (Dest.Width >= Src.Width) or (Dest.Height >= Src.Height) then
  begin  //we don't do upsampling
    r1 := rect(0, 0, Src.Width, Src.Height);
    r2 := r1;
    OffsetRect(r2, (Dest.Width - Src.Width) div 2,
      (Dest.Height - Src.Height) div 2);
    Dest.Canvas.CopyRect(r2, Src.Canvas, r1);
    exit;
  end;
  w := Dest.Width;
  h := Dest.Height;
  ptrD := (w * 32 + 31) and not 31;
  ptrD := ptrD div 8; // BytesPerScanline
  ptrS := (Src.Width * 32 + 31) and not 31;
  ptrS := ptrS div 8;

  xscale := Src.Width / w;
  yscale := Src.Height / h; // turns div into mults
  MakeStepsAndWeights(xscale, yscale, w, h, dxmin, dymin, weights, xsteps, ysteps);
  // Make 3 lookup tables for the steps and the ratios

  w := w - 1;
  h := h - 1;
  RowDest := integer(Dest.Scanline[0]);
  RowSourceStart := integer(Src.Scanline[0]);
  RowSource := RowSourceStart;
  for y := 0 to h do
  begin
    dy := ysteps[y];
    x1 := 0;
    x3 := 0;
    for x := 0 to w do
    begin
      dx := xsteps[x];
      totalRed := 0;
      totalGreen := 0;
      totalBlue := 0;
      RowSource := RowSourceStart;
      for iy := 1 to dy do
      begin
        p := PRGB32(RowSource + x1);
        for ix := 1 to dx do
        begin
          totalRed := totalRed + p^.r;
          totalGreen := totalGreen + p^.g;
          totalBlue := totalBlue + p^.b; //maybe add the alpha-channel optionally
          inc(p);
        end;
        RowSource := RowSource - ptrS;
      end;
      pt1 := PRGB32(RowDest + x3);
      ratio := weights[dx - dxmin, dy - dymin];
      pt1^.r := (totalRed * ratio) shr 16;  //"rounding"
      pt1^.g := (totalGreen * ratio) shr 16;
      pt1^.b := (totalBlue * ratio) shr 16;
      x1 := x1 + 4 * dx;
      x3 := x3 + 4;
    end;
    RowDest := RowDest - ptrD;
    RowSourceStart := RowSource;
  end;
  //SharpenMod(Work, Dest, min(1 + 0.4 * (xscale - 1), 2.5));
  //The sharpening makes the thumb look nicer, but is omitted here
end;


来源: stackexchange

问:
Is it possible to access parent class's members from a nested class in an aggregation
My Question is, say i declare a class within a class, as a sort of an aggregation:

```<code>class A:

    self.foo = 20
    self.bar = 30

    def someFunc(self):

        class B:
            # some code here

        BObject = B()
</code>```

is it possible to access the foo/bar variables from within class B ? If yes, then how ?

I have run into this problem while using wxpython, and needing to write a class within the main frame class to handle a particular custom dialog.

Thanks in Advance :)

答:
```<code>class A(object):
    foo = 20
    bar = 30
    def build_b(self):
        class B(object):
            foo = self.foo
            bar = self.bar
        return B()
</code>```

Then you could do:

```<code>>>> b_obj = A().build_b()

>>> b_obj.foo, b_obj.bar
<<< (20, 30)
</code>```

But, you should really break class B out of class A if you can, use it's __init__ method to initialize it...

ContentLicense: CC BY-SA 3.0

Body:
My Question is, say i declare a class within a class, as a sort of an aggregation:

class A:

    self.foo = 20
    self.bar = 30

    def someFunc(self):

        class B:
            # some code here

        BObject = B()

is it possible to access the foo/bar variables from within class B ? If yes, then how ?

I have run into this problem while using wxpython, and needing to write a class within the main frame class to handle a particular custom dialog.

Thanks in Advance :)

Body:
class A(object):
    foo = 20
    bar = 30
    def build_b(self):
        class B(object):
            foo = self.foo
            bar = self.bar
        return B()

Then you could do:

>>> b_obj = A().build_b()

>>> b_obj.foo, b_obj.bar
<<< (20, 30)

But, you should really break class B out of class A if you can, use it's __init__ method to initialize it...


问:
How to implement the ReLU function in Numpy
I want to make a simple neural network which uses the ReLU function. Can someone give me a clue of how can I implement the function using numpy.</p>

答: ReLU(x) also is equal to (x+abs(x))/2  </p>

ContentLicense: CC BY-SA 4.0

Body: ReLU(x) also is equal to (x+abs(x))/2


问:
I am receiving an infinite while loop when I run my code and enter the wrong input values. Does anyone know why, and how to fix it?
I receive an infinite while loop when I incorrectly enter the input for user_vendor or user_card. It works fine when I enter the correct values. card_check is set to the correct card value. The vendors I have listed are </p>

```<code>def user_vendor(vendor):

 while True:

    if vendor == 'Visa' or vendor == 'MasterCard' or vendor == 'American Express' or vendor == 'Discover':

        print("\nValid vendor, thank you!")
        break

    else:
        print("\nPlease enter a valid vendor.")
        continue

def user_card(card, card_check):

 while True:

    if card == card_check:

        print("\nCard matches, thank you!")
        break

    else:
        print("\nCard does not match!")
        continue

def main():

 card_check = 5412753456789010

 vendor = input("\nPlease enter your Vendor for your card (Visa, MasterCard, American Express, Discover): ")
 user_vendor(vendor)
 card = int(input("\nPlease enter your card number: "))
 user_card(card,card_check)

 return;

main()
</code>```

答:
Something like the following would be better fit. You have to re-request the input, otherwise you are simply repeating the check on the bad input.</p>

```<code>def user_vendor(vendor):

 while True:

    if vendor == 'Visa' or vendor == 'MasterCard' or vendor == 'American Express' or vendor == 'Discover':

        print("\nValid vendor, thank you!")
        return True

    else:
        print("\nPlease enter a valid vendor.")
        return False

def user_card(card, card_check):

 while True:

    if card == card_check:

        print("\nCard matches, thank you!")
        return True

    else:
        print("\nCard does not match!")
        return False

def main():

 card_check = 5412753456789010
 vendor = ""
 card = 0
 while user_vendor(vendor) == False:
    vendor = input("\nPlease enter your Vendor for your card (Visa, MasterCard, American Express, Discover): ")
    user_vendor(vendor)
 while user_card(card,card_check) == False:
    card = int(input("\nPlease enter your card number: "))
    user_card(card,card_check)

 return;

main()
</code>```

Body:
I receive an infinite while loop when I incorrectly enter the input for user_vendor or user_card. It works fine when I enter the correct values. card_check is set to the correct card value. The vendors I have listed are

def user_vendor(vendor):

 while True:

    if vendor == 'Visa' or vendor == 'MasterCard' or vendor == 'American Express' or vendor == 'Discover':

        print("\nValid vendor, thank you!")
        break

    else:
        print("\nPlease enter a valid vendor.")
        continue

def user_card(card, card_check):

 while True:

    if card == card_check:

        print("\nCard matches, thank you!")
        break

    else:
        print("\nCard does not match!")
        continue

def main():

 card_check = 5412753456789010

 vendor = input("\nPlease enter your Vendor for your card (Visa, MasterCard, American Express, Discover): ")
 user_vendor(vendor)
 card = int(input("\nPlease enter your card number: "))
 user_card(card,card_check)

 return;

main()

Body:
Something like the following would be better fit. You have to re-request the input, otherwise you are simply repeating the check on the bad input.

def user_vendor(vendor):

 while True:

    if vendor == 'Visa' or vendor == 'MasterCard' or vendor == 'American Express' or vendor == 'Discover':

        print("\nValid vendor, thank you!")
        return True

    else:
        print("\nPlease enter a valid vendor.")
        return False

def user_card(card, card_check):

 while True:

    if card == card_check:

        print("\nCard matches, thank you!")
        return True

    else:
        print("\nCard does not match!")
        return False

def main():

 card_check = 5412753456789010
 vendor = ""
 card = 0
 while user_vendor(vendor) == False:
    vendor = input("\nPlease enter your Vendor for your card (Visa, MasterCard, American Express, Discover): ")
    user_vendor(vendor)
 while user_card(card,card_check) == False:
    card = int(input("\nPlease enter your card number: "))
    user_card(card,card_check)

 return;

main()


问:
remove empty tags and the parent if empty as well from xml using python
I am new to python and trying to use lxml to remove the empty tags from XML. I want to get rid of all empty elements and if by doing that parent is empty as well, I want to remove it as well.

Actual XML

```<code><magento_api>
  <data_item>
    <code>400</code>
    <message>Attribute weight is not applicable for product type Configurable Product</message>
  </data_item>
  <data_item>
    <code></code>
    <message>Resource data pre-validation error.</message>
  </data_item>
  <data_item>
    <code>1</code>
    <message></message>
  </data_item>
  <data_item>
    <code></code>
    <message></message>
  </data_item>
</magento_api>
</code>```

Modified XML

```<code><magento_api>
  <data_item>
    <code>400</code>
    <message>Attribute weight is not applicable for product type Configurable Product</message>
  </data_item>
  <data_item>
    <message>Resource data pre-validation error.</message>
  </data_item>
  <data_item>
    <code>1</code>
  </data_item>
</magento_api>
</code>```

I have used something like below but it ain't working

```<code>from lxml import etree

def recursively_empty(xml_element):
   if xml_element.text:
       return False
   return all((recursively_empty(xe) for xe in xml_element.iterchildren()))

data = """
<magento_api>
<data_item>
 <code>400</code>
<message>Attribute weight is not applicable for product type Configurable Product</message>
</data_item>
<data_item>
<code>400</code>
<message></message>
</data_item>
<data_item>
<code></code>
<message>abc</message>
</data_item>
<data_item>
<code></code>
<message></message>
</data_item>
</magento_api>
"""

xml_root = etree.fromstring(data)

for action, xml_element in xml_root:
    parent = xml_element.getparent()
    if recursively_empty(xml_element):
        parent.remove(xml_element)

print (etree.tostring(xml_root))
</code>```

答:
One thing you could do is use the normalize-space() xpath function on each element to get the string value. If it's empty, remove the element.

Example...

Python (Note: I used your "Actual XML" example; not the XML you had in your Python.)

from lxml import etree

data = """
<magento_api>
  <data_item>
    400
    <message>Attribute weight is not applicable for product type Configurable Product</message>
  </data_item>
  <data_item>

    <message>Resource data pre-validation error.</message>
  </data_item>
  <data_item>
    1
    <message></message>
  </data_item>
  <data_item>

    <message></message>
  </data_item>
</magento_api>
"""

parser = etree.XMLParser(remove_blank_text=True)
xml_root = etree.fromstring(data, parser=parser)

for xml_element in xml_root.iter():
    content = xml_element.xpath('normalize-space()')
    if not content:
        xml_element.getparent().remove(xml_element)

print(etree.tostring(xml_root, pretty_print=True).decode())
```

<p><strong>Output</strong></p>

<pre class="lang-xml prettyprint-override"><code><magento_api>
  <data_item>
    <code>400</code>
    <message>Attribute weight is not applicable for product type Configurable Product</message>
  </data_item>
  <data_item>
    <message>Resource data pre-validation error.</message>
  </data_item>
  <data_item>
    <code>1</code>
  </data_item>
</magento_api>
</code>```

Body:
I am new to python and trying to use lxml to remove the empty tags from XML. I want to get rid of all empty elements and if by doing that parent is empty as well, I want to remove it as well.

Actual XML

<magento_api>
  <data_item>
    400
    <message>Attribute weight is not applicable for product type Configurable Product</message>
  </data_item>
  <data_item>

    <message>Resource data pre-validation error.</message>
  </data_item>
  <data_item>
    1
    <message></message>
  </data_item>
  <data_item>

    <message></message>
  </data_item>
</magento_api>

Modified XML

<magento_api>
  <data_item>
    400
    <message>Attribute weight is not applicable for product type Configurable Product</message>
  </data_item>
  <data_item>
    <message>Resource data pre-validation error.</message>
  </data_item>
  <data_item>
    1
  </data_item>
</magento_api>

I have used something like below but it ain't working

from lxml import etree

def recursively_empty(xml_element):
   if xml_element.text:
       return False
   return all((recursively_empty(xe) for xe in xml_element.iterchildren()))

data = """
<magento_api>
<data_item>
 400
<message>Attribute weight is not applicable for product type Configurable Product</message>
</data_item>
<data_item>
400
<message></message>
</data_item>
<data_item>

<message>abc</message>
</data_item>
<data_item>

<message></message>
</data_item>
</magento_api>
"""

xml_root = etree.fromstring(data)

for action, xml_element in xml_root:
    parent = xml_element.getparent()
    if recursively_empty(xml_element):
        parent.remove(xml_element)

print (etree.tostring(xml_root))

Body:
One thing you could do is use the normalize-space() xpath function on each element to get the string value. If it's empty, remove the element.

Example...

Python (Note: I used your "Actual XML" example; not the XML you had in your Python.)

from lxml import etree

data = """
<magento_api>
  <data_item>
    <code>400</code>
    <message>Attribute weight is not applicable for product type Configurable Product</message>
  </data_item>
  <data_item>
    <code></code>
    <message>Resource data pre-validation error.</message>
  </data_item>
  <data_item>
    <code>1</code>
    <message></message>
  </data_item>
  <data_item>
    <code></code>
    <message></message>
  </data_item>
</magento_api>
"""

parser = etree.XMLParser(remove_blank_text=True)
xml_root = etree.fromstring(data, parser=parser)

for xml_element in xml_root.iter():
    content = xml_element.xpath('normalize-space()')
    if not content:
        xml_element.getparent().remove(xml_element)

print(etree.tostring(xml_root, pretty_print=True).decode())

Output

<magento_api>
  <data_item>
    <code>400</code>
    <message>Attribute weight is not applicable for product type Configurable Product</message>
  </data_item>
  <data_item>
    <message>Resource data pre-validation error.</message>
  </data_item>
  <data_item>
    <code>1</code>
  </data_item>
</magento_api>


问:
AWS Amplify error import StorageProvider class from aws-amplify
The documentation of AWS Amplify says:

```<code>import { Storage, StorageProvider } from 'aws-amplify';
export default class MyStorageProvider implements StorageProvider {
</code>```

https://aws-amplify.github.io/docs/js/storage#using-a-custom-plugin

In my angular 8 app, the import fails with this error:

Module '"node_modules/aws-amplify/lib-esm"' has no exported member 'StorageProvider'. Did you mean to use 'import StorageProvider from "/node_modules/aws-amplify/lib-esm"' instead?

Version: "aws-amplify": "^2.2.2"

What's wrong?
Thanks!

答:
StorageProvider may be exported from export default StorageProvider instead of an export StorageProvider, so you may have to do:

```<code>import StorageProvider from 'aws-amplify'
</code>```

Body:
The documentation of AWS Amplify says:

import { Storage, StorageProvider } from 'aws-amplify';
export default class MyStorageProvider implements StorageProvider {

https://aws-amplify.github.io/docs/js/storage#using-a-custom-plugin

In my angular 8 app, the import fails with this error:

Module '"node_modules/aws-amplify/lib-esm"' has no exported member 'StorageProvider'. Did you mean to use 'import StorageProvider from "/node_modules/aws-amplify/lib-esm"' instead?

Version: "aws-amplify": "^2.2.2"

What's wrong?
Thanks!

Body:
StorageProvider may be exported from export default StorageProvider instead of an export StorageProvider, so you may have to do:

import StorageProvider from 'aws-amplify'


问:
How to see top processes sorted by actual memory usage?
I have a server with 12G of memory. A fragment of top is shown below:

```<code>PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
12979 frank  20   0  206m  21m  12m S   11  0.2  26667:24 krfb
13 root      15  -5     0    0    0 S    1  0.0  36:25.04 ksoftirqd/3
59 root      15  -5     0    0    0 S    0  0.0   4:53.00 ata/2
2155 root      20   0  662m  37m 8364 S    0  0.3 338:10.25 Xorg
4560 frank  20   0  8672 1300  852 R    0  0.0   0:00.03 top
12981 frank  20   0  987m  27m  15m S    0  0.2  45:10.82 amarok
24908 frank  20   0 16648  708  548 S    0  0.0   2:08.84 wrapper
1 root      20   0  8072  608  572 S    0  0.0   0:47.36 init
2 root      15  -5     0    0    0 S    0  0.0   0:00.00 kthreadd
</code>```

The free -m shows the following:

```<code>             total       used       free     shared    buffers     cached
Mem:         12038      11676        362          0        599       9745
-/+ buffers/cache:       1331      10706
Swap:         2204        257       1946
</code>```

If I understand correctly, the system has only 362 MB of available memory. My question is: How can I find out which process is consuming most of the memory?

Just as background info, the system is running 64bit OpenSuse 12.

答:
This very second in time

```<code>ps -U $(whoami) -eom pid,pmem,pcpu,comm | head -n4
</code>```

Continuously updating

```<code>watch -n 1 'ps -U $(whoami) -eom pid,pmem,pcpu,comm | head -n4'
</code>```

I also added a few goodies here you might appreciate (or you might ignore)

-n 1 watch and update every second

-U $(whoami) To show only your processes. $(some command) evaluates now

| head -n4 To only show the header and 3 processes at a time bc often you just need high usage line items

${1-4} says my first argument $1 I want to default to 4, unless I provide it

If you are using a mac you may need to install watch first
brew install watch

Alternatively you might use a function

```<code>psm(){
    watch -n 1 "ps -eom pid,pmem,pcpu,comm | head -n ${1-4}"
    # EXAMPLES:
    # psm
    # psm 10
}
</code>```

Body:
I have a server with 12G of memory. A fragment of top is shown below:

PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
12979 frank  20   0  206m  21m  12m S   11  0.2  26667:24 krfb
13 root      15  -5     0    0    0 S    1  0.0  36:25.04 ksoftirqd/3
59 root      15  -5     0    0    0 S    0  0.0   4:53.00 ata/2
2155 root      20   0  662m  37m 8364 S    0  0.3 338:10.25 Xorg
4560 frank  20   0  8672 1300  852 R    0  0.0   0:00.03 top
12981 frank  20   0  987m  27m  15m S    0  0.2  45:10.82 amarok
24908 frank  20   0 16648  708  548 S    0  0.0   2:08.84 wrapper
1 root      20   0  8072  608  572 S    0  0.0   0:47.36 init
2 root      15  -5     0    0    0 S    0  0.0   0:00.00 kthreadd

The free -m shows the following:

             total       used       free     shared    buffers     cached
Mem:         12038      11676        362          0        599       9745
-/+ buffers/cache:       1331      10706
Swap:         2204        257       1946

If I understand correctly, the system has only 362 MB of available memory. My question is: How can I find out which process is consuming most of the memory?

Just as background info, the system is running 64bit OpenSuse 12.

Body:
This very second in time

ps -U $(whoami) -eom pid,pmem,pcpu,comm | head -n4

Continuously updating

watch -n 1 'ps -U $(whoami) -eom pid,pmem,pcpu,comm | head -n4'

I also added a few goodies here you might appreciate (or you might ignore)

-n 1 watch and update every second

-U $(whoami) To show only your processes. $(some command) evaluates now

| head -n4 To only show the header and 3 processes at a time bc often you just need high usage line items

${1-4} says my first argument $1 I want to default to 4, unless I provide it

If you are using a mac you may need to install watch first
brew install watch

Alternatively you might use a function

psm(){
    watch -n 1 "ps -eom pid,pmem,pcpu,comm | head -n ${1-4}"
    # EXAMPLES:
    # psm
    # psm 10
}


问:
HTML CSS Modal content is "out of box"
```<code>.modal-body {
    height:100%;
    overflow-y: scroll;
}

<div id="modal" class="modal fade" role="dialog">
  <div class="modal-dialog" style="width:80%;height:100%">

    <!-- Modal content-->
    <div class="modal-content" style="width:80%;height:100%">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">×</button>
        <h4 class="modal-title">ABC </h4>
      </div>
      <div class="modal-body" id="abcmodal" style="display:inline-block"style="height:auto;">
      </div>
      <div class="modal-footer" style="display:none;">
      </div>
    </div>

  </div>
</div>
</code>```

Everything works fine , but when the content is too "long" , the content will out of place.

Screenshot : https://prnt.sc/sre2vw

any idea what should i edit ?

答:
I tested your code and it is working fine. I put a long paragraph in the modal-body, the content was shown properly with scrolling. Please run the code snippet for the result.

.modal-body {
  height: 100%;
  overflow-y: scroll;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">

<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>

<!-- Button trigger modal -->
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#modal">
  Launch demo modal
</button>

<div id="modal" class="modal fade" role="dialog">
  <div class="modal-dialog" style="width:80%;height:100%">

    <!-- Modal content-->
    <div class="modal-content" style="width:80%;height:100%">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">×</button>
        <h4 class="modal-title">ABC </h4>
      </div>
      <div class="modal-body" id="abcmodal" style="display:inline-block" style="height:auto;">
        <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae
          est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis
          tempus lacus enim ac dui. Donec non enim in turpis pulvinar facilisis. Ut felis. Praesent dapibus, neque id cursus faucibus, tortor neque egestas augue, eu vulputate magna eros eu erat. Aliquam erat volutpat. Nam dui mi, tincidunt quis, accumsan
          porttitor, facilisis luctus, metus</p>
        <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae
          est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis
          tempus lacus enim ac dui. Donec non enim in turpis pulvinar facilisis. Ut felis. Praesent dapibus, neque id cursus faucibus, tortor neque egestas augue, eu vulputate magna eros eu erat. Aliquam erat volutpat. Nam dui mi, tincidunt quis, accumsan
          porttitor, facilisis luctus, metus</p>
        <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae
          est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis
          tempus lacus enim ac dui. Donec non enim in turpis pulvinar facilisis. Ut felis. Praesent dapibus, neque id cursus faucibus, tortor neque egestas augue, eu vulputate magna eros eu erat. Aliquam erat volutpat. Nam dui mi, tincidunt quis, accumsan
          porttitor, facilisis luctus, metus</p>
      </div>

      <div class="modal-footer" style="display:none;">
      </div>
    </div>

  </div>
</div></code>```

Title: HTML CSS Modal content is "out of box"

Body:
.modal-body {
    height:100%;
    overflow-y: scroll;
}

        <button type="button" class="close" data-dismiss="modal">×</button>

ABC

Everything works fine , but when the content is too "long" , the content will out of place.

Screenshot : https://prnt.sc/sre2vw

any idea what should i edit ?

Body:
I tested your code and it is working fine. I put a long paragraph in the modal-body, the content was shown properly with scrolling. Please run the code snippet for the result.

.modal-body {
  height: 100%;
  overflow-y: scroll;
}

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">

<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>

<!-- Button trigger modal -->
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#modal">
  Launch demo modal
</button>

<div id="modal" class="modal fade" role="dialog">
  <div class="modal-dialog" style="width:80%;height:100%">

    <!-- Modal content-->
    <div class="modal-content" style="width:80%;height:100%">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">ABC </h4>
      </div>
      <div class="modal-body" id="abcmodal" style="display:inline-block" style="height:auto;">
        <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae
          est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis
          tempus lacus enim ac dui. Donec non enim in turpis pulvinar facilisis. Ut felis. Praesent dapibus, neque id cursus faucibus, tortor neque egestas augue, eu vulputate magna eros eu erat. Aliquam erat volutpat. Nam dui mi, tincidunt quis, accumsan
          porttitor, facilisis luctus, metus</p>
        <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae
          est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis
          tempus lacus enim ac dui. Donec non enim in turpis pulvinar facilisis. Ut felis. Praesent dapibus, neque id cursus faucibus, tortor neque egestas augue, eu vulputate magna eros eu erat. Aliquam erat volutpat. Nam dui mi, tincidunt quis, accumsan
          porttitor, facilisis luctus, metus</p>
        <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae
          est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis
          tempus lacus enim ac dui. Donec non enim in turpis pulvinar facilisis. Ut felis. Praesent dapibus, neque id cursus faucibus, tortor neque egestas augue, eu vulputate magna eros eu erat. Aliquam erat volutpat. Nam dui mi, tincidunt quis, accumsan
          porttitor, facilisis luctus, metus</p>
      </div>

      <div class="modal-footer" style="display:none;">
      </div>
    </div>

  </div>
</div>


问:
Custom slider positioning elements over it.(HTML+CSS)
Creating a custom slider which should be supporting Chrome and IE11.
Facing issues positioning the thumb and elements(White circle and red oval) on the slider track.
The white circles should be connected with a line.

Here is the fiddle of what i have achieved.

https://jsfiddle.net/Pravin_it14/7t9bsrdn/7/

/*Slider*/

.areaDetail_graph_04 {
  height: 87px;
  width: 614px!important;
  position: relative;
  /* background-color: rgba(255,255,255,0.5); */
  /* border-radius: 8px 8px 8px 8px; */
}

.areaDetail_graph_04 .img {
  background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAmYAAABXCAYAAACulYmrAAAACXBIWXMAAAsSAAALEgHS3X78AAADzklEQVR4nO3dT25TVxTA4ROHCuq4LaZS1M5AQuowLCE7apbQJSQ7yhYyrIQEM6pIjaGx3UYUXB3zAlWC0H0PiI+U75tkEsfRu5Of7r+3tVqt4qrZfPkwIg4iYj8i9q79AgAAQ5xExHFEHE4n4+dXP38tzGbz5WFE/OpRAwB8VUfTyfjg/1/wPsxm8+X9ruDMkAEA3IycQdufTsYv89tGIcoAADYl2+u4a7F3YRYRv4kyAICN2OtaLLbOzhe50f+ZcQAA2KhHo+70JQAAm3Uw6q7EAABgs/ZzKfP6RWYAANy4kUcOAFCDMAMAKEKYAQAUIcwAAIoQZgAARdz5nH9jcfE6Xryax19/X8TFv2+MKQBwK929sx3ff3s3dr8br38ONei6jIywp6ezdZABAPBBhtnj3ek61vrqHWZni3/WUfbm7VtDAADwEduj0TrOHuzc6/V4eu0xyyj7/Y8/RRkAwCdkK2UzZTv10Rxml8uXAAC0yXbqsw+/OcwsXwIA9JPt1GdiqynMcpO/jf4AAP1lQ+VNFi2awuz0fGkYAAAGyuvFWjTPmAEAMExrSzWFmctjAQCGa20pr2QCAChCmAEAFCHMAACKEGYAAEU0hdmQl3ACANCvpZrCLN+SDgDAMK0t1RRmP/8wMQwAAAO1tlRTmO3c/casGQDAANlQ2VItmjf/P96dxvbIWQEAgFbZTtlQrZpLKzet9fnDAAC3XbZTn0OUvabAHuzci19++tHMGQDAJ2QrZTNlO/WxdXa+WPV9sPm+p6enMy83BwC4IveU9Z0puzQozC4tLl7Hi1fzdaB50TkAcFtlhGWQ5enL1o3+H/NZYQYAwJdjsxgAQBHCDACgCGEGAFCEMAMAKEKYAQAUIcwAAIoQZgAARQgzAIAihBkAQBHCDACgCGEGAFCEMAMAKEKYAQAUIcwAAIoQZgAARQgzAIAihBkAQBHCDACgCGEGAFCEMAMAKEKYAQAUIcwAAIoQZgAARQgzAIAihBkAQBHCDACgCGEGAFCEMAMAKEKYAQAUIcwAAIoQZgAARQgzAIAihBkAQBHCDACgCGEGAFCEMAMAKEKYAQAUIcwAAIoQZgAARQgzAIAihBkAQBEZZicGAwBg404yzI6NAwDAxh1vnZ0vHkbEM2MBALBRj0bTyfh5RBwZBwCAjTnKJttarVYxmy/vd0uae8YDAOBGnUwn4ydxeSpzOhm/jIh9BwEAAG7USddga++vy8g462rNsiYAwNeXy5dPugmytfVS5lWz+TIPBBx0BWd5EwDgy8gZstw+dtjt8/8gIv4DGWnfdriGm90AAAAASUVORK5CYII=);
  height: 87px;
  margin-left: -1px;
  width: 614px!important;
  z-index: 1;
  position: absolute;
  top: 0;
}

.range {
  position: absolute;
  top: 0;
  z-index: 99;
  width: 614px!important;
}

.range-labels {
  margin: 55px -20px 0 5px;
  padding: 0;
  list-style: none;
  width: 614px!important;
}

.range-labels li {
  position: relative;
  float: left;
  width: 100px;
  text-align: center;
  color: #808093;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.range-labels li::before {
  position: absolute;
  top: -35px;
  right: 0;
  left: 0px;
  content: "";
  margin: 0 auto;
  width: 10px;
  height: 10px;
  background: #E9EEF0;
  border-radius: 50%;
}

.range-labels li:nth-child(1):before {
  position: absolute;
  top: -42px;
  right: 0;
  left: -20px;
  content: "";
  margin: 0 auto;
  width: 35px;
  height: 23px;
  background: #F06C81;
  border-radius: 40%;
}

.range-labels li:nth-child(2):before {
  position: absolute;
  top: -42px;
  right: 0;
  left: -20px;
  content: "";
  margin: 0 auto;
  width: 35px;
  height: 23px;
  background: #F06C81;
  border-radius: 40%;
}

.range-labels li:nth-child(3):before {
  position: absolute;
  top: -42px;
  right: 0;
  left: -20px;
  content: "";
  margin: 0 auto;
  width: 35px;
  height: 23px;
  background: #F06C81;
  border-radius: 40%;
}

.range-labels li:nth-child(4):before {
  position: absolute;
  top: -42px;
  right: 0;
  left: -20px;
  content: "";
  margin: 0 auto;
  width: 35px;
  height: 23px;
  background: #F06C81;
  border-radius: 40%;
}

.range-labels li:nth-child(5):before {
  position: absolute;
  top: -42px;
  right: 0;
  left: -35px;
  content: "";
  margin: 0 auto;
  width: 35px;
  height: 23px;
  background: #F06C81;
  border-radius: 40%;
}

.range-labels li:nth-child(6):before {
  position: absolute;
  top: -42px;
  right: 0;
  left: -50px;
  content: "";
  margin: 0 auto;
  width: 35px;
  height: 23px;
  background: #826AA7;
  border-radius: 40%;
}

.range-labels li::after {
  position: absolute;
  top: -35px;
  right: 0;
  left: 0px;
  content: "";
  margin: 0 auto;
  width: 9px;
  height: 9px;
  background: #E9EEF0;
  border-radius: 50%;
}

input[type=range] {
  -webkit-appearance: none;
  margin: 0px 0 0 30px;
  width: 88%;
  z-index: 9999;
}

input[type=range]:focus {
  outline: none;
}

input[type=range]::-webkit-slider-runnable-track {
  height: 2px;
  background: #E9EEF0;
  width: 100%;
  cursor: pointer;
  animate: 0.2s;
}

input[type=range]::-webkit-slider-thumb {
  position: relative;
  height: 29px;
  width: 29px;
  background: transparent;
  cursor: pointer;
  z-index: 9999;
  -webkit-appearance: none;
  margin-top: -14px;
  background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB0AAAAdCAYAAABWk2cPAAAACXBIWXMAAAsSAAALEgHS3X78AAACeklEQVRIicWXMWgTYRiGv+T+y9WgtlocSrAekmBDS61ZrEtHoZSCg0MHIVNBJDg5hg6S0amEUugU6ODQoYuLY5fWpUZR0pJQLi2hiFitldjL3Rl5691xJrnepfnTvpAld3mfu+///+97E6jX6+RXyUx2jIjwkR0/UYgon0un8n59PKEAhXukl6qmPZREMXDjWl/oeu8V+/rB4RF9/f6jpmpaXRLFt9Vjdc7rAVyhyUxWDvdIyzVNv39HvslityLU33vV1ehX9Td9Kim0rezpIZG9qx6rT3LplOIbmsxkHwlC8PWQPCgl4lEKieKp1XCqpmm0WSjRlrKrGsafmVw6teoJffpq6Zmu6/MP7g4LscGIb1ijirsVWv/w2WCMPV98MbvgCsUbikxYmZoYF04rpV99O/xJb9Y2DE03HjvfOOgAyigp3pAHEIIP/OAL/yYoNg3WsJOSthL8bkcGJPj/B8WxwC7FpumGxkfjBH/znP+D4hziWLSzS9sRfOEPjg3FwR+JyrwYLYVzDg6uMbPjBC6HL7W8ebNQpPdbJd/m94ailIjHmr7HpkJHA4+hl6K1uZnAoJXJWQROef/LGMorO3tpN2Vy5OC50BrEvG7gtaZOAapgPLmJ55qaHAXlzWMecnH1kMnJBzFwMYDRnLsp+IMD3smaYuIXy5Xp/tHmRs9rTYvlygmHrI2EiLGt7E0m4tGmVshjTTHYkSh0w5gjqw3ilRExMPG7oY2PBYK/lZ3sc4pMg4iBic9T8Nup7Kvwt2xtKEIUMg0iBq9NBR/4mVnJDmkXn5EsdZoGsYYoqe806AC3lXtRShyLM+feBvj5JXy3B+j4vwwR/QWs5oN+Ncbm9gAAAABJRU5ErkJggg==);
}

input[type=range]::-ms-track {
  position: absolute;
  width: 100%;
  height: 2px;
  cursor: pointer;
  animate: 0.2s;
  margin-top: -10px;
  background: transparent;
  border-color: transparent;
  border-width: 16px 0;
  color: transparent;
}

input[type=range]::-ms-fill-lower {
  background: #E9EEF0;
  border: 0.2px solid#E9EEF0;
  border-radius: 2.6px;
  box-shadow: 1px 1px 1px #E9EEF0, 0px 0px 1px #E9EEF0;
}

input[type=range]::-ms-fill-upper {
  background: #E9EEF0;
  border: 0.2px solid #E9EEF0;
  border-radius: 2.6px;
  box-shadow: 1px 1px 1px #E9EEF0, 0px 0px 1px #E9EEF0;
}

input[type=range]::-ms-thumb {
  position: absolute;
  z-index: 99999;
  border: transparent;
  height: 29px;
  width: 29px;
  background: transparent;
  cursor: pointer;
  background-image: url("../parts/icons/handle.png");
}

input[type=range]:focus::-ms-fill-lower {
  background: #E9EEF0;
}

input[type=range]:focus::-ms-fill-upper {
  background: #E9EEF0;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="areaDetail_graph_04">
  <div class="img">
    <div class="range">
      <input type="range" class="slider" width="614px" value="0" min="0" max="5" id="rangeSlider">
    </div>
    <ul class="range-labels">
      <li>11:00</li>
      <li>12:00</li>
      <li>13:00</li>
      <li>14:00</li>
      <li>15:00</li>
      <li>16:00</li>

    </ul>
    <span id="valBox"></span>
  </div>
</div></code>```

答:
Do you mean the white circle is behind the white line?

You could try adding "margin-bottom: -15px;" to
"input[type=range]::-webkit-slider-runnable-track";

In addition, you'd better change the position of the circles inside li(5) and li (6).

use "left: -20px;"both in "li:nth-child(5)" and "li:nth-child(6)".

The complete code is as follows:

/*Slider*/

.areaDetail_graph_04 {
  height: 87px;
  width: 614px!important;
  position: relative;

  /* background-color: rgba(255,255,255,0.5); */
  /* border-radius: 8px 8px 8px 8px; */
}

.areaDetail_graph_04 .img {
  background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAmYAAABXCAYAAACulYmrAAAACXBIWXMAAAsSAAALEgHS3X78AAADzklEQVR4nO3dT25TVxTA4ROHCuq4LaZS1M5AQuowLCE7apbQJSQ7yhYyrIQEM6pIjaGx3UYUXB3zAlWC0H0PiI+U75tkEsfRu5Of7r+3tVqt4qrZfPkwIg4iYj8i9q79AgAAQ5xExHFEHE4n4+dXP38tzGbz5WFE/OpRAwB8VUfTyfjg/1/wPsxm8+X9ruDMkAEA3IycQdufTsYv89tGIcoAADYl2+u4a7F3YRYRv4kyAICN2OtaLLbOzhe50f+ZcQAA2KhHo+70JQAAm3Uw6q7EAABgs/ZzKfP6RWYAANy4kUcOAFCDMAMAKEKYAQAUIcwAAIoQZgAARdz5nH9jcfE6Xryax19/X8TFv2+MKQBwK929sx3ff3s3dr8br38ONei6jIywp6ezdZABAPBBhtnj3ek61vrqHWZni3/WUfbm7VtDAADwEduj0TrOHuzc6/V4eu0xyyj7/Y8/RRkAwCdkK2UzZTv10Rxml8uXAAC0yXbqsw+/OcwsXwIA9JPt1GdiqynMcpO/jf4AAP1lQ+VNFi2awuz0fGkYAAAGyuvFWjTPmAEAMExrSzWFmctjAQCGa20pr2QCAChCmAEAFCHMAACKEGYAAEU0hdmQl3ACANCvpZrCLN+SDgDAMK0t1RRmP/8wMQwAAAO1tlRTmO3c/casGQDAANlQ2VItmjf/P96dxvbIWQEAgFbZTtlQrZpLKzet9fnDAAC3XbZTn0OUvabAHuzci19++tHMGQDAJ2QrZTNlO/WxdXa+WPV9sPm+p6enMy83BwC4IveU9Z0puzQozC4tLl7Hi1fzdaB50TkAcFtlhGWQ5enL1o3+H/NZYQYAwJdjsxgAQBHCDACgCGEGAFCEMAMAKEKYAQAUIcwAAIoQZgAARQgzAIAihBkAQBHCDACgCGEGAFCEMAMAKEKYAQAUIcwAAIoQZgAARQgzAIAihBkAQBHCDACgCGEGAFCEMAMAKEKYAQAUIcwAAIoQZgAARQgzAIAihBkAQBHCDACgCGEGAFCEMAMAKEKYAQAUIcwAAIoQZgAARQgzAIAihBkAQBHCDACgCGEGAFCEMAMAKEKYAQAUIcwAAIoQZgAARQgzAIAihBkAQBEZZicGAwBg404yzI6NAwDAxh1vnZ0vHkbEM2MBALBRj0bTyfh5RBwZBwCAjTnKJttarVYxmy/vd0uae8YDAOBGnUwn4ydxeSpzOhm/jIh9BwEAAG7USddga++vy8g462rNsiYAwNeXy5dPugmytfVS5lWz+TIPBBx0BWd5EwDgy8gZstw+dtjt8/8gIv4DGWnfdriGm90AAAAASUVORK5CYII=);
  height: 87px;
  margin-left: -1px;
  width: 614px!important;
  z-index: 1;
  position: absolute;
  top: 0;

}

.range {
  position: absolute;
  top: 0;
  z-index: 99;
  width: 614px!important;
}

.range-labels {
  margin: 55px -20px 0 5px;
  padding: 0px;
  list-style: none;
  width: 614px!important;
}

.range-labels li {
  position: relative;
  float: left;
  width: 100px;
  text-align: center;
  color: #808093;

  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.range-labels li::before {
  position: absolute;
  top: -35px;
  right: 0;
  left: 0px;
  content: "";
  margin: 0 auto;
  width: 10px;
  height: 10px;
  background: #E9EEF0;

  border-radius: 50%;
}

.range-labels li:nth-child(1):before {
  position: absolute;
  top: -42px;
  right: 0;
  left: -10px;
  content: "";
  margin: 0 auto;
  width: 35px;
  height: 23px;
  background: #F06C81;
  border-radius: 40%;
}

.range-labels li:nth-child(2):before {
  position: absolute;
  top: -42px;
  right: 0;
  left: -10px;
  content: "";
  margin: 0 auto;
  width: 35px;
  height: 23px;
  background: #F06C81;
  border-radius: 40%;
}

.range-labels li:nth-child(3):before {
  position: absolute;
  top: -42px;
  right: 0;
  left: -4px;
  content: "";
  margin: 0 auto;
  width: 35px;
  height: 23px;
  background: #F06C81;
  border-radius: 40%;
}

.range-labels li:nth-child(4):before {
  position: absolute;
  top: -42px;
  right: 0;
  left: 0px;
  content: "";
  margin: 0 auto;
  width: 35px;
  height: 23px;
  background: #F06C81;
  border-radius: 40%;
}

.range-labels li:nth-child(5):before {
  position: absolute;
  top: -42px;
  right: 0;
  /*left: -35px;*/
  left: 6px;

  content: "";
  margin: 0 auto;
  width: 35px;
  height: 23px;
  background: #F06C81;
  border-radius: 40%;
}

.range-labels li:nth-child(6):before {
  position: absolute;
  top: -42px;
  right: 0;
  /*left: -50px;*/
  left: 8px;

  content: "";
  margin: 0 auto;
  width: 35px;
  height: 23px;
  background: #826AA7;
  border-radius: 40%;
}

/*White circle01*/
.range-labels li:nth-child(1):after {

  left: -6px;

}

/*White circle02*/
.range-labels li:nth-child(2):after {

  left: -10px;

}

/*White circle03*/
.range-labels li:nth-child(3):after {

  left: -1px;

}

/*White circle04*/
.range-labels li:nth-child(4):after {

  left: 0px;

}
/*White circle05*/
.range-labels li:nth-child(5):after {

  left: 7px;

}
/*White circle06*/
.range-labels li:nth-child(6):after {

  left: 10px;

}

/*White circle*/
.range-labels li::after {
  position: absolute;
  top: -35px;
  right: 0px;
  /*left: 0px;*/
  content: "";
  margin: 0px auto;

  width: 9px;
  height: 9px;
  background: #E9EEF0;

  border-radius: 50%;
}

input[type=range] {
  -webkit-appearance: none;
  margin: -10px 0px 0px 35px;
  width: 88%;
  z-index: 9999;

}

input[type=range]:focus {
  outline: none;

}

input[type=range]::-webkit-slider-runnable-track {
  height: 2px;

  background: #E9EEF0;

  width:100%;
  margin-bottom: -15px;    /*add*/
  /*margin-right: -5px;*/

  cursor: pointer;
  animate: 0.2s;

}

input[type=range]::-webkit-slider-thumb {
  position: relative;
  height: 29px;
  width: 29px;
  background: transparent;
  cursor: pointer;
  z-index: 9999;
  -webkit-appearance: none;
  margin-top: -14px;
  background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB0AAAAdCAYAAABWk2cPAAAACXBIWXMAAAsSAAALEgHS3X78AAACeklEQVRIicWXMWgTYRiGv+T+y9WgtlocSrAekmBDS61ZrEtHoZSCg0MHIVNBJDg5hg6S0amEUugU6ODQoYuLY5fWpUZR0pJQLi2hiFitldjL3Rl5691xJrnepfnTvpAld3mfu+///+97E6jX6+RXyUx2jIjwkR0/UYgon0un8n59PKEAhXukl6qmPZREMXDjWl/oeu8V+/rB4RF9/f6jpmpaXRLFt9Vjdc7rAVyhyUxWDvdIyzVNv39HvslityLU33vV1ehX9Td9Kim0rezpIZG9qx6rT3LplOIbmsxkHwlC8PWQPCgl4lEKieKp1XCqpmm0WSjRlrKrGsafmVw6teoJffpq6Zmu6/MP7g4LscGIb1ijirsVWv/w2WCMPV98MbvgCsUbikxYmZoYF04rpV99O/xJb9Y2DE03HjvfOOgAyigp3pAHEIIP/OAL/yYoNg3WsJOSthL8bkcGJPj/B8WxwC7FpumGxkfjBH/znP+D4hziWLSzS9sRfOEPjg3FwR+JyrwYLYVzDg6uMbPjBC6HL7W8ebNQpPdbJd/m94ailIjHmr7HpkJHA4+hl6K1uZnAoJXJWQROef/LGMorO3tpN2Vy5OC50BrEvG7gtaZOAapgPLmJ55qaHAXlzWMecnH1kMnJBzFwMYDRnLsp+IMD3smaYuIXy5Xp/tHmRs9rTYvlygmHrI2EiLGt7E0m4tGmVshjTTHYkSh0w5gjqw3ilRExMPG7oY2PBYK/lZ3sc4pMg4iBic9T8Nup7Kvwt2xtKEIUMg0iBq9NBR/4mVnJDmkXn5EsdZoGsYYoqe806AC3lXtRShyLM+feBvj5JXy3B+j4vwwR/QWs5oN+Ncbm9gAAAABJRU5ErkJggg==);

}

input[type=range]::-ms-track {
  position: absolute;
  width: 100%;
  height: 2px;
  cursor: pointer;
  animate: 0.2s;
  margin-top: -10px;
  background: transparent;
  border-color: transparent;
  border-width: 16px 0;
  color: transparent;
}

input[type=range]::-ms-fill-lower {
  background: #E9EEF0;

  border: 0.2px solid#E9EEF0;

  border-radius: 2.6px;
  box-shadow: 1px 1px 1px #E9EEF0, 0px 0px 1px #E9EEF0;
}

input[type=range]::-ms-fill-upper {
  background: #E9EEF0;

  border: 0.2px solid #E9EEF0;
  border-radius: 2.6px;
  box-shadow: 1px 1px 1px #E9EEF0, 0px 0px 1px #E9EEF0;
}

input[type=range]::-ms-thumb {
  position: absolute;
  z-index: 99999;
  border: transparent;
  height: 29px;
  width: 29px;
  background: transparent;
  cursor: pointer;
  background-image: url("../parts/icons/handle.png");
}

input[type=range]:focus::-ms-fill-lower {
  background: #E9EEF0;

}

input[type=range]:focus::-ms-fill-upper {
 background: #E9EEF0;

}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="areaDetail_graph_04">
    <div class="img">
      <div class="range">
       <input type="range" class="slider" width="614px" value="0" min="0" max="5" id="rangeSlider">

      </div>
      <ul class="range-labels">
        <li>11:00</li>
        <li>12:00</li>
        <li>13:00</li>
        <li>14:00</li>
        <li>15:00</li>
        <li>16:00</li>

      </ul>
      <span id="valBox"></span>
    </div>
  </div></code>```

Body:
Creating a custom slider which should be supporting Chrome and IE11.
Facing issues positioning the thumb and elements(White circle and red oval) on the slider track.
The white circles should be connected with a line.

Here is the fiddle of what i have achieved.

https://jsfiddle.net/Pravin_it14/7t9bsrdn/7/

/*Slider*/

.areaDetail_graph_04 {
  height: 87px;
  width: 614px!important;
  position: relative;
  /* background-color: rgba(255,255,255,0.5); */
  /* border-radius: 8px 8px 8px 8px; */
}

.areaDetail_graph_04 .img {
  background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAmYAAABXCAYAAACulYmrAAAACXBIWXMAAAsSAAALEgHS3X78AAADzklEQVR4nO3dT25TVxTA4ROHCuq4LaZS1M5AQuowLCE7apbQJSQ7yhYyrIQEM6pIjaGx3UYUXB3zAlWC0H0PiI+U75tkEsfRu5Of7r+3tVqt4qrZfPkwIg4iYj8i9q79AgAAQ5xExHFEHE4n4+dXP38tzGbz5WFE/OpRAwB8VUfTyfjg/1/wPsxm8+X9ruDMkAEA3IycQdufTsYv89tGIcoAADYl2+u4a7F3YRYRv4kyAICN2OtaLLbOzhe50f+ZcQAA2KhHo+70JQAAm3Uw6q7EAABgs/ZzKfP6RWYAANy4kUcOAFCDMAMAKEKYAQAUIcwAAIoQZgAARdz5nH9jcfE6Xryax19/X8TFv2+MKQBwK929sx3ff3s3dr8br38ONei6jIywp6ezdZABAPBBhtnj3ek61vrqHWZni3/WUfbm7VtDAADwEduj0TrOHuzc6/V4eu0xyyj7/Y8/RRkAwCdkK2UzZTv10Rxml8uXAAC0yXbqsw+/OcwsXwIA9JPt1GdiqynMcpO/jf4AAP1lQ+VNFi2awuz0fGkYAAAGyuvFWjTPmAEAMExrSzWFmctjAQCGa20pr2QCAChCmAEAFCHMAACKEGYAAEU0hdmQl3ACANCvpZrCLN+SDgDAMK0t1RRmP/8wMQwAAAO1tlRTmO3c/casGQDAANlQ2VItmjf/P96dxvbIWQEAgFbZTtlQrZpLKzet9fnDAAC3XbZTn0OUvabAHuzci19++tHMGQDAJ2QrZTNlO/WxdXa+WPV9sPm+p6enMy83BwC4IveU9Z0puzQozC4tLl7Hi1fzdaB50TkAcFtlhGWQ5enL1o3+H/NZYQYAwJdjsxgAQBHCDACgCGEGAFCEMAMAKEKYAQAUIcwAAIoQZgAARQgzAIAihBkAQBHCDACgCGEGAFCEMAMAKEKYAQAUIcwAAIoQZgAARQgzAIAihBkAQBHCDACgCGEGAFCEMAMAKEKYAQAUIcwAAIoQZgAARQgzAIAihBkAQBHCDACgCGEGAFCEMAMAKEKYAQAUIcwAAIoQZgAARQgzAIAihBkAQBHCDACgCGEGAFCEMAMAKEKYAQAUIcwAAIoQZgAARQgzAIAihBkAQBEZZicGAwBg404yzI6NAwDAxh1vnZ0vHkbEM2MBALBRj0bTyfh5RBwZBwCAjTnKJttarVYxmy/vd0uae8YDAOBGnUwn4ydxeSpzOhm/jIh9BwEAAG7USddga++vy8g462rNsiYAwNeXy5dPugmytfVS5lWz+TIPBBx0BWd5EwDgy8gZstw+dtjt8/8gIv4DGWnfdriGm90AAAAASUVORK5CYII=);
  height: 87px;
  margin-left: -1px;
  width: 614px!important;
  z-index: 1;
  position: absolute;
  top: 0;
}

.range {
  position: absolute;
  top: 0;
  z-index: 99;
  width: 614px!important;
}

.range-labels {
  margin: 55px -20px 0 5px;
  padding: 0;
  list-style: none;
  width: 614px!important;
}

.range-labels li {
  position: relative;
  float: left;
  width: 100px;
  text-align: center;
  color: #808093;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.range-labels li::before {
  position: absolute;
  top: -35px;
  right: 0;
  left: 0px;
  content: "";
  margin: 0 auto;
  width: 10px;
  height: 10px;
  background: #E9EEF0;
  border-radius: 50%;
}

.range-labels li:nth-child(1):before {
  position: absolute;
  top: -42px;
  right: 0;
  left: -20px;
  content: "";
  margin: 0 auto;
  width: 35px;
  height: 23px;
  background: #F06C81;
  border-radius: 40%;
}

.range-labels li:nth-child(2):before {
  position: absolute;
  top: -42px;
  right: 0;
  left: -20px;
  content: "";
  margin: 0 auto;
  width: 35px;
  height: 23px;
  background: #F06C81;
  border-radius: 40%;
}

.range-labels li:nth-child(3):before {
  position: absolute;
  top: -42px;
  right: 0;
  left: -20px;
  content: "";
  margin: 0 auto;
  width: 35px;
  height: 23px;
  background: #F06C81;
  border-radius: 40%;
}

.range-labels li:nth-child(4):before {
  position: absolute;
  top: -42px;
  right: 0;
  left: -20px;
  content: "";
  margin: 0 auto;
  width: 35px;
  height: 23px;
  background: #F06C81;
  border-radius: 40%;
}

.range-labels li:nth-child(5):before {
  position: absolute;
  top: -42px;
  right: 0;
  left: -35px;
  content: "";
  margin: 0 auto;
  width: 35px;
  height: 23px;
  background: #F06C81;
  border-radius: 40%;
}

.range-labels li:nth-child(6):before {
  position: absolute;
  top: -42px;
  right: 0;
  left: -50px;
  content: "";
  margin: 0 auto;
  width: 35px;
  height: 23px;
  background: #826AA7;
  border-radius: 40%;
}

.range-labels li::after {
  position: absolute;
  top: -35px;
  right: 0;
  left: 0px;
  content: "";
  margin: 0 auto;
  width: 9px;
  height: 9px;
  background: #E9EEF0;
  border-radius: 50%;
}

input[type=range] {
  -webkit-appearance: none;
  margin: 0px 0 0 30px;
  width: 88%;
  z-index: 9999;
}

input[type=range]:focus {
  outline: none;
}

input[type=range]::-webkit-slider-runnable-track {
  height: 2px;
  background: #E9EEF0;
  width: 100%;
  cursor: pointer;
  animate: 0.2s;
}

input[type=range]::-webkit-slider-thumb {
  position: relative;
  height: 29px;
  width: 29px;
  background: transparent;
  cursor: pointer;
  z-index: 9999;
  -webkit-appearance: none;
  margin-top: -14px;
  background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB0AAAAdCAYAAABWk2cPAAAACXBIWXMAAAsSAAALEgHS3X78AAACeklEQVRIicWXMWgTYRiGv+T+y9WgtlocSrAekmBDS61ZrEtHoZSCg0MHIVNBJDg5hg6S0amEUugU6ODQoYuLY5fWpUZR0pJQLi2hiFitldjL3Rl5691xJrnepfnTvpAld3mfu+///+97E6jX6+RXyUx2jIjwkR0/UYgon0un8n59PKEAhXukl6qmPZREMXDjWl/oeu8V+/rB4RF9/f6jpmpaXRLFt9Vjdc7rAVyhyUxWDvdIyzVNv39HvslityLU33vV1ehX9Td9Kim0rezpIZG9qx6rT3LplOIbmsxkHwlC8PWQPCgl4lEKieKp1XCqpmm0WSjRlrKrGsafmVw6teoJffpq6Zmu6/MP7g4LscGIb1ijirsVWv/w2WCMPV98MbvgCsUbikxYmZoYF04rpV99O/xJb9Y2DE03HjvfOOgAyigp3pAHEIIP/OAL/yYoNg3WsJOSthL8bkcGJPj/B8WxwC7FpumGxkfjBH/znP+D4hziWLSzS9sRfOEPjg3FwR+JyrwYLYVzDg6uMbPjBC6HL7W8ebNQpPdbJd/m94ailIjHmr7HpkJHA4+hl6K1uZnAoJXJWQROef/LGMorO3tpN2Vy5OC50BrEvG7gtaZOAapgPLmJ55qaHAXlzWMecnH1kMnJBzFwMYDRnLsp+IMD3smaYuIXy5Xp/tHmRs9rTYvlygmHrI2EiLGt7E0m4tGmVshjTTHYkSh0w5gjqw3ilRExMPG7oY2PBYK/lZ3sc4pMg4iBic9T8Nup7Kvwt2xtKEIUMg0iBq9NBR/4mVnJDmkXn5EsdZoGsYYoqe806AC3lXtRShyLM+feBvj5JXy3B+j4vwwR/QWs5oN+Ncbm9gAAAABJRU5ErkJggg==);
}

input[type=range]::-ms-track {
  position: absolute;
  width: 100%;
  height: 2px;
  cursor: pointer;
  animate: 0.2s;
  margin-top: -10px;
  background: transparent;
  border-color: transparent;
  border-width: 16px 0;
  color: transparent;
}

input[type=range]::-ms-fill-lower {
  background: #E9EEF0;
  border: 0.2px solid#E9EEF0;
  border-radius: 2.6px;
  box-shadow: 1px 1px 1px #E9EEF0, 0px 0px 1px #E9EEF0;
}

input[type=range]::-ms-fill-upper {
  background: #E9EEF0;
  border: 0.2px solid #E9EEF0;
  border-radius: 2.6px;
  box-shadow: 1px 1px 1px #E9EEF0, 0px 0px 1px #E9EEF0;
}

input[type=range]::-ms-thumb {
  position: absolute;
  z-index: 99999;
  border: transparent;
  height: 29px;
  width: 29px;
  background: transparent;
  cursor: pointer;
  background-image: url("../parts/icons/handle.png");
}

input[type=range]:focus::-ms-fill-lower {
  background: #E9EEF0;
}

input[type=range]:focus::-ms-fill-upper {
  background: #E9EEF0;
}

      <input type="range" class="slider" width="614px" value="0" min="0" max="5" id="rangeSlider">

11:00

12:00

13:00

14:00

15:00

16:00

Body:
Do you mean the white circle is behind the white line?

You could try adding "margin-bottom: -15px;" to
"input[type=range]::-webkit-slider-runnable-track";

In addition, you'd better change the position of the circles inside li(5) and li (6).

use "left: -20px;"both in "li:nth-child(5)" and "li:nth-child(6)".

The complete code is as follows:

/*Slider*/

.areaDetail_graph_04 {
  height: 87px;
  width: 614px!important;
  position: relative;

  /* background-color: rgba(255,255,255,0.5); */
  /* border-radius: 8px 8px 8px 8px; */
}

.areaDetail_graph_04 .img {
  background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAmYAAABXCAYAAACulYmrAAAACXBIWXMAAAsSAAALEgHS3X78AAADzklEQVR4nO3dT25TVxTA4ROHCuq4LaZS1M5AQuowLCE7apbQJSQ7yhYyrIQEM6pIjaGx3UYUXB3zAlWC0H0PiI+U75tkEsfRu5Of7r+3tVqt4qrZfPkwIg4iYj8i9q79AgAAQ5xExHFEHE4n4+dXP38tzGbz5WFE/OpRAwB8VUfTyfjg/1/wPsxm8+X9ruDMkAEA3IycQdufTsYv89tGIcoAADYl2+u4a7F3YRYRv4kyAICN2OtaLLbOzhe50f+ZcQAA2KhHo+70JQAAm3Uw6q7EAABgs/ZzKfP6RWYAANy4kUcOAFCDMAMAKEKYAQAUIcwAAIoQZgAARdz5nH9jcfE6Xryax19/X8TFv2+MKQBwK929sx3ff3s3dr8br38ONei6jIywp6ezdZABAPBBhtnj3ek61vrqHWZni3/WUfbm7VtDAADwEduj0TrOHuzc6/V4eu0xyyj7/Y8/RRkAwCdkK2UzZTv10Rxml8uXAAC0yXbqsw+/OcwsXwIA9JPt1GdiqynMcpO/jf4AAP1lQ+VNFi2awuz0fGkYAAAGyuvFWjTPmAEAMExrSzWFmctjAQCGa20pr2QCAChCmAEAFCHMAACKEGYAAEU0hdmQl3ACANCvpZrCLN+SDgDAMK0t1RRmP/8wMQwAAAO1tlRTmO3c/casGQDAANlQ2VItmjf/P96dxvbIWQEAgFbZTtlQrZpLKzet9fnDAAC3XbZTn0OUvabAHuzci19++tHMGQDAJ2QrZTNlO/WxdXa+WPV9sPm+p6enMy83BwC4IveU9Z0puzQozC4tLl7Hi1fzdaB50TkAcFtlhGWQ5enL1o3+H/NZYQYAwJdjsxgAQBHCDACgCGEGAFCEMAMAKEKYAQAUIcwAAIoQZgAARQgzAIAihBkAQBHCDACgCGEGAFCEMAMAKEKYAQAUIcwAAIoQZgAARQgzAIAihBkAQBHCDACgCGEGAFCEMAMAKEKYAQAUIcwAAIoQZgAARQgzAIAihBkAQBHCDACgCGEGAFCEMAMAKEKYAQAUIcwAAIoQZgAARQgzAIAihBkAQBHCDACgCGEGAFCEMAMAKEKYAQAUIcwAAIoQZgAARQgzAIAihBkAQBEZZicGAwBg404yzI6NAwDAxh1vnZ0vHkbEM2MBALBRj0bTyfh5RBwZBwCAjTnKJttarVYxmy/vd0uae8YDAOBGnUwn4ydxeSpzOhm/jIh9BwEAAG7USddga++vy8g462rNsiYAwNeXy5dPugmytfVS5lWz+TIPBBx0BWd5EwDgy8gZstw+dtjt8/8gIv4DGWnfdriGm90AAAAASUVORK5CYII=);
  height: 87px;
  margin-left: -1px;
  width: 614px!important;
  z-index: 1;
  position: absolute;
  top: 0;

}

.range {
  position: absolute;
  top: 0;
  z-index: 99;
  width: 614px!important;
}

.range-labels {
  margin: 55px -20px 0 5px;
  padding: 0px;
  list-style: none;
  width: 614px!important;
}

.range-labels li {
  position: relative;
  float: left;
  width: 100px;
  text-align: center;
  color: #808093;

  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.range-labels li::before {
  position: absolute;
  top: -35px;
  right: 0;
  left: 0px;
  content: "";
  margin: 0 auto;
  width: 10px;
  height: 10px;
  background: #E9EEF0;

  border-radius: 50%;
}

.range-labels li:nth-child(1):before {
  position: absolute;
  top: -42px;
  right: 0;
  left: -10px;
  content: "";
  margin: 0 auto;
  width: 35px;
  height: 23px;
  background: #F06C81;
  border-radius: 40%;
}

.range-labels li:nth-child(2):before {
  position: absolute;
  top: -42px;
  right: 0;
  left: -10px;
  content: "";
  margin: 0 auto;
  width: 35px;
  height: 23px;
  background: #F06C81;
  border-radius: 40%;
}

.range-labels li:nth-child(3):before {
  position: absolute;
  top: -42px;
  right: 0;
  left: -4px;
  content: "";
  margin: 0 auto;
  width: 35px;
  height: 23px;
  background: #F06C81;
  border-radius: 40%;
}

.range-labels li:nth-child(4):before {
  position: absolute;
  top: -42px;
  right: 0;
  left: 0px;
  content: "";
  margin: 0 auto;
  width: 35px;
  height: 23px;
  background: #F06C81;
  border-radius: 40%;
}

.range-labels li:nth-child(5):before {
  position: absolute;
  top: -42px;
  right: 0;
  /*left: -35px;*/
  left: 6px;

  content: "";
  margin: 0 auto;
  width: 35px;
  height: 23px;
  background: #F06C81;
  border-radius: 40%;
}

.range-labels li:nth-child(6):before {
  position: absolute;
  top: -42px;
  right: 0;
  /*left: -50px;*/
  left: 8px;

  content: "";
  margin: 0 auto;
  width: 35px;
  height: 23px;
  background: #826AA7;
  border-radius: 40%;
}

/*White circle01*/
.range-labels li:nth-child(1):after {

  left: -6px;

}

/*White circle02*/
.range-labels li:nth-child(2):after {

  left: -10px;

}

/*White circle03*/
.range-labels li:nth-child(3):after {

  left: -1px;

}

/*White circle04*/
.range-labels li:nth-child(4):after {

  left: 0px;

}
/*White circle05*/
.range-labels li:nth-child(5):after {

  left: 7px;

}
/*White circle06*/
.range-labels li:nth-child(6):after {

  left: 10px;

}

/*White circle*/
.range-labels li::after {
  position: absolute;
  top: -35px;
  right: 0px;
  /*left: 0px;*/
  content: "";
  margin: 0px auto;

  width: 9px;
  height: 9px;
  background: #E9EEF0;

  border-radius: 50%;
}

input[type=range] {
  -webkit-appearance: none;
  margin: -10px 0px 0px 35px;
  width: 88%;
  z-index: 9999;

}

input[type=range]:focus {
  outline: none;

}

input[type=range]::-webkit-slider-runnable-track {
  height: 2px;

  background: #E9EEF0;

  width:100%;
  margin-bottom: -15px;    /*add*/
  /*margin-right: -5px;*/

  cursor: pointer;
  animate: 0.2s;

}

input[type=range]::-webkit-slider-thumb {
  position: relative;
  height: 29px;
  width: 29px;
  background: transparent;
  cursor: pointer;
  z-index: 9999;
  -webkit-appearance: none;
  margin-top: -14px;
  background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB0AAAAdCAYAAABWk2cPAAAACXBIWXMAAAsSAAALEgHS3X78AAACeklEQVRIicWXMWgTYRiGv+T+y9WgtlocSrAekmBDS61ZrEtHoZSCg0MHIVNBJDg5hg6S0amEUugU6ODQoYuLY5fWpUZR0pJQLi2hiFitldjL3Rl5691xJrnepfnTvpAld3mfu+///+97E6jX6+RXyUx2jIjwkR0/UYgon0un8n59PKEAhXukl6qmPZREMXDjWl/oeu8V+/rB4RF9/f6jpmpaXRLFt9Vjdc7rAVyhyUxWDvdIyzVNv39HvslityLU33vV1ehX9Td9Kim0rezpIZG9qx6rT3LplOIbmsxkHwlC8PWQPCgl4lEKieKp1XCqpmm0WSjRlrKrGsafmVw6teoJffpq6Zmu6/MP7g4LscGIb1ijirsVWv/w2WCMPV98MbvgCsUbikxYmZoYF04rpV99O/xJb9Y2DE03HjvfOOgAyigp3pAHEIIP/OAL/yYoNg3WsJOSthL8bkcGJPj/B8WxwC7FpumGxkfjBH/znP+D4hziWLSzS9sRfOEPjg3FwR+JyrwYLYVzDg6uMbPjBC6HL7W8ebNQpPdbJd/m94ailIjHmr7HpkJHA4+hl6K1uZnAoJXJWQROef/LGMorO3tpN2Vy5OC50BrEvG7gtaZOAapgPLmJ55qaHAXlzWMecnH1kMnJBzFwMYDRnLsp+IMD3smaYuIXy5Xp/tHmRs9rTYvlygmHrI2EiLGt7E0m4tGmVshjTTHYkSh0w5gjqw3ilRExMPG7oY2PBYK/lZ3sc4pMg4iBic9T8Nup7Kvwt2xtKEIUMg0iBq9NBR/4mVnJDmkXn5EsdZoGsYYoqe806AC3lXtRShyLM+feBvj5JXy3B+j4vwwR/QWs5oN+Ncbm9gAAAABJRU5ErkJggg==);

}

input[type=range]::-ms-track {
  position: absolute;
  width: 100%;
  height: 2px;
  cursor: pointer;
  animate: 0.2s;
  margin-top: -10px;
  background: transparent;
  border-color: transparent;
  border-width: 16px 0;
  color: transparent;
}

input[type=range]::-ms-fill-lower {
  background: #E9EEF0;

  border: 0.2px solid#E9EEF0;

  border-radius: 2.6px;
  box-shadow: 1px 1px 1px #E9EEF0, 0px 0px 1px #E9EEF0;
}

input[type=range]::-ms-fill-upper {
  background: #E9EEF0;

  border: 0.2px solid #E9EEF0;
  border-radius: 2.6px;
  box-shadow: 1px 1px 1px #E9EEF0, 0px 0px 1px #E9EEF0;
}

input[type=range]::-ms-thumb {
  position: absolute;
  z-index: 99999;
  border: transparent;
  height: 29px;
  width: 29px;
  background: transparent;
  cursor: pointer;
  background-image: url("../parts/icons/handle.png");
}

input[type=range]:focus::-ms-fill-lower {
  background: #E9EEF0;

}

input[type=range]:focus::-ms-fill-upper {
 background: #E9EEF0;

}

<div class="areaDetail_graph_04">
    <div class="img">
      <div class="range">
       <input type="range" class="slider" width="614px" value="0" min="0" max="5" id="rangeSlider">

      </div>
      <ul class="range-labels">
        <li>11:00</li>
        <li>12:00</li>
        <li>13:00</li>
        <li>14:00</li>
        <li>15:00</li>
        <li>16:00</li>

      </ul>
      <span id="valBox"></span>
    </div>
  </div>


问:
Flask in Docker unable to detect FLASK_ENV
I built a flask app and launch it in docker with the Dockerfile as below.

```<code>FROM python:3.7

COPY requirements.txt .
RUN pip install -r requirements.txt

COPY . .
WORKDIR /app

CMD export FLASK_ENV=production
ENTRYPOINT [ "python", "-u", "app.py" ]
</code>```

In the flask app, I specified some configuration for development & production

```<code>if os.environ['FLASK_ENV'] == 'production':
    UPLOAD_URL = '/v1/path/to/production/server'
elif os.environ['FLASK_ENV'] == 'development':
    UPLOAD_URL = '/upload'
</code>```

However, launching the script caused an error, where the container cannot detect the FLASK_ENV, even though the command was set in the Dockerfile. Can anyone help?

```<code>Traceback (most recent call last):
  File "app.py", line 14, in <module>
    import config
  File "/app/config.py", line 14, in <module>
    if os.environ['FLASK_ENV'] == 'production':
  File "/usr/local/lib/python3.7/os.py", line 681, in __getitem__
    raise KeyError(key) from None
KeyError: 'FLASK_ENV'
</code>```

答:
When you run the resulting image, ENTRYPOINT and CMD are combined into a single command.  The CMD you describe will be wrapped in sh -c and then passed as command-line arguments to the program you name as the ENTRYPOINT.

(In your application, try printing out sys.argv.  You should see this contain ["app.py", "/bin/sh", "-c", "export ..."].)

If you want to set an environment variable for the image, you need the Dockerfile ENV directive.  (You cannot for example RUN export ...; any variables you set this way will be lost at the end of the RUN line.)

```<code>ENV FLASK_ENV=production
CMD ["python", "-u", "app.py"]
</code>```

Body:
I built a flask app and launch it in docker with the Dockerfile as below.

FROM python:3.7

COPY requirements.txt .
RUN pip install -r requirements.txt

COPY . .
WORKDIR /app

CMD export FLASK_ENV=production
ENTRYPOINT [ "python", "-u", "app.py" ]

In the flask app, I specified some configuration for development & production

if os.environ['FLASK_ENV'] == 'production':
    UPLOAD_URL = '/v1/path/to/production/server'
elif os.environ['FLASK_ENV'] == 'development':
    UPLOAD_URL = '/upload'

However, launching the script caused an error, where the container cannot detect the FLASK_ENV, even though the command was set in the Dockerfile. Can anyone help?

Traceback (most recent call last):
  File "app.py", line 14, in <module>
    import config
  File "/app/config.py", line 14, in <module>
    if os.environ['FLASK_ENV'] == 'production':
  File "/usr/local/lib/python3.7/os.py", line 681, in __getitem__
    raise KeyError(key) from None
KeyError: 'FLASK_ENV'

Body:
When you run the resulting image, ENTRYPOINT and CMD are combined into a single command.  The CMD you describe will be wrapped in sh -c and then passed as command-line arguments to the program you name as the ENTRYPOINT.

(In your application, try printing out sys.argv.  You should see this contain ["app.py", "/bin/sh", "-c", "export ..."].)

If you want to set an environment variable for the image, you need the Dockerfile ENV directive.  (You cannot for example RUN export ...; any variables you set this way will be lost at the end of the RUN line.)

ENV FLASK_ENV=production
CMD ["python", "-u", "app.py"]


问:
Can't retrieve metadata for Blob in azure storage blob with java
I am using java api for azure as described here https://learn.microsoft.com/en-us/java/api/overview/azure/storage?view=azure-java-stable

In the code sample below i am able to retrieve blob content from the BlobItem object with exception of "metadata" which returns null despite the fact that i have added metadata manually to the blob in azure portal.

```<code>BlobServiceClient blobServiceClient = new
BlobServiceClientBuilder().connectionString(azConnectionString).buildClient();
BlobContainerClient blobContainerClient = blobServiceClient.getBlobContainerClient("myContainer")

ListBlobsOptions listsBlobOptions = new ListBlobsOptions();
listsBlobOptions.getDetails().getRetrieveMetadata();

blobContainerClient.listBlobs(listsBlobOptions, Duration.ofHours(1000)).forEach(blobItem -> {
    log.info(blobItem.getName());
    log.info(blobItem.getProperties().getETag());
    log.info(String.valueOf(blobItem.getProperties().getLeaseStatus()));
    log.info(String.valueOf(blobItem.getMetadata()));
  });
</code>```

Help is appreciated

Regards

答:
I believe the reason you're not getting the metadata is because you're not setting the metadata option.

Can you try something like the following (untested code):

```<code>BlobServiceClient blobServiceClient = new
BlobServiceClientBuilder().connectionString(azConnectionString).buildClient();
BlobContainerClient blobContainerClient = blobServiceClient.getBlobContainerClient("myContainer")

BlobListDetails blobListDetails = (new BlobListDetails()).setRetrieveMetadata(true);//set "retrieve metadata" option to true
ListBlobOptions listBlobOptions = (new ListBlobOptions()).setDetails(blobListDetails);

blobContainerClient.listBlobs(listsBlobOptions, Duration.ofHours(1000)).forEach(blobItem -> {
    log.info(blobItem.getName());
    log.info(blobItem.getProperties().getETag());
    log.info(String.valueOf(blobItem.getProperties().getLeaseStatus()));
    log.info(String.valueOf(blobItem.getMetadata()));
  });
</code>```

Body:
I am using java api for azure as described here https://learn.microsoft.com/en-us/java/api/overview/azure/storage?view=azure-java-stable

In the code sample below i am able to retrieve blob content from the BlobItem object with exception of "metadata" which returns null despite the fact that i have added metadata manually to the blob in azure portal.

BlobServiceClient blobServiceClient = new
BlobServiceClientBuilder().connectionString(azConnectionString).buildClient();
BlobContainerClient blobContainerClient = blobServiceClient.getBlobContainerClient("myContainer")

ListBlobsOptions listsBlobOptions = new ListBlobsOptions();
listsBlobOptions.getDetails().getRetrieveMetadata();

blobContainerClient.listBlobs(listsBlobOptions, Duration.ofHours(1000)).forEach(blobItem -> {
    log.info(blobItem.getName());
    log.info(blobItem.getProperties().getETag());
    log.info(String.valueOf(blobItem.getProperties().getLeaseStatus()));
    log.info(String.valueOf(blobItem.getMetadata()));
  });

Help is appreciated

Regards

Body:
I believe the reason you're not getting the metadata is because you're not setting the metadata option.

Can you try something like the following (untested code):

BlobServiceClient blobServiceClient = new
BlobServiceClientBuilder().connectionString(azConnectionString).buildClient();
BlobContainerClient blobContainerClient = blobServiceClient.getBlobContainerClient("myContainer")

BlobListDetails blobListDetails = (new BlobListDetails()).setRetrieveMetadata(true);//set "retrieve metadata" option to true
ListBlobOptions listBlobOptions = (new ListBlobOptions()).setDetails(blobListDetails);

blobContainerClient.listBlobs(listsBlobOptions, Duration.ofHours(1000)).forEach(blobItem -> {
    log.info(blobItem.getName());
    log.info(blobItem.getProperties().getETag());
    log.info(String.valueOf(blobItem.getProperties().getLeaseStatus()));
    log.info(String.valueOf(blobItem.getMetadata()));
  });


问:
Ideal way to cancel an executing AsyncTask
I am running remote audio-file-fetching and audio file playback operations in a background thread using AsyncTask. A Cancellable progress bar is shown for the time the fetch operation runs.

I want to cancel/abort the AsyncTask run when the user cancels (decides against) the operation. What is the ideal way to handle such a case?

答:
This is how I write my AsyncTask<br>
the key point is add Thread.sleep(1);   </p>

```<code>@Override   protected Integer doInBackground(String... params) {

        Log.d(TAG, PRE + "url:" + params[0]);
        Log.d(TAG, PRE + "file name:" + params[1]);
        downloadPath = params[1];

        int returnCode = SUCCESS;
        FileOutputStream fos = null;
        try {
            URL url = new URL(params[0]);
            File file = new File(params[1]);
            fos = new FileOutputStream(file);

            long startTime = System.currentTimeMillis();
            URLConnection ucon = url.openConnection();
            InputStream is = ucon.getInputStream();
            BufferedInputStream bis = new BufferedInputStream(is);

            byte[] data = new byte[10240];
            int nFinishSize = 0;
            while( bis.read(data, 0, 10240) != -1){
                fos.write(data, 0, 10240);
                nFinishSize += 10240;
                **Thread.sleep( 1 ); // this make cancel method work**
                this.publishProgress(nFinishSize);
            }
            data = null;
            Log.d(TAG, "download ready in"
                  + ((System.currentTimeMillis() - startTime) / 1000)
                  + " sec");

        } catch (IOException e) {
                Log.d(TAG, PRE + "Error: " + e);
                returnCode = FAIL;
        } catch (Exception e){
                 e.printStackTrace();
        } finally{
            try {
                if(fos != null)
                    fos.close();
            } catch (IOException e) {
                Log.d(TAG, PRE + "Error: " + e);
                e.printStackTrace();
            }
        }

        return returnCode;
    }
</code>```

ContentLicense: CC BY-SA 2.5

Body:
This is how I write my AsyncTask

the key point is add Thread.sleep(1);

@Override   protected Integer doInBackground(String... params) {

        Log.d(TAG, PRE + "url:" + params[0]);
        Log.d(TAG, PRE + "file name:" + params[1]);
        downloadPath = params[1];

        int returnCode = SUCCESS;
        FileOutputStream fos = null;
        try {
            URL url = new URL(params[0]);
            File file = new File(params[1]);
            fos = new FileOutputStream(file);

            long startTime = System.currentTimeMillis();
            URLConnection ucon = url.openConnection();
            InputStream is = ucon.getInputStream();
            BufferedInputStream bis = new BufferedInputStream(is);

            byte[] data = new byte[10240];
            int nFinishSize = 0;
            while( bis.read(data, 0, 10240) != -1){
                fos.write(data, 0, 10240);
                nFinishSize += 10240;
                **Thread.sleep( 1 ); // this make cancel method work**
                this.publishProgress(nFinishSize);
            }
            data = null;
            Log.d(TAG, "download ready in"
                  + ((System.currentTimeMillis() - startTime) / 1000)
                  + " sec");

        } catch (IOException e) {
                Log.d(TAG, PRE + "Error: " + e);
                returnCode = FAIL;
        } catch (Exception e){
                 e.printStackTrace();
        } finally{
            try {
                if(fos != null)
                    fos.close();
            } catch (IOException e) {
                Log.d(TAG, PRE + "Error: " + e);
                e.printStackTrace();
            }
        }

        return returnCode;
    }


问:
Remove empty rows within a dataframe and check similarity
I am having some difficulties to select not empty fields using regex (findall) within my dataframe, looking for words contained into a text source:

```<code>text = "Be careful otherwise police will capture you quickly."
</code>```

I will need to look for words that ends with ful in my text string, then looking for words that ends with full in my dataset.

```<code>Author      DF_Text

31       Better the devil you know than the one you don't
53       Beware the door with too many keys.
563      Be careful what you tolerate. You are teaching people how to treat you.
41       Fear the Greeks bearing gifts.
539      NaN
51       The honey is sweet but the bee has a sting.
21       Be careful what you ask for; you may get it.
</code>```

(from csv/txt file).
I need to extract words ending with ful in text, then look at both DF_Text (thus Author) which contains words ending with ful and appending results in a list.

```<code>n=0
for i in df['DF_Text']:
        print(re.findall(r"\w+ful", i))
        n=n+1
        print(n)
</code>```

My question is: how can I remove empty rows([]) from the analysis (NaN) and report the author names (e.g. 563, 21) related to?
I will be happy to provide further information, in case it would be not clear.

答:
Use str.findall instead of looping with re.findall:

```<code>df["found"] = df["DF_Text"].str.findall(r"(\w+ful)")

df.loc[df["found"].str.len().eq(0),"found"] = df["Author"]

print (df)

   Author                                            DF_Text      found
0      31   Better the devil you know than the one you don't         31
1      53                Beware the door with too many keys.         53
2     563  Be careful what you tolerate. You are teaching...  [careful]
3      41                     Fear the Greeks bearing gifts.         41
4     539                                                NaN        NaN
5      51        The honey is sweet but the bee has a sting.         51
6      21       Be careful what you ask for; you may get it.  [careful]
</code>```

Body:
I am having some difficulties to select not empty fields using regex (findall) within my dataframe, looking for words contained into a text source:

text = "Be careful otherwise police will capture you quickly."

I will need to look for words that ends with ful in my text string, then looking for words that ends with full in my dataset.

Author      DF_Text

31       Better the devil you know than the one you don't
53       Beware the door with too many keys.
563      Be careful what you tolerate. You are teaching people how to treat you.
41       Fear the Greeks bearing gifts.
539      NaN
51       The honey is sweet but the bee has a sting.
21       Be careful what you ask for; you may get it.

(from csv/txt file).
I need to extract words ending with ful in text, then look at both DF_Text (thus Author) which contains words ending with ful and appending results in a list.

n=0
for i in df['DF_Text']:
        print(re.findall(r"\w+ful", i))
        n=n+1
        print(n)

My question is: how can I remove empty rows([]) from the analysis (NaN) and report the author names (e.g. 563, 21) related to?
I will be happy to provide further information, in case it would be not clear.

Body:
Use str.findall instead of looping with re.findall:

df["found"] = df["DF_Text"].str.findall(r"(\w+ful)")

df.loc[df["found"].str.len().eq(0),"found"] = df["Author"]

print (df)

   Author                                            DF_Text      found
0      31   Better the devil you know than the one you don't         31
1      53                Beware the door with too many keys.         53
2     563  Be careful what you tolerate. You are teaching...  [careful]
3      41                     Fear the Greeks bearing gifts.         41
4     539                                                NaN        NaN
5      51        The honey is sweet but the bee has a sting.         51
6      21       Be careful what you ask for; you may get it.  [careful]