问:
CustomEvent listener callback is firing twice?
I've created a custom element:

```<code>const templ = document.createElement('template');
templ.innerHTML = `
<span><slot></slot></span>
`;
</code>```

```<code>class SlideButton extends HTMLElement {

    constructor() {
        super();

        // Attach a shadow root to the element.
        const shadowRoot = this.attachShadow({ mode: 'open' });
        shadowRoot.appendChild(tmpl.content.cloneNode(true));
        this.span = shadowRoot.querySelector('span');

        this.triggerEvent = new CustomEvent("trigger", {
            bubbles: false,
            cancelable: false,
        });

        this.initMouseEvents();
    }

    initMouseEvents() {
        this.span.addEventListener('mousedown', (e) => {

            //Watch and calculate slide amount..
            this.addEventListener('mousemove', this.slide, false);

        });

        //When button is released...
        document.addEventListener('mouseup', handleMouseUp = (e) => {

            this.removeEventListener('mousemove', this.slide, false);
            document.removeEventListener('mouseup', handleMouseUp);

            //If slided enough, dispatch event...
            if (Math.abs(this.slideAmount) > (this.maxSlide * 0.75)) {
                console.log('firing event');
                this.dispatchEvent(this.triggerEvent);
            }
            //Reset button to normal state...

        }, false);
    }
}
</code>```

Somewhere else in my code..

```<code>class SpotLightModal {

    //Constructor..
    //code..
    //code..

    init() {
        this.actions.querySelector('slide-button[type="den"]').addEventListener('trigger', e => {
            console.log(e);
            console.log('den');
            //Do stuff..
        });
    }

    //code...
    //code...

}
</code>```

Everything works as expected except that the callback in the event listener is runs twice and the output is:

```<code>firing event
CustomEvent {...}
den
CustomEvent {...}
den
</code>```

Both e.stopPropagation() and e.preventDefault() have no effect and trying to use them did nothing..

I've edited to include this.span and also moved the "mouseup" event listener outside the "mousedown" event listener but that didn't work, infact when logging this, now, it gives another different element (of the same kind, <slide-button>, the first on the page), the "mouseover" listener doesn't get removed, and the event isn't fired.

Am I doing something wrong in here? or what am I missing exactly?

Thanks in advance..

答:
There's a "bubbles" option that you can set to false, which should eliminate the mouse-down/up bubbling phases:</p>

```<code>var evt = new CustomEvent(name, {
    detail : data,
    bubbles: true, // <-- try setting to false
    cancelable: true
});

document.dispatchEvent(evt);
</code>```

Body:
I've created a custom element:

const templ = document.createElement('template');
templ.innerHTML = `
<slot></slot>
`;

class SlideButton extends HTMLElement {

    constructor() {
        super();

        // Attach a shadow root to the element.
        const shadowRoot = this.attachShadow({ mode: 'open' });
        shadowRoot.appendChild(tmpl.content.cloneNode(true));
        this.span = shadowRoot.querySelector('span');

        this.triggerEvent = new CustomEvent("trigger", {
            bubbles: false,
            cancelable: false,
        });

        this.initMouseEvents();
    }

    initMouseEvents() {
        this.span.addEventListener('mousedown', (e) => {

            //Watch and calculate slide amount..
            this.addEventListener('mousemove', this.slide, false);

        });

        //When button is released...
        document.addEventListener('mouseup', handleMouseUp = (e) => {

            this.removeEventListener('mousemove', this.slide, false);
            document.removeEventListener('mouseup', handleMouseUp);

            //If slided enough, dispatch event...
            if (Math.abs(this.slideAmount) > (this.maxSlide * 0.75)) {
                console.log('firing event');
                this.dispatchEvent(this.triggerEvent);
            }
            //Reset button to normal state...

        }, false);
    }
}

Somewhere else in my code..

class SpotLightModal {

    //Constructor..
    //code..
    //code..

    init() {
        this.actions.querySelector('slide-button[type="den"]').addEventListener('trigger', e => {
            console.log(e);
            console.log('den');
            //Do stuff..
        });
    }

    //code...
    //code...

}

Everything works as expected except that the callback in the event listener is runs twice and the output is:

firing event
CustomEvent {...}
den
CustomEvent {...}
den

Both e.stopPropagation() and e.preventDefault() have no effect and trying to use them did nothing..

I've edited to include this.span and also moved the "mouseup" event listener outside the "mousedown" event listener but that didn't work, infact when logging this, now, it gives another different element (of the same kind, <slide-button>, the first on the page), the "mouseover" listener doesn't get removed, and the event isn't fired.

Am I doing something wrong in here? or what am I missing exactly?

Thanks in advance..

Body:
There's a "bubbles" option that you can set to false, which should eliminate the mouse-down/up bubbling phases:

var evt = new CustomEvent(name, {
    detail : data,
    bubbles: true, // <-- try setting to false
    cancelable: true
});

document.dispatchEvent(evt);


来源: stackexchange

问:
Is it possible to generate random numbers through physical process simulation?
Is it possible to generate random numbers through physical process simulation?

If I simulate the physical roll of a dice (i.e. you picking it up, shaking it in your hand, releasing it onto the table and recording which side ends up "up"...) will that produce a "random" number or would I just have a complex simulation which really accomplishes nothing.

答:
Your algorithm will be a pseudo-random number generator, that is to say it will take in a random seed and produce potentially large number strings which look fairly random.

There is no guarantee however that your random output will be of the quality that you need for cryptography or other purposes.  I'd be inclined to think that there will be undesirable repeated patterns in your output, and that too much work will go towards the physics of the problem, and not enough to producing pseudo randomness.  (Sorry for the wishy washiness, but that's it in a nutshell.)  There exist effective pseudo number generators, and I would use one of the shelf.

That said, this might be an interesting and informative experiment for your own purposes.

ContentLicense: CC BY-SA 2.5

LastEditorDisplayName: Jonathan Leffler

OwnerDisplayName: Rob


问:
PHP constant not defined when using cli but works via apache
I have a scenario where a static function in an included file will see my defined values if I trigger that code via web-request but when the exact same code is triggered via a cron fired schedule the defined values are not seen as defined. I have reduced my code scenario to the simplest possible form as follows:

Update I put an error_log(print_r(get_defined_constants(true),true)); in the file and compared the results between a web execution and a cron execution and the only thing different is my missing constant on the cron side and the pcntl extension constants on the cron web side

note: all web requests require this settings file and have no issue

note: I have other scheduled files that see the defined values

note: I have other web files that utilize this class and its functions without issue.

confirmed: The settings file is included

confirmed: The function is being called

I feel like I'm missing something completely obvious or highly esoteric.

```<code>//-- settings file
...
define("NEED_THIS_CONST","DOODLYDOO");
...
</code>```

