问:
How fix bug in delphi 7 with scale dpi?
Please help fix bug in delphi 7 with scale dpi.
In this sample, I use TButton with Anchor:=[akRight] and as you can see button text overflow if window setting 125 dpi scale mode.

I prepared example for demonstration:

1) Default scale

2) Large scale ( as you see button2 is gone )

Source code:

Unit1.pas

```<code>unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls;

type
  TForm1 = class(TForm)
    Panel1: TPanel;
    Panel2: TPanel;
    Button1: TButton;
    Button2: TButton;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

end.
</code>```

Unit1.dfm

```<code>object Form1: TForm1
  Left = 488
  Top = 196
  Width = 720
  Height = 511
  Caption = 'Form1'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object Panel1: TPanel
    Left = 0
    Top = 432
    Width = 704
    Height = 41
    Align = alBottom
    Caption = 'Panel1'
    TabOrder = 0
    DesignSize = (
      704
      41)
    object Button1: TButton
      Left = 12
      Top = 8
      Width = 75
      Height = 25
      Caption = 'Button1'
      TabOrder = 0
    end
    object Button2: TButton
      Left = 616
      Top = 8
      Width = 75
      Height = 25
      Anchors = [akTop, akRight]
      Caption = 'Button2'
      TabOrder = 1
    end
  end
  object Panel2: TPanel
    Left = 0
    Top = 0
    Width = 704
    Height = 432
    Align = alClient
    Caption = 'Panel2'
    TabOrder = 1
  end
end
</code>```

答:
To work properly with scaling, you must use an environment prepared for this.
there is nothing complicated and the letters will not shrink and everything will work fine.
I have a demo application that shows how to work with scaling
if the global scale of the system differs from the scale on the development aspiration also
depending on the overall scale, it is possible to adjust the scale of only the application itself.
EXE APP DEMO
screen</p>
```<code>unit AmUserScale;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs;

//type
  type
  AmScale = class
    private
      class procedure SetScaleAppCustom(New,Old:integer);
    public
     //хранит значение  маштаба по умолчанию
     //  AppScaleDesing рекомедую выстовить в 100 при создании формы а не здесь
     //  WinScaleDPIDesing рекомедую выстовить в 96 при создании формы что равно WinApi.Windows.USER_DEFAULT_SCREEN_DPI  а не здесь
     //если вы разрабатываете прогу и у вас на компе глобальный маштаб 120 то его и установите по умолчанию в WinScaleDPIDesing
     // если у вас всегда глобальный маштаб 96 то ничего устанавливать не нужно см initialization

      class var AppScaleDesing:Integer; //  какой маштаб был на этапе разработки
      class var AppScaleNow:Integer;    //какой маштаб сейчас в приложении
      class var WinScaleDPIDesing:Integer; //какой глобальный маштаб системы был  на этапе разработки
      class var WinScaleDPINow:Integer; //какой глобальный маштаб системы сейчас в приложении
      class var IsShow:boolean;
      // при создании главной формы запустить Init
      // можно передать параметр сохраненного маштаба приложения например с какой то базы данных
      // это процент от 30 до 200 обычно это 100 процентов от размера приложения на этапе разработки
      class procedure Init(ASavedProcent:Integer=100);

      // в собыитии FormShow запустить Show
      class procedure Show;
      //  запустить в событии главной формы FormAfterMonitorDpiChanged
      // проиходит когда в системе глобально меняется маштаб
      class procedure ChangeDPI(NewDPI,OldDPI:integer);

      // получить новое значение размера для числа val смотрите ниже описание
      // если кратко то  P:=Tpanel.create(self); P.height:=  AmScale.Value(88);
      class function Value(val:integer):integer; static;

      // если хотим поменять мастаб всего приложения  SetScaleApp(120,100) увеличится на 20%
      class procedure SetScaleApp(New,Old:integer);

      // получить список для юзера возможных маштабов приложения
      class procedure GetAppToList(L:TStrings);

      // у вас есть значение но не знаете индек его в списке  = найдите
      class function GetIndexFromList(L:TStrings;value:integer=0):integer;

      // получить значение с строки которая была  получена в GetAppToList
      class function GetValueFromStr(S:String):integer;
      // изменить маштаб когда юзер выбрал новое значение из списка
      class procedure SetAppFromListInt(New:Integer);
      //передать одну линию со списка полученного в GetAppToList
      class procedure SetAppFromList(S:String);
  end;

  function UserMainScale(val:integer):integer;

{
  ЭТО СТАРОЕ ОПИСАНИЕ СМЫСЛ ТОТ ЖЕ просто имена процедур изменены

  получает маштаб экрана у пользователя на форм create занести значение в UserMainScaleGetConst

 где
 Width_now это ширина формы когда програ запускается
 Width_debag это ширина формы на этапе разработки
 в ответ приходит процент изменения , т.е маштаб
USER_MAIN_SCALE_CREATE:= UserMainScaleGetConst(MyForm.Width,500);
USER_MAIN_SCALE_CREATE хранит текуший маштаб наример 125.67 но обычно 100

далее если создаем компоненты диначимичеки то указываем ширину и высоту и отступы как
P:=Tpanel.create(self);
P.parent:=self;
P.height:=  UserMainScale(88);  //хотя раньше бы писали как  P.height:=  88;
P.font.size:=  UserMainScale(10);

  небольшое замечание по динамическому созданию котролов
  после TWinControl.Create
  и до уставновки Parent
  нужно ставить значения высот обычно т.е
  P.height:=  88;
  P.parent:=self;
  после установки  Parent
  P.height:=  UserMainScale(88);
}

implementation

{ AmScale }
function UserMainScale(val:integer):integer;
begin
   Result:=AmScale.Value(val);
end;
class procedure AmScale.GetAppToList(L: TStrings);
begin
    L.Clear;
    L.Add('70 %');
    L.Add('80 %');
    L.Add('90 %');
    L.Add('95 %');
    L.Add('100 % (рекомедуется)');
    L.Add('110 %');
    L.Add('120 %');
    L.Add('130 %');
    L.Add('140 %');
    L.Add('150 %');
    L.Add('175 %');
    L.Add('200 %');
end;
class function AmScale.GetIndexFromList(L: TStrings; value: integer=0): integer;
begin
    if value<30 then
    value:= AppScaleNow;
    for Result := 0 to L.Count-1 do
    if GetValueFromStr(L[Result]) = value then exit;
    Result:=-1;
end;

class function AmScale.GetValueFromStr(S: String): integer;
var tok:integer;
begin
    Result:=0;
    tok:=  pos(' ',S);
    if (tok<>1) and (tok<>0) then
    begin
       S:=s.Split([' '])[0];
       TryStrToInt(S,Result);
    end;
end;

class procedure AmScale.SetAppFromList(S: String);
begin
    SetAppFromListInt(GetValueFromStr(S));
end;
class procedure AmScale.SetAppFromListInt(New: Integer);
begin
   SetScaleApp(New,AppScaleNow);
end;

class procedure AmScale.SetScaleApp(New,Old:integer);
begin
   if New<30 then exit;
   if Old<30 then
   Old:= AppScaleNow;
   if Old<30 then exit;

   if New<>AppScaleNow then
   begin
       SetScaleAppCustom(New,AppScaleNow);
       AppScaleNow:= New;
   end;
end;
class procedure AmScale.SetScaleAppCustom(New, Old: integer);
var i:integer;
begin
     for  I := 0 to Screen.FormCount-1 do
     Screen.Forms[i].ScaleBy(New,Old);
end;

class procedure AmScale.Show;
begin
    SetScaleAppCustom(AppScaleNow,AppScaleDesing);
    IsShow:=true;
end;

class procedure AmScale.ChangeDPI(NewDPI,OldDPI:integer);
begin
  WinScaleDPINow:= NewDPI;
end;
class procedure AmScale.Init(ASavedProcent:Integer=100);
var LMonitor:TMonitor;
    LForm: TForm;
    LPlacement: TWindowPlacement;
begin
      if ASavedProcent<=0 then
      ASavedProcent:=100;
      if ASavedProcent<30 then  ASavedProcent:=30;
      if ASavedProcent>300 then  ASavedProcent:=300;

      AppScaleDesing:=100;
      AppScaleNow:=ASavedProcent;

      WinScaleDPINow:=USER_DEFAULT_SCREEN_DPI;
      WinScaleDPIDesing:=USER_DEFAULT_SCREEN_DPI;

      if (Application<>nil) and (Screen<>nil) then
      begin
        LMonitor := Screen.MonitorFromWindow(Application.Handle);
        if LMonitor <> nil then
          WinScaleDPINow := LMonitor.PixelsPerInch
        else
         WinScaleDPINow := Screen.PixelsPerInch;

        LForm := Application.MainForm;
        if (LForm <> nil)  then
        WinScaleDPIDesing := LForm.PixelsPerInch;

      end
      else if (Screen<>nil) and (Mouse<>nil) then
      begin
        LMonitor := Screen.MonitorFromPoint(Mouse.CursorPos);
        if LMonitor <> nil then
          WinScaleDPINow := LMonitor.PixelsPerInch
        else
         WinScaleDPINow := Screen.PixelsPerInch;

        LForm := Application.MainForm;
        if (LForm <> nil)  then
        WinScaleDPIDesing := LForm.PixelsPerInch;
      end;

      //ScaleForPPI(GetParentCurrentDpi);

end;

class function AmScale.Value(val: integer): integer;
begin
  // result:=Round( Value(Real(val)) );
    // сначало маштаб системы потом маштаб приложения
    result:=MulDiv(val, WinScaleDPINow, WinScaleDPIDesing);
   if IsShow then
    result:=MulDiv(result, AppScaleNow, AppScaleDesing);
end;

 {
class procedure AmScale.Start(Width_now, Width_debag: real);
begin

     USER_SCALE:=100;
   if Width_debag=0 then exit;
   USER_SCALE:=(Width_now/Width_debag)*100;

 c:=TMonitor.Create;
 c.PixelsPerInch

end;}
initialization
begin
   AmScale.IsShow:=false;
   AmScale.AppScaleDesing:=100;
   AmScale.AppScaleNow:=100;
   AmScale.WinScaleDPIDesing:= WinApi.Windows.USER_DEFAULT_SCREEN_DPI;
   AmScale.WinScaleDPINow:=    WinApi.Windows.USER_DEFAULT_SCREEN_DPI;
end;
end.
</code>```

Title: How fix bug in delphi 7 with scale dpi?

Body:
Please help fix bug in delphi 7 with scale dpi.
In this sample, I use TButton with Anchor:=[akRight] and as you can see button text overflow if window setting 125 dpi scale mode.

I prepared example for demonstration:

1) Default scale

2) Large scale ( as you see button2 is gone )

Source code:

Unit1.pas

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls;

type
  TForm1 = class(TForm)
    Panel1: TPanel;
    Panel2: TPanel;
    Button1: TButton;
    Button2: TButton;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

end.

Unit1.dfm

object Form1: TForm1
  Left = 488
  Top = 196
  Width = 720
  Height = 511
  Caption = 'Form1'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object Panel1: TPanel
    Left = 0
    Top = 432
    Width = 704
    Height = 41
    Align = alBottom
    Caption = 'Panel1'
    TabOrder = 0
    DesignSize = (
      704
      41)
    object Button1: TButton
      Left = 12
      Top = 8
      Width = 75
      Height = 25
      Caption = 'Button1'
      TabOrder = 0
    end
    object Button2: TButton
      Left = 616
      Top = 8
      Width = 75
      Height = 25
      Anchors = [akTop, akRight]
      Caption = 'Button2'
      TabOrder = 1
    end
  end
  object Panel2: TPanel
    Left = 0
    Top = 0
    Width = 704
    Height = 432
    Align = alClient
    Caption = 'Panel2'
    TabOrder = 1
  end
end

Body:
To work properly with scaling, you must use an environment prepared for this.
there is nothing complicated and the letters will not shrink and everything will work fine.
I have a demo application that shows how to work with scaling
if the global scale of the system differs from the scale on the development aspiration also
depending on the overall scale, it is possible to adjust the scale of only the application itself.
EXE APP DEMO
screen