```<code>//-- class file
class vendor {
  public static function dothis() {
    error_log("reached the file");
    if(!defined("NEED_THIS_CONST")) {
      error_log("not defined");
    else
      error_log("defined");
    }
  }
}
</code>```

```<code>//-- requested file
...
require_once("settings.php");
include_once("vendor.php");
vendor::dothis();
</code>```

答: The issue has been resolved. At some point I had copied the settings file (a hidden file) to my home directory to scp it, and for some reason this script (not in the same path) was using that settings file when triggered from cron, when I removed that copy (not a link) cron instantly started using the live file. I still dont know why that copy was used as the actual include pathing is relative pathing to the absolute codebase root that wouldn't find that file anyway. I'm lost as to the how, shadow file handle? On Linux? Never heard of that. It works now though.</p>

ContentLicense: CC BY-SA 4.0

Body:
I have a scenario where a static function in an included file will see my defined values if I trigger that code via web-request but when the exact same code is triggered via a cron fired schedule the defined values are not seen as defined. I have reduced my code scenario to the simplest possible form as follows:

Update I put an error_log(print_r(get_defined_constants(true),true)); in the file and compared the results between a web execution and a cron execution and the only thing different is my missing constant on the cron side and the pcntl extension constants on the cron web side

note: all web requests require this settings file and have no issue

note: I have other scheduled files that see the defined values

note: I have other web files that utilize this class and its functions without issue.

confirmed: The settings file is included

confirmed: The function is being called

I feel like I'm missing something completely obvious or highly esoteric.

//-- settings file
...
define("NEED_THIS_CONST","DOODLYDOO");
...

//-- class file
class vendor {
  public static function dothis() {
    error_log("reached the file");
    if(!defined("NEED_THIS_CONST")) {
      error_log("not defined");
    else
      error_log("defined");
    }
  }
}

//-- requested file
...
require_once("settings.php");
include_once("vendor.php");
vendor::dothis();


问:
Docker can not access external network
I have a docker compose with 3 applications : postgres, pgadmin and war inside tomcat.
When I launch the war on container, the application can not access to external urls (others containers running on others machines or on the same machine but in different network).

Thanks

答:
Intercommunication of containers is only possible if they are running withing the same network.
One possible solution of your problem is to create another network and connect all your containers with this network.</p>

Title: Docker can not access external network


问:
Regex to find phone number with country code from string
I currently have the following:

```<code>    preg_match_all('/\b[0-9]{3}\s*-\s*[0-9]{3}\s*-\s*[0-9]{4}\b/',$cacax,$matches);
    echo '```';
    print_r($matches[0]);
```

<p>This will output:</p>

```[0] => 888-618-0367
```

<p>instead of</p>

``` [0] => +1 888-618-0367
```

I got no clue on how to make that regex expression only match +1 starting numbers and also include the number in the match.

Will appreciate any help, thanks!

答:
Add \+1\s* at the start, use

```<code>\+1\s*[0-9]{3}\s*-\s*[0-9]{3}\s*-\s*[0-9]{4}\b
</code>```

See proof. The \+1\s* part will require +1 and zero or more whitespace characters at the start of your matches.

Body:
I currently have the following:

    preg_match_all('/\b[0-9]{3}\s*-\s*[0-9]{3}\s*-\s*[0-9]{4}\b/',$cacax,$matches);
    echo '
';
    print_r($matches[0]);

This will output:

[0] => 888-618-0367

instead of

 [0] => +1 888-618-0367

I got no clue on how to make that regex expression only match +1 starting numbers and also include the number in the match.

Will appreciate any help, thanks!

Body:
Add \+1\s* at the start, use

\+1\s*[0-9]{3}\s*-\s*[0-9]{3}\s*-\s*[0-9]{4}\b

See proof. The \+1\s* part will require +1 and zero or more whitespace characters at the start of your matches.


问:
Java dynamically create buttons and pass a parameter to action performed
I am new to java and i am trying a small project on my own, i want to list the first and lastname of users from a sql database (this all works fine, but i don't just want to list them

I want to list all users in a GUI with a delete button, naturally this delete button will be generated dynamically and i want to pass the userID of the button to the action performed.
like this:

```<code> John      Doe      'Delete button'
 Jane      Doe      'Delete button'
</code>```

In my code below i just generate 16 buttons dynamically (without a users table) instead of passing the userID i am trying to pass the 'i' value of the for loop, but my code does not seem to work

CODE

    public class UsersView implements ActionListener {

    JFrame frame = new JFrame();
    JPanel panel = new JPanel();

    public UsersView() {

        //Create the 16 buttons.
        for (int i=0; i<16; i++) {
            Button button = new Button("Click "+i);
            button.setId(i);  //this gives me and error 'Symbol not find' on the 'setId'
            panel.add(button);
            button.addActionListener(this);
        }

        panel.setBorder(BorderFactory.createBevelBorder(0, Color.lightGray, Color.yellow));
        //panel.setBorder(BorderFactory.createEmptyBorder(300, 300, 100, 300));
        panel.setLayout(new GridLayout(4,4)); //Rows Cols

        frame.add(panel, BorderLayout.CENTER);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setTitle("App GUI");
        frame.pack();
        frame.setVisible(true);

    }

    public static void main(String[] args) {
        // TODO code application logic here
        new UsersView();
    }

    //On button click.
    @Override
    public void actionPerformed(ActionEvent e) {
        //I know i have nothing here (yet) that is because the 'setId' gives me an error.

    }

}
```

答:
Use a JButton instead of Button. Mixing AWT and Swing components rarely works well, if at all. If you want to set a custom field for a component, just subclass it (use direct subclassing or a decorator pattern with composition). E.g.:

```<code>public class IdButton extends JButton {
    private int id;

    public IdButton(String label, int id) {
        super(label);
        this id = id;
    }

    public int getId() {
        return id;
    }
}
</code>```

The J/Button classes do not have set/getId methods on it's own.

Body:
I am new to java and i am trying a small project on my own, i want to list the first and lastname of users from a sql database (this all works fine, but i don't just want to list them

I want to list all users in a GUI with a delete button, naturally this delete button will be generated dynamically and i want to pass the userID of the button to the action performed.
like this:

 John      Doe      'Delete button'
 Jane      Doe      'Delete button'

In my code below i just generate 16 buttons dynamically (without a users table) instead of passing the userID i am trying to pass the 'i' value of the for loop, but my code does not seem to work

CODE

    public class UsersView implements ActionListener {

    JFrame frame = new JFrame();
    JPanel panel = new JPanel();

    public UsersView() {

        //Create the 16 buttons.
        for (int i=0; i<16; i++) {
            Button button = new Button("Click "+i);
            button.setId(i);  //this gives me and error 'Symbol not find' on the 'setId'
            panel.add(button);
            button.addActionListener(this);
        }

        panel.setBorder(BorderFactory.createBevelBorder(0, Color.lightGray, Color.yellow));
        //panel.setBorder(BorderFactory.createEmptyBorder(300, 300, 100, 300));
        panel.setLayout(new GridLayout(4,4)); //Rows Cols

        frame.add(panel, BorderLayout.CENTER);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setTitle("App GUI");
        frame.pack();
        frame.setVisible(true);

    }

    public static void main(String[] args) {
        // TODO code application logic here
        new UsersView();
    }

    //On button click.
    @Override
    public void actionPerformed(ActionEvent e) {
        //I know i have nothing here (yet) that is because the 'setId' gives me an error.

    }

}

Body:
Use a JButton instead of Button. Mixing AWT and Swing components rarely works well, if at all. If you want to set a custom field for a component, just subclass it (use direct subclassing or a decorator pattern with composition). E.g.:

public class IdButton extends JButton {
    private int id;

    public IdButton(String label, int id) {
        super(label);
        this id = id;
    }

    public int getId() {
        return id;
    }
}

The J/Button classes do not have set/getId methods on it's own.


问:
Query keys are encoded in URLComponent's url
I'm using URLQueryItem to encode query values but when I pass queries to the URLComponent in the url property query keys are encoded too.

```<code>var urlComponents = URLComponents(url: url, resolvingAgainstBaseURL: false)
urlComponents.queryItems = [URLQueryItem]()
for (key,value) in parameters {
    let queryItem = URLQueryItem(name: key,
                                 value: "\(value)".addingPercentEncoding(withAllowedCharacters: .urlHostAllowed))
    urlComponents.queryItems?.append(queryItem)
}
print("URLComponents Query Items:\n \(urlComponents.queryItems)")
print("URLComponents URL:\n \(urlComponents.url)")
</code>```

Output is:

```<code>URLComponents Query Items:
 Optional([per_page=10, filters[status]=Active])
URLComponents URL:
 Optional(https://example.com/endpoint?per_page=10&filters%5Bstatus%5D=Active)
</code>```

How can this be prevented? I don't want query names be encoded.

答: Remove the explict .addingPercentEncoding(withAllowedCharacters: .urlHostAllowed) call - URLQueryItem takes care of the encoding.

Body:
I'm using URLQueryItem to encode query values but when I pass queries to the URLComponent in the url property query keys are encoded too.

var urlComponents = URLComponents(url: url, resolvingAgainstBaseURL: false)
urlComponents.queryItems = [URLQueryItem]()
for (key,value) in parameters {
    let queryItem = URLQueryItem(name: key,
                                 value: "\(value)".addingPercentEncoding(withAllowedCharacters: .urlHostAllowed))
    urlComponents.queryItems?.append(queryItem)
}
print("URLComponents Query Items:\n \(urlComponents.queryItems)")
print("URLComponents URL:\n \(urlComponents.url)")

Output is:

URLComponents Query Items:
 Optional([per_page=10, filters[status]=Active])
URLComponents URL:
 Optional(https://example.com/endpoint?per_page=10&filters%5Bstatus%5D=Active)

How can this be prevented? I don't want query names be encoded.


问:
How do I access my array from my table data source?
I am starting my first Cocoa Project. And I have a serious (for me) but maybe easy problem (for you) to solve and I need some direction where to start.

The short description: I have built a class "PortConnection.h" who writes all ports found by an external class (AMSerial.h) into an array when the function -listPorts is called. Here is the code for the PortConnection.h

```<code>#import <Cocoa/Cocoa.h>
#import "AMSerialPortList.h"
#import "AMSerialPortAdditions.h"
#import "AMSerialPort.h"

@interface PortConnection : NSObject {
@private
    AMSerialPort *port;
    NSMutableArray *portArray;
}

- (void)listDevices;

@property (nonatomic, retain) NSMutableArray *portArray;
@property (nonatomic, retain) AMSerialPort *port;

@end
</code>```

and following the PortConnection.m

```<code>#import "PortConnection.h"
#import "AMSerialPortList.h"
#import "AMSerialPortAdditions.h"
#import "AMSerialPort.h"

@implementation PortConnection
@synthesize portArray;
@synthesize port;

- (void)listDevices
{
    // get an port enumerator
    NSEnumerator *enumerator = [AMSerialPortList portEnumerator];
    AMSerialPort *aPort;

    while ((aPort = [enumerator nextObject]))
    {
        // Add Devices to Array
        [portArray addObject:[aPort bsdPath]];

    }
}
</code>```

So far it is perfectly working.
Now my questions

I have implemented an tableView in the GUI for display the results of the method called above. This file is called "PortTableViewController.h" and is the datasource for my TableView.

Here is the .h file

```<code>#import <Foundation/Foundation.h>
#import "PortConnection.h"

@interface PortTableViewController : NSObject <NSTableViewDataSource> {
@private
    IBOutlet NSTableView *portTableView;
}

@property (assign) IBOutlet NSTableView *portTableView;

@end
</code>```

and here is the .m file:

```<code>#import "PortTableViewController.h"
#import "PortConnection.h"

@implementation PortTableViewController
@synthesize portTableView;

#pragma mark -
#pragma mark TableView Delegates

- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView{
    PortConnection *portConnection = [[PortConnection alloc] init];
    [portConnection listDevices];
    return [portConnection.portArray count];
}

- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row{
        ??????? I DO NOT HAVE A CLUE HOW TO ACCESS THE ARRAY IN PORTCONNECTION.M CORRECTLY
}

@end
</code>```

QUESTIONS:

1) When having a look on the TableViewDataSourceDelegates how do I access the filled portArray in the PortConnection.m class correctly. It doesn't seem to work the way I do it.

2) Do I have to create an Object from Portconnection.h every time I want to retrieve Data from it in a tableviewdelegate method?

I am really thankful for every kind of help! I want to learn something.. and I really appreciate your support! Thanks.. for question in order to help me, don't hesitate. I really appreciate it....

Thanks
Sebastian

答:
A simple fix is to have your table view controller declare an instance variable that holds a PortConnection instance. This instance is created and sent -listDevices in -init, it is used by all methods in your table view controller (which means that all methods refer to the same PortConnection instance), and released in -dealloc.

For example:

PortTableViewController.h

```<code>#import <Foundation/Foundation.h>
#import "PortConnection.h"

@interface PortTableViewController : NSObject <NSTableViewDataSource> {
@private
    IBOutlet NSTableView *portTableView;
    PortConnection *portConnection;
}

@property (assign) IBOutlet NSTableView *portTableView;

@end
</code>```

PortTableViewController.m