unit AmUserScale;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs;

//type
  type
  AmScale = class
    private
      class procedure SetScaleAppCustom(New,Old:integer);
    public
     //хранит значение  маштаба по умолчанию
     //  AppScaleDesing рекомедую выстовить в 100 при создании формы а не здесь
     //  WinScaleDPIDesing рекомедую выстовить в 96 при создании формы что равно WinApi.Windows.USER_DEFAULT_SCREEN_DPI  а не здесь
     //если вы разрабатываете прогу и у вас на компе глобальный маштаб 120 то его и установите по умолчанию в WinScaleDPIDesing
     // если у вас всегда глобальный маштаб 96 то ничего устанавливать не нужно см initialization

      class var AppScaleDesing:Integer; //  какой маштаб был на этапе разработки
      class var AppScaleNow:Integer;    //какой маштаб сейчас в приложении
      class var WinScaleDPIDesing:Integer; //какой глобальный маштаб системы был  на этапе разработки
      class var WinScaleDPINow:Integer; //какой глобальный маштаб системы сейчас в приложении
      class var IsShow:boolean;
      // при создании главной формы запустить Init
      // можно передать параметр сохраненного маштаба приложения например с какой то базы данных
      // это процент от 30 до 200 обычно это 100 процентов от размера приложения на этапе разработки
      class procedure Init(ASavedProcent:Integer=100);

      // в собыитии FormShow запустить Show
      class procedure Show;
      //  запустить в событии главной формы FormAfterMonitorDpiChanged
      // проиходит когда в системе глобально меняется маштаб
      class procedure ChangeDPI(NewDPI,OldDPI:integer);

      // получить новое значение размера для числа val смотрите ниже описание
      // если кратко то  P:=Tpanel.create(self); P.height:=  AmScale.Value(88);
      class function Value(val:integer):integer; static;

      // если хотим поменять мастаб всего приложения  SetScaleApp(120,100) увеличится на 20%
      class procedure SetScaleApp(New,Old:integer);

      // получить список для юзера возможных маштабов приложения
      class procedure GetAppToList(L:TStrings);

      // у вас есть значение но не знаете индек его в списке  = найдите
      class function GetIndexFromList(L:TStrings;value:integer=0):integer;

      // получить значение с строки которая была  получена в GetAppToList
      class function GetValueFromStr(S:String):integer;
      // изменить маштаб когда юзер выбрал новое значение из списка
      class procedure SetAppFromListInt(New:Integer);
      //передать одну линию со списка полученного в GetAppToList
      class procedure SetAppFromList(S:String);
  end;

  function UserMainScale(val:integer):integer;

{
  ЭТО СТАРОЕ ОПИСАНИЕ СМЫСЛ ТОТ ЖЕ просто имена процедур изменены

  получает маштаб экрана у пользователя на форм create занести значение в UserMainScaleGetConst

 где
 Width_now это ширина формы когда програ запускается
 Width_debag это ширина формы на этапе разработки
 в ответ приходит процент изменения , т.е маштаб
USER_MAIN_SCALE_CREATE:= UserMainScaleGetConst(MyForm.Width,500);
USER_MAIN_SCALE_CREATE хранит текуший маштаб наример 125.67 но обычно 100

далее если создаем компоненты диначимичеки то указываем ширину и высоту и отступы как
P:=Tpanel.create(self);
P.parent:=self;
P.height:=  UserMainScale(88);  //хотя раньше бы писали как  P.height:=  88;
P.font.size:=  UserMainScale(10);

  небольшое замечание по динамическому созданию котролов
  после TWinControl.Create
  и до уставновки Parent
  нужно ставить значения высот обычно т.е
  P.height:=  88;
  P.parent:=self;
  после установки  Parent
  P.height:=  UserMainScale(88);
}

implementation

{ AmScale }
function UserMainScale(val:integer):integer;
begin
   Result:=AmScale.Value(val);
end;
class procedure AmScale.GetAppToList(L: TStrings);
begin
    L.Clear;
    L.Add('70 %');
    L.Add('80 %');
    L.Add('90 %');
    L.Add('95 %');
    L.Add('100 % (рекомедуется)');
    L.Add('110 %');
    L.Add('120 %');
    L.Add('130 %');
    L.Add('140 %');
    L.Add('150 %');
    L.Add('175 %');
    L.Add('200 %');
end;
class function AmScale.GetIndexFromList(L: TStrings; value: integer=0): integer;
begin
    if value<30 then
    value:= AppScaleNow;
    for Result := 0 to L.Count-1 do
    if GetValueFromStr(L[Result]) = value then exit;
    Result:=-1;
end;

class function AmScale.GetValueFromStr(S: String): integer;
var tok:integer;
begin
    Result:=0;
    tok:=  pos(' ',S);
    if (tok<>1) and (tok<>0) then
    begin
       S:=s.Split([' '])[0];
       TryStrToInt(S,Result);
    end;
end;

class procedure AmScale.SetAppFromList(S: String);
begin
    SetAppFromListInt(GetValueFromStr(S));
end;
class procedure AmScale.SetAppFromListInt(New: Integer);
begin
   SetScaleApp(New,AppScaleNow);
end;

class procedure AmScale.SetScaleApp(New,Old:integer);
begin
   if New<30 then exit;
   if Old<30 then
   Old:= AppScaleNow;
   if Old<30 then exit;

   if New<>AppScaleNow then
   begin
       SetScaleAppCustom(New,AppScaleNow);
       AppScaleNow:= New;
   end;
end;
class procedure AmScale.SetScaleAppCustom(New, Old: integer);
var i:integer;
begin
     for  I := 0 to Screen.FormCount-1 do
     Screen.Forms[i].ScaleBy(New,Old);
end;

class procedure AmScale.Show;
begin
    SetScaleAppCustom(AppScaleNow,AppScaleDesing);
    IsShow:=true;
end;

class procedure AmScale.ChangeDPI(NewDPI,OldDPI:integer);
begin
  WinScaleDPINow:= NewDPI;
end;
class procedure AmScale.Init(ASavedProcent:Integer=100);
var LMonitor:TMonitor;
    LForm: TForm;
    LPlacement: TWindowPlacement;
begin
      if ASavedProcent<=0 then
      ASavedProcent:=100;
      if ASavedProcent<30 then  ASavedProcent:=30;
      if ASavedProcent>300 then  ASavedProcent:=300;

      AppScaleDesing:=100;
      AppScaleNow:=ASavedProcent;

      WinScaleDPINow:=USER_DEFAULT_SCREEN_DPI;
      WinScaleDPIDesing:=USER_DEFAULT_SCREEN_DPI;

      if (Application<>nil) and (Screen<>nil) then
      begin
        LMonitor := Screen.MonitorFromWindow(Application.Handle);
        if LMonitor <> nil then
          WinScaleDPINow := LMonitor.PixelsPerInch
        else
         WinScaleDPINow := Screen.PixelsPerInch;

        LForm := Application.MainForm;
        if (LForm <> nil)  then
        WinScaleDPIDesing := LForm.PixelsPerInch;

      end
      else if (Screen<>nil) and (Mouse<>nil) then
      begin
        LMonitor := Screen.MonitorFromPoint(Mouse.CursorPos);
        if LMonitor <> nil then
          WinScaleDPINow := LMonitor.PixelsPerInch
        else
         WinScaleDPINow := Screen.PixelsPerInch;

        LForm := Application.MainForm;
        if (LForm <> nil)  then
        WinScaleDPIDesing := LForm.PixelsPerInch;
      end;

      //ScaleForPPI(GetParentCurrentDpi);

end;

class function AmScale.Value(val: integer): integer;
begin
  // result:=Round( Value(Real(val)) );
    // сначало маштаб системы потом маштаб приложения
    result:=MulDiv(val, WinScaleDPINow, WinScaleDPIDesing);
   if IsShow then
    result:=MulDiv(result, AppScaleNow, AppScaleDesing);
end;

 {
class procedure AmScale.Start(Width_now, Width_debag: real);
begin

     USER_SCALE:=100;
   if Width_debag=0 then exit;
   USER_SCALE:=(Width_now/Width_debag)*100;

 c:=TMonitor.Create;
 c.PixelsPerInch

end;}
initialization
begin
   AmScale.IsShow:=false;
   AmScale.AppScaleDesing:=100;
   AmScale.AppScaleNow:=100;
   AmScale.WinScaleDPIDesing:= WinApi.Windows.USER_DEFAULT_SCREEN_DPI;
   AmScale.WinScaleDPINow:=    WinApi.Windows.USER_DEFAULT_SCREEN_DPI;
end;
end.


来源: stackexchange

问:
Matching a number against a comma-separated sequence of ranges
I'm writing a bash script which takes a number, and also a comma-separated sequence of values and strings, e.g.: 3,15,4-7,19-20. I want to check whether the number is contained in the set corresponding to the sequence. For simplicity, assume no comma-separated elements intersect, and that the elements are sorted in ascending order.

Is there a simple way to do this in bash other than the brute-force naive way? Some shell utility which does something like that for me, maybe something related to lpr which already knows how to process page range sequences etc.

答:
As bash is tagged, why not just