```<code>#import "PortTableViewController.h"
#import "PortConnection.h"

@implementation PortTableViewController
@synthesize portTableView;

#pragma mark -
#pragma mark TableView Delegates

- (id)init {
    self = [super init];
    if (self) {
        portConnection = [[PortConnection alloc] init];
        [portConnection listDevices];
    }
    return self;
}

- (void)dealloc {
    [portConnection release];
    [super dealloc];
}

- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView{
    return [portConnection.portArray count];
}

- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row{
    return [portConnection.portArray objectAtIndex:row];
    // or whatever behaviour provides an object value for the column/row
}

@end
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I am starting my first Cocoa Project. And I have a serious (for me) but maybe easy problem (for you) to solve and I need some direction where to start.

The short description: I have built a class "PortConnection.h" who writes all ports found by an external class (AMSerial.h) into an array when the function -listPorts is called. Here is the code for the PortConnection.h

#import <Cocoa/Cocoa.h>
#import "AMSerialPortList.h"
#import "AMSerialPortAdditions.h"
#import "AMSerialPort.h"

@interface PortConnection : NSObject {
@private
    AMSerialPort *port;
    NSMutableArray *portArray;
}

- (void)listDevices;

@property (nonatomic, retain) NSMutableArray *portArray;
@property (nonatomic, retain) AMSerialPort *port;

@end

and following the PortConnection.m

#import "PortConnection.h"
#import "AMSerialPortList.h"
#import "AMSerialPortAdditions.h"
#import "AMSerialPort.h"

@implementation PortConnection
@synthesize portArray;
@synthesize port;

- (void)listDevices
{
    // get an port enumerator
    NSEnumerator *enumerator = [AMSerialPortList portEnumerator];
    AMSerialPort *aPort;

    while ((aPort = [enumerator nextObject]))
    {
        // Add Devices to Array
        [portArray addObject:[aPort bsdPath]];

    }
}

So far it is perfectly working.
Now my questions

I have implemented an tableView in the GUI for display the results of the method called above. This file is called "PortTableViewController.h" and is the datasource for my TableView.

Here is the .h file

#import <Foundation/Foundation.h>
#import "PortConnection.h"

@interface PortTableViewController : NSObject <NSTableViewDataSource> {
@private
    IBOutlet NSTableView *portTableView;
}

@property (assign) IBOutlet NSTableView *portTableView;

@end

and here is the .m file:

#import "PortTableViewController.h"
#import "PortConnection.h"

@implementation PortTableViewController
@synthesize portTableView;

#pragma mark -
#pragma mark TableView Delegates

- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView{
    PortConnection *portConnection = [[PortConnection alloc] init];
    [portConnection listDevices];
    return [portConnection.portArray count];
}

- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row{
        ??????? I DO NOT HAVE A CLUE HOW TO ACCESS THE ARRAY IN PORTCONNECTION.M CORRECTLY
}

@end

QUESTIONS:

1) When having a look on the TableViewDataSourceDelegates how do I access the filled portArray in the PortConnection.m class correctly. It doesn't seem to work the way I do it.

2) Do I have to create an Object from Portconnection.h every time I want to retrieve Data from it in a tableviewdelegate method?

I am really thankful for every kind of help! I want to learn something.. and I really appreciate your support! Thanks.. for question in order to help me, don't hesitate. I really appreciate it....

Thanks
Sebastian

Body:
A simple fix is to have your table view controller declare an instance variable that holds a PortConnection instance. This instance is created and sent -listDevices in -init, it is used by all methods in your table view controller (which means that all methods refer to the same PortConnection instance), and released in -dealloc.

For example:

PortTableViewController.h

#import <Foundation/Foundation.h>
#import "PortConnection.h"

@interface PortTableViewController : NSObject <NSTableViewDataSource> {
@private
    IBOutlet NSTableView *portTableView;
    PortConnection *portConnection;
}

@property (assign) IBOutlet NSTableView *portTableView;

@end

PortTableViewController.m

#import "PortTableViewController.h"
#import "PortConnection.h"

@implementation PortTableViewController
@synthesize portTableView;

#pragma mark -
#pragma mark TableView Delegates

- (id)init {
    self = [super init];
    if (self) {
        portConnection = [[PortConnection alloc] init];
        [portConnection listDevices];
    }
    return self;
}

- (void)dealloc {
    [portConnection release];
    [super dealloc];
}

- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView{
    return [portConnection.portArray count];
}

- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row{
    return [portConnection.portArray objectAtIndex:row];
    // or whatever behaviour provides an object value for the column/row
}

@end


问:
How to make sure each character of a command argument is a decimal digit?
We have to make a code to encrypt Caesar's cipher. One of the steps is: instead of printing out the command-line argument provided, your program instead checks to make sure that each character of that command line argument is a decimal digit (i.e., 0, 1, 2, etc.) and, if any of them are not, terminates after printing the message Usage: ./caesar key. But if the argument consists solely of digit characters, you should convert that string (recall that argv is an array of strings, even if those strings happen to look like numbers) to an actual integer, and print out the integer, as via %i with printf.
The code below is what I have, but it returns both Success & Error. How can I fix this so that the program checks that each character of the command line argument is a digit?
Code I have

答:
isdigit apply on an int containing the code of a character but doing isdigit(atoi(argv[1])) you try first to convert the string to an integer so this is wrong. If you use isdigit this is iterating on all the string.

atoi silently returns 0 when the argument is not a valid integer, do not use it.

This is not because the string contains only digits that you can get the corresponding int because the number can be too large for an int. If you accept negative number the first character can be - which is not a digit. One way to both convert and check all the string represents a valid integer is to use strtol returning a long.

Out of that when argc is not 2 you must terminate the execution rather than continue as you do.


问:
How to style child components from parent component's CSS file?
I've got a parent component:

```<code><parent></parent>
</code>```

And I want to populate this group with child components:

```<code><parent>
  <child></child>
  <child></child>
  <child></child>
</parent>
</code>```

Parent template:

```<code><div class="parent">
  <!-- Children goes here -->
  <ng-content></ng-content>
</div>
</code>```

Child template:

```<code><div class="child">Test</div>
</code>```

Since parent and child are two separate components, their styles are locked to their own scope.

In my parent component I tried doing:

```<code>.parent .child {
  // Styles for child
}
</code>```

But the .child styles are not getting applied to the child components.

I tried using styleUrls to include the parent's stylesheet into child component to solve the scope issue:

```<code>// child.component.ts
styleUrls: [
  './parent.component.css',
  './child.component.css',
]
</code>```

But that didn't help, also tried the other way by fetching the child stylesheet into parent but that didn't help either.

So how do you style child components that are included into a parent component?

答:
As of today (Angular 9), Angular uses a Shadow DOM to display the components as custom HTML elements. One elegant way to style those custom elements might be using custom CSS variables. Here is a generic example:

class ChildElement extends HTMLElement {
  constructor() {
    super();

    var shadow = this.attachShadow({mode: 'open'});
    var wrapper = document.createElement('div');
    wrapper.setAttribute('class', 'wrapper');

    // Create some CSS to apply to the shadow dom
    var style = document.createElement('style');

    style.textContent = `

      /* Here we define the default value for the variable --background-clr */
      :host {
        --background-clr: green;
      }

      .wrapper {
        width: 100px;
        height: 100px;
        background-color: var(--background-clr);
        border: 1px solid red;
      }
    `;

    shadow.appendChild(style);
    shadow.appendChild(wrapper);
  }
}

// Define the new element
customElements.define('child-element', ChildElement);```
<pre class="snippet-code-css lang-css prettyprint-override"><code>/* CSS CODE */

/* This element is referred as :host from the point of view of the custom element. Commenting out this CSS will result in the background to be green, as defined in the custom element */

child-element {
  --background-clr: yellow;
}</code>```

  <child-element></child-element>

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

<p>As we can see from the above code, we create a custom element, just like Angular would do for us with every component, and then we override the variable responsible for the background color within the shadow root of the custom element, from the global scope.</p>

<p>In an Angular app, this might be something like:</p>

<p>parent.component.scss</p>

```child-element {
  --background-clr: yellow;
}
```

<p>child-element.component.scss</p>

```:host {
  --background-clr: green;
}

.wrapper {
  width: 100px;
  height: 100px;
  background-color: var(--background-clr);
  border: 1px solid red;
}
```

Body:
I've got a parent component:

<parent></parent>

And I want to populate this group with child components:

<parent>
  <child></child>
  <child></child>
  <child></child>
</parent>

Parent template:

  <ng-content></ng-content>

Child template:

Test

Since parent and child are two separate components, their styles are locked to their own scope.

In my parent component I tried doing:

.parent .child {
  // Styles for child
}

But the .child styles are not getting applied to the child components.

I tried using styleUrls to include the parent's stylesheet into child component to solve the scope issue:

// child.component.ts
styleUrls: [
  './parent.component.css',
  './child.component.css',
]

But that didn't help, also tried the other way by fetching the child stylesheet into parent but that didn't help either.

So how do you style child components that are included into a parent component?

Body:
As of today (Angular 9), Angular uses a Shadow DOM to display the components as custom HTML elements. One elegant way to style those custom elements might be using custom CSS variables. Here is a generic example:

class ChildElement extends HTMLElement {
  constructor() {
    super();

    var shadow = this.attachShadow({mode: 'open'});
    var wrapper = document.createElement('div');
    wrapper.setAttribute('class', 'wrapper');

    // Create some CSS to apply to the shadow dom
    var style = document.createElement('style');

    style.textContent = `

      /* Here we define the default value for the variable --background-clr */
      :host {
        --background-clr: green;
      }

      .wrapper {
        width: 100px;
        height: 100px;
        background-color: var(--background-clr);
        border: 1px solid red;
      }
    `;

    shadow.appendChild(style);
    shadow.appendChild(wrapper);
  }
}

// Define the new element
customElements.define('child-element', ChildElement);

/* CSS CODE */

/* This element is referred as :host from the point of view of the custom element. Commenting out this CSS will result in the background to be green, as defined in the custom element */

child-element {
  --background-clr: yellow;
}

<div>
  <child-element></child-element>
</div>

As we can see from the above code, we create a custom element, just like Angular would do for us with every component, and then we override the variable responsible for the background color within the shadow root of the custom element, from the global scope.

In an Angular app, this might be something like:

parent.component.scss

child-element {
  --background-clr: yellow;
}

child-element.component.scss

:host {
  --background-clr: green;
}

.wrapper {
  width: 100px;
  height: 100px;
  background-color: var(--background-clr);
  border: 1px solid red;
}


问:
Get error and warning when I apply smote function to balance the class
I am trying to apply a smote function in order to balance my classes.

this is my code:

```<code>smote_train <- SMOTE(tested_covid ~., data = dataTrain, k = 5, perc.over = 100, perc.under = 200)
</code>```

And this is my error with the warnings:

```<code>Error in T[, col] <- data[, col] :
  incorrect number of subscripts on matrix