inrange() { for r in ${2//,/ }; do ((${r%-*}<=$1 && $1<=${r#*-})) && break; done; }
```
<p>Then test it as usual:</p>
<pre class="lang-sh prettyprint-override"><code>$ inrange 6 3,15,4-7,19-20 && echo yes || echo no
yes
$ inrange 42 3,15,4-7,19-20 && echo yes || echo no
no
</code>```

ContentLicense: CC BY-SA 4.0

Body:
As bash is tagged, why not just

inrange() { for r in ${2//,/ }; do ((${r%-*}<=$1 && $1<=${r#*-})) && break; done; }

Then test it as usual:

$ inrange 6 3,15,4-7,19-20 && echo yes || echo no
yes
$ inrange 42 3,15,4-7,19-20 && echo yes || echo no
no


问:
Looking for Java method capable of identifying which method it is called by
I have been working on a small logging/debug library for my Java projects. I know there are many good ones already out there but I want to learn from doing one myself.

One method I want to have as part of this library is the ability to find out which method you are in at any one time, similar to __func__ in C++. Most of the time it'd be fine to just use the StackTrace to find this, since you often don't need more than the name (and/or declaring class) of the method, but I want to have the ability to get the method as an instance of the java.lang.reflect.Method

The easiest way of doing this is by simply doing

```<code>Method currentMethod = new Object() {}.getClass().getEnclosingMethod();
</code>```

which will work just fine, but I can't figure out a way to do the same without creating that 'new Object() {}' within the method itself. Ideally I'd prefer if I could make a simple

```<code>Method currentMethod = _method();
</code>```

to get the same result but with my current approach it'd just get me the Method-instance of _method itself.

Is there any known method to achieve this? If there isn't that's fine, but it'd be nice to have one.

EDIT: A lot of suggestions I receive, such as this post, provide mostly answers that provide you with the NAME of the method. It would be possible to use that (and the Class info gained in the same way) to find the Method, but only if the class in question has only one method with that name. Methods with the same name but different arguments cannot be identified with this!

答:
This can be done using a StackWalker (since Java 9). It does not directly
provide a Method but enough information to create one.
Here the basic idea, can be improved (e.g. better Exception(s)):

```<code>import java.lang.StackWalker.Option;
import java.lang.StackWalker.StackFrame;
import java.lang.reflect.Method;

public class MethodFinder {

    public static Method method() {
        return StackWalker.getInstance(Option.RETAIN_CLASS_REFERENCE).walk(stream ->
            stream
            .filter(MethodFinder::notThisClass)
            .findFirst()
            .map(MethodFinder::frameToMethod))
            .orElseThrow();
    }

    private static boolean notThisClass(StackFrame frame) {
        return frame.getDeclaringClass() != MethodFinder.class;
    }

    private static Method frameToMethod(StackFrame frame) {
        var cl = frame.getDeclaringClass();
        try {
            return cl.getDeclaredMethod(frame.getMethodName(), frame.getMethodType().parameterArray());
        } catch (NoSuchMethodException | SecurityException ex) {
            throw new RuntimeException(ex);
        }
    }
}
</code>```

To be used like Method myself = MethodFinder.method().

Body:
I have been working on a small logging/debug library for my Java projects. I know there are many good ones already out there but I want to learn from doing one myself.

One method I want to have as part of this library is the ability to find out which method you are in at any one time, similar to __func__ in C++. Most of the time it'd be fine to just use the StackTrace to find this, since you often don't need more than the name (and/or declaring class) of the method, but I want to have the ability to get the method as an instance of the java.lang.reflect.Method

The easiest way of doing this is by simply doing

Method currentMethod = new Object() {}.getClass().getEnclosingMethod();

which will work just fine, but I can't figure out a way to do the same without creating that 'new Object() {}' within the method itself. Ideally I'd prefer if I could make a simple

Method currentMethod = _method();

to get the same result but with my current approach it'd just get me the Method-instance of _method itself.

Is there any known method to achieve this? If there isn't that's fine, but it'd be nice to have one.

EDIT: A lot of suggestions I receive, such as this post, provide mostly answers that provide you with the NAME of the method. It would be possible to use that (and the Class info gained in the same way) to find the Method, but only if the class in question has only one method with that name. Methods with the same name but different arguments cannot be identified with this!

Body:
This can be done using a StackWalker (since Java 9). It does not directly
provide a Method but enough information to create one.
Here the basic idea, can be improved (e.g. better Exception(s)):

import java.lang.StackWalker.Option;
import java.lang.StackWalker.StackFrame;
import java.lang.reflect.Method;

public class MethodFinder {

    public static Method method() {
        return StackWalker.getInstance(Option.RETAIN_CLASS_REFERENCE).walk(stream ->
            stream
            .filter(MethodFinder::notThisClass)
            .findFirst()
            .map(MethodFinder::frameToMethod))
            .orElseThrow();
    }

    private static boolean notThisClass(StackFrame frame) {
        return frame.getDeclaringClass() != MethodFinder.class;
    }

    private static Method frameToMethod(StackFrame frame) {
        var cl = frame.getDeclaringClass();
        try {
            return cl.getDeclaredMethod(frame.getMethodName(), frame.getMethodType().parameterArray());
        } catch (NoSuchMethodException | SecurityException ex) {
            throw new RuntimeException(ex);
        }
    }
}

To be used like Method myself = MethodFinder.method().


问:
winforms - Can't get windows narrator to read message box content
I have a simple message box:

```<code>MessageBox.Show(this, "bla bla bla", "banana man", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, options);
</code>```

And for some reason I don't manage to get the windows narrator to read its content ("bla bla bla").
Any idea how I can solve this?

Thanks,
Li

答:
Narrator is a very basic screen reader and not intelligent enough for many cases. I am not sure whether it is possible at all to support narrator to read this. This may give you more details.

See here if it helps you.

ContentLicense: CC BY-SA 3.0

Body:
I have a simple message box:

MessageBox.Show(this, "bla bla bla", "banana man", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, options);

And for some reason I don't manage to get the windows narrator to read its content ("bla bla bla").
Any idea how I can solve this?

Thanks,
Li


问:
Flask Rest API SQLAlchemy foreign key error
I got SQLALchemy error, when I tried "flask db migrate"

```<code>NoReferencedTableError: Foreign key associated with column 'user.menu_id' could not find table 'menu' with which to generate a foreign key to target column 'id
</code>```

Menu table

```<code>class Menu(db.Model):
   __tablename__ = 'menus'
   id = db.Column(db.Integer(), primary_key=True)
   name = db.Column(db.String(64), index=True, unique=True)
   price = db.Column(db.String(64), index=True, unique=True)
   description = db.Column(db.String(64), index=True, unique=True)
   picture = db.Column(db.String(64), index=True, unique=True)
   create_date = db.Column(db.DateTime, default=datetime.utcnow)
   users = db.relationship('User', backref="menu", lazy=True)
</code>```

User table

```<code>class User(Model):
""" User model for storing user related data """

   id = Column(db.Integer, primary_key=True)
   email = Column(db.String(64), unique=True, index=True)
   username = Column(db.String(15), unique=True, index=True)
   name = Column(db.String(64))
   password_hash = Column(db.String(128))
   admin = Column(db.Boolean, default=False)

   joined_date = Column(db.DateTime, default=datetime.utcnow)
   userdataset = db.relationship("Dataset", backref="user", lazy="dynamic")
   menu_id = Column(db.Integer(), db.ForeignKey('menu.id'), nullable=False)
   def __init__(self, **kwargs):
      super(User, self).__init__(**kwargs)
</code>```

How can ı solve this problem? Where am i doing wrong?

答:
You have renamed your 'Menu' table to 'menus' with this __tablename__ property in your 'Menu' model:

```<code>__tablename__ = 'menus'
</code>```

You then try to reference to the 'Menu' table, when in fact, its name has been changed to 'menus'. The simplest way to solve this would be to change your User.menu_id column to this:

```<code>menu_id = Column(db.Integer(), db.ForeignKey('menus.id'), nullable=False)
</code>```

Another way of fixing this issue would be modifying the __tablename__ property to 'menu'. (You could also just delete it.)

Body:
I got SQLALchemy error, when I tried "flask db migrate"

NoReferencedTableError: Foreign key associated with column 'user.menu_id' could not find table 'menu' with which to generate a foreign key to target column 'id

Menu table

class Menu(db.Model):
   __tablename__ = 'menus'
   id = db.Column(db.Integer(), primary_key=True)
   name = db.Column(db.String(64), index=True, unique=True)
   price = db.Column(db.String(64), index=True, unique=True)
   description = db.Column(db.String(64), index=True, unique=True)
   picture = db.Column(db.String(64), index=True, unique=True)
   create_date = db.Column(db.DateTime, default=datetime.utcnow)
   users = db.relationship('User', backref="menu", lazy=True)

User table

class User(Model):
""" User model for storing user related data """

   id = Column(db.Integer, primary_key=True)
   email = Column(db.String(64), unique=True, index=True)
   username = Column(db.String(15), unique=True, index=True)
   name = Column(db.String(64))
   password_hash = Column(db.String(128))
   admin = Column(db.Boolean, default=False)

   joined_date = Column(db.DateTime, default=datetime.utcnow)
   userdataset = db.relationship("Dataset", backref="user", lazy="dynamic")
   menu_id = Column(db.Integer(), db.ForeignKey('menu.id'), nullable=False)
   def __init__(self, **kwargs):
      super(User, self).__init__(**kwargs)

How can ı solve this problem? Where am i doing wrong?

Body:
You have renamed your 'Menu' table to 'menus' with this __tablename__ property in your 'Menu' model:

__tablename__ = 'menus'

You then try to reference to the 'Menu' table, when in fact, its name has been changed to 'menus'. The simplest way to solve this would be to change your User.menu_id column to this:

menu_id = Column(db.Integer(), db.ForeignKey('menus.id'), nullable=False)

Another way of fixing this issue would be modifying the __tablename__ property to 'menu'. (You could also just delete it.)


问:
VBA How to select a range of rows relative to active cell?
In VBA, I want to select a range of rows relative to the active cell.  For example, select rows +3 to +5 relative to the active cell.  I tried the following without success:

Rows(ActiveCell.Row+3:ActiveCell.Row+5).Select

答:
```<code>Sub ActiveCellNewRange()
 Dim rngArea As Range

 'set new range
 Set rngArea = Sheet1.Range("C5").Offset(3).EntireRow.Resize(5)

 'Select and write to immeadiate window
 rngArea.Select
 Debug.Print rngArea.Address

End Sub
</code>```


问:
Could someone help me to add a moving value bubble in my slider?
I want to add a value bubble in my slider but no tutorials helped me do it myself since I'm new to HTML and CSS.

I prefer the position of the value to be just above the invisible thumb, and move it along with the thumb. But if such a moving bubble is too much work, I can also adjust with a static bubble on the left side of the slider.

I also want to be able to control the color of the value text and bubble.

Following is my slider;

    <input type="range"
    min="0"
    max="25"
    step="any"
    value="%VOLM"
    id="volm">

```

答:
You can achieve that with some Javascript. For example:

const
  range = document.getElementById('range'),
  rangeV = document.getElementById('rangeV'),
  setValue = () => {
    const
      newValue = Number((range.value - range.min) * 100 / (range.max - range.min)),
      newPosition = 10 - (newValue * 0.2);
    rangeV.innerHTML = `<span>${range.value}</span>`;
    rangeV.style.left = `calc(${newValue}% + (${newPosition}px))`;
  };
document.addEventListener("DOMContentLoaded", setValue);
range.addEventListener('input', setValue);

rangeV.style.display = "none";

function mouseDown() {
  rangeV.style.display = "block";
}

function mouseUp() {
  rangeV.style.display = "none";
}

range.addEventListener('mousedown', mouseDown);
range.addEventListener('mouseup', mouseUp);```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body {
  min-height: 100vh;
  padding: 0 10vh;
  margin: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

input[type=range] {
  -webkit-appearance: none;
  margin: 20px 0;
  width: 100%;
}

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

.range-wrap {
  width: 500px;
  position: relative;
}

.range-value {
  position: absolute;
  top: -50%;
}

.range-value span {
  width: 30px;
  height: 24px;
  line-height: 24px;
  text-align: center;
  background: #000;
  color: #fff;
  font-size: 12px;
  display: block;
  position: absolute;
  left: 50%;
  transform: translate(-50%, 0);
  border-radius: 6px;
}

.container {
  display: flex;
  width: 100%;
  padding-top: 2;
  height: fit-content;
}

#volm {
  position: relative;
  margin-top: 5px;
  width: 153px;
  border-radius: 3px;
  height: 5px;
  -webkit-appearance: none;
}

input::-webkit-slider-runnable-track {
  -webkit-appearance: none;
  background: linear-gradient(to right, #D4C81C, #FF0000);
  position: relative;
  box-sizing: border-box;
  width: 100%;
  height: 5px;
  border-radius: 3px;
  overflow: hidden;
}

input::-webkit-slider-thumb {
  position: relative;
  left: initial;
  bottom: 10px;
  -webkit-appearance: none;
  width: 0px;
  height: 20px;
  box-shadow: 330px 0 0 330px #DEDEDE, inset 0 0 0 40px #DEDEDE;
  margin-top: 5px;
}</code>```

<!DOCTYPE html>

  <meta charset="UTF-8">
  <title>Input Range with Dynamic Label</title>

      <input id="range" type="range" min="0" max="25" step="any" value="%VOLM" id="volm">

```

Body:
You can achieve that with some Javascript. For example:

const
  range = document.getElementById('range'),
  rangeV = document.getElementById('rangeV'),
  setValue = () => {
    const
      newValue = Number((range.value - range.min) * 100 / (range.max - range.min)),
      newPosition = 10 - (newValue * 0.2);
    rangeV.innerHTML = `<span>${range.value}</span>`;
    rangeV.style.left = `calc(${newValue}% + (${newPosition}px))`;
  };
document.addEventListener("DOMContentLoaded", setValue);
range.addEventListener('input', setValue);

rangeV.style.display = "none";

function mouseDown() {
  rangeV.style.display = "block";
}

function mouseUp() {
  rangeV.style.display = "none";
}

range.addEventListener('mousedown', mouseDown);
range.addEventListener('mouseup', mouseUp);

body {
  min-height: 100vh;
  padding: 0 10vh;
  margin: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

input[type=range] {
  -webkit-appearance: none;
  margin: 20px 0;
  width: 100%;
}

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

.range-wrap {
  width: 500px;
  position: relative;
}

.range-value {
  position: absolute;
  top: -50%;
}

.range-value span {
  width: 30px;
  height: 24px;
  line-height: 24px;
  text-align: center;
  background: #000;
  color: #fff;
  font-size: 12px;
  display: block;
  position: absolute;
  left: 50%;
  transform: translate(-50%, 0);
  border-radius: 6px;
}

.container {
  display: flex;
  width: 100%;
  padding-top: 2;
  height: fit-content;
}

#volm {
  position: relative;
  margin-top: 5px;
  width: 153px;
  border-radius: 3px;
  height: 5px;
  -webkit-appearance: none;
}

input::-webkit-slider-runnable-track {
  -webkit-appearance: none;
  background: linear-gradient(to right, #D4C81C, #FF0000);
  position: relative;
  box-sizing: border-box;
  width: 100%;
  height: 5px;
  border-radius: 3px;
  overflow: hidden;
}

input::-webkit-slider-thumb {
  position: relative;
  left: initial;
  bottom: 10px;
  -webkit-appearance: none;
  width: 0px;
  height: 20px;
  box-shadow: 330px 0 0 330px #DEDEDE, inset 0 0 0 40px #DEDEDE;
  margin-top: 5px;
}

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <title>Input Range with Dynamic Label</title>
</head>

<body>
  <div class="range-wrap">
    <div class="container">
      <div class="range-value" id="rangeV"></div>
      <input id="range" type="range" min="0" max="25" step="any" value="%VOLM" id="volm">
    </div>
  </div>
</body>

</html>


问:
Flexbox column inside flexbox row, but only for tablet version
I am building a website with 3 designs, depending on the screen width.
My html/php file contains the content in the following order (relating to the picture): B, A, C.
Link to responsive layout blocks picture

Phone: This is the same order as desired for the phone version, so that version is easily solved.

Desktop: I use one div that wraps around all 3 parts; with display: flex in combination with the order property I was able to generate the desktop version, so that one was also easily solved.

Tablet: But unfortunately I can’t get the tablet version working. When I wrap a div around A and C the desired tablet layout is easily obtained, but then it is not possible anymore to put B in between them for the desktop version (even if the CSS media query for the desktop does not mention that specific div).

My question: Is it possible to put a flexbox column inside flexbox row, but only for the tablet version?
I have tried several things with the flex-direction and align-items properties, but haven’t succeeded unfortunately. Maybe it is not possible?

Any advice would be very much appreciated!

答:
You can detect when the website is visited from a phone or tablet with plain js:

if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
    //Do stuff
}
```
<p>Or use a <strong>3rd party library</strong> such as <strong>wurfl.io</strong> to detect only <strong>tablet</strong> users:</p>
```if (WURFL.is_mobile === true && WURFL.form_factor === "Tablet") {
    //Do stuff
}
```

Body:
You can detect when the website is visited from a phone or tablet with plain js:

if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
    //Do stuff
}

Or use a 3rd party library such as wurfl.io to detect only tablet users:

if (WURFL.is_mobile === true && WURFL.form_factor === "Tablet") {
    //Do stuff
}


问:
How do you parse a poorly formatted HTML file?
I have to parse a series of web pages in order to import data into an application. Each type of web page provides the same kind of data. The problem is that the HTML of each page is different, so the location of the data varies. Another problem is that the HTML code is poorly formatted, making it impossible to use a XML-like parser.

So far, the best strategy I can think of, is to define a template for each kind of page, like:

Template A:

```<code><html>
...
  <tr><td>Table column that is missing a td
      <td> Another table column</td></tr>
  <tr><td>$data_item_1$</td>
...
</html>
</code>```

Template B:

```<code><html>
...
  <ul><li>Yet another poorly formatted page <li>$data_item_1$</td></tr>
...
</html>
</code>```

This way I would only need one single parser for all the pages, that would compare each page with its template and retrieving the $data_item_1$, $data_item_2$, etc.  Still, it is going to be a lot of work.  Can you think of any simpler solution? Any library that can help?

Thanks

答:
You can pass the page's source through tidy to get a valid page. You can find tidy here
. Tidy has bindings for a lot of programming languages. After you've done this, you can use your favorite parser/content extraction technique.</p>

OwnerDisplayName: ivo

ContentLicense: CC BY-SA 2.5

Body:
I have to parse a series of web pages in order to import data into an application. Each type of web page provides the same kind of data. The problem is that the HTML of each page is different, so the location of the data varies. Another problem is that the HTML code is poorly formatted, making it impossible to use a XML-like parser.

So far, the best strategy I can think of, is to define a template for each kind of page, like:

Template A:

...

Table column that is missing a td
       Another table column

$data_item_1$
...

Template B:

...

Yet another poorly formatted page
$data_item_1$

...

This way I would only need one single parser for all the pages, that would compare each page with its template and retrieving the $data_item_1$, $data_item_2$, etc.  Still, it is going to be a lot of work.  Can you think of any simpler solution? Any library that can help?

Thanks

LastEditorDisplayName: Eddie

OwnerDisplayName: Geo


问:
How to connect to AWS RabbitMQ from C#?
In my C# application, I have this code:

```<code>var factory = new ConnectionFactory
        {
            Port = 5671,
            UserName = "userxxxx",
            Password = "passwordxxx",
            HostName = "amqps://xxxx.mq.us-east-1.amazonaws.com"
        };
        using var connection = factory.CreateConnection();
</code>```

But during the CreateConnection I receive:

```<code>RabbitMQ.Client.Exceptions.BrokerUnreachableException
   HResult=0x80131620
   Message=None of the specified endpoints were reachable
   Source=RabbitMQ.Client
</code>```

The AWS Console shows me:

Endpoint: amqps://xxxx.mq.us-east-1.amazonaws.com:5671

What am I doing wrong?

答:
Use a tool like "netcat" to verify you can connect to port 5671 on the AWS MQ.  Netcat should be used from the same host you are trying to connect from.  Alternatively, consider using a cloud-based portscanner like https://www.whatismyip.com/port-scanner/ to take your local network out of the equation.

Successful example with netcat:

$ nc -vz myownawsmq.mq.us-east-1.amazonaws.com 5671
Connection to  myownawsmq.mq.us-east-1.amazonaws.com 5671 port [tcp/amqps] succeeded!

If you get an error or timeout, then your URL is incorrect or port 5671 is blocked.

When I created my AWS RabbitMQ instance, port 5671 was open to the internet because publicly accessible is the default. You cannot use a security group with RabbitMQ instance that is publicly accessible. If you set Private Access for the RabbitMQ instance, you won't be able to reach it externally.

It's also possible 5671 is blocked by local firewall rules. Check the firewall configuration in your local network to make sure 5671 is allowed.  If a cloud-based port scanner can connect to the port, but a local scan can't, it's probably your local network configuration.

Title: How to connect to AWS RabbitMQ from C#?

Body:
In my C# application, I have this code:

var factory = new ConnectionFactory
        {
            Port = 5671,
            UserName = "userxxxx",
            Password = "passwordxxx",
            HostName = "amqps://xxxx.mq.us-east-1.amazonaws.com"
        };
        using var connection = factory.CreateConnection();

But during the CreateConnection I receive:

RabbitMQ.Client.Exceptions.BrokerUnreachableException
   HResult=0x80131620
   Message=None of the specified endpoints were reachable
   Source=RabbitMQ.Client

The AWS Console shows me:

Endpoint: amqps://xxxx.mq.us-east-1.amazonaws.com:5671

What am I doing wrong?


问:
Cypress sees undefined when reffering to an aliased text value
My test results in adding a row to the table. In afterEach hook I wanted to add a method to delete the newest row after the test ran so I wrote this piece of code:

```<code>deleteTheNewestRequest() {
    cy.get('table#return-request-list').find('tr').eq(1).then( firstRow => {
        cy.wrap(firstRow).find('td').eq(0).invoke('text').as('rowId')
        cy.wrap(firstRow).find('a[title="Delete"]').click()
        cy.get('button.btn-delete-return-request').click()
        cy.wrap(firstRow).find('td').first().should('not.have.text', this.rowId)
    })
}
</code>```

With 'then' I'm saving a table element to later use to find and operate on the elements inside it. I wanted to first save the value of the newest row in the table that was added after the test ran successfully, then delete and as the last step make sure that the row with the ID that was deleted is actually gone from the table. The problem is that cypress test runner assertions marks it green because it sees that value of  is not equal to 'undefined' and not, let's say 3794.

答:
This looks like the culprit cy.get('table#return-request-list').find('tr').eq(1). You get the row you want to delete, you delete it, then you wrapping the delete row element even though it does not exist. So it will return undefined. You should instead get all rows initially.

```<code>function deleteTheNewestRequest(){
    // get all rows in table
    cy.get('table#return-request-list').find('tr').then( rows => {
        // get last row and store rowId
        cy.wrap(rows).last().find('td').first().invoke('text').as('deletedRowId')
        cy.wrap(rows).last().find('a[title="Delete"]').click()
        cy.get('button.btn-delete-return-request').click()
        // check new last row does not have same rowId
        cy.wrap(rows).last().find('td').first().should('not.have.text', this.rowId)
    })
}
</code>```

Body:
My test results in adding a row to the table. In afterEach hook I wanted to add a method to delete the newest row after the test ran so I wrote this piece of code:

deleteTheNewestRequest() {
    cy.get('table#return-request-list').find('tr').eq(1).then( firstRow => {
        cy.wrap(firstRow).find('td').eq(0).invoke('text').as('rowId')
        cy.wrap(firstRow).find('a[title="Delete"]').click()
        cy.get('button.btn-delete-return-request').click()
        cy.wrap(firstRow).find('td').first().should('not.have.text', this.rowId)
    })
}

With 'then' I'm saving a table element to later use to find and operate on the elements inside it. I wanted to first save the value of the newest row in the table that was added after the test ran successfully, then delete and as the last step make sure that the row with the ID that was deleted is actually gone from the table. The problem is that cypress test runner assertions marks it green because it sees that value of  is not equal to 'undefined' and not, let's say 3794.

Body:
This looks like the culprit cy.get('table#return-request-list').find('tr').eq(1). You get the row you want to delete, you delete it, then you wrapping the delete row element even though it does not exist. So it will return undefined. You should instead get all rows initially.

function deleteTheNewestRequest(){
    // get all rows in table
    cy.get('table#return-request-list').find('tr').then( rows => {
        // get last row and store rowId
        cy.wrap(rows).last().find('td').first().invoke('text').as('deletedRowId')
        cy.wrap(rows).last().find('a[title="Delete"]').click()
        cy.get('button.btn-delete-return-request').click()
        // check new last row does not have same rowId
        cy.wrap(rows).last().find('td').first().should('not.have.text', this.rowId)
    })
}


问:
Multiple instances in Add/Remove program Wix
I'm using WixSharp to build an installer.

Using Major Upgrade element works as excepted(upgrade and downgrade)

I don't want multiple instances to be installed.

I've copy msi file in two location in the PC,

so I have two files: a.msi and b.msi with same version and upgrade code and different ProductId

installing a.msi works as excepted(open gui with remove option)

installing b.msi didn't work as excepted(install the product instead of saying that this is installed)

In Add/Remove programs I have two entries with same version.
How can I to disable it?

答:
you can do this in two ways.

You can make the ProductId the same so that Windows sees that you install the same thing instead of thinking you are installing two different components (ProductId) of the same softwaresuite (UpgradeCode). This will result in an errormessage that the product is already installed until you increase the version.

Or

You can configure an upgrade fragment.

```<code><Upgrade Id='$(var.UpgradeCode)'>
  <UpgradeVersion OnlyDetect='no' Property='ISUPGRADE'
                  Minimum='1.0' IncludeMinimum='yes'
                  Maximum='$(var.ProductVersion)' IncludeMaximum='yes' />
</Upgrade>
</code>```

which will uninstall the existing version and install the currently running setup.

Body:
you can do this in two ways.

You can make the ProductId the same so that Windows sees that you install the same thing instead of thinking you are installing two different components (ProductId) of the same softwaresuite (UpgradeCode). This will result in an errormessage that the product is already installed until you increase the version.

Or

You can configure an upgrade fragment.

<Upgrade Id='$(var.UpgradeCode)'>
  <UpgradeVersion OnlyDetect='no' Property='ISUPGRADE'
                  Minimum='1.0' IncludeMinimum='yes'
                  Maximum='$(var.ProductVersion)' IncludeMaximum='yes' />
</Upgrade>

which will uninstall the existing version and install the currently running setup.


问:
Find tables & columns that will have the specific data in oracle
I want to find the columns in all the tables that could have the specific data or value in Oracle.

Example:tom@gmail.com

How can I narrow down on the tables that might have the email value?

--TABLE OR VIEW DOES NOT EXIST

```<code>SET SERVEROUTPUT ON SIZE 100000

DECLARE
  match_count INTEGER;
-- Type the owner of the tables you are looking at
  v_owner VARCHAR2(255) :='GWEB';

-- Type the data type you are look at (in CAPITAL)
-- VARCHAR2, NUMBER, etc.
  v_data_type VARCHAR2(255) :='VARCHAR2';

-- Type the string you are looking at
  v_search_string VARCHAR2(4000) :='tom@gmail.com';

BEGIN
  FOR t IN (SELECT table_name, column_name FROM all_tab_cols where owner=v_owner and data_type = v_data_type) LOOP

    EXECUTE IMMEDIATE
    'SELECT COUNT(*) FROM '||t.table_name||' WHERE '||t.column_name||' = :1'
    INTO match_count
    USING v_search_string;

    IF match_count > 0 THEN
      dbms_output.put_line( t.table_name ||' '||t.column_name||' '||match_count );
    END IF;

  END LOOP;
END;
</code>```

答:
You:

Do not consider the owner of the table in the dynamic query.

May need to quote the identifiers.

Can also filter on the data_length.

Like this:

DECLARE
  match_count     INTEGER;
  v_owner         VARCHAR2(255)  := 'GWEB';
  v_data_type     VARCHAR2(255)  := 'VARCHAR2';
  v_search_string VARCHAR2(4000) :='tom@example.com';
BEGIN
  FOR t IN (
    SELECT table_name,
           column_name
    FROM   all_tab_cols
    WHERE  owner       = v_owner
    AND    data_type   = v_data_type
    AND    data_length >= LENGTH(v_search_string)
  )
  LOOP
    EXECUTE IMMEDIATE
        'SELECT COUNT(*)'
      || ' FROM "'||v_owner||'"."'||t.table_name||'"'
      || ' WHERE "'||t.column_name||'" = :1'
    INTO match_count
    USING v_search_string;

    IF match_count > 0 THEN
      dbms_output.put_line( t.table_name ||' '||t.column_name||' '||match_count );
    END IF;
  END LOOP;
END;
/
```

db<>fiddle here

Body:
I want to find the columns in all the tables that could have the specific data or value in Oracle.

Example:tom@gmail.com

How can I narrow down on the tables that might have the email value?

--TABLE OR VIEW DOES NOT EXIST

SET SERVEROUTPUT ON SIZE 100000

DECLARE
  match_count INTEGER;
-- Type the owner of the tables you are looking at
  v_owner VARCHAR2(255) :='GWEB';

-- Type the data type you are look at (in CAPITAL)
-- VARCHAR2, NUMBER, etc.
  v_data_type VARCHAR2(255) :='VARCHAR2';

-- Type the string you are looking at
  v_search_string VARCHAR2(4000) :='tom@gmail.com';

BEGIN
  FOR t IN (SELECT table_name, column_name FROM all_tab_cols where owner=v_owner and data_type = v_data_type) LOOP

    EXECUTE IMMEDIATE
    'SELECT COUNT(*) FROM '||t.table_name||' WHERE '||t.column_name||' = :1'
    INTO match_count
    USING v_search_string;

    IF match_count > 0 THEN
      dbms_output.put_line( t.table_name ||' '||t.column_name||' '||match_count );
    END IF;

  END LOOP;
END;

Body:
You:

Do not consider the owner of the table in the dynamic query.

May need to quote the identifiers.

Can also filter on the data_length.

Like this:

DECLARE
  match_count     INTEGER;
  v_owner         VARCHAR2(255)  := 'GWEB';
  v_data_type     VARCHAR2(255)  := 'VARCHAR2';
  v_search_string VARCHAR2(4000) :='tom@example.com';
BEGIN
  FOR t IN (
    SELECT table_name,
           column_name
    FROM   all_tab_cols
    WHERE  owner       = v_owner
    AND    data_type   = v_data_type
    AND    data_length >= LENGTH(v_search_string)
  )
  LOOP
    EXECUTE IMMEDIATE
        'SELECT COUNT(*)'
      || ' FROM "'||v_owner||'"."'||t.table_name||'"'
      || ' WHERE "'||t.column_name||'" = :1'
    INTO match_count
    USING v_search_string;

    IF match_count > 0 THEN
      dbms_output.put_line( t.table_name ||' '||t.column_name||' '||match_count );
    END IF;
  END LOOP;
END;
/

db<>fiddle here


问:
How to limit the amount of simultaneously running jobs of a certain "type"?
I would like to be able to limit the amount of jobs of a given "type" that run at the same time (maybe based on their label, e.g. no more than N jobs with label mylabel may run at the same time).

I have a long running computation that requires a license key to run.  I have N license keys and I would like to limit the amount of simultaneously running jobs to N. Here's how I imagine it working: I label the jobs with some special tag.  Then, I schedule N + K jobs, then at most N jobs may be in state "running" and K jobs should be in the queue and may only transition to "running" state when the total number of running jobs labeled mytag is less or equal to N.

[UPDATE]

The jobs are independent of each other.

The execution order is not important, although I would like them to be FIFO (time wise).

The jobs are scheduled on user requests. That is, there is no fixed amount of work known in advance that needs to be processed, the requests to run a job with some set of parameters (configuration file) come sporadically in time.

答:
Unfortunately there is no built-in feature to do it using labels in k8s. But since your jobs are scheduled based on unpredictable user requests, you can achieve your goal like this:

create a new namespace kubectl create namespace quota-pod-ns

create a ResourceQuota

apiVersion: v1
kind: ResourceQuota
metadata:
  name: pod-max-number
  namespace: quota-pod-ns
spec:
  hard:
    pods: "5"
```

This  will limit max number of pods to 5 in the namespace quota-pod-ns.

create k8s jobs in the quota-pod-ns namespace.

When you want to run the 6th job in that namespace, k8s will try to create the 6th pod and will fail to do that. But once one of the running pods is Completed, job-controller will create that new pod within a max limit.

Body:
Unfortunately there is no built-in feature to do it using labels in k8s. But since your jobs are scheduled based on unpredictable user requests, you can achieve your goal like this:

create a new namespace kubectl create namespace quota-pod-ns

create a ResourceQuota

apiVersion: v1
kind: ResourceQuota
metadata:
  name: pod-max-number
  namespace: quota-pod-ns
spec:
  hard:
    pods: "5"

This  will limit max number of pods to 5 in the namespace quota-pod-ns.

create k8s jobs in the quota-pod-ns namespace.

When you want to run the 6th job in that namespace, k8s will try to create the 6th pod and will fail to do that. But once one of the running pods is Completed, job-controller will create that new pod within a max limit.


问:
How should I use ccache if the compiler absolute path is hard-coded in the makefile?
It's not an option for me to modify the complicated nest of makefiles that builds our code, and in various places they construct absolute paths to very specific compilers, e.g. /home/arm2gcc/gcc-arm-none-eabi-8-2018-q4-major/bin/arm-none-eabi-gcc

That makes it hard to use ccache either as a prefix or by putting it first in the path.

So I wonder about moving the compiler installations on my personal machine to e.g. /home/arm2gcc-real and putting fake scripts in /home/arm2gcc that redirect to the real compilers.

Can anyone suggest how to do this? Or is there a better way?

答:
Disclaimer: I've only limited experience with Ccache and CMake.

Can you try adding this in the root CMakeLists.txt file:

```<code>find_program(CCACHE ccache)
if(CCACHE)
    set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE})
endif()
</code>```

If that does not work, I think we may need some more info on how the compilers are setup exactly in your CMakeLists.txt files.

Body:
Disclaimer: I've only limited experience with Ccache and CMake.

Can you try adding this in the root CMakeLists.txt file:

find_program(CCACHE ccache)
if(CCACHE)
    set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE})
endif()

If that does not work, I think we may need some more info on how the compilers are setup exactly in your CMakeLists.txt files.


问:
Filter apache files using linux
I'm trying to filter down a heap of apache log files to EXCLUDE all requests that have:

The pattern /static/  (this is my images/js folder that I want to exclude)

10.xxx.xxx.xxx (where x is any number - I don't want internal requests included)

Any response other than "GET / HTTP/1.1" 200 - only want successes

I have a folder containing multiple .gz files. Is there a way to run a linux command that will do the proper filtering and save the results in a file called apache_log.txt?

I'm really limited in my linux knowledge so will appreciate any help greatly!

答:
For each file *.gz, uncompress and filter out unwanted static and local, and filter wanted "GET 200", and append this in result file.

```<code>for f in *.gz ; do zcat $f | grep -v '/static/' | grep -v '10\.[0-9]\+\.\.[0-9]\+\.[0-9]\+' | grep 'GET / HTTP/1.1" 200' >> apache_log.txt ; done
</code>```

Or on multiple lines.

```<code>for f in *.gz
do
    zcat $f \
        | grep -v '/static/' \
        | grep -v '10\.[0-9]\+\.\.[0-9]\+\.[0-9]\+' \
        | grep 'GET / HTTP/1.1" 200' \
        >> apache_log.txt
done
</code>```

Title: Filter apache files using linux

Body:
For each file *.gz, uncompress and filter out unwanted static and local, and filter wanted "GET 200", and append this in result file.

for f in *.gz ; do zcat $f | grep -v '/static/' | grep -v '10\.[0-9]\+\.\.[0-9]\+\.[0-9]\+' | grep 'GET / HTTP/1.1" 200' >> apache_log.txt ; done

Or on multiple lines.

for f in *.gz
do
    zcat $f \
        | grep -v '/static/' \
        | grep -v '10\.[0-9]\+\.\.[0-9]\+\.[0-9]\+' \
        | grep 'GET / HTTP/1.1" 200' \
        >> apache_log.txt
done


问:
Google drive edit link for not logged in users
I need to share files with others so that they can see and edit my google docs without logging into google.

I created correctly permissions for writing for "anyone with the link", and I can only view that file as not logged into google because I don't have an edit button, that button is only visible for logged-in users.
For the spreadsheet I resolved this problem, because the edit link is always the same, with google-file-id like this: https://docs.google.com/spreadsheets/d/{33_character_google_id}/edit

But for other files, the edit link looks like this: https://docs.google.com/document/d/{44_character_hash}/edit

I have no idea where this hash is coming from

Is it possible to prepare that hash or get him from API?

答:
The problem was more complicated than I thought.
I didn't get webLink from DriveFile in response after upload, and also I was getting an object with webViewLink only for read after download - I don't know for what reason.

But the solution was to download webViewLink by this one line of code:

```<code>$this->googleServiceDrive->files->get($googleId, ['fields' => 'webViewLink'])
</code>```

(BTW I have read somewhere that webViewLink stores edit link if edition is possible by google editor, and stores read link if not).

Body:
The problem was more complicated than I thought.
I didn't get webLink from DriveFile in response after upload, and also I was getting an object with webViewLink only for read after download - I don't know for what reason.

But the solution was to download webViewLink by this one line of code:

$this->googleServiceDrive->files->get($googleId, ['fields' => 'webViewLink'])

(BTW I have read somewhere that webViewLink stores edit link if edition is possible by google editor, and stores read link if not).


问:
Multiple Errors Relating Kotlin Version
After restarting my project with almost no changes I suddenly got this errorlog:

```<code>Incompatible classes were found in dependencies. Remove them from the classpath or use '-Xskip-metadata-version-check' to suppress errors
e: C:/Users/Gerald/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.5.31/43331609c7de811fed085e0dfd150874b157c32/kotlin-stdlib-common-1.5.31.jar!/META-INF/kotlin-stdlib-common.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
e: C:/Users/Gerald/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.5.30/525f5a7fa6d7790a571c07dd24214ed2dda352fe/kotlin-stdlib-jdk7-1.5.30.jar!/META-INF/kotlin-stdlib-jdk7.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
e: C:/Users/Gerald/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk8/1.5.30/5fd47535cc85f9e24996f939c2de6583991481b0/kotlin-stdlib-jdk8-1.5.30.jar!/META-INF/kotlin-stdlib-jdk8.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
e: C:/Users/Gerald/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.5.31/6628d61d0f5603568e72d2d5915d2c034b4f1c55/kotlin-stdlib-1.5.31.jar!/META-INF/kotlin-stdlib.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
e: C:/Users/Gerald/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlinx/kotlinx-coroutines-android/1.5.2/d246a704a55b7bddb79407cce4348890eaa341d9/kotlinx-coroutines-android-1.5.2.jar!/META-INF/kotlinx-coroutines-android.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
e: C:/Users/Gerald/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlinx/kotlinx-coroutines-core-jvm/1.5.2/f4cc07a50437659e0043e7da762809a46932b6a0/kotlinx-coroutines-core-jvm-1.5.2.jar!/META-INF/kotlinx-coroutines-core.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
e: C:/Users/Gerald/.gradle/caches/transforms-2/files-2.1/510d2c0b665cbe8abe1bcbf4bf8b6987/window-java-1.0.0-beta04/jars/classes.jar!/META-INF/window-java_release.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
e: C:/Users/Gerald/.gradle/caches/transforms-2/files-2.1/7ad239db5bbf66449a1f587f3afa295b/jetified-window-1.0.0-beta04/jars/classes.jar!/META-INF/window_release.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
e: C:\flutter\.pub-cache\hosted\pub.dartlang.org\maps_launcher-2.0.1\android\src\main\kotlin\com\example\maps_launcher\MapsLauncherPlugin.kt: (20, 5): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.

The class is loaded from C:/Users/Gerald/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.5.31/6628d61d0f5603568e72d2d5915d2c034b4f1c55/kotlin-stdlib-1.5.31.jar!/kotlin/Unit.class
e: C:\flutter\.pub-cache\hosted\pub.dartlang.org\maps_launcher-2.0.1\android\src\main\kotlin\com\example\maps_launcher\MapsLauncherPlugin.kt: (21, 13): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
The class is loaded from C:/Users/Gerald/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.5.31/6628d61d0f5603568e72d2d5915d2c034b4f1c55/kotlin-stdlib-1.5.31.jar!/kotlin/Unit.class
e: C:\flutter\.pub-cache\hosted\pub.dartlang.org\maps_launcher-2.0.1\android\src\main\kotlin\com\example\maps_launcher\MapsLauncherPlugin.kt: (25, 5): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.

The class is loaded from C:/Users/Gerald/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.5.31/6628d61d0f5603568e72d2d5915d2c034b4f1c55/kotlin-stdlib-1.5.31.jar!/kotlin/Unit.class
e: C:\flutter\.pub-cache\hosted\pub.dartlang.org\maps_launcher-2.0.1\android\src\main\kotlin\com\example\maps_launcher\MapsLauncherPlugin.kt: (26, 14): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
The class is loaded from C:/Users/Gerald/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.5.31/6628d61d0f5603568e72d2d5915d2c034b4f1c55/kotlin-stdlib-1.5.31.jar!/kotlin/Unit.class
e: C:\flutter\.pub-cache\hosted\pub.dartlang.org\maps_launcher-2.0.1\android\src\main\kotlin\com\example\maps_launcher\MapsLauncherPlugin.kt: (28, 14): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.

 C:/Users/Gerald/.gradle/caches/transforms-2/files-2.1/7ad239db5bbf66449a1f587f3afa295b/jetified-window-1.0.0-beta04/jars/classes.jar!/META-INF/window_release.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
e: C:\flutter\.pub-cache\hosted\pub.dartlang.org\maps_launcher-2.0.1\android\src\main\kotlin\com\example\maps_launcher\MapsLauncherPlugin.kt: (20, 5): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.

The class is loaded from C:/Users/Gerald/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.5.31/6628d61d0f5603568e72d2d5915d2c034b4f1c55/kotlin-stdlib-1.5.31.jar!/kotlin/Unit.class
e: C:\flutter\.pub-cache\hosted\pub.dartlang.org\maps_launcher-2.0.1\android\src\main\kotlin\com\example\maps_launcher\MapsLauncherPlugin.kt: (21, 13): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
The class is loaded from C:/Users/Gerald/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.5.31/6628d61d0f5603568e72d2d5915d2c034b4f1c55/kotlin-stdlib-1.5.31.jar!/kotlin/Unit.class
e: C:\flutter\.pub-cache\hosted\pub.dartlang.org\maps_launcher-2.0.1\android\src\main\kotlin\com\example\maps_launcher\MapsLauncherPlugin.kt: (25, 5): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.

The class is loaded from C:/Users/Gerald/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.5.31/6628d61d0f5603568e72d2d5915d2c034b4f1c55/kotlin-stdlib-1.5.31.jar!/kotlin/Unit.class
e: C:\flutter\.pub-cache\hosted\pub.dartlang.org\maps_launcher-2.0.1\android\src\main\kotlin\com\example\maps_launcher\MapsLauncherPlugin.kt: (26, 14): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
The class is loaded from C:/Users/Gerald/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.5.31/6628d61d0f5603568e72d2d5915d2c034b4f1c55/kotlin-stdlib-1.5.31.jar!/kotlin/Unit.class
e: C:\flutter\.pub-cache\hosted\pub.dartlang.org\maps_launcher-2.0.1\android\src\main\kotlin\com\example\maps_launcher\MapsLauncherPlugin.kt: (28, 14): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.

The class is loaded from C:/Users/Gerald/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.5.31/6628d61d0f5603568e72d2d5915d2c034b4f1c55/kotlin-stdlib-1.5.31.jar!/kotlin/Unit.class
e: C:\flutter\.pub-cache\hosted\pub.dartlang.org\maps_launcher-2.0.1\android\src\main\kotlin\com\example\maps_launcher\MapsLauncherPlugin.kt: (33, 13): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.

The class is loaded from C:/Users/Gerald/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.5.31/6628d61d0f5603568e72d2d5915d2c034b4f1c55/kotlin-stdlib-1.5.31.jar!/kotlin/Unit.class

</code>```

Flutter says I have to add a line in my android/build.gradle, after doing that, nothing happens
I have also tried clearing all the caches, same error.

```<code>buildscript {
    ext.kotlin_version = '1.6.10' // line to add
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.1'
        classpath 'com.google.gms:google-services:4.3.8'
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
    project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

</code>```

I have also tried to downgrade 'com.android.tools.build:gradle:3.5.1' to 3.2.1 after reading a thread about it.
Error of trying that

```<code>Where:
Build file 'E:\GitHub\BauFuchs\baufuchs\android\app\build.gradle' line: 24

* What went wrong:
A problem occurred evaluating project ':app'.
> ASCII
</code>```

Line 24 of app build.gradle
apply plugin: 'com.android.application'
Thanks for your help I have to start working again I can't do anything

答:
I fixed it

I created a temporary Flutter project, looked at the android/build.gradle, updated the versions of the classpaths and looked into android/gradle/gralde-wrapper.properties and copied the distribution aswell.

Title: Multiple Errors Relating Kotlin Version

Body:
After restarting my project with almost no changes I suddenly got this errorlog:

Incompatible classes were found in dependencies. Remove them from the classpath or use '-Xskip-metadata-version-check' to suppress errors
e: C:/Users/Gerald/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.5.31/43331609c7de811fed085e0dfd150874b157c32/kotlin-stdlib-common-1.5.31.jar!/META-INF/kotlin-stdlib-common.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
e: C:/Users/Gerald/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.5.30/525f5a7fa6d7790a571c07dd24214ed2dda352fe/kotlin-stdlib-jdk7-1.5.30.jar!/META-INF/kotlin-stdlib-jdk7.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
e: C:/Users/Gerald/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk8/1.5.30/5fd47535cc85f9e24996f939c2de6583991481b0/kotlin-stdlib-jdk8-1.5.30.jar!/META-INF/kotlin-stdlib-jdk8.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
e: C:/Users/Gerald/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.5.31/6628d61d0f5603568e72d2d5915d2c034b4f1c55/kotlin-stdlib-1.5.31.jar!/META-INF/kotlin-stdlib.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
e: C:/Users/Gerald/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlinx/kotlinx-coroutines-android/1.5.2/d246a704a55b7bddb79407cce4348890eaa341d9/kotlinx-coroutines-android-1.5.2.jar!/META-INF/kotlinx-coroutines-android.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
e: C:/Users/Gerald/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlinx/kotlinx-coroutines-core-jvm/1.5.2/f4cc07a50437659e0043e7da762809a46932b6a0/kotlinx-coroutines-core-jvm-1.5.2.jar!/META-INF/kotlinx-coroutines-core.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
e: C:/Users/Gerald/.gradle/caches/transforms-2/files-2.1/510d2c0b665cbe8abe1bcbf4bf8b6987/window-java-1.0.0-beta04/jars/classes.jar!/META-INF/window-java_release.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
e: C:/Users/Gerald/.gradle/caches/transforms-2/files-2.1/7ad239db5bbf66449a1f587f3afa295b/jetified-window-1.0.0-beta04/jars/classes.jar!/META-INF/window_release.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
e: C:\flutter\.pub-cache\hosted\pub.dartlang.org\maps_launcher-2.0.1\android\src\main\kotlin\com\example\maps_launcher\MapsLauncherPlugin.kt: (20, 5): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.

The class is loaded from C:/Users/Gerald/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.5.31/6628d61d0f5603568e72d2d5915d2c034b4f1c55/kotlin-stdlib-1.5.31.jar!/kotlin/Unit.class
e: C:\flutter\.pub-cache\hosted\pub.dartlang.org\maps_launcher-2.0.1\android\src\main\kotlin\com\example\maps_launcher\MapsLauncherPlugin.kt: (21, 13): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
The class is loaded from C:/Users/Gerald/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.5.31/6628d61d0f5603568e72d2d5915d2c034b4f1c55/kotlin-stdlib-1.5.31.jar!/kotlin/Unit.class
e: C:\flutter\.pub-cache\hosted\pub.dartlang.org\maps_launcher-2.0.1\android\src\main\kotlin\com\example\maps_launcher\MapsLauncherPlugin.kt: (25, 5): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.

The class is loaded from C:/Users/Gerald/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.5.31/6628d61d0f5603568e72d2d5915d2c034b4f1c55/kotlin-stdlib-1.5.31.jar!/kotlin/Unit.class
e: C:\flutter\.pub-cache\hosted\pub.dartlang.org\maps_launcher-2.0.1\android\src\main\kotlin\com\example\maps_launcher\MapsLauncherPlugin.kt: (26, 14): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
The class is loaded from C:/Users/Gerald/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.5.31/6628d61d0f5603568e72d2d5915d2c034b4f1c55/kotlin-stdlib-1.5.31.jar!/kotlin/Unit.class
e: C:\flutter\.pub-cache\hosted\pub.dartlang.org\maps_launcher-2.0.1\android\src\main\kotlin\com\example\maps_launcher\MapsLauncherPlugin.kt: (28, 14): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.

 C:/Users/Gerald/.gradle/caches/transforms-2/files-2.1/7ad239db5bbf66449a1f587f3afa295b/jetified-window-1.0.0-beta04/jars/classes.jar!/META-INF/window_release.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
e: C:\flutter\.pub-cache\hosted\pub.dartlang.org\maps_launcher-2.0.1\android\src\main\kotlin\com\example\maps_launcher\MapsLauncherPlugin.kt: (20, 5): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.

The class is loaded from C:/Users/Gerald/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.5.31/6628d61d0f5603568e72d2d5915d2c034b4f1c55/kotlin-stdlib-1.5.31.jar!/kotlin/Unit.class
e: C:\flutter\.pub-cache\hosted\pub.dartlang.org\maps_launcher-2.0.1\android\src\main\kotlin\com\example\maps_launcher\MapsLauncherPlugin.kt: (21, 13): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
The class is loaded from C:/Users/Gerald/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.5.31/6628d61d0f5603568e72d2d5915d2c034b4f1c55/kotlin-stdlib-1.5.31.jar!/kotlin/Unit.class
e: C:\flutter\.pub-cache\hosted\pub.dartlang.org\maps_launcher-2.0.1\android\src\main\kotlin\com\example\maps_launcher\MapsLauncherPlugin.kt: (25, 5): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.

The class is loaded from C:/Users/Gerald/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.5.31/6628d61d0f5603568e72d2d5915d2c034b4f1c55/kotlin-stdlib-1.5.31.jar!/kotlin/Unit.class
e: C:\flutter\.pub-cache\hosted\pub.dartlang.org\maps_launcher-2.0.1\android\src\main\kotlin\com\example\maps_launcher\MapsLauncherPlugin.kt: (26, 14): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
The class is loaded from C:/Users/Gerald/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.5.31/6628d61d0f5603568e72d2d5915d2c034b4f1c55/kotlin-stdlib-1.5.31.jar!/kotlin/Unit.class
e: C:\flutter\.pub-cache\hosted\pub.dartlang.org\maps_launcher-2.0.1\android\src\main\kotlin\com\example\maps_launcher\MapsLauncherPlugin.kt: (28, 14): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.

The class is loaded from C:/Users/Gerald/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.5.31/6628d61d0f5603568e72d2d5915d2c034b4f1c55/kotlin-stdlib-1.5.31.jar!/kotlin/Unit.class
e: C:\flutter\.pub-cache\hosted\pub.dartlang.org\maps_launcher-2.0.1\android\src\main\kotlin\com\example\maps_launcher\MapsLauncherPlugin.kt: (33, 13): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.

The class is loaded from C:/Users/Gerald/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.5.31/6628d61d0f5603568e72d2d5915d2c034b4f1c55/kotlin-stdlib-1.5.31.jar!/kotlin/Unit.class

Flutter says I have to add a line in my android/build.gradle, after doing that, nothing happens
I have also tried clearing all the caches, same error.

buildscript {
    ext.kotlin_version = '1.6.10' // line to add
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.1'
        classpath 'com.google.gms:google-services:4.3.8'
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
    project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

I have also tried to downgrade 'com.android.tools.build:gradle:3.5.1' to 3.2.1 after reading a thread about it.
Error of trying that

Where:
Build file 'E:\GitHub\BauFuchs\baufuchs\android\app\build.gradle' line: 24

* What went wrong:
A problem occurred evaluating project ':app'.
> ASCII

Line 24 of app build.gradle
apply plugin: 'com.android.application'
Thanks for your help I have to start working again I can't do anything


Title: 'cut' function for date column not labeling actual dates from data

Body:
I'm trying to bin a date column by every 7 days. If the following date does not land within the 7 days of the previous date, I want the bin to start from that new date and check 7 days forward. I'm using the cut function, but I can't seem to get the function to "start over" when it reaches a new date that doesn't fall within the interval. I have an example below:

 ex <- structure(list(svcdate_form = structure(c(17700, 17700, 17700,
17711, 17711, 17711, 17714, 17714, 17714), class = "Date"), map = structure(c(42L,
42L, 42L, 4L, 4L, 4L, 43L, 43L, 43L), .Label = c("2019-12-05",
"2018-08-28", "2018-08-13", "2018-06-25", "2018-04-11", "2019-06-03",
"2019-04-15", "2019-04-22", "2019-04-29", "2019-05-06", "2019-05-13",
"2019-05-20", "2019-05-27", "2019-11-21", "2019-05-21", "2019-08-21",
"2019-05-23", "2018-12-03", "2018-11-08", "2018-11-15", "2019-11-11",
"2019-06-20", "2019-12-23", "2018-08-15", "2018-08-22", "2018-08-29",
"2018-09-05", "2018-01-12", "2018-04-28", "2019-03-15", "2019-04-04",
"2019-02-12", "2019-10-14", "2019-12-15", "2019-02-26", "2019-03-05",
"2018-07-18", "2018-10-03", "2018-01-29", "2018-02-05", "2018-02-12",
"2018-06-18", "2018-07-02", "2019-01-22", "2018-10-26", "2018-02-28",
"2018-03-07", "2019-11-18", "2019-12-17", "2019-07-24", "2019-11-14",
"2018-02-07", "2018-11-05", "2018-02-13", "2018-08-14", "2018-08-21",
"2018-09-04", "2018-09-11", "2018-09-18", "2018-09-25", "2018-10-02",
"2018-10-09", "2018-10-16", "2018-10-23", "2018-10-30", "2018-01-03",
"2019-02-05", "2019-01-18", "2019-04-09", "2019-04-10", "2019-04-17",
"2019-12-13", "2018-11-27", "2018-12-04", "2018-12-11", "2018-04-01",
"2018-03-01", "2018-05-14", "2019-01-28", "2019-02-04", "2018-05-15",
"2018-02-21", "2018-03-14", "2018-03-21", "2018-12-20", "2019-02-14",
"2018-04-16", "2019-01-08", "2019-02-21", "2019-02-28", "2019-03-07",
"2019-03-14", "2018-06-12", "2018-06-19", "2018-06-26", "2018-07-03",
"2018-07-10", "2018-07-17", "2018-07-24", "2018-07-31", "2018-11-20",
"2019-09-06", "2018-06-13", "2018-07-30", "2019-02-06", "2019-11-13",
"2018-12-26", "2018-08-06", "2018-07-20", "2018-03-23", "2018-09-26",
"2019-01-09", "2019-12-30", "2018-08-27", "2019-08-14", "2018-04-17",
"2019-12-20", "2019-07-16", "2019-12-03", "2018-07-23", "2018-09-19",
"2018-11-29", "2019-03-18", "2019-05-16", "2019-09-16", "2019-10-24",
"2018-02-26", "2019-08-23", "2018-03-06", "2019-03-01", "2019-01-07",
"2019-07-30", "2018-12-14", "2018-01-10", "2018-03-08", "2018-10-10",
"2019-10-15", "2019-05-29", "2019-12-19", "2019-05-14", "2019-05-28",
"2018-09-10", "2019-06-17", "2018-11-21", "2018-11-28", "2018-12-05",
"2019-04-01", "2019-10-23", "2018-11-16", "2019-03-22", "2018-06-27",
"2018-10-22", "2019-10-11", "2019-09-19", "2018-07-12", "2018-01-15",
"2019-12-31", "2019-12-02", "2018-10-31", "2019-07-13", "2019-07-20",
"2019-07-27", "2019-08-03", "2019-08-10", "2019-07-03", "2018-04-26",
"2018-03-28", "2018-04-04", "2018-04-18", "2018-04-25", "2018-05-02",
"2019-08-22", "2019-08-29", "2019-09-05", "2019-09-12", "2019-09-26",
"2019-10-03", "2019-10-10", "2019-10-17", "2019-10-31", "2019-11-07",
"2019-01-23", "2018-07-25", "2019-01-21", "2019-12-09", "2018-10-20",
"2018-02-09", "2018-04-24", "2019-11-20", "2019-08-07", "2019-01-02",
"2019-01-16", "2018-12-12", "2018-12-19", "2019-01-30", "2019-02-13",
"2019-02-20", "2019-02-27", "2019-03-06", "2019-03-13", "2019-03-20",
"2019-03-27", "2019-04-03", "2019-04-24", "2019-05-01", "2019-05-08",
"2019-05-15", "2019-06-27", "2019-03-28", "2019-06-04", "2018-04-10",
"2019-06-26", "2019-07-01", "2018-01-02", "2018-02-01", "2019-05-03",
"2019-05-09", "2018-07-06", "2019-06-24", "2019-07-08", "2019-07-15",
"2019-07-22", "2018-02-23", "2018-11-12", "2018-08-20", "2019-06-13",
"2018-10-29", "2019-11-04", "2019-03-21", "2018-07-19", "2018-02-19",
"2019-06-11", "2019-02-19", "2019-07-29", "2018-12-18", "2019-12-10",
"2019-10-30", "2019-12-01", "2019-04-02", "2019-09-03", "2019-09-10",
"2019-09-17", "2018-04-20", "2018-10-01", "2018-01-18", "2019-06-06",
"2019-12-16", "2019-03-29", "2018-03-13", "2019-07-09", "2019-07-23",
"2019-03-19", "2019-07-05", "2018-05-01", "2018-06-05", "2018-08-23",
"2019-04-30", "2018-10-19", "2018-05-31", "2018-01-11", "2019-03-25",
"2018-04-23", "2019-06-28", "2018-03-26", "2019-08-28", "2018-05-08",
"2019-02-11", "2018-08-24", "2019-06-21", "2018-08-19", "2019-07-26",
"2018-08-01", "2019-03-12", "2019-08-12", "2018-09-17", "2019-11-25",
"2019-09-23", "2018-05-05", "2019-08-20", "2018-09-27", "2018-02-16",
"2019-05-07", "2019-03-11", "2019-06-18", "2019-12-04", "2018-09-12",
"2018-12-17", "2018-03-15", "2018-02-08", "2019-04-12", "2019-08-05",
"2018-03-05", "2018-06-15", "2019-11-29", "2018-09-24", "2019-07-17",
"2019-07-31", "2018-07-09", "2018-11-19", "2018-11-26", "2018-10-24",
"2019-09-09", "2018-05-30", "2019-03-26", "2018-07-16", "2019-02-18",
"2019-02-25", "2019-03-04", "2019-05-10", "2019-09-25", "2019-09-24",
"2019-10-01", "2018-12-28", "2019-09-27", "2018-07-26", "2018-10-15",
"2018-05-29", "2018-05-04", "2019-09-13", "2019-10-28", "2018-04-30",
"2019-04-16", "2019-04-23", "2018-02-14", "2018-04-19", "2019-02-08",
"2018-05-18", "2019-12-24", "2019-01-03", "2018-05-21", "2019-06-10",
"2018-12-21", "2019-01-04", "2018-02-06", "2019-10-29", "2018-03-27",
"2018-09-06", "2019-07-12", "2019-10-07", "2019-12-12", "2018-04-03",
"2018-10-08", "2019-06-25", "2019-07-02", "2019-04-19", "2019-04-26",
"2019-05-17", "2019-05-24", "2019-05-31", "2018-11-07", "2018-11-14",
"2018-03-30", "2018-08-09", "2018-01-04", "2018-01-25", "2018-03-02",
"2018-06-06", "2018-05-07", "2018-02-20", "2018-02-27", "2019-09-04",
"2018-11-02", "2019-11-28", "2019-01-17", "2019-09-11", "2019-09-18",
"2019-12-11", "2018-01-13", "2018-01-22", "2019-11-12", "2019-10-08",
"2018-12-10", "2018-06-11", "2018-08-17", "2018-01-31", "2018-01-19",
"2019-11-16", "2018-04-02", "2018-04-09", "2018-05-28", "2018-06-04",
"2018-09-03", "2018-12-24", "2018-12-31", "2019-01-14", "2019-04-08",
"2018-06-14", "2018-06-21", "2018-06-28", "2018-07-05", "2019-08-30",
"2019-01-15", "2018-05-09", "2018-09-28", "2018-04-05", "2018-01-26",
"2018-02-02", "2018-08-10", "2019-08-26", "2018-08-31", "2019-09-30",
"2019-07-18", "2018-01-09", "2018-01-16", "2018-01-23", "2018-01-30",
"2018-08-07", "2019-03-02", "2018-01-17", "2018-01-24", "2018-05-16",
"2018-05-23", "2018-06-20", "2018-07-04", "2018-07-11", "2018-08-08",
"2018-10-17", "2019-06-19", "2019-07-10", "2018-08-03", "2019-08-06",
"2018-04-27", "2018-04-06", "2018-12-06", "2019-10-22", "2019-11-05",
"2019-11-19", "2019-11-26", "2018-05-24", "2019-02-15", "2018-03-20",
"2019-04-11", "2019-12-06", "2019-07-19", "2019-11-22", "2018-03-19",
"2019-10-02", "2019-10-09", "2019-12-27", "2019-08-27", "2019-08-02",
"2019-08-09", "2019-05-22", "2019-06-05", "2019-10-25", "2019-10-16",
"2019-11-06", "2018-05-22", "2018-01-08", "2019-10-21", "2019-01-29",
"2019-08-19", "2019-04-05", "2018-06-22", "2018-06-29", "2019-11-27",
"2018-10-12", "2018-11-25", "2019-12-26", "2018-06-07", "2019-08-15",
"2018-04-12", "2019-02-01", "2019-08-13", "2018-05-03", "2018-09-13",
"2018-09-20", "2018-10-04", "2018-10-11", "2018-10-18", "2018-10-25",
"2019-10-18", "2018-09-07", "2019-11-08", "2018-05-11", "2019-04-18",
"2019-12-07", "2018-11-13", "2018-09-21", "2019-01-11", "2018-03-29",
"2019-07-25", "2019-08-01", "2019-08-08", "2019-09-20", "2018-03-12",
"2019-06-12", "2018-12-27", "2018-07-27", "2019-07-11", "2019-09-01",
"2019-01-10", "2018-02-15", "2018-12-07", "2018-09-14", "2019-01-31",
"2018-01-05", "2018-05-10", "2019-02-02", "2018-07-08", "2018-07-15",
"2018-07-22", "2018-07-29", "2018-08-05", "2018-08-12", "2018-11-01",
"2018-03-16", "2018-11-30", "2019-11-15", "2018-08-02", "2018-02-22",
"2019-03-08", "2018-12-13", "2019-06-07", "2019-06-14", "2018-05-17",
"2018-08-04", "2018-06-08", "2018-08-30", "2018-07-13", "2019-01-24",
"2019-02-07", "2018-12-25", "2019-01-01", "2018-08-16", "2018-03-22",
"2018-11-06", "2018-04-13", "2018-05-25", "2018-06-01", "2018-11-22",
"2019-12-21", "2019-01-25", "2019-10-04", "2019-11-01", "2019-05-30",
"2019-08-16", "2019-08-25", "2019-12-18", "2018-03-09", "2019-04-25",
"2019-11-24", "2019-04-28", "2018-05-27", "2019-07-04", "2019-04-06",
"2019-01-06", "2019-02-22", "2018-10-05", "2019-12-08", "2019-06-22",
"2019-07-28", "2018-11-09", "2018-11-23", "2019-08-31", "2019-09-07",
"2019-09-14", "2019-09-21", "2019-05-18", "2019-10-19", "2019-04-14",
"2018-03-03", "2018-03-10", "2018-03-17", "2018-03-24", "2018-03-31",
"2018-04-07", "2018-12-01", "2018-12-08", "2019-05-02", "2019-06-23",
"2018-06-02", "2019-09-02", "2018-08-18", "2018-01-01", "2018-12-15",
"2018-05-26", "2018-06-09", "2019-10-06", "2019-09-15", "2019-12-14",
"2018-11-11", "2018-11-18", "2018-12-02", "2018-12-09", "2018-07-01",
"2019-05-12", "2019-10-12", "2019-10-26", "2019-09-22", "2018-09-01",
"2019-06-02", "2019-06-01", "2018-01-07", "2018-01-14", "2018-01-21",
"2018-01-28", "2018-02-04", "2018-02-11", "2018-02-18", "2018-02-25",
"2018-03-04", "2018-03-11", "2018-03-18", "2018-03-25", "2018-04-08",
"2018-04-15", "2018-04-22", "2018-04-29", "2018-05-06", "2018-05-13",
"2018-05-20", "2018-06-03", "2018-06-10", "2018-06-17", "2018-06-24",
"2018-08-26", "2018-09-02", "2018-09-09", "2018-09-16", "2018-09-23",
"2018-09-30", "2018-10-07", "2018-10-14", "2018-10-21", "2018-10-28",
"2019-12-25", "2018-09-15", "2018-02-24", "2018-06-30", "2019-01-20",
"2018-07-21", "2019-01-27", "2019-10-27", "2018-11-04", "2018-12-16",
"2018-12-23", "2018-12-30", "2019-01-13", "2019-02-03", "2019-02-10",
"2019-02-17", "2019-02-24", "2019-03-03", "2019-03-10", "2019-03-17",
"2019-03-24", "2019-03-31", "2019-04-07", "2019-04-21", "2019-05-05",
"2019-05-19", "2019-05-26", "2019-06-09", "2019-10-05", "2019-04-27",
"2019-05-04", "2019-05-11", "2019-05-25", "2019-04-13", "2019-04-20",
"2018-02-17", "2019-07-14", "2019-01-05", "2019-03-30", "2018-11-24",
"2019-01-12", "2018-05-19", "2018-06-16", "2018-06-23", "2019-09-08",
"2018-09-22", "2018-11-10", "2019-11-09", "2018-01-06", "2019-07-06",
"2018-07-14", "2018-10-27", "2018-11-03", "2018-11-17", "2018-09-08",
"2019-03-23", "2019-08-11", "2019-07-21", "2019-08-04", "2019-08-18",
"2019-01-26", "2019-12-29", "2018-02-10", "2018-07-28", "2019-02-23",
"2019-09-29", "2019-08-24", "2018-02-03", "2019-06-30", "2018-10-13"
), class = "factor")), row.names = c(NA, -9L), class = c("data.table",
"data.frame"))

The svcdate_form column is what I'm basing this on. The map column is the output I get after using cut. My code is below:

setDT(ex)
ex[,map:= cut(svcdate_form, "7 days", include.lowest = TRUE, right = FALSE)]

I've messed around with the include.lowest and right arguments, but the second group in map always starts with 2018-06-25. What I wanted was, since 2018-06-29 isn't within 7 days of 2018-06-18, the bin would 'start over' and count 7 days from 2018-06-29 and include 2018-07-02. Therefore, in the end my map column would only have two labels: 2018-06-18 and 2018-06-29, but instead it has 3, and 2018-06-25 isn't even in the data.

Is there anything I'm missing, or maybe I'm approaching this with the wrong function? Thank you in advance for any help or insight you can give!

Body:
Perhaps this?

ex[, map := cut(svcdate_form, "7 days"), by = .(cumsum(c(TRUE, diff(svcdate_form) > 7)))]
#    svcdate_form        map
#          <Date>     <fctr>
# 1:   2018-06-18 2018-06-18
# 2:   2018-06-18 2018-06-18
# 3:   2018-06-18 2018-06-18
# 4:   2018-06-29 2018-06-29
# 5:   2018-06-29 2018-06-29
# 6:   2018-06-29 2018-06-29
# 7:   2018-07-02 2018-06-29
# 8:   2018-07-02 2018-06-29
# 9:   2018-07-02 2018-06-29

This presumes that the data is ordered meaningfully. Depending on previous steps in the pipe, you may prefer to setorder(ex, svcdate_form) or something similar so that diff(svcdate_form) is appropriate.


问:
What are possible values for the FileSystemName string that GetVolumeInformation returns?
The MSDN documentation and the knowledge base article  of GetVolumeInformation are not very specific what the file system name string can contain.

The obvious values are NTFS, CDFS and FAT32. But can it also detect other file systems and what would be the strings ?
I also read somewhere that sometimes version numbers are included in the string. Any idea regarding this ? I don't know the specifics anymore. :(

Thanks for your help !

答:
This function can detect the following file systems:

FAT, FAT32, NTFS, HPFS, CDFS, UDF, NWFS

As I can remember for my experiences in 3 years ago, ex2 or ex3 were not detectable at all on Windows XP SP3.

Edit

Since Vista SP2, there is also support for exFAT


问:
How to have a React child component call a function from a parent component
I have a parent component and a child component (as a separate component file). How would I go about calling a function in the parent component from the child component?

The child component is imported into the parent component and the parent component has a function that makes an API call. I would like the child component to be able to also reach into the parent and run the api call function.

I could post the code I have but it's simply making an API call in the parent and having the child component imported in the parent.

thanks for any help.

答:
Provide the function as a property on the child element:

const Parent = () => {
  const someFunction = () => { /*...*/ };

  return <Child someProp={someFunction}/>;
}

const Child = ({ someProp }) => {
  return (

 someProp()}>
      Hello World

  );
}
```

Body:
Provide the function as a property on the child element:

const Parent = () => {
  const someFunction = () => { /*...*/ };

  return <Child someProp={someFunction}/>;
}

const Child = ({ someProp }) => {
  return (
    <div onClick={() => someProp()}>
      Hello World
    </div>
  );
}


问:
Custom ordering on elastic search
I'm executing a simple query which returns items matched by companyId.

In addition to only showing clients matching a specific company I also want records matching a certain location to appear at the top.So if somehow I pass through pseudo sort:"location=Johannesburg" it would return the data below and items which match the specific location would appear on top, followed by items with other locations.

Data:

```<code>{
  "clientId" : 1,
  "clientName" : "Name1",
  "companyId" : 8,
  "location" : "Cape Town"
},
{
  "clientId" : 2,
  "clientName" : "Name2",
  "companyId" : 8,
  "location" : "Johannesburg"
}
</code>```

Query:

```<code> {
      "query": {
        "match": {
          "companyId": "8"
        }
      },
      "size": 10,
      "_source": {
        "includes": [
          "firstName",
          "companyId",
          "location"
        ]
      }
    }
</code>```

Is something like this possible in elastic and if so what is the name of this concept?(I'm not sure what to even Google for to solve this problem)

答:
It can be done in different ways.
Simplest (if go only with text matching) is use bool query with  should statement.

The bool query takes a more-matches-is-better approach, so the score from each matching must or should clause will be added together to provide the final _score for each document. Doc

Example:

```<code>{"query":
   "bool": {
     "must": [
        "match": {
          "companyId": "8"
        }
      ],
     "should": [
        "match": {
          "location": "Johannesburg"
         }
      ]
     }
   }
}
</code>```

More complex solution is to store GEO points in location, and use Distance feature query as example.

Title: Custom ordering on elastic search

Body:
I'm executing a simple query which returns items matched by companyId.

In addition to only showing clients matching a specific company I also want records matching a certain location to appear at the top.So if somehow I pass through pseudo sort:"location=Johannesburg" it would return the data below and items which match the specific location would appear on top, followed by items with other locations.

Data:

{
  "clientId" : 1,
  "clientName" : "Name1",
  "companyId" : 8,
  "location" : "Cape Town"
},
{
  "clientId" : 2,
  "clientName" : "Name2",
  "companyId" : 8,
  "location" : "Johannesburg"
}

Query:

 {
      "query": {
        "match": {
          "companyId": "8"
        }
      },
      "size": 10,
      "_source": {
        "includes": [
          "firstName",
          "companyId",
          "location"
        ]
      }
    }

Is something like this possible in elastic and if so what is the name of this concept?(I'm not sure what to even Google for to solve this problem)

Body:
It can be done in different ways.
Simplest (if go only with text matching) is use bool query with  should statement.

The bool query takes a more-matches-is-better approach, so the score from each matching must or should clause will be added together to provide the final _score for each document. Doc

Example:

{"query":
   "bool": {
     "must": [
        "match": {
          "companyId": "8"
        }
      ],
     "should": [
        "match": {
          "location": "Johannesburg"
         }
      ]
     }
   }
}

More complex solution is to store GEO points in location, and use Distance feature query as example.


问:
How to load a pandas dataframe that is stored as pickle or feather (df.pkl or df.ftr) into sqldf
I have two files - df.pkl and df.ftr.
And I am using run_qry = lambda q: sqldf(q, globals()) to run sql queries.
So for example:
I am creating a new DataFrame like new_dfr = run_qry("""select * from df""") but I need to load the df.pkl or df.ftr in run_qry(sqldf) to run this query.

Can you tell me, how to do load previously created DataFrame here?

Thanks in advance.

答:
If I understand correctly, you are just trying to load dataframes from pickle and feather files?

If so I think you can use the pandas.read_pickle() and read_feather() methods:

```<code>import pandas as pd
df_pkl = pd.read_pickle(pickle_file_path)
df_ftr = pd.read_feather(feather_file_path)
</code>```

Body:
If I understand correctly, you are just trying to load dataframes from pickle and feather files?

If so I think you can use the pandas.read_pickle() and read_feather() methods:

import pandas as pd
df_pkl = pd.read_pickle(pickle_file_path)
df_ftr = pd.read_feather(feather_file_path)