In addition: Warning messages:
1: In if (class(data[, col]) %in% c("factor", "character")) { :
  the condition has length > 1 and only the first element will be used
2: In if (class(data[, col]) %in% c("factor", "character")) { :
  the condition has length > 1 and only the first element will be used
</code>```

This is the data structure and type I have:

```<code>structure(list(id = c("ff0113a9-79d4-4042-992f-c5092e30b6af",
"7b104740-c0c2-44bb-82d8-442ea06a3a96", "8533b6e2-bffe-46da-8056-8b77b89a5819",
"21d33ae7-8ad8-4744-8370-d376a7e5d251", "c9225467-8ff1-4305-85ad-6c9386e38347",
"e2e445c4-dffd-4543-b311-efdf2af23744"), age = c(63, 19, 23,
28, 40, 31), gender = c("Male", "Female", "Male", "Female", "Female",
"Male"), country = c("India", "Phillipines", "India", "Phillipines",
"South Africa", "Pakistan"), chills = c("No", "Mild", "No", "Mild",
"No", "No"), Cough = c("No", "Severe", "No", "Mild", "Mild",
"No"), diarrhoea = c("No", "Mild", "No", "No", "No", "No"), fatigue = c("No",
"Moderate", "Mild", "Mild", "Mild", "Mild"), healthcare_worker = c("No",
"No", "No", "No", "No", "Yes"), how_unwell = c(1, 7, 1, 6, 4,
2), comorbidity_one = c("Asthma (managed with an inhaler)", "None",
"Obesity", "High Blood Pressure (hypertension)", "None", "None"
), loss_smell_taste = c("No", "No", "No", "No", "No", "No"),
    muscle_ache = c("No", "Moderate", "No", "Moderate", "Mild",
    "Mild"), nasal_congestion = c("No", "No", "No", "No", "Mild",
    "No"), nausea_vomiting = c("No", "No", "No", "No", "No",
    "No"), no_days_symptoms_show = c("None", "4", "None", "More than 21",
    "None", "2"), self_diagnosis = c("None", "Mild", "None",
    "Mild", "None", "Mild"), shortness_breath = c("No", "Mild",
    "No", "No", "No", "Mild"), sore_throat = c("No", "No", "No",
    "No", "Mild", "No"), sputum = c("No", "Mild", "No", "Mild",
    "Mild", "No"), temperature = c("No", "No", "No", "No", "No",
    "37.5-38"), tested_covid = structure(c(1L, 1L, 1L, 1L, 1L,
    1L), .Label = c("Negative", "Positive"), class = "factor")), row.names = c(NA,
-6L), class = c("tbl_df", "tbl", "data.frame"))
</code>```

答: I have read the data with read.csv instead of read_csv. I also changed the variables to from character to factor and from int to numeric and that solved the problem.</p>

Body:
I am trying to apply a smote function in order to balance my classes.

this is my code:

smote_train <- SMOTE(tested_covid ~., data = dataTrain, k = 5, perc.over = 100, perc.under = 200)

And this is my error with the warnings:

Error in T[, col] <- data[, col] :
  incorrect number of subscripts on matrix
In addition: Warning messages:
1: In if (class(data[, col]) %in% c("factor", "character")) { :
  the condition has length > 1 and only the first element will be used
2: In if (class(data[, col]) %in% c("factor", "character")) { :
  the condition has length > 1 and only the first element will be used

This is the data structure and type I have:

structure(list(id = c("ff0113a9-79d4-4042-992f-c5092e30b6af",
"7b104740-c0c2-44bb-82d8-442ea06a3a96", "8533b6e2-bffe-46da-8056-8b77b89a5819",
"21d33ae7-8ad8-4744-8370-d376a7e5d251", "c9225467-8ff1-4305-85ad-6c9386e38347",
"e2e445c4-dffd-4543-b311-efdf2af23744"), age = c(63, 19, 23,
28, 40, 31), gender = c("Male", "Female", "Male", "Female", "Female",
"Male"), country = c("India", "Phillipines", "India", "Phillipines",
"South Africa", "Pakistan"), chills = c("No", "Mild", "No", "Mild",
"No", "No"), Cough = c("No", "Severe", "No", "Mild", "Mild",
"No"), diarrhoea = c("No", "Mild", "No", "No", "No", "No"), fatigue = c("No",
"Moderate", "Mild", "Mild", "Mild", "Mild"), healthcare_worker = c("No",
"No", "No", "No", "No", "Yes"), how_unwell = c(1, 7, 1, 6, 4,
2), comorbidity_one = c("Asthma (managed with an inhaler)", "None",
"Obesity", "High Blood Pressure (hypertension)", "None", "None"
), loss_smell_taste = c("No", "No", "No", "No", "No", "No"),
    muscle_ache = c("No", "Moderate", "No", "Moderate", "Mild",
    "Mild"), nasal_congestion = c("No", "No", "No", "No", "Mild",
    "No"), nausea_vomiting = c("No", "No", "No", "No", "No",
    "No"), no_days_symptoms_show = c("None", "4", "None", "More than 21",
    "None", "2"), self_diagnosis = c("None", "Mild", "None",
    "Mild", "None", "Mild"), shortness_breath = c("No", "Mild",
    "No", "No", "No", "Mild"), sore_throat = c("No", "No", "No",
    "No", "Mild", "No"), sputum = c("No", "Mild", "No", "Mild",
    "Mild", "No"), temperature = c("No", "No", "No", "No", "No",
    "37.5-38"), tested_covid = structure(c(1L, 1L, 1L, 1L, 1L,
    1L), .Label = c("Negative", "Positive"), class = "factor")), row.names = c(NA,
-6L), class = c("tbl_df", "tbl", "data.frame"))


问:
Dealing with the Tkinter Text Widgets Indexing System.
How do I split a floating point number.

For example :

1.24345 would return 24345

1455.24 would return 24

1455.0 would return 0

Edit :

My solution inspired by Nick ODell. This is oriented specifically toward the Tkinter Text widget.

```<code>index = '140.2020'

split = index.split('.')

nindex = [int(i) for i in split]

print nindex
</code>```

答:
```<code>def after_period(number):
    return int(str(number).partition(".")[2])
</code>```

Body:
How do I split a floating point number.

For example :

1.24345 would return 24345

1455.24 would return 24

1455.0 would return 0

Edit :

My solution inspired by Nick ODell. This is oriented specifically toward the Tkinter Text widget.

index = '140.2020'

split = index.split('.')

nindex = [int(i) for i in split]

print nindex


问:
Convert date to PostgreSQL syntax
The following logic in SQL Server needs to be converted appropriately to PostgreSQL syntax. Please helpm me convert this over to the correct syntax so I can use it in PostgreSQL database:</p>

```<code>  convert(DATE, dateadd(m, -17, convert(DATE, getdate())))
</code>```

答:
Click: demo:db<>fiddle

This subtracts 17 months from your date.

```<code>SELECT
    current_date + interval '-17 months'
</code>```

Title: Convert date to PostgreSQL syntax

Body:
The following logic in SQL Server needs to be converted appropriately to PostgreSQL syntax. Please helpm me convert this over to the correct syntax so I can use it in PostgreSQL database:

  convert(DATE, dateadd(m, -17, convert(DATE, getdate())))

Body:
Click: demo:db<>fiddle

This subtracts 17 months from your date.

SELECT
    current_date + interval '-17 months'


问:
Have multiple intervals in a staggered animation
Hi I was wondering if it was possible to have a tween that can have multiple intervals in a staggered in serval e.g.

opacity goes from 1.0 to 0.0 (% time: 0.45 to 0.5)

then

opacity goes from 0.0 to 1.0 (% time: 0.5 to 0.55)

using a similar tween

```<code>opacity1 = Tween<double>(
      begin: 1.0,
      end: 0.0,
    ).animate(
      CurvedAnimation(
        parent: controller,
        curve: Interval(
          0.45, 0.5,
          curve: Curves.ease,
        ),
      ),
    ).NextTween<double>( ///Pseudo code
      begin: 0.0,
      end: 1.0,
    ).animate(
      CurvedAnimation(
        parent: controller,
        curve: Interval(
          0.5, 0.55,
          curve: Curves.ease,
        ),
      ),
    )
</code>```

答:
Ok in the end I use a TweenSquence the flutter docs uses the example below which is very helpful link to the docs is Flutter docs.

This example defines an animation that uses an easing curve to interpolate between 5.0 and 10.0 during the first 40% of the animation, remains at 10.0 for the next 20%, and then returns to 5.0 for the final 40%.

```<code>final Animation<double> animation = TweenSequence(

 <TweenSequenceItem<double>>[
    TweenSequenceItem<double>(
      tween: Tween<double>(begin: 5.0, end: 10.0)
        .chain(CurveTween(curve: Curves.ease)),
      weight: 40.0,
    ),
    TweenSequenceItem<double>(
      tween: ConstantTween<double>(10.0),
      weight: 20.0,
    ),
    TweenSequenceItem<double>(
      tween: Tween<double>(begin: 10.0, end: 5.0)
        .chain(CurveTween(curve: Curves.ease)),
      weight: 40.0,
    ),
  ],
).animate(myAnimationController);
</code>```

Body:
Hi I was wondering if it was possible to have a tween that can have multiple intervals in a staggered in serval e.g.

opacity goes from 1.0 to 0.0 (% time: 0.45 to 0.5)

then

opacity goes from 0.0 to 1.0 (% time: 0.5 to 0.55)

using a similar tween

opacity1 = Tween<double>(
      begin: 1.0,
      end: 0.0,
    ).animate(
      CurvedAnimation(
        parent: controller,
        curve: Interval(
          0.45, 0.5,
          curve: Curves.ease,
        ),
      ),
    ).NextTween<double>( ///Pseudo code
      begin: 0.0,
      end: 1.0,
    ).animate(
      CurvedAnimation(
        parent: controller,
        curve: Interval(
          0.5, 0.55,
          curve: Curves.ease,
        ),
      ),
    )

Body:
Ok in the end I use a TweenSquence the flutter docs uses the example below which is very helpful link to the docs is Flutter docs.

This example defines an animation that uses an easing curve to interpolate between 5.0 and 10.0 during the first 40% of the animation, remains at 10.0 for the next 20%, and then returns to 5.0 for the final 40%.

final Animation<double> animation = TweenSequence(

 <TweenSequenceItem<double>>[
    TweenSequenceItem<double>(
      tween: Tween<double>(begin: 5.0, end: 10.0)
        .chain(CurveTween(curve: Curves.ease)),
      weight: 40.0,
    ),
    TweenSequenceItem<double>(
      tween: ConstantTween<double>(10.0),
      weight: 20.0,
    ),
    TweenSequenceItem<double>(
      tween: Tween<double>(begin: 10.0, end: 5.0)
        .chain(CurveTween(curve: Curves.ease)),
      weight: 40.0,
    ),
  ],
).animate(myAnimationController);


问:
Generate One year dates using Oracle SQL
I have a table with three ID and Dates
i want generate dates of one year from current date and before and after six months
Then i want to plot three dates on this one year generated calandar
I tried</p>

```<code>SELECT (TO_DATE(SYSDATE)-180) + ROWNUM DT
  FROM (SELECT 1
          FROM DUAL
       CONNECT BY LEVEL <=180)
</code>```

答:
Literally following what you said: there's a table with 3 IDs and their dates, and you want to plot the calendar.

Using a hierarchical query, dates are generated as

```<code>SQL> with
  2  threeid (id, datum) as
  3    (select 1, date '2020-05-29' from dual union all
  4     select 2, date '2020-01-01' from dual union all
  5     select 3, date '2020-02-29' from dual
  6    ),
  7  cal as
  8    (select add_months(datum, -6) + column_value - 1 datum
  9      from threeid cross join
 10       table(cast(multiset(select level from dual
 11                           connect by level <= add_months(datum, 6) - add_months(datum, -6)
 12                          ) as sys.odcinumberlist))
 13      where id = 1         --> for the 1st ID; change that for other calendars
 14    )
 15  select * from cal order by datum;

DATUM
----------
29.11.2019
30.11.2019
01.12.2019
02.12.2019
03.12.2019
<snip>
25.11.2020
26.11.2020
27.11.2020
28.11.2020

366 rows selected.
</code>```

If you want to plot that, instead of line #15 you'd use this ...

```<code> <snip>
 15  select lpad(month, 20, ' ') month,
 16    "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"
 17  from (select to_char(dt, 'fmMonthfm YYYY') month,
 18          week,
 19          max(decode(to_char(dt, 'd'), '1', lpad(to_char(dt, 'fmdd'), 2))) "Mon",
 20          max(decode(to_char(dt, 'd'), '2', lpad(to_char(dt, 'fmdd'), 2))) "Tue",
 21          max(decode(to_char(dt, 'd'), '3', lpad(to_char(dt, 'fmdd'), 2))) "Wed",
 22          max(decode(to_char(dt, 'd'), '4', lpad(to_char(dt, 'fmdd'), 2))) "Thu",
 23          max(decode(to_char(dt, 'd'), '5', lpad(to_char(dt, 'fmdd'), 2))) "Fri",
 24          max(decode(to_char(dt, 'd'), '6', lpad(to_char(dt, 'fmdd'), 2))) "Sat",
 25          max(decode(to_char(dt, 'd'), '7', lpad(to_char(dt, 'fmdd'), 2))) "Sun"
 26        from ( select dt,
 27                      case when     dt >= to_date(to_char(dt, 'dd/') ||'12/'||
 28                                          to_char(sysdate,'yyyy'), 'dd/mm/yyyy')
 29                                and wk = '01'
 30                           then '53'
 31                           else wk
 32                      end week
 33               from (select datum dt, to_char(datum, 'iw') wk
 34                     from cal
 35                    )
 36             )
 37        group by to_char(dt, 'fmMonthfm YYYY'), week
 38       )
 39  order by to_date( month, 'Month YYYY' ), to_number(week);
</code>```

... and get that:

```<code>MONTH                Mon      Tue      Wed      Thu      Fri      Sat      Sun
-------------------- -------- -------- -------- -------- -------- -------- --------
       November 2019                                     29       30
       December 2019 30       31
       December 2019                                                        1
       December 2019  2        3        4        5        6        7        8
       December 2019  9       10       11       12       13       14       15
       December 2019 16       17       18       19       20       21       22
       December 2019 23       24       25       26       27       28       29
        January 2020                    1        2        3        4        5
        January 2020  6        7        8        9       10       11       12
        January 2020 13       14       15       16       17       18       19
        January 2020 20       21       22       23       24       25       26
        January 2020 27       28       29       30       31
       February 2020                                               1        2
       February 2020  3        4        5        6        7        8        9
       February 2020 10       11       12       13       14       15       16
       February 2020 17       18       19       20       21       22       23
       February 2020 24       25       26       27       28       29
          March 2020                                                        1
          March 2020  2        3        4        5        6        7        8
          March 2020  9       10       11       12       13       14       15
          March 2020 16       17       18       19       20       21       22
          March 2020 23       24       25       26       27       28       29
          March 2020 30       31
          April 2020                    1        2        3        4        5
          April 2020  6        7        8        9       10       11       12
          April 2020 13       14       15       16       17       18       19
          April 2020 20       21       22       23       24       25       26
          April 2020 27       28       29       30
            May 2020                                      1        2        3
            May 2020  4        5        6        7        8        9       10
            May 2020 11       12       13       14       15       16       17
            May 2020 18       19       20       21       22       23       24
            May 2020 25       26       27       28       29       30       31
           June 2020  1        2        3        4        5        6        7
           June 2020  8        9       10       11       12       13       14
           June 2020 15       16       17       18       19       20       21
           June 2020 22       23       24       25       26       27       28
           June 2020 29       30
           July 2020                    1        2        3        4        5
           July 2020  6        7        8        9       10       11       12
           July 2020 13       14       15       16       17       18       19
           July 2020 20       21       22       23       24       25       26
           July 2020 27       28       29       30       31
         August 2020                                               1        2
         August 2020  3        4        5        6        7        8        9
         August 2020 10       11       12       13       14       15       16
         August 2020 17       18       19       20       21       22       23
         August 2020 24       25       26       27       28       29       30
         August 2020 31
      September 2020           1        2        3        4        5        6
      September 2020  7        8        9       10       11       12       13
      September 2020 14       15       16       17       18       19       20
      September 2020 21       22       23       24       25       26       27
      September 2020 28       29       30
        October 2020                             1        2        3        4
        October 2020  5        6        7        8        9       10       11
        October 2020 12       13       14       15       16       17       18
        October 2020 19       20       21       22       23       24       25
        October 2020 26       27       28       29       30       31
       November 2020                                                        1
       November 2020  2        3        4        5        6        7        8
       November 2020  9       10       11       12       13       14       15
       November 2020 16       17       18       19       20       21       22
       November 2020 23       24       25       26       27       28

64 rows selected.

SQL>
</code>```

(That nice calendar query is originally (at least, I think so) posted on OraFAQ site; I adjusted it, hoping that it correctly displays dates)

Body:
I have a table with three ID and Dates
i want generate dates of one year from current date and before and after six months
Then i want to plot three dates on this one year generated calandar
I tried

SELECT (TO_DATE(SYSDATE)-180) + ROWNUM DT
  FROM (SELECT 1
          FROM DUAL
       CONNECT BY LEVEL <=180)

Body:
Literally following what you said: there's a table with 3 IDs and their dates, and you want to plot the calendar.

Using a hierarchical query, dates are generated as

SQL> with
  2  threeid (id, datum) as
  3    (select 1, date '2020-05-29' from dual union all
  4     select 2, date '2020-01-01' from dual union all
  5     select 3, date '2020-02-29' from dual
  6    ),
  7  cal as
  8    (select add_months(datum, -6) + column_value - 1 datum
  9      from threeid cross join
 10       table(cast(multiset(select level from dual
 11                           connect by level <= add_months(datum, 6) - add_months(datum, -6)
 12                          ) as sys.odcinumberlist))
 13      where id = 1         --> for the 1st ID; change that for other calendars
 14    )
 15  select * from cal order by datum;

DATUM
----------
29.11.2019
30.11.2019
01.12.2019
02.12.2019
03.12.2019
<snip>
25.11.2020
26.11.2020
27.11.2020
28.11.2020

366 rows selected.

If you want to plot that, instead of line #15 you'd use this ...

 <snip>
 15  select lpad(month, 20, ' ') month,
 16    "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"
 17  from (select to_char(dt, 'fmMonthfm YYYY') month,
 18          week,
 19          max(decode(to_char(dt, 'd'), '1', lpad(to_char(dt, 'fmdd'), 2))) "Mon",
 20          max(decode(to_char(dt, 'd'), '2', lpad(to_char(dt, 'fmdd'), 2))) "Tue",
 21          max(decode(to_char(dt, 'd'), '3', lpad(to_char(dt, 'fmdd'), 2))) "Wed",
 22          max(decode(to_char(dt, 'd'), '4', lpad(to_char(dt, 'fmdd'), 2))) "Thu",
 23          max(decode(to_char(dt, 'd'), '5', lpad(to_char(dt, 'fmdd'), 2))) "Fri",
 24          max(decode(to_char(dt, 'd'), '6', lpad(to_char(dt, 'fmdd'), 2))) "Sat",
 25          max(decode(to_char(dt, 'd'), '7', lpad(to_char(dt, 'fmdd'), 2))) "Sun"
 26        from ( select dt,
 27                      case when     dt >= to_date(to_char(dt, 'dd/') ||'12/'||
 28                                          to_char(sysdate,'yyyy'), 'dd/mm/yyyy')
 29                                and wk = '01'
 30                           then '53'
 31                           else wk
 32                      end week
 33               from (select datum dt, to_char(datum, 'iw') wk
 34                     from cal
 35                    )
 36             )
 37        group by to_char(dt, 'fmMonthfm YYYY'), week
 38       )
 39  order by to_date( month, 'Month YYYY' ), to_number(week);

... and get that:

MONTH                Mon      Tue      Wed      Thu      Fri      Sat      Sun
-------------------- -------- -------- -------- -------- -------- -------- --------
       November 2019                                     29       30
       December 2019 30       31
       December 2019                                                        1
       December 2019  2        3        4        5        6        7        8
       December 2019  9       10       11       12       13       14       15
       December 2019 16       17       18       19       20       21       22
       December 2019 23       24       25       26       27       28       29
        January 2020                    1        2        3        4        5
        January 2020  6        7        8        9       10       11       12
        January 2020 13       14       15       16       17       18       19
        January 2020 20       21       22       23       24       25       26
        January 2020 27       28       29       30       31
       February 2020                                               1        2
       February 2020  3        4        5        6        7        8        9
       February 2020 10       11       12       13       14       15       16
       February 2020 17       18       19       20       21       22       23
       February 2020 24       25       26       27       28       29
          March 2020                                                        1
          March 2020  2        3        4        5        6        7        8
          March 2020  9       10       11       12       13       14       15
          March 2020 16       17       18       19       20       21       22
          March 2020 23       24       25       26       27       28       29
          March 2020 30       31
          April 2020                    1        2        3        4        5
          April 2020  6        7        8        9       10       11       12
          April 2020 13       14       15       16       17       18       19
          April 2020 20       21       22       23       24       25       26
          April 2020 27       28       29       30
            May 2020                                      1        2        3
            May 2020  4        5        6        7        8        9       10
            May 2020 11       12       13       14       15       16       17
            May 2020 18       19       20       21       22       23       24
            May 2020 25       26       27       28       29       30       31
           June 2020  1        2        3        4        5        6        7
           June 2020  8        9       10       11       12       13       14
           June 2020 15       16       17       18       19       20       21
           June 2020 22       23       24       25       26       27       28
           June 2020 29       30
           July 2020                    1        2        3        4        5
           July 2020  6        7        8        9       10       11       12
           July 2020 13       14       15       16       17       18       19
           July 2020 20       21       22       23       24       25       26
           July 2020 27       28       29       30       31
         August 2020                                               1        2
         August 2020  3        4        5        6        7        8        9
         August 2020 10       11       12       13       14       15       16
         August 2020 17       18       19       20       21       22       23
         August 2020 24       25       26       27       28       29       30
         August 2020 31
      September 2020           1        2        3        4        5        6
      September 2020  7        8        9       10       11       12       13
      September 2020 14       15       16       17       18       19       20
      September 2020 21       22       23       24       25       26       27
      September 2020 28       29       30
        October 2020                             1        2        3        4
        October 2020  5        6        7        8        9       10       11
        October 2020 12       13       14       15       16       17       18
        October 2020 19       20       21       22       23       24       25
        October 2020 26       27       28       29       30       31
       November 2020                                                        1
       November 2020  2        3        4        5        6        7        8
       November 2020  9       10       11       12       13       14       15
       November 2020 16       17       18       19       20       21       22
       November 2020 23       24       25       26       27       28

64 rows selected.

SQL>

(That nice calendar query is originally (at least, I think so) posted on OraFAQ site; I adjusted it, hoping that it correctly displays dates